[ { "index": 920483, "code": "copy_blkmode_from_reg (tgtblk, srcreg, type)\n rtx tgtblk;\n rtx srcreg;\n tree type;\n{\n unsigned HOST_WIDE_INT bytes = int_size_in_bytes (type);\n rtx src = NULL, dst = NULL;\n unsigned HOST_WIDE_INT bitsize = MIN (TYPE_ALIGN (type), BITS_PER_WORD);\n unsigned HOST_WIDE_INT bitpos, xbitpos, big_endian_correction = 0;\n\n if (tgtblk == 0)\n {\n tgtblk = assign_temp (build_qualified_type (type,\n\t\t\t\t\t\t (TYPE_QUALS (type)\n\t\t\t\t\t\t | TYPE_QUAL_CONST)),\n\t\t\t 0, 1, 1);\n preserve_temp_slots (tgtblk);\n }\n\n /* This code assumes srcreg is at least a full word. If it isn't, copy it\n into a new pseudo which is a full word. */\n\n if (GET_MODE (srcreg) != BLKmode\n && GET_MODE_SIZE (GET_MODE (srcreg)) < UNITS_PER_WORD)\n srcreg = convert_to_mode (word_mode, srcreg, TREE_UNSIGNED (type));\n\n /* Structures whose size is not a multiple of a word are aligned\n to the least significant byte (to the right). On a BYTES_BIG_ENDIAN\n machine, this means we must skip the empty high order bytes when\n calculating the bit offset. */\n if (BYTES_BIG_ENDIAN\n && bytes % UNITS_PER_WORD)\n big_endian_correction\n = (BITS_PER_WORD - ((bytes % UNITS_PER_WORD) * BITS_PER_UNIT));\n\n /* Copy the structure BITSIZE bites at a time.\n\n We could probably emit more efficient code for machines which do not use\n strict alignment, but it doesn't seem worth the effort at the current\n time. */\n for (bitpos = 0, xbitpos = big_endian_correction;\n bitpos < bytes * BITS_PER_UNIT;\n bitpos += bitsize, xbitpos += bitsize)\n {\n /* We need a new source operand each time xbitpos is on a\n\t word boundary and when xbitpos == big_endian_correction\n\t (the first time through). */\n if (xbitpos % BITS_PER_WORD == 0\n\t || xbitpos == big_endian_correction)\n\tsrc = operand_subword_force (srcreg, xbitpos / BITS_PER_WORD,\n\t\t\t\t GET_MODE (srcreg));\n\n /* We need a new destination operand each time bitpos is on\n\t a word boundary. */\n if (bitpos % BITS_PER_WORD == 0)\n\tdst = operand_subword (tgtblk, bitpos / BITS_PER_WORD, 1, BLKmode);\n\n /* Use xbitpos for the source extraction (right justified) and\n\t xbitpos for the destination store (left justified). */\n store_bit_field (dst, bitsize, bitpos % BITS_PER_WORD, word_mode,\n\t\t extract_bit_field (src, bitsize,\n\t\t\t\t\t xbitpos % BITS_PER_WORD, 1,\n\t\t\t\t\t NULL_RTX, word_mode, word_mode,\n\t\t\t\t\t BITS_PER_WORD),\n\t\t BITS_PER_WORD);\n }\n\n return tgtblk;\n}", "label": 0, "cwe": null, "length": 689 }, { "index": 30607, "code": "add_accessible_from_iter (DBusMessageIter *iter)\n{\n DBusMessageIter iter_struct, iter_array;\n const char *app_name, *path;\n AtspiAccessible *accessible;\n const char *name, *description;\n dbus_uint32_t role;\n\n dbus_message_iter_recurse (iter, &iter_struct);\n\n /* get accessible */\n get_reference_from_iter (&iter_struct, &app_name, &path);\n accessible = ref_accessible (app_name, path);\n if (!accessible)\n return;\n\n /* Get application: TODO */\n dbus_message_iter_next (&iter_struct);\n\n /* get parent */\n get_reference_from_iter (&iter_struct, &app_name, &path);\n if (accessible->accessible_parent)\n g_object_unref (accessible->accessible_parent);\n accessible->accessible_parent = ref_accessible (app_name, path);\n\n /* Get children */\n while (accessible->children)\n {\n g_object_unref (accessible->children->data);\n accessible->children = g_list_remove (accessible->children, accessible->children->data);\n }\n dbus_message_iter_recurse (&iter_struct, &iter_array);\n while (dbus_message_iter_get_arg_type (&iter_array) != DBUS_TYPE_INVALID)\n {\n AtspiAccessible *child;\n get_reference_from_iter (&iter_array, &app_name, &path);\n child = ref_accessible (app_name, path);\n accessible->children = g_list_append (accessible->children, child);\n }\n\n /* interfaces */\n dbus_message_iter_next (&iter_struct);\n _atspi_dbus_set_interfaces (accessible, &iter_struct);\n dbus_message_iter_next (&iter_struct);\n\n /* name */\n if (accessible->name)\n g_free (accessible->name);\n dbus_message_iter_get_basic (&iter_struct, &name);\n accessible->name = g_strdup (name);\n dbus_message_iter_next (&iter_struct);\n\n /* role */\n dbus_message_iter_get_basic (&iter_struct, &role);\n accessible->role = role;\n dbus_message_iter_next (&iter_struct);\n\n /* description */\n if (accessible->description)\n g_free (accessible->description);\n dbus_message_iter_get_basic (&iter_struct, &description);\n accessible->description = g_strdup (description);\n dbus_message_iter_next (&iter_struct);\n\n _atspi_dbus_set_state (accessible, &iter_struct);\n dbus_message_iter_next (&iter_struct);\n\n _atspi_accessible_add_cache (accessible, ATSPI_CACHE_NAME | ATSPI_CACHE_ROLE |\n ATSPI_CACHE_PARENT | ATSPI_CACHE_DESCRIPTION);\n if (!atspi_state_set_contains (accessible->states,\n ATSPI_STATE_MANAGES_DESCENDANTS))\n _atspi_accessible_add_cache (accessible, ATSPI_CACHE_CHILDREN);\n\n /* This is a bit of a hack since the cache holds a ref, so we don't need\n * the one provided for us anymore */\n g_object_unref (accessible);\n}", "label": 0, "cwe": null, "length": 618 }, { "index": 90070, "code": "bt_ctf_get_field_list(const struct bt_ctf_event *ctf_event,\n\t\tconst struct bt_definition *scope,\n\t\tstruct bt_definition const * const **list,\n\t\tunsigned int *count)\n{\n\tif (!ctf_event || !scope || !list || !count)\n\t\treturn -EINVAL;\n\n\tswitch (bt_ctf_field_type(bt_ctf_get_decl_from_def(scope))) {\n\tcase CTF_TYPE_INTEGER:\n\tcase CTF_TYPE_FLOAT:\n\tcase CTF_TYPE_STRING:\n\tcase CTF_TYPE_ENUM:\n\t\tgoto error;\n\tcase CTF_TYPE_STRUCT:\n\t{\n\t\tconst struct definition_struct *def_struct;\n\n\t\tdef_struct = container_of(scope, const struct definition_struct, p);\n\t\tif (!def_struct)\n\t\t\tgoto error;\n\t\tif (def_struct->fields->pdata) {\n\t\t\t*list = (struct bt_definition const* const*) def_struct->fields->pdata;\n\t\t\t*count = def_struct->fields->len;\n\t\t\tgoto end;\n\t\t} else {\n\t\t\tgoto error;\n\t\t}\n\t\tbreak;\n\t}\n\tcase CTF_TYPE_UNTAGGED_VARIANT:\n\t\tgoto error;\n\tcase CTF_TYPE_VARIANT:\n\t{\n\t\tconst struct definition_variant *def_variant;\n\n\t\tdef_variant = container_of(scope, const struct definition_variant, p);\n\t\tif (!def_variant)\n\t\t\tgoto error;\n\t\tif (def_variant->fields->pdata) {\n\t\t\t*list = (struct bt_definition const* const*) def_variant->fields->pdata;\n\t\t\t*count = def_variant->fields->len;\n\t\t\tgoto end;\n\t\t} else {\n\t\t\tgoto error;\n\t\t}\n\t\tbreak;\n\t}\n\tcase CTF_TYPE_ARRAY:\n\t{\n\t\tconst struct definition_array *def_array;\n\n\t\tdef_array = container_of(scope, const struct definition_array, p);\n\t\tif (!def_array)\n\t\t\tgoto error;\n\t\tif (def_array->elems->pdata) {\n\t\t\t*list = (struct bt_definition const* const*) def_array->elems->pdata;\n\t\t\t*count = def_array->elems->len;\n\t\t\tgoto end;\n\t\t} else {\n\t\t\tgoto error;\n\t\t}\n\t\tbreak;\n\t}\n\tcase CTF_TYPE_SEQUENCE:\n\t{\n\t\tconst struct definition_sequence *def_sequence;\n\n\t\tdef_sequence = container_of(scope, const struct definition_sequence, p);\n\t\tif (!def_sequence)\n\t\t\tgoto error;\n\t\tif (def_sequence->elems->pdata) {\n\t\t\t*list = (struct bt_definition const* const*) def_sequence->elems->pdata;\n\t\t\t*count = def_sequence->elems->len;\n\t\t\tgoto end;\n\t\t} else {\n\t\t\tgoto error;\n\t\t}\n\t\tbreak;\n\t}\n\tdefault:\n\t\tbreak;\n\t}\n\nend:\n\treturn 0;\n\nerror:\n\t*list = NULL;\n\t*count = 0;\n\treturn -1;\n}", "label": 0, "cwe": null, "length": 580 }, { "index": 82635, "code": "depmod_output(struct depmod *depmod, FILE *out)\n{\n\tstatic const struct depfile {\n\t\tconst char *name;\n\t\tint (*cb)(struct depmod *depmod, FILE *out);\n\t} *itr, depfiles[] = {\n\t\t{\"modules.dep\", output_deps},\n\t\t{\"modules.dep.bin\", output_deps_bin},\n\t\t{\"modules.alias\", output_aliases},\n\t\t{\"modules.alias.bin\", output_aliases_bin},\n\t\t{\"modules.softdep\", output_softdeps},\n\t\t{\"modules.symbols\", output_symbols},\n\t\t{\"modules.symbols.bin\", output_symbols_bin},\n\t\t{\"modules.builtin.bin\", output_builtin_bin},\n\t\t{\"modules.devname\", output_devname},\n\t\t{NULL, NULL}\n\t};\n\tconst char *dname = depmod->cfg->dirname;\n\tint dfd, err = 0;\n\n\tif (out != NULL)\n\t\tdfd = -1;\n\telse {\n\t\tdfd = open(dname, O_RDONLY);\n\t\tif (dfd < 0) {\n\t\t\terr = -errno;\n\t\t\tCRIT(\"could not open directory %s: %m\\n\", dname);\n\t\t\treturn err;\n\t\t}\n\t}\n\n\tfor (itr = depfiles; itr->name != NULL; itr++) {\n\t\tFILE *fp = out;\n\t\tchar tmp[NAME_MAX] = \"\";\n\t\tint r;\n\n\t\tif (fp == NULL) {\n\t\t\tint flags = O_CREAT | O_TRUNC | O_WRONLY;\n\t\t\tint mode = 0644;\n\t\t\tint fd;\n\n\t\t\tsnprintf(tmp, sizeof(tmp), \"%s.tmp\", itr->name);\n\t\t\tfd = openat(dfd, tmp, flags, mode);\n\t\t\tif (fd < 0) {\n\t\t\t\tERR(\"openat(%s, %s, %o, %o): %m\\n\",\n\t\t\t\t dname, tmp, flags, mode);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfp = fdopen(fd, \"wb\");\n\t\t\tif (fp == NULL) {\n\t\t\t\tERR(\"fdopen(%d=%s/%s): %m\\n\", fd, dname, tmp);\n\t\t\t\tclose(fd);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\n\t\tr = itr->cb(depmod, fp);\n\t\tif (fp == out)\n\t\t\tcontinue;\n\n\t\tfclose(fp);\n\t\tif (r < 0) {\n\t\t\tif (unlinkat(dfd, tmp, 0) != 0)\n\t\t\t\tERR(\"unlinkat(%s, %s): %m\\n\", dname, tmp);\n\t\t} else {\n\t\t\tunlinkat(dfd, itr->name, 0);\n\t\t\tif (renameat(dfd, tmp, dfd, itr->name) != 0) {\n\t\t\t\terr = -errno;\n\t\t\t\tCRIT(\"renameat(%s, %s, %s, %s): %m\\n\",\n\t\t\t\t dname, tmp, dname, itr->name);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (dfd >= 0)\n\t\tclose(dfd);\n\treturn err;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-469", "CWE-other" ], "length": 629 }, { "index": 740713, "code": "mach64FillTriangle( void *drv, void *dev, DFBTriangle *tri )\n{\n Mach64DriverData *mdrv = (Mach64DriverData*) drv;\n Mach64DeviceData *mdev = (Mach64DeviceData*) dev;\n\n dfb_sort_triangle( tri );\n\n if (tri->y2 == tri->y3) {\n mach64_fill_trapezoid( mdrv, mdev,\n tri->x1, tri->x1,\n MIN( tri->x2, tri->x3), MAX( tri->x2, tri->x3 ),\n tri->y1, tri->y3 - tri->y1 );\n } else if (tri->y1 == tri->y2) {\n mach64_fill_trapezoid( mdrv, mdev,\n MIN( tri->x1, tri->x2), MAX( tri->x1, tri->x2 ),\n tri->x3, tri->x3,\n tri->y1, tri->y3 - tri->y1 );\n } else {\n int majDx = tri->x3 - tri->x1;\n int majDy = tri->y3 - tri->y1;\n int topDx = tri->x2 - tri->x1;\n int topDy = tri->y2 - tri->y1;\n int botDy = tri->y3 - tri->y2;\n\n int topXperY = (topDx << 20) / topDy;\n int X2a = tri->x1 + (((topXperY * topDy) + (1<<19)) >> 20);\n\n int majXperY = (majDx << 20) / majDy;\n int majX2 = tri->x1 + (((majXperY * topDy) + (1<<19)) >> 20);\n int majX2a = majX2 - ((majXperY + (1<<19)) >> 20);\n\n mach64_fill_trapezoid( mdrv, mdev,\n tri->x1, tri->x1,\n MIN( X2a, majX2a ), MAX( X2a, majX2a ),\n tri->y1, topDy - 1 );\n mach64_fill_trapezoid( mdrv, mdev,\n MIN( tri->x2, majX2 ), MAX( tri->x2, majX2 ),\n tri->x3, tri->x3,\n tri->y2, botDy );\n }\n\n return true;\n}", "label": 0, "cwe": null, "length": 570 }, { "index": 12922, "code": "cxd2841er_shutdown_to_sleep_s(struct cxd2841er_priv *priv)\n{\n\tdev_dbg(&priv->i2c->dev, \"%s()\\n\", __func__);\n\tif (priv->state != STATE_SHUTDOWN) {\n\t\tdev_dbg(&priv->i2c->dev, \"%s(): invalid demod state %d\\n\",\n\t\t\t__func__, priv->state);\n\t\treturn -EINVAL;\n\t}\n\t/* Set SLV-X Bank : 0x00 */\n\tcxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);\n\t/* Clear all demodulator registers */\n\tcxd2841er_write_reg(priv, I2C_SLVX, 0x02, 0x00);\n\tusleep_range(3000, 5000);\n\t/* Set SLV-X Bank : 0x00 */\n\tcxd2841er_write_reg(priv, I2C_SLVX, 0x00, 0x00);\n\t/* Set demod SW reset */\n\tcxd2841er_write_reg(priv, I2C_SLVX, 0x10, 0x01);\n\t/* Set X'tal clock to 20.5Mhz */\n\tcxd2841er_write_reg(priv, I2C_SLVX, 0x14, 0x00);\n\t/* Set demod mode */\n\tcxd2841er_write_reg(priv, I2C_SLVX, 0x17, 0x0a);\n\t/* Clear demod SW reset */\n\tcxd2841er_write_reg(priv, I2C_SLVX, 0x10, 0x00);\n\tusleep_range(1000, 2000);\n\t/* Set SLV-T Bank : 0x00 */\n\tcxd2841er_write_reg(priv, I2C_SLVT, 0x00, 0x00);\n\t/* enable DSQOUT */\n\tcxd2841er_write_reg(priv, I2C_SLVT, 0x80, 0x1F);\n\t/* enable DSQIN */\n\tcxd2841er_write_reg(priv, I2C_SLVT, 0x9C, 0x40);\n\t/* TADC Bias On */\n\tcxd2841er_write_reg(priv, I2C_SLVT, 0x43, 0x0a);\n\tcxd2841er_write_reg(priv, I2C_SLVT, 0x41, 0x0a);\n\t/* SADC Bias On */\n\tcxd2841er_write_reg(priv, I2C_SLVT, 0x63, 0x16);\n\tcxd2841er_write_reg(priv, I2C_SLVT, 0x65, 0x27);\n\tcxd2841er_write_reg(priv, I2C_SLVT, 0x69, 0x06);\n\tpriv->state = STATE_SLEEP_S;\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 626 }, { "index": 62244, "code": "fix_string_type (tree value)\n{\n int length = TREE_STRING_LENGTH (value);\n int nchars;\n tree e_type, i_type, a_type;\n\n /* Compute the number of elements, for the array type. */\n if (TREE_TYPE (value) == char_array_type_node || !TREE_TYPE (value))\n {\n nchars = length;\n e_type = char_type_node;\n }\n else if (TREE_TYPE (value) == char16_array_type_node)\n {\n nchars = length / (TYPE_PRECISION (char16_type_node) / BITS_PER_UNIT);\n e_type = char16_type_node;\n }\n else if (TREE_TYPE (value) == char32_array_type_node)\n {\n nchars = length / (TYPE_PRECISION (char32_type_node) / BITS_PER_UNIT);\n e_type = char32_type_node;\n }\n else\n {\n nchars = length / (TYPE_PRECISION (wchar_type_node) / BITS_PER_UNIT);\n e_type = wchar_type_node;\n }\n\n /* C89 2.2.4.1, C99 5.2.4.1 (Translation limits). The analogous\n limit in C++98 Annex B is very large (65536) and is not normative,\n so we do not diagnose it (warn_overlength_strings is forced off\n in c_common_post_options). */\n if (warn_overlength_strings)\n {\n const int nchars_max = flag_isoc99 ? 4095 : 509;\n const int relevant_std = flag_isoc99 ? 99 : 90;\n if (nchars - 1 > nchars_max)\n\t/* Translators: The %d after 'ISO C' will be 90 or 99. Do not\n\t separate the %d from the 'C'. 'ISO' should not be\n\t translated, but it may be moved after 'C%d' in languages\n\t where modifiers follow nouns. */\n\tpedwarn (input_location, OPT_Woverlength_strings,\n\t\t \"string length %qd is greater than the length %qd \"\n\t\t \"ISO C%d compilers are required to support\",\n\t\t nchars - 1, nchars_max, relevant_std);\n }\n\n /* Create the array type for the string constant. The ISO C++\n standard says that a string literal has type `const char[N]' or\n `const wchar_t[N]'. We use the same logic when invoked as a C\n front-end with -Wwrite-strings.\n ??? We should change the type of an expression depending on the\n state of a warning flag. We should just be warning -- see how\n this is handled in the C++ front-end for the deprecated implicit\n conversion from string literals to `char*' or `wchar_t*'.\n\n The C++ front end relies on TYPE_MAIN_VARIANT of a cv-qualified\n array type being the unqualified version of that type.\n Therefore, if we are constructing an array of const char, we must\n construct the matching unqualified array type first. The C front\n end does not require this, but it does no harm, so we do it\n unconditionally. */\n i_type = build_index_type (size_int (nchars - 1));\n a_type = build_array_type (e_type, i_type);\n if (c_dialect_cxx() || warn_write_strings)\n a_type = c_build_qualified_type (a_type, TYPE_QUAL_CONST);\n\n TREE_TYPE (value) = a_type;\n TREE_CONSTANT (value) = 1;\n TREE_READONLY (value) = 1;\n TREE_STATIC (value) = 1;\n return value;\n}", "label": 0, "cwe": null, "length": 796 }, { "index": 69082, "code": "write_result(N_array_3d * status, N_array_3d * phead_start,\n\t N_array_3d * phead, double *result, G3D_Region * region,\n\t char *name)\n{\n void *map = NULL;\n int changemask = 0;\n int z, y, x, rows, cols, depths, count, stat;\n double d1 = 0;\n\n rows = region->rows;\n cols = region->cols;\n depths = region->depths;\n\n /*Open the new map */\n map = G3d_openCellNew(name, DCELL_TYPE, G3D_USE_CACHE_DEFAULT, region);\n\n if (map == NULL)\n\tG3d_fatalError(_(\"Unable to create 3D raster map <%s>\"), name);\n\n /*if requested set the Mask on */\n if (param.mask->answer) {\n\tif (G3d_maskFileExists()) {\n\t changemask = 0;\n\t if (G3d_maskIsOff(map)) {\n\t\tG3d_maskOn(map);\n\t\tchangemask = 1;\n\t }\n\t}\n }\n\n count = 0;\n for (z = 0; z < depths; z++) {\n\tG_percent(z, depths - 1, 10);\n\tfor (y = 0; y < rows; y++) {\n\t for (x = 0; x < cols; x++) {\n\t\tstat = (int)N_get_array_3d_d_value(status, x, y, z);\n\t\tif (stat == N_CELL_ACTIVE) {\t/*only active cells */\n\t\t d1 = result[count];\n\t\t /*copy the values */\n\t\t N_put_array_3d_d_value(phead, x, y, z, d1);\n\t\t count++;\n\t\t}\n\t\telse if (stat == N_CELL_DIRICHLET) {\t/*dirichlet cells */\n\t\t d1 = N_get_array_3d_d_value(phead_start, x, y, z);\n\t\t}\n\t\telse {\n\t\t G3d_setNullValue(&d1, 1, DCELL_TYPE);\n\t\t}\n\t\tG3d_putDouble(map, x, y, z, d1);\n\t }\n\t}\n }\n\n /*We set the Mask off, if it was off before */\n if (param.mask->answer) {\n\tif (G3d_maskFileExists())\n\t if (G3d_maskIsOn(map) && changemask)\n\t\tG3d_maskOff(map);\n }\n\n if (!G3d_closeCell(map))\n\tG3d_fatalError(map, NULL, 0, _(\"Unable to close 3D raster map <%s>\"), name);\n\n return;\n}", "label": 0, "cwe": null, "length": 573 }, { "index": 698281, "code": "e_def_9_(fortint * inputArray, unsigned char * gribSection1) {\n/*\n// Encodes ECMWF local definition 9 (from byte 41 onwards) into\n// gribSection1 using integer array values in inputArray.\n//\n// inputArray[0] corresponds to KSEC1(37) in the description at\n// http://www.ecmwf.int/publications/manuals/libraries/gribex/localDefinition9.html\n//\n// Returns the number of bytes (octets) in local definition 9 after\n// byte 40.\n*/\nfortint value;\nfortint * n = inputArray;\nunsigned char * p = gribSection1;\n\n encodeMarsPart(n,p);\n p += 9;\n n += 5;\n\n MOVE2BYTES(p,n); /* NUMBER */\n p += 2;\n n++;\n MOVE2BYTES(p,n); /* ITERATIONCOUNT */\n p += 2;\n n++;\n MOVE2BYTES(p,n); /* VECTORCOUNT */\n p += 2;\n n++;\n\n *p++ = ONEBYTE(n);n++; /* INITIALNORM */\n *p++ = ONEBYTE(n);n++; /* FINALNORM */\n\n MOVE4BYTES(p,n); /* VECTORCOUNT */\n p += 4;\n n++;\n/*\n// When coding values, set sign bit to 1, if value is negative.\n*/\n value = *n++; /* NORTHWESTLAT */\n if( value < 0 ) value = 0x80000000 | (-value);\n MOVE4BYTES(p,&value);\n p += 4;\n\n value = *n++; /* NORTHWESTLON */\n if( value < 0 ) value = 0x80000000 | (-value);\n MOVE4BYTES(p,&value);\n p += 4;\n\n value = *n++; /* SOUTHEASTLAT */\n if( value < 0 ) value = 0x80000000 | (-value);\n MOVE4BYTES(p,&value);\n p += 4;\n\n value = *n++; /* SOUTHEASTLON */\n if( value < 0 ) value = 0x80000000 | (-value);\n MOVE4BYTES(p,&value);\n p += 4;\n\n MOVE4BYTES(p,n); /* ACCURACY */\n p += 4;\n n++;\n\n MOVE2BYTES(p,n); /* NUMBEREVOLVED */\n p += 2;\n n++;\n\n value = *n++; /* RITZNUMBER1 */\n if( value < 0 ) value = 0x80000000 | (-value);\n MOVE4BYTES(p,&value);\n p += 4;\n\n value = *n++; /* RITZNUMBER2 */\n if( value < 0 ) value = 0x80000000 | (-value);\n MOVE4BYTES(p,&value);\n p += 4;\n\n *p++ = (unsigned char) 0; /* SPARE */\n/*\n// Definition 9 has a fixed length section 1 (92 bytes)\n*/\n\n return (fortint) (92-40);\n}", "label": 0, "cwe": null, "length": 675 }, { "index": 336165, "code": "gwy_graph_model_get_property(GObject*object,\n guint prop_id,\n GValue *value,\n GParamSpec *pspec)\n{\n GwyGraphModel *gmodel = GWY_GRAPH_MODEL(object);\n\n switch (prop_id) {\n case PROP_TITLE:\n g_value_set_string(value, gmodel->title->str);\n break;\n\n case PROP_N_CURVES:\n g_value_set_uint(value, gmodel->curves->len);\n break;\n\n case PROP_X_MIN:\n g_value_set_double(value, gmodel->x_min);\n break;\n\n case PROP_X_MIN_SET:\n g_value_set_boolean(value, gmodel->x_min_set);\n break;\n\n case PROP_X_MAX:\n g_value_set_double(value, gmodel->x_max);\n break;\n\n case PROP_X_MAX_SET:\n g_value_set_boolean(value, gmodel->x_max_set);\n break;\n\n case PROP_Y_MIN:\n g_value_set_double(value, gmodel->y_min);\n break;\n\n case PROP_Y_MIN_SET:\n g_value_set_boolean(value, gmodel->y_min_set);\n break;\n\n case PROP_Y_MAX:\n g_value_set_double(value, gmodel->y_max);\n break;\n\n case PROP_Y_MAX_SET:\n g_value_set_boolean(value, gmodel->y_max_set);\n break;\n\n case PROP_AXIS_LABEL_BOTTOM:\n g_value_set_string(value, gmodel->bottom_label->str);\n break;\n\n case PROP_AXIS_LABEL_LEFT:\n g_value_set_string(value, gmodel->left_label->str);\n break;\n\n case PROP_AXIS_LABEL_RIGHT:\n g_value_set_string(value, gmodel->right_label->str);\n break;\n\n case PROP_AXIS_LABEL_TOP:\n g_value_set_string(value, gmodel->top_label->str);\n break;\n\n case PROP_SI_UNIT_X:\n /* Keep the idiosyncratic semantics of gwy_graph_model_get_si_unit_x */\n g_value_take_object(value, gwy_si_unit_duplicate(gmodel->x_unit));\n break;\n\n case PROP_SI_UNIT_Y:\n /* Keep the idiosyncratic semantics of gwy_graph_model_get_si_unit_y */\n g_value_take_object(value, gwy_si_unit_duplicate(gmodel->y_unit));\n break;\n\n case PROP_X_LOGARITHMIC:\n g_value_set_boolean(value, gmodel->x_is_logarithmic);\n break;\n\n case PROP_Y_LOGARITHMIC:\n g_value_set_boolean(value, gmodel->y_is_logarithmic);\n break;\n\n case PROP_LABEL_FRAME_THICKNESS:\n g_value_set_int(value, gmodel->label_frame_thickness);\n break;\n\n case PROP_LABEL_HAS_FRAME:\n g_value_set_boolean(value, gmodel->label_has_frame);\n break;\n\n case PROP_LABEL_REVERSE:\n g_value_set_boolean(value, gmodel->label_reverse);\n break;\n\n case PROP_LABEL_VISIBLE:\n g_value_set_boolean(value, gmodel->label_visible);\n break;\n\n case PROP_LABEL_POSITION:\n g_value_set_enum(value, gmodel->label_position);\n break;\n\n case PROP_GRID_TYPE:\n g_value_set_enum(value, gmodel->grid_type);\n break;\n\n default:\n G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);\n break;\n }\n}", "label": 0, "cwe": null, "length": 700 }, { "index": 210822, "code": "pkix_RetrieveOutputs(\n PKIX_List *checkers,\n PKIX_PL_PublicKey **pFinalSubjPubKey,\n PKIX_PolicyNode **pPolicyTree,\n void *plContext)\n{\n PKIX_PL_PublicKey *finalSubjPubKey = NULL;\n PKIX_PolicyNode *validPolicyTree = NULL;\n PKIX_CertChainChecker *checker = NULL;\n PKIX_PL_Object *state = NULL;\n PKIX_UInt32 numCheckers = 0;\n PKIX_UInt32 type;\n PKIX_Int32 j;\n\n PKIX_ENTER(VALIDATE, \"pkix_RetrieveOutputs\");\n\n PKIX_NULLCHECK_TWO(checkers, pPolicyTree);\n\n /*\n * To optimize the search, we guess that the sigChecker is\n * last in the tree and is preceded by the policyChecker. We\n * search toward the front of the chain. Remember that List\n * items are indexed 0..(numItems - 1).\n */\n\n PKIX_CHECK(PKIX_List_GetLength(checkers, &numCheckers, plContext),\n PKIX_LISTGETLENGTHFAILED);\n\n for (j = numCheckers - 1; j >= 0; j--){\n PKIX_CHECK(PKIX_List_GetItem\n (checkers, j, (PKIX_PL_Object **)&checker, plContext),\n PKIX_LISTGETITEMFAILED);\n\n PKIX_CHECK(PKIX_CertChainChecker_GetCertChainCheckerState\n (checker, &state, plContext),\n PKIX_CERTCHAINCHECKERGETCERTCHAINCHECKERSTATEFAILED);\n\n /* user defined checker may have no state */\n if (state != NULL) {\n\n PKIX_CHECK(PKIX_PL_Object_GetType(state, &type, plContext),\n PKIX_OBJECTGETTYPEFAILED);\n\n if (type == PKIX_SIGNATURECHECKERSTATE_TYPE){\n /* final pubKey will include any inherited DSA params */\n finalSubjPubKey =\n ((pkix_SignatureCheckerState *)state)->\n prevPublicKey;\n PKIX_INCREF(finalSubjPubKey);\n *pFinalSubjPubKey = finalSubjPubKey;\n }\n\n if (type == PKIX_CERTPOLICYCHECKERSTATE_TYPE) {\n validPolicyTree =\n ((PKIX_PolicyCheckerState *)state)->validPolicyTree;\n break;\n }\n }\n\n PKIX_DECREF(checker);\n PKIX_DECREF(state);\n }\n\n PKIX_INCREF(validPolicyTree);\n *pPolicyTree = validPolicyTree;\n\ncleanup:\n\n PKIX_DECREF(checker);\n PKIX_DECREF(state);\n\n PKIX_RETURN(VALIDATE);\n\n}", "label": 0, "cwe": null, "length": 568 }, { "index": 98364, "code": "process_cell(struct cache *cache, struct prealloc *structs,\n\t\t\t struct dm_bio_prison_cell *new_ocell)\n{\n\tint r;\n\tbool release_cell = true;\n\tstruct bio *bio = new_ocell->holder;\n\tdm_oblock_t block = get_bio_block(cache, bio);\n\tstruct policy_result lookup_result;\n\tbool passthrough = passthrough_mode(&cache->features);\n\tbool fast_promotion, can_migrate;\n\tstruct old_oblock_lock ool;\n\n\tfast_promotion = is_discarded_oblock(cache, block) || bio_writes_complete_block(cache, bio);\n\tcan_migrate = !passthrough && (fast_promotion || spare_migration_bandwidth(cache));\n\n\tool.locker.fn = cell_locker;\n\tool.cache = cache;\n\tool.structs = structs;\n\tool.cell = NULL;\n\tr = policy_map(cache->policy, block, true, can_migrate, fast_promotion,\n\t\t bio, &ool.locker, &lookup_result);\n\n\tif (r == -EWOULDBLOCK)\n\t\t/* migration has been denied */\n\t\tlookup_result.op = POLICY_MISS;\n\n\tswitch (lookup_result.op) {\n\tcase POLICY_HIT:\n\t\tif (passthrough) {\n\t\t\tinc_miss_counter(cache, bio);\n\n\t\t\t/*\n\t\t\t * Passthrough always maps to the origin,\n\t\t\t * invalidating any cache blocks that are written\n\t\t\t * to.\n\t\t\t */\n\n\t\t\tif (bio_data_dir(bio) == WRITE) {\n\t\t\t\tatomic_inc(&cache->stats.demotion);\n\t\t\t\tinvalidate(cache, structs, block, lookup_result.cblock, new_ocell);\n\t\t\t\trelease_cell = false;\n\n\t\t\t} else {\n\t\t\t\t/* FIXME: factor out issue_origin() */\n\t\t\t\tremap_to_origin_clear_discard(cache, bio, block);\n\t\t\t\tinc_and_issue(cache, bio, new_ocell);\n\t\t\t}\n\t\t} else {\n\t\t\tinc_hit_counter(cache, bio);\n\n\t\t\tif (bio_data_dir(bio) == WRITE &&\n\t\t\t writethrough_mode(&cache->features) &&\n\t\t\t !is_dirty(cache, lookup_result.cblock)) {\n\t\t\t\tremap_to_origin_then_cache(cache, bio, block, lookup_result.cblock);\n\t\t\t\tinc_and_issue(cache, bio, new_ocell);\n\n\t\t\t} else {\n\t\t\t\tremap_cell_to_cache_dirty(cache, new_ocell, block, lookup_result.cblock, true);\n\t\t\t\trelease_cell = false;\n\t\t\t}\n\t\t}\n\n\t\tbreak;\n\n\tcase POLICY_MISS:\n\t\tinc_miss_counter(cache, bio);\n\t\tremap_cell_to_origin_clear_discard(cache, new_ocell, block, true);\n\t\trelease_cell = false;\n\t\tbreak;\n\n\tcase POLICY_NEW:\n\t\tatomic_inc(&cache->stats.promotion);\n\t\tpromote(cache, structs, block, lookup_result.cblock, new_ocell);\n\t\trelease_cell = false;\n\t\tbreak;\n\n\tcase POLICY_REPLACE:\n\t\tatomic_inc(&cache->stats.demotion);\n\t\tatomic_inc(&cache->stats.promotion);\n\t\tdemote_then_promote(cache, structs, lookup_result.old_oblock,\n\t\t\t\t block, lookup_result.cblock,\n\t\t\t\t ool.cell, new_ocell);\n\t\trelease_cell = false;\n\t\tbreak;\n\n\tdefault:\n\t\tDMERR_LIMIT(\"%s: %s: erroring bio, unknown policy op: %u\",\n\t\t\t cache_device_name(cache), __func__,\n\t\t\t (unsigned) lookup_result.op);\n\t\tbio_io_error(bio);\n\t}\n\n\tif (release_cell)\n\t\tcell_defer(cache, new_ocell, false);\n}", "label": 0, "cwe": null, "length": 734 }, { "index": 867147, "code": "cmp_contig(PyObject *self, PyObject *args)\n{\n PyObject *b1, *b2; /* buffer objects */\n Py_buffer v1, v2;\n PyObject *ret;\n int equal = 0;\n\n if (!PyArg_ParseTuple(args, \"OO\", &b1, &b2)) {\n return NULL;\n }\n\n if (PyObject_GetBuffer(b1, &v1, PyBUF_FULL_RO) < 0) {\n PyErr_SetString(PyExc_TypeError,\n \"cmp_contig: first argument does not implement the buffer \"\n \"protocol\");\n return NULL;\n }\n if (PyObject_GetBuffer(b2, &v2, PyBUF_FULL_RO) < 0) {\n PyErr_SetString(PyExc_TypeError,\n \"cmp_contig: second argument does not implement the buffer \"\n \"protocol\");\n PyBuffer_Release(&v1);\n return NULL;\n }\n\n if (!(PyBuffer_IsContiguous(&v1, 'C')&&PyBuffer_IsContiguous(&v2, 'C')) &&\n !(PyBuffer_IsContiguous(&v1, 'F')&&PyBuffer_IsContiguous(&v2, 'F'))) {\n goto result;\n }\n\n /* readonly may differ if created from non-contiguous */\n if (v1.len != v2.len ||\n v1.itemsize != v2.itemsize ||\n v1.ndim != v2.ndim ||\n !fmtcmp(v1.format, v2.format) ||\n !!v1.shape != !!v2.shape ||\n !!v1.strides != !!v2.strides ||\n !!v1.suboffsets != !!v2.suboffsets) {\n goto result;\n }\n\n if ((v1.shape && !arraycmp(v1.shape, v2.shape, NULL, v1.ndim)) ||\n (v1.strides && !arraycmp(v1.strides, v2.strides, v1.shape, v1.ndim)) ||\n (v1.suboffsets && !arraycmp(v1.suboffsets, v2.suboffsets, NULL,\n v1.ndim))) {\n goto result;\n }\n\n if (memcmp((char *)v1.buf, (char *)v2.buf, v1.len) != 0) {\n goto result;\n }\n\n equal = 1;\n\nresult:\n PyBuffer_Release(&v1);\n PyBuffer_Release(&v2);\n\n ret = equal ? Py_True : Py_False; \n Py_INCREF(ret);\n return ret;\n}", "label": 0, "cwe": null, "length": 531 }, { "index": 403757, "code": "format_sexp(ScmPort *out, ScmObj arg,\n ScmObj *params, int nparams,\n int rightalign, int dots, int mode)\n{\n int mincol = 0, colinc = 1, minpad = 0, maxcol = -1, nwritten = 0, i;\n ScmChar padchar = ' ';\n ScmObj tmpout = Scm_MakeOutputStringPort(TRUE);\n ScmString *tmpstr;\n\n if (nparams>0 && SCM_INTP(params[0])) mincol = SCM_INT_VALUE(params[0]);\n if (nparams>1 && SCM_INTP(params[1])) colinc = SCM_INT_VALUE(params[1]);\n if (nparams>2 && SCM_INTP(params[2])) minpad = SCM_INT_VALUE(params[2]);\n if (nparams>3 && SCM_CHARP(params[3])) padchar = SCM_CHAR_VALUE(params[3]);\n if (nparams>4 && SCM_INTP(params[4])) maxcol = SCM_INT_VALUE(params[4]);\n\n if (minpad > 0 && rightalign) {\n for (i=0; i 0) {\n nwritten = Scm_WriteLimited(arg, tmpout, mode, maxcol);\n } else {\n Scm_Write(arg, tmpout, mode);\n }\n if (minpad > 0 && !rightalign) {\n for (i=0; i 0 && nwritten < 0) {\n const char *s = Scm_GetStringContent(tmpstr, NULL, NULL, NULL), *e;\n if (dots && maxcol > 4) {\n e = Scm_StringBodyPosition(SCM_STRING_BODY(tmpstr), maxcol-4);\n Scm_PutzUnsafe(s, (int)(e-s), out);\n Scm_PutzUnsafe(\" ...\", 4, out);\n } else {\n e = Scm_StringBodyPosition(SCM_STRING_BODY(tmpstr), maxcol);\n Scm_PutzUnsafe(s, (int)(e-s), out);\n }\n } else {\n format_pad(out, tmpstr, mincol, colinc, padchar, rightalign);\n }\n}", "label": 0, "cwe": null, "length": 550 }, { "index": 61774, "code": "setup( QString Data, QString WD )\n\t{\n\t\t// First initializing some data.\n\t\tType = \"\";\n\t\tValue = \"\";\n\t\tOptions.clear();\n\n\t\tGpsBabelWorkingDir = WD;\n\t\tif ( Data.startsWith( \" -i \" ) )\n\t\t\t{\n\t\t\t\tDataType = \"Input\";\n\t\t\t\tData.remove( \" -i \" );\n\t\t\t}\n\t\telse if ( Data.startsWith( \" -o \" ) )\n\t\t\t{\n\t\t\t\tDataType = \"Output\";\n\t\t\t\tData.remove( \" -o \" );\n\t\t\t}\n\t\telse if ( Data.startsWith( \" -x \" ) )\n\t\t\t{\n\t\t\t\tDataType = \"Filter\";\n\t\t\t\tData.remove( \" -x \" );\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\t\treturn;\n\t\t\t}\n\t\t// Removing possible whitespace\n\t\tData = Data.trimmed();\n\n\t\t// Splitting Data\n\t\tQRegExp Separators;\n\t\tif ( DataType == \"Input\" || DataType == \"Output\" )\n\t\t\t{\n\t\t\t\t// Splitting the string from right to left\n\t\t\t\t// The rightmost part always is a file or an interface\n\t\t\t\tSeparators.setPattern( \" -[fF] \" );\n\t\t\t\tValue = Data.split( Separators ).at( 1 );\n\t\t\t\tData.remove( Value );\n\t\t\t\tData.remove( Separators );\n\t\t\t\tData = Data.trimmed();\n\n\t\t\t\t// Checking if there is a character set\n\t\t\t\tif ( Data.contains( \" -c \" ) )\n\t\t\t\t\t{\n\t\t\t\t\t\tSeparators.setPattern( \" -c \" );\n\t\t\t\t\t\tCharSet = Data.split( Separators ).at( 1 );\n\t\t\t\t\t\tData.remove( CharSet );\n\t\t\t\t\t\tData.remove( Separators );\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\tCharSet = \"\";\n\t\t\t\t\t}\n\t\t\t}\n\t\t// Removing possibly existing blanks at both ends\n\t\tData = Data.trimmed();\n\n\t\t// That's it for IO specific stuff. The rest is equal for filters, inputs and outputs\n\t\tif ( Data.contains( \",\" ) )\n\t\t\t{\n\t\t\t\tSeparators.setPattern( \",\" );\n\t\t\t\tOptions = Data.split( Separators );\n\t\t\t\t// The first element contains the type\n\t\t\t\tType = Options.at( 0 );\n\t\t\t\t// Removing Type from the options list\n\t\t\t\tOptions.removeAt( 0 );\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\t\tType = Data;\n\t\t\t}\n\t\t// Data has done its job\n\t\tData = \"\";\n\n\t\t// DisplayType is used to feed the first column of the GUI items and is equal for IOs and filters\n\t\t// Currently it equals Type, but future versions will convert DisplayType to something more human readable\n\t\tDisplayType = Type;\n\n\t\t// Determining if this object is a device, which only makes sense in case of IOs\n\t\t// Devices are read from the config file so users are able to add device types manually\n\t\tIsDevice = false;\n\t\tif ( DataType != \"Filter\" )\n\t\t\t{\n\t\t\t\tQStringList DeviceTypes = SettingsManager::instance()->deviceTypes();\n\t\t\t\tfor ( int i = 0; i < DeviceTypes.count(); i++ )\n\t\t\t\t\t{\n\t\t\t\t\t\tif ( DeviceTypes.at( i ) == Type )\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tIsDevice = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t}\n\n\t\t// If \"Value\" doesn't contain an absolute file path (inputs and outputs only, not filters),\n\t\t// prepend the gpsbabel working dir before checking for the file's existence\n\t\t// TODO: Even in filters, file existence should be checked, but it's difficult to determine files => postponed\n\t\tif ( DataType != \"Filter\" )\n\t\t\t{\n\t\t\t\tQFileInfo FileInfo( Value );\n\t\t\t\tif ( !FileInfo.isAbsolute() && !IsDevice )\n\t\t\t\t\t{\n\t\t\t\t\t\t// Even on Windows, paths use \"/\" instead of \"\\\" inside QT\n\t\t\t\t\t\tValue.prepend( \"/\" );\n\t\t\t\t\t\tValue.prepend( GpsBabelWorkingDir );\n\t\t\t\t\t\tFileInfo.setFile( Value );\n\t\t\t\t\t}\n\t\t\t\tFileExists = FileInfo.exists();\n\n\t\t\t\t// Display value is used to feed the second column of the GUI items and is *not* equal for IOs and filters\n\t\t\t\t// For filters it will display the filter options\n\t\t\t\t// For files it will display the file name without its path\n\t\t\t\tif ( !IsDevice )\n\t\t\t\t\t{\n\t\t\t\t\t\tDisplayValue = FileInfo.fileName();\n\t\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\t{\n\t\t\t\t\t\t// This if statement mainly is necessary for Windows because fileName()\n\t\t\t\t\t\t// does treat a colon treat as a path delimiter there.\n\t\t\t\t\t\t// Thus usb:0 gets displayed as \"0\" on Windows\n\t\t\t\t\t\tDisplayValue = Value;\n\t\t\t\t\t}\n\t\t\t}\n\t\telse if ( DataType == \"Filter\" )\n\t\t\t{\n\t\t\t\tDisplayValue = Options.join( \",\" );\n\t\t\t}\n\n\t\tupdateGuiItem();\n\t}", "label": 0, "cwe": null, "length": 1009 }, { "index": 329062, "code": "init_channel_set(struct rtw_adapter *padapter, u8 cplan,\n\t\t\t struct rt_channel_info *c_set)\n{\n\tu8 i, ch_size = 0;\n\tu8 b5GBand = false, b2_4GBand = false;\n\tu8 Index2G = 0, Index5G = 0;\n\n\tmemset(c_set, 0, sizeof(struct rt_channel_info) * MAX_CHANNEL_NUM);\n\n\tif (cplan >= RT_CHANNEL_DOMAIN_MAX &&\n\t cplan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) {\n\t\tDBG_8723A(\"ChannelPlan ID %x error !!!!!\\n\", cplan);\n\t\treturn ch_size;\n\t}\n\n\tif (padapter->registrypriv.wireless_mode & WIRELESS_11G) {\n\t\tb2_4GBand = true;\n\t\tif (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == cplan)\n\t\t\tIndex2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G;\n\t\telse\n\t\t\tIndex2G = RTW_ChannelPlanMap[cplan].Index2G;\n\t}\n\n\tif (padapter->registrypriv.wireless_mode & WIRELESS_11A) {\n\t\tb5GBand = true;\n\t\tif (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == cplan)\n\t\t\tIndex5G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index5G;\n\t\telse\n\t\t\tIndex5G = RTW_ChannelPlanMap[cplan].Index5G;\n\t}\n\n\tif (b2_4GBand) {\n\t\tfor (i = 0; i < RTW_ChannelPlan2G[Index2G].Len; i++) {\n\t\t\tc_set[ch_size].ChannelNum =\n\t\t\t\tRTW_ChannelPlan2G[Index2G].Channel[i];\n\n\t\t\tif ((RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN == cplan) ||\n\t\t\t /* Channel 1~11 is active, and 12~14 is passive */\n\t\t\t RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G == cplan) {\n\t\t\t\tif (c_set[ch_size].ChannelNum >= 1 &&\n\t\t\t\t c_set[ch_size].ChannelNum <= 11)\n\t\t\t\t\tc_set[ch_size].ScanType = SCAN_ACTIVE;\n\t\t\t\telse if (c_set[ch_size].ChannelNum >= 12 &&\n\t\t\t\t\t c_set[ch_size].ChannelNum <= 14)\n\t\t\t\t\tc_set[ch_size].ScanType = SCAN_PASSIVE;\n\t\t\t} else if (RT_CHANNEL_DOMAIN_WORLD_WIDE_13 == cplan ||\n\t\t\t\t RT_CHANNEL_DOMAIN_WORLD_WIDE_5G == cplan ||\n\t\t\t\t RT_CHANNEL_DOMAIN_2G_WORLD == Index2G) {\n\t\t\t\t/* channel 12~13, passive scan */\n\t\t\t\tif (c_set[ch_size].ChannelNum <= 11)\n\t\t\t\t\tc_set[ch_size].ScanType = SCAN_ACTIVE;\n\t\t\t\telse\n\t\t\t\t\tc_set[ch_size].ScanType = SCAN_PASSIVE;\n\t\t\t} else\n\t\t\t\tc_set[ch_size].ScanType = SCAN_ACTIVE;\n\n\t\t\tch_size++;\n\t\t}\n\t}\n\n\tif (b5GBand) {\n\t\tfor (i = 0; i < RTW_ChannelPlan5G[Index5G].Len; i++) {\n\t\t\tif (RTW_ChannelPlan5G[Index5G].Channel[i] <= 48 ||\n\t\t\t RTW_ChannelPlan5G[Index5G].Channel[i] >= 149) {\n\t\t\t\tc_set[ch_size].ChannelNum =\n\t\t\t\t\tRTW_ChannelPlan5G[Index5G].Channel[i];\n\t\t\t\tif (RT_CHANNEL_DOMAIN_WORLD_WIDE_5G == cplan) {\n\t\t\t\t\t/* passive scan for all 5G channels */\n\t\t\t\t\tc_set[ch_size].ScanType =\n\t\t\t\t\t\tSCAN_PASSIVE;\n\t\t\t\t} else\n\t\t\t\t\tc_set[ch_size].ScanType =\n\t\t\t\t\t\tSCAN_ACTIVE;\n\t\t\t\tDBG_8723A(\"%s(): channel_set[%d].ChannelNum = \"\n\t\t\t\t\t \"%d\\n\", __func__, ch_size,\n\t\t\t\t\t c_set[ch_size].ChannelNum);\n\t\t\t\tch_size++;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn ch_size;\n}", "label": 0, "cwe": null, "length": 836 }, { "index": 100163, "code": "ibnd_discover_fabric(char * ca_name, int ca_port,\n\t\t\t\t ib_portid_t * from,\n\t\t\t\t struct ibnd_config *cfg)\n{\n\tstruct ibnd_config config = { 0 };\n\tibnd_fabric_t *fabric = NULL;\n\tib_portid_t my_portid = { 0 };\n\tsmp_engine_t engine;\n\tibnd_scan_t scan;\n\tint nc = 2;\n\tint mc[2] = { IB_SMI_CLASS, IB_SMI_DIRECT_CLASS };\n\n\t/* If not specified start from \"my\" port */\n\tif (!from)\n\t\tfrom = &my_portid;\n\n\tif (set_config(&config, cfg)) {\n\t\tIBND_ERROR(\"Invalid ibnd_config\\n\");\n\t\treturn NULL;\n\t}\n\n\tfabric = calloc(1, sizeof(*fabric));\n\tif (!fabric) {\n\t\tIBND_ERROR(\"OOM: failed to calloc ibnd_fabric_t\\n\");\n\t\treturn NULL;\n\t}\n\n\tmemset(fabric, 0, sizeof(*fabric));\n\n\tmemset(&scan.selfportid, 0, sizeof(scan.selfportid));\n\tscan.fabric = fabric;\n\tscan.cfg = &config;\n\tscan.initial_hops = from->drpath.cnt;\n\n\tif (smp_engine_init(&engine, ca_name, ca_port, &scan, &config)) {\n\t\tfree(fabric);\n\t\treturn (NULL);\n\t}\n\n\tscan.ibmad_port = mad_rpc_open_port(ca_name, ca_port, mc, nc);\n\tif (!scan.ibmad_port) {\n\t\tIBND_ERROR(\"can't open MAD port (%s:%d)\\n\", ca_name, ca_port);\n\t\tsmp_engine_destroy(&engine);\n\t\treturn (NULL);\n\t}\n\tmad_rpc_set_timeout(scan.ibmad_port, cfg->timeout_ms);\n\tmad_rpc_set_retries(scan.ibmad_port, cfg->retries);\n\tsmp_mkey_set(scan.ibmad_port, cfg->mkey);\n\n\tIBND_DEBUG(\"from %s\\n\", portid2str(from));\n\n\tif (!query_node_info(&engine, from, NULL))\n\t\tif (process_mads(&engine) != 0)\n\t\t\tgoto error;\n\n\tfabric->total_mads_used = engine.total_smps;\n\tfabric->maxhops_discovered += scan.initial_hops;\n\n\tif (group_nodes(fabric))\n\t\tgoto error;\n\n\tsmp_engine_destroy(&engine);\n\tmad_rpc_close_port(scan.ibmad_port);\n\treturn fabric;\nerror:\n\tsmp_engine_destroy(&engine);\n\tmad_rpc_close_port(scan.ibmad_port);\n\tibnd_destroy_fabric(fabric);\n\treturn NULL;\n}", "label": 0, "cwe": null, "length": 532 }, { "index": 267499, "code": "uwb_est_get_size(struct uwb_rc *uwb_rc, struct uwb_est *est,\n\t\t\t u8 event_low, const struct uwb_rceb *rceb,\n\t\t\t size_t rceb_size)\n{\n\tunsigned offset;\n\tssize_t size;\n\tstruct device *dev = &uwb_rc->uwb_dev.dev;\n\tconst struct uwb_est_entry *entry;\n\n\tsize = -ENOENT;\n\tif (event_low >= est->entries) {\t/* in range? */\n\t\tdev_err(dev, \"EST %p 0x%04x/%04x/%04x[%u]: event %u out of range\\n\",\n\t\t\test, est->type_event_high, est->vendor, est->product,\n\t\t\test->entries, event_low);\n\t\tgoto out;\n\t}\n\tsize = -ENOENT;\n\tentry = &est->entry[event_low];\n\tif (entry->size == 0 && entry->offset == 0) {\t/* unknown? */\n\t\tdev_err(dev, \"EST %p 0x%04x/%04x/%04x[%u]: event %u unknown\\n\",\n\t\t\test, est->type_event_high, est->vendor,\test->product,\n\t\t\test->entries, event_low);\n\t\tgoto out;\n\t}\n\toffset = entry->offset;\t/* extra fries with that? */\n\tif (offset == 0)\n\t\tsize = entry->size;\n\telse {\n\t\t/* Ops, got an extra size field at 'offset'--read it */\n\t\tconst void *ptr = rceb;\n\t\tsize_t type_size = 0;\n\t\toffset--;\n\t\tsize = -ENOSPC;\t\t\t/* enough data for more? */\n\t\tswitch (entry->type) {\n\t\tcase UWB_EST_16: type_size = sizeof(__le16); break;\n\t\tcase UWB_EST_8: type_size = sizeof(u8); break;\n\t\tdefault: \t BUG();\n\t\t}\n\t\tif (offset + type_size > rceb_size) {\n\t\t\tdev_err(dev, \"EST %p 0x%04x/%04x/%04x[%u]: \"\n\t\t\t\t\"not enough data to read extra size\\n\",\n\t\t\t\test, est->type_event_high, est->vendor,\n\t\t\t\test->product, est->entries);\n\t\t\tgoto out;\n\t\t}\n\t\tsize = entry->size;\n\t\tptr += offset;\n\t\tswitch (entry->type) {\n\t\tcase UWB_EST_16: size += le16_to_cpu(*(__le16 *)ptr); break;\n\t\tcase UWB_EST_8: size += *(u8 *)ptr; break;\n\t\tdefault: \t BUG();\n\t\t}\n\t}\nout:\n\treturn size;\n}", "label": 0, "cwe": null, "length": 569 }, { "index": 326538, "code": "smm665_read_adc(struct smm665_data *data, int adc)\n{\n\tstruct i2c_client *client = data->cmdreg;\n\tint rv;\n\tint radc;\n\n\t/*\n\t * Algorithm for reading ADC, per SMM665 datasheet\n\t *\n\t * {[S][addr][W][Ack]} {[offset][Ack]} {[S][addr][R][Nack]}\n\t * [wait conversion time]\n\t * {[S][addr][R][Ack]} {[datahi][Ack]} {[datalo][Ack][P]}\n\t *\n\t * To implement the first part of this exchange,\n\t * do a full read transaction and expect a failure/Nack.\n\t * This sets up the address pointer on the SMM665\n\t * and starts the ADC conversion.\n\t * Then do a two-byte read transaction.\n\t */\n\trv = i2c_smbus_read_byte_data(client, adc << 3);\n\tif (rv != -ENXIO) {\n\t\t/*\n\t\t * We expect ENXIO to reflect NACK\n\t\t * (per Documentation/i2c/fault-codes).\n\t\t * Everything else is an error.\n\t\t */\n\t\tdev_dbg(&client->dev,\n\t\t\t\"Unexpected return code %d when setting ADC index\", rv);\n\t\treturn (rv < 0) ? rv : -EIO;\n\t}\n\n\tudelay(data->conversion_time);\n\n\t/*\n\t * Now read two bytes.\n\t *\n\t * Neither i2c_smbus_read_byte() nor\n\t * i2c_smbus_read_block_data() worked here,\n\t * so use i2c_smbus_read_word_swapped() instead.\n\t * We could also try to use i2c_master_recv(),\n\t * but that is not always supported.\n\t */\n\trv = i2c_smbus_read_word_swapped(client, 0);\n\tif (rv < 0) {\n\t\tdev_dbg(&client->dev, \"Failed to read ADC value: error %d\", rv);\n\t\treturn rv;\n\t}\n\t/*\n\t * Validate/verify readback adc channel (in bit 11..14).\n\t */\n\tradc = (rv >> 11) & 0x0f;\n\tif (radc != adc) {\n\t\tdev_dbg(&client->dev, \"Unexpected RADC: Expected %d got %d\",\n\t\t\tadc, radc);\n\t\treturn -EIO;\n\t}\n\n\treturn rv & SMM665_ADC_MASK;\n}", "label": 0, "cwe": null, "length": 515 }, { "index": 316211, "code": "mapif_parse_GuildCastleDataSave(int fd,int castle_id,int idx,int value)\n{\n\tstruct guild_castle *gc;\n\n\tif(castle_id < 0 || castle_id >= MAX_GUILDCASTLE) {\n\t\treturn mapif_guild_castle_datasave(castle_id,idx,value);\n\t}\n\tgc = &castle_db[castle_id];\n\n\tswitch(idx){\n\t\tcase 1:\n\t\t\tif( gc->guild_id != value ) {\n\t\t\t\tinterlog_log(\n\t\t\t\t\t\"guild id=%d %s castle id=%d\",\n\t\t\t\t\t((value)? value: gc->guild_id), ((value)? \"occupy\": \"abandon\"), idx\n\t\t\t\t);\n\t\t\t}\n\t\t\tgc->guild_id = value;\n\t\t\tbreak;\n\t\tcase 2: gc->economy = value; break;\n\t\tcase 3: gc->defense = value; break;\n\t\tcase 4: gc->triggerE = value; break;\n\t\tcase 5: gc->triggerD = value; break;\n\t\tcase 6: gc->nextTime = value; break;\n\t\tcase 7: gc->payTime = value; break;\n\t\tcase 8: gc->createTime = value; break;\n\t\tcase 9: gc->visibleC = value; break;\n\t\tcase 10: gc->guardian[0].visible = value; break;\n\t\tcase 11: gc->guardian[1].visible = value; break;\n\t\tcase 12: gc->guardian[2].visible = value; break;\n\t\tcase 13: gc->guardian[3].visible = value; break;\n\t\tcase 14: gc->guardian[4].visible = value; break;\n\t\tcase 15: gc->guardian[5].visible = value; break;\n\t\tcase 16: gc->guardian[6].visible = value; break;\n\t\tcase 17: gc->guardian[7].visible = value; break;\n\t\tdefault:\n\t\t\tprintf(\"mapif_parse_GuildCastleDataSave ERROR!! (Not found index=%d)\\n\", idx);\n\t\t\treturn 0;\n\t}\n#if defined(TXT_ONLY) && defined(TXT_JOURNAL)\n\tif( guildcastle_journal_enable )\n\t\tjournal_write( &guildcastle_journal, gc->castle_id, gc );\n#endif\n\treturn mapif_guild_castle_datasave(gc->castle_id,idx,value);\n}", "label": 0, "cwe": null, "length": 514 }, { "index": 118840, "code": "neb2_skip_render(object *objp, float z_depth)\n{\n\tfloat fog_near, fog_far;\n\n\t// if we're never skipping\n\tif (!neb_skip_opt) {\n\t\treturn 0;\n\t}\n\n\t// lame rendering\n\tif (Neb2_render_mode == NEB2_RENDER_LAME) {\n\t\treturn 0;\n\t}\n\n\t// get near and far fog values based upon object type and rendering mode\n\tneb2_get_adjusted_fog_values(&fog_near, &fog_far, objp);\n\n\t// by object type\n\tswitch( objp->type ) {\n\t// some objects we always render\n\t\tcase OBJ_SHOCKWAVE:\n\t\tcase OBJ_JUMP_NODE:\n\t\tcase OBJ_NONE:\n\t\tcase OBJ_GHOST:\n\t\tcase OBJ_BEAM:\n\t\tcase OBJ_WAYPOINT:\n\t\treturn 0;\n\n\t\t// any weapon over 500 meters away\n\t\t// Use the \"far\" distance multiplier here\n\t\tcase OBJ_WEAPON:\n\t\t\tif (z_depth >= 500.0f * Neb2_fog_far_mult) {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tbreak;\n\n\t\t// any small ship over the fog limit, or any cruiser 50% further than the fog limit\n\t\tcase OBJ_SHIP:\n\t\t\tship_info *sip;\n\t\t\tif ( (objp->instance >= 0) && (Ships[objp->instance].ship_info_index >= 0) ) {\n\t\t\t\tsip = &Ship_info[Ships[objp->instance].ship_info_index];\n\t\t\t} else {\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\t// small ships over the fog limit by a small factor\n\t\t\tif ( (sip->flags & SIF_SMALL_SHIP) && (z_depth >= (fog_far * 1.5f)) ) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// big ships\n\t\t\tif ( (sip->flags & SIF_BIG_SHIP) && (z_depth >= (fog_far * 2.0f)) ) {\n\t\t\t\treturn 1;\n\t\t\t}\n\n\t\t\t// huge ships\n\t\t\tif ( (sip->flags & SIF_HUGE_SHIP) && (z_depth >= (fog_far * 3.0f)) ) {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tbreak;\n\n\t\t// any fireball over the fog limit for small ships\n\t\tcase OBJ_FIREBALL:\n\t\t\treturn 0;\n\t\t\tbreak;\n\n\t\t// any debris over the fog limit for small ships\n\t\tcase OBJ_DEBRIS:\n\t\t\treturn 0;\n\t\t\tbreak;\n\n\t\t// any asteroids 50% farther than the fog limit for small ships\n\t\tcase OBJ_ASTEROID:\n\t\t\tif (z_depth >= (fog_far * 1.5f)) {\n\t\t\t\treturn 1;\n\t\t\t}\n\t\t\tbreak;\n\n\t\t// hmmm. unknown object type - should probably let it through\n\t\tdefault:\n\t\t\tInt3();\n\t\treturn 0;\n\t}\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 629 }, { "index": 878622, "code": "Browser_Tree_Rename_Directory (const gchar *last_path, const gchar *new_path)\n{\n\n gchar **textsplit;\n gint i;\n GtkTreeIter iter;\n GtkTreePath *childpath;\n GtkTreePath *parentpath;\n gchar *new_basename;\n gchar *new_basename_utf8;\n gchar *path;\n\n if (!last_path || !new_path)\n return;\n\n /*\n * Find the existing tree entry\n */\n textsplit = g_strsplit(last_path, G_DIR_SEPARATOR_S, 0);\n\n#ifdef G_OS_WIN32\n if (!Browser_Win32_Get_Drive_Root(textsplit[0], &iter, &parentpath))\n return;\n#else /* !G_OS_WIN32 */\n parentpath = gtk_tree_path_new_first();\n#endif /* !G_OS_WIN32 */\n\n for (i = 1; textsplit[i] != NULL; i++)\n {\n gboolean valid = gtk_tree_model_get_iter (GTK_TREE_MODEL (directoryTreeModel),\n &iter, parentpath);\n if (valid)\n {\n childpath = Find_Child_Node (&iter, textsplit[i]);\n }\n else\n {\n childpath = NULL;\n }\n\n if (childpath == NULL)\n {\n // ERROR! Could not find it!\n gchar *text_utf8 = filename_to_display(textsplit[i]);\n Log_Print(LOG_ERROR,_(\"Error: Searching for %s, could not find node %s in tree.\"), last_path, text_utf8);\n g_strfreev(textsplit);\n g_free(text_utf8);\n return;\n }\n gtk_tree_path_free(parentpath);\n parentpath = childpath;\n }\n\n gtk_tree_model_get_iter(GTK_TREE_MODEL(directoryTreeModel), &iter, parentpath);\n gtk_tree_path_free(parentpath);\n\n /* Rename the on-screen node */\n new_basename = g_path_get_basename(new_path);\n new_basename_utf8 = filename_to_display(new_basename);\n gtk_tree_store_set(directoryTreeModel, &iter,\n TREE_COLUMN_DIR_NAME, new_basename_utf8,\n TREE_COLUMN_FULL_PATH, new_path,\n -1);\n\n /* Update fullpath of child nodes */\n Browser_Tree_Handle_Rename(&iter, last_path, new_path);\n\n /* Update the variable of the current path */\n path = Browser_Tree_Get_Path_Of_Selected_Node();\n Browser_Update_Current_Path(path);\n g_free(path);\n\n g_strfreev(textsplit);\n g_free(new_basename);\n g_free(new_basename_utf8);\n}", "label": 0, "cwe": null, "length": 531 }, { "index": 55222, "code": "btrescan(PG_FUNCTION_ARGS)\n{\n\tIndexScanDesc scan = (IndexScanDesc) PG_GETARG_POINTER(0);\n\tScanKey\t\tscankey = (ScanKey) PG_GETARG_POINTER(1);\n\n\t/* remaining arguments are ignored */\n\tBTScanOpaque so = (BTScanOpaque) scan->opaque;\n\n\t/* we aren't holding any read locks, but gotta drop the pins */\n\tif (BTScanPosIsValid(so->currPos))\n\t{\n\t\t/* Before leaving current page, deal with any killed items */\n\t\tif (so->numKilled > 0)\n\t\t\t_bt_killitems(scan);\n\t\tBTScanPosUnpinIfPinned(so->currPos);\n\t\tBTScanPosInvalidate(so->currPos);\n\t}\n\n\tso->markItemIndex = -1;\n\tBTScanPosUnpinIfPinned(so->markPos);\n\tBTScanPosInvalidate(so->markPos);\n\n\t/*\n\t * Allocate tuple workspace arrays, if needed for an index-only scan and\n\t * not already done in a previous rescan call. To save on palloc\n\t * overhead, both workspaces are allocated as one palloc block; only this\n\t * function and btendscan know that.\n\t *\n\t * NOTE: this data structure also makes it safe to return data from a\n\t * \"name\" column, even though btree name_ops uses an underlying storage\n\t * datatype of cstring. The risk there is that \"name\" is supposed to be\n\t * padded to NAMEDATALEN, but the actual index tuple is probably shorter.\n\t * However, since we only return data out of tuples sitting in the\n\t * currTuples array, a fetch of NAMEDATALEN bytes can at worst pull some\n\t * data out of the markTuples array --- running off the end of memory for\n\t * a SIGSEGV is not possible. Yeah, this is ugly as sin, but it beats\n\t * adding special-case treatment for name_ops elsewhere.\n\t */\n\tif (scan->xs_want_itup && so->currTuples == NULL)\n\t{\n\t\tso->currTuples = (char *) palloc(BLCKSZ * 2);\n\t\tso->markTuples = so->currTuples + BLCKSZ;\n\t}\n\n\t/*\n\t * Reset the scan keys. Note that keys ordering stuff moved to _bt_first.\n\t * - vadim 05/05/97\n\t */\n\tif (scankey && scan->numberOfKeys > 0)\n\t\tmemmove(scan->keyData,\n\t\t\t\tscankey,\n\t\t\t\tscan->numberOfKeys * sizeof(ScanKeyData));\n\tso->numberOfKeys = 0;\t\t/* until _bt_preprocess_keys sets it */\n\n\t/* If any keys are SK_SEARCHARRAY type, set up array-key info */\n\t_bt_preprocess_array_keys(scan);\n\n\tPG_RETURN_VOID();\n}", "label": 0, "cwe": null, "length": 614 }, { "index": 689653, "code": "gt_snpper_runner(GT_UNUSED int argc, const char **argv,\n int parsed_args, void *tool_arguments,\n GtError *err)\n{\n GtNodeStream *gff3_in_stream = NULL,\n *gvf_in_stream = NULL,\n *gvf_out_stream = NULL,\n *snp_annotator_stream = NULL;\n GtSnpperArguments *arguments = tool_arguments;\n GtRegionMapping *region_mapping = NULL;\n GtTransTable *tt = NULL;\n int had_err = 0;\n\n gt_error_check(err);\n gt_assert(arguments);\n\n if (!(tt = gt_trans_table_new(arguments->ttable, err)))\n had_err = -1;\n\n if (!had_err) {\n /* create GFF3 input stream */\n gff3_in_stream = gt_gff3_in_stream_new_sorted(argv[parsed_args]);\n if (!gff3_in_stream)\n had_err = -1;\n }\n\n if (!had_err) {\n /* create GVF input stream */\n gvf_in_stream = gt_gff3_in_stream_new_sorted(argv[parsed_args+1]);\n if (!gvf_in_stream)\n had_err = -1;\n }\n\n if (!had_err) {\n /* create region mapping */\n region_mapping = gt_seqid2file_region_mapping_new(arguments->s2fi, err);\n if (!region_mapping)\n had_err = -1;\n }\n\n if (!had_err) {\n gt_assert(tt);\n snp_annotator_stream = gt_snp_annotator_stream_new(gvf_in_stream,\n gff3_in_stream,\n tt,\n region_mapping);\n if (!snp_annotator_stream)\n had_err = -1;\n }\n\n if (!had_err) {\n gvf_out_stream = gt_gff3_out_stream_new(snp_annotator_stream,\n arguments->outfp);\n if (!gvf_out_stream)\n had_err = -1;\n }\n\n if (!had_err) {\n /* pull the features through the stream and free them afterwards */\n had_err = gt_node_stream_pull(gvf_out_stream, err);\n }\n\n /* free */\n gt_node_stream_delete(snp_annotator_stream);\n gt_node_stream_delete(gff3_in_stream);\n gt_node_stream_delete(gvf_in_stream);\n gt_node_stream_delete(gvf_out_stream);\n gt_trans_table_delete(tt);\n gt_region_mapping_delete(region_mapping);\n\n return had_err;\n}", "label": 0, "cwe": null, "length": 528 }, { "index": 876405, "code": "soc_resume_deferred(struct work_struct *work)\n{\n\tstruct snd_soc_card *card =\n\t\t\tcontainer_of(work, struct snd_soc_card, deferred_resume_work);\n\tstruct snd_soc_codec *codec;\n\tint i, j;\n\n\t/* our power state is still SNDRV_CTL_POWER_D3hot from suspend time,\n\t * so userspace apps are blocked from touching us\n\t */\n\n\tdev_dbg(card->dev, \"ASoC: starting resume work\\n\");\n\n\t/* Bring us up into D2 so that DAPM starts enabling things */\n\tsnd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D2);\n\n\tif (card->resume_pre)\n\t\tcard->resume_pre(card);\n\n\t/* resume control bus DAIs */\n\tfor (i = 0; i < card->num_rtd; i++) {\n\t\tstruct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;\n\n\t\tif (card->rtd[i].dai_link->ignore_suspend)\n\t\t\tcontinue;\n\n\t\tif (cpu_dai->driver->resume && cpu_dai->driver->bus_control)\n\t\t\tcpu_dai->driver->resume(cpu_dai);\n\t}\n\n\tlist_for_each_entry(codec, &card->codec_dev_list, card_list) {\n\t\tif (codec->suspended) {\n\t\t\tif (codec->driver->resume)\n\t\t\t\tcodec->driver->resume(codec);\n\t\t\tcodec->suspended = 0;\n\t\t}\n\t}\n\n\tfor (i = 0; i < card->num_rtd; i++) {\n\n\t\tif (card->rtd[i].dai_link->ignore_suspend)\n\t\t\tcontinue;\n\n\t\tsnd_soc_dapm_stream_event(&card->rtd[i],\n\t\t\t\t\t SNDRV_PCM_STREAM_PLAYBACK,\n\t\t\t\t\t SND_SOC_DAPM_STREAM_RESUME);\n\n\t\tsnd_soc_dapm_stream_event(&card->rtd[i],\n\t\t\t\t\t SNDRV_PCM_STREAM_CAPTURE,\n\t\t\t\t\t SND_SOC_DAPM_STREAM_RESUME);\n\t}\n\n\t/* unmute any active DACs */\n\tfor (i = 0; i < card->num_rtd; i++) {\n\n\t\tif (card->rtd[i].dai_link->ignore_suspend)\n\t\t\tcontinue;\n\n\t\tfor (j = 0; j < card->rtd[i].num_codecs; j++) {\n\t\t\tstruct snd_soc_dai *dai = card->rtd[i].codec_dais[j];\n\t\t\tstruct snd_soc_dai_driver *drv = dai->driver;\n\n\t\t\tif (drv->ops->digital_mute && dai->playback_active)\n\t\t\t\tdrv->ops->digital_mute(dai, 0);\n\t\t}\n\t}\n\n\tfor (i = 0; i < card->num_rtd; i++) {\n\t\tstruct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai;\n\n\t\tif (card->rtd[i].dai_link->ignore_suspend)\n\t\t\tcontinue;\n\n\t\tif (cpu_dai->driver->resume && !cpu_dai->driver->bus_control)\n\t\t\tcpu_dai->driver->resume(cpu_dai);\n\t}\n\n\tif (card->resume_post)\n\t\tcard->resume_post(card);\n\n\tdev_dbg(card->dev, \"ASoC: resume work completed\\n\");\n\n\t/* Recheck all endpoints too, their state is affected by suspend */\n\tdapm_mark_endpoints_dirty(card);\n\tsnd_soc_dapm_sync(&card->dapm);\n\n\t/* userspace can access us now we are back as we were before */\n\tsnd_power_change_state(card->snd_card, SNDRV_CTL_POWER_D0);\n}", "label": 0, "cwe": null, "length": 742 }, { "index": 717698, "code": "OnTreeItemDoubleClick(wxTreeEvent& event)\n{\n wxTreeCtrl* wx_tree = (wxTreeCtrl*)event.GetEventObject();\n if (!wx_tree || !m_Parser)\n return;\n\n wxTreeItemId id = event.GetItem();\n CCTreeCtrlData* ctd = (CCTreeCtrlData*)wx_tree->GetItemData(id);\n if (ctd && ctd->m_Token)\n {\n if (wxGetKeyState(WXK_CONTROL) && wxGetKeyState(WXK_SHIFT))\n {\n// TokenTree* tree = m_Parser->GetTokenTree(); // the one used inside CCDebugInfo\n\n CC_LOCKER_TRACK_TT_MTX_LOCK(s_TokenTreeMutex)\n\n CCDebugInfo info(wx_tree, m_Parser, ctd->m_Token);\n info.ShowModal();\n\n CC_LOCKER_TRACK_TT_MTX_UNLOCK(s_TokenTreeMutex)\n\n return;\n }\n\n bool toImp = false;\n switch (ctd->m_Token->m_TokenKind)\n {\n case tkConstructor:\n case tkDestructor:\n case tkFunction:\n if (ctd->m_Token->m_ImplLine != 0 && !ctd->m_Token->GetImplFilename().IsEmpty())\n toImp = true;\n break;\n case tkNamespace:\n case tkClass:\n case tkEnum:\n case tkTypedef:\n case tkVariable:\n case tkEnumerator:\n case tkPreprocessor:\n case tkMacro:\n case tkAnyContainer:\n case tkAnyFunction:\n case tkUndefined:\n default:\n break;\n }\n\n wxFileName fname;\n if (toImp)\n fname.Assign(ctd->m_Token->GetImplFilename());\n else\n fname.Assign(ctd->m_Token->GetFilename());\n\n cbProject* project = nullptr;\n if (!m_NativeParser->IsParserPerWorkspace())\n project = m_NativeParser->GetProjectByParser(m_Parser);\n else\n project = m_NativeParser->GetCurrentProject();\n\n wxString base;\n if (project)\n {\n base = project->GetBasePath();\n NormalizePath(fname, base);\n }\n else\n {\n const wxArrayString& incDirs = m_Parser->GetIncludeDirs();\n for (size_t i = 0; i < incDirs.GetCount(); ++i)\n {\n if (NormalizePath(fname, incDirs.Item(i)))\n break;\n }\n }\n\n cbEditor* ed = Manager::Get()->GetEditorManager()->Open(fname.GetFullPath());\n if (ed)\n {\n int line;\n if (toImp)\n line = ctd->m_Token->m_ImplLine - 1;\n else\n line = ctd->m_Token->m_Line - 1;\n\n ed->GotoTokenPosition(line, ctd->m_Token->m_Name);\n }\n }\n}", "label": 0, "cwe": null, "length": 624 }, { "index": 355031, "code": "jump_cond_integer(const char *label, int cond, int distance)\n{\n bool reverse = false;\n\n if (stack > 1)\n {\n fprintf(out, \"; jump_cond_integer\\n\");\n fprintf(out, \" inx\\n\");\n fprintf(out, \" inx\\n\");\n fprintf(out, \" txa\\n\");\n fprintf(out, \" tay\\n\");\n\n if(cond == COND_LESS_EQUAL)\n {\n reverse = true;\n cond = COND_GREATER_EQUAL;\n }\n else\n if(cond == COND_GREATER)\n {\n reverse = true;\n cond = COND_LESS;\n }\n\n switch(cond)\n {\n case COND_EQUAL:\n fprintf(out, \" lda stack_lo - 0,y\\n\");\n fprintf(out, \" cmp stack_lo - 1,y\\n\");\n fprintf(out, \" bne #11\\n\");\n fprintf(out, \" lda stack_hi - 0,y\\n\");\n fprintf(out, \" cmp stack_hi - 1,y\\n\");\n fprintf(out, \" bne #3\\n\");\n fprintf(out, \" jmp %s\\n\", label);\n break;\n case COND_NOT_EQUAL:\n fprintf(out, \" lda stack_lo - 0,y\\n\");\n fprintf(out, \" cmp stack_lo - 1,y\\n\");\n fprintf(out, \" bne #8\\n\");\n fprintf(out, \" lda stack_hi - 0,y\\n\");\n fprintf(out, \" cmp stack_hi - 1,y\\n\");\n fprintf(out, \" beq #3\\n\");\n fprintf(out, \" jmp %s\\n\", label);\n break;\n case COND_LESS:\n if(reverse == false)\n {\n fprintf(out, \" lda stack_lo - 0,y\\n\");\n fprintf(out, \" cmp stack_lo - 1,y\\n\");\n fprintf(out, \" lda stack_hi - 0,y\\n\");\n fprintf(out, \" sbc stack_hi - 1,y\\n\");\n fprintf(out, \" bvc #2\\n\");\n fprintf(out, \" eor #0x80\\n\");\n fprintf(out, \" bpl #3\\n\");\n fprintf(out, \" jmp %s\\n\", label);\n }\n else\n {\n fprintf(out, \" lda stack_lo - 1,y\\n\");\n fprintf(out, \" cmp stack_lo - 0,y\\n\");\n fprintf(out, \" lda stack_hi - 1,y\\n\");\n fprintf(out, \" sbc stack_hi - 0,y\\n\");\n fprintf(out, \" bvc #2\\n\");\n fprintf(out, \" eor #0x80\\n\");\n fprintf(out, \" bpl #3\\n\");\n fprintf(out, \" jmp %s\\n\", label);\n }\n break;\n case COND_GREATER_EQUAL:\n if(reverse == false)\n {\n fprintf(out, \" lda stack_lo - 0,y\\n\");\n fprintf(out, \" cmp stack_lo - 1,y\\n\");\n fprintf(out, \" lda stack_hi - 0,y\\n\");\n fprintf(out, \" sbc stack_hi - 1,y\\n\");\n fprintf(out, \" bvc #2\\n\");\n fprintf(out, \" eor #0x80\\n\");\n fprintf(out, \" bmi #3\\n\");\n fprintf(out, \" jmp %s\\n\", label);\n }\n else\n {\n fprintf(out, \" lda stack_lo - 1,y\\n\");\n fprintf(out, \" cmp stack_lo - 0,y\\n\");\n fprintf(out, \" lda stack_hi - 1,y\\n\");\n fprintf(out, \" sbc stack_hi - 0,y\\n\");\n fprintf(out, \" bvc #2\\n\");\n fprintf(out, \" eor #0x80\\n\");\n fprintf(out, \" bmi #3\\n\");\n fprintf(out, \" jmp %s\\n\", label);\n }\n break;\n }\n\n stack -= 2;\n }\n\n return 0;\n}", "label": 0, "cwe": null, "length": 871 }, { "index": 117800, "code": "read_stackstate(dest_t *dest, glui32 chunklen, int portable)\n{\n glui32 res;\n glui32 frameend, frm, frm2, frm3, locpos, frlen, numlocals;\n\n if (chunklen > stacksize)\n return 1;\n\n stackptr = chunklen;\n frameptr = 0;\n valstackbase = 0;\n localsbase = 0;\n\n if (!portable) {\n res = read_buffer(dest, stack, stackptr);\n if (res)\n return res;\n return 0;\n }\n\n /* This isn't going to be pleasant; we're going to read the data in\n as a block, and then convert it in-place. */\n res = read_buffer(dest, stack, stackptr);\n if (res)\n return res;\n\n frameend = stackptr;\n while (frameend != 0) {\n /* Read the beginning-of-frame pointer. Remember, right now, the\n whole frame is stored big-endian. So we have to read with the\n Read*() macros, and then write with the StkW*() macros. */\n frm = Read4(stack+(frameend-4));\n\n frm2 = frm;\n\n frlen = Read4(stack+frm2);\n StkW4(frm2, frlen);\n frm2 += 4;\n locpos = Read4(stack+frm2);\n StkW4(frm2, locpos);\n frm2 += 4;\n\n /* The locals-format list is in bytes, so we don't have to convert it. */\n frm3 = frm2;\n frm2 = frm+locpos;\n\n numlocals = 0;\n\n while (1) {\n unsigned char loctype, loccount;\n loctype = Read1(stack+frm3);\n frm3 += 1;\n loccount = Read1(stack+frm3);\n frm3 += 1;\n\n if (loctype == 0 && loccount == 0)\n break;\n\n /* Skip up to 0, 1, or 3 bytes of padding, depending on loctype. */\n while (frm2 & (loctype-1)) {\n StkW1(frm2, 0);\n frm2++;\n }\n \n /* Convert this set of locals. */\n switch (loctype) {\n \n case 1:\n do {\n /* Don't need to convert bytes. */\n frm2 += 1;\n loccount--;\n } while (loccount);\n break;\n\n case 2:\n do {\n glui16 loc = Read2(stack+frm2);\n StkW2(frm2, loc);\n frm2 += 2;\n loccount--;\n } while (loccount);\n break;\n\n case 4:\n do {\n glui32 loc = Read4(stack+frm2);\n StkW4(frm2, loc);\n frm2 += 4;\n loccount--;\n } while (loccount);\n break;\n\n }\n\n numlocals++;\n }\n\n if ((numlocals & 1) == 0) {\n StkW1(frm3, 0);\n frm3++;\n StkW1(frm3, 0);\n frm3++;\n }\n\n if (frm3 != frm+locpos) {\n return 1;\n }\n\n while (frm2 & 3) {\n StkW1(frm2, 0);\n frm2++;\n }\n\n if (frm2 != frm+frlen) {\n return 1;\n }\n\n /* Now, the values pushed on the stack after the call frame itself.\n This includes the stub. */\n while (frm2 < frameend) {\n glui32 loc = Read4(stack+frm2);\n StkW4(frm2, loc);\n frm2 += 4;\n }\n\n frameend = frm;\n }\n\n return 0;\n}", "label": 0, "cwe": null, "length": 859 }, { "index": 787848, "code": "cx18_av_set_fmt(struct v4l2_subdev *sd,\n\t\tstruct v4l2_subdev_pad_config *cfg,\n\t\tstruct v4l2_subdev_format *format)\n{\n\tstruct v4l2_mbus_framefmt *fmt = &format->format;\n\tstruct cx18_av_state *state = to_cx18_av_state(sd);\n\tstruct cx18 *cx = v4l2_get_subdevdata(sd);\n\tint HSC, VSC, Vsrc, Hsrc, filter, Vlines;\n\tint is_50Hz = !(state->std & V4L2_STD_525_60);\n\n\tif (format->pad || fmt->code != MEDIA_BUS_FMT_FIXED)\n\t\treturn -EINVAL;\n\n\tfmt->field = V4L2_FIELD_INTERLACED;\n\tfmt->colorspace = V4L2_COLORSPACE_SMPTE170M;\n\n\tVsrc = (cx18_av_read(cx, 0x476) & 0x3f) << 4;\n\tVsrc |= (cx18_av_read(cx, 0x475) & 0xf0) >> 4;\n\n\tHsrc = (cx18_av_read(cx, 0x472) & 0x3f) << 4;\n\tHsrc |= (cx18_av_read(cx, 0x471) & 0xf0) >> 4;\n\n\t/*\n\t * This adjustment reflects the excess of vactive, set in\n\t * cx18_av_std_setup(), above standard values:\n\t *\n\t * 480 + 1 for 60 Hz systems\n\t * 576 + 3 for 50 Hz systems\n\t */\n\tVlines = fmt->height + (is_50Hz ? 3 : 1);\n\n\t/*\n\t * Invalid height and width scaling requests are:\n\t * 1. width less than 1/16 of the source width\n\t * 2. width greater than the source width\n\t * 3. height less than 1/8 of the source height\n\t * 4. height greater than the source height\n\t */\n\tif ((fmt->width * 16 < Hsrc) || (Hsrc < fmt->width) ||\n\t (Vlines * 8 < Vsrc) || (Vsrc < Vlines)) {\n\t\tCX18_ERR_DEV(sd, \"%dx%d is not a valid size!\\n\",\n\t\t\t fmt->width, fmt->height);\n\t\treturn -ERANGE;\n\t}\n\n\tif (format->which == V4L2_SUBDEV_FORMAT_TRY)\n\t\treturn 0;\n\n\tHSC = (Hsrc * (1 << 20)) / fmt->width - (1 << 20);\n\tVSC = (1 << 16) - (Vsrc * (1 << 9) / Vlines - (1 << 9));\n\tVSC &= 0x1fff;\n\n\tif (fmt->width >= 385)\n\t\tfilter = 0;\n\telse if (fmt->width > 192)\n\t\tfilter = 1;\n\telse if (fmt->width > 96)\n\t\tfilter = 2;\n\telse\n\t\tfilter = 3;\n\n\tCX18_DEBUG_INFO_DEV(sd,\n\t\t\t \"decoder set size %dx%d -> scale %ux%u\\n\",\n\t\t\t fmt->width, fmt->height, HSC, VSC);\n\n\t/* HSCALE=HSC */\n\tcx18_av_write(cx, 0x418, HSC & 0xff);\n\tcx18_av_write(cx, 0x419, (HSC >> 8) & 0xff);\n\tcx18_av_write(cx, 0x41a, HSC >> 16);\n\t/* VSCALE=VSC */\n\tcx18_av_write(cx, 0x41c, VSC & 0xff);\n\tcx18_av_write(cx, 0x41d, VSC >> 8);\n\t/* VS_INTRLACE=1 VFILT=filter */\n\tcx18_av_write(cx, 0x41e, 0x8 | filter);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 843 }, { "index": 16618, "code": "prvListTaskWithinSingleList( TaskStatus_t *pxTaskStatusArray, List_t *pxList, eTaskState eState )\r\n\t{\r\n\tvolatile TCB_t *pxNextTCB, *pxFirstTCB;\r\n\tUBaseType_t uxTask = 0;\r\n\r\n\t\tif( listCURRENT_LIST_LENGTH( pxList ) > ( UBaseType_t ) 0 )\r\n\t\t{\r\n\t\t\tlistGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList );\r\n\r\n\t\t\t/* Populate an TaskStatus_t structure within the\r\n\t\t\tpxTaskStatusArray array for each task that is referenced from\r\n\t\t\tpxList. See the definition of TaskStatus_t in task.h for the\r\n\t\t\tmeaning of each TaskStatus_t structure member. */\r\n\t\t\tdo\r\n\t\t\t{\r\n\t\t\t\tlistGET_OWNER_OF_NEXT_ENTRY( pxNextTCB, pxList );\r\n\r\n\t\t\t\tpxTaskStatusArray[ uxTask ].xHandle = ( TaskHandle_t ) pxNextTCB;\r\n\t\t\t\tpxTaskStatusArray[ uxTask ].pcTaskName = ( const char * ) &( pxNextTCB->pcTaskName [ 0 ] );\r\n\t\t\t\tpxTaskStatusArray[ uxTask ].xTaskNumber = pxNextTCB->uxTCBNumber;\r\n\t\t\t\tpxTaskStatusArray[ uxTask ].eCurrentState = eState;\r\n\t\t\t\tpxTaskStatusArray[ uxTask ].uxCurrentPriority = pxNextTCB->uxPriority;\r\n\r\n\t\t\t\t#if ( INCLUDE_vTaskSuspend == 1 )\r\n\t\t\t\t{\r\n\t\t\t\t\t/* If the task is in the suspended list then there is a chance\r\n\t\t\t\t\tit is actually just blocked indefinitely - so really it should\r\n\t\t\t\t\tbe reported as being in the Blocked state. */\r\n\t\t\t\t\tif( eState == eSuspended )\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\tif( listLIST_ITEM_CONTAINER( &( pxNextTCB->xEventListItem ) ) != NULL )\r\n\t\t\t\t\t\t{\r\n\t\t\t\t\t\t\tpxTaskStatusArray[ uxTask ].eCurrentState = eBlocked;\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t\t#endif /* INCLUDE_vTaskSuspend */\r\n\r\n\t\t\t\t#if ( configUSE_MUTEXES == 1 )\r\n\t\t\t\t{\r\n\t\t\t\t\tpxTaskStatusArray[ uxTask ].uxBasePriority = pxNextTCB->uxBasePriority;\r\n\t\t\t\t}\r\n\t\t\t\t#else\r\n\t\t\t\t{\r\n\t\t\t\t\tpxTaskStatusArray[ uxTask ].uxBasePriority = 0;\r\n\t\t\t\t}\r\n\t\t\t\t#endif\r\n\r\n\t\t\t\t#if ( configGENERATE_RUN_TIME_STATS == 1 )\r\n\t\t\t\t{\r\n\t\t\t\t\tpxTaskStatusArray[ uxTask ].ulRunTimeCounter = pxNextTCB->ulRunTimeCounter;\r\n\t\t\t\t}\r\n\t\t\t\t#else\r\n\t\t\t\t{\r\n\t\t\t\t\tpxTaskStatusArray[ uxTask ].ulRunTimeCounter = 0;\r\n\t\t\t\t}\r\n\t\t\t\t#endif\r\n\r\n\t\t\t\t#if ( portSTACK_GROWTH > 0 )\r\n\t\t\t\t{\r\n\t\t\t\t\tpxTaskStatusArray[ uxTask ].usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( uint8_t * ) pxNextTCB->pxEndOfStack );\r\n\t\t\t\t}\r\n\t\t\t\t#else\r\n\t\t\t\t{\r\n\t\t\t\t\tpxTaskStatusArray[ uxTask ].usStackHighWaterMark = prvTaskCheckFreeStackSpace( ( uint8_t * ) pxNextTCB->pxStack );\r\n\t\t\t\t}\r\n\t\t\t\t#endif\r\n\r\n\t\t\t\tuxTask++;\r\n\r\n\t\t\t} while( pxNextTCB != pxFirstTCB );\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tmtCOVERAGE_TEST_MARKER();\r\n\t\t}\r\n\r\n\t\treturn uxTask;\r\n\t}", "label": 0, "cwe": null, "length": 734 }, { "index": 375196, "code": "tls_read(struct wrap_io *wio, void *buf, size_t size)\n{\n\tstruct gnutella_socket *s = wio->ctx;\n\tssize_t ret;\n\n\tsocket_check(s);\n\tg_assert(socket_uses_tls(s));\n\tg_assert(NULL != buf);\n\tg_assert(size_is_positive(size));\n\n\tif (tls_flush(wio) && !is_temporary_error(errno)) {\n\t\tif (GNET_PROPERTY(tls_debug)) {\n\t\t\tg_warning(\"tls_read: tls_flush(fd=%d) error: %m\", s->file_desc);\n\t\t}\n\t\treturn -1;\n\t}\n\n\tret = gnutls_record_recv(tls_socket_get_session(s), buf, size);\n\tif (ret < 0) {\n\t\tswitch (ret) {\n\t\tcase GNUTLS_E_INTERRUPTED:\n\t\tcase GNUTLS_E_AGAIN:\n\t\t\terrno = VAL_EAGAIN;\n\t\t\tbreak;\n\t\tcase GNUTLS_E_PULL_ERROR:\n\t\tcase GNUTLS_E_PUSH_ERROR:\n\t\t\t/* Logging already done by tls_transport_debug() */\n\t\t\terrno = (SOCK_F_CONNRESET & s->flags) ? ECONNRESET : EIO;\n\t\t\tbreak;\n\t\tcase GNUTLS_E_UNEXPECTED_PACKET_LENGTH:\n\t\t\tif (SOCK_F_EOF & s->flags) {\n\t\t\t \t/*\n\t\t\t\t * Remote peer has hung up.\n\t\t\t\t *\n\t\t\t\t * This is not exceptional, so we make it appear to upper\n\t\t\t\t * layers (who do not necessarily know they're dealing with\n\t\t\t\t * a TLS socket) as a regular EOF condition: the read()\n\t\t\t\t * operation return 0.\n\t\t\t\t */\n\t\t\t\tret = 0;\n\t\t\t\tgoto no_error;\n\t\t\t} else if (SOCK_F_CONNRESET & s->flags) {\n\t\t\t\terrno = ECONNRESET;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t/* FALLTHROUGH */\n\t\tdefault:\n\t\t\tif (GNET_PROPERTY(tls_debug)) {\n\t\t\t\tg_carp(\"tls_read(): gnutls_record_recv(fd=%d) failed: \"\n\t\t\t\t\t\"host=%s error=\\\"%s\\\"\",\n\t\t\t\t\ts->file_desc, host_addr_port_to_string(s->addr, s->port),\n\t\t\t\t\tgnutls_strerror(ret));\n\t\t\t}\n\t\t\terrno = EIO;\n\t\t}\n\t\tret = -1;\n\t}\n\nno_error:\n\tif (s->gdk_tag && 0 == s->tls.snarf) {\n\t\ttls_socket_evt_change(s, INPUT_EVENT_RX);\n\t}\n\tg_assert(ret == (ssize_t) -1 || (size_t) ret <= size);\n\ttls_signal_pending(s);\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 533 }, { "index": 41292, "code": "SimpleLruInit(SlruCtl ctl, const char *name, int nslots,\n\t\t\t LWLockId ctllock, const char *subdir)\n{\n\tSlruShared\tshared;\n\tbool\t\tfound;\n\n\tshared = (SlruShared) ShmemInitStruct(name,\n\t\t\t\t\t\t\t\t\t\t SimpleLruShmemSize(nslots),\n\t\t\t\t\t\t\t\t\t\t &found);\n\n\tif (!IsUnderPostmaster)\n\t{\n\t\t/* Initialize locks and shared memory area */\n\t\tchar\t *ptr;\n\t\tSize\t\toffset;\n\t\tint\t\t\tslotno;\n\n\t\tAssert(!found);\n\n\t\tmemset(shared, 0, sizeof(SlruSharedData));\n\n\t\tshared->ControlLock = ctllock;\n\n\t\tshared->num_slots = nslots;\n\n\t\tshared->cur_lru_count = 0;\n\n\t\t/* shared->latest_page_number will be set later */\n\n\t\tptr = (char *) shared;\n\t\toffset = MAXALIGN(sizeof(SlruSharedData));\n\t\tshared->page_buffer = (char **) (ptr + offset);\n\t\toffset += MAXALIGN(nslots * sizeof(char *));\n\t\tshared->page_status = (SlruPageStatus *) (ptr + offset);\n\t\toffset += MAXALIGN(nslots * sizeof(SlruPageStatus));\n\t\tshared->page_dirty = (bool *) (ptr + offset);\n\t\toffset += MAXALIGN(nslots * sizeof(bool));\n\t\tshared->page_number = (int *) (ptr + offset);\n\t\toffset += MAXALIGN(nslots * sizeof(int));\n\t\tshared->page_lru_count = (int *) (ptr + offset);\n\t\toffset += MAXALIGN(nslots * sizeof(int));\n\t\tshared->buffer_locks = (LWLockId *) (ptr + offset);\n\t\toffset += MAXALIGN(nslots * sizeof(LWLockId));\n\t\tptr += BUFFERALIGN(offset);\n\n\t\tfor (slotno = 0; slotno < nslots; slotno++)\n\t\t{\n\t\t\tshared->page_buffer[slotno] = ptr;\n\t\t\tshared->page_status[slotno] = SLRU_PAGE_EMPTY;\n\t\t\tshared->page_dirty[slotno] = false;\n\t\t\tshared->page_lru_count[slotno] = 0;\n\t\t\tshared->buffer_locks[slotno] = LWLockAssign();\n\t\t\tptr += BLCKSZ;\n\t\t}\n\t}\n\telse\n\t\tAssert(found);\n\n\t/*\n\t * Initialize the unshared control struct, including directory path. We\n\t * assume caller set PagePrecedes.\n\t */\n\tctl->shared = shared;\n\tctl->do_fsync = true;\t\t/* default behavior */\n\tStrNCpy(ctl->Dir, subdir, sizeof(ctl->Dir));\n}", "label": 1, "cwe": "CWE-120", "length": 547 }, { "index": 1000549, "code": "qcow_write_compressed(BlockDriverState *bs, int64_t sector_num,\n const uint8_t *buf, int nb_sectors)\n{\n BDRVQcowState *s = bs->opaque;\n z_stream strm;\n int ret, out_len;\n uint8_t *out_buf;\n uint64_t cluster_offset;\n\n if (nb_sectors == 0) {\n /* align end of file to a sector boundary to ease reading with\n sector based I/Os */\n cluster_offset = bdrv_getlength(s->hd);\n cluster_offset = (cluster_offset + 511) & ~511;\n bdrv_truncate(s->hd, cluster_offset);\n return 0;\n }\n\n if (nb_sectors != s->cluster_sectors)\n return -EINVAL;\n\n out_buf = qemu_malloc(s->cluster_size + (s->cluster_size / 1000) + 128);\n if (!out_buf)\n return -ENOMEM;\n\n /* best compression, small window, no zlib header */\n memset(&strm, 0, sizeof(strm));\n ret = deflateInit2(&strm, Z_DEFAULT_COMPRESSION,\n Z_DEFLATED, -12,\n 9, Z_DEFAULT_STRATEGY);\n if (ret != 0) {\n qemu_free(out_buf);\n return -1;\n }\n\n strm.avail_in = s->cluster_size;\n strm.next_in = (uint8_t *)buf;\n strm.avail_out = s->cluster_size;\n strm.next_out = out_buf;\n\n ret = deflate(&strm, Z_FINISH);\n if (ret != Z_STREAM_END && ret != Z_OK) {\n qemu_free(out_buf);\n deflateEnd(&strm);\n return -1;\n }\n out_len = strm.next_out - out_buf;\n\n deflateEnd(&strm);\n\n if (ret != Z_STREAM_END || out_len >= s->cluster_size) {\n /* could not compress: write normal cluster */\n qcow_write(bs, sector_num, buf, s->cluster_sectors);\n } else {\n cluster_offset = get_cluster_offset(bs, sector_num << 9, 2,\n out_len, 0, 0);\n cluster_offset &= s->cluster_offset_mask;\n if (bdrv_pwrite(s->hd, cluster_offset, out_buf, out_len) != out_len) {\n qemu_free(out_buf);\n return -1;\n }\n }\n\n qemu_free(out_buf);\n return 0;\n}", "label": 0, "cwe": null, "length": 530 }, { "index": 224416, "code": "get_ibrk_linref(struct itree_t *itp, struct task_t *tskp,\n int32 *ifi, int32 *lini) \n{\n register char *chp;\n struct sy_t *syp;\n struct mod_t *mdp;\n char *savchp, *endchp;\n char sref[RECLEN];\n\n /* return F on error, if not [file]:[line], ifi set to -1 */\n if (!try_get_fillin_ref(__visp->vichp, ifi, lini, &savchp, &endchp))\n return(FALSE);\n\n if (*ifi != -1) __visp->vichp = endchp;\n else\n { \n /* know not [file]:[line] ref - must be line by itself */\n strncpy(sref, savchp, endchp - savchp); \n sref[endchp - savchp] = '\\0'; \n __visp->vichp = endchp;\n /* does not have : not [file]:[line] but maybe [line] */\n if (!isdigit(sref[0]))\n {\nbad_lin_num:\n __ia_err(1481, \":ibreakpoint ,[number] expected - %s read\", sref);\n return(FALSE);\n }\n for (chp = sref; *chp != '\\0'; chp++)\n { if (!isdigit(*chp)) goto bad_lin_num; } \n if (sscanf(sref, \"%d\", lini) != 1) goto bad_lin_num; \n if (tskp != NULL) syp = tskp->tsksyp; else syp = itp->itip->imsym;\n /* have [line] form - file is first in scope */\n *ifi = (int32) syp->syfnam_ind;\n }\n /* make sure in range */\n if (tskp != NULL)\n {\n if (!scope_lini_inrng(*lini, *ifi, tskp->tsksyp->sylin_cnt,\n (int32) tskp->tsksyp->syfnam_ind, tskp->tsk_last_lini, tskp->tsk_last_ifi))\n {\nout_of_rng:\n __ia_err(1482, \":ibreakpoint %s:%d not before statement in scope %s\",\n __in_fils[*ifi], *lini, __msg_blditree(__xs, itp, tskp));\n return(FALSE);\n }\n return(TRUE);\n }\n /* must be in scope with initial/always and before last */\n mdp = itp->itip->imsym->el.emdp;\n if (!scope_lini_inrng(*lini, *ifi, mdp->msym->sylin_cnt,\n (int32) mdp->msym->syfnam_ind, mdp->mod_last_lini, mdp->mod_last_ifi))\n goto out_of_rng;\n if (mdp->ialst == NULL) goto out_of_rng;\n /* if after last - error later */\n return(TRUE); \n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 672 }, { "index": 978, "code": "init_new_state (bool_t auxiliary_state, bool_t delta, range_t *range,\n\t\tconst range_t *child, const int *y_state,\n\t\twfa_t *wfa, coding_t *c)\n/*\n * Initializes a new state with all parameters needed for the encoding step.\n * If flag 'auxiliary_state' is set then don't insert state into domain pools.\n * If flag 'delta' is set then state represents a delta image (prediction via\n * nondeterminism or motion compensation).\n * 'range' the current range image,\n * 'child []' the left and right childs of 'range'.\n *\n * No return value.\n *\n * Side effects:\n *\tNew state is appended to 'wfa' (and also its inner products and images\n * are computed and stored in 'c')\n */\n{\n unsigned label;\n bool_t state_is_domain = NO;\n\n if (!auxiliary_state)\n {\n if (!delta || c->options.delta_domains)\n\t state_is_domain = c->domain_pool->append (wfa->states, range->level,\n\t\t\t\t\t\t wfa, c->domain_pool->model);\n if (delta || c->options.normal_domains)\n\t state_is_domain = c->d_domain_pool->append (wfa->states, range->level,\n\t\t\t\t\t\t wfa,\n\t\t\t\t\t\t c->d_domain_pool->model)\n\t\t\t || state_is_domain;\n }\n else\n state_is_domain = NO;\n \n range->into [0] = NO_EDGE;\n range->tree = wfa->states;\n \n for (label = 0; label < MAXLABELS; label++) \n {\n wfa->tree [wfa->states][label] = child [label].tree;\n wfa->y_state [wfa->states][label] = y_state [label];\n wfa->mv_tree [wfa->states][label] = child [label].mv;\n wfa->x [wfa->states][label] = child [label].x;\n wfa->y [wfa->states][label] = child [label].y;\n wfa->prediction [wfa->states][label] = child [label].prediction;\n\n append_transitions (wfa->states, label, child [label].weight,\n\t\t\t child [label].into, wfa);\n }\n wfa->delta_state [wfa->states] = delta;\n\n if (range->err < 0)\n warning (\"Negative image norm: %f, %f\", child [0].err, child [1].err);\n\n/* state_is_domain = YES; */\n \n append_state (!state_is_domain,\n\t\t compute_final_distribution (wfa->states, wfa),\n\t\t range->level, wfa, c);\n}", "label": 1, "cwe": "CWE-other", "length": 600 }, { "index": 594430, "code": "InitSearch( time_t /*ttimeout*/ )\n{\n\tCStringList * StringList = 0;\n\n\t// clear searchlist\n\t// TODO: we can leave it and search again on the last break, \n\t// but we need a check against the current queue (traffic)\n\tm_pSearchList->Clear();\n\tm_pSearchQueryList->Clear();\n\n\tif ( !CSearchManager::Instance() )\n\t{\n\t\treturn false;\n\t}\n\n\tm_pDownloadQueue->pQueueMutex->Lock();\n\n\twhile( m_pDownloadQueue->pQueue->Next( &StringList ) )\n\t{\n\t\tDCTransferQueueObject * TransferObject = 0;\n\n\t\twhile( StringList->Next( &TransferObject ) )\n\t\t{\n\t\t\tDCTransferFileObject * TransferFileObject = 0;\n\n\t\t\twhile( TransferObject->pTransferFileList.Next( &TransferFileObject ) )\n\t\t\t{\n\t\t\t\tif ( TransferFileObject->m_bMulti && // only if md enabled\n\t\t\t\t TransferFileObject->m_sHash.NotEmpty() && // only if we have a TTH\n\t\t\t\t (TransferFileObject->m_eMedium == eltFILE) ) // only if medium file\n\t\t\t\t{\n\t\t\t\t\tbool dupe = false;\n\t\t\t\t\tCMessageSearchResult * it = 0;\n\t\t\t\t\twhile ( (it = m_pSearchList->Next(it)) != 0 )\n\t\t\t\t\t{\n\t\t\t\t\t\tif ( it->m_sHash == TransferFileObject->m_sHash )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tdupe = true;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tif ( dupe )\n\t\t\t\t\t{\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t\t\n\t\t\t\t\tCMessageSearchResult * msg = new CMessageSearchResult();\n\n\t\t\t\t\tmsg->m_nSize = TransferFileObject->m_nSize;\n\t\t\t\t\tmsg->m_sFile = TransferFileObject->m_sRemoteFile;\n\t\t\t\t\tmsg->m_sNick = TransferObject->sNick;\n\t\t\t\t\tmsg->m_sHubName = TransferObject->sHubName;\n\t\t\t\t\tmsg->m_sHash = TransferFileObject->m_sHash;\n\n\t\t\t\t\tCMessageSearchFile * smsg = new CMessageSearchFile();\n\t\t\t\t\t\n\t\t\t\t\tsmsg->m_sString = TransferFileObject->m_sHash;\n\t\t\t\t\tsmsg->m_eFileType = eftHASH;\n\t\t\t\t\tsmsg->m_bLocal = (CConfig::Instance()->GetMode() == ecmPASSIVE);\n\t\t\t\t\t/* CClient sets the source (nick or IP) before sending the search */\n\t\t\t\t\n\t\t\t\t\tm_pSearchList->Add(msg);\n\t\t\t\t\tm_pSearchQueryList->Add(smsg);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tm_pDownloadQueue->pQueueMutex->UnLock();\n\n\tif ( m_pSearchList->Count() <= 0 )\n\t{\n\t\treturn false;\n\t}\n\n\tif ( CSearchManager::Instance()->StartSearch(esmCONNECTEDALL,estyEXTERNAL,m_pSearchQueryList,0) != eseNONE )\n\t{\n\t\treturn false;\n\t}\n\n\treturn true;\n}", "label": 0, "cwe": null, "length": 633 }, { "index": 555099, "code": "gtab_scan_pre_select(gboolean b_incr)\n{\n if (!gtab_phrase_pre_select)\n return;\n// dbg(\"gtab_scan_pre_select\\n\");\n\n tss.pre_selN = 0;\n\n hide_gtab_pre_sel();\n\n if (!gtab_cursor_end() || !ggg.gbufN)\n return;\n\n init_tsin_table();\n init_pre_sel();\n\n int Maxlen = ggg.gbufN;\n if (Maxlen > MAX_PHRASE_LEN)\n Maxlen = MAX_PHRASE_LEN;\n\n int len, selN, max_len=-1, max_selN;\n for(len=1; len <= Maxlen; len++) {\n int idx = ggg.gbufN - len;\n if (gbuf[idx].flag & FLAG_CHPHO_PHRASE_TAIL)\n break;\n int mlen = scanphr_e(ggg.gbufN - len, len, b_incr, &selN);\n if (mlen) {\n max_len = len;\n max_selN = selN;\n }\n }\n\n// dbg(\"max_len:%d max_selN:%d\\n\", max_len, max_selN);\n\n if (max_len < 0 || max_selN >= strlen(cur_inmd->selkey) * 2) {\n tss.pre_selN = 0;\n return;\n }\n\n gtab_pre_select_phrase_len = max_len;\n\n scanphr_e(ggg.gbufN - max_len, max_len, b_incr, &selN);\n\n// dbg(\"selN:%d %d\\n\", selN, tss.pre_selN);\n\n if (selN==1 && tss.pre_sel[0].len==max_len) {\n char out[MAX_PHRASE_LEN * CH_SZ + 1];\n extract_gbuf_str(ggg.gbufN - max_len, max_len, out);\n if (!strcmp(out, tss.pre_sel[0].str))\n return;\n }\n\n// dbg(\"selN %d %d\\n\",selN, tss.pre_selN);\n\n if (use_tsin_sel_win()) {\n\tif (gwin1)\n clear_sele();\n\telse\n init_tsin_selection_win();\n\n int i;\n for(i=0;i%c%s%s\", gcin_sel_key_color,\n cur_inmd->selkey[i], tss.pre_sel[i].str, br);\n strcat(tt, ts);\n if (!gtab_vertical_select_on() && i < tss.pre_selN-1)\n strcat(tt, \" \");\n }\n\n// dbg(\"tt %s\\n\", tt);\n disp_gtab_pre_sel(tt);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 717 }, { "index": 946695, "code": "rtl8139_hw_start (struct net_device *dev)\n{\n\tstruct rtl8139_private *tp = netdev_priv(dev);\n\tvoid __iomem *ioaddr = tp->mmio_addr;\n\tu32 i;\n\tu8 tmp;\n\n\t/* Bring old chips out of low-power mode. */\n\tif (rtl_chip_info[tp->chipset].flags & HasHltClk)\n\t\tRTL_W8 (HltClk, 'R');\n\n\trtl8139_chip_reset (ioaddr);\n\n\t/* unlock Config[01234] and BMCR register writes */\n\tRTL_W8_F (Cfg9346, Cfg9346_Unlock);\n\t/* Restore our idea of the MAC address. */\n\tRTL_W32_F (MAC0 + 0, le32_to_cpu (*(__le32 *) (dev->dev_addr + 0)));\n\tRTL_W32_F (MAC0 + 4, le16_to_cpu (*(__le16 *) (dev->dev_addr + 4)));\n\n\ttp->cur_rx = 0;\n\n\t/* init Rx ring buffer DMA address */\n\tRTL_W32_F (RxBuf, tp->rx_ring_dma);\n\n\t/* Must enable Tx/Rx before setting transfer thresholds! */\n\tRTL_W8 (ChipCmd, CmdRxEnb | CmdTxEnb);\n\n\ttp->rx_config = rtl8139_rx_config | AcceptBroadcast | AcceptMyPhys;\n\tRTL_W32 (RxConfig, tp->rx_config);\n\tRTL_W32 (TxConfig, rtl8139_tx_config);\n\n\trtl_check_media (dev, 1);\n\n\tif (tp->chipset >= CH_8139B) {\n\t\t/* Disable magic packet scanning, which is enabled\n\t\t * when PM is enabled in Config1. It can be reenabled\n\t\t * via ETHTOOL_SWOL if desired. */\n\t\tRTL_W8 (Config3, RTL_R8 (Config3) & ~Cfg3_Magic);\n\t}\n\n\tnetdev_dbg(dev, \"init buffer addresses\\n\");\n\n\t/* Lock Config[01234] and BMCR register writes */\n\tRTL_W8 (Cfg9346, Cfg9346_Lock);\n\n\t/* init Tx buffer DMA addresses */\n\tfor (i = 0; i < NUM_TX_DESC; i++)\n\t\tRTL_W32_F (TxAddr0 + (i * 4), tp->tx_bufs_dma + (tp->tx_buf[i] - tp->tx_bufs));\n\n\tRTL_W32 (RxMissed, 0);\n\n\trtl8139_set_rx_mode (dev);\n\n\t/* no early-rx interrupts */\n\tRTL_W16 (MultiIntr, RTL_R16 (MultiIntr) & MultiIntrClear);\n\n\t/* make sure RxTx has started */\n\ttmp = RTL_R8 (ChipCmd);\n\tif ((!(tmp & CmdRxEnb)) || (!(tmp & CmdTxEnb)))\n\t\tRTL_W8 (ChipCmd, CmdRxEnb | CmdTxEnb);\n\n\t/* Enable all known interrupts by setting the interrupt mask. */\n\tRTL_W16 (IntrMask, rtl8139_intr_mask);\n}", "label": 0, "cwe": null, "length": 647 }, { "index": 614158, "code": "plugin_notice (struct bfd_link_info *info,\n\t struct bfd_link_hash_entry *h,\n\t bfd *abfd,\n\t asection *section,\n\t bfd_vma value,\n\t flagword flags,\n\t const char *string)\n{\n if (h != NULL)\n {\n bfd *sym_bfd;\n\n /* No further processing if this def/ref is from an IR dummy BFD. */\n if (is_ir_dummy_bfd (abfd))\n\treturn TRUE;\n\n /* Making an indirect symbol counts as a reference unless this\n\t is a brand new symbol. */\n if (bfd_is_ind_section (section)\n\t || (flags & BSF_INDIRECT) != 0)\n\t{\n\t if (h->type != bfd_link_hash_new)\n\t {\n\t struct bfd_link_hash_entry *inh;\n\n\t h->non_ir_ref = TRUE;\n\t inh = bfd_wrapped_link_hash_lookup (abfd, info, string, FALSE,\n\t\t\t\t\t\t FALSE, FALSE);\n\t if (inh != NULL)\n\t\tinh->non_ir_ref = TRUE;\n\t }\n\t}\n\n /* Nothing to do here for warning symbols. */\n else if ((flags & BSF_WARNING) != 0)\n\t;\n\n /* Nothing to do here for constructor symbols. */\n else if ((flags & BSF_CONSTRUCTOR) != 0)\n\t;\n\n /* If this is a ref, set non_ir_ref. */\n else if (bfd_is_und_section (section))\n\th->non_ir_ref = TRUE;\n\n /* Otherwise, it must be a new def. Ensure any symbol defined\n\t in an IR dummy BFD takes on a new value from a real BFD.\n\t Weak symbols are not normally overridden by a new weak\n\t definition, and strong symbols will normally cause multiple\n\t definition errors. Avoid this by making the symbol appear\n\t to be undefined. */\n else if (((h->type == bfd_link_hash_defweak\n\t\t || h->type == bfd_link_hash_defined)\n\t\t&& is_ir_dummy_bfd (sym_bfd = h->u.def.section->owner))\n\t || (h->type == bfd_link_hash_common\n\t\t && is_ir_dummy_bfd (sym_bfd = h->u.c.p->section->owner)))\n\t{\n\t h->type = bfd_link_hash_undefweak;\n\t h->u.undef.abfd = sym_bfd;\n\t}\n }\n\n /* Continue with cref/nocrossref/trace-sym processing. */\n if (h == NULL\n || orig_notice_all\n || (info->notice_hash != NULL\n\t && bfd_hash_lookup (info->notice_hash, h->root.string,\n\t\t\t FALSE, FALSE) != NULL))\n return (*orig_callbacks->notice) (info, h,\n\t\t\t\t abfd, section, value, flags, string);\n return TRUE;\n}", "label": 0, "cwe": null, "length": 600 }, { "index": 985468, "code": "L124__PICMENU_CALCULATE_SIZE__dwtrans()\n{register object *base=vs_base;\n\tregister object *sup=base+VM124; VC124\n\tvs_check;\n\t{register object V698;\n\tV698=(base[0]);\n\tvs_top=sup;\n\tgoto TTL;\nTTL:;\n\t{object V699;\n\tobject V700;\n\tV699= Cnil;\n\tV700= Cnil;\n\tif(((*(LnkLI270))((V698)))==Cnil){\n\tgoto T2737;}\n\tV702= (*(LnkLI270))((V698));\n\tV703 = CMPmake_fixnum((long)(length(/* INLINE-ARGS */V702)));\n\tV704= immnum_times(small_fixnum(9),V703);\n\tV701= immnum_plus(small_fixnum(6),/* INLINE-ARGS */V704);\n\tgoto T2735;\n\tgoto T2737;\nT2737:;\n\tV701= small_fixnum(0);\n\tgoto T2735;\nT2735:;\n\tV699= immnum_max(V701,CMPcadr(({register fixnum _i=(long)10;register object _x=(V698);for (;_i--;_x=_x->c.c_cdr);_x->c.c_car;})));\n\tif(((*(LnkLI270))((V698)))==Cnil){\n\tgoto T2743;}\n\tV706= (*(LnkLI270))((V698));\n\tif(!(((long)length(/* INLINE-ARGS */V706))>0)){\n\tgoto T2743;}\n\tif((CMPcaddr((V698)))!=Cnil){\n\tgoto T2742;}\n\tif(((((object)VV[74])->s.s_dbind))==Cnil){\n\tgoto T2743;}\n\tgoto T2742;\nT2742:;\n\tV705= small_fixnum(15);\n\tgoto T2741;\n\tgoto T2743;\nT2743:;\n\tV705= small_fixnum(0);\n\tgoto T2741;\nT2741:;\n\tV700= immnum_plus(V705,CMPcaddr(({register fixnum _i=(long)10;register object _x=(V698);for (;_i--;_x=_x->c.c_cdr);_x->c.c_car;})));\n\t(CMPcddr(CMPcddddr(V698)))->c.c_car = V699;\n\t(void)(CMPcddr(CMPcddddr(V698)));\n\t(CMPcdddr(CMPcddddr(V698)))->c.c_car = V700;\n\t(void)(CMPcdddr(CMPcddddr(V698)));\n\tbase[1]= V700;\n\tvs_top=(vs_base=base+1)+1;\n\treturn;}\n\t}\n}", "label": 0, "cwe": null, "length": 562 }, { "index": 302922, "code": "IsTextureSizeSupported(int size[3],\n int components)\n{\n GLint maxSize;\n glGetIntegerv(vtkgl::MAX_3D_TEXTURE_SIZE,&maxSize);\n \n if(size[0]>maxSize || size[1]>maxSize || size[2]>maxSize)\n {\n return 0;\n }\n \n GLuint id1;\n glGenTextures(1,&id1);\n glBindTexture(vtkgl::TEXTURE_3D,id1);\n if(components==1)\n {\n vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,this->InternalLA,size[0], \n size[1], size[2], 0, GL_LUMINANCE_ALPHA,\n GL_UNSIGNED_BYTE,0);\n }\n else\n {\n vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,this->InternalRGB,size[0], \n size[1], size[2], 0, GL_RGB,\n GL_UNSIGNED_BYTE,0);\n }\n bool result=glGetError()==GL_NO_ERROR;\n if(result) // ie. not GL_OUT_OF_MEMORY\n {\n GLuint id2;\n glGenTextures(1,&id2);\n glBindTexture(vtkgl::TEXTURE_3D,id2);\n if(components==4)\n {\n vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,this->InternalLA,size[0], \n size[1], size[2], 0, GL_LUMINANCE_ALPHA,\n GL_UNSIGNED_BYTE,0);\n }\n else\n {\n vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,this->InternalRGB,size[0], \n size[1], size[2], 0, GL_RGB,\n GL_UNSIGNED_BYTE,0);\n }\n result=glGetError()==GL_NO_ERROR;\n if(result && components==4) // ie. not GL_OUT_OF_MEMORY\n {\n GLuint id3;\n glGenTextures(1,&id3);\n glBindTexture(vtkgl::TEXTURE_3D,id3);\n vtkgl::TexImage3D(vtkgl::TEXTURE_3D,0,this->InternalRGB,size[0], \n size[1], size[2], 0, GL_RGB,\n GL_UNSIGNED_BYTE,0);\n result=glGetError()==GL_NO_ERROR;\n glBindTexture(vtkgl::TEXTURE_3D,0); // bind to default texture object.\n glDeleteTextures(1,&id3);\n }\n glBindTexture(vtkgl::TEXTURE_3D,0); // bind to default texture object.\n glDeleteTextures(1,&id2);\n }\n glBindTexture(vtkgl::TEXTURE_3D,0); // bind to default texture object.\n glDeleteTextures(1,&id1);\n return result;\n}", "label": 0, "cwe": null, "length": 619 }, { "index": 112835, "code": "header(ostream& os, string name)\n\t\t{\n\t\t\tif (!name.empty())\n\t\t\t\tname += \" \";\n\t\t\tname = escape(name);\n\t\t\tos <<\n\t\t\t\t\"\\n\"\n\t\t\t\t\"\\n\"\n\t\t\t\t\"\\n\"\n\t\t\t\t\" \\n\"\n\t\t\t\t\" \\n\"\n\t\t\t\t\" \\n\"\n\t\t\t\t\" \" << name << \"Unit Tests Results\\n\"\n\t\t\t\t\" \\n\"\n\t\t\t\t\" \\n\"\n\t\t\t\t\"\\n\"\n\t\t\t\t\"\\n\"\n\t\t\t\t\"\\n\"\n\t\t\t\t\"\\n\"\n\t\t\t\t\"

\" << name << \"Unit Tests Results

\\n\"\n\t\t\t\t\"\\n\"\n\t\t\t\t\"
\\n\"\n\t\t\t\t\"Designed by CppTest\\n\"\n\t\t\t\t\"
\\n\"\n\t\t\t\t\"
\\n\"\n\t\t\t\t\"\\n\";\n\t\t}", "label": 0, "cwe": null, "length": 920 }, { "index": 413046, "code": "png_check_fp_number(png_const_charp string, png_size_t size, int *statep,\n png_size_tp whereami)\n{\n int state = *statep;\n png_size_t i = *whereami;\n\n while (i < size)\n {\n int type;\n /* First find the type of the next character */\n switch (string[i])\n {\n case 43: type = PNG_FP_SAW_SIGN; break;\n case 45: type = PNG_FP_SAW_SIGN + PNG_FP_NEGATIVE; break;\n case 46: type = PNG_FP_SAW_DOT; break;\n case 48: type = PNG_FP_SAW_DIGIT; break;\n case 49: case 50: case 51: case 52:\n case 53: case 54: case 55: case 56:\n case 57: type = PNG_FP_SAW_DIGIT + PNG_FP_NONZERO; break;\n case 69:\n case 101: type = PNG_FP_SAW_E; break;\n default: goto PNG_FP_End;\n }\n\n /* Now deal with this type according to the current\n * state, the type is arranged to not overlap the\n * bits of the PNG_FP_STATE.\n */\n switch ((state & PNG_FP_STATE) + (type & PNG_FP_SAW_ANY))\n {\n case PNG_FP_INTEGER + PNG_FP_SAW_SIGN:\n if (state & PNG_FP_SAW_ANY)\n goto PNG_FP_End; /* not a part of the number */\n\n png_fp_add(state, type);\n break;\n\n case PNG_FP_INTEGER + PNG_FP_SAW_DOT:\n /* Ok as trailer, ok as lead of fraction. */\n if (state & PNG_FP_SAW_DOT) /* two dots */\n goto PNG_FP_End;\n\n else if (state & PNG_FP_SAW_DIGIT) /* trailing dot? */\n png_fp_add(state, type);\n\n else\n png_fp_set(state, PNG_FP_FRACTION | type);\n\n break;\n\n case PNG_FP_INTEGER + PNG_FP_SAW_DIGIT:\n if (state & PNG_FP_SAW_DOT) /* delayed fraction */\n png_fp_set(state, PNG_FP_FRACTION | PNG_FP_SAW_DOT);\n\n png_fp_add(state, type | PNG_FP_WAS_VALID);\n\n break;\n\n case PNG_FP_INTEGER + PNG_FP_SAW_E:\n if ((state & PNG_FP_SAW_DIGIT) == 0)\n goto PNG_FP_End;\n\n png_fp_set(state, PNG_FP_EXPONENT);\n\n break;\n\n /* case PNG_FP_FRACTION + PNG_FP_SAW_SIGN:\n goto PNG_FP_End; ** no sign in fraction */\n\n /* case PNG_FP_FRACTION + PNG_FP_SAW_DOT:\n goto PNG_FP_End; ** Because SAW_DOT is always set */\n\n case PNG_FP_FRACTION + PNG_FP_SAW_DIGIT:\n png_fp_add(state, type | PNG_FP_WAS_VALID);\n break;\n\n case PNG_FP_FRACTION + PNG_FP_SAW_E:\n /* This is correct because the trailing '.' on an\n * integer is handled above - so we can only get here\n * with the sequence \".E\" (with no preceding digits).\n */\n if ((state & PNG_FP_SAW_DIGIT) == 0)\n goto PNG_FP_End;\n\n png_fp_set(state, PNG_FP_EXPONENT);\n\n break;\n\n case PNG_FP_EXPONENT + PNG_FP_SAW_SIGN:\n if (state & PNG_FP_SAW_ANY)\n goto PNG_FP_End; /* not a part of the number */\n\n png_fp_add(state, PNG_FP_SAW_SIGN);\n\n break;\n\n /* case PNG_FP_EXPONENT + PNG_FP_SAW_DOT:\n goto PNG_FP_End; */\n\n case PNG_FP_EXPONENT + PNG_FP_SAW_DIGIT:\n png_fp_add(state, PNG_FP_SAW_DIGIT | PNG_FP_WAS_VALID);\n\n break;\n\n /* case PNG_FP_EXPONEXT + PNG_FP_SAW_E:\n goto PNG_FP_End; */\n\n default: goto PNG_FP_End; /* I.e. break 2 */\n }\n\n /* The character seems ok, continue. */\n ++i;\n }\n\nPNG_FP_End:\n /* Here at the end, update the state and return the correct\n * return code.\n */\n *statep = state;\n *whereami = i;\n\n return (state & PNG_FP_SAW_DIGIT) != 0;\n}", "label": 0, "cwe": null, "length": 952 }, { "index": 82002, "code": "main(int argc,\n char **argv)\n{\nl_int32 i, nsels, same1, same2, ok;\nchar *filein, *selname;\nPIX *pixs, *pixref, *pixt1, *pixt2, *pixt3, *pixt4;\nSEL *sel;\nSELA *sela;\nstatic char mainName[] = \"fhmtauto_reg\";\n\n if (argc != 2)\n return ERROR_INT(\" Syntax: fhmtauto_reg filein\", mainName, 1);\n\n filein = argv[1];\n if ((pixs = pixRead(filein)) == NULL)\n return ERROR_INT(\"pixs not made\", mainName, 1);\n\n sela = selaAddHitMiss(NULL);\n nsels = selaGetCount(sela);\n\n ok = TRUE;\n for (i = 0; i < nsels; i++)\n {\n sel = selaGetSel(sela, i);\n selname = selGetName(sel);\n\n pixref = pixHMT(NULL, pixs, sel);\n\n pixt1 = pixAddBorder(pixs, 32, 0);\n pixt2 = pixFHMTGen_1(NULL, pixt1, selname);\n pixt3 = pixRemoveBorder(pixt2, 32);\n\n pixt4 = pixHMTDwa_1(NULL, pixs, selname);\n\n pixEqual(pixref, pixt3, &same1);\n pixEqual(pixref, pixt4, &same2);\n if (same1 && same2)\n fprintf(stderr, \"hmt are identical for sel %d (%s)\\n\", i, selname);\n else {\n fprintf(stderr, \"hmt differ for sel %d (%s)\\n\", i, selname);\n ok = FALSE;\n }\n\n pixDestroy(&pixref);\n pixDestroy(&pixt1);\n pixDestroy(&pixt2);\n pixDestroy(&pixt3);\n pixDestroy(&pixt4);\n }\n\n if (ok)\n fprintf(stderr, \"\\n ******** All hmt are correct *******\\n\");\n else\n fprintf(stderr, \"\\n ******** ERROR in at least one hmt *******\\n\");\n\n pixDestroy(&pixs);\n selaDestroy(&sela);\n return 0;\n}", "label": 0, "cwe": null, "length": 515 }, { "index": 818916, "code": "wil6210_debug_irq_mask(struct wil6210_priv *wil, u32 pseudo_cause)\n{\n\tif (!test_bit(wil_status_irqen, wil->status)) {\n\t\tu32 icm_rx = wil_ioread32_and_clear(wil->csr +\n\t\t\t\tHOSTADDR(RGF_DMA_EP_RX_ICR) +\n\t\t\t\toffsetof(struct RGF_ICR, ICM));\n\t\tu32 icr_rx = wil_ioread32_and_clear(wil->csr +\n\t\t\t\tHOSTADDR(RGF_DMA_EP_RX_ICR) +\n\t\t\t\toffsetof(struct RGF_ICR, ICR));\n\t\tu32 imv_rx = wil_r(wil, RGF_DMA_EP_RX_ICR +\n\t\t\t\t offsetof(struct RGF_ICR, IMV));\n\t\tu32 icm_tx = wil_ioread32_and_clear(wil->csr +\n\t\t\t\tHOSTADDR(RGF_DMA_EP_TX_ICR) +\n\t\t\t\toffsetof(struct RGF_ICR, ICM));\n\t\tu32 icr_tx = wil_ioread32_and_clear(wil->csr +\n\t\t\t\tHOSTADDR(RGF_DMA_EP_TX_ICR) +\n\t\t\t\toffsetof(struct RGF_ICR, ICR));\n\t\tu32 imv_tx = wil_r(wil, RGF_DMA_EP_TX_ICR +\n\t\t\t\t offsetof(struct RGF_ICR, IMV));\n\t\tu32 icm_misc = wil_ioread32_and_clear(wil->csr +\n\t\t\t\tHOSTADDR(RGF_DMA_EP_MISC_ICR) +\n\t\t\t\toffsetof(struct RGF_ICR, ICM));\n\t\tu32 icr_misc = wil_ioread32_and_clear(wil->csr +\n\t\t\t\tHOSTADDR(RGF_DMA_EP_MISC_ICR) +\n\t\t\t\toffsetof(struct RGF_ICR, ICR));\n\t\tu32 imv_misc = wil_r(wil, RGF_DMA_EP_MISC_ICR +\n\t\t\t\t offsetof(struct RGF_ICR, IMV));\n\t\twil_err(wil, \"IRQ when it should be masked: pseudo 0x%08x\\n\"\n\t\t\t\t\"Rx icm:icr:imv 0x%08x 0x%08x 0x%08x\\n\"\n\t\t\t\t\"Tx icm:icr:imv 0x%08x 0x%08x 0x%08x\\n\"\n\t\t\t\t\"Misc icm:icr:imv 0x%08x 0x%08x 0x%08x\\n\",\n\t\t\t\tpseudo_cause,\n\t\t\t\ticm_rx, icr_rx, imv_rx,\n\t\t\t\ticm_tx, icr_tx, imv_tx,\n\t\t\t\ticm_misc, icr_misc, imv_misc);\n\n\t\treturn -EINVAL;\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 576 }, { "index": 141296, "code": "ExecMaterial(MaterialState *node)\n{\n\tEState\t *estate;\n\tScanDirection dir;\n\tbool\t\tforward;\n\tTuplestorestate *tuplestorestate;\n\tbool\t\teof_tuplestore;\n\tTupleTableSlot *slot;\n\n\t/*\n\t * get state info from node\n\t */\n\testate = node->ss.ps.state;\n\tdir = estate->es_direction;\n\tforward = ScanDirectionIsForward(dir);\n\ttuplestorestate = (Tuplestorestate *) node->tuplestorestate;\n\n\t/*\n\t * If first time through, and we need a tuplestore, initialize it.\n\t */\n\tif (tuplestorestate == NULL && node->randomAccess)\n\t{\n\t\ttuplestorestate = tuplestore_begin_heap(true, false, work_mem);\n\n\t\tnode->tuplestorestate = (void *) tuplestorestate;\n\t}\n\n\t/*\n\t * If we are not at the end of the tuplestore, or are going backwards, try\n\t * to fetch a tuple from tuplestore.\n\t */\n\teof_tuplestore = (tuplestorestate == NULL) ||\n\t\ttuplestore_ateof(tuplestorestate);\n\n\tif (!forward && eof_tuplestore)\n\t{\n\t\tif (!node->eof_underlying)\n\t\t{\n\t\t\t/*\n\t\t\t * When reversing direction at tuplestore EOF, the first\n\t\t\t * gettupleslot call will fetch the last-added tuple; but we want\n\t\t\t * to return the one before that, if possible. So do an extra\n\t\t\t * fetch.\n\t\t\t */\n\t\t\tif (!tuplestore_advance(tuplestorestate, forward))\n\t\t\t\treturn NULL;\t/* the tuplestore must be empty */\n\t\t}\n\t\teof_tuplestore = false;\n\t}\n\n\t/*\n\t * If we can fetch another tuple from the tuplestore, return it.\n\t */\n\tslot = node->ss.ps.ps_ResultTupleSlot;\n\tif (!eof_tuplestore)\n\t{\n\t\tif (tuplestore_gettupleslot(tuplestorestate, forward, slot))\n\t\t\treturn slot;\n\t\tif (forward)\n\t\t\teof_tuplestore = true;\n\t}\n\n\t/*\n\t * If necessary, try to fetch another row from the subplan.\n\t *\n\t * Note: the eof_underlying state variable exists to short-circuit further\n\t * subplan calls. It's not optional, unfortunately, because some plan\n\t * node types are not robust about being called again when they've already\n\t * returned NULL.\n\t */\n\tif (eof_tuplestore && !node->eof_underlying)\n\t{\n\t\tPlanState *outerNode;\n\t\tTupleTableSlot *outerslot;\n\n\t\t/*\n\t\t * We can only get here with forward==true, so no need to worry about\n\t\t * which direction the subplan will go.\n\t\t */\n\t\touterNode = outerPlanState(node);\n\t\touterslot = ExecProcNode(outerNode);\n\t\tif (TupIsNull(outerslot))\n\t\t{\n\t\t\tnode->eof_underlying = true;\n\t\t\treturn NULL;\n\t\t}\n\n\t\t/*\n\t\t * Append returned tuple to tuplestore. NOTE: because the tuplestore\n\t\t * is certainly in EOF state, its read position will move forward over\n\t\t * the added tuple. This is what we want.\n\t\t */\n\t\tif (tuplestorestate)\n\t\t\ttuplestore_puttupleslot(tuplestorestate, outerslot);\n\n\t\t/*\n\t\t * And return a copy of the tuple.\t(XXX couldn't we just return the\n\t\t * outerslot?)\n\t\t */\n\t\treturn ExecCopySlot(slot, outerslot);\n\t}\n\n\t/*\n\t * Nothing left ...\n\t */\n\treturn ExecClearTuple(slot);\n}", "label": 0, "cwe": null, "length": 750 }, { "index": 63825, "code": "hwsim_tx_info_frame_received_nl(struct sk_buff *skb_2,\n\t\t\t\t\t struct genl_info *info)\n{\n\n\tstruct ieee80211_hdr *hdr;\n\tstruct mac80211_hwsim_data *data2;\n\tstruct ieee80211_tx_info *txi;\n\tstruct hwsim_tx_rate *tx_attempts;\n\tunsigned long ret_skb_ptr;\n\tstruct sk_buff *skb, *tmp;\n\tconst u8 *src;\n\tunsigned int hwsim_flags;\n\tint i;\n\tbool found = false;\n\n\tif (info->snd_portid != wmediumd_portid)\n\t\treturn -EINVAL;\n\n\tif (!info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER] ||\n\t !info->attrs[HWSIM_ATTR_FLAGS] ||\n\t !info->attrs[HWSIM_ATTR_COOKIE] ||\n\t !info->attrs[HWSIM_ATTR_SIGNAL] ||\n\t !info->attrs[HWSIM_ATTR_TX_INFO])\n\t\tgoto out;\n\n\tsrc = (void *)nla_data(info->attrs[HWSIM_ATTR_ADDR_TRANSMITTER]);\n\thwsim_flags = nla_get_u32(info->attrs[HWSIM_ATTR_FLAGS]);\n\tret_skb_ptr = nla_get_u64(info->attrs[HWSIM_ATTR_COOKIE]);\n\n\tdata2 = get_hwsim_data_ref_from_addr(src);\n\tif (!data2)\n\t\tgoto out;\n\n\t/* look for the skb matching the cookie passed back from user */\n\tskb_queue_walk_safe(&data2->pending, skb, tmp) {\n\t\tif ((unsigned long)skb == ret_skb_ptr) {\n\t\t\tskb_unlink(skb, &data2->pending);\n\t\t\tfound = true;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\t/* not found */\n\tif (!found)\n\t\tgoto out;\n\n\t/* Tx info received because the frame was broadcasted on user space,\n\t so we get all the necessary info: tx attempts and skb control buff */\n\n\ttx_attempts = (struct hwsim_tx_rate *)nla_data(\n\t\t info->attrs[HWSIM_ATTR_TX_INFO]);\n\n\t/* now send back TX status */\n\ttxi = IEEE80211_SKB_CB(skb);\n\n\tieee80211_tx_info_clear_status(txi);\n\n\tfor (i = 0; i < IEEE80211_TX_MAX_RATES; i++) {\n\t\ttxi->status.rates[i].idx = tx_attempts[i].idx;\n\t\ttxi->status.rates[i].count = tx_attempts[i].count;\n\t\t/*txi->status.rates[i].flags = 0;*/\n\t}\n\n\ttxi->status.ack_signal = nla_get_u32(info->attrs[HWSIM_ATTR_SIGNAL]);\n\n\tif (!(hwsim_flags & HWSIM_TX_CTL_NO_ACK) &&\n\t (hwsim_flags & HWSIM_TX_STAT_ACK)) {\n\t\tif (skb->len >= 16) {\n\t\t\thdr = (struct ieee80211_hdr *) skb->data;\n\t\t\tmac80211_hwsim_monitor_ack(data2->channel,\n\t\t\t\t\t\t hdr->addr2);\n\t\t}\n\t\ttxi->flags |= IEEE80211_TX_STAT_ACK;\n\t}\n\tieee80211_tx_status_irqsafe(data2->hw, skb);\n\treturn 0;\nout:\n\treturn -EINVAL;\n\n}", "label": 0, "cwe": null, "length": 652 }, { "index": 62904, "code": "CDTV_hsync_handler (void)\n{\n\tstatic int subqcnt;\n\n\tif (!currprefs.cs_cdtvcd || configured <= 0)\n\t\treturn;\n\n\tcdtv_hsync++;\n\n\tif (dma_wait >= 1024)\n\t\tdma_wait -= 1024;\n\tif (dma_wait >= 0 && dma_wait < 1024 && dma_finished) {\n\t\tif ((dmac_cntr & (CNTR_INTEN | CNTR_TCEN)) == (CNTR_INTEN | CNTR_TCEN)) {\n\t\t\tdmac_istr |= ISTR_INT_P | ISTR_E_INT;\n#ifdef CDTV_DEBUG_CMD\n\t\t\twrite_log (_T(\"DMA finished\\n\"));\n#endif\n\t\t}\n\t\tdma_finished = 0;\n\t\tcdtv_hsync = -1;\n\t}\n\tcheckint ();\n\n\tif (cdrom_command_done) {\n\t\tcdrom_command_done = 0;\n\t\tsten = 1;\n\t\tstch = 0;\n\t\ttp_check_interrupts ();\n\t}\n\n\tif (sten < 0) {\n\t\tsten--;\n\t\tif (sten < -3)\n\t\t\tsten = 0;\n\t}\n\n\tif (cd_audio_finished) {\n\t\tcd_audio_finished = 0;\n\t\tcd_playing = 0;\n\t\tcd_finished = 1;\n\t\tcd_paused = 0;\n\t\t//cd_error = 1;\n\t\tactivate_stch = 1;\n\t}\n\n\tstatic int subchannelcounter;\n\tint cntmax = (int)(maxvpos * vblank_hz / 75 - 6);\n\tif (subchannelcounter > 0)\n\t\tsubchannelcounter--;\n\tif (subchannelcounter <= 0) {\n\t\tif (cd_playing || cd_media) {\n\t\t\tif (subcodebufferoffset != subcodebufferoffsetw) {\n\t\t\t\tuae_sem_wait (&sub_sem);\n#ifdef CDTV_SUB_DEBUG\n\t\t\t\tif (subcodeoffset >= 0)\n\t\t\t\t\twrite_log (_T(\"CDTV: frame interrupt, subchannel not empty! %d\\n\"), subcodeoffset);\n#endif\n\t\t\t\tsubcodeoffset = -1;\n\t\t\t\tif (subcodebufferinuse[subcodebufferoffset]) {\n\t\t\t\t\tsubcodebufferinuse[subcodebufferoffset] = 0;\n\t\t\t\t\tmemcpy (subtransferbuf, subcodebuffer + subcodebufferoffset * SUB_CHANNEL_SIZE, SUB_CHANNEL_SIZE);\n\t\t\t\t\tsubcodebufferoffset++;\n\t\t\t\t\tif (subcodebufferoffset >= MAX_SUBCODEBUFFER)\n\t\t\t\t\t\tsubcodebufferoffset -= MAX_SUBCODEBUFFER;\n\t\t\t\t\tsbcp = 0;\n\t\t\t\t\tscor = 1;\n\t\t\t\t\tsubcode_activecnt++;\n\t\t\t\t\tevent2_newevent2 (SUBCODE_CYCLES, 0, subcode_interrupt);\n\t\t\t\t\ttp_check_interrupts ();\n\t\t\t\t}\n\t\t\t\tuae_sem_post (&sub_sem);\n\t\t\t\tsubchannelcounter = cntmax;\n\t\t\t}\n\t\t}\n\t\tif (!scor && !cd_playing) {\n\t\t\t// frame interrupts happen all the time motor is running\n\t\t\tscor = 1;\n\t\t\ttp_check_interrupts ();\n\t\t\tscor = 0;\n\t\t\tsubchannelcounter = cntmax;\n\t\t}\n\t}\n\n\tif (cdtv_hsync < cntmax && cdtv_hsync >= 0)\n\t\treturn;\n\tcdtv_hsync = 0;\n#if 0\n\tif (cd_isready > 0) {\n\t\tcd_isready--;\n\t\tif (!cd_isready)\n\t\t\tdo_stch ();\n\t}\n#endif\n\tif (dmac_dma || dma_finished)\n\t\tcd_led |= LED_CD_ACTIVE;\n\telse\n\t\tcd_led &= ~LED_CD_ACTIVE;\n\tif ((cd_led & ~LED_CD_ACTIVE2) && !cd_playing)\n\t\tgui_flicker_led (LED_CD, 0, cd_led);\n\n\tsubqcnt--;\n\tif (subqcnt < 0) {\n\t\twrite_comm_pipe_u32 (&requests, 0x0101, 1);\n\t\tif (cd_playing)\n\t\t\tsubqcnt = 10;\n\t\telse\n\t\t\tsubqcnt = 75;\n\t}\n\n\tif (activate_stch)\n\t\tdo_stch ();\n}", "label": 0, "cwe": null, "length": 839 }, { "index": 203061, "code": "tini_download(flytec_t *flytec, set_t *indexes, const char *manufacturer, igc_filename_format_t igc_filename_format)\n{\n int count = 0;\n track_t **ptrack;\n for (ptrack = flytec_pbrtl(flytec, manufacturer, igc_filename_format); *ptrack; ++ptrack) {\n\ttrack_t *track = *ptrack;\n\tif (indexes && !set_include(indexes, track->index + 1))\n\t continue;\n\tif (!overwrite) {\n\t struct stat buf;\n\t if (stat(track->igc_filename, &buf) == 0)\n\t\tcontinue;\n\t if (errno != ENOENT)\n\t\tDIE(\"stat\", errno);\n\t}\n\tif (!quiet)\n\t fprintf(stderr, \"%s: downloading %s \", program_name, track->igc_filename);\n\tdownload_data_t download_data;\n\tmemset(&download_data, 0, sizeof download_data);\n\tdownload_data.track = track;\n\tdownload_data.file = fopen(track->igc_filename, \"w\");\n\tif (!download_data.file)\n\t error(\"fopen: %s: %s\", track->igc_filename, strerror(errno));\n\tdownload_data._sc_clk_tck = sysconf(_SC_CLK_TCK);\n\tif (download_data._sc_clk_tck == -1)\n\t DIE(\"sysconf\", errno);\n\tstruct tms tms;\n\tdownload_data.clock = times(&tms);\n\tif (download_data.clock == (clock_t) -1)\n\t DIE(\"times\", errno);\n\tif (!quiet)\n\t fprintf(stderr, \" 0%% \");\n\tflytec_pbrtr(flytec, track, download_callback, &download_data);\n\tif (fclose(download_data.file) == EOF)\n\t DIE(\"fclose\", errno);\n\tif (!quiet) {\n\t struct tms tms;\n\t clock_t clock = times(&tms);\n\t if (clock == (clock_t) -1)\n\t\tDIE(\"times\", errno);\n\t int sec = (clock - download_data.clock + download_data._sc_clk_tck / 2) / download_data._sc_clk_tck;\n\t if (sec > 99 * 60 + 59)\n\t\tsec = 99 * 60 + 59;\n\t fprintf(stderr, \"\\b\\b\\b\\b\\b\\b\\b\\b\\b\\b\\b\\b\\b\\b\\b100%% %02d:%02d \\n\", sec / 60, sec % 60);\n\t}\n\t++count;\n }\n if (!quiet) {\n\tif (count)\n\t fprintf(stderr, \"%s: %d tracklog%s downloaded\\n\", program_name, count, count == 1 ? \"\" : \"s\");\n\telse if (*flytec_pbrtl(flytec, manufacturer, igc_filename_format) == 0)\n\t fprintf(stderr, \"%s: no tracklogs to download\\n\", program_name);\n\telse\n\t fprintf(stderr, \"%s: no new tracklogs to download\\n\", program_name);\n }\n}", "label": 1, "cwe": "CWE-other", "length": 629 }, { "index": 8306, "code": "ciconvert (char *filename)\n{\n#if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__\n return;\n#else\n /* Parse all the directories that composes filename */\n char *cur_dir = NULL;\n char *pcur_elt, *pend_of_elt, *pend_of_cur_dir;\n int error = 0;\n \n /* First simply try to open the file, constant complexity. Permits\n decent speed for careful authors who write exact filenames. */\n FILE *f;\n if ((f = fopen(filename, \"r\")) != NULL)\n {\n fclose(f);\n return;\n }\n\n /* Else, check each path element of the filename */\n /* No need to support volumes (\"C:\\\"...) because this function\n already returned in case-insensitive environments (woe&dos) */\n if (filename[0] == '/')\n {\n cur_dir = malloc(strlen(\"/\") + strlen(filename) + 1);\n strcpy(cur_dir, \"/\");\n pend_of_cur_dir = cur_dir + 1;\n }\n else\n {\n cur_dir = malloc(strlen(\"./\") + strlen(filename) + 1);\n strcpy(cur_dir, \"./\");\n pend_of_cur_dir = cur_dir + 2;\n }\n pcur_elt = filename;\n do\n {\n char end_of_elt_backup;\n\n /* skip leading or multiple slashes */\n while (*pcur_elt == '/' || *pcur_elt == '\\\\')\n\t{\n\t *pcur_elt = '/';\n\t pcur_elt++;\n\t}\n\n pend_of_elt = end_of_elt(pcur_elt);\n end_of_elt_backup = *pend_of_elt;\n *pend_of_elt = '\\0';\n /* pcur_elt is now a \\0-terminated string containing the current\n\t path element. */\n \n /* Now check if there's a matching entry in the directory */\n DIR *list;\n struct dirent *entry;\n int found = 0;\n \n list = opendir (cur_dir);\n if (list != NULL)\n\t{\n\t /* note: we may want to sort list first */\n\t while ((entry = readdir (list)) != NULL && !found)\n\t {\n\t if (strcasecmp(pcur_elt, entry->d_name) == 0)\n\t\t{\n\t\t /* Good case-insensitive match: replace the\n\t\t user-provided filename with it */\n\t\t strcpy(pcur_elt, entry->d_name);\n\t\t found = 1;\n\t\t}\n\t }\n\t closedir (list);\n\t}\n if (!found)\n\terror = 1;\n\n /* Prepare parsing next path element, unless the current element\n\t was the last one */\n if (end_of_elt_backup != '\\0')\n\t{\n\t *pend_of_elt = '/'; /* restore */\n\n\t /* Prepare next directory */\n\t {\n\t int cur_elt_len = pend_of_elt - pcur_elt;\n\t strncpy(pend_of_cur_dir, pcur_elt, cur_elt_len + 1);\n\t pend_of_cur_dir += cur_elt_len + 1;\n\t *pend_of_cur_dir = '\\0';\n\t }\n\t \n\t /* go to the next path element */\n\t pcur_elt = pend_of_elt + 1;\n\t}\n }\n while(*pend_of_elt != '\\0' && !error);\n free(cur_dir);\n\n /* If there was an error, we return a half-converted path (maybe the\n file didn't exist yet, but leading directories still needed to be\n converted); otherwise, filename contains the fully-converted\n path, ready to be opened on a case-sensitive filesystem. */\n#endif /* !_WIN32 */\n}", "label": 1, "cwe": [ "CWE-120", "CWE-other" ], "length": 772 }, { "index": 275515, "code": "Dot4Init(mud_channel *pc, int fd)\n{\n mud_device *pd = &msp->device[pc->dindex];\n unsigned char buf[HPMUD_BUFFER_SIZE];\n int stat=0, len, n, cnt;\n DOT4Init *pCmd;\n DOT4InitReply *pReply;\n\n memset(buf, 0, sizeof(DOT4Init));\n pCmd = (DOT4Init *)buf;\n n = sizeof(DOT4Init);\n pCmd->h.length = htons(n);\n pCmd->h.credit = 1; /* transaction credit for reply */\n pCmd->cmd = DOT4_INIT;\n pCmd->rev = 0x20;\n \n if ((len = (pd->vf.write)(fd, pCmd, n, HPMUD_EXCEPTION_TIMEOUT)) != n)\n {\n BUG(\"unable to write DOT4Init: %m\\n\");\n stat = 1;\n goto bugout;\n }\n\n cnt=0;\n while(1)\n {\n stat = Dot4ReverseReply(pc, fd, buf, sizeof(buf));\n pReply = (DOT4InitReply *)buf;\n\n if ((stat != 0) || (pReply->cmd != (0x80 | DOT4_INIT)) || (pReply->result != 0))\n {\n if (errno == EIO && cnt<1)\n {\n /* hack for usblp.c 2.6.5 */\n BUG(\"invalid DOT4InitReply retrying...\\n\");\n sleep(1); \n cnt++;\n continue;\n }\n if (stat == 2 && cnt<1)\n {\n /* hack for Fullhouse, Swami and Northstar */\n BUG(\"invalid DOT4InitReply retrying command...\\n\");\n memset(buf, 0, sizeof(DOT4Init));\n n = sizeof(DOT4Init);\n pCmd->h.length = htons(n);\n pCmd->h.credit = 1; /* transaction credit for reply */\n pCmd->cmd = DOT4_INIT;\n pCmd->rev = 0x20;\n (pd->vf.write)(fd, pCmd, n, HPMUD_EXCEPTION_TIMEOUT);\n cnt++;\n continue;\n }\n BUG(\"invalid DOT4InitReply: cmd=%x, result=%x\\n, revision=%x\\n\", pReply->cmd, pReply->result, pReply->rev);\n stat = 1;\n goto bugout;\n }\n break;\n }\n\nbugout:\n return stat;\n}", "label": 0, "cwe": null, "length": 543 }, { "index": 458048, "code": "watched_accounts_parser(struct nv_pair *nv, int line,\n\tprelude_conf_t *config)\n{\n\tchar *str = (char *)nv->value;\n\tdo {\n\t\tchar *ptr = strchr(str, '-');\n\t\tif (ptr) {\n\t\t\tchar *user1, *user2;\n\t\t\tint start, end, i;\n\n\t\t\tuser1 = str;\n\t\t\t*ptr = 0;\n\t\t\tuser2 = ptr+1;\n\t\t\tif (string_is_numeric(user1)) {\n\t\t\t\tstart = strtoul(user1, NULL, 10);\n\t\t\t} else {\n\t\t\t\tstruct passwd *pw;\n\t\t\t\tpw = getpwnam(user1);\n\t\t\t\tif (pw == NULL) {\n\t\t\t\t\tsyslog(LOG_ERR,\n\t\t\t\t\"user %s is invalid - line %d, skipping\",\n\t\t\t\t\t\tuser1, line);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tstart = pw->pw_uid;\n\t\t\t}\n\t\t\ti = strlen(user2);\n\t\t\tif (i>0 && user2[i-1] == ',')\n\t\t\t\tuser2[i-1] = 0;\n\t\t\tif (string_is_numeric(user2)) {\n\t\t\t\tend = strtoul(user2, NULL, 10);\n\t\t\t} else {\n\t\t\t\tstruct passwd *pw;\n\t\t\t\tpw = getpwnam(user2);\n\t\t\t\tif (pw == NULL) {\n\t\t\t\t\tsyslog(LOG_ERR,\n\t\t\t\t\"user %s is invalid - line %d, skipping\",\n\t\t\t\t\t\tuser2, line);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tend = pw->pw_uid;\n\t\t\t}\n\t\t\tif (start >= end) {\n\t\t\t\tsyslog(LOG_ERR,\n\t\t\t\"%s is larger or equal to %s, please fix, skipping\",\n\t\t\t\t\tuser1, user2);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tfor (i=start; i<=end; i++) {\n\t\t\t\tilist_add_if_uniq(\n\t\t\t\t\t\t&config->watched_accounts, i);\n\t\t\t}\n\t\t} else {\n\t\t\tint acct;\n\t\t\tif (string_is_numeric(str))\n\t\t\t\tacct = strtoul(str, NULL, 10);\n\t\t\telse {\n\t\t\t\tstruct passwd *pw;\n\t\t\t\tpw = getpwnam(str);\n\t\t\t\tif (pw == NULL) {\n\t\t\t\t\tsyslog(LOG_ERR,\n\t\t\t\t\"user %s is invalid - line %d, skipping\",\n\t\t\t\t\t\tstr, line);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tacct = pw->pw_uid;\n\t\t\t}\n\t\t\tilist_add_if_uniq(&config->watched_accounts, acct);\n\t\t}\n\t\tstr = strtok(NULL, \", \");\n\t} while(str);\n\n return 0;\n}", "label": 0, "cwe": null, "length": 531 }, { "index": 110692, "code": "_detailed_output_oem_record (ipmi_sensors_state_data_t *state_data,\n const void *sdr_record,\n unsigned int sdr_record_len,\n uint8_t record_type,\n uint16_t record_id)\n{\n uint32_t manufacturer_id;\n uint8_t oem_data[IPMI_SENSORS_OEM_DATA_LEN];\n int len = 0;\n int i;\n\n assert (state_data);\n assert (sdr_record);\n assert (sdr_record_len);\n assert (state_data->prog_data->args->verbose_count >= 2);\n\n if (_detailed_output_record_type_and_id (state_data,\n record_type,\n record_id) < 0)\n return (-1);\n\n if (_output_manufacturer_id (state_data,\n sdr_record,\n sdr_record_len) < 0)\n return (-1);\n\n if (ipmi_sdr_parse_manufacturer_id (state_data->sdr_parse_ctx,\n sdr_record,\n sdr_record_len,\n &manufacturer_id) < 0)\n {\n pstdout_fprintf (state_data->pstate,\n stderr,\n \"ipmi_sdr_parse_manufacturer_id: %s\\n\",\n ipmi_sdr_parse_ctx_errormsg (state_data->sdr_parse_ctx));\n return (-1);\n }\n\n if ((len = ipmi_sdr_parse_oem_data (state_data->sdr_parse_ctx,\n\t\t\t\t sdr_record,\n\t\t\t\t sdr_record_len,\n\t\t\t\t oem_data,\n\t\t\t\t IPMI_SENSORS_OEM_DATA_LEN)) < 0)\n {\n pstdout_fprintf (state_data->pstate,\n\t\t stderr,\n\t\t \"ipmi_sdr_parse_oem_data: %s\\n\",\n\t\t ipmi_sdr_parse_ctx_errormsg (state_data->sdr_parse_ctx));\n return (-1);\n }\n\n if (len && state_data->prog_data->args->interpret_oem_data)\n {\n int ret;\n\n if (state_data->oem_data.manufacturer_id == IPMI_IANA_ENTERPRISE_ID_INTEL)\n\t{\n\t if ((ret = ipmi_sensors_oem_intel_output_oem_record (state_data,\n\t\t\t\t\t\t\t sdr_record,\n\t\t\t\t\t\t\t sdr_record_len,\n\t\t\t\t\t\t\t manufacturer_id,\n\t\t\t\t\t\t\t oem_data,\n\t\t\t\t\t\t\t len)) < 0)\n\t return (-1);\n\n\t if (ret)\n\t goto out;\n\t}\n\n if (state_data->oem_data.manufacturer_id == IPMI_IANA_ENTERPRISE_ID_INVENTEC)\n\t{\n\t if ((ret = ipmi_sensors_oem_inventec_output_oem_record (state_data,\n\t\t\t\t\t\t\t\t sdr_record,\n\t\t\t\t\t\t\t\t sdr_record_len,\n\t\t\t\t\t\t\t\t manufacturer_id,\n\t\t\t\t\t\t\t\t oem_data,\n\t\t\t\t\t\t\t\t len)) < 0)\n\t return (-1);\n\n\t if (ret)\n\t goto out;\n\t}\n\n if (state_data->oem_data.manufacturer_id == IPMI_IANA_ENTERPRISE_ID_QUANTA)\n\t{\n\t if ((ret = ipmi_sensors_oem_quanta_output_oem_record (state_data,\n\t\t\t\t\t\t\t\tsdr_record,\n\t\t\t\t\t\t\t\tsdr_record_len,\n\t\t\t\t\t\t\t\tmanufacturer_id,\n\t\t\t\t\t\t\t\toem_data,\n\t\t\t\t\t\t\t\tlen)) < 0)\n\t return (-1);\n\n\t if (ret)\n\t goto out;\n\t}\n }\n\n pstdout_printf (state_data->pstate,\n\t\t \"OEM Data: \");\n \n for (i = 0; i < len; i++)\n pstdout_printf (state_data->pstate,\n\t\t \"%02X \",\n\t\t oem_data[i]);\n pstdout_printf (state_data->pstate, \"\\n\");\n\n out: \n pstdout_printf (state_data->pstate, \"\\n\");\n\n return (0);\n}", "label": 0, "cwe": null, "length": 787 }, { "index": 900339, "code": "to_file_format(const Gnome::Gda::Value& value, glom_field_type glom_type)\n{\n //Handle TYPE_IMAGE specially:\n if(glom_type == TYPE_IMAGE)\n {\n if(!value.gobj())\n return Glib::ustring();\n \n gchar* str = 0;\n const GType value_type = value.get_value_type();\n if(value_type == GDA_TYPE_BINARY)\n {\n const GdaBinary* gdabinary = gda_value_get_binary(value.gobj());\n if(!gdabinary)\n return Glib::ustring();\n else\n {\n str = gda_binary_to_string(gdabinary, 0);\n }\n }\n else if(value_type == GDA_TYPE_BLOB)\n {\n const GdaBlob* gdablob = gda_value_get_blob(value.gobj());\n if(!gdablob)\n return Glib::ustring();\n else\n {\n str = gda_blob_to_string(const_cast(gdablob), 0);\n }\n }\n\n if(!str)\n return Glib::ustring();\n\n Glib::ustring result = (str) ? \n Glib::ustring(Glib::ScopedPtr(str).get()) : Glib::ustring();\n\n //Correction for text representations of image (binary) data:\n //Avoid arbitrary newlines in this text.\n //See libgda bug: https://bugzilla.gnome.org/show_bug.cgi?id=597390\n result = Utils::string_replace(result, \"\\n\", \"\\\\012\");\n\n //Avoid arbitrary newlines in this text.\n //See libgda bug: https://bugzilla.gnome.org/show_bug.cgi?id=597390\n result = Utils::string_replace(result, \"\\r\", \"\\\\015\");\n\n //Escape any quotes in this text:\n //See libgda bug: https://bugzilla.gnome.org/show_bug.cgi?id=597390\n return Utils::string_replace(result, \"\\\"\", \"\\\\042\");\n }\n \n NumericFormat format_ignored; //Because we use ISO format.\n const Glib::ustring result = Conversions::get_text_for_gda_value(glom_type, value, std::locale::classic() /* SQL uses the C locale */, format_ignored, true /* ISO standard */);\n \n //Escape \" as \"\", as specified by the CSV RFC:\n return Utils::string_replace(result, GLOM_QUOTE_FOR_FILE_FORMAT, GLOM_QUOTE_FOR_FILE_FORMAT GLOM_QUOTE_FOR_FILE_FORMAT);\n}", "label": 0, "cwe": null, "length": 544 }, { "index": 807732, "code": "csv_import_read_file (const gchar *filename, const gchar *parser_regexp,\n GtkListStore *store, guint max_rows )\n{\n FILE *f;\n char *line;\n gchar *line_utf8, *temp;\n GMatchInfo *match_info;\n GError *err;\n GRegex *regexpat;\n int row = 0;\n gboolean match_found = FALSE;\n\n // model\n GtkTreeIter iter;\n\n f = g_fopen (filename, \"rt\");\n if (!f)\n {\n //gnc_error_dialog( 0, _(\"File %s cannot be opened.\"), filename );\n return RESULT_OPEN_FAILED;\n }\n\n // compile the regular expression and check for errors\n err = NULL;\n regexpat =\n g_regex_new (parser_regexp, G_REGEX_EXTENDED | G_REGEX_OPTIMIZE | G_REGEX_DUPNAMES, 0, &err);\n if (err != NULL)\n {\n GtkWidget *dialog;\n gchar *errmsg;\n\n errmsg = g_strdup_printf (_(\"Error in regular expression '%s':\\n%s\"),\n parser_regexp, err->message);\n g_error_free (err);\n err = NULL;\n\n dialog = gtk_message_dialog_new (NULL,\n GTK_DIALOG_MODAL,\n GTK_MESSAGE_ERROR,\n GTK_BUTTONS_OK, \"%s\", errmsg);\n gtk_dialog_run (GTK_DIALOG (dialog));\n gtk_widget_destroy (dialog);\n g_free (errmsg);\n errmsg = 0;\n\n fclose (f);\n return RESULT_ERROR_IN_REGEXP;\n }\n\n // start the import\n#define buffer_size 1000\n line = g_malloc0 (buffer_size);\n while (!feof (f))\n {\n int l;\n row++;\n if (row == max_rows)\n break;\n // read one line\n if (!fgets (line, buffer_size, f))\n break;\t\t\t// eof\n // now strip the '\\n' from the end of the line\n l = strlen (line);\n if ((l > 0) && (line[l - 1] == '\\n'))\n line[l - 1] = 0;\n\n // convert line from locale into utf8\n line_utf8 = g_locale_to_utf8 (line, -1, NULL, NULL, NULL);\n\n // parse the line\n match_info = NULL;\t// it seems, that in contrast to documentation, match_info is not always set -> g_match_info_free will segfault\n if (g_regex_match (regexpat, line_utf8, 0, &match_info))\n {\n match_found = TRUE;\n // fill in the values\n gtk_list_store_append (store, &iter);\n FILL_IN_HELPER (\"type\", TYPE);\n FILL_IN_HELPER (\"full_name\", FULL_NAME);\n FILL_IN_HELPER (\"name\", NAME);\n FILL_IN_HELPER (\"code\", CODE);\n FILL_IN_HELPER (\"description\", DESCRIPTION);\n FILL_IN_HELPER (\"color\", COLOR);\n FILL_IN_HELPER (\"notes\", NOTES);\n FILL_IN_HELPER (\"commoditym\", COMMODITYM);\n FILL_IN_HELPER (\"commodityn\", COMMODITYN);\n FILL_IN_HELPER (\"hidden\", HIDDEN);\n FILL_IN_HELPER (\"tax\", TAX);\n FILL_IN_HELPER (\"place_holder\", PLACE_HOLDER);\n gtk_list_store_set (store, &iter, ROW_COLOR, NULL, -1);\n }\n\n g_match_info_free (match_info);\n match_info = 0;\n g_free (line_utf8);\n line_utf8 = 0;\n }\n g_free (line);\n line = 0;\n\n g_regex_unref (regexpat);\n regexpat = 0;\n fclose (f);\n if (match_found == TRUE)\n return MATCH_FOUND;\n else\n return RESULT_OK;\n}", "label": 0, "cwe": null, "length": 824 }, { "index": 97920, "code": "vf610_adc_sample_set(struct vf610_adc *info)\n{\n\tstruct vf610_adc_feature *adc_feature = &(info->adc_feature);\n\tint cfg_data, gc_data;\n\n\tcfg_data = readl(info->regs + VF610_REG_ADC_CFG);\n\tgc_data = readl(info->regs + VF610_REG_ADC_GC);\n\n\t/* resolution mode */\n\tcfg_data &= ~VF610_ADC_MODE_MASK;\n\tswitch (adc_feature->res_mode) {\n\tcase 8:\n\t\tcfg_data |= VF610_ADC_MODE_BIT8;\n\t\tbreak;\n\tcase 10:\n\t\tcfg_data |= VF610_ADC_MODE_BIT10;\n\t\tbreak;\n\tcase 12:\n\t\tcfg_data |= VF610_ADC_MODE_BIT12;\n\t\tbreak;\n\tdefault:\n\t\tdev_err(info->dev, \"error resolution mode\\n\");\n\t\tbreak;\n\t}\n\n\t/* clock select and clock divider */\n\tcfg_data &= ~(VF610_ADC_CLK_MASK | VF610_ADC_ADCCLK_MASK);\n\tswitch (adc_feature->clk_div) {\n\tcase 1:\n\t\tbreak;\n\tcase 2:\n\t\tcfg_data |= VF610_ADC_CLK_DIV2;\n\t\tbreak;\n\tcase 4:\n\t\tcfg_data |= VF610_ADC_CLK_DIV4;\n\t\tbreak;\n\tcase 8:\n\t\tcfg_data |= VF610_ADC_CLK_DIV8;\n\t\tbreak;\n\tcase 16:\n\t\tswitch (adc_feature->clk_sel) {\n\t\tcase VF610_ADCIOC_BUSCLK_SET:\n\t\t\tcfg_data |= VF610_ADC_BUSCLK2_SEL | VF610_ADC_CLK_DIV8;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tdev_err(info->dev, \"error clk divider\\n\");\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\t}\n\n\t/*\n\t * Set ADLSMP and ADSTS based on the Long Sample Time Adder value\n\t * determined.\n\t */\n\tswitch (adc_feature->lst_adder_index) {\n\tcase VF610_ADCK_CYCLES_3:\n\t\tbreak;\n\tcase VF610_ADCK_CYCLES_5:\n\t\tcfg_data |= VF610_ADC_ADSTS_SHORT;\n\t\tbreak;\n\tcase VF610_ADCK_CYCLES_7:\n\t\tcfg_data |= VF610_ADC_ADSTS_NORMAL;\n\t\tbreak;\n\tcase VF610_ADCK_CYCLES_9:\n\t\tcfg_data |= VF610_ADC_ADSTS_LONG;\n\t\tbreak;\n\tcase VF610_ADCK_CYCLES_13:\n\t\tcfg_data |= VF610_ADC_ADLSMP_LONG;\n\t\tbreak;\n\tcase VF610_ADCK_CYCLES_17:\n\t\tcfg_data |= VF610_ADC_ADLSMP_LONG;\n\t\tcfg_data |= VF610_ADC_ADSTS_SHORT;\n\t\tbreak;\n\tcase VF610_ADCK_CYCLES_21:\n\t\tcfg_data |= VF610_ADC_ADLSMP_LONG;\n\t\tcfg_data |= VF610_ADC_ADSTS_NORMAL;\n\t\tbreak;\n\tcase VF610_ADCK_CYCLES_25:\n\t\tcfg_data |= VF610_ADC_ADLSMP_LONG;\n\t\tcfg_data |= VF610_ADC_ADSTS_NORMAL;\n\t\tbreak;\n\tdefault:\n\t\tdev_err(info->dev, \"error in sample time select\\n\");\n\t}\n\n\t/* update hardware average selection */\n\tcfg_data &= ~VF610_ADC_AVGS_MASK;\n\tgc_data &= ~VF610_ADC_AVGEN;\n\tswitch (adc_feature->sample_rate) {\n\tcase VF610_ADC_SAMPLE_1:\n\t\tbreak;\n\tcase VF610_ADC_SAMPLE_4:\n\t\tgc_data |= VF610_ADC_AVGEN;\n\t\tbreak;\n\tcase VF610_ADC_SAMPLE_8:\n\t\tgc_data |= VF610_ADC_AVGEN;\n\t\tcfg_data |= VF610_ADC_AVGS_8;\n\t\tbreak;\n\tcase VF610_ADC_SAMPLE_16:\n\t\tgc_data |= VF610_ADC_AVGEN;\n\t\tcfg_data |= VF610_ADC_AVGS_16;\n\t\tbreak;\n\tcase VF610_ADC_SAMPLE_32:\n\t\tgc_data |= VF610_ADC_AVGEN;\n\t\tcfg_data |= VF610_ADC_AVGS_32;\n\t\tbreak;\n\tdefault:\n\t\tdev_err(info->dev,\n\t\t\t\"error hardware sample average select\\n\");\n\t}\n\n\twritel(cfg_data, info->regs + VF610_REG_ADC_CFG);\n\twritel(gc_data, info->regs + VF610_REG_ADC_GC);\n}", "label": 0, "cwe": null, "length": 839 }, { "index": 99267, "code": "get_input_image_name (char const * const *templptr, unsigned ith_image)\n/*\n * Construct the i-th image-name using templates.\n * If the template contains a '[' it must be of the form\n * \"prefix[start-end{+,-}step]suffix\"\n * where \"{+,-}step\" is optional.\n * Leading zeros of \"start\" are significant.\n *\n * Example:\n * \"image0[12-01-1].pgm\" yields image012.pgm, image011.pgm, ..., image001.pgm\n *\n * Return value:\n * ptr to name of image 'ith_image' or NULL if ith_image is out of range.\n */\n{\n while (*templptr)\n {\n const char *template = *templptr++;\n char *s;\n\n if (!(s = strchr (template, '['))) /* no template, just a filename */\n {\n\t if (ith_image == 0)\n\t return strdup (template);\n\t else\n\t ith_image--;\n }\n else\t\t\t\t/* template parser */\n {\n\t unsigned n_digits;\t\t/* # of digits in image name no. */\n\t char \t *s2;\n\t char \t *suffix;\t\t/* characters after template end */\n\t char \t prefix [MAXSTRLEN];\t/* chars up to the template start */\n\t unsigned first;\t\t/* first image number */\n\t unsigned last;\t\t/* last image number */\n\t int \t image_num;\t\t/* current image number */\n\t int \t increment = 1;\n\t int \t dummy;\n\n\t strcpy (prefix, template);\n\t prefix [s - template] = '\\0';\n \n\t for (s2 = ++s, n_digits = 0; isdigit (*s2); s2++, n_digits++)\n\t ;\n\t if (sscanf (s, \"%d\", &dummy) == 0 || dummy < 0)\n\t error (\"Input name template conversion failure.\\n\"\n\t\t \"Check spelling of template.\");\n\t first = (unsigned) dummy;\n\t \n\t if (*s2++ != '-')\n\t error (\"Input name template conversion failure.\\n\"\n\t\t \"Check spelling of template.\");\n \n\t for (s = s2; isdigit (*s2); s2++)\n\t ;\n\t if (sscanf (s, \"%d\", &dummy) == 0 || dummy < 0)\n\t error (\"Input name template conversion failure.\\n\"\n\t\t \"Check spelling of template.\");\n\t last = (unsigned) dummy;\n\t \n\t if (*s2 == '+' || *s2 == '-') \n\t {\n\t for (s = s2++; isdigit (*s2); s2++)\n\t ;\n\t if (sscanf (s, \"%d\", &increment) == 0)\n\t error (\"Input name template conversion failure.\\n\"\n\t\t \"Check spelling of template.\");\n\t } \t \n\t if (*s2 != ']')\n\t error (\"Input name template conversion failure.\\n\"\n\t\t \"Check spelling of template.\");\n\t suffix = s2 + 1;\n \n\t image_num = first + increment * ith_image;\n\t if (image_num < 0)\n\t error (\"Input name template conversion failure.\\n\"\n\t\t \"Check spelling of template.\");\n\t \n\t if ((increment > 0 && (unsigned) image_num > last) || \n\t (increment <= 0 && (unsigned) image_num < last))\n\t {\n\t /* TODO: check this */\n\t ith_image -= (last - first) / increment + 1;\n\t }\n\t else\n\t {\n\t char formatstr [MAXSTRLEN]; /* format string for image filename */\n\t char image_name [MAXSTRLEN]; /* image file name to be composed */\n\t \n\t strcpy (formatstr, \"%s%0?d%s\");\n\t formatstr [4] = '0' + (char) n_digits;\n\t sprintf (image_name, formatstr, prefix, image_num, suffix);\n\t return strdup (image_name);\n\t }\n }\n }\n return NULL;\n}", "label": 0, "cwe": null, "length": 846 }, { "index": 296227, "code": "parser_if (args)\n char *args;\n{\n register int i;\n\n /* Push parser state. */\n if (if_stack_depth + 1 >= if_stack_size)\n {\n if (!if_stack)\n\tif_stack = (unsigned char *)xmalloc (if_stack_size = 20);\n else\n\tif_stack = (unsigned char *)xrealloc (if_stack, if_stack_size += 20);\n }\n if_stack[if_stack_depth++] = _rl_parsing_conditionalized_out;\n\n /* If parsing is turned off, then nothing can turn it back on except\n for finding the matching endif. In that case, return right now. */\n if (_rl_parsing_conditionalized_out)\n return 0;\n\n /* Isolate first argument. */\n for (i = 0; args[i] && !whitespace (args[i]); i++);\n\n if (args[i])\n args[i++] = '\\0';\n\n /* Handle \"$if term=foo\" and \"$if mode=emacs\" constructs. If this\n isn't term=foo, or mode=emacs, then check to see if the first\n word in ARGS is the same as the value stored in rl_readline_name. */\n if (rl_terminal_name && _rl_strnicmp (args, \"term=\", 5) == 0)\n {\n char *tem, *tname;\n\n /* Terminals like \"aaa-60\" are equivalent to \"aaa\". */\n tname = savestring (rl_terminal_name);\n tem = strchr (tname, '-');\n if (tem)\n\t*tem = '\\0';\n\n /* Test the `long' and `short' forms of the terminal name so that\n\t if someone has a `sun-cmd' and does not want to have bindings\n\t that will be executed if the terminal is a `sun', they can put\n\t `$if term=sun-cmd' into their .inputrc. */\n _rl_parsing_conditionalized_out = _rl_stricmp (args + 5, tname) &&\n\t\t\t\t\t_rl_stricmp (args + 5, rl_terminal_name);\n xfree (tname);\n }\n#if defined (VI_MODE)\n else if (_rl_strnicmp (args, \"mode=\", 5) == 0)\n {\n int mode;\n\n if (_rl_stricmp (args + 5, \"emacs\") == 0)\n\tmode = emacs_mode;\n else if (_rl_stricmp (args + 5, \"vi\") == 0)\n\tmode = vi_mode;\n else\n\tmode = no_mode;\n\n _rl_parsing_conditionalized_out = mode != rl_editing_mode;\n }\n#endif /* VI_MODE */\n /* Check to see if the first word in ARGS is the same as the\n value stored in rl_readline_name. */\n else if (_rl_stricmp (args, rl_readline_name) == 0)\n _rl_parsing_conditionalized_out = 0;\n else\n _rl_parsing_conditionalized_out = 1;\n return 0;\n}", "label": 0, "cwe": null, "length": 659 }, { "index": 815586, "code": "do_find_more_owl_attack_and_defense_moves(int color, int pos,\n\t\t\t\t\t int move_reason_type, int what)\n{\n int k;\n int dd1 = NO_MOVE;\n int dd2 = NO_MOVE;\n int save_verbose;\n\n gg_assert(stackp == 0);\n \n /* Never consider moves of the send-two-return-one type here. */\n if (send_two_return_one(pos, color))\n return;\n\n /* Never consider moves playing into snapback here. */\n if (playing_into_snapback(pos, color))\n return;\n\n save_verbose = verbose;\n if (verbose > 0)\n verbose --;\n\n if (move_reason_type == STRATEGIC_ATTACK_MOVE\n || move_reason_type == STRATEGIC_DEFEND_MOVE)\n dd1 = what;\n else if (move_reason_type == ATTACK_MOVE\n\t || move_reason_type == ATTACK_MOVE_GOOD_KO\n\t || move_reason_type == ATTACK_MOVE_BAD_KO\n\t || move_reason_type == DEFEND_MOVE\n\t || move_reason_type == DEFEND_MOVE_GOOD_KO\n\t || move_reason_type == DEFEND_MOVE_BAD_KO\n\t || move_reason_type == VITAL_EYE_MOVE)\n dd1 = what;\n else if (move_reason_type == CONNECT_MOVE) {\n int worm1 = conn_worm1[what];\n int worm2 = conn_worm2[what];\n\n dd1 = dragon[worm1].origin;\n dd2 = dragon[worm2].origin;\n if (dd1 == dd2)\n dd2 = NO_MOVE;\n }\n else {\n verbose = save_verbose;\n return;\n }\n\n for (k = 0; k < 2; k++) {\n int dd = (k == 0 ? dd1 : dd2);\n\n if (dd == NO_MOVE)\n continue;\n\n /* Don't care about inessential dragons. */\n if (DRAGON2(dd).safety == INESSENTIAL)\n continue;\n\n if (DRAGON2(dd).owl_status != CRITICAL)\n continue;\n\n if ((move_reason_type == STRATEGIC_ATTACK_MOVE\n\t || move_reason_type == ATTACK_MOVE\n\t || move_reason_type == ATTACK_MOVE_GOOD_KO\n\t || move_reason_type == ATTACK_MOVE_BAD_KO\n\t || (move_reason_type == VITAL_EYE_MOVE\n\t && board[dd] == OTHER_COLOR(color)))\n\t&& !owl_attack_move_reason_known(pos, dd)) {\n int kworm = NO_MOVE;\n int acode = owl_does_attack(pos, dd, &kworm);\n\n if (acode >= DRAGON2(dd).owl_attack_code) {\n\tadd_owl_attack_move(pos, dd, kworm, acode);\n\tif (save_verbose)\n\t gprintf(\"Move at %1m upgraded to owl attack on %1m (%s).\\n\",\n\t\t pos, dd, result_to_string(acode));\n }\n }\n\n if ((move_reason_type == STRATEGIC_DEFEND_MOVE\n\t || move_reason_type == CONNECT_MOVE\n\t || move_reason_type == DEFEND_MOVE\n\t || move_reason_type == DEFEND_MOVE_GOOD_KO\n\t || move_reason_type == DEFEND_MOVE_BAD_KO\n\t || (move_reason_type == VITAL_EYE_MOVE\n\t && board[dd] == color))\n\t&& !owl_defense_move_reason_known(pos, dd)) {\n int kworm = NO_MOVE;\n /* FIXME: Better use owl_connection_defend() for CONNECT_MOVE ? */\n int dcode = owl_does_defend(pos, dd, &kworm);\n\n if (dcode >= DRAGON2(dd).owl_defense_code) {\n\tif (dcode == LOSS)\n\t add_loss_move(pos, dd, kworm);\n\telse\n\t add_owl_defense_move(pos, dd, dcode);\n\tif (save_verbose)\n\t gprintf(\"Move at %1m upgraded to owl defense for %1m (%s).\\n\",\n\t\t pos, dd, result_to_string(dcode));\n }\n }\n }\n\n verbose = save_verbose;\n}", "label": 0, "cwe": null, "length": 854 }, { "index": 239901, "code": "fcntl( int fd, int cmd, void *arg )\n{\n\tint result;\n\tint flags;\n\n\tif( (fd<0) || (fd>=pointer_count) || (pointers[fd]==0) ) {\n\t\terrno = EBADF;\n\t\tresult = -1;\n\t} else switch(cmd) {\n\t\tcase F_GETFD:\n\t\t\tresult = fd_flags[fd];\n\t\t\tbreak;\n\t\tcase F_SETFD:\n\t\t\tfd_flags[fd] = (PTRINT_T)arg;\n\t\t\tresult = 0;\n\t\t\tbreak;\n\t\tcase F_GETFL:\n\t\t\tresult = pointers[fd]->flags;\n\t\t\tbreak;\n\t\tcase F_SETFL:\n\t\t\tflags = (PTRINT_T)arg;\n\t\t\tpointers[fd]->flags = flags;\n\t\t\tflags |= O_NONBLOCK;\n\t\t\tpointers[fd]->file->fcntl(cmd,(void*)(PTRINT_T)flags);\n\t\t\tresult = 0;\n\t\t\tbreak;\n\n\t\t#ifdef F_DUPFD\n\t\tcase F_DUPFD:\n\t\t\tresult = this->search_dup2(fd,(PTRINT_T)arg);\n\t\t\tbreak;\n\t\t#endif\n\n\t\t#ifdef F_DUP2FD\n\t\tcase F_DUP2FD:\n\t\t\tresult = this->dup2(fd,(PTRINT_T)arg);\n\t\t\tbreak;\n\t\t#endif\n\n\t\t/*\n\t\t\tA length of zero to FREESP indicates the file\n\t\t\tshould be truncated at the start value.\n\t\t\tOtherwise, we don't support it.\n\t\t*/\n\n\t\t#ifdef F_FREESP\n\t\tcase F_FREESP:\n\t\t\t{\n\t\t\t\tstruct flock *f = (struct flock *)arg;\n\n\t\t\t\tif( (f->l_whence==0) && (f->l_len==0) ) {\n\t\t\t\t\tresult = this->ftruncate(fd,f->l_start);\n\t\t\t\t} else {\n\t\t\t\t\terrno = ENOSYS;\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t#endif\n\n\t\t#ifdef F_FREESP64\n\t\tcase F_FREESP64:\n\t\t\t{\n\t\t\t\tstruct flock64 *f64 = (struct flock64 *)arg;\n\n\t\t\t\tif( (f64->l_whence==0) && (f64->l_len==0) ) {\n\t\t\t\t\tresult = this->ftruncate(fd,f64->l_start);\n\t\t\t\t} else {\n\t\t\t\t\terrno = ENOSYS;\n\t\t\t\t\tresult = -1;\n\t\t\t\t}\n\t\t\t}\n\t\t\tbreak;\n\t\t#endif\n\n\t\tdefault:\n\t\t\tresult = pointers[fd]->file->fcntl(cmd,arg);\n\t\t\tbreak;\n\t}\n\n\n\treturn result;\n}", "label": 0, "cwe": null, "length": 526 }, { "index": 553963, "code": "gbser_set_port(void* handle, unsigned speed, unsigned bits, unsigned parity, unsigned stop)\n{\n gbser_handle* h = gbser__get_handle(handle);\n speed_t s;\n\n static unsigned bit_flags[] = {\n 0, 0, 0, 0, 0, CS5, CS6, CS7, CS8\n };\n\n if (bits < 5 || bits > 8) {\n fatal(\"Unsupported bits setting: %d\\n\", bits);\n }\n\n if (parity > 2) {\n fatal(\"Unsupported parity setting: %d\\n\", parity);\n }\n\n if (stop < 1 || stop > 2) {\n fatal(\"Unsupported stop setting: %d\\n\", stop);\n }\n\n s = mkspeed(speed);\n\n /* TODO: We don't /fully/ initialise the port's stat here... */\n\n tcgetattr(h->fd, &h->old_tio);\n\n h->new_tio = h->old_tio;\n\n /* clear bits */\n//\tcfmakeraw(&h->new_tio);\n h->new_tio.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP\n |INLCR|IGNCR|ICRNL|IXON);\n h->new_tio.c_oflag &= ~OPOST;\n h->new_tio.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);\n h->new_tio.c_cflag &= ~(CSIZE|PARENB);\n h->new_tio.c_cflag |= CS8;\n\n h->new_tio.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP |\n INLCR | IGNCR | IXON);\n h->new_tio.c_cflag &= ~(CSIZE | PARENB | PARODD | CSTOPB);\n\n /* set data bits, */\n h->new_tio.c_cflag |= bit_flags[bits];\n\n /* stop bits and... */\n if (stop == 2) {\n h->new_tio.c_cflag |= CSTOPB;\n }\n\n /* parity */\n if (parity != 0) {\n h->new_tio.c_cflag |= PARENB;\n if (parity == 1) {\n h->new_tio.c_cflag |= PARODD;\n }\n }\n\n h->new_tio.c_oflag = 0;\n h->new_tio.c_lflag = 0;\n\n h->new_tio.c_cc[VMIN] = h->vmin;\n h->new_tio.c_cc[VTIME] = h->vtime;\n\n cfsetospeed(&h->new_tio, s);\n cfsetispeed(&h->new_tio, s);\n\n return tcsetattr(h->fd, TCSADRAIN, &h->new_tio) ? gbser_ERROR : gbser_OK;\n}", "label": 0, "cwe": null, "length": 642 }, { "index": 185814, "code": "gst_rdt_manager_chain_rdt (GstPad * pad, GstObject * parent, GstBuffer * buffer)\n{\n GstFlowReturn res;\n GstRDTManager *rdtmanager;\n GstRDTManagerSession *session;\n GstClockTime timestamp;\n GstRDTPacket packet;\n guint32 ssrc;\n guint8 pt;\n gboolean more;\n\n rdtmanager = GST_RDT_MANAGER (parent);\n\n GST_DEBUG_OBJECT (rdtmanager, \"got RDT packet\");\n\n ssrc = 0;\n pt = 0;\n\n GST_DEBUG_OBJECT (rdtmanager, \"SSRC %08x, PT %d\", ssrc, pt);\n\n /* find session */\n session = gst_pad_get_element_private (pad);\n\n /* see if we have the pad */\n if (!session->active) {\n activate_session (rdtmanager, session, ssrc, pt);\n session->active = TRUE;\n }\n\n if (GST_BUFFER_IS_DISCONT (buffer)) {\n GST_DEBUG_OBJECT (rdtmanager, \"received discont\");\n session->discont = TRUE;\n }\n\n res = GST_FLOW_OK;\n\n /* take the timestamp of the buffer. This is the time when the packet was\n * received and is used to calculate jitter and clock skew. We will adjust\n * this timestamp with the smoothed value after processing it in the\n * jitterbuffer. */\n timestamp = GST_BUFFER_TIMESTAMP (buffer);\n /* bring to running time */\n timestamp = gst_segment_to_running_time (&session->segment, GST_FORMAT_TIME,\n timestamp);\n\n more = gst_rdt_buffer_get_first_packet (buffer, &packet);\n while (more) {\n GstRDTType type;\n\n type = gst_rdt_packet_get_type (&packet);\n GST_DEBUG_OBJECT (rdtmanager, \"Have packet of type %04x\", type);\n\n if (GST_RDT_IS_DATA_TYPE (type)) {\n GST_DEBUG_OBJECT (rdtmanager, \"We have a data packet\");\n res = gst_rdt_manager_handle_data_packet (session, timestamp, &packet);\n } else {\n switch (type) {\n default:\n GST_DEBUG_OBJECT (rdtmanager, \"Ignoring packet\");\n break;\n }\n }\n if (res != GST_FLOW_OK)\n break;\n\n more = gst_rdt_packet_move_to_next (&packet);\n }\n\n gst_buffer_unref (buffer);\n\n return res;\n}", "label": 0, "cwe": null, "length": 515 }, { "index": 872267, "code": "ICDrmgroup(NEWSGROUP *ngp)\n{\n struct iovec iov[2];\n int i;\n bool ret;\n char *Name;\n\n /* Don't let anyone remove newsgroups that INN requires exist. */\n if (strcmp(ngp->Name, \"junk\") == 0 || strcmp(ngp->Name, \"control\") == 0\n || strcmp(ngp->Name, \"control.cancel\") == 0)\n return false;\n if (innconf->mergetogroups && strcmp(ngp->Name, \"to\") == 0)\n return false;\n\n Name = xstrdup(ngp->Name);\n /* If this is the first group in the file, write everything after. */\n if (ngp == &Groups[0]) {\n\ti = ngp[1].Start;\n\tICDiovset(&iov[0], &ICDactpointer[i], ICDactsize - i);\n\tret = ICDwritevactive(iov, 1);\n\tICDiovrelease(&iov[0]);\n\tif (ret) {\n\t if (innconf->enableoverview && !OVgroupdel(Name)) {\n\t\tfree(Name);\n\t\treturn false;\n\t }\n\t}\n\tfree(Name);\n\treturn ret;\n }\n\n /* Write everything up to this group. */\n ICDiovset(&iov[0], ICDactpointer, ngp->Start);\n\n /* If this is the last group, that's all we have to write. */\n if (ngp == &Groups[nGroups - 1]) {\n\tret = ICDwritevactive(iov, 1);\n\tICDiovrelease(&iov[0]);\n\tif (ret) {\n\t if (innconf->enableoverview && !OVgroupdel(Name)) {\n\t\tfree(Name);\n\t\treturn false;\n\t }\n\t}\n\tfree(Name);\n\treturn ret;\n }\n\n /* Write everything after this group. */\n i = ngp[1].Start;\n ICDiovset(&iov[1], &ICDactpointer[i], ICDactsize - i);\n ret = ICDwritevactive(iov, 2);\n ICDiovrelease(&iov[0]);\n ICDiovrelease(&iov[1]);\n if (ret) {\n\tif (innconf->enableoverview && !OVgroupdel(Name)) {\n\t free(Name);\n\t return false;\n\t}\n }\n free(Name);\n return ret;\n}", "label": 1, "cwe": [ "CWE-469", "CWE-other" ], "length": 518 }, { "index": 846328, "code": "create_index(const IndexOptions *options) {\n int i=0;\n IndexWriter *writer=NULL;\n FileList *file_list=NULL;\n SGREPDATA(options);\n\n file_list=new_flist(sgrep);\n if (options->file_list_files) {\n\tflist_add_file_list_files(file_list,options->file_list_files);\n }\n if (options->file_list) {\n\tflist_cat(file_list,options->file_list);\n }\n flist_ready(file_list);\n if (flist_files(file_list)==0) {\n\tsgrep_error(sgrep,\"No files to index.\\n\");\n\tgoto error;\n }\n writer=new_index_writer(options);\n if (writer==NULL) goto error;\n writer->file_list=file_list;\n\n /* Check if we have a list of stop words */\n if (writer->options->input_stop_word_file) {\n\tif (read_stop_word_file(writer,\n\t\t\t\twriter->options->input_stop_word_file)==SGREP_ERROR) {\n\t goto error;\n\t}\n }\n\n if (index_search(writer->sgrep,writer,writer->file_list)==SGREP_ERROR) {\n\tgoto error;\n }\n\n /* index_stream(stdin); */\n /* FIXME: move this \"f\" thing to pmatch.c */ \n {\n\tSgrepString *s=new_string(sgrep,1024);\n\tfor(i=0;ifile_list);i++) {\n\t string_clear(s);\n\t string_cat(s,\"f\");\n\t string_cat(s,flist_name(writer->file_list,i));\n\t /* fprintf(stderr,\"Adding index file term %s\\n\",string_to_char(s)); */\n\t if (add_region_to_index(writer,\n\t\t\t\t string_to_char(s),\n\t\t\t\t flist_start(writer->file_list,i),\n\t\t\t\t flist_start(writer->file_list,i)+\n\t\t\t\t flist_length(writer->file_list,i)-1)\n\t\t==SGREP_ERROR) {\n\t\tgoto error;\n\t }\n\t}\n\tdelete_string(s);\n }\n\n\n writer->stream=fopen(writer->options->file_name,\"wb\");\n if (writer->stream==NULL) {\n\tsgrep_error(sgrep,\"Can't open '%s' for writing:%s\\n\",\n\t\t writer->options->file_name,strerror(errno));\n\tgoto error;\n }\n\n if (write_index(writer)==SGREP_ERROR) {\n\tgoto error;\n }\n\n fclose(writer->stream);\n writer->stream=NULL;\n\n if (writer->options->index_stats) {\n\tdisplay_index_statistics(writer);\n\tsgrep_error(sgrep,\"Indexed %d files having %dK total size\\n\",\n\t\t flist_files(writer->file_list), \n\t\t flist_total(writer->file_list)/1024);\n }\n \n if (writer->file_list) {\n\tdelete_flist(writer->file_list);\n }\n delete_index_writer(writer);\n return SGREP_OK;\n\n error:\n if (file_list) {\n\tdelete_flist(file_list);\n }\n if (writer && writer->stream) {\n\tfclose(writer->stream);\n\tremove(writer->options->file_name);\n }\n if (writer) delete_index_writer(writer);\n return SGREP_ERROR;\n}", "label": 1, "cwe": "CWE-other", "length": 643 }, { "index": 481712, "code": "__smb_send_rqst(struct TCP_Server_Info *server, struct smb_rqst *rqst)\n{\n\tint rc;\n\tstruct kvec *iov = rqst->rq_iov;\n\tint n_vec = rqst->rq_nvec;\n\tunsigned int smb_buf_length = get_rfc1002_length(iov[0].iov_base);\n\tunsigned long send_length;\n\tunsigned int i;\n\tsize_t total_len = 0, sent;\n\tstruct socket *ssocket = server->ssocket;\n\tint val = 1;\n\n\tif (ssocket == NULL)\n\t\treturn -ENOTSOCK;\n\n\t/* sanity check send length */\n\tsend_length = rqst_len(rqst);\n\tif (send_length != smb_buf_length + 4) {\n\t\tWARN(1, \"Send length mismatch(send_length=%lu smb_buf_length=%u)\\n\",\n\t\t\tsend_length, smb_buf_length);\n\t\treturn -EIO;\n\t}\n\n\tif (n_vec < 2)\n\t\treturn -EIO;\n\n\tcifs_dbg(FYI, \"Sending smb: smb_len=%u\\n\", smb_buf_length);\n\tdump_smb(iov[0].iov_base, iov[0].iov_len);\n\tdump_smb(iov[1].iov_base, iov[1].iov_len);\n\n\t/* cork the socket */\n\tkernel_setsockopt(ssocket, SOL_TCP, TCP_CORK,\n\t\t\t\t(char *)&val, sizeof(val));\n\n\trc = smb_send_kvec(server, iov, n_vec, &sent);\n\tif (rc < 0)\n\t\tgoto uncork;\n\n\ttotal_len += sent;\n\n\t/* now walk the page array and send each page in it */\n\tfor (i = 0; i < rqst->rq_npages; i++) {\n\t\tstruct kvec p_iov;\n\n\t\tcifs_rqst_page_to_kvec(rqst, i, &p_iov);\n\t\trc = smb_send_kvec(server, &p_iov, 1, &sent);\n\t\tkunmap(rqst->rq_pages[i]);\n\t\tif (rc < 0)\n\t\t\tbreak;\n\n\t\ttotal_len += sent;\n\t}\n\nuncork:\n\t/* uncork it */\n\tval = 0;\n\tkernel_setsockopt(ssocket, SOL_TCP, TCP_CORK,\n\t\t\t\t(char *)&val, sizeof(val));\n\n\tif ((total_len > 0) && (total_len != smb_buf_length + 4)) {\n\t\tcifs_dbg(FYI, \"partial send (wanted=%u sent=%zu): terminating session\\n\",\n\t\t\t smb_buf_length + 4, total_len);\n\t\t/*\n\t\t * If we have only sent part of an SMB then the next SMB could\n\t\t * be taken as the remainder of this one. We need to kill the\n\t\t * socket so the server throws away the partial SMB\n\t\t */\n\t\tserver->tcpStatus = CifsNeedReconnect;\n\t}\n\n\tif (rc < 0 && rc != -EINTR)\n\t\tcifs_dbg(VFS, \"Error %d sending data on socket to server\\n\",\n\t\t\t rc);\n\telse\n\t\trc = 0;\n\n\treturn rc;\n}", "label": 0, "cwe": null, "length": 640 }, { "index": 783257, "code": "test_compound_6()\n{\n typedef struct {\n\tshort b;\n\tshort d;\n } src_typ_t;\n\n typedef struct {\n\tlong b;\n\tlong d;\n } dst_typ_t;\n\n src_typ_t\t *s_ptr;\n dst_typ_t\t *d_ptr;\n int\t\t i;\n const int\t nelmts = NTESTELEM;\n unsigned char *buf=NULL, *orig=NULL, *bkg=NULL;\n\n // Output message about test being performed\n SUBTEST(\"Compound Element Growing\");\n try {\n\t/* Sizes should be the same, but be careful just in case */\n\tbuf = (unsigned char*)malloc(nelmts * MAX(sizeof(src_typ_t), sizeof(dst_typ_t)));\n\tbkg = (unsigned char*)malloc(nelmts * sizeof(dst_typ_t));\n\torig = (unsigned char*)malloc(nelmts * sizeof(src_typ_t));\n\tfor (i=0; ib = (i*8+1) & 0x7fff;\n\t s_ptr->d = (i*8+6) & 0x7fff;\n\t}\n\tmemcpy(buf, orig, nelmts*sizeof(src_typ_t));\n\n\t/* Build hdf5 datatypes */\n\tCompType st(sizeof(src_typ_t));\n\tst.insertMember(\"b\", HOFFSET(src_typ_t, b), PredType::NATIVE_SHORT);\n\tst.insertMember(\"d\", HOFFSET(src_typ_t, d), PredType::NATIVE_SHORT);\n\n\tCompType dt(sizeof(dst_typ_t));\n\tdt.insertMember(\"b\", HOFFSET(dst_typ_t, b), PredType::NATIVE_LONG);\n\tdt.insertMember(\"d\", HOFFSET(dst_typ_t, d), PredType::NATIVE_LONG);\n\n\t/* Perform the conversion */\n\tst.convert(dt, (size_t)nelmts, buf, bkg);\n\n\t/* Compare results */\n\tfor (i=0; ib != d_ptr->b ||\n\t\ts_ptr->d != d_ptr->d)\n\t {\n\t\tH5_FAILED();\n\t\tcerr << \" i=\" << i << endl;\n\t\tcerr << \" src={b=\" << s_ptr->b << \", d=\" << s_ptr->d\n\t\t << \"}\" << endl;\n\t\tcerr << \" dst={b=\" << d_ptr->b << \", d=\" << d_ptr->d\n\t\t << \"}\" << endl;\n\t } // if\n\t} // for\n\n\t/* Release resources */\n\tfree(buf);\n\tfree(bkg);\n\tfree(orig);\n\ts_ptr = NULL;\n\td_ptr = NULL;\n\tst.close();\n\tdt.close();\n\tPASSED();\n } // end of try block\n\n catch (Exception E) {\ncerr << \"test_compound_6 in catch\" << endl;\n issue_fail_msg(E.getCFuncName(), __LINE__, __FILE__, E.getCDetailMsg());\n }\n}", "label": 0, "cwe": null, "length": 653 }, { "index": 810948, "code": "write_data_block(struct archive_write_disk *a, const char *buff, size_t size)\n{\n uint64_t start_size = size;\n ssize_t bytes_written = 0;\n ssize_t block_size = 0, bytes_to_write;\n\n if (size == 0)\n return (ARCHIVE_OK);\n\n if (a->filesize == 0 || a->fd < 0) {\n archive_set_error(&a->archive, 0,\n \"Attempt to write to an empty file\");\n return (ARCHIVE_WARN);\n }\n\n if (a->flags & ARCHIVE_EXTRACT_SPARSE) {\n#if HAVE_STRUCT_STAT_ST_BLKSIZE\n int r;\n if ((r = _archive_write_disk_lazy_stat(a)) != ARCHIVE_OK)\n return (r);\n block_size = a->pst->st_blksize;\n#else\n /* XXX TODO XXX Is there a more appropriate choice here ? */\n /* This needn't match the filesystem allocation size. */\n block_size = 16*1024;\n#endif\n }\n\n /* If this write would run beyond the file size, truncate it. */\n if (a->filesize >= 0 && (off_t)(a->offset + size) > a->filesize)\n start_size = size = (size_t)(a->filesize - a->offset);\n\n /* Write the data. */\n while (size > 0) {\n if (block_size == 0) {\n bytes_to_write = size;\n } else {\n /* We're sparsifying the file. */\n const char *p, *end;\n off_t block_end;\n\n /* Skip leading zero bytes. */\n for (p = buff, end = buff + size; p < end; ++p) {\n if (*p != '\\0')\n break;\n }\n a->offset += p - buff;\n size -= p - buff;\n buff = p;\n if (size == 0)\n break;\n\n /* Calculate next block boundary after offset. */\n block_end\n = (a->offset / block_size + 1) * block_size;\n\n /* If the adjusted write would cross block boundary,\n * truncate it to the block boundary. */\n bytes_to_write = size;\n if (a->offset + bytes_to_write > block_end)\n bytes_to_write = block_end - a->offset;\n }\n /* Seek if necessary to the specified offset. */\n if (a->offset != a->fd_offset) {\n if (lseek(a->fd, a->offset, SEEK_SET) < 0) {\n archive_set_error(&a->archive, errno,\n \"Seek failed\");\n return (ARCHIVE_FATAL);\n }\n a->fd_offset = a->offset;\n a->archive.file_position = a->offset;\n a->archive.raw_position = a->offset;\n }\n bytes_written = write(a->fd, buff, bytes_to_write);\n if (bytes_written < 0) {\n archive_set_error(&a->archive, errno, \"Write failed\");\n return (ARCHIVE_WARN);\n }\n buff += bytes_written;\n size -= bytes_written;\n a->offset += bytes_written;\n a->archive.file_position += bytes_written;\n a->archive.raw_position += bytes_written;\n a->fd_offset = a->offset;\n }\n return (start_size - size);\n}", "label": 0, "cwe": null, "length": 718 }, { "index": 147122, "code": "zDCTE(i_ctx_t *i_ctx_p)\n{\n os_ptr op = osp;\n gs_memory_t *mem = gs_memory_stable(imemory);\n stream_DCT_state state;\n dict_param_list list;\n jpeg_compress_data *jcdp;\n int code;\n const ref *dop;\n uint dspace;\n\n /* First allocate space for IJG parameters. */\n jcdp = gs_alloc_struct_immovable(mem, jpeg_compress_data,\n &st_jpeg_compress_data, \"zDCTE\");\n if (jcdp == 0)\n return_error(e_VMerror);\n state.memory = mem;\n if (s_DCTE_template.set_defaults)\n (*s_DCTE_template.set_defaults) ((stream_state *) & state);\n state.data.compress = jcdp;\n jcdp->memory = state.jpeg_memory = mem;\t/* set now for allocation */\n state.report_error = filter_report_error;\t/* in case create fails */\n if ((code = gs_jpeg_create_compress(&state)) < 0)\n goto fail;\t\t/* correct to do jpeg_destroy here */\n /* Read parameters from dictionary */\n if (r_has_type(op, t_dictionary))\n dop = op, dspace = r_space(op);\n else\n dop = 0, dspace = 0;\n if ((code = dict_param_list_read(&list, dop, NULL, false, iimemory)) < 0)\n goto fail;\n if ((code = s_DCTE_put_params((gs_param_list *) & list, &state)) < 0)\n goto rel;\n /* Create the filter. */\n jcdp->templat = s_DCTE_template;\n /* Make sure we get at least a full scan line of input. */\n state.scan_line_size = jcdp->cinfo.input_components *\n jcdp->cinfo.image_width;\n state.icc_profile = NULL;\n jcdp->templat.min_in_size =\n max(s_DCTE_template.min_in_size, state.scan_line_size);\n /* Make sure we can write the user markers in a single go. */\n jcdp->templat.min_out_size =\n max(s_DCTE_template.min_out_size, state.Markers.size);\n code = filter_write(i_ctx_p, 0, &jcdp->templat,\n (stream_state *) & state, dspace);\n if (code >= 0)\t\t/* Success! */\n return code;\n /* We assume that if filter_write fails, the stream has not been\n * registered for closing, so s_DCTE_release will never be called.\n * Therefore we free the allocated memory before failing.\n */\nrel:\n iparam_list_release(&list);\nfail:\n gs_jpeg_destroy(&state);\n gs_free_object(mem, jcdp, \"zDCTE fail\");\n return code;\n}", "label": 0, "cwe": null, "length": 624 }, { "index": 9721, "code": "H5G__traverse_special(const H5G_loc_t *grp_loc, const H5O_link_t *lnk,\n unsigned target, size_t *nlinks, hbool_t last_comp,\n H5G_loc_t *obj_loc, hbool_t *obj_exists, hid_t lapl_id, hid_t dxpl_id)\n{\n herr_t ret_value = SUCCEED; /* Return value */\n\n FUNC_ENTER_PACKAGE\n\n /* Sanity check */\n HDassert(grp_loc);\n HDassert(lnk);\n HDassert(obj_loc);\n HDassert(nlinks);\n\n /*\n * If we found a symbolic link then we should follow it. But if this\n * is the last component of the name and the H5G_TARGET_SLINK bit of\n * TARGET is set then we don't follow it.\n */\n if(H5L_TYPE_SOFT == lnk->type &&\n (0 == (target & H5G_TARGET_SLINK) || !last_comp)) {\n if((*nlinks)-- <= 0)\n HGOTO_ERROR(H5E_LINK, H5E_NLINKS, FAIL, \"too many links\")\n if(H5G_traverse_slink(grp_loc, lnk, obj_loc, (target & H5G_TARGET_EXISTS), nlinks, obj_exists, lapl_id, dxpl_id) < 0)\n HGOTO_ERROR(H5E_LINK, H5E_TRAVERSE, FAIL, \"symbolic link traversal failed\")\n } /* end if */\n\n /*\n * If we found a user-defined link then we should follow it. But if this\n * is the last component of the name and the H5G_TARGET_UDLINK bit of\n * TARGET is set then we don't follow it.\n */\n if(lnk->type >= H5L_TYPE_UD_MIN &&\n (0 == (target & H5G_TARGET_UDLINK) || !last_comp) ) {\n if((*nlinks)-- <= 0)\n HGOTO_ERROR(H5E_LINK, H5E_NLINKS, FAIL, \"too many links\")\n if(H5G_traverse_ud(grp_loc, lnk, obj_loc, (target & H5G_TARGET_EXISTS), nlinks, obj_exists, lapl_id, dxpl_id) < 0)\n HGOTO_ERROR(H5E_LINK, H5E_TRAVERSE, FAIL, \"user-defined link traversal failed\")\n } /* end if */\n\n /*\n * Resolve mount points to the mounted group. Do not do this step if\n * the H5G_TARGET_MOUNT bit of TARGET is set and this is the last\n * component of the name.\n *\n * (If this link is a hard link, try to perform mount point traversal)\n *\n * (Note that the soft and external link traversal above can change\n * the status of the object (into a hard link), so don't use an 'else'\n * statement here. -QAK)\n */\n if(H5F_addr_defined(obj_loc->oloc->addr) &&\n (0 == (target & H5G_TARGET_MOUNT) || !last_comp)) {\n if(H5F_traverse_mount(obj_loc->oloc/*in,out*/) < 0)\n HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, \"mount point traversal failed\")\n } /* end if */\n\n /* If the grp_loc is the only thing holding an external file open\n * and obj_loc is in the same file, obj_loc should also hold the\n * file open so that closing the grp_loc doesn't close the file.\n */\n if(grp_loc->oloc->holding_file && grp_loc->oloc->file == obj_loc->oloc->file)\n if(H5O_loc_hold_file(obj_loc->oloc) < 0)\n HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, \"unable to hold file open\")\n\ndone:\n FUNC_LEAVE_NOAPI(ret_value)\n}", "label": 0, "cwe": null, "length": 857 }, { "index": 433443, "code": "getKeyFramesAtTime(const TimeIndex& timeIndex, KeyFrame** keyFrame1, KeyFrame** keyFrame2,\n unsigned short* firstKeyIndex) const\n {\n // Parametric time\n // t1 = time of previous keyframe\n // t2 = time of next keyframe\n Real t1, t2;\n\n Real timePos = timeIndex.getTimePos();\n\n // Find first keyframe after or on current time\n KeyFrameList::const_iterator i;\n if (timeIndex.hasKeyIndex())\n {\n // Global keyframe index available, map to local keyframe index directly.\n assert(timeIndex.getKeyIndex() < mKeyFrameIndexMap.size());\n i = mKeyFrames.begin() + mKeyFrameIndexMap[timeIndex.getKeyIndex()];\n#if OGRE_DEBUG_MODE\n KeyFrame timeKey(0, timePos);\n if (i != std::lower_bound(mKeyFrames.begin(), mKeyFrames.end(), &timeKey, KeyFrameTimeLess()))\n {\n OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,\n \"Optimised key frame search failed\",\n \"AnimationTrack::getKeyFramesAtTime\");\n }\n#endif\n }\n else\n {\n // Wrap time\n Real totalAnimationLength = mParent->getLength();\n assert(totalAnimationLength > 0.0f && \"Invalid animation length!\");\n\n if( timePos > totalAnimationLength && totalAnimationLength > 0.0f )\n timePos = fmod( timePos, totalAnimationLength );\n\n // No global keyframe index, need to search with local keyframes.\n KeyFrame timeKey(0, timePos);\n i = std::lower_bound(mKeyFrames.begin(), mKeyFrames.end(), &timeKey, KeyFrameTimeLess());\n }\n\n if (i == mKeyFrames.end())\n {\n // There is no keyframe after this time, wrap back to first\n *keyFrame2 = mKeyFrames.front();\n t2 = mParent->getLength() + (*keyFrame2)->getTime();\n\n // Use last keyframe as previous keyframe\n --i;\n }\n else\n {\n *keyFrame2 = *i;\n t2 = (*keyFrame2)->getTime();\n\n // Find last keyframe before or on current time\n if (i != mKeyFrames.begin() && timePos < (*i)->getTime())\n {\n --i;\n }\n }\n\n // Fill index of the first key\n if (firstKeyIndex)\n {\n *firstKeyIndex = static_cast(std::distance(mKeyFrames.begin(), i));\n }\n\n *keyFrame1 = *i;\n\n t1 = (*keyFrame1)->getTime();\n\n if (t1 == t2)\n {\n // Same KeyFrame (only one)\n return 0.0;\n }\n else\n {\n return (timePos - t1) / (t2 - t1);\n }\n }", "label": 0, "cwe": null, "length": 635 }, { "index": 286271, "code": "beginAnalysis()\n{\n//\tAddress *entry = NULL;\n\n//\tentry = createAddress32(pef_shared->header32.e_entry);\n\n\tsetLocationTreeOptimizeThreshold(100);\n\tsetSymbolTreeOptimizeThreshold(100);\n\n\t/*\n\t *\tentrypoint\n\t */\n//\tpushAddress(entry, entry);\n\t\n\t/*\n\t *\tgive all sections a descriptive comment:\n\t */\n\n\tPEF_SECTION_HEADER *s32=pef_shared->sheaders.sheaders;\n\tchar blub[100];\n\tfor (uint i=0; i < pef_shared->sheaders.count; i++) {\n\t\tAddress *secaddr;\n\t\tsecaddr = createAddress32(s32->defaultAddress);\n\t\tif (validAddress(secaddr, scvalid)) {\n\t\t\tht_snprintf(blub, sizeof blub, \"; section %d <%s>\", i, getSegmentNameByAddress(secaddr));\n\t\t\taddComment(secaddr, 0, \"\");\n\t\t\taddComment(secaddr, 0, \";******************************************************************\");\n\t\t\taddComment(secaddr, 0, blub);\n\t\t\tht_snprintf(blub, sizeof blub, \"; virtual address %08x virtual size %08x\", s32->defaultAddress, s32->totalSize);\n\t\t\taddComment(secaddr, 0, blub);\n\t\t\tht_snprintf(blub, sizeof blub, \"; file offset %08x file size %08x\", s32->containerOffset, s32->packedSize);\n\t\t\taddComment(secaddr, 0, blub);\n\t\t\taddComment(secaddr, 0, \";******************************************************************\");\n\n\t\t\t// mark end of sections\n\t\t\tht_snprintf(blub, sizeof blub, \"; end of section <%s>\", getSegmentNameByAddress(secaddr));\n\t\t\tAddress *secend_addr = secaddr->clone();\n\t\t\tsecend_addr->add(s32->totalSize);\n\t\t\tnewLocation(secend_addr)->flags |= AF_FUNCTION_END;\n\t\t\taddComment(secend_addr, 0, \"\");\n\t\t\taddComment(secend_addr, 0, \";******************************************************************\");\n\t\t\taddComment(secend_addr, 0, blub);\n\t\t\taddComment(secend_addr, 0, \";******************************************************************\");\n\n\t\t\tvalidarea->add(secaddr, secend_addr);\n\n\t\t\tdelete secend_addr;\n\t\t}\n\t\tdelete secaddr;\n\t\ts32++;\n\t}\n\n/* symbols */\n/*\tfor (uint i=1; isheaders.count; i++) {\n\t\tif ((pef_shared->sheaders.sheaders32[i].sh_type==PEF_SHT_SYMTAB) || (pef_shared->sheaders.sheaders32[i].sh_type==PEF_SHT_DYNSYM)) {\n\t\t\tinitInsertSymbols(i);\n\t\t}\n\t}*/\n/*\tassignSymbol(entry, \"entrypoint\", label_func);\n\taddComment(entry, 0, \"\");\n\taddComment(entry, 0, \";****************************\");\n\taddComment(entry, 0, \"; executable entry point\");\n\taddComment(entry, 0, \";****************************\");*/\n\n\tsetLocationTreeOptimizeThreshold(1000);\n\tsetSymbolTreeOptimizeThreshold(1000);\n//\tdelete entry;\n\t\n\tAnalyser::beginAnalysis();\n}", "label": 0, "cwe": null, "length": 666 }, { "index": 557436, "code": "skx_tad_decode(struct decoded_addr *res)\n{\n\tint i;\n\tu32 base, wayness, chnilvoffset;\n\tint skt_interleave_bit, chn_interleave_bit;\n\tu64 channel_addr;\n\n\tfor (i = 0; i < SKX_MAX_TAD; i++) {\n\t\tSKX_GET_TADBASE(res->dev, res->imc, i, base);\n\t\tSKX_GET_TADWAYNESS(res->dev, res->imc, i, wayness);\n\t\tif (SKX_TAD_BASE(base) <= res->addr && res->addr <= SKX_TAD_LIMIT(wayness))\n\t\t\tgoto tad_found;\n\t}\n\tedac_dbg(0, \"No TAD entry for %llx\\n\", res->addr);\n\treturn false;\n\ntad_found:\n\tres->sktways = SKX_TAD_SKTWAYS(wayness);\n\tres->chanways = SKX_TAD_CHNWAYS(wayness);\n\tskt_interleave_bit = skx_granularity[SKX_TAD_SKT_GRAN(base)];\n\tchn_interleave_bit = skx_granularity[SKX_TAD_CHN_GRAN(base)];\n\n\tSKX_GET_TADCHNILVOFFSET(res->dev, res->imc, res->channel, i, chnilvoffset);\n\tchannel_addr = res->addr - SKX_TAD_OFFSET(chnilvoffset);\n\n\tif (res->chanways == 3 && skt_interleave_bit > chn_interleave_bit) {\n\t\t/* Must handle channel first, then socket */\n\t\tchannel_addr = skx_do_interleave(channel_addr, chn_interleave_bit,\n\t\t\t\t\t\t res->chanways, channel_addr);\n\t\tchannel_addr = skx_do_interleave(channel_addr, skt_interleave_bit,\n\t\t\t\t\t\t res->sktways, channel_addr);\n\t} else {\n\t\t/* Handle socket then channel. Preserve low bits from original address */\n\t\tchannel_addr = skx_do_interleave(channel_addr, skt_interleave_bit,\n\t\t\t\t\t\t res->sktways, res->addr);\n\t\tchannel_addr = skx_do_interleave(channel_addr, chn_interleave_bit,\n\t\t\t\t\t\t res->chanways, res->addr);\n\t}\n\n\tres->chan_addr = channel_addr;\n\n\tedac_dbg(2, \"%llx: chan_addr=%llx sktways=%d chanways=%d\\n\",\n\t\t res->addr, res->chan_addr, res->sktways, res->chanways);\n\treturn true;\n}", "label": 0, "cwe": null, "length": 522 }, { "index": 465384, "code": "bfd_elf64_archive_slurp_armap (bfd *abfd)\n{\n struct artdata *ardata = bfd_ardata (abfd);\n char nextname[17];\n bfd_size_type i, parsed_size, nsymz, stringsize, carsym_size, ptrsize;\n struct areltdata *mapdata;\n bfd_byte int_buf[8];\n char *stringbase;\n bfd_byte *raw_armap = NULL;\n carsym *carsyms;\n bfd_size_type amt;\n\n ardata->symdefs = NULL;\n\n /* Get the name of the first element. */\n i = bfd_bread (nextname, 16, abfd);\n if (i == 0)\n return TRUE;\n if (i != 16)\n return FALSE;\n\n if (bfd_seek (abfd, (file_ptr) - 16, SEEK_CUR) != 0)\n return FALSE;\n\n /* Archives with traditional armaps are still permitted. */\n if (CONST_STRNEQ (nextname, \"/ \"))\n return bfd_slurp_armap (abfd);\n\n if (! CONST_STRNEQ (nextname, \"/SYM64/ \"))\n {\n bfd_has_map (abfd) = FALSE;\n return TRUE;\n }\n\n mapdata = (struct areltdata *) _bfd_read_ar_hdr (abfd);\n if (mapdata == NULL)\n return FALSE;\n parsed_size = mapdata->parsed_size;\n bfd_release (abfd, mapdata);\n\n if (bfd_bread (int_buf, 8, abfd) != 8)\n {\n if (bfd_get_error () != bfd_error_system_call)\n\tbfd_set_error (bfd_error_malformed_archive);\n return FALSE;\n }\n\n nsymz = bfd_getb64 (int_buf);\n stringsize = parsed_size - 8 * nsymz - 8;\n\n carsym_size = nsymz * sizeof (carsym);\n ptrsize = 8 * nsymz;\n\n amt = carsym_size + stringsize + 1;\n ardata->symdefs = (struct carsym *) bfd_zalloc (abfd, amt);\n if (ardata->symdefs == NULL)\n return FALSE;\n carsyms = ardata->symdefs;\n stringbase = ((char *) ardata->symdefs) + carsym_size;\n\n raw_armap = (bfd_byte *) bfd_alloc (abfd, ptrsize);\n if (raw_armap == NULL)\n goto release_symdefs;\n\n if (bfd_bread (raw_armap, ptrsize, abfd) != ptrsize\n || bfd_bread (stringbase, stringsize, abfd) != stringsize)\n {\n if (bfd_get_error () != bfd_error_system_call)\n\tbfd_set_error (bfd_error_malformed_archive);\n goto release_raw_armap;\n }\n\n for (i = 0; i < nsymz; i++)\n {\n carsyms->file_offset = bfd_getb64 (raw_armap + i * 8);\n carsyms->name = stringbase;\n stringbase += strlen (stringbase) + 1;\n ++carsyms;\n }\n *stringbase = '\\0';\n\n ardata->symdef_count = nsymz;\n ardata->first_file_filepos = bfd_tell (abfd);\n /* Pad to an even boundary if you have to. */\n ardata->first_file_filepos += (ardata->first_file_filepos) % 2;\n\n bfd_has_map (abfd) = TRUE;\n bfd_release (abfd, raw_armap);\n\n return TRUE;\n\nrelease_raw_armap:\n bfd_release (abfd, raw_armap);\nrelease_symdefs:\n bfd_release (abfd, ardata->symdefs);\n return FALSE;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 823 }, { "index": 40032, "code": "test_repo_iterator__tree_icase(void)\n{\n\tgit_iterator *i;\n\tgit_tree *head;\n\tgit_iterator_flag_t flag;\n\n\tg_repo = cl_git_sandbox_init(\"icase\");\n\n\tcl_git_pass(git_repository_head_tree(&head, g_repo));\n\n\tflag = GIT_ITERATOR_DONT_IGNORE_CASE;\n\n\t/* auto expand with no tree entries */\n\tcl_git_pass(git_iterator_for_tree(&i, head, flag, \"c\", \"k/D\"));\n\texpect_iterator_items(i, 7, NULL, 7, NULL);\n\tgit_iterator_free(i);\n\n\tcl_git_pass(git_iterator_for_tree(&i, head, flag, \"k\", \"k/Z\"));\n\texpect_iterator_items(i, 3, NULL, 3, NULL);\n\tgit_iterator_free(i);\n\n\t/* auto expand with tree entries */\n\tcl_git_pass(git_iterator_for_tree(\n\t\t&i, head, flag | GIT_ITERATOR_INCLUDE_TREES, \"c\", \"k/D\"));\n\texpect_iterator_items(i, 8, NULL, 8, NULL);\n\tgit_iterator_free(i);\n\n\tcl_git_pass(git_iterator_for_tree(\n\t\t&i, head, flag | GIT_ITERATOR_INCLUDE_TREES, \"k\", \"k/Z\"));\n\texpect_iterator_items(i, 4, NULL, 4, NULL);\n\tgit_iterator_free(i);\n\n\t/* no auto expand (implies trees included) */\n\tcl_git_pass(git_iterator_for_tree(\n\t\t&i, head, flag | GIT_ITERATOR_DONT_AUTOEXPAND, \"c\", \"k/D\"));\n\texpect_iterator_items(i, 5, NULL, 8, NULL);\n\tgit_iterator_free(i);\n\n\tcl_git_pass(git_iterator_for_tree(\n\t\t&i, head, flag | GIT_ITERATOR_DONT_AUTOEXPAND, \"k\", \"k/Z\"));\n\texpect_iterator_items(i, 1, NULL, 4, NULL);\n\tgit_iterator_free(i);\n\n\tflag = GIT_ITERATOR_IGNORE_CASE;\n\n\t/* auto expand with no tree entries */\n\tcl_git_pass(git_iterator_for_tree(&i, head, flag, \"c\", \"k/D\"));\n\texpect_iterator_items(i, 13, NULL, 13, NULL);\n\tgit_iterator_free(i);\n\n\tcl_git_pass(git_iterator_for_tree(&i, head, flag, \"k\", \"k/Z\"));\n\texpect_iterator_items(i, 5, NULL, 5, NULL);\n\tgit_iterator_free(i);\n\n\t/* auto expand with tree entries */\n\tcl_git_pass(git_iterator_for_tree(\n\t\t&i, head, flag | GIT_ITERATOR_INCLUDE_TREES, \"c\", \"k/D\"));\n\texpect_iterator_items(i, 14, NULL, 14, NULL);\n\tgit_iterator_free(i);\n\n\tcl_git_pass(git_iterator_for_tree(\n\t\t&i, head, flag | GIT_ITERATOR_INCLUDE_TREES, \"k\", \"k/Z\"));\n\texpect_iterator_items(i, 6, NULL, 6, NULL);\n\tgit_iterator_free(i);\n\n\t/* no auto expand (implies trees included) */\n\tcl_git_pass(git_iterator_for_tree(\n\t\t&i, head, flag | GIT_ITERATOR_DONT_AUTOEXPAND, \"c\", \"k/D\"));\n\texpect_iterator_items(i, 9, NULL, 14, NULL);\n\tgit_iterator_free(i);\n\n\tcl_git_pass(git_iterator_for_tree(\n\t\t&i, head, flag | GIT_ITERATOR_DONT_AUTOEXPAND, \"k\", \"k/Z\"));\n\texpect_iterator_items(i, 1, NULL, 6, NULL);\n\tgit_iterator_free(i);\n\n\tgit_tree_free(head);\n}", "label": 0, "cwe": null, "length": 731 }, { "index": 62498, "code": "ReadEffectProfileCommon( Collada::Effect& pEffect)\n{\n\twhile( mReader->read())\n\t{\n\t\tif( mReader->getNodeType() == irr::io::EXN_ELEMENT) \n\t\t{\n\t\t\tif( IsElement( \"newparam\"))\t{\n\t\t\t\t// save ID\n\t\t\t\tint attrSID = GetAttribute( \"sid\");\n\t\t\t\tstd::string sid = mReader->getAttributeValue( attrSID);\n\t\t\t\tpEffect.mParams[sid] = EffectParam();\n\t\t\t\tReadEffectParam( pEffect.mParams[sid]);\n\t\t\t} \n\t\t\telse if( IsElement( \"technique\") || IsElement( \"extra\"))\n\t\t\t{\n\t\t\t\t// just syntactic sugar\n\t\t\t}\n\n\t\t\t/* Shading modes */\n\t\t\telse if( IsElement( \"phong\"))\n\t\t\t\tpEffect.mShadeType = Shade_Phong;\n\t\t\telse if( IsElement( \"constant\"))\n\t\t\t\tpEffect.mShadeType = Shade_Constant;\n\t\t\telse if( IsElement( \"lambert\"))\n\t\t\t\tpEffect.mShadeType = Shade_Lambert;\n\t\t\telse if( IsElement( \"blinn\"))\n\t\t\t\tpEffect.mShadeType = Shade_Blinn;\n\n\t\t\t/* Color + texture properties */\n\t\t\telse if( IsElement( \"emission\"))\n\t\t\t\tReadEffectColor( pEffect.mEmissive, pEffect.mTexEmissive);\n\t\t\telse if( IsElement( \"ambient\"))\n\t\t\t\tReadEffectColor( pEffect.mAmbient, pEffect.mTexAmbient);\n\t\t\telse if( IsElement( \"diffuse\"))\n\t\t\t\tReadEffectColor( pEffect.mDiffuse, pEffect.mTexDiffuse);\n\t\t\telse if( IsElement( \"specular\"))\n\t\t\t\tReadEffectColor( pEffect.mSpecular, pEffect.mTexSpecular);\n\t\t\telse if( IsElement( \"reflective\")) {\n\t\t\t\tReadEffectColor( pEffect.mReflective, pEffect.mTexReflective);\n\t\t\t}\n\t\t\telse if( IsElement( \"transparent\")) {\n\t\t\t\tReadEffectColor( pEffect.mTransparent,pEffect.mTexTransparent);\n\t\t\t}\n\t\t\telse if( IsElement( \"shininess\"))\n\t\t\t\tReadEffectFloat( pEffect.mShininess);\n\t\t\telse if( IsElement( \"reflectivity\"))\n\t\t\t\tReadEffectFloat( pEffect.mReflectivity);\n\n\t\t\t/* Single scalar properties */\n\t\t\telse if( IsElement( \"transparency\"))\n\t\t\t\tReadEffectFloat( pEffect.mTransparency);\n\t\t\telse if( IsElement( \"index_of_refraction\"))\n\t\t\t\tReadEffectFloat( pEffect.mRefractIndex);\n\n\t\t\t// GOOGLEEARTH/OKINO extensions \n\t\t\t// -------------------------------------------------------\n\t\t\telse if( IsElement( \"double_sided\"))\n\t\t\t\tpEffect.mDoubleSided = ReadBoolFromTextContent();\n\n\t\t\t// FCOLLADA extensions\n\t\t\t// -------------------------------------------------------\n\t\t\telse if( IsElement( \"bump\")) {\n\t\t\t\taiColor4D dummy;\n\t\t\t\tReadEffectColor( dummy,pEffect.mTexBump);\n\t\t\t}\n\n\t\t\t// MAX3D extensions\n\t\t\t// -------------------------------------------------------\n\t\t\telse if( IsElement( \"wireframe\"))\t{\n\t\t\t\tpEffect.mWireframe = ReadBoolFromTextContent();\n\t\t\t\tTestClosing( \"wireframe\");\n\t\t\t}\n\t\t\telse if( IsElement( \"faceted\"))\t{\n\t\t\t\tpEffect.mFaceted = ReadBoolFromTextContent();\n\t\t\t\tTestClosing( \"faceted\");\n\t\t\t}\n\t\t\telse \n\t\t\t{\n\t\t\t\t// ignore the rest\n\t\t\t\tSkipElement();\n\t\t\t}\n\t\t}\n\t\telse if( mReader->getNodeType() == irr::io::EXN_ELEMENT_END) {\n\t\t\tif( strcmp( mReader->getNodeName(), \"profile_COMMON\") == 0)\n\t\t\t{\n\t\t\t\tbreak;\n\t\t\t} \n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 795 }, { "index": 27060, "code": "drop_pt(void)\n{\n register int child, childr, parent;\n CELL ele, eler;\n register int i;\n\n if (heap_size == 1) {\n\theap_index[1] = -1;\n\theap_size = 0;\n\treturn 0;\n }\n\n /* start with root */\n parent = 1;\n\n /* sift down: move hole back towards bottom of heap */\n /* sift-down routine customised for A * Search logic */\n\n while ((child = GET_CHILD(parent)) <= heap_size) {\n\t/* select child with lower ele, if equal, older child\n\t * older child is older startpoint for flow path, important */\n\tele = alt[astar_pts[child]];\n\tif (child < heap_size) {\n\t childr = child + 1;\n\t i = child + 3;\n\t while (childr <= heap_size && childr < i) {\n\t\teler = alt[astar_pts[childr]];\n\t\t/* get smallest child */\n\t\tif (cmp_pnt(eler, ele, heap_index[childr], heap_index[child])) {\n\t\t child = childr;\n\t\t ele = eler;\n\t\t}\n\t\tchildr++;\n\t }\n\t /* break if childr > last entry? that saves sifting up again\n\t * OTOH, this is another comparison\n\t * we have a max heap height of 20: log(INT_MAX)/log(n children per node)\n\t * that would give us in the worst case 20*2 additional comparisons with 3 children\n\t * the last entry will never go far up again, less than half the way\n\t * so the additional comparisons for going all the way down\n\t * and then a bit up again are likely less than 20*2 */\n\t /* find the error in this reasoning */\n\t}\n\n\t/* move hole down */\n\n\theap_index[parent] = heap_index[child];\n\tastar_pts[parent] = astar_pts[child];\n\tparent = child;\n\n }\n\n /* hole is in lowest layer, move to heap end */\n if (parent < heap_size) {\n\theap_index[parent] = heap_index[heap_size];\n\tastar_pts[parent] = astar_pts[heap_size];\n\n\tele = alt[astar_pts[parent]];\n\t/* sift up last swapped point, only necessary if hole moved to heap end */\n\tsift_up(parent, ele);\n }\n\n /* the actual drop */\n heap_size--;\n\n return 0;\n}", "label": 0, "cwe": null, "length": 514 }, { "index": 146663, "code": "bcm_sysport_resume(struct device *d)\n{\n\tstruct net_device *dev = dev_get_drvdata(d);\n\tstruct bcm_sysport_priv *priv = netdev_priv(dev);\n\tunsigned int i;\n\tu32 reg;\n\tint ret;\n\n\tif (!netif_running(dev))\n\t\treturn 0;\n\n\tumac_reset(priv);\n\n\t/* We may have been suspended and never received a WOL event that\n\t * would turn off MPD detection, take care of that now\n\t */\n\tbcm_sysport_resume_from_wol(priv);\n\n\t/* Initialize both hardware and software ring */\n\tfor (i = 0; i < dev->num_tx_queues; i++) {\n\t\tret = bcm_sysport_init_tx_ring(priv, i);\n\t\tif (ret) {\n\t\t\tnetdev_err(dev, \"failed to initialize TX ring %d\\n\",\n\t\t\t\t i);\n\t\t\tgoto out_free_tx_rings;\n\t\t}\n\t}\n\n\t/* Initialize linked-list */\n\ttdma_writel(priv, TDMA_LL_RAM_INIT_BUSY, TDMA_STATUS);\n\n\t/* Initialize RX ring */\n\tret = bcm_sysport_init_rx_ring(priv);\n\tif (ret) {\n\t\tnetdev_err(dev, \"failed to initialize RX ring\\n\");\n\t\tgoto out_free_rx_ring;\n\t}\n\n\tnetif_device_attach(dev);\n\n\t/* RX pipe enable */\n\ttopctrl_writel(priv, 0, RX_FLUSH_CNTL);\n\n\tret = rdma_enable_set(priv, 1);\n\tif (ret) {\n\t\tnetdev_err(dev, \"failed to enable RDMA\\n\");\n\t\tgoto out_free_rx_ring;\n\t}\n\n\t/* Enable rxhck */\n\tif (priv->rx_chk_en) {\n\t\treg = rxchk_readl(priv, RXCHK_CONTROL);\n\t\treg |= RXCHK_EN;\n\t\trxchk_writel(priv, reg, RXCHK_CONTROL);\n\t}\n\n\trbuf_init(priv);\n\n\t/* Set maximum frame length */\n\tumac_writel(priv, UMAC_MAX_MTU_SIZE, UMAC_MAX_FRAME_LEN);\n\n\t/* Set MAC address */\n\tumac_set_hw_addr(priv, dev->dev_addr);\n\n\tumac_enable_set(priv, CMD_RX_EN, 1);\n\n\t/* TX pipe enable */\n\ttopctrl_writel(priv, 0, TX_FLUSH_CNTL);\n\n\tumac_enable_set(priv, CMD_TX_EN, 1);\n\n\tret = tdma_enable_set(priv, 1);\n\tif (ret) {\n\t\tnetdev_err(dev, \"TDMA timeout!\\n\");\n\t\tgoto out_free_rx_ring;\n\t}\n\n\tphy_resume(priv->phydev);\n\n\tbcm_sysport_netif_start(dev);\n\n\treturn 0;\n\nout_free_rx_ring:\n\tbcm_sysport_fini_rx_ring(priv);\nout_free_tx_rings:\n\tfor (i = 0; i < dev->num_tx_queues; i++)\n\t\tbcm_sysport_fini_tx_ring(priv, i);\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 580 }, { "index": 331164, "code": "SetFromXML(XMLNode job) {\n\n JXMLTOSTRING(Type)\n\n // TODO: find out how to treat IDFromEndpoint in case of pure GLUE2\n \n JXMLTOSTRING(LocalIDFromManager)\n\n /* Earlier the 'JobDescription' element in a XMLNode representing a Job\n * object contained the actual job description, but in GLUE2 the name\n * 'JobDescription' specifies the job description language which was used to\n * describe the job. Due to the name clash we must guess what is meant when\n * parsing the 'JobDescription' element.\n */\n\n // TODO: same for JobDescription\n\n // Parse libarccompute special state format.\n if (job[\"State\"][\"General\"] && job[\"State\"][\"Specific\"]) {\n State.state = (std::string)job[\"State\"][\"Specific\"];\n State.type = JobState::GetStateType((std::string)job[\"State\"][\"General\"]);\n }\n // Only use the first state. ACC modules should set the state them selves.\n else if (job[\"State\"] && job[\"State\"].Size() == 0) {\n State.state = (std::string)job[\"State\"];\n State.type = JobState::OTHER;\n }\n if (job[\"RestartState\"][\"General\"] && job[\"RestartState\"][\"Specific\"]) {\n RestartState.state = (std::string)job[\"RestartState\"][\"Specific\"];\n RestartState.type = JobState::GetStateType((std::string)job[\"RestartState\"][\"General\"]);\n }\n // Only use the first state. ACC modules should set the state them selves.\n else if (job[\"RestartState\"] && job[\"RestartState\"].Size() == 0) {\n RestartState.state = (std::string)job[\"RestartState\"];\n RestartState.type = JobState::OTHER;\n }\n\n JXMLSTRINGTO(int, ExitCode)\n JXMLTOSTRING(ComputingManagerExitCode)\n JXMLTOSTRINGLIST(Error)\n JXMLSTRINGTO(int, WaitingPosition)\n JXMLTOSTRING(UserDomain)\n JXMLTOSTRING(Owner)\n JXMLTOSTRING(LocalOwner)\n JXMLSTRINGTO(long, RequestedTotalWallTime)\n JXMLSTRINGTO(long, RequestedTotalCPUTime)\n JXMLSTRINGTO(int, RequestedSlots)\n JXMLTOSTRINGLIST(RequestedApplicationEnvironment)\n JXMLTOSTRING(StdIn)\n JXMLTOSTRING(StdOut)\n JXMLTOSTRING(StdErr)\n JXMLTOSTRING(LogDir)\n JXMLTOSTRINGLIST(ExecutionNode)\n JXMLTOSTRING(Queue)\n JXMLSTRINGTO(long, UsedTotalWallTime)\n JXMLSTRINGTO(long, UsedTotalCPUTime)\n JXMLSTRINGTO(int, UsedMainMemory)\n JXMLTOTIME(SubmissionTime)\n JXMLTOTIME(ComputingManagerSubmissionTime)\n JXMLTOTIME(StartTime)\n JXMLTOTIME(ComputingManagerEndTime)\n JXMLTOTIME(EndTime)\n JXMLTOTIME(WorkingAreaEraseTime)\n JXMLTOTIME(ProxyExpirationTime)\n JXMLTOSTRING(SubmissionHost)\n JXMLTOSTRING(SubmissionClientName)\n JXMLTOSTRINGLIST(OtherMessages)\n }", "label": 0, "cwe": null, "length": 712 }, { "index": 464324, "code": "btrfs_insert_inode_ref(struct btrfs_trans_handle *trans,\n\t\t\t struct btrfs_root *root,\n\t\t\t const char *name, int name_len,\n\t\t\t u64 inode_objectid, u64 ref_objectid, u64 index)\n{\n\tstruct btrfs_path *path;\n\tstruct btrfs_key key;\n\tstruct btrfs_inode_ref *ref;\n\tunsigned long ptr;\n\tint ret;\n\tint ins_len = name_len + sizeof(*ref);\n\n\tkey.objectid = inode_objectid;\n\tkey.offset = ref_objectid;\n\tkey.type = BTRFS_INODE_REF_KEY;\n\n\tpath = btrfs_alloc_path();\n\tif (!path)\n\t\treturn -ENOMEM;\n\n\tpath->leave_spinning = 1;\n\tpath->skip_release_on_error = 1;\n\tret = btrfs_insert_empty_item(trans, root, path, &key,\n\t\t\t\t ins_len);\n\tif (ret == -EEXIST) {\n\t\tu32 old_size;\n\n\t\tif (find_name_in_backref(path, name, name_len, &ref))\n\t\t\tgoto out;\n\n\t\told_size = btrfs_item_size_nr(path->nodes[0], path->slots[0]);\n\t\tbtrfs_extend_item(root, path, ins_len);\n\t\tref = btrfs_item_ptr(path->nodes[0], path->slots[0],\n\t\t\t\t struct btrfs_inode_ref);\n\t\tref = (struct btrfs_inode_ref *)((unsigned long)ref + old_size);\n\t\tbtrfs_set_inode_ref_name_len(path->nodes[0], ref, name_len);\n\t\tbtrfs_set_inode_ref_index(path->nodes[0], ref, index);\n\t\tptr = (unsigned long)(ref + 1);\n\t\tret = 0;\n\t} else if (ret < 0) {\n\t\tif (ret == -EOVERFLOW) {\n\t\t\tif (find_name_in_backref(path, name, name_len, &ref))\n\t\t\t\tret = -EEXIST;\n\t\t\telse\n\t\t\t\tret = -EMLINK;\n\t\t}\n\t\tgoto out;\n\t} else {\n\t\tref = btrfs_item_ptr(path->nodes[0], path->slots[0],\n\t\t\t\t struct btrfs_inode_ref);\n\t\tbtrfs_set_inode_ref_name_len(path->nodes[0], ref, name_len);\n\t\tbtrfs_set_inode_ref_index(path->nodes[0], ref, index);\n\t\tptr = (unsigned long)(ref + 1);\n\t}\n\twrite_extent_buffer(path->nodes[0], name, ptr, name_len);\n\tbtrfs_mark_buffer_dirty(path->nodes[0]);\n\nout:\n\tbtrfs_free_path(path);\n\n\tif (ret == -EMLINK) {\n\t\tstruct btrfs_super_block *disk_super = root->fs_info->super_copy;\n\t\t/* We ran out of space in the ref array. Need to\n\t\t * add an extended ref. */\n\t\tif (btrfs_super_incompat_flags(disk_super)\n\t\t & BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF)\n\t\t\tret = btrfs_insert_inode_extref(trans, root, name,\n\t\t\t\t\t\t\tname_len,\n\t\t\t\t\t\t\tinode_objectid,\n\t\t\t\t\t\t\tref_objectid, index);\n\t}\n\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 634 }, { "index": 55961, "code": "db_log_verify_app_record(dbenv, dbt, lsnp, op)\n\tDB_ENV *dbenv;\n\tDBT *dbt;\n\tDB_LSN *lsnp;\n\tdb_recops op;\n{\n\tu_int32_t i, len, len2, rectype;\n\tint ret;\n\tu_int8_t ch;\n\tchar *buf, *p;\n\n\tDB_ASSERT(dbenv->env, op == DB_TXN_LOG_VERIFY);\n\tCOMPQUIET(op, DB_TXN_LOG_VERIFY);\n\tch = 0;\n\tret = 0;\n\ti = len = len2 = rectype = 0;\n\tbuf = p = NULL;\n\n\t/*\n\t * Fetch the rectype, which always must be at the beginning of the\n\t * record (if dispatching is to work at all).\n\t */\n\tmemcpy(&rectype, dbt->data, sizeof(rectype));\n\n\t/*\n\t * Applications may wish to customize the output here based on the\n\t * rectype. We just print the entire log record in the generic\n\t * mixed-hex-and-printable format we use for binary data.\n\t */\n\tif ((ret = __os_malloc(dbenv->env,\n\t len = 256 + 2 * dbt->size, &buf)) != 0)\n\t\tgoto err;\n\tmemset(buf, 0, len);\n\tsnprintf(buf, len, DB_STR_A(\"5004\",\n\t \"[%lu][%lu] App-specific log record: %lu\\n\\tdata: \",\n\t \"%lu %lu %lu\"), (u_long)lsnp->file, (u_long)lsnp->offset,\n\t (u_long)rectype);\n\n\t/*\n\t * Each unprintable character takes up several bytes, so be aware of\n\t * memory violation.\n\t */\n\tfor (i = 0; i < dbt->size && len2 < len; i++) {\n\t\tch = ((u_int8_t *)dbt->data)[i];\n\t\tlen2 = (u_int32_t)strlen(buf);\n\t\tp = buf + len2;\n\t\tsnprintf(p, len - len2 - 1,\n\t\t isprint(ch) || ch == 0x0a ? \"%c\" : \"%#x \", ch);\n\t}\n\tlen2 = (u_int32_t)strlen(buf);\n\tp = buf + len2;\n\tsnprintf(p, len - len2 - 1, \"\\n\\n\");\n\t__db_msg(dbenv->env, \"%s\", buf);\n\nerr:\tif (buf != NULL)\n\t\t__os_free(dbenv->env, buf);\n\treturn (ret);\n}", "label": 0, "cwe": null, "length": 532 }, { "index": 985431, "code": "pcice_ew_fill_net(struct fpga_model *model, int y, int *cur_x, int x_dir, struct w_net *net)\n{\n\tRC_CHECK(model);\n\tnet->last_inc = 0;\n\tnet->num_pts = 0;\n\tif (is_atx(X_FABRIC_BRAM_COL|X_FABRIC_MACC_COL, model, *cur_x)) {\n\t\tnet->pt[net->num_pts].name = \n\t\t\tis_atx(X_FABRIC_BRAM_COL, model, *cur_x)\n\t\t\t ? \"BRAM_TTERM_PCICE_IN\" : \"MACCSITE2_TTERM_PCICE_IN\";\n\t\tnet->pt[net->num_pts].start_count = 0;\n\t\tnet->pt[net->num_pts].y = y;\n\t\tnet->pt[net->num_pts].x = *cur_x;\n\t\tnet->num_pts++;\n\t\t*cur_x += x_dir;\n\t}\n\twhile (1) {\n\t\tif (is_atx(X_FABRIC_BRAM_COL|X_FABRIC_MACC_COL, model, *cur_x)) {\n\t\t\tnet->pt[net->num_pts].name = \n\t\t\t\tis_atx(X_FABRIC_BRAM_COL, model, *cur_x)\n\t\t\t\t ? \"BRAM_TTERM_PCICE_OUT\" : \"MACCSITE2_TTERM_PCICE_OUT\";\n\t\t\tnet->pt[net->num_pts].start_count = 0;\n\t\t\tnet->pt[net->num_pts].y = y;\n\t\t\tnet->pt[net->num_pts].x = *cur_x;\n\t\t\tnet->num_pts++;\n\t\t\tbreak;\n\t\t}\n\t\t// todo: special case until is_at() system is better\n\t\tif (y > model->center_y\n\t\t && is_atx(X_FABRIC_LOGIC_COL, model, *cur_x)\n\t\t && is_atx(X_ROUTING_NO_IO, model, (*cur_x)-1))\n\t\t\tnet->pt[net->num_pts].name = \"CLB_EMP_TTERM_PCICE\";\n\t\telse\n\t\t\tnet->pt[net->num_pts].name = model->tmp_str[*cur_x];\n\t\tnet->pt[net->num_pts].start_count = 0;\n\t\tnet->pt[net->num_pts].y = y;\n\t\tnet->pt[net->num_pts].x = *cur_x;\n\t\tnet->num_pts++;\n\t\tif (is_atx(X_LEFT_IO_DEVS_COL|X_RIGHT_IO_DEVS_COL, model, *cur_x)) {\n\t\t\t*cur_x = -1;\n\t\t\tbreak;\n\t\t}\n\t\t*cur_x += x_dir;\n\t}\n\tRC_RETURN(model);\n}", "label": 0, "cwe": null, "length": 563 }, { "index": 190832, "code": "update_icon (ShowDesktopData *sdd)\n{\n int width, height;\n GdkPixbuf *icon;\n GdkPixbuf *scaled;\n int icon_size;\n\tGError *error;\n\tint\t focus_width = 0;\n\tint\t focus_pad = 0;\n\tint\t thickness = 0;\n\tGtkStyleContext *context;\n\tGtkStateFlags state;\n\tGtkBorder padding;\n\n\tif (!sdd->icon_theme)\n\t\treturn;\n\n\tstate = gtk_widget_get_state_flags (sdd->button);\n\tcontext = gtk_widget_get_style_context (sdd->button);\n\tgtk_style_context_get_padding (context, state, &padding);\n\tgtk_style_context_get_style (context,\n\t\t\t \"focus-line-width\", &focus_width,\n\t\t\t \"focus-padding\", &focus_pad,\n\t\t\t NULL);\n\n\tswitch (sdd->orient) {\n\tcase GTK_ORIENTATION_HORIZONTAL:\n\t\tthickness = padding.top + padding.bottom;\n\t\tbreak;\n\tcase GTK_ORIENTATION_VERTICAL:\n\t\tthickness = padding.left + padding.right;\n\t\tbreak;\n\t}\n\n\ticon_size = sdd->size - 2 * (focus_width + focus_pad) - thickness;\n\n\tif (icon_size < 22)\n\t\ticon_size = 16;\n\telse if (icon_size < 32)\n\t\ticon_size = 22;\n\telse if (icon_size < 48)\n\t\ticon_size = 32;\n\n\terror = NULL;\n\ticon = gtk_icon_theme_load_icon (sdd->icon_theme,\n\t\t\t\t\t SHOW_DESKTOP_ICON,\n\t\t\t\t\t icon_size, 0, &error);\n\n\tif (icon == NULL) {\n\t\tg_printerr (_(\"Failed to load %s: %s\\n\"), SHOW_DESKTOP_ICON,\n\t\t\t error ? error->message : _(\"Icon not found\"));\n\t\tif (error) {\n\t\t\tg_error_free (error);\n\t\t\terror = NULL;\n\t\t}\n\n\t\tgtk_image_set_from_stock (GTK_IMAGE (sdd->image),\n\t\t\t\t\t GTK_STOCK_MISSING_IMAGE,\n\t\t\t\t\t GTK_ICON_SIZE_SMALL_TOOLBAR);\n\t\treturn;\n\t}\n\n width = gdk_pixbuf_get_width (icon);\n height = gdk_pixbuf_get_height (icon);\n\n scaled = NULL;\n\n /* Make it fit on the given panel */\n switch (sdd->orient) {\n case GTK_ORIENTATION_HORIZONTAL:\n width = (icon_size * width) / height;\n height = icon_size;\n break;\n case GTK_ORIENTATION_VERTICAL:\n height = (icon_size * height) / width;\n width = icon_size;\n break;\n }\n\n scaled = gdk_pixbuf_scale_simple (icon,\n width, height,\n GDK_INTERP_BILINEAR);\n\n if (scaled != NULL) {\n\t\tgtk_image_set_from_pixbuf (GTK_IMAGE (sdd->image),\n\t\t\t\t\t scaled);\n\t\tg_object_unref (scaled);\n\t} else\n\t\tgtk_image_set_from_pixbuf (GTK_IMAGE (sdd->image),\n\t\t\t\t\t icon);\n\n g_object_unref (icon);\n}", "label": 0, "cwe": null, "length": 601 }, { "index": 12504, "code": "ovlInitLayer( CoreLayer *layer,\n void *driver_data,\n void *layer_data,\n DFBDisplayLayerDescription *description,\n DFBDisplayLayerConfig *config,\n DFBColorAdjustment *adjustment )\n{\n RadeonDriverData *rdrv = (RadeonDriverData*) driver_data;\n RadeonOverlayLayerData *rovl = (RadeonOverlayLayerData*) layer_data;\n volatile u8 *mmio = rdrv->mmio_base;\n DFBScreenDescription dsc;\n \n dfb_screen_get_info( layer->screen, NULL, &dsc );\n if (strstr( dsc.name, \"CRTC2\" ))\n rovl->crtc2 = 1;\n \n rovl->level = 1;\n \n /* fill layer description */\n description->type = DLTF_GRAPHICS | DLTF_VIDEO | DLTF_STILL_PICTURE;\n description->caps = DLCAPS_SURFACE | DLCAPS_SCREEN_LOCATION |\n DLCAPS_BRIGHTNESS | DLCAPS_CONTRAST |\n DLCAPS_SATURATION | DLCAPS_HUE |\n DLCAPS_DST_COLORKEY | DLCAPS_OPACITY |\n DLCAPS_DEINTERLACING | DLCAPS_LEVELS;\n\n snprintf( description->name,\n DFB_DISPLAY_LAYER_DESC_NAME_LENGTH, \n \"Radeon CRTC%c's Overlay\", rovl->crtc2 ? '2' : '1' );\n\n /* set default configuration */\n config->flags = DLCONF_WIDTH | DLCONF_HEIGHT |\n DLCONF_PIXELFORMAT | DLCONF_BUFFERMODE |\n DLCONF_OPTIONS;\n config->width = 640;\n config->height = 480; \n config->pixelformat = DSPF_YUY2;\n config->buffermode = DLBM_FRONTONLY;\n config->options = DLOP_NONE;\n \n /* set default color adjustment */\n adjustment->flags = DCAF_BRIGHTNESS | DCAF_CONTRAST |\n DCAF_SATURATION | DCAF_HUE;\n adjustment->brightness = 0x8000;\n adjustment->contrast = 0x8000;\n adjustment->saturation = 0x8000;\n adjustment->hue = 0x8000;\n\n /* reset overlay */\n radeon_out32( mmio, OV0_SCALE_CNTL, SCALER_SOFT_RESET ); \n radeon_out32( mmio, OV0_AUTO_FLIP_CNTL, 0 );\n radeon_out32( mmio, OV0_DEINTERLACE_PATTERN, 0 );\n radeon_out32( mmio, OV0_EXCLUSIVE_HORZ, 0 ); \n radeon_out32( mmio, OV0_FILTER_CNTL, FILTER_HARDCODED_COEF );\n radeon_out32( mmio, OV0_TEST, 0 );\n \n /* reset color adjustments */\n ovl_set_adjustment( rdrv, rovl, 0, 0, 0, 0 );\n\n return DFB_OK;\n}", "label": 0, "cwe": null, "length": 654 }, { "index": 15761, "code": "xsh_cfg_recover_select_peaks(cpl_table* tab_xy_guess,\n cpl_table* tab_xy_peaks, \n const double factor)\n{\n\n\n int ord=0;\n int nord=0;\n int ord_min=0;\n int ord_max=0;\n int ord_min_peaks=0;\n int ord_max_peaks=0;\n int ord_min_guess=0;\n int ord_max_guess=0;\n\n int npks=0;\n cpl_table* tab_tmp=NULL;\n cpl_table* tab_tmp1=NULL;\n cpl_table* result=NULL;\n int weight_min=0;\n int nrows=0;\n\n check(ord_min_guess=cpl_table_get_column_min(tab_xy_guess,\"ABS_ORD\"));\n check(ord_max_guess=cpl_table_get_column_max(tab_xy_guess,\"ABS_ORD\"));\n\n check(ord_min_peaks=cpl_table_get_column_min(tab_xy_peaks,\"ABS_ORD\"));\n check(ord_max_peaks=cpl_table_get_column_max(tab_xy_peaks,\"ABS_ORD\"));\n ord_min=(ord_min_guess<=ord_min_peaks) ? ord_min_guess : ord_min_peaks;\n ord_max=(ord_max_guess>=ord_max_peaks) ? ord_max_guess : ord_max_peaks;\n\n cpl_table_select_all(tab_xy_peaks);\n\n xsh_msg(\"select lines in order range=[%d,%d]\",ord_min,ord_max);\n //select the line peak sub table having for each order as many entries\n //as in the input table line list. Those are the brighest lines\n for(ord=ord_min;ord<=ord_max;ord++) {\n \n nord=cpl_table_and_selected_int(tab_xy_guess,\"ABS_ORD\",CPL_EQUAL_TO,ord);\n npks=cpl_table_and_selected_int(tab_xy_peaks,\"ABS_ORD\",CPL_EQUAL_TO,ord);\n check(tab_tmp=cpl_table_extract_selected(tab_xy_peaks));\n //xsh_msg(\"ord=%d nord=%d npks=%d\",ord,nord,npks);\n if(npks>nord) {\n weight_min=cpl_table_get_column_min(tab_tmp,\"WEIGHT\");\n check(npks=cpl_table_and_selected_int(tab_tmp,\"WEIGHT\",\n\t\t\t\t\t CPL_NOT_GREATER_THAN,\n\t\t\t\t\t (int)(weight_min+factor*nord)));\n tab_tmp1=cpl_table_extract_selected(tab_tmp);\n //xsh_msg(\"ord=%d nord=%d weight_min=%d thresh=%d npks=%d\",\n // ord,nord,weight_min,(int)(weight_min+factor*nord),npks);\n\n } else {\n tab_tmp1=cpl_table_duplicate(tab_tmp);\n }\n if(ord == ord_min) {\n result=cpl_table_duplicate(tab_tmp1);\n } else {\n nrows=cpl_table_get_nrow(tab_xy_peaks);\n cpl_table_insert(result,tab_tmp1,nrows);\n }\n\n xsh_free_table(&tab_tmp1);\n xsh_free_table(&tab_tmp);\n cpl_table_select_all(tab_xy_peaks);\n cpl_table_select_all(tab_xy_guess);\n }\n \n cleanup:\n xsh_free_table(&tab_tmp1);\n xsh_free_table(&tab_tmp);\n\n if (cpl_error_get_code() != CPL_ERROR_NONE) {\n return NULL;\n } else {\n return result;\n }\n\n\n}", "label": 0, "cwe": null, "length": 704 }, { "index": 119373, "code": "execute()\n{\n bool execResult = true;\n char* tmpByteData = new char[256];\n \n int ret = mpNetClient->recvData(256, tmpByteData);\n if (ret < 0)\n {\n // Do nothing...\n //printf(\"--Nothing received\\n\");\n }\n else if (tmpByteData[0] == -1)\n {\n mSendLength = (unsigned char)tmpByteData[1];\n //printf(\"--Send Length = %d\\n\", mSendLength);\n }\n else if (tmpByteData[0] == 127)\n {\n execResult = false;\n //printf(\"--Game Ended\\n\");\n }\n else\n {\n //printf(\"++Game Updates (%d) of [%d bytes]\\n\", (int)tmpByteData[0], ret);\n int tmpPieceCount = formIntFromByte(tmpByteData + 13);\n for (int i = 0; i < tmpPieceCount; ++i)\n {\n mpGame->getPiece(i)->decodeData((unsigned char*)tmpByteData + 17 + i * 4);\n }\n \n mpGame->getField()->decodeData((unsigned char*)tmpByteData + 18 + tmpPieceCount * 4);\n \n mActionList.clear();\n mpPlayer->think(&mActionList);\n \n GamePlayer_ActionList::iterator it;\n int byteCounter = 0;\n char* tmpSendData = new char[256];\n tmpSendData[byteCounter++] = '|';\n tmpSendData[byteCounter++] = 'r';\n tmpSendData[byteCounter++] = 'p';\n tmpSendData[byteCounter++] = '|';\n if (mSendLength == 0)\n {\n for(it = mActionList.begin(); it != mActionList.end(); it++)\n {\n tmpSendData[byteCounter++] = (char)*it + '0';\n }\n }\n else if (!mActionList.empty())\n {\n for(int i = 0; i < mSendLength; i++)\n {\n tmpSendData[byteCounter++] = (char)mActionList.front() + '0';\n mActionList.pop_front();\n if (mActionList.empty())\n {\n break;\n }\n }\n }\n tmpSendData[byteCounter++] = '|';\n tmpSendData[byteCounter++] = '\\0';\n \n mpNetClient->sendData(byteCounter, tmpSendData);\n //printf(\"Sending : [%s]\\n\", tmpSendData);\n \n delete [] tmpSendData;\n }\n \n delete [] tmpByteData;\n \n return execResult;\n}", "label": 0, "cwe": null, "length": 570 }, { "index": 830579, "code": "apu_dmc (dmc_t * chan)\n{\n int delta_bit;\n\n APU_VOLUME_DECAY (chan->output_vol);\n\n /* only process when channel is alive */\n if (chan->dma_length) {\n chan->phaseacc -= apu->cycle_rate; /* # of cycles per sample */\n\n while (chan->phaseacc < 0) {\n chan->phaseacc += chan->freq;\n\n delta_bit = (chan->dma_length & 7) ^ 7;\n\n if (7 == delta_bit) {\n chan->cur_byte = nes6502_getbyte (chan->address);\n\n /* steal a cycle from CPU */\n nes6502_setdma (1);\n\n if (0xFFFF == chan->address)\n chan->address = 0x8000;\n else\n chan->address++;\n }\n\n if (--chan->dma_length == 0) {\n /* if loop bit set, we're cool to retrigger sample */\n if (chan->looping)\n apu_dmcreload (chan);\n else {\n /* check to see if we should generate an irq */\n if (chan->irq_gen) {\n chan->irq_occurred = TRUE;\n nes6502_irq ();\n }\n\n /* bodge for timestamp queue */\n chan->enabled = FALSE;\n break;\n }\n }\n\n /* positive delta */\n if (chan->cur_byte & (1 << delta_bit)) {\n if (chan->regs[1] < 0x7D) {\n chan->regs[1] += 2;\n chan->output_vol += (2 << 8);\n }\n/*\n if (chan->regs[1] < 0x3F)\n chan->regs[1]++;\n\n chan->output_vol &= ~(0x7E << 8);\n chan->output_vol |= ((chan->regs[1] << 1) << 8);\n*/\n }\n /* negative delta */\n else {\n if (chan->regs[1] > 1) {\n chan->regs[1] -= 2;\n chan->output_vol -= (2 << 8);\n }\n\n/*\n if (chan->regs[1] > 0)\n chan->regs[1]--;\n\n chan->output_vol &= ~(0x7E << 8);\n chan->output_vol |= ((chan->regs[1] << 1) << 8);\n*/\n }\n }\n }\n\n return APU_DMC_OUTPUT;\n}", "label": 0, "cwe": null, "length": 534 }, { "index": 275071, "code": "lowerBITCAST(SDValue Op,\n SelectionDAG &DAG) const {\n SDLoc DL(Op);\n SDValue In = Op.getOperand(0);\n EVT InVT = In.getValueType();\n EVT ResVT = Op.getValueType();\n\n // Convert loads directly. This is normally done by DAGCombiner,\n // but we need this case for bitcasts that are created during lowering\n // and which are then lowered themselves.\n if (auto *LoadN = dyn_cast(In))\n return DAG.getLoad(ResVT, DL, LoadN->getChain(), LoadN->getBasePtr(),\n LoadN->getMemOperand());\n\n if (InVT == MVT::i32 && ResVT == MVT::f32) {\n SDValue In64;\n if (Subtarget.hasHighWord()) {\n SDNode *U64 = DAG.getMachineNode(TargetOpcode::IMPLICIT_DEF, DL,\n MVT::i64);\n In64 = DAG.getTargetInsertSubreg(SystemZ::subreg_h32, DL,\n MVT::i64, SDValue(U64, 0), In);\n } else {\n In64 = DAG.getNode(ISD::ANY_EXTEND, DL, MVT::i64, In);\n In64 = DAG.getNode(ISD::SHL, DL, MVT::i64, In64,\n DAG.getConstant(32, DL, MVT::i64));\n }\n SDValue Out64 = DAG.getNode(ISD::BITCAST, DL, MVT::f64, In64);\n return DAG.getTargetExtractSubreg(SystemZ::subreg_r32,\n DL, MVT::f32, Out64);\n }\n if (InVT == MVT::f32 && ResVT == MVT::i32) {\n SDNode *U64 = DAG.getMachineNode(TargetOpcode::IMPLICIT_DEF, DL, MVT::f64);\n SDValue In64 = DAG.getTargetInsertSubreg(SystemZ::subreg_r32, DL,\n MVT::f64, SDValue(U64, 0), In);\n SDValue Out64 = DAG.getNode(ISD::BITCAST, DL, MVT::i64, In64);\n if (Subtarget.hasHighWord())\n return DAG.getTargetExtractSubreg(SystemZ::subreg_h32, DL,\n MVT::i32, Out64);\n SDValue Shift = DAG.getNode(ISD::SRL, DL, MVT::i64, Out64,\n DAG.getConstant(32, DL, MVT::i64));\n return DAG.getNode(ISD::TRUNCATE, DL, MVT::i32, Shift);\n }\n llvm_unreachable(\"Unexpected bitcast combination\");\n}", "label": 0, "cwe": null, "length": 587 }, { "index": 1007107, "code": "auth_html(const char *host, int port, const char *user_name)\n{\n FILE *fp;\n int need_host = 1;\n if (!user_name)\n\tuser_name = \"\";\n if (!host || !strlen(host))\n\thost = \"\";\n printf(\"Content-Type: text/html\\r\\n\\r\\n\");\n printf(\"\\n\");\n printf(\"Cache Manager Interface\\n\");\n printf(\"\\n\");\n printf(\"

Cache Manager Interface

\\n\");\n printf(\"

This is a WWW interface to the instrumentation interface\\n\");\n printf(\"for the Squid object cache.

\\n\");\n printf(\"
\\n\");\n printf(\"
\\n\", script_name);\n printf(\"\\n\");\n fp = fopen(\"cachemgr.conf\", \"r\");\n if (fp == NULL)\n\tfp = fopen(DEFAULT_CACHEMGR_CONFIG, \"r\");\n if (fp != NULL) {\n\tint servers = 0;\n\tchar config_line[BUFSIZ];\n\twhile (fgets(config_line, BUFSIZ, fp)) {\n\t char *server, *comment;\n\t strtok(config_line, \"\\r\\n\");\n\t if (config_line[0] == '#')\n\t\tcontinue;\n\t if (config_line[0] == '\\0')\n\t\tcontinue;\n\t if ((server = strtok(config_line, \" \\t\")) == NULL)\n\t\tcontinue;\n\t if (strchr(server, '*') || strchr(server, '[') || strchr(server, '?')) {\n\t\tneed_host = -1;\n\t\tcontinue;\n\t }\n\t comment = strtok(NULL, \"\");\n\t if (comment)\n\t\twhile (*comment == ' ' || *comment == '\\t')\n\t\t comment++;\n\t if (!comment || !*comment)\n\t\tcomment = server;\n\t if (!servers) {\n\t\tprintf(\"\\n\");\n\t}\n\tfclose(fp);\n }\n if (need_host) {\n\tif (need_host == 1 && !*host)\n\t host = \"localhost\";\n\tprintf(\"\\n\", host);\n\tprintf(\"\\n\", port);\n }\n printf(\"\\n\", user_name);\n printf(\"\\n\");\n printf(\"
Cache Server:
Cache Host:
Cache Port:
Manager name:
Password:

\\n\");\n printf(\"\\n\");\n printf(\"
\\n\");\n print_trailer();\n}", "label": 0, "cwe": null, "length": 843 }, { "index": 5336, "code": "efx_test_eventq_irq(struct efx_nic *efx,\n\t\t\t struct efx_self_tests *tests)\n{\n\tstruct efx_channel *channel;\n\tunsigned int read_ptr[EFX_MAX_CHANNELS];\n\tunsigned long napi_ran = 0, dma_pend = 0, int_pend = 0;\n\tunsigned long timeout, wait;\n\n\tBUILD_BUG_ON(EFX_MAX_CHANNELS > BITS_PER_LONG);\n\n\tefx_for_each_channel(channel, efx) {\n\t\tread_ptr[channel->channel] = channel->eventq_read_ptr;\n\t\tset_bit(channel->channel, &dma_pend);\n\t\tset_bit(channel->channel, &int_pend);\n\t\tefx_nic_event_test_start(channel);\n\t}\n\n\ttimeout = jiffies + IRQ_TIMEOUT;\n\twait = 1;\n\n\t/* Wait for arrival of interrupts. NAPI processing may or may\n\t * not complete in time, but we can cope in any case.\n\t */\n\tdo {\n\t\tschedule_timeout_uninterruptible(wait);\n\n\t\tefx_for_each_channel(channel, efx) {\n\t\t\tefx_stop_eventq(channel);\n\t\t\tif (channel->eventq_read_ptr !=\n\t\t\t read_ptr[channel->channel]) {\n\t\t\t\tset_bit(channel->channel, &napi_ran);\n\t\t\t\tclear_bit(channel->channel, &dma_pend);\n\t\t\t\tclear_bit(channel->channel, &int_pend);\n\t\t\t} else {\n\t\t\t\tif (efx_nic_event_present(channel))\n\t\t\t\t\tclear_bit(channel->channel, &dma_pend);\n\t\t\t\tif (efx_nic_event_test_irq_cpu(channel) >= 0)\n\t\t\t\t\tclear_bit(channel->channel, &int_pend);\n\t\t\t}\n\t\t\tefx_start_eventq(channel);\n\t\t}\n\n\t\twait *= 2;\n\t} while ((dma_pend || int_pend) && time_before(jiffies, timeout));\n\n\tefx_for_each_channel(channel, efx) {\n\t\tbool dma_seen = !test_bit(channel->channel, &dma_pend);\n\t\tbool int_seen = !test_bit(channel->channel, &int_pend);\n\n\t\ttests->eventq_dma[channel->channel] = dma_seen ? 1 : -1;\n\t\ttests->eventq_int[channel->channel] = int_seen ? 1 : -1;\n\n\t\tif (dma_seen && int_seen) {\n\t\t\tnetif_dbg(efx, drv, efx->net_dev,\n\t\t\t\t \"channel %d event queue passed (with%s NAPI)\\n\",\n\t\t\t\t channel->channel,\n\t\t\t\t test_bit(channel->channel, &napi_ran) ?\n\t\t\t\t \"\" : \"out\");\n\t\t} else {\n\t\t\t/* Report failure and whether either interrupt or DMA\n\t\t\t * worked\n\t\t\t */\n\t\t\tnetif_err(efx, drv, efx->net_dev,\n\t\t\t\t \"channel %d timed out waiting for event queue\\n\",\n\t\t\t\t channel->channel);\n\t\t\tif (int_seen)\n\t\t\t\tnetif_err(efx, drv, efx->net_dev,\n\t\t\t\t\t \"channel %d saw interrupt \"\n\t\t\t\t\t \"during event queue test\\n\",\n\t\t\t\t\t channel->channel);\n\t\t\tif (dma_seen)\n\t\t\t\tnetif_err(efx, drv, efx->net_dev,\n\t\t\t\t\t \"channel %d event was generated, but \"\n\t\t\t\t\t \"failed to trigger an interrupt\\n\",\n\t\t\t\t\t channel->channel);\n\t\t}\n\t}\n\n\treturn (dma_pend || int_pend) ? -ETIMEDOUT : 0;\n}", "label": 0, "cwe": null, "length": 709 }, { "index": 286240, "code": "get_sha1_basic(const char *str, int len, unsigned char *sha1)\n{\n\tstatic const char *warning = \"warning: refname '%.*s' is ambiguous.\\n\";\n\tchar *real_ref = NULL;\n\tint refs_found = 0;\n\tint at, reflog_len;\n\n\tif (len == 40 && !get_sha1_hex(str, sha1))\n\t\treturn 0;\n\n\t/* basic@{time or number} format to query ref-log */\n\treflog_len = at = 0;\n\tif (str[len-1] == '}') {\n\t\tfor (at = 0; at < len - 1; at++) {\n\t\t\tif (str[at] == '@' && str[at+1] == '{') {\n\t\t\t\treflog_len = (len-1) - (at+2);\n\t\t\t\tlen = at;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/* Accept only unambiguous ref paths. */\n\tif (len && ambiguous_path(str, len))\n\t\treturn -1;\n\n\tif (!len && reflog_len) {\n\t\t/* allow \"@{...}\" to mean the current branch reflog */\n\t\trefs_found = dwim_ref(\"HEAD\", 4, sha1, &real_ref);\n\t} else if (reflog_len)\n\t\trefs_found = dwim_log(str, len, sha1, &real_ref);\n\telse\n\t\trefs_found = dwim_ref(str, len, sha1, &real_ref);\n\n\tif (!refs_found)\n\t\treturn -1;\n\n\tif (warn_ambiguous_refs && refs_found > 1)\n\t\tfprintf(stderr, warning, len, str);\n\n\tif (reflog_len) {\n\t\tint nth, i;\n\t\tunsigned long at_time;\n\t\tunsigned long co_time;\n\t\tint co_tz, co_cnt;\n\n\t\t/* Is it asking for N-th entry, or approxidate? */\n\t\tfor (i = nth = 0; 0 <= nth && i < reflog_len; i++) {\n\t\t\tchar ch = str[at+2+i];\n\t\t\tif ('0' <= ch && ch <= '9')\n\t\t\t\tnth = nth * 10 + ch - '0';\n\t\t\telse\n\t\t\t\tnth = -1;\n\t\t}\n\t\tif (0 <= nth)\n\t\t\tat_time = 0;\n\t\telse {\n\t\t\tchar *tmp = xstrndup(str + at + 2, reflog_len);\n\t\t\tat_time = approxidate(tmp);\n\t\t\tfree(tmp);\n\t\t}\n\t\tif (read_ref_at(real_ref, at_time, nth, sha1, NULL,\n\t\t\t\t&co_time, &co_tz, &co_cnt)) {\n\t\t\tif (at_time)\n\t\t\t\tfprintf(stderr,\n\t\t\t\t\t\"warning: Log for '%.*s' only goes \"\n\t\t\t\t\t\"back to %s.\\n\", len, str,\n\t\t\t\t\tshow_date(co_time, co_tz, DATE_RFC2822));\n\t\t\telse\n\t\t\t\tfprintf(stderr,\n\t\t\t\t\t\"warning: Log for '%.*s' only has \"\n\t\t\t\t\t\"%d entries.\\n\", len, str, co_cnt);\n\t\t}\n\t}\n\n\tfree(real_ref);\n\treturn 0;\n}", "label": 1, "cwe": "CWE-other", "length": 657 }, { "index": 45766, "code": "writeinfoargs(section *SPtr, info_args *infoarg)\n{\n\tsection *Ptr;\n\tauto char s[BUFSIZ];\n\tauto char s1[BUFSIZ];\n\n\tstrcpy(s, CONF_SEC_FLAG);\n\tif ((Ptr = Set_Section(&SPtr,s,C_OVERWRITE | C_WARN | C_NOT_UNIQUE)) == NULL)\n\t{\n\t\t_print_msg(\"Can't set section `%s'!\\n\",CONF_SEC_FLAG);\n\t\tfree_section(SPtr);\n\t\treturn NULL;\n\t}\n\n\tsprintf(s1,\"%d\",infoarg->flag);\n\tstrcpy(s, CONF_ENT_FLAGS);\n\tif (Set_Entry(Ptr,NULL,s,writeflags(infoarg->flag),C_OVERWRITE | C_WARN) == NULL)\n\t{\n\t\t_print_msg(\"Can't set entry `%s'!\\n\",CONF_ENT_FLAGS);\n\t\tfree_section(SPtr);\n\t\treturn NULL;\n\t}\n\n\tstrcpy(s, CONF_ENT_PROG);\n\tif (Set_Entry(Ptr,NULL,s,infoarg->infoarg,C_OVERWRITE | C_WARN) == NULL)\n\t{\n\t\t_print_msg(\"Can't set entry `%s'!\\n\",CONF_ENT_PROG);\n\t\tfree_section(SPtr);\n\t\treturn NULL;\n\t}\n\n\tif (infoarg->user != NULL)\n\t{\n\t\tstrcpy(s, CONF_ENT_USER);\n\t\tif (Set_Entry(Ptr,NULL,s,infoarg->user,C_OVERWRITE | C_WARN) == NULL)\n\t\t{\n\t\t\t_print_msg(\"Can't set entry `%s'!\\n\",CONF_ENT_USER);\n\t\t\tfree_section(SPtr);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\tif (infoarg->group != NULL)\n\t{\n\t\tstrcpy(s, CONF_ENT_GROUP);\n\t\tif (Set_Entry(Ptr,NULL,s,infoarg->group,C_OVERWRITE | C_WARN) == NULL)\n\t\t{\n\t\t_print_msg(\"Can't set entry `%s'!\\n\",CONF_ENT_GROUP);\n\t\t\tfree_section(SPtr);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\tif (infoarg->interval != 0)\n\t{\n\t\tsprintf(s1,\"%d\",infoarg->interval);\n\t\tstrcpy(s, CONF_ENT_INTVAL);\n\t\tif (Set_Entry(Ptr,NULL,s,s1,C_OVERWRITE | C_WARN) == NULL)\n\t\t{\n\t\t\t_print_msg(\"Can't set entry `%s'!\\n\",CONF_ENT_INTVAL);\n\t\t\tfree_section(SPtr);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\tif (infoarg->time != NULL)\n\t{\n\t\tstrcpy(s, CONF_ENT_TIME);\n\t\tif (Set_Entry(Ptr,NULL,s,infoarg->time,C_OVERWRITE | C_WARN) == NULL)\n\t\t{\n\t\t\t_print_msg(\"Can't set entry `%s'!\\n\",CONF_ENT_TIME);\n\t\t\tfree_section(SPtr);\n\t\t\treturn NULL;\n\t\t}\n\t}\n\n\treturn SPtr;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 585 }, { "index": 71281, "code": "_IsList(const char* string,\n\t\tint& index,\n\t\tconst Type type)\n{\n Type value_type;\n int i;\n int tuple;\n int first_tuple=0;\n int elements;\n boolean lexed;\n\n //\n // Parameter validity check...\n //\n if (string == NUL(char*))\n {\n\treturn FALSE;\n }\n \n ASSERT(index >= 0 AND index <= STRLEN(string) + 1);\n\n elements = 0;\n value_type = DXType::UndefinedType;\n \n //\n // Skip space.\n //\n i = index;\n SkipWhiteSpace(string, i);\n\n //\n // Lex '{'.\n //\n if (string[i] == '{')\n {\n\ti++;\n\tSkipWhiteSpace(string, i);\n }\n else\n {\n\treturn FALSE;\n }\n\n while (string[i] != '\\0' AND string[i] != '}')\n {\n\tif (elements > 0)\n\t{\n\t //\n\t // Lex optional comma.\n\t //\n\t if (string[i] == ',')\n\t {\n\t\ti++;\n\t\tSkipWhiteSpace(string, i);\n\t }\n\t}\n\n\tswitch(type)\n\t{\n\t case DXType::FlagType:\n\t lexed = IsFlag(string, i);\n\t break;\n\t case DXType::IntegerType:\n\t lexed = IsInteger(string, i);\n\t break;\n\n\t case DXType::ScalarType:\n\t lexed = IsScalar(string, i);\n\t break;\n\n\t case DXType::VectorType:\n\t lexed = IsVector(string, i, tuple);\n\t if (elements == 0)\n\t {\n\t\tfirst_tuple = tuple;\n\t }\n\t else if (tuple != first_tuple)\n\t {\n\t\treturn FALSE;\n\t }\n\t break;\n\n\t case DXType::TensorType:\n\t lexed = IsTensor(string, i);\n\t break;\n\n\t case DXType::ValueType:\n\t lexed = _IsValue(string, i, value_type);\n\t break;\n\n\t case DXType::StringType:\n\t lexed = IsString(string, i);\n\t break;\n\n\t default:\n\t return FALSE;\n\t}\n\n\tif (lexed)\n\t{\n\t elements++;\n\t}\n\telse\n\t{\n\t return FALSE;\n\t}\n\n\tboolean value_ok = FALSE;\n\tswitch (type) {\n\t default:\n\t\t break;\n\t case DXType::ValueType:\n\t\t switch (value_type) {\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t\tcase DXType::VectorType:\n\t\t\tcase DXType::TensorType: \n\t\t\t\tif (string[i] == '[') value_ok = TRUE;\n\t\t\t\t\tbreak; \n\t\t\t}\n\t\t // Fall through\n\t case DXType::ScalarType:\n\t\t //\n\t\t // Make sure there is a separator\n\t\t // If we don't do this, then '{.01.01.01}' is a scalar list.\n\t\t //\n\t\t if (!value_ok && !IsWhiteSpace(&string[i]) && \n\t\t\t (string[i] != ',') && (string[i] != '}'))\n\t\t\t return FALSE;\n\t\t break;\n\t}\n\t//\n\t// Skip space.\n\t//\n\tSkipWhiteSpace(string, i);\n }\n\n //\n // No end delimiter and no elements... return unsuccessfully.\n //\n if (string[i] != '}' OR elements == 0)\n {\n\treturn FALSE;\n }\n\n //\n // Return successfully.\n //\n index = i + 1;\n return TRUE;\n\n}", "label": 0, "cwe": null, "length": 709 }, { "index": 991028, "code": "hexchat_plugin_init(hexchat_plugin *plugin_handle,\n\t\t char **plugin_name,\n\t\t char **plugin_desc,\n\t\t char **plugin_version,\n\t\t char *arg)\n{\n#ifdef IS_PY3K\n\twchar_t *argv[] = { L\"\", 0 };\n#else\n\tchar *argv[] = { \"\", 0 };\n#endif\n\n\tph = plugin_handle;\n\n\t/* Block double initalization. */\n\tif (initialized != 0) {\n\t\thexchat_print(ph, \"Python interface already loaded\");\n\t\t/* deinit is called even when init fails, so keep track\n\t\t * of a reinit failure. */\n\t\treinit_tried++;\n\t\treturn 0;\n\t}\n\tinitialized = 1;\n\n\t*plugin_name = \"Python\";\n\t*plugin_version = VERSION;\n\n\t/* FIXME You can't free this since it's used as long as the plugin's\n\t * loaded, but if you unload it, everything belonging to the plugin is\n\t * supposed to be freed anyway.\n\t */\n\t*plugin_desc = g_strdup_printf (\"Python %d scripting interface\", PY_MAJOR_VERSION);\n\n\t/* Initialize python. */\n#ifdef IS_PY3K\n\tPy_SetProgramName(L\"hexchat\");\n\tPyImport_AppendInittab(\"hexchat\", PyInit_hexchat);\n\tPyImport_AppendInittab(\"xchat\", PyInit_xchat);\n#else\n\tPy_SetProgramName(\"hexchat\");\n\tPyImport_AppendInittab(\"hexchat\", inithexchat);\n\tPyImport_AppendInittab(\"xchat\", initxchat);\n#endif\n\tPy_Initialize();\n\tPySys_SetArgv(1, argv);\n\n\txchatout = XChatOut_New();\n\tif (xchatout == NULL) {\n\t\thexchat_print(ph, \"Can't allocate xchatout object\");\n\t\treturn 0;\n\t}\n\n#ifdef WITH_THREAD\n\tPyEval_InitThreads();\n\txchat_lock = PyThread_allocate_lock();\n\tif (xchat_lock == NULL) {\n\t\thexchat_print(ph, \"Can't allocate hexchat lock\");\n\t\tPy_DECREF(xchatout);\n\t\txchatout = NULL;\n\t\treturn 0;\n\t}\n#endif\n\n\tmain_tstate = PyEval_SaveThread();\n\n\tinterp_plugin = Plugin_New(NULL, xchatout);\n\tif (interp_plugin == NULL) {\n\t\thexchat_print(ph, \"Plugin_New() failed.\\n\");\n#ifdef WITH_THREAD\n\t\tPyThread_free_lock(xchat_lock);\n#endif\n\t\tPy_DECREF(xchatout);\n\t\txchatout = NULL;\n\t\treturn 0;\n\t}\n\n\n\thexchat_hook_command(ph, \"\", HEXCHAT_PRI_NORM, IInterp_Cmd, 0, 0);\n\thexchat_hook_command(ph, \"PY\", HEXCHAT_PRI_NORM, Command_Py, usage, 0);\n\thexchat_hook_command(ph, \"LOAD\", HEXCHAT_PRI_NORM, Command_Load, 0, 0);\n\thexchat_hook_command(ph, \"UNLOAD\", HEXCHAT_PRI_NORM, Command_Unload, 0, 0);\n\thexchat_hook_command(ph, \"RELOAD\", HEXCHAT_PRI_NORM, Command_Reload, 0, 0);\n#ifdef WITH_THREAD\n\tthread_timer = hexchat_hook_timer(ph, 300, Callback_ThreadTimer, NULL);\n#endif\n\n\thexchat_print(ph, \"Python interface loaded\\n\");\n\n\tUtil_Autoload();\n\treturn 1;\n}", "label": 0, "cwe": null, "length": 707 }, { "index": 889761, "code": "enter_your_name (char c, char* name)\n{\n a_keycode t = 0;\n int pos = 0;\n char head[256];\n a_timer pixelize_timer = new_htimer (T_GLOBAL, HZ (7));\n a_sprite *player_number;\n a_sprite *player_name = 0;\n a_pixel *pixbuf;\n\n XMALLOC_ARRAY (pixbuf, 200 * xbuf);\n\n sprintf (head, _(\"PLAYER %d, YOU CAME IN THE TOP 10\"), c);\n player_number = compile_menu_para (head, T_CENTERED, 20, 159, 310);\n\n memset (name, 0, PLAYER_NAME_SIZE + 1);\n\n std_white_fadein (&tile_set_img.palette);\n event_sfx (73);\n do {\n background_menu ();\n DRAW_SPRITE (player_number, corner[0]);\n DRAW_SPRITE (enter_your_name_txt, corner[0]);\n if (!player_name)\n player_name = compile_menu_text (name, T_CENTERED, 120, 159);\n DRAW_SPRITE (player_name, corner[0]);\n hrule (112);\n hrule (135);\n {\n long p = read_htimer (pixelize_timer);\n if (p <= 6) {\n\tpixelize[6 - p] (pixbuf, corner[0]);\n\tflush_display (pixbuf);\n } else {\n\tflush_display (corner[0]);\n }\n }\n if (key_ready ()) {\n t = get_key ();\n if (pos < PLAYER_NAME_SIZE) {\n\tint a = TOUPPER (keycode_to_ascii (t));\n\tif ((a > ' ' && a <= '_') || (a == ' ' && pos > 0)) {\n\t name[pos++] = a;\n\t name[pos] = 0;\n\t event_sfx (70);\n\t FREE_SPRITE0 (player_name); /* force recompilation */\n\t}\n }\n if ((t == HK_BackSpace || t == HK_Delete) && (pos > 0)) {\n\tpos--;\n\tname[pos] = 0;\n\tevent_sfx (71);\n\tFREE_SPRITE0 (player_name); /* force recompilation */\n }\n }\n } while (t != HK_Escape && t != HK_Enter);\n event_sfx (72);\n if (pos == 0 || t == HK_Escape)\n memset (name, 0, PLAYER_NAME_SIZE);\n free (pixbuf);\n free_htimer (pixelize_timer);\n FREE_SPRITE0 (player_number);\n FREE_SPRITE0 (player_name);\n}", "label": 0, "cwe": null, "length": 557 }, { "index": 12624, "code": "lgdt3306a_pre_monitoring(struct lgdt3306a_state *state)\n{\n\tu8 val = 0;\n\tint ret;\n\tu8 currChDiffACQ, snrRef, mainStrong, aiccrejStatus;\n\n\t/* Channel variation */\n\tret = lgdt3306a_read_reg(state, 0x21bc, &currChDiffACQ);\n\tif (ret)\n\t\treturn ret;\n\n\t/* SNR of Frame sync */\n\tret = lgdt3306a_read_reg(state, 0x21a1, &val);\n\tif (ret)\n\t\treturn ret;\n\tsnrRef = val & 0x3f;\n\n\t/* Strong Main CIR */\n\tret = lgdt3306a_read_reg(state, 0x2199, &val);\n\tif (ret)\n\t\treturn ret;\n\tmainStrong = (val & 0x40) >> 6;\n\n\tret = lgdt3306a_read_reg(state, 0x0090, &val);\n\tif (ret)\n\t\treturn ret;\n\taiccrejStatus = (val & 0xf0) >> 4;\n\n\tdbg_info(\"snrRef=%d mainStrong=%d aiccrejStatus=%d currChDiffACQ=0x%x\\n\",\n\t\tsnrRef, mainStrong, aiccrejStatus, currChDiffACQ);\n\n#if 0\n\t/* Dynamic ghost exists */\n\tif ((mainStrong == 0) && (currChDiffACQ > 0x70))\n#endif\n\tif (mainStrong == 0) {\n\t\tret = lgdt3306a_read_reg(state, 0x2135, &val);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\tval &= 0x0f;\n\t\tval |= 0xa0;\n\t\tret = lgdt3306a_write_reg(state, 0x2135, val);\n\t\tif (ret)\n\t\t\treturn ret;\n\n\t\tret = lgdt3306a_read_reg(state, 0x2141, &val);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\tval &= 0x3f;\n\t\tval |= 0x80;\n\t\tret = lgdt3306a_write_reg(state, 0x2141, val);\n\t\tif (ret)\n\t\t\treturn ret;\n\n\t\tret = lgdt3306a_write_reg(state, 0x2122, 0x70);\n\t\tif (ret)\n\t\t\treturn ret;\n\t} else { /* Weak ghost or static channel */\n\t\tret = lgdt3306a_read_reg(state, 0x2135, &val);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\tval &= 0x0f;\n\t\tval |= 0x70;\n\t\tret = lgdt3306a_write_reg(state, 0x2135, val);\n\t\tif (ret)\n\t\t\treturn ret;\n\n\t\tret = lgdt3306a_read_reg(state, 0x2141, &val);\n\t\tif (ret)\n\t\t\treturn ret;\n\t\tval &= 0x3f;\n\t\tval |= 0x40;\n\t\tret = lgdt3306a_write_reg(state, 0x2141, val);\n\t\tif (ret)\n\t\t\treturn ret;\n\n\t\tret = lgdt3306a_write_reg(state, 0x2122, 0x40);\n\t\tif (ret)\n\t\t\treturn ret;\n\t}\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 712 }, { "index": 74049, "code": "tpm_tis_i2c_send(struct tpm_chip *chip, u8 *buf, size_t len)\n{\n\tint rc, status;\n\tssize_t burstcnt;\n\tsize_t count = 0;\n\tu8 retries = 0;\n\tu8 sts = TPM_STS_GO;\n\n\tif (len > TPM_BUFSIZE)\n\t\treturn -E2BIG;\t/* command is too long for our tpm, sorry */\n\n\tif (request_locality(chip, 0) < 0)\n\t\treturn -EBUSY;\n\n\tstatus = tpm_tis_i2c_status(chip);\n\tif ((status & TPM_STS_COMMAND_READY) == 0) {\n\t\ttpm_tis_i2c_ready(chip);\n\t\tif (wait_for_stat\n\t\t (chip, TPM_STS_COMMAND_READY,\n\t\t chip->vendor.timeout_b, &status) < 0) {\n\t\t\trc = -ETIME;\n\t\t\tgoto out_err;\n\t\t}\n\t}\n\n\twhile (count < len - 1) {\n\t\tburstcnt = get_burstcount(chip);\n\n\t\t/* burstcnt < 0 = TPM is busy */\n\t\tif (burstcnt < 0)\n\t\t\treturn burstcnt;\n\n\t\tif (burstcnt > (len - 1 - count))\n\t\t\tburstcnt = len - 1 - count;\n\n\t\trc = iic_tpm_write(TPM_DATA_FIFO(chip->vendor.locality),\n\t\t\t\t &(buf[count]), burstcnt);\n\t\tif (rc == 0)\n\t\t\tcount += burstcnt;\n\t\telse if (rc < 0)\n\t\t\tretries++;\n\n\t\t/* avoid endless loop in case of broken HW */\n\t\tif (retries > MAX_COUNT_LONG) {\n\t\t\trc = -EIO;\n\t\t\tgoto out_err;\n\t\t}\n\n\t\twait_for_stat(chip, TPM_STS_VALID,\n\t\t\t chip->vendor.timeout_c, &status);\n\n\t\tif ((status & TPM_STS_DATA_EXPECT) == 0) {\n\t\t\trc = -EIO;\n\t\t\tgoto out_err;\n\t\t}\n\t}\n\n\t/* write last byte */\n\tiic_tpm_write(TPM_DATA_FIFO(chip->vendor.locality), &(buf[count]), 1);\n\twait_for_stat(chip, TPM_STS_VALID, chip->vendor.timeout_c, &status);\n\tif ((status & TPM_STS_DATA_EXPECT) != 0) {\n\t\trc = -EIO;\n\t\tgoto out_err;\n\t}\n\n\t/* go and do it */\n\tiic_tpm_write(TPM_STS(chip->vendor.locality), &sts, 1);\n\n\treturn len;\nout_err:\n\ttpm_tis_i2c_ready(chip);\n\t/* The TPM needs some time to clean up here,\n\t * so we sleep rather than keeping the bus busy\n\t */\n\tusleep_range(SLEEP_DURATION_RESET_LOW, SLEEP_DURATION_RESET_HI);\n\trelease_locality(chip, chip->vendor.locality, 0);\n\treturn rc;\n}", "label": 0, "cwe": null, "length": 586 }, { "index": 174488, "code": "_e_smart_add(Evas_Object *obj)\n{\n E_Smart_Data *sd;\n\n sd = calloc(1, sizeof(E_Smart_Data));\n if (!sd) return;\n evas_object_smart_data_set(obj, sd);\n\n sd->smart_obj = obj;\n sd->x = 0;\n sd->y = 0;\n sd->w = 0;\n sd->h = 0;\n\n sd->val = 0.0;\n sd->val_min = 0.0;\n sd->val_max = 1.0;\n sd->val_range = 1.0;\n sd->step_size = 0.01;\n sd->reversed = 0;\n sd->step_count = 0;\n sd->horizontal = 0;\n sd->format = NULL;\n sd->direction = 0;\n\n sd->edje_obj = edje_object_add(evas_object_evas_get(obj));\n e_theme_edje_object_set(sd->edje_obj, \"base/theme/widgets\",\n\t\t\t \"e/widgets/slider_vertical\");\n edje_object_size_min_calc(sd->edje_obj, &(sd->minw), &(sd->minh));\n evas_object_smart_member_add(sd->edje_obj, obj);\n\n sd->event = evas_object_rectangle_add(evas_object_evas_get(obj));\n evas_object_color_set(sd->event, 0, 0, 0, 0);\n evas_object_pass_events_set(sd->event, EINA_TRUE);\n edje_object_part_swallow(sd->edje_obj, \"e.swallow.bar\", sd->event);\n evas_object_smart_member_add(sd->event, sd->edje_obj);\n\n edje_object_signal_callback_add(sd->edje_obj, \"drag\", \"*\", _e_smart_signal_cb_drag, sd);\n edje_object_signal_callback_add(sd->edje_obj, \"drag,start\", \"*\", _e_smart_signal_cb_drag_start, sd);\n edje_object_signal_callback_add(sd->edje_obj, \"drag,stop\", \"*\", _e_smart_signal_cb_drag_stop, sd);\n edje_object_signal_callback_add(sd->edje_obj, \"drag,step\", \"*\", _e_smart_signal_cb_drag_stop, sd);\n edje_object_signal_callback_add(sd->edje_obj, \"drag,set\", \"*\", _e_smart_signal_cb_drag_stop, sd);\n edje_object_signal_callback_add(sd->edje_obj, \"mouse,wheel,0,1\", \"*\", _e_smart_signal_cb_wheel_up, sd);\n edje_object_signal_callback_add(sd->edje_obj, \"mouse,wheel,0,-1\", \"*\", _e_smart_signal_cb_wheel_down, sd);\n\n evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN, _e_smart_event_key_down, sd);\n evas_object_event_callback_add(sd->event, EVAS_CALLBACK_MOUSE_DOWN, _e_smart_event_mouse_down, sd);\n}", "label": 0, "cwe": null, "length": 620 }, { "index": 152862, "code": "main(int argc, char *argv[])\n{\n try\n {\n // open phonebook file\n gsmlib::SortedPhonebook pb(std::string(\"spb-copy.pb\"), false);\n \n // print all entries\n std::cout << \"Entries in pbs-copy.pb:\" << std::endl;\n for (gsmlib::SortedPhonebook::iterator i = pb.begin(); i != pb.end(); ++i)\n std::cout << \" Text: \" << i->text()\n\t\t<< \" Telephone: \" << i->telephone() << std::endl;\n\n // remove all entries with telephone == \"0815\"\n std::cout << \"Removing entries with telephone == 0815\" << std::endl;\n pb.setSortOrder(gsmlib::ByTelephone);\n\n std::string s = \"0815\";\n pb.erase(s);\n\n std::cout << \"Entries in pbs-copy.pb<2>:\" << std::endl;\n for (gsmlib::SortedPhonebook::iterator i = pb.begin(); i != pb.end(); ++i)\n std::cout << \" Text: \" << i->text()\n\t\t<< \" Telephone: \" << i->telephone() << std::endl;\n \n // insert some entries\n std::cout << \"Inserting some entries\" << std::endl;\n pb.insert(gsmlib::PhonebookEntryBase(\"08152\", \"new line with \\r continued\"));\n pb.insert(gsmlib::PhonebookEntryBase(\"41598254\", \"Hans-Dieter Schmidt\"));\n pb.insert(gsmlib::PhonebookEntryBase(\"34058\", \"Hans-Dieter|Hofmann\"));\n\n pb.setSortOrder(gsmlib::ByText);\n std::cout << \"Entries in pbs-copy.pb<3>:\" << std::endl;\n for (gsmlib::SortedPhonebook::iterator i = pb.begin(); i != pb.end(); ++i)\n std::cout << \" Text: \" << i->text()\n\t\t<< \" Telephone: \" << i->telephone() << std::endl;\n\n // test erasing all \"Hans-Dieter Schmidt\" entries\n std::cout << \"Erasing all Hans-Dieter Schmidt entries\" << std::endl;\n s = \"Hans-Dieter Schmidt\";\n std::pair range =\n pb.equal_range(s);\n std::cout << \"About to erase:\" << std::endl;\n for (gsmlib::SortedPhonebook::iterator i = range.first; i != range.second; ++i)\n std::cout << \" Text: \" << i->text()\n\t\t<< \" Telephone: \" << i->telephone() << std::endl;\n \n pb.erase(range.first, range.second);\n\n // write back to file\n std::cout << \"Writing back to file\" << std::endl;\n pb.sync();\n\n // tests the NoCopy class\n //SortedPhonebook pb2(\"spb.pb\");\n //pb2 = pb;\n }\n catch (gsmlib::GsmException &ge)\n {\n std::cerr << \"GsmException '\" << ge.what() << \"'\" << std::endl;\n return 1;\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 716 }, { "index": 345128, "code": "get_path_for_pred_task(Sche_task *sche_task,\n Path *pred_path)\n{\n Path *path;\n Boolean certain_length = FALSE;\n Boolean certain_energy = FALSE;\n real cost[FV_STATE_NUM];\n real cf_min_length[FV_STATE_NUM];\n real sche_length[FV_STATE_NUM];\n real energy[FV_STATE_NUM];\n real s_energy[FV_STATE_NUM];\n fv_kind fv;\n\n int nest = sche_task_get_nest(sche_task);\n int *nested_id = copy_int_vector(sche_task_get_nested_id(sche_task), nest);\n proc_kind proc = sche_task_get_proc(sche_task);\n int acc_tp = sche_task_get_acc_tp(sche_task);\n\n Term *term = term_new_from_sche_task(sche_task);\n List *term_list;\n\n term_list = term_list_copy(path_get_term_list(pred_path));\n term_list = list_append(term_list, term);\n\n Block_info *b = sche_task_get_body_b(sche_task);\n\n certain_length = path_is_certain_length(pred_path)\n && (b != NULL ? block_info_is_certain_length(b) : TRUE);\n\n certain_energy = path_is_certain_energy(pred_path)\n && (b != NULL ? block_info_is_certain_energy(b) : TRUE);\n\n path = path_new(nested_id[nest-1], nested_id, nest,\n proc, acc_tp, term_list,\n certain_length, certain_energy);\n\n for (fv = FULL; fv <= SLOWEST_FV; fv++) {\n cost[fv] = path_get_cost(pred_path, fv)\n + (b != NULL ? block_info_get_cost(b, fv) : 0);\n\n sche_length[fv] = path_get_sche_length(pred_path, fv)\n + (b != NULL ? block_info_get_sche_length(b, fv) : 0);\n\n cf_min_length[fv] = path_get_cf_min_length(pred_path, fv)\n + (b != NULL ? block_info_get_cf_min_length(b, fv) : 0);\n\n energy[fv] = path_get_energy(pred_path, fv)\n + (b != NULL ? block_info_get_energy(b, fv) : 0);\n\n s_energy[fv] = path_get_s_energy(pred_path, fv)\n + (b != NULL ? block_info_get_s_energy(b, fv) : 0);\n }\n\n for (fv = FULL; fv <= SLOWEST_FV; fv++) {\n path_set_cost(path, fv, cost[fv]);\n path_set_sche_length(path, fv, sche_length[fv]);\n path_set_cf_min_length(path, fv, cf_min_length[fv]);\n path_set_energy(path, fv, energy[fv]);\n path_set_s_energy(path, fv, s_energy[fv]);\n }\n\n return path;\n}", "label": 0, "cwe": null, "length": 598 }, { "index": 711295, "code": "sspm_make_multipart_subpart(struct mime_impl *impl,\n\t\t\t struct sspm_header *parent_header)\n{\n struct sspm_header header;\n char *line;\n void* part;\n size_t size;\n\n if(parent_header->boundary == 0){\n\t/* Error. Multipart headers must have a boundary*/\n\t\n\tsspm_set_error(parent_header,SSPM_NO_BOUNDARY_ERROR,0);\n\t/* read all of the reamining lines */\n\twhile((line = sspm_get_next_line(impl)) != 0){\n\t} \n\n\treturn 0;\n }\n\n\n /* Step 1: Read the opening boundary */\n\n if(get_line_type(impl->temp) != BOUNDARY){\n\twhile((line=sspm_get_next_line(impl)) != 0 ){\n\t if(sspm_is_mime_boundary(line)){\n\n\t\tassert(parent_header != 0);\n\n\t\t/* Check if it is the right boundary */\n\t\tif(!sspm_is_mime_terminating_boundary(line) &&\n\t\t strncmp((line+2),parent_header->boundary, \n\t\t\t sizeof(parent_header->boundary)) \n\t\t == 0){\n\t\t /* The +2 in strncmp skips over the leading \"--\" */\n\t\t \n\t\t break;\n\t\t} else {\n\t\t /* Got the wrong boundary, so read and discard\n until we get the right boundary. */\n\t\t char* boundary;\n\t\t char msg[256];\n\t\t \n\t\t snprintf(msg,256,\n\t\t\t \"Expected: %s. Got: %s\",\n\t\t\t parent_header->boundary,line);\n\n\t\t sspm_set_error(parent_header,\n\t\t\t\t SSPM_WRONG_BOUNDARY_ERROR,msg);\n\n\t\t /* Read until the paired terminating boundary */\n\t\t if((boundary = (char*)malloc(strlen(line)+5)) == 0){\n\t\t\tfprintf(stderr,\"Out of memory\");\n\t\t\tabort();\n\t\t }\n\t\t strcpy(boundary,line);\n\t\t strcat(boundary,\"--\");\n\t\t while((line = sspm_get_next_line(impl)) != 0){\n\t\t\tif(strcmp(boundary,line)==0){\n\t\t\t break;\n\t\t\t}\n\t\t }\n\t\t free(boundary);\n\t\t \n\t\t return 0;\n\t\t}\n\t }\n\t}\n }\n\n /* Step 2: Get the part header */\n sspm_read_header(impl,&header);\n\n /* If the header is still listed as default, there was probably an\n error */\n if(header.def == 1 && header.error != SSPM_NO_ERROR){\n\tsspm_set_error(&header,SSPM_NO_HEADER_ERROR,0);\n\treturn 0;\n }\n\n if(header.error!= SSPM_NO_ERROR){\n\tsspm_store_part(impl,header,impl->level,0,0);\n\treturn 0;\n }\t\n\n /* Step 3: read the body */\n \n if(header.major == SSPM_MULTIPART_MAJOR_TYPE){\n\tstruct sspm_header *child_header;\n\tchild_header = &(impl->parts[impl->part_no].header);\n\n\t/* Store the multipart part */\n\tsspm_store_part(impl,header,impl->level,0,0);\n\n\t/* now get all of the sub-parts */\n\tpart = sspm_make_multipart_part(impl,child_header);\n\n\tif(get_line_type(impl->temp) != TERMINATING_BOUNDARY){\n\n\t sspm_set_error(child_header,SSPM_NO_BOUNDARY_ERROR,impl->temp);\n\t return 0;\n\t}\n\t\n\tsspm_get_next_line(impl); /* Step past the terminating boundary */\n\n } else {\n\tsspm_make_part(impl, &header,parent_header,&part,&size);\n\n\tmemset(&(impl->parts[impl->part_no]), 0, sizeof(struct sspm_part));\n\n\tsspm_store_part(impl,header,impl->level,part,size);\n\n }\n\n return part;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 764 }, { "index": 6415, "code": "__ecereMethod___ecereNameSpace__ecere__sys__JSONParser_GetNumber(struct __ecereNameSpace__ecere__com__Instance * this, struct __ecereNameSpace__ecere__com__Class * type, struct __ecereNameSpace__ecere__com__DataValue * value)\n{\nstruct __ecereNameSpace__ecere__sys__JSONParser * __ecerePointer___ecereNameSpace__ecere__sys__JSONParser = (struct __ecereNameSpace__ecere__sys__JSONParser *)(this ? (((char *)this) + __ecereClass___ecereNameSpace__ecere__sys__JSONParser->offset) : 0);\nint result = 0;\nchar buffer[256];\nint c = 0;\n\nwhile(c < sizeof buffer - 1 && (__ecerePointer___ecereNameSpace__ecere__sys__JSONParser->ch == '-' || __ecerePointer___ecereNameSpace__ecere__sys__JSONParser->ch == '.' || tolower(__ecerePointer___ecereNameSpace__ecere__sys__JSONParser->ch) == 'e' || __ecerePointer___ecereNameSpace__ecere__sys__JSONParser->ch == '+' || isdigit(__ecerePointer___ecereNameSpace__ecere__sys__JSONParser->ch)))\n{\nbuffer[c++] = __ecerePointer___ecereNameSpace__ecere__sys__JSONParser->ch;\nif(!((unsigned int (*)(struct __ecereNameSpace__ecere__com__Instance *, char * ch))__extension__ ({\nstruct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = __ecerePointer___ecereNameSpace__ecere__sys__JSONParser->f;\n\n__internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__sys__File->_vTbl;\n})[__ecereVMethodID___ecereNameSpace__ecere__sys__File_Getc])(__ecerePointer___ecereNameSpace__ecere__sys__JSONParser->f, &__ecerePointer___ecereNameSpace__ecere__sys__JSONParser->ch))\nbreak;\n}\nbuffer[c] = (char)0;\nif(type == __ecereClass_double || !strcmp(type->dataTypeString, \"double\"))\n{\nvalue->d = strtod(buffer, (((void *)0)));\nresult = 1;\n}\nelse if(type == __ecereClass_float || !strcmp(type->dataTypeString, \"float\"))\n{\nvalue->f = (float)strtod(buffer, (((void *)0)));\nresult = 1;\n}\nelse if(!strcmp(type->dataTypeString, \"int64\"))\n{\nvalue->i64 = strtol(buffer, (((void *)0)), 10);\nresult = 1;\n}\nelse if(type == __ecereClass_uint64 || !strcmp(type->dataTypeString, \"uint64\"))\n{\nvalue->ui64 = strtol(buffer, (((void *)0)), 10);\nresult = 1;\n}\nelse\n{\nvalue->i = strtol(buffer, (((void *)0)), 10);\nresult = 1;\n}\nreturn result;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-476" ], "length": 684 }, { "index": 651155, "code": "checkContentRelationship(const E_ValueType sourceValueType,\n const E_RelationshipType relationshipType,\n const E_ValueType targetValueType,\n const OFBool byReference) const\n{\n /* the following code implements the constraints of table A.35.8-2 in DICOM PS3.3 */\n OFBool result = OFFalse;\n /* by-reference relationships not allowed at all */\n if (!byReference)\n {\n /* row 1 of the table */\n if ((relationshipType == RT_contains) && (sourceValueType == VT_Container))\n {\n result = (targetValueType == VT_Text) || (targetValueType == VT_Code) || (targetValueType == VT_Num) ||\n (targetValueType == VT_DateTime) || (targetValueType == VT_UIDRef) || (targetValueType == VT_PName) ||\n (targetValueType == VT_Image) || (targetValueType == VT_Composite) || (targetValueType == VT_Container);\n }\n /* row 2 of the table */\n else if ((relationshipType == RT_hasObsContext) && (sourceValueType == VT_Container))\n {\n result = (targetValueType == VT_Text) || (targetValueType == VT_Code) || (targetValueType == VT_DateTime) ||\n (targetValueType == VT_UIDRef) || (targetValueType == VT_PName);\n }\n /* row 3 of the table */\n else if ((relationshipType == RT_hasObsContext) && ((sourceValueType == VT_Text) || (sourceValueType == VT_Code) ||\n (sourceValueType == VT_Num)))\n {\n result = (targetValueType == VT_Text) || (targetValueType == VT_Code) || (targetValueType == VT_Num) ||\n (targetValueType == VT_DateTime) || (targetValueType == VT_UIDRef) || (targetValueType == VT_PName) ||\n (targetValueType == VT_Composite);\n }\n /* row 4 of the table */\n else if ((relationshipType == RT_hasAcqContext) && ((sourceValueType == VT_Container) || (sourceValueType == VT_Image) ||\n (sourceValueType == VT_Composite)))\n {\n result = (targetValueType == VT_Text) || (targetValueType == VT_Code) || (targetValueType == VT_Num) ||\n (targetValueType == VT_DateTime) || (targetValueType == VT_UIDRef) || (targetValueType == VT_PName) ||\n (targetValueType == VT_Container);\n }\n /* row 5 of the table */\n else if (relationshipType == RT_hasConceptMod)\n {\n result = (targetValueType == VT_Text) || (targetValueType == VT_Code);\n }\n /* row 6 of the table */\n else if ((relationshipType == RT_hasProperties) && ((sourceValueType == VT_Text) || (sourceValueType == VT_Code) ||\n (sourceValueType == VT_Num)))\n {\n result = (targetValueType == VT_Text) || (targetValueType == VT_Code) || (targetValueType == VT_Num) ||\n (targetValueType == VT_DateTime) || (targetValueType == VT_UIDRef) || (targetValueType == VT_PName) ||\n (targetValueType == VT_Image) || (targetValueType == VT_Composite) || (targetValueType == VT_Container);\n }\n /* row 7 of the table */\n else if ((relationshipType == RT_inferredFrom) && ((sourceValueType == VT_Text) || (sourceValueType == VT_Code) ||\n (sourceValueType == VT_Num)))\n {\n result = (targetValueType == VT_Text) || (targetValueType == VT_Code) || (targetValueType == VT_Num) ||\n (targetValueType == VT_DateTime) || (targetValueType == VT_UIDRef) || (targetValueType == VT_Image) ||\n (targetValueType == VT_Composite) || (targetValueType == VT_Container);\n }\n }\n return result;\n}", "label": 0, "cwe": null, "length": 836 }, { "index": 338489, "code": "__handle_setup_get_version_rsp(struct ipw_hardware *hw)\n{\n\tstruct ipw_setup_config_packet *config_packet;\n\tstruct ipw_setup_config_done_packet *config_done_packet;\n\tstruct ipw_setup_open_packet *open_packet;\n\tstruct ipw_setup_info_packet *info_packet;\n\tint port;\n\tunsigned int channel_idx;\n\n\t/* generate config packet */\n\tfor (port = 1; port <= NL_NUM_OF_ADDRESSES; port++) {\n\t\tconfig_packet = alloc_ctrl_packet(\n\t\t\t\tsizeof(struct ipw_setup_config_packet),\n\t\t\t\tADDR_SETUP_PROT,\n\t\t\t\tTL_PROTOCOLID_SETUP,\n\t\t\t\tTL_SETUP_SIGNO_CONFIG_MSG);\n\t\tif (!config_packet)\n\t\t\tgoto exit_nomem;\n\t\tconfig_packet->header.length = sizeof(struct tl_setup_config_msg);\n\t\tconfig_packet->body.port_no = port;\n\t\tconfig_packet->body.prio_data = PRIO_DATA;\n\t\tconfig_packet->body.prio_ctrl = PRIO_CTRL;\n\t\tsend_packet(hw, PRIO_SETUP, &config_packet->header);\n\t}\n\tconfig_done_packet = alloc_ctrl_packet(\n\t\t\tsizeof(struct ipw_setup_config_done_packet),\n\t\t\tADDR_SETUP_PROT,\n\t\t\tTL_PROTOCOLID_SETUP,\n\t\t\tTL_SETUP_SIGNO_CONFIG_DONE_MSG);\n\tif (!config_done_packet)\n\t\tgoto exit_nomem;\n\tconfig_done_packet->header.length = sizeof(struct tl_setup_config_done_msg);\n\tsend_packet(hw, PRIO_SETUP, &config_done_packet->header);\n\n\t/* generate open packet */\n\tfor (port = 1; port <= NL_NUM_OF_ADDRESSES; port++) {\n\t\topen_packet = alloc_ctrl_packet(\n\t\t\t\tsizeof(struct ipw_setup_open_packet),\n\t\t\t\tADDR_SETUP_PROT,\n\t\t\t\tTL_PROTOCOLID_SETUP,\n\t\t\t\tTL_SETUP_SIGNO_OPEN_MSG);\n\t\tif (!open_packet)\n\t\t\tgoto exit_nomem;\n\t\topen_packet->header.length = sizeof(struct tl_setup_open_msg);\n\t\topen_packet->body.port_no = port;\n\t\tsend_packet(hw, PRIO_SETUP, &open_packet->header);\n\t}\n\tfor (channel_idx = 0;\n\t\t\tchannel_idx < NL_NUM_OF_ADDRESSES; channel_idx++) {\n\t\tint ret;\n\n\t\tret = set_DTR(hw, PRIO_SETUP, channel_idx,\n\t\t\t(hw->control_lines[channel_idx] &\n\t\t\t IPW_CONTROL_LINE_DTR) != 0);\n\t\tif (ret) {\n\t\t\tprintk(KERN_ERR IPWIRELESS_PCCARD_NAME\n\t\t\t\t\t\": error setting DTR (%d)\\n\", ret);\n\t\t\treturn;\n\t\t}\n\n\t\tret = set_RTS(hw, PRIO_SETUP, channel_idx,\n\t\t\t(hw->control_lines [channel_idx] &\n\t\t\t IPW_CONTROL_LINE_RTS) != 0);\n\t\tif (ret) {\n\t\t\tprintk(KERN_ERR IPWIRELESS_PCCARD_NAME\n\t\t\t\t\t\": error setting RTS (%d)\\n\", ret);\n\t\t\treturn;\n\t\t}\n\t}\n\t/*\n\t * For NDIS we assume that we are using sync PPP frames, for COM async.\n\t * This driver uses NDIS mode too. We don't bother with translation\n\t * from async -> sync PPP.\n\t */\n\tinfo_packet = alloc_ctrl_packet(sizeof(struct ipw_setup_info_packet),\n\t\t\tADDR_SETUP_PROT,\n\t\t\tTL_PROTOCOLID_SETUP,\n\t\t\tTL_SETUP_SIGNO_INFO_MSG);\n\tif (!info_packet)\n\t\tgoto exit_nomem;\n\tinfo_packet->header.length = sizeof(struct tl_setup_info_msg);\n\tinfo_packet->body.driver_type = NDISWAN_DRIVER;\n\tinfo_packet->body.major_version = NDISWAN_DRIVER_MAJOR_VERSION;\n\tinfo_packet->body.minor_version = NDISWAN_DRIVER_MINOR_VERSION;\n\tsend_packet(hw, PRIO_SETUP, &info_packet->header);\n\n\t/* Initialization is now complete, so we clear the 'to_setup' flag */\n\thw->to_setup = 0;\n\n\treturn;\n\nexit_nomem:\n\tprintk(KERN_ERR IPWIRELESS_PCCARD_NAME\n\t\t\t\": not enough memory to alloc control packet\\n\");\n\thw->to_setup = -1;\n}", "label": 0, "cwe": null, "length": 826 }, { "index": 908423, "code": "up_device_get_history (UpDevice *device, const gchar *type_string, guint timespan, guint resolution, DBusGMethodInvocation *context)\n{\n\tGError *error;\n\tGPtrArray *array = NULL;\n\tGPtrArray *complex;\n\tUpHistoryItem *item;\n\tGValue *value;\n\tguint i;\n\tUpHistoryType type = UP_HISTORY_TYPE_UNKNOWN;\n\n\tg_return_val_if_fail (UP_IS_DEVICE (device), FALSE);\n\tg_return_val_if_fail (type_string != NULL, FALSE);\n\n\t/* doesn't even try to support this */\n\tif (!device->priv->has_history) {\n\t\terror = g_error_new (UP_DAEMON_ERROR, UP_DAEMON_ERROR_GENERAL, \"device does not support getting history\");\n\t\tdbus_g_method_return_error (context, error);\n\t\tgoto out;\n\t}\n\n\t/* get the correct data */\n\tif (g_strcmp0 (type_string, \"rate\") == 0)\n\t\ttype = UP_HISTORY_TYPE_RATE;\n\telse if (g_strcmp0 (type_string, \"charge\") == 0)\n\t\ttype = UP_HISTORY_TYPE_CHARGE;\n\telse if (g_strcmp0 (type_string, \"time-full\") == 0)\n\t\ttype = UP_HISTORY_TYPE_TIME_FULL;\n\telse if (g_strcmp0 (type_string, \"time-empty\") == 0)\n\t\ttype = UP_HISTORY_TYPE_TIME_EMPTY;\n\n\t/* something recognised */\n\tif (type != UP_HISTORY_TYPE_UNKNOWN)\n\t\tarray = up_history_get_data (device->priv->history, type, timespan, resolution);\n\n\t/* maybe the device doesn't have any history */\n\tif (array == NULL) {\n\t\terror = g_error_new (UP_DAEMON_ERROR, UP_DAEMON_ERROR_GENERAL, \"device has no history\");\n\t\tdbus_g_method_return_error (context, error);\n\t\tgoto out;\n\t}\n\n\t/* copy data to dbus struct */\n\tcomplex = g_ptr_array_sized_new (array->len);\n\tfor (i=0; ilen; i++) {\n\t\titem = (UpHistoryItem *) g_ptr_array_index (array, i);\n\t\tvalue = g_new0 (GValue, 1);\n\t\tg_value_init (value, UP_DBUS_STRUCT_UINT_DOUBLE_UINT);\n\t\tg_value_take_boxed (value, dbus_g_type_specialized_construct (UP_DBUS_STRUCT_UINT_DOUBLE_UINT));\n\t\tdbus_g_type_struct_set (value,\n\t\t\t\t\t0, up_history_item_get_time (item),\n\t\t\t\t\t1, up_history_item_get_value (item),\n\t\t\t\t\t2, up_history_item_get_state (item), -1);\n\t\tg_ptr_array_add (complex, g_value_get_boxed (value));\n\t\tg_free (value);\n\t}\n\n\tdbus_g_method_return (context, complex);\nout:\n\tif (array != NULL)\n\t\tg_ptr_array_unref (array);\n\treturn TRUE;\n}", "label": 0, "cwe": null, "length": 585 }, { "index": 663460, "code": "hub_handle_support(struct hub_info* hub, struct hub_user* u, struct adc_message* cmd)\n{\n\tint ret = 0;\n\tint index = 0;\n\tint ok = 1;\n\tchar* arg = adc_msg_get_argument(cmd, index);\n\n\tif (hub->status == hub_status_disabled && u->state == state_protocol)\n\t{\n\t\ton_login_failure(hub, u, status_msg_hub_disabled);\n\t\thub_free(arg);\n\t\treturn -1;\n\t}\n\n\twhile (arg)\n\t{\n\t\tif (strlen(arg) == 6)\n\t\t{\n\t\t\tfourcc_t fourcc = FOURCC(arg[2], arg[3], arg[4], arg[5]);\n\t\t\tif (strncmp(arg, ADC_SUP_FLAG_ADD, 2) == 0)\n\t\t\t{\n\t\t\t\tuser_support_add(u, fourcc);\n\t\t\t}\n\t\t\telse if (strncmp(arg, ADC_SUP_FLAG_REMOVE, 2) == 0)\n\t\t\t{\n\t\t\t\tuser_support_remove(u, fourcc);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tok = 0;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tok = 0;\n\t\t}\n\n\t\tindex++;\n\t\thub_free(arg);\n\t\targ = adc_msg_get_argument(cmd, index);\n\t}\n\n\tif (u->state == state_protocol)\n\t{\n\t\tif (index == 0) ok = 0; /* Need to support *SOMETHING*, at least BASE */\n\t\tif (!ok)\n\t\t{\n\t\t\t/* disconnect user. Do not send crap during initial handshake! */\n\t\t\thub_disconnect_user(hub, u, quit_logon_error);\n\t\t\treturn -1;\n\t\t}\n\n\t\tif (user_flag_get(u, feature_base))\n\t\t{\n\t\t\t/* User supports ADC/1.0 and a hash we know */\n\t\t\tif (user_flag_get(u, feature_tiger))\n\t\t\t{\n\t\t\t\thub_send_handshake(hub, u);\n\t\t\t\tnet_con_set_timeout(u->connection, TIMEOUT_HANDSHAKE);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// no common hash algorithm.\n\t\t\t\thub_send_status(hub, u, status_msg_proto_no_common_hash, status_level_fatal);\n\t\t\t\thub_disconnect_user(hub, u, quit_protocol_error);\n\t\t\t}\n\t\t}\n\t\telse if (user_flag_get(u, feature_bas0))\n\t\t{\n\t\t\tif (hub->config->obsolete_clients)\n\t\t\t{\n\t\t\t\thub_send_handshake(hub, u);\n\t\t\t\tnet_con_set_timeout(u->connection, TIMEOUT_HANDSHAKE);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t/* disconnect user for using an obsolete client. */\n\t\t\t\tchar* tmp = adc_msg_escape(hub->config->msg_proto_obsolete_adc0);\n\t\t\t\tstruct adc_message* message = adc_msg_construct(ADC_CMD_IMSG, 6 + strlen(tmp));\n\t\t\t\tadc_msg_add_argument(message, tmp);\n\t\t\t\thub_free(tmp);\n\t\t\t\troute_to_user(hub, u, message);\n\t\t\t\tadc_msg_free(message);\n\t\t\t\thub_disconnect_user(hub, u, quit_protocol_error);\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\t/* Not speaking a compatible protocol - just disconnect. */\n\t\t\thub_disconnect_user(hub, u, quit_logon_error);\n\t\t}\n\t}\n\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 694 }, { "index": 174018, "code": "do_dim(gpasmVal r,\n char *name,\n int arity,\n struct pnode *parms)\n{\n struct pnode *p;\n char *symbol_name = NULL;\n gp_symbol_type *coff_symbol = NULL;\n int number_symbols;\n gp_aux_type *aux_list;\n struct sllist first_list;\n struct sllist *list = &first_list;\n struct sllist *previous;\n int i;\n int value;\n\n state.lst.line.linetype = dir;\n\n if (state.mode == absolute) {\n gperror(GPE_OBJECT_ONLY, NULL);\n } else {\n if (arity < 3) { \n enforce_arity(arity, 1);\n return r;\n }\n \n /* the first argument is the symbol name */\n p = HEAD(parms);\n if (enforce_simple(p)) {\n /* lookup the symbol */\n symbol_name = p->value.symbol;\n coff_symbol = gp_coffgen_findsymbol(state.obj.object, symbol_name);\n if (coff_symbol == NULL) {\n gperror(GPE_NOSYM, NULL);\n return r;\n }\n } else {\n return r;\n }\n parms = TAIL(parms);\n\n /* the second argument must be the number of aux symbols */\n p = HEAD(parms);\n number_symbols = maybe_evaluate(p);\n if ((number_symbols < 0) || (number_symbols > 127)) {\n gperror(GPE_UNKNOWN, \"number of auxiliary symbols must be less then 128 and positive\"); \n return r;\n }\n state.obj.symbol_num += number_symbols;\n parms = TAIL(parms);\n\n /* create the symbols */\n aux_list = gp_coffgen_blockaux(number_symbols);\n coff_symbol->num_auxsym = number_symbols;\n coff_symbol->aux_list = aux_list;\n\n /* convert the arguments into a list of values */\n list->next = NULL;\n simplify_data(parms, list, 0);\n\n /* write the data to the auxiliary symbols */\n list = list->next;\n i = 0;\n while(list) {\n value = maybe_evaluate(list->p);\n if (value & (~0xff)) {\n gperror(GPE_RANGE, NULL); \n return r;\n }\n \n if (aux_list == NULL) {\n gperror(GPE_UNKNOWN, \"insufficent number of auxiliary symbols\"); \n return r;\n }\n \n if (i == (state.obj.newcoff ? SYMBOL_SIZE_v2 : SYMBOL_SIZE_v1)) {\n i = 0;\n aux_list = aux_list->next; \n } else {\n aux_list->_aux_symbol.data[i++] = value;\n }\n\n previous = list;\n list = list->next;\n free(previous);\n }\n }\n\n return r;\n}", "label": 0, "cwe": null, "length": 605 }, { "index": 841258, "code": "mgmt_get_fw_config(struct be_ctrl_info *ctrl,\n\t\t\t\tstruct beiscsi_hba *phba)\n{\n\tstruct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem);\n\tstruct be_fw_cfg *req = embedded_payload(wrb);\n\tint status = 0;\n\n\tspin_lock(&ctrl->mbox_lock);\n\tmemset(wrb, 0, sizeof(*wrb));\n\n\tbe_wrb_hdr_prepare(wrb, sizeof(*req), true, 0);\n\n\tbe_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,\n\t\t\t OPCODE_COMMON_QUERY_FIRMWARE_CONFIG,\n\t\t\t EMBED_MBX_MAX_PAYLOAD_SIZE);\n\tstatus = be_mbox_notify(ctrl);\n\tif (!status) {\n\t\tuint8_t ulp_num = 0;\n\t\tstruct be_fw_cfg *pfw_cfg;\n\t\tpfw_cfg = req;\n\n\t\tif (!is_chip_be2_be3r(phba)) {\n\t\t\tphba->fw_config.eqid_count = pfw_cfg->eqid_count;\n\t\t\tphba->fw_config.cqid_count = pfw_cfg->cqid_count;\n\n\t\t\tbeiscsi_log(phba, KERN_INFO,\n\t\t\t\t BEISCSI_LOG_INIT,\n\t\t\t\t \"BG_%d : EQ_Count : %d CQ_Count : %d\\n\",\n\t\t\t\t phba->fw_config.eqid_count,\n\t\t\t\t phba->fw_config.cqid_count);\n\t\t}\n\n\t\tfor (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++)\n\t\t\tif (pfw_cfg->ulp[ulp_num].ulp_mode &\n\t\t\t BEISCSI_ULP_ISCSI_INI_MODE)\n\t\t\t\tset_bit(ulp_num,\n\t\t\t\t&phba->fw_config.ulp_supported);\n\n\t\tphba->fw_config.phys_port = pfw_cfg->phys_port;\n\t\tfor (ulp_num = 0; ulp_num < BEISCSI_ULP_COUNT; ulp_num++) {\n\t\t\tif (test_bit(ulp_num, &phba->fw_config.ulp_supported)) {\n\n\t\t\t\tphba->fw_config.iscsi_cid_start[ulp_num] =\n\t\t\t\t\tpfw_cfg->ulp[ulp_num].sq_base;\n\t\t\t\tphba->fw_config.iscsi_cid_count[ulp_num] =\n\t\t\t\t\tpfw_cfg->ulp[ulp_num].sq_count;\n\n\t\t\t\tphba->fw_config.iscsi_icd_start[ulp_num] =\n\t\t\t\t\tpfw_cfg->ulp[ulp_num].icd_base;\n\t\t\t\tphba->fw_config.iscsi_icd_count[ulp_num] =\n\t\t\t\t\tpfw_cfg->ulp[ulp_num].icd_count;\n\n\t\t\t\tphba->fw_config.iscsi_chain_start[ulp_num] =\n\t\t\t\t\tpfw_cfg->chain_icd[ulp_num].chain_base;\n\t\t\t\tphba->fw_config.iscsi_chain_count[ulp_num] =\n\t\t\t\t\tpfw_cfg->chain_icd[ulp_num].chain_count;\n\n\t\t\t\tbeiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,\n\t\t\t\t\t \"BG_%d : Function loaded on ULP : %d\\n\"\n\t\t\t\t\t \"\\tiscsi_cid_count : %d\\n\"\n\t\t\t\t\t \"\\tiscsi_cid_start : %d\\n\"\n\t\t\t\t\t \"\\t iscsi_icd_count : %d\\n\"\n\t\t\t\t\t \"\\t iscsi_icd_start : %d\\n\",\n\t\t\t\t\t ulp_num,\n\t\t\t\t\t phba->fw_config.\n\t\t\t\t\t iscsi_cid_count[ulp_num],\n\t\t\t\t\t phba->fw_config.\n\t\t\t\t\t iscsi_cid_start[ulp_num],\n\t\t\t\t\t phba->fw_config.\n\t\t\t\t\t iscsi_icd_count[ulp_num],\n\t\t\t\t\t phba->fw_config.\n\t\t\t\t\t iscsi_icd_start[ulp_num]);\n\t\t\t}\n\t\t}\n\n\t\tphba->fw_config.dual_ulp_aware = (pfw_cfg->function_mode &\n\t\t\t\t\t\t BEISCSI_FUNC_DUA_MODE);\n\n\t\tbeiscsi_log(phba, KERN_INFO, BEISCSI_LOG_INIT,\n\t\t\t \"BG_%d : DUA Mode : 0x%x\\n\",\n\t\t\t phba->fw_config.dual_ulp_aware);\n\n\t} else {\n\t\tbeiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,\n\t\t\t \"BG_%d : Failed in mgmt_get_fw_config\\n\");\n\t\tstatus = -EINVAL;\n\t}\n\n\tspin_unlock(&ctrl->mbox_lock);\n\treturn status;\n}", "label": 0, "cwe": null, "length": 901 }, { "index": 859360, "code": "_dxf_SetCompositeImageOrigin ( CompositeField image,\n int xorigin, int yorigin )\n{\n Object member;\n int cfield_origin[2];\n int member_origin[2];\n int i;\n\n if ( !DXGetImageBounds ( (Object)image, &cfield_origin[0], &cfield_origin[1],\n NULL, NULL ) )\n goto error;\n\n if ( ( cfield_origin[0] == xorigin )\n &&\n ( cfield_origin[1] == yorigin ) )\n\n return image; /* We are in luck */\n\n for ( i = 0;\n (member= DXGetEnumeratedMember ( (Group)image, i, NULL ));\n i++ )\n\n switch ( DXGetObjectClass ( member ) )\n {\n case CLASS_FIELD:\n if ( !DXGetImageBounds\n ( (Object)member,\n &member_origin[0], &member_origin[1], NULL, NULL ) )\n goto error;\n\n member_origin[0] = ( member_origin[0] - cfield_origin[0] )\n + xorigin;\n member_origin[1] = ( member_origin[1] - cfield_origin[1] )\n + yorigin;\n\n if ( !_dxf_SetImageOrigin\n ( (Field)member,\n member_origin[0],\n member_origin[1] ) )\n goto error;\n\n break;\n\n case CLASS_GROUP:\n\n switch ( DXGetGroupClass ( (Group)member ) )\n {\n case CLASS_COMPOSITEFIELD:\n\n if ( !DXGetImageBounds\n ( (Object)member,\n &member_origin[0], &member_origin[1],\n NULL, NULL ) )\n goto error;\n\n member_origin[0]\n = ( member_origin[0] - cfield_origin[0] ) + xorigin;\n\n member_origin[1]\n = ( member_origin[1] - cfield_origin[1] ) + yorigin;\n\n if ( !_dxf_SetCompositeImageOrigin\n ( (CompositeField)member,\n member_origin[0],\n member_origin[1] ) )\n goto error;\n\n break;\n\n default:\n DXErrorGoto\n ( ERROR_DATA_INVALID, \n \"Illegal member in Arranged Group\" );\n }\n break;\n\n default:\n DXErrorGoto ( ERROR_DATA_INVALID, \n \"Illegal member in Arranged Group\" );\n }\n\n return image;\n error:\n ERROR_SECTION;\n return ERROR;\n\n}", "label": 0, "cwe": null, "length": 533 }, { "index": 737077, "code": "event_del_internal(struct event *ev)\n{\n\tstruct event_base *base;\n\tint res = 0, notify = 0;\n\n\tevent_debug((\"event_del: %p (fd \"EV_SOCK_FMT\"), callback %p\",\n\t\tev, EV_SOCK_ARG(ev->ev_fd), ev->ev_callback));\n\n\t/* An event without a base has not been added */\n\tif (ev->ev_base == NULL)\n\t\treturn (-1);\n\n\tEVENT_BASE_ASSERT_LOCKED(ev->ev_base);\n\n\t/* If the main thread is currently executing this event's callback,\n\t * and we are not the main thread, then we want to wait until the\n\t * callback is done before we start removing the event. That way,\n\t * when this function returns, it will be safe to free the\n\t * user-supplied argument. */\n\tbase = ev->ev_base;\n#ifndef _EVENT_DISABLE_THREAD_SUPPORT\n\tif (base->current_event == ev && !EVBASE_IN_THREAD(base)) {\n\t\t++base->current_event_waiters;\n\t\tEVTHREAD_COND_WAIT(base->current_event_cond, base->th_base_lock);\n\t}\n#endif\n\n\tEVUTIL_ASSERT(!(ev->ev_flags & ~EVLIST_ALL));\n\n\t/* See if we are just active executing this event in a loop */\n\tif (ev->ev_events & EV_SIGNAL) {\n\t\tif (ev->ev_ncalls && ev->ev_pncalls) {\n\t\t\t/* Abort loop */\n\t\t\t*ev->ev_pncalls = 0;\n\t\t}\n\t}\n\n\tif (ev->ev_flags & EVLIST_TIMEOUT) {\n\t\t/* NOTE: We never need to notify the main thread because of a\n\t\t * deleted timeout event: all that could happen if we don't is\n\t\t * that the dispatch loop might wake up too early. But the\n\t\t * point of notifying the main thread _is_ to wake up the\n\t\t * dispatch loop early anyway, so we wouldn't gain anything by\n\t\t * doing it.\n\t\t */\n\t\tevent_queue_remove(base, ev, EVLIST_TIMEOUT);\n\t}\n\n\tif (ev->ev_flags & EVLIST_ACTIVE)\n\t\tevent_queue_remove(base, ev, EVLIST_ACTIVE);\n\n\tif (ev->ev_flags & EVLIST_INSERTED) {\n\t\tevent_queue_remove(base, ev, EVLIST_INSERTED);\n\t\tif (ev->ev_events & (EV_READ|EV_WRITE))\n\t\t\tres = evmap_io_del(base, ev->ev_fd, ev);\n\t\telse\n\t\t\tres = evmap_signal_del(base, (int)ev->ev_fd, ev);\n\t\tif (res == 1) {\n\t\t\t/* evmap says we need to notify the main thread. */\n\t\t\tnotify = 1;\n\t\t\tres = 0;\n\t\t}\n\t}\n\n\t/* if we are not in the right thread, we need to wake up the loop */\n\tif (res != -1 && notify && EVBASE_NEED_NOTIFY(base))\n\t\tevthread_notify_base(base);\n\n\t_event_debug_note_del(ev);\n\n\treturn (res);\n}", "label": 0, "cwe": null, "length": 627 }, { "index": 61076, "code": "main (int argc, char *argv[])\n{\n int i, N=10000, p;\n mpfr_rnd_t rnd;\n double d;\n\n tests_start_mpfr ();\n\n /* with no argument: prints to /dev/null,\n tout_str N: prints N tests to stdout */\n if (argc == 1)\n {\n fout = fopen (\"/dev/null\", \"w\");\n /* If we failed to open this device, try with a dummy file */\n if (fout == NULL)\n fout = fopen (\"mpfrtest.txt\", \"w\");\n }\n else\n {\n fout = stdout;\n N = atoi (argv[1]);\n }\n\n if (fout == NULL)\n {\n printf (\"Can't open /dev/null or stdout\\n\");\n exit (1);\n }\n\n special ();\n\n check (-1.37247529013405550000e+15, MPFR_RNDN, 7);\n check (-1.5674376729569697500e+15, MPFR_RNDN, 19);\n check (-5.71262771772792640000e-79, MPFR_RNDU, 16);\n check (DBL_NEG_ZERO, MPFR_RNDU, 7);\n check (-4.5306392613572974756e-308, MPFR_RNDN, 8);\n check (-6.7265890111403371523e-165, MPFR_RNDN, 4);\n check (-1.3242553591261807653e+156, MPFR_RNDN, 16);\n check (-6.606499965302424244461355e233, MPFR_RNDN, 10);\n check4 (1.0, MPFR_RNDN, 10, 120);\n check (1.0, MPFR_RNDU, 10);\n check (4.059650008e-83, MPFR_RNDN, 10);\n check (-7.4, MPFR_RNDN, 10);\n check (0.997, MPFR_RNDN, 10);\n check (-4.53063926135729747564e-308, MPFR_RNDN, 10);\n check (2.14478198760196000000e+16, MPFR_RNDN, 10);\n check (7.02293374921793516813e-84, MPFR_RNDN, 10);\n\n /* random tests */\n for (i=0;ismall.\n\t *\n\t * The above is pure speculation and has not been derived\n\t * empirically. In actual practice, the distribution of the\n\t * data, both spatially and in terms of their values, will\n\t * have a strong effect on convergence.\n\t *\n\t * W. H. F. Smith, 26 Feb 1992. */\n\n\tGMT_LONG\tgcd;\t\t/* Current value of the gcd */\n\tGMT_LONG\tnxg, nyg;\t/* Current value of the grid dimensions */\n\tGMT_LONG\tnfactors = 0;\t/* Number of prime factors of current gcd */\n\tGMT_LONG\tfactor;\t\t/* Currently used factor */\n\t/* Doubles are used below, even though the values will be integers,\n\t\tbecause the multiplications might reach sizes of O(n**3) */\n\tdouble\tt_sum;\t\t/* Sum of values of T at each grid cycle */\n\tdouble\tlength;\t\t/* Current propagation distance. */\n\n\n\tgcd = gcd_euclid((GMT_LONG)nx, (GMT_LONG)ny);\n\tif (gcd > 1) {\n\t\tnfactors = get_prime_factors(gcd, factors);\n\t\tnxg = (GMT_LONG)(nx/gcd);\n\t\tnyg = (GMT_LONG)(ny/gcd);\n\t\tif (nxg < 3 || nyg < 3) {\n\t\t\tfactor = factors[nfactors - 1];\n\t\t\tnfactors--;\n\t\t\tgcd /= factor;\n\t\t\tnxg *= factor;\n\t\t\tnyg *= factor;\n\t\t}\n\t}\n\telse {\n\t\tnxg = nx;\n\t\tnyg = ny;\n\t}\n\tlength = (double)MAX(nxg, nyg);\n\tt_sum = nxg * (nyg * length);\t/* Make it double at each multiply */\n\n\t/* Are there more grid cycles ? */\n\twhile (gcd > 1) {\n\t\tfactor = factors[nfactors - 1];\n\t\tnfactors--;\n\t\tgcd /= factor;\n\t\tnxg *= factor;\n\t\tnyg *= factor;\n\t\tlength = (double)factor;\n\t\tt_sum += nxg * (nyg * length);\n\t}\n\treturn(t_sum);\n}", "label": 0, "cwe": null, "length": 752 }, { "index": 795826, "code": "teletex_validate(\n\tstruct berval\t*val\n)\n{\n\tint rc = 0; /* assume the value is valid */\n\tconst char *start = NULL;\n\tconst char *end = NULL;\n\tconst char *p = NULL;\n\tint got_ttx_term = 0;\n\n\t/* Per RFC4517:\n\t *\n\t * teletex-id = ttx-term *(DOLLAR ttx-param)\n\t * ttx-term = PrintableString\n\t * ttx-param = ttx-key COLON ttx-value\n\t * tty-key = \"graphic\" / \"control\" / \"misc\" / \"page\" / \"private\"\n\t * ttx-value = *ttx-value-octet\n\t *\n\t * ttx-value-octet = %x00-23\n\t * / (%x5C \"24\") ; escaped \"$\"\n\t * / %x25-5B\n\t * / (%x5C \"5C\") ; escaped \"\\\"\n\t * / %x5D-FF\n\t */\n\n\t/* Don't allow a 0 length string */\n\tif ((val == NULL) || (val->bv_len == 0)) {\n\t\trc = 1;\n\t\tgoto exit;\n\t}\n\n\tstart = &(val->bv_val[0]);\n\tend = &(val->bv_val[val->bv_len - 1]);\n\n\t/* Look for a DOLLAR separator. */\n\tfor (p = start; p <= end; p++) {\n\t\tif (IS_DOLLAR(*p)) {\n\t\t\t/* Ensure we don't have an empty element. */\n\t\t\tif ((p == start) || (p == end)) {\n\t\t\t\trc = 1;\n\t\t\t\tgoto exit;\n\t\t\t}\n\n\t\t\tif (!got_ttx_term) {\n\t\t\t\t/* Validate the ttx-term. */\n\t\t\t\twhile (start < p) {\n\t\t\t\t\tif (!IS_PRINTABLE(*start)) {\n\t\t\t\t\t\trc = 1;\n\t\t\t\t\t\tgoto exit;\n\t\t\t\t\t}\n\t\t\t\t\tstart++;\n\t\t\t\t}\n\n\t\t\t\tgot_ttx_term = 1;\n\t\t\t} else {\n\t\t\t\t/* Validate the ttx-param. */\n\t\t\t\tif ((rc = ttx_param_validate(start, p - 1)) != 0) {\n\t\t\t\t\trc = 1;\n\t\t\t\t\tgoto exit;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/* Reset start to point at the\n\t\t\t * next ttx-param. We're\n\t\t\t * guaranteed to have at least\n\t\t\t * one more char after p. */\n\t\t\tstart = p + 1;\n\t\t}\n\t}\n\n\t/* If we didn't find the ttx-term, validate\n\t * the whole value as the ttx-term. */\n\tif (!got_ttx_term) {\n\t\tfor (p = start; p <= end; p++) {\n\t\t\tif (!IS_PRINTABLE(*p)) {\n\t\t\t\trc = 1;\n\t\t\t\tgoto exit;\n\t\t\t}\n\t\t}\n\t} else {\n\t\t/* Validate the final ttx-param. */\n\t\trc = ttx_param_validate(start, end);\n\t}\n\nexit:\n\treturn rc;\n}", "label": 0, "cwe": null, "length": 643 }, { "index": 169148, "code": "rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe)\n{\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t/* exclude ICV */\n\tu16 pnl;\n\tu32 pnh;\n\tu8 rc4key[16];\n\tu8 ttkey[16];\n\tu8\tcrc[4];\n\tstruct arc4context mycontext;\n\tint\t\t\tlength;\n\n\tu8\t*pframe, *payload, *iv, *prwskey;\n\tunion pn48 dot11txpn;\n\tstruct\tsta_info\t\t*stainfo;\n\tstruct\trx_pkt_attrib\t *prxattrib = &((struct recv_frame *)precvframe)->attrib;\n\tstruct\tsecurity_priv\t*psecuritypriv = &padapter->securitypriv;\n\tu32\t\tres = _SUCCESS;\n\n\n\tpframe = (unsigned char *)((struct recv_frame *)precvframe)->rx_data;\n\n\t/* 4 start to decrypt recvframe */\n\tif (prxattrib->encrypt == _TKIP_) {\n\t\tstainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]);\n\t\tif (stainfo != NULL) {\n\t\t\tif (IS_MCAST(prxattrib->ra)) {\n\t\t\t\tif (!psecuritypriv->binstallGrpkey) {\n\t\t\t\t\tres = _FAIL;\n\t\t\t\t\tDBG_88E(\"%s:rx bc/mc packets, but didn't install group key!!!!!!!!!!\\n\", __func__);\n\t\t\t\t\tgoto exit;\n\t\t\t\t}\n\t\t\t\tprwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey;\n\t\t\t} else {\n\t\t\t\tRT_TRACE(_module_rtl871x_security_c_, _drv_err_, (\"rtw_tkip_decrypt: stainfo!= NULL!!!\\n\"));\n\t\t\t\tprwskey = &stainfo->dot118021x_UncstKey.skey[0];\n\t\t\t}\n\n\t\t\tiv = pframe+prxattrib->hdrlen;\n\t\t\tpayload = pframe+prxattrib->iv_len+prxattrib->hdrlen;\n\t\t\tlength = ((struct recv_frame *)precvframe)->len-prxattrib->hdrlen-prxattrib->iv_len;\n\n\t\t\tGET_TKIP_PN(iv, dot11txpn);\n\n\t\t\tpnl = (u16)(dot11txpn.val);\n\t\t\tpnh = (u32)(dot11txpn.val>>16);\n\n\t\t\tphase1((u16 *)&ttkey[0], prwskey, &prxattrib->ta[0], pnh);\n\t\t\tphase2(&rc4key[0], prwskey, (unsigned short *)&ttkey[0], pnl);\n\n\t\t\t/* 4 decrypt payload include icv */\n\n\t\t\tarcfour_init(&mycontext, rc4key, 16);\n\t\t\tarcfour_encrypt(&mycontext, payload, payload, length);\n\n\t\t\t*((__le32 *)crc) = getcrc32(payload, length-4);\n\n\t\t\tif (crc[3] != payload[length-1] ||\n\t\t\t crc[2] != payload[length-2] ||\n\t\t\t crc[1] != payload[length-3] ||\n\t\t\t crc[0] != payload[length-4]) {\n\t\t\t\tRT_TRACE(_module_rtl871x_security_c_, _drv_err_,\n\t\t\t\t\t (\"rtw_wep_decrypt:icv error crc (%4ph)!=payload (%4ph)\\n\",\n\t\t\t\t\t &crc, &payload[length-4]));\n\t\t\t\tres = _FAIL;\n\t\t\t}\n\t\t} else {\n\t\t\tRT_TRACE(_module_rtl871x_security_c_, _drv_err_, (\"rtw_tkip_decrypt: stainfo==NULL!!!\\n\"));\n\t\t\tres = _FAIL;\n\t\t}\n\t}\nexit:\n\treturn res;\n}", "label": 1, "cwe": "CWE-other", "length": 773 }, { "index": 930740, "code": "do_takeoff()\n{\n\tregister struct obj *otmp = (struct obj *)0;\n\n\tif (taking_off == W_WEP) {\n\t if(!cursed(uwep)) {\n\t setuwep((struct obj *) 0);\n\t You(\"are empty %s.\", body_part(HANDED));\n\t u.twoweap = FALSE;\n\t }\n\t} else if (taking_off == W_SWAPWEP) {\n\t setuswapwep((struct obj *) 0);\n\t You(\"no longer have a second weapon readied.\");\n\t u.twoweap = FALSE;\n\t} else if (taking_off == W_QUIVER) {\n\t setuqwep((struct obj *) 0);\n\t You(\"no longer have ammunition readied.\");\n\t} else if (taking_off == WORN_ARMOR) {\n\t otmp = uarm;\n\t if(!cursed(otmp)) (void) Armor_off();\n\t} else if (taking_off == WORN_CLOAK) {\n\t otmp = uarmc;\n\t if(!cursed(otmp)) (void) Cloak_off();\n\t} else if (taking_off == WORN_BOOTS) {\n\t otmp = uarmf;\n\t if(!cursed(otmp)) (void) Boots_off();\n\t} else if (taking_off == WORN_GLOVES) {\n\t otmp = uarmg;\n\t if(!cursed(otmp)) (void) Gloves_off();\n\t} else if (taking_off == WORN_HELMET) {\n\t otmp = uarmh;\n\t if(!cursed(otmp)) (void) Helmet_off();\n\t} else if (taking_off == WORN_SHIELD) {\n\t otmp = uarms;\n\t if(!cursed(otmp)) (void) Shield_off();\n#ifdef TOURIST\n\t} else if (taking_off == WORN_SHIRT) {\n\t otmp = uarmu;\n\t if (!cursed(otmp)) (void) Shirt_off();\n#endif\n\t} else if (taking_off == WORN_AMUL) {\n\t otmp = uamul;\n\t if(!cursed(otmp)) Amulet_off();\n\t} else if (taking_off == LEFT_RING) {\n\t otmp = uleft;\n\t if(!cursed(otmp)) Ring_off(uleft);\n\t} else if (taking_off == RIGHT_RING) {\n\t otmp = uright;\n\t if(!cursed(otmp)) Ring_off(uright);\n\t} else if (taking_off == WORN_BLINDF) {\n\t if (!cursed(ublindf)) Blindf_off(ublindf);\n\t} else impossible(\"do_takeoff: taking off %lx\", taking_off);\n\n\treturn(otmp);\n}", "label": 0, "cwe": null, "length": 582 }, { "index": 92815, "code": "exo_tree_view_single_click_timeout (gpointer user_data)\n{\n GtkTreeViewColumn *cursor_column;\n GtkTreeSelection *selection;\n GtkTreeModel *model;\n GtkTreePath *cursor_path;\n GtkTreeIter iter;\n ExoTreeView *tree_view = EXO_TREE_VIEW (user_data);\n gboolean hover_path_selected;\n GList *rows;\n GList *lp;\n\n GDK_THREADS_ENTER ();\n\n /* verify that we are in single-click mode, have focus and a hover path */\n if (GTK_WIDGET_HAS_FOCUS (tree_view) && tree_view->priv->single_click && tree_view->priv->hover_path != NULL)\n {\n /* transform the hover_path to a tree iterator */\n model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));\n if (model != NULL && gtk_tree_model_get_iter (model, &iter, tree_view->priv->hover_path))\n {\n /* determine the current cursor path/column */\n gtk_tree_view_get_cursor (GTK_TREE_VIEW (tree_view), &cursor_path, &cursor_column);\n\n /* be sure the row is fully visible */\n gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tree_view), tree_view->priv->hover_path, cursor_column, FALSE, 0.0f, 0.0f);\n\n /* determine the selection and change it appropriately */\n selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));\n if (gtk_tree_selection_get_mode (selection) == GTK_SELECTION_NONE)\n {\n /* just place the cursor on the row */\n gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree_view), tree_view->priv->hover_path, cursor_column, FALSE);\n }\n else if ((tree_view->priv->single_click_timeout_state & GDK_SHIFT_MASK) != 0\n && gtk_tree_selection_get_mode (selection) == GTK_SELECTION_MULTIPLE)\n {\n /* check if the item is not already selected (otherwise do nothing) */\n if (!gtk_tree_selection_path_is_selected (selection, tree_view->priv->hover_path))\n {\n /* unselect all previously selected items */\n gtk_tree_selection_unselect_all (selection);\n\n /* since we cannot access the anchor of a GtkTreeView, we\n * use the cursor instead which is usually the same row.\n */\n if (G_UNLIKELY (cursor_path == NULL))\n {\n /* place the cursor on the new row */\n gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree_view), tree_view->priv->hover_path, cursor_column, FALSE);\n }\n else\n {\n /* select all between the cursor and the current row */\n gtk_tree_selection_select_range (selection, tree_view->priv->hover_path, cursor_path);\n }\n }\n }\n else\n {\n /* remember the previously selected rows as set_cursor() clears the selection */\n rows = gtk_tree_selection_get_selected_rows (selection, NULL);\n\n /* check if the hover path is selected (as it will be selected after the set_cursor() call) */\n hover_path_selected = gtk_tree_selection_path_is_selected (selection, tree_view->priv->hover_path);\n\n /* place the cursor on the hover row */\n gtk_tree_view_set_cursor (GTK_TREE_VIEW (tree_view), tree_view->priv->hover_path, cursor_column, FALSE);\n\n /* restore the previous selection */\n for (lp = rows; lp != NULL; lp = lp->next)\n {\n gtk_tree_selection_select_path (selection, lp->data);\n gtk_tree_path_free (lp->data);\n }\n g_list_free (rows);\n\n /* check what to do */\n if ((gtk_tree_selection_get_mode (selection) == GTK_SELECTION_MULTIPLE ||\n (gtk_tree_selection_get_mode (selection) == GTK_SELECTION_SINGLE && hover_path_selected))\n && (tree_view->priv->single_click_timeout_state & GDK_CONTROL_MASK) != 0)\n {\n /* toggle the selection state of the row */\n if (G_UNLIKELY (hover_path_selected))\n gtk_tree_selection_unselect_path (selection, tree_view->priv->hover_path);\n else\n gtk_tree_selection_select_path (selection, tree_view->priv->hover_path);\n }\n else if (G_UNLIKELY (!hover_path_selected))\n {\n /* unselect all other rows */\n gtk_tree_selection_unselect_all (selection);\n\n /* select only the hover row */\n gtk_tree_selection_select_path (selection, tree_view->priv->hover_path);\n }\n }\n\n /* cleanup */\n if (G_LIKELY (cursor_path != NULL))\n gtk_tree_path_free (cursor_path);\n }\n }\n\n GDK_THREADS_LEAVE ();\n\n return FALSE;\n}", "label": 0, "cwe": null, "length": 991 }, { "index": 731863, "code": "slurm_build_cpuset(char *base, char *path, uid_t uid, gid_t gid)\n{\n\tchar file_path[PATH_MAX], mstr[16];\n\tint fd, rc;\n\n\tif (mkdir(path, 0700) && (errno != EEXIST)) {\n\t\terror(\"mkdir(%s): %m\", path);\n\t\treturn -1;\n\t}\n\tif (chown(path, uid, gid))\n\t\terror(\"chown(%s): %m\", path);\n\n\t/* Copy \"cpus\" contents from parent directory\n\t * \"cpus\" must be set before any tasks can be added. */\n\tsnprintf(file_path, sizeof(file_path), \"%s/cpus\", base);\n\tfd = open(file_path, O_RDONLY);\n\tif (fd < 0) {\n\t\terror(\"open(%s): %m\", file_path);\n\t\treturn -1;\n\t}\n\trc = read(fd, mstr, sizeof(mstr));\n\tclose(fd);\n\tif (rc < 1) {\n\t\terror(\"read(%s): %m\", file_path);\n\t\treturn -1;\n\t}\n\tsnprintf(file_path, sizeof(file_path), \"%s/cpus\", path);\n\tfd = open(file_path, O_CREAT | O_WRONLY, 0700);\n\tif (fd < 0) {\n\t\terror(\"open(%s): %m\", file_path);\n\t\treturn -1;\n\t}\n\trc = write(fd, mstr, rc);\n\tclose(fd);\n\tif (rc < 1) {\n\t\terror(\"write(%s): %m\", file_path);\n\t\treturn -1;\n\t}\n\n\t/* Copy \"mems\" contents from parent directory, if it exists.\n\t * \"mems\" must be set before any tasks can be added. */\n\tsnprintf(file_path, sizeof(file_path), \"%s/mems\", base);\n\tfd = open(file_path, O_RDONLY);\n\tif (fd < 0) {\n\t\terror(\"open(%s): %m\", file_path);\n\t\treturn -1;\n\t}\n\trc = read(fd, mstr, sizeof(mstr));\n\tclose(fd);\n\tif (rc < 1) {\n\t\terror(\"read(%s): %m\", file_path);\n\t\treturn -1;\n\t}\n\tsnprintf(file_path, sizeof(file_path), \"%s/mems\", path);\n\tfd = open(file_path, O_CREAT | O_WRONLY, 0700);\n\tif (fd < 0) {\n\t\terror(\"open(%s): %m\", file_path);\n\t\treturn -1;\n\t}\n\trc = write(fd, mstr, rc);\n\tclose(fd);\n\tif (rc < 1) {\n\t\terror(\"write(%s): %m\", file_path);\n\t\treturn -1;\n\t}\n\n\t/* Delete cpuset once its tasks complete.\n\t * Dependent upon system daemon. */\n\tsnprintf(file_path, sizeof(file_path), \"%s/notify_on_release\", path);\n\tfd = open(file_path, O_CREAT | O_WRONLY, 0700);\n\tif (fd < 0) {\n\t\terror(\"open(%s): %m\", file_path);\n\t\treturn -1;\n\t}\n\trc = write(fd, \"1\", 2);\n\tclose(fd);\n\tif (rc < 1) {\n\t\terror(\"write(%s): %m\", file_path);\n\t\treturn -1;\n\t}\n\n\t/* Only now can we add tasks.\n\t * We can't add self, so add tasks after exec. */\n\n\treturn 0;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-other" ], "length": 702 }, { "index": 58637, "code": "b2n_div(b2n_ptr q, b2n_ptr r, b2n_ptr n, b2n_ptr m)\n{\n\tint\t\ti, j, len, bits;\n\tu_int32_t\tsm, sn;\n\tb2n_t\t\tnenn, div, shift, mask;\n\n\t/* If Teiler > Zaehler, the result is 0 */\n\tif ((sm = b2n_sigbit(m)) > (sn = b2n_sigbit(n))) {\n\t\tif (b2n_set_null(q))\n\t\t\treturn -1;\n\t\treturn b2n_set(r, n);\n\t}\n\tif (sm == 0)\n\t\t/* Division by Zero */\n\t\treturn -1;\n\telse if (sm == 1) {\n\t\t/* Division by the One-Element */\n\t\tif (b2n_set(q, n))\n\t\t\treturn -1;\n\t\treturn b2n_set_null(r);\n\t}\n\tb2n_init(nenn);\n\tb2n_init(div);\n\tb2n_init(shift);\n\tb2n_init(mask);\n\n\tif (b2n_set(nenn, n))\n\t\tgoto fail;\n\tif (b2n_set(div, m))\n\t\tgoto fail;\n\tif (b2n_set(shift, m))\n\t\tgoto fail;\n\tif (b2n_set_ui(mask, 1))\n\t\tgoto fail;\n\n\tif (b2n_resize(q, (sn - sm + CHUNK_MASK) >> CHUNK_SHIFTS))\n\t\tgoto fail;\n\tmemset(q->limp, 0, CHUNK_BYTES * q->chunks);\n\n\tif (b2n_lshift(shift, shift, sn - sm))\n\t\tgoto fail;\n\tif (b2n_lshift(mask, mask, sn - sm))\n\t\tgoto fail;\n\n\t/* Number of significant octets */\n\tlen = (sn - 1) >> CHUNK_SHIFTS;\n\t/* The first iteration is done over the relevant bits */\n\tbits = (CHUNK_MASK + sn) & CHUNK_MASK;\n\tfor (i = len; i >= 0 && b2n_sigbit(nenn) >= sm; i--)\n\t\tfor (j = (i == len ? bits : CHUNK_MASK); j >= 0\n\t\t && b2n_sigbit(nenn) >= sm; j--) {\n\t\t\tif (nenn->limp[i] & b2n_mask[j]) {\n\t\t\t\tif (b2n_sub(nenn, nenn, shift))\n\t\t\t\t\tgoto fail;\n\t\t\t\tif (b2n_add(q, q, mask))\n\t\t\t\t\tgoto fail;\n\t\t\t}\n\t\t\tif (b2n_rshift(shift, shift, 1))\n\t\t\t\tgoto fail;\n\t\t\tif (b2n_rshift(mask, mask, 1))\n\t\t\t\tgoto fail;\n\t\t}\n\n\tB2N_SWAP(r, nenn);\n\n\tb2n_clear(nenn);\n\tb2n_clear(div);\n\tb2n_clear(shift);\n\tb2n_clear(mask);\n\treturn 0;\n\nfail:\n\tb2n_clear(nenn);\n\tb2n_clear(div);\n\tb2n_clear(shift);\n\tb2n_clear(mask);\n\treturn -1;\n}", "label": 0, "cwe": null, "length": 632 }, { "index": 101219, "code": "lhMapInstallBucket(lhash_kv_engine *pEngine,pgno iLogic,pgno iReal)\n{\n\tlhash_bmap_rec *pRec;\n\tsxu32 iBucket;\n\t/* Allocate a new instance */\n\tpRec = (lhash_bmap_rec *)SyMemBackendPoolAlloc(&pEngine->sAllocator,sizeof(lhash_bmap_rec));\n\tif( pRec == 0 ){\n\t\treturn UNQLITE_NOMEM;\n\t}\n\t/* Zero the structure */\n\tSyZero(pRec,sizeof(lhash_bmap_rec));\n\t/* Fill in the structure */\n\tpRec->iLogic = iLogic;\n\tpRec->iReal = iReal;\n\tiBucket = iLogic & (pEngine->nBuckSize - 1);\n\tpRec->pNextCol = pEngine->apMap[iBucket];\n\tif( pEngine->apMap[iBucket] ){\n\t\tpEngine->apMap[iBucket]->pPrevCol = pRec;\n\t}\n\tpEngine->apMap[iBucket] = pRec;\n\t/* Link */\n\tif( pEngine->pFirst == 0 ){\n\t\tpEngine->pFirst = pEngine->pList = pRec;\n\t}else{\n\t\tMACRO_LD_PUSH(pEngine->pList,pRec);\n\t}\n\tpEngine->nBuckRec++;\n\tif( (pEngine->nBuckRec >= pEngine->nBuckSize * 3) && pEngine->nBuckRec < 100000 ){\n\t\t/* Allocate a new larger table */\n\t\tsxu32 nNewSize = pEngine->nBuckSize << 1;\n\t\tlhash_bmap_rec *pEntry;\n\t\tlhash_bmap_rec **apNew;\n\t\tsxu32 n;\n\t\t\n\t\tapNew = (lhash_bmap_rec **)SyMemBackendAlloc(&pEngine->sAllocator, nNewSize * sizeof(lhash_bmap_rec *));\n\t\tif( apNew ){\n\t\t\t/* Zero the new table */\n\t\t\tSyZero((void *)apNew, nNewSize * sizeof(lhash_bmap_rec *));\n\t\t\t/* Rehash all entries */\n\t\t\tn = 0;\n\t\t\tpEntry = pEngine->pList;\n\t\t\tfor(;;){\n\t\t\t\t/* Loop one */\n\t\t\t\tif( n >= pEngine->nBuckRec ){\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tpEntry->pNextCol = pEntry->pPrevCol = 0;\n\t\t\t\t/* Install in the new bucket */\n\t\t\t\tiBucket = pEntry->iLogic & (nNewSize - 1);\n\t\t\t\tpEntry->pNextCol = apNew[iBucket];\n\t\t\t\tif( apNew[iBucket] ){\n\t\t\t\t\tapNew[iBucket]->pPrevCol = pEntry;\n\t\t\t\t}\n\t\t\t\tapNew[iBucket] = pEntry;\n\t\t\t\t/* Point to the next entry */\n\t\t\t\tpEntry = pEntry->pNext;\n\t\t\t\tn++;\n\t\t\t}\n\t\t\t/* Release the old table and reflect the change */\n\t\t\tSyMemBackendFree(&pEngine->sAllocator,(void *)pEngine->apMap);\n\t\t\tpEngine->apMap = apNew;\n\t\t\tpEngine->nBuckSize = nNewSize;\n\t\t}\n\t}\n\treturn UNQLITE_OK;\n}", "label": 0, "cwe": null, "length": 665 }, { "index": 628104, "code": "gfs_diffusion_cycle (GfsDomain * domain,\n\t\t\t guint levelmin,\n\t\t\t guint depth,\n\t\t\t guint nrelax,\n\t\t\t GfsVariable * u,\n\t\t\t GfsVariable * rhs,\n\t\t\t GfsVariable * rhoc,\n\t\t\t GfsVariable * axi,\n\t\t\t GfsVariable * res)\n{\n GfsVariable * dp;\n RelaxParams p;\n gpointer data[2];\n\n g_return_if_fail (domain != NULL);\n g_return_if_fail (u != NULL);\n g_return_if_fail (rhs != NULL);\n g_return_if_fail (rhoc != NULL);\n g_return_if_fail (res != NULL);\n\n dp = gfs_temporary_variable (domain);\n dp->component = u->component;\n\n /* compute residual on non-leafs cells */\n gfs_domain_cell_traverse (domain, \n\t\t\t FTT_POST_ORDER, FTT_TRAVERSE_NON_LEAFS, -1,\n\t\t\t (FttCellTraverseFunc) gfs_get_from_below_intensive, res);\n\n /* relax top level */\n p.maxlevel = levelmin;\n p.u = dp->i;\n p.res = res->i;\n p.dia = rhoc->i;\n p.component = GFS_IS_AXI (domain) ? u->component : FTT_DIMENSION;\n p.axi = axi ? axi->i : FALSE;\n\n gfs_domain_cell_traverse (domain, \n\t\t\t FTT_PRE_ORDER, FTT_TRAVERSE_LEVEL, levelmin,\n\t\t\t (FttCellTraverseFunc) gfs_cell_reset, dp);\n relax_loop (domain, dp, u, &p, 10*nrelax, (FttCellTraverseFunc) diffusion_relax);\n /* relax from top to bottom */\n for (p.maxlevel = levelmin + 1; p.maxlevel <= depth; p.maxlevel++) {\n /* get initial guess from coarser grid */ \n gfs_domain_cell_traverse (domain,\n\t\t\t FTT_PRE_ORDER, FTT_TRAVERSE_LEVEL | FTT_TRAVERSE_NON_LEAFS,\n\t\t\t p.maxlevel - 1,\n\t\t\t (FttCellTraverseFunc) get_from_above, dp);\n relax_loop (domain, dp, u, &p, nrelax, (FttCellTraverseFunc) diffusion_relax);\n }\n /* correct on leaf cells */\n data[0] = u;\n data[1] = dp;\n gfs_traverse_and_bc (domain, FTT_PRE_ORDER, FTT_TRAVERSE_LEAFS, -1,\n\t\t (FttCellTraverseFunc) correct, data,\n\t\t u, u);\n /* compute new residual on leaf cells */\n gfs_diffusion_residual (domain, u, rhs, rhoc, axi, res);\n\n gts_object_destroy (GTS_OBJECT (dp));\n}", "label": 0, "cwe": null, "length": 602 }, { "index": 803684, "code": "sphfwd (lng, lat, eul, phi, theta)\n\nconst double lat, lng, eul[5];\ndouble *phi, *theta;\n\n{\n double coslat, coslng, dlng, dphi, sinlat, sinlng, x, y, z;\n\n coslat = cosdeg (lat);\n sinlat = sindeg (lat);\n\n dlng = lng - eul[0];\n coslng = cosdeg (dlng);\n sinlng = sindeg (dlng);\n\n /* Compute the native longitude. */\n x = sinlat*eul[4] - coslat*eul[3]*coslng;\n if (fabs(x) < tol) {\n /* Rearrange formula to reduce roundoff errors. */\n x = -cosdeg (lat+eul[1]) + coslat*eul[3]*(1.0 - coslng);\n }\n y = -coslat*sinlng;\n if (x != 0.0 || y != 0.0) {\n dphi = atan2deg (y, x);\n } else {\n /* Change of origin of longitude. */\n dphi = dlng - 180.0;\n }\n *phi = eul[2] + dphi;\n\n /* Normalize the native longitude. */\n if (*phi > 180.0) {\n *phi -= 360.0;\n } else if (*phi < -180.0) {\n *phi += 360.0;\n }\n\n /* Compute the native latitude. */\n if (fmod(dlng,180.0) == 0.0) {\n *theta = lat + coslng*eul[1];\n if (*theta > 90.0) *theta = 180.0 - *theta;\n if (*theta < -90.0) *theta = -180.0 - *theta;\n } else {\n z = sinlat*eul[3] + coslat*eul[4]*coslng;\n /* Use an alternative formula for greater numerical accuracy. */\n if (fabs(z) > 0.99) {\n\tif (z < 0)\n *theta = -acosdeg (sqrt(x*x+y*y));\n\telse\n *theta = acosdeg (sqrt(x*x+y*y));\n } else {\n *theta = asindeg (z);\n }\n }\n\n return 0;\n}", "label": 0, "cwe": null, "length": 519 }, { "index": 373718, "code": "process_packet(\n u_char* const user,\n const struct pcap_pkthdr* const header,\n const u_char* const bytes) {\n if (sigprocmask(SIG_BLOCK, &block_set, NULL) < 0) {\n perror(\"sigprocmask\");\n exit(1);\n }\n\n#ifndef NDEBUG\n static int packets_received = 0;\n ++packets_received;\n if (packets_received % 1000 == 0) {\n struct pcap_stat statistics;\n pcap_stats(pcap_handle, &statistics);\n printf(\"-----\\n\");\n printf(\"STATISTICS (printed once for every thousand packets)\\n\");\n printf(\"Libpcap has dropped %d packets since process creation\\n\", statistics.ps_drop);\n printf(\"There are %d entries in the flow table\\n\", flow_table.num_elements);\n printf(\"The flow table has dropped %d flows\\n\", flow_table.num_dropped_flows);\n printf(\"The flow table has expired %d flows\\n\", flow_table.num_expired_flows);\n printf(\"-----\\n\");\n }\n if (packet_data.discarded_by_overflow % 1000 == 1) {\n printf(\"%d packets have overflowed the packet table!\\n\", packet_data.discarded_by_overflow);\n }\n#endif\n\n flow_table_entry_t flow_entry;\n flow_table_entry_init(&flow_entry);\n int mac_id = -1;\n u_char* dns_bytes = NULL;\n int dns_bytes_len = -1;\n#ifdef ENABLE_HTTP_URL \n u_char* http_bytes = NULL;\n int http_bytes_len = -1;\n#endif\n int ether_type = get_flow_entry_for_packet(\n bytes, header->caplen, header->len, &flow_entry, &mac_id, &dns_bytes, &dns_bytes_len \n#ifdef ENABLE_HTTP_URL \n,&http_bytes, &http_bytes_len\n#endif\n);\n uint16_t flow_id;\n switch (ether_type) {\n case ETHERTYPE_AARP:\n flow_id = FLOW_ID_AARP;\n break;\n case ETHERTYPE_ARP:\n flow_id = FLOW_ID_ARP;\n break;\n case ETHERTYPE_AT:\n flow_id = FLOW_ID_AT;\n break;\n case ETHERTYPE_IP:\n {\n flow_id = flow_table_process_flow(&flow_table,\n &flow_entry,\n header->ts.tv_sec);\n#ifndef NDEBUG\n if (flow_id == FLOW_ID_ERROR) {\n fprintf(stderr, \"Error adding to flow table\\n\");\n }\n#endif\n }\n break;\n case ETHERTYPE_IPV6:\n flow_id = FLOW_ID_IPV6;\n break;\n case ETHERTYPE_IPX:\n flow_id = FLOW_ID_IPX;\n break;\n case ETHERTYPE_REVARP:\n flow_id = FLOW_ID_REVARP;\n break;\n default:\n flow_id = FLOW_ID_ERROR;\n break;\n }\n \n int packet_id = packet_series_add_packet(\n &packet_data, &header->ts, header->len, flow_id);\n if (packet_id < 0) {\n fprintf(stderr, \"Error adding to packet series\\n\");\n drop_statistics_process_packet(&drop_statistics, header->len);\n }\n\n if (dns_bytes_len > 0 && mac_id >= 0) {\n process_dns_packet(dns_bytes, dns_bytes_len, &dns_table, packet_id, mac_id);\n }\n#ifdef ENABLE_HTTP_URL \n if (http_bytes_len > 0) {\n process_http_packet(http_bytes, http_bytes_len, & http_table, flow_id);\n }\n#endif\n if (sigprocmask(SIG_UNBLOCK, &block_set, NULL) < 0) {\n perror(\"sigprocmask\");\n exit(1);\n }\n}", "label": 0, "cwe": null, "length": 803 }, { "index": 915618, "code": "cheese_camera_device_get_caps (CheeseCameraDevice *device)\n{\n CheeseCameraDevicePrivate *priv = device->priv;\n\n gchar *pipeline_desc;\n GstElement *pipeline;\n GstStateChangeReturn ret;\n GstMessage *msg;\n GstBus *bus;\n GError *err = NULL;\n\n pipeline_desc = g_strdup_printf (\"%s name=source device=%s ! fakesink\",\n priv->src, priv->device_node);\n pipeline = gst_parse_launch (pipeline_desc, &err);\n if ((pipeline != NULL) && (err == NULL))\n {\n /* Start the pipeline and wait for max. 10 seconds for it to start up */\n gst_element_set_state (pipeline, GST_STATE_READY);\n ret = gst_element_get_state (pipeline, NULL, NULL, 10 * GST_SECOND);\n\n /* Check if any error messages were posted on the bus */\n bus = gst_element_get_bus (pipeline);\n msg = gst_bus_pop_filtered (bus, GST_MESSAGE_ERROR);\n gst_object_unref (bus);\n\n if ((msg == NULL) && (ret == GST_STATE_CHANGE_SUCCESS))\n {\n GstElement *src;\n GstPad *pad;\n GstCaps *caps;\n\n src = gst_bin_get_by_name (GST_BIN (pipeline), \"source\");\n\n GST_LOG (\"Device: %s (%s)\\n\", priv->name, priv->device_node);\n pad = gst_element_get_static_pad (src, \"src\");\n caps = gst_pad_get_allowed_caps (pad);\n\n gst_caps_unref (priv->caps);\n priv->caps = cheese_camera_device_filter_caps (device, caps, supported_formats);\n\n if (!gst_caps_is_empty (priv->caps))\n cheese_camera_device_update_format_table (device);\n else\n {\n g_set_error_literal (&priv->construct_error,\n CHEESE_CAMERA_DEVICE_ERROR,\n CHEESE_CAMERA_DEVICE_ERROR_UNSUPPORTED_CAPS,\n _(\"Device capabilities not supported\"));\n }\n\n gst_object_unref (pad);\n gst_caps_unref (caps);\n gst_object_unref (src);\n }\n else\n {\n if (msg)\n {\n gchar *dbg_info = NULL;\n gst_message_parse_error (msg, &err, &dbg_info);\n GST_WARNING (\"Failed to start the capability probing pipeline\");\n GST_WARNING (\"Error from element %s: %s, %s\",\n GST_OBJECT_NAME (msg->src),\n err->message,\n (dbg_info) ? dbg_info : \"no extra debug detail\");\n g_error_free (err);\n err = NULL;\n\n /* construct_error is meant to be displayed in the UI\n * (although it currently isn't displayed in cheese),\n * err->message from gstreamer is too technical for this\n * purpose, the idea is warn the user about an error and point\n * him to the logs for more info */\n g_set_error (&priv->construct_error,\n CHEESE_CAMERA_DEVICE_ERROR,\n CHEESE_CAMERA_DEVICE_ERROR_FAILED_INITIALIZATION,\n _(\"Failed to initialize device %s for capability probing\"),\n priv->device_node);\n }\n }\n gst_element_set_state (pipeline, GST_STATE_NULL);\n gst_object_unref (pipeline);\n }\n\n if (err)\n g_error_free (err);\n\n g_free (pipeline_desc);\n}", "label": 0, "cwe": null, "length": 707 }, { "index": 81525, "code": "ews_modify_contact_cb (GObject *object,\n GAsyncResult *res,\n gpointer user_data)\n{\n\tEEwsConnection *cnc = E_EWS_CONNECTION (object);\n\tEwsModifyContact *modify_contact = user_data;\n\tEBookBackendEws *ebews = modify_contact->ebews;\n\tEBookBackendEwsPrivate *priv = ebews->priv;\n\tGError *error = NULL;\n\tGSList *items = NULL;\n\tgchar *id;\n\tconst EwsId *item_id;\n\n\tg_object_ref (modify_contact->new_contact);\n\tg_object_ref (modify_contact->old_contact);\n\n\te_ews_connection_update_items_finish (cnc, res, &items, &error);\n\n\tg_return_if_fail (priv->summary != NULL);\n\n\tif (error == NULL) {\n\t\tif (items != NULL) {\n\t\t\tEEwsItem *item = (EEwsItem *) items->data;\n\n\t\t\t/* set item id */\n\t\t\titem_id = e_ews_item_get_id (item);\n\n\t\t\te_contact_set (modify_contact->new_contact, E_CONTACT_UID, item_id->id);\n\t\t\te_contact_set (modify_contact->new_contact, E_CONTACT_REV, item_id->change_key);\n\n\t\t\tg_object_unref (item);\n\t\t}\n\n\t\tid = e_contact_get (modify_contact->old_contact, E_CONTACT_UID);\n\n\t\te_book_backend_sqlitedb_remove_contact (priv->summary, priv->folder_id, id, &error);\n\t\te_book_backend_sqlitedb_new_contact (\n\t\t\t\tebews->priv->summary,\n\t\t\t\tebews->priv->folder_id,\n\t\t\t\tmodify_contact->new_contact,\n\t\t\t\tTRUE,\n\t\t\t\t&error);\n\n\t\tif (error == NULL) {\n\t\t\tGSList *new_contacts;\n\n\t\t\tnew_contacts = g_slist_append (NULL, modify_contact->new_contact);\n\t\t\te_data_book_respond_modify_contacts (modify_contact->book, modify_contact->opid, EDB_ERROR (SUCCESS), new_contacts);\n\t\t\tg_slist_free (new_contacts);\n\t\t}\n\n\t\tg_slist_free (items);\n\t}\n\n\tif (error) {\n\t\tg_warning (\"Error while Modifying contact: %s\", error->message);\n\n\t\te_data_book_respond_modify_contacts (modify_contact->book, modify_contact->opid, EDB_ERROR_EX (OTHER_ERROR, error->message), NULL);\n\t}\n\n\t/* free memory allocated for create_contact & unref contained objects */\n\tg_object_unref (modify_contact->ebews);\n\tg_object_unref (modify_contact->new_contact);\n\tg_object_unref (modify_contact->old_contact);\n\tg_object_unref (modify_contact->cancellable);\n\tg_free (modify_contact);\n\tg_clear_error (&error);\n}", "label": 0, "cwe": null, "length": 555 }, { "index": 215201, "code": "install_link(ENCAP *encap, encap_source_info_t *srcinfo,\n\t encap_target_info_t *tgtinfo)\n{\n\tint type = EPT_INST_OK;\n\tchar *msg = NULL;\n\n#ifdef DEBUG\n\tprintf(\"==> install_link(encap=\\\"%s\\\", srcinfo=\\\"%s\\\")\\n\",\n\t encap->e_pkgname, srcinfo->src_pkgdir_relative);\n#endif\n\n\t/* conflict resolution */\n\tif (BIT_ISSET(tgtinfo->tgt_flags, TGT_EXISTS))\n\t{\n\t\t/*\n\t\t * if the desired link already exists, return without\n\t\t * doing anything\n\t\t */\n\t\tif (BIT_ISSET(tgtinfo->tgt_flags, TGT_DEST_ENCAP_SRC) &&\n\t\t BIT_ISSET(tgtinfo->tgt_flags, TGT_DEST_PKGDIR_EXISTS) &&\n\t\t strcmp(tgtinfo->tgt_link_existing_pkg,\n\t\t\t encap->e_pkgname) == 0 &&\n\t\t strcmp(tgtinfo->tgt_link_existing_pkgdir_relative,\n\t\t\t srcinfo->src_link_expecting +\n\t\t\t strlen(srcinfo->src_link_expecting) -\n\t\t\t strlen(tgtinfo->tgt_link_existing_pkgdir_relative))\n\t\t\t\t\t\t\t\t\t== 0)\n\t\t{\n\t\t\t(*encap->e_print_func)(encap, srcinfo, tgtinfo,\n\t\t\t\t\t EPT_INST_NOOP, NULL);\n\t\t\treturn R_SKIP;\n\t\t}\n\n\t\t/*\n\t\t * unless we're in force mode, detect non-resolvable\n\t\t * conflicts and fail\n\t\t */\n\t\tif (!BIT_ISSET(encap->e_options, OPT_FORCE))\n\t\t{\n\t\t\t/* make sure it's a symlink */\n\t\t\tif (!BIT_ISSET(tgtinfo->tgt_flags, TGT_ISLNK))\n\t\t\t{\n\t\t\t\t(*encap->e_print_func)(encap, srcinfo,\n\t\t\t\t\t\t tgtinfo,\n\t\t\t\t\t\t EPT_INST_FAIL,\n\t\t\t\t\t\t \"not a symlink\");\n\t\t\t\treturn R_ERR;\n\t\t\t}\n\n\t\t\t/* make sure it's an encap link */\n\t\t\tif (!BIT_ISSET(tgtinfo->tgt_flags, TGT_DEST_ENCAP_SRC))\n\t\t\t{\n\t\t\t\t(*encap->e_print_func)(encap, srcinfo,\n\t\t\t\t\t\t tgtinfo,\n\t\t\t\t\t\t EPT_INST_FAIL,\n\t\t\t\t\t\t \"not an Encap link\");\n\t\t\t\treturn R_ERR;\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * if the existing link points to an existing file\n\t\t\t * in an existing package other than the one we're\n\t\t\t * installing, it's a conflict\n\t\t\t */\n\t\t\tif (BIT_ISSET(tgtinfo->tgt_flags, TGT_DEST_EXISTS) &&\n\t\t\t BIT_ISSET(tgtinfo->tgt_flags,\n\t\t\t\t TGT_DEST_PKGDIR_EXISTS) &&\n\t\t\t strcmp(tgtinfo->tgt_link_existing_pkg,\n\t\t\t\t encap->e_pkgname) != 0)\n\t\t\t{\n\t\t\t\t(*encap->e_print_func)(encap, srcinfo,\n\t\t\t\t\t\ttgtinfo, EPT_INST_FAIL,\n\t\t\t\t\t\t\"conflicting link to \"\n\t\t\t\t\t\t \"package %s\",\n\t\t\t\t\t\ttgtinfo->tgt_link_existing_pkg);\n\t\t\t\treturn R_ERR;\n\t\t\t}\n\n\t\t}\n\t\telse\n\t\t\tmsg = \"forced replacement\";\n\n\t\tif (!BIT_ISSET(encap->e_options, OPT_SHOWONLY) &&\n\t\t remove(srcinfo->src_target_path) != 0)\n\t\t{\n\t\t\t(*encap->e_print_func)(encap, srcinfo, tgtinfo,\n\t\t\t\t\t EPT_INST_ERROR, \"remove\");\n\t\t\treturn R_ERR;\n\t\t}\n\n\t\ttype = EPT_INST_REPL;\n\t}\n\n\tif (!BIT_ISSET(encap->e_options, OPT_SHOWONLY) &&\n\t symlink(srcinfo->src_link_expecting, srcinfo->src_target_path) != 0)\n\t{\n\t\t(*encap->e_print_func)(encap, srcinfo, tgtinfo,\n\t\t\t\t EPT_INST_ERROR, \"symlink\");\n\t\treturn R_ERR;\n\t}\n\telse\n\t\t(*encap->e_print_func)(encap, srcinfo, tgtinfo, type, msg);\n\n\treturn R_FILEOK;\n}", "label": 0, "cwe": null, "length": 841 }, { "index": 25322, "code": "ilIsValidL(ILenum Type, void *Lump, ILuint Size)\n{\n\tif (Lump == NULL) {\n\t\tilSetError(IL_INVALID_PARAM);\n\t\treturn IL_FALSE;\n\t}\n\n\tswitch (Type)\n\t{\n\t\t#ifndef IL_NO_TGA\n\t\tcase IL_TGA:\n\t\t\treturn ilIsValidTgaL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_JPG\n\t\tcase IL_JPG:\n\t\t\treturn ilIsValidJpegL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_DDS\n\t\tcase IL_DDS:\n\t\t\treturn ilIsValidDdsL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_PNG\n\t\tcase IL_PNG:\n\t\t\treturn ilIsValidPngL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_BMP\n\t\tcase IL_BMP:\n\t\t\treturn ilIsValidBmpL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_DICOM\n\t\tcase IL_DICOM:\n\t\t\treturn ilIsValidDicomL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_EXR\n\t\tcase IL_EXR:\n\t\t\treturn ilIsValidExrL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_GIF\n\t\tcase IL_GIF:\n\t\t\treturn ilIsValidGifL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_HDR\n\t\tcase IL_HDR:\n\t\t\treturn ilIsValidHdrL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_ICNS\n\t\tcase IL_ICNS:\n\t\t\treturn ilIsValidIcnsL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_IWI\n\t\tcase IL_IWI:\n\t\t\treturn ilIsValidIwiL(Lump, Size);\n\t\t#endif\n\n \t#ifndef IL_NO_ILBM\n case IL_ILBM:\n return ilIsValidIlbmL(Lump, Size);\n\t #endif\n\n\t\t#ifndef IL_NO_JP2\n\t\tcase IL_JP2:\n\t\t\treturn ilIsValidJp2L(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_LIF\n\t\tcase IL_LIF:\n\t\t\treturn ilIsValidLifL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_MDL\n\t\tcase IL_MDL:\n\t\t\treturn ilIsValidMdlL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_MP3\n\t\tcase IL_MP3:\n\t\t\treturn ilIsValidMp3L(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_PCX\n\t\tcase IL_PCX:\n\t\t\treturn ilIsValidPcxL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_PIC\n\t\tcase IL_PIC:\n\t\t\treturn ilIsValidPicL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_PNM\n\t\tcase IL_PNM:\n\t\t\treturn ilIsValidPnmL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_PSD\n\t\tcase IL_PSD:\n\t\t\treturn ilIsValidPsdL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_PSP\n\t\tcase IL_PSP:\n\t\t\treturn ilIsValidPspL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_SGI\n\t\tcase IL_SGI:\n\t\t\treturn ilIsValidSgiL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_SUN\n\t\tcase IL_SUN:\n\t\t\treturn ilIsValidSunL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_TIF\n\t\tcase IL_TIF:\n\t\t\treturn ilIsValidTiffL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_TPL\n\t\tcase IL_TPL:\n\t\t\treturn ilIsValidTplL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_VTF\n\t\tcase IL_VTF:\n\t\t\treturn ilIsValidVtfL(Lump, Size);\n\t\t#endif\n\n\t\t#ifndef IL_NO_XPM\n\t\tcase IL_XPM:\n\t\t\treturn ilIsValidXpmL(Lump, Size);\n\t\t#endif\n\t}\n\n\tilSetError(IL_INVALID_ENUM);\n\treturn IL_FALSE;\n}", "label": 0, "cwe": null, "length": 871 }, { "index": 260741, "code": "ipmi_oem_inventec_set_authentication_config (ipmi_oem_state_data_t *state_data)\n{\n uint8_t maxauthenticationfailures = 0;\n uint16_t lockoutwindow = 0;\n uint16_t lockouttime = 0;\n int rv = -1;\n unsigned int i;\n\n assert (state_data);\n\n if (!state_data->prog_data->args->oem_options_count)\n {\n pstdout_printf (state_data->pstate,\n\t\t \"Option: maxauthenticationfailures=count\\n\"\n\t\t \"Option: lockoutwindow=seconds\\n\"\n\t\t \"Option: lockouttime=seconds\\n\");\n return (0); \n }\n\n for (i = 0; i < state_data->prog_data->args->oem_options_count; i++)\n {\n char *key = NULL;\n char *value = NULL;\n \n if (ipmi_oem_parse_key_value (state_data,\n i,\n &key,\n &value) < 0)\n goto cleanup;\n\n if (!strcasecmp (key, \"maxauthenticationfailures\"))\n {\n if (ipmi_oem_parse_1_byte_field (state_data, i, value, &maxauthenticationfailures) < 0)\n goto cleanup;\n\n if (_ipmi_oem_inventec_set_extended_config_value (state_data,\n IPMI_OEM_INVENTEC_EXTENDED_CONFIGURATION_ID_SECURITY,\n IPMI_OEM_INVENTEC_EXTENDED_ATTRIBUTE_ID_SECURITY_MAX_AUTHENTICATION_FAILURES,\n 0,\n 1,\n (uint32_t)maxauthenticationfailures) < 0)\n goto cleanup;\n }\n else if (!strcasecmp (key, \"lockoutwindow\"))\n {\n if (ipmi_oem_parse_2_byte_field (state_data, i, value, &lockoutwindow) < 0)\n goto cleanup;\n \n if (_ipmi_oem_inventec_set_extended_config_value (state_data,\n IPMI_OEM_INVENTEC_EXTENDED_CONFIGURATION_ID_SECURITY,\n IPMI_OEM_INVENTEC_EXTENDED_ATTRIBUTE_ID_SECURITY_LOCKOUT_WINDOW,\n 0,\n 2,\n (uint32_t)lockoutwindow) < 0)\n goto cleanup;\n }\n else if (!strcasecmp (key, \"lockouttime\"))\n {\n if (ipmi_oem_parse_2_byte_field (state_data, i, value, &lockouttime) < 0)\n goto cleanup;\n \n if (_ipmi_oem_inventec_set_extended_config_value (state_data,\n IPMI_OEM_INVENTEC_EXTENDED_CONFIGURATION_ID_SECURITY,\n IPMI_OEM_INVENTEC_EXTENDED_ATTRIBUTE_ID_SECURITY_LOCKOUT_TIME,\n 0,\n 2,\n (uint32_t)lockouttime) < 0)\n goto cleanup;\n }\n else\n {\n pstdout_fprintf (state_data->pstate,\n stderr,\n \"%s:%s invalid OEM option argument '%s' : invalid key\\n\",\n state_data->prog_data->args->oem_id,\n state_data->prog_data->args->oem_command,\n state_data->prog_data->args->oem_options[i]);\n goto cleanup;\n }\n\n free (key);\n free (value);\n }\n\n rv = 0;\n cleanup:\n return (rv);\n}", "label": 0, "cwe": null, "length": 705 }, { "index": 482213, "code": "server_getspec (rpcsvc_request_t *req)\n{\n int32_t ret = -1;\n int32_t op_errno = ENOENT;\n int32_t spec_fd = -1;\n size_t file_len = 0;\n char filename[PATH_MAX] = {0,};\n struct stat stbuf = {0,};\n uint32_t checksum = 0;\n char *key = NULL;\n server_conf_t *conf = NULL;\n xlator_t *this = NULL;\n gf_getspec_req args = {0,};\n gf_getspec_rsp rsp = {0,};\n\n this = req->svc->mydata;\n conf = this->private;\n ret = xdr_to_generic (req->msg[0], &args,\n (xdrproc_t)xdr_gf_getspec_req);\n if (ret < 0) {\n //failed to decode msg;\n req->rpc_err = GARBAGE_ARGS;\n op_errno = EINVAL;\n goto fail;\n }\n\n ret = getspec_build_volfile_path (this, args.key,\n filename, sizeof (filename));\n if (ret > 0) {\n /* to allocate the proper buffer to hold the file data */\n ret = stat (filename, &stbuf);\n if (ret < 0){\n gf_log (this->name, GF_LOG_ERROR,\n \"Unable to stat %s (%s)\",\n filename, strerror (errno));\n op_errno = errno;\n goto fail;\n }\n\n spec_fd = open (filename, O_RDONLY);\n if (spec_fd < 0) {\n gf_log (this->name, GF_LOG_ERROR,\n \"Unable to open %s (%s)\",\n filename, strerror (errno));\n op_errno = errno;\n goto fail;\n }\n ret = file_len = stbuf.st_size;\n\n if (conf->verify_volfile) {\n get_checksum_for_file (spec_fd, &checksum);\n _volfile_update_checksum (this, key, checksum);\n }\n } else {\n op_errno = ENOENT;\n }\n\n if (file_len) {\n rsp.spec = GF_CALLOC (file_len, sizeof (char),\n gf_server_mt_rsp_buf_t);\n if (!rsp.spec) {\n ret = -1;\n op_errno = ENOMEM;\n goto fail;\n }\n ret = read (spec_fd, rsp.spec, file_len);\n }\n\n /* convert to XDR */\n op_errno = errno;\nfail:\n if (!rsp.spec)\n rsp.spec = \"\";\n rsp.op_errno = gf_errno_to_error (op_errno);\n rsp.op_ret = ret;\n\n if (spec_fd != -1)\n close (spec_fd);\n\n server_submit_reply (NULL, req, &rsp, NULL, 0, NULL,\n (xdrproc_t)xdr_gf_getspec_rsp);\n\n return 0;\n}", "label": 0, "cwe": null, "length": 642 }, { "index": 532923, "code": "DiffVectorVector (\n Obj vecL,\n Obj vecR )\n{\n Obj vecD; /* handle of the sum */\n Obj * ptrD; /* pointer into the sum */\n Obj elmD; /* one element of sum list */\n Obj * ptrL; /* pointer into the left operand */\n Obj elmL; /* one element of left operand */\n Obj * ptrR; /* pointer into the right operand */\n Obj elmR; /* one element of right operand */\n UInt lenL, lenR, len, lenmin; /* lengths */\n UInt i; /* loop variable */\n\n /* make the result list */\n lenL = LEN_PLIST( vecL );\n lenR = LEN_PLIST( vecR );\n if (lenL < lenR) {\n lenmin = lenL;\n len = lenR;\n } else {\n lenmin = lenR;\n len = lenL;\n }\n vecD = NEW_PLIST( (IS_IMM_PLIST(vecL) && IS_IMM_PLIST(vecR)) ?\n T_PLIST_CYC+IMMUTABLE : T_PLIST_CYC, len );\n SET_LEN_PLIST( vecD, len );\n\n /* loop over the elements and subtract */\n ptrL = ADDR_OBJ( vecL );\n ptrR = ADDR_OBJ( vecR );\n ptrD = ADDR_OBJ( vecD );\n for ( i = 1; i <= lenmin; i++ ) {\n elmL = ptrL[i];\n elmR = ptrR[i];\n if ( ! ARE_INTOBJS(elmL,elmR) || ! DIFF_INTOBJS(elmD,elmL,elmR) ) {\n CHANGED_BAG( vecD );\n elmD = DIFF( elmL, elmR );\n ptrL = ADDR_OBJ( vecL );\n ptrR = ADDR_OBJ( vecR );\n ptrD = ADDR_OBJ( vecD );\n }\n ptrD[i] = elmD;\n }\n if (lenL < lenR)\n for (;i <= lenR; i++) {\n elmR = ptrR[i];\n if ( ! IS_INTOBJ(elmR) || ! DIFF_INTOBJS(elmD,INTOBJ_INT(0),elmR) ) {\n CHANGED_BAG( vecD );\n elmD = AINV( elmR );\n ptrR = ADDR_OBJ( vecR );\n ptrD = ADDR_OBJ( vecD );\n }\n ptrD[i] = elmD;\n }\n else\n for (;i <= lenL; i++) {\n ptrD[i] = ptrL[i];\n }\n /* return the result */\n CHANGED_BAG( vecD );\n return vecD;\n}", "label": 0, "cwe": null, "length": 611 }, { "index": 435297, "code": "_uuconf_iread_locations (qglobal)\n struct sglobal *qglobal;\n{\n char *zline;\n size_t cline;\n struct sinfo si;\n int iret;\n char **pz;\n\n if (qglobal->qprocess->fread_syslocs)\n return UUCONF_SUCCESS;\n\n zline = NULL;\n cline = 0;\n\n si.qlocs = NULL;\n si.qvals = NULL;\n\n iret = UUCONF_SUCCESS;\n\n for (pz = qglobal->qprocess->pzsysfiles; *pz != NULL; pz++)\n {\n FILE *e;\n int cchars;\n\n qglobal->ilineno = 0;\n\n e = fopen (*pz, \"r\");\n if (e == NULL)\n\t{\n\t if (FNO_SUCH_FILE ())\n\t continue;\n\t qglobal->ierrno = errno;\n\t iret = UUCONF_FOPEN_FAILED | UUCONF_ERROR_ERRNO;\n\t break;\n\t}\n\n#ifdef CLOSE_ON_EXEC\n CLOSE_ON_EXEC (e);\n#endif\n\n si.zname = *pz;\n si.e = e;\n\n while ((cchars = _uuconf_getline (qglobal, &zline, &cline, e)) > 0)\n\t{\n\t char *zcmd;\n\n\t ++qglobal->ilineno;\n\n\t zcmd = zline + strspn (zline, \" \\t\");\n\t if (strncasecmp (zcmd, \"system\", sizeof \"system\" - 1) == 0\n\t || strncasecmp (zcmd, \"alias\", sizeof \"alias\" - 1) == 0\n\t || strncasecmp (zcmd, \"called-login\",\n\t\t\t sizeof \"called-login\" - 1) == 0\n\t || strncasecmp (zcmd, \"myname\", sizeof \"myname\" - 1) == 0)\n\t {\n\t iret = uuconf_cmd_line ((pointer) qglobal, zline, asTcmds,\n\t\t\t\t (pointer) &si, (uuconf_cmdtabfn) NULL,\n\t\t\t\t 0, qglobal->pblock);\n\t if ((iret & UUCONF_CMDTABRET_KEEP) != 0)\n\t\t{\n\t\t iret &=~ UUCONF_CMDTABRET_KEEP;\n\t\t zline = NULL;\n\t\t cline = 0;\n\t\t}\n\t if (iret != UUCONF_SUCCESS)\n\t\t{\n\t\t iret &=~ UUCONF_CMDTABRET_EXIT;\n\t\t break;\n\t\t}\n\t }\n\t}\n\n if (iret != UUCONF_SUCCESS)\n\tbreak;\n }\n\n if (zline != NULL)\n free ((pointer) zline);\n\n if (iret != UUCONF_SUCCESS)\n {\n qglobal->zfilename = *pz;\n iret |= UUCONF_ERROR_FILENAME | UUCONF_ERROR_LINENO;\n if (UUCONF_ERROR_VALUE (iret) != UUCONF_MALLOC_FAILED)\n\tqglobal->qprocess->fread_syslocs = TRUE;\n }\n else\n {\n qglobal->qprocess->qsyslocs = si.qlocs;\n qglobal->qprocess->qvalidate = si.qvals;\n qglobal->qprocess->fread_syslocs = TRUE;\n }\t\n\n return iret;\n}", "label": 1, "cwe": [ "CWE-469", "CWE-other" ], "length": 722 }, { "index": 392710, "code": "piix4_setup_sb800(struct pci_dev *PIIX4_dev,\n\t\t\t const struct pci_device_id *id, u8 aux)\n{\n\tunsigned short piix4_smba;\n\tunsigned short smba_idx = 0xcd6;\n\tu8 smba_en_lo, smba_en_hi, smb_en, smb_en_status;\n\tu8 i2ccfg, i2ccfg_offset = 0x10;\n\n\t/* SB800 and later SMBus does not support forcing address */\n\tif (force || force_addr) {\n\t\tdev_err(&PIIX4_dev->dev, \"SMBus does not support \"\n\t\t\t\"forcing address!\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\t/* Determine the address of the SMBus areas */\n\tif ((PIIX4_dev->vendor == PCI_VENDOR_ID_AMD &&\n\t PIIX4_dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS &&\n\t PIIX4_dev->revision >= 0x41) ||\n\t (PIIX4_dev->vendor == PCI_VENDOR_ID_AMD &&\n\t PIIX4_dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS &&\n\t PIIX4_dev->revision >= 0x49))\n\t\tsmb_en = 0x00;\n\telse\n\t\tsmb_en = (aux) ? 0x28 : 0x2c;\n\n\tif (!request_region(smba_idx, 2, \"smba_idx\")) {\n\t\tdev_err(&PIIX4_dev->dev, \"SMBus base address index region \"\n\t\t\t\"0x%x already in use!\\n\", smba_idx);\n\t\treturn -EBUSY;\n\t}\n\toutb_p(smb_en, smba_idx);\n\tsmba_en_lo = inb_p(smba_idx + 1);\n\toutb_p(smb_en + 1, smba_idx);\n\tsmba_en_hi = inb_p(smba_idx + 1);\n\trelease_region(smba_idx, 2);\n\n\tif (!smb_en) {\n\t\tsmb_en_status = smba_en_lo & 0x10;\n\t\tpiix4_smba = smba_en_hi << 8;\n\t\tif (aux)\n\t\t\tpiix4_smba |= 0x20;\n\t} else {\n\t\tsmb_en_status = smba_en_lo & 0x01;\n\t\tpiix4_smba = ((smba_en_hi << 8) | smba_en_lo) & 0xffe0;\n\t}\n\n\tif (!smb_en_status) {\n\t\tdev_err(&PIIX4_dev->dev,\n\t\t\t\"SMBus Host Controller not enabled!\\n\");\n\t\treturn -ENODEV;\n\t}\n\n\tif (acpi_check_region(piix4_smba, SMBIOSIZE, piix4_driver.name))\n\t\treturn -ENODEV;\n\n\tif (!request_region(piix4_smba, SMBIOSIZE, piix4_driver.name)) {\n\t\tdev_err(&PIIX4_dev->dev, \"SMBus region 0x%x already in use!\\n\",\n\t\t\tpiix4_smba);\n\t\treturn -EBUSY;\n\t}\n\n\t/* Aux SMBus does not support IRQ information */\n\tif (aux) {\n\t\tdev_info(&PIIX4_dev->dev,\n\t\t\t \"Auxiliary SMBus Host Controller at 0x%x\\n\",\n\t\t\t piix4_smba);\n\t\treturn piix4_smba;\n\t}\n\n\t/* Request the SMBus I2C bus config region */\n\tif (!request_region(piix4_smba + i2ccfg_offset, 1, \"i2ccfg\")) {\n\t\tdev_err(&PIIX4_dev->dev, \"SMBus I2C bus config region \"\n\t\t\t\"0x%x already in use!\\n\", piix4_smba + i2ccfg_offset);\n\t\trelease_region(piix4_smba, SMBIOSIZE);\n\t\treturn -EBUSY;\n\t}\n\ti2ccfg = inb_p(piix4_smba + i2ccfg_offset);\n\trelease_region(piix4_smba + i2ccfg_offset, 1);\n\n\tif (i2ccfg & 1)\n\t\tdev_dbg(&PIIX4_dev->dev, \"Using IRQ for SMBus\\n\");\n\telse\n\t\tdev_dbg(&PIIX4_dev->dev, \"Using SMI# for SMBus\\n\");\n\n\tdev_info(&PIIX4_dev->dev,\n\t\t \"SMBus Host Controller at 0x%x, revision %d\\n\",\n\t\t piix4_smba, i2ccfg >> 4);\n\n\treturn piix4_smba;\n}", "label": 0, "cwe": null, "length": 979 }, { "index": 391322, "code": "_flFTGetOutline(FLfontStruct *_fs, GLuint c)\n{\n FLFreeTypeFontStruct *fs = (FLFreeTypeFontStruct *) _fs;\n FLFreeTypeOutline *outline;\n int start, end, num, code, i;\n\n TRACE((\"_flFTGetOutline: '%c'(0x%04x)\\n\", c, c));\n\n // Search for the code point c in the 8 bit range\n if (c < 256) {\n outline = fs->char8[c];\n if (! outline)\n fs->char8[c] = outline = _flFTLoadChar(fs, c);\n return (FLoutline *) outline;\n }\n\n // Search for the code point c in the 16 bit range\n start = 0;\n end = fs->num16 - 1;\n\n for (i = end >> 1; start < end; i = (start + end) >> 1) {\n code = fs->index16[i];\n if (c < code)\n end = i - 1;\n else if (c > code)\n start = i + 1;\n else\n return (FLoutline *) fs->char16[i];\n }\n\n // Cannot find code point c, load the glyph char\n outline = _flFTLoadChar(fs, c);\n if (outline) {\n FLchar *newIndex16;\n FLFreeTypeOutline **newChar16;\n\n fs->num16++;\n newIndex16 = (FLchar *) malloc(fs->num16 * sizeof(FLchar));\n newChar16 = (FLFreeTypeOutline **) malloc(fs->num16 * sizeof(FLFreeTypeOutline *));\n\n if (fs->index16) {\n if (start > 0) {\n\tmemcpy(newIndex16, fs->index16, sizeof(FLchar) * start);\n\tmemcpy(newChar16, fs->char16, sizeof(FLFreeTypeOutline *) * start);\n }\n\n if ((num = fs->num16 - start - 1) > 0) {\n\tmemcpy(newIndex16 + start + 1, fs->index16 + start, sizeof(FLchar) * num);\n\tmemcpy(newChar16 + start + 1, fs->char16 + start, sizeof(FLFreeTypeOutline *) * num);\n }\n\n free(fs->index16);\n free(fs->char16);\n }\n\n fs->index16 = newIndex16;\n fs->char16 = newChar16;\n\n fs->index16[start] = c;\n fs->char16[start] = outline;\n }\n \n return (FLoutline *) outline;\n}", "label": 1, "cwe": "CWE-120", "length": 564 }, { "index": 13997, "code": "filterCompressedObjects(std::map const& object_stream_data)\n{\n if (object_stream_data.empty())\n {\n\treturn;\n }\n\n // Transform object_to_obj_users and obj_user_to_objects so that\n // they refer only to uncompressed objects. If something is a\n // user of a compressed object, then it is really a user of the\n // object stream that contains it.\n\n std::map > t_obj_user_to_objects;\n std::map > t_object_to_obj_users;\n\n for (std::map >::iterator i1 =\n\t this->obj_user_to_objects.begin();\n\t i1 != this->obj_user_to_objects.end(); ++i1)\n {\n\tObjUser const& ou = (*i1).first;\n\tstd::set const& objects = (*i1).second;\n\tfor (std::set::const_iterator i2 = objects.begin();\n\t i2 != objects.end(); ++i2)\n\t{\n\t QPDFObjGen const& og = (*i2);\n\t std::map::const_iterator i3 =\n\t\tobject_stream_data.find(og.getObj());\n\t if (i3 == object_stream_data.end())\n\t {\n\t\tt_obj_user_to_objects[ou].insert(og);\n\t }\n\t else\n\t {\n\t\tt_obj_user_to_objects[ou].insert(QPDFObjGen((*i3).second, 0));\n\t }\n\t}\n }\n\n for (std::map >::iterator i1 =\n\t this->object_to_obj_users.begin();\n\t i1 != this->object_to_obj_users.end(); ++i1)\n {\n\tQPDFObjGen const& og = (*i1).first;\n\tstd::set const& objusers = (*i1).second;\n\tfor (std::set::const_iterator i2 = objusers.begin();\n\t i2 != objusers.end(); ++i2)\n\t{\n\t ObjUser const& ou = (*i2);\n\t std::map::const_iterator i3 =\n\t\tobject_stream_data.find(og.getObj());\n\t if (i3 == object_stream_data.end())\n\t {\n\t\tt_object_to_obj_users[og].insert(ou);\n\t }\n\t else\n\t {\n\t\tt_object_to_obj_users[QPDFObjGen((*i3).second, 0)].insert(ou);\n\t }\n\t}\n }\n\n this->obj_user_to_objects = t_obj_user_to_objects;\n this->object_to_obj_users = t_object_to_obj_users;\n}", "label": 0, "cwe": null, "length": 594 }, { "index": 300773, "code": "__lambda72_ (BoxesProperties* self, GtkTreeView* treeview, GtkTreePath* path, GtkTreeViewColumn* column) {\n\tGtkTreeIter filter_iter = {0};\n\tGtkTreeIter iter = {0};\n\tGtkTreeModelFilter* _tmp0_ = NULL;\n\tGtkTreePath* _tmp1_ = NULL;\n\tGtkTreeIter _tmp2_ = {0};\n\tGtkTreeModelFilter* _tmp3_ = NULL;\n\tGtkTreeIter _tmp4_ = {0};\n\tGtkTreeIter _tmp5_ = {0};\n\tGtkNotebook* _tmp6_ = NULL;\n\tGtkListStore* _tmp7_ = NULL;\n\tGtkTreeIter _tmp8_ = {0};\n\tGtkTreePath* _tmp9_ = NULL;\n\tGtkTreePath* _tmp10_ = NULL;\n\tgint _tmp11_ = 0;\n\tgint* _tmp12_ = NULL;\n\tgint _tmp13_ = 0;\n#line 239 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\tg_return_if_fail (treeview != NULL);\n#line 239 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\tg_return_if_fail (path != NULL);\n#line 239 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\tg_return_if_fail (column != NULL);\n#line 241 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\t_tmp0_ = self->priv->model_filter;\n#line 241 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\t_tmp1_ = path;\n#line 241 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\tgtk_tree_model_get_iter ((GtkTreeModel*) _tmp0_, &_tmp2_, _tmp1_);\n#line 241 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\tfilter_iter = _tmp2_;\n#line 242 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\t_tmp3_ = self->priv->model_filter;\n#line 242 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\t_tmp4_ = filter_iter;\n#line 242 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\tgtk_tree_model_filter_convert_iter_to_child_iter (_tmp3_, &_tmp5_, &_tmp4_);\n#line 242 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\titer = _tmp5_;\n#line 243 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\t_tmp6_ = self->priv->notebook;\n#line 243 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\t_tmp7_ = self->priv->listmodel;\n#line 243 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\t_tmp8_ = iter;\n#line 243 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\t_tmp9_ = gtk_tree_model_get_path ((GtkTreeModel*) _tmp7_, &_tmp8_);\n#line 243 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\t_tmp10_ = _tmp9_;\n#line 243 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\t_tmp12_ = gtk_tree_path_get_indices_with_depth (_tmp10_, &_tmp11_);\n#line 243 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\t_tmp13_ = _tmp12_[0];\n#line 243 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\tg_object_set (_tmp6_, \"page\", _tmp13_, NULL);\n#line 243 \"/extra-data/checkout/gnome/gnome-boxes/src/properties.vala\"\n\t_gtk_tree_path_free0 (_tmp10_);\n#line 1112 \"properties.c\"\n}", "label": 0, "cwe": null, "length": 852 }, { "index": 851165, "code": "rs400_init(struct radeon_device *rdev)\n{\n\tint r;\n\n\t/* Disable VGA */\n\tr100_vga_render_disable(rdev);\n\t/* Initialize scratch registers */\n\tradeon_scratch_init(rdev);\n\t/* Initialize surface registers */\n\tradeon_surface_init(rdev);\n\t/* TODO: disable VGA need to use VGA request */\n\t/* restore some register to sane defaults */\n\tr100_restore_sanity(rdev);\n\t/* BIOS*/\n\tif (!radeon_get_bios(rdev)) {\n\t\tif (ASIC_IS_AVIVO(rdev))\n\t\t\treturn -EINVAL;\n\t}\n\tif (rdev->is_atom_bios) {\n\t\tdev_err(rdev->dev, \"Expecting combios for RS400/RS480 GPU\\n\");\n\t\treturn -EINVAL;\n\t} else {\n\t\tr = radeon_combios_init(rdev);\n\t\tif (r)\n\t\t\treturn r;\n\t}\n\t/* Reset gpu before posting otherwise ATOM will enter infinite loop */\n\tif (radeon_asic_reset(rdev)) {\n\t\tdev_warn(rdev->dev,\n\t\t\t\"GPU reset failed ! (0xE40=0x%08X, 0x7C0=0x%08X)\\n\",\n\t\t\tRREG32(R_000E40_RBBM_STATUS),\n\t\t\tRREG32(R_0007C0_CP_STAT));\n\t}\n\t/* check if cards are posted or not */\n\tif (radeon_boot_test_post_card(rdev) == false)\n\t\treturn -EINVAL;\n\n\t/* Initialize clocks */\n\tradeon_get_clock_info(rdev->ddev);\n\t/* initialize memory controller */\n\trs400_mc_init(rdev);\n\t/* Fence driver */\n\tr = radeon_fence_driver_init(rdev);\n\tif (r)\n\t\treturn r;\n\t/* Memory manager */\n\tr = radeon_bo_init(rdev);\n\tif (r)\n\t\treturn r;\n\tr = rs400_gart_init(rdev);\n\tif (r)\n\t\treturn r;\n\tr300_set_reg_safe(rdev);\n\n\t/* Initialize power management */\n\tradeon_pm_init(rdev);\n\n\trdev->accel_working = true;\n\tr = rs400_startup(rdev);\n\tif (r) {\n\t\t/* Somethings want wront with the accel init stop accel */\n\t\tdev_err(rdev->dev, \"Disabling GPU acceleration\\n\");\n\t\tr100_cp_fini(rdev);\n\t\tradeon_wb_fini(rdev);\n\t\tradeon_ib_pool_fini(rdev);\n\t\trs400_gart_fini(rdev);\n\t\tradeon_irq_kms_fini(rdev);\n\t\trdev->accel_working = false;\n\t}\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 537 }, { "index": 199912, "code": "mono_gc_cleanup (void)\n{\n#ifdef DEBUG\n\tg_message (\"%s: cleaning up finalizer\", __func__);\n#endif\n\n\tif (!gc_disabled) {\n\t\tResetEvent (shutdown_event);\n\t\tfinished = TRUE;\n\t\tif (mono_thread_internal_current () != gc_thread) {\n\t\t\tmono_gc_finalize_notify ();\n\t\t\t/* Finishing the finalizer thread, so wait a little bit... */\n\t\t\t/* MS seems to wait for about 2 seconds */\n\t\t\tif (WaitForSingleObjectEx (shutdown_event, 2000, FALSE) == WAIT_TIMEOUT) {\n\t\t\t\tint ret;\n\n\t\t\t\t/* Set a flag which the finalizer thread can check */\n\t\t\t\tsuspend_finalizers = TRUE;\n\n\t\t\t\t/* Try to abort the thread, in the hope that it is running managed code */\n\t\t\t\tmono_thread_internal_stop (gc_thread);\n\n\t\t\t\t/* Wait for it to stop */\n\t\t\t\tret = WaitForSingleObjectEx (gc_thread->handle, 100, TRUE);\n\n\t\t\t\tif (ret == WAIT_TIMEOUT) {\n\t\t\t\t\t/* \n\t\t\t\t\t * The finalizer thread refused to die. There is not much we \n\t\t\t\t\t * can do here, since the runtime is shutting down so the \n\t\t\t\t\t * state the finalizer thread depends on will vanish.\n\t\t\t\t\t */\n\t\t\t\t\tg_warning (\"Shutting down finalizer thread timed out.\");\n\t\t\t\t} else {\n\t\t\t\t\t/*\n\t\t\t\t\t * FIXME: On unix, when the above wait returns, the thread \n\t\t\t\t\t * might still be running io-layer code, or pthreads code.\n\t\t\t\t\t */\n\t\t\t\t\tSleep (100);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tint ret;\n\n\t\t\t\t/* Wait for the thread to actually exit */\n\t\t\t\tret = WaitForSingleObjectEx (gc_thread->handle, INFINITE, TRUE);\n\t\t\t\tg_assert (ret == WAIT_OBJECT_0);\n\n#ifndef HOST_WIN32\n\t\t\t\t/*\n\t\t\t\t * The above wait only waits for the exited event to be signalled, the thread might still be running. To fix this race, we\n\t\t\t\t * create the finalizer thread without calling pthread_detach () on it, so we can wait for it manually.\n\t\t\t\t */\n\t\t\t\tret = pthread_join ((MonoNativeThreadId)(gpointer)(gsize)gc_thread->tid, NULL);\n\t\t\t\tg_assert (ret == 0);\n#endif\n\t\t\t}\n\t\t}\n\t\tgc_thread = NULL;\n#ifdef HAVE_BOEHM_GC\n\t\tGC_finalizer_notifier = NULL;\n#endif\n\t}\n\n\tmono_reference_queue_cleanup ();\n\n\tDeleteCriticalSection (&handle_section);\n\tDeleteCriticalSection (&allocator_section);\n\tDeleteCriticalSection (&finalizer_mutex);\n\tDeleteCriticalSection (&reference_queue_mutex);\n}", "label": 0, "cwe": null, "length": 534 }, { "index": 877113, "code": "DATE_adjust( GB_DATE *vdate, int period, int interval) /* Adjust the date by the interval period */\n{\n\n GB_DATE_SERIAL *date;\n int year, month, day;\n date = GB.SplitDate(vdate);\n\n switch(period){\n\t case 0: /* Calendar Month */\n\t\t year = ((date->year * 12) + (date->month - 1) + interval)/12;\n\t\t month = modulo((date->month - 1)+interval, 12) + 1;\n\t\t day = date->day > days_in_months[date_is_leap_year(year)][month] ? days_in_months[date_is_leap_year(year)][month] : date->day;\n\t\t date->day = day;\n\t\t date->month = month;\n\t\t date->year = year;\n GB.MakeDate(date, vdate);\n\t\t break;\n\t case 1: /* days */\n\t\t vdate->value.date += interval;\n\t\t break;\n\t case 2: /* Time */\n\t\t vdate->value.time += interval;\n\t\t break;\n\t case 3: /* weekdays - in this case weekdays are Mon - Fri */\n\t\t vdate->value.date += ( 7 * ( interval / 5));\n\t\t date->weekday += ( interval % 5 );\n\t\t if (date->weekday > 5){\n\t\t\t date->weekday -= 5;\n vdate->value.date += 2;\n\t\t }\n\t\t if (date->weekday < 1){\n\t\t\t date->weekday += 5;\n vdate->value.date -= 2;\n\t\t }\n vdate->value.date += ( interval % 5);\n\t\t break;\n\t case 4: /* Add year */\n\t\t while ( interval != 0){\n\t\t\tif ( interval < 0 ){\n\t\t vdate->value.date -= days_in_year[date_is_leap_year(date->year)][13];\n\t\t\t date->year--;\n\t\t\t interval++;\n\t\t\t}\n\t\t\telse {\n\t\t vdate->value.date += days_in_year[date_is_leap_year(date->year)][13];\n\t\t\t date->year++;\n\t\t\t interval--;\n\t\t\t}\n\t\t }\n\t\t break;\n }\n\n /* Now if time takes it into another day */\n while (vdate->value.time >= 86400000){\n\t vdate->value.date++;\n\t vdate->value.time -= 86400000;\n }\n /* Or time is negative so we need to take off a day */\n while (vdate->value.time < 0){\n\t vdate->value.date--;\n\t vdate->value.time += 86400000;\n }\n\n CLEAR(&date);\n date = GB.SplitDate(vdate);\n\n if (!date_is_valid(date)){\n /*printf(\"Invalid date : year [%i] month [%i] day [%i] hour [%i] min [%i] sec [%i] weekday [%i] msec [%i]\\n\",\n\t\t date->year, date->month, date->day, date->hour, date->min, date->sec, date->weekday, date->msec);*/\n GB.Error(\"Invalid Date Returned\");\n }\n CLEAR(&date);\n\n}", "label": 0, "cwe": null, "length": 646 }, { "index": 302838, "code": "gpk_session_init (GpkSession *session)\n{\n\tDBusGConnection *connection;\n\tGError *error = NULL;\n\n\tsession->priv = GPK_SESSION_GET_PRIVATE (session);\n\tsession->priv->is_idle_old = FALSE;\n\tsession->priv->is_inhibited_old = FALSE;\n\tsession->priv->proxy_client_private = NULL;\n\n\tconnection = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);\n\n\t/* get org.gnome.Session interface */\n\tsession->priv->proxy = dbus_g_proxy_new_for_name_owner (connection, GPK_SESSION_MANAGER_SERVICE,\n\t\t\t\t\t\t\t\tGPK_SESSION_MANAGER_PATH,\n\t\t\t\t\t\t\t\tGPK_SESSION_MANAGER_INTERFACE, &error);\n\tif (session->priv->proxy == NULL) {\n\t\tg_warning (\"DBUS error: %s\", error->message);\n\t\tg_error_free (error);\n\t\treturn;\n\t}\n\n\t/* get org.gnome.Session.Presence interface */\n\tsession->priv->proxy_presence = dbus_g_proxy_new_for_name_owner (connection, GPK_SESSION_MANAGER_SERVICE,\n\t\t\t\t\t\t\t\t\t GPK_SESSION_MANAGER_PRESENCE_PATH,\n\t\t\t\t\t\t\t\t\t GPK_SESSION_MANAGER_PRESENCE_INTERFACE, &error);\n\tif (session->priv->proxy_presence == NULL) {\n\t\tg_warning (\"DBUS error: %s\", error->message);\n\t\tg_error_free (error);\n\t\treturn;\n\t}\n\n\t/* get properties interface */\n\tsession->priv->proxy_prop = dbus_g_proxy_new_for_name_owner (connection, GPK_SESSION_MANAGER_SERVICE,\n\t\t\t\t\t\t\t\t GPK_SESSION_MANAGER_PRESENCE_PATH,\n\t\t\t\t\t\t\t\t GPK_DBUS_PROPERTIES_INTERFACE, &error);\n\tif (session->priv->proxy_prop == NULL) {\n\t\tg_warning (\"DBUS error: %s\", error->message);\n\t\tg_error_free (error);\n\t\treturn;\n\t}\n\n\t/* get StatusChanged */\n\tdbus_g_proxy_add_signal (session->priv->proxy_presence, \"StatusChanged\", G_TYPE_UINT, G_TYPE_INVALID);\n\tdbus_g_proxy_connect_signal (session->priv->proxy_presence, \"StatusChanged\", G_CALLBACK (gpk_session_presence_status_changed_cb), session, NULL);\n\n\t/* get InhibitorAdded */\n\tdbus_g_proxy_add_signal (session->priv->proxy, \"InhibitorAdded\", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);\n\tdbus_g_proxy_connect_signal (session->priv->proxy, \"InhibitorAdded\", G_CALLBACK (gpk_session_inhibit_changed_cb), session, NULL);\n\n\t/* get InhibitorRemoved */\n\tdbus_g_proxy_add_signal (session->priv->proxy, \"InhibitorRemoved\", DBUS_TYPE_G_OBJECT_PATH, G_TYPE_INVALID);\n\tdbus_g_proxy_connect_signal (session->priv->proxy, \"InhibitorRemoved\", G_CALLBACK (gpk_session_inhibit_changed_cb), session, NULL);\n\n\t/* coldplug */\n\tsession->priv->is_inhibited_old = gpk_session_is_inhibited (session);\n\tsession->priv->is_idle_old = gpk_session_is_idle (session);\n\tg_debug (\"idle: %i, inhibited: %i\", session->priv->is_idle_old, session->priv->is_inhibited_old);\n}", "label": 0, "cwe": null, "length": 637 }, { "index": 124310, "code": "learnedClauses(const Theorem& thm,\n vector& clauses,\n bool newLemma)\n{\n IF_DEBUG(if(debugger.trace(\"cnf proofs\")) {\n ostream& os = debugger.getOS();\n os << \"learnedClause {\" << endl;\n os << thm;\n })\n \n if (!newLemma && d_smartClauses) {\n getSmartClauses(thm, clauses);\n return;\n }\n\n// if (newLemma || d_flags[\"dynack\"].getInt() <= 0) {\n// \t if (NewClausel == true) {\n// \t return;\n// }\n\n vector assumptions;\n Proof pf;\n thm.getLeafAssumptions(assumptions, true /*negate*/);\n\n vector::iterator iend = assumptions.end();\n for (vector::iterator i = assumptions.begin();\n i != iend; ++i) {\n DebugAssert(i->isAbsLiteral(), \"Expected only literal assumptions\");\n }\n\n if (!thm.getExpr().isFalse())\n assumptions.push_back(thm.getExpr());\n\n DebugAssert(assumptions.size() > 0, \"Expected at least one entry\");\n\n Theorem thm2;\n if (assumptions.size() == 1) {\n if(withProof()) {\n pf = newPf(\"learned_clause\", thm.getProof());\n }\n thm2 = newTheorem(assumptions[0], Assumptions::emptyAssump(), pf);\n }\n else {\n Expr clauseExpr = Expr(OR, assumptions);\n if(withProof()) {\n pf = newPf(\"learned_clause\", thm.getProof());\n }\n thm2 = newTheorem(clauseExpr, Assumptions::emptyAssump(), pf);\n }\n thm2.setQuantLevel(thm.getQuantLevel());\n clauses.push_back(thm2);\n// }\n// else {\n\n// vector congruences;\n\n// thm.getAssumptionsAndCong(assumptions, congruences, true /*negate*/);\n\n// vector::iterator i = assumptions.begin(), iend = assumptions.end();\n// for (; i != iend; ++i) {\n// DebugAssert(i->isAbsLiteral(), \"Expected only literal assumptions\");\n// }\n\n// if (!thm.getExpr().isFalse())\n// assumptions.push_back(thm.getExpr());\n\n// if(withProof()) {\n// pf = newPf(\"learned_clause\", thm.getProof());\n// }\n\n// DebugAssert(assumptions.size() > 0, \"Expected at least one entry\");\n\n// Theorem thm2;\n// if (assumptions.size() == 1) {\n// Expr clauseExpr = assumptions[0];\n// if(withProof()) {\n// \tpf = newPf(\"learned_clause\", clauseExpr, thm.getProof());\n// }\n// thm2 = newTheorem(clauseExpr, Assumptions::emptyAssump(), pf);\n// }\n// else {\n// Expr clauseExpr = Expr(OR, assumptions);\n// if(withProof()) {\n// \tpf = newPf(\"learned_clause\", clauseExpr, thm.getProof());\n// }\n// thm2 = newTheorem(clauseExpr, Assumptions::emptyAssump(), pf);\n// }\n// thm2.setQuantLevel(thm.getQuantLevel());\n// clauses.push_back(thm2);\n\n// for (i = congruences.begin(), iend = congruences.end(); i != iend; ++i) {\n// if (withProof()) {\n// pf = newPf(\"congruence\", *i);\n// }\n// thm2 = newTheorem(*i, Assumptions::emptyAssump(), pf);\n// thm2.setQuantLevel(thm.getQuantLevel());\n// clauses.push_back(thm2);\n// }\n// }\n}", "label": 0, "cwe": null, "length": 865 }, { "index": 917910, "code": "cr_tknzr_parse_num (CRTknzr * a_this, \n CRNum ** a_num)\n{\n enum CRStatus status = CR_PARSING_ERROR;\n enum CRNumType val_type = NUM_GENERIC;\n gboolean parsing_dec, /* true iff seen decimal point. */\n parsed; /* true iff the substring seen so far is a valid CSS\n number, i.e. `[0-9]+|[0-9]*\\.[0-9]+'. */\n guint32 cur_char = 0,\n next_char = 0;\n gdouble numerator, denominator = 1;\n CRInputPos init_pos;\n CRParsingLocation location = {0} ;\n int sign = 1;\n\n g_return_val_if_fail (a_this && PRIVATE (a_this)\n && PRIVATE (a_this)->input, \n CR_BAD_PARAM_ERROR);\n\n RECORD_INITIAL_POS (a_this, &init_pos);\n READ_NEXT_CHAR (a_this, &cur_char);\n\n if (cur_char == '+' || cur_char == '-') {\n if (cur_char == '-') {\n sign = -1;\n }\n READ_NEXT_CHAR (a_this, &cur_char);\n }\n\n if (IS_NUM (cur_char)) {\n numerator = (cur_char - '0');\n parsing_dec = FALSE;\n parsed = TRUE;\n } else if (cur_char == '.') {\n numerator = 0;\n parsing_dec = TRUE;\n parsed = FALSE;\n } else {\n status = CR_PARSING_ERROR;\n goto error;\n }\n cr_tknzr_get_parsing_location (a_this, &location) ;\n\n for (;;) {\n status = cr_tknzr_peek_char (a_this, &next_char);\n if (status != CR_OK) {\n if (status == CR_END_OF_INPUT_ERROR)\n status = CR_OK;\n break;\n }\n if (next_char == '.') {\n if (parsing_dec) {\n status = CR_PARSING_ERROR;\n goto error;\n }\n\n READ_NEXT_CHAR (a_this, &cur_char);\n parsing_dec = TRUE;\n parsed = FALSE; /* In CSS, there must be at least\n one digit after `.'. */\n } else if (IS_NUM (next_char)) {\n READ_NEXT_CHAR (a_this, &cur_char);\n parsed = TRUE;\n\n numerator = numerator * 10 + (cur_char - '0');\n if (parsing_dec) {\n denominator *= 10;\n }\n } else {\n break;\n }\n }\n\n if (!parsed) {\n status = CR_PARSING_ERROR;\n }\n\n /*\n *Now, set the output param values.\n */\n if (status == CR_OK) {\n gdouble val = (numerator / denominator) * sign;\n if (*a_num == NULL) {\n *a_num = cr_num_new_with_val (val, val_type);\n\n if (*a_num == NULL) {\n status = CR_ERROR;\n goto error;\n }\n } else {\n (*a_num)->val = val;\n (*a_num)->type = val_type;\n }\n cr_parsing_location_copy (&(*a_num)->location,\n &location) ;\n return CR_OK;\n }\n\n error:\n\n cr_tknzr_set_cur_pos (a_this, &init_pos);\n\n return status;\n}", "label": 0, "cwe": null, "length": 717 }, { "index": 111567, "code": "change_test_time_set(change::pointer cp, string_ty *variant, time_t when)\n{\n trace((\"change_test_time_set(cp = %08lX, variant = \\\"%s\\\", when = %ld)\\n\"\n\t\"{\\n\", (long)cp, variant->str_text, (long)when));\n\n trace((\"change_test_time_set(cp = %8.8lX)\\n{\\n\", (long)cp));\n assert(cp->reference_count >= 1);\n pconf_ty *pconf_data = change_pconf_get(cp, 1);\n cstate_ty *cstate_data = cp->cstate_get();\n // set the test_time in the change state - no matter what\n cstate_data->test_time = when;\n\n if (pconf_data->test_covers_all_architectures)\n {\n //\n // set the test_time in all of the architecture variant records\n\t//\n for (size_t j = 0; j < cstate_data->architecture->length; ++j)\n {\n trace((\"j = %ld of %ld \\\"%s\\\"\\n\", (long)j,\n (long)cstate_data->architecture->length,\n cstate_data->architecture->list[j]->str_text));\n\n\t cstate_architecture_times_ty *tp =\n\t\tcstate_data->architecture_times->list[j];\n trace((\"j = %ld of %ld \\\"%s\\\"\\n\", (long)j,\n (long)cstate_data->architecture_times->length,\n tp->variant->str_text));\n tp->test_time = when;\n }\n }\n else\n {\n //\n // set the test_time in the one architecture variant record\n //\n cstate_architecture_times_ty *tp =\n change_find_architecture_variant(cp, variant);\n trace_string(tp->variant);\n tp->test_time = when;\n\n if (when)\n {\n // figure the oldest time of all variants.\n // if one is missing, then is zero.\n // TODO: why traverse the list nested? Once is enough yes?\n for (size_t j = 0; j < cstate_data->architecture->length; ++j)\n {\n trace((\"j = %ld of %ld \\\"%s\\\"\\n\", (long)j,\n (long)cstate_data->architecture->length,\n cstate_data->architecture->list[j]->str_text));\n\n\t\tsize_t k = 0;\n for (k = 0; k < cstate_data->architecture_times->length; ++k)\n {\n tp = cstate_data->architecture_times->list[k];\n trace((\"k = %ld of %ld \\\"%s\\\"\\n\", (long)k,\n (long)cstate_data->architecture_times->length,\n tp->variant->str_text));\n if (str_equal(cstate_data->architecture->list[j],\n tp->variant))\n break;\n }\n if (k >= cstate_data->architecture_times->length)\n {\n trace((\"clear change test time\\n\"));\n cstate_data->test_time = 0;\n break;\n }\n if (tp->test_time < cstate_data->test_time)\n {\n trace((\"shorten change test time\\n\"));\n cstate_data->test_time = tp->test_time;\n trace_time(cstate_data->test_time);\n if (!cstate_data->test_time)\n break;\n }\n }\n }\n }\n trace((\"}\\n\"));\n}", "label": 0, "cwe": null, "length": 733 }, { "index": 474787, "code": "camlidl_environment_ap_environment_lce_change(\n\tvalue _v_e1,\n\tvalue _v_e2)\n{\n ap_environment_ptr e1; /*in*/\n ap_environment_ptr e2; /*in*/\n ap_dimchange_t *c1; /*out*/\n ap_dimchange_t *c2; /*out*/\n ap_environment_ptr _res;\n struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };\n camlidl_ctx _ctx = &_ctxs;\n ap_dimchange_t _c1;\n ap_dimchange_t _c2;\n value _v3;\n value _v4;\n value _vresult;\n value _vres[3] = { 0, 0, 0, };\n\n camlidl_ml2c_environment_ap_environment_ptr(_v_e1, &e1, _ctx);\n camlidl_ml2c_environment_ap_environment_ptr(_v_e2, &e2, _ctx);\n c1 = &_c1;\n c2 = &_c2;\n /* begin user-supplied calling sequence */\n\n{\n_res = ap_environment_lce(e1,e2,&c1,&c2);\n}\nif (_res==NULL){\ncamlidl_free(_ctx);\ncaml_failwith(\"Environment.lce: variable with two different types\");\n}\nassert(_res->count >= 1);\n /* end user-supplied calling sequence */\n Begin_roots_block(_vres, 3)\n _vres[0] = camlidl_c2ml_environment_ap_environment_ptr(&_res, _ctx);\n if (c1 == NULL) {\n _vres[1] = Val_int(0);\n } else {\n _v3 = camlidl_c2ml_dim_ap_dimchange_t(&*c1, _ctx);\n Begin_root(_v3)\n _vres[1] = camlidl_alloc_small(1, 0);\n Field(_vres[1], 0) = _v3;\n End_roots();\n }\n if (c2 == NULL) {\n _vres[2] = Val_int(0);\n } else {\n _v4 = camlidl_c2ml_dim_ap_dimchange_t(&*c2, _ctx);\n Begin_root(_v4)\n _vres[2] = camlidl_alloc_small(1, 0);\n Field(_vres[2], 0) = _v4;\n End_roots();\n }\n _vresult = camlidl_alloc_small(3, 0);\n Field(_vresult, 0) = _vres[0];\n Field(_vresult, 1) = _vres[1];\n Field(_vresult, 2) = _vres[2];\n End_roots()\n camlidl_free(_ctx);\n /* begin user-supplied deallocation sequence */\n\n if (c1) ap_dimchange_free(c1);\n if (c2) ap_dimchange_free(c2);\n\n /* end user-supplied deallocation sequence */\n return _vresult;\n}", "label": 0, "cwe": null, "length": 664 }, { "index": 726396, "code": "command_add_list (int argc, char *argv[], ProgEnv *env)\n{\n const char *enc_name, *input_name;\n int opt_idx;\n iconv_t saved_conv;\n FILE *input;\n char line[256];\n\n enc_name = 0;\n opt_idx = 0;\n saved_conv = env->to_alpha_conv;\n if (strcmp (argv[0], \"-e\") == 0 ||\n strcmp (argv[0], \"--encoding\") == 0)\n {\n if (++opt_idx >= argc) {\n fprintf (stderr, \"add-list option \\\"%s\\\" requires encoding name\",\n argv[0]);\n return opt_idx;\n }\n enc_name = argv[opt_idx++];\n }\n if (opt_idx >= argc) {\n fprintf (stderr, \"add-list requires input word list file name\\n\");\n return opt_idx;\n }\n input_name = argv[opt_idx++];\n\n if (enc_name) {\n iconv_t conv = iconv_open (ALPHA_ENC, enc_name);\n if ((iconv_t) -1 == conv) {\n fprintf (stderr,\n \"Conversion from \\\"%s\\\" to \\\"%s\\\" is not supported.\\n\",\n enc_name, ALPHA_ENC);\n return opt_idx;\n }\n\n env->to_alpha_conv = conv;\n }\n\n input = fopen (input_name, \"r\");\n if (!input) {\n fprintf (stderr, \"add-list: Cannot open input file \\\"%s\\\"\\n\",\n input_name);\n goto exit_iconv_openned;\n }\n\n while (fgets (line, sizeof line, input)) {\n char *key, *data;\n AlphaChar key_alpha[256];\n TrieData data_val;\n\n key = string_trim (line);\n if ('\\0' != *key) {\n /* find key boundary */\n for (data = key; *data && !strchr (\"\\t,\", *data); ++data)\n ;\n /* mark key ending and find data begin */\n if ('\\0' != *data) {\n *data++ = '\\0';\n while (isspace (*data))\n ++data;\n }\n /* decode data */\n data_val = ('\\0' != *data) ? atoi (data) : TRIE_DATA_ERROR;\n\n /* store the key */\n conv_to_alpha (env, key, key_alpha, N_ELEMENTS (key_alpha));\n if (!trie_store (env->trie, key_alpha, data_val))\n fprintf (stderr, \"Failed to add key '%s' with data %d.\\n\",\n key, data_val);\n }\n }\n\n fclose (input);\n\nexit_iconv_openned:\n if (enc_name) {\n iconv_close (env->to_alpha_conv);\n env->to_alpha_conv = saved_conv;\n }\n\n return opt_idx;\n}", "label": 0, "cwe": null, "length": 605 }, { "index": 65128, "code": "mmc_select_hs_ddr(struct mmc_card *card)\n{\n\tstruct mmc_host *host = card->host;\n\tu32 bus_width, ext_csd_bits;\n\tint err = 0;\n\n\tif (!(card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_52))\n\t\treturn 0;\n\n\tbus_width = host->ios.bus_width;\n\tif (bus_width == MMC_BUS_WIDTH_1)\n\t\treturn 0;\n\n\text_csd_bits = (bus_width == MMC_BUS_WIDTH_8) ?\n\t\tEXT_CSD_DDR_BUS_WIDTH_8 : EXT_CSD_DDR_BUS_WIDTH_4;\n\n\terr = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,\n\t\t\tEXT_CSD_BUS_WIDTH,\n\t\t\text_csd_bits,\n\t\t\tcard->ext_csd.generic_cmd6_time);\n\tif (err) {\n\t\tpr_err(\"%s: switch to bus width %d ddr failed\\n\",\n\t\t\tmmc_hostname(host), 1 << bus_width);\n\t\treturn err;\n\t}\n\n\t/*\n\t * eMMC cards can support 3.3V to 1.2V i/o (vccq)\n\t * signaling.\n\t *\n\t * EXT_CSD_CARD_TYPE_DDR_1_8V means 3.3V or 1.8V vccq.\n\t *\n\t * 1.8V vccq at 3.3V core voltage (vcc) is not required\n\t * in the JEDEC spec for DDR.\n\t *\n\t * Even (e)MMC card can support 3.3v to 1.2v vccq, but not all\n\t * host controller can support this, like some of the SDHCI\n\t * controller which connect to an eMMC device. Some of these\n\t * host controller still needs to use 1.8v vccq for supporting\n\t * DDR mode.\n\t *\n\t * So the sequence will be:\n\t * if (host and device can both support 1.2v IO)\n\t *\tuse 1.2v IO;\n\t * else if (host and device can both support 1.8v IO)\n\t *\tuse 1.8v IO;\n\t * so if host and device can only support 3.3v IO, this is the\n\t * last choice.\n\t *\n\t * WARNING: eMMC rules are NOT the same as SD DDR\n\t */\n\terr = -EINVAL;\n\tif (card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_1_2V)\n\t\terr = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_120);\n\n\tif (err && (card->mmc_avail_type & EXT_CSD_CARD_TYPE_DDR_1_8V))\n\t\terr = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_180);\n\n\t/* make sure vccq is 3.3v after switching disaster */\n\tif (err)\n\t\terr = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330);\n\n\tif (!err)\n\t\tmmc_set_timing(host, MMC_TIMING_MMC_DDR52);\n\n\treturn err;\n}", "label": 0, "cwe": null, "length": 638 }, { "index": 160665, "code": "xlog_find_zeroed(\n\tstruct xlog\t*log,\n\txfs_daddr_t\t*blk_no)\n{\n\txfs_buf_t\t*bp;\n\tchar\t\t*offset;\n\tuint\t first_cycle, last_cycle;\n\txfs_daddr_t\tnew_blk, last_blk, start_blk;\n\txfs_daddr_t num_scan_bblks;\n\tint\t error, log_bbnum = log->l_logBBsize;\n\n\t*blk_no = 0;\n\n\t/* check totally zeroed log */\n\tbp = xlog_get_bp(log, 1);\n\tif (!bp)\n\t\treturn -ENOMEM;\n\terror = xlog_bread(log, 0, 1, bp, &offset);\n\tif (error)\n\t\tgoto bp_err;\n\n\tfirst_cycle = xlog_get_cycle(offset);\n\tif (first_cycle == 0) {\t\t/* completely zeroed log */\n\t\t*blk_no = 0;\n\t\txlog_put_bp(bp);\n\t\treturn 1;\n\t}\n\n\t/* check partially zeroed log */\n\terror = xlog_bread(log, log_bbnum-1, 1, bp, &offset);\n\tif (error)\n\t\tgoto bp_err;\n\n\tlast_cycle = xlog_get_cycle(offset);\n\tif (last_cycle != 0) {\t\t/* log completely written to */\n\t\txlog_put_bp(bp);\n\t\treturn 0;\n\t} else if (first_cycle != 1) {\n\t\t/*\n\t\t * If the cycle of the last block is zero, the cycle of\n\t\t * the first block must be 1. If it's not, maybe we're\n\t\t * not looking at a log... Bail out.\n\t\t */\n\t\txfs_warn(log->l_mp,\n\t\t\t\"Log inconsistent or not a log (last==0, first!=1)\");\n\t\terror = -EINVAL;\n\t\tgoto bp_err;\n\t}\n\n\t/* we have a partially zeroed log */\n\tlast_blk = log_bbnum-1;\n\tif ((error = xlog_find_cycle_start(log, bp, 0, &last_blk, 0)))\n\t\tgoto bp_err;\n\n\t/*\n\t * Validate the answer. Because there is no way to guarantee that\n\t * the entire log is made up of log records which are the same size,\n\t * we scan over the defined maximum blocks. At this point, the maximum\n\t * is not chosen to mean anything special. XXXmiken\n\t */\n\tnum_scan_bblks = XLOG_TOTAL_REC_SHIFT(log);\n\tASSERT(num_scan_bblks <= INT_MAX);\n\n\tif (last_blk < num_scan_bblks)\n\t\tnum_scan_bblks = last_blk;\n\tstart_blk = last_blk - num_scan_bblks;\n\n\t/*\n\t * We search for any instances of cycle number 0 that occur before\n\t * our current estimate of the head. What we're trying to detect is\n\t * 1 ... | 0 | 1 | 0...\n\t * ^ binary search ends here\n\t */\n\tif ((error = xlog_find_verify_cycle(log, start_blk,\n\t\t\t\t\t (int)num_scan_bblks, 0, &new_blk)))\n\t\tgoto bp_err;\n\tif (new_blk != -1)\n\t\tlast_blk = new_blk;\n\n\t/*\n\t * Potentially backup over partial log record write. We don't need\n\t * to search the end of the log because we know it is zero.\n\t */\n\terror = xlog_find_verify_log_record(log, start_blk, &last_blk, 0);\n\tif (error == 1)\n\t\terror = -EIO;\n\tif (error)\n\t\tgoto bp_err;\n\n\t*blk_no = last_blk;\nbp_err:\n\txlog_put_bp(bp);\n\tif (error)\n\t\treturn error;\n\treturn 1;\n}", "label": 0, "cwe": null, "length": 778 }, { "index": 433113, "code": "parseAttributeParameter(Boolean inDecl,\n\t\t\t\t\tBoolean allowVi,\n\t\t\t\t\tAttributeParameter::Type &result,\n\t\t\t\t\tBoolean &netEnabling)\n{\n Mode mode = inDecl ? asMode : tagMode;\n Token token = getToken(mode);\n Markup *markup = currentMarkup();\n if (markup) {\n while (token == tokenS) {\n markup->addS(currentChar());\n token = getToken(mode);\n }\n }\n else {\n while (token == tokenS)\n token = getToken(mode);\n }\n switch (token) {\n case tokenUnrecognized:\n if (reportNonSgmlCharacter())\n return 0;\n extendUnquotedAttributeValue();\n result = AttributeParameter::recoverUnquoted;\n break;\n case tokenEe:\n message(ParserMessages::attributeSpecEntityEnd);\n return 0;\n case tokenEtago:\n case tokenStago:\n if (!sd().startTagUnclosed())\n message(ParserMessages::unclosedStartTagShorttag);\n result = AttributeParameter::end;\n currentInput()->ungetToken();\n netEnabling = 0;\n break;\n case tokenNestc:\n if (markup)\n markup->addDelim(Syntax::dNESTC);\n switch (sd().startTagNetEnable()) {\n case Sd::netEnableNo:\n message(ParserMessages::netEnablingStartTagShorttag);\n break;\n case Sd::netEnableImmednet:\n if (getToken(econnetMode) != tokenNet) \n\tmessage(ParserMessages::nestcWithoutNet);\n currentInput()->ungetToken();\n break;\n case Sd::netEnableAll:\n break;\n }\n netEnabling = 1;\n result = AttributeParameter::end;\n break;\n case tokenTagc:\n if (markup)\n markup->addDelim(Syntax::dTAGC);\n netEnabling = 0;\n result = AttributeParameter::end;\n break;\n case tokenDsc:\n if (markup)\n markup->addDelim(Syntax::dDSC);\n result = AttributeParameter::end;\n break;\n case tokenNameStart:\n extendNameToken(syntax().namelen(), ParserMessages::nameTokenLength);\n if (markup)\n markup->addName(currentInput());\n result = AttributeParameter::name;\n break;\n case tokenDigit:\n case tokenLcUcNmchar:\n extendNameToken(syntax().namelen(), ParserMessages::nameTokenLength);\n if (markup)\n markup->addName(currentInput());\n result = AttributeParameter::nameToken;\n break;\n case tokenLit:\n case tokenLita:\n message(allowVi\n\t ? ParserMessages::attributeSpecLiteral\n\t : ParserMessages::attributeSpecNameTokenExpected);\n return 0;\n case tokenVi:\n if (!allowVi) {\n message(ParserMessages::attributeSpecNameTokenExpected);\n return 0;\n }\n if (markup)\n markup->addDelim(Syntax::dVI);\n result = AttributeParameter::vi;\n break;\n default:\n CANNOT_HAPPEN();\n }\n return 1;\n}", "label": 0, "cwe": null, "length": 673 }, { "index": 285268, "code": "socket_source_cb (GSSDPSocketSource *socket_source, GSSDPClient *client)\n{\n int type, len;\n char buf[BUF_SIZE], *end;\n SoupMessageHeaders *headers = NULL;\n GSocket *socket;\n GSocketAddress *address = NULL;\n gssize bytes;\n GInetAddress *inetaddr;\n char *ip_string = NULL;\n guint16 port;\n GError *error = NULL;\n in_addr_t our_addr;\n in_addr_t mask;\n struct sockaddr_in addr;\n\n /* Get Socket */\n socket = gssdp_socket_source_get_socket (socket_source);\n bytes = g_socket_receive_from (socket,\n &address,\n buf,\n BUF_SIZE - 1,\n NULL,\n &error);\n if (bytes == -1) {\n g_warning (\"Failed to receive from socket: %s\",\n error->message);\n\n goto out;\n }\n\n /* We need the following lines to make sure the right client received\n * the packet. We won't need to do this if there was any way to tell\n * Mr. Unix that we are only interested in receiving multicast packets\n * on this socket from a particular interface but AFAIK that is not\n * possible, at least not in a portable way.\n */\n\n if (!g_socket_address_to_native (address,\n &addr,\n sizeof (struct sockaddr_in),\n &error)) {\n g_warning (\"Could not convert address to native: %s\",\n error->message);\n\n goto out;\n }\n\n mask = client->priv->device.mask.sin_addr.s_addr;\n our_addr = inet_addr (gssdp_client_get_host_ip (client));\n\n if ((addr.sin_addr.s_addr & mask) != (our_addr & mask))\n goto out;\n\n if (bytes >= BUF_SIZE) {\n g_warning (\"Received packet of %u bytes, but the maximum \"\n \"buffer size is %d. Packed dropped.\",\n (unsigned int) bytes, BUF_SIZE);\n\n goto out;\n }\n\n /* Add trailing \\0 */\n buf[bytes] = '\\0';\n\n /* Find length */\n end = strstr (buf, \"\\r\\n\\r\\n\");\n if (!end) {\n g_warning (\"Received packet lacks \\\"\\\\r\\\\n\\\\r\\\\n\\\" sequence. \"\n \"Packed dropped.\");\n\n goto out;\n }\n\n len = end - buf + 2;\n \n /* Parse message */\n type = -1;\n headers = NULL;\n\n if (!parse_http_request (buf,\n len,\n &headers,\n &type)) {\n if (!parse_http_response (buf,\n len,\n &headers,\n &type)) {\n g_warning (\"Unhandled message '%s'\", buf);\n }\n }\n \n /* Emit signal if parsing succeeded */\n inetaddr = g_inet_socket_address_get_address (\n G_INET_SOCKET_ADDRESS (address));\n ip_string = g_inet_address_to_string (inetaddr);\n port = g_inet_socket_address_get_port (\n G_INET_SOCKET_ADDRESS (address));\n if (type >= 0) {\n g_signal_emit (client,\n signals[MESSAGE_RECEIVED],\n 0,\n ip_string,\n port,\n type,\n headers);\n }\n\nout:\n if (error)\n g_error_free (error);\n\n if (ip_string)\n g_free (ip_string);\n\n if (headers)\n soup_message_headers_free (headers);\n\n if (address)\n g_object_unref (address);\n\n return TRUE;\n}", "label": 0, "cwe": null, "length": 752 }, { "index": 406277, "code": "avc_has_extended_perms(u32 ssid, u32 tsid, u16 tclass, u32 requested,\n\t\t\tu8 driver, u8 xperm, struct common_audit_data *ad)\n{\n\tstruct avc_node *node;\n\tstruct av_decision avd;\n\tu32 denied;\n\tstruct extended_perms_decision local_xpd;\n\tstruct extended_perms_decision *xpd = NULL;\n\tstruct extended_perms_data allowed;\n\tstruct extended_perms_data auditallow;\n\tstruct extended_perms_data dontaudit;\n\tstruct avc_xperms_node local_xp_node;\n\tstruct avc_xperms_node *xp_node;\n\tint rc = 0, rc2;\n\n\txp_node = &local_xp_node;\n\tBUG_ON(!requested);\n\n\trcu_read_lock();\n\n\tnode = avc_lookup(ssid, tsid, tclass);\n\tif (unlikely(!node)) {\n\t\tnode = avc_compute_av(ssid, tsid, tclass, &avd, xp_node);\n\t} else {\n\t\tmemcpy(&avd, &node->ae.avd, sizeof(avd));\n\t\txp_node = node->ae.xp_node;\n\t}\n\t/* if extended permissions are not defined, only consider av_decision */\n\tif (!xp_node || !xp_node->xp.len)\n\t\tgoto decision;\n\n\tlocal_xpd.allowed = &allowed;\n\tlocal_xpd.auditallow = &auditallow;\n\tlocal_xpd.dontaudit = &dontaudit;\n\n\txpd = avc_xperms_decision_lookup(driver, xp_node);\n\tif (unlikely(!xpd)) {\n\t\t/*\n\t\t * Compute the extended_perms_decision only if the driver\n\t\t * is flagged\n\t\t */\n\t\tif (!security_xperm_test(xp_node->xp.drivers.p, driver)) {\n\t\t\tavd.allowed &= ~requested;\n\t\t\tgoto decision;\n\t\t}\n\t\trcu_read_unlock();\n\t\tsecurity_compute_xperms_decision(ssid, tsid, tclass, driver,\n\t\t\t\t\t\t&local_xpd);\n\t\trcu_read_lock();\n\t\tavc_update_node(AVC_CALLBACK_ADD_XPERMS, requested, driver, xperm,\n\t\t\t\tssid, tsid, tclass, avd.seqno, &local_xpd, 0);\n\t} else {\n\t\tavc_quick_copy_xperms_decision(xperm, &local_xpd, xpd);\n\t}\n\txpd = &local_xpd;\n\n\tif (!avc_xperms_has_perm(xpd, xperm, XPERMS_ALLOWED))\n\t\tavd.allowed &= ~requested;\n\ndecision:\n\tdenied = requested & ~(avd.allowed);\n\tif (unlikely(denied))\n\t\trc = avc_denied(ssid, tsid, tclass, requested, driver, xperm,\n\t\t\t\tAVC_EXTENDED_PERMS, &avd);\n\n\trcu_read_unlock();\n\n\trc2 = avc_xperms_audit(ssid, tsid, tclass, requested,\n\t\t\t&avd, xpd, xperm, rc, ad);\n\tif (rc2)\n\t\treturn rc2;\n\treturn rc;\n}", "label": 1, "cwe": "CWE-120", "length": 618 }, { "index": 115856, "code": "peephole2_optimize (void)\n{\n rtx insn;\n bitmap live;\n int i;\n basic_block bb;\n\n peep2_do_cleanup_cfg = false;\n peep2_do_rebuild_jump_labels = false;\n\n df_set_flags (DF_LR_RUN_DCE);\n df_note_add_problem ();\n df_analyze ();\n\n /* Initialize the regsets we're going to use. */\n for (i = 0; i < MAX_INSNS_PER_PEEP2 + 1; ++i)\n peep2_insn_data[i].live_before = BITMAP_ALLOC (®_obstack);\n search_ofs = 0;\n live = BITMAP_ALLOC (®_obstack);\n\n FOR_EACH_BB_REVERSE (bb)\n {\n bool past_end = false;\n int pos;\n\n rtl_profile_for_bb (bb);\n\n /* Start up propagation. */\n bitmap_copy (live, DF_LR_IN (bb));\n df_simulate_initialize_forwards (bb, live);\n peep2_reinit_state (live);\n\n insn = BB_HEAD (bb);\n for (;;)\n\t{\n\t rtx attempt, head;\n\t int match_len;\n\n\t if (!past_end && !NONDEBUG_INSN_P (insn))\n\t {\n\t next_insn:\n\t insn = NEXT_INSN (insn);\n\t if (insn == NEXT_INSN (BB_END (bb)))\n\t\tpast_end = true;\n\t continue;\n\t }\n\t if (!past_end && peep2_fill_buffer (bb, insn, live))\n\t goto next_insn;\n\n\t /* If we did not fill an empty buffer, it signals the end of the\n\t block. */\n\t if (peep2_current_count == 0)\n\t break;\n\n\t /* The buffer filled to the current maximum, so try to match. */\n\n\t pos = peep2_buf_position (peep2_current + peep2_current_count);\n\t peep2_insn_data[pos].insn = PEEP2_EOB;\n\t COPY_REG_SET (peep2_insn_data[pos].live_before, live);\n\n\t /* Match the peephole. */\n\t head = peep2_insn_data[peep2_current].insn;\n\t attempt = peephole2_insns (PATTERN (head), head, &match_len);\n\t if (attempt != NULL)\n\t {\n\t rtx last = peep2_attempt (bb, head, match_len, attempt);\n\t if (last)\n\t\t{\n\t\t peep2_update_life (bb, match_len, last, PREV_INSN (attempt));\n\t\t continue;\n\t\t}\n\t }\n\n\t /* No match: advance the buffer by one insn. */\n\t peep2_current = peep2_buf_position (peep2_current + 1);\n\t peep2_current_count--;\n\t}\n }\n\n default_rtl_profile ();\n for (i = 0; i < MAX_INSNS_PER_PEEP2 + 1; ++i)\n BITMAP_FREE (peep2_insn_data[i].live_before);\n BITMAP_FREE (live);\n if (peep2_do_rebuild_jump_labels)\n rebuild_jump_labels (get_insns ());\n}", "label": 0, "cwe": null, "length": 666 }, { "index": 788941, "code": "loader_read_child_output(\n char * vgraph_name,\n char * app_name,\n int fd,\n bool error,\n char * buffer_ptr,\n char ** buffer_ptr_ptr,\n char * last_line,\n unsigned int * last_line_repeat_count)\n{\n ssize_t ret;\n char *char_ptr;\n char *eol_ptr;\n size_t left;\n size_t max_read;\n\n do\n {\n max_read = CLIENT_OUTPUT_BUFFER_SIZE - 1 - (*buffer_ptr_ptr - buffer_ptr);\n ret = read(fd, *buffer_ptr_ptr, max_read);\n if (ret > 0)\n {\n (*buffer_ptr_ptr)[ret] = 0;\n char_ptr = buffer_ptr;\n\n while ((eol_ptr = strchr(char_ptr, '\\n')) != NULL)\n {\n *eol_ptr = 0;\n\n if (*last_line_repeat_count > 0 && strcmp(last_line, char_ptr) == 0)\n {\n if (*last_line_repeat_count == 1)\n {\n if (error)\n {\n log_error_plain(\"%s:%s: last stderr line repeating..\", vgraph_name, app_name);\n }\n else\n {\n log_info(\"%s:%s: last stdout line repeating...\", vgraph_name, app_name);\n }\n }\n\n (*last_line_repeat_count)++;\n }\n else\n {\n loader_check_line_repeat_end(vgraph_name, app_name, error, *last_line_repeat_count);\n\n strcpy(last_line, char_ptr);\n *last_line_repeat_count = 1;\n\n if (error)\n {\n log_error_plain(\"%s:%s: %s\", vgraph_name, app_name, char_ptr);\n }\n else\n {\n log_info(\"%s:%s: %s\", vgraph_name, app_name, char_ptr);\n }\n }\n\n char_ptr = eol_ptr + 1;\n }\n\n left = ret - (char_ptr - *buffer_ptr_ptr);\n if (left != 0)\n {\n /* last line does not end with newline */\n\n if (left == CLIENT_OUTPUT_BUFFER_SIZE - 1)\n {\n /* line is too long to fit in buffer */\n /* print it like it is, rest (or more) of it will be logged on next interation */\n\n if (error)\n {\n log_error_plain(\"%s:%s: %s \" ANSI_RESET ANSI_COLOR_RED \"(truncated) \" ANSI_RESET, vgraph_name, app_name, char_ptr);\n }\n else\n {\n log_info(\"%s:%s: %s \" ANSI_RESET ANSI_COLOR_RED \"(truncated) \" ANSI_RESET, vgraph_name, app_name, char_ptr);\n }\n\n left = 0;\n }\n else\n {\n memmove(buffer_ptr, char_ptr, left);\n }\n }\n\n *buffer_ptr_ptr = buffer_ptr + left;\n }\n }\n while (ret == max_read); /* if we have read everything as much as we can, then maybe there is more to read */\n}", "label": 0, "cwe": null, "length": 646 }, { "index": 42369, "code": "min_op (GelCtx *ctx, GelETree * * a, gboolean *exception)\n{\n\tGelETree *min = NULL;\n\tint i;\n\tif (a[1] == NULL) {\n\t\tif (a[0]->type == GEL_MATRIX_NODE) {\n\t\t\tint j, w, h;\n\t\t\tif ( ! gel_is_matrix_value_only (a[0]->mat.matrix)) {\n\t\t\t\tgel_errorout (_(\"%s: matrix argument must be value only\"),\n\t\t\t\t\t \"min\");\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tw = gel_matrixw_width (a[0]->mat.matrix);\n\t\t\th = gel_matrixw_height (a[0]->mat.matrix);\n\t\t\tfor (i = 0; i < w; i++) {\n\t\t\t\tfor (j = 0; j < h; j++) {\n\t\t\t\t\tGelETree *n = gel_matrixw_index (a[0]->mat.matrix, i, j);\n\t\t\t\t\tif (min == NULL) {\n\t\t\t\t\t\tmin = n;\n\t\t\t\t\t} else if (min != n) {\n\t\t\t\t\t\tif (mpw_cmp (n->val.value, min->val.value) < 0)\n\t\t\t\t\t\t\tmin = n;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tg_assert (min != NULL);\n\t\t\treturn gel_copynode (min);\n\t\t} else if (a[0]->type == GEL_VALUE_NODE) {\n\t\t\t/*\n\t\t\t * Evil optimization to avoid copying the node from the argument\n\t\t\t */\n\t\t\treturn gel_stealnode (a[0]);\n\t\t}\n\t}\n\n\t/* FIXME: optimize value only case */\n\n\t/* kind of a quick hack follows */\n\tmin = a[0];\n\tfor (i = 1; a[i] != NULL; i++) {\n\t\t/* at least ONE iteration will be run */\n\t\tGelETree *argv[2] = { min, a[i] };\n\t\tGelETree *res;\n\t\tres = min2_op (ctx, argv, exception);\n\t\tif (res == NULL) {\n\t\t\tif (min != a[0])\n\t\t\t\tgel_freetree (min);\n\t\t\treturn NULL;\n\t\t}\n\t\tif (min != a[0])\n\t\t\tgel_freetree (min);\n\t\tmin = res;\n\t}\n\tif (min == a[0])\n\t\t/*\n\t\t * Evil optimization to avoid copying the node from the argument\n\t\t */\n\t\treturn gel_stealnode (a[0]);\n\telse\n\t\treturn min;\n}", "label": 0, "cwe": null, "length": 515 }, { "index": 431823, "code": "deps_join (struct deps_desc *succ_deps, struct deps_desc *pred_deps)\n{\n unsigned reg;\n reg_set_iterator rsi;\n\n /* The reg_last lists are inherited by successor. */\n EXECUTE_IF_SET_IN_REG_SET (&pred_deps->reg_last_in_use, 0, reg, rsi)\n {\n struct deps_reg *pred_rl = &pred_deps->reg_last[reg];\n struct deps_reg *succ_rl = &succ_deps->reg_last[reg];\n\n succ_rl->uses = concat_INSN_LIST (pred_rl->uses, succ_rl->uses);\n succ_rl->sets = concat_INSN_LIST (pred_rl->sets, succ_rl->sets);\n succ_rl->implicit_sets\n\t= concat_INSN_LIST (pred_rl->implicit_sets, succ_rl->implicit_sets);\n succ_rl->clobbers = concat_INSN_LIST (pred_rl->clobbers,\n succ_rl->clobbers);\n succ_rl->uses_length += pred_rl->uses_length;\n succ_rl->clobbers_length += pred_rl->clobbers_length;\n }\n IOR_REG_SET (&succ_deps->reg_last_in_use, &pred_deps->reg_last_in_use);\n\n /* Mem read/write lists are inherited by successor. */\n concat_insn_mem_list (pred_deps->pending_read_insns,\n pred_deps->pending_read_mems,\n &succ_deps->pending_read_insns,\n &succ_deps->pending_read_mems);\n concat_insn_mem_list (pred_deps->pending_write_insns,\n pred_deps->pending_write_mems,\n &succ_deps->pending_write_insns,\n &succ_deps->pending_write_mems);\n\n succ_deps->pending_jump_insns\n = concat_INSN_LIST (pred_deps->pending_jump_insns,\n succ_deps->pending_jump_insns);\n succ_deps->last_pending_memory_flush\n = concat_INSN_LIST (pred_deps->last_pending_memory_flush,\n succ_deps->last_pending_memory_flush);\n\n succ_deps->pending_read_list_length += pred_deps->pending_read_list_length;\n succ_deps->pending_write_list_length += pred_deps->pending_write_list_length;\n succ_deps->pending_flush_length += pred_deps->pending_flush_length;\n\n /* last_function_call is inherited by successor. */\n succ_deps->last_function_call\n = concat_INSN_LIST (pred_deps->last_function_call,\n succ_deps->last_function_call);\n\n /* last_function_call_may_noreturn is inherited by successor. */\n succ_deps->last_function_call_may_noreturn\n = concat_INSN_LIST (pred_deps->last_function_call_may_noreturn,\n succ_deps->last_function_call_may_noreturn);\n\n /* sched_before_next_call is inherited by successor. */\n succ_deps->sched_before_next_call\n = concat_INSN_LIST (pred_deps->sched_before_next_call,\n succ_deps->sched_before_next_call);\n}", "label": 0, "cwe": null, "length": 620 }, { "index": 78126, "code": "soap_server(void* arg)\n{\n SMSCConn* conn = (SMSCConn*)arg;\n PrivData* privdata = conn->data;\n /* PrivData* privdata = (PrivData*)arg; */\n\n HTTPClient* remote_client = NULL;\n List *request_headers = NULL, *response_headers = NULL;\n List *cgivars = NULL;\n Octstr *client_ip = NULL, *request_uri = NULL, *request_body = NULL;\n Octstr *response_body = NULL;\n Octstr *timebuf = NULL;\n int http_response_status;\n\n debug(\"bb.soap.server\",0,\"SOAP[%s]: Server starting\", \n octstr_get_cstr(privdata->name));\n\n /* create basic headers */\n response_headers = http_create_empty_headers();\n http_header_add(response_headers, \"Content-type\",\"text/xml\");\n /* http_header_add(response_headers, \"Content-type\",\"application/x-www-form-urlencoded\"); */\n /* http_header_add(response_headers,\"Connection\", \"Close\"); */\n http_header_add(response_headers, \"Server\",\"Kannel\");\n\n while (privdata->soap_server) {\n if ((remote_client = http_accept_request(privdata->port,\n &client_ip, &request_uri, &request_headers, \n &request_body, &cgivars))) {\n\n debug(\"bb.soap.server\",0,\"SOAP[%s]: server got a request for \"\n \"%s from %s, with body <%s>\", octstr_get_cstr(privdata->name),\n octstr_get_cstr(request_uri),octstr_get_cstr(client_ip),\n request_body ? octstr_get_cstr(request_body) : \"\");\n\n /* parse request */\n if (!octstr_compare(request_uri,octstr_imm(SOAP_MO_URI))) {\n /* this is an incoming MO */\n if ((http_response_status = \n soap_parse_mo(conn,request_body, &response_body)) == -1) {\n /* fatal error parsing MO */\n error(0,\"SOAP[%s]: fatal error parsing MO\", \n octstr_get_cstr(privdata->name));\n response_body = octstr_create(SOAP_ERROR_MO_MESSAGE);\n http_response_status = SOAP_ERROR_MO_CODE;\n }\n } else if (!octstr_compare(request_uri,octstr_imm(SOAP_DLR_URI))) {\n /* a delivery report */\n if ((http_response_status = \n soap_parse_dlr(conn,request_body, &response_body)) == -1) {\n /* fatal error parsing MO */\n error(0,\"SOAP[%s]: fatal error parsing DLR\", \n octstr_get_cstr(privdata->name));\n response_body = octstr_create(SOAP_ERROR_DLR_MESSAGE);\n http_response_status = SOAP_ERROR_DLR_CODE;\n }\n } else {\n /* unknown command send default message */\n response_body = octstr_create(SOAP_DEFAULT_MESSAGE);\n http_response_status = SOAP_DEFAULT_CODE;\n }\n\n /* create response */\n /*\n response_body = octstr_create(\"\\n\"\n \"\\n\"\n \"\\n\"\n \" 447951718145\\n\"\n \" 22/01/2002:15:12\\n\"\n \" 00\\n\"\n \"\\n\");\n */\n\n /* encode date in headers */\n\n timebuf = date_format_http(time(NULL));\n /* http_header_add(response_headers, \"Date\", octstr_get_cstr(timebuf)); */\n O_DESTROY(timebuf);\n /* http_header_dump(response_headers); */\n\n /* send response back to client */\n http_send_reply(remote_client,http_response_status,response_headers, response_body);\n\n /* destroy response data */\n /* http_destroy_headers(response_headers); */\n O_DESTROY(response_body);\n\n /* destroy request data */\n O_DESTROY(request_uri);\n O_DESTROY(request_body);\n O_DESTROY(client_ip);\n\n http_destroy_headers(request_headers);\n gwlist_destroy(cgivars, NULL);\n }\n\n gwthread_sleep(SOAP_SLEEP_TIME);\n }\n\n debug(\"bb.soap.server\",0,\"SOAP[%s]: server going down\", \n octstr_get_cstr(privdata->name));\n /* privdata->server_thread = 0; */\n}", "label": 0, "cwe": null, "length": 955 }, { "index": 692286, "code": "consumer_connection_extension_relinquish_exclusive_access(void* conn, PRUint64 connid, int opid, PRBool force)\n{\n int ret = 0;\n \n /* step 1, grab the connext */\n consumer_connection_extension* connext = (consumer_connection_extension*)\n repl_con_get_ext(REPL_CON_EXT_CONN, conn);\n \n if (NULL != connext)\n {\n /* step 2, acquire its lock */\n PR_Lock(connext->lock);\n\n /* step 3, see if it is in use */\n if (0 > connext->in_use_opid)\n {\n slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, \n \"conn=%\" NSPRIu64 \" op=%d Consumer connection extension is not in use\\n\",\n (long long unsigned int)connid, opid);\n ret = 2;\n }\n else if (opid == connext->in_use_opid)\n {\n /* step 4, relinquish it (normal) */\n slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, \n \"conn=%\" NSPRIu64 \" op=%d Relinquishing consumer connection extension\\n\",\n (long long unsigned int)connid, opid);\n connext->in_use_opid = -1;\n ret = 1;\n }\n else if (force)\n {\n /* step 4, relinquish it (forced) */\n slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, \n \"conn=%\" NSPRIu64 \" op=%d Forced to relinquish consumer connection extension held by op=%d\\n\",\n (long long unsigned int)connid, opid, connext->in_use_opid);\n connext->in_use_opid = -1;\n ret = 1;\n }\n else\n {\n slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, \n \"conn=%\" NSPRIu64 \" op=%d Not relinquishing consumer connection extension, it is held by op=%d!\\n\",\n (long long unsigned int)connid, opid, connext->in_use_opid);\n }\n \n /* step 5, drop the lock */\n PR_Unlock(connext->lock);\n }\n else\n {\n slapi_log_error(SLAPI_LOG_REPL, repl_plugin_name, \n \"conn=%\" NSPRIu64 \" op=%d Could not relinquish consumer extension, it is NULL!\\n\",\n (long long unsigned int)connid, opid);\n }\n \n return ret;\n}", "label": 0, "cwe": null, "length": 566 }, { "index": 912755, "code": "initialize_super_blocks() {\n\tint* super_buffer;\n\tint i;\n\tsuper_buffer = (int*)malloc(sizeof(int)*BUFFER_SIZE);\n\t\n\t/* marking all data blocks as free */\n\tsuper->block_freelist[0] = EFFS_ROOT_CHECKSUM; // because r00t iZ l33t\n\n\tfor (i=1; i < data_block_size; i++)\n\t\tsuper->block_freelist[i] = FREE;\n\t\n\t/* marking first inode as root and rest as free */\n\tsuper->inode_freelist[0] = OCCUPIED;\n\tfor (i=1; i < num_of_inodes; i++)\n\t\tsuper->inode_freelist[i] = FREE;\n\t\n\t/***** WRITING SUPER BLOCK TO FISK *****/\n\t/***** WRITING SUPER BLOCK TO FISK *****/\n\t\n\tint blocknr = 0; // keeps track of fisk block to write to\n\tint count = 0; // keeps track of buffer position\n\n\t/* loads one full block (256 ints per 1 block) to buffer and writes to fisk */\n\tfor (i=0; i < data_block_size; i++)\n\t{\n\t\tsuper_buffer[count++] = super->block_freelist[i];\t\t\n\t\tif ( (count % 256 == 0) && (count != 0) ) {\n\t\t\twriteBlock(fisky, blocknr, super_buffer);\t\t\n\t\t\tblocknr++;\n\t\t\tcount = 0;\n\t\t}\n\t}\n\t\n\tfor (i=0; i < num_of_inodes; i++) {\n\t\tsuper_buffer[count++] = super->inode_freelist[i];\n\t\tif ( (count % 256 == 0) && (count != 0) ) {\n\t\t\twriteBlock(fisky, blocknr, super_buffer);\t\t\n\t\t\tblocknr++;\n\t\t\tcount = 0;\n\t\t}\n\t}\n\t\n\tif (count <= 254) {\n\t\tsuper_buffer[count++] = super->free_data_space;\n\t\tsuper_buffer[count++] = super->rootinode;\n\n\t\t/* clearing the rest of buffer for SANITY's sake */\n\t\tfor (i = count; i < 256; ++i)\n\t\t\tsuper_buffer[i] = 0;\n\n\t\twriteBlock(fisky, blocknr, super_buffer);\n\t} else if (count == 255) {\n\t\tsuper_buffer[count++] = super->free_data_space;\n\t\twriteBlock(fisky, blocknr, super_buffer);\n\t\tcount = 0;\n\t\tblocknr++;\n\t\tsuper_buffer[count++] = super->rootinode;\n\n\t\t/* clearing the rest of buffer for SANITY's sake */\n\t\tfor (i = count; i < 256; ++i)\n\t\t\tsuper_buffer[i] = 0;\n\n\t\twriteBlock(fisky, blocknr, super_buffer);\n\t}\n}", "label": 0, "cwe": null, "length": 570 }, { "index": 82731, "code": "Java_org_gdal_gdal_gdalJNI_Band_1WriteRaster_1_1SWIG_114(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jint jarg2, jint jarg3, jint jarg4, jint jarg5, jint jarg6, jint jarg7, jint jarg8, jdoubleArray jarg9) {\n jint jresult = 0 ;\n GDALRasterBandShadow *arg1 = (GDALRasterBandShadow *) 0 ;\n int arg2 ;\n int arg3 ;\n int arg4 ;\n int arg5 ;\n int arg6 ;\n int arg7 ;\n GDALDataType arg8 ;\n double *arg9 = (double *) 0 ;\n long arg10 ;\n CPLErr result;\n \n (void)jenv;\n (void)jcls;\n (void)jarg1_;\n arg1 = *(GDALRasterBandShadow **)&jarg1; \n arg2 = (int)jarg2; \n arg3 = (int)jarg3; \n arg4 = (int)jarg4; \n arg5 = (int)jarg5; \n arg6 = (int)jarg6; \n arg7 = (int)jarg7; \n arg8 = (GDALDataType)jarg8; \n {\n /* %typemap(in, numinputs=1) (double *regularArrayIn, long nRegularArraySizeIn) */\n if (jarg9 == 0)\n {\n SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, \"null array\");\n return 0;\n }\n \n arg10 = sizeof(double) * jenv->GetArrayLength(jarg9);\n arg9 = (double*) jenv->GetDoubleArrayElements(jarg9, 0);\n if (arg9 == NULL)\n {\n SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException, \n \"Unable to get buffer.\");\n return 0;\n }\n }\n result = (CPLErr)GDALRasterBandShadow_WriteRaster__SWIG_12(arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9,arg10);\n jresult = (jint)result; \n {\n /* %typemap(freearg) (double *regularArrayIn, long nRegularArraySizeIn) */\n jenv->ReleaseDoubleArrayElements(jarg9, (jdouble*) arg9, JNI_ABORT);\n }\n return jresult;\n}", "label": 0, "cwe": null, "length": 560 }, { "index": 538680, "code": "del_sig(dns_db_t *db, dns_dbversion_t *version, dns_name_t *name,\n\tdns_dbnode_t *node, unsigned int nkeys, dns_secalg_t algorithm,\n\tisc_uint16_t keyid, dns_diff_t *diff)\n{\n\tdns_rdata_rrsig_t rrsig;\n\tdns_rdataset_t rdataset;\n\tdns_rdatasetiter_t *iterator = NULL;\n\tisc_result_t result;\n\n\tresult = dns_db_allrdatasets(db, node, version, 0, &iterator);\n\tif (result != ISC_R_SUCCESS) {\n\t\tif (result == ISC_R_NOTFOUND)\n\t\t\tresult = ISC_R_SUCCESS;\n\t\treturn (result);\n\t}\n\n\tdns_rdataset_init(&rdataset);\n\tfor (result = dns_rdatasetiter_first(iterator);\n\t result == ISC_R_SUCCESS;\n\t result = dns_rdatasetiter_next(iterator)) {\n\t\tdns_rdatasetiter_current(iterator, &rdataset);\n\t\tif (nkeys == 0 && rdataset.type == dns_rdatatype_nsec) {\n\t\t\tfor (result = dns_rdataset_first(&rdataset);\n\t\t\t result == ISC_R_SUCCESS;\n\t\t\t result = dns_rdataset_next(&rdataset)) {\n\t\t\t\tdns_rdata_t rdata = DNS_RDATA_INIT;\n\t\t\t\tdns_rdataset_current(&rdataset, &rdata);\n\t\t\t\tCHECK(update_one_rr(db, version, diff,\n\t\t\t\t\t\t DNS_DIFFOP_DEL, name,\n\t\t\t\t\t\t rdataset.ttl, &rdata));\n\t\t\t}\n\t\t\tif (result != ISC_R_NOMORE)\n\t\t\t\tgoto failure;\n\t\t\tdns_rdataset_disassociate(&rdataset);\n\t\t\tcontinue;\n\t\t}\n\t\tif (rdataset.type != dns_rdatatype_rrsig) {\n\t\t\tdns_rdataset_disassociate(&rdataset);\n\t\t\tcontinue;\n\t\t}\n\t\tfor (result = dns_rdataset_first(&rdataset);\n\t\t result == ISC_R_SUCCESS;\n\t\t result = dns_rdataset_next(&rdataset)) {\n\t\t\tdns_rdata_t rdata = DNS_RDATA_INIT;\n\t\t\tdns_rdataset_current(&rdataset, &rdata);\n\t\t\tCHECK(dns_rdata_tostruct(&rdata, &rrsig, NULL));\n\t\t\tif (rrsig.algorithm != algorithm ||\n\t\t\t rrsig.keyid != keyid)\n\t\t\t\tcontinue;\n\t\t\tCHECK(update_one_rr(db, version, diff,\n\t\t\t\t\t DNS_DIFFOP_DELRESIGN, name,\n\t\t\t\t\t rdataset.ttl, &rdata));\n\t\t}\n\t\tdns_rdataset_disassociate(&rdataset);\n\t\tif (result != ISC_R_NOMORE)\n\t\t\tbreak;\n\t}\n\tif (result == ISC_R_NOMORE)\n\t\tresult = ISC_R_SUCCESS;\n failure:\n\tif (dns_rdataset_isassociated(&rdataset))\n\t\tdns_rdataset_disassociate(&rdataset);\n\tdns_rdatasetiter_destroy(&iterator);\n\treturn (result);\n}", "label": 0, "cwe": null, "length": 587 }, { "index": 742151, "code": "GDALRegister_netCDF()\n\n{\n if (! GDAL_CHECK_VERSION(\"netCDF driver\"))\n return;\n\n if( GDALGetDriverByName( \"netCDF\" ) == NULL )\n {\n GDALDriver\t*poDriver;\n char szCreateOptions[3072];\n\n poDriver = new GDALDriver( );\n\n/* -------------------------------------------------------------------- */\n/* Build full creation option list. */\n/* -------------------------------------------------------------------- */\n sprintf( szCreateOptions, \"%s\", \n\"\"\n\" \"\n#ifdef NETCDF_HAS_NC4\n\" \"\n\" \"\n\" \"\n\" \"\n\" \"\n\" \"\n\" \"\n\"\" );\n\n \n/* -------------------------------------------------------------------- */\n/* Set the driver details. */\n/* -------------------------------------------------------------------- */\n poDriver->SetDescription( \"netCDF\" );\n poDriver->SetMetadataItem( GDAL_DMD_LONGNAME, \n \"Network Common Data Format\" );\n poDriver->SetMetadataItem( GDAL_DMD_HELPTOPIC, \n \"frmt_netcdf.html\" );\n poDriver->SetMetadataItem( GDAL_DMD_EXTENSION, \"nc\" );\n poDriver->SetMetadataItem( GDAL_DMD_CREATIONOPTIONLIST, \n szCreateOptions );\n poDriver->SetMetadataItem( GDAL_DMD_SUBDATASETS, \"YES\" );\n\n /* make driver config and capabilities available */\n poDriver->SetMetadataItem( \"NETCDF_VERSION\", nc_inq_libvers() );\n poDriver->SetMetadataItem( \"NETCDF_CONVENTIONS\", NCDF_CONVENTIONS_CF );\n#ifdef NETCDF_HAS_NC2\n poDriver->SetMetadataItem( \"NETCDF_HAS_NC2\", \"YES\" );\n#endif\n#ifdef NETCDF_HAS_NC4\n poDriver->SetMetadataItem( \"NETCDF_HAS_NC4\", \"YES\" );\n#endif\n#ifdef NETCDF_HAS_HDF4\n poDriver->SetMetadataItem( \"NETCDF_HAS_HDF4\", \"YES\" );\n#endif\n#ifdef HAVE_HDF4\n poDriver->SetMetadataItem( \"GDAL_HAS_HDF4\", \"YES\" );\n#endif\n#ifdef HAVE_HDF5\n poDriver->SetMetadataItem( \"GDAL_HAS_HDF5\", \"YES\" );\n#endif\n \n /* set pfns and register driver */\n poDriver->pfnOpen = netCDFDataset::Open;\n poDriver->pfnCreateCopy = netCDFDataset::CreateCopy;\n poDriver->pfnCreate = netCDFDataset::Create;\n poDriver->pfnIdentify = netCDFDataset::Identify;\n poDriver->pfnUnloadDriver = NCDFUnloadDriver;\n\n GetGDALDriverManager( )->RegisterDriver( poDriver );\n }\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 935 }, { "index": 16908, "code": "tcl_console STDVAR\n{\n int i, j, pls, arg;\n module_entry *me;\n\n BADARGS(2, 4, \" idx ?channel? ?console-modes?\");\n\n i = findidx(atoi(argv[1]));\n if (i < 0 || dcc[i].type != &DCC_CHAT) {\n Tcl_AppendResult(irp, \"invalid idx\", NULL);\n return TCL_ERROR;\n }\n pls = 1;\n\n for (arg = 2; arg < argc; arg++) {\n if (argv[arg][0] && ((strchr(CHANMETA, argv[arg][0]) != NULL) ||\n (argv[arg][0] == '*'))) {\n if ((argv[arg][0] != '*') && (!findchan_by_dname(argv[arg]))) {\n /* If we dont find the channel, and it starts with a +, assume it\n * should be the console flags to set. */\n if (argv[arg][0] == '+')\n goto do_console_flags;\n Tcl_AppendResult(irp, \"invalid channel\", NULL);\n return TCL_ERROR;\n }\n strncpyz(dcc[i].u.chat->con_chan, argv[arg], 81);\n } else {\n if ((argv[arg][0] != '+') && (argv[arg][0] != '-'))\n dcc[i].u.chat->con_flags = 0;\n do_console_flags:\n for (j = 0; j < strlen(argv[arg]); j++) {\n if (argv[arg][j] == '+')\n pls = 1;\n else if (argv[arg][j] == '-')\n pls = -1;\n else {\n char s[2];\n\n s[0] = argv[arg][j];\n s[1] = 0;\n if (pls == 1)\n dcc[i].u.chat->con_flags |= logmodes(s);\n else\n dcc[i].u.chat->con_flags &= ~logmodes(s);\n }\n }\n }\n }\n Tcl_AppendElement(irp, dcc[i].u.chat->con_chan);\n Tcl_AppendElement(irp, masktype(dcc[i].u.chat->con_flags));\n /* Console autosave. */\n if (argc > 2 && (me = module_find(\"console\", 1, 1))) {\n Function *func = me->funcs;\n\n (func[CONSOLE_DOSTORE]) (i);\n }\n return TCL_OK;\n}", "label": 0, "cwe": null, "length": 529 }, { "index": 975839, "code": "bdf_save_options(FILE *out, bdf_options_t *opts)\n#else\nbdf_save_options(out, opts)\nFILE *out;\nbdf_options_t *opts;\n#endif\n{\n unsigned long i;\n\n if (out == 0 || opts == 0)\n return;\n\n fprintf(out, \"#\\n# Metrics corrections.\\n#\\ncorrect_metrics \");\n if (opts->correct_metrics)\n fprintf(out, \"true\\n\\n\");\n else\n fprintf(out, \"false\\n\\n\");\n\n fprintf(out, \"#\\n# Preserve unencoded glyphs.\\n#\\nkeep_unencoded \");\n if (opts->keep_unencoded)\n fprintf(out, \"true\\n\\n\");\n else\n fprintf(out, \"false\\n\\n\");\n\n fprintf(out, \"#\\n# Preserve comments.\\n#\\nkeep_comments \");\n if (opts->keep_comments)\n fprintf(out, \"true\\n\\n\");\n else\n fprintf(out, \"false\\n\\n\");\n\n fprintf(out, \"#\\n# Pad character cells.\\n#\\npad_character_cells \");\n if (opts->pad_cells)\n fprintf(out, \"true\\n\\n\");\n else\n fprintf(out, \"false\\n\\n\");\n\n fprintf(out, \"#\\n# Font spacing.\\n#\\nfont_spacing \");\n switch (opts->font_spacing) {\n case BDF_PROPORTIONAL: fprintf(out, \"proportional\\n\\n\"); break;\n case BDF_MONOWIDTH: fprintf(out, \"monowidth\\n\\n\"); break;\n case BDF_CHARCELL: fprintf(out, \"charactercell\\n\\n\"); break;\n }\n\n fprintf(out, \"#\\n# Point size.\\n#\\npoint_size %ld\\n\\n\", opts->point_size);\n\n fprintf(out,\n \"#\\n# Horizontal resolution.\\n#\\nhorizontal_resolution %ld\\n\\n\",\n opts->resolution_x);\n\n fprintf(out,\n \"#\\n# Vertical resolution.\\n#\\nvertical_resolution %ld\\n\\n\",\n opts->resolution_x);\n\n fprintf(out,\n \"#\\n# Bits per pixel.\\n#\\nbits_per_pixel %d\\n\\n\",\n opts->bits_per_pixel);\n\n fprintf(out, \"#\\n# Hint TrueType glyphs.\\n#\\nhint_truetype_glyphs \");\n if (opts->ttf_hint)\n fprintf(out, \"true\\n\\n\");\n else\n fprintf(out, \"false\\n\\n\");\n\n fprintf(out, \"#\\n# Set the EOL used when writing BDF fonts.\\n#\\neol \");\n switch (opts->eol) {\n case BDF_UNIX_EOL: fprintf(out, \"unix\\n\\n\"); break;\n case BDF_DOS_EOL: fprintf(out, \"dos\\n\\n\"); break;\n case BDF_MAC_EOL: fprintf(out, \"mac\\n\\n\"); break;\n }\n\n /*\n * Write out the user defined properties if they exist.\n */\n if (nuser_props == 0)\n return;\n\n fprintf(out, \"#\\n# User defined properties.\\n#\\n\");\n\n for (i = 0; i < nuser_props; i++) {\n fprintf(out, \"property %s \", user_props[i].name);\n switch (user_props[i].format) {\n case BDF_ATOM: fprintf(out, \"atom\\n\"); break;\n case BDF_CARDINAL: fprintf(out, \"cardinal\\n\"); break;\n case BDF_INTEGER: fprintf(out, \"integer\\n\"); break;\n }\n }\n}", "label": 0, "cwe": null, "length": 729 }, { "index": 20766, "code": "ath10k_vdev_start_restart(struct ath10k_vif *arvif,\n\t\t\t\t const struct cfg80211_chan_def *chandef,\n\t\t\t\t bool restart)\n{\n\tstruct ath10k *ar = arvif->ar;\n\tstruct wmi_vdev_start_request_arg arg = {};\n\tint ret = 0;\n\n\tlockdep_assert_held(&ar->conf_mutex);\n\n\treinit_completion(&ar->vdev_setup_done);\n\n\targ.vdev_id = arvif->vdev_id;\n\targ.dtim_period = arvif->dtim_period;\n\targ.bcn_intval = arvif->beacon_interval;\n\n\targ.channel.freq = chandef->chan->center_freq;\n\targ.channel.band_center_freq1 = chandef->center_freq1;\n\targ.channel.mode = chan_to_phymode(chandef);\n\n\targ.channel.min_power = 0;\n\targ.channel.max_power = chandef->chan->max_power * 2;\n\targ.channel.max_reg_power = chandef->chan->max_reg_power * 2;\n\targ.channel.max_antenna_gain = chandef->chan->max_antenna_gain * 2;\n\n\tif (arvif->vdev_type == WMI_VDEV_TYPE_AP) {\n\t\targ.ssid = arvif->u.ap.ssid;\n\t\targ.ssid_len = arvif->u.ap.ssid_len;\n\t\targ.hidden_ssid = arvif->u.ap.hidden_ssid;\n\n\t\t/* For now allow DFS for AP mode */\n\t\targ.channel.chan_radar =\n\t\t\t!!(chandef->chan->flags & IEEE80211_CHAN_RADAR);\n\t} else if (arvif->vdev_type == WMI_VDEV_TYPE_IBSS) {\n\t\targ.ssid = arvif->vif->bss_conf.ssid;\n\t\targ.ssid_len = arvif->vif->bss_conf.ssid_len;\n\t}\n\n\tath10k_dbg(ar, ATH10K_DBG_MAC,\n\t\t \"mac vdev %d start center_freq %d phymode %s\\n\",\n\t\t arg.vdev_id, arg.channel.freq,\n\t\t ath10k_wmi_phymode_str(arg.channel.mode));\n\n\tif (restart)\n\t\tret = ath10k_wmi_vdev_restart(ar, &arg);\n\telse\n\t\tret = ath10k_wmi_vdev_start(ar, &arg);\n\n\tif (ret) {\n\t\tath10k_warn(ar, \"failed to start WMI vdev %i: %d\\n\",\n\t\t\t arg.vdev_id, ret);\n\t\treturn ret;\n\t}\n\n\tret = ath10k_vdev_setup_sync(ar);\n\tif (ret) {\n\t\tath10k_warn(ar,\n\t\t\t \"failed to synchronize setup for vdev %i restart %d: %d\\n\",\n\t\t\t arg.vdev_id, restart, ret);\n\t\treturn ret;\n\t}\n\n\tar->num_started_vdevs++;\n\tath10k_recalc_radar_detection(ar);\n\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 617 }, { "index": 117614, "code": "_ell_3m2sub_evecs_d(double evec[9], double eval[3], int roots,\n const double m[9]) {\n double n[4];\n static const char me[]=\"_ell_3m2sub_evecs_d\";\n\n if (ell_cubic_root_three == roots) {\n /* set off-diagonal entries once */\n n[1] = m[1];\n n[2] = m[3];\n /* find first evec */\n n[0] = m[0] - eval[0];\n n[3] = m[3] - eval[0];\n ell_2m_1d_nullspace_d(evec + 3*0, n);\n (evec + 3*0)[2] = 0;\n /* find second evec */\n n[0] = m[0] - eval[1];\n n[3] = m[3] - eval[1];\n ell_2m_1d_nullspace_d(evec + 3*1, n);\n (evec + 3*1)[2] = 0;\n _ell_22v_enforce_orthogonality(evec + 3*0, evec + 3*1);\n /* make right-handed */\n ELL_3V_CROSS(evec + 3*2, evec + 3*0, evec + 3*1);\n } else if (ell_cubic_root_single_double == roots) {\n /* can pick any 2D basis */\n ELL_3V_SET(evec + 3*0, 1, 0, 0);\n ELL_3V_SET(evec + 3*1, 0, 1, 0);\n ELL_3V_SET(evec + 3*2, 0, 0, 1);\n } else {\n /* ell_cubic_root_single == roots, if assumptions are met */\n ELL_3V_SET(evec + 3*0, AIR_NAN, AIR_NAN, 0);\n ELL_3V_SET(evec + 3*1, AIR_NAN, AIR_NAN, 0);\n ELL_3V_SET(evec + 3*2, 0, 0, 1);\n }\n if (!ELL_3M_EXISTS(evec)) {\n fprintf(stderr, \"%s: given m = \\n\", me);\n ell_3m_print_d(stderr, m);\n fprintf(stderr, \"%s: got roots = %s (%d) and evecs = \\n\", me,\n airEnumStr(ell_cubic_root, roots), roots);\n ell_3m_print_d(stderr, evec);\n }\n return;\n}", "label": 0, "cwe": null, "length": 600 }, { "index": 722902, "code": "lkkbd_connect(struct serio *serio, struct serio_driver *drv)\n{\n\tstruct lkkbd *lk;\n\tstruct input_dev *input_dev;\n\tint i;\n\tint err;\n\n\tlk = kzalloc(sizeof(struct lkkbd), GFP_KERNEL);\n\tinput_dev = input_allocate_device();\n\tif (!lk || !input_dev) {\n\t\terr = -ENOMEM;\n\t\tgoto fail1;\n\t}\n\n\tlk->serio = serio;\n\tlk->dev = input_dev;\n\tINIT_WORK(&lk->tq, lkkbd_reinit);\n\tlk->bell_volume = bell_volume;\n\tlk->keyclick_volume = keyclick_volume;\n\tlk->ctrlclick_volume = ctrlclick_volume;\n\tmemcpy(lk->keycode, lkkbd_keycode, sizeof(lk->keycode));\n\n\tstrlcpy(lk->name, \"DEC LK keyboard\", sizeof(lk->name));\n\tsnprintf(lk->phys, sizeof(lk->phys), \"%s/input0\", serio->phys);\n\n\tinput_dev->name = lk->name;\n\tinput_dev->phys = lk->phys;\n\tinput_dev->id.bustype = BUS_RS232;\n\tinput_dev->id.vendor = SERIO_LKKBD;\n\tinput_dev->id.product = 0;\n\tinput_dev->id.version = 0x0100;\n\tinput_dev->dev.parent = &serio->dev;\n\tinput_dev->event = lkkbd_event;\n\n\tinput_set_drvdata(input_dev, lk);\n\n\t__set_bit(EV_KEY, input_dev->evbit);\n\t__set_bit(EV_LED, input_dev->evbit);\n\t__set_bit(EV_SND, input_dev->evbit);\n\t__set_bit(EV_REP, input_dev->evbit);\n\t__set_bit(LED_CAPSL, input_dev->ledbit);\n\t__set_bit(LED_SLEEP, input_dev->ledbit);\n\t__set_bit(LED_COMPOSE, input_dev->ledbit);\n\t__set_bit(LED_SCROLLL, input_dev->ledbit);\n\t__set_bit(SND_BELL, input_dev->sndbit);\n\t__set_bit(SND_CLICK, input_dev->sndbit);\n\n\tinput_dev->keycode = lk->keycode;\n\tinput_dev->keycodesize = sizeof(lk->keycode[0]);\n\tinput_dev->keycodemax = ARRAY_SIZE(lk->keycode);\n\n\tfor (i = 0; i < LK_NUM_KEYCODES; i++)\n\t\t__set_bit(lk->keycode[i], input_dev->keybit);\n\t__clear_bit(KEY_RESERVED, input_dev->keybit);\n\n\tserio_set_drvdata(serio, lk);\n\n\terr = serio_open(serio, drv);\n\tif (err)\n\t\tgoto fail2;\n\n\terr = input_register_device(lk->dev);\n\tif (err)\n\t\tgoto fail3;\n\n\tserio_write(lk->serio, LK_CMD_POWERCYCLE_RESET);\n\n\treturn 0;\n\n fail3:\tserio_close(serio);\n fail2:\tserio_set_drvdata(serio, NULL);\n fail1:\tinput_free_device(input_dev);\n\tkfree(lk);\n\treturn err;\n}", "label": 1, "cwe": "CWE-120", "length": 648 }, { "index": 115104, "code": "correct_url(char **buf,char *protocol)\n{\n\tchar *buftmp;\n\tint len;\n\tint myloop,myloop2;\n\tint pos=-1;\n\tint myok=1;\n\n\tlen=strlen(*buf);\n\tfor (myloop=0;myloop0x39) )\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tmyok=0;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (!myok) pos=myloop;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tmyok=0;\n\n\tif (pos==-1)\n\t{\n\n\t\tGB.Alloc(POINTER(&buftmp),len+1);\n\t\tstrcpy(buftmp,*buf);\n\t\tGB.Free(POINTER(buf));\n\t\tGB.Alloc(POINTER(buf),len+strlen(protocol)+1);\n\t\tstrcpy(*buf,protocol);\n\t\tif (strlen(buftmp)>=2)\n\t\t{\n\t\t\tif ( buftmp[0]=='/') myok++;\n\t\t\tif ( buftmp[1]=='/') myok++;\n\t\t}\n\t\tstrcat(*buf,buftmp+myok);\n\t\tGB.Free(POINTER(&buftmp));\n\t}\n\telse\n\t{\n\t\tGB.Alloc(POINTER(&buftmp),(len-pos)+1);\n\t\tstrcpy(buftmp,*buf+pos+1);\n\t\tGB.Free(POINTER(buf));\n\t\tGB.Alloc(POINTER(buf),strlen(buftmp)+strlen(protocol)+1);\n\t\tstrcpy(*buf,protocol);\n\t\tif (strlen(buftmp)>=2)\n\t\t{\n\t\t\tif ( buftmp[0]=='/') myok++;\n\t\t\tif ( buftmp[1]=='/') myok++;\n\t\t}\n\t\tstrcat(*buf,buftmp+myok);\n\t\tGB.Free(POINTER(&buftmp));\n\t}\n}", "label": 0, "cwe": null, "length": 520 }, { "index": 854580, "code": "P_FallingDamage (edict_t * ent)\n{\n\tfloat delta;\n\tint damage;\n\tvec3_t dir;\n\n\tif (lights_camera_action || ent->client->ctf_uvtime > 0)\n\t\treturn;\n\t\n\tif (ent->s.modelindex != 255)\n\t\treturn;\t\t\t// not in the player model\n\n\tif (ent->movetype == MOVETYPE_NOCLIP)\n\t\treturn;\n\n\tif ((ent->client->oldvelocity[2] < 0)\n\t\t&& (ent->velocity[2] > ent->client->oldvelocity[2])\n\t\t&& (!ent->groundentity))\n\t{\n\t\tdelta = ent->client->oldvelocity[2];\n\t}\n\telse\n\t{\n\t\tif (!ent->groundentity)\n\t\t\treturn;\n\t\tdelta = ent->velocity[2] - ent->client->oldvelocity[2];\n\t\tent->client->jumping = 0;\n\t}\n\tdelta = delta * delta * 0.0001;\n\n\t// never take falling damage if completely underwater\n\tif (ent->waterlevel == 3)\n\t\treturn;\n\telse if (ent->waterlevel == 2)\n\t\tdelta *= 0.25;\n\telse if (ent->waterlevel == 1)\n\t\tdelta *= 0.5;\n\n\tif (delta < 1)\n\t\treturn;\n\n\tif (delta < 15)\n\t{\n\t\t// zucc look for slippers to avoid noise\n\t\tif(!INV_AMMO(ent, SLIP_NUM))\n\t\t\tent->s.event = EV_FOOTSTEP;\n\n\t\treturn;\n\t}\n\n\tent->client->fall_value = delta * 0.5;\n\tif (ent->client->fall_value > 40)\n\t\tent->client->fall_value = 40;\n\tent->client->fall_time = level.time + FALL_TIME;\n\n\tif (delta <= 30)\n\t{\n\t\t//zucc added check for slippers, this is just another noise\n\t\tif(!INV_AMMO(ent, SLIP_NUM))\n\t\t\tent->s.event = EV_FALLSHORT;\n\n\t\treturn;\n\t}\n\n\t/* when fall damage is disabled, play the normal fall sound */\n\tif((int) dmflags->value & DF_NO_FALLING)\n\t{\n\t\tent->s.event = EV_FALLSHORT;\n\t\treturn;\n\t}\n\n\n\tif (ent->health > 0)\n\t{\n\t\tif (delta >= 55)\n\t\t\tent->s.event = EV_FALLFAR;\n\t\telse\t\t\t// all falls are far\n\t\t\tent->s.event = EV_FALLFAR;\n\t}\n\tent->pain_debounce_time = level.time;\t// no normal pain sound\n\n\tif (!deathmatch->value || !((int) dmflags->value & DF_NO_FALLING))\n\t{\n\t\tdamage = (int) (((delta - 30) / 2));\n\t\tif (damage < 1)\n\t\t\tdamage = 1;\n\t\t// zucc scale this up\n\t\tdamage *= 10;\n\t\tVectorSet (dir, 0, 0, 1);\n\t\tT_Damage (ent, world, world, dir, ent->s.origin, vec3_origin,\n\t\t\tdamage, 0, 0, MOD_FALLING);\n\t}\n}", "label": 0, "cwe": null, "length": 664 }, { "index": 941100, "code": "loadXPDataIntoLocal(void)\n{\n\t//\n\t// This function reads the various memeber variables and loads them into\n\t// into the dialog variables.\n\t//\n\n //\n // Block all signals while setting these things\n //\n\tXAP_GtkSignalBlocker b1( G_OBJECT(m_oAlignList_adj), m_iAlignListSpinID);\n\tXAP_GtkSignalBlocker b2( G_OBJECT(m_oIndentAlign_adj), m_iIndentAlignSpinID);\n\n\tXAP_GtkSignalBlocker b3( G_OBJECT(m_wDecimalEntry), m_iDecimalEntryID);\n\tXAP_GtkSignalBlocker b4( G_OBJECT(m_wDelimEntry), m_iDelimEntryID );\n\t//\n\t// HACK to effectively block an update during this method\n\t//\n\tm_bDontUpdate = true;\n\n\tUT_DEBUGMSG((\"loadXP newListType = %d \\n\",getNewListType()));\n\tgtk_spin_button_set_value(GTK_SPIN_BUTTON(m_wAlignListSpin),getfAlign());\n\tfloat indent = getfAlign() + getfIndent();\n\tgtk_spin_button_set_value(GTK_SPIN_BUTTON( m_wIndentAlignSpin),indent);\n\tif( (getfIndent() + getfAlign()) < 0.0)\n\t{\n\t\tsetfIndent( - getfAlign());\n\t\tgtk_spin_button_set_value(GTK_SPIN_BUTTON( m_wIndentAlignSpin), 0.0);\n\n\t}\n\t//\n\t// Code to work out which is active Font\n\t//\n\tif(getFont() == \"NULL\")\n\t{\n\t\tgtk_combo_box_set_active(m_wFontOptions, 0 );\n\t}\n\telse\n\t{\n size_t i = 0;\n\t\tfor(std::vector::const_iterator iter = m_glFonts.begin();\n iter != m_glFonts.end(); ++iter, ++i)\n\t\t{\n\t\t\tif(*iter == getFont())\n\t\t\t\tbreak;\n\t\t}\n if(i < m_glFonts.size())\n\t\t{\n\t\t\tgtk_combo_box_set_active(m_wFontOptions, i + 1 );\n\t\t}\n\t\telse\n\t\t{\n\t\t\tgtk_combo_box_set_active(m_wFontOptions, 0 );\n\t\t}\n\t}\n\tgtk_spin_button_set_value(GTK_SPIN_BUTTON(m_wStartSpin),static_cast(getiStartValue()));\n\n gtk_entry_set_text( GTK_ENTRY(m_wDecimalEntry), getDecimal().c_str());\n\tgtk_entry_set_text( GTK_ENTRY(m_wDelimEntry), getDelim().c_str());\n\n\t//\n\t// Now set the list type and style\n\tFL_ListType save = getNewListType();\n\tif(getNewListType() == NOT_A_LIST)\n\t{\n\t\tstyleChanged(0);\n\t\tsetNewListType(save);\n\t\tgtk_combo_box_set_active(m_wListTypeBox, 0);\n\t\tgtk_combo_box_set_active(m_wListStyleBox, 0);\n\t}\n\telse if(IS_BULLETED_LIST_TYPE(getNewListType()) )\n\t{\n\t\tstyleChanged(1);\n\t\tsetNewListType(save);\n\t\tgtk_combo_box_set_active(m_wListTypeBox, 1);\n\t\tgtk_combo_box_set_active(m_wListStyleBox, (gint) (getNewListType() - BULLETED_LIST));\n\t}\n\telse\n\t{\n\t\tstyleChanged(2);\n\t setNewListType(save);\n\t\tgtk_combo_box_set_active(m_wListTypeBox, 2);\n\t\tif(getNewListType() < OTHER_NUMBERED_LISTS)\n\t\t{\n\t\t\tgtk_combo_box_set_active(m_wListStyleBox, getNewListType());\n\t\t}\n\t\telse\n\t\t{\n\t\t gint iMenu = static_cast(getNewListType()) - OTHER_NUMBERED_LISTS + BULLETED_LIST -1 ;\n\t\t\tgtk_combo_box_set_active(m_wListStyleBox,iMenu);\n\t\t}\n\t}\n\n\t//\n\t// HACK to allow an update during this method\n\t//\n\tm_bDontUpdate = false;\n}", "label": 0, "cwe": null, "length": 820 }, { "index": 257759, "code": "metadata( Meta::TrackPtr track )\n{\n QStringList list;\n if( track )\n {\n bool noTags = false;\n QString title = track->prettyName();\n if(( noTags = title.isEmpty() )) // should not happen\n title = track->prettyUrl();\n if(( noTags = title.isEmpty() )) // should never happen\n title = track->playableUrl().url();\n if(( noTags = title.isEmpty() )) // sth's MEGA wrong ;-)\n title = \"???\";\n\n // no tags -> probably filename. try to strip the suffix\n if( noTags || track->name().isEmpty() )\n {\n noTags = true;\n int dot = title.lastIndexOf('.');\n if( dot > 0 && title.length() - dot < 6 )\n title = title.left( dot );\n }\n\n // the track has no tags, is long or contains tags other than the titlebar\n // ==> separate\n if( noTags || title.length() > 50 ||\n (HAS_TAG(artist) && title.CONTAINS_TAG(artist)) ||\n (HAS_TAG(composer) && title.CONTAINS_TAG(composer)) ||\n (HAS_TAG(album) && title.CONTAINS_TAG(album)) )\n {\n // this will split \"all-in-one\" filename tags\n QRegExp rx(\"(\\\\s+-\\\\s+|\\\\s*;\\\\s*|\\\\s*:\\\\s*)\");\n list << title.split( rx, QString::SkipEmptyParts );\n QList::iterator i = list.begin();\n bool ok;\n while ( i != list.end() )\n {\n // check whether this entry is only a number, i.e. probably year or track #\n i->toInt( &ok );\n if( ok )\n i = list.erase( i );\n else\n ++i;\n }\n }\n else // plain title\n {\n list << title;\n }\n\n if( HAS_TAG(artist) && !list.CONTAINS_TAG(artist) )\n list << TAG(artist);\n else if( HAS_TAG(composer) && !list.CONTAINS_TAG(composer) )\n list << TAG(composer);\n if( HAS_TAG(album) && !list.CONTAINS_TAG(album) )\n list << TAG(album);\n\n /* other tags\n string year\n string genre\n double score\n int rating\n qint64 length // ms\n int sampleRate\n int bitrate\n int trackNumber\n int discNumber\n uint lastPlayed\n uint firstPlayed\n int playCount\n QString type\n bool inCollection\n */\n }\n return list;\n}", "label": 0, "cwe": null, "length": 558 }, { "index": 667295, "code": "pbsize_(fortint* unit,fortint* plen) {\n/*\n// Returns the size in bytes of the next GRIB, BUFR, TIDE, BUDG, DIAG\n// product.\n//\n// Called from FORTRAN:\n// CALL PBSIZE( KUNIT, LENGTH)\n//\n// unit = file id returned from PBOPEN.\n// plen = size in bytes of the next product.\n// = -2 if error allocating memory for internal buffer.\n//\n// The input file is left positioned where it started.\n*/\nfortint iret;\nchar statbuff[BUFFLEN];\nchar * buff;\nlong offset, loop = 1;\n\n/*\n// Use a smallish buffer for processing; this should suffice for all cases\n// except versions -1 and 0 of GRIB and large BUFR products\n*/\n offset = (fortint) fileTell( CURRENT_FILE);\n if( DEBUG ) {\n printf(\"PBIO_SIZE: fptable slot = %d. \", *unit);\n printf(\"Current file position = %d\\n\", offset);\n }\n\n *plen = BUFFLEN;\n if( DEBUG )\n printf(\"PBIO_SIZE: current buffer size = %d\\n\", *plen);\n\n iret = readprod(NULL,statbuff,plen,fileRead,fileSeek,fileTell,CURRENT_FILE);\n if( iret == -2 ) {\n printf(\"readprod error %d\\n\", iret);\n *plen = -2;\n return;\n }\n/*\n// If the smallish buffer is too small, progressively increase it until \n// big enough\n*/\n while ( iret == -4 ) {\n loop++;\n buff = (char *) malloc( BUFFLEN*loop);\n if( buff == NULL) {\n perror(\"malloc failed in PBSIZE\");\n *plen = -2;\n return;\n }\n *plen = BUFFLEN*loop;\n if( DEBUG )\n printf(\"PBIO_SIZE: buffer size increased to: %d\\n\", *plen);\n\n offset = (fortint) fileSeek( CURRENT_FILE, offset, SEEK_SET);\n offset = (fortint) fileTell( CURRENT_FILE);\n iret = readprod(NULL,buff,plen,fileRead,fileSeek,fileTell,CURRENT_FILE);\n free(buff);\n }\n\n if( iret == -2 ) {\n printf(\"readprod error %d\\n\", iret);\n *plen = -2;\n }\n/*\n// Put the file pointer back where it started\n*/\n if( DEBUG ) {\n printf(\"PBIO_SIZE: file pointer set back to: %d\\n\", offset);\n printf(\"PBIO_SIZE: Product size = %d\\n\", *plen);\n }\n offset = (fortint) fileSeek( CURRENT_FILE, offset, SEEK_SET);\n\n return ;\n}", "label": 1, "cwe": "CWE-120", "length": 600 }, { "index": 182892, "code": "read_keymap(char const *fname)\n{\n\tint\tfds[2];\n\tpid_t\tpid;\n\tint\trc = EX_OK;\n\n\tif (pipe(fds) < 0) {\n\t\terr(\"pipe(): %m\");\n\t\treturn EX_OSERR;\n\t}\n\n\tpid = fork();\n\tif (pid < 0) {\n\t\terr(\"fork(): %m\");\n\t\t\t_exit(EX_OSERR);\n\t\t}\n\n\t\tclose(fds[0]);\n\t\tclose(fds[1]);\n\t\tclose(0);\n\t\t\n\t\tsprintf(buf, \"%zu\", ARRAY_SIZE(KEY_DEFS));\n\t\texeclp(\"hama-keymap-parser\",\n\t\t \"hama-keymap-parser\", fname, buf,\n\t\t (char *)NULL);\n\t\terr(\"execlp(hama-keymap-parser): %m\");\n\t\t_exit(EX_OSERR);\n\t} else {\n\t\tstruct keymap_data_rpc\tinfo;\n\t\tint\t\t\tstatus;\n\n\t\tclose(fds[1]);\n\n\t\tfor (;;) {\n\t\t\tssize_t\tl = read(fds[0], &info, sizeof info);\n\n\t\t\tif (l == 0) {\n\t\t\t\tbreak;\n\t\t\t} else if (l < 0) {\n\t\t\t\terr( \"read(): %m\");\n\t\t\t\trc = EX_OSERR;\n\t\t\t\tbreak;\n\t\t\t} else if ((size_t)l != sizeof info) {\n\t\t\t\terr(\"incomplete data read (%zd vs. %zu)\\n\",\n\t\t\t\t l, sizeof info);\n\t\t\t\trc = EX_OSERR;\n\t\t\t\tbreak;\n\t\t\t} else if (info.scancode >= ARRAY_SIZE(KEY_DEFS) ||\n\t\t\t\t info.keyid >= KEY_MAX) {\n\t\t\t\terr(\"inconsistent data (%u, %04x)\\n\",\n\t\t\t\t info.scancode, info.keyid);\n\t\t\t\trc = EX_OSERR;\n\t\t\t\tbreak;\n\t\t\t} else {\n\t\t\t\tdbg(\"mapping %u to %04x\\n\", info.scancode,\n\t\t\t\t info.keyid);\n\t\t\t\tKEY_DEFS[info.scancode].code = info.keyid;\n\t\t\t}\n\t\t}\n\n\t\tclose(fds[0]);\n\n\t\tif (waitpid(pid, &status, 0) < 0) {\n\t\t\terr(\"waitpid(): %m\");\n\t\t\tif (rc == EX_OK)\n\t\t\t\trc = EX_OSERR;\n\t\t} else if (!WIFEXITED(status) || WEXITSTATUS(status) != EX_OK) {\n\t\t\terr(\"keymap parser exited with %x\\n\", status);\n\t\t\tif (rc != EX_OK)\n\t\t\t\t;\t/* noop */\n\t\t\telse if (WIFEXITED(status))\n\t\t\t\trc = WEXITSTATUS(status);\n\t\t\telse\n\t\t\t\trc = EX_SOFTWARE;\n\t\t}\n\t}\n\n\treturn rc;\n}", "label": 0, "cwe": null, "length": 637 }, { "index": 115325, "code": "fill_runtime_generic_context (MonoVTable *class_vtable, MonoRuntimeGenericContext *rgctx, guint32 slot,\n\t\tMonoGenericInst *method_inst)\n{\n\tgpointer info;\n\tint i, first_slot, size;\n\tMonoDomain *domain = class_vtable->domain;\n\tMonoClass *klass = class_vtable->klass;\n\tMonoGenericContext *class_context = klass->generic_class ? &klass->generic_class->context : NULL;\n\tMonoRuntimeGenericContextInfoTemplate oti;\n\tMonoGenericContext context = { class_context ? class_context->class_inst : NULL, method_inst };\n\tint rgctx_index;\n\tgboolean do_free;\n\n\tg_assert (rgctx);\n\n\tmono_domain_lock (domain);\n\n\t/* First check whether that slot isn't already instantiated.\n\t This might happen because lookup doesn't lock. Allocate\n\t arrays on the way. */\n\tfirst_slot = 0;\n\tsize = mono_class_rgctx_get_array_size (0, method_inst != NULL);\n\tif (method_inst)\n\t\tsize -= MONO_SIZEOF_METHOD_RUNTIME_GENERIC_CONTEXT / sizeof (gpointer);\n\tfor (i = 0; ; ++i) {\n\t\tint offset;\n\n\t\tif (method_inst && i == 0)\n\t\t\toffset = MONO_SIZEOF_METHOD_RUNTIME_GENERIC_CONTEXT / sizeof (gpointer);\n\t\telse\n\t\t\toffset = 0;\n\n\t\tif (slot < first_slot + size - 1) {\n\t\t\trgctx_index = slot - first_slot + 1 + offset;\n\t\t\tinfo = rgctx [rgctx_index];\n\t\t\tif (info) {\n\t\t\t\tmono_domain_unlock (domain);\n\t\t\t\treturn info;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\tif (!rgctx [offset + 0])\n\t\t\trgctx [offset + 0] = alloc_rgctx_array (domain, i + 1, method_inst != NULL);\n\t\trgctx = (void **)rgctx [offset + 0];\n\t\tfirst_slot += size - 1;\n\t\tsize = mono_class_rgctx_get_array_size (i + 1, method_inst != NULL);\n\t}\n\n\tg_assert (!rgctx [rgctx_index]);\n\n\tmono_domain_unlock (domain);\n\n\toti = class_get_rgctx_template_oti (get_shared_class (klass),\n\t\t\t\t\t\t\t\t\t\tmethod_inst ? method_inst->type_argc : 0, slot, TRUE, TRUE, &do_free);\n\t/* This might take the loader lock */\n\tinfo = instantiate_info (domain, &oti, &context, klass);\n\tg_assert (info);\n\n\t/*\n\tif (method_inst)\n\t\tg_print (\"filling mrgctx slot %d table %d index %d\\n\", slot, i, rgctx_index);\n\t*/\n\n\t/*FIXME We should use CAS here, no need to take a lock.*/\n\tmono_domain_lock (domain);\n\n\t/* Check whether the slot hasn't been instantiated in the\n\t meantime. */\n\tif (rgctx [rgctx_index])\n\t\tinfo = rgctx [rgctx_index];\n\telse\n\t\trgctx [rgctx_index] = info;\n\n\tmono_domain_unlock (domain);\n\n\tif (do_free)\n\t\tfree_inflated_info (oti.info_type, oti.data);\n\n\treturn info;\n}", "label": 0, "cwe": null, "length": 639 }, { "index": 132530, "code": "gss_acquire_cred_with_password(OM_uint32 *minor_status,\n\t\t\t gss_const_name_t desired_name,\n\t\t\t const gss_buffer_t password,\n\t\t\t OM_uint32 time_req,\n\t\t\t const gss_OID_set desired_mechs,\n\t\t\t gss_cred_usage_t cred_usage,\n\t\t\t gss_cred_id_t *output_cred_handle,\n\t\t\t gss_OID_set *actual_mechs,\n\t\t\t OM_uint32 *time_rec)\n{\n OM_uint32 major_status, tmp_minor;\n\n if (desired_mechs == GSS_C_NO_OID_SET) {\n\tmajor_status = _gss_acquire_cred_ext(minor_status,\n\t\t\t\t\t desired_name,\n\t\t\t\t\t GSS_C_CRED_PASSWORD,\n\t\t\t\t\t password,\n\t\t\t\t\t time_req,\n\t\t\t\t\t GSS_C_NO_OID,\n\t\t\t\t\t cred_usage,\n\t\t\t\t\t output_cred_handle);\n\tif (GSS_ERROR(major_status))\n\t return major_status;\n } else {\n\tsize_t i;\n\tstruct _gss_cred *new_cred;\n\n\tnew_cred = calloc(1, sizeof(*new_cred));\n\tif (new_cred == NULL) {\n\t *minor_status = ENOMEM;\n\t return GSS_S_FAILURE;\n\t}\n\tHEIM_SLIST_INIT(&new_cred->gc_mc);\n\n\tfor (i = 0; i < desired_mechs->count; i++) {\n\t struct _gss_cred *tmp_cred = NULL;\n\t struct _gss_mechanism_cred *mc;\n\n\t major_status = _gss_acquire_cred_ext(minor_status,\n\t\t\t\t\t\t desired_name,\n\t\t\t\t\t\t GSS_C_CRED_PASSWORD,\n\t\t\t\t\t\t password,\n\t\t\t\t\t\t time_req,\n\t\t\t\t\t\t &desired_mechs->elements[i],\n\t\t\t\t\t\t cred_usage,\n\t\t\t\t\t\t (gss_cred_id_t *)&tmp_cred);\n\t if (GSS_ERROR(major_status))\n\t\tcontinue;\n\n\t mc = HEIM_SLIST_FIRST(&tmp_cred->gc_mc);\n\t if (mc) {\n\t\tHEIM_SLIST_REMOVE_HEAD(&tmp_cred->gc_mc, gmc_link);\n\t\tHEIM_SLIST_INSERT_HEAD(&new_cred->gc_mc, mc, gmc_link);\n\t }\n\n\t gss_release_cred(&tmp_minor, (gss_cred_id_t *)&tmp_cred);\n\t}\n\n\tif (!HEIM_SLIST_FIRST(&new_cred->gc_mc)) {\n\t free(new_cred);\n\t *minor_status = 0;\n\t return GSS_S_NO_CRED;\n\t}\n\n\t*output_cred_handle = (gss_cred_id_t)new_cred;\n }\n\n if (actual_mechs != NULL || time_rec != NULL) {\n\tmajor_status = gss_inquire_cred(minor_status,\n\t\t\t\t\t*output_cred_handle,\n\t\t\t\t\tNULL,\n\t\t\t\t\ttime_rec,\n\t\t\t\t\tNULL,\n\t\t\t\t\tactual_mechs);\n\tif (GSS_ERROR(major_status)) {\n\t gss_release_cred(&tmp_minor, output_cred_handle);\n\t return major_status;\n\t}\n }\n\n *minor_status = 0;\n return GSS_S_COMPLETE;\n}", "label": 0, "cwe": null, "length": 600 }, { "index": 88978, "code": "process_version_directive(YYLTYPE *locp, int version,\n const char *ident)\n{\n bool es_token_present = false;\n if (ident) {\n if (strcmp(ident, \"es\") == 0) {\n es_token_present = true;\n } else if (version >= 150) {\n if (strcmp(ident, \"core\") == 0) {\n /* Accept the token. There's no need to record that this is\n * a core profile shader since that's the only profile we support.\n */\n } else if (strcmp(ident, \"compatibility\") == 0) {\n _mesa_glsl_error(locp, this,\n \"the compatibility profile is not supported\");\n } else {\n _mesa_glsl_error(locp, this,\n \"\\\"%s\\\" is not a valid shading language profile; \"\n \"if present, it must be \\\"core\\\"\", ident);\n }\n } else {\n _mesa_glsl_error(locp, this,\n \"illegal text following version number\");\n }\n }\n\n this->es_shader = es_token_present;\n if (version == 100) {\n if (es_token_present) {\n _mesa_glsl_error(locp, this,\n \"GLSL 1.00 ES should be selected using \"\n \"`#version 100'\");\n } else {\n this->es_shader = true;\n }\n }\n\n if (this->es_shader) {\n this->ARB_texture_rectangle_enable = false;\n }\n\n this->language_version = version;\n\n bool supported = false;\n for (unsigned i = 0; i < this->num_supported_versions; i++) {\n if (this->supported_versions[i].ver == (unsigned) version\n && this->supported_versions[i].es == this->es_shader) {\n supported = true;\n break;\n }\n }\n\n if (!supported) {\n _mesa_glsl_error(locp, this, \"%s is not supported. \"\n \"Supported versions are: %s\",\n this->get_version_string(),\n this->supported_version_string);\n\n /* On exit, the language_version must be set to a valid value.\n * Later calls to _mesa_glsl_initialize_types will misbehave if\n * the version is invalid.\n */\n switch (this->ctx->API) {\n case API_OPENGL_COMPAT:\n case API_OPENGL_CORE:\n\t this->language_version = this->ctx->Const.GLSLVersion;\n\t break;\n\n case API_OPENGLES:\n\t assert(!\"Should not get here.\");\n\t /* FALLTHROUGH */\n\n case API_OPENGLES2:\n\t this->language_version = 100;\n\t break;\n }\n }\n}", "label": 0, "cwe": null, "length": 582 }, { "index": 690620, "code": "check_for_droids_to_attack_or_talk_with()\n{\n\t/* NOTA : the call to GetLivingDroidBelowMouseCursor() does set the virt_pos attribute\n\t * of the found droid to be the bot's position relatively to Tux current level\n\t */\n\tenemy *droid_below_mouse_cursor = GetLivingDroidBelowMouseCursor();\n\n\t// Set a move action unless there's a droid below the cursor,\n\t// 'A' is pressed,\n\t// or the player has clicked to pickup an item and hasn't released the LMB\n\tif (droid_below_mouse_cursor == NULL && (!APressed()) &&\n\t\t(no_left_button_press_in_previous_analyze_mouse_click ||\n\t\tMe.mouse_move_target_combo_action_type != COMBO_ACTION_PICK_UP_ITEM)) {\n\n\t\tMe.mouse_move_target.x = translate_pixel_to_map_location(input_axis.x, input_axis.y, TRUE);\n\t\tMe.mouse_move_target.y = translate_pixel_to_map_location(input_axis.x, input_axis.y, FALSE);\n\t\tMe.mouse_move_target.z = Me.pos.z;\n\t\tif (!ShiftPressed()) {\n\t\t\tenemy_set_reference(&Me.current_enemy_target_n, &Me.current_enemy_target_addr, NULL);\n\t\t}\n\n\t\treturn;\n\t} else if (APressed()) {\n\t\ttux_wants_to_attack_now(TRUE);\n\t\treturn;\n\t}\n\n\tif (droid_below_mouse_cursor != NULL &&\n\t DirectLineColldet(Me.pos.x, Me.pos.y, droid_below_mouse_cursor->virt_pos.x, droid_below_mouse_cursor->virt_pos.y, Me.pos.z,\n\t\t\t &VisiblePassFilter)) {\n\n\t\tenemy_set_reference(&Me.current_enemy_target_n, &Me.current_enemy_target_addr, droid_below_mouse_cursor);\n\n\t\tenemy *e = enemy_resolve_address(Me.current_enemy_target_n, &Me.current_enemy_target_addr);\n\t\tif (is_friendly(e->faction, FACTION_SELF)) {\n\t\t\tif (no_left_button_press_in_previous_analyze_mouse_click) {\n\t\t\t\tChatWithFriendlyDroid(enemy_resolve_address(Me.current_enemy_target_n, &Me.current_enemy_target_addr));\n\t\t\t\tenemy_set_reference(&Me.current_enemy_target_n, &Me.current_enemy_target_addr, NULL);\n\t\t\t}\n\n\t\t\treturn;\n\t\t}\n\n\t\tif (!ShiftPressed()) {\n\t\t\tMe.mouse_move_target.x = -1;\n\t\t\tMe.mouse_move_target.y = -1;\n\t\t}\n\n\t\tif (Me.weapon_item.type >= 0) {\n\t\t\tif ((ItemMap[Me.weapon_item.type].item_weapon_is_melee) &&\n\t\t\t (calc_distance(Me.pos.x, Me.pos.y, droid_below_mouse_cursor->virt_pos.x, droid_below_mouse_cursor->virt_pos.y)\n\t\t\t > BEST_MELEE_DISTANCE + 0.1)) {\n\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else if (calc_distance(Me.pos.x, Me.pos.y, droid_below_mouse_cursor->virt_pos.x, droid_below_mouse_cursor->virt_pos.y)\n\t\t\t > BEST_MELEE_DISTANCE + 0.1) {\n\n\t\t\treturn;\n\t\t}\n\t\t// But if we're close enough or there is a ranged weapon in Tux hands,\n\t\t// then we can finally start the attack motion right away...\n\t\t//\n\t\ttux_wants_to_attack_now(TRUE);\n\t}\n}", "label": 0, "cwe": null, "length": 677 }, { "index": 247527, "code": "init()\n{\n // set index and check validity of region\n\n iregion = domain->find_region(idregion);\n if (iregion == -1)\n error->all(FLERR,\"Region ID for fix wall/region does not exist\");\n\n // error checks for style COLLOID\n // insure all particles in group are extended particles\n\n if (style == COLLOID) {\n if (!atom->sphere_flag)\n error->all(FLERR,\"Fix wall/region colloid requires atom style sphere\");\n\n double *radius = atom->radius;\n int *mask = atom->mask;\n int nlocal = atom->nlocal;\n\n int flag = 0;\n for (int i = 0; i < nlocal; i++)\n if (mask[i] & groupbit)\n if (radius[i] == 0.0) flag = 1;\n\n int flagall;\n MPI_Allreduce(&flag,&flagall,1,MPI_INT,MPI_SUM,world);\n if (flagall)\n error->all(FLERR,\"Fix wall/region colloid requires extended particles\");\n }\n\n // setup coefficients for each style\n\n if (style == LJ93) {\n coeff1 = 6.0/5.0 * epsilon * pow(sigma,9.0);\n coeff2 = 3.0 * epsilon * pow(sigma,3.0);\n coeff3 = 2.0/15.0 * epsilon * pow(sigma,9.0);\n coeff4 = epsilon * pow(sigma,3.0);\n double rinv = 1.0/cutoff;\n double r2inv = rinv*rinv;\n double r4inv = r2inv*r2inv;\n offset = coeff3*r4inv*r4inv*rinv - coeff4*r2inv*rinv;\n } else if (style == LJ126) {\n coeff1 = 48.0 * epsilon * pow(sigma,12.0);\n coeff2 = 24.0 * epsilon * pow(sigma,6.0);\n coeff3 = 4.0 * epsilon * pow(sigma,12.0);\n coeff4 = 4.0 * epsilon * pow(sigma,6.0);\n double r2inv = 1.0/(cutoff*cutoff);\n double r6inv = r2inv*r2inv*r2inv;\n offset = r6inv*(coeff3*r6inv - coeff4);\n } else if (style == COLLOID) {\n coeff1 = -4.0/315.0 * epsilon * pow(sigma,6.0);\n coeff2 = -2.0/3.0 * epsilon;\n coeff3 = epsilon * pow(sigma,6.0)/7560.0;\n coeff4 = epsilon/6.0;\n double rinv = 1.0/cutoff;\n double r2inv = rinv*rinv;\n double r4inv = r2inv*r2inv;\n offset = coeff3*r4inv*r4inv*rinv - coeff4*r2inv*rinv;\n }\n\n if (strstr(update->integrate_style,\"respa\"))\n nlevels_respa = ((Respa *) update->integrate)->nlevels;\n}", "label": 0, "cwe": null, "length": 692 }, { "index": 680437, "code": "gui_radiogroup_create(\n GuiWidget *parent, int x, int y, int width, int height, int with_frame,\n void (*user_event_handler)(GuiWidget*,GuiEvent*),\n int item_count, char **items, int min, int max )\n{\n int px, py, i, j, gap = 4;\n GuiWidget *widget = gui_widget_create( \n parent, GUI_RADIOGROUP, x, y, width, height, \n default_event_handler, user_event_handler );\n /* events */\n gui_widget_enable_event( widget, GUI_CLICKED );\n /* create surface, wallpaper and frame it */\n widget->surface = stk_surface_create( \n SDL_SWSURFACE, width, height );\n SDL_SetColorKey( widget->surface, 0,0 );\n stk_surface_apply_wallpaper( widget->surface, 0,0,-1,-1,\n gui_theme->widget_wallpaper, -1 );\n if ( with_frame )\n widget->border = stk_surface_apply_frame(\n widget->surface, 0, 0, -1, -1, \n gui_theme->widget_frame );\n /* size w/o border */\n widget->width -= 2 * widget->border;\n widget->height -= 2 * widget->border;\n /* various */\n widget->spec.radiogroup.size = item_count;\n widget->spec.radiogroup.min = min;\n widget->spec.radiogroup.max = max;\n widget->spec.radiogroup.single_check = -1;\n /* compute offset of single items */\n widget->spec.radiogroup.offset = \n (height - 2 * widget->border) / \n item_count;\n /* position of first checkbox */\n widget->spec.radiogroup.x = widget->border + gap;\n widget->spec.radiogroup.y = widget->border + \n (widget->spec.radiogroup.offset - \n gui_theme->checkbox_size) / 2;\n /* add empty checkboxes and labels */\n gui_theme->label_font->align = STK_FONT_ALIGN_CENTER_Y;\n px = widget->spec.radiogroup.x;\n py = widget->spec.radiogroup.y;\n for ( i = 0, j = 0; i < widget->spec.radiogroup.size; \n i++, py += widget->spec.radiogroup.offset, j++ ) {\n stk_surface_blit( \n gui_theme->checkbox, 0, 0,\n gui_theme->checkbox_size,\n gui_theme->checkbox_size,\n widget->surface, px, py );\n stk_font_write( gui_theme->label_font, \n widget->surface, px + gui_theme->checkbox_size + gap,\n py + gui_theme->checkbox_size/2, -1, items[j] );\n }\n /* create empty checkers */\n widget->spec.radiogroup.checks = calloc( item_count, sizeof( int ) );\n if ( widget->spec.radiogroup.checks == 0 )\n GUI_ABORT( \"Out Of Memory\" );\n return widget;\n}", "label": 0, "cwe": null, "length": 665 }, { "index": 46103, "code": "_findLastStruxOfType( pf_Frag * pfStart,\n PTStruxType pst,\n PTStruxType* stopConditions,\n bool bSkipEmbededSections )\n{\n\tUT_return_val_if_fail( pfStart, NULL );\n\n\tpf_Frag * pf = pfStart;\n PTStruxType* stopConditionsBegin = stopConditions;\n PTStruxType* stopConditionsEnd = stopConditions;\n while( *stopConditionsEnd != PTX_StruxDummy )\n ++stopConditionsEnd;\n\n while(pf)\n\t{\n\t\tif(pf->getType() == pf_Frag::PFT_Strux)\n\t\t{\n\t\t\tpf_Frag_Strux * pfs2 = static_cast(pf);\n\n PTStruxType eStruxType = pfs2->getStruxType();\n\n\t\t\tif( eStruxType == pst)\n return pfs2;\n \n if( stopConditionsEnd !=\n std::find( stopConditionsBegin, stopConditionsEnd, eStruxType ))\n {\n return 0;\n }\n \n\t\t\tif(bSkipEmbededSections)\n\t\t\t{\n\t\t\t\tif(pfs2->getStruxType() == PTX_EndTOC)\n\t\t\t\t{\n\t\t\t\t\twhile(pf)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(pf->getType() == pf_Frag::PFT_Strux)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpf_Frag_Strux * pfs = static_cast(pf);\n\n\t\t\t\t\t\t\tif(pfs->getStruxType() == PTX_SectionTOC)\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tpf = pf->getPrev();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(pfs2->getStruxType() == PTX_EndFrame)\n\t\t\t\t{\n\t\t\t\t\twhile(pf)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(pf->getType() == pf_Frag::PFT_Strux)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpf_Frag_Strux * pfs = static_cast(pf);\n\n\t\t\t\t\t\t\tif(pfs->getStruxType() == PTX_SectionFrame)\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tpf = pf->getPrev();\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif(pfs2->getStruxType() == PTX_EndEndnote)\n\t\t\t\t{\n\t\t\t\t\twhile(pf)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(pf->getType() == pf_Frag::PFT_Strux)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpf_Frag_Strux * pfs = static_cast(pf);\n\n\t\t\t\t\t\t\tif(pfs->getStruxType() == PTX_SectionEndnote)\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tpf = pf->getPrev();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(pfs2->getStruxType() == PTX_EndFootnote)\n\t\t\t\t{\n\t\t\t\t\twhile(pf)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(pf->getType() == pf_Frag::PFT_Strux)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpf_Frag_Strux * pfs = static_cast(pf);\n\n\t\t\t\t\t\t\tif(pfs->getStruxType() == PTX_SectionFootnote)\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tpf = pf->getPrev();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif(pfs2->getStruxType() == PTX_EndMarginnote)\n\t\t\t\t{\n\t\t\t\t\twhile(pf)\n\t\t\t\t\t{\n\t\t\t\t\t\tif(pf->getType() == pf_Frag::PFT_Strux)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tpf_Frag_Strux * pfs = static_cast(pf);\n\n\t\t\t\t\t\t\tif(pfs->getStruxType() == PTX_SectionMarginnote)\n\t\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tpf = pf->getPrev();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif(pf)\n\t\t\tpf = pf->getPrev();\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 802 }, { "index": 671807, "code": "NDMeshFLoad(IOBFILE *file, char *fname)\n{\n NDMesh\tm;\n int\tn;\n int i, u, v;\n int size[2];\n int binary;\n\n if (!file)\n return NULL;\n\n if ((m.geomflags = getheader(file, fname, &m.pdim)) == -1)\n return NULL;\n\n m.meshd = 2;\t/* Hack. Should allow general meshes */\n\n binary = m.geomflags & MESH_BINARY;\n\n if (iobfgetni(file, m.meshd, size, binary) < 2) {\n OOGLSyntax(file,\"Reading nMESH from \\\"%s\\\": expected mesh grid size\", fname);\n return NULL;\n }\n if (size[0] <= 0 || size[1] <= 0 || size[0] > 9999999 || size[1] > 9999999) {\n OOGLSyntax(file,\"Reading nMESH from \\\"%s\\\": invalid mesh size %d %d\",\n\t fname,size[0],size[1]);\n return NULL;\n }\n\n n = size[0] * size[1];\n\n m.p = OOGLNewNE(HPointN *, n, \"NDMeshFLoad: vertices\");\n m.u = NULL;\n m.c = NULL;\n\n if (m.geomflags & MESH_C) {\n m.c = OOGLNewNE(ColorA, n, \"NDMeshFLoad: colors\");\n }\n if (m.geomflags & MESH_U) {\n m.u = OOGLNewNE(TxST, n, \"NDMeshFLoad: texture coords\");\n }\n\n for (i = 0, v = 0; v < size[1]; v++) {\n for (u = 0; u < size[0]; u++, i++) {\n if (getmeshvert(file, m.geomflags, m.pdim, u, v,\n\t\t &m.p[i], &m.c[i], &m.u[i]) == 0) {\n\tOOGLSyntax(file,\n\t\t \"Reading nMESH from \\\"%s\\\": bad element (%d,%d) of (%d,%d)\",\n\t\t fname, u, v, size[0], size[1]);\n\treturn NULL;\n }\n }\n }\n return (NDMesh *)GeomCCreate(NULL, NDMeshMethods(), CR_NOCOPY,\n\t\t\t CR_MESHDIM, 2, CR_MESHSIZE, size,\n\t\t\t CR_DIM, m.pdim-1,\n\t\t\t CR_4D, (m.geomflags & MESH_4D),\n\t\t\t CR_FLAG, m.geomflags,\n\t\t\t CR_POINT4, m.p, CR_COLOR, m.c,\n\t\t\t CR_U, m.u, CR_END);\n}", "label": 0, "cwe": null, "length": 588 }, { "index": 511906, "code": "mlx4_en_dcbnl_ieee_setqcn(struct net_device *dev,\n\t\t\t\t struct ieee_qcn *qcn)\n{\n\tstruct mlx4_en_priv *priv = netdev_priv(dev);\n\tstruct mlx4_congestion_control_mb_prio_802_1_qau_params *hw_qcn;\n\tstruct mlx4_cmd_mailbox *mailbox_in = NULL;\n\tu64 mailbox_in_dma = 0;\n\tu32 inmod = 0;\n\tint i, err;\n#define MODIFY_ENABLE_HIGH_MASK 0xc0000000\n#define MODIFY_ENABLE_LOW_MASK 0xffc00000\n\n\tif (!(priv->mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_QCN))\n\t\treturn -EOPNOTSUPP;\n\n\tmailbox_in = mlx4_alloc_cmd_mailbox(priv->mdev->dev);\n\tif (IS_ERR(mailbox_in))\n\t\treturn -ENOMEM;\n\n\tmailbox_in_dma = mailbox_in->dma;\n\thw_qcn =\n\t(struct mlx4_congestion_control_mb_prio_802_1_qau_params *)mailbox_in->buf;\n\tfor (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {\n\t\tinmod = priv->port | ((1 << i) << 8) |\n\t\t\t (MLX4_CTRL_ALGO_802_1_QAU_REACTION_POINT << 16);\n\n\t\t/* Before updating QCN parameter,\n\t\t * need to set it's modify enable bit to 1\n\t\t */\n\n\t\thw_qcn->modify_enable_high = cpu_to_be32(\n\t\t\t\t\t\tMODIFY_ENABLE_HIGH_MASK);\n\t\thw_qcn->modify_enable_low = cpu_to_be32(MODIFY_ENABLE_LOW_MASK);\n\n\t\thw_qcn->extended_enable = cpu_to_be32(qcn->rpg_enable[i] << RPG_ENABLE_BIT);\n\t\thw_qcn->rppp_max_rps = cpu_to_be32(qcn->rppp_max_rps[i]);\n\t\thw_qcn->rpg_time_reset = cpu_to_be32(qcn->rpg_time_reset[i]);\n\t\thw_qcn->rpg_byte_reset = cpu_to_be32(qcn->rpg_byte_reset[i]);\n\t\thw_qcn->rpg_threshold = cpu_to_be32(qcn->rpg_threshold[i]);\n\t\thw_qcn->rpg_max_rate = cpu_to_be32(qcn->rpg_max_rate[i]);\n\t\thw_qcn->rpg_ai_rate = cpu_to_be32(qcn->rpg_ai_rate[i]);\n\t\thw_qcn->rpg_hai_rate = cpu_to_be32(qcn->rpg_hai_rate[i]);\n\t\thw_qcn->rpg_gd = cpu_to_be32(qcn->rpg_gd[i]);\n\t\thw_qcn->rpg_min_dec_fac = cpu_to_be32(qcn->rpg_min_dec_fac[i]);\n\t\thw_qcn->rpg_min_rate = cpu_to_be32(qcn->rpg_min_rate[i]);\n\t\tpriv->cndd_state[i] = qcn->cndd_state_machine[i];\n\t\tif (qcn->cndd_state_machine[i] == DCB_CNDD_INTERIOR_READY)\n\t\t\thw_qcn->extended_enable |= cpu_to_be32(1 << CN_TAG_BIT);\n\n\t\terr = mlx4_cmd(priv->mdev->dev, mailbox_in_dma, inmod,\n\t\t\t MLX4_CONGESTION_CONTROL_SET_PARAMS,\n\t\t\t MLX4_CMD_CONGESTION_CTRL_OPCODE,\n\t\t\t MLX4_CMD_TIME_CLASS_C,\n\t\t\t MLX4_CMD_NATIVE);\n\t\tif (err) {\n\t\t\tmlx4_free_cmd_mailbox(priv->mdev->dev, mailbox_in);\n\t\t\treturn err;\n\t\t}\n\t}\n\tmlx4_free_cmd_mailbox(priv->mdev->dev, mailbox_in);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 801 }, { "index": 44078, "code": "emitSelT16(unsigned Opc1, unsigned Opc2, MachineInstr *MI,\n MachineBasicBlock *BB) const {\n if (DontExpandCondPseudos16)\n return BB;\n const TargetInstrInfo *TII = Subtarget.getInstrInfo();\n DebugLoc DL = MI->getDebugLoc();\n // To \"insert\" a SELECT_CC instruction, we actually have to insert the\n // diamond control-flow pattern. The incoming instruction knows the\n // destination vreg to set, the condition code register to branch on, the\n // true/false values to select between, and a branch opcode to use.\n const BasicBlock *LLVM_BB = BB->getBasicBlock();\n MachineFunction::iterator It = ++BB->getIterator();\n\n // thisMBB:\n // ...\n // TrueVal = ...\n // setcc r1, r2, r3\n // bNE r1, r0, copy1MBB\n // fallthrough --> copy0MBB\n MachineBasicBlock *thisMBB = BB;\n MachineFunction *F = BB->getParent();\n MachineBasicBlock *copy0MBB = F->CreateMachineBasicBlock(LLVM_BB);\n MachineBasicBlock *sinkMBB = F->CreateMachineBasicBlock(LLVM_BB);\n F->insert(It, copy0MBB);\n F->insert(It, sinkMBB);\n\n // Transfer the remainder of BB and its successor edges to sinkMBB.\n sinkMBB->splice(sinkMBB->begin(), BB,\n std::next(MachineBasicBlock::iterator(MI)), BB->end());\n sinkMBB->transferSuccessorsAndUpdatePHIs(BB);\n\n // Next, add the true and fallthrough blocks as its successors.\n BB->addSuccessor(copy0MBB);\n BB->addSuccessor(sinkMBB);\n\n BuildMI(BB, DL, TII->get(Opc2)).addReg(MI->getOperand(3).getReg())\n .addReg(MI->getOperand(4).getReg());\n BuildMI(BB, DL, TII->get(Opc1)).addMBB(sinkMBB);\n\n // copy0MBB:\n // %FalseValue = ...\n // # fallthrough to sinkMBB\n BB = copy0MBB;\n\n // Update machine-CFG edges\n BB->addSuccessor(sinkMBB);\n\n // sinkMBB:\n // %Result = phi [ %TrueValue, thisMBB ], [ %FalseValue, copy0MBB ]\n // ...\n BB = sinkMBB;\n\n BuildMI(*BB, BB->begin(), DL,\n TII->get(Mips::PHI), MI->getOperand(0).getReg())\n .addReg(MI->getOperand(1).getReg()).addMBB(thisMBB)\n .addReg(MI->getOperand(2).getReg()).addMBB(copy0MBB);\n\n MI->eraseFromParent(); // The pseudo instruction is gone now.\n return BB;\n\n}", "label": 0, "cwe": null, "length": 672 }, { "index": 626473, "code": "loadLights(void* globals, gatherO gather, materialAttrP newMaterial)\n{\n DEFGLOBALDATA(globals);\n DEFPORT(PORT_HANDLE);\n int\ti,j;\n Light\tnewLight;\n static materialAttrT\tidentMaterial = {1.0, 1.0, 1.0, 1};\n RGBColor color;\n listO lights;\n materialO omo, nmo;\n float gka, gkd, gks, gsp;\n\n ENTRY((\"loadLights(0x%x, 0x%x, 0x%x)\",globals, gather, newMaterial));\n\n /* \n * if no material coeficients were specified or this port does not\n * want the coeficients pre-multiplied into the lights, use all\n * unit valued coeficients.\n */\n if(!newMaterial || \n !_dxf_isFlagsSet(_dxf_SERVICES_FLAGS(),SF_CONST_COEF_HELP))\n newMaterial = &identMaterial;\n\n /*\n * Only re-load the lights if the material coeficients have changed\n */\n if (! _dxf_getHwGatherMaterial(gather, &omo))\n goto error;\n\n if (omo)\n if (! _dxf_getHwMaterialInfo(omo, &gka, &gkd, &gks, &gsp))\n\t goto error;\n\n if(!omo ||\n gka != newMaterial->ambient ||\n gkd != newMaterial->diffuse) {\n\n nmo = _dxf_newHwMaterial(\n\t\tnewMaterial->ambient,\n\t\tnewMaterial->diffuse,\n\t\tnewMaterial->specular,\n\t\tnewMaterial->shininess);\n\n if (! nmo)\n\tgoto error;\n \n if (! _dxf_setHwGatherMaterial(gather, nmo))\n goto error;\n\n if (! _dxf_getHwGatherAmbientColor(gather, &color))\n goto error;\n \n /* Load (or disable) the Ambient light */\n if(color.r == 0.0 && color.g == 0.0 && color.b == 0.0) \n {\n\n if (!_dxf_DEFINE_LIGHT (LWIN, 0, NULL))\n goto error;\n\n }\n else\n {\n\tfloat\t\tambient = 1.0;\n\n\t/* \n\t * For ports with SF_CONST_COEF_HELP we put the ambient/diffuse coefs\n\t * in the ambient light color. This is for GL, this allows us to\n\t * use LMC_AD color for surfaces. This reduces the number of calls\n\t * we need by 2 per vertex.\n\t *\n\t * The ambient is divided by the diffuse so that we can multiply the\n\t * diffuse into the surface color and use LMC_AD for the color.\n\t */\n\n\tif(newMaterial->diffuse)\n\t ambient = newMaterial->ambient / newMaterial->diffuse;\n\telse\n\t ambient = newMaterial->ambient / (1./10000.);\n\n\tcolor.r *= ambient;\n\tcolor.g *= ambient;\n\tcolor.b *= ambient;\n\n\tif(!(newLight = DXNewAmbientLight(color)))\n\t goto error;\n\n\tif (!_dxf_DEFINE_LIGHT (LWIN, 0, newLight))\n\t goto error;\n\t\n\tDXDelete((dxObject)newLight);\n }\n\n if (! _dxf_getHwGatherLights(gather, &lights))\n\tgoto error;\n\n /* Load all directional lights */\n for(i=1,j=_dxf_listSize(lights)-1;j>=0 && i<=8;j--,i++) {\n if (!_dxf_DEFINE_LIGHT (LWIN, i, \n\t\t\t _dxf_listGetItem(lights,j)))\n\tgoto error;\n }\n \n /* remove any previously defined lights, that have not been redefined */\n for(;i<=8;i++) {\n if (!_dxf_DEFINE_LIGHT (LWIN, i, NULL))\n\tgoto error;\n }\t\n }\n\n EXIT((\"OK\"));\n return OK;\n\n error:\n\n EXIT((\"ERROR\"));\n return ERROR;\n}", "label": 0, "cwe": null, "length": 845 }, { "index": 185154, "code": "SendStore(File const &file)\n{\n ULConnection* mConnection = Internals->mConnection;\n\n std::vector theDataPDU;\n try\n {\n theDataPDU = PDUFactory::CreateCStoreRQPDU(*mConnection, file);\n }\n catch ( std::exception &ex )\n {\n (void)ex; //to avoid unreferenced variable warning on release\n gdcmErrorMacro( \"Could not C-STORE: \" << ex.what() );\n return false;\n }\n\n network::ULBasicCallback theCallback;\n network::ULConnectionCallback* inCallback = &theCallback;\n\n ULEvent theEvent(ePDATArequest, theDataPDU);\n EStateID stateid = RunEventLoop(theEvent, mConnection, inCallback, false);\n assert( stateid == eSta6TransferReady ); (void)stateid;\n std::vector const &theDataSets = theCallback.GetResponses();\n\n bool ret = true;\n assert( theDataSets.size() == 1 );\n const DataSet &ds = theDataSets[0];\n assert ( ds.FindDataElement(Tag(0x0, 0x0900)) );\n DataElement const & de = ds.GetDataElement(Tag(0x0,0x0900));\n Attribute<0x0,0x0900> at;\n at.SetFromDataElement( de );\n // PS 3.4 - 2011\n // Table W.4-1 C-STORE RESPONSE STATUS VALUES\n const uint16_t theVal = at.GetValue();\n switch( theVal )\n {\n case 0x0:\n gdcmDebugMacro( \"C-Store of file was successful.\" );\n break;\n case 0xA700:\n case 0xA900:\n case 0xC000:\n {\n // TODO: value from 0901 ?\n gdcmErrorMacro( \"C-Store of file was a failure.\" );\n Attribute<0x0,0x0902> errormsg;\n errormsg.SetFromDataSet( ds );\n const char *themsg = errormsg.GetValue();\n assert( themsg ); (void)themsg;\n gdcmErrorMacro( \"Response Status: \" << themsg );\n ret = false; // at least one file was not sent correctly\n }\n break;\n default:\n gdcmErrorMacro( \"Unhandle error code: \" << theVal );\n gdcmAssertAlwaysMacro( 0 );\n }\n\n return ret;\n}", "label": 0, "cwe": null, "length": 550 }, { "index": 23569, "code": "ipmi_sol_red_pill(struct ipmi_intf * intf)\n{\n\tchar * buffer;\n\tint numRead;\n\tint bShouldExit = 0;\n\tint bBmcClosedSession = 0;\n\tfd_set read_fds;\n\tstruct timeval tv;\n\tint retval;\n\tint buffer_size = intf->session->sol_data.max_inbound_payload_size;\n\tint keepAliveRet = 0;\n\tint retrySol = 0;\n\tstruct timeval current_time;\n\n\tbuffer = (char*)malloc(buffer_size);\n\tif (buffer == NULL) {\n\t\tlprintf(LOG_ERR, \"ipmitool: malloc failure\"); \n\t\treturn -1;\n\t}\n\n\t/* Initialize keepalive start time */\n\tgettimeofday(&_start_keepalive, 0);\n\n\tenter_raw_mode();\n\n\twhile (! bShouldExit)\n\t{\n\t\tFD_ZERO(&read_fds);\n\t\tFD_SET(0, &read_fds);\n\t\tFD_SET(intf->fd, &read_fds);\n\n\t\t/* Send periodic keepalive packet */\n\t\tgettimeofday(¤t_time, 0);\n\t\tif (current_time.tv_sec - _start_keepalive.tv_sec > SOL_KEEPALIVE_TIMEOUT) {\n\n\t\t\tkeepAliveRet = do_keepalive(intf);\n\n\t\t\tretrySol = (keepAliveRet == 0)\n\t\t\t\t\t? 0\n\t\t\t\t\t: retrySol + 1;\n\n\t\t\t/*\n\t\t\t * Retrying the keep Alive before declaring a communication\n\t\t\t * lost state with the IPMC. Helpful when the payload is\n\t\t\t * reset and brings down the connection temporarily. Otherwise,\n\t\t\t * if we send getDevice Id to check the status of IPMC during\n\t\t\t * this down time when the connection is restarting, SOL will\n\t\t\t * exit even though the IPMC is available and the session is open.\n\t\t\t */\n\t\t\tif (retrySol >= SOL_KEEPALIVE_RETRIES)\n\t\t\t{\n\t\t\t\t/* no response to Get Device ID keepalive message */\n\t\t\t\tbShouldExit = 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t/* Get next keepalive time */\n\t\t\tgettimeofday(&_start_keepalive, 0);\n\t\t}\n\n\t\t/* Wait up to half a second */\n\t\ttv.tv_sec = 0;\n\t\ttv.tv_usec = 500000;\n\n\t\tretval = select(intf->fd + 1, &read_fds, NULL, NULL, &tv);\n\n\t\tif (retval)\n\t\t{\n\t\t\tif (retval == -1)\n\t\t\t{\n\t\t\t\t/* ERROR */\n\t\t\t\tperror(\"select\");\n\t\t\t\treturn -1;\n\t\t\t}\n\n\n\t\t\t/*\n\t\t\t * Process input from the user\n\t\t\t */\n\t\t\tif (FD_ISSET(0, &read_fds))\n\t \t\t{\n\t\t\t\tbzero(buffer, sizeof(buffer));\n\t\t\t\tnumRead = read(fileno(stdin),\n\t\t\t\t\t\t\t buffer,\n\t\t\t\t\t\t\t buffer_size);\n\n\t\t\t\tif (numRead > 0)\n\t\t\t\t{\n\t\t\t\t\tint rc = processSolUserInput(intf, (uint8_t *)buffer, numRead);\n\n\t\t\t\t\tif (rc)\n\t\t\t\t\t{\n\t\t\t\t\t\tif (rc < 0)\n\t\t\t\t\t\t\tbShouldExit = bBmcClosedSession = 1;\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tbShouldExit = 1;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tbShouldExit = 1;\n\t\t\t\t}\n\t\t\t}\n\n\n\t\t\t/*\n\t\t\t * Process input from the BMC\n\t\t\t */\n\t\t\telse if (FD_ISSET(intf->fd, &read_fds))\n\t\t\t{\n\t\t\t\tstruct ipmi_rs * rs =intf->recv_sol(intf);\n\t\t\t\tif (! rs ||\n\t\t\t\t\t(rs->payload.sol_packet.is_nack && rs->payload.sol_packet.sol_inactive))\n\t\t\t\t{\n\t\t\t\t\tbShouldExit = bBmcClosedSession = 1;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\toutput(rs);\n\t\t\t\t}\n \t\t\t}\n\n\n\t\t\t/*\n\t\t\t * ERROR in select\n\t\t\t */\n \t\t\telse\n\t\t\t{\n\t\t\t\tlprintf(LOG_ERR, \"Error: Select returned with nothing to read\");\n\t\t\t\tbShouldExit = 1;\n\t\t\t}\n\t\t}\n\t}\n\n\tleave_raw_mode();\n\n\tif (keepAliveRet != 0)\n\t{\n\t\tlprintf(LOG_ERR, \"Error: No response to keepalive - Terminating session\");\n\t\t/* attempt to clean up anyway */\n\t\tipmi_sol_deactivate(intf);\n\t\texit(1);\n\t}\n\n\tif (bBmcClosedSession)\n\t{\n\t\tlprintf(LOG_ERR, \"SOL session closed by BMC\");\n\t\texit(1);\n\t}\n\telse\n\t\tipmi_sol_deactivate(intf);\n\n\treturn 0;\n}", "label": 1, "cwe": "CWE-other", "length": 943 }, { "index": 9823, "code": "utf8_int2char(unsigned int in, unsigned char* out)\n{\n if (in < 0x80)\n\treturn 0;\n if (in < 0x800)\n {\n\tif (out)\n\t{\n\t out[0] = 0xc0 + (in >> 6);\n\t out[1] = 0x80 + ((in >> 0) & 0x3f);\n\t}\n\treturn 2;\n }\n if (in < 0x10000)\n {\n\tif (out)\n\t{\n\t out[0] = 0xe0 + (in >> 12);\n\t out[1] = 0x80 + ((in >> 6) & 0x3f);\n\t out[2] = 0x80 + ((in >> 0) & 0x3f);\n\t}\n\treturn 3;\n }\n if (in < 0x200000)\n {\n\tif (out)\n\t{\n\t out[0] = 0xf0 + (in >> 18);\n\t out[1] = 0x80 + ((in >> 12) & 0x3f);\n\t out[2] = 0x80 + ((in >> 6) & 0x3f);\n\t out[3] = 0x80 + ((in >> 0) & 0x3f);\n\t}\n\treturn 4;\n }\n if (in < 0x4000000)\n {\n\tif (out)\n\t{\n\t out[0] = 0xf8 + (in >> 24);\n\t out[1] = 0x80 + ((in >> 18) & 0x3f);\n\t out[2] = 0x80 + ((in >> 12) & 0x3f);\n\t out[3] = 0x80 + ((in >> 6) & 0x3f);\n\t out[4] = 0x80 + ((in >> 0) & 0x3f);\n\t}\n\treturn 5;\n }\n else\n {\n\tif (out)\n\t{\n\t out[0] = 0xf8 + (in >> 30);\n\t out[1] = 0x80 + ((in >> 24) & 0x3f);\n\t out[2] = 0x80 + ((in >> 18) & 0x3f);\n\t out[3] = 0x80 + ((in >> 12) & 0x3f);\n\t out[4] = 0x80 + ((in >> 6) & 0x3f);\n\t out[5] = 0x80 + ((in >> 0) & 0x3f);\n\t}\n\treturn 6;\n }\n}", "label": 0, "cwe": null, "length": 603 }, { "index": 164449, "code": "xsltCopyNamespaceList(xsltTransformContextPtr ctxt, xmlNodePtr node,\n\t xmlNsPtr cur) {\n xmlNsPtr ret = NULL, tmp;\n xmlNsPtr p = NULL,q; \n\n if (cur == NULL)\n\treturn(NULL);\n if (cur->type != XML_NAMESPACE_DECL)\n\treturn(NULL);\n\n /*\n * One can add namespaces only on element nodes\n */\n if ((node != NULL) && (node->type != XML_ELEMENT_NODE))\n\tnode = NULL;\n\n while (cur != NULL) {\n\tif (cur->type != XML_NAMESPACE_DECL)\n\t break;\n\n\t/*\n\t * Avoid duplicating namespace declarations in the tree if\n\t * a matching declaration is in scope.\n\t */\n\tif (node != NULL) {\n\t if ((node->ns != NULL) &&\n\t\t(xmlStrEqual(node->ns->prefix, cur->prefix)) &&\n \t(xmlStrEqual(node->ns->href, cur->href))) {\n\t\tcur = cur->next;\n\t\tcontinue;\n\t }\n\t tmp = xmlSearchNs(node->doc, node, cur->prefix);\n\t if ((tmp != NULL) && (xmlStrEqual(tmp->href, cur->href))) {\n\t\tcur = cur->next;\n\t\tcontinue;\n\t }\n\t}\n#ifdef XSLT_REFACTORED\n\t/*\n\t* Namespace exclusion and ns-aliasing is performed at\n\t* compilation-time in the refactored code.\n\t*/\n\tq = xmlNewNs(node, cur->href, cur->prefix);\n\tif (p == NULL) {\n\t ret = p = q;\n\t} else {\n\t p->next = q;\n\t p = q;\n\t}\n#else\n\t/*\n\t* TODO: Remove this if the refactored code gets enabled.\n\t*/\n\tif (!xmlStrEqual(cur->href, XSLT_NAMESPACE)) {\n\t const xmlChar *URI;\n\t /* TODO apply cascading */\n\t URI = (const xmlChar *) xmlHashLookup(ctxt->style->nsAliases,\n\t\t cur->href);\n\t if (URI == UNDEFINED_DEFAULT_NS)\n\t continue;\n\t if (URI != NULL) {\n\t\tq = xmlNewNs(node, URI, cur->prefix);\n\t } else {\n\t\tq = xmlNewNs(node, cur->href, cur->prefix);\n\t }\n\t if (p == NULL) {\n\t\tret = p = q;\n\t } else {\n\t\tp->next = q;\n\t\tp = q;\n\t }\n\t}\n#endif\n\tcur = cur->next;\n }\n return(ret);\n}", "label": 0, "cwe": null, "length": 528 }, { "index": 89029, "code": "mii_check_media ( struct mii_if_info *mii,\n unsigned int ok_to_print,\n unsigned int init_media )\n{\n\tunsigned int old_carrier, new_carrier;\n\tint advertise, lpa, media, duplex;\n\tint lpa2 = 0;\n\n\t/* if forced media, go no further */\n\tif (mii->force_media)\n\t\treturn 0; /* duplex did not change */\n\n\t/* check current and old link status */\n\told_carrier = netdev_link_ok ( mii->dev ) ? 1 : 0;\n\tnew_carrier = (unsigned int) mii_link_ok ( mii );\n\n\t/* if carrier state did not change, this is a \"bounce\",\n\t * just exit as everything is already set correctly\n\t */\n\tif ( ( ! init_media ) && ( old_carrier == new_carrier ) )\n\t\treturn 0; /* duplex did not change */\n\n\t/* no carrier, nothing much to do */\n\tif ( ! new_carrier ) {\n\t\tnetdev_link_down ( mii->dev );\n\t\tif ( ok_to_print )\n\t\t\tDBG ( \"%s: link down\\n\", mii->dev->name);\n\t\treturn 0; /* duplex did not change */\n\t}\n\n\t/*\n\t * we have carrier, see who's on the other end\n\t */\n\tnetdev_link_up ( mii->dev );\n\n\t/* get MII advertise and LPA values */\n\tif ( ( ! init_media ) && ( mii->advertising ) ) {\n\t\tadvertise = mii->advertising;\n\t} else {\n\t\tadvertise = mii->mdio_read ( mii->dev, mii->phy_id, MII_ADVERTISE );\n\t\tmii->advertising = advertise;\n\t}\n\tlpa = mii->mdio_read ( mii->dev, mii->phy_id, MII_LPA );\n\tif ( mii->supports_gmii )\n\t\tlpa2 = mii->mdio_read ( mii->dev, mii->phy_id, MII_STAT1000 );\n\n\t/* figure out media and duplex from advertise and LPA values */\n\tmedia = mii_nway_result ( lpa & advertise );\n\tduplex = ( media & ADVERTISE_FULL ) ? 1 : 0;\n\tif ( lpa2 & LPA_1000FULL )\n\t\tduplex = 1;\n\n\tif ( ok_to_print )\n\t\tDBG ( \"%s: link up, %sMbps, %s-duplex, lpa 0x%04X\\n\",\n\t\t mii->dev->name,\n\t\t lpa2 & ( LPA_1000FULL | LPA_1000HALF ) ? \"1000\" :\n\t\t media & ( ADVERTISE_100FULL | ADVERTISE_100HALF ) ? \"100\" : \"10\",\n\t\t duplex ? \"full\" : \"half\",\n\t\t lpa);\n\n\tif ( ( init_media ) || ( mii->full_duplex != duplex ) ) {\n\t\tmii->full_duplex = duplex;\n\t\treturn 1; /* duplex changed */\n\t}\n\n\treturn 0; /* duplex did not change */\n}", "label": 0, "cwe": null, "length": 657 }, { "index": 26556, "code": "toString( int &exceptioncode )\n{\n if (m_detached) {\n exceptioncode = DOMException::INVALID_STATE_ERR;\n return DOMString();\n }\n\n DOMString text = \"\";\n NodeImpl *n = m_startContainer;\n\n /* This function converts a dom range to the plain text string that the user would see in this\n * portion of rendered html.\n *\n * There are several ways ranges can be used.\n *\n * The simplest is the start and endContainer is a text node. The start and end offset is the\n * number of characters into the text to remove/truncate.\n *\n * The next case is the start and endContainer is, well, a container, such a P tag or DIV tag.\n * In this case the start and end offset is the number of children into the container to start\n * from and end at.\n *\n * The other cases are different arrangements of the first two.\n *\n * pseudo code:\n *\n * if start container is not text:\n * count through the children to find where we start (m_startOffset children)\n *\n * loop from the start position:\n * if the current node is text, add the text to our variable 'text', truncating/removing if at the end/start.\n *\n * if the node has children, step to the first child.\n * if the node has no children but does have siblings, step to the next sibling\n * until we find a sibling, go to next the parent but:\n * make sure this sibling isn't past the end of where we are supposed to go. (position > endOffset and the parent is the endContainer)\n *\n */\n\n\n if( m_startContainer == m_endContainer && m_startOffset >= m_endOffset)\n\treturn text;\n\n\n if(n->firstChild()) {\n\tn = n->firstChild();\n \tint current_offset = m_startOffset;\n\twhile(current_offset-- && n) {\n\t n = n->nextSibling();\n\t}\n }\n\n while(n) {\n if(n == m_endContainer && m_endOffset == 0)\n break;\n if(n->nodeType() == DOM::Node::TEXT_NODE ||\n n->nodeType() == DOM::Node::CDATA_SECTION_NODE) {\n\n DOMString str = static_cast(n)->string();\n\t if( n == m_endContainer || n == m_startContainer)\n\t str = str.copy(); //copy if we are going to modify.\n\n if (n == m_endContainer)\n str.truncate(m_endOffset);\n if (n == m_startContainer)\n str.remove(0,m_startOffset);\n\t text += str;\n\t if (n == m_endContainer)\n break;\n }\n\n\n\tNodeImpl *next = n->firstChild();\n\tif(!next)\n next = n->nextSibling();\n\n while( !next && n->parentNode() ) {\n if (n == m_endContainer) return text;\n n = n->parentNode();\n if (n == m_endContainer) return text;\n next = n->nextSibling();\n }\n\n if(n->parentNode() == m_endContainer) {\n if(!next) break;\n\t unsigned long current_offset = 0;\n\t NodeImpl *it = n;\n\t while((it = it->previousSibling())) ++current_offset;\n\t if(current_offset >= m_endOffset) {\n\t break;\n\t }\n\t}\n\n n = next;\n }\n return text;\n}", "label": 0, "cwe": null, "length": 740 }, { "index": 25236, "code": "EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src)\n\t{\n\tEC_EXTRA_DATA *d;\n\n\tif (dest->meth->group_copy == 0)\n\t\t{\n\t\tECerr(EC_F_EC_GROUP_COPY, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);\n\t\treturn 0;\n\t\t}\n\tif (dest->meth != src->meth)\n\t\t{\n\t\tECerr(EC_F_EC_GROUP_COPY, EC_R_INCOMPATIBLE_OBJECTS);\n\t\treturn 0;\n\t\t}\n\tif (dest == src)\n\t\treturn 1;\n\t\n\tEC_EX_DATA_free_all_data(&dest->extra_data);\n\n\tfor (d = src->extra_data; d != NULL; d = d->next)\n\t\t{\n\t\tvoid *t = d->dup_func(d->data);\n\t\t\n\t\tif (t == NULL)\n\t\t\treturn 0;\n\t\tif (!EC_EX_DATA_set_data(&dest->extra_data, t, d->dup_func, d->free_func, d->clear_free_func))\n\t\t\treturn 0;\n\t\t}\n\n\tif (src->generator != NULL)\n\t\t{\n\t\tif (dest->generator == NULL)\n\t\t\t{\n\t\t\tdest->generator = EC_POINT_new(dest);\n\t\t\tif (dest->generator == NULL) return 0;\n\t\t\t}\n\t\tif (!EC_POINT_copy(dest->generator, src->generator)) return 0;\n\t\t}\n\telse\n\t\t{\n\t\t/* src->generator == NULL */\n\t\tif (dest->generator != NULL)\n\t\t\t{\n\t\t\tEC_POINT_clear_free(dest->generator);\n\t\t\tdest->generator = NULL;\n\t\t\t}\n\t\t}\n\n\tif (!BN_copy(&dest->order, &src->order)) return 0;\n\tif (!BN_copy(&dest->cofactor, &src->cofactor)) return 0;\n\n\tdest->curve_name = src->curve_name;\n\tdest->asn1_flag = src->asn1_flag;\n\tdest->asn1_form = src->asn1_form;\n\n\tif (src->seed)\n\t\t{\n\t\tif (dest->seed)\n\t\t\tOPENSSL_free(dest->seed);\n\t\tdest->seed = OPENSSL_malloc(src->seed_len);\n\t\tif (dest->seed == NULL)\n\t\t\treturn 0;\n\t\tif (!memcpy(dest->seed, src->seed, src->seed_len))\n\t\t\treturn 0;\n\t\tdest->seed_len = src->seed_len;\n\t\t}\n\telse\n\t\t{\n\t\tif (dest->seed)\n\t\t\tOPENSSL_free(dest->seed);\n\t\tdest->seed = NULL;\n\t\tdest->seed_len = 0;\n\t\t}\n\t\n\n\treturn dest->meth->group_copy(dest, src);\n\t}", "label": 0, "cwe": null, "length": 556 }, { "index": 110644, "code": "imap_body_type_mpart_to_body(struct mailimap_body_type_mpart *\n\t\t\t type_mpart,\n\t\t\t struct mailmime ** result)\n{\n struct mailmime_fields * mime_fields;\n struct mailmime_composite_type * composite_type;\n struct mailmime_type * mime_type;\n struct mailmime_content * content_type;\n struct mailmime * body;\n clistiter * cur;\n clist * list;\n int r;\n int res;\n uint32_t mime_size;\n\n if (type_mpart->bd_ext_mpart == NULL) {\n mime_fields = mailmime_fields_new_empty();\n mime_size = 0;\n r = MAIL_NO_ERROR;\n }\n else {\n r = imap_body_fields_to_mime_fields(NULL,\n type_mpart->bd_ext_mpart->bd_disposition,\n type_mpart->bd_ext_mpart->bd_language,\n &mime_fields, &mime_size);\n }\n if (r != MAIL_NO_ERROR) {\n res = r;\n goto err;\n }\n\n composite_type =\n mailmime_composite_type_new(MAILMIME_COMPOSITE_TYPE_MULTIPART,\n\t\t\t\tNULL);\n if (composite_type == NULL) {\n res = MAIL_ERROR_MEMORY;\n goto free_fields;\n }\n \n mime_type = mailmime_type_new(MAILMIME_TYPE_COMPOSITE_TYPE,\n\t\t\t\tNULL, composite_type);\n if (mime_type == NULL) {\n mailmime_composite_type_free(composite_type);\n res = MAIL_ERROR_MEMORY;\n goto free_fields;\n }\n\n if (type_mpart->bd_ext_mpart == NULL) {\n r = imap_body_parameter_to_content(NULL,\n type_mpart->bd_media_subtype,\n mime_type, &content_type);\n }\n else {\n r = imap_body_parameter_to_content(type_mpart->bd_ext_mpart->bd_parameter,\n type_mpart->bd_media_subtype,\n mime_type, &content_type);\n }\n if (r != MAIL_NO_ERROR) {\n mailmime_type_free(mime_type);\n res = r;\n goto free_fields;\n }\n\n list = clist_new();\n if (list == NULL) {\n res = MAIL_ERROR_MEMORY;\n goto free_content;\n }\n\n for(cur = clist_begin(type_mpart->bd_list) ; cur != NULL ;\n cur = clist_next(cur)) {\n struct mailimap_body * imap_body;\n struct mailmime * sub_body;\n\n imap_body = clist_content(cur);\n\n r = imap_body_to_body(imap_body, &sub_body);\n if (r != MAIL_NO_ERROR) {\n res = r;\n goto free_list;\n }\n\n r = clist_append(list, sub_body);\n if (r != 0) {\n mailmime_free(sub_body);\n res = r;\n goto free_list;\n }\n }\n\n body = mailmime_new(MAILMIME_MULTIPLE, NULL,\n mime_size, mime_fields, content_type,\n NULL, NULL, NULL, list, NULL, NULL);\n\n if (body == NULL) {\n res = MAIL_ERROR_MEMORY;\n goto free_list;\n }\n\n * result = body;\n\n return MAIL_NO_ERROR;\n\n free_list:\n clist_foreach(list, (clist_func) mailmime_free, NULL);\n clist_free(list);\n free_content:\n mailmime_content_free(content_type);\n free_fields:\n mailmime_fields_free(mime_fields);\n err:\n return res;\n}", "label": 0, "cwe": null, "length": 728 }, { "index": 406870, "code": "s5p_mfc_reset(struct s5p_mfc_dev *dev)\n{\n\tunsigned int mc_status;\n\tunsigned long timeout;\n\tint i;\n\n\tmfc_debug_enter();\n\n\tif (IS_MFCV6_PLUS(dev)) {\n\t\t/* Zero Initialization of MFC registers */\n\t\tmfc_write(dev, 0, S5P_FIMV_RISC2HOST_CMD_V6);\n\t\tmfc_write(dev, 0, S5P_FIMV_HOST2RISC_CMD_V6);\n\t\tmfc_write(dev, 0, S5P_FIMV_FW_VERSION_V6);\n\n\t\tfor (i = 0; i < S5P_FIMV_REG_CLEAR_COUNT_V6; i++)\n\t\t\tmfc_write(dev, 0, S5P_FIMV_REG_CLEAR_BEGIN_V6 + (i*4));\n\n\t\t/* check bus reset control before reset */\n\t\tif (dev->risc_on)\n\t\t\tif (s5p_mfc_bus_reset(dev))\n\t\t\t\treturn -EIO;\n\t\t/* Reset\n\t\t * set RISC_ON to 0 during power_on & wake_up.\n\t\t * V6 needs RISC_ON set to 0 during reset also.\n\t\t */\n\t\tif ((!dev->risc_on) || (!IS_MFCV7_PLUS(dev)))\n\t\t\tmfc_write(dev, 0, S5P_FIMV_RISC_ON_V6);\n\n\t\tmfc_write(dev, 0x1FFF, S5P_FIMV_MFC_RESET_V6);\n\t\tmfc_write(dev, 0, S5P_FIMV_MFC_RESET_V6);\n\t} else {\n\t\t/* Stop procedure */\n\t\t/* reset RISC */\n\t\tmfc_write(dev, 0x3f6, S5P_FIMV_SW_RESET);\n\t\t/* All reset except for MC */\n\t\tmfc_write(dev, 0x3e2, S5P_FIMV_SW_RESET);\n\t\tmdelay(10);\n\n\t\ttimeout = jiffies + msecs_to_jiffies(MFC_BW_TIMEOUT);\n\t\t/* Check MC status */\n\t\tdo {\n\t\t\tif (time_after(jiffies, timeout)) {\n\t\t\t\tmfc_err(\"Timeout while resetting MFC\\n\");\n\t\t\t\treturn -EIO;\n\t\t\t}\n\n\t\t\tmc_status = mfc_read(dev, S5P_FIMV_MC_STATUS);\n\n\t\t} while (mc_status & 0x3);\n\n\t\tmfc_write(dev, 0x0, S5P_FIMV_SW_RESET);\n\t\tmfc_write(dev, 0x3fe, S5P_FIMV_SW_RESET);\n\t}\n\n\tmfc_debug_leave();\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 554 }, { "index": 184109, "code": "gen_k( gcry_mpi_t p, int small_k )\n{\n gcry_mpi_t k = mpi_alloc_secure( 0 );\n gcry_mpi_t temp = mpi_alloc( mpi_get_nlimbs(p) );\n gcry_mpi_t p_1 = mpi_copy(p);\n unsigned int orig_nbits = mpi_get_nbits(p);\n unsigned int nbits, nbytes;\n char *rndbuf = NULL;\n\n if (small_k)\n {\n /* Using a k much lesser than p is sufficient for encryption and\n * it greatly improves the encryption performance. We use\n * Wiener's table and add a large safety margin. */\n nbits = wiener_map( orig_nbits ) * 3 / 2;\n if( nbits >= orig_nbits )\n BUG();\n }\n else\n nbits = orig_nbits;\n\n\n nbytes = (nbits+7)/8;\n if( DBG_CIPHER )\n log_debug(\"choosing a random k \");\n mpi_sub_ui( p_1, p, 1);\n for(;;)\n {\n if( !rndbuf || nbits < 32 )\n {\n gcry_free(rndbuf);\n rndbuf = gcry_random_bytes_secure( nbytes, GCRY_STRONG_RANDOM );\n }\n else\n {\n /* Change only some of the higher bits. We could improve\n this by directly requesting more memory at the first call\n to get_random_bytes() and use this the here maybe it is\n easier to do this directly in random.c Anyway, it is\n highly inlikely that we will ever reach this code. */\n char *pp = gcry_random_bytes_secure( 4, GCRY_STRONG_RANDOM );\n memcpy( rndbuf, pp, 4 );\n gcry_free(pp);\n\t}\n _gcry_mpi_set_buffer( k, rndbuf, nbytes, 0 );\n\n for(;;)\n {\n if( !(mpi_cmp( k, p_1 ) < 0) ) /* check: k < (p-1) */\n {\n if( DBG_CIPHER )\n progress('+');\n break; /* no */\n }\n if( !(mpi_cmp_ui( k, 0 ) > 0) ) /* check: k > 0 */\n {\n if( DBG_CIPHER )\n progress('-');\n break; /* no */\n }\n if (gcry_mpi_gcd( temp, k, p_1 ))\n goto found; /* okay, k is relative prime to (p-1) */\n mpi_add_ui( k, k, 1 );\n if( DBG_CIPHER )\n progress('.');\n\t}\n }\n found:\n gcry_free(rndbuf);\n if( DBG_CIPHER )\n progress('\\n');\n mpi_free(p_1);\n mpi_free(temp);\n\n return k;\n}", "label": 0, "cwe": null, "length": 610 }, { "index": 44953, "code": "update_ip6_setting_from_if_block(NMConnection *connection,\n\t\t\t\t\t\t if_block *block,\n\t\t\t\t\t\t GError **error)\n{\n\tNMSettingIP6Config *s_ip6 = NM_SETTING_IP6_CONFIG (nm_setting_ip6_config_new());\n\tconst char *type = ifparser_getkey(block, \"inet6\");\n\tgboolean is_static = type && (!strcmp(\"static\", type) ||\n\t\t\t\t\t\t\t!strcmp(\"v4tunnel\", type));\n\n\tif (!is_static) {\n\t\tg_object_set(s_ip6, NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO, NULL);\n\t} else {\n\t\tstruct in6_addr tmp_addr, tmp_gw;\n\t\tNMIP6Address *addr;\n\t\tconst char *address_v;\n\t\tconst char *prefix_v;\n\t\tconst char *gateway_v;\n\t\tconst char *nameserver_v;\n\t\tconst char *nameservers_v;\n\t\tconst char *search_v;\n\t\tint prefix_int = 128;\n\t\tchar **list, **iter;\n\n\t\t/* Address */\n\t\taddress_v = ifparser_getkey(block, \"address\");\n\t\tif (!address_v || !inet_pton (AF_INET6, address_v, &tmp_addr)) {\n\t\t\tg_set_error (error, eni_plugin_error_quark (), 0,\n\t\t\t \"Missing IPv6 address '%s'\",\n\t\t\t address_v ? address_v : \"(none)\");\n\t\t\tgoto error;\n\t\t}\n\n\t\t/* Prefix */\n\t\tprefix_v = ifparser_getkey(block, \"netmask\");\n\t\tif (prefix_v)\n\t\t\tprefix_int = g_ascii_strtoll (prefix_v, NULL, 10);\n\n\t\t/* Gateway */\n\t\tgateway_v = ifparser_getkey (block, \"gateway\");\n\t\tif (!gateway_v)\n\t\t\tgateway_v = address_v; /* dcbw: whaaa?? */\n\t\tif (!inet_pton (AF_INET6, gateway_v, &tmp_gw)) {\n\t\t\tg_set_error (error, eni_plugin_error_quark (), 0,\n\t\t\t\t\t \"Invalid IPv6 gateway '%s'\", gateway_v);\n\t\t\tgoto error;\n\t\t}\n\n\t\t/* Add the new address to the setting */\n\t\taddr = nm_ip6_address_new ();\n\t\tnm_ip6_address_set_address (addr, &tmp_addr);\n\t\tnm_ip6_address_set_prefix (addr, prefix_int);\n\t\tnm_ip6_address_set_gateway (addr, &tmp_gw);\n\n\t\tif (nm_setting_ip6_config_add_address (s_ip6, addr)) {\n\t\t\tPLUGIN_PRINT(\"SCPlugin-Ifupdown\", \"addresses count: %d\",\n\t\t\t\t\t nm_setting_ip6_config_get_num_addresses (s_ip6));\n\t\t} else {\n\t\t\tPLUGIN_PRINT(\"SCPlugin-Ifupdown\", \"ignoring duplicate IP6 address\");\n\t\t}\n\n\t\tnameserver_v = ifparser_getkey(block, \"dns-nameserver\");\n\t\tifupdown_ip6_add_dns (s_ip6, nameserver_v);\n\n\t\tnameservers_v = ifparser_getkey(block, \"dns-nameservers\");\n\t\tifupdown_ip6_add_dns (s_ip6, nameservers_v);\n\n\t\tif (!nm_setting_ip6_config_get_num_dns (s_ip6))\n\t\t\tPLUGIN_PRINT(\"SCPlugin-Ifupdown\", \"No dns-nameserver configured in /etc/network/interfaces\");\n\n\t\t/* DNS searches */\n\t\tsearch_v = ifparser_getkey (block, \"dns-search\");\n\t\tif (search_v) {\n\t\t\tlist = g_strsplit_set (search_v, \" \\t\", -1);\n\t\t\tfor (iter = list; iter && *iter; iter++) {\n\t\t\t\tg_strstrip (*iter);\n\t\t\t\tif (isblank (*iter[0]))\n\t\t\t\t\tcontinue;\n\t\t\t\tif (!nm_setting_ip6_config_add_dns_search (s_ip6, *iter)) {\n\t\t\t\t\tPLUGIN_WARN (\"SCPlugin-Ifupdown\",\n\t\t\t\t\t\t\t \" warning: duplicate DNS domain '%s'\", *iter);\n\t\t\t\t}\n\t\t\t}\n\t\t\tg_strfreev (list);\n\t\t}\n\n\t\tg_object_set (s_ip6,\n\t\t NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_MANUAL,\n\t\t NULL);\n\t}\n\n\tnm_connection_add_setting (connection, NM_SETTING (s_ip6));\n\treturn TRUE;\n\nerror:\n\tg_object_unref (s_ip6);\n\treturn FALSE;\n}", "label": 0, "cwe": null, "length": 899 }, { "index": 8048, "code": "kmo_wave_guess_table_update_2 (const char *filename,\n int ifu_nr, int global_ifu_nr, const char *filter_id,\n int flip_trace,\n cpl_matrix **fitpars) {\n\n// cpl_error_code error = CPL_ERROR_NONE;\n cpl_table* table = NULL;\n int selected_row = 0, i = 0;\n char *coeff_cols[NR_COEFFS_COLS] = {COEFF_COLS};\n double coeffs[NR_COEFFS_COLS];\n\n KMO_TRY\n {\n table = kmo_wave_guess_table_open(filename, 1);\n\n selected_row = kmo_wave_guess_table_get_column(table, filter_id, global_ifu_nr);\n\n for (i = 0; i < NR_COEFFS_COLS; i++) {\n cpl_matrix *col = cpl_matrix_extract_column(fitpars[ifu_nr-1], i);\n coeffs[i] = cpl_matrix_get_median(col);\n printf(\"coeffs distribution: %d %d: %g %g %g\\n\", ifu_nr, i,\n cpl_matrix_get_min(col),cpl_matrix_get_median(col),cpl_matrix_get_max(col));\n }\n\n if (!flip_trace) {\n double x = 2047.;\n KMO_TRY_EXIT_IF_ERROR(\n cpl_table_set_double(table, coeff_cols[0], selected_row,\n coeffs[0] + coeffs[1]*x + coeffs[2]*x*x + coeffs[3]*x*x*x ));\n KMO_TRY_EXIT_IF_ERROR(\n cpl_table_set_double(table, coeff_cols[1], selected_row,\n -coeffs[1] - 2*coeffs[2]*x - 3*coeffs[3]*x*x ));\n KMO_TRY_EXIT_IF_ERROR(\n cpl_table_set_double(table, coeff_cols[2], selected_row,\n coeffs[2] + 3*coeffs[3]*x ));\n KMO_TRY_EXIT_IF_ERROR(\n cpl_table_set_double(table, coeff_cols[3], selected_row,\n -coeffs[3]));\n } else {\n for (i = 0; i < NR_COEFFS_COLS; i++) {\n KMO_TRY_EXIT_IF_ERROR(\n cpl_table_set_double(table, coeff_cols[i], selected_row, coeffs[i]));\n }\n }\n\n int dummy;\n printf(\"coeffs to table: %g %g %g %g\\n\",\n cpl_table_get_double(table, coeff_cols[0], selected_row, &dummy),\n cpl_table_get_double(table, coeff_cols[1], selected_row, &dummy),\n cpl_table_get_double(table, coeff_cols[2], selected_row, &dummy),\n cpl_table_get_double(table, coeff_cols[3], selected_row, &dummy)\n );\n\n KMO_TRY_EXIT_IF_ERROR(\n cpl_table_fill_invalid_int(table, \"IFU\", -1));\n KMO_TRY_EXIT_IF_ERROR(\n cpl_table_save(table, NULL, NULL, filename, CPL_IO_CREATE));\n\n } KMO_CATCH {\n KMO_CATCH_MSG();\n }\n cpl_table_delete(table);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 674 }, { "index": 928447, "code": "get_charset_aliases ()\n{\n const char *cp;\n\n cp = charset_aliases;\n if (cp == NULL)\n {\n#ifndef WIN32\n FILE *fp;\n const char *dir = LIBDIR;\n const char *base = \"charset.alias\";\n char *file_name;\n\n /* Concatenate dir and base into freshly allocated file_name. */\n {\n\tsize_t dir_len = strlen (dir);\n\tsize_t base_len = strlen (base);\n\tint add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));\n\tfile_name = (char *) malloc (dir_len + add_slash + base_len + 1);\n\tif (file_name != NULL)\n\t {\n\t memcpy (file_name, dir, dir_len);\n\t if (add_slash)\n\t file_name[dir_len] = DIRECTORY_SEPARATOR;\n\t memcpy (file_name + dir_len + add_slash, base, base_len + 1);\n\t }\n }\n\n if (file_name == NULL || (fp = fopen (file_name, \"r\")) == NULL)\n\t/* Out of memory or file not found, treat it as empty. */\n\tcp = \"\";\n else\n\t{\n\t /* Parse the file's contents. */\n\t int c;\n\t char buf1[50+1];\n\t char buf2[50+1];\n\t char *res_ptr = NULL;\n\t size_t res_size = 0;\n\t size_t l1, l2;\n\n\t for (;;)\n\t {\n\t c = getc (fp);\n\t if (c == EOF)\n\t\tbreak;\n\t if (c == '\\n' || c == ' ' || c == '\\t')\n\t\tcontinue;\n\t if (c == '#')\n\t\t{\n\t\t /* Skip comment, to end of line. */\n\t\t do\n\t\t c = getc (fp);\n\t\t while (!(c == EOF || c == '\\n'));\n\t\t if (c == EOF)\n\t\t break;\n\t\t continue;\n\t\t}\n\t ungetc (c, fp);\n\t if (fscanf(fp, \"%50s %50s\", buf1, buf2) < 2)\n\t\tbreak;\n\t l1 = strlen (buf1);\n\t l2 = strlen (buf2);\n\t if (res_size == 0)\n\t\t{\n\t\t res_size = l1 + 1 + l2 + 1;\n\t\t res_ptr = malloc (res_size + 1);\n\t\t}\n\t else\n\t\t{\n\t\t res_size += l1 + 1 + l2 + 1;\n\t\t res_ptr = realloc (res_ptr, res_size + 1);\n\t\t}\n\t if (res_ptr == NULL)\n\t\t{\n\t\t /* Out of memory. */\n\t\t res_size = 0;\n\t\t break;\n\t\t}\n\t strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);\n\t strcpy (res_ptr + res_size - (l2 + 1), buf2);\n\t }\n\t fclose (fp);\n\t if (res_size == 0)\n\t cp = \"\";\n\t else\n\t {\n\t *(res_ptr + res_size) = '\\0';\n\t cp = res_ptr;\n\t }\n\t}\n\n if (file_name != NULL)\n\tfree (file_name);\n\n#else /* WIN32 */\n\n /* To avoid the troubles of installing a separate file in the same\n\t directory as the DLL and of retrieving the DLL's directory at\n\t runtime, simply inline the aliases here. */\n\n cp = \"CP936\" \"\\0\" \"GBK\" \"\\0\"\n\t \"CP1361\" \"\\0\" \"JOHAB\" \"\\0\";\n#endif\n\n charset_aliases = cp;\n }\n\n return cp;\n}", "label": 0, "cwe": null, "length": 781 }, { "index": 270812, "code": "enable_buttons()\n{\n sharedptr layout_item_available;\n bool enable_add = false;\n\n //Available Parts:\n Glib::RefPtr refSelectionAvailable = m_treeview_available_parts->get_selection();\n if(refSelectionAvailable)\n {\n Gtk::TreeModel::iterator iter = refSelectionAvailable->get_selected();\n if(iter)\n {\n layout_item_available = (*iter)[m_model_available_parts_main->m_columns.m_col_item];\n\n enable_add = true;\n }\n else\n {\n enable_add = false;\n }\n }\n\n sharedptr layout_item_parent;\n\n Gtk::TreeView* treeview = get_selected_treeview();\n if(!treeview)\n return;\n\n Glib::RefPtr model = get_selected_model();\n\n //Parts:\n Glib::RefPtr refSelection = treeview->get_selection();\n if(refSelection)\n {\n Gtk::TreeModel::iterator iter = refSelection->get_selected();\n if(iter)\n {\n layout_item_parent = (*iter)[model->m_columns.m_col_item];\n\n //Disable Up if It can't go any higher.\n bool enable_up = true;\n if(iter == model->children().begin())\n enable_up = false; //It can't go any higher.\n\n m_button_up->set_sensitive(enable_up);\n\n\n //Disable Down if It can't go any lower.\n Gtk::TreeModel::iterator iterNext = iter;\n iterNext++;\n\n bool enable_down = true;\n if(iterNext == model->children().end())\n enable_down = false;\n\n m_button_down->set_sensitive(enable_down);\n\n m_button_delete->set_sensitive(true);\n\n //The [Formatting] button:\n bool enable_formatting = false;\n sharedptr item_field = sharedptr::cast_dynamic(layout_item_parent);\n if(item_field)\n enable_formatting = true;\n\n m_button_formatting->set_sensitive(enable_formatting);\n\n //m_button_formatting->set_sensitive( (*iter)[m_columns_parts->m_columns.m_col_type] == TreeStore_Layout::TYPE_FIELD);\n }\n else\n {\n //Disable all buttons that act on a selection:\n m_button_down->set_sensitive(false);\n m_button_up->set_sensitive(false);\n m_button_delete->set_sensitive(false);\n m_button_formatting->set_sensitive(false);\n }\n\n //Not all parts may be children of all other parts.\n if(layout_item_available && layout_item_parent)\n {\n const bool may_be_child_of_parent = TreeStore_ReportLayout::may_be_child_of(layout_item_parent, layout_item_available);\n enable_add = may_be_child_of_parent;\n\n if(!may_be_child_of_parent)\n {\n //Maybe it can be a sibling of the parent instead (and that's what would happen if Add was clicked).\n sharedptr layout_item_parent_of_parent;\n\n Gtk::TreeModel::iterator iterParent = iter->parent();\n if(iterParent)\n layout_item_parent_of_parent = (*iterParent)[model->m_columns.m_col_item];\n\n enable_add = TreeStore_ReportLayout::may_be_child_of(layout_item_parent_of_parent, layout_item_available);\n }\n }\n }\n\n m_button_add->set_sensitive(enable_add);\n}", "label": 0, "cwe": null, "length": 707 }, { "index": 45586, "code": "udisks_object_skeleton_get_property (GObject *gobject,\n guint prop_id,\n GValue *value,\n GParamSpec *pspec)\n{\n UDisksObjectSkeleton *object = UDISKS_OBJECT_SKELETON (gobject);\n GDBusInterface *interface;\n\n switch (prop_id)\n {\n case 1:\n interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), \"org.freedesktop.UDisks2.Manager\");\n g_value_take_object (value, interface);\n break;\n\n case 2:\n interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), \"org.freedesktop.UDisks2.Drive\");\n g_value_take_object (value, interface);\n break;\n\n case 3:\n interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), \"org.freedesktop.UDisks2.Drive.Ata\");\n g_value_take_object (value, interface);\n break;\n\n case 4:\n interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), \"org.freedesktop.UDisks2.Block\");\n g_value_take_object (value, interface);\n break;\n\n case 5:\n interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), \"org.freedesktop.UDisks2.PartitionTable\");\n g_value_take_object (value, interface);\n break;\n\n case 6:\n interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), \"org.freedesktop.UDisks2.Partition\");\n g_value_take_object (value, interface);\n break;\n\n case 7:\n interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), \"org.freedesktop.UDisks2.Filesystem\");\n g_value_take_object (value, interface);\n break;\n\n case 8:\n interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), \"org.freedesktop.UDisks2.Swapspace\");\n g_value_take_object (value, interface);\n break;\n\n case 9:\n interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), \"org.freedesktop.UDisks2.Encrypted\");\n g_value_take_object (value, interface);\n break;\n\n case 10:\n interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), \"org.freedesktop.UDisks2.Loop\");\n g_value_take_object (value, interface);\n break;\n\n case 11:\n interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), \"org.freedesktop.UDisks2.MDRaid\");\n g_value_take_object (value, interface);\n break;\n\n case 12:\n interface = g_dbus_object_get_interface (G_DBUS_OBJECT (object), \"org.freedesktop.UDisks2.Job\");\n g_value_take_object (value, interface);\n break;\n\n default:\n G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);\n break;\n }\n}", "label": 0, "cwe": null, "length": 668 }, { "index": 57027, "code": "WavInit()\n//PRE: fileName corresponds to a valid .wav file.\n//POST: wavData has been initialized to contain all samples of audio data from the file\n// denoted by fileName. fileSize, numChannels, sampleRate, qLevel, samplesPerChannel,\n// and songLength have been set according to information in the .wav file header.\n{\n unsigned char holder[4]; //holds up to 4 bytes of raw data from file\n ifstream inFile(fileName.c_str(), ios::binary); //pointer to input wave file\n\n // READ WAV HEADER\n // (WAV Header Reference: http://ccrma.stanford.edu/courses/422/projects/WaveFormat/)\n // We ignore parts of the header that do not vary based upon the sound. (Compare to WriteHeader.)\n // All data is stored in Little Endian format, hence bytes are reversed from \"natural\" order. We\n // reverse this using LittleEndianCharToInt.\n\n inFile.seekg(0x4); //bytes 4, 5, 6, 7 contain the file size\n inFile.read(reinterpret_cast(holder), 4); // in B - 8 (for part of the header)\n fileSize = Utility::LittleEndianCharToInt(holder, 4)+8;\n\n inFile.seekg(0x16); //bytes 16 and 17 contain the number of channels\n inFile.read(reinterpret_cast(holder), 2);\n numChannels = Utility::LittleEndianCharToInt(holder, 2);\n\n inFile.seekg(0x18); //bytes 18, 19, 20, and 21 contain the sample\n inFile.read(reinterpret_cast(holder), 4); // rate in Hz\n sampleRate = Utility::LittleEndianCharToInt(holder, 4);\n\n inFile.seekg(0x22); //bytes 22 and 23 contain the quantization level\n inFile.read(reinterpret_cast(holder), 2); // level, i.e. significant bits/sample\n qLevel = Utility::LittleEndianCharToInt(holder, 2);\n\n samplesPerChannel = fileSize-HEADERSIZE; //begin calculation of how many samples of data\n // we have per channel by assuming file is only\n // header bytes and sample bytes\n\n inFile.seekg(fileSize-MSFOOTERSIZE); //check if there's a Microsoft-generated footer\n inFile.read(reinterpret_cast(holder), 4); // at the end of the file...\n\n if (Utility::LittleEndianCharToInt(holder, 4) == 0x5453494C || //footer would begin with bytes reading \"list\" or\n Utility::LittleEndianCharToInt(holder, 4) == 0x7473696C) // \"LIST\" in little endian (hence reversed ASCII here)\n samplesPerChannel -= MSFOOTERSIZE; //subtract header size from # samples if so\n\n samplesPerChannel /= numChannels*2; //each sample takes 2 bytes and we want samples per\n // channel, so divide accordingly\n\n songLength = double(samplesPerChannel)/sampleRate; //sample rate in samples/second. dimensional analysis\n // gives us the song length in seconds\n\n // ALLOCATE MEMORY FOR SAMPLES\n\n wavData = new vector[numChannels]; //create a vector for each channel's sound data\n\n for(int i=0; i < numChannels; i++) //...and size it\n wavData[i].resize(samplesPerChannel);\n\n // READ ACTUAL SAMPLE DATA\n\n inFile.seekg(0x2C); //actual sound data starts right after the header\n\n cout << \"Loading \" << fileName << \"...\\n\";\n\n for (int i=0; i < samplesPerChannel; i++) //read each sample, samples contain all channels\n { // grouped together\n Utility::Bar(cout, i, samplesPerChannel); //display progress bar\n\n for (int j=0; j < numChannels; j++) //read data for all channels of this sample\n {\n inFile.read(reinterpret_cast(holder), 2);\n wavData[j][i] = ChannelAmp(holder); //store it as a value between -1 and 1\n }\n }\n\n Utility::Bar(cout, samplesPerChannel, samplesPerChannel); //display progress bar at the end of reading samples\n cout << endl;\n\n inFile.close();\n}", "label": 0, "cwe": null, "length": 973 }, { "index": 100661, "code": "load_plugin_module (GnomeSettingsPluginInfo *info)\n{\n char *path;\n char *dirname;\n gboolean ret;\n\n ret = FALSE;\n\n g_return_val_if_fail (GNOME_IS_SETTINGS_PLUGIN_INFO (info), FALSE);\n g_return_val_if_fail (info->priv->file != NULL, FALSE);\n g_return_val_if_fail (info->priv->location != NULL, FALSE);\n g_return_val_if_fail (info->priv->plugin == NULL, FALSE);\n g_return_val_if_fail (info->priv->available, FALSE);\n\n gnome_settings_profile_start (\"%s\", info->priv->location);\n\n dirname = g_path_get_dirname (info->priv->file);\n g_return_val_if_fail (dirname != NULL, FALSE);\n\n path = g_module_build_path (dirname, info->priv->location);\n g_free (dirname);\n g_return_val_if_fail (path != NULL, FALSE);\n\n info->priv->module = G_TYPE_MODULE (gnome_settings_module_new (path));\n g_free (path);\n\n if (!g_type_module_use (info->priv->module)) {\n g_warning (\"Cannot load plugin '%s' since file '%s' cannot be read.\",\n info->priv->name,\n gnome_settings_module_get_path (GNOME_SETTINGS_MODULE (info->priv->module)));\n\n g_object_unref (G_OBJECT (info->priv->module));\n info->priv->module = NULL;\n\n /* Mark plugin as unavailable and fails */\n info->priv->available = FALSE;\n\n goto out;\n }\n\n if (g_strcmp0 (g_getenv (\"XDG_CURRENT_DESKTOP\"), \"Unity\") == 0\n && g_strcmp0 (info->priv->name, \"Print-notifications\") == 0) {\n\n g_warning (\"Disable print plugin under Unity\");\n\n g_object_unref (G_OBJECT (info->priv->module));\n info->priv->module = NULL;\n\n /* Mark plugin as unavailable */\n info->priv->available = FALSE;\n\n goto out;\n }\n\n if (g_strcmp0 (g_getenv (\"XDG_CURRENT_DESKTOP\"), \"GNOME\") == 0\n && g_strcmp0 (info->priv->name, \"Background\") == 0) {\n\n g_warning (\"Disable background plugin when under gnome-shell\");\n\n g_object_unref (G_OBJECT (info->priv->module));\n info->priv->module = NULL;\n\n /* Mark plugin as unavailable */\n info->priv->available = FALSE;\n\n goto out;\n }\n\n\n info->priv->plugin = GNOME_SETTINGS_PLUGIN (gnome_settings_module_new_object (GNOME_SETTINGS_MODULE (info->priv->module)));\n\n g_type_module_unuse (info->priv->module);\n ret = TRUE;\n out:\n gnome_settings_profile_end (\"%s\", info->priv->location);\n return ret;\n}", "label": 0, "cwe": null, "length": 598 }, { "index": 391317, "code": "buflist_getfile(n, lnum, options, forceit)\n int\t\tn;\n linenr_T\tlnum;\n int\t\toptions;\n int\t\tforceit;\n{\n buf_T\t*buf;\n#ifdef FEAT_WINDOWS\n win_T\t*wp = NULL;\n#endif\n pos_T\t*fpos;\n colnr_T\tcol;\n\n buf = buflist_findnr(n);\n if (buf == NULL)\n {\n\tif ((options & GETF_ALT) && n == 0)\n\t EMSG(_(e_noalt));\n\telse\n\t EMSGN(_(\"E92: Buffer %ld not found\"), n);\n\treturn FAIL;\n }\n\n /* if alternate file is the current buffer, nothing to do */\n if (buf == curbuf)\n\treturn OK;\n\n if (text_locked())\n {\n\ttext_locked_msg();\n\treturn FAIL;\n }\n#ifdef FEAT_AUTOCMD\n if (curbuf_locked())\n\treturn FAIL;\n#endif\n\n /* altfpos may be changed by getfile(), get it now */\n if (lnum == 0)\n {\n\tfpos = buflist_findfpos(buf);\n\tlnum = fpos->lnum;\n\tcol = fpos->col;\n }\n else\n\tcol = 0;\n\n#ifdef FEAT_WINDOWS\n if (options & GETF_SWITCH)\n {\n\t/* If 'switchbuf' contains \"useopen\": jump to first window containing\n\t * \"buf\" if one exists */\n\tif (swb_flags & SWB_USEOPEN)\n\t wp = buf_jump_open_win(buf);\n\t/* If 'switchbuf' contians \"usetab\": jump to first window in any tab\n\t * page containing \"buf\" if one exists */\n\tif (wp == NULL && (swb_flags & SWB_USETAB))\n\t wp = buf_jump_open_tab(buf);\n\t/* If 'switchbuf' contains \"split\" or \"newtab\" and the current buffer\n\t * isn't empty: open new window */\n\tif (wp == NULL && (swb_flags & (SWB_SPLIT | SWB_NEWTAB)) && !bufempty())\n\t{\n\t if (swb_flags & SWB_NEWTAB)\t\t/* Open in a new tab */\n\t\ttabpage_new();\n\t else if (win_split(0, 0) == FAIL)\t/* Open in a new window */\n\t\treturn FAIL;\n# ifdef FEAT_SCROLLBIND\n\t curwin->w_p_scb = FALSE;\n# endif\n\t}\n }\n#endif\n\n ++RedrawingDisabled;\n if (getfile(buf->b_fnum, NULL, NULL, (options & GETF_SETMARK),\n\t\t\t\t\t\t\t lnum, forceit) <= 0)\n {\n\t--RedrawingDisabled;\n\n\t/* cursor is at to BOL and w_cursor.lnum is checked due to getfile() */\n\tif (!p_sol && col != 0)\n\t{\n\t curwin->w_cursor.col = col;\n\t check_cursor_col();\n#ifdef FEAT_VIRTUALEDIT\n\t curwin->w_cursor.coladd = 0;\n#endif\n\t curwin->w_set_curswant = TRUE;\n\t}\n\treturn OK;\n }\n --RedrawingDisabled;\n return FAIL;\n}", "label": 0, "cwe": null, "length": 680 }, { "index": 301640, "code": "handle_rvalue(ir_rvalue **ir)\n{\n int swizzle_chan[4];\n ir_dereference_variable *deref_var;\n ir_variable *source[4] = {NULL, NULL, NULL, NULL};\n int source_chan[4];\n int chans;\n\n if (!*ir)\n return;\n\n ir_swizzle *swizzle = (*ir)->as_swizzle();\n if (swizzle) {\n deref_var = swizzle->val->as_dereference_variable();\n if (!deref_var)\n\t return;\n\n swizzle_chan[0] = swizzle->mask.x;\n swizzle_chan[1] = swizzle->mask.y;\n swizzle_chan[2] = swizzle->mask.z;\n swizzle_chan[3] = swizzle->mask.w;\n chans = swizzle->type->vector_elements;\n } else {\n deref_var = (*ir)->as_dereference_variable();\n if (!deref_var)\n\t return;\n\n swizzle_chan[0] = 0;\n swizzle_chan[1] = 1;\n swizzle_chan[2] = 2;\n swizzle_chan[3] = 3;\n chans = deref_var->type->vector_elements;\n }\n\n if (this->in_assignee)\n return;\n\n ir_variable *var = deref_var->var;\n\n /* Try to find ACP entries covering swizzle_chan[], hoping they're\n * the same source variable.\n */\n foreach_iter(exec_list_iterator, iter, *this->acp) {\n acp_entry *entry = (acp_entry *)iter.get();\n\n if (var == entry->lhs) {\n\t for (int c = 0; c < chans; c++) {\n\t if (entry->write_mask & (1 << swizzle_chan[c])) {\n\t source[c] = entry->rhs;\n\t source_chan[c] = entry->swizzle[swizzle_chan[c]];\n\t }\n\t }\n }\n }\n\n /* Make sure all channels are copying from the same source variable. */\n if (!source[0])\n return;\n for (int c = 1; c < chans; c++) {\n if (source[c] != source[0])\n\t return;\n }\n\n if (!shader_mem_ctx)\n shader_mem_ctx = ralloc_parent(deref_var);\n\n if (debug) {\n printf(\"Copy propagation from:\\n\");\n (*ir)->print();\n }\n\n deref_var = new(shader_mem_ctx) ir_dereference_variable(source[0]);\n *ir = new(shader_mem_ctx) ir_swizzle(deref_var,\n\t\t\t\t\tsource_chan[0],\n\t\t\t\t\tsource_chan[1],\n\t\t\t\t\tsource_chan[2],\n\t\t\t\t\tsource_chan[3],\n\t\t\t\t\tchans);\n\n if (debug) {\n printf(\"to:\\n\");\n (*ir)->print();\n printf(\"\\n\");\n }\n}", "label": 1, "cwe": "CWE-other", "length": 620 }, { "index": 65903, "code": "set_occ_orbitals_comp(gchar* FileName)\n{\n \tFILE *file;\n\tgint nAlpha = 0;\n\tgint nBeta = 0;\n\tgint n = 0;\n\tgint i;\n\tgint nBeginAlpha = 0;\n\tgint nEndAlpha = 0;\n\tgint nBeginBeta = 0;\n\tgint nEndBeta = 0;\n\tgint nBegin = 0;\n\tgint nEnd = 0;\n\tgint ne = 0;\n\tgint nA = 0;\n\tgint nB = 0;\n\n \tfile = FOpen(FileName, \"rb\");\n \tif(file ==NULL) return FALSE;\n\tne = get_num_electrons(file);\n\n\tget_number_of_mos(file, &n, &nAlpha, &nBeta, &nBegin, &nEnd, &nBeginAlpha, &nEndAlpha, &nBeginBeta, &nEndBeta);\n\n\tif(n>0)\n\t{\n\t\tOccAlphaOrbitals = g_malloc(NOrb*sizeof(gdouble));\n\t\tOccBetaOrbitals = g_malloc(NOrb*sizeof(gdouble));\n\t\tfor(i=0;i0 && nAlpha==nBeta)\n\t{\n\t\tOccAlphaOrbitals = g_malloc(NOrb*sizeof(gdouble));\n\t\tOccBetaOrbitals = g_malloc(NOrb*sizeof(gdouble));\n\t\tfor(i=0;i0 || (nAlpha>0 && nAlpha==nBeta)) return TRUE;\n\telse return FALSE;\n}", "label": 0, "cwe": null, "length": 624 }, { "index": 373067, "code": "bfstate(int nodeid)\n{\n\tint\t\tsize;\t\t/* # of return blocks */\n\tint\t\tlimit;\t\t/* # of blocks to print */\n\tint\t\ti;\t\t/* favourite index */\n\tint4\t\ttotlength;\t/* total message length */\n\tstruct bfparms\tparms;\t\t/* buffer parameters */\n\tstruct bfstatus\t*pi;\t\t/* current packet ptr */\n\n\tsize = rbfstate(nodeid, bftable, bfmax, &parms);\n\tif (size < 0) lamfail(\"bfstate (rbfstate)\");\n\n\tlimit = (size < bfmax) ? size : bfmax;\n\n\tfor (i = 0; i < limit; ++i) {\n\t\tpi = bftable + i;\n\n\t\tif ((!opt_taken('p') && (pi->bfs_flags & N2ND)) ||\n\t\t\t\t(!opt_taken('g') && (pi->bfs_event < 0)))\n\t\t\t\tcontinue;\n/*\n * Collect all packets from long messages.\n */\n\t\tif (!opt_taken('p') && !(pi->bfs_flags & N2ND) &&\n\t\t\t\t(pi->bfs_flags & NMORE)) {\n\t\t\ttotlength = pi->bfs_data[0];\n\t\t} else {\n\t\t\ttotlength = pi->bfs_length;\n\t\t}\n\n\t\tif (totlength >= 0) {\n\t\t\tprintf(\"%-9.9s\", nid_fmt(nodeid));\n\t\t\tprintf(\" %-9.9s\", nid_fmt(pi->bfs_node));\n\n\t\t\tif ((pi->bfs_flags & KSYNCSQL) ||\n\t\t\t\t\t(((pi->bfs_event & 0xFFFF0000) != 0)\n\t\t\t\t\t&& ((pi->bfs_event & 0xFFFF0000) !=\n\t\t\t\t\t0xFFFF0000))) {\n\t\t\t\tprintf(\" %-8X\", pi->bfs_event);\n\t\t\t} else {\n\t\t\t\tprintf(\" %-8d\", pi->bfs_event);\n\t\t\t}\n\n\t\t\tprintf(\" %-8X\", pi->bfs_type);\n\t\t\tprintf(\" %-7d\\n\", totlength);\n\t\t}\n\t}\n\n\tif (size > bfmax) {\n\t\tprintf(\"...and more buffered messages...\\n\");\n\t}\n\n\tif (opt_taken('l')) {\n\t\tprintf(\"%-9.9s\", nid_fmt(nodeid));\n\t\tprintf(\" max space = %d, used space = %d\\n\",\n\t\t\t\tparms.bfp_maxspace, parms.bfp_nspace);\n\t}\n}", "label": 0, "cwe": null, "length": 515 }, { "index": 213319, "code": "bn_expand_internal(const BIGNUM *b, int words)\n\t{\n\tBN_ULONG *A,*a = NULL;\n\tconst BN_ULONG *B;\n\tint i;\n\n\tbn_check_top(b);\n\n\tif (words > (INT_MAX/(4*BN_BITS2)))\n\t\t{\n\t\tBNerr(BN_F_BN_EXPAND_INTERNAL,BN_R_BIGNUM_TOO_LONG);\n\t\treturn NULL;\n\t\t}\n\tif (BN_get_flags(b,BN_FLG_STATIC_DATA))\n\t\t{\n\t\tBNerr(BN_F_BN_EXPAND_INTERNAL,BN_R_EXPAND_ON_STATIC_BIGNUM_DATA);\n\t\treturn(NULL);\n\t\t}\n\ta=A=(BN_ULONG *)OPENSSL_malloc(sizeof(BN_ULONG)*words);\n\tif (A == NULL)\n\t\t{\n\t\tBNerr(BN_F_BN_EXPAND_INTERNAL,ERR_R_MALLOC_FAILURE);\n\t\treturn(NULL);\n\t\t}\n#if 1\n\tB=b->d;\n\t/* Check if the previous number needs to be copied */\n\tif (B != NULL)\n\t\t{\n\t\tfor (i=b->top>>2; i>0; i--,A+=4,B+=4)\n\t\t\t{\n\t\t\t/*\n\t\t\t * The fact that the loop is unrolled\n\t\t\t * 4-wise is a tribute to Intel. It's\n\t\t\t * the one that doesn't have enough\n\t\t\t * registers to accomodate more data.\n\t\t\t * I'd unroll it 8-wise otherwise:-)\n\t\t\t *\n\t\t\t *\t\t\n\t\t\t */\n\t\t\tBN_ULONG a0,a1,a2,a3;\n\t\t\ta0=B[0]; a1=B[1]; a2=B[2]; a3=B[3];\n\t\t\tA[0]=a0; A[1]=a1; A[2]=a2; A[3]=a3;\n\t\t\t}\n\t\tswitch (b->top&3)\n\t\t\t{\n\t\tcase 3:\tA[2]=B[2];\n\t\tcase 2:\tA[1]=B[1];\n\t\tcase 1:\tA[0]=B[0];\n\t\tcase 0: /* workaround for ultrix cc: without 'case 0', the optimizer does\n\t\t * the switch table by doing a=top&3; a--; goto jump_table[a];\n\t\t * which fails for top== 0 */\n\t\t\t;\n\t\t\t}\n\t\t}\n\n#else\n\tmemset(A,0,sizeof(BN_ULONG)*words);\n\tmemcpy(A,b->d,sizeof(b->d[0])*b->top);\n#endif\n\t\t\n\treturn(a);\n\t}", "label": 0, "cwe": null, "length": 539 }, { "index": 325752, "code": "syb_db_commit(SV *dbh, imp_dbh_t *imp_dbh) {\n\tCS_COMMAND *cmd;\n\tchar buff[128];\n\tCS_INT restype;\n\tCS_RETCODE retcode;\n\tint failFlag = 0;\n\n\tif (imp_dbh->imp_sth && imp_dbh->imp_sth->bcpFlag) {\n\t\tif (DBIc_DBISTATE(imp_dbh)->debug >= 3)\n\t\t\tPerlIO_printf(DBIc_LOGPIO(imp_dbh),\n\t\t\t\t\t\" syb_db_commit() -> bcp op, calling syb_blk_done()\\n\");\n\t\treturn syb_blk_done(imp_dbh->imp_sth, CS_BLK_BATCH);\n\t}\n\n\tif (imp_dbh->doRealTran && !imp_dbh->inTransaction)\n\t\treturn 1;\n\n\tif (DBIc_is(imp_dbh, DBIcf_AutoCommit)) {\n\t\twarn(\"commit ineffective with AutoCommit\");\n\t\treturn 1;\n\t}\n\n\tcmd = syb_alloc_cmd(imp_dbh, imp_dbh->connection);\n\tif (imp_dbh->doRealTran)\n\t\tsprintf(buff, \"\\nCOMMIT TRAN %s\\n\", imp_dbh->tranName);\n\telse\n\t\tstrcpy(buff, \"\\nCOMMIT TRAN\\n\");\n\tif (DBIc_DBISTATE(imp_dbh)->debug >= 3)\n\t\tPerlIO_printf(DBIc_LOGPIO(imp_dbh),\n\t\t\t\t\" syb_db_commit() -> ct_command(%s)\\n\", buff);\n\tretcode = ct_command(cmd, CS_LANG_CMD, buff, CS_NULLTERM, CS_UNUSED);\n\tif (retcode != CS_SUCCEED)\n\t\treturn 0;\n\n\tif (ct_send(cmd) != CS_SUCCEED)\n\t\treturn 0;\n\n\tif (DBIc_DBISTATE(imp_dbh)->debug >= 3)\n\t\tPerlIO_printf(DBIc_LOGPIO(imp_dbh),\n\t\t\t\t\" syb_db_commit() -> ct_send() OK\\n\");\n\n\twhile ((retcode = ct_results(cmd, &restype)) == CS_SUCCEED) {\n\t\tif (DBIc_DBISTATE(imp_dbh)->debug >= 3)\n\t\t\tPerlIO_printf(DBIc_LOGPIO(imp_dbh),\n\t\t\t\t\t\" syb_db_commit() -> ct_results(%d) == %d\\n\", restype,\n\t\t\t\t\tretcode);\n\n\t\tif (restype == CS_CMD_FAIL)\n\t\t\tfailFlag = 1;\n\t}\n\n\tct_cmd_drop(cmd);\n\timp_dbh->inTransaction = 0;\n\n\treturn !failFlag;\n}", "label": 0, "cwe": null, "length": 548 }, { "index": 583309, "code": "odbc_server_to_sql_type(int col_type, int col_size)\n{\n\t/* FIXME finish */\n\tswitch ((TDS_SERVER_TYPE) col_type) {\n\tcase XSYBCHAR:\n\tcase SYBCHAR:\n\t\treturn SQL_CHAR;\n\tcase XSYBVARCHAR:\n\tcase SYBVARCHAR:\n\t\treturn SQL_VARCHAR;\n\tcase SYBTEXT:\n\t\treturn SQL_LONGVARCHAR;\n\tcase XSYBNCHAR:\n\t\treturn SQL_WCHAR;\n\t/* TODO really sure ?? SYBNVARCHAR sybase only ?? */\n\tcase SYBNVARCHAR:\n\tcase XSYBNVARCHAR:\n\t\treturn SQL_WVARCHAR;\n\tcase SYBNTEXT:\n\t\treturn SQL_WLONGVARCHAR;\n\tcase SYBBIT:\n\tcase SYBBITN:\n\t\treturn SQL_BIT;\n#if (ODBCVER >= 0x0300)\n\tcase SYB5INT8:\n\tcase SYBINT8:\n\t\t/* TODO return numeric for odbc2 and convert bigint to numeric */\n\t\treturn SQL_BIGINT;\n#endif\n\tcase SYBINT4:\n\t\treturn SQL_INTEGER;\n\tcase SYBINT2:\n\t\treturn SQL_SMALLINT;\n\tcase SYBINT1:\n\t\treturn SQL_TINYINT;\n\tcase SYBINTN:\n\t\tswitch (col_size) {\n\t\tcase 1:\n\t\t\treturn SQL_TINYINT;\n\t\tcase 2:\n\t\t\treturn SQL_SMALLINT;\n\t\tcase 4:\n\t\t\treturn SQL_INTEGER;\n#if (ODBCVER >= 0x0300)\n\t\tcase 8:\n\t\t\treturn SQL_BIGINT;\n#endif\n\t\t}\n\t\tbreak;\n\tcase SYBREAL:\n\t\treturn SQL_REAL;\n\tcase SYBFLT8:\n\t\treturn SQL_DOUBLE;\n\tcase SYBFLTN:\n\t\tswitch (col_size) {\n\t\tcase 4:\n\t\t\treturn SQL_REAL;\n\t\tcase 8:\n\t\t\treturn SQL_DOUBLE;\n\t\t}\n\t\tbreak;\n\tcase SYBMONEY:\n\tcase SYBMONEY4:\n\tcase SYBMONEYN:\n\t\treturn SQL_DECIMAL;\n\tcase SYBDATETIME:\n\tcase SYBDATETIME4:\n\tcase SYBDATETIMN:\n#if (ODBCVER >= 0x0300)\n\t\treturn SQL_TYPE_TIMESTAMP;\n#else\n\t\treturn SQL_TIMESTAMP;\n#endif\n\tcase XSYBBINARY:\n\tcase SYBBINARY:\n\t\treturn SQL_BINARY;\n\tcase SYBLONGBINARY:\n\tcase SYBIMAGE:\n\t\treturn SQL_LONGVARBINARY;\n\tcase XSYBVARBINARY:\n\tcase SYBVARBINARY:\n\t\treturn SQL_VARBINARY;\n\tcase SYBNUMERIC:\n\tcase SYBDECIMAL:\n\t\treturn SQL_NUMERIC;\n#if (ODBCVER >= 0x0300)\n\tcase SYBUNIQUE:\n#ifdef SQL_GUID\n\t\treturn SQL_GUID;\n#else\n\t\treturn SQL_CHAR;\n#endif\n\tcase SYBVARIANT:\n\t\tbreak;\n#endif\n\tcase SYBMSXML:\n\t\treturn SQL_CHAR;\n\t\t/*\n\t\t * TODO what should I do with these types ?? \n\t\t * return other types can cause additional problems\n\t\t */\n\tcase SYBVOID:\n\tcase SYBSINT1:\n\tcase SYBUINT2:\n\tcase SYBUINT4:\n\tcase SYBUINT8:\n\tcase SYBUINT1:\n\tcase SYBDATE:\n\tcase SYBDATEN:\n\tcase SYBINTERVAL:\n\tcase SYBTIME:\n\tcase SYBTIMEN:\n\tcase SYBUINTN:\n\tcase SYBUNITEXT:\n\tcase SYBXML:\n\tcase SYBMSUDT:\n\t\tbreak;\n\t}\n\treturn SQL_UNKNOWN_TYPE;\n}", "label": 0, "cwe": null, "length": 697 }, { "index": 228596, "code": "check_special (void)\n{\n mpfr_t x, y;\n int inexact;\n\n mpfr_init (x);\n mpfr_init (y);\n\n mpfr_set_inf (x, 1);\n PRINT_ERROR_IF (!mpfr_inf_p (x) || mpfr_sgn (x) < 0,\n \"ERROR: mpfr_set_inf failed to set variable to +infinity.\\n\");\n inexact = mpfr_set (y, x, MPFR_RNDN);\n PRINT_ERROR_IF (!mpfr_inf_p (y) || mpfr_sgn (y) < 0 || inexact != 0,\n \"ERROR: mpfr_set failed to set variable to +infinity.\\n\");\n\n inexact = mpfr_set_ui (y, 0, MPFR_RNDN);\n PRINT_ERROR_IF (!mpfr_zero_p (y) || mpfr_sgn (y) < 0 || inexact != 0,\n \"ERROR: mpfr_set_ui failed to set variable to +0.\\n\");\n\n mpfr_set_inf (x, -1);\n PRINT_ERROR_IF (!mpfr_inf_p (x) || mpfr_sgn (x) > 0,\n \"ERROR: mpfr_set_inf failed to set variable to -infinity.\\n\");\n inexact = mpfr_set (y, x, MPFR_RNDN);\n PRINT_ERROR_IF (!mpfr_inf_p (y) || mpfr_sgn (y) > 0 || inexact != 0,\n \"ERROR: mpfr_set failed to set variable to -infinity.\\n\");\n\n mpfr_set_zero (x, 1);\n PRINT_ERROR_IF (!mpfr_zero_p (x) || mpfr_sgn (x) < 0,\n \"ERROR: mpfr_set_zero failed to set variable to +0.\\n\");\n inexact = mpfr_set (y, x, MPFR_RNDN);\n PRINT_ERROR_IF (!mpfr_zero_p (y) || mpfr_sgn (y) < 0 || inexact != 0,\n \"ERROR: mpfr_set failed to set variable to +0.\\n\");\n\n mpfr_set_zero (x, -1);\n PRINT_ERROR_IF (!mpfr_zero_p (x) || mpfr_sgn (x) > 0,\n \"ERROR: mpfr_set_zero failed to set variable to -0.\\n\");\n inexact = mpfr_set (y, x, MPFR_RNDN);\n PRINT_ERROR_IF (!mpfr_zero_p (y) || mpfr_sgn (y) > 0 || inexact != 0,\n \"ERROR: mpfr_set failed to set variable to -0.\\n\");\n\n mpfr_set_nan (x);\n PRINT_ERROR_IF (!mpfr_nan_p (x),\n \"ERROR: mpfr_set_nan failed to set variable to NaN.\\n\");\n inexact = mpfr_set (y, x, MPFR_RNDN);\n PRINT_ERROR_IF (!mpfr_nan_p (y) || inexact != 0,\n \"ERROR: mpfr_set failed to set variable to NaN.\\n\");\n\n mpfr_clear (x);\n mpfr_clear (y);\n}", "label": 0, "cwe": null, "length": 643 }, { "index": 2227, "code": "show_switch(ivl_switch_t net)\n{\n const char*name = ivl_switch_basename(net);\n int has_enable = 0;\n ivl_nexus_t nexa, nexb;\n ivl_variable_type_t nex_type_a, nex_type_b;\n\n switch (ivl_switch_type(net)) {\n\t case IVL_SW_TRAN:\n\t fprintf(out, \" tran %s\", name);\n\t break;\n\t case IVL_SW_RTRAN:\n\t fprintf(out, \" rtran %s\", name);\n\t break;\n\t case IVL_SW_TRANIF0:\n\t fprintf(out, \" tranif0 %s\", name);\n\t has_enable = 1;\n\t break;\n\t case IVL_SW_RTRANIF0:\n\t fprintf(out, \" rtranif0 %s\", name);\n\t has_enable = 1;\n\t break;\n\t case IVL_SW_TRANIF1:\n\t fprintf(out, \" tranif1 %s\", name);\n\t has_enable = 1;\n\t break;\n\t case IVL_SW_RTRANIF1:\n\t fprintf(out, \" rtranif1 %s\", name);\n\t has_enable = 1;\n\t break;\n\t case IVL_SW_TRAN_VP:\n\t fprintf(out, \" tran(VP wid=%u, part=%u, off=%u) %s\",\n\t\t ivl_switch_width(net), ivl_switch_part(net),\n\t\t ivl_switch_offset(net), name);\n\t break;\n }\n\n fprintf(out, \" island=%p\\n\", ivl_switch_island(net));\n\n nexa = ivl_switch_a(net);\n nex_type_a = nexa? type_of_nexus(nexa) : IVL_VT_NO_TYPE;\n fprintf(out, \" A: %p \\n\", nexa, data_type_string(nex_type_a));\n\n nexb = ivl_switch_b(net);\n nex_type_b = nexb? type_of_nexus(nexb) : IVL_VT_NO_TYPE;\n fprintf(out, \" B: %p \\n\", nexb, data_type_string(nex_type_b));\n\n\t/* The A/B pins of the switch must be present, and must match. */\n if (nex_type_a == IVL_VT_NO_TYPE) {\n\t fprintf(out, \" A: ERROR: Type missing for pin A\\n\");\n\t stub_errors += 1;\n }\n if (nex_type_b == IVL_VT_NO_TYPE) {\n\t fprintf(out, \" B: ERROR: Type missing for pin B\\n\");\n\t stub_errors += 1;\n }\n if (nex_type_a != nex_type_b) {\n\t fprintf(out, \" A/B: ERROR: Type mismatch between pins A and B\\n\");\n\t stub_errors += 1;\n }\n\n if (ivl_switch_type(net) == IVL_SW_TRAN_VP) {\n\t /* The TRAN_VP nodes are special in that the specific\n\t\t width matters for each port and should be exactly\n\t\t right for both. */\n\t if (width_of_nexus(nexa) != ivl_switch_width(net)) {\n\t\t fprintf(out, \" A: ERROR: part vector nexus \"\n\t\t\t \"width=%u, expecting width=%u\\n\",\n\t\t\t width_of_nexus(nexa), ivl_switch_width(net));\n\t\t stub_errors += 1;\n\t }\n\t if (width_of_nexus(nexb) != ivl_switch_part(net)) {\n\t\t fprintf(out, \" B: ERROR: part select nexus \"\n\t\t\t \"width=%u, expecting width=%u\\n\",\n\t\t\t width_of_nexus(nexb), ivl_switch_part(net));\n\t\t stub_errors += 1;\n\t }\n } else {\n\t /* All other TRAN nodes will have matching vector\n\t\t widths, but the actual value doesn't matter. */\n\t if (width_of_nexus(nexa) != width_of_nexus(nexb)) {\n\t\t fprintf(out, \" A/B: ERROR: Width of ports don't match\"\n\t\t\t \": A=%u, B=%u\\n\",\n\t\t\t width_of_nexus(nexa), width_of_nexus(nexb));\n\t\t stub_errors += 1;\n\t }\n }\n\n if (has_enable) {\n\t ivl_nexus_t nexe = ivl_switch_enable(net);\n\t fprintf(out, \" E: %p\\n\", nexe);\n\t if (width_of_nexus(nexe) != 1) {\n\t\t fprintf(out, \" E: ERROR: Nexus width is %u\\n\",\n\t\t\t width_of_nexus(nexe));\n\t }\n }\n}", "label": 0, "cwe": null, "length": 964 }, { "index": 428313, "code": "master_kill_execds(\nsge_gdi_ctx_class_t *ctx, sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task) \n{\n int kill_jobs;\n lListElem *lel, *rep;\n char host[CL_MAXHOSTLEN];\n const char *hostname;\n\n DENTER(TOP_LAYER, \"master_kill_execds\");\n\n if (lGetString(lFirst(task->data_list), ID_str) == NULL) {\n /* this means, we have to kill every execd. */\n\n kill_jobs = lGetUlong(lFirst(task->data_list), ID_force)?1:0;\n /* walk over exechost list and send every exechosts execd a\n notification */\n for_each(lel, *object_type_get_master_list(SGE_TYPE_EXECHOST)) { \n hostname = lGetHost(lel, EH_name);\n if (strcmp(hostname, SGE_TEMPLATE_NAME) && strcmp(hostname, SGE_GLOBAL_NAME)) {\n notify(ctx, lel, packet, task, kill_jobs, 0); \n\n /* RU: */\n /* initiate timer for this host which turns into unknown state */\n reschedule_unknown_trigger(lel);\n }\n }\n if (lGetNumberOfElem(task->answer_list) == 0) {\n /* no exechosts have been killed */\n DPRINTF((MSG_SGETEXT_NOEXECHOSTS));\n INFO((SGE_EVENT, MSG_SGETEXT_NOEXECHOSTS));\n answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_OK, ANSWER_QUALITY_INFO);\n }\n } else {\n /* only specified exechosts should be killed. */\n \n /* walk over list with execd's to kill */\n for_each(rep, task->data_list) {\n if ((getuniquehostname(lGetString(rep, ID_str), host, 0)) != CL_RETVAL_OK)\n {\n WARNING((SGE_EVENT, MSG_SGETEXT_CANTRESOLVEHOST_S, lGetString(rep, ID_str)));\n answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_ESEMANTIC, ANSWER_QUALITY_WARNING);\n } else {\n if ((lel = host_list_locate(*object_type_get_master_list(SGE_TYPE_EXECHOST), host))) {\n kill_jobs = lGetUlong(rep, ID_force)?1:0;\n /*\n ** if a host name is given, then a kill is forced\n ** this means that even if the host is unheard we try\n ** to kill it\n */\n notify(ctx, lel, packet, task, kill_jobs, 1);\n /* RU: */\n /* initiate timer for this host which turns into unknown state */ \n reschedule_unknown_trigger(lel);\n } else {\n WARNING((SGE_EVENT, MSG_SGETEXT_ISNOEXECHOST_S, host));\n answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_ESEMANTIC, ANSWER_QUALITY_WARNING);\n }\n }\n }\n }\n DEXIT;\n}", "label": 0, "cwe": null, "length": 656 }, { "index": 109708, "code": "ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep)\n{\n\tstruct ahci_host_priv *hpriv = ap->host->private_data;\n\tvoid __iomem *port_mmio = ahci_port_base(ap);\n\tstruct ata_device *dev = ap->link.device;\n\tu32 devslp, dm, dito, mdat, deto;\n\tint rc;\n\tunsigned int err_mask;\n\n\tdevslp = readl(port_mmio + PORT_DEVSLP);\n\tif (!(devslp & PORT_DEVSLP_DSP)) {\n\t\tdev_info(ap->host->dev, \"port does not support device sleep\\n\");\n\t\treturn;\n\t}\n\n\t/* disable device sleep */\n\tif (!sleep) {\n\t\tif (devslp & PORT_DEVSLP_ADSE) {\n\t\t\twritel(devslp & ~PORT_DEVSLP_ADSE,\n\t\t\t port_mmio + PORT_DEVSLP);\n\t\t\terr_mask = ata_dev_set_feature(dev,\n\t\t\t\t\t\t SETFEATURES_SATA_DISABLE,\n\t\t\t\t\t\t SATA_DEVSLP);\n\t\t\tif (err_mask && err_mask != AC_ERR_DEV)\n\t\t\t\tata_dev_warn(dev, \"failed to disable DEVSLP\\n\");\n\t\t}\n\t\treturn;\n\t}\n\n\t/* device sleep was already enabled */\n\tif (devslp & PORT_DEVSLP_ADSE)\n\t\treturn;\n\n\t/* set DITO, MDAT, DETO and enable DevSlp, need to stop engine first */\n\trc = ahci_stop_engine(ap);\n\tif (rc)\n\t\treturn;\n\n\tdm = (devslp & PORT_DEVSLP_DM_MASK) >> PORT_DEVSLP_DM_OFFSET;\n\tdito = devslp_idle_timeout / (dm + 1);\n\tif (dito > 0x3ff)\n\t\tdito = 0x3ff;\n\n\t/* Use the nominal value 10 ms if the read MDAT is zero,\n\t * the nominal value of DETO is 20 ms.\n\t */\n\tif (dev->devslp_timing[ATA_LOG_DEVSLP_VALID] &\n\t ATA_LOG_DEVSLP_VALID_MASK) {\n\t\tmdat = dev->devslp_timing[ATA_LOG_DEVSLP_MDAT] &\n\t\t ATA_LOG_DEVSLP_MDAT_MASK;\n\t\tif (!mdat)\n\t\t\tmdat = 10;\n\t\tdeto = dev->devslp_timing[ATA_LOG_DEVSLP_DETO];\n\t\tif (!deto)\n\t\t\tdeto = 20;\n\t} else {\n\t\tmdat = 10;\n\t\tdeto = 20;\n\t}\n\n\tdevslp |= ((dito << PORT_DEVSLP_DITO_OFFSET) |\n\t\t (mdat << PORT_DEVSLP_MDAT_OFFSET) |\n\t\t (deto << PORT_DEVSLP_DETO_OFFSET) |\n\t\t PORT_DEVSLP_ADSE);\n\twritel(devslp, port_mmio + PORT_DEVSLP);\n\n\thpriv->start_engine(ap);\n\n\t/* enable device sleep feature for the drive */\n\terr_mask = ata_dev_set_feature(dev,\n\t\t\t\t SETFEATURES_SATA_ENABLE,\n\t\t\t\t SATA_DEVSLP);\n\tif (err_mask && err_mask != AC_ERR_DEV)\n\t\tata_dev_warn(dev, \"failed to enable DEVSLP\\n\");\n}", "label": 0, "cwe": null, "length": 659 }, { "index": 643660, "code": "__set_focus_to_fwin(\n\tWindow w, FvwmWindow *fw, sftfwin_args_t *args)\n{\n\tFvwmWindow *sf;\n\n\tif (__try_forbid_user_focus(w, fw) == True)\n\t{\n\t\treturn;\n\t}\n\t__try_program_focus(w, fw);\n\tif (__check_allow_focus(w, fw, args->set_by) == False)\n\t{\n\t\treturn;\n\t}\n\t__update_windowlist(fw, args->set_by, args->is_focus_by_flip_focus_cmd);\n\tif (__try_other_screen_focus(fw) == True)\n\t{\n\t\treturn;\n\t}\n\n\tif (fw && !args->do_forbid_warp)\n\t{\n\t\tif (IS_ICONIFIED(fw))\n\t\t{\n\t\t\trectangle r;\n\t\t\tBool rc;\n\n\t\t\trc = get_visible_icon_geometry(fw, &r);\n\t\t\tif (!rc || !IsRectangleOnThisPage(&r, fw->Desk))\n\t\t\t{\n\t\t\t\tfw = NULL;\n\t\t\t\tw = Scr.NoFocusWin;\n\t\t\t}\n\t\t}\n\t\telse if (!IsRectangleOnThisPage(&(fw->g.frame), fw->Desk))\n\t\t{\n\t\t\tfw = NULL;\n\t\t\tw = Scr.NoFocusWin;\n\t\t}\n\t}\n\n\tsf = get_focus_window();\n\tif (fw == NULL)\n\t{\n\t\tFOCUS_SET(Scr.NoFocusWin);\n\t\tset_focus_window(NULL);\n\t\tScr.UnknownWinFocused = None;\n\t\tXFlush(dpy);\n\t\treturn;\n\t}\n\t/* RBW - allow focus to go to a NoIconTitle icon window so\n\t * auto-raise will work on it. */\n\tif (IS_ICONIFIED(fw))\n\t{\n\t\tBool is_window_selected = False;\n\n\t\tif (FW_W_ICON_TITLE(fw))\n\t\t{\n\t\t\tw = FW_W_ICON_TITLE(fw);\n\t\t\tis_window_selected = True;\n\t\t}\n\t\tif ((!is_window_selected || WAS_ICON_HINT_PROVIDED(fw)) &&\n\t\t FW_W_ICON_PIXMAP(fw))\n\t\t{\n\t\t\tw = FW_W_ICON_PIXMAP(fw);\n\t\t}\n\t}\n\n\tif (FP_IS_LENIENT(FW_FOCUS_POLICY(fw)))\n\t{\n\t\tFOCUS_SET(w);\n\t\tset_focus_window(fw);\n\t\tif (args->do_allow_force_broadcast)\n\t\t{\n\t\t\tSET_FOCUS_CHANGE_BROADCAST_PENDING(fw, 1);\n\t\t}\n\t\tScr.UnknownWinFocused = None;\n\t}\n\telse if (focus_does_accept_input_focus(fw))\n\t{\n\t\t/* Window will accept input focus */\n\t\tif (Scr.StolenFocusWin == w && Scr.UnknownWinFocused != None)\n\t\t{\n\t\t\t/* Without this FocusIn is not generated on the\n\t\t\t * window if it was focuesed when the unmanaged\n\t\t\t * window took focus. */\n\t\t\tFOCUS_SET(Scr.NoFocusWin);\n\n\t\t}\n\t\tFOCUS_SET(w);\n\t\tset_focus_window(fw);\n\t\tif (fw)\n\t\t{\n\t\t\tif (args->do_allow_force_broadcast)\n\t\t\t{\n\t\t\t\tSET_FOCUS_CHANGE_BROADCAST_PENDING(fw, 1);\n\t\t\t}\n\t\t}\n\t\tScr.UnknownWinFocused = None;\n\t}\n\telse if (sf && sf->Desk == Scr.CurrentDesk)\n\t{\n\t\t/* Window doesn't want focus. Leave focus alone */\n\t}\n\telse\n\t{\n\t\tFOCUS_SET(Scr.NoFocusWin);\n\t\tset_focus_window(NULL);\n\t}\n\tXFlush(dpy);\n\n\treturn;\n}", "label": 0, "cwe": null, "length": 725 }, { "index": 426134, "code": "fso_gsm_plus_cnmi_real_parse (FsoGsmAbstractAtCommand* base, const gchar* response, GError** error) {\n\tFsoGsmPlusCNMI * self;\n\tconst gchar* _tmp0_ = NULL;\n\tgint _tmp1_ = 0;\n\tgint _tmp2_ = 0;\n\tgint _tmp3_ = 0;\n\tgint _tmp4_ = 0;\n\tgint _tmp5_ = 0;\n\tGError * _inner_error_ = NULL;\n\tself = (FsoGsmPlusCNMI*) base;\n\tg_return_if_fail (response != NULL);\n\t_tmp0_ = response;\n\tFSO_GSM_ABSTRACT_AT_COMMAND_CLASS (fso_gsm_plus_cnmi_parent_class)->parse (G_TYPE_CHECK_INSTANCE_CAST (self, FSO_GSM_TYPE_ABSTRACT_AT_COMMAND, FsoGsmAbstractAtCommand), _tmp0_, &_inner_error_);\n\tif (_inner_error_ != NULL) {\n\t\tif (_inner_error_->domain == FSO_GSM_AT_COMMAND_ERROR) {\n\t\t\tg_propagate_error (error, _inner_error_);\n\t\t\treturn;\n\t\t} else {\n\t\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\t\t\tg_clear_error (&_inner_error_);\n\t\t\treturn;\n\t\t}\n\t}\n\t_tmp1_ = fso_gsm_abstract_at_command_to_int ((FsoGsmAbstractAtCommand*) self, \"mode\");\n\tfso_gsm_plus_cnmi_set_mode (self, _tmp1_);\n\t_tmp2_ = fso_gsm_abstract_at_command_to_int ((FsoGsmAbstractAtCommand*) self, \"mt\");\n\tfso_gsm_plus_cnmi_set_mt (self, _tmp2_);\n\t_tmp3_ = fso_gsm_abstract_at_command_to_int ((FsoGsmAbstractAtCommand*) self, \"bm\");\n\tfso_gsm_plus_cnmi_set_bm (self, _tmp3_);\n\t_tmp4_ = fso_gsm_abstract_at_command_to_int ((FsoGsmAbstractAtCommand*) self, \"ds\");\n\tfso_gsm_plus_cnmi_set_ds (self, _tmp4_);\n\t_tmp5_ = fso_gsm_abstract_at_command_to_int ((FsoGsmAbstractAtCommand*) self, \"bfr\");\n\tfso_gsm_plus_cnmi_set_bfr (self, _tmp5_);\n}", "label": 0, "cwe": null, "length": 537 }, { "index": 15757, "code": "zend_load_extension(const char *path)\n{\n#if ZEND_EXTENSIONS_SUPPORT\n\tDL_HANDLE handle;\n\tzend_extension *new_extension;\n\tzend_extension_version_info *extension_version_info;\n\n\thandle = DL_LOAD(path);\n\tif (!handle) {\n#ifndef ZEND_WIN32\n\t\tfprintf(stderr, \"Failed loading %s: %s\\n\", path, DL_ERROR());\n/* See http://support.microsoft.com/kb/190351 */\n#ifdef PHP_WIN32\n\t\tfflush(stderr);\n#endif\n#else\n\t\tfprintf(stderr, \"Failed loading %s\\n\", path);\n#endif\n\t\treturn FAILURE;\n\t}\n\n\textension_version_info = (zend_extension_version_info *) DL_FETCH_SYMBOL(handle, \"extension_version_info\");\n\tif (!extension_version_info) {\n\t\textension_version_info = (zend_extension_version_info *) DL_FETCH_SYMBOL(handle, \"_extension_version_info\");\n\t}\n\tnew_extension = (zend_extension *) DL_FETCH_SYMBOL(handle, \"zend_extension_entry\");\n\tif (!new_extension) {\n\t\tnew_extension = (zend_extension *) DL_FETCH_SYMBOL(handle, \"_zend_extension_entry\");\n\t}\n\tif (!extension_version_info || !new_extension) {\n\t\tfprintf(stderr, \"%s doesn't appear to be a valid Zend extension\\n\", path);\n/* See http://support.microsoft.com/kb/190351 */\n#ifdef PHP_WIN32\n\t\tfflush(stderr);\n#endif\n\t\tDL_UNLOAD(handle);\n\t\treturn FAILURE;\n\t}\n\n\n\t/* allow extension to proclaim compatibility with any Zend version */\n\tif (extension_version_info->zend_extension_api_no != ZEND_EXTENSION_API_NO &&(!new_extension->api_no_check || new_extension->api_no_check(ZEND_EXTENSION_API_NO) != SUCCESS)) {\n\t\tif (extension_version_info->zend_extension_api_no > ZEND_EXTENSION_API_NO) {\n\t\t\tfprintf(stderr, \"%s requires Zend Engine API version %d.\\n\"\n\t\t\t\t\t\"The Zend Engine API version %d which is installed, is outdated.\\n\\n\",\n\t\t\t\t\tnew_extension->name,\n\t\t\t\t\textension_version_info->zend_extension_api_no,\n\t\t\t\t\tZEND_EXTENSION_API_NO);\n/* See http://support.microsoft.com/kb/190351 */\n#ifdef PHP_WIN32\n\t\t\tfflush(stderr);\n#endif\n\t\t\tDL_UNLOAD(handle);\n\t\t\treturn FAILURE;\n\t\t} else if (extension_version_info->zend_extension_api_no < ZEND_EXTENSION_API_NO) {\n\t\t\tfprintf(stderr, \"%s requires Zend Engine API version %d.\\n\"\n\t\t\t\t\t\"The Zend Engine API version %d which is installed, is newer.\\n\"\n\t\t\t\t\t\"Contact %s at %s for a later version of %s.\\n\\n\",\n\t\t\t\t\tnew_extension->name,\n\t\t\t\t\textension_version_info->zend_extension_api_no,\n\t\t\t\t\tZEND_EXTENSION_API_NO,\n\t\t\t\t\tnew_extension->author,\n\t\t\t\t\tnew_extension->URL,\n\t\t\t\t\tnew_extension->name);\n/* See http://support.microsoft.com/kb/190351 */\n#ifdef PHP_WIN32\n\t\t\tfflush(stderr);\n#endif\n\t\t\tDL_UNLOAD(handle);\n\t\t\treturn FAILURE;\n\t\t}\n\t} else if (strcmp(ZEND_EXTENSION_BUILD_ID, extension_version_info->build_id) &&\n\t (!new_extension->build_id_check || new_extension->build_id_check(ZEND_EXTENSION_BUILD_ID) != SUCCESS)) {\n\t\tfprintf(stderr, \"Cannot load %s - it was built with configuration %s, whereas running engine is %s\\n\",\n\t\t\t\t\tnew_extension->name, extension_version_info->build_id, ZEND_EXTENSION_BUILD_ID);\n/* See http://support.microsoft.com/kb/190351 */\n#ifdef PHP_WIN32\n\t\tfflush(stderr);\n#endif\n\t\tDL_UNLOAD(handle);\n\t\treturn FAILURE;\n\t}\n\n\treturn zend_register_extension(new_extension, handle);\n#else\n\tfprintf(stderr, \"Extensions are not supported on this platform.\\n\");\n/* See http://support.microsoft.com/kb/190351 */\n#ifdef PHP_WIN32\n\tfflush(stderr);\n#endif\n\treturn FAILURE;\n#endif\n}", "label": 0, "cwe": null, "length": 781 }, { "index": 81152, "code": "gcm_memory( int cipher,\n const unsigned char *key, unsigned long keylen,\n const unsigned char *IV, unsigned long IVlen,\n const unsigned char *adata, unsigned long adatalen,\n unsigned char *pt, unsigned long ptlen,\n unsigned char *ct, \n unsigned char *tag, unsigned long *taglen,\n int direction)\n{\n void *orig;\n gcm_state *gcm;\n int err;\n\n if ((err = cipher_is_valid(cipher)) != CRYPT_OK) {\n return err;\n }\n \n if (cipher_descriptor[cipher].accel_gcm_memory != NULL) {\n return \n cipher_descriptor[cipher].accel_gcm_memory\n (key, keylen,\n IV, IVlen,\n adata, adatalen,\n pt, ptlen,\n ct,\n tag, taglen,\n direction);\n }\n\n\n\n#ifndef GCM_TABLES_SSE2\n orig = gcm = XMALLOC(sizeof(*gcm));\n#else\n orig = gcm = XMALLOC(sizeof(*gcm) + 16);\n#endif\n if (gcm == NULL) {\n return CRYPT_MEM;\n }\n\n /* Force GCM to be on a multiple of 16 so we can use 128-bit aligned operations\n * note that we only modify gcm and keep orig intact. This code is not portable\n * but again it's only for SSE2 anyways, so who cares?\n */\n#ifdef GCM_TABLES_SSE2\n if ((unsigned long)gcm & 15) {\n gcm = (gcm_state *)((unsigned long)gcm + (16 - ((unsigned long)gcm & 15)));\n }\n#endif\n\n if ((err = gcm_init(gcm, cipher, key, keylen)) != CRYPT_OK) {\n goto LTC_ERR;\n }\n if ((err = gcm_add_iv(gcm, IV, IVlen)) != CRYPT_OK) {\n goto LTC_ERR;\n }\n if ((err = gcm_add_aad(gcm, adata, adatalen)) != CRYPT_OK) {\n goto LTC_ERR;\n }\n if ((err = gcm_process(gcm, pt, ptlen, ct, direction)) != CRYPT_OK) {\n goto LTC_ERR;\n }\n err = gcm_done(gcm, tag, taglen);\nLTC_ERR:\n XFREE(orig);\n return err;\n}", "label": 0, "cwe": null, "length": 536 }, { "index": 818909, "code": "gee_array_list_real_remove (GeeAbstractCollection* base, gconstpointer item) {\n\tGeeArrayList * self;\n\tgboolean result = FALSE;\n\tself = (GeeArrayList*) base;\n\t{\n\t\tgint index = 0;\n\t\tindex = 0;\n\t\t{\n\t\t\tgboolean _tmp0_ = FALSE;\n\t\t\t_tmp0_ = TRUE;\n\t\t\twhile (TRUE) {\n\t\t\t\tgboolean _tmp1_ = FALSE;\n\t\t\t\tgint _tmp3_ = 0;\n\t\t\t\tgint _tmp4_ = 0;\n\t\t\t\tGEqualFunc _tmp5_ = NULL;\n\t\t\t\tGEqualFunc _tmp6_ = NULL;\n\t\t\t\tgpointer* _tmp7_ = NULL;\n\t\t\t\tgint _tmp7__length1 = 0;\n\t\t\t\tgint _tmp8_ = 0;\n\t\t\t\tgconstpointer _tmp9_ = NULL;\n\t\t\t\tgconstpointer _tmp10_ = NULL;\n\t\t\t\tgboolean _tmp11_ = FALSE;\n\t\t\t\t_tmp1_ = _tmp0_;\n\t\t\t\tif (!_tmp1_) {\n\t\t\t\t\tgint _tmp2_ = 0;\n\t\t\t\t\t_tmp2_ = index;\n\t\t\t\t\tindex = _tmp2_ + 1;\n\t\t\t\t}\n\t\t\t\t_tmp0_ = FALSE;\n\t\t\t\t_tmp3_ = index;\n\t\t\t\t_tmp4_ = self->_size;\n\t\t\t\tif (!(_tmp3_ < _tmp4_)) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t_tmp5_ = gee_array_list_get_equal_func (self);\n\t\t\t\t_tmp6_ = _tmp5_;\n\t\t\t\t_tmp7_ = self->_items;\n\t\t\t\t_tmp7__length1 = self->_items_length1;\n\t\t\t\t_tmp8_ = index;\n\t\t\t\t_tmp9_ = _tmp7_[_tmp8_];\n\t\t\t\t_tmp10_ = item;\n\t\t\t\t_tmp11_ = _tmp6_ (_tmp9_, _tmp10_);\n\t\t\t\tif (_tmp11_) {\n\t\t\t\t\tgint _tmp12_ = 0;\n\t\t\t\t\tgpointer _tmp13_ = NULL;\n\t\t\t\t\tgpointer _tmp14_ = NULL;\n\t\t\t\t\t_tmp12_ = index;\n\t\t\t\t\t_tmp13_ = gee_abstract_list_remove_at ((GeeAbstractList*) self, _tmp12_);\n\t\t\t\t\t_tmp14_ = _tmp13_;\n\t\t\t\t\t((_tmp14_ == NULL) || (self->priv->g_destroy_func == NULL)) ? NULL : (_tmp14_ = (self->priv->g_destroy_func (_tmp14_), NULL));\n\t\t\t\t\tresult = TRUE;\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tresult = FALSE;\n\treturn result;\n}", "label": 0, "cwe": null, "length": 549 }, { "index": 193781, "code": "boulder_hits_pool(otmp, rx, ry, pushing)\nstruct obj *otmp;\nregister int rx, ry;\nboolean pushing;\n{\n\tif (!otmp || otmp->otyp != BOULDER)\n\t impossible(\"Not a boulder?\");\n\telse if (!Is_waterlevel(&u.uz) && (is_pool(rx,ry) || is_lava(rx,ry))) {\n\t boolean lava = is_lava(rx,ry), fills_up;\n\t const char *what = waterbody_name(rx,ry);\n\t schar ltyp = levl[rx][ry].typ;\n\t int chance = rn2(10);\t\t/* water: 90%; lava: 10% */\n\t fills_up = lava ? chance == 0 : chance != 0;\n\n\t if (fills_up) {\n\t\tstruct trap *ttmp = t_at(rx, ry);\n\n\t\tif (ltyp == DRAWBRIDGE_UP) {\n\t\t levl[rx][ry].drawbridgemask &= ~DB_UNDER; /* clear lava */\n\t\t levl[rx][ry].drawbridgemask |= DB_FLOOR;\n\t\t} else\n\t\t levl[rx][ry].typ = ROOM;\n\n\t\tif (ttmp) (void) delfloortrap(ttmp);\n\t\tbury_objs(rx, ry);\n\t\t\n\t\tnewsym(rx,ry);\n\t\tif (pushing) {\n\t\t You(\"push %s into the %s.\", the(xname(otmp)), what);\n\t\t if (flags.verbose && !Blind)\n\t\t\tpline(\"Now you can cross it!\");\n\t\t /* no splashing in this case */\n\t\t}\n\t }\n\t if (!fills_up || !pushing) {\t/* splashing occurs */\n\t\tif (!u.uinwater) {\n\t\t if (pushing ? !Blind : cansee(rx,ry)) {\n\t\t\tThere(\"is a large splash as %s %s the %s.\",\n\t\t\t the(xname(otmp)), fills_up? \"fills\":\"falls into\",\n\t\t\t what);\n\t\t } else if (flags.soundok)\n\t\t\tYou_hear(\"a%s splash.\", lava ? \" sizzling\" : \"\");\n\t\t wake_nearto(rx, ry, 40);\n\t\t}\n\n\t\tif (fills_up && u.uinwater && distu(rx,ry) == 0) {\n\t\t u.uinwater = 0;\n\t\t docrt();\n\t\t vision_full_recalc = 1;\n\t\t You(\"find yourself on dry land again!\");\n\t\t} else if (lava && distu(rx,ry) <= 2) {\n\t\t You(\"are hit by molten lava%c\",\n\t\t\tFire_resistance ? '.' : '!');\n\t\t\tburn_away_slime();\n\t\t losehp(d((Fire_resistance ? 1 : 3), 6),\n\t\t\t \"molten lava\", KILLED_BY);\n\t\t} else if (!fills_up && flags.verbose &&\n\t\t\t (pushing ? !Blind : cansee(rx,ry)))\n\t\t pline(\"It sinks without a trace!\");\n\t }\n\n\t /* boulder is now gone */\n\t if (pushing) delobj(otmp);\n\t else obfree(otmp, (struct obj *)0);\n\t return TRUE;\n\t}\n\treturn FALSE;\n}", "label": 0, "cwe": null, "length": 677 }, { "index": 456036, "code": "_kadm5_c_get_cred_cache(krb5_context context,\n\t\t\tconst char *client_name,\n\t\t\tconst char *server_name,\n\t\t\tconst char *password,\n\t\t\tkrb5_prompter_fct prompter,\n\t\t\tconst char *keytab,\n\t\t\tkrb5_ccache ccache,\n\t\t\tkrb5_ccache *ret_cache)\n{\n krb5_error_code ret;\n krb5_ccache id = NULL;\n krb5_principal default_client = NULL, client = NULL;\n\n /* treat empty password as NULL */\n if(password && *password == '\\0')\n\tpassword = NULL;\n if(server_name == NULL)\n\tserver_name = KADM5_ADMIN_SERVICE;\n\n if(client_name != NULL) {\n\tret = krb5_parse_name(context, client_name, &client);\n\tif(ret)\n\t return ret;\n }\n\n if(ccache != NULL) {\n\tid = ccache;\n\tret = krb5_cc_get_principal(context, id, &client);\n\tif(ret)\n\t return ret;\n } else {\n\t/* get principal from default cache, ok if this doesn't work */\n\n\tret = get_cache_principal(context, &id, &default_client);\n\tif (ret) {\n\t /*\n\t * No client was specified by the caller and we cannot\n\t * determine the client from a credentials cache.\n\t */\n\t const char *user;\n\n\t user = get_default_username ();\n\n\t if(user == NULL) {\n\t\tkrb5_set_error_message(context, KADM5_FAILURE, \"Unable to find local user name\");\n\t\treturn KADM5_FAILURE;\n\t }\n\t ret = krb5_make_principal(context, &default_client,\n\t\t\t\t NULL, user, \"admin\", NULL);\n\t if(ret)\n\t\treturn ret;\n\t}\n }\n\n\n /*\n * No client was specified by the caller, but we have a client\n * from the default credentials cache.\n */\n if (client == NULL && default_client != NULL)\n\tclient = default_client;\n\n\n if(id && client && (default_client == NULL ||\n\t krb5_principal_compare(context, client, default_client) != 0)) {\n\tret = get_kadm_ticket(context, id, client, server_name);\n\tif(ret == 0) {\n\t *ret_cache = id;\n\t krb5_free_principal(context, default_client);\n\t if (default_client != client)\n\t\tkrb5_free_principal(context, client);\n\t return 0;\n\t}\n\tif(ccache != NULL)\n\t /* couldn't get ticket from cache */\n\t return -1;\n }\n /* get creds via AS request */\n if(id && (id != ccache))\n\tkrb5_cc_close(context, id);\n if (client != default_client)\n\tkrb5_free_principal(context, default_client);\n\n ret = get_new_cache(context, client, password, prompter, keytab,\n\t\t\tserver_name, ret_cache);\n krb5_free_principal(context, client);\n return ret;\n}", "label": 0, "cwe": null, "length": 606 }, { "index": 752856, "code": "importFromWkt( char ** ppszInput )\n\n{\n char szToken[OGR_WKT_TOKEN_MAX];\n const char *pszInput = *ppszInput;\n\n empty();\n\n/* -------------------------------------------------------------------- */\n/* Read and verify the ``LINESTRING'' keyword token. */\n/* -------------------------------------------------------------------- */\n pszInput = OGRWktReadToken( pszInput, szToken );\n\n if( !EQUAL(szToken,getGeometryName()) )\n return OGRERR_CORRUPT_DATA;\n\n/* -------------------------------------------------------------------- */\n/* Check for EMPTY */\n/* -------------------------------------------------------------------- */\n const char *pszPreScan;\n int bHasZ = FALSE, bHasM = FALSE;\n\n pszPreScan = OGRWktReadToken( pszInput, szToken );\n if( EQUAL(szToken,\"EMPTY\") )\n {\n *ppszInput = (char *) pszPreScan;\n return OGRERR_NONE;\n }\n\n/* -------------------------------------------------------------------- */\n/* Check for Z, M or ZM. Will ignore the Measure */\n/* -------------------------------------------------------------------- */\n else if( EQUAL(szToken,\"Z\") )\n {\n bHasZ = TRUE;\n }\n else if( EQUAL(szToken,\"M\") )\n {\n bHasM = TRUE;\n }\n else if( EQUAL(szToken,\"ZM\") )\n {\n bHasZ = TRUE;\n bHasM = TRUE;\n }\n\n if (bHasZ || bHasM)\n {\n pszInput = pszPreScan;\n pszPreScan = OGRWktReadToken( pszInput, szToken );\n if( EQUAL(szToken,\"EMPTY\") )\n {\n *ppszInput = (char *) pszPreScan;\n empty();\n /* FIXME?: In theory we should store the dimension and M presence */\n /* if we want to allow round-trip with ExportToWKT v1.2 */\n return OGRERR_NONE;\n }\n }\n\n if( !EQUAL(szToken,\"(\") )\n return OGRERR_CORRUPT_DATA;\n\n if ( !bHasZ && !bHasM )\n {\n /* Test for old-style LINESTRING(EMPTY) */\n pszPreScan = OGRWktReadToken( pszPreScan, szToken );\n if( EQUAL(szToken,\"EMPTY\") )\n {\n pszInput = OGRWktReadToken( pszPreScan, szToken );\n\n if( !EQUAL(szToken,\")\") )\n return OGRERR_CORRUPT_DATA;\n else\n {\n *ppszInput = (char *) pszInput;\n empty();\n return OGRERR_NONE;\n }\n }\n }\n\n/* -------------------------------------------------------------------- */\n/* Read the point list. */\n/* -------------------------------------------------------------------- */\n int nMaxPoint = 0;\n\n nPointCount = 0;\n\n pszInput = OGRWktReadPoints( pszInput, &paoPoints, &padfZ, &nMaxPoint,\n &nPointCount );\n if( pszInput == NULL )\n return OGRERR_CORRUPT_DATA;\n\n *ppszInput = (char *) pszInput;\n\n if( padfZ == NULL )\n nCoordDimension = 2;\n else\n {\n /* Ignore Z array when we have a LINESTRING M */\n if (bHasM && !bHasZ)\n {\n nCoordDimension = 2;\n CPLFree(padfZ);\n padfZ = NULL;\n }\n else\n nCoordDimension = 3;\n }\n \n return OGRERR_NONE;\n}", "label": 0, "cwe": null, "length": 751 }, { "index": 884754, "code": "point_init(node_t * n)\n{\n polygon_t *poly = NEW(polygon_t);\n int sides, outp, peripheries = ND_shape(n)->polygon->peripheries;\n double sz;\n pointf P, *vertices;\n int i, j;\n double w, h;\n\n /* set width and height, and make them equal\n * if user has set weight or height, use it.\n * if both are set, use smallest.\n * if neither, use default\n */\n w = late_double(n, N_width, MAXDOUBLE, 0.0);\n h = late_double(n, N_height, MAXDOUBLE, 0.0);\n w = MIN(w, h);\n if ((w == MAXDOUBLE) && (h == MAXDOUBLE))\t/* neither defined */\n\tND_width(n) = ND_height(n) = DEF_POINT;\n else {\n\tw = MIN(w, h);\n\t/* If w == 0, use it; otherwise, make w no less than MIN_POINT due\n * to the restrictions mentioned above.\n */\n\tif (w > 0.0) \n\t w = MAX(w,MIN_POINT);\n\tND_width(n) = ND_height(n) = w;\n }\n\n sz = ND_width(n) * POINTS_PER_INCH;\n peripheries = late_int(n, N_peripheries, peripheries, 0);\n if (peripheries < 1)\n\toutp = 1;\n else\n\toutp = peripheries;\n sides = 2;\n vertices = N_NEW(outp * sides, pointf);\n P.y = P.x = sz / 2.;\n vertices[0].x = -P.x;\n vertices[0].y = -P.y;\n vertices[1] = P;\n if (peripheries > 1) {\n\tfor (j = 1, i = 2; j < peripheries; j++) {\n\t P.x += GAP;\n\t P.y += GAP;\n\t vertices[i].x = -P.x;\n\t vertices[i].y = -P.y;\n\t i++;\n\t vertices[i].x = P.x;\n\t vertices[i].y = P.y;\n\t i++;\n\t}\n\tsz = 2. * P.x;\n }\n poly->regular = 1;\n poly->peripheries = peripheries;\n poly->sides = 2;\n poly->orientation = 0;\n poly->skew = 0;\n poly->distortion = 0;\n poly->vertices = vertices;\n\n ND_height(n) = ND_width(n) = PS2INCH(sz);\n ND_shape_info(n) = (void *) poly;\n}", "label": 0, "cwe": null, "length": 579 }, { "index": 71259, "code": "dib8000_set_13seg_channel(struct dib8000_state *state)\n{\n\tu16 i;\n\tu16 coff_pow = 0x2800;\n\n\tstate->seg_mask = 0x1fff; /* All 13 segments enabled */\n\n\t/* ---- COFF ---- Carloff, the most robust --- */\n\tif (state->isdbt_cfg_loaded == 0) { /* if not Sound Broadcasting mode : put default values for 13 segments */\n\t\tdib8000_write_word(state, 180, (16 << 6) | 9);\n\t\tdib8000_write_word(state, 187, (4 << 12) | (8 << 5) | 0x2);\n\t\tcoff_pow = 0x2800;\n\t\tfor (i = 0; i < 6; i++)\n\t\t\tdib8000_write_word(state, 181+i, coff_pow);\n\n\t\t/* P_ctrl_corm_thres4pre_freq_inh=1, P_ctrl_pre_freq_mode_sat=1 */\n\t\t/* P_ctrl_pre_freq_mode_sat=1, P_ctrl_pre_freq_inh=0, P_ctrl_pre_freq_step = 3, P_pre_freq_win_len=1 */\n\t\tdib8000_write_word(state, 338, (1 << 12) | (1 << 10) | (0 << 9) | (3 << 5) | 1);\n\n\t\t/* P_ctrl_pre_freq_win_len=8, P_ctrl_pre_freq_thres_lockin=6 */\n\t\tdib8000_write_word(state, 340, (8 << 6) | (6 << 0));\n\t\t/* P_ctrl_pre_freq_thres_lockout=4, P_small_use_tmcc/ac/cp=1 */\n\t\tdib8000_write_word(state, 341, (4 << 3) | (1 << 2) | (1 << 1) | (1 << 0));\n\n\t\tdib8000_write_word(state, 228, 0); /* default value */\n\t\tdib8000_write_word(state, 265, 31); /* default value */\n\t\tdib8000_write_word(state, 205, 0x200f); /* init value */\n\t}\n\n\t/*\n\t * make the cpil_coff_lock more robust but slower p_coff_winlen\n\t * 6bits; p_coff_thres_lock 6bits (for coff lock if needed)\n\t */\n\n\tif (state->cfg.pll->ifreq == 0)\n\t\tdib8000_write_word(state, 266, ~state->seg_mask | state->seg_diff_mask | 0x40); /* P_equal_noise_seg_inh */\n\n\tdib8000_load_ana_fe_coefs(state, ana_fe_coeff_13seg);\n}", "label": 0, "cwe": null, "length": 590 }, { "index": 674772, "code": "SteepestDescentTakeNSteps(int n)\n {\n if (!_validSetup)\n return 0;\n\n int _ncoords = _mol.NumAtoms() * 3;\n double e_n2, alpha;\n vector3 dir;\n\n for (int i = 1; i <= n; i++) {\n _cstep++;\n\n FOR_ATOMS_OF_MOL (a, _mol) {\n unsigned int idx = a->GetIdx();\n unsigned int coordIdx = (idx - 1) * 3;\n\n if (_constraints.IsFixed(idx) || (_fixAtom == idx) || (_ignoreAtom == idx)) {\n _gradientPtr[coordIdx] = 0.0;\n _gradientPtr[coordIdx+1] = 0.0;\n _gradientPtr[coordIdx+2] = 0.0;\n } else {\n if (!HasAnalyticalGradients()) {\n // use numerical gradients\n dir = NumericalDerivative(&*a) + _constraints.GetGradient(a->GetIdx());\n } else {\n // use analytical gradients\n dir = GetGradient(&*a) + _constraints.GetGradient(a->GetIdx());\n }\n\n if (!_constraints.IsXFixed(idx))\n _gradientPtr[coordIdx] = dir.x();\n else\n _gradientPtr[coordIdx] = 0.0;\n\n if (!_constraints.IsYFixed(idx))\n _gradientPtr[coordIdx+1] = dir.y();\n else\n _gradientPtr[coordIdx+1] = 0.0;\n\n if (!_constraints.IsZFixed(idx))\n _gradientPtr[coordIdx+2] = dir.z();\n else\n _gradientPtr[coordIdx+2] = 0.0;\n }\n }\n // perform a linesearch\n switch (_linesearch) {\n case LineSearchType::Newton2Num:\n alpha = Newton2NumLineSearch(_gradientPtr);\n break;\n default:\n case LineSearchType::Simple:\n alpha = LineSearch(_mol.GetCoordinates(), _gradientPtr);\n break;\n }\n e_n2 = Energy() + _constraints.GetConstraintEnergy();\n\n if ((_cstep % _pairfreq == 0) && _cutoff)\n UpdatePairsSimple(); // Update the non-bonded pairs (Cut-off)\n\n IF_OBFF_LOGLVL_LOW {\n if (_cstep % 10 == 0) {\n snprintf(_logbuf, BUFF_SIZE, \" %4d %8.5f %8.5f\\n\", _cstep, e_n2, _e_n1);\n OBFFLog(_logbuf);\n }\n }\n\n if (IsNear(e_n2, _e_n1, _econv)) {\n IF_OBFF_LOGLVL_LOW\n OBFFLog(\" STEEPEST DESCENT HAS CONVERGED\\n\");\n return false;\n }\n\n if (_nsteps == _cstep) {\n return false;\n }\n\n _e_n1 = e_n2;\n }\n\n return true; // no convergence reached\n }", "label": 0, "cwe": null, "length": 668 }, { "index": 114697, "code": "ompi_coll_libnbc_iscatter_inter(void* sendbuf, int sendcount, MPI_Datatype sendtype,\n void* recvbuf, int recvcount, MPI_Datatype recvtype, int root,\n struct ompi_communicator_t *comm, ompi_request_t ** request,\n struct mca_coll_base_module_2_0_0_t *module) {\n int rank, res, i, rsize;\n MPI_Aint sndext;\n NBC_Schedule *schedule;\n char *sbuf;\n NBC_Handle *handle;\n ompi_coll_libnbc_request_t **coll_req = (ompi_coll_libnbc_request_t**) request;\n ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;\n\n res = NBC_Init_handle(comm, coll_req, libnbc_module);\n if(res != NBC_OK) { printf(\"Error in NBC_Init_handle(%i)\\n\", res); return res; }\n handle = (*coll_req);\n res = MPI_Comm_rank(comm, &rank);\n if (MPI_SUCCESS != res) { printf(\"MPI Error in MPI_Comm_rank() (%i)\\n\", res); return res; }\n res = MPI_Type_extent(sendtype, &sndext);\n if (MPI_SUCCESS != res) { printf(\"MPI Error in MPI_Type_extent() (%i)\\n\", res); return res; }\n res = MPI_Comm_remote_size (comm, &rsize);\n if (MPI_SUCCESS != res) { printf(\"MPI Error in MPI_Comm_remote_size() (%i)\\n\", res); return res; }\n\n handle->tmpbuf = NULL;\n\n schedule = (NBC_Schedule*)malloc(sizeof(NBC_Schedule));\n if (NULL == schedule) { printf(\"Error in malloc()\\n\"); return res; }\n\n res = NBC_Sched_create(schedule);\n if(res != NBC_OK) { printf(\"Error in NBC_Sched_create (%i)\\n\", res); return res; }\n\n /* receive from root */\n if (MPI_ROOT != root && MPI_PROC_NULL != root) {\n /* recv msg from remote root */\n res = NBC_Sched_recv(recvbuf, false, recvcount, recvtype, root, schedule);\n if (NBC_OK != res) { printf(\"Error in NBC_Sched_recv() (%i)\\n\", res); return res; }\n } else if (MPI_ROOT == root) {\n for (i = 0 ; i < rsize ; ++i) {\n sbuf = ((char *)sendbuf) + (i * sendcount * sndext);\n /* root sends the right buffer to the right receiver */\n res = NBC_Sched_send(sbuf, false, sendcount, sendtype, i, schedule);\n if (NBC_OK != res) { printf(\"Error in NBC_Sched_send() (%i)\\n\", res); return res; }\n }\n }\n\n res = NBC_Sched_commit(schedule);\n if (NBC_OK != res) { printf(\"Error in NBC_Sched_commit() (%i)\\n\", res); return res; }\n\n res = NBC_Start(handle, schedule);\n if (NBC_OK != res) { printf(\"Error in NBC_Start() (%i)\\n\", res); return res; }\n\n return NBC_OK;\n}", "label": 0, "cwe": null, "length": 699 }, { "index": 896238, "code": "ip_range_split(\n\tuint32 lower_ip, uint32 upper_ip, cidr_split_t cb, void *udata)\n{\n\tuint8 bits;\n\tuint32 mask;\n\tuint32 trailing;\n\n\tg_assert(lower_ip <= upper_ip);\n\n\tbits = find_common_leading(lower_ip, upper_ip);\n\tmask = 1 << (32 - bits);\n\ttrailing = mask - 1;\n\n\tif (bits == 32) {\n\t\tg_assert(lower_ip == upper_ip);\n\t\t(*cb)(lower_ip, bits, udata);\n\t} else if (trailing == (upper_ip & trailing)) {\n\t\t/*\n\t\t * All the trailing bits of upper_ip are 1s.\n\t\t */\n\n\t\tif (0 == (lower_ip & trailing)) {\n\t\t\t/*\n\t\t\t * All the trailing bits of lower_ip are 0s -- we're done\n\t\t\t */\n\n\t\t\t(*cb)(lower_ip, bits, udata);\n\t\t} else {\n\t\t\tuint32 cut;\n\n\t\t\t/*\n\t\t\t * Start filling after the first 1 bit in lower_ip.\n\t\t\t */\n\n\t\t\tmask = 1;\n\t\t\twhile (0 == (lower_ip & mask))\n\t\t\t\tmask <<= 1;\n\t\t\tcut = (mask - 1) | lower_ip;\n\n\t\t\t/*\n\t\t\t * Recurse on sub-ranges [lower_ip, cut] and ]cut, upper_ip].\n\t\t\t */\n\n\t\t\tip_range_split(lower_ip, cut, cb, udata);\n\t\t\tip_range_split(cut + 1, upper_ip, cb, udata);\n\t\t}\n\t} else {\n\t\tuint32 cut;\n\n\t\t/*\n\t\t * We can't cover the full range.\n\t\t *\n\t\t * We know that bits #(32-bits) in lower_ip and upper_ip differ.\n\t\t * Since lower_ip <= upper_ip, the bit is necessary 0 in lower_ip.\n\t\t */\n\n\t\tmask >>= 1;\t\t\t\t\t/* First bit that differs */\n\n\t\tg_assert(0 == (lower_ip & mask));\n\t\tg_assert(0 != (upper_ip & mask));\n\n\t\tcut = upper_ip & ~mask;\t\t/* Reset that bit in upper_ip */\n\t\tcut |= mask - 1;\t\t\t/* And set the trailing bits to 1s */\n\n\t\t/*\n\t\t * Recurse on sub-ranges [lower_ip, cut] and ]cut, upper_ip].\n\t\t */\n\n\t\tip_range_split(lower_ip, cut, cb, udata);\n\t\tip_range_split(cut + 1, upper_ip, cb, udata);\n\t}\n}", "label": 0, "cwe": null, "length": 522 }, { "index": 100984, "code": "mono_message_init (MonoDomain *domain,\n\t\t MonoMethodMessage *this_obj, \n\t\t MonoReflectionMethod *method,\n\t\t MonoArray *out_args)\n{\n\tMONO_REQ_GC_UNSAFE_MODE;\n\n\tstatic MonoClass *object_array_klass;\n\tstatic MonoClass *byte_array_klass;\n\tstatic MonoClass *string_array_klass;\n\tMonoMethodSignature *sig = mono_method_signature (method->method);\n\tMonoString *name;\n\tint i, j;\n\tchar **names;\n\tguint8 arg_type;\n\n\tif (!object_array_klass) {\n\t\tMonoClass *klass;\n\n\t\tklass = mono_array_class_get (mono_defaults.byte_class, 1);\n\t\tg_assert (klass);\n\t\tbyte_array_klass = klass;\n\n\t\tklass = mono_array_class_get (mono_defaults.string_class, 1);\n\t\tg_assert (klass);\n\t\tstring_array_klass = klass;\n\n\t\tklass = mono_array_class_get (mono_defaults.object_class, 1);\n\t\tg_assert (klass);\n\n\t\tmono_atomic_store_release (&object_array_klass, klass);\n\t}\n\n\tMONO_OBJECT_SETREF (this_obj, method, method);\n\n\tMONO_OBJECT_SETREF (this_obj, args, mono_array_new_specific (mono_class_vtable (domain, object_array_klass), sig->param_count));\n\tMONO_OBJECT_SETREF (this_obj, arg_types, mono_array_new_specific (mono_class_vtable (domain, byte_array_klass), sig->param_count));\n\tthis_obj->async_result = NULL;\n\tthis_obj->call_type = CallType_Sync;\n\n\tnames = g_new (char *, sig->param_count);\n\tmono_method_get_param_names (method->method, (const char **) names);\n\tMONO_OBJECT_SETREF (this_obj, names, mono_array_new_specific (mono_class_vtable (domain, string_array_klass), sig->param_count));\n\t\n\tfor (i = 0; i < sig->param_count; i++) {\n\t\tname = mono_string_new (domain, names [i]);\n\t\tmono_array_setref (this_obj->names, i, name);\t\n\t}\n\n\tg_free (names);\n\tfor (i = 0, j = 0; i < sig->param_count; i++) {\n\t\tif (sig->params [i]->byref) {\n\t\t\tif (out_args) {\n\t\t\t\tMonoObject* arg = (MonoObject *)mono_array_get (out_args, gpointer, j);\n\t\t\t\tmono_array_setref (this_obj->args, i, arg);\n\t\t\t\tj++;\n\t\t\t}\n\t\t\targ_type = 2;\n\t\t\tif (!(sig->params [i]->attrs & PARAM_ATTRIBUTE_OUT))\n\t\t\t\targ_type |= 1;\n\t\t} else {\n\t\t\targ_type = 1;\n\t\t\tif (sig->params [i]->attrs & PARAM_ATTRIBUTE_OUT)\n\t\t\t\targ_type |= 4;\n\t\t}\n\t\tmono_array_set (this_obj->arg_types, guint8, i, arg_type);\n\t}\n}", "label": 0, "cwe": null, "length": 608 }, { "index": 248090, "code": "ddr_consistent_p (FILE *file,\n\t\t struct data_dependence_relation *ddr,\n\t\t vec dist_vects,\n\t\t vec dir_vects)\n{\n unsigned int i, j;\n\n /* If dump_file is set, output there. */\n if (dump_file && (dump_flags & TDF_DETAILS))\n file = dump_file;\n\n if (dist_vects.length () != DDR_NUM_DIST_VECTS (ddr))\n {\n lambda_vector b_dist_v;\n fprintf (file, \"\\n(Number of distance vectors differ: Banerjee has %d, Omega has %d.\\n\",\n\t dist_vects.length (),\n\t DDR_NUM_DIST_VECTS (ddr));\n\n fprintf (file, \"Banerjee dist vectors:\\n\");\n FOR_EACH_VEC_ELT (dist_vects, i, b_dist_v)\n\tprint_lambda_vector (file, b_dist_v, DDR_NB_LOOPS (ddr));\n\n fprintf (file, \"Omega dist vectors:\\n\");\n for (i = 0; i < DDR_NUM_DIST_VECTS (ddr); i++)\n\tprint_lambda_vector (file, DDR_DIST_VECT (ddr, i), DDR_NB_LOOPS (ddr));\n\n fprintf (file, \"data dependence relation:\\n\");\n dump_data_dependence_relation (file, ddr);\n\n fprintf (file, \")\\n\");\n return false;\n }\n\n if (dir_vects.length () != DDR_NUM_DIR_VECTS (ddr))\n {\n fprintf (file, \"\\n(Number of direction vectors differ: Banerjee has %d, Omega has %d.)\\n\",\n\t dir_vects.length (),\n\t DDR_NUM_DIR_VECTS (ddr));\n return false;\n }\n\n for (i = 0; i < DDR_NUM_DIST_VECTS (ddr); i++)\n {\n lambda_vector a_dist_v;\n lambda_vector b_dist_v = DDR_DIST_VECT (ddr, i);\n\n /* Distance vectors are not ordered in the same way in the DDR\n\t and in the DIST_VECTS: search for a matching vector. */\n FOR_EACH_VEC_ELT (dist_vects, j, a_dist_v)\n\tif (lambda_vector_equal (a_dist_v, b_dist_v, DDR_NB_LOOPS (ddr)))\n\t break;\n\n if (j == dist_vects.length ())\n\t{\n\t fprintf (file, \"\\n(Dist vectors from the first dependence analyzer:\\n\");\n\t print_dist_vectors (file, dist_vects, DDR_NB_LOOPS (ddr));\n\t fprintf (file, \"not found in Omega dist vectors:\\n\");\n\t print_dist_vectors (file, DDR_DIST_VECTS (ddr), DDR_NB_LOOPS (ddr));\n\t fprintf (file, \"data dependence relation:\\n\");\n\t dump_data_dependence_relation (file, ddr);\n\t fprintf (file, \")\\n\");\n\t}\n }\n\n for (i = 0; i < DDR_NUM_DIR_VECTS (ddr); i++)\n {\n lambda_vector a_dir_v;\n lambda_vector b_dir_v = DDR_DIR_VECT (ddr, i);\n\n /* Direction vectors are not ordered in the same way in the DDR\n\t and in the DIR_VECTS: search for a matching vector. */\n FOR_EACH_VEC_ELT (dir_vects, j, a_dir_v)\n\tif (lambda_vector_equal (a_dir_v, b_dir_v, DDR_NB_LOOPS (ddr)))\n\t break;\n\n if (j == dist_vects.length ())\n\t{\n\t fprintf (file, \"\\n(Dir vectors from the first dependence analyzer:\\n\");\n\t print_dir_vectors (file, dir_vects, DDR_NB_LOOPS (ddr));\n\t fprintf (file, \"not found in Omega dir vectors:\\n\");\n\t print_dir_vectors (file, DDR_DIR_VECTS (ddr), DDR_NB_LOOPS (ddr));\n\t fprintf (file, \"data dependence relation:\\n\");\n\t dump_data_dependence_relation (file, ddr);\n\t fprintf (file, \")\\n\");\n\t}\n }\n\n return true;\n}", "label": 0, "cwe": null, "length": 874 }, { "index": 86497, "code": "ixgbevf_sw_init(struct ixgbevf_adapter *adapter)\n{\n\tstruct ixgbe_hw *hw = &adapter->hw;\n\tstruct pci_dev *pdev = adapter->pdev;\n\tstruct net_device *netdev = adapter->netdev;\n\tint err;\n\n\t/* PCI config space info */\n\thw->vendor_id = pdev->vendor;\n\thw->device_id = pdev->device;\n\thw->revision_id = pdev->revision;\n\thw->subsystem_vendor_id = pdev->subsystem_vendor;\n\thw->subsystem_device_id = pdev->subsystem_device;\n\n\thw->mbx.ops.init_params(hw);\n\n\t/* assume legacy case in which PF would only give VF 2 queues */\n\thw->mac.max_tx_queues = 2;\n\thw->mac.max_rx_queues = 2;\n\n\t/* lock to protect mailbox accesses */\n\tspin_lock_init(&adapter->mbx_lock);\n\n\terr = hw->mac.ops.reset_hw(hw);\n\tif (err) {\n\t\tdev_info(&pdev->dev,\n\t\t\t \"PF still in reset state. Is the PF interface up?\\n\");\n\t} else {\n\t\terr = hw->mac.ops.init_hw(hw);\n\t\tif (err) {\n\t\t\tpr_err(\"init_shared_code failed: %d\\n\", err);\n\t\t\tgoto out;\n\t\t}\n\t\tixgbevf_negotiate_api(adapter);\n\t\terr = hw->mac.ops.get_mac_addr(hw, hw->mac.addr);\n\t\tif (err)\n\t\t\tdev_info(&pdev->dev, \"Error reading MAC address\\n\");\n\t\telse if (is_zero_ether_addr(adapter->hw.mac.addr))\n\t\t\tdev_info(&pdev->dev,\n\t\t\t\t \"MAC address not assigned by administrator.\\n\");\n\t\tether_addr_copy(netdev->dev_addr, hw->mac.addr);\n\t}\n\n\tif (!is_valid_ether_addr(netdev->dev_addr)) {\n\t\tdev_info(&pdev->dev, \"Assigning random MAC address\\n\");\n\t\teth_hw_addr_random(netdev);\n\t\tether_addr_copy(hw->mac.addr, netdev->dev_addr);\n\t\tether_addr_copy(hw->mac.perm_addr, netdev->dev_addr);\n\t}\n\n\t/* Enable dynamic interrupt throttling rates */\n\tadapter->rx_itr_setting = 1;\n\tadapter->tx_itr_setting = 1;\n\n\t/* set default ring sizes */\n\tadapter->tx_ring_count = IXGBEVF_DEFAULT_TXD;\n\tadapter->rx_ring_count = IXGBEVF_DEFAULT_RXD;\n\n\tset_bit(__IXGBEVF_DOWN, &adapter->state);\n\treturn 0;\n\nout:\n\treturn err;\n}", "label": 0, "cwe": null, "length": 539 }, { "index": 21706, "code": "get_property_length(uint8_t *property)\n{\n uint8_t length_and_number;\n uint8_t length;\n\n#ifdef STRICT_Z\n if (property == NULL)\n {\n i18n_translate(\n libfizmo_module_name,\n i18n_libfizmo_WARNING_FOR_P0S_AT_P0X,\n \"get_property_length\",\n (unsigned int)(current_instruction_location - z_mem));\n streams_latin1_output(\" \");\n i18n_translate(\n libfizmo_module_name,\n i18n_libfizmo_NULL_POINTER_RECEIVED);\n streams_latin1_output(\"\\n\");\n return 0;\n }\n#endif // STRICT_Z\n\n if (ver <= 3)\n {\n return (*property >> 5) + 1;\n }\n else\n {\n length_and_number = *property;\n TRACE_LOG(\"Property-byte: %x.\\n\", *property);\n\n if ((length_and_number & 0x80) != 0)\n {\n TRACE_LOG(\"Property-byte: %x.\\n\", *(property+1));\n // 12.4.2.1 If the top bit (bit 7) of the first size byte is set,\n // then there are two size-and-number bytes as follows. In the\n // first byte, bits 0 to 5 contain the property number; bit 6 is\n // undetermined (it is clear in all Infocom or Inform story files);\n // bit 7 is set. In the second byte, bits 0 to 5 contain the property\n // data length, counting in bytes; bit 6 is undetermined (it is set\n // in Infocom story files, but clear in Inform ones); bit 7 is always\n // set.\n length = *(++property) & 0x3f;\n\n // 12.4.2.1.1 A value of 0 as property data length (in the\n // second byte) should be interpreted as a length of 64. (Inform\n // can compile such properties.)\n if (length == 0)\n length = 64;\n }\n else\n {\n // 12.4.2.2 If the top bit (bit 7) of the first size byte is clear,\n // then there is only one size-and-number byte. Bits 0 to 5 contain\n // the property number; bit 6 is either clear to indicate a property\n // data length of 1, or set to indicate a length of 2; bit 7 is clear.\n length = (length_and_number & 0x40) != 0 ? (uint8_t)2 : (uint8_t)1;\n }\n\n return length;\n }\n}", "label": 0, "cwe": null, "length": 592 }, { "index": 583467, "code": "nfs_rename(struct inode *old_dir, struct dentry *old_dentry,\n\t\t struct inode *new_dir, struct dentry *new_dentry)\n{\n\tstruct inode *old_inode = d_inode(old_dentry);\n\tstruct inode *new_inode = d_inode(new_dentry);\n\tstruct dentry *dentry = NULL, *rehash = NULL;\n\tstruct rpc_task *task;\n\tint error = -EBUSY;\n\n\tdfprintk(VFS, \"NFS: rename(%pd2 -> %pd2, ct=%d)\\n\",\n\t\t old_dentry, new_dentry,\n\t\t d_count(new_dentry));\n\n\ttrace_nfs_rename_enter(old_dir, old_dentry, new_dir, new_dentry);\n\t/*\n\t * For non-directories, check whether the target is busy and if so,\n\t * make a copy of the dentry and then do a silly-rename. If the\n\t * silly-rename succeeds, the copied dentry is hashed and becomes\n\t * the new target.\n\t */\n\tif (new_inode && !S_ISDIR(new_inode->i_mode)) {\n\t\t/*\n\t\t * To prevent any new references to the target during the\n\t\t * rename, we unhash the dentry in advance.\n\t\t */\n\t\tif (!d_unhashed(new_dentry)) {\n\t\t\td_drop(new_dentry);\n\t\t\trehash = new_dentry;\n\t\t}\n\n\t\tif (d_count(new_dentry) > 2) {\n\t\t\tint err;\n\n\t\t\t/* copy the target dentry's name */\n\t\t\tdentry = d_alloc(new_dentry->d_parent,\n\t\t\t\t\t &new_dentry->d_name);\n\t\t\tif (!dentry)\n\t\t\t\tgoto out;\n\n\t\t\t/* silly-rename the existing target ... */\n\t\t\terr = nfs_sillyrename(new_dir, new_dentry);\n\t\t\tif (err)\n\t\t\t\tgoto out;\n\n\t\t\tnew_dentry = dentry;\n\t\t\trehash = NULL;\n\t\t\tnew_inode = NULL;\n\t\t}\n\t}\n\n\tNFS_PROTO(old_inode)->return_delegation(old_inode);\n\tif (new_inode != NULL)\n\t\tNFS_PROTO(new_inode)->return_delegation(new_inode);\n\n\ttask = nfs_async_rename(old_dir, new_dir, old_dentry, new_dentry, NULL);\n\tif (IS_ERR(task)) {\n\t\terror = PTR_ERR(task);\n\t\tgoto out;\n\t}\n\n\terror = rpc_wait_for_completion_task(task);\n\tif (error == 0)\n\t\terror = task->tk_status;\n\trpc_put_task(task);\n\tnfs_mark_for_revalidate(old_inode);\nout:\n\tif (rehash)\n\t\td_rehash(rehash);\n\ttrace_nfs_rename_exit(old_dir, old_dentry,\n\t\t\tnew_dir, new_dentry, error);\n\tif (!error) {\n\t\tif (new_inode != NULL)\n\t\t\tnfs_drop_nlink(new_inode);\n\t\td_move(old_dentry, new_dentry);\n\t\tnfs_set_verifier(old_dentry,\n\t\t\t\t\tnfs_save_change_attribute(new_dir));\n\t} else if (error == -ENOENT)\n\t\tnfs_dentry_handle_enoent(old_dentry);\n\n\t/* new dentry created? */\n\tif (dentry)\n\t\tdput(dentry);\n\treturn error;\n}", "label": 0, "cwe": null, "length": 653 }, { "index": 824610, "code": "reg_submatch(no)\n int\t\tno;\n{\n char_u\t*retval = NULL;\n char_u\t*s;\n int\t\tlen;\n int\t\tround;\n linenr_T\tlnum;\n\n if (!can_f_submatch || no < 0)\n\treturn NULL;\n\n if (submatch_match == NULL)\n {\n\t/*\n\t * First round: compute the length and allocate memory.\n\t * Second round: copy the text.\n\t */\n\tfor (round = 1; round <= 2; ++round)\n\t{\n\t lnum = submatch_mmatch->startpos[no].lnum;\n\t if (lnum < 0 || submatch_mmatch->endpos[no].lnum < 0)\n\t\treturn NULL;\n\n\t s = reg_getline(lnum) + submatch_mmatch->startpos[no].col;\n\t if (s == NULL) /* anti-crash check, cannot happen? */\n\t\tbreak;\n\t if (submatch_mmatch->endpos[no].lnum == lnum)\n\t {\n\t\t/* Within one line: take form start to end col. */\n\t\tlen = submatch_mmatch->endpos[no].col\n\t\t\t\t\t - submatch_mmatch->startpos[no].col;\n\t\tif (round == 2)\n\t\t vim_strncpy(retval, s, len);\n\t\t++len;\n\t }\n\t else\n\t {\n\t\t/* Multiple lines: take start line from start col, middle\n\t\t * lines completely and end line up to end col. */\n\t\tlen = (int)STRLEN(s);\n\t\tif (round == 2)\n\t\t{\n\t\t STRCPY(retval, s);\n\t\t retval[len] = '\\n';\n\t\t}\n\t\t++len;\n\t\t++lnum;\n\t\twhile (lnum < submatch_mmatch->endpos[no].lnum)\n\t\t{\n\t\t s = reg_getline(lnum++);\n\t\t if (round == 2)\n\t\t\tSTRCPY(retval + len, s);\n\t\t len += (int)STRLEN(s);\n\t\t if (round == 2)\n\t\t\tretval[len] = '\\n';\n\t\t ++len;\n\t\t}\n\t\tif (round == 2)\n\t\t STRNCPY(retval + len, reg_getline(lnum),\n\t\t\t\t\t submatch_mmatch->endpos[no].col);\n\t\tlen += submatch_mmatch->endpos[no].col;\n\t\tif (round == 2)\n\t\t retval[len] = NUL;\n\t\t++len;\n\t }\n\n\t if (retval == NULL)\n\t {\n\t\tretval = lalloc((long_u)len, TRUE);\n\t\tif (retval == NULL)\n\t\t return NULL;\n\t }\n\t}\n }\n else\n {\n\tif (submatch_match->endp[no] == NULL)\n\t retval = NULL;\n\telse\n\t{\n\t s = submatch_match->startp[no];\n\t retval = vim_strnsave(s, (int)(submatch_match->endp[no] - s));\n\t}\n }\n\n return retval;\n}", "label": 0, "cwe": null, "length": 647 }, { "index": 744260, "code": "find_field_in_group_list(Item *find_item, ORDER *group_list)\n{\n const char *db_name;\n const char *table_name;\n const char *field_name;\n ORDER *found_group= NULL;\n int found_match_degree= 0;\n Item_ident *cur_field;\n int cur_match_degree= 0;\n char name_buff[NAME_LEN+1];\n\n if (find_item->type() == Item::FIELD_ITEM ||\n find_item->type() == Item::REF_ITEM)\n {\n db_name= ((Item_ident*) find_item)->db_name;\n table_name= ((Item_ident*) find_item)->table_name;\n field_name= ((Item_ident*) find_item)->field_name;\n }\n else\n return NULL;\n\n if (db_name && lower_case_table_names)\n {\n /* Convert database to lower case for comparison */\n strmake(name_buff, db_name, sizeof(name_buff)-1);\n my_casedn_str(files_charset_info, name_buff);\n db_name= name_buff;\n }\n\n DBUG_ASSERT(field_name != 0);\n\n for (ORDER *cur_group= group_list ; cur_group ; cur_group= cur_group->next)\n {\n if ((*(cur_group->item))->real_item()->type() == Item::FIELD_ITEM)\n {\n cur_field= (Item_ident*) *cur_group->item;\n cur_match_degree= 0;\n \n DBUG_ASSERT(cur_field->field_name != 0);\n\n if (!my_strcasecmp(system_charset_info,\n cur_field->field_name, field_name))\n ++cur_match_degree;\n else\n continue;\n\n if (cur_field->table_name && table_name)\n {\n /* If field_name is qualified by a table name. */\n if (my_strcasecmp(table_alias_charset, cur_field->table_name, table_name))\n /* Same field names, different tables. */\n return NULL;\n\n ++cur_match_degree;\n if (cur_field->db_name && db_name)\n {\n /* If field_name is also qualified by a database name. */\n if (strcmp(cur_field->db_name, db_name))\n /* Same field names, different databases. */\n return NULL;\n ++cur_match_degree;\n }\n }\n\n if (cur_match_degree > found_match_degree)\n {\n found_match_degree= cur_match_degree;\n found_group= cur_group;\n }\n else if (found_group && (cur_match_degree == found_match_degree) &&\n ! (*(found_group->item))->eq(cur_field, 0))\n {\n /*\n If the current resolve candidate matches equally well as the current\n best match, they must reference the same column, otherwise the field\n is ambiguous.\n */\n my_error(ER_NON_UNIQ_ERROR, MYF(0),\n find_item->full_name(), current_thd->where);\n return NULL;\n }\n }\n }\n\n if (found_group)\n return found_group->item;\n else\n return NULL;\n}", "label": 0, "cwe": null, "length": 640 }, { "index": 106987, "code": "GoForward ()\n{\n\tif (m_stage == WIZ_START) {\n\t\tm_crypt_dir = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (m_magic));\n\t\tif (m_crypt_dir == NULL) {\n\t\t\tGtkWidget *dialog = \n\t\t\t\tgtk_message_dialog_new_with_markup (GTK_WINDOW (m_window),\n\t\t\t\t\t\tGTK_DIALOG_MODAL,\n\t\t\t\t\t\tGTK_MESSAGE_ERROR,\n\t\t\t\t\t\tGTK_BUTTONS_OK,\n\t\t\t\t\t\t\"%s\",\n\t\t\t\t\t\t_(\"You must select a folder\"));\n\t\t\tgtk_dialog_run (GTK_DIALOG (dialog));\n\t\t\tgtk_widget_destroy (dialog);\n\t\t\treturn;\n\t\t}\n\t\tchar buf[1024];\n\t\tstruct stat blah;\n\t\tconst char* const conf[] = {\"%s/.encfs5\", \"%s/.encfs6.xml\"};\n\t\tunsigned int confs = sizeof conf / sizeof conf[0];\n\n\t\tfor (int i = 0; i <= confs; i++) {\n\t\t\tif (i == confs) {\n\t\t\t\tGtkWidget *dialog = \n\t\t\t\t\tgtk_message_dialog_new_with_markup (GTK_WINDOW (m_window),\n\t\t\t\t\t\t\tGTK_DIALOG_MODAL,\n\t\t\t\t\t\t\tGTK_MESSAGE_ERROR,\n\t\t\t\t\t\t\tGTK_BUTTONS_OK,\n\t\t\t\t\t\t\t\"%s\",\n\t\t\t\t\t\t\t_(\"The selected folder is not an EncFS encrypted folder\"));\n\t\t\t\tgtk_dialog_run (GTK_DIALOG (dialog));\n\t\t\t\tgtk_widget_destroy (dialog);\n\t\t\t\tg_free (m_crypt_dir);\n\t\t\t\tm_crypt_dir = NULL;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsnprintf (buf, sizeof (buf), conf[i], m_crypt_dir);\n\t\t\tif (stat (buf, &blah) == 0 ) \n\t\t\t\tbreak;\n\t\t}\n\t}\n\tif (m_stage == WIZ_PASSWD) {\n\t\tm_mount_dir = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (m_magic));\n\t\tif (m_mount_dir == NULL) {\n\t\t\tGtkWidget *dialog = \n\t\t\t\tgtk_message_dialog_new_with_markup (GTK_WINDOW (m_window),\n\t\t\t\t\t\tGTK_DIALOG_MODAL,\n\t\t\t\t\t\tGTK_MESSAGE_ERROR,\n\t\t\t\t\t\tGTK_BUTTONS_OK,\n\t\t\t\t\t\t\"%s\",\n\t\t\t\t\t\t_(\"You must enter a name\"));\n\t\t\tgtk_dialog_run (GTK_DIALOG (dialog));\n\t\t\tgtk_widget_destroy (dialog);\n\t\t\treturn;\n\t\t}\n\t}\n\tm_stage++;\n\tif (m_stage == WIZ_END) {\n\t\tgtk_widget_set_sensitive (m_button_cancel, FALSE);\n\t\tgtk_button_set_label (GTK_BUTTON (m_button_forward), GTK_STOCK_OK);\n\t\t\n\t\tadd_crypt_point (m_crypt_dir, m_mount_dir);\n\n\t\tg_free (m_crypt_dir);\n\t\tg_free (m_mount_dir);\n\t\tm_mount_dir = NULL;\n\t\tm_crypt_dir = NULL;\n\t}\n\tif (m_stage > WIZ_END) {\n\t\tHide ();\n\t} else {\n\t\tUpdateStageUI ();\n\t}\n}", "label": 0, "cwe": null, "length": 618 }, { "index": 506885, "code": "FBBegin(Dspl)\n\nchar *Dspl;\n{\n FB.fDisplay = Dspl;\n if (!(FB.fInitialized)) {\n if ((*GR[FB.fInterface].gOpen)(FB.fDisplay))\n fatal_error(\"Unable to open display.\");\n else {\n if (Parameters.kpFontName[0] != '\\0')\n MFBSetFont(Parameters.kpFontName);\n if (Parameters.kpCursorShape >= 0)\n MFBSetCursor(Parameters.kpCursorShape);\n if (Parameters.kpFullScreenCursor)\n MFBSetFullScreenCursor(True);\n }\n }\n\n FBSetLineStyle(0);\n FB.fMaxX = FBInfo(MAXX);\n FB.fMaxY = FBInfo(MAXY);\n FB.fMaxP = 1000;\n FB.fMaxIntensity = 255;\n FB.fNumColors = FBInfo(MAXCOLORS) - 1;\n if (FB.fNumColors >= 32)\n Parameters.kpMergeColors = False;\n else\n Parameters.kpMergeColors = True;\n FB.fNumFillPatterns = FBInfo(MAXFILLPATTERNS) - 1;\n FB.fButtonMask = SetButtonMask();\n FB.fButtons = FBInfo(POINTINGBUTTONS);\n FB.fNumButtons = FBInfo(NUMBUTTONS);\n /*\n * Font width and height is henceforth assumed to\n * include the X and Y offsets.\n */\n FB.fFontWidth = FBInfo(FONTWIDTH);\n FB.fFontHeight = FBInfo(FONTHEIGHT);\n FB.fFontWidth += FBInfo(FONTXOFFSET);\n FB.fFontHeight += FBInfo(FONTYOFFSET);\n FB.fNumRows = FB.fMaxY/FB.fFontHeight;\n FB.fNumColumns = FB.fMaxX/FB.fFontWidth;\n FB.fFilledPolygons = FBInfo(FILLEDPOLYGONS);\n FB.fDefinableFillPatterns = FBInfo(DEFFILLPATTERNS);\n FB.fNonDestructiveText = FBInfo(OVERSTRIKETEXT);\n FB.fLastCursorColumn = 0;\n FB.fBlinkers = FBInfo(BLINKERS);\n FB.fInitialized = True;\n MFBSetTextMode(False);\n FBSetTextClip(0,0,FB.fMaxX,FB.fMaxY);\n}", "label": 0, "cwe": null, "length": 514 }, { "index": 647164, "code": "setProperScales(\n const CFeaturePtr & feat1,\n const CFeaturePtr & feat2,\n int & firstScale,\n int & lastScale )\n{\n // Find the range of scales (of those within feat1) where the descriptor should be matched\n // For the feat1 we use \"initialDepth\" since all the scales are relative to this depth while for the\n // feat2 it is used \"depth\" which is the actual scale of the feature.\n MRPT_START\n int numScales = int(feat1->multiScales.size());\n// if( numScales <= 1 )\n// {\n// cout << \"BAD NUMBER OF SCALES: \" << endl;\n// feat1->dumpToConsole();\n// feat2->dumpToConsole();\n ASSERT_( numScales > 1 );\n// }\n\n firstScale = 0;\n lastScale = numScales-1;\n\n // Determine the range of scale where to look for in the list1\n double smin = (feat2->depth-0.15*feat1->initialDepth)/feat1->initialDepth;\n double smax = (feat2->depth+0.15*feat1->initialDepth)/feat1->initialDepth;\n\n if( smin <= feat1->multiScales[1] )\n firstScale = 0;\n else\n {\n if( smin > feat1->multiScales[numScales-2] )\n firstScale = numScales-2;\n else // it is in between the limits\n {\n for( int k = 1; k <= numScales-3; ++k )\n if( smin > feat1->multiScales[k] )\n firstScale = k;\n } // end else\n } // end else\n\n if( smax <= feat1->multiScales[1] )\n lastScale = 1;\n else\n {\n if( smax > feat1->multiScales[numScales-2] )\n lastScale = numScales-1;\n else\n {\n for( int k = 1; k <= numScales-3; ++k )\n if( smax <= feat1->multiScales[k] )\n {\n lastScale = k;\n break;\n } // end if\n } // end else\n } // end else\n\n ASSERT_( firstScale >= 0 && lastScale < numScales && firstScale < lastScale );\n MRPT_END\n}", "label": 0, "cwe": null, "length": 554 }, { "index": 74139, "code": "pdf_write_encoding(gx_device_pdf *pdev, const pdf_font_resource_t *pdfont, long id, int ch)\n{\n /* Note : this truncates extended glyph names to original names. */\n stream *s;\n gs_encoding_index_t base_encoding = pdfont->u.simple.BaseEncoding;\n const int sl = strlen(gx_extendeg_glyph_name_separator);\n int prev = 256, code, cnt = 0;\n\n pdf_open_separate(pdev, id, resourceEncoding);\n s = pdev->strm;\n stream_puts(s, \"<ForOPDFRead)\n base_encoding = ENCODING_INDEX_STANDARD;\n if (base_encoding > 0)\n pprints1(s, \"/BaseEncoding/%s\", encoding_names[base_encoding]);\n stream_puts(s, \"/Differences[\");\n for (; ch < 256; ++ch) {\n code = pdf_different_encoding_element(pdfont, ch, base_encoding);\n if (code < 0)\n return code; /* Must not happen */\n if (code == 0 && (pdfont->FontType == ft_user_defined ||\n pdfont->FontType == ft_PCL_user_defined ||\n pdfont->FontType == ft_MicroType ||\n pdfont->FontType == ft_GL2_stick_user_defined ||\n pdfont->FontType == ft_GL2_531)) {\n /* PDF 1.4 spec Appendix H Note 42 says that\n * Acrobat 4 can't properly handle Base Encoding.\n * Enforce writing differences against that.\n */\n if (pdfont->used[ch >> 3] & 0x80 >> (ch & 7))\n if (pdfont->u.simple.Encoding[ch].str.size)\n code = 1;\n }\n if (code) {\n const byte *d = pdfont->u.simple.Encoding[ch].str.data;\n int i, l = pdfont->u.simple.Encoding[ch].str.size;\n\n if (pdev->HavePDFWidths) {\n for (i = 0; i + sl < l; i++)\n if (!memcmp(d + i, gx_extendeg_glyph_name_separator, sl)) {\n l = i;\n break;\n }\n }\n if (ch != prev + 1) {\n pprintd1(s, \"\\n%d\", ch);\n cnt = 1;\n } else if (!(cnt++ & 15))\n stream_puts(s, \"\\n\");\n pdf_put_name(pdev, d, l);\n prev = ch;\n }\n }\n stream_puts(s, \"]>>\\n\");\n pdf_end_separate(pdev, resourceEncoding);\n return 0;\n}", "label": 0, "cwe": null, "length": 579 }, { "index": 378360, "code": "howNearCM(const HepLorentzVector & w) const {\n\n double tTotal = (ee + w.ee);\n Hep3Vector vTotal (pp + w.pp);\n double vTotal2 = vTotal.mag2();\n\n if ( vTotal2 >= tTotal*tTotal ) {\n // Either one or both vectors are spacelike, or the dominant T components\n // are in opposite directions. So boosting and testing makes no sense;\n // but we do consider two exactly equal vectors to be equal in any frame,\n // even if they are spacelike and can't be boosted to a CM frame.\n if (*this == w) {\n return 0;\n } else {\n return 1;\n }\n }\n\n if ( vTotal2 == 0 ) { // no boost needed!\n return (howNear(w));\n }\n\n // Find the boost to the CM frame. We know that the total vector is timelike.\n\n double tRecip = 1./tTotal;\n Hep3Vector bboost ( vTotal * (-tRecip) );\n\n //-| Note that you could do pp/t and not be terribly inefficient since\n //-| SpaceVector/t itself takes 1/t and multiplies. The code here saves\n //-| a redundant check for t=0.\n\n // Boost both vectors. Since we have the same boost, there is no need\n // to repeat the beta and gamma calculation; and there is no question\n // about beta >= 1. That is why we don't just call w.boosted().\n\n double b2 = vTotal2*tRecip*tRecip;\n if ( b2 >= 1 ) {\t\t\t// NaN-proofing\n ZMthrowC ( ZMxpvTachyonic (\n\t\"boost vector in howNearCM appears to be tachyonic\"));\n }\n register double ggamma = std::sqrt(1./(1.-b2));\n register double boostDotV1 = bboost.dot(pp);\n register double gm1_b2 = (ggamma-1)/b2;\n\n HepLorentzVector w1 ( pp + ((gm1_b2)*boostDotV1+ggamma*ee) * bboost,\n ggamma * (ee + boostDotV1) );\n\n register double boostDotV2 = bboost.dot(w.pp);\n HepLorentzVector w2 ( w.pp + ((gm1_b2)*boostDotV2+ggamma*w.ee) * bboost,\n ggamma * (w.ee + boostDotV2) );\n\n return (w1.howNear(w2));\n\n}", "label": 0, "cwe": null, "length": 572 }, { "index": 813074, "code": "expand_builtin_printf (tree arglist, rtx target, enum machine_mode mode,\n\t\t bool unlocked)\n{\n /* If we're using an unlocked function, assume the other unlocked\n functions exist explicitly. */\n tree const fn_putchar = unlocked ? built_in_decls[BUILT_IN_PUTCHAR_UNLOCKED]\n : implicit_built_in_decls[BUILT_IN_PUTCHAR];\n tree const fn_puts = unlocked ? built_in_decls[BUILT_IN_PUTS_UNLOCKED]\n : implicit_built_in_decls[BUILT_IN_PUTS];\n const char *fmt_str;\n tree fn, fmt, arg;\n\n /* If the return value is used, don't do the transformation. */\n if (target != const0_rtx)\n return 0;\n\n /* Verify the required arguments in the original call. */\n if (! arglist)\n return 0;\n fmt = TREE_VALUE (arglist);\n if (TREE_CODE (TREE_TYPE (fmt)) != POINTER_TYPE)\n return 0;\n arglist = TREE_CHAIN (arglist);\n\n /* Check whether the format is a literal string constant. */\n fmt_str = c_getstr (fmt);\n if (fmt_str == NULL)\n return 0;\n\n /* If the format specifier was \"%s\\n\", call __builtin_puts(arg). */\n if (strcmp (fmt_str, \"%s\\n\") == 0)\n {\n if (! arglist\n || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != POINTER_TYPE\n\t || TREE_CHAIN (arglist))\n\treturn 0;\n fn = fn_puts;\n }\n /* If the format specifier was \"%c\", call __builtin_putchar(arg). */\n else if (strcmp (fmt_str, \"%c\") == 0)\n {\n if (! arglist\n\t || TREE_CODE (TREE_TYPE (TREE_VALUE (arglist))) != INTEGER_TYPE\n\t || TREE_CHAIN (arglist))\n\treturn 0;\n fn = fn_putchar;\n }\n else\n {\n /* We can't handle anything else with % args or %% ... yet. */\n if (strchr (fmt_str, '%'))\n return 0;\n\n if (arglist)\n\treturn 0;\n\n /* If the format specifier was \"\", printf does nothing. */\n if (fmt_str[0] == '\\0')\n\treturn const0_rtx;\n /* If the format specifier has length of 1, call putchar. */\n if (fmt_str[1] == '\\0')\n\t{\n\t /* Given printf(\"c\"), (where c is any one character,)\n\t convert \"c\"[0] to an int and pass that to the replacement\n\t function. */\n\t arg = build_int_2 (fmt_str[0], 0);\n\t arglist = build_tree_list (NULL_TREE, arg);\n\t fn = fn_putchar;\n\t}\n else\n\t{\n\t /* If the format specifier was \"string\\n\", call puts(\"string\"). */\n\t size_t len = strlen (fmt_str);\n\t if (fmt_str[len - 1] == '\\n')\n\t {\n\t /* Create a NUL-terminated string that's one char shorter\n\t\t than the original, stripping off the trailing '\\n'. */\n\t char *newstr = (char *) alloca (len);\n\t memcpy (newstr, fmt_str, len - 1);\n\t newstr[len - 1] = 0;\n\n\t arg = build_string_literal (len, newstr);\n\t arglist = build_tree_list (NULL_TREE, arg);\n\t fn = fn_puts;\n\t }\n\t else\n\t /* We'd like to arrange to call fputs(string,stdout) here,\n\t but we need stdout and don't have a way to get it yet. */\n\t return 0;\n\t}\n }\n\n if (!fn)\n return 0;\n return expand_expr (build_function_call_expr (fn, arglist),\n\t\t target, mode, EXPAND_NORMAL);\n}", "label": 0, "cwe": null, "length": 839 }, { "index": 150560, "code": "getScaleFactorPsStatesBuffer(HANDLE_PS_DEC h_ps_d)\n{\n INT i;\n int scale = DFRACT_BITS-1;\n\n for (i=0; ispecificTo.mpeg.hybrid.mQmfBufferRealSlot[i], NO_SUB_QMF_CHANNELS));\n scale = fMin(scale, getScalefactor(h_ps_d->specificTo.mpeg.hybrid.mQmfBufferImagSlot[i], NO_SUB_QMF_CHANNELS));\n }\n\n for (i=0; ispecificTo.mpeg.aaRealDelayBufferQmf[i], FIRST_DELAY_SB));\n scale = fMin(scale, getScalefactor(h_ps_d->specificTo.mpeg.aaImagDelayBufferQmf[i], FIRST_DELAY_SB));\n }\n\n for (i=0; ispecificTo.mpeg.aaRealDelayBufferSubQmf[i], NO_SUB_QMF_CHANNELS));\n scale = fMin(scale, getScalefactor(h_ps_d->specificTo.mpeg.aaImagDelayBufferSubQmf[i], NO_SUB_QMF_CHANNELS));\n }\n\n for (i=0; ispecificTo.mpeg.aaaRealDelayRBufferSerQmf[i], NO_DELAY_LENGTH_VECTORS));\n scale = fMin(scale, getScalefactor(h_ps_d->specificTo.mpeg.aaaImagDelayRBufferSerQmf[i], NO_DELAY_LENGTH_VECTORS));\n }\n\n for (i=0; ispecificTo.mpeg.aaaRealDelayRBufferSerSubQmf[i], NO_DELAY_LENGTH_VECTORS));\n scale = fMin(scale, getScalefactor(h_ps_d->specificTo.mpeg.aaaImagDelayRBufferSerSubQmf[i], NO_DELAY_LENGTH_VECTORS));\n }\n\n for (i=0; ispecificTo.mpeg.pAaRealDelayBufferQmf[i], len));\n scale = fMin(scale, getScalefactor(h_ps_d->specificTo.mpeg.pAaImagDelayBufferQmf[i], len));\n }\n\n return (scale);\n}", "label": 0, "cwe": null, "length": 607 }, { "index": 658657, "code": "amd756_probe(struct pci_dev *pdev, const struct pci_device_id *id)\n{\n\tint nforce = (id->driver_data == NFORCE);\n\tint error;\n\tu8 temp;\n\t\n\tif (amd756_ioport) {\n\t\tdev_err(&pdev->dev, \"Only one device supported \"\n\t\t \"(you have a strange motherboard, btw)\\n\");\n\t\treturn -ENODEV;\n\t}\n\n\tif (nforce) {\n\t\tif (PCI_FUNC(pdev->devfn) != 1)\n\t\t\treturn -ENODEV;\n\n\t\tpci_read_config_word(pdev, SMBBANFORCE, &amd756_ioport);\n\t\tamd756_ioport &= 0xfffc;\n\t} else { /* amd */\n\t\tif (PCI_FUNC(pdev->devfn) != 3)\n\t\t\treturn -ENODEV;\n\n\t\tpci_read_config_byte(pdev, SMBGCFG, &temp);\n\t\tif ((temp & 128) == 0) {\n\t\t\tdev_err(&pdev->dev,\n\t\t\t\t\"Error: SMBus controller I/O not enabled!\\n\");\n\t\t\treturn -ENODEV;\n\t\t}\n\n\t\t/* Determine the address of the SMBus areas */\n\t\t/* Technically it is a dword but... */\n\t\tpci_read_config_word(pdev, SMBBA, &amd756_ioport);\n\t\tamd756_ioport &= 0xff00;\n\t\tamd756_ioport += SMB_ADDR_OFFSET;\n\t}\n\n\terror = acpi_check_region(amd756_ioport, SMB_IOSIZE,\n\t\t\t\t amd756_driver.name);\n\tif (error)\n\t\treturn -ENODEV;\n\n\tif (!request_region(amd756_ioport, SMB_IOSIZE, amd756_driver.name)) {\n\t\tdev_err(&pdev->dev, \"SMB region 0x%x already in use!\\n\",\n\t\t\tamd756_ioport);\n\t\treturn -ENODEV;\n\t}\n\n\tpci_read_config_byte(pdev, SMBREV, &temp);\n\tdev_dbg(&pdev->dev, \"SMBREV = 0x%X\\n\", temp);\n\tdev_dbg(&pdev->dev, \"AMD756_smba = 0x%X\\n\", amd756_ioport);\n\n\t/* set up the sysfs linkage to our parent device */\n\tamd756_smbus.dev.parent = &pdev->dev;\n\n\tsnprintf(amd756_smbus.name, sizeof(amd756_smbus.name),\n\t\t \"SMBus %s adapter at %04x\", chipname[id->driver_data],\n\t\t amd756_ioport);\n\n\terror = i2c_add_adapter(&amd756_smbus);\n\tif (error) {\n\t\tdev_err(&pdev->dev,\n\t\t\t\"Adapter registration failed, module not inserted\\n\");\n\t\tgoto out_err;\n\t}\n\n\treturn 0;\n\n out_err:\n\trelease_region(amd756_ioport, SMB_IOSIZE);\n\treturn error;\n}", "label": 0, "cwe": null, "length": 580 }, { "index": 468733, "code": "locate_attributes (BusConfigParser *parser,\n const char *element_name,\n const char **attribute_names,\n const char **attribute_values,\n DBusError *error,\n const char *first_attribute_name,\n const char **first_attribute_retloc,\n ...)\n{\n va_list args;\n const char *name;\n const char **retloc;\n int n_attrs;\n#define MAX_ATTRS 24\n LocateAttr attrs[MAX_ATTRS];\n dbus_bool_t retval;\n int i;\n\n _dbus_assert (first_attribute_name != NULL);\n _dbus_assert (first_attribute_retloc != NULL);\n\n retval = TRUE;\n\n n_attrs = 1;\n attrs[0].name = first_attribute_name;\n attrs[0].retloc = first_attribute_retloc;\n *first_attribute_retloc = NULL;\n\n va_start (args, first_attribute_retloc);\n\n name = va_arg (args, const char*);\n retloc = va_arg (args, const char**);\n\n while (name != NULL)\n {\n _dbus_assert (retloc != NULL);\n _dbus_assert (n_attrs < MAX_ATTRS);\n\n attrs[n_attrs].name = name;\n attrs[n_attrs].retloc = retloc;\n n_attrs += 1;\n *retloc = NULL;\n\n name = va_arg (args, const char*);\n retloc = va_arg (args, const char**);\n }\n\n va_end (args);\n\n i = 0;\n while (attribute_names[i])\n {\n int j;\n dbus_bool_t found;\n \n found = FALSE;\n j = 0;\n while (j < n_attrs)\n {\n if (strcmp (attrs[j].name, attribute_names[i]) == 0)\n {\n retloc = attrs[j].retloc;\n\n if (*retloc != NULL)\n {\n dbus_set_error (error, DBUS_ERROR_FAILED,\n \"Attribute \\\"%s\\\" repeated twice on the same <%s> element\",\n attrs[j].name, element_name);\n retval = FALSE;\n goto out;\n }\n\n *retloc = attribute_values[i];\n found = TRUE;\n }\n\n ++j;\n }\n\n if (!found)\n {\n dbus_set_error (error, DBUS_ERROR_FAILED,\n \"Attribute \\\"%s\\\" is invalid on <%s> element in this context\",\n attribute_names[i], element_name);\n retval = FALSE;\n goto out;\n }\n\n ++i;\n }\n\n out:\n return retval;\n}", "label": 0, "cwe": null, "length": 538 }, { "index": 460278, "code": "add_inter_constraints(struct isl_sched_graph *graph,\n\tstruct isl_sched_edge *edge, __isl_take isl_map *map, int pos)\n{\n\tunsigned total;\n\tisl_ctx *ctx = isl_map_get_ctx(map);\n\tisl_space *dim;\n\tisl_dim_map *dim_map;\n\tisl_basic_set *coef;\n\tstruct isl_sched_node *src = edge->src;\n\tstruct isl_sched_node *dst = edge->dst;\n\n\tcoef = inter_coefficients(graph, edge, map);\n\tif (!coef)\n\t\treturn -1;\n\n\tdim = isl_space_domain(isl_space_unwrap(isl_basic_set_get_space(coef)));\n\n\ttotal = isl_basic_set_total_dim(graph->lp);\n\tdim_map = isl_dim_map_alloc(ctx, total);\n\n\tisl_dim_map_range(dim_map, 3 + pos, 0, 0, 0, 1, -1);\n\n\tisl_dim_map_range(dim_map, dst->start, 0, 0, 0, 1, 1);\n\tisl_dim_map_range(dim_map, dst->start + 1, 2, 1, 1, dst->nparam, -1);\n\tisl_dim_map_range(dim_map, dst->start + 2, 2, 1, 1, dst->nparam, 1);\n\tisl_dim_map_range(dim_map, dst->start + 2 * dst->nparam + 1, 2,\n\t\t\t isl_space_dim(dim, isl_dim_set) + src->nvar, 1,\n\t\t\t dst->nvar, -1);\n\tisl_dim_map_range(dim_map, dst->start + 2 * dst->nparam + 2, 2,\n\t\t\t isl_space_dim(dim, isl_dim_set) + src->nvar, 1,\n\t\t\t dst->nvar, 1);\n\n\tisl_dim_map_range(dim_map, src->start, 0, 0, 0, 1, -1);\n\tisl_dim_map_range(dim_map, src->start + 1, 2, 1, 1, src->nparam, 1);\n\tisl_dim_map_range(dim_map, src->start + 2, 2, 1, 1, src->nparam, -1);\n\tisl_dim_map_range(dim_map, src->start + 2 * src->nparam + 1, 2,\n\t\t\t isl_space_dim(dim, isl_dim_set), 1,\n\t\t\t src->nvar, 1);\n\tisl_dim_map_range(dim_map, src->start + 2 * src->nparam + 2, 2,\n\t\t\t isl_space_dim(dim, isl_dim_set), 1,\n\t\t\t src->nvar, -1);\n\n\tgraph->lp = isl_basic_set_extend_constraints(graph->lp,\n\t\t\tcoef->n_eq, coef->n_ineq);\n\tgraph->lp = isl_basic_set_add_constraints_dim_map(graph->lp,\n\t\t\t\t\t\t\t coef, dim_map);\n\tisl_space_free(dim);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 625 }, { "index": 190715, "code": "init(const char* pszFile)\n{\n m_iFd = open(pszFile, O_RDONLY | O_LARGEFILE);\n if (m_iFd < 0)\n {\n\tAVM_WRITE(\"ASF reader\", \"Could not open the file\\n\");\n\treturn -1;\n }\n uint8_t* header = 0;\n ssize_t r;\n m_lDataOffset = 0;\n\n for (;;)\n {\n\tGUID guid;\n\tint64_t size;\n\tif (read(m_iFd, &guid, 16) <= 0 || read(m_iFd, &size, 8) <= 0)\n\t break;\n\tavm_get_leGUID(&guid);\n\tsize = avm_get_le64(&size) - 24;\n\tif (size < 0)\n\t break;\n\t//char buf[100];printf(\"GUID type %d\t%s\\n\", (int) guid_get_guidid(&guid), guid_to_string(buf, &guid));\n\tAVM_WRITE(\"ASF reader\", 1, \"Object: %s - object size: %5\" PRId64 \"\\n\", guidid_to_text(guid_get_guidid(&guid)), size);\n\n\tswitch (guid_get_guidid(&guid))\n\t{\n\tcase GUID_ASF_HEADER:\n\t if ((header = new uint8_t[size]))\n\t {\n\t\tr = read(m_iFd, header, size);\n\t\tif (r <= 0 || !parseHeader(header, (uint_t) r))\n\t\t{\n\t\t delete[] header;\n\t\t header = 0;\n\t\t}\n\t }\n\t break;\n\tcase GUID_ASF_DATA:\n\t if (size < 26 || !header)\n\t {\n\t\tAVM_WRITE(\"ASF reader\", \"Wrong data chunk size\\n\");\n\t\treturn -1;\n\t }\n\t m_lDataOffset = lseek64(m_iFd, 0, SEEK_CUR) + 26;\n\t lseek64(m_iFd, size, SEEK_CUR);\n\t break;\n\tcase GUID_ERROR: //unknown chunk type\n\tdefault:\n\t if (!header)\n\t\tbreak;\n\t lseek64(m_iFd, size, SEEK_CUR);\n\t break;\n\t}\n }\n if (!header)\n {\n\tAVM_WRITE(\"ASF reader\", 1, \"Could not find ASF header chunk in file\\n\");\n\treturn -1;\n }\n if (!m_lDataOffset)\n {\n\tAVM_WRITE(\"ASF reader\", \"Could not find data chunk in file\\n\");\n\treturn -1;\n }\n delete[] header;\n createSeekData();\n return 0;\n}", "label": 0, "cwe": null, "length": 532 }, { "index": 476675, "code": "esas2r_start_request(struct esas2r_adapter *a, struct esas2r_request *rq)\n{\n\tstruct esas2r_target *t = NULL;\n\tstruct esas2r_request *startrq = rq;\n\tunsigned long flags;\n\n\tif (unlikely(test_bit(AF_DEGRADED_MODE, &a->flags) ||\n\t\t test_bit(AF_POWER_DOWN, &a->flags))) {\n\t\tif (rq->vrq->scsi.function == VDA_FUNC_SCSI)\n\t\t\trq->req_stat = RS_SEL2;\n\t\telse\n\t\t\trq->req_stat = RS_DEGRADED;\n\t} else if (likely(rq->vrq->scsi.function == VDA_FUNC_SCSI)) {\n\t\tt = a->targetdb + rq->target_id;\n\n\t\tif (unlikely(t >= a->targetdb_end\n\t\t\t || !(t->flags & TF_USED))) {\n\t\t\trq->req_stat = RS_SEL;\n\t\t} else {\n\t\t\t/* copy in the target ID. */\n\t\t\trq->vrq->scsi.target_id = cpu_to_le16(t->virt_targ_id);\n\n\t\t\t/*\n\t\t\t * Test if we want to report RS_SEL for missing target.\n\t\t\t * Note that if AF_DISC_PENDING is set than this will\n\t\t\t * go on the defer queue.\n\t\t\t */\n\t\t\tif (unlikely(t->target_state != TS_PRESENT &&\n\t\t\t\t !test_bit(AF_DISC_PENDING, &a->flags)))\n\t\t\t\trq->req_stat = RS_SEL;\n\t\t}\n\t}\n\n\tif (unlikely(rq->req_stat != RS_PENDING)) {\n\t\tesas2r_complete_request(a, rq);\n\t\treturn;\n\t}\n\n\tesas2r_trace(\"rq=%p\", rq);\n\tesas2r_trace(\"rq->vrq->scsi.handle=%x\", rq->vrq->scsi.handle);\n\n\tif (rq->vrq->scsi.function == VDA_FUNC_SCSI) {\n\t\tesas2r_trace(\"rq->target_id=%d\", rq->target_id);\n\t\tesas2r_trace(\"rq->vrq->scsi.flags=%x\", rq->vrq->scsi.flags);\n\t}\n\n\tspin_lock_irqsave(&a->queue_lock, flags);\n\n\tif (likely(list_empty(&a->defer_list) &&\n\t\t !test_bit(AF_CHPRST_PENDING, &a->flags) &&\n\t\t !test_bit(AF_FLASHING, &a->flags) &&\n\t\t !test_bit(AF_DISC_PENDING, &a->flags)))\n\t\tesas2r_local_start_request(a, startrq);\n\telse\n\t\tlist_add_tail(&startrq->req_list, &a->defer_list);\n\n\tspin_unlock_irqrestore(&a->queue_lock, flags);\n}", "label": 0, "cwe": null, "length": 562 }, { "index": 995679, "code": "Java_org_gdal_osr_osrJNI_SpatialReference_1ImportFromPCI_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jstring jarg3, jdoubleArray jarg4) {\n jint jresult = 0 ;\n OSRSpatialReferenceShadow *arg1 = (OSRSpatialReferenceShadow *) 0 ;\n char *arg2 = (char *) 0 ;\n char *arg3 = (char *) 0 ;\n double *arg4 ;\n OGRErr result;\n \n (void)jenv;\n (void)jcls;\n (void)jarg1_;\n arg1 = *(OSRSpatialReferenceShadow **)&jarg1; \n arg2 = 0;\n if (jarg2) {\n arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);\n if (!arg2) return 0;\n }\n arg3 = 0;\n if (jarg3) {\n arg3 = (char *)jenv->GetStringUTFChars(jarg3, 0);\n if (!arg3) return 0;\n }\n {\n /* %typemap(in) (double argin[ANY]) */\n if(jarg4 == NULL || jenv->GetArrayLength(jarg4) != 17) {\n char errorMsg[512];\n sprintf(errorMsg, \"array of size %d expected\", 17);\n SWIG_JavaThrowException(jenv, SWIG_JavaIndexOutOfBoundsException, errorMsg);\n return 0;\n }\n arg4 = (double *)jenv->GetDoubleArrayElements(jarg4, NULL);\n }\n result = (OGRErr)OSRSpatialReferenceShadow_ImportFromPCI__SWIG_0(arg1,(char const *)arg2,(char const *)arg3,arg4);\n {\n /* %typemap(out) OGRErr */\n if (result != 0 && bUseExceptions) {\n SWIG_JavaThrowException(jenv, SWIG_JavaRuntimeException,\n OGRErrMessages(result));\n return 0;\n }\n jresult = (jint)result;\n }\n {\n /* %typemap(argout) (double argin[ANY]) */\n }\n if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);\n if (arg3) jenv->ReleaseStringUTFChars(jarg3, (const char *)arg3);\n {\n /* %typemap(in) (double argin[ANY]) */\n if(arg4) {\n jenv->ReleaseDoubleArrayElements(jarg4, (jdouble *)arg4, JNI_ABORT);\n }\n }\n {\n /* %typemap(ret) OGRErr */\n \n }\n return jresult;\n}", "label": 0, "cwe": null, "length": 618 }, { "index": 563166, "code": "normalisebutton_cb(Fl_Button*, transferRGB *panel)\n{\n int spp, val, minval, maxval;\n long nbpix;\n unsigned char *p, *end;\n double slope, startp;\n int normR, normG, normB;\n char buf[100];\n \n // asks which channels to affect\n panel->affectChannels(normR, normG, normB);\n panel->ensureImageRedraw(true); // we want the result to be shown on the image\n \n nbpix = (long)IOBlackBox->imageWidth() * (long)IOBlackBox->imageHeight();\n spp = IOBlackBox->imageDepth();\n\n maxval = 0;\n minval = 255;\n \n if (spp == 1) {\n\tp = IOBlackBox->imageData();\n\tend = p + nbpix;\n\t\n\twhile (p != end) {\n\t if (*p > maxval)\n\t\tmaxval = *p;\n\t if (*p < minval)\n\t\tminval = *p;\n\t p++;\n\t}\n } else if (spp == 3) {\n\tp = IOBlackBox->imageData();\n\tend = p + spp * nbpix;\n\t// we only include in the calculation the channels\n\t// to be normalized\n\twhile (p != end) {\n\t if (normR) {\n\t\tval = *p++;\n\t\tif (val > maxval)\n\t\t maxval = val;\n\t\tif (val < maxval)\n\t\t minval = val;\n\t } else {\n\t\tp++; // red pixels ignored in calculation\n\t }\n\t \n\t if (normG) {\n\t\tval = *p++;\n\t\tif (val > maxval)\n\t\t maxval = val;\n\t\tif (val < maxval)\n\t\t minval = val;\n\t } else {\n\t\tp++; // green pixels ignored\n\t }\n\n\t if (normB) {\n\t\tval = *p++;\n\t\tif (val > maxval)\n\t\t maxval = val;\n\t\tif (val < maxval)\n\t\t minval = val;\n\t } else {\n\t\tp++; // blue pixels ignored\n\t }\n\t}\n }\n\n dbgprintf(\"Min val:%d, max val: %d\\n\", minval, maxval);\n\n // now compute the slope parameters, etc\n if (maxval != minval)\n\tslope = 2*atan(255.0/(maxval-minval))/M_PI;\n else\n\tslope = 1;\n \n startp = ((double)maxval+minval)/(512);\n\n // this is now pretty simple...\n\n sprintf(buf, \"%g\", persistentGamma);\n if (normR) {\n\tpanel->setRGammaInputValue(buf);\n\tpanel->setRGammaSliderValue(0);\n\tpanel->setRContrastSliderValue(slope);\n\tpanel->setRBrightnessSliderValue(startp);\n }\n\n if (normG) {\n\tpanel->setGGammaInputValue(buf);\n\tpanel->setGGammaSliderValue(0);\n\tpanel->setGContrastSliderValue(slope);\n\tpanel->setGBrightnessSliderValue(startp);\n }\n\n if (normB) {\n\tpanel->setBGammaInputValue(buf);\n\tpanel->setBGammaSliderValue(0);\n\tpanel->setBContrastSliderValue(slope);\n\tpanel->setBBrightnessSliderValue(startp);\n }\n \n panel->setDrawingParms();\n panel->computeDrawingParms();\n\n return;\n}", "label": 0, "cwe": null, "length": 730 }, { "index": 110437, "code": "OpenWeaponMenu (edict_t * ent)\n{\n\t//AQ2:TNG - Igor adding wp_flags\n\tstatic char *menu_weapnames[] = {\n\t\t\"MP5/10 Submachinegun\",\n\t\t\"M3 Super90 Assault Shotgun\",\n\t\t\"Handcannon\",\n\t\t\"SSG 3000 Sniper Rifle\",\n\t\t\"M4 Assault Rifle\",\n\t\t\"Combat Knives\",\n\t\t\"Akimbo Pistols\"\n\t\t};\n\tint pos;\n\n\tif ((int) wp_flags->value & ~(WPF_MK23 | WPF_GRENADE))\n\t{\n\t\tpos = 4;\n\t\tif ((int) wp_flags->value & WPF_MP5)\n\t\t{\n\t\t\tweapmenu[pos].text = menu_weapnames[0];\n\t\t\tweapmenu[pos].SelectFunc = SelectWeapon2;\n\t\t\tpos++;\n\t\t}\n\n\t\tif ((int) wp_flags->value & WPF_M3)\n\t\t{\n\t\t\tweapmenu[pos].text = menu_weapnames[1];\n\t\t\tweapmenu[pos].SelectFunc = SelectWeapon3;\n\t\t\tpos++;\n\t\t}\n\n\t\tif ((int) wp_flags->value & WPF_HC)\n\t\t{\n\t\t\tweapmenu[pos].text = menu_weapnames[2];\n\t\t\tweapmenu[pos].SelectFunc = SelectWeapon4;\n\t\t\tpos++;\n\t\t}\n\n\t\tif ((int) wp_flags->value & WPF_SNIPER)\n\t\t{\n\t\t\tweapmenu[pos].text = menu_weapnames[3];\n\t\t\tweapmenu[pos].SelectFunc = SelectWeapon5;\n\t\t\tpos++;\n\t\t}\n\n\t\tif ((int) wp_flags->value & WPF_M4)\n\t\t{\n\t\t\tweapmenu[pos].text = menu_weapnames[4];\n\t\t\tweapmenu[pos].SelectFunc = SelectWeapon6;\n\t\t\tpos++;\n\t\t}\n\n\t\tif ((int) wp_flags->value & WPF_KNIFE)\n\t\t{\n\t\t\tweapmenu[pos].text = menu_weapnames[5];\n\t\t\tweapmenu[pos].SelectFunc = SelectWeapon0;\n\t\t\tpos++;\n\t\t}\n\n\t\tif ((int) wp_flags->value & WPF_DUAL)\n\t\t{\n\t\t\tweapmenu[pos].text = menu_weapnames[6];\n\t\t\tweapmenu[pos].SelectFunc = SelectWeapon9;\n\t\t\tpos++;\n\t\t}\n\n\t\tfor (; pos < 11; pos++)\n\t\t{\n\t\t\tweapmenu[pos].text = NULL;\n\t\t\tweapmenu[pos].SelectFunc = NULL;\n\t\t}\n\n\t\tPMenu_Open (ent, weapmenu, 4, sizeof (weapmenu) / sizeof (pmenu_t));\n\t}\n\telse\n\t{\n\t\tOpenItemMenu (ent);\n\t}\n\t//AQ2:TNG End adding wp_flags\n}", "label": 0, "cwe": null, "length": 602 }, { "index": 100681, "code": "Provokable(ProxyWindow *proxy,proxy_provoke_t provocation)\n{\n\tint soft=proxy->flags.is_soft;\n\tProxyGroup* proxy_group=proxy->proxy_group;\n\tproxy_follow_t follow;\n\tWindowName* include;\n#if PROXY_GROUP_DEBUG\n\tfprintf(stderr, \"Provokable %p %s %x soft %d\\n\",\n\t\tproxy,proxy->name,provocation,soft);\n#endif\n\tif(!proxy_group)\n\t{\n\t\tproxy_group=FindProxyGroupOfNeighbor(proxy);\n\t}\n\tif(!proxy_group)\n\t{\n\t\treturn True;\n\t}\n\n\tfollow=PROXY_FOLLOW_INHERIT;\n\n#if PROXY_GROUP_DEBUG\n\tfprintf(stderr, \" group flags %x\\n\",proxy_group->flags);\n#endif\n\tinclude = FindWindowName(proxy_group->includes,proxy->name);\n\tif(include)\n\t{\n#if PROXY_GROUP_DEBUG\n\t\tfprintf(stderr, \" include flags %x\\n\",include->flags);\n#endif\n\n\t\tswitch(provocation)\n\t\t{\n\t\t\tcase PROXY_PROVOKE_RAISE:\n\t\t\t\tfollow=soft? include->flags.soft_raise:\n\t\t\t\t\tinclude->flags.hard_raise;\n\t\t\tbreak;\n\n\t\t\tcase PROXY_PROVOKE_DESK:\n\t\t\t\tfollow=soft? include->flags.soft_desk:\n\t\t\t\t\tinclude->flags.hard_desk;\n\t\t\tbreak;\n\n\t\t\tcase PROXY_PROVOKE_DRAG:\n\t\t\t\tfollow=soft? include->flags.soft_drag:\n\t\t\t\t\tinclude->flags.hard_drag;\n\t\t\tbreak;\n\n\t\t\tcase PROXY_PROVOKE_ICON:\n\t\t\t\tfollow=soft? include->flags.soft_icon:\n\t\t\t\t\tinclude->flags.hard_icon;\n\t\t\tbreak;\n\t\t}\n#if PROXY_GROUP_DEBUG\n\t\tfprintf(stderr, \" include follow %d\\n\",follow);\n#endif\n\t\tif(follow!=PROXY_FOLLOW_INHERIT)\n\t\t{\n\t\t\treturn (follow!=PROXY_FOLLOW_OFF);\n\t\t}\n\t}\n\n\tfollow=PROXY_FOLLOW_INHERIT;\n\tswitch(provocation)\n\t{\n\t\tcase PROXY_PROVOKE_RAISE:\n\t\t\tfollow=soft? proxy_group->flags.soft_raise:\n\t\t\t\tproxy_group->flags.hard_raise;\n\t\tbreak;\n\n\t\tcase PROXY_PROVOKE_DESK:\n\t\t\tfollow=soft? proxy_group->flags.soft_desk:\n\t\t\t\tproxy_group->flags.hard_desk;\n\t\tbreak;\n\n\t\tcase PROXY_PROVOKE_DRAG:\n\t\t\tfollow=soft? proxy_group->flags.soft_drag:\n\t\t\t\tproxy_group->flags.hard_drag;\n\t\tbreak;\n\n\t\tcase PROXY_PROVOKE_ICON:\n\t\t\tfollow=soft? proxy_group->flags.soft_icon:\n\t\t\t\tproxy_group->flags.hard_icon;\n\t\tbreak;\n\t}\n#if PROXY_GROUP_DEBUG\n\tfprintf(stderr, \" group follow %d\\n\",follow);\n#endif\n\treturn (follow!=PROXY_FOLLOW_OFF);\n}", "label": 0, "cwe": null, "length": 583 }, { "index": 934758, "code": "rk2_apply (void *vstate,\n size_t dim,\n double t,\n double h,\n double y[],\n double yerr[],\n const double dydt_in[],\n double dydt_out[], \n const gsl_odeiv_system * sys)\n{\n rk2_state_t *state = (rk2_state_t *) vstate;\n\n size_t i;\n\n double *const k1 = state->k1;\n double *const k2 = state->k2;\n double *const k3 = state->k3;\n double *const ytmp = state->ytmp;\n\n /* k1 step */\n /* k1 = f(t,y) */\n\n if (dydt_in != NULL)\n {\n DBL_MEMCPY (k1, dydt_in, dim);\n }\n else\n {\n int s = GSL_ODEIV_FN_EVAL (sys, t, y, k1);\n\n if (s != GSL_SUCCESS)\n\t{\n\t return s;\n\t}\n }\n\n /* k2 step */\n /* k2 = f(t + 0.5*h, y + 0.5*k1) */\n\n for (i = 0; i < dim; i++)\n {\n ytmp[i] = y[i] + 0.5 * h * k1[i];\n }\n\n {\n int s = GSL_ODEIV_FN_EVAL (sys, t + 0.5 * h, ytmp, k2);\n\n if (s != GSL_SUCCESS)\n {\n\treturn s;\n }\n }\n\n /* k3 step */\n /* for 3rd order estimates, is used for error estimation\n k3 = f(t + h, y - k1 + 2*k2) */\n \n for (i = 0; i < dim; i++)\n {\n ytmp[i] = y[i] + h * (-k1[i] + 2.0 * k2[i]);\n }\n\n {\n int s = GSL_ODEIV_FN_EVAL (sys, t + h, ytmp, k3);\n\n if (s != GSL_SUCCESS)\n {\n\treturn s;\n }\n }\n\n /* final sum */\n \n for (i = 0; i < dim; i++)\n {\n /* Save original values if derivative evaluation below fails */\n ytmp[i] = y[i];\n\n {\n\tconst double ksum3 = (k1[i] + 4.0 * k2[i] + k3[i]) / 6.0;\n\ty[i] += h * ksum3;\n }\n }\n \n /* Derivatives at output */\n\n if (dydt_out != NULL)\n {\n int s = GSL_ODEIV_FN_EVAL (sys, t + h, y, dydt_out);\n \n if (s != GSL_SUCCESS)\n\t{\n\t /* Restore original values */\n\t DBL_MEMCPY (y, ytmp, dim);\n\t \n\t return s;\n\t}\n }\n\n /* Error estimation */\n\n for (i = 0; i < dim; i++)\n {\n const double ksum3 = (k1[i] + 4.0 * k2[i] + k3[i]) / 6.0;\n yerr[i] = h * (k2[i] - ksum3);\n }\n \n return GSL_SUCCESS;\n}", "label": 0, "cwe": null, "length": 714 }, { "index": 716697, "code": "sdbm_storage_needs(size_t key_size, size_t value_size, size_t *needed)\n{\n#ifdef BIGDATA\n\t/*\n\t * This is the same logic as in putpair().\n\t *\n\t * Instead of just checking:\n\t *\n\t *\t\tkey_size <= DBM_PAIRMAX && DBM_PAIRMAX - key_size >= value_size\n\t *\n\t * which would only indicate whether the expanded key and value can\n\t * fit in the page we loook at whether the sum of key + value sizes is\n\t * big enough to warrant offloading of the value in a .dat file, thereby\n\t * reducing the memory constraints in the .pag file. However we don't\n\t * offload the value to the .dat if its ends up wasting more than half\n\t * the pages there.\n\t *\n\t * NOTE: any change to the logic below must also be reported to putpair().\n\t */\n\n\tif (\n\t\tkey_size <= DBM_PAIRMAX && DBM_PAIRMAX - key_size >= value_size &&\n\t\t(\n\t\t\tkey_size + value_size < DBM_PAIRMAX / 2 ||\n\t\t\tvalue_size < DBM_BBLKSIZ / 2\n\t\t)\n\t) {\n\t\t/* Will expand both the key and the value in the page */\n\t\tif (needed != NULL)\n\t\t\t*needed = key_size + value_size;\n\t\treturn TRUE;\n\t} else {\n\t\tsize_t kl;\n\t\tsize_t vl;\n\n\t\t/*\n\t\t * Large keys are sub-optimal because key comparison involves extra\n\t\t * I/O operations, so it's best to attempt to inline keys as much\n\t\t * as possible.\n\t\t */\n\n\t\tvl = bigval_length(value_size);\n\n\t\tif (vl >= DBM_PAIRMAX)\t\t/* Cannot store by indirection anyway */\n\t\t\treturn FALSE;\n\n\t\tif (key_size <= DBM_PAIRMAX && DBM_PAIRMAX - key_size >= vl) {\n\t\t\t/* Will expand the key but store the value in the .dat file */\n\t\t\tif (needed != NULL)\n\t\t\t\t*needed = key_size + vl;\n\t\t\treturn TRUE;\n\t\t}\n\n\t\t/*\n\t\t * No choice but to try to store the key via indirection as well.\n\t\t */\n\n\t\tkl = bigkey_length(key_size);\n\n\t\tif (needed != NULL)\n\t\t\t*needed = kl + vl;\n\t\treturn kl <= DBM_PAIRMAX && DBM_PAIRMAX - kl >= vl;\n\t}\n#else\t/* !BIGDATA */\n\tif (needed != NULL)\n\t\t*needed = key_size + value_size;\n\treturn key_size <= DBM_PAIRMAX && DBM_PAIRMAX - key_size >= value_size;\n#endif\n}", "label": 0, "cwe": null, "length": 559 }, { "index": 629470, "code": "configuration_editor_dir_selected_cb (ConfigurationEditor* self) {\n\tKeyModel* key_model;\n\tGtkTreeIter iter = {0};\n\tGtkTreeView* _tmp0_;\n\tGtkTreeSelection* _tmp1_ = NULL;\n\tGtkTreeIter _tmp2_ = {0};\n\tgboolean _tmp3_ = FALSE;\n\tGtkTreeView* _tmp11_;\n\tKeyModel* _tmp12_;\n\tgboolean _tmp13_ = FALSE;\n\tKeyModel* _tmp14_;\n\tgboolean _tmp18_;\n\tg_return_if_fail (self != NULL);\n\tkey_model = NULL;\n\t_tmp0_ = self->priv->dir_tree_view;\n\t_tmp1_ = gtk_tree_view_get_selection (_tmp0_);\n\t_tmp3_ = gtk_tree_selection_get_selected (_tmp1_, NULL, &_tmp2_);\n\titer = _tmp2_;\n\tif (_tmp3_) {\n\t\tSettingsModel* _tmp4_;\n\t\tGtkTreeIter _tmp5_;\n\t\tDirectory* _tmp6_ = NULL;\n\t\tDirectory* _tmp7_;\n\t\tKeyModel* _tmp8_;\n\t\tKeyModel* _tmp9_;\n\t\tKeyModel* _tmp10_;\n\t\t_tmp4_ = self->priv->model;\n\t\t_tmp5_ = iter;\n\t\t_tmp6_ = settings_model_get_directory (_tmp4_, &_tmp5_);\n\t\t_tmp7_ = _tmp6_;\n\t\t_tmp8_ = directory_get_key_model (_tmp7_);\n\t\t_tmp9_ = _tmp8_;\n\t\t_tmp10_ = _g_object_ref0 (_tmp9_);\n\t\t_g_object_unref0 (key_model);\n\t\tkey_model = _tmp10_;\n\t\t_g_object_unref0 (_tmp7_);\n\t}\n\t_tmp11_ = self->priv->key_tree_view;\n\t_tmp12_ = key_model;\n\tgtk_tree_view_set_model (_tmp11_, (GtkTreeModel*) _tmp12_);\n\t_tmp14_ = key_model;\n\tif (_tmp14_ != NULL) {\n\t\tKeyModel* _tmp15_;\n\t\tGtkTreeIter _tmp16_ = {0};\n\t\tgboolean _tmp17_ = FALSE;\n\t\t_tmp15_ = key_model;\n\t\t_tmp17_ = gtk_tree_model_get_iter_first ((GtkTreeModel*) _tmp15_, &_tmp16_);\n\t\titer = _tmp16_;\n\t\t_tmp13_ = _tmp17_;\n\t} else {\n\t\t_tmp13_ = FALSE;\n\t}\n\t_tmp18_ = _tmp13_;\n\tif (_tmp18_) {\n\t\tGtkTreeView* _tmp19_;\n\t\tGtkTreeSelection* _tmp20_ = NULL;\n\t\tGtkTreeIter _tmp21_;\n\t\t_tmp19_ = self->priv->key_tree_view;\n\t\t_tmp20_ = gtk_tree_view_get_selection (_tmp19_);\n\t\t_tmp21_ = iter;\n\t\tgtk_tree_selection_select_iter (_tmp20_, &_tmp21_);\n\t}\n\t_g_object_unref0 (key_model);\n}", "label": 0, "cwe": null, "length": 608 }, { "index": 885755, "code": "VdbeFillPolygon(Viewport * v, Window win, GC gc, VPolygon * poly)\n{\n VPoint *p;\n XPoint xpt[VmaxVP], *lastpt;\n register int i, k;\n Drawable d;\n Color c;\n Display *dpy = v->dpy;\n GC xgc = v->gc;\n\n d = (Drawable) v->dbeDrawable;\n\n if (poly == (VPolygon *) NULL)\n return;\n\n k = 0;\n lastpt = &xpt[0];\n\n c = VComputePolygonColor(v, poly);\n\n if (c != v->lastPixel) {\n XSetForeground (dpy, xgc, c);\n v->lastPixel = c;\n }\n\n for ((i = 0, p = poly->vertex); i < poly->numVtces; (++i, ++p)) {\n\n if (v->flags & VPPerspective && p->z != 0.0) {\n xpt[k].x = (v->Middl.x + (int) (v->Scale.x * p->x / p->z)) >> 2;\n xpt[k].y = (v->Middl.y - (int) (v->Scale.y * p->y / p->z)) >> 2;\n }\n else {\n xpt[k].x = (v->Middl.x + (int) (v->Scale.x * p->x)) >> 2;\n xpt[k].y = (v->Middl.y - (int) (v->Scale.y * p->y)) >> 2;\n }\n\n#ifdef COLLAPSEUNUSEDPOINTS\n if (k == 0 || !(xpt[k].x == lastpt->x && xpt[k].y == lastpt->y))\n lastpt = &xpt[k++];\n#else\n ++k;\n#endif\n\n }\n\n if (k > 0) {\n#ifdef COLLAPSEUNUSEDPOINTS\n if (k == 1) {\n\n XDrawPoint(dpy, d, xgc, xpt[0].x, xpt[0].y);\n }\n else if (k == 2) {\n XDrawLine(dpy, d, xgc, xpt[0].x, xpt[0].y,\n\t\txpt[1].x, xpt[1].y);\n }\n else\n#endif\n XFillPolygon(dpy, d, xgc, xpt, k, Convex, CoordModeOrigin);\n }\n}", "label": 0, "cwe": null, "length": 554 }, { "index": 615704, "code": "gconf_list_model_notify_func (GConfClient* client, guint cnxn_id, GConfEntry *entry, gpointer user_data)\n{\n\tGSList *list;\n\tconst gchar *key;\n\tchar *path_str;\n\tGConfListModel *list_model = user_data;\n\tGtkTreeIter iter;\n\tGtkTreePath *path;\n\n\tkey = gconf_entry_get_key (entry);\n\n\tpath_str = g_path_get_dirname (key);\n\n\tif (strcmp (path_str, list_model->root_path) != 0)\n\t {\n\t g_free (path_str);\n\t return;\n\t }\n\n\tg_free (path_str);\n\n\tif (strncmp (key, list_model->root_path, strlen (list_model->root_path)) != 0)\n\t return;\n\t\n\tif (gconf_client_dir_exists (client, key, NULL))\n\t\t/* this is a directory -- ignore */\n\t\treturn;\n\n\tlist = g_hash_table_lookup (list_model->key_hash, key);\n\n\tif (list == NULL) {\n\t\t/* Create a new entry */\n\t\tentry = gconf_entry_new (gconf_entry_get_key (entry),\n\t\t\t\t\t gconf_entry_get_value (entry));\n\n\t\tlist = g_slist_append (list, entry);\n\t\tlist_model->values = g_slist_concat (list_model->values, list);\n\t\tg_hash_table_insert (list_model->key_hash, g_strdup (key), list);\n\n\t\tlist_model->stamp++;\n\n\t\titer.stamp = list_model->stamp;\n\t\titer.user_data = list;\n\n\t\tlist_model->length++;\n\n\t\tpath = gtk_tree_model_get_path (GTK_TREE_MODEL (list_model), &iter);\n\t\tgtk_tree_model_row_inserted (GTK_TREE_MODEL (list_model), path, &iter);\n\t\tgtk_tree_path_free (path);\n\t}\n\telse {\n\t\tlist_model->stamp++;\n\n\t\titer.stamp = list_model->stamp;\n\t\titer.user_data = list;\n\n\t\tpath = gtk_tree_model_get_path (GTK_TREE_MODEL (list_model), &iter);\n\n\t\tgconf_entry_unref (list->data);\n\n\t\tif (gconf_entry_get_value (entry) != NULL) {\n\t\t\tlist->data = gconf_entry_new (gconf_entry_get_key (entry),\n\t\t\t\t\t\t gconf_entry_get_value (entry));\n\t\t\tgtk_tree_model_row_changed (GTK_TREE_MODEL (list_model), path, &iter);\n\t\t}\n\t\telse {\n\t\t\tgtk_tree_model_row_deleted (GTK_TREE_MODEL (list_model), path);\n\t\t\tlist_model->values = g_slist_remove (list_model->values, list->data);\n\t\t\tlist_model->length--;\n\t\t\tg_hash_table_remove (list_model->key_hash, key);\n\t\t}\n\n\t\tgtk_tree_path_free (path);\n\t}\n}", "label": 0, "cwe": null, "length": 552 }, { "index": 796161, "code": "OpenObjectFileContainingPcAndGetStartAddress(uint64_t pc,\n uint64_t &start_address) {\n int object_fd;\n\n // Open /proc/self/maps.\n int maps_fd;\n NO_INTR(maps_fd = open(\"/proc/self/maps\", O_RDONLY));\n FileDescriptor wrapped_maps_fd(maps_fd);\n if (wrapped_maps_fd.get() < 0) {\n return -1;\n }\n\n // Iterate over maps and look for the map containing the pc. Then\n // look into the symbol tables inside.\n char buf[1024]; // Big enough for line of sane /proc/self/maps\n LineReader reader(wrapped_maps_fd.get(), buf, sizeof(buf));\n while (true) {\n const char *cursor;\n const char *eol;\n if (!reader.ReadLine(&cursor, &eol)) { // EOF or malformed line.\n return -1;\n }\n\n // Start parsing line in /proc/self/maps. Here is an example:\n //\n // 08048000-0804c000 r-xp 00000000 08:01 2142121 /bin/cat\n //\n // We want start address (08048000), end address (0804c000), flags\n // (r-xp) and file name (/bin/cat).\n\n // Read start address.\n cursor = GetHex(cursor, eol, &start_address);\n if (cursor == eol || *cursor != '-') {\n return -1; // Malformed line.\n }\n ++cursor; // Skip '-'.\n\n // Read end address.\n uint64_t end_address;\n cursor = GetHex(cursor, eol, &end_address);\n if (cursor == eol || *cursor != ' ') {\n return -1; // Malformed line.\n }\n ++cursor; // Skip ' '.\n\n // Check start and end addresses.\n if (!(start_address <= pc && pc < end_address)) {\n continue; // We skip this map. PC isn't in this map.\n }\n\n // Read flags. Skip flags until we encounter a space or eol.\n const char * const flags_start = cursor;\n while (cursor < eol && *cursor != ' ') {\n ++cursor;\n }\n // We expect at least four letters for flags (ex. \"r-xp\").\n if (cursor == eol || cursor < flags_start + 4) {\n return -1; // Malformed line.\n }\n\n // Check flags. We are only interested in \"r-x\" maps.\n if (memcmp(flags_start, \"r-x\", 3) != 0) { // Not a \"r-x\" map.\n continue; // We skip this map.\n }\n ++cursor; // Skip ' '.\n\n // Skip to file name. \"cursor\" now points to file offset. We need to\n // skip at least three spaces for file offset, dev, and inode.\n int num_spaces = 0;\n while (cursor < eol) {\n if (*cursor == ' ') {\n ++num_spaces;\n } else if (num_spaces >= 3) {\n // The first non-space character after skipping three spaces\n // is the beginning of the file name.\n break;\n }\n ++cursor;\n }\n if (cursor == eol) {\n return -1; // Malformed line.\n }\n\n // Finally, \"cursor\" now points to file name of our interest.\n NO_INTR(object_fd = open(cursor, O_RDONLY));\n if (object_fd < 0) {\n return -1;\n }\n return object_fd;\n }\n}", "label": 0, "cwe": null, "length": 795 }, { "index": 638472, "code": "genwqe_user_vmap(struct genwqe_dev *cd, struct dma_mapping *m, void *uaddr,\n\t\t unsigned long size, struct ddcb_requ *req)\n{\n\tint rc = -EINVAL;\n\tunsigned long data, offs;\n\tstruct pci_dev *pci_dev = cd->pci_dev;\n\n\tif ((uaddr == NULL) || (size == 0)) {\n\t\tm->size = 0;\t/* mark unused and not added */\n\t\treturn -EINVAL;\n\t}\n\tm->u_vaddr = uaddr;\n\tm->size = size;\n\n\t/* determine space needed for page_list. */\n\tdata = (unsigned long)uaddr;\n\toffs = offset_in_page(data);\n\tm->nr_pages = DIV_ROUND_UP(offs + size, PAGE_SIZE);\n\n\tm->page_list = kcalloc(m->nr_pages,\n\t\t\t sizeof(struct page *) + sizeof(dma_addr_t),\n\t\t\t GFP_KERNEL);\n\tif (!m->page_list) {\n\t\tdev_err(&pci_dev->dev, \"err: alloc page_list failed\\n\");\n\t\tm->nr_pages = 0;\n\t\tm->u_vaddr = NULL;\n\t\tm->size = 0;\t/* mark unused and not added */\n\t\treturn -ENOMEM;\n\t}\n\tm->dma_list = (dma_addr_t *)(m->page_list + m->nr_pages);\n\n\t/* pin user pages in memory */\n\trc = get_user_pages_fast(data & PAGE_MASK, /* page aligned addr */\n\t\t\t\t m->nr_pages,\n\t\t\t\t 1,\t\t/* write by caller */\n\t\t\t\t m->page_list);\t/* ptrs to pages */\n\tif (rc < 0)\n\t\tgoto fail_get_user_pages;\n\n\t/* assumption: get_user_pages can be killed by signals. */\n\tif (rc < m->nr_pages) {\n\t\tfree_user_pages(m->page_list, rc, 0);\n\t\trc = -EFAULT;\n\t\tgoto fail_get_user_pages;\n\t}\n\n\trc = genwqe_map_pages(cd, m->page_list, m->nr_pages, m->dma_list);\n\tif (rc != 0)\n\t\tgoto fail_free_user_pages;\n\n\treturn 0;\n\n fail_free_user_pages:\n\tfree_user_pages(m->page_list, m->nr_pages, 0);\n\n fail_get_user_pages:\n\tkfree(m->page_list);\n\tm->page_list = NULL;\n\tm->dma_list = NULL;\n\tm->nr_pages = 0;\n\tm->u_vaddr = NULL;\n\tm->size = 0;\t\t/* mark unused and not added */\n\treturn rc;\n}", "label": 0, "cwe": null, "length": 521 }, { "index": 114152, "code": "synaptics_resolution(struct psmouse *psmouse)\n{\n\tstruct synaptics_data *priv = psmouse->private;\n\tunsigned char resp[3];\n\n\tif (SYN_ID_MAJOR(priv->identity) < 4)\n\t\treturn 0;\n\n\tif (synaptics_send_cmd(psmouse, SYN_QUE_RESOLUTION, resp) == 0) {\n\t\tif (resp[0] != 0 && (resp[1] & 0x80) && resp[2] != 0) {\n\t\t\tpriv->x_res = resp[0]; /* x resolution in units/mm */\n\t\t\tpriv->y_res = resp[2]; /* y resolution in units/mm */\n\t\t}\n\t}\n\n\tif (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 5 &&\n\t SYN_CAP_MAX_DIMENSIONS(priv->ext_cap_0c)) {\n\t\tif (synaptics_send_cmd(psmouse, SYN_QUE_EXT_MAX_COORDS, resp)) {\n\t\t\tpsmouse_warn(psmouse,\n\t\t\t\t \"device claims to have max coordinates query, but I'm not able to read it.\\n\");\n\t\t} else {\n\t\t\tpriv->x_max = (resp[0] << 5) | ((resp[1] & 0x0f) << 1);\n\t\t\tpriv->y_max = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3);\n\t\t\tpsmouse_info(psmouse,\n\t\t\t\t \"queried max coordinates: x [..%d], y [..%d]\\n\",\n\t\t\t\t priv->x_max, priv->y_max);\n\t\t}\n\t}\n\n\tif (SYN_CAP_MIN_DIMENSIONS(priv->ext_cap_0c) &&\n\t (SYN_EXT_CAP_REQUESTS(priv->capabilities) >= 7 ||\n\t /*\n\t * Firmware v8.1 does not report proper number of extended\n\t * capabilities, but has been proven to report correct min\n\t * coordinates.\n\t */\n\t SYN_ID_FULL(priv->identity) == 0x801)) {\n\t\tif (synaptics_send_cmd(psmouse, SYN_QUE_EXT_MIN_COORDS, resp)) {\n\t\t\tpsmouse_warn(psmouse,\n\t\t\t\t \"device claims to have min coordinates query, but I'm not able to read it.\\n\");\n\t\t} else {\n\t\t\tpriv->x_min = (resp[0] << 5) | ((resp[1] & 0x0f) << 1);\n\t\t\tpriv->y_min = (resp[2] << 5) | ((resp[1] & 0xf0) >> 3);\n\t\t\tpsmouse_info(psmouse,\n\t\t\t\t \"queried min coordinates: x [%d..], y [%d..]\\n\",\n\t\t\t\t priv->x_min, priv->y_min);\n\t\t}\n\t}\n\n\treturn 0;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 595 }, { "index": 719012, "code": "cuddAddComposeRecur(\n DdManager * dd,\n DdNode * f,\n DdNode * g,\n DdNode * proj)\n{\n DdNode *f1, *f0, *g1, *g0, *r, *t, *e;\n unsigned int v, topf, topg, topindex;\n\n statLine(dd);\n v = dd->perm[proj->index];\n topf = cuddI(dd,f->index);\n\n /* Terminal case. Subsumes the test for constant f. */\n if (topf > v) return(f);\n\n /* Check cache. */\n r = cuddCacheLookup(dd,DD_ADD_COMPOSE_RECUR_TAG,f,g,proj);\n if (r != NULL) {\n\treturn(r);\n }\n\n if (topf == v) {\n\t/* Compose. */\n\tf1 = cuddT(f);\n\tf0 = cuddE(f);\n\tr = cuddAddIteRecur(dd, g, f1, f0);\n\tif (r == NULL) return(NULL);\n } else {\n\t/* Compute cofactors of f and g. Remember the index of the top\n\t** variable.\n\t*/\n\ttopg = cuddI(dd,g->index);\n\tif (topf > topg) {\n\t topindex = g->index;\n\t f1 = f0 = f;\n\t} else {\n\t topindex = f->index;\n\t f1 = cuddT(f);\n\t f0 = cuddE(f);\n\t}\n\tif (topg > topf) {\n\t g1 = g0 = g;\n\t} else {\n\t g1 = cuddT(g);\n\t g0 = cuddE(g);\n\t}\n\t/* Recursive step. */\n\tt = cuddAddComposeRecur(dd, f1, g1, proj);\n\tif (t == NULL) return(NULL);\n\tcuddRef(t);\n\te = cuddAddComposeRecur(dd, f0, g0, proj);\n\tif (e == NULL) {\n\t Cudd_RecursiveDeref(dd, t);\n\t return(NULL);\n\t}\n\tcuddRef(e);\n\n\tif (t == e) {\n\t r = t;\n\t} else {\n\t r = cuddUniqueInter(dd, (int) topindex, t, e);\n\t if (r == NULL) {\n\t\tCudd_RecursiveDeref(dd, t);\n\t\tCudd_RecursiveDeref(dd, e);\n\t\treturn(NULL);\n\t }\n\t}\n\tcuddDeref(t);\n\tcuddDeref(e);\n }\n\n cuddCacheInsert(dd,DD_ADD_COMPOSE_RECUR_TAG,f,g,proj,r);\n\n return(r);\n\n}", "label": 0, "cwe": null, "length": 554 }, { "index": 530275, "code": "filter_func (GdkXEvent *gdk_xevent, GdkEvent *event, gpointer data)\n{\n\tXEvent *xevent = (XEvent *) gdk_xevent;\n\tGdkKeymap *keymap = gdk_keymap_get_default();\n\tguint keyval;\n\tGdkModifierType consumed, modifiers;\n\tguint mod_mask = gtk_accelerator_get_default_mod_mask();\n\tGSList *iter;\n\n\t(void) event;\n\t(void) data;\n\n\tswitch (xevent->type) {\n\tcase KeyPress:\n\t\tmodifiers = xevent->xkey.state;\n\n\t\tTRACE (g_print (\"Got KeyPress keycode: %d, modifiers: 0x%x\\n\", \n\t\t\t\txevent->xkey.keycode, \n\t\t\t\txevent->xkey.state));\n\n\t\tif (use_xkb_extension) {\n\t\t\tgdk_keymap_translate_keyboard_state(\n\t\t\t\tkeymap,\n\t\t\t\txevent->xkey.keycode,\n\t\t\t\tmodifiers,\n\t\t\t\t/* See top comment why we don't use this here:\n\t\t\t\t XkbGroupForCoreState (xevent->xkey.state)\n\t\t\t\t */\n\t\t\t\tWE_ONLY_USE_ONE_GROUP,\n\t\t\t\t&keyval, NULL, NULL, &consumed);\n\t\t} else {\n\t\t\tconsumed = 0;\n\t\t\tkeyval = XLookupKeysym(&xevent->xkey, 0);\n\t\t}\n\n\t\t/* Map non-virtual to virtual modifiers */\n\t\tmodifiers &= ~consumed;\n\t\tgdk_keymap_add_virtual_modifiers(keymap, &modifiers);\n\t\tmodifiers &= mod_mask;\n\n\t\tTRACE (g_print (\"Translated keyval: %d, vmodifiers: 0x%x, name: %s\\n\",\n\t\t keyval, modifiers,\n\t\t gtk_accelerator_name(keyval, modifiers)));\n\n\t\t/*\n\t\t * Set the last event time for use when showing\n\t\t * windows to avoid anti-focus-stealing code.\n\t\t */\n\t\tprocessing_event = TRUE;\n\t\tlast_event_time = xevent->xkey.time;\n\n\t\titer = bindings;\n\t\twhile (iter != NULL) {\n\t\t\t/* NOTE: ``iter`` might be removed from the list\n\t\t\t * in the callback.\n\t\t\t */\n\t\t\tstruct Binding *binding = iter->data;\n\t\t\titer = iter->next;\n\n\t\t\tif (keyvalues_equal(binding->keyval, keyval) &&\n\t\t\t modifiers_equal(binding->modifiers, modifiers)) {\n\t\t\t\tTRACE (g_print (\"Calling handler for '%s'...\\n\", \n\t\t\t\t\t\tbinding->keystring));\n\n\t\t\t\t(binding->handler) (binding->keystring, \n\t\t\t\t\t\t binding->user_data);\n\t\t\t}\n\t\t}\n\n\t\tprocessing_event = FALSE;\n\t\tbreak;\n\tcase KeyRelease:\n\t\tTRACE (g_print (\"Got KeyRelease! \\n\"));\n\t\tbreak;\n\t}\n\n\treturn GDK_FILTER_CONTINUE;\n}", "label": 0, "cwe": null, "length": 574 }, { "index": 158977, "code": "trx_rseg_header_create(\n/*===================*/\n\tulint\tspace,\t\t/*!< in: space id */\n\tulint\tzip_size,\t/*!< in: compressed page size in bytes\n\t\t\t\tor 0 for uncompressed pages */\n\tulint\tmax_size,\t/*!< in: max size in pages */\n\tulint\trseg_slot_no,\t/*!< in: rseg id == slot number in trx sys */\n\tmtr_t*\tmtr)\t\t/*!< in: mtr */\n{\n\tulint\t\tpage_no;\n\ttrx_rsegf_t*\trsegf;\n\ttrx_sysf_t*\tsys_header;\n\tulint\t\ti;\n\tbuf_block_t*\tblock;\n\n\tut_ad(mtr);\n\tut_ad(mutex_own(&kernel_mutex));\n\tut_ad(mtr_memo_contains(mtr, fil_space_get_latch(space, NULL),\n\t\t\t\tMTR_MEMO_X_LOCK));\n\n\t/* Allocate a new file segment for the rollback segment */\n\tblock = fseg_create(space, 0,\n\t\t\t TRX_RSEG + TRX_RSEG_FSEG_HEADER, mtr);\n\n\tif (block == NULL) {\n\t\t/* No space left */\n\n\t\treturn(FIL_NULL);\n\t}\n\n\tbuf_block_dbg_add_level(block, SYNC_RSEG_HEADER_NEW);\n\n\tpage_no = buf_block_get_page_no(block);\n\n\t/* Get the rollback segment file page */\n\trsegf = trx_rsegf_get_new(space, zip_size, page_no, mtr);\n\n\t/* Initialize max size field */\n\tmlog_write_ulint(rsegf + TRX_RSEG_MAX_SIZE, max_size,\n\t\t\t MLOG_4BYTES, mtr);\n\n\t/* Initialize the history list */\n\n\tmlog_write_ulint(rsegf + TRX_RSEG_HISTORY_SIZE, 0, MLOG_4BYTES, mtr);\n\tflst_init(rsegf + TRX_RSEG_HISTORY, mtr);\n\n\t/* Reset the undo log slots */\n\tfor (i = 0; i < TRX_RSEG_N_SLOTS; i++) {\n\n\t\ttrx_rsegf_set_nth_undo(rsegf, i, FIL_NULL, mtr);\n\t}\n\n\t/* Add the rollback segment info to the free slot in\n\tthe trx system header */\n\n\tsys_header = trx_sysf_get(mtr);\n\n\ttrx_sysf_rseg_set_space(sys_header, rseg_slot_no, space, mtr);\n\ttrx_sysf_rseg_set_page_no(sys_header, rseg_slot_no, page_no, mtr);\n\n\treturn(page_no);\n}", "label": 0, "cwe": null, "length": 519 }, { "index": 408517, "code": "gst_mpeg_audio_parse_check_valid_frame (GstBaseParse * parse,\n GstBaseParseFrame * frame, guint * framesize, gint * skipsize)\n{\n GstMpegAudioParse *mp3parse = GST_MPEG_AUDIO_PARSE (parse);\n GstBuffer *buf = frame->buffer;\n GstByteReader reader = GST_BYTE_READER_INIT_FROM_BUFFER (buf);\n gint off, bpf;\n gboolean lost_sync, draining, valid, caps_change;\n guint32 header;\n guint bitrate, layer, rate, channels, version, mode, crc;\n\n if (G_UNLIKELY (GST_BUFFER_SIZE (buf) < 6))\n return FALSE;\n\n off = gst_byte_reader_masked_scan_uint32 (&reader, 0xffe00000, 0xffe00000,\n 0, GST_BUFFER_SIZE (buf));\n\n GST_LOG_OBJECT (parse, \"possible sync at buffer offset %d\", off);\n\n /* didn't find anything that looks like a sync word, skip */\n if (off < 0) {\n *skipsize = GST_BUFFER_SIZE (buf) - 3;\n return FALSE;\n }\n\n /* possible frame header, but not at offset 0? skip bytes before sync */\n if (off > 0) {\n *skipsize = off;\n return FALSE;\n }\n\n /* make sure the values in the frame header look sane */\n header = GST_READ_UINT32_BE (GST_BUFFER_DATA (buf));\n if (!gst_mpeg_audio_parse_head_check (mp3parse, header)) {\n *skipsize = 1;\n return FALSE;\n }\n\n GST_LOG_OBJECT (parse, \"got frame\");\n\n bpf = mp3_type_frame_length_from_header (mp3parse, header,\n &version, &layer, &channels, &bitrate, &rate, &mode, &crc);\n g_assert (bpf != 0);\n\n if (channels != mp3parse->channels || rate != mp3parse->rate ||\n layer != mp3parse->layer || version != mp3parse->version)\n caps_change = TRUE;\n else\n caps_change = FALSE;\n\n lost_sync = GST_BASE_PARSE_LOST_SYNC (parse);\n draining = GST_BASE_PARSE_DRAINING (parse);\n\n if (!draining && (lost_sync || caps_change)) {\n if (!gst_mp3parse_validate_extended (mp3parse, buf, header, bpf, draining,\n &valid)) {\n /* not enough data */\n gst_base_parse_set_min_frame_size (parse, valid);\n *skipsize = 0;\n return FALSE;\n } else {\n if (!valid) {\n *skipsize = off + 2;\n return FALSE;\n }\n }\n } else if (draining && lost_sync && caps_change && mp3parse->rate > 0) {\n /* avoid caps jitter that we can't be sure of */\n *skipsize = off + 2;\n return FALSE;\n }\n\n /* restore default minimum */\n gst_base_parse_set_min_frame_size (parse, MIN_FRAME_SIZE);\n\n *framesize = bpf;\n return TRUE;\n}", "label": 0, "cwe": null, "length": 669 }, { "index": 153997, "code": "show_characteristics(bool verbose, std::ostringstream &output)\n{\n output <ifname(interface_num[i]) << \" \";\n }\n output << std::endl << std::endl;\n\n output << \"Circuit Timer (msec): \" << std::setw(6) << circuit_timer*10 << \" Keepalive Timer (sec): \" << std::setw(6) << keepalive_timer << std::endl;\n output << \"Retransmit Limit: \" << std::setw(6) << retransmit_limit << std::endl;\n output << \"Multicast Timer (sec):\" << std::setw(6) << multicast_timer << std::endl;\n output << std::endl;\n\n // Show groups\n output << \"User Groups: \";\n print_bitmap(output, true, user_groups);\n output << \"Service Groups: \";\n print_bitmap(output, groups_set, groups);\n output << std::endl;\n\n // Show services we are accepting for.\n output << \"Service Name Status Rating Identification\" << std::endl;\n std::list::iterator i(servicelist.begin());\n for (; i != servicelist.end(); i++)\n {\n\toutput.width(15);\n\toutput.setf(std::ios::left, std::ios::adjustfield);\n\toutput << i->get_name().c_str();\n\toutput.setf(std::ios::right, std::ios::adjustfield);\n\toutput << \"Enabled\" << std::setw(6) << i->get_rating() <<\n\t (i->get_static()?\" \":\" D \") << i->get_id() << std::endl;\n }\n\n output << std::endl << \"Port Service Node Remote Port Queued\" << std::endl;\n\n // Show allocated ports\n std::list::iterator p(portlist.begin());\n for (; p != portlist.end(); p++)\n {\n\tp->show_info(verbose, output);\n }\n\n // NUL-terminate it.\n output << std::endl << std::ends;\n\n return true;\n}", "label": 0, "cwe": null, "length": 624 }, { "index": 411804, "code": "panel_desktop_menu_item_new (gboolean use_image,\n\t\t\t gboolean in_menubar,\n\t\t\t gboolean append_lock_logout)\n{\n\tPanelDesktopMenuItem *menuitem;\n\tchar *name;\n\tconst char *icon_name;\n#ifdef HAVE_TELEPATHY_GLIB\n\tPanelSessionManager *manager;\n#endif\n\n\tmenuitem = g_object_new (PANEL_TYPE_DESKTOP_MENU_ITEM, NULL);\n\n\tname = panel_util_get_user_name ();\n#ifdef HAVE_TELEPATHY_GLIB\n\ticon_name = PANEL_ICON_USER_AVAILABLE;\n#else\n\ticon_name = PANEL_ICON_COMPUTER;\n#endif\n\n\t/* if we're in a menubar, we don't want to use setup_* as it changes\n\t * the size requests and can make the panels bigger than we'd like */\n\tif (in_menubar) {\n\t\tgtk_menu_item_set_label (GTK_MENU_ITEM (menuitem), name);\n\t\tmenuitem->priv->icon_size = panel_menu_bar_object_icon_get_size ();\n\n\t\tif (use_image) {\n\t\t\tGtkWidget *image;\n\t\t\timage = gtk_image_new_from_icon_name (icon_name,\n\t\t\t\t\t\t\t menuitem->priv->icon_size);\n\t\t\tgtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem),\n\t\t\t\t\t\t image);\n\t\t}\n\t} else {\n\t\tmenuitem->priv->icon_size = panel_menu_icon_get_size ();\n\n\t\tif (use_image)\n\t\t\tsetup_menu_item_with_icon (GTK_WIDGET (menuitem),\n\t\t\t\t\t\t menuitem->priv->icon_size,\n\t\t\t\t\t\t icon_name, NULL, NULL,\n\t\t\t\t\t\t name);\n\t\telse\n\t\t\tsetup_menuitem (GTK_WIDGET (menuitem),\n\t\t\t\t\tGTK_ICON_SIZE_INVALID, NULL,\n\t\t\t\t\tname);\n\t}\n\n#ifdef HAVE_TELEPATHY_GLIB\n\tif (use_image)\n\t\tgtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menuitem),\n\t\t\t\t\t\t\t TRUE);\n#endif\n\n\tg_free (name);\n\n\tmenuitem->priv->menu = panel_desktop_menu_item_create_menu (menuitem,\n\t\t\t\t\t\t\t\t append_lock_logout);\n\tgtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem),\n\t\t\t\t menuitem->priv->menu);\n\n#ifdef HAVE_TELEPATHY_GLIB\n\tmanager = panel_session_manager_get ();\n\n\tmenuitem->priv->presence_changed_id =\n\t\tg_signal_connect (manager,\n\t\t\t\t \"presence-changed\",\n\t\t\t\t G_CALLBACK (panel_desktop_menu_item_on_presence_changed),\n\t\t\t\t menuitem);\n\n\tpanel_desktop_menu_item_on_presence_changed (manager,\n\t\t\t\t\t\t panel_session_manager_get_presence (manager),\n\t\t\t\t\t\t menuitem);\n#endif\n\n\treturn GTK_WIDGET (menuitem);\n}", "label": 0, "cwe": null, "length": 521 }, { "index": 753297, "code": "compute_transp (const_rtx x, int indx, sbitmap *bmap, int set_p)\n{\n int i, j;\n enum rtx_code code;\n const char *fmt;\n\n /* repeat is used to turn tail-recursion into iteration since GCC\n can't do it when there's no return value. */\n repeat:\n\n if (x == 0)\n return;\n\n code = GET_CODE (x);\n switch (code)\n {\n case REG:\n if (set_p)\n\t{\n\t df_ref def;\n\t for (def = DF_REG_DEF_CHAIN (REGNO (x));\n\t def;\n\t def = DF_REF_NEXT_REG (def))\n\t SET_BIT (bmap[DF_REF_BB (def)->index], indx);\n\t}\n else\n\t{\n\t df_ref def;\n\t for (def = DF_REG_DEF_CHAIN (REGNO (x));\n\t def;\n\t def = DF_REF_NEXT_REG (def))\n\t RESET_BIT (bmap[DF_REF_BB (def)->index], indx);\n\t}\n\n return;\n\n case MEM:\n if (! MEM_READONLY_P (x))\n\t{\n\t bitmap_iterator bi;\n\t unsigned bb_index;\n\n\t /* First handle all the blocks with calls. We don't need to\n\t do any list walking for them. */\n\t EXECUTE_IF_SET_IN_BITMAP (blocks_with_calls, 0, bb_index, bi)\n\t {\n\t if (set_p)\n\t\tSET_BIT (bmap[bb_index], indx);\n\t else\n\t\tRESET_BIT (bmap[bb_index], indx);\n\t }\n\n\t /* Now iterate over the blocks which have memory modifications\n\t but which do not have any calls. */\n\t EXECUTE_IF_AND_COMPL_IN_BITMAP (modify_mem_list_set,\n\t\t\t\t\t blocks_with_calls,\n\t\t\t\t\t 0, bb_index, bi)\n\t {\n\t\trtx list_entry = canon_modify_mem_list[bb_index];\n\n\t\twhile (list_entry)\n\t\t {\n\t\t rtx dest, dest_addr;\n\n\t\t /* LIST_ENTRY must be an INSN of some kind that sets memory.\n\t\t Examine each hunk of memory that is modified. */\n\n\t\t dest = XEXP (list_entry, 0);\n\t\t list_entry = XEXP (list_entry, 1);\n\t\t dest_addr = XEXP (list_entry, 0);\n\n\t\t if (canon_true_dependence (dest, GET_MODE (dest), dest_addr,\n\t\t\t\t\t x, NULL_RTX, rtx_addr_varies_p))\n\t\t {\n\t\t\tif (set_p)\n\t\t\t SET_BIT (bmap[bb_index], indx);\n\t\t\telse\n\t\t\t RESET_BIT (bmap[bb_index], indx);\n\t\t\tbreak;\n\t\t }\n\t\t list_entry = XEXP (list_entry, 1);\n\t }\n\t }\n\t}\n\n x = XEXP (x, 0);\n goto repeat;\n\n case PC:\n case CC0: /*FIXME*/\n case CONST:\n case CONST_INT:\n case CONST_DOUBLE:\n case CONST_FIXED:\n case CONST_VECTOR:\n case SYMBOL_REF:\n case LABEL_REF:\n case ADDR_VEC:\n case ADDR_DIFF_VEC:\n return;\n\n default:\n break;\n }\n\n for (i = GET_RTX_LENGTH (code) - 1, fmt = GET_RTX_FORMAT (code); i >= 0; i--)\n {\n if (fmt[i] == 'e')\n\t{\n\t /* If we are about to do the last recursive call\n\t needed at this level, change it into iteration.\n\t This function is called enough to be worth it. */\n\t if (i == 0)\n\t {\n\t x = XEXP (x, i);\n\t goto repeat;\n\t }\n\n\t compute_transp (XEXP (x, i), indx, bmap, set_p);\n\t}\n else if (fmt[i] == 'E')\n\tfor (j = 0; j < XVECLEN (x, i); j++)\n\t compute_transp (XVECEXP (x, i, j), indx, bmap, set_p);\n }\n}", "label": 0, "cwe": null, "length": 849 }, { "index": 894826, "code": "rijndael_invkey_expansion(AESContext *cx, const unsigned char *key, unsigned int Nk)\n{\n unsigned int r;\n PRUint32 *roundkeyw;\n PRUint8 *b;\n int Nb = cx->Nb;\n /* begins like usual key expansion ... */\n if (rijndael_key_expansion(cx, key, Nk) != SECSuccess)\n\treturn SECFailure;\n /* ... but has the additional step of InvMixColumn,\n * excepting the first and last round keys.\n */\n roundkeyw = cx->expandedKey + cx->Nb;\n for (r=1; rNr; ++r) {\n\t/* each key word, roundkeyw, represents a column in the key\n\t * matrix. Each column is multiplied by the InvMixColumn matrix.\n\t * [ 0E 0B 0D 09 ] [ b0 ]\n\t * [ 09 0E 0B 0D ] * [ b1 ]\n\t * [ 0D 09 0E 0B ] [ b2 ]\n\t * [ 0B 0D 09 0E ] [ b3 ]\n\t */\n\tb = (PRUint8 *)roundkeyw;\n\t*roundkeyw++ = IMXC0(b[0]) ^ IMXC1(b[1]) ^ IMXC2(b[2]) ^ IMXC3(b[3]);\n\tb = (PRUint8 *)roundkeyw;\n\t*roundkeyw++ = IMXC0(b[0]) ^ IMXC1(b[1]) ^ IMXC2(b[2]) ^ IMXC3(b[3]);\n\tb = (PRUint8 *)roundkeyw;\n\t*roundkeyw++ = IMXC0(b[0]) ^ IMXC1(b[1]) ^ IMXC2(b[2]) ^ IMXC3(b[3]);\n\tb = (PRUint8 *)roundkeyw;\n\t*roundkeyw++ = IMXC0(b[0]) ^ IMXC1(b[1]) ^ IMXC2(b[2]) ^ IMXC3(b[3]);\n\tif (Nb <= 4)\n\t continue;\n\tswitch (Nb) {\n\tcase 8: b = (PRUint8 *)roundkeyw;\n\t *roundkeyw++ = IMXC0(b[0]) ^ IMXC1(b[1]) ^ \n\t IMXC2(b[2]) ^ IMXC3(b[3]);\n\tcase 7: b = (PRUint8 *)roundkeyw;\n\t *roundkeyw++ = IMXC0(b[0]) ^ IMXC1(b[1]) ^ \n\t IMXC2(b[2]) ^ IMXC3(b[3]);\n\tcase 6: b = (PRUint8 *)roundkeyw;\n\t *roundkeyw++ = IMXC0(b[0]) ^ IMXC1(b[1]) ^ \n\t IMXC2(b[2]) ^ IMXC3(b[3]);\n\tcase 5: b = (PRUint8 *)roundkeyw;\n\t *roundkeyw++ = IMXC0(b[0]) ^ IMXC1(b[1]) ^ \n\t IMXC2(b[2]) ^ IMXC3(b[3]);\n\t}\n }\n return SECSuccess;\n}", "label": 0, "cwe": null, "length": 712 }, { "index": 817477, "code": "ParsePrimaryExpression(bool* ok) {\n // PrimaryExpression ::\n // 'this'\n // 'null'\n // 'true'\n // 'false'\n // Identifier\n // Number\n // String\n // ArrayLiteral\n // ObjectLiteral\n // RegExpLiteral\n // '(' Expression ')'\n\n Expression result = Expression::Default();\n switch (peek()) {\n case i::Token::THIS: {\n Next();\n result = Expression::This();\n break;\n }\n\n case i::Token::FUTURE_RESERVED_WORD: {\n Next();\n i::Scanner::Location location = scanner_->location();\n ReportMessageAt(location.beg_pos, location.end_pos,\n \"reserved_word\", NULL);\n *ok = false;\n return Expression::Default();\n }\n\n case i::Token::FUTURE_STRICT_RESERVED_WORD:\n if (strict_mode()) {\n Next();\n i::Scanner::Location location = scanner_->location();\n ReportMessageAt(location, \"strict_reserved_word\", NULL);\n *ok = false;\n return Expression::Default();\n }\n // FALLTHROUGH\n case i::Token::IDENTIFIER: {\n Identifier id = ParseIdentifier(CHECK_OK);\n result = Expression::FromIdentifier(id);\n break;\n }\n\n case i::Token::NULL_LITERAL:\n case i::Token::TRUE_LITERAL:\n case i::Token::FALSE_LITERAL:\n case i::Token::NUMBER: {\n Next();\n break;\n }\n case i::Token::STRING: {\n Next();\n result = GetStringSymbol();\n break;\n }\n\n case i::Token::ASSIGN_DIV:\n result = ParseRegExpLiteral(true, CHECK_OK);\n break;\n\n case i::Token::DIV:\n result = ParseRegExpLiteral(false, CHECK_OK);\n break;\n\n case i::Token::LBRACK:\n result = ParseArrayLiteral(CHECK_OK);\n break;\n\n case i::Token::LBRACE:\n result = ParseObjectLiteral(CHECK_OK);\n break;\n\n case i::Token::LPAREN:\n Consume(i::Token::LPAREN);\n parenthesized_function_ = (peek() == i::Token::FUNCTION);\n result = ParseExpression(true, CHECK_OK);\n Expect(i::Token::RPAREN, CHECK_OK);\n result = result.Parenthesize();\n break;\n\n case i::Token::MOD:\n result = ParseV8Intrinsic(CHECK_OK);\n break;\n\n default: {\n Next();\n *ok = false;\n return Expression::Default();\n }\n }\n\n return result;\n}", "label": 0, "cwe": null, "length": 557 }, { "index": 336089, "code": "_pullBinNeighborSet(pullContext *pctx, pullBin *bin) {\n static const char me[]=\"_pullBinNeighborSet\";\n unsigned int neiIdx, neiNum, be[4], binIdx;\n unsigned int xi, yi, zi, si, xx, yy, zz, ss,\n xmax, ymax, zmax, smax;\n pullBin *nei[3*3*3*3];\n int xmin, ymin, zmin, smin;\n\n binIdx = AIR_UINT(bin - pctx->bin);\n /* annoyingly, have to recover the bin coordinates */\n ELL_4V_COPY(be, pctx->binsEdge);\n xi = binIdx % be[0];\n binIdx = (binIdx - xi)/be[0];\n yi = binIdx % be[1];\n binIdx = (binIdx - yi)/be[1];\n zi = binIdx % be[2];\n si = (binIdx - zi)/be[2];\n neiNum = 0;\n bin->neighBin = (pullBin **)airFree(bin->neighBin);\n smin = AIR_MAX(0, (int)si-1);\n smax = AIR_MIN(si+1, be[3]-1);\n zmin = AIR_MAX(0, (int)zi-1);\n zmax = AIR_MIN(zi+1, be[2]-1);\n ymin = AIR_MAX(0, (int)yi-1);\n ymax = AIR_MIN(yi+1, be[1]-1);\n xmin = AIR_MAX(0, (int)xi-1);\n xmax = AIR_MIN(xi+1, be[0]-1);\n for (ss=smin; ss<=smax; ss++) {\n for (zz=zmin; zz<=zmax; zz++) {\n for (yy=ymin; yy<=ymax; yy++) {\n for (xx=xmin; xx<=xmax; xx++) {\n nei[neiNum++] = pctx->bin + xx + be[0]*(yy + be[1]*(zz + be[2]*ss));\n }\n }\n }\n }\n if (!( bin->neighBin = AIR_CALLOC(1+neiNum, pullBin*) )) {\n biffAddf(PULL, \"%s: couldn't calloc array of %u neighbor pointers\", me, 1+neiNum);\n return 1;\n }\n for (neiIdx=0; neiIdxneighBin[neiIdx] = nei[neiIdx];\n }\n /* NULL-terminate the bin array */\n bin->neighBin[neiIdx] = NULL;\n return 0;\n}", "label": 0, "cwe": null, "length": 595 }, { "index": 47507, "code": "msoffice_xml_metadata_parse_start (GMarkupParseContext *context,\n const gchar *element_name,\n const gchar **attribute_names,\n const gchar **attribute_values,\n gpointer user_data,\n GError **error)\n{\n\tMsOfficeXMLParserInfo *info = user_data;\n\n\t/* Setup the proper tag type */\n\tif (g_ascii_strcasecmp (element_name, \"dc:title\") == 0) {\n\t\tinfo->tag_type = MS_OFFICE_XML_TAG_TITLE;\n\t} else if (g_ascii_strcasecmp (element_name, \"dc:subject\") == 0) {\n\t\tinfo->tag_type = MS_OFFICE_XML_TAG_SUBJECT;\n\t} else if (g_ascii_strcasecmp (element_name, \"dc:creator\") == 0) {\n\t\tinfo->tag_type = MS_OFFICE_XML_TAG_AUTHOR;\n\t} else if (g_ascii_strcasecmp (element_name, \"dc:description\") == 0) {\n\t\tinfo->tag_type = MS_OFFICE_XML_TAG_COMMENTS;\n\t} else if (g_ascii_strcasecmp (element_name, \"dcterms:created\") == 0) {\n\t\tinfo->tag_type = MS_OFFICE_XML_TAG_CREATED;\n\t} else if (g_ascii_strcasecmp (element_name, \"meta:generator\") == 0) {\n\t\tinfo->tag_type = MS_OFFICE_XML_TAG_GENERATOR;\n\t} else if (g_ascii_strcasecmp (element_name, \"dcterms:modified\") == 0) {\n\t\tinfo->tag_type = MS_OFFICE_XML_TAG_MODIFIED;\n\t} else if (g_ascii_strcasecmp (element_name, \"Pages\") == 0) {\n\t\tinfo->tag_type = MS_OFFICE_XML_TAG_NUM_OF_PAGES;\n\t} else if (g_ascii_strcasecmp (element_name, \"Slides\") == 0) {\n\t\tinfo->tag_type = MS_OFFICE_XML_TAG_NUM_OF_PAGES;\n\t} else if (g_ascii_strcasecmp (element_name, \"Paragraphs\") == 0) {\n\t\tinfo->tag_type = MS_OFFICE_XML_TAG_NUM_OF_PARAGRAPHS;\n\t} else if (g_ascii_strcasecmp (element_name, \"Characters\") == 0) {\n\t\tinfo->tag_type = MS_OFFICE_XML_TAG_NUM_OF_CHARACTERS;\n\t} else if (g_ascii_strcasecmp (element_name, \"Words\") == 0) {\n\t\tinfo->tag_type = MS_OFFICE_XML_TAG_NUM_OF_WORDS;\n\t} else if (g_ascii_strcasecmp (element_name, \"Lines\") == 0) {\n\t\tinfo->tag_type = MS_OFFICE_XML_TAG_NUM_OF_LINES;\n\t} else if (g_ascii_strcasecmp (element_name, \"Application\") == 0) {\n\t\tinfo->tag_type = MS_OFFICE_XML_TAG_APPLICATION;\n\t} else {\n\t\tinfo->tag_type = MS_OFFICE_XML_TAG_INVALID;\n\t}\n}", "label": 0, "cwe": null, "length": 605 }, { "index": 45315, "code": "mdt_get_metadata(MDTFile *mdtfile, guint i)\n{\n GwyContainer *meta;\n MDTFrame *frame;\n MDTScannedDataFrame *sdframe;\n const gchar *v;\n GString *s;\n\n meta = gwy_container_new();\n\n g_return_val_if_fail(i <= mdtfile->last_frame, meta);\n frame = mdtfile->frames + i;\n if ((frame->type == MDT_FRAME_SCANNED)\n || (frame->type == MDT_FRAME_SPECTROSCOPY)\n || (frame->type == MDT_FRAME_CURVES)) {\n sdframe = (MDTScannedDataFrame*)frame->frame_data;\n\n s = g_string_new(NULL);\n g_string_printf(s, \"%d-%02d-%02d %02d:%02d:%02d\",\n frame->year, frame->month, frame->day,\n frame->hour, frame->min, frame->sec);\n gwy_container_set_string_by_name(meta, \"Date\", g_strdup(s->str));\n\n g_string_printf(s, \"%d.%d\",\n frame->version/0x100, frame->version % 0x100);\n gwy_container_set_string_by_name(meta, \"Version\", g_strdup(s->str));\n\n g_string_printf(s, \"%s, %s %s %s\",\n (sdframe->scan_dir & 0x01) ? \"Horizontal\" : \"Vertical\",\n (sdframe->scan_dir & 0x02) ? \"Left\" : \"Right\",\n (sdframe->scan_dir & 0x04) ? \"Bottom\" : \"Top\",\n (sdframe->scan_dir & 0x80) ? \" (double pass)\" : \"\");\n gwy_container_set_string_by_name(meta, \"Scan direction\", g_strdup(s->str));\n\n HASH_SET_META(\"%d\", sdframe->adc_index + 1, \"ADC index\");\n HASH_SET_META(\"%d\", sdframe->mode, \"Mode\");\n HASH_SET_META(\"%d\", sdframe->ndacq, \"Step (DAC)\");\n HASH_SET_META(\"%.2f nm\", sdframe->step_length/Nano, \"Step length\");\n HASH_SET_META(\"%.0f nm/s\", sdframe->velocity/Nano, \"Scan velocity\");\n HASH_SET_META(\"%.2f nA\", sdframe->setpoint/Nano, \"Setpoint value\");\n HASH_SET_META(\"%.2f V\", sdframe->bias_voltage, \"Bias voltage\");\n\n g_string_free(s, TRUE);\n\n if ((v = gwy_enuml_to_string(sdframe->channel_index,\n \"Off\", MDT_ADC_MODE_OFF,\n \"Height\", MDT_ADC_MODE_HEIGHT,\n \"DFL\", MDT_ADC_MODE_DFL,\n \"Lateral F\", MDT_ADC_MODE_LATERAL_F,\n \"Bias V\", MDT_ADC_MODE_BIAS_V,\n \"Current\", MDT_ADC_MODE_CURRENT,\n \"FB-Out\", MDT_ADC_MODE_FB_OUT,\n \"MAG\", MDT_ADC_MODE_MAG,\n \"MAG*Sin\", MDT_ADC_MODE_MAG_SIN,\n \"MAG*Cos\", MDT_ADC_MODE_MAG_COS,\n \"RMS\", MDT_ADC_MODE_RMS,\n \"CalcMag\", MDT_ADC_MODE_CALCMAG,\n \"Phase1\", MDT_ADC_MODE_PHASE1,\n \"Phase2\", MDT_ADC_MODE_PHASE2,\n \"CalcPhase\", MDT_ADC_MODE_CALCPHASE,\n \"Ex1\", MDT_ADC_MODE_EX1,\n \"Ex2\", MDT_ADC_MODE_EX2,\n \"HvX\", MDT_ADC_MODE_HVX,\n \"HvY\", MDT_ADC_MODE_HVY,\n \"Snap Back\", MDT_ADC_MODE_SNAP_BACK,\n NULL)))\n gwy_container_set_string_by_name(meta, \"ADC Mode\", g_strdup(v));\n }\n\n return meta;\n}", "label": 0, "cwe": null, "length": 836 }, { "index": 550115, "code": "print_bad_pte(struct vm_area_struct *vma, unsigned long addr,\n\t\t\t pte_t pte, struct page *page)\n{\n\tpgd_t *pgd = pgd_offset(vma->vm_mm, addr);\n\tpud_t *pud = pud_offset(pgd, addr);\n\tpmd_t *pmd = pmd_offset(pud, addr);\n\tstruct address_space *mapping;\n\tpgoff_t index;\n\tstatic unsigned long resume;\n\tstatic unsigned long nr_shown;\n\tstatic unsigned long nr_unshown;\n\n\t/*\n\t * Allow a burst of 60 reports, then keep quiet for that minute;\n\t * or allow a steady drip of one report per second.\n\t */\n\tif (nr_shown == 60) {\n\t\tif (time_before(jiffies, resume)) {\n\t\t\tnr_unshown++;\n\t\t\treturn;\n\t\t}\n\t\tif (nr_unshown) {\n\t\t\tprintk(KERN_ALERT\n\t\t\t\t\"BUG: Bad page map: %lu messages suppressed\\n\",\n\t\t\t\tnr_unshown);\n\t\t\tnr_unshown = 0;\n\t\t}\n\t\tnr_shown = 0;\n\t}\n\tif (nr_shown++ == 0)\n\t\tresume = jiffies + 60 * HZ;\n\n\tmapping = vma->vm_file ? vma->vm_file->f_mapping : NULL;\n\tindex = linear_page_index(vma, addr);\n\n\tprintk(KERN_ALERT\n\t\t\"BUG: Bad page map in process %s pte:%08llx pmd:%08llx\\n\",\n\t\tcurrent->comm,\n\t\t(long long)pte_val(pte), (long long)pmd_val(*pmd));\n\tif (page)\n\t\tdump_page(page, \"bad pte\");\n\tprintk(KERN_ALERT\n\t\t\"addr:%p vm_flags:%08lx anon_vma:%p mapping:%p index:%lx\\n\",\n\t\t(void *)addr, vma->vm_flags, vma->anon_vma, mapping, index);\n\t/*\n\t * Choose text because data symbols depend on CONFIG_KALLSYMS_ALL=y\n\t */\n\tpr_alert(\"file:%pD fault:%pf mmap:%pf readpage:%pf\\n\",\n\t\t vma->vm_file,\n\t\t vma->vm_ops ? vma->vm_ops->fault : NULL,\n\t\t vma->vm_file ? vma->vm_file->f_op->mmap : NULL,\n\t\t mapping ? mapping->a_ops->readpage : NULL);\n\tdump_stack();\n\tadd_taint(TAINT_BAD_PAGE, LOCKDEP_NOW_UNRELIABLE);\n}", "label": 0, "cwe": null, "length": 526 }, { "index": 623817, "code": "MakeLegacyDigest ( std::string * digestStr )\n{\n\tstd::string strClipPath;\n\tstd::string strPlaylistPath;\n\tstd::vector legacyBuff;\n\n\tbool ok = this->MakeClipInfoPath ( &strClipPath, \".clpi\", true /* checkFile */ );\n\tif ( ! ok ) return;\n\n\tok = this->MakePlaylistPath ( &strPlaylistPath, \".mpls\", true /* checkFile */ );\n\tif ( ! ok ) return;\n\t\n\ttry {\n\t\t{\n\t\t\tAutoFile cpiFile;\n\t\t\tcpiFile.fileRef = LFA_Open ( strClipPath.c_str(), 'r' );\n\t\t\tif ( cpiFile.fileRef == 0 ) return;\t// The open failed.\n\t\t\t\n\t\t\t// Read at most the first 2k of data from the cpi file to use in the digest\n\t\t\t// (every CPI file I've seen is less than 1k).\n\t\t\tconst XMP_Int64 cpiLen = LFA_Measure ( cpiFile.fileRef );\n\t\t\tconst XMP_Int64 buffLen = (cpiLen <= 2048) ? cpiLen : 2048;\n\n\t\t\tlegacyBuff.resize ( (unsigned int) buffLen );\n\t\t\tLFA_Read ( cpiFile.fileRef, &(legacyBuff[0]), static_cast ( buffLen ) );\n\t\t}\n\t\t\n\t\t{\n\t\t\tAutoFile mplFile;\n\t\t\tmplFile.fileRef = LFA_Open ( strPlaylistPath.c_str(), 'r' );\n\t\t\tif ( mplFile.fileRef == 0 ) return;\t// The open failed.\n\t\t\t\n\t\t\t// Read at most the first 2k of data from the cpi file to use in the digest\n\t\t\t// (every playlist file I've seen is less than 1k).\n\t\t\tconst XMP_Int64 mplLen = LFA_Measure ( mplFile.fileRef );\n\t\t\tconst XMP_Int64 buffLen = (mplLen <= 2048) ? mplLen : 2048;\n\t\t\tconst XMP_Int64 clipBuffLen = legacyBuff.size();\n\n\t\t\tlegacyBuff.resize ( (unsigned int) (clipBuffLen + buffLen) );\n\t\t\tLFA_Read ( mplFile.fileRef, &( legacyBuff [(unsigned int)clipBuffLen] ), (XMP_Int32)buffLen );\n\t\t}\n\t} catch (...) {\n\t\treturn;\n\t}\n\t\n\tMD5_CTX context;\n\tunsigned char digestBin [16];\n\n\tMD5Init ( &context );\n\tMD5Update ( &context, (XMP_Uns8*)&(legacyBuff[0]), (unsigned int) legacyBuff.size() );\n\tMD5Final ( digestBin, &context );\n\n\t*digestStr = BytesToHex ( digestBin, 16 );\n}", "label": 0, "cwe": null, "length": 584 }, { "index": 273978, "code": "jabber_avatar_load(session_t *s, const char *path, const int quiet) {\n\tconst char *fn = prepare_path_user(path);\n\tFILE *fd;\n\tstruct stat st;\n\tchar buf[16385]; /* XEP-0153 says we should limit avatar size to 8k,\n\t\t\t but I like to be honest and give 16k */\n\tint len;\n\n\t\t/* code from dcc */\n\tif (!fn) {\n\t\tprintq(\"generic_error\", \"path too long\"); /* XXX? */\n\t\treturn NULL;\n\t}\n\n\tif (!stat(fn, &st) && !S_ISREG(st.st_mode)) {\n\t\tprintq(\"io_nonfile\", path);\n\t\treturn NULL;\n\t}\n\n\tif ((fd = fopen(fn, \"r\")) == NULL) {\n\t\tprintq(\"io_cantopen\", path, strerror(errno));\n\t\treturn NULL;\n\t}\n\n\tif (!(len = fread(buf, 1, sizeof(buf), fd))) {\n\t\tif (ferror(fd))\n\t\t\tprintq(\"io_cantread\", path, strerror(errno)); /* can we use errno here? */\n\t\telse\n\t\t\tprintq(\"io_emptyfile\", path);\n\t} else if (len >= sizeof(buf))\n\t\tprintq(\"io_toobig\", path, itoa(len), sizeof(buf)-1);\n\telse {\n\t\tchar *enc\t\t= base64_encode(buf, len);\t\t\t/* XXX base64_encode() CHANGED!! len+1 ? */\n\t\tchar *out;\n\t\tconst char *type\t= \"application/octet-stream\";\n\n\t\tstring_t str\t\t= string_init(NULL);\n\t\tint enclen\t\t= xstrlen(enc);\n\t\tchar *p\t\t\t= enc;\n\n\t\t\t/* those are from 'magic.mime', from 'file' utility */ \n\t\tif (len > 4 && !xstrncmp(buf, \"\\x89PNG\", 4))\n\t\t\ttype = \"image/png\";\n\t\telse if (len > 3 && !xstrncmp(buf, \"GIF\", 3))\n\t\t\ttype = \"image/gif\";\n\t\telse if (len > 2 && !xstrncmp(buf, \"\\xFF\\xD8\", 2))\n\t\t\ttype = \"image/jpeg\";\n\n\t\tfclose(fd);\n\t\tsession_set(s, \"photo_hash\", jabber_sha1_generic(buf, len));\n\n\t\twhile (enclen > 72) {\n\t\t\tstring_append_n(str, p, 72);\n\t\t\tstring_append_c(str, '\\n');\n\t\t\t\n\t\t\tp += 72;\n\t\t\tenclen -= 72;\n\t\t}\n\t\tstring_append(str, p);\n\t\txfree(enc);\n\n\t\tout = saprintf(\"%s\\n%s\\n\", type, str->str);\n\t\tstring_free(str, 1);\n\n\t\treturn out;\n\t}\n\n\tfclose(fd);\n\treturn NULL;\n}", "label": 0, "cwe": null, "length": 591 }, { "index": 917077, "code": "jpeg_read_exif_profile(FIBITMAP *dib, const BYTE *dataptr, unsigned int datalen) {\n // marker identifying string for Exif = \"Exif\\0\\0\"\n BYTE exif_signature[6] = { 0x45, 0x78, 0x69, 0x66, 0x00, 0x00 };\n\tBYTE lsb_first[4] = { 0x49, 0x49, 0x2A, 0x00 };\t\t// Intel order\n\tBYTE msb_first[4] = { 0x4D, 0x4D, 0x00, 0x2A };\t\t// Motorola order\n\n\tunsigned int length = datalen;\n\tBYTE *profile = (BYTE*)dataptr;\n\n\t// verify the identifying string\n\n\tif(memcmp(exif_signature, profile, sizeof(exif_signature)) == 0) {\n\t\t// Exif profile - TIFF header with 2 IFDs. 0th - the image attributes, 1st - may be used for thumbnail\n\n\t\tprofile += sizeof(exif_signature);\n\t\tlength -= sizeof(exif_signature);\n\n\t\t// read the TIFF header (8 bytes)\n\n\t\t// check the endianess order\n\t\t\n\t\tBOOL bMotorolaOrder = TRUE;\n\n\t\tif(memcmp(profile, lsb_first, sizeof(lsb_first)) == 0) {\n\t\t\t// Exif section in Intel order\n\t\t\tbMotorolaOrder = FALSE;\n\t\t} else {\n\t\t\tif(memcmp(profile, msb_first, sizeof(msb_first)) == 0) {\n\t\t\t\t// Exif section in Motorola order\n\t\t\t\tbMotorolaOrder = TRUE;\n\t\t\t} else {\n\t\t\t\t// Invalid Exif alignment marker\n\t\t\t\treturn FALSE;\n\t\t\t}\n\t\t}\n\n\t\t// this is the offset to the first IFD (Image File Directory)\n\t\tunsigned long first_offset = ReadUint32(bMotorolaOrder, profile + 4);\n\t\tif (first_offset > length) {\n\t\t\t// bad Exif data\n\t\t\treturn FALSE;\n\t\t}\n\n\t\t/*\n\t\tNote: as FreeImage 3.14.0, this test is no longer needed for images with similar suspicious offset\n\t\t=> tested with Pentax Optio 230, FujiFilm SP-2500 and Canon EOS 300D\n\t\tif (first_offset < 8 || first_offset > 16) {\n\t\t\t// This is usually set to 8\n\t\t\t// but PENTAX Optio 230 has it set differently, and uses it as offset. \n\t\t\tFreeImage_OutputMessageProc(FIF_JPEG, \"Exif: Suspicious offset of first IFD value\");\n\t\t\treturn FALSE;\n\t\t}\n\t\t*/\n\n\t\t// process Exif directories\n\t\treturn jpeg_read_exif_dir(dib, profile, first_offset, length, bMotorolaOrder);\n\t}\n\n\treturn FALSE;\n}", "label": 0, "cwe": null, "length": 621 } ]