VulResource / draper /split /draper_1024-*_validate.json
xuefen's picture
Upload folder using huggingface_hub
0faab25 verified
[
{
"index": 27544,
"code": "find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId,\n\t\t\t\t\t CoercionContext ccontext,\n\t\t\t\t\t Oid *funcid)\n{\n\tCoercionPathType result = COERCION_PATH_NONE;\n\tHeapTuple\ttuple;\n\n\t*funcid = InvalidOid;\n\n\t/* Perhaps the types are domains; if so, look at their base types */\n\tif (OidIsValid(sourceTypeId))\n\t\tsourceTypeId = getBaseType(sourceTypeId);\n\tif (OidIsValid(targetTypeId))\n\t\ttargetTypeId = getBaseType(targetTypeId);\n\n\t/* Domains are always coercible to and from their base type */\n\tif (sourceTypeId == targetTypeId)\n\t\treturn COERCION_PATH_RELABELTYPE;\n\n\t/* Look in pg_cast */\n\ttuple = SearchSysCache(CASTSOURCETARGET,\n\t\t\t\t\t\t ObjectIdGetDatum(sourceTypeId),\n\t\t\t\t\t\t ObjectIdGetDatum(targetTypeId),\n\t\t\t\t\t\t 0, 0);\n\n\tif (HeapTupleIsValid(tuple))\n\t{\n\t\tForm_pg_cast castForm = (Form_pg_cast) GETSTRUCT(tuple);\n\t\tCoercionContext castcontext;\n\n\t\t/* convert char value for castcontext to CoercionContext enum */\n\t\tswitch (castForm->castcontext)\n\t\t{\n\t\t\tcase COERCION_CODE_IMPLICIT:\n\t\t\t\tcastcontext = COERCION_IMPLICIT;\n\t\t\t\tbreak;\n\t\t\tcase COERCION_CODE_ASSIGNMENT:\n\t\t\t\tcastcontext = COERCION_ASSIGNMENT;\n\t\t\t\tbreak;\n\t\t\tcase COERCION_CODE_EXPLICIT:\n\t\t\t\tcastcontext = COERCION_EXPLICIT;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\telog(ERROR, \"unrecognized castcontext: %d\",\n\t\t\t\t\t (int) castForm->castcontext);\n\t\t\t\tcastcontext = 0;\t/* keep compiler quiet */\n\t\t\t\tbreak;\n\t\t}\n\n\t\t/* Rely on ordering of enum for correct behavior here */\n\t\tif (ccontext >= castcontext)\n\t\t{\n\t\t\t*funcid = castForm->castfunc;\n\t\t\tif (OidIsValid(*funcid))\n\t\t\t\tresult = COERCION_PATH_FUNC;\n\t\t\telse\n\t\t\t\tresult = COERCION_PATH_RELABELTYPE;\n\t\t}\n\n\t\tReleaseSysCache(tuple);\n\t}\n\telse\n\t{\n\t\t/*\n\t\t * If there's no pg_cast entry, perhaps we are dealing with a pair of\n\t\t * array types. If so, and if the element types have a suitable cast,\n\t\t * report that we can coerce with an ArrayCoerceExpr.\n\t\t *\n\t\t * Hack: disallow coercions to oidvector and int2vector, which\n\t\t * otherwise tend to capture coercions that should go to \"real\" array\n\t\t * types. We want those types to be considered \"real\" arrays for many\n\t\t * purposes, but not this one.\t(Also, ArrayCoerceExpr isn't\n\t\t * guaranteed to produce an output that meets the restrictions of\n\t\t * these datatypes, such as being 1-dimensional.)\n\t\t */\n\t\tif (targetTypeId != OIDVECTOROID && targetTypeId != INT2VECTOROID)\n\t\t{\n\t\t\tOid\t\t\ttargetElem;\n\t\t\tOid\t\t\tsourceElem;\n\n\t\t\tif ((targetElem = get_element_type(targetTypeId)) != InvalidOid &&\n\t\t\t\t(sourceElem = get_element_type(sourceTypeId)) != InvalidOid)\n\t\t\t{\n\t\t\t\tCoercionPathType elempathtype;\n\t\t\t\tOid\t\t\telemfuncid;\n\n\t\t\t\telempathtype = find_coercion_pathway(targetElem,\n\t\t\t\t\t\t\t\t\t\t\t\t\t sourceElem,\n\t\t\t\t\t\t\t\t\t\t\t\t\t ccontext,\n\t\t\t\t\t\t\t\t\t\t\t\t\t &elemfuncid);\n\t\t\t\tif (elempathtype != COERCION_PATH_NONE &&\n\t\t\t\t\telempathtype != COERCION_PATH_ARRAYCOERCE)\n\t\t\t\t{\n\t\t\t\t\t*funcid = elemfuncid;\n\t\t\t\t\tif (elempathtype == COERCION_PATH_COERCEVIAIO)\n\t\t\t\t\t\tresult = COERCION_PATH_COERCEVIAIO;\n\t\t\t\t\telse\n\t\t\t\t\t\tresult = COERCION_PATH_ARRAYCOERCE;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t/*\n\t\t * If we still haven't found a possibility, consider automatic casting\n\t\t * using I/O functions. We allow assignment casts to textual types\n\t\t * and explicit casts from textual types to be handled this way. (The\n\t\t * CoerceViaIO mechanism is a lot more general than that, but this is\n\t\t * all we want to allow in the absence of a pg_cast entry.) It would\n\t\t * probably be better to insist on explicit casts in both directions,\n\t\t * but this is a compromise to preserve something of the pre-8.3\n\t\t * behavior that many types had implicit (yipes!) casts to text.\n\t\t */\n\t\tif (result == COERCION_PATH_NONE)\n\t\t{\n\t\t\tif (ccontext >= COERCION_ASSIGNMENT &&\n\t\t\t\t(targetTypeId == TEXTOID ||\n\t\t\t\t targetTypeId == VARCHAROID ||\n\t\t\t\t targetTypeId == BPCHAROID))\n\t\t\t\tresult = COERCION_PATH_COERCEVIAIO;\n\t\t\telse if (ccontext >= COERCION_EXPLICIT &&\n\t\t\t\t\t (sourceTypeId == TEXTOID ||\n\t\t\t\t\t sourceTypeId == VARCHAROID ||\n\t\t\t\t\t sourceTypeId == BPCHAROID))\n\t\t\t\tresult = COERCION_PATH_COERCEVIAIO;\n\t\t}\n\t}\n\n\treturn result;\n}",
"label": 0,
"cwe": null,
"length": 1104
},
{
"index": 380540,
"code": "xfs_ialloc_ag_select(\n\txfs_trans_t\t*tp,\t\t/* transaction pointer */\n\txfs_ino_t\tparent,\t\t/* parent directory inode number */\n\tumode_t\t\tmode,\t\t/* bits set to indicate file type */\n\tint\t\tokalloc)\t/* ok to allocate more space */\n{\n\txfs_agnumber_t\tagcount;\t/* number of ag's in the filesystem */\n\txfs_agnumber_t\tagno;\t\t/* current ag number */\n\tint\t\tflags;\t\t/* alloc buffer locking flags */\n\txfs_extlen_t\tineed;\t\t/* blocks needed for inode allocation */\n\txfs_extlen_t\tlongest = 0;\t/* longest extent available */\n\txfs_mount_t\t*mp;\t\t/* mount point structure */\n\tint\t\tneedspace;\t/* file mode implies space allocated */\n\txfs_perag_t\t*pag;\t\t/* per allocation group data */\n\txfs_agnumber_t\tpagno;\t\t/* parent (starting) ag number */\n\tint\t\terror;\n\n\t/*\n\t * Files of these types need at least one block if length > 0\n\t * (and they won't fit in the inode, but that's hard to figure out).\n\t */\n\tneedspace = S_ISDIR(mode) || S_ISREG(mode) || S_ISLNK(mode);\n\tmp = tp->t_mountp;\n\tagcount = mp->m_maxagi;\n\tif (S_ISDIR(mode))\n\t\tpagno = xfs_ialloc_next_ag(mp);\n\telse {\n\t\tpagno = XFS_INO_TO_AGNO(mp, parent);\n\t\tif (pagno >= agcount)\n\t\t\tpagno = 0;\n\t}\n\n\tASSERT(pagno < agcount);\n\n\t/*\n\t * Loop through allocation groups, looking for one with a little\n\t * free space in it. Note we don't look for free inodes, exactly.\n\t * Instead, we include whether there is a need to allocate inodes\n\t * to mean that blocks must be allocated for them,\n\t * if none are currently free.\n\t */\n\tagno = pagno;\n\tflags = XFS_ALLOC_FLAG_TRYLOCK;\n\tfor (;;) {\n\t\tpag = xfs_perag_get(mp, agno);\n\t\tif (!pag->pagi_inodeok) {\n\t\t\txfs_ialloc_next_ag(mp);\n\t\t\tgoto nextag;\n\t\t}\n\n\t\tif (!pag->pagi_init) {\n\t\t\terror = xfs_ialloc_pagi_init(mp, tp, agno);\n\t\t\tif (error)\n\t\t\t\tgoto nextag;\n\t\t}\n\n\t\tif (pag->pagi_freecount) {\n\t\t\txfs_perag_put(pag);\n\t\t\treturn agno;\n\t\t}\n\n\t\tif (!okalloc)\n\t\t\tgoto nextag;\n\n\t\tif (!pag->pagf_init) {\n\t\t\terror = xfs_alloc_pagf_init(mp, tp, agno, flags);\n\t\t\tif (error)\n\t\t\t\tgoto nextag;\n\t\t}\n\n\t\t/*\n\t\t * Check that there is enough free space for the file plus a\n\t\t * chunk of inodes if we need to allocate some. If this is the\n\t\t * first pass across the AGs, take into account the potential\n\t\t * space needed for alignment of inode chunks when checking the\n\t\t * longest contiguous free space in the AG - this prevents us\n\t\t * from getting ENOSPC because we have free space larger than\n\t\t * m_ialloc_blks but alignment constraints prevent us from using\n\t\t * it.\n\t\t *\n\t\t * If we can't find an AG with space for full alignment slack to\n\t\t * be taken into account, we must be near ENOSPC in all AGs.\n\t\t * Hence we don't include alignment for the second pass and so\n\t\t * if we fail allocation due to alignment issues then it is most\n\t\t * likely a real ENOSPC condition.\n\t\t */\n\t\tineed = mp->m_ialloc_min_blks;\n\t\tif (flags && ineed > 1)\n\t\t\tineed += xfs_ialloc_cluster_alignment(mp);\n\t\tlongest = pag->pagf_longest;\n\t\tif (!longest)\n\t\t\tlongest = pag->pagf_flcount > 0;\n\n\t\tif (pag->pagf_freeblks >= needspace + ineed &&\n\t\t longest >= ineed) {\n\t\t\txfs_perag_put(pag);\n\t\t\treturn agno;\n\t\t}\nnextag:\n\t\txfs_perag_put(pag);\n\t\t/*\n\t\t * No point in iterating over the rest, if we're shutting\n\t\t * down.\n\t\t */\n\t\tif (XFS_FORCED_SHUTDOWN(mp))\n\t\t\treturn NULLAGNUMBER;\n\t\tagno++;\n\t\tif (agno >= agcount)\n\t\t\tagno = 0;\n\t\tif (agno == pagno) {\n\t\t\tif (flags == 0)\n\t\t\t\treturn NULLAGNUMBER;\n\t\t\tflags = 0;\n\t\t}\n\t}\n}",
"label": 0,
"cwe": null,
"length": 1044
},
{
"index": 223274,
"code": "IFDHPowerICC(DWORD Lun, DWORD Action,\n\tPUCHAR Atr, PDWORD AtrLength)\n{\n\t/*\n\t * This function controls the power and reset signals of the smartcard\n\t * reader at the particular reader/slot specified by Lun.\n\t *\n\t * Action - Action to be taken on the card.\n\t *\n\t * IFD_POWER_UP - Power and reset the card if not done so (store the\n\t * ATR and return it and it's length).\n\t *\n\t * IFD_POWER_DOWN - Power down the card if not done already\n\t * (Atr/AtrLength should be zero'd)\n\t *\n\t * IFD_RESET - Perform a quick reset on the card. If the card is not\n\t * powered power up the card. (Store and return the Atr/Length)\n\t *\n\t * Atr - Answer to Reset of the card. The driver is responsible for\n\t * caching this value in case IFDHGetCapabilities is called requesting\n\t * the ATR and it's length. This should not exceed MAX_ATR_SIZE.\n\t *\n\t * AtrLength - Length of the Atr. This should not exceed\n\t * MAX_ATR_SIZE.\n\t *\n\t * Notes:\n\t *\n\t * Memory cards without an ATR should return IFD_SUCCESS on reset but\n\t * the Atr should be zero'd and the length should be zero\n\t *\n\t * Reset errors should return zero for the AtrLength and return\n\t * IFD_ERROR_POWER_ACTION.\n\t *\n\t * returns:\n\t *\n\t * IFD_SUCCESS IFD_ERROR_POWER_ACTION IFD_COMMUNICATION_ERROR\n\t * IFD_NOT_SUPPORTED\n\t */\n\n\tunsigned int nlength;\n\tRESPONSECODE return_value = IFD_SUCCESS;\n\tunsigned char pcbuffer[10+MAX_ATR_SIZE];\n\tint reader_index;\n\tconst char *actions[] = { \"PowerUp\", \"PowerDown\", \"Reset\" };\n\tunsigned int oldReadTimeout;\n\t_ccid_descriptor *ccid_descriptor;\n\n\t/* By default, assume it won't work :) */\n\t*AtrLength = 0;\n\n\tif (-1 == (reader_index = LunToReaderIndex(Lun)))\n\t\treturn IFD_COMMUNICATION_ERROR;\n\n\tDEBUG_INFO4(\"action: %s, %s (lun: \" DWORD_X \")\",\n\t\tactions[Action-IFD_POWER_UP], CcidSlots[reader_index].readerName, Lun);\n\n\tswitch (Action)\n\t{\n\t\tcase IFD_POWER_DOWN:\n\t\t\t/* Clear ATR buffer */\n\t\t\tCcidSlots[reader_index].nATRLength = 0;\n\t\t\t*CcidSlots[reader_index].pcATRBuffer = '\\0';\n\n\t\t\t/* Memorise the request */\n\t\t\tCcidSlots[reader_index].bPowerFlags |= MASK_POWERFLAGS_PDWN;\n\n\t\t\t/* send the command */\n\t\t\tif (IFD_SUCCESS != CmdPowerOff(reader_index))\n\t\t\t{\n\t\t\t\tDEBUG_CRITICAL(\"PowerDown failed\");\n\t\t\t\treturn_value = IFD_ERROR_POWER_ACTION;\n\t\t\t\tgoto end;\n\t\t\t}\n\n\t\t\t/* clear T=1 context */\n\t\t\tt1_release(&(get_ccid_slot(reader_index) -> t1));\n\t\t\tbreak;\n\n\t\tcase IFD_POWER_UP:\n\t\tcase IFD_RESET:\n\t\t\t/* save the current read timeout computed from card capabilities */\n\t\t\tccid_descriptor = get_ccid_descriptor(reader_index);\n\t\t\toldReadTimeout = ccid_descriptor->readTimeout;\n\n\t\t\t/* The German eID card is bogus and need to be powered off\n\t\t\t * before a power on */\n\t\t\tif (KOBIL_IDTOKEN == ccid_descriptor -> readerID)\n\t\t\t{\n\t\t\t\t/* send the command */\n\t\t\t\tif (IFD_SUCCESS != CmdPowerOff(reader_index))\n\t\t\t\t{\n\t\t\t\t\tDEBUG_CRITICAL(\"PowerDown failed\");\n\t\t\t\t\treturn_value = IFD_ERROR_POWER_ACTION;\n\t\t\t\t\tgoto end;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* use a very long timeout since the card can use up to\n\t\t\t * (9600+12)*33 ETU in total\n\t\t\t * 12 ETU per byte\n\t\t\t * 9600 ETU max between each byte\n\t\t\t * 33 bytes max for ATR\n\t\t\t * 1 ETU = 372 cycles during ATR\n\t\t\t * with a 4 MHz clock => 29 seconds\n\t\t\t */\n\t\t\tccid_descriptor->readTimeout = 60*1000;\n\n\t\t\tnlength = sizeof(pcbuffer);\n\t\t\treturn_value = CmdPowerOn(reader_index, &nlength, pcbuffer,\n\t\t\t\tPowerOnVoltage);\n\n\t\t\t/* set back the old timeout */\n\t\t\tccid_descriptor->readTimeout = oldReadTimeout;\n\n\t\t\tif (return_value != IFD_SUCCESS)\n\t\t\t{\n\t\t\t\t/* used by GemCore SIM PRO: no card is present */\n\t\t\t\tif (GEMCORESIMPRO == ccid_descriptor -> readerID)\n\t\t\t\t\tget_ccid_descriptor(reader_index)->dwSlotStatus\n\t\t\t\t\t\t= IFD_ICC_NOT_PRESENT;\n\n\t\t\t\tDEBUG_CRITICAL(\"PowerUp failed\");\n\t\t\t\treturn_value = IFD_ERROR_POWER_ACTION;\n\t\t\t\tgoto end;\n\t\t\t}\n\n\t\t\t/* Power up successful, set state variable to memorise it */\n\t\t\tCcidSlots[reader_index].bPowerFlags |= MASK_POWERFLAGS_PUP;\n\t\t\tCcidSlots[reader_index].bPowerFlags &= ~MASK_POWERFLAGS_PDWN;\n\n\t\t\t/* Reset is returned, even if TCK is wrong */\n\t\t\tCcidSlots[reader_index].nATRLength = *AtrLength =\n\t\t\t\t(nlength < MAX_ATR_SIZE) ? nlength : MAX_ATR_SIZE;\n\t\t\tmemcpy(Atr, pcbuffer, *AtrLength);\n\t\t\tmemcpy(CcidSlots[reader_index].pcATRBuffer, pcbuffer, *AtrLength);\n\n\t\t\t/* initialise T=1 context */\n\t\t\t(void)t1_init(&(get_ccid_slot(reader_index) -> t1), reader_index);\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tDEBUG_CRITICAL(\"Action not supported\");\n\t\t\treturn_value = IFD_NOT_SUPPORTED;\n\t}\nend:\n\n\treturn return_value;\n}",
"label": 0,
"cwe": null,
"length": 1257
},
{
"index": 187175,
"code": "pr_plist(pp_plist,p_before,p_after)\n/* This function parses an optional parameter list. If the current token is */\n/* not TK_OPAR, then it is assumed that no list is present and no tokens are */\n/* consumed and empty lists are returned. */\n/* The three lists returned are: */\n/* A list of parameters each being a pointer to a list of elements. */\n/* A list of whitespace blocks being the space before each parameter. */\n/* A list of whitespace blocks being the space after each parameter. */\n/* The last parameter glo_p_ma should be supplied by the caller and should */\n/* contain a pointer to the macro currently being parsed. */\np_elll_t *pp_plist;\np_scll_t *p_before;\np_scll_t *p_after;\n{\n ps_t open_ps; /* Position of start of parameter list. */\n\n /* Initialize all the result lists to empty. */\n *pp_plist = ls_cre(sizeof(p_ells_t));\n *p_before = ls_cre(sizeof(p_scls_t));\n *p_after = ls_cre(sizeof(p_scls_t));\n\n /* The parameter list is optional. If it isn't there we assume a null one. */\n if (p_tk->tk_kind!=TK_OPAR)\n return;\n\n /* We need to remember the position of the open parameter list token so that */\n /* if the list isn't closed, we can attach an error to this opening token. */\n ASSIGN(open_ps,p_tk->tk_ps);\n next_tk(TRUE);\n\n /* Now parse the parameter list, one parameter during each iteration. */\n while (TRUE)\n {\n ps_t exp_ps;\n p_ells_t p_ex;\n p_scls_t p_white;\n\n /* Things get a little tricky here because the double quotes around */\n /* parameters are optional (per parameter). Thus the following calls are */\n /* all legal (and functionally identical): */\n /* @<Sloth@>@( @\"walrus@\" @, @\"aardvark@\" @) */\n /* @<Sloth@>@(walrus@, @\"aardvark@\" @) */\n /* @<Sloth@>@(walrus@,aardvark@) */\n\n /* Note the position of the start of this parameter slot. */\n ASSIGN(exp_ps,p_tk->tk_ps);\n\n /* Because we face either crud text or an expression, we parse an exp. */\n pr_exp(&p_ex);\n\n /* Now take a look at the next token. If it is @\" we know that we have */\n /* been parsing whitespace crud. If it is @, or @) we know that we have */\n /* been parsing the parameter expression itself. */\n if (p_tk->tk_kind==TK_COMA || p_tk->tk_kind==TK_CPAR)\n {\n p_scls_t p_scls = ls_cre(sizeof(sc_t));\n ls_add(*p_before,PV &p_scls); /* Add empty whitespace to crud list. */\n ls_add(*pp_plist,PV &p_ex); /* Add expression to parameter list. */\n ls_add(*p_after ,PV &p_scls); /* Add empty whitespace to crud list. */\n }\n else\n if (p_tk->tk_kind==TK_QUOT)\n {\n /* After parsing the expression we hit a @\". This means that the */\n /* expression just parsed SHOULD turn out to contain a single */\n /* element consisting of a white space text list. */\n chk_whex(&exp_ps,p_ex,&p_white);\n ls_add(*p_before,PV &p_white);\n\n /* Get past the quote. */\n next_tk(TRUE);\n\n /* Parse the expression and add it to the parameter list. */\n pr_exp(&p_ex); ls_add(*pp_plist,PV &p_ex);\n\n /* Parse the quote to move onto the whitespace. */\n pr_token(TK_QUOT);\n\n /* Parse the whitespace after the parameter. */\n {p_scls_t p_white; pr_white(&p_white); ls_add(*p_after,PV &p_white);}\n }\n else\n {\n lr_err(TKPS,\"Expecting @\\\" or @, or @).\");\n\n /* Experience has shown that with input files containing very */\n /* long macros, it's very difficult, given the above error */\n /* message, to determine which macro call has the unclosed */\n /* parameter list. So, the following error identifies the macro. */\n lr_err(&open_ps,\"This parameter list contains a syntax error.\");\n\n recover();\n }\n\n /* The parameter list can now end (TK_CPAR) or continue (TK_COMA). */\n if (p_tk->tk_kind==TK_COMA)\n next_tk(TRUE);\n else\n if (p_tk->tk_kind==TK_CPAR)\n {next_tk(TRUE);return;}\n else\n {\n lr_err(TKPS,\"Expecting @, or @).\");\n \n /* Experience has shown that with input files containing very */\n /* long macros, it's very difficult, given the above error */\n /* message, to determine which macro call has the unclosed */\n /* parameter list. So, the following error identifies the macro. */\n lr_err(&open_ps,\"This parameter list contains a syntax error.\");\n\n recover();\n }\n } /* End while */\n}",
"label": 0,
"cwe": null,
"length": 1176
},
{
"index": 81847,
"code": "check_tag_decl (cp_decl_specifier_seq *declspecs,\n\t\tbool explicit_type_instantiation_p)\n{\n int saw_friend = decl_spec_seq_has_spec_p (declspecs, ds_friend);\n int saw_typedef = decl_spec_seq_has_spec_p (declspecs, ds_typedef);\n /* If a class, struct, or enum type is declared by the DECLSPECS\n (i.e, if a class-specifier, enum-specifier, or non-typename\n elaborated-type-specifier appears in the DECLSPECS),\n DECLARED_TYPE is set to the corresponding type. */\n tree declared_type = NULL_TREE;\n bool error_p = false;\n\n if (declspecs->multiple_types_p)\n error (\"multiple types in one declaration\");\n else if (declspecs->redefined_builtin_type)\n {\n if (!in_system_header)\n\tpermerror (declspecs->locations[ds_redefined_builtin_type_spec],\n\t\t \"redeclaration of C++ built-in type %qT\",\n\t\t declspecs->redefined_builtin_type);\n return NULL_TREE;\n }\n\n if (declspecs->type\n && TYPE_P (declspecs->type)\n && ((TREE_CODE (declspecs->type) != TYPENAME_TYPE\n\t && MAYBE_CLASS_TYPE_P (declspecs->type))\n\t || TREE_CODE (declspecs->type) == ENUMERAL_TYPE))\n declared_type = declspecs->type;\n else if (declspecs->type == error_mark_node)\n error_p = true;\n if (declared_type == NULL_TREE && ! saw_friend && !error_p)\n permerror (input_location, \"declaration does not declare anything\");\n else if (declared_type != NULL_TREE && type_uses_auto (declared_type))\n {\n error (\"%<auto%> can only be specified for variables \"\n\t \"or function declarations\");\n return error_mark_node;\n }\n /* Check for an anonymous union. */\n else if (declared_type && RECORD_OR_UNION_CODE_P (TREE_CODE (declared_type))\n\t && TYPE_ANONYMOUS_P (declared_type))\n {\n /* 7/3 In a simple-declaration, the optional init-declarator-list\n\t can be omitted only when declaring a class (clause 9) or\n\t enumeration (7.2), that is, when the decl-specifier-seq contains\n\t either a class-specifier, an elaborated-type-specifier with\n\t a class-key (9.1), or an enum-specifier. In these cases and\n\t whenever a class-specifier or enum-specifier is present in the\n\t decl-specifier-seq, the identifiers in these specifiers are among\n\t the names being declared by the declaration (as class-name,\n\t enum-names, or enumerators, depending on the syntax). In such\n\t cases, and except for the declaration of an unnamed bit-field (9.6),\n\t the decl-specifier-seq shall introduce one or more names into the\n\t program, or shall redeclare a name introduced by a previous\n\t declaration. [Example:\n\t enum { };\t\t\t// ill-formed\n\t typedef class { };\t\t// ill-formed\n\t --end example] */\n if (saw_typedef)\n\t{\n\t error (\"missing type-name in typedef-declaration\");\n\t return NULL_TREE;\n\t}\n /* Anonymous unions are objects, so they can have specifiers. */;\n SET_ANON_AGGR_TYPE_P (declared_type);\n\n if (TREE_CODE (declared_type) != UNION_TYPE && !in_system_header)\n\tpedwarn (input_location, OPT_Wpedantic, \"ISO C++ prohibits anonymous structs\");\n }\n\n else\n {\n if (decl_spec_seq_has_spec_p (declspecs, ds_inline)\n\t || decl_spec_seq_has_spec_p (declspecs, ds_virtual))\n\terror (\"%qs can only be specified for functions\",\n\t decl_spec_seq_has_spec_p (declspecs, ds_inline)\n\t ? \"inline\" : \"virtual\");\n else if (saw_friend\n\t && (!current_class_type\n\t\t || current_scope () != current_class_type))\n\terror (\"%<friend%> can only be specified inside a class\");\n else if (decl_spec_seq_has_spec_p (declspecs, ds_explicit))\n\terror (\"%<explicit%> can only be specified for constructors\");\n else if (declspecs->storage_class)\n\terror (\"a storage class can only be specified for objects \"\n\t \"and functions\");\n else if (decl_spec_seq_has_spec_p (declspecs, ds_const)\n\t || decl_spec_seq_has_spec_p (declspecs, ds_volatile)\n\t || decl_spec_seq_has_spec_p (declspecs, ds_restrict)\n\t || decl_spec_seq_has_spec_p (declspecs, ds_thread))\n\terror (\"qualifiers can only be specified for objects \"\n\t \"and functions\");\n else if (saw_typedef)\n\twarning (0, \"%<typedef%> was ignored in this declaration\");\n else if (decl_spec_seq_has_spec_p (declspecs, ds_constexpr))\n error (\"%<constexpr%> cannot be used for type declarations\");\n }\n\n if (declspecs->attributes && warn_attributes && declared_type)\n {\n location_t loc;\n if (!CLASS_TYPE_P (declared_type)\n\t || !CLASSTYPE_TEMPLATE_INSTANTIATION (declared_type))\n\t/* For a non-template class, use the name location. */\n\tloc = location_of (declared_type);\n else\n\t/* For a template class (an explicit instantiation), use the\n\t current location. */\n\tloc = input_location;\n\n if (explicit_type_instantiation_p)\n\t/* [dcl.attr.grammar]/4:\n\n\t No attribute-specifier-seq shall appertain to an explicit\n\t instantiation. */\n\t{\n\t warning_at (loc, OPT_Wattributes,\n\t\t \"attribute ignored in explicit instantiation %q#T\",\n\t\t declared_type);\n\t inform (loc,\n\t\t \"no attribute can be applied to \"\n\t\t \"an explicit instantiation\");\n\t}\n else\n\twarn_misplaced_attr_for_class_type (loc, declared_type);\n }\n\n return declared_type;\n}",
"label": 0,
"cwe": null,
"length": 1304
},
{
"index": 870732,
"code": "find_replaceable_in_bb (temp_expr_table_p tab, basic_block bb)\n{\n gimple_stmt_iterator bsi;\n gimple stmt;\n tree def, use, fndecl;\n int partition;\n var_map map = tab->map;\n ssa_op_iter iter;\n bool stmt_replaceable;\n int cur_call_cnt = 0;\n\n for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))\n {\n stmt = gsi_stmt (bsi);\n\n if (is_gimple_debug (stmt))\n\tcontinue;\n\n stmt_replaceable = is_replaceable_p (stmt, true);\n\n /* Determine if this stmt finishes an existing expression. */\n FOR_EACH_SSA_TREE_OPERAND (use, stmt, iter, SSA_OP_USE)\n\t{\n\t unsigned ver = SSA_NAME_VERSION (use);\n\n\t /* If this use is a potential replacement variable, process it. */\n\t if (tab->expr_decl_uids[ver])\n\t {\n\t bool same_root_var = false;\n\t ssa_op_iter iter2;\n\t bitmap vars = tab->expr_decl_uids[ver];\n\n\t /* See if the root variables are the same. If they are, we\n\t\t do not want to do the replacement to avoid problems with\n\t\t code size, see PR tree-optimization/17549. */\n\t if (!bitmap_empty_p (vars))\n\t\tFOR_EACH_SSA_TREE_OPERAND (def, stmt, iter2, SSA_OP_DEF)\n\t\t {\n\t\t if (SSA_NAME_VAR (def)\n\t\t\t&& bitmap_bit_p (vars, DECL_UID (SSA_NAME_VAR (def))))\n\t\t {\n\t\t\tsame_root_var = true;\n\t\t\tbreak;\n\t\t }\n\t\t }\n\n\t /* If the stmt does a memory store and the replacement\n\t is a load aliasing it avoid creating overlapping\n\t\t assignments which we cannot expand correctly. */\n\t if (gimple_vdef (stmt))\n\t\t{\n\t\t gimple def_stmt = SSA_NAME_DEF_STMT (use);\n\t\t while (is_gimple_assign (def_stmt)\n\t\t\t && gimple_assign_rhs_code (def_stmt) == SSA_NAME)\n\t\t def_stmt\n\t\t = SSA_NAME_DEF_STMT (gimple_assign_rhs1 (def_stmt));\n\t\t if (gimple_vuse (def_stmt)\n\t\t && gimple_assign_single_p (def_stmt)\n\t\t && stmt_may_clobber_ref_p (stmt,\n\t\t\t\t\t\t gimple_assign_rhs1 (def_stmt)))\n\t\t {\n\t\t /* For calls, it is not a problem if USE is among\n\t\t\t call's arguments or say OBJ_TYPE_REF argument,\n\t\t\t all those necessarily need to be evaluated before\n\t\t\t the call that may clobber the memory. But if\n\t\t\t LHS of the call refers to USE, expansion might\n\t\t\t evaluate it after the call, prevent TER in that\n\t\t\t case.\n\t\t\t For inline asm, allow TER of loads into input\n\t\t\t arguments, but disallow TER for USEs that occur\n\t\t\t somewhere in outputs. */\n\t\t if (is_gimple_call (stmt)\n\t\t\t || gimple_code (stmt) == GIMPLE_ASM)\n\t\t\t{\n\t\t\t if (walk_stmt_load_store_ops (stmt, use, NULL,\n\t\t\t\t\t\t\tfind_ssaname_in_store))\n\t\t\t same_root_var = true;\n\t\t\t}\n\t\t else\n\t\t\tsame_root_var = true;\n\t\t }\n\t\t}\n\n\t /* Mark expression as replaceable unless stmt is volatile, or the\n\t\t def variable has the same root variable as something in the\n\t\t substitution list, or the def and use span a call such that\n\t\t we'll expand lifetimes across a call. */\n\t if (gimple_has_volatile_ops (stmt) || same_root_var\n\t\t || (tab->call_cnt[ver] != cur_call_cnt\n\t\t && SINGLE_SSA_USE_OPERAND (SSA_NAME_DEF_STMT (use), SSA_OP_USE)\n\t\t\t == NULL_USE_OPERAND_P))\n\t\tfinished_with_expr (tab, ver, true);\n\t else\n\t\tmark_replaceable (tab, use, stmt_replaceable);\n\t }\n\t}\n\n /* Next, see if this stmt kills off an active expression. */\n FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_DEF)\n\t{\n\t partition = var_to_partition (map, def);\n\t if (partition != NO_PARTITION && tab->kill_list[partition])\n\t kill_expr (tab, partition);\n\t}\n\n /* Increment counter if this is a non BUILT_IN call. We allow\n\t replacement over BUILT_IN calls since many will expand to inline\n\t insns instead of a true call. */\n if (is_gimple_call (stmt)\n\t && !((fndecl = gimple_call_fndecl (stmt))\n\t && DECL_BUILT_IN (fndecl)))\n\tcur_call_cnt++;\n\n /* Now see if we are creating a new expression or not. */\n if (stmt_replaceable)\n\tprocess_replaceable (tab, stmt, cur_call_cnt);\n\n /* Free any unused dependency lists. */\n bitmap_clear (tab->new_replaceable_dependencies);\n\n /* A V_{MAY,MUST}_DEF kills any expression using a virtual operand,\n\t including the current stmt. */\n if (gimple_vdef (stmt))\n kill_virtual_exprs (tab);\n }\n}",
"label": 0,
"cwe": null,
"length": 1118
},
{
"index": 908192,
"code": "get_cast_hashentry(PLpgSQL_execstate *estate,\n\t\t\t\t Oid srctype, int32 srctypmod,\n\t\t\t\t Oid dsttype, int32 dsttypmod)\n{\n\tplpgsql_CastHashKey cast_key;\n\tplpgsql_CastHashEntry *cast_entry;\n\tbool\t\tfound;\n\tLocalTransactionId curlxid;\n\tMemoryContext oldcontext;\n\n\t/* Look for existing entry */\n\tcast_key.srctype = srctype;\n\tcast_key.dsttype = dsttype;\n\tcast_key.srctypmod = srctypmod;\n\tcast_key.dsttypmod = dsttypmod;\n\tcast_entry = (plpgsql_CastHashEntry *) hash_search(estate->cast_hash,\n\t\t\t\t\t\t\t\t\t\t\t\t\t (void *) &cast_key,\n\t\t\t\t\t\t\t\t\t\t\t\t\t HASH_FIND, NULL);\n\n\tif (cast_entry == NULL)\n\t{\n\t\t/* We've not looked up this coercion before */\n\t\tNode\t *cast_expr;\n\t\tCaseTestExpr *placeholder;\n\n\t\t/*\n\t\t * Since we could easily fail (no such coercion), construct a\n\t\t * temporary coercion expression tree in a short-lived context, then\n\t\t * if successful copy it to cast_hash_context.\n\t\t */\n\t\toldcontext = MemoryContextSwitchTo(estate->eval_econtext->ecxt_per_tuple_memory);\n\n\t\t/*\n\t\t * We use a CaseTestExpr as the base of the coercion tree, since it's\n\t\t * very cheap to insert the source value for that.\n\t\t */\n\t\tplaceholder = makeNode(CaseTestExpr);\n\t\tplaceholder->typeId = srctype;\n\t\tplaceholder->typeMod = srctypmod;\n\t\tplaceholder->collation = get_typcollation(srctype);\n\n\t\t/*\n\t\t * Apply coercion. We use ASSIGNMENT coercion because that's the\n\t\t * closest match to plpgsql's historical behavior; in particular,\n\t\t * EXPLICIT coercion would allow silent truncation to a destination\n\t\t * varchar/bpchar's length, which we do not want.\n\t\t *\n\t\t * If source type is UNKNOWN, coerce_to_target_type will fail (it only\n\t\t * expects to see that for Const input nodes), so don't call it; we'll\n\t\t * apply CoerceViaIO instead. Likewise, it doesn't currently work for\n\t\t * coercing RECORD to some other type, so skip for that too.\n\t\t */\n\t\tif (srctype == UNKNOWNOID || srctype == RECORDOID)\n\t\t\tcast_expr = NULL;\n\t\telse\n\t\t\tcast_expr = coerce_to_target_type(NULL,\n\t\t\t\t\t\t\t\t\t\t\t (Node *) placeholder, srctype,\n\t\t\t\t\t\t\t\t\t\t\t dsttype, dsttypmod,\n\t\t\t\t\t\t\t\t\t\t\t COERCION_ASSIGNMENT,\n\t\t\t\t\t\t\t\t\t\t\t COERCE_IMPLICIT_CAST,\n\t\t\t\t\t\t\t\t\t\t\t -1);\n\n\t\t/*\n\t\t * If there's no cast path according to the parser, fall back to using\n\t\t * an I/O coercion; this is semantically dubious but matches plpgsql's\n\t\t * historical behavior. We would need something of the sort for\n\t\t * UNKNOWN literals in any case.\n\t\t */\n\t\tif (cast_expr == NULL)\n\t\t{\n\t\t\tCoerceViaIO *iocoerce = makeNode(CoerceViaIO);\n\n\t\t\tiocoerce->arg = (Expr *) placeholder;\n\t\t\tiocoerce->resulttype = dsttype;\n\t\t\tiocoerce->resultcollid = InvalidOid;\n\t\t\tiocoerce->coerceformat = COERCE_IMPLICIT_CAST;\n\t\t\tiocoerce->location = -1;\n\t\t\tcast_expr = (Node *) iocoerce;\n\t\t\tif (dsttypmod != -1)\n\t\t\t\tcast_expr = coerce_to_target_type(NULL,\n\t\t\t\t\t\t\t\t\t\t\t\t cast_expr, dsttype,\n\t\t\t\t\t\t\t\t\t\t\t\t dsttype, dsttypmod,\n\t\t\t\t\t\t\t\t\t\t\t\t COERCION_ASSIGNMENT,\n\t\t\t\t\t\t\t\t\t\t\t\t COERCE_IMPLICIT_CAST,\n\t\t\t\t\t\t\t\t\t\t\t\t -1);\n\t\t}\n\n\t\t/* Note: we don't bother labeling the expression tree with collation */\n\n\t\t/* Detect whether we have a no-op (RelabelType) coercion */\n\t\tif (IsA(cast_expr, RelabelType) &&\n\t\t\t((RelabelType *) cast_expr)->arg == (Expr *) placeholder)\n\t\t\tcast_expr = NULL;\n\n\t\tif (cast_expr)\n\t\t{\n\t\t\t/* ExecInitExpr assumes we've planned the expression */\n\t\t\tcast_expr = (Node *) expression_planner((Expr *) cast_expr);\n\n\t\t\t/* Now copy the tree into cast_hash_context */\n\t\t\tMemoryContextSwitchTo(estate->cast_hash_context);\n\n\t\t\tcast_expr = copyObject(cast_expr);\n\t\t}\n\n\t\tMemoryContextSwitchTo(oldcontext);\n\n\t\t/* Now we can fill in a hashtable entry. */\n\t\tcast_entry = (plpgsql_CastHashEntry *) hash_search(estate->cast_hash,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t (void *) &cast_key,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t HASH_ENTER, &found);\n\t\tAssert(!found);\t\t\t/* wasn't there a moment ago */\n\t\tcast_entry->cast_expr = (Expr *) cast_expr;\n\t\tcast_entry->cast_exprstate = NULL;\n\t\tcast_entry->cast_in_use = false;\n\t\tcast_entry->cast_lxid = InvalidLocalTransactionId;\n\t}\n\n\t/* Done if we have determined that this is a no-op cast. */\n\tif (cast_entry->cast_expr == NULL)\n\t\treturn NULL;\n\n\t/*\n\t * Prepare the expression for execution, if it's not been done already in\n\t * the current transaction; also, if it's marked busy in the current\n\t * transaction, abandon that expression tree and build a new one, so as to\n\t * avoid potential problems with recursive cast expressions and failed\n\t * executions. (We will leak some memory intra-transaction if that\n\t * happens a lot, but we don't expect it to.) It's okay to update the\n\t * hash table with the new tree because all plpgsql functions within a\n\t * given transaction share the same simple_eval_estate. (Well, regular\n\t * functions do; DO blocks have private simple_eval_estates, and private\n\t * cast hash tables to go with them.)\n\t */\n\tcurlxid = MyProc->lxid;\n\tif (cast_entry->cast_lxid != curlxid || cast_entry->cast_in_use)\n\t{\n\t\toldcontext = MemoryContextSwitchTo(estate->simple_eval_estate->es_query_cxt);\n\t\tcast_entry->cast_exprstate = ExecInitExpr(cast_entry->cast_expr, NULL);\n\t\tcast_entry->cast_in_use = false;\n\t\tcast_entry->cast_lxid = curlxid;\n\t\tMemoryContextSwitchTo(oldcontext);\n\t}\n\n\treturn cast_entry;\n}",
"label": 0,
"cwe": null,
"length": 1383
},
{
"index": 914488,
"code": "tracker_dbus_init (void) {\n\tgboolean result = FALSE;\n\tGDBusConnection* _tmp0_ = NULL;\n\tGError * _inner_error_ = NULL;\n#line 90 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t_tmp0_ = tracker_dbus_connection;\n#line 90 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\tif (_tmp0_ != NULL) {\n#line 91 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\tresult = TRUE;\n#line 91 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\treturn result;\n#line 442 \"tracker-dbus.c\"\n\t}\n\t{\n\t\tGDBusConnection* _tmp1_ = NULL;\n\t\tGDBusConnection* _tmp2_ = NULL;\n#line 95 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\t_tmp2_ = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &_inner_error_);\n#line 95 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\t_tmp1_ = _tmp2_;\n#line 95 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\tif (_inner_error_ != NULL) {\n#line 453 \"tracker-dbus.c\"\n\t\t\tgoto __catch4_g_error;\n\t\t}\n#line 95 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\t_g_object_unref0 (tracker_dbus_connection);\n#line 95 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\ttracker_dbus_connection = _tmp1_;\n#line 460 \"tracker-dbus.c\"\n\t}\n\tgoto __finally4;\n\t__catch4_g_error:\n\t{\n\t\tGError* e = NULL;\n\t\tGError* _tmp3_ = NULL;\n\t\tconst gchar* _tmp4_ = NULL;\n#line 94 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\te = _inner_error_;\n#line 94 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\t_inner_error_ = NULL;\n#line 97 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\t_tmp3_ = e;\n#line 97 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\t_tmp4_ = _tmp3_->message;\n#line 97 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\tg_critical (\"Could not connect to the D-Bus session bus, %s\", _tmp4_);\n#line 98 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\tresult = FALSE;\n#line 98 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\t_g_error_free0 (e);\n#line 98 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\treturn result;\n#line 484 \"tracker-dbus.c\"\n\t}\n\t__finally4:\n#line 94 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\tif (_inner_error_ != NULL) {\n#line 94 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\tg_critical (\"file %s: line %d: uncaught error: %s (%s, %d)\", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);\n#line 94 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\tg_clear_error (&_inner_error_);\n#line 94 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\t\treturn FALSE;\n#line 495 \"tracker-dbus.c\"\n\t}\n#line 101 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\tresult = TRUE;\n#line 101 \"/home/martyn/Source/checkout/gnome/tracker/src/tracker-store/tracker-dbus.vala\"\n\treturn result;\n#line 501 \"tracker-dbus.c\"\n}",
"label": 0,
"cwe": null,
"length": 1056
},
{
"index": 325457,
"code": "decode_mtr(struct i7300_pvt *pvt,\n\t\t int slot, int ch, int branch,\n\t\t struct i7300_dimm_info *dinfo,\n\t\t struct dimm_info *dimm)\n{\n\tint mtr, ans, addrBits, channel;\n\n\tchannel = to_channel(ch, branch);\n\n\tmtr = pvt->mtr[slot][branch];\n\tans = MTR_DIMMS_PRESENT(mtr) ? 1 : 0;\n\n\tedac_dbg(2, \"\\tMTR%d CH%d: DIMMs are %sPresent (mtr)\\n\",\n\t\t slot, channel, ans ? \"\" : \"NOT \");\n\n\t/* Determine if there is a DIMM present in this DIMM slot */\n\tif (!ans)\n\t\treturn 0;\n\n\t/* Start with the number of bits for a Bank\n\t* on the DRAM */\n\taddrBits = MTR_DRAM_BANKS_ADDR_BITS;\n\t/* Add thenumber of ROW bits */\n\taddrBits += MTR_DIMM_ROWS_ADDR_BITS(mtr);\n\t/* add the number of COLUMN bits */\n\taddrBits += MTR_DIMM_COLS_ADDR_BITS(mtr);\n\t/* add the number of RANK bits */\n\taddrBits += MTR_DIMM_RANKS(mtr);\n\n\taddrBits += 6;\t/* add 64 bits per DIMM */\n\taddrBits -= 20;\t/* divide by 2^^20 */\n\taddrBits -= 3;\t/* 8 bits per bytes */\n\n\tdinfo->megabytes = 1 << addrBits;\n\n\tedac_dbg(2, \"\\t\\tWIDTH: x%d\\n\", MTR_DRAM_WIDTH(mtr));\n\n\tedac_dbg(2, \"\\t\\tELECTRICAL THROTTLING is %s\\n\",\n\t\t MTR_DIMMS_ETHROTTLE(mtr) ? \"enabled\" : \"disabled\");\n\n\tedac_dbg(2, \"\\t\\tNUMBANK: %d bank(s)\\n\", MTR_DRAM_BANKS(mtr));\n\tedac_dbg(2, \"\\t\\tNUMRANK: %s\\n\",\n\t\t MTR_DIMM_RANKS(mtr) ? \"double\" : \"single\");\n\tedac_dbg(2, \"\\t\\tNUMROW: %s\\n\",\n\t\t MTR_DIMM_ROWS(mtr) == 0 ? \"8,192 - 13 rows\" :\n\t\t MTR_DIMM_ROWS(mtr) == 1 ? \"16,384 - 14 rows\" :\n\t\t MTR_DIMM_ROWS(mtr) == 2 ? \"32,768 - 15 rows\" :\n\t\t \"65,536 - 16 rows\");\n\tedac_dbg(2, \"\\t\\tNUMCOL: %s\\n\",\n\t\t MTR_DIMM_COLS(mtr) == 0 ? \"1,024 - 10 columns\" :\n\t\t MTR_DIMM_COLS(mtr) == 1 ? \"2,048 - 11 columns\" :\n\t\t MTR_DIMM_COLS(mtr) == 2 ? \"4,096 - 12 columns\" :\n\t\t \"reserved\");\n\tedac_dbg(2, \"\\t\\tSIZE: %d MB\\n\", dinfo->megabytes);\n\n\t/*\n\t * The type of error detection actually depends of the\n\t * mode of operation. When it is just one single memory chip, at\n\t * socket 0, channel 0, it uses 8-byte-over-32-byte SECDED+ code.\n\t * In normal or mirrored mode, it uses Lockstep mode,\n\t * with the possibility of using an extended algorithm for x8 memories\n\t * See datasheet Sections 7.3.6 to 7.3.8\n\t */\n\n\tdimm->nr_pages = MiB_TO_PAGES(dinfo->megabytes);\n\tdimm->grain = 8;\n\tdimm->mtype = MEM_FB_DDR2;\n\tif (IS_SINGLE_MODE(pvt->mc_settings_a)) {\n\t\tdimm->edac_mode = EDAC_SECDED;\n\t\tedac_dbg(2, \"\\t\\tECC code is 8-byte-over-32-byte SECDED+ code\\n\");\n\t} else {\n\t\tedac_dbg(2, \"\\t\\tECC code is on Lockstep mode\\n\");\n\t\tif (MTR_DRAM_WIDTH(mtr) == 8)\n\t\t\tdimm->edac_mode = EDAC_S8ECD8ED;\n\t\telse\n\t\t\tdimm->edac_mode = EDAC_S4ECD4ED;\n\t}\n\n\t/* ask what device type on this row */\n\tif (MTR_DRAM_WIDTH(mtr) == 8) {\n\t\tedac_dbg(2, \"\\t\\tScrub algorithm for x8 is on %s mode\\n\",\n\t\t\t IS_SCRBALGO_ENHANCED(pvt->mc_settings) ?\n\t\t\t \"enhanced\" : \"normal\");\n\n\t\tdimm->dtype = DEV_X8;\n\t} else\n\t\tdimm->dtype = DEV_X4;\n\n\treturn mtr;\n}",
"label": 0,
"cwe": null,
"length": 1031
}
]