[ { "index": 657012, "code": "sortCachedPoints(const btManifoldPoint& pt) \n{\n\n\t\t//calculate 4 possible cases areas, and take biggest area\n\t\t//also need to keep 'deepest'\n\t\t\n\t\tint maxPenetrationIndex = -1;\n#define KEEP_DEEPEST_POINT 1\n#ifdef KEEP_DEEPEST_POINT\n\t\tbtScalar maxPenetration = pt.getDistance();\n\t\tfor (int i=0;i<4;i++)\n\t\t{\n\t\t\tif (m_pointCache[i].getDistance() < maxPenetration)\n\t\t\t{\n\t\t\t\tmaxPenetrationIndex = i;\n\t\t\t\tmaxPenetration = m_pointCache[i].getDistance();\n\t\t\t}\n\t\t}\n#endif //KEEP_DEEPEST_POINT\n\t\t\n\t\tbtScalar res0(btScalar(0.)),res1(btScalar(0.)),res2(btScalar(0.)),res3(btScalar(0.));\n\t\tif (maxPenetrationIndex != 0)\n\t\t{\n\t\t\tbtVector3 a0 = pt.m_localPointA-m_pointCache[1].m_localPointA;\n\t\t\tbtVector3 b0 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA;\n\t\t\tbtVector3 cross = a0.cross(b0);\n\t\t\tres0 = cross.length2();\n\t\t}\n\t\tif (maxPenetrationIndex != 1)\n\t\t{\n\t\t\tbtVector3 a1 = pt.m_localPointA-m_pointCache[0].m_localPointA;\n\t\t\tbtVector3 b1 = m_pointCache[3].m_localPointA-m_pointCache[2].m_localPointA;\n\t\t\tbtVector3 cross = a1.cross(b1);\n\t\t\tres1 = cross.length2();\n\t\t}\n\n\t\tif (maxPenetrationIndex != 2)\n\t\t{\n\t\t\tbtVector3 a2 = pt.m_localPointA-m_pointCache[0].m_localPointA;\n\t\t\tbtVector3 b2 = m_pointCache[3].m_localPointA-m_pointCache[1].m_localPointA;\n\t\t\tbtVector3 cross = a2.cross(b2);\n\t\t\tres2 = cross.length2();\n\t\t}\n\n\t\tif (maxPenetrationIndex != 3)\n\t\t{\n\t\t\tbtVector3 a3 = pt.m_localPointA-m_pointCache[0].m_localPointA;\n\t\t\tbtVector3 b3 = m_pointCache[2].m_localPointA-m_pointCache[1].m_localPointA;\n\t\t\tbtVector3 cross = a3.cross(b3);\n\t\t\tres3 = cross.length2();\n\t\t}\n\n\t\tbtVector4 maxvec(res0,res1,res2,res3);\n\t\tint biggestarea = maxvec.closestAxis4();\n\t\treturn biggestarea;\n}", "label": 0, "cwe": null, "length": 569 }, { "index": 783496, "code": "CL_ParseConfigString (void)\r\n{\r\n\tint\t\ti;\r\n\tchar\t*s;\r\n\tchar\tolds[MAX_QPATH];\r\n\tsize_t\tlength;\r\n\r\n\ti = MSG_ReadShort (&net_message);\r\n\tif (i < 0 || i >= MAX_CONFIGSTRINGS)\r\n\t\tCom_Error (ERR_DROP, \"configstring > MAX_CONFIGSTRINGS\");\r\n\ts = MSG_ReadString(&net_message);\r\n\r\n\tstrncpy (olds, cl.configstrings[i], sizeof(olds));\r\n\tolds[sizeof(olds) - 1] = 0;\r\n\r\n\t//r1: overflow may be desired by some mods in stats programs for example. who knows.\r\n\tlength = strlen(s);\r\n\r\n\tif (length >= (sizeof(cl.configstrings[0]) * (MAX_CONFIGSTRINGS-i)) - 1)\r\n\t\tCom_Error (ERR_DROP, \"CL_ParseConfigString: configstring %d exceeds available space\", i);\r\n\r\n\t//r1: don't allow basic things to overflow\r\n\tif (i != CS_NAME && i < CS_GENERAL)\r\n\t{\r\n\t\tif (i >= CS_STATUSBAR && i < CS_AIRACCEL)\r\n\t\t{\r\n\t\t\tstrncpy (cl.configstrings[i], s, (sizeof(cl.configstrings[i]) * (CS_AIRACCEL - i))-1);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t// Alien Arena client/server protocol depends on MAX_QPATH being 64\r\n\t\t\tif (length >= MAX_QPATH)\r\n\t\t\t\tCom_Printf (\"WARNING: Configstring %d of length %d exceeds MAX_QPATH.\\n\", i, length);\r\n\t\t\tQ_strncpyz (cl.configstrings[i], s, sizeof(cl.configstrings[i])-1);\r\n\t\t}\r\n\t}\r\n\telse\r\n\t{\r\n\t\tstrcpy (cl.configstrings[i], s);\r\n\t}\r\n\r\n\t// do something apropriate\r\n\r\n\tif (i >= CS_LIGHTS && i < CS_LIGHTS+MAX_LIGHTSTYLES)\r\n\t\tCL_SetLightstyle (i - CS_LIGHTS);\r\n\telse if (i >= CS_MODELS && i < CS_MODELS+MAX_MODELS)\r\n\t{\r\n\t\tif (cl.refresh_prepped)\r\n\t\t{\r\n\t\t\tcl.model_draw[i-CS_MODELS] = R_RegisterModel (cl.configstrings[i]);\r\n\t\t\tif (cl.configstrings[i][0] == '*')\r\n\t\t\t\tcl.model_clip[i-CS_MODELS] = CM_InlineModel (cl.configstrings[i]);\r\n\t\t\telse\r\n\t\t\t\tcl.model_clip[i-CS_MODELS] = NULL;\r\n\t\t}\r\n\t}\r\n\telse if (i >= CS_SOUNDS && i < CS_SOUNDS+MAX_MODELS)\r\n\t{\r\n\t\tif (cl.refresh_prepped)\r\n\t\t\tcl.sound_precache[i-CS_SOUNDS] = S_RegisterSound (cl.configstrings[i]);\r\n\t}\r\n\telse if (i >= CS_IMAGES && i < CS_IMAGES+MAX_MODELS)\r\n\t{\r\n\t\tif (cl.refresh_prepped)\r\n\t\t\tcl.image_precache[i-CS_IMAGES] = R_RegisterPic (cl.configstrings[i]);\r\n\t}\r\n\telse if (i >= CS_PLAYERSKINS && i < CS_PLAYERSKINS+MAX_CLIENTS)\r\n\t{\r\n\t\tif (cl.refresh_prepped && strcmp(olds, s))\r\n\t\t\tCL_ParseClientinfo (i-CS_PLAYERSKINS);\r\n\t}\r\n\telse if ( i == CS_GENERAL)\r\n\t\tCL_ParseTaunt(s);\r\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 672 }, { "index": 98462, "code": "tftp_file_read(FILE *fp, char *data_buffer, int data_buffer_size, int block_number,\n int convert, int *prev_block_number, int *prev_file_pos, int *temp)\n{\n int i;\n int c;\n char prevchar = *temp & 0xff;\n char newline = (*temp & 0xff00) >> 8;\n int data_size;\n\n if (!convert)\n {\n\t /* In this case, just read the requested data block.\n\t Anyway, in the multicast case it can be in random\n\t order. */\n\t fseek(fp, block_number * data_buffer_size, SEEK_SET);\n\t data_size = fread(data_buffer, 1, data_buffer_size, fp);\n return data_size;\n }\n else\n {\n\t /* \n\t * When converting data, it become impossible to seek in\n\t * the file based on the block number. So we must always\n\t * remeber the position in the file from were to read the\n\t * data requested by the client. Client can only request data\n\t * for the same block or the next, but we cannot assume this\n\t * block number will increase at every ACK since it can be\n\t * lost in transmission.\n\t *\n\t * The stategy is to remeber the file position as well as\n\t * the block number from the current call to this function.\n\t * If the client request a block number different from that\n * we return ERR.\n\t * \n\t * If the client request many time the same block, the\n\t * netascii conversion is done each time. Since this is not\n\t * a normal condition it should not be a problem for system\n\t * performance.\n\t *\n\t */\n\t if ((block_number != *prev_block_number) && (block_number != *prev_block_number + 1))\n\t return ERR;\n\t if (block_number == *prev_block_number)\n\t fseek(fp, *prev_file_pos, SEEK_SET);\n\n\t *prev_block_number = block_number;\n\t *prev_file_pos = ftell(fp);\n\n\t /*\n\t * convert to netascii, based on netkit-tftp-0.17 routine in tftpsubs.c\n\t * i index output buffer\n\t */\n\t for (i = 0; i < data_buffer_size; i++)\n\t {\n\t if (newline)\n\t {\n\t\t if (prevchar == '\\n')\n\t\t\t c = '\\n'; /* lf to cr,lf */\n\t\t else\n\t\t\t c = '\\0'; /* cr to cr,nul */\n\t\t newline = 0;\n\t }\n\t else\n\t {\n\t\t c = fgetc(fp);\n\t\t if (c == EOF)\n\t\t\t break;\n\t\t if (c == '\\n' || c == '\\r')\n\t\t {\n\t\t\t prevchar = c;\n\t\t\t c = '\\r';\n\t\t\t newline = 1;\n\t\t }\n\t }\n data_buffer[i] = c;\n\t }\n\t /* save state */\n\t *temp = (newline << 8) | prevchar;\n\n return i;\n }\n}", "label": 0, "cwe": null, "length": 642 }, { "index": 438000, "code": "get_column_info_for_window(PlannerInfo *root, WindowClause *wc, List *tlist,\n\t\t\t\t\t\t int numSortCols, AttrNumber *sortColIdx,\n\t\t\t\t\t\t int *partNumCols,\n\t\t\t\t\t\t AttrNumber **partColIdx,\n\t\t\t\t\t\t Oid **partOperators,\n\t\t\t\t\t\t int *ordNumCols,\n\t\t\t\t\t\t AttrNumber **ordColIdx,\n\t\t\t\t\t\t Oid **ordOperators)\n{\n\tint\t\t\tnumPart = list_length(wc->partitionClause);\n\tint\t\t\tnumOrder = list_length(wc->orderClause);\n\n\tif (numSortCols == numPart + numOrder)\n\t{\n\t\t/* easy case */\n\t\t*partNumCols = numPart;\n\t\t*partColIdx = sortColIdx;\n\t\t*partOperators = extract_grouping_ops(wc->partitionClause);\n\t\t*ordNumCols = numOrder;\n\t\t*ordColIdx = sortColIdx + numPart;\n\t\t*ordOperators = extract_grouping_ops(wc->orderClause);\n\t}\n\telse\n\t{\n\t\tList\t *sortclauses;\n\t\tList\t *pathkeys;\n\t\tint\t\t\tscidx;\n\t\tListCell *lc;\n\n\t\t/* first, allocate what's certainly enough space for the arrays */\n\t\t*partNumCols = 0;\n\t\t*partColIdx = (AttrNumber *) palloc(numPart * sizeof(AttrNumber));\n\t\t*partOperators = (Oid *) palloc(numPart * sizeof(Oid));\n\t\t*ordNumCols = 0;\n\t\t*ordColIdx = (AttrNumber *) palloc(numOrder * sizeof(AttrNumber));\n\t\t*ordOperators = (Oid *) palloc(numOrder * sizeof(Oid));\n\t\tsortclauses = NIL;\n\t\tpathkeys = NIL;\n\t\tscidx = 0;\n\t\tforeach(lc, wc->partitionClause)\n\t\t{\n\t\t\tSortGroupClause *sgc = (SortGroupClause *) lfirst(lc);\n\t\t\tList\t *new_pathkeys;\n\n\t\t\tsortclauses = lappend(sortclauses, sgc);\n\t\t\tnew_pathkeys = make_pathkeys_for_sortclauses(root,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t sortclauses,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t tlist,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t true);\n\t\t\tif (list_length(new_pathkeys) > list_length(pathkeys))\n\t\t\t{\n\t\t\t\t/* this sort clause is actually significant */\n\t\t\t\t(*partColIdx)[*partNumCols] = sortColIdx[scidx++];\n\t\t\t\t(*partOperators)[*partNumCols] = sgc->eqop;\n\t\t\t\t(*partNumCols)++;\n\t\t\t\tpathkeys = new_pathkeys;\n\t\t\t}\n\t\t}\n\t\tforeach(lc, wc->orderClause)\n\t\t{\n\t\t\tSortGroupClause *sgc = (SortGroupClause *) lfirst(lc);\n\t\t\tList\t *new_pathkeys;\n\n\t\t\tsortclauses = lappend(sortclauses, sgc);\n\t\t\tnew_pathkeys = make_pathkeys_for_sortclauses(root,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t sortclauses,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t tlist,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t true);\n\t\t\tif (list_length(new_pathkeys) > list_length(pathkeys))\n\t\t\t{\n\t\t\t\t/* this sort clause is actually significant */\n\t\t\t\t(*ordColIdx)[*ordNumCols] = sortColIdx[scidx++];\n\t\t\t\t(*ordOperators)[*ordNumCols] = sgc->eqop;\n\t\t\t\t(*ordNumCols)++;\n\t\t\t\tpathkeys = new_pathkeys;\n\t\t\t}\n\t\t}\n\t\t/* complain if we didn't eat exactly the right number of sort cols */\n\t\tif (scidx != numSortCols)\n\t\t\telog(ERROR, \"failed to deconstruct sort operators into partitioning/ordering operators\");\n\t}\n}", "label": 0, "cwe": null, "length": 756 }, { "index": 819755, "code": "getRedo(PX_ChangeRecord ** ppcr) const\n{\n\tif ((m_iAdjustOffset == 0) && (m_undoPosition >= m_vecChangeRecords.getItemCount()))\n\t\treturn false;\n\t\n\tif (m_bOverlap)\n\t\treturn false;\n\t\n\tUT_sint32 iRedoPos = m_undoPosition-m_iAdjustOffset;\n\tif(iRedoPos <0)\n\t\treturn false;\n\tPX_ChangeRecord * pcr = m_vecChangeRecords.getNthItem(iRedoPos);\n\tUT_return_val_if_fail(pcr, false);\n\n\t// leave records from external documents in place so we can correct\n\tbool bIncrementAdjust = false;\n\n\tif (pcr->isFromThisDoc())\n\t{\n\t\t*ppcr = pcr;\n\t\tif (m_iAdjustOffset == 0)\n\t\t{\n\t\t return true;\n\t\t}\n\t\telse\n\t\t{\n\t\t bIncrementAdjust = true;\n\t\t m_iAdjustOffset--;\n\t\t}\n\t}\n\t\n\twhile (pcr && !pcr->isFromThisDoc() && (m_iAdjustOffset > 0))\n\t{\n\t pcr = m_vecChangeRecords.getNthItem(iRedoPos);\n\t m_iAdjustOffset--;\n\t\tiRedoPos++;\n\t bIncrementAdjust = true;\n\t xxx_UT_DEBUGMSG((\"AdjustOffset decremented -1 %d \", m_iAdjustOffset));\n\t}\n\t\n\tif (pcr && bIncrementAdjust)\n\t{\n\t PX_ChangeRecord * pcrOrig = pcr;\n\t pcr->setAdjustment(0);\n\t PT_DocPosition low,high;\n\t getCRRange(pcr,low,high);\n\t PT_DocPosition pos = pcr->getPosition();\n\t UT_sint32 iAdj = 0;\n\t for (UT_sint32 i = m_iAdjustOffset; i >= 1;i--)\n\t {\n\t\t\tpcr = m_vecChangeRecords.getNthItem(m_undoPosition-i);\n\t\t\tif (!pcr->isFromThisDoc())\n\t\t\t{\n\t\t\t\tUT_sint32 iCur = getDoc()->getAdjustmentForCR(pcr);\n\t\t\t if (pcr->getPosition() <= static_cast(static_cast(pos) + iAdj + iCur))\n\t\t\t {\n\t\t\t\t\tiAdj += iCur; \n\t\t\t\t\tlow += iCur;\n\t\t\t\t\thigh += iCur;\n\t\t\t }\n\t\t\t\tPT_DocPosition p1,p2;\n\t\t\t\tgetCRRange(pcr,p1,p2);\n\t\t\t\tbool bZero = (p1 == p2);\n\t\t\t\tif(bZero)\n\t\t\t\t\tm_bOverlap = doesOverlap(pcr,low+1,high);\n\t\t\t\telse\n\t\t\t\t\tm_bOverlap = doesOverlap(pcr,low,high);\n\t\t\t if (m_bOverlap)\n\t\t\t {\n\t\t\t\t\t*ppcr = NULL;\n\t\t\t\t\treturn false;\n\t\t\t }\n\t\t\t}\n\t }\n\t pcr = pcrOrig;\n\t pcr->setAdjustment(iAdj);\n\t xxx_UT_DEBUGMSG((\"Redo Adjustment set to %d \\n\",iAdj));\n\t}\n\t\n\tif (pcr && pcr->isFromThisDoc())\n\t{ \n\t *ppcr = pcr;\n\t if(bIncrementAdjust)\n\t {\n\t m_iAdjustOffset += 1; // for didRedo\n\t xxx_UT_DEBUGMSG((\"AdjustOffset incremented -2 %d \\n\", m_iAdjustOffset));\n\t }\n\t return true;\n\t}\n\n\t*ppcr = NULL;\n\treturn false;\n}", "label": 0, "cwe": null, "length": 729 }, { "index": 857033, "code": "citizens_dialog_create(const struct city *pcity)\n{\n GtkWidget *frame, *sw;\n struct citizens_dialog *pdialog = fc_malloc(sizeof(struct citizens_dialog));\n int i;\n\n pdialog->pcity = pcity;\n pdialog->store = citizens_dialog_store_new();\n pdialog->sort\n = gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(pdialog->store));\n g_object_unref(pdialog->store);\n\n gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(pdialog->sort),\n citizens_dialog_default_sort_column(),\n GTK_SORT_DESCENDING);\n\n pdialog->list\n = gtk_tree_view_new_with_model(GTK_TREE_MODEL(pdialog->sort));\n gtk_widget_set_halign(pdialog->list, GTK_ALIGN_CENTER);\n g_object_unref(pdialog->sort);\n\n for (i = 0; i < num_citizens_cols; i++) {\n struct citizens_column *pcol;\n GtkCellRenderer *renderer;\n GtkTreeViewColumn *col;\n\n pcol = &citizens_cols[i];\n col = NULL;\n\n switch (pcol->type) {\n case COL_FLAG:\n renderer = gtk_cell_renderer_pixbuf_new();\n col = gtk_tree_view_column_new_with_attributes(pcol->title, renderer,\n \"pixbuf\", i, NULL);\n break;\n case COL_TEXT:\n renderer = gtk_cell_renderer_text_new();\n g_object_set(renderer, \"style-set\", TRUE, \"weight-set\", TRUE, NULL);\n\n col = gtk_tree_view_column_new_with_attributes(pcol->title, renderer,\n \"text\", i,\n \"style\", CITIZENS_DLG_COL_STYLE,\n \"weight\", CITIZENS_DLG_COL_WEIGHT,\n NULL);\n gtk_tree_view_column_set_sort_column_id(col, i);\n break;\n case COL_RIGHT_TEXT:\n renderer = gtk_cell_renderer_text_new();\n g_object_set(renderer, \"style-set\", TRUE, \"weight-set\", TRUE, NULL);\n\n col = gtk_tree_view_column_new_with_attributes(pcol->title, renderer,\n \"text\", i,\n \"style\", CITIZENS_DLG_COL_STYLE,\n \"weight\", CITIZENS_DLG_COL_WEIGHT,\n NULL);\n gtk_tree_view_column_set_sort_column_id(col, i);\n g_object_set(renderer, \"xalign\", 1.0, NULL);\n gtk_tree_view_column_set_alignment(col, 1.0);\n break;\n case COL_COLOR:\n case COL_BOOLEAN:\n /* These are not used. */\n fc_assert(pcol->type != COL_COLOR && pcol->type != COL_BOOLEAN);\n continue;\n }\n\n if (col) {\n gtk_tree_view_append_column(GTK_TREE_VIEW(pdialog->list), col);\n }\n }\n\n gtk_widget_set_hexpand(GTK_WIDGET(pdialog->list), TRUE);\n gtk_widget_set_vexpand(GTK_WIDGET(pdialog->list), TRUE);\n\n sw = gtk_scrolled_window_new(NULL, NULL);\n gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw),\n GTK_POLICY_AUTOMATIC,\n GTK_POLICY_AUTOMATIC);\n gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw),\n GTK_SHADOW_NONE);\n gtk_container_add(GTK_CONTAINER(sw), pdialog->list);\n\n frame = gtk_frame_new(_(\"Citizens\"));\n gtk_container_add(GTK_CONTAINER(frame), sw);\n\n pdialog->shell = frame;\n\n dialog_list_prepend(dialog_list, pdialog);\n\n citizens_dialog_refresh(pcity);\n\n return pdialog;\n}", "label": 0, "cwe": null, "length": 732 }, { "index": 974506, "code": "_send_eof_msg(struct task_read_info *out)\n{\n\tstruct client_io_info *client;\n\tstruct io_buf *msg = NULL;\n\teio_obj_t *eio;\n\tListIterator clients;\n\tstruct slurm_io_header header;\n\tBuf packbuf;\n\n\tdebug4(\"Entering _send_eof_msg\");\n\tout->eof_msg_sent = true;\n\n\tif (_outgoing_buf_free(out->job)) {\n\t\tmsg = list_dequeue(out->job->free_outgoing);\n\t} else {\n\t\t/* eof message must be allowed to allocate new memory\n\t\t because _task_readable() will return \"true\" until\n\t\t the eof message is enqueued. For instance, if\n\t\t a poll returns POLLHUP on the incoming task pipe,\n\t\t put there are no outgoing message buffers available,\n\t\t the slurmstepd will start spinning. */\n\t\tmsg = alloc_io_buf();\n\t}\n\n\theader.type = out->type;\n\theader.ltaskid = out->ltaskid;\n\theader.gtaskid = out->gtaskid;\n\theader.length = 0; /* eof */\n\n\tpackbuf = create_buf(msg->data, io_hdr_packed_size());\n\tif (!packbuf)\n\t\tfatal(\"Failure to allocate memory for a message header\");\n\n\tio_hdr_pack(&header, packbuf);\n\tmsg->length = io_hdr_packed_size() + header.length;\n\tmsg->ref_count = 0; /* make certain it is initialized */\n\n\t/* Add eof message to the msg_queue of all clients */\n\tclients = list_iterator_create(out->job->clients);\n\tif (!clients)\n\t\tfatal(\"Could not allocate iterator\");\n\twhile((eio = list_next(clients))) {\n\t\tclient = (struct client_io_info *)eio->arg;\n\t\tdebug5(\"======================== Enqueued eof message\");\n\t\txassert(client->magic == CLIENT_IO_MAGIC);\n\n\t\t/* Some clients only take certain I/O streams */\n\t\tif (out->type==SLURM_IO_STDOUT) {\n\t\t\tif (client->ltaskid_stdout != -1 &&\n\t\t\t client->ltaskid_stdout != out->ltaskid)\n\t\t\t\tcontinue;\n\t\t}\n\t\tif (out->type==SLURM_IO_STDERR) {\n\t\t\tif (client->ltaskid_stderr != -1 &&\n\t\t\t client->ltaskid_stderr != out->ltaskid)\n\t\t\t\tcontinue;\n\t\t}\n\n\t\tif (list_enqueue(client->msg_queue, msg))\n\t\t\tmsg->ref_count++;\n\t}\n\tlist_iterator_destroy(clients);\n\n\tdebug4(\"Leaving _send_eof_msg\");\n}", "label": 0, "cwe": null, "length": 520 }, { "index": 236022, "code": "install_button_clicked_cb (GtkButton *button,\n gpointer user_data)\n{\n FontViewApplication *self = user_data;\n gchar *dest_filename;\n GError *err = NULL;\n FcConfig *config;\n FcStrList *str_list;\n FcChar8 *path;\n GFile *xdg_prefix, *home_prefix, *file;\n GFile *xdg_location = NULL, *home_location = NULL;\n GFile *dest_location = NULL, *dest_file;\n\n config = FcConfigGetCurrent ();\n str_list = FcConfigGetFontDirs (config);\n\n home_prefix = g_file_new_for_path (g_get_home_dir ());\n xdg_prefix = g_file_new_for_path (g_get_user_data_dir ());\n\n /* pick the XDG location, if any, or fallback to the first location\n * under the home directory.\n */\n while ((path = FcStrListNext (str_list)) != NULL) {\n file = g_file_new_for_path ((const gchar *) path);\n\n if (g_file_has_prefix (file, xdg_prefix)) {\n xdg_location = file;\n break;\n }\n\n if ((home_location == NULL) &&\n g_file_has_prefix (file, home_prefix)) {\n home_location = file;\n break;\n }\n\n g_object_unref (file);\n }\n\n FcStrListDone (str_list);\n g_object_unref (home_prefix);\n g_object_unref (xdg_prefix);\n\n if (xdg_location != NULL)\n dest_location = g_object_ref (xdg_location);\n else if (home_location != NULL)\n dest_location = g_object_ref (home_location);\n\n g_clear_object (&home_location);\n g_clear_object (&xdg_location);\n\n if (dest_location == NULL) {\n g_warning (\"Install failed: can't find any configured user font directory.\");\n return;\n }\n\n if (!g_file_query_exists (dest_location, NULL)) {\n g_file_make_directory_with_parents (dest_location, NULL, &err);\n if (err) {\n /* TODO: show error dialog */\n g_warning (\"Could not create fonts directory: %s\", err->message);\n g_error_free (err);\n g_object_unref (dest_location);\n return;\n }\n }\n\n /* create destination filename */\n dest_filename = g_file_get_basename (self->font_file);\n dest_file = g_file_get_child (dest_location, dest_filename);\n g_free (dest_filename);\n\n /* TODO: show error dialog if file exists */\n g_file_copy_async (self->font_file, dest_file, G_FILE_COPY_NONE, 0, NULL, NULL, NULL,\n font_install_finished_cb, self);\n\n g_object_unref (dest_file);\n g_object_unref (dest_location);\n}", "label": 1, "cwe": "CWE-other", "length": 593 }, { "index": 150892, "code": "Java_org_gdal_gdal_gdalJNI_Driver_1Create_1_1SWIG_10(JNIEnv *jenv, jclass jcls, jlong jarg1, jobject jarg1_, jstring jarg2, jint jarg3, jint jarg4, jint jarg5, jint jarg6, jobject jarg7) {\n jlong jresult = 0 ;\n GDALDriverShadow *arg1 = (GDALDriverShadow *) 0 ;\n char *arg2 = (char *) 0 ;\n int arg3 ;\n int arg4 ;\n int arg5 ;\n GDALDataType arg6 ;\n char **arg7 = (char **) 0 ;\n GDALDatasetShadow *result = 0 ;\n \n (void)jenv;\n (void)jcls;\n (void)jarg1_;\n arg1 = *(GDALDriverShadow **)&jarg1; \n arg2 = 0;\n if (jarg2) {\n arg2 = (char *)jenv->GetStringUTFChars(jarg2, 0);\n if (!arg2) return 0;\n }\n arg3 = (int)jarg3; \n arg4 = (int)jarg4; \n arg5 = (int)jarg5; \n arg6 = (GDALDataType)jarg6; \n {\n /* %typemap(in) char **options */\n arg7 = NULL;\n if(jarg7 != 0) {\n const jclass vector = jenv->FindClass(\"java/util/Vector\");\n const jclass enumeration = jenv->FindClass(\"java/util/Enumeration\");\n const jclass stringClass = jenv->FindClass(\"java/lang/String\");\n const jmethodID elements = jenv->GetMethodID(vector, \"elements\",\n \"()Ljava/util/Enumeration;\");\n const jmethodID hasMoreElements = jenv->GetMethodID(enumeration, \n \"hasMoreElements\", \"()Z\");\n const jmethodID getNextElement = jenv->GetMethodID(enumeration,\n \"nextElement\", \"()Ljava/lang/Object;\");\n if(vector == NULL || enumeration == NULL || elements == NULL ||\n hasMoreElements == NULL || getNextElement == NULL) {\n fprintf(stderr, \"Could not load (options **) jni types.\\n\");\n return 0;\n }\n for (jobject keys = jenv->CallObjectMethod(jarg7, elements);\n jenv->CallBooleanMethod(keys, hasMoreElements) == JNI_TRUE;) {\n jstring value = (jstring)jenv->CallObjectMethod(keys, getNextElement);\n if (value == NULL || !jenv->IsInstanceOf(value, stringClass))\n {\n CSLDestroy(arg7);\n SWIG_JavaThrowException(jenv, SWIG_JavaIllegalArgumentException, \"an element in the vector is not a string\");\n return 0;\n }\n const char *valptr = jenv->GetStringUTFChars(value, 0);\n arg7 = CSLAddString(arg7, valptr);\n jenv->ReleaseStringUTFChars(value, valptr);\n }\n }\n }\n result = (GDALDatasetShadow *)GDALDriverShadow_Create__SWIG_0(arg1,(char const *)arg2,arg3,arg4,arg5,arg6,arg7);\n *(GDALDatasetShadow **)&jresult = result; \n if (arg2) jenv->ReleaseStringUTFChars(jarg2, (const char *)arg2);\n {\n /* %typemap(freearg) char **options */\n CSLDestroy( arg7 );\n }\n return jresult;\n}", "label": 0, "cwe": null, "length": 773 }, { "index": 45182, "code": "unpack_resources(xmlNode * xml_resources, pe_working_set_t * data_set)\n{\n xmlNode *xml_obj = NULL;\n GListPtr gIter = NULL;\n\n data_set->template_rsc_sets =\n g_hash_table_new_full(crm_str_hash, g_str_equal, g_hash_destroy_str,\n destroy_template_rsc_set);\n\n for (xml_obj = __xml_first_child(xml_resources); xml_obj != NULL; xml_obj = __xml_next(xml_obj)) {\n resource_t *new_rsc = NULL;\n\n if (crm_str_eq((const char *)xml_obj->name, XML_CIB_TAG_RSC_TEMPLATE, TRUE)) {\n const char *template_id = ID(xml_obj);\n\n if (template_id && g_hash_table_lookup_extended(data_set->template_rsc_sets,\n template_id, NULL, NULL) == FALSE) {\n /* Record the template's ID for the knowledge of its existence anyway. */\n g_hash_table_insert(data_set->template_rsc_sets, strdup(template_id), NULL);\n }\n continue;\n }\n\n crm_trace(\"Beginning unpack... <%s id=%s... >\", crm_element_name(xml_obj), ID(xml_obj));\n if (common_unpack(xml_obj, &new_rsc, NULL, data_set)) {\n data_set->resources = g_list_append(data_set->resources, new_rsc);\n\n if (is_remote_node(xml_obj)) {\n node_t *remote = pe_find_node(data_set->nodes, new_rsc->id);\n if (remote) {\n remote->details->remote_rsc = new_rsc;\n new_rsc->is_remote_node = TRUE;\n }\n }\n print_resource(LOG_DEBUG_3, \"Added \", new_rsc, FALSE);\n\n } else {\n crm_config_err(\"Failed unpacking %s %s\",\n crm_element_name(xml_obj), crm_element_value(xml_obj, XML_ATTR_ID));\n if (new_rsc != NULL && new_rsc->fns != NULL) {\n new_rsc->fns->free(new_rsc);\n }\n }\n }\n\n for (gIter = data_set->resources; gIter != NULL; gIter = gIter->next) {\n resource_t *rsc = (resource_t *) gIter->data;\n\n setup_container(rsc, data_set);\n }\n\n data_set->resources = g_list_sort(data_set->resources, sort_rsc_priority);\n\n if (is_not_set(data_set->flags, pe_flag_quick_location)\n && is_set(data_set->flags, pe_flag_stonith_enabled)\n && is_set(data_set->flags, pe_flag_have_stonith_resource) == FALSE) {\n crm_config_err(\"Resource start-up disabled since no STONITH resources have been defined\");\n crm_config_err(\"Either configure some or disable STONITH with the stonith-enabled option\");\n crm_config_err(\"NOTE: Clusters with shared data need STONITH to ensure data integrity\");\n }\n\n return TRUE;\n}", "label": 0, "cwe": null, "length": 634 }, { "index": 942612, "code": "__nvme_submit_user_cmd(struct request_queue *q, struct nvme_command *cmd,\n\t\tvoid __user *ubuffer, unsigned bufflen,\n\t\tvoid __user *meta_buffer, unsigned meta_len, u32 meta_seed,\n\t\tu32 *result, unsigned timeout)\n{\n\tbool write = nvme_is_write(cmd);\n\tstruct nvme_completion cqe;\n\tstruct nvme_ns *ns = q->queuedata;\n\tstruct gendisk *disk = ns ? ns->disk : NULL;\n\tstruct request *req;\n\tstruct bio *bio = NULL;\n\tvoid *meta = NULL;\n\tint ret;\n\n\treq = nvme_alloc_request(q, cmd, 0, NVME_QID_ANY);\n\tif (IS_ERR(req))\n\t\treturn PTR_ERR(req);\n\n\treq->timeout = timeout ? timeout : ADMIN_TIMEOUT;\n\treq->special = &cqe;\n\n\tif (ubuffer && bufflen) {\n\t\tret = blk_rq_map_user(q, req, NULL, ubuffer, bufflen,\n\t\t\t\tGFP_KERNEL);\n\t\tif (ret)\n\t\t\tgoto out;\n\t\tbio = req->bio;\n\n\t\tif (!disk)\n\t\t\tgoto submit;\n\t\tbio->bi_bdev = bdget_disk(disk, 0);\n\t\tif (!bio->bi_bdev) {\n\t\t\tret = -ENODEV;\n\t\t\tgoto out_unmap;\n\t\t}\n\n\t\tif (meta_buffer) {\n\t\t\tstruct bio_integrity_payload *bip;\n\n\t\t\tmeta = kmalloc(meta_len, GFP_KERNEL);\n\t\t\tif (!meta) {\n\t\t\t\tret = -ENOMEM;\n\t\t\t\tgoto out_unmap;\n\t\t\t}\n\n\t\t\tif (write) {\n\t\t\t\tif (copy_from_user(meta, meta_buffer,\n\t\t\t\t\t\tmeta_len)) {\n\t\t\t\t\tret = -EFAULT;\n\t\t\t\t\tgoto out_free_meta;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tbip = bio_integrity_alloc(bio, GFP_KERNEL, 1);\n\t\t\tif (IS_ERR(bip)) {\n\t\t\t\tret = PTR_ERR(bip);\n\t\t\t\tgoto out_free_meta;\n\t\t\t}\n\n\t\t\tbip->bip_iter.bi_size = meta_len;\n\t\t\tbip->bip_iter.bi_sector = meta_seed;\n\n\t\t\tret = bio_integrity_add_page(bio, virt_to_page(meta),\n\t\t\t\t\tmeta_len, offset_in_page(meta));\n\t\t\tif (ret != meta_len) {\n\t\t\t\tret = -ENOMEM;\n\t\t\t\tgoto out_free_meta;\n\t\t\t}\n\t\t}\n\t}\n submit:\n\tblk_execute_rq(req->q, disk, req, 0);\n\tret = req->errors;\n\tif (result)\n\t\t*result = le32_to_cpu(cqe.result);\n\tif (meta && !ret && !write) {\n\t\tif (copy_to_user(meta_buffer, meta, meta_len))\n\t\t\tret = -EFAULT;\n\t}\n out_free_meta:\n\tkfree(meta);\n out_unmap:\n\tif (bio) {\n\t\tif (disk && bio->bi_bdev)\n\t\t\tbdput(bio->bi_bdev);\n\t\tblk_rq_unmap_user(bio);\n\t}\n out:\n\tblk_mq_free_request(req);\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 624 }, { "index": 170136, "code": "BuildTree(BYTE *aLevels)\n{\n m_BlockBitLength = 0;\n int aMaxCode = -1; // WAS = -1; largest code with non zero frequency */\n\n // Construct the initial m_Heap, with least frequent element in\n // m_Heap[kSmallest]. The sons of m_Heap[n] are m_Heap[2*n] and m_Heap[2*n+1].\n // m_Heap[0] is not used.\n //\n\n m_HeapLength = 0;\n UINT32 n; // iterate over m_Heap elements \n for (n = 0; n < m_NumSymbols; n++) \n {\n if (m_Items[n].Freq != 0) \n {\n m_Heap[++m_HeapLength] = aMaxCode = n;\n m_Depth[n] = 0;\n } \n else \n m_Items[n].Len = 0;\n }\n\n // The pkzip format requires that at least one distance code exists,\n // and that at least one bit should be sent even if there is only one\n // possible code. So to avoid special checks later on we force at least\n // two codes of non zero frequency.\n while (m_HeapLength < 2) \n {\n int aNewNode = m_Heap[++m_HeapLength] = (aMaxCode < 2 ? ++aMaxCode : 0);\n m_Items[aNewNode].Freq = 1;\n m_Depth[aNewNode] = 0;\n m_BlockBitLength--; \n // if (stree) static_len -= stree[aNewNode].Len;\n // aNewNode is 0 or 1 so it does not have m_ExtraBits bits\n }\n \n // The elements m_Heap[m_HeapLength/2+1 .. m_HeapLength] are leaves of the m_Items,\n // establish sub-heaps of increasing lengths:\n for (n = m_HeapLength / 2; n >= 1; n--) \n DownHeap(n);\n \n // Construct the Huffman tree by repeatedly combining the least two\n // frequent nodes.\n int aNode = m_NumSymbols; // next internal node of the tree\n UINT32 aHeapMax = m_NumSymbols * 2+ 1;\n do \n {\n n = RemoveSmallest(); /* n = node of least frequency */\n UINT32 m = m_Heap[kSmallest]; /* m = node of next least frequency */\n \n m_Heap[--aHeapMax] = n; /* keep the nodes sorted by frequency */\n m_Heap[--aHeapMax] = m;\n \n // Create a new node father of n and m \n m_Items[aNode].Freq = m_Items[n].Freq + m_Items[m].Freq;\n m_Depth[aNode] = (BYTE) (MyMax(m_Depth[n], m_Depth[m]) + 1);\n m_Items[n].Dad = m_Items[m].Dad = aNode;\n // and insert the new node in the m_Heap\n m_Heap[kSmallest] = aNode++;\n DownHeap(kSmallest);\n \n } \n while (m_HeapLength >= 2);\n \n m_Heap[--aHeapMax] = m_Heap[kSmallest];\n \n // At this point, the fields freq and dad are set. We can now\n // generate the bit lengths.\n GenerateBitLen(aMaxCode, aHeapMax);\n \n // The field len is now set, we can generate the bit codes \n GenerateCodes (aMaxCode);\n\n for (n = 0; n < m_NumSymbols; n++) \n aLevels[n] = BYTE(m_Items[n].Len);\n}\n\n}}", "label": 0, "cwe": null, "length": 821 }, { "index": 211503, "code": "cnt_lookup(struct sess *sp)\n{\n\tstruct objcore *oc;\n\tstruct object *o;\n\tstruct objhead *oh;\n\n\tCHECK_OBJ_NOTNULL(sp, SESS_MAGIC);\n\tCHECK_OBJ_NOTNULL(sp->vcl, VCL_CONF_MAGIC);\n\n\tif (sp->hash_objhead == NULL) {\n\t\t/* Not a waiting list return */\n\t\tAZ(sp->vary_b);\n\t\tAZ(sp->vary_l);\n\t\tAZ(sp->vary_e);\n\t\t(void)WS_Reserve(sp->ws, 0);\n\t\tsp->vary_b = (void*)sp->ws->f;\n\t\tsp->vary_e = (void*)sp->ws->r;\n\t\tsp->vary_b[2] = '\\0';\n\t}\n\n\toc = HSH_Lookup(sp, &oh);\n\n\tif (oc == NULL) {\n\t\t/*\n\t\t * We lost the session to a busy object, disembark the\n\t\t * worker thread. The hash code to restart the session,\n\t\t * still in STP_LOOKUP, later when the busy object isn't.\n\t\t * NB: Do not access sp any more !\n\t\t */\n\t\treturn (1);\n\t}\n\n\n\tCHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);\n\tCHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);\n\n\t/* If we inserted a new object it's a miss */\n\tif (oc->flags & OC_F_BUSY) {\n\t\tsp->wrk->stats.cache_miss++;\n\n\t\tif (sp->vary_l != NULL)\n\t\t\tWS_ReleaseP(sp->ws, (void*)sp->vary_l);\n\t\telse\n\t\t\tWS_Release(sp->ws, 0);\n\t\tsp->vary_b = NULL;\n\t\tsp->vary_l = NULL;\n\t\tsp->vary_e = NULL;\n\n\t\tsp->objcore = oc;\n\t\tsp->step = STP_MISS;\n\t\treturn (0);\n\t}\n\n\to = oc_getobj(sp->wrk, oc);\n\tCHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);\n\tsp->obj = o;\n\n\tWS_Release(sp->ws, 0);\n\tsp->vary_b = NULL;\n\tsp->vary_l = NULL;\n\tsp->vary_e = NULL;\n\n\tif (oc->flags & OC_F_PASS) {\n\t\tsp->wrk->stats.cache_hitpass++;\n\t\tWSP(sp, SLT_HitPass, \"%u\", sp->obj->xid);\n\t\t(void)HSH_Deref(sp->wrk, NULL, &sp->obj);\n\t\tsp->objcore = NULL;\n\t\tsp->step = STP_PASS;\n\t\treturn (0);\n\t}\n\n\tsp->wrk->stats.cache_hit++;\n\tWSP(sp, SLT_Hit, \"%u\", sp->obj->xid);\n\tsp->step = STP_HIT;\n\treturn (0);\n}", "label": 1, "cwe": "CWE-476", "length": 572 }, { "index": 515000, "code": "hostap_rx_frame_mgmt(local_info_t *local, struct sk_buff *skb,\n\t\t struct hostap_80211_rx_status *rx_stats, u16 type,\n\t\t u16 stype)\n{\n\tif (local->iw_mode == IW_MODE_MASTER)\n\t\thostap_update_sta_ps(local, (struct ieee80211_hdr *) skb->data);\n\n\tif (local->hostapd && type == IEEE80211_FTYPE_MGMT) {\n\t\tif (stype == IEEE80211_STYPE_BEACON &&\n\t\t local->iw_mode == IW_MODE_MASTER) {\n\t\t\tstruct sk_buff *skb2;\n\t\t\t/* Process beacon frames also in kernel driver to\n\t\t\t * update STA(AP) table statistics */\n\t\t\tskb2 = skb_clone(skb, GFP_ATOMIC);\n\t\t\tif (skb2)\n\t\t\t\thostap_rx(skb2->dev, skb2, rx_stats);\n\t\t}\n\n\t\t/* send management frames to the user space daemon for\n\t\t * processing */\n\t\tlocal->apdevstats.rx_packets++;\n\t\tlocal->apdevstats.rx_bytes += skb->len;\n\t\tif (local->apdev == NULL)\n\t\t\treturn -1;\n\t\tprism2_rx_80211(local->apdev, skb, rx_stats, PRISM2_RX_MGMT);\n\t\treturn 0;\n\t}\n\n\tif (local->iw_mode == IW_MODE_MASTER) {\n\t\tif (type != IEEE80211_FTYPE_MGMT &&\n\t\t type != IEEE80211_FTYPE_CTL) {\n\t\t\tprintk(KERN_DEBUG \"%s: unknown management frame \"\n\t\t\t \"(type=0x%02x, stype=0x%02x) dropped\\n\",\n\t\t\t skb->dev->name, type >> 2, stype >> 4);\n\t\t\treturn -1;\n\t\t}\n\n\t\thostap_rx(skb->dev, skb, rx_stats);\n\t\treturn 0;\n\t} else if (type == IEEE80211_FTYPE_MGMT &&\n\t\t (stype == IEEE80211_STYPE_BEACON ||\n\t\t stype == IEEE80211_STYPE_PROBE_RESP)) {\n\t\thostap_rx_sta_beacon(local, skb, stype);\n\t\treturn -1;\n\t} else if (type == IEEE80211_FTYPE_MGMT &&\n\t\t (stype == IEEE80211_STYPE_ASSOC_RESP ||\n\t\t stype == IEEE80211_STYPE_REASSOC_RESP)) {\n\t\t/* Ignore (Re)AssocResp silently since these are not currently\n\t\t * needed but are still received when WPA/RSN mode is enabled.\n\t\t */\n\t\treturn -1;\n\t} else {\n\t\tprintk(KERN_DEBUG \"%s: hostap_rx_frame_mgmt: dropped unhandled\"\n\t\t \" management frame in non-Host AP mode (type=%d:%d)\\n\",\n\t\t skb->dev->name, type >> 2, stype >> 4);\n\t\treturn -1;\n\t}\n}", "label": 0, "cwe": null, "length": 590 }, { "index": 764563, "code": "be_mcc_compl_process_isr(struct be_ctrl_info *ctrl,\n\t\t\t\t struct be_mcc_compl *compl)\n{\n\tstruct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev);\n\tu16 compl_status, extd_status;\n\tunsigned short tag;\n\n\tbe_dws_le_to_cpu(compl, 4);\n\n\tcompl_status = (compl->status >> CQE_STATUS_COMPL_SHIFT) &\n\t\t\t\t\tCQE_STATUS_COMPL_MASK;\n\t/* The ctrl.mcc_numtag[tag] is filled with\n\t * [31] = valid, [30:24] = Rsvd, [23:16] = wrb, [15:8] = extd_status,\n\t * [7:0] = compl_status\n\t */\n\ttag = (compl->tag0 & 0x000000FF);\n\textd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) &\n\t\t\t\t\tCQE_STATUS_EXTD_MASK;\n\n\tctrl->mcc_numtag[tag] = 0x80000000;\n\tctrl->mcc_numtag[tag] |= (compl->tag0 & 0x00FF0000);\n\tctrl->mcc_numtag[tag] |= (extd_status & 0x000000FF) << 8;\n\tctrl->mcc_numtag[tag] |= (compl_status & 0x000000FF);\n\n\tif (ctrl->ptag_state[tag].tag_state == MCC_TAG_STATE_RUNNING) {\n\t\twake_up_interruptible(&ctrl->mcc_wait[tag]);\n\t} else if (ctrl->ptag_state[tag].tag_state == MCC_TAG_STATE_TIMEOUT) {\n\t\tstruct be_dma_mem *tag_mem;\n\t\ttag_mem = &ctrl->ptag_state[tag].tag_mem_state;\n\n\t\tbeiscsi_log(phba, KERN_WARNING,\n\t\t\t BEISCSI_LOG_MBOX | BEISCSI_LOG_INIT |\n\t\t\t BEISCSI_LOG_CONFIG,\n\t\t\t \"BC_%d : MBX Completion for timeout Command \"\n\t\t\t \"from FW\\n\");\n\t\t/* Check if memory needs to be freed */\n\t\tif (tag_mem->size)\n\t\t\tpci_free_consistent(ctrl->pdev, tag_mem->size,\n\t\t\t\t\t tag_mem->va, tag_mem->dma);\n\n\t\t/* Change tag state */\n\t\tspin_lock(&phba->ctrl.mbox_lock);\n\t\tctrl->ptag_state[tag].tag_state = MCC_TAG_STATE_COMPLETED;\n\t\tspin_unlock(&phba->ctrl.mbox_lock);\n\n\t\t/* Free MCC Tag */\n\t\tfree_mcc_tag(ctrl, tag);\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 533 }, { "index": 1012377, "code": "initialize_GMM(Jconf *jconf)\n{\n HTK_HMM_INFO *gmm;\n \n jlog(\"STAT: reading GMM: %s\\n\", jconf->reject.gmm_filename);\n\n if (jconf->gmm == NULL) {\n /* no acoustic parameter setting was given for GMM using -AM_GMM, \n copy the first AM setting */\n jlog(\"STAT: -AM_GMM not used, use parameter of the first AM\\n\");\n jconf->gmm = j_jconf_am_new();\n memcpy(jconf->gmm, jconf->am_root, sizeof(JCONF_AM));\n jconf->gmm->hmmfilename = NULL;\n jconf->gmm->mapfilename = NULL;\n jconf->gmm->spmodel_name = NULL;\n jconf->gmm->hmm_gs_filename = NULL;\n if (jconf->am_root->analysis.cmnload_filename) {\n jconf->gmm->analysis.cmnload_filename = strcpy((char *)mymalloc(strlen(jconf->am_root->analysis.cmnload_filename)+ 1), jconf->am_root->analysis.cmnload_filename);\n }\n if (jconf->am_root->analysis.cmnsave_filename) {\n jconf->gmm->analysis.cmnsave_filename = strcpy((char *)mymalloc(strlen(jconf->am_root->analysis.cmnsave_filename)+ 1), jconf->am_root->analysis.cmnsave_filename);\n }\n if (jconf->am_root->frontend.ssload_filename) {\n jconf->gmm->frontend.ssload_filename = strcpy((char *)mymalloc(strlen(jconf->am_root->frontend.ssload_filename)+ 1), jconf->am_root->frontend.ssload_filename);\n }\n }\n\n gmm = hmminfo_new();\n if (init_hmminfo(gmm, jconf->reject.gmm_filename, NULL, &(jconf->gmm->analysis.para_hmm)) == FALSE) {\n hmminfo_free(gmm);\n return NULL;\n }\n /* check parameter type of this acoustic HMM */\n if (jconf->input.type == INPUT_WAVEFORM) {\n /* Decode parameter extraction type according to the training\n parameter type in the header of the given acoustic HMM */\n if ((gmm->opt.param_type & F_BASEMASK) != F_MFCC) {\n jlog(\"ERROR: m_fusion: for direct speech input, only GMM trained by MFCC is supported\\n\");\n hmminfo_free(gmm);\n return NULL;\n }\n }\n\n /* set acoustic analysis parameters from HMM header */\n calc_para_from_header(&(jconf->gmm->analysis.para), gmm->opt.param_type, gmm->opt.vec_size);\n\n if (jconf->gmm->analysis.para_htk.loaded == 1) apply_para(&(jconf->gmm->analysis.para), &(jconf->gmm->analysis.para_htk));\n if (jconf->gmm->analysis.para_hmm.loaded == 1) apply_para(&(jconf->gmm->analysis.para), &(jconf->gmm->analysis.para_hmm));\n apply_para(&(jconf->gmm->analysis.para), &(jconf->gmm->analysis.para_default));\n\n return(gmm);\n}", "label": 0, "cwe": null, "length": 719 }, { "index": 420945, "code": "find_value (const DBusString *str,\n int start,\n const char *key,\n DBusString *value,\n int *value_end,\n DBusError *error)\n{\n const char *p;\n const char *s;\n char quote_char;\n int orig_len;\n\n _DBUS_ASSERT_ERROR_IS_CLEAR (error);\n \n orig_len = _dbus_string_get_length (value);\n \n s = _dbus_string_get_const_data (str);\n\n p = s + start;\n\n quote_char = '\\0';\n\n while (*p)\n {\n if (quote_char == '\\0')\n {\n switch (*p)\n {\n case '\\0':\n goto done;\n\n case '\\'':\n quote_char = '\\'';\n goto next;\n \n case ',':\n ++p;\n goto done;\n\n case '\\\\':\n quote_char = '\\\\';\n goto next;\n \n default:\n if (!_dbus_string_append_byte (value, *p))\n {\n BUS_SET_OOM (error);\n goto failed;\n }\n }\n }\n else if (quote_char == '\\\\')\n {\n /* \\ only counts as an escape if escaping a quote mark */\n if (*p != '\\'')\n {\n if (!_dbus_string_append_byte (value, '\\\\'))\n {\n BUS_SET_OOM (error);\n goto failed;\n }\n }\n\n if (!_dbus_string_append_byte (value, *p))\n {\n BUS_SET_OOM (error);\n goto failed;\n }\n \n quote_char = '\\0';\n }\n else\n {\n _dbus_assert (quote_char == '\\'');\n\n if (*p == '\\'')\n {\n quote_char = '\\0';\n }\n else\n {\n if (!_dbus_string_append_byte (value, *p))\n {\n BUS_SET_OOM (error);\n goto failed;\n }\n }\n }\n\n next:\n ++p;\n }\n\n done:\n\n if (quote_char == '\\\\')\n {\n if (!_dbus_string_append_byte (value, '\\\\'))\n {\n BUS_SET_OOM (error);\n goto failed;\n }\n }\n else if (quote_char == '\\'')\n {\n dbus_set_error (error, DBUS_ERROR_MATCH_RULE_INVALID,\n \"Unbalanced quotation marks in match rule\");\n goto failed;\n }\n else\n _dbus_assert (quote_char == '\\0');\n\n /* Zero-length values are allowed */\n \n *value_end = p - s;\n \n return TRUE;\n\n failed:\n _DBUS_ASSERT_ERROR_IS_SET (error);\n _dbus_string_set_length (value, orig_len);\n return FALSE;\n}", "label": 0, "cwe": null, "length": 565 }, { "index": 681682, "code": "vpfe_probe_complete(struct vpfe_device *vpfe)\n{\n\tstruct video_device *vdev;\n\tstruct vb2_queue *q;\n\tint err;\n\n\tspin_lock_init(&vpfe->dma_queue_lock);\n\tmutex_init(&vpfe->lock);\n\n\tvpfe->fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;\n\n\t/* set first sub device as current one */\n\tvpfe->current_subdev = &vpfe->cfg->sub_devs[0];\n\tvpfe->v4l2_dev.ctrl_handler = vpfe->sd[0]->ctrl_handler;\n\n\terr = vpfe_set_input(vpfe, 0);\n\tif (err)\n\t\tgoto probe_out;\n\n\t/* Initialize videobuf2 queue as per the buffer type */\n\tvpfe->alloc_ctx = vb2_dma_contig_init_ctx(vpfe->pdev);\n\tif (IS_ERR(vpfe->alloc_ctx)) {\n\t\tvpfe_err(vpfe, \"Failed to get the context\\n\");\n\t\terr = PTR_ERR(vpfe->alloc_ctx);\n\t\tgoto probe_out;\n\t}\n\n\tq = &vpfe->buffer_queue;\n\tq->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;\n\tq->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;\n\tq->drv_priv = vpfe;\n\tq->ops = &vpfe_video_qops;\n\tq->mem_ops = &vb2_dma_contig_memops;\n\tq->buf_struct_size = sizeof(struct vpfe_cap_buffer);\n\tq->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;\n\tq->lock = &vpfe->lock;\n\tq->min_buffers_needed = 1;\n\n\terr = vb2_queue_init(q);\n\tif (err) {\n\t\tvpfe_err(vpfe, \"vb2_queue_init() failed\\n\");\n\t\tvb2_dma_contig_cleanup_ctx(vpfe->alloc_ctx);\n\t\tgoto probe_out;\n\t}\n\n\tINIT_LIST_HEAD(&vpfe->dma_queue);\n\n\tvdev = &vpfe->video_dev;\n\tstrlcpy(vdev->name, VPFE_MODULE_NAME, sizeof(vdev->name));\n\tvdev->release = video_device_release_empty;\n\tvdev->fops = &vpfe_fops;\n\tvdev->ioctl_ops = &vpfe_ioctl_ops;\n\tvdev->v4l2_dev = &vpfe->v4l2_dev;\n\tvdev->vfl_dir = VFL_DIR_RX;\n\tvdev->queue = q;\n\tvdev->lock = &vpfe->lock;\n\tvideo_set_drvdata(vdev, vpfe);\n\terr = video_register_device(&vpfe->video_dev, VFL_TYPE_GRABBER, -1);\n\tif (err) {\n\t\tvpfe_err(vpfe,\n\t\t\t\"Unable to register video device.\\n\");\n\t\tgoto probe_out;\n\t}\n\n\treturn 0;\n\nprobe_out:\n\tv4l2_device_unregister(&vpfe->v4l2_dev);\n\treturn err;\n}", "label": 0, "cwe": null, "length": 604 }, { "index": 626594, "code": "read_json_string_basic(std::istream &s)\n{\n\tchar c;\n\tstd::string text;\n\n\t// Read opening quote.\n\tc = s.get();\n\tcheck_stream(s);\n\tif(!s || c != '\\\"')\n\t\tthrow json::ParseException();\n\t\n\twhile(true)\n\t{\n\t\tc = s.get();\n\t\tcheck_stream(s);\n\n\t\tif(c == '\\\"')\n\t\t\tbreak;\n\n\t\t// Characters below 0x20 must be escaped.\n\t\tif(c < 0x20)\n\t\t\tthrow json::ParseException();\n\n\t\tif(c == '\\\\')\n\t\t{\n\t\t\tchar escape_code = s.get();\n\t\t\tcheck_stream(s);\n\n\t\t\tif(escape_code == '\\\"')\n\t\t\t\ttext += '\\\"';\n\t\t\telse if(escape_code == '\\\\')\n\t\t\t\ttext += '\\\\';\n\t\t\telse if(escape_code == '/')\n\t\t\t\ttext += '/';\n\t\t\telse if(escape_code == 'b')\n\t\t\t\ttext += 0x08;\n\t\t\telse if(escape_code == 'f')\n\t\t\t\ttext += 0x0C;\n\t\t\telse if(escape_code == 'n')\n\t\t\t\ttext += '\\n';\n\t\t\telse if(escape_code == 'r')\n\t\t\t\ttext += '\\r';\n\t\t\telse if(escape_code == 't')\n\t\t\t\ttext += '\\t';\n\t\t\telse if(escape_code == 'u')\n\t\t\t{\n\t\t\t\tchar four_hex[5] = {0};\n\t\t\t\tread_four_hex_digits(s, four_hex);\n\n\t\t\t\tunsigned int code = strtoul(four_hex, NULL, 16);\n\t\t\t\tint surrogate_type = is_surrogate_pair(code);\n\t\t\t\tif(surrogate_type == 0)\n\t\t\t\t\ttext += to_utf8(code);\n\t\t\t\telse if(surrogate_type == 1)\n\t\t\t\t{\n\t\t\t\t\t// The last \\u escape was the start marker of a surrogate pair.\n\t\t\t\t\t// Look for the second half of the pair.\n\t\t\t\t\tread_string(s, \"\\\\u\");\n\t\t\t\t\tchar four_hex_2[5] = {0};\n\t\t\t\t\tread_four_hex_digits(s, four_hex_2);\n\t\t\t\t\tunsigned int code2 = strtoul(four_hex_2, NULL, 16);\n\t\t\t\t\tif(is_surrogate_pair(code2) != 2)\n\t\t\t\t\t\t// There was another \\u escape, but it wasn't the second half\n\t\t\t\t\t\t// of the surrogate pair...\n\t\t\t\t\t\tthrow json::ParseException();\n\t\t\t\t\tuint32_t code_point = decode_surrogate_pair(code, code2);\n\t\t\t\t\ttext += to_utf8(code);\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t\t// We found the second half of a surrogate pair, but there wasn't\n\t\t\t\t\t// a first half...\n\t\t\t\t\tthrow json::ParseException();\n\t\t\t}\n\t\t\telse\n\t\t\t\tthrow json::ParseException();\n\t\t}\n\t\telse\n\t\t\ttext += c;\n\t}\n\n\tcheck_is_valid_utf8(text);\n\treturn text;\n}", "label": 0, "cwe": null, "length": 565 }, { "index": 964095, "code": "wslay_event_context_init\n(wslay_event_context_ptr *ctx,\n const struct wslay_event_callbacks *callbacks,\n void *user_data)\n{\n int i, r;\n struct wslay_frame_callbacks frame_callbacks = {\n wslay_event_frame_send_callback,\n wslay_event_frame_recv_callback,\n wslay_event_frame_genmask_callback\n };\n *ctx = (wslay_event_context_ptr)malloc(sizeof(struct wslay_event_context));\n if(!*ctx) {\n return WSLAY_ERR_NOMEM;\n }\n memset(*ctx, 0, sizeof(struct wslay_event_context));\n wslay_event_config_set_callbacks(*ctx, callbacks);\n (*ctx)->user_data = user_data;\n (*ctx)->frame_user_data.ctx = *ctx;\n (*ctx)->frame_user_data.user_data = user_data;\n if((r = wslay_frame_context_init(&(*ctx)->frame_ctx, &frame_callbacks,\n &(*ctx)->frame_user_data)) != 0) {\n wslay_event_context_free(*ctx);\n return r;\n }\n (*ctx)->read_enabled = (*ctx)->write_enabled = 1;\n (*ctx)->send_queue = wslay_queue_new();\n if(!(*ctx)->send_queue) {\n wslay_event_context_free(*ctx);\n return WSLAY_ERR_NOMEM;\n }\n (*ctx)->send_ctrl_queue = wslay_queue_new();\n if(!(*ctx)->send_ctrl_queue) {\n wslay_event_context_free(*ctx);\n return WSLAY_ERR_NOMEM;\n }\n (*ctx)->queued_msg_count = 0;\n (*ctx)->queued_msg_length = 0;\n for(i = 0; i < 2; ++i) {\n wslay_event_imsg_reset(&(*ctx)->imsgs[i]);\n (*ctx)->imsgs[i].chunks = wslay_queue_new();\n if(!(*ctx)->imsgs[i].chunks) {\n wslay_event_context_free(*ctx);\n return WSLAY_ERR_NOMEM;\n }\n }\n (*ctx)->imsg = &(*ctx)->imsgs[0];\n (*ctx)->obufmark = (*ctx)->obuflimit = (*ctx)->obuf;\n (*ctx)->status_code_sent = WSLAY_CODE_ABNORMAL_CLOSURE;\n (*ctx)->status_code_recv = WSLAY_CODE_ABNORMAL_CLOSURE;\n (*ctx)->max_recv_msg_length = (1u << 31)-1;\n return 0;\n}", "label": 0, "cwe": null, "length": 549 }, { "index": 584473, "code": "e1000_poll ( struct net_device *netdev )\n{\n\tstruct e1000_adapter *adapter = netdev_priv( netdev );\n\tstruct e1000_hw *hw = &adapter->hw;\n\n\tuint32_t icr;\n\tuint32_t tx_status;\n\tuint32_t rx_status;\n\tuint32_t rx_len;\n\tuint32_t rx_err;\n\tstruct e1000_tx_desc *tx_curr_desc;\n\tstruct e1000_rx_desc *rx_curr_desc;\n\tuint32_t i;\n\n\tDBGP ( \"e1000_poll\\n\" );\n\n\t/* Acknowledge interrupts */\n\ticr = E1000_READ_REG ( hw, ICR );\n\tif ( ! icr )\n\t\treturn;\n\t\t\n DBG ( \"e1000_poll: intr_status = %#08x\\n\", icr );\n\n\t/* Check status of transmitted packets\n\t */\n\twhile ( ( i = adapter->tx_head ) != adapter->tx_tail ) {\n\t\t\t\n\t\ttx_curr_desc = ( void * ) ( adapter->tx_base ) + \n\t\t\t\t\t ( i * sizeof ( *adapter->tx_base ) ); \n\t\t\t\t\t \t\t\n\t\ttx_status = tx_curr_desc->upper.data;\n\n\t\t/* if the packet at tx_head is not owned by hardware it is for us */\n\t\tif ( ! ( tx_status & E1000_TXD_STAT_DD ) )\n\t\t\tbreak;\n\t\t\n\t\tDBG ( \"Sent packet. tx_head: %d tx_tail: %d tx_status: %#08x\\n\",\n\t \t adapter->tx_head, adapter->tx_tail, tx_status );\n\n\t\tif ( tx_status & ( E1000_TXD_STAT_EC | E1000_TXD_STAT_LC | \n\t\t\t\t E1000_TXD_STAT_TU ) ) {\n\t\t\tnetdev_tx_complete_err ( netdev, adapter->tx_iobuf[i], -EINVAL );\n\t\t\tDBG ( \"Error transmitting packet, tx_status: %#08x\\n\",\n\t\t\t tx_status );\n\t\t} else {\n\t\t\tnetdev_tx_complete ( netdev, adapter->tx_iobuf[i] );\n\t\t\tDBG ( \"Success transmitting packet, tx_status: %#08x\\n\",\n\t\t\t tx_status );\n\t\t}\n\n\t\t/* Decrement count of used descriptors, clear this descriptor \n\t\t */\n\t\tadapter->tx_fill_ctr--;\n\t\tmemset ( tx_curr_desc, 0, sizeof ( *tx_curr_desc ) );\n\t\t\n\t\tadapter->tx_head = ( adapter->tx_head + 1 ) % NUM_TX_DESC;\t\t\n\t}\n\t\n\t/* Process received packets \n\t */\n\twhile ( 1 ) {\n\t\n\t\ti = adapter->rx_curr;\n\t\t\n\t\trx_curr_desc = ( void * ) ( adapter->rx_base ) + \n\t\t\t ( i * sizeof ( *adapter->rx_base ) ); \n\t\trx_status = rx_curr_desc->status;\n\t\t\n\t\tDBG2 ( \"Before DD Check RX_status: %#08x\\n\", rx_status );\n\t\n\t\tif ( ! ( rx_status & E1000_RXD_STAT_DD ) )\n\t\t\tbreak;\n\n\t\tif ( adapter->rx_iobuf[i] == NULL )\n\t\t\tbreak;\n\n\t\tDBG ( \"RCTL = %#08x\\n\", E1000_READ_REG ( &adapter->hw, RCTL ) );\n\t\n\t\trx_len = rx_curr_desc->length;\n\n DBG ( \"Received packet, rx_curr: %d rx_status: %#08x rx_len: %d\\n\",\n i, rx_status, rx_len );\n\n rx_err = rx_curr_desc->errors;\n\n\t\tiob_put ( adapter->rx_iobuf[i], rx_len );\n\n\t\tif ( rx_err & E1000_RXD_ERR_FRAME_ERR_MASK ) {\n\t\t\n\t\t\tnetdev_rx_err ( netdev, adapter->rx_iobuf[i], -EINVAL );\n\t\t\tDBG ( \"e1000_poll: Corrupted packet received!\"\n\t\t\t \" rx_err: %#08x\\n\", rx_err );\n\t\t} else \t{\n\t\t\t/* Add this packet to the receive queue. */\n\t\t\tnetdev_rx ( netdev, adapter->rx_iobuf[i] );\n\t\t}\n\t\tadapter->rx_iobuf[i] = NULL;\n\n\t\tmemset ( rx_curr_desc, 0, sizeof ( *rx_curr_desc ) );\n\n\t\tadapter->rx_curr = ( adapter->rx_curr + 1 ) % NUM_RX_DESC;\n\t}\n\te1000_refill_rx_ring(adapter);\n}", "label": 0, "cwe": null, "length": 895 }, { "index": 48788, "code": "diMount(struct inode *ipimap)\n{\n\tstruct inomap *imap;\n\tstruct metapage *mp;\n\tint index;\n\tstruct dinomap_disk *dinom_le;\n\n\t/*\n\t * allocate/initialize the in-memory inode map control structure\n\t */\n\t/* allocate the in-memory inode map control structure. */\n\timap = kmalloc(sizeof(struct inomap), GFP_KERNEL);\n\tif (imap == NULL) {\n\t\tjfs_err(\"diMount: kmalloc returned NULL!\");\n\t\treturn -ENOMEM;\n\t}\n\n\t/* read the on-disk inode map control structure. */\n\n\tmp = read_metapage(ipimap,\n\t\t\t IMAPBLKNO << JFS_SBI(ipimap->i_sb)->l2nbperpage,\n\t\t\t PSIZE, 0);\n\tif (mp == NULL) {\n\t\tkfree(imap);\n\t\treturn -EIO;\n\t}\n\n\t/* copy the on-disk version to the in-memory version. */\n\tdinom_le = (struct dinomap_disk *) mp->data;\n\timap->im_freeiag = le32_to_cpu(dinom_le->in_freeiag);\n\timap->im_nextiag = le32_to_cpu(dinom_le->in_nextiag);\n\tatomic_set(&imap->im_numinos, le32_to_cpu(dinom_le->in_numinos));\n\tatomic_set(&imap->im_numfree, le32_to_cpu(dinom_le->in_numfree));\n\timap->im_nbperiext = le32_to_cpu(dinom_le->in_nbperiext);\n\timap->im_l2nbperiext = le32_to_cpu(dinom_le->in_l2nbperiext);\n\tfor (index = 0; index < MAXAG; index++) {\n\t\timap->im_agctl[index].inofree =\n\t\t le32_to_cpu(dinom_le->in_agctl[index].inofree);\n\t\timap->im_agctl[index].extfree =\n\t\t le32_to_cpu(dinom_le->in_agctl[index].extfree);\n\t\timap->im_agctl[index].numinos =\n\t\t le32_to_cpu(dinom_le->in_agctl[index].numinos);\n\t\timap->im_agctl[index].numfree =\n\t\t le32_to_cpu(dinom_le->in_agctl[index].numfree);\n\t}\n\n\t/* release the buffer. */\n\trelease_metapage(mp);\n\n\t/*\n\t * allocate/initialize inode allocation map locks\n\t */\n\t/* allocate and init iag free list lock */\n\tIAGFREE_LOCK_INIT(imap);\n\n\t/* allocate and init ag list locks */\n\tfor (index = 0; index < MAXAG; index++) {\n\t\tAG_LOCK_INIT(imap, index);\n\t}\n\n\t/* bind the inode map inode and inode map control structure\n\t * to each other.\n\t */\n\timap->im_ipimap = ipimap;\n\tJFS_IP(ipimap)->i_imap = imap;\n\n\treturn (0);\n}", "label": 0, "cwe": null, "length": 608 }, { "index": 155927, "code": "preload_mountpoint(KDB *handle, char* name, char *mountpoint, char *backend, char *path)\n{\n\tchar buffer [MAX_PATH_LENGTH];\n\n\tKeySet *ks = ksNew (100,\n\t\tkeyNew(\tmountpoint,\n\t\t\tKEY_DIR,\n\t\t\tKEY_VALUE, backend,\n\t\t\tKEY_COMMENT, \"This is a mounted backend.\",\n\t\t\tKEY_END),\n\t\tkeyNew(\tlocation (buffer, name, \"\"),\n\t\t\tKEY_DIR,\n\t\t\tKEY_VALUE, \"\",\n\t\t\tKEY_COMMENT, \"This is a mounted backend, see subkeys for more information\",\n\t\t\tKEY_END),\n\t\tkeyNew(\tlocation (buffer, name, \"/mountpoint\"),\n\t\t\tKEY_VALUE, mountpoint,\n\t\t\tKEY_COMMENT, \"The mountpoint says the location where the backend should be mounted.\\n\"\n\t\t\t\"It must be a valid, canonical elektra path. There are no ., .. or multiple slashes allowed.\\n\"\n\t\t\t\"You are not allowed to mount inside system/elektra.\",\n\t\t\tKEY_END),\n\t\tkeyNew(\tlocation (buffer, name, \"/backend\"),\n\t\t\tKEY_VALUE, backend,\n\t\t\tKEY_COMMENT, \"The name of the backend library.\\n\"\n\t\t\t\"This name describes which .so should be loaded for that backend.\\n\"\n\t\t\t\"You are allowed to mount the same backend multiple times.\",\n\t\t\tKEY_END),\n\t\tkeyNew(\tlocation (buffer, name, \"/config\"),\n\t\t\tKEY_DIR,\n\t\t\tKEY_VALUE, \"\",\n\t\t\tKEY_COMMENT, \"The configuration for the specific backend.\\n\"\n\t\t\t\"All keys below that directory will be passed to backend.\\n\"\n\t\t\t\"These keys have backend specific meaning.\\n\"\n\t\t\t\"See documentation http://www.libelektra.org for which keys must or can be set.\\n\"\n\t\t\t\"Here the most important keys should be preloaded.\",\n\t\t\tKEY_END),\n\t\tkeyNew(\tlocation (buffer, name, \"/config/path\"),\n\t\t\tKEY_VALUE, path,\n\t\t\tKEY_COMMENT, \"The path where the config file is located.\"\n\t\t\t\"This item is often used by backends using configuration in a filesystem\"\n\t\t\t\"to know there relative location of the keys to fetch or write.\",\n\t\t\tKEY_END),\n\t\tKS_END);\n\tprintf (\"Set %s mountpoint %s in path %s... \", name, mountpoint, path);\n\tif (kdbSet (handle, ks, keyNew(\"system\",0), KDB_O_DEL) == -1)\n\t{\n\t\tprintf (\"failure\\n\");\n\t\treturn 1;\n\t} else {\n\t\tprintf (\"done\\n\");\n\t\treturn 0;\n\t}\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-469" ], "length": 528 }, { "index": 485276, "code": "imapx_search_body_contains (CamelSExp *sexp,\n gint argc,\n CamelSExpResult **argv,\n CamelFolderSearch *search)\n{\n\tCamelIMAPXSearch *imapx_search = CAMEL_IMAPX_SEARCH (search);\n\tCamelIMAPXServer *server;\n\tCamelSExpResult *result;\n\tGString *criteria;\n\tgint ii, jj;\n\n\t/* Always do body-search server-side */\n\tif (imapx_search->priv->local_data_search) {\n\t\t*imapx_search->priv->local_data_search = -1;\n\t\treturn imapx_search_result_match_none (sexp, search);\n\t}\n\n\t/* Match everything if argv = [\"\"] */\n\tif (argc == 1 && argv[0]->value.string[0] == '\\0')\n\t\treturn imapx_search_result_match_all (sexp, search);\n\n\t/* Match nothing if empty argv or empty summary. */\n\tif (argc == 0 || search->summary->len == 0)\n\t\treturn imapx_search_result_match_none (sexp, search);\n\n\tserver = camel_imapx_search_ref_server (CAMEL_IMAPX_SEARCH (search));\n\n\t/* This will be NULL if we're offline. Search from cache. */\n\tif (server == NULL) {\n\t\t/* Chain up to parent's method. */\n\t\treturn CAMEL_FOLDER_SEARCH_CLASS (camel_imapx_search_parent_class)->\n\t\t\tbody_contains (sexp, argc, argv, search);\n\t}\n\n\t/* Build the IMAP search criteria. */\n\n\tcriteria = g_string_sized_new (128);\n\n\tif (search->current != NULL) {\n\t\tconst gchar *uid;\n\n\t\t/* Limit the search to a single UID. */\n\t\tuid = camel_message_info_uid (search->current);\n\t\tg_string_append_printf (criteria, \"UID %s\", uid);\n\t}\n\n\tfor (ii = 0; ii < argc; ii++) {\n\t\tstruct _camel_search_words *words;\n\t\tconst guchar *term;\n\n\t\tif (argv[ii]->type != CAMEL_SEXP_RES_STRING)\n\t\t\tcontinue;\n\n\t\t/* Handle multiple search words within a single term. */\n\t\tterm = (const guchar *) argv[ii]->value.string;\n\t\twords = camel_search_words_split (term);\n\n\t\tfor (jj = 0; jj < words->len; jj++) {\n\t\t\tgchar *cp;\n\n\t\t\tif (criteria->len > 0)\n\t\t\t\tg_string_append_c (criteria, ' ');\n\n\t\t\tg_string_append (criteria, \"BODY \\\"\");\n\n\t\t\tcp = words->words[jj]->word;\n\t\t\tfor (; *cp != '\\0'; cp++) {\n\t\t\t\tif (*cp == '\\\\' || *cp == '\"')\n\t\t\t\t\tg_string_append_c (criteria, '\\\\');\n\t\t\t\tg_string_append_c (criteria, *cp);\n\t\t\t}\n\n\t\t\tg_string_append_c (criteria, '\"');\n\t\t}\n\t}\n\n\tresult = imapx_search_process_criteria (sexp, search, server, criteria, G_STRFUNC);\n\n\tg_string_free (criteria, TRUE);\n\tg_object_unref (server);\n\n\treturn result;\n}", "label": 0, "cwe": null, "length": 644 }, { "index": 1308, "code": "gst_base_parse_handle_and_push_frame (GstBaseParse * parse,\n GstBaseParseFrame * frame)\n{\n gint64 offset;\n GstBuffer *buffer;\n\n g_return_val_if_fail (frame != NULL, GST_FLOW_ERROR);\n\n buffer = frame->buffer;\n offset = frame->offset;\n\n /* check if subclass/format can provide ts.\n * If so, that allows and enables extra seek and duration determining options */\n if (G_UNLIKELY (parse->priv->first_frame_offset < 0)) {\n if (GST_BUFFER_PTS_IS_VALID (buffer) && parse->priv->has_timing_info\n && parse->priv->pad_mode == GST_PAD_MODE_PULL) {\n parse->priv->first_frame_offset = offset;\n parse->priv->first_frame_pts = GST_BUFFER_PTS (buffer);\n parse->priv->first_frame_dts = GST_BUFFER_DTS (buffer);\n GST_DEBUG_OBJECT (parse, \"subclass provided dts %\" GST_TIME_FORMAT\n \", pts %\" GST_TIME_FORMAT \" for first frame at offset %\"\n G_GINT64_FORMAT, GST_TIME_ARGS (parse->priv->first_frame_dts),\n GST_TIME_ARGS (parse->priv->first_frame_pts),\n parse->priv->first_frame_offset);\n if (!GST_CLOCK_TIME_IS_VALID (parse->priv->duration)) {\n gint64 off;\n GstClockTime last_ts = G_MAXINT64;\n\n GST_DEBUG_OBJECT (parse, \"no duration; trying scan to determine\");\n gst_base_parse_locate_time (parse, &last_ts, &off);\n if (GST_CLOCK_TIME_IS_VALID (last_ts))\n gst_base_parse_set_duration (parse, GST_FORMAT_TIME, last_ts, 0);\n }\n } else {\n /* disable further checks */\n parse->priv->first_frame_offset = 0;\n }\n }\n\n /* track upstream time if provided, not subclass' internal notion of it */\n if (parse->priv->upstream_format == GST_FORMAT_TIME) {\n GST_BUFFER_PTS (frame->buffer) = GST_CLOCK_TIME_NONE;\n GST_BUFFER_DTS (frame->buffer) = GST_CLOCK_TIME_NONE;\n }\n\n /* interpolating and no valid pts yet,\n * start with dts and carry on from there */\n if (parse->priv->infer_ts && parse->priv->pts_interpolate\n && !GST_CLOCK_TIME_IS_VALID (parse->priv->next_pts))\n parse->priv->next_pts = parse->priv->next_dts;\n\n /* again use default handler to add missing metadata;\n * we may have new information on frame properties */\n gst_base_parse_parse_frame (parse, frame);\n\n parse->priv->next_pts = GST_CLOCK_TIME_NONE;\n if (GST_BUFFER_DTS_IS_VALID (buffer) && GST_BUFFER_DURATION_IS_VALID (buffer)) {\n parse->priv->next_dts =\n GST_BUFFER_DTS (buffer) + GST_BUFFER_DURATION (buffer);\n if (parse->priv->pts_interpolate && GST_BUFFER_PTS_IS_VALID (buffer)) {\n GstClockTime next_pts =\n GST_BUFFER_PTS (buffer) + GST_BUFFER_DURATION (buffer);\n if (next_pts >= parse->priv->next_dts)\n parse->priv->next_pts = next_pts;\n }\n } else {\n /* we lost track, do not produce bogus time next time around\n * (probably means parser subclass has given up on parsing as well) */\n GST_DEBUG_OBJECT (parse, \"no next fallback timestamp\");\n parse->priv->next_dts = GST_CLOCK_TIME_NONE;\n }\n\n if (parse->priv->upstream_seekable && parse->priv->exact_position &&\n GST_BUFFER_PTS_IS_VALID (buffer))\n gst_base_parse_add_index_entry (parse, offset,\n GST_BUFFER_PTS (buffer),\n !GST_BUFFER_FLAG_IS_SET (buffer, GST_BUFFER_FLAG_DELTA_UNIT), FALSE);\n\n /* All OK, push queued frames if there are any */\n if (G_UNLIKELY (!g_queue_is_empty (&parse->priv->queued_frames))) {\n GstBaseParseFrame *queued_frame;\n\n while ((queued_frame = g_queue_pop_head (&parse->priv->queued_frames))) {\n gst_base_parse_push_frame (parse, queued_frame);\n gst_base_parse_frame_free (queued_frame);\n }\n }\n\n return gst_base_parse_push_frame (parse, frame);\n}", "label": 0, "cwe": null, "length": 920 }, { "index": 414158, "code": "synth_stars_to_frame(struct ccd_frame * fr, struct wcs *wcs, GList *sl)\n{\n\tfloat *psf;\n\tint pw, ph, xc, yc;\n\tdouble vol;\n\tdouble x, y;\n\tstruct cat_star *cats;\n\tint n = 0;\n\n\tg_return_val_if_fail(fr != NULL, 0);\n\tg_return_val_if_fail(wcs != NULL, 0);\n\n\tph = pw = 10 * P_INT(SYNTH_OVSAMPLE) * P_DBL(SYNTH_FWHM);\n\tyc = xc = pw / 2;\n\n\tpsf = malloc(pw * ph * sizeof(float));\n\tif (psf == NULL)\n\t\treturn 0;\n\n\tswitch(P_INT(SYNTH_PROFILE)) {\n\tcase PAR_SYNTH_GAUSSIAN:\n\t\tvol = create_gaussian_psf(psf, pw, ph, xc, yc, 0.4246 * \n\t\t\t\t\t P_DBL(SYNTH_FWHM) * P_INT(SYNTH_OVSAMPLE));\n\t\tbreak;\n\tcase PAR_SYNTH_MOFFAT:\n\t\tvol = create_moffat_psf(psf, pw, ph, xc, yc, \n\t\t\t\t\tP_DBL(SYNTH_FWHM) * P_INT(SYNTH_OVSAMPLE),\n\t\t\t\t\tP_DBL(SYNTH_MOFFAT_BETA));\n\t\tbreak;\n\tdefault:\n\t\terr_printf(\"unknown star profile %d\\n\", P_INT(SYNTH_PROFILE));\n\t\treturn 0;\n\t}\n\n\td3_printf(\"vol is %.3g pw %d ph %d\\n\", vol, pw, ph);\n\n\tfor (; sl != NULL; sl = sl->next) {\n\t\tdouble mag;\n\t\tdouble vv, v;\n\t\tdouble flux;\n\t\tcats = CAT_STAR(sl->data);\n\t\tcats_xypix(wcs, cats, &x, &y);\n\t\tcats->flags |= INFO_POS;\n\t\tcats->pos[POS_X] = x;\n\t\tcats->pos[POS_Y] = y;\n\t\tcats->pos[POS_DX] = 0.0;\n\t\tcats->pos[POS_DY] = 0.0;\n\t\tcats->pos[POS_XERR] = 0.0;\n\t\tcats->pos[POS_YERR] = 0.0;\n\t\t\n\t\tif (get_band_by_name(cats->smags, P_STR(AP_IBAND_NAME),\n\t\t\t\t &mag, NULL))\n\t\t\tmag = cats->mag;\n\t\tflux = absmag_to_flux(mag - P_DBL(SYNTH_ZP));\n\t\tvv = v = add_psf_to_frame(fr, psf, pw, ph, xc, yc, \n\t\t\t\t x, y, flux / vol,\n\t\t\t\t P_INT(SYNTH_OVSAMPLE));\n\t\tif (vv == 0)\n\t\t\tcontinue;\n/*\n\t\twhile (v > 0 && (flux - vv > flux / 10000.0)) {\n\t\t\tv = add_psf_to_frame(fr, psf, pw, ph, xc, yc, \n\t\t\t\t\t x, y, (flux - vv) / vol,\n\t\t\t\t\t P_INT(SYNTH_OVSAMPLE));\n\t\t\tvv += v;\n\t\t}\n*/\n\t\tn++;\n\t}\n\treturn n;\n}", "label": 0, "cwe": null, "length": 680 }, { "index": 231545, "code": "tridiagonal (float afDiag[3], float afSubDiag[3]) {\n // Householder reduction T = Q^t M Q\n // Input:\n // mat, symmetric 3x3 matrix M\n // Output:\n // mat, orthogonal matrix Q\n // diag, diagonal entries of T\n // subd, subdiagonal entries of T (T is symmetric)\n\n float fA = elt[0][0];\n float fB = elt[0][1];\n float fC = elt[0][2];\n float fD = elt[1][1];\n float fE = elt[1][2];\n float fF = elt[2][2];\n\n afDiag[0] = fA;\n afSubDiag[2] = 0.0;\n\n if ( G3D::abs(fC) >= EPSILON ) {\n float fLength = sqrt(fB * fB + fC * fC);\n float fInvLength = 1.0 / fLength;\n fB *= fInvLength;\n fC *= fInvLength;\n float fQ = 2.0 * fB * fE + fC * (fF - fD);\n afDiag[1] = fD + fC * fQ;\n afDiag[2] = fF - fC * fQ;\n afSubDiag[0] = fLength;\n afSubDiag[1] = fE - fB * fQ;\n elt[0][0] = 1.0;\n elt[0][1] = 0.0;\n elt[0][2] = 0.0;\n elt[1][0] = 0.0;\n elt[1][1] = fB;\n elt[1][2] = fC;\n elt[2][0] = 0.0;\n elt[2][1] = fC;\n elt[2][2] = -fB;\n } else {\n afDiag[1] = fD;\n afDiag[2] = fF;\n afSubDiag[0] = fB;\n afSubDiag[1] = fE;\n elt[0][0] = 1.0;\n elt[0][1] = 0.0;\n elt[0][2] = 0.0;\n elt[1][0] = 0.0;\n elt[1][1] = 1.0;\n elt[1][2] = 0.0;\n elt[2][0] = 0.0;\n elt[2][1] = 0.0;\n elt[2][2] = 1.0;\n }\n}", "label": 0, "cwe": null, "length": 618 }, { "index": 883480, "code": "zisofs_detect_magic(struct archive_write *a, const void *buff, size_t s)\n{\n\tstruct iso9660 *iso9660 = a->format_data;\n\tstruct isofile *file = iso9660->cur_file;\n\tconst unsigned char *p, *endp;\n\tconst unsigned char *magic_buff;\n\tuint32_t uncompressed_size;\n\tunsigned char header_size;\n\tunsigned char log2_bs;\n\tsize_t ceil, doff;\n\tuint32_t bst, bed;\n\tint magic_max;\n\tint64_t entry_size;\n\n\tentry_size = archive_entry_size(file->entry);\n\tif (sizeof(iso9660->zisofs.magic_buffer) > entry_size)\n\t\tmagic_max = entry_size;\n\telse\n\t\tmagic_max = sizeof(iso9660->zisofs.magic_buffer);\n\n\tif (iso9660->zisofs.magic_cnt == 0 && s >= (size_t)magic_max)\n\t\t/* It's unnecessary we copy buffer. */\n\t\tmagic_buff = buff;\n\telse {\n\t\tif (iso9660->zisofs.magic_cnt < magic_max) {\n\t\t\tsize_t l;\n\n\t\t\tl = sizeof(iso9660->zisofs.magic_buffer)\n\t\t\t - iso9660->zisofs.magic_cnt;\n\t\t\tif (l > s)\n\t\t\t\tl = s;\n\t\t\tmemcpy(iso9660->zisofs.magic_buffer\n\t\t\t + iso9660->zisofs.magic_cnt, buff, l);\n\t\t\tiso9660->zisofs.magic_cnt += l;\n\t\t\tif (iso9660->zisofs.magic_cnt < magic_max)\n\t\t\t\treturn;\n\t\t}\n\t\tmagic_buff = iso9660->zisofs.magic_buffer;\n\t}\n\tiso9660->zisofs.detect_magic = 0;\n\tp = magic_buff;\n\n\t/* Check the magic code of zisofs. */\n\tif (memcmp(p, zisofs_magic, sizeof(zisofs_magic)) != 0)\n\t\t/* This is not zisofs file which made by mkzftree. */\n\t\treturn;\n\tp += sizeof(zisofs_magic);\n\n\t/* Read a zisofs header. */\n\tuncompressed_size = archive_le32dec(p);\n\theader_size = p[4];\n\tlog2_bs = p[5];\n\tif (uncompressed_size < 24 || header_size != 4 ||\n\t log2_bs > 30 || log2_bs < 7)\n\t\treturn;/* Invalid or not supported header. */\n\n\t/* Calculate a size of Block Pointers of zisofs. */\n\tceil = (uncompressed_size +\n\t (ARCHIVE_LITERAL_LL(1) << log2_bs) -1) >> log2_bs;\n\tdoff = (ceil + 1) * 4 + 16;\n\tif (entry_size < doff)\n\t\treturn;/* Invalid data. */\n\n\t/* Check every Block Pointer has valid value. */\n\tp = magic_buff + 16;\n\tendp = magic_buff + magic_max;\n\twhile (ceil && p + 8 <= endp) {\n\t\tbst = archive_le32dec(p);\n\t\tif (bst != doff)\n\t\t\treturn;/* Invalid data. */\n\t\tp += 4;\n\t\tbed = archive_le32dec(p);\n\t\tif (bed < bst || bed > entry_size)\n\t\t\treturn;/* Invalid data. */\n\t\tdoff += bed - bst;\n\t\tceil--;\n\t}\n\n\tfile->zisofs.uncompressed_size = uncompressed_size;\n\tfile->zisofs.header_size = header_size;\n\tfile->zisofs.log2_bs = log2_bs;\n\n\t/* Disable making a zisofs image. */\n\tiso9660->zisofs.making = 0;\n}", "label": 0, "cwe": null, "length": 758 }, { "index": 654718, "code": "generateCertificateRequest(SECKEYPrivateKey* privateKey, SECKEYPublicKey* pubKey, char* subjectName)\n{\n\n SECItem *der = NULL;\n SECItem *result = NULL;\n CERTName* certName = NULL;\n CERTSubjectPublicKeyInfo* keyInfo = NULL;\n CERTCertificateRequest* request = NULL;\n PRArenaPool *arena = NULL;\n PRBool error = PR_FALSE;\n char *line;\n char *sSignAlgo = NULL;\n int signAlgo = 0;\n /*DebugBreak();*/\n /* convert subject name(DN) */\n certName = CERT_AsciiToName(subjectName);\n if (!certName) {\n line = getResourceString(DBT_DN_CONVERT_FAIL);\n error = PR_TRUE;\n goto loser;\n }\n\n keyInfo = SECKEY_CreateSubjectPublicKeyInfo(pubKey);\n if (!keyInfo) {\n line = getResourceString(DBT_PUB_KEY_GEN_FAIL);\n error = PR_TRUE;\n goto loser;\n }\n\n \n /* Create certificate request blob */\n request = CERT_CreateCertificateRequest(certName, keyInfo, NULL);\n if (!request) {\n line = getResourceString(DBT_CSR_GEN_FAIL);\n error = PR_TRUE;\n goto loser;\n }\n\n arena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE);\n if (!arena) {\n line = getResourceString(DBT_ALLOCATE_ERROR);\n error = PR_TRUE;\n goto loser;\n }\n\n result = (SECItem*) PORT_ZAlloc(sizeof(SECItem));\n\n /* Encode the result will get a \"request blob\" */\n der = (SECItem *)SEC_ASN1EncodeItem(arena, result, request, SEC_ASN1_GET(CERT_CertificateRequestTemplate));\n\n /* Determine the signing algorithm to use. We default\n * to SHA-1 and support SHA-256, SHA-384, and SHA-512. */\n sSignAlgo = get_cgi_var(\"signingalgo\", NULL, NULL);\n\n if (!sSignAlgo || !PORT_Strcmp(sSignAlgo, \"SHA-1\")) {\n signAlgo = SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION;\n } else if (!PORT_Strcmp(sSignAlgo, \"SHA-256\")) {\n signAlgo = SEC_OID_PKCS1_SHA256_WITH_RSA_ENCRYPTION;\n } else if (!PORT_Strcmp(sSignAlgo, \"SHA-384\")) {\n signAlgo = SEC_OID_PKCS1_SHA384_WITH_RSA_ENCRYPTION;\n } else if (!PORT_Strcmp(sSignAlgo, \"SHA-512\")) {\n signAlgo = SEC_OID_PKCS1_SHA512_WITH_RSA_ENCRYPTION;\n } else {\n /* Unknown algorithm, so just use the default. */\n signAlgo = SEC_OID_PKCS1_SHA1_WITH_RSA_ENCRYPTION;\n }\n\n /* Sign certificate request(the blob) with private key */\n if (SEC_DerSignData(arena, result, der->data, der->len, privateKey, signAlgo) != SECSuccess) {\n rpt_err(GENERAL_FAILURE, \n getResourceString(DBT_INTERNAL_ERROR), \n getResourceString(DBT_CSR_GEN_FAIL), \n NULL);\n }\n\n /* destroy all */\n loser:\n if (privateKey) SECKEY_DestroyPrivateKey(privateKey);\n if (pubKey) SECKEY_DestroyPublicKey(pubKey);\n if (keyInfo) SECKEY_DestroySubjectPublicKeyInfo(keyInfo);\n if (request) CERT_DestroyCertificateRequest(request);\n if (certName) CERT_DestroyName(certName);\n\n /*for debug purpose */\n /*fprintf(stdout, \"%s\\n\", BTOA_ConvertItemToAscii(result));*/\n\n if (error == PR_TRUE) {\n /*{\n char tmpLine[BIG_LINE];\n\n PR_GetErrorText(tmpLine);\n PR_snprintf(line, sizeof(line), \"%d:%s\", PR_GetError(), tmpLine);\n }*/\n\n errorRpt(GENERAL_FAILURE, line);\n }\n\n return result;\n}", "label": 0, "cwe": null, "length": 875 }, { "index": 997871, "code": "Vnoldattrs(int32 vgid)\n{\n CONSTR(FUNC, \"Vnoldattrs\");\n VGROUP *vg;\n vginstance_t *v;\n intn n_old_attrs=0;\n intn ii;\n uint16 *areflist=NULL;\n int32 ret_value = 0;\n\n HEclear();\n if (HAatom_group(vgid) != VGIDGROUP)\n HGOTO_ERROR(DFE_ARGS, FAIL);\n\n /* Get number of old-style attributes */\n n_old_attrs = VSofclass(vgid, _HDF_ATTRIBUTE, 0, 0, NULL);\n\n /* Note: a new attribute is stored in vdata of class _HDF_ATTRIBUTE too, but\n it is only saved in the file as attribute (by tag/ref,) not as an element\n of the vgroup. Hence, vg->nattrs = 1, but vg->nvelt = 0 -BMR Feb, 2011*/\n\n /* Store the ref numbers of old-style attributes into the list\n vg->old_alist, for easy access later by Vattrinfo2 and Vgetattr2 */ \n if (n_old_attrs > 0)\n {\n /* Locate vg's index in vgtab */\n if (NULL == (v = (vginstance_t *)HAatom_object(vgid)))\n HGOTO_ERROR(DFE_VTAB, FAIL);\n vg = v->vg;\n if (vg == NULL)\n HGOTO_ERROR(DFE_BADPTR, FAIL);\n if (vg->otag != DFTAG_VG)\n HGOTO_ERROR(DFE_ARGS,FAIL);\n\n\t/* Establish the list of attribute refs if it is not done so already \n\t or if it is outdated. */\n\n\t/* temporary list of attr refs to pass into VSofclass */\n areflist = (uint16 *) HDmalloc(sizeof(uint16) * n_old_attrs);\n\tif (areflist == NULL)\n\t HGOTO_ERROR(DFE_NOSPACE, FAIL);\n\n\t/* Get ref numbers of old-style attributes belonging to this vg */\n\tn_old_attrs = VSofclass(vgid, _HDF_ATTRIBUTE, 0, (uintn)n_old_attrs, areflist);\n\tif (n_old_attrs == FAIL)\n HGOTO_ERROR(DFE_INTERNAL, FAIL);\n\n\t/* Do nothing when the list exists and is current */\n\tif (vg->old_alist != NULL && vg->noldattrs == n_old_attrs)\n\t{\n\t ret_value = vg->noldattrs;\n\t HGOTO_DONE(vg->noldattrs);\n\t}\n\n\t/* Either list doesn't exist or exists but is not current */\n\telse if (vg->noldattrs != n_old_attrs)\n\t{\n\t /* List is outdated, i.e., more old style attributes had been added\n\t since the list was established, release it */\n\t if (vg->old_alist != NULL)\n\t\tHDfree(vg->old_alist);\n\n\t /* Allocate new list */\n vg->old_alist = (vg_attr_t *)HDmalloc(sizeof(vg_attr_t) * (n_old_attrs));\n\t if (vg->old_alist == NULL)\n\t\tHGOTO_ERROR(DFE_NOSPACE, FAIL);\n\n\t} /* not current */\n\n\t/* Transfer ref nums to the vg_attr_t list for future accesses */\n for (ii = 0; ii < n_old_attrs; ii++)\n\t{\n\t vg->old_alist[ii].aref = areflist[ii];\n\t /* atag is not needed */\n\t}\n\tvg->noldattrs = n_old_attrs; /* record number of old-style attrs */\n\n\tret_value = vg->noldattrs;\n } /* there are some old attributes */\n\ndone:\n if (ret_value == FAIL)\n { /* Error condition cleanup */\n\n } /* end if */\n\n if (areflist != NULL)\n\tHDfree(areflist);\n\n /* Normal function cleanup */\n return ret_value;\n}", "label": 1, "cwe": "CWE-476", "length": 834 }, { "index": 453856, "code": "fffr4r8(float *input, /* I - array of values to be converted */\n long ntodo, /* I - number of elements in the array */\n double scale, /* I - FITS TSCALn or BSCALE value */\n double zero, /* I - FITS TZEROn or BZERO value */\n int nullcheck, /* I - null checking code; 0 = don't check */\n /* 1:set null pixels = nullval */\n /* 2: if null pixel, set nullarray = 1 */\n double nullval, /* I - set null pixels, if nullcheck = 1 */\n char *nullarray, /* I - bad pixel array, if nullcheck = 2 */\n int *anynull, /* O - set to 1 if any pixels are null */\n double *output, /* O - array of converted pixels */\n int *status) /* IO - error status */\n/*\n Copy input to output following reading of the input from a FITS file.\n Check for null values and do datatype conversion and scaling if required.\n The nullcheck code value determines how any null values in the input array\n are treated. A null value is an input pixel that is equal to NaN. If \n nullcheck = 0, then no checking for nulls is performed and any null values\n will be transformed just like any other pixel. If nullcheck = 1, then the\n output pixel will be set = nullval if the corresponding input pixel is null.\n If nullcheck = 2, then if the pixel is null then the corresponding value of\n nullarray will be set to 1; the value of nullarray for non-null pixels \n will = 0. The anynull parameter will be set = 1 if any of the returned\n pixels are null, otherwise anynull will be returned with a value = 0;\n*/\n{\n long ii;\n short *sptr, iret;\n\n if (nullcheck == 0) /* no null checking required */\n {\n if (scale == 1. && zero == 0.) /* no scaling */\n { \n for (ii = 0; ii < ntodo; ii++)\n output[ii] = (double) input[ii]; /* copy input to output */\n }\n else /* must scale the data */\n {\n for (ii = 0; ii < ntodo; ii++)\n {\n output[ii] = input[ii] * scale + zero;\n }\n }\n }\n else /* must check for null values */\n {\n sptr = (short *) input;\n\n#if BYTESWAPPED && MACHINE != VAXVMS && MACHINE != ALPHAVMS\n sptr++; /* point to MSBs */\n#endif\n if (scale == 1. && zero == 0.) /* no scaling */\n { \n for (ii = 0; ii < ntodo; ii++, sptr += 2)\n {\n if (0 != (iret = fnan(*sptr) ) ) /* test for NaN or underflow */\n {\n if (iret == 1) /* is it a NaN? */\n {\n *anynull = 1;\n if (nullcheck == 1)\n output[ii] = nullval;\n else\n nullarray[ii] = 1;\n }\n else /* it's an underflow */\n output[ii] = 0;\n }\n else\n output[ii] = (double) input[ii];\n }\n }\n else /* must scale the data */\n {\n for (ii = 0; ii < ntodo; ii++, sptr += 2)\n {\n if (0 != (iret = fnan(*sptr) ) ) /* test for NaN or underflow */\n {\n if (iret == 1) /* is it a NaN? */\n { \n *anynull = 1;\n if (nullcheck == 1)\n output[ii] = nullval;\n else\n nullarray[ii] = 1;\n }\n else /* it's an underflow */\n output[ii] = zero;\n }\n else\n output[ii] = input[ii] * scale + zero;\n }\n }\n }\n return(*status);\n}", "label": 1, "cwe": "CWE-476", "length": 959 }, { "index": 774746, "code": "gst_mxf_demux_handle_random_index_pack (GstMXFDemux * demux, const MXFUL * key,\n GstBuffer * buffer)\n{\n guint i;\n GList *l;\n GstMapInfo map;\n gboolean ret;\n\n GST_DEBUG_OBJECT (demux,\n \"Handling random index pack of size %\" G_GSIZE_FORMAT \" at offset %\"\n G_GUINT64_FORMAT, gst_buffer_get_size (buffer), demux->offset);\n\n if (demux->random_index_pack) {\n GST_DEBUG_OBJECT (demux, \"Already parsed random index pack\");\n return GST_FLOW_OK;\n }\n\n gst_buffer_map (buffer, &map, GST_MAP_READ);\n ret =\n mxf_random_index_pack_parse (key, map.data, map.size,\n &demux->random_index_pack);\n gst_buffer_unmap (buffer, &map);\n\n if (!ret) {\n GST_ERROR_OBJECT (demux, \"Parsing random index pack failed\");\n return GST_FLOW_ERROR;\n }\n\n for (i = 0; i < demux->random_index_pack->len; i++) {\n GstMXFDemuxPartition *p = NULL;\n MXFRandomIndexPackEntry *e =\n &g_array_index (demux->random_index_pack, MXFRandomIndexPackEntry, i);\n\n if (e->offset < demux->run_in) {\n GST_ERROR_OBJECT (demux, \"Invalid random index pack entry\");\n return GST_FLOW_ERROR;\n }\n\n for (l = demux->partitions; l; l = l->next) {\n GstMXFDemuxPartition *tmp = l->data;\n\n if (tmp->partition.this_partition + demux->run_in == e->offset) {\n p = tmp;\n break;\n }\n }\n\n if (!p) {\n p = g_new0 (GstMXFDemuxPartition, 1);\n p->partition.this_partition = e->offset - demux->run_in;\n p->partition.body_sid = e->body_sid;\n demux->partitions =\n g_list_insert_sorted (demux->partitions, p,\n (GCompareFunc) gst_mxf_demux_partition_compare);\n }\n }\n\n for (l = demux->partitions; l; l = l->next) {\n GstMXFDemuxPartition *a, *b;\n\n if (l->next == NULL)\n break;\n\n a = l->data;\n b = l->next->data;\n\n b->partition.prev_partition = a->partition.this_partition;\n }\n\n return GST_FLOW_OK;\n}", "label": 0, "cwe": null, "length": 559 }, { "index": 852416, "code": "ira_build (void)\n{\n bool loops_p;\n\n df_analyze ();\n initiate_cost_vectors ();\n initiate_allocnos ();\n initiate_copies ();\n create_loop_tree_nodes ();\n form_loop_tree ();\n create_allocnos ();\n ira_costs ();\n create_allocno_objects ();\n ira_create_allocno_live_ranges ();\n remove_unnecessary_regions (false);\n ira_compress_allocno_live_ranges ();\n update_bad_spill_attribute ();\n loops_p = more_one_region_p ();\n if (loops_p)\n {\n propagate_allocno_info ();\n create_caps ();\n }\n ira_tune_allocno_costs ();\n#ifdef ENABLE_IRA_CHECKING\n check_allocno_creation ();\n#endif\n setup_min_max_allocno_live_range_point ();\n sort_conflict_id_map ();\n setup_min_max_conflict_allocno_ids ();\n ira_build_conflicts ();\n update_conflict_hard_reg_costs ();\n if (! ira_conflicts_p)\n {\n ira_allocno_t a;\n ira_allocno_iterator ai;\n\n /* Remove all regions but root one. */\n if (loops_p)\n\t{\n\t remove_unnecessary_regions (true);\n\t loops_p = false;\n\t}\n /* We don't save hard registers around calls for fast allocation\n\t -- add caller clobbered registers as conflicting ones to\n\t allocno crossing calls. */\n FOR_EACH_ALLOCNO (a, ai)\n\tif (ALLOCNO_CALLS_CROSSED_NUM (a) != 0)\n\t ior_hard_reg_conflicts (a, &call_used_reg_set);\n }\n if (internal_flag_ira_verbose > 2 && ira_dump_file != NULL)\n print_copies (ira_dump_file);\n if (internal_flag_ira_verbose > 0 && ira_dump_file != NULL)\n {\n int n, nr, nr_big;\n ira_allocno_t a;\n live_range_t r;\n ira_allocno_iterator ai;\n\n n = 0;\n nr = 0;\n nr_big = 0;\n FOR_EACH_ALLOCNO (a, ai)\n\t{\n\t int j, nobj = ALLOCNO_NUM_OBJECTS (a);\n\n\t if (nobj > 1)\n\t nr_big++;\n\t for (j = 0; j < nobj; j++)\n\t {\n\t ira_object_t obj = ALLOCNO_OBJECT (a, j);\n\t n += OBJECT_NUM_CONFLICTS (obj);\n\t for (r = OBJECT_LIVE_RANGES (obj); r != NULL; r = r->next)\n\t\tnr++;\n\t }\n\t}\n fprintf (ira_dump_file, \" regions=%d, blocks=%d, points=%d\\n\",\n\t current_loops == NULL ? 1 : number_of_loops (),\n\t n_basic_blocks, ira_max_point);\n fprintf (ira_dump_file,\n\t \" allocnos=%d (big %d), copies=%d, conflicts=%d, ranges=%d\\n\",\n\t ira_allocnos_num, nr_big, ira_copies_num, n, nr);\n }\n return loops_p;\n}", "label": 1, "cwe": "CWE-other", "length": 653 }, { "index": 99875, "code": "on_pe(lame_global_flags const *gfp, FLOAT pe[][2],\n int targ_bits[2], int mean_bits, int gr, int cbr)\n{\n lame_internal_flags const *const gfc = gfp->internal_flags;\n int extra_bits, tbits, bits;\n int add_bits[2];\n int max_bits; /* maximum allowed bits for this granule */\n int ch;\n\n /* allocate targ_bits for granule */\n ResvMaxBits(gfp, mean_bits, &tbits, &extra_bits, cbr);\n max_bits = tbits + extra_bits;\n if (max_bits > MAX_BITS_PER_GRANULE) /* hard limit per granule */\n max_bits = MAX_BITS_PER_GRANULE;\n\n for (bits = 0, ch = 0; ch < gfc->channels_out; ++ch) {\n /******************************************************************\n * allocate bits for each channel \n ******************************************************************/\n targ_bits[ch] = Min(MAX_BITS_PER_CHANNEL, tbits / gfc->channels_out);\n\n add_bits[ch] = targ_bits[ch] * pe[gr][ch] / 700.0 - targ_bits[ch];\n\n /* at most increase bits by 1.5*average */\n if (add_bits[ch] > mean_bits * 3 / 4)\n add_bits[ch] = mean_bits * 3 / 4;\n if (add_bits[ch] < 0)\n add_bits[ch] = 0;\n\n if (add_bits[ch] + targ_bits[ch] > MAX_BITS_PER_CHANNEL)\n add_bits[ch] = Max(0, MAX_BITS_PER_CHANNEL - targ_bits[ch]);\n\n bits += add_bits[ch];\n }\n if (bits > extra_bits) {\n for (ch = 0; ch < gfc->channels_out; ++ch) {\n add_bits[ch] = extra_bits * add_bits[ch] / bits;\n }\n }\n\n for (ch = 0; ch < gfc->channels_out; ++ch) {\n targ_bits[ch] += add_bits[ch];\n extra_bits -= add_bits[ch];\n }\n\n for (bits = 0, ch = 0; ch < gfc->channels_out; ++ch) {\n bits += targ_bits[ch];\n }\n if (bits > MAX_BITS_PER_GRANULE) {\n int sum = 0;\n for (ch = 0; ch < gfc->channels_out; ++ch) {\n targ_bits[ch] *= MAX_BITS_PER_GRANULE;\n targ_bits[ch] /= bits;\n sum += targ_bits[ch];\n }\n assert(sum <= MAX_BITS_PER_GRANULE);\n }\n\n return max_bits;\n}", "label": 1, "cwe": "CWE-other", "length": 576 }, { "index": 91080, "code": "FTransformWHT(const int16_t* in, int16_t* out) {\n int32_t tmp[16];\n int i;\n for (i = 0; i < 4; ++i, in += 64) {\n const int a0 = (in[0 * 16] + in[2 * 16]);\n const int a1 = (in[1 * 16] + in[3 * 16]);\n const int a2 = (in[1 * 16] - in[3 * 16]);\n const int a3 = (in[0 * 16] - in[2 * 16]);\n tmp[0 + i * 4] = a0 + a1;\n tmp[1 + i * 4] = a3 + a2;\n tmp[2 + i * 4] = a3 - a2;\n tmp[3 + i * 4] = a0 - a1;\n }\n {\n const __m128i src0 = _mm_loadu_si128((__m128i*)&tmp[0]);\n const __m128i src1 = _mm_loadu_si128((__m128i*)&tmp[4]);\n const __m128i src2 = _mm_loadu_si128((__m128i*)&tmp[8]);\n const __m128i src3 = _mm_loadu_si128((__m128i*)&tmp[12]);\n const __m128i a0 = _mm_add_epi32(src0, src2);\n const __m128i a1 = _mm_add_epi32(src1, src3);\n const __m128i a2 = _mm_sub_epi32(src1, src3);\n const __m128i a3 = _mm_sub_epi32(src0, src2);\n const __m128i b0 = _mm_srai_epi32(_mm_add_epi32(a0, a1), 1);\n const __m128i b1 = _mm_srai_epi32(_mm_add_epi32(a3, a2), 1);\n const __m128i b2 = _mm_srai_epi32(_mm_sub_epi32(a3, a2), 1);\n const __m128i b3 = _mm_srai_epi32(_mm_sub_epi32(a0, a1), 1);\n const __m128i out0 = _mm_packs_epi32(b0, b1);\n const __m128i out1 = _mm_packs_epi32(b2, b3);\n _mm_storeu_si128((__m128i*)&out[0], out0);\n _mm_storeu_si128((__m128i*)&out[8], out1);\n }\n}", "label": 0, "cwe": null, "length": 588 }, { "index": 311731, "code": "make_raw_data_56k(struct BCState *bcs) {\n// this make_raw is for 56k\n\tregister u_int i, s_cnt = 0;\n\tregister u_char j;\n\tregister u_char val;\n\tregister u_char s_one = 0;\n\tregister u_char s_val = 0;\n\tregister u_char bitcnt = 0;\n\tu_int fcs;\n\n\tif (!bcs->tx_skb) {\n\t\tdebugl1(bcs->cs, \"tiger make_raw_56k: NULL skb\");\n\t\treturn (1);\n\t}\n\tval = HDLC_FLAG_VALUE;\n\tfor (j = 0; j < 8; j++) {\n\t\tbitcnt++;\n\t\ts_val >>= 1;\n\t\tif (val & 1)\n\t\t\ts_val |= 0x80;\n\t\telse\n\t\t\ts_val &= 0x7f;\n\t\tif (bitcnt == 7) {\n\t\t\ts_val >>= 1;\n\t\t\ts_val |= 0x80;\n\t\t\tbcs->hw.tiger.sendbuf[s_cnt++] = s_val;\n\t\t\tbitcnt = 0;\n\t\t}\n\t\tval >>= 1;\n\t};\n\tfcs = PPP_INITFCS;\n\tfor (i = 0; i < bcs->tx_skb->len; i++) {\n\t\tval = bcs->tx_skb->data[i];\n\t\tfcs = PPP_FCS(fcs, val);\n\t\tMAKE_RAW_BYTE_56K;\n\t}\n\tfcs ^= 0xffff;\n\tval = fcs & 0xff;\n\tMAKE_RAW_BYTE_56K;\n\tval = (fcs >> 8) & 0xff;\n\tMAKE_RAW_BYTE_56K;\n\tval = HDLC_FLAG_VALUE;\n\tfor (j = 0; j < 8; j++) {\n\t\tbitcnt++;\n\t\ts_val >>= 1;\n\t\tif (val & 1)\n\t\t\ts_val |= 0x80;\n\t\telse\n\t\t\ts_val &= 0x7f;\n\t\tif (bitcnt == 7) {\n\t\t\ts_val >>= 1;\n\t\t\ts_val |= 0x80;\n\t\t\tbcs->hw.tiger.sendbuf[s_cnt++] = s_val;\n\t\t\tbitcnt = 0;\n\t\t}\n\t\tval >>= 1;\n\t}\n\tif (bcs->cs->debug & L1_DEB_HSCX)\n\t\tdebugl1(bcs->cs, \"tiger make_raw_56k: in %u out %d.%d\",\n\t\t\tbcs->tx_skb->len, s_cnt, bitcnt);\n\tif (bitcnt) {\n\t\twhile (8 > bitcnt++) {\n\t\t\ts_val >>= 1;\n\t\t\ts_val |= 0x80;\n\t\t}\n\t\tbcs->hw.tiger.sendbuf[s_cnt++] = s_val;\n\t\tbcs->hw.tiger.sendbuf[s_cnt++] = 0xff;\t// NJ<->NJ thoughput bug fix\n\t}\n\tbcs->hw.tiger.sendcnt = s_cnt;\n\tbcs->tx_cnt -= bcs->tx_skb->len;\n\tbcs->hw.tiger.sp = bcs->hw.tiger.sendbuf;\n\treturn (0);\n}", "label": 0, "cwe": null, "length": 657 }, { "index": 794224, "code": "normalizzaStima( float avail, uint32 from, uint32 to ) {\n\t// Parte necessaria per il debug\n\t// calcolo il coefficiente di normalizzazione\n\t// int kRTK = theApp->rm->kadRepublishTimeK;\n\tint kRTK = theApp->get_kadRepublishTimeK();\n\n \tfloat norm_factor = (float) 1.0;\n\n\t// if (avail > theApp->rm->kadFreshGuess_NoNorm) {\n\tif (avail > theApp->get_kadFreshGuess_NoNorm()) {\n// Mr Hyde Patch BEGIN\t\n\t\tif (kRTK == 0) {\n\t\t\tAddDebugLogLineN(logKadSearch, wxString::Format(wxT(\"DENOMINATORE kRTK ZERO\")));\n\t\t\treturn 0.0; \n\t\t}\n// Mr Hyde Patch END\t\n\t\tnorm_factor = (to - from)/kRTK;\n// Mr Hyde Patch BEGIN\t\n\t\tif (avail == 0.0) {\n\t\t\tAddDebugLogLineN(logKadSearch, wxString::Format(wxT(\"DENOMINATORE avail ZERO\")));\n\t\t\treturn 0.0; \n\t\t}\n\t\tif ( norm_factor > 1-1/avail ) {\n\t\t\tnorm_factor = (float) 1.0;\n\t\t}\n// Mr Hyde Patch END\t\n\n\t\t// norm_factor = ( norm_factor < theApp->rm->kadFreshGuess_Tol ? theApp->rm->kadFreshGuess_Tol : norm_factor );\n\t\tnorm_factor = ( norm_factor < theApp->get_kadFreshGuess_Tol() ? theApp->get_kadFreshGuess_Tol() : norm_factor );\n\n\t\t// We have a good number of publishes, but not high.\n\t\t// Low normalization is still suggested.\n\t\t// if ( avail < theApp->rm->kadFreshGuess_LowNorm && norm_factor > avail / theApp->rm->kadFreshGuess_LowNorm ) {\n\t\tif ( (avail < theApp->get_kadFreshGuess_LowNorm()) && (norm_factor > (avail / theApp->get_kadFreshGuess_LowNorm())) ) {\n\t\t\t// norm_factor /= powf( (avail/theApp->rm->kadFreshGuess_LowNorm), 0.5f );\n\t\t\tnorm_factor /= powf( (avail/theApp->get_kadFreshGuess_LowNorm()), 0.5f );\n\t\t}\n\t}\n\n\tif ( avail > 2.0f ) {\n\t\t// avail /= powf( norm_factor, theApp->rm->kadFreshGuess_Weight );\n\t\tavail /= powf( norm_factor, theApp->get_kadFreshGuess_Weight() );\n\t}\n\n return avail;\n}", "label": 0, "cwe": null, "length": 580 }, { "index": 568226, "code": "ufs1_read_inode(struct inode *inode, struct ufs_inode *ufs_inode)\n{\n\tstruct ufs_inode_info *ufsi = UFS_I(inode);\n\tstruct super_block *sb = inode->i_sb;\n\tumode_t mode;\n\n\t/*\n\t * Copy data to the in-core inode.\n\t */\n\tinode->i_mode = mode = fs16_to_cpu(sb, ufs_inode->ui_mode);\n\tset_nlink(inode, fs16_to_cpu(sb, ufs_inode->ui_nlink));\n\tif (inode->i_nlink == 0) {\n\t\tufs_error (sb, \"ufs_read_inode\", \"inode %lu has zero nlink\\n\", inode->i_ino);\n\t\treturn -1;\n\t}\n\n\t/*\n\t * Linux now has 32-bit uid and gid, so we can support EFT.\n\t */\n\ti_uid_write(inode, ufs_get_inode_uid(sb, ufs_inode));\n\ti_gid_write(inode, ufs_get_inode_gid(sb, ufs_inode));\n\n\tinode->i_size = fs64_to_cpu(sb, ufs_inode->ui_size);\n\tinode->i_atime.tv_sec = fs32_to_cpu(sb, ufs_inode->ui_atime.tv_sec);\n\tinode->i_ctime.tv_sec = fs32_to_cpu(sb, ufs_inode->ui_ctime.tv_sec);\n\tinode->i_mtime.tv_sec = fs32_to_cpu(sb, ufs_inode->ui_mtime.tv_sec);\n\tinode->i_mtime.tv_nsec = 0;\n\tinode->i_atime.tv_nsec = 0;\n\tinode->i_ctime.tv_nsec = 0;\n\tinode->i_blocks = fs32_to_cpu(sb, ufs_inode->ui_blocks);\n\tinode->i_generation = fs32_to_cpu(sb, ufs_inode->ui_gen);\n\tufsi->i_flags = fs32_to_cpu(sb, ufs_inode->ui_flags);\n\tufsi->i_shadow = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_shadow);\n\tufsi->i_oeftflag = fs32_to_cpu(sb, ufs_inode->ui_u3.ui_sun.ui_oeftflag);\n\n\n\tif (S_ISCHR(mode) || S_ISBLK(mode) || inode->i_blocks) {\n\t\tmemcpy(ufsi->i_u1.i_data, &ufs_inode->ui_u2.ui_addr,\n\t\t sizeof(ufs_inode->ui_u2.ui_addr));\n\t} else {\n\t\tmemcpy(ufsi->i_u1.i_symlink, ufs_inode->ui_u2.ui_symlink,\n\t\t sizeof(ufs_inode->ui_u2.ui_symlink) - 1);\n\t\tufsi->i_u1.i_symlink[sizeof(ufs_inode->ui_u2.ui_symlink) - 1] = 0;\n\t}\n\treturn 0;\n}", "label": 1, "cwe": "CWE-120", "length": 585 }, { "index": 666880, "code": "getinfo_slist(struct SessionHandle *data, CURLINFO info,\n struct curl_slist **param_slistp)\n{\n union {\n struct curl_certinfo * to_certinfo;\n struct curl_slist * to_slist;\n } ptr;\n\n switch(info) {\n case CURLINFO_SSL_ENGINES:\n *param_slistp = Curl_ssl_engines_list(data);\n break;\n case CURLINFO_COOKIELIST:\n *param_slistp = Curl_cookie_list(data);\n break;\n case CURLINFO_CERTINFO:\n /* Return the a pointer to the certinfo struct. Not really an slist\n pointer but we can pretend it is here */\n ptr.to_certinfo = &data->info.certs;\n *param_slistp = ptr.to_slist;\n break;\n case CURLINFO_TLS_SESSION:\n {\n struct curl_tlssessioninfo **tsip = (struct curl_tlssessioninfo **)\n param_slistp;\n struct curl_tlssessioninfo *tsi = &data->tsi;\n struct connectdata *conn = data->easy_conn;\n unsigned int sockindex = 0;\n void *internals = NULL;\n\n *tsip = tsi;\n tsi->backend = CURLSSLBACKEND_NONE;\n tsi->internals = NULL;\n\n if(!conn)\n break;\n\n /* Find the active (\"in use\") SSL connection, if any */\n while((sockindex < sizeof(conn->ssl) / sizeof(conn->ssl[0])) &&\n (!conn->ssl[sockindex].use))\n sockindex++;\n\n if(sockindex == sizeof(conn->ssl) / sizeof(conn->ssl[0]))\n break; /* no SSL session found */\n\n /* Return the TLS session information from the relevant backend */\n#ifdef USE_SSLEAY\n internals = conn->ssl[sockindex].ctx;\n#endif\n#ifdef USE_GNUTLS\n internals = conn->ssl[sockindex].session;\n#endif\n#ifdef USE_NSS\n internals = conn->ssl[sockindex].handle;\n#endif\n#ifdef USE_GSKIT\n internals = conn->ssl[sockindex].handle;\n#endif\n if(internals) {\n tsi->backend = Curl_ssl_backend();\n tsi->internals = internals;\n }\n /* NOTE: For other SSL backends, it is not immediately clear what data\n to return from 'struct ssl_connect_data'; thus, for now we keep the\n backend as CURLSSLBACKEND_NONE in those cases, which should be\n interpreted as \"not supported\" */\n }\n break;\n default:\n return CURLE_BAD_FUNCTION_ARGUMENT;\n }\n return CURLE_OK;\n}", "label": 0, "cwe": null, "length": 572 }, { "index": 25076, "code": "zxbus_close(zxid_conf* cf, struct zxid_bus_url* bu)\n{\n int len;\n char buf[1024];\n struct stomp_hdr stomp;\n\n D(\"closing(%x) bu_%p\", bu->fd, bu);\n \n if (!bu || !bu->s || !bu->s[0] || !bu->fd)\n return 0; /* No bus_url configured means audit bus reporting is disabled. */\n\n /* *** implement intelligent lbfo algo */\n \n D(\"disconnecting(%p) bu->s(%s)\", bu, bu->s);\n\n len = snprintf(buf, sizeof(buf), \"DISCONNECT\\nreceipt:%d\\n\\n%c\", bu->cur_rcpt-1, 0);\n send_all_socket(bu->fd, buf, len);\n\n memset(&stomp, 0, sizeof(struct stomp_hdr));\n if (zxbus_read_stomp(cf, bu, &stomp)) {\n if (!memcmp(bu->m, \"RECEIPT\", sizeof(\"RECEIPT\")-1)) {\n if (atoi(stomp.rcpt_id) == bu->cur_rcpt - 1) {\n\tzxbus_shift_read_buf(cf, bu, &stomp);\n\tD(\"DISCONNECT got RECEIPT %d\", bu->cur_rcpt-1);\n#ifdef USE_OPENSSL\n\tif (bu->ssl) {\n\t SSL_shutdown(bu->ssl);\n\t SSL_free(bu->ssl);\n\t bu->ssl = 0;\n\t}\n#endif\n\tclose(bu->fd);\n\tbu->fd = 0;\n\treturn 1;\n } else {\n\tERR(\"DISCONNECT to %s failed. RECEIPT number(%.*s)=%d mismatch cur_rcpt-1=%d\", bu->s, (int)(bu->ap - stomp.rcpt_id), stomp.rcpt_id, atoi(stomp.rcpt_id), bu->cur_rcpt-1);\n\tzxbus_shift_read_buf(cf, bu, &stomp);\n\tgoto errout;\n }\n } else {\n ERR(\"DISCONNECT to %s failed. Other end did not send RECEIPT(%.*s)\", bu->s, (int)(bu->ap - bu->m), bu->m);\n zxbus_shift_read_buf(cf, bu, &stomp);\n }\n } else {\n ERR(\"DISCONNECT to %s failed. Other end did not send RECEIPT. Read error. Probably connection drop.\", bu->s);\n }\n errout:\n#ifdef USE_OPENSSL\n if (bu->ssl) {\n SSL_shutdown(bu->ssl);\n SSL_free(bu->ssl);\n bu->ssl = 0;\n }\n#endif\n close(bu->fd);\n bu->fd = 0;\n return 0;\n}", "label": 0, "cwe": null, "length": 598 }, { "index": 672702, "code": "bond_change_active_slave(struct bonding *bond, struct slave *new_active)\n{\n\tstruct slave *old_active;\n\n\tASSERT_RTNL();\n\n\told_active = rtnl_dereference(bond->curr_active_slave);\n\n\tif (old_active == new_active)\n\t\treturn;\n\n\tif (new_active) {\n\t\tnew_active->last_link_up = jiffies;\n\n\t\tif (new_active->link == BOND_LINK_BACK) {\n\t\t\tif (bond_uses_primary(bond)) {\n\t\t\t\tnetdev_info(bond->dev, \"making interface %s the new active one %d ms earlier\\n\",\n\t\t\t\t\t new_active->dev->name,\n\t\t\t\t\t (bond->params.updelay - new_active->delay) * bond->params.miimon);\n\t\t\t}\n\n\t\t\tnew_active->delay = 0;\n\t\t\tbond_set_slave_link_state(new_active, BOND_LINK_UP,\n\t\t\t\t\t\t BOND_SLAVE_NOTIFY_NOW);\n\n\t\t\tif (BOND_MODE(bond) == BOND_MODE_8023AD)\n\t\t\t\tbond_3ad_handle_link_change(new_active, BOND_LINK_UP);\n\n\t\t\tif (bond_is_lb(bond))\n\t\t\t\tbond_alb_handle_link_change(bond, new_active, BOND_LINK_UP);\n\t\t} else {\n\t\t\tif (bond_uses_primary(bond)) {\n\t\t\t\tnetdev_info(bond->dev, \"making interface %s the new active one\\n\",\n\t\t\t\t\t new_active->dev->name);\n\t\t\t}\n\t\t}\n\t}\n\n\tif (bond_uses_primary(bond))\n\t\tbond_hw_addr_swap(bond, new_active, old_active);\n\n\tif (bond_is_lb(bond)) {\n\t\tbond_alb_handle_active_change(bond, new_active);\n\t\tif (old_active)\n\t\t\tbond_set_slave_inactive_flags(old_active,\n\t\t\t\t\t\t BOND_SLAVE_NOTIFY_NOW);\n\t\tif (new_active)\n\t\t\tbond_set_slave_active_flags(new_active,\n\t\t\t\t\t\t BOND_SLAVE_NOTIFY_NOW);\n\t} else {\n\t\trcu_assign_pointer(bond->curr_active_slave, new_active);\n\t}\n\n\tif (BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP) {\n\t\tif (old_active)\n\t\t\tbond_set_slave_inactive_flags(old_active,\n\t\t\t\t\t\t BOND_SLAVE_NOTIFY_NOW);\n\n\t\tif (new_active) {\n\t\t\tbool should_notify_peers = false;\n\n\t\t\tbond_set_slave_active_flags(new_active,\n\t\t\t\t\t\t BOND_SLAVE_NOTIFY_NOW);\n\n\t\t\tif (bond->params.fail_over_mac)\n\t\t\t\tbond_do_fail_over_mac(bond, new_active,\n\t\t\t\t\t\t old_active);\n\n\t\t\tif (netif_running(bond->dev)) {\n\t\t\t\tbond->send_peer_notif =\n\t\t\t\t\tbond->params.num_peer_notif;\n\t\t\t\tshould_notify_peers =\n\t\t\t\t\tbond_should_notify_peers(bond);\n\t\t\t}\n\n\t\t\tcall_netdevice_notifiers(NETDEV_BONDING_FAILOVER, bond->dev);\n\t\t\tif (should_notify_peers)\n\t\t\t\tcall_netdevice_notifiers(NETDEV_NOTIFY_PEERS,\n\t\t\t\t\t\t\t bond->dev);\n\t\t}\n\t}\n\n\t/* resend IGMP joins since active slave has changed or\n\t * all were sent on curr_active_slave.\n\t * resend only if bond is brought up with the affected\n\t * bonding modes and the retransmission is enabled\n\t */\n\tif (netif_running(bond->dev) && (bond->params.resend_igmp > 0) &&\n\t ((bond_uses_primary(bond) && new_active) ||\n\t BOND_MODE(bond) == BOND_MODE_ROUNDROBIN)) {\n\t\tbond->igmp_retrans = bond->params.resend_igmp;\n\t\tqueue_delayed_work(bond->wq, &bond->mcast_work, 1);\n\t}\n}", "label": 0, "cwe": null, "length": 764 }, { "index": 31109, "code": "r8712_set_802_11_ssid(struct _adapter *padapter,\n\t\t\t struct ndis_802_11_ssid *ssid)\n{\n\tunsigned long irqL;\n\tstruct mlme_priv *pmlmepriv = &padapter->mlmepriv;\n\tstruct wlan_network *pnetwork = &pmlmepriv->cur_network;\n\n\tif (!padapter->hw_init_completed)\n\t\treturn;\n\tspin_lock_irqsave(&pmlmepriv->lock, irqL);\n\tif (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING)) {\n\t\tcheck_fwstate(pmlmepriv, _FW_UNDER_LINKING);\n\t\tgoto _Abort_Set_SSID;\n\t}\n\tif (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) {\n\t\tif ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) &&\n\t\t (!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid,\n\t\t ssid->SsidLength))) {\n\t\t\tif (!check_fwstate(pmlmepriv, WIFI_STATION_STATE)) {\n\t\t\t\tif (!r8712_is_same_ibss(padapter,\n\t\t\t\t pnetwork)) {\n\t\t\t\t\t/* if in WIFI_ADHOC_MASTER_STATE or\n\t\t\t\t\t * WIFI_ADHOC_STATE, create bss or\n\t\t\t\t\t * rejoin again\n\t\t\t\t\t */\n\t\t\t\t\tr8712_disassoc_cmd(padapter);\n\t\t\t\t\tif (check_fwstate(pmlmepriv,\n\t\t\t\t\t _FW_LINKED))\n\t\t\t\t\t\tr8712_ind_disconnect(padapter);\n\t\t\t\t\tr8712_free_assoc_resources(padapter);\n\t\t\t\t\tif (check_fwstate(pmlmepriv,\n\t\t\t\t\t WIFI_ADHOC_MASTER_STATE)) {\n\t\t\t\t\t\t_clr_fwstate_(pmlmepriv,\n\t\t\t\t\t\t WIFI_ADHOC_MASTER_STATE);\n\t\t\t\t\t\tset_fwstate(pmlmepriv,\n\t\t\t\t\t\t\t WIFI_ADHOC_STATE);\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tgoto _Abort_Set_SSID; /* driver is in\n\t\t\t\t\t\t * WIFI_ADHOC_MASTER_STATE */\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tr8712_disassoc_cmd(padapter);\n\t\t\tif (check_fwstate(pmlmepriv, _FW_LINKED))\n\t\t\t\tr8712_ind_disconnect(padapter);\n\t\t\tr8712_free_assoc_resources(padapter);\n\t\t\tif (check_fwstate(pmlmepriv,\n\t\t\t WIFI_ADHOC_MASTER_STATE)) {\n\t\t\t\t_clr_fwstate_(pmlmepriv,\n\t\t\t\t\t WIFI_ADHOC_MASTER_STATE);\n\t\t\t\tset_fwstate(pmlmepriv, WIFI_ADHOC_STATE);\n\t\t\t}\n\t\t}\n\t}\n\tif (padapter->securitypriv.btkip_countermeasure)\n\t\tgoto _Abort_Set_SSID;\n\tif (!validate_ssid(ssid))\n\t\tgoto _Abort_Set_SSID;\n\tmemcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct ndis_802_11_ssid));\n\tpmlmepriv->assoc_by_bssid = false;\n\tdo_join(padapter);\n\tgoto done;\n_Abort_Set_SSID:\ndone:\n\tspin_unlock_irqrestore(&pmlmepriv->lock, irqL);\n}", "label": 1, "cwe": "CWE-120", "length": 645 }, { "index": 847689, "code": "_backup_video_orc_pack_I420 (OrcExecutor * ORC_RESTRICT ex)\n{\n int i;\n int n = ex->n;\n orc_union16 * ORC_RESTRICT ptr0;\n orc_int8 * ORC_RESTRICT ptr1;\n orc_int8 * ORC_RESTRICT ptr2;\n const orc_union64 * ORC_RESTRICT ptr4;\n orc_union64 var38;\n orc_union16 var39;\n orc_int8 var40;\n orc_int8 var41;\n orc_union32 var42;\n orc_union32 var43;\n orc_union16 var44;\n orc_union16 var45;\n\n ptr0 = (orc_union16 *)ex->arrays[0];\n ptr1 = (orc_int8 *)ex->arrays[1];\n ptr2 = (orc_int8 *)ex->arrays[2];\n ptr4 = (orc_union64 *)ex->arrays[4];\n\n\n for (i = 0; i < n; i++) {\n /* 0: loadq */\n var38 = ptr4[i];\n /* 1: splitlw */\n {\n orc_union32 _src;\n _src.i = var38.x2[0];\n var42.x2[0] = _src.x2[1];\n var43.x2[0] = _src.x2[0];\n }\n {\n orc_union32 _src;\n _src.i = var38.x2[1];\n var42.x2[1] = _src.x2[1];\n var43.x2[1] = _src.x2[0];\n }\n /* 2: select1wb */\n {\n orc_union16 _src;\n _src.i = var43.x2[0];\n var39.x2[0] = _src.x2[1];\n }\n {\n orc_union16 _src;\n _src.i = var43.x2[1];\n var39.x2[1] = _src.x2[1];\n }\n /* 3: storew */\n ptr0[i] = var39;\n /* 4: splitwb */\n {\n orc_union16 _src;\n _src.i = var42.x2[0];\n var44.x2[0] = _src.x2[1];\n var45.x2[0] = _src.x2[0];\n }\n {\n orc_union16 _src;\n _src.i = var42.x2[1];\n var44.x2[1] = _src.x2[1];\n var45.x2[1] = _src.x2[0];\n }\n /* 5: select0wb */\n {\n orc_union16 _src;\n _src.i = var45.i;\n var40 = _src.x2[0];\n }\n /* 6: storeb */\n ptr1[i] = var40;\n /* 7: select0wb */\n {\n orc_union16 _src;\n _src.i = var44.i;\n var41 = _src.x2[0];\n }\n /* 8: storeb */\n ptr2[i] = var41;\n }\n\n}", "label": 0, "cwe": null, "length": 685 }, { "index": 657827, "code": "rndis_msg_parser(struct rndis_params *params, u8 *buf)\n{\n\tu32 MsgType, MsgLength;\n\t__le32 *tmp;\n\n\tif (!buf)\n\t\treturn -ENOMEM;\n\n\ttmp = (__le32 *)buf;\n\tMsgType = get_unaligned_le32(tmp++);\n\tMsgLength = get_unaligned_le32(tmp++);\n\n\tif (!params)\n\t\treturn -ENOTSUPP;\n\n\t/* NOTE: RNDIS is *EXTREMELY* chatty ... Windows constantly polls for\n\t * rx/tx statistics and link status, in addition to KEEPALIVE traffic\n\t * and normal HC level polling to see if there's any IN traffic.\n\t */\n\n\t/* For USB: responses may take up to 10 seconds */\n\tswitch (MsgType) {\n\tcase RNDIS_MSG_INIT:\n\t\tpr_debug(\"%s: RNDIS_MSG_INIT\\n\",\n\t\t\t__func__);\n\t\tparams->state = RNDIS_INITIALIZED;\n\t\treturn rndis_init_response(params, (rndis_init_msg_type *)buf);\n\n\tcase RNDIS_MSG_HALT:\n\t\tpr_debug(\"%s: RNDIS_MSG_HALT\\n\",\n\t\t\t__func__);\n\t\tparams->state = RNDIS_UNINITIALIZED;\n\t\tif (params->dev) {\n\t\t\tnetif_carrier_off(params->dev);\n\t\t\tnetif_stop_queue(params->dev);\n\t\t}\n\t\treturn 0;\n\n\tcase RNDIS_MSG_QUERY:\n\t\treturn rndis_query_response(params,\n\t\t\t\t\t(rndis_query_msg_type *)buf);\n\n\tcase RNDIS_MSG_SET:\n\t\treturn rndis_set_response(params, (rndis_set_msg_type *)buf);\n\n\tcase RNDIS_MSG_RESET:\n\t\tpr_debug(\"%s: RNDIS_MSG_RESET\\n\",\n\t\t\t__func__);\n\t\treturn rndis_reset_response(params,\n\t\t\t\t\t(rndis_reset_msg_type *)buf);\n\n\tcase RNDIS_MSG_KEEPALIVE:\n\t\t/* For USB: host does this every 5 seconds */\n\t\tif (rndis_debug > 1)\n\t\t\tpr_debug(\"%s: RNDIS_MSG_KEEPALIVE\\n\",\n\t\t\t\t__func__);\n\t\treturn rndis_keepalive_response(params,\n\t\t\t\t\t\t (rndis_keepalive_msg_type *)\n\t\t\t\t\t\t buf);\n\n\tdefault:\n\t\t/* At least Windows XP emits some undefined RNDIS messages.\n\t\t * In one case those messages seemed to relate to the host\n\t\t * suspending itself.\n\t\t */\n\t\tpr_warning(\"%s: unknown RNDIS message 0x%08X len %d\\n\",\n\t\t\t__func__, MsgType, MsgLength);\n\t\tprint_hex_dump_bytes(__func__, DUMP_PREFIX_OFFSET,\n\t\t\t\t buf, MsgLength);\n\t\tbreak;\n\t}\n\n\treturn -ENOTSUPP;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-other" ], "length": 562 }, { "index": 39314, "code": "process_trpthdst_ev(register struct tev_t *tevp)\n{\n register int32 bi;\n register struct net_t *np;\n register byte *sbp;\n struct traux_t *trap;\n word32 nval, av, bv;\n struct rngdwir_t *dwirp;\n struct xstk_t *xsp;\n\n /* notice event here emitted in change gate outwire */\n np = tevp->tu.tenp->tenu.np;\n bi = tevp->tu.tenp->nbi;\n /* DBG remove ---\n if (bi < 0) __misc_terr(__FILE__, __LINE__);\n --- */\n\n /* free wire event auxialiary field here since bit and wire extracted */\n __my_free((char *) tevp->tu.tenp, sizeof(struct tenp_t));\n tevp->tu.tenp = NULL;\n\n nval = tevp->outv;\n if (__ev_tracing)\n {\n char s1[RECLEN];\n\n __evtr_resume_msg();\n __tr_msg(\n \"-- processing inout path dest. %s driven value update event, value %s\\n\",\n __to_evtrwnam(__xs, np, bi, bi, tevp->teitp),\n __to_vvnam(s1, (word32) nval));\n }\n dwirp = np->nu.rngdwir;\n dwirp->wschd_pbtevs[np->nwid*tevp->teitp->itinum + bi] = -1;\n\n trap = np->ntraux;\n __push_itstk(tevp->teitp);\n /* update hard driver stored value and re-eval tran channel if needed */\n if (np->n_stren)\n {\n /* get strength wire address */\n sbp = &(trap->trnva.bp[__inum*np->nwid]);\n if (sbp[bi] == nval) goto done;\n sbp[bi] = nval;\n }\n else\n {\n if (!np->n_isavec)\n {\n ld_scalval_(&av, &bv, trap->trnva.bp);\n if (nval == (av | (bv << 1))) goto done;\n /* SJM 07/16/01 - typo was storing old val so tr chan value never chgs */\n /* need to store new non stren value not old */\n /* ??? wrong - st_scalval_(trap->trnva.bp, av, bv); */\n st2_scalval_(trap->trnva.bp, nval);\n }\n else\n {\n push_xstk_(xsp, np->nwid);\n __ld_perinst_val(xsp->ap, xsp->bp, trap->trnva, np->nwid);\n av = rhsbsel_(xsp->ap, bi);\n bv = rhsbsel_(xsp->bp, bi);\n if (nval == (av | (bv << 1))) { __pop_xstk(); goto done; }\n __lhsbsel(xsp->ap, bi, (nval & 1L));\n __lhsbsel(xsp->bp, bi, ((nval >> 1) & 1L));\n __st_perinst_val(trap->trnva, np->nwid, xsp->ap, xsp->bp);\n __pop_xstk();\n }\n }\n /* if some but not this bit in tran channel, just assign */\n /* SJM - 03/15/01 - know bit not -1 since schedules as 0 for scalar */\n __eval_tran_1bit(np, bi);\ndone:\n __pop_itstk();\n}", "label": 1, "cwe": "CWE-other", "length": 774 }, { "index": 126761, "code": "test_diff_tree__0(void)\n{\n\t/* grabbed a couple of commit oids from the history of the attr repo */\n\tconst char *a_commit = \"605812a\";\n\tconst char *b_commit = \"370fe9ec22\";\n\tconst char *c_commit = \"f5b0af1fb4f5c\";\n\tgit_tree *a, *b, *c;\n\tgit_diff_options opts = {0};\n\tgit_diff_list *diff = NULL;\n\tdiff_expects exp;\n\n\tg_repo = cl_git_sandbox_init(\"attr\");\n\n\tcl_assert((a = resolve_commit_oid_to_tree(g_repo, a_commit)) != NULL);\n\tcl_assert((b = resolve_commit_oid_to_tree(g_repo, b_commit)) != NULL);\n\tcl_assert((c = resolve_commit_oid_to_tree(g_repo, c_commit)) != NULL);\n\n\topts.context_lines = 1;\n\topts.interhunk_lines = 1;\n\n\tmemset(&exp, 0, sizeof(exp));\n\n\tcl_git_pass(git_diff_tree_to_tree(&diff, g_repo, a, b, &opts));\n\n\tcl_git_pass(git_diff_foreach(\n\t\tdiff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));\n\n\tcl_assert_equal_i(5, exp.files);\n\tcl_assert_equal_i(2, exp.file_status[GIT_DELTA_ADDED]);\n\tcl_assert_equal_i(1, exp.file_status[GIT_DELTA_DELETED]);\n\tcl_assert_equal_i(2, exp.file_status[GIT_DELTA_MODIFIED]);\n\n\tcl_assert_equal_i(5, exp.hunks);\n\n\tcl_assert_equal_i(7 + 24 + 1 + 6 + 6, exp.lines);\n\tcl_assert_equal_i(1, exp.line_ctxt);\n\tcl_assert_equal_i(24 + 1 + 5 + 5, exp.line_adds);\n\tcl_assert_equal_i(7 + 1, exp.line_dels);\n\n\tgit_diff_list_free(diff);\n\tdiff = NULL;\n\n\tmemset(&exp, 0, sizeof(exp));\n\n\tcl_git_pass(git_diff_tree_to_tree(&diff, g_repo, c, b, &opts));\n\n\tcl_git_pass(git_diff_foreach(\n\t\tdiff, &exp, diff_file_fn, diff_hunk_fn, diff_line_fn));\n\n\tcl_assert_equal_i(2, exp.files);\n\tcl_assert_equal_i(0, exp.file_status[GIT_DELTA_ADDED]);\n\tcl_assert_equal_i(0, exp.file_status[GIT_DELTA_DELETED]);\n\tcl_assert_equal_i(2, exp.file_status[GIT_DELTA_MODIFIED]);\n\n\tcl_assert_equal_i(2, exp.hunks);\n\n\tcl_assert_equal_i(8 + 15, exp.lines);\n\tcl_assert_equal_i(1, exp.line_ctxt);\n\tcl_assert_equal_i(1, exp.line_adds);\n\tcl_assert_equal_i(7 + 14, exp.line_dels);\n\n\tgit_diff_list_free(diff);\n\n\tgit_tree_free(a);\n\tgit_tree_free(b);\n\tgit_tree_free(c);\n}", "label": 0, "cwe": null, "length": 591 }, { "index": 270081, "code": "evas_common_font_draw(RGBA_Image *dst, RGBA_Draw_Context *dc, int x, int y, const Evas_Text_Props *text_props)\n{\n static Cutout_Rects *rects = NULL;\n int ext_x, ext_y, ext_w, ext_h;\n int im_w, im_h;\n RGBA_Gfx_Func func;\n Cutout_Rect *r;\n int c, cx, cy, cw, ch;\n int i;\n\n im_w = dst->cache_entry.w;\n im_h = dst->cache_entry.h;\n\n ext_x = 0; ext_y = 0; ext_w = im_w; ext_h = im_h;\n if (dc->clip.use)\n {\n\text_x = dc->clip.x;\n\text_y = dc->clip.y;\n\text_w = dc->clip.w;\n\text_h = dc->clip.h;\n\tif (ext_x < 0)\n\t {\n\t ext_w += ext_x;\n\t ext_x = 0;\n\t }\n\tif (ext_y < 0)\n\t {\n\t ext_h += ext_y;\n\t ext_y = 0;\n\t }\n\tif ((ext_x + ext_w) > im_w)\n\t ext_w = im_w - ext_x;\n\tif ((ext_y + ext_h) > im_h)\n\t ext_h = im_h - ext_y;\n }\n if (ext_w <= 0) return;\n if (ext_h <= 0) return;\n\n// evas_common_font_size_use(fn);\n func = evas_common_gfx_func_composite_mask_color_span_get(dc->col.col, dst, 1, dc->render_op);\n\n if (!dc->cutout.rects)\n {\n evas_common_font_draw_internal(dst, dc, x, y, text_props,\n func, ext_x, ext_y, ext_w, ext_h,\n im_w, im_h);\n }\n else\n {\n c = dc->clip.use; cx = dc->clip.x; cy = dc->clip.y; cw = dc->clip.w; ch = dc->clip.h;\n evas_common_draw_context_clip_clip(dc, 0, 0, dst->cache_entry.w, dst->cache_entry.h);\n /* our clip is 0 size.. abort */\n if ((dc->clip.w > 0) && (dc->clip.h > 0))\n {\n rects = evas_common_draw_context_apply_cutouts(dc, rects);\n for (i = 0; i < rects->active; ++i)\n {\n r = rects->rects + i;\n evas_common_draw_context_set_clip(dc, r->x, r->y, r->w, r->h);\n evas_common_font_draw_internal(dst, dc, x, y, text_props,\n func, r->x, r->y, r->w, r->h,\n im_w, im_h);\n }\n }\n dc->clip.use = c; dc->clip.x = cx; dc->clip.y = cy; dc->clip.w = cw; dc->clip.h = ch;\n }\n}", "label": 0, "cwe": null, "length": 663 }, { "index": 963615, "code": "session_free(struct session *s)\n{\n\tstruct http_txn *txn = &s->txn;\n\tstruct proxy *fe = s->fe;\n\tstruct bref *bref, *back;\n\tint i;\n\n\tif (s->pend_pos)\n\t\tpendconn_free(s->pend_pos);\n\n\tif (s->srv) { /* there may be requests left pending in queue */\n\t\tif (s->flags & SN_CURR_SESS) {\n\t\t\ts->flags &= ~SN_CURR_SESS;\n\t\t\ts->srv->cur_sess--;\n\t\t}\n\t\tif (may_dequeue_tasks(s->srv, s->be))\n\t\t\tprocess_srv_queue(s->srv);\n\t}\n\n\tif (unlikely(s->srv_conn)) {\n\t\t/* the session still has a reserved slot on a server, but\n\t\t * it should normally be only the same as the one above,\n\t\t * so this should not happen in fact.\n\t\t */\n\t\tsess_change_server(s, NULL);\n\t}\n\n\tif (s->req->pipe)\n\t\tput_pipe(s->req->pipe);\n\n\tif (s->rep->pipe)\n\t\tput_pipe(s->rep->pipe);\n\n\tpool_free2(pool2_buffer, s->req);\n\tpool_free2(pool2_buffer, s->rep);\n\n\thttp_end_txn(s);\n\n\tfor (i = 0; i < s->store_count; i++) {\n\t\tif (!s->store[i].ts)\n\t\t\tcontinue;\n\t\tstksess_free(s->store[i].table, s->store[i].ts);\n\t\ts->store[i].ts = NULL;\n\t}\n\n\tif (fe) {\n\t\tpool_free2(fe->hdr_idx_pool, txn->hdr_idx.v);\n\t\tpool_free2(fe->rsp_cap_pool, txn->rsp.cap);\n\t\tpool_free2(fe->req_cap_pool, txn->req.cap);\n\t}\n\n\tlist_for_each_entry_safe(bref, back, &s->back_refs, users) {\n\t\t/* we have to unlink all watchers. We must not relink them if\n\t\t * this session was the last one in the list.\n\t\t */\n\t\tLIST_DEL(&bref->users);\n\t\tLIST_INIT(&bref->users);\n\t\tif (s->list.n != &sessions)\n\t\t\tLIST_ADDQ(&LIST_ELEM(s->list.n, struct session *, list)->back_refs, &bref->users);\n\t\tbref->ref = s->list.n;\n\t}\n\tLIST_DEL(&s->list);\n\tpool_free2(pool2_session, s);\n\n\t/* We may want to free the maximum amount of pools if the proxy is stopping */\n\tif (fe && unlikely(fe->state == PR_STSTOPPED)) {\n\t\tpool_flush2(pool2_buffer);\n\t\tpool_flush2(fe->hdr_idx_pool);\n\t\tpool_flush2(pool2_requri);\n\t\tpool_flush2(pool2_capture);\n\t\tpool_flush2(pool2_session);\n\t\tpool_flush2(fe->req_cap_pool);\n\t\tpool_flush2(fe->rsp_cap_pool);\n\t}\n}", "label": 0, "cwe": null, "length": 613 }, { "index": 211050, "code": "cyberpro_pci_probe(struct pci_dev *dev,\n\t\t\t const struct pci_device_id *id)\n{\n\tstruct cfb_info *cfb;\n\tchar name[16];\n\tint err;\n\n\tsprintf(name, \"CyberPro%4X\", id->device);\n\n\terr = pci_enable_device(dev);\n\tif (err)\n\t\treturn err;\n\n\terr = -ENOMEM;\n\tcfb = cyberpro_alloc_fb_info(id->driver_data, name);\n\tif (!cfb)\n\t\tgoto failed_release;\n\n\terr = pci_request_regions(dev, cfb->fb.fix.id);\n\tif (err)\n\t\tgoto failed_regions;\n\n\tcfb->irq = dev->irq;\n\tcfb->region = pci_ioremap_bar(dev, 0);\n\tif (!cfb->region) {\n\t\terr = -ENOMEM;\n\t\tgoto failed_ioremap;\n\t}\n\n\tcfb->regs = cfb->region + MMIO_OFFSET;\n\tcfb->fb.device = &dev->dev;\n\tcfb->fb.fix.mmio_start = pci_resource_start(dev, 0) + MMIO_OFFSET;\n\tcfb->fb.fix.smem_start = pci_resource_start(dev, 0);\n\n\t/*\n\t * Bring up the hardware. This is expected to enable access\n\t * to the linear memory region, and allow access to the memory\n\t * mapped registers. Also, mem_ctl1 and mem_ctl2 must be\n\t * initialised.\n\t */\n\terr = cyberpro_pci_enable_mmio(cfb);\n\tif (err)\n\t\tgoto failed;\n\n\t/*\n\t * Use MCLK from BIOS. FIXME: what about hotplug?\n\t */\n\tcfb->mclk_mult = cyber2000_grphr(EXT_MCLK_MULT, cfb);\n\tcfb->mclk_div = cyber2000_grphr(EXT_MCLK_DIV, cfb);\n\n#ifdef __arm__\n\t/*\n\t * MCLK on the NetWinder and the Shark is fixed at 75MHz\n\t */\n\tif (machine_is_netwinder()) {\n\t\tcfb->mclk_mult = 0xdb;\n\t\tcfb->mclk_div = 0x54;\n\t}\n#endif\n\n\terr = cyberpro_common_probe(cfb);\n\tif (err)\n\t\tgoto failed;\n\n\t/*\n\t * Our driver data\n\t */\n\tpci_set_drvdata(dev, cfb);\n\tif (int_cfb_info == NULL)\n\t\tint_cfb_info = cfb;\n\n\treturn 0;\n\nfailed:\n\tiounmap(cfb->region);\nfailed_ioremap:\n\tpci_release_regions(dev);\nfailed_regions:\n\tcyberpro_free_fb_info(cfb);\nfailed_release:\n\treturn err;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 536 }, { "index": 995040, "code": "detect_field_duplicates (tree fieldlist)\n{\n tree x, y;\n int timeout = 10;\n\n /* If the struct is the list of instance variables of an Objective-C\n class, then we need to add all the instance variables of\n superclasses before checking for duplicates (since you can't have\n an instance variable in a subclass with the same name as an\n instance variable in a superclass). objc_get_interface_ivars()\n leaves fieldlist unchanged if we are not in this case, so in that\n case nothing changes compared to C.\n */\n if (c_dialect_objc ())\n fieldlist = objc_get_interface_ivars (fieldlist);\n\n /* First, see if there are more than \"a few\" fields.\n This is trivially true if there are zero or one fields. */\n if (!fieldlist || !DECL_CHAIN (fieldlist))\n return;\n x = fieldlist;\n do {\n timeout--;\n if (DECL_NAME (x) == NULL_TREE\n\t&& (TREE_CODE (TREE_TYPE (x)) == RECORD_TYPE\n\t || TREE_CODE (TREE_TYPE (x)) == UNION_TYPE))\n timeout = 0;\n x = DECL_CHAIN (x);\n } while (timeout > 0 && x);\n\n /* If there were \"few\" fields and no anonymous structures or unions,\n avoid the overhead of allocating a hash table. Instead just do\n the nested traversal thing. */\n if (timeout > 0)\n {\n for (x = DECL_CHAIN (fieldlist); x; x = DECL_CHAIN (x))\n\t/* When using -fplan9-extensions, we can have duplicates\n\t between typedef names and fields. */\n\tif (DECL_NAME (x)\n\t || (flag_plan9_extensions\n\t\t&& DECL_NAME (x) == NULL_TREE\n\t\t&& (TREE_CODE (TREE_TYPE (x)) == RECORD_TYPE\n\t\t || TREE_CODE (TREE_TYPE (x)) == UNION_TYPE)\n\t\t&& TYPE_NAME (TREE_TYPE (x)) != NULL_TREE\n\t\t&& TREE_CODE (TYPE_NAME (TREE_TYPE (x))) == TYPE_DECL))\n\t {\n\t for (y = fieldlist; y != x; y = TREE_CHAIN (y))\n\t if (is_duplicate_field (y, x))\n\t\t{\n\t\t error (\"duplicate member %q+D\", x);\n\t\t DECL_NAME (x) = NULL_TREE;\n\t\t}\n\t }\n }\n else\n {\n htab_t htab = htab_create (37, htab_hash_pointer, htab_eq_pointer, NULL);\n\n detect_field_duplicates_hash (fieldlist, htab);\n htab_delete (htab);\n }\n}", "label": 0, "cwe": null, "length": 571 }, { "index": 51794, "code": "unpack_lrm_rsc_state(node_t * node, xmlNode * rsc_entry, pe_working_set_t * data_set)\n{\n GListPtr gIter = NULL;\n int stop_index = -1;\n int start_index = -1;\n enum rsc_role_e req_role = RSC_ROLE_UNKNOWN;\n\n const char *task = NULL;\n const char *rsc_id = crm_element_value(rsc_entry, XML_ATTR_ID);\n\n resource_t *rsc = NULL;\n GListPtr op_list = NULL;\n GListPtr sorted_op_list = NULL;\n\n xmlNode *migrate_op = NULL;\n xmlNode *rsc_op = NULL;\n\n enum action_fail_response on_fail = FALSE;\n enum rsc_role_e saved_role = RSC_ROLE_UNKNOWN;\n\n crm_trace(\"[%s] Processing %s on %s\",\n crm_element_name(rsc_entry), rsc_id, node->details->uname);\n\n /* extract operations */\n op_list = NULL;\n sorted_op_list = NULL;\n\n for (rsc_op = __xml_first_child(rsc_entry); rsc_op != NULL; rsc_op = __xml_next(rsc_op)) {\n if (crm_str_eq((const char *)rsc_op->name, XML_LRM_TAG_RSC_OP, TRUE)) {\n op_list = g_list_prepend(op_list, rsc_op);\n }\n }\n\n if (op_list == NULL) {\n /* if there are no operations, there is nothing to do */\n return;\n }\n\n /* find the resource */\n rsc = unpack_find_resource(data_set, node, rsc_id, rsc_entry);\n if (rsc == NULL) {\n rsc = process_orphan_resource(rsc_entry, node, data_set);\n }\n CRM_ASSERT(rsc != NULL);\n\n /* process operations */\n saved_role = rsc->role;\n on_fail = action_fail_ignore;\n rsc->role = RSC_ROLE_UNKNOWN;\n sorted_op_list = g_list_sort(op_list, sort_op_by_callid);\n\n for (gIter = sorted_op_list; gIter != NULL; gIter = gIter->next) {\n xmlNode *rsc_op = (xmlNode *) gIter->data;\n\n task = crm_element_value(rsc_op, XML_LRM_ATTR_TASK);\n if (safe_str_eq(task, CRMD_ACTION_MIGRATED)) {\n migrate_op = rsc_op;\n }\n\n unpack_rsc_op(rsc, node, rsc_op, &on_fail, data_set);\n }\n\n /* create active recurring operations as optional */\n calculate_active_ops(sorted_op_list, &start_index, &stop_index);\n process_recurring(node, rsc, start_index, stop_index, sorted_op_list, data_set);\n\n /* no need to free the contents */\n g_list_free(sorted_op_list);\n\n process_rsc_state(rsc, node, on_fail, migrate_op, data_set);\n\n if (get_target_role(rsc, &req_role)) {\n if (rsc->next_role == RSC_ROLE_UNKNOWN || req_role < rsc->next_role) {\n pe_rsc_debug(rsc, \"%s: Overwriting calculated next role %s\"\n \" with requested next role %s\",\n rsc->id, role2text(rsc->next_role), role2text(req_role));\n rsc->next_role = req_role;\n\n } else if (req_role > rsc->next_role) {\n pe_rsc_info(rsc, \"%s: Not overwriting calculated next role %s\"\n \" with requested next role %s\",\n rsc->id, role2text(rsc->next_role), role2text(req_role));\n }\n }\n\n if (saved_role > rsc->role) {\n rsc->role = saved_role;\n }\n}", "label": 1, "cwe": "CWE-476", "length": 818 }, { "index": 883755, "code": "_update_step_record(job_step_info_t *step_ptr,\n\t\t\t\tGtkTreeStore *treestore,\n\t\t\t\tGtkTreeIter *iter)\n{\n\tchar *tmp_uname;\n\tchar tmp_nodes[50];\n\tchar tmp_cpu_min[40], tmp_time_run[40], tmp_time_limit[40];\n\tchar tmp_node_cnt[40], tmp_time_start[40], tmp_task_cnt[40];\n\ttime_t now_time = time(NULL);\n\tenum job_states state;\n\tint color_inx = step_ptr->step_id % sview_colors_cnt;\n\n\tconvert_num_unit((float)step_ptr->num_cpus, tmp_cpu_min,\n\t\t\t sizeof(tmp_cpu_min), UNIT_NONE);\n\n\tif (!step_ptr->nodes ||\n\t !strcasecmp(step_ptr->nodes,\"waiting...\")) {\n\t\tsprintf(tmp_time_run, \"00:00:00\");\n\t\tsnprintf(tmp_nodes, sizeof(tmp_nodes), \"waiting...\");\n\t\ttmp_node_cnt[0] = '\\0';\n\t\tstate = JOB_PENDING;\n\t} else {\n\t\tnow_time -= step_ptr->start_time;\n\t\tsecs2time_str(now_time, tmp_time_run, sizeof(tmp_time_run));\n\t\t_get_step_nodelist(step_ptr, tmp_nodes, sizeof(tmp_nodes));\n\t\tif (cluster_flags & CLUSTER_FLAG_BGQ) {\n\t\t\tuint32_t nodes = 0;\n\t\t\tselect_g_select_jobinfo_get(step_ptr->select_jobinfo,\n\t\t\t\t\t\t SELECT_JOBDATA_NODE_CNT,\n\t\t\t\t\t\t &nodes);\n\t\t\tconvert_num_unit((float)nodes, tmp_node_cnt,\n\t\t\t\t\t sizeof(tmp_node_cnt), UNIT_NONE);\n\t\t} else if (cluster_flags & CLUSTER_FLAG_BG) {\n\t\t\tconvert_num_unit(\n\t\t\t\t(float)step_ptr->num_tasks / cpus_per_node,\n\t\t\t\ttmp_node_cnt, sizeof(tmp_node_cnt), UNIT_NONE);\n\t\t} else {\n\t\t\tconvert_num_unit((float)_nodes_in_list(tmp_nodes),\n\t\t\t\t\t tmp_node_cnt, sizeof(tmp_node_cnt),\n\t\t\t\t\t UNIT_NONE);\n\t\t}\n\t\tstate = JOB_RUNNING;\n\t}\n\n\tconvert_num_unit((float)step_ptr->num_tasks, tmp_task_cnt,\n\t\t\t sizeof(tmp_task_cnt), UNIT_NONE);\n\n\tif ((step_ptr->time_limit == NO_VAL) ||\n\t (step_ptr->time_limit == INFINITE)) {\n\t\tsprintf(tmp_time_limit, \"Job Limit\");\n\t} else {\n\t\tsecs2time_str((step_ptr->time_limit * 60),\n\t\t\t tmp_time_limit, sizeof(tmp_time_limit));\n\t}\n\n\tslurm_make_time_str((time_t *)&step_ptr->start_time, tmp_time_start,\n\t\t\t sizeof(tmp_time_start));\n\n\ttmp_uname = uid_to_string((uid_t)step_ptr->user_id);\n\n\tgtk_tree_store_set(treestore, iter,\n\t\t\t SORTID_ALLOC, 0,\n\t\t\t SORTID_COLOR,\tsview_colors[color_inx],\n\t\t\t SORTID_COLOR_INX, color_inx,\n\t\t\t SORTID_CPUS, tmp_cpu_min,\n\t\t\t SORTID_GRES, step_ptr->gres,\n\t\t\t SORTID_JOBID, step_ptr->step_id,\n\t\t\t SORTID_NAME, step_ptr->name,\n\t\t\t SORTID_NODE_INX, step_ptr->node_inx,\n\t\t\t SORTID_NODELIST, tmp_nodes,\n\t\t\t SORTID_NODES, tmp_node_cnt,\n\t\t\t SORTID_PARTITION, step_ptr->partition,\n\t\t\t SORTID_STATE, job_state_string(state),\n\t\t\t SORTID_TASKS, tmp_task_cnt,\n\t\t\t SORTID_TIME_RUNNING, tmp_time_run,\n\t\t\t SORTID_TIME_START, tmp_time_start,\n\t\t\t SORTID_TIMELIMIT, tmp_time_limit,\n\t\t\t SORTID_UPDATED, 1,\n\t\t\t SORTID_USER_ID, tmp_uname,\n\t\t\t -1);\n\n\txfree(tmp_uname);\n\n\treturn;\n}", "label": 0, "cwe": null, "length": 769 }, { "index": 199098, "code": "calc_control_signal_rate_pid(int32_t motor_setpoint[], uint32_t nr_motors, control_values_pid_t *parameters_pid, control_values_pid_t *ctrl_error, state_data_t *state, state_data_t *setpoint, control_signal_t *ctrl_signal)\n{\n \n static control_signal_t error_d_last = {};\n \n \n /*Update control error - Remember that the state and setpoint uses MULT_FACTOR*/\n ctrl_error->pitch_p = (setpoint->pitch_rate - state->pitch_rate);\n ctrl_error->pitch_i += (setpoint->pitch_rate - state->pitch_rate);\n ctrl_error->pitch_d = ((setpoint->pitch_rate - state->pitch_rate) - error_d_last.torque_pitch);\n ctrl_error->roll_p = (setpoint->roll_rate - state->roll_rate);\n ctrl_error->roll_i += (setpoint->roll_rate - state->roll_rate);\n ctrl_error->roll_d = ((setpoint->roll_rate - state->roll_rate) - error_d_last.torque_roll);\n ctrl_error->yaw_p = (setpoint->yaw_rate - state->yaw_rate);\n ctrl_error->yaw_i += (setpoint->yaw_rate - state->yaw_rate);\n ctrl_error->yaw_d = ((setpoint->yaw_rate - state->yaw_rate) - error_d_last.torque_yaw);\n // TODO no altitude control yet.\n \n error_d_last.torque_pitch = ctrl_error->pitch_p;\n error_d_last.torque_roll = ctrl_error->roll_p;\n error_d_last.torque_yaw = ctrl_error->yaw_p;\n\n /*Calculate control signal*/\n ctrl_signal->torque_pitch = (my_mult(parameters_pid->pitch_p, ctrl_error->pitch_p) + my_mult(parameters_pid->pitch_i, ctrl_error->pitch_i) + my_mult(parameters_pid->pitch_d, ctrl_error->pitch_d)) >> SHIFT_EXP;\n ctrl_signal->torque_roll = (my_mult(parameters_pid->roll_p, ctrl_error->roll_p) + my_mult(parameters_pid->roll_i, ctrl_error->roll_i) + my_mult(parameters_pid->roll_d, ctrl_error->roll_d)) >> SHIFT_EXP;\n ctrl_signal->torque_yaw = (my_mult(parameters_pid->yaw_p, ctrl_error->yaw_p) + my_mult(parameters_pid->yaw_i, ctrl_error->yaw_i) + my_mult(parameters_pid->yaw_d, ctrl_error->yaw_d)) >> SHIFT_EXP;\n // TODO No automatic altitude control yet.\n ctrl_signal->thrust = my_mult(parameters_pid->altitude_p, setpoint->z_vel);\n \n\n if (nr_motors == 4)\n {\n control_allocation_quad_x(ctrl_signal, motor_setpoint);\n }\n \n \n}", "label": 0, "cwe": null, "length": 571 }, { "index": 10836, "code": "send_resolution_request(uint32_t rqst_id,\n\t\t\t uint16_t source_ip_present, \n\t\t\t uint32_t dest_ip,\n\t\t\t uint8_t prefix_length, \n\t\t\t uint32_t service_category){\n int pos = 0;\n struct nhrp_fixed_h *fixed;\n struct nhrp_common_h *common;\n struct nhrp_common_h_short *common_s;\n struct nhrp_extension *extension;\n struct nhrp_cie_short *cie;\n struct nhrp_extension_with_value *extension_with_value;\n uint8_t buff[MAX_PACKET_LENGTH];\n memset(buff,0,MAX_PACKET_LENGTH);\n \n dprintf(\"mpcd: p_factory.c: sending a resolution request %x \",dest_ip);\n \n fixed = (struct nhrp_fixed_h *)buff;\n prefill_fixed_h(fixed);\n fixed->ar_op_type = MPOA_RESOLUTION_REQUEST;\n pos += sizeof(struct nhrp_fixed_h);\n if( source_ip_present ){\n common = (struct nhrp_common_h *)(buff + sizeof(struct nhrp_fixed_h));\n prefill_common_h(common);\n pos += sizeof(struct nhrp_common_h);\n common->dst_protocol_address = dest_ip;\n if(!rqst_id){\n common->request_ID = htonl(Request_ID());\n new_id(ntohl(common->request_ID),dest_ip,MPOA_RESOLUTION_REQUEST);\n }\n else\n common->request_ID = htonl(rqst_id);\n dprintf(\"mpcd: p_factory.c: with request_id %d\\n\",ntohl(common->request_ID));\n }\n else{\n common_s = (struct nhrp_common_h_short *)(buff + sizeof(struct nhrp_fixed_h));\n prefill_common_h_short(common_s);\n pos += sizeof(struct nhrp_common_h_short);\n common_s->dst_protocol_address = dest_ip;\n if(!rqst_id){\n common_s->request_ID = htonl(Request_ID());\n new_id(ntohl(common_s->request_ID),dest_ip,MPOA_RESOLUTION_REQUEST);\n }\n else\n common_s->request_ID = htonl(rqst_id);\n dprintf(\"mpcd: p_factory.c: with request_id %d\\n\",ntohl(common_s->request_ID));\n }\n \n cie = (struct nhrp_cie_short *)(buff + pos);\n cie->prefix_length = MAX_PREFIX_LENGTH;\n pos += sizeof(struct nhrp_cie_short);\n \n fixed->ar_extoff = htons(pos);\n extension = (struct nhrp_extension *)(buff + pos); \n extension->type = htons(MPOA_EGRESS_CACHE_TAG_EXTENSION);\n extension->length = 0;\n pos += sizeof(struct nhrp_extension);\n if(service_category){\n extension_with_value = (struct nhrp_extension_with_value *)(buff + pos);\n extension_with_value->type = htons(MPOA_ATM_SERVICE_CATEGORY_EXTENSION);\n extension_with_value->length = htons(sizeof(service_category));\n extension_with_value->value = htonl(service_category);\n pos += sizeof(struct nhrp_extension_with_value);\n } \n extension = (struct nhrp_extension *)(buff + pos);\n extension->type = htons(NHRP_END_OF_EXTENSIONS);\n extension->length = 0;\n pos += sizeof(struct nhrp_extension);\n\n finish(pos,buff,fixed);\n return send_to_mps(buff,pos);\n}", "label": 0, "cwe": null, "length": 720 }, { "index": 73469, "code": "DecodeV4DBCertEntry(unsigned char *buf, int len)\n{\n certDBEntryCert *entry;\n int certlen;\n int nnlen;\n PLArenaPool *arena;\n \n /* make sure length is at least long enough for the header */\n if ( len < DBCERT_V4_HEADER_LEN ) {\n\tPORT_SetError(SEC_ERROR_BAD_DATABASE);\n\treturn(0);\n }\n\n /* get other lengths */\n certlen = buf[3] << 8 | buf[4];\n nnlen = buf[5] << 8 | buf[6];\n \n /* make sure DB entry is the right size */\n if ( ( certlen + nnlen + DBCERT_V4_HEADER_LEN ) != len ) {\n\tPORT_SetError(SEC_ERROR_BAD_DATABASE);\n\treturn(0);\n }\n\n /* allocate arena */\n arena = PORT_NewArena( DER_DEFAULT_CHUNKSIZE );\n\n if ( !arena ) {\n\tPORT_SetError(SEC_ERROR_NO_MEMORY);\n\treturn(0);\n }\n\t\n /* allocate structure and members */\n entry = (certDBEntryCert *) PORT_ArenaAlloc(arena, sizeof(certDBEntryCert));\n\n if ( !entry ) {\n\tgoto loser;\n }\n\n entry->common.arena = arena;\n entry->common.version = CERT_DB_FILE_VERSION;\n entry->common.type = certDBEntryTypeCert;\n entry->common.flags = 0;\n entry->trust.sslFlags = buf[0];\n entry->trust.emailFlags = buf[1];\n entry->trust.objectSigningFlags = buf[2];\n\n entry->derCert.data = (unsigned char *)PORT_ArenaAlloc(arena, certlen);\n if ( !entry->derCert.data ) {\n\tgoto loser;\n }\n entry->derCert.len = certlen;\n PORT_Memcpy(entry->derCert.data, &buf[DBCERT_V4_HEADER_LEN], certlen);\n\n if ( nnlen ) {\n entry->nickname = (char *) PORT_ArenaAlloc(arena, nnlen);\n if ( !entry->nickname ) {\n goto loser;\n }\n PORT_Memcpy(entry->nickname, &buf[DBCERT_V4_HEADER_LEN + certlen], nnlen);\n \n if (PORT_Strcmp(entry->nickname, \"Server-Cert\") == 0) {\n entry->trust.sslFlags |= CERTDB_USER;\n }\n } else {\n entry->nickname = 0;\n }\n\n return(entry);\n \nloser:\n PORT_FreeArena(arena, PR_FALSE);\n PORT_SetError(SEC_ERROR_NO_MEMORY);\n return(0);\n}", "label": 0, "cwe": null, "length": 546 }, { "index": 548265, "code": "start_master_send_async(char *child_host_name, int child_port, struct in_addr my_s_addr)\n#else\nint\nstart_master_send_async(child_host_name, child_port, my_s_addr)\nchar *child_host_name; \nint child_port;\nstruct in_addr my_s_addr;\n#endif\n{\n\tint rc,master_socket_val;\n\tstruct sockaddr_in addr,raddr;\n\tint port,tmp_port;\n\tint ecount = 0;\n\tstruct timespec req,rem;\n\n\treq.tv_sec = 0;\n\treq.tv_nsec = 10000000;\n\trem.tv_sec = 0;\n\trem.tv_nsec = 10000000;\n\n\n\tport=child_port;\n\tnanosleep(&req,&rem);\n\nover:\n raddr.sin_family = AF_INET;\n raddr.sin_port = htons(port);\n raddr.sin_addr.s_addr = my_s_addr.s_addr;\n master_socket_val = socket(AF_INET, SOCK_STREAM, 0);\n if (master_socket_val < 0)\n {\n perror(\"Master: async socket failed:\");\n exit(23);\n }\n bzero(&addr, sizeof(struct sockaddr_in));\n\ttmp_port=HOST_ASEND_PORT;\n addr.sin_port = htons(tmp_port);\n addr.sin_family = AF_INET;\n addr.sin_addr.s_addr = INADDR_ANY;\n rc = -1;\n while (rc < 0)\n {\n rc = bind(master_socket_val, (struct sockaddr *)&addr,\n sizeof(struct sockaddr_in));\n\t\tif(rc < 0)\n\t\t{\n\t\t\ttmp_port++;\n \taddr.sin_port=htons(tmp_port);\n\t\t\tcontinue;\n\t\t}\n }\n\tif(mdebug ==1)\n\t{\n\t\tprintf(\"Master: Bound async port\\n\");\n\t\tfflush(stdout);\n\t}\n if (rc < 0)\n {\n perror(\"Master: bind async failed\\n\");\n exit(24);\n }\nagain:\n\n rc = connect(master_socket_val, (struct sockaddr *)&raddr, \n\t\t\tsizeof(struct sockaddr_in));\n\tif (rc < 0)\n {\n\t\tif(ecount++ < 300)\n\t\t{\n\t\t/* Really need this sleep for Windows */\n#if defined (Windows)\n\t\t\tsleep(1);\n#else\n\t\t\tnanosleep(&req,&rem);\n#endif\n\t\t\tgoto again;\n\t\t}\n perror(\"Master: async connect failed\\n\");\n close(master_socket_val);\n#if defined (Windows)\n\t\tsleep(1);\n#else\n\t\tnanosleep(&req,&rem);\n#endif\n /*sleep(1);*/\n ecount=0;\n goto over;\n }\n\tif(mdebug ==1)\n\t{\n\t\tprintf(\"Master async Connected\\n\");\n\t\tfflush(stdout);\n\t}\n\treturn (master_socket_val);\n}", "label": 0, "cwe": null, "length": 555 }, { "index": 475160, "code": "slog (gint level, const gchar *fmt, ...) {\n gchar message[BUFSIZ];\n gchar* out;\n va_list vap;\n\n if (L_IS_TYPE (level, L_DEBUG) && !slog_debug) return;\n\n if (g_thread_self () != main_thread)\n g_fprintf (stderr, \"%s\", slogmsg_thread);\n\n if (L_IS_TYPE (level, L_DEBUG))\n g_fprintf (stderr, \"%s\", slogmsg_debug);\n else if (L_IS_TYPE (level, L_FATAL) || L_IS_TYPE (level, L_G_FATAL))\n g_fprintf (stderr, \"%s\", slogmsg_fatal);\n else if (L_IS_TYPE (level, L_ERROR) || L_IS_TYPE (level, L_G_ERROR))\n g_fprintf (stderr, \"%s\", slogmsg_error);\n else if (L_IS_TYPE (level, L_WARNING))\n g_fprintf (stderr, \"%s\", slogmsg_warning);\n else\n g_fprintf (stderr, \"%s\", slogmsg_info);\n\n va_start (vap, fmt);\n vsnprintf (message, BUFSIZ, fmt, vap);\n va_end (vap);\n fprintf (stderr, \"%s\", message);\n\n if (L_IS_GUI (level)) {\n GtkWidget* dialog;\n\n if (L_IS_TYPE (level, L_G_FATAL))\n out = g_strdup_printf (_(\"%s has encountered a serious error and \"\n \"will require a restart. Your working data will be \"\n \"restored when you reload your document. Please \"\n \"report bugs at: http://dev.midnightcoding.org\"),\n PACKAGE_NAME);\n else\n out = g_strdup (message);\n\n dialog = gtk_message_dialog_new (parent, \n GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,\n L_IS_TYPE (level,L_G_INFO)? GTK_MESSAGE_INFO: GTK_MESSAGE_ERROR,\n GTK_BUTTONS_OK,\n \"%s\", message);\n g_free (out);\n\n if (L_IS_TYPE (level, L_G_ERROR))\n gtk_window_set_title (GTK_WINDOW (dialog), \"Error!\");\n else if (L_IS_TYPE (level, L_G_FATAL))\n gtk_window_set_title (GTK_WINDOW (dialog), \"Fatal Error!\");\n else if (L_IS_TYPE (level, L_G_INFO))\n gtk_window_set_title (GTK_WINDOW (dialog), \"Info\");\n\n gtk_dialog_run (GTK_DIALOG (dialog));\n gtk_widget_destroy (dialog);\n }\n\n if (!L_IS_TYPE (level, L_INFO) &&\n !L_IS_TYPE (level, L_DEBUG) && \n !L_IS_TYPE (level, L_ERROR) && \n !L_IS_TYPE (level, L_G_INFO) &&\n !L_IS_TYPE (level, L_G_ERROR))\n exit (1);\n}", "label": 0, "cwe": null, "length": 592 }, { "index": 65412, "code": "ExVCRAdvance ()\n{\n int\t\tn;\n\n n = now.n_frame + (now.d_frame * vcr->dir * (vcr->flip ? -1 : 1));\n\n /* We are still within the valid region, this was a simple advance */\n if (n >= now.s_frame && n <= now.e_frame)\n {\n\tnow.n_frame = n;\n\treturn;\n }\n \n /* Now we have to decide what to do based upon the state of the VCR */\n if (n > now.e_frame)\n {\n\tif (vcr->loop)\n\t{\n\t if (vcr->palin)\n\t {\n\t\tvcr->flip = ! vcr->flip;\n\t\tn = now.n_frame + (now.d_frame * vcr->dir * (vcr->flip ? -1 : 1));\n\t }\n\t else\n\t {\n\t\tn = now.s_frame;\n\t }\n\t}\n\telse\t/* no vcr->loop */\n\t{\n\t if (vcr->palin)\n\t {\n\t\tif (vcr->flip)\n\t\t{\n\t\t vcr->flip = FALSE;\n\t\t vcr->mode = VCR_M_STOP;\n\t\t n = now.e_frame;\n\t\t}\n\t\telse\n\t\t{\n\t\t vcr->flip = ! vcr->flip;\n\t\t n = now.n_frame + (now.d_frame * vcr->dir * (vcr->flip ? -1 : 1));\n\t\t}\n\t }\n\t else\n\t {\n\t\tn = now.s_frame;\n\t\tvcr->mode = VCR_M_STOP;\n\t }\n\t}\n }\n else\t/* n < now.s_frame */\n {\n\tif (vcr->loop)\n\t{\n\t if (vcr->palin)\n\t {\n\t\tvcr->flip = ! vcr->flip;\n\t\tn = now.n_frame + (now.d_frame * vcr->dir * (vcr->flip ? -1 : 1));\n\t }\n\t else\n\t {\n\t\tn = now.e_frame;\n\t }\n\t}\n\telse\t/* no vcr->loop */\n\t{\n\t if (vcr->palin)\n\t {\n\t\tif (vcr->flip)\n\t\t{\n\t\t vcr->flip = FALSE;\n\t\t vcr->mode = VCR_M_STOP;\n\t\t n = now.s_frame;\n\t\t}\n\t\telse\n\t\t{\n\t\t vcr->flip = ! vcr->flip;\n\t\t n = now.n_frame + (now.d_frame * vcr->dir * (vcr->flip ? -1 : 1));\n\t\t}\n\t }\n\t else\n\t {\n\t\tn = now.e_frame;\n\t\tvcr->mode = VCR_M_STOP;\n\t }\n\t}\n }\n\n now.n_frame = (n < now.s_frame) ? now.s_frame : ((n > now.e_frame) ? now.e_frame : n);\n return;\n}", "label": 0, "cwe": null, "length": 607 }, { "index": 87944, "code": "os_get_path_name(char *pathbuf, size_t pathbuflen, const char *fname)\r\n{\r\n const char *lastsep;\r\n const char *p;\r\n size_t len;\r\n int root_path;\r\n \r\n /* find the last separator in the filename */\r\n for (p = fname, lastsep = fname ; *p != '\\0' ; ++p)\r\n {\r\n /* \r\n * if it's a path separator character, remember it as the last one\r\n * we've found so far \r\n */\r\n if (*p == OSPATHCHAR || strchr(OSPATHALT, *p) != 0)\r\n lastsep = p;\r\n }\r\n \r\n /* get the length of the prefix, not including the separator */\r\n len = lastsep - fname;\r\n \r\n /*\r\n * Normally, we don't include the last path separator in the path; for\r\n * example, on Unix, the path of \"/a/b/c\" is \"/a/b\", not \"/a/b/\".\r\n * However, on Unix/DOS-like file systems, a root path *does* require\r\n * the last path separator: the path of \"/a\" is \"/\", not an empty\r\n * string. So, we need to check to see if the file is in a root path,\r\n * and if so, include the final path separator character in the path. \r\n */\r\n for (p = fname, root_path = FALSE ; p != lastsep ; ++p)\r\n {\r\n /*\r\n * if this is NOT a path separator character, we don't have all\r\n * path separator characters before the filename, so we don't have\r\n * a root path \r\n */\r\n if (*p != OSPATHCHAR && strchr(OSPATHALT, *p) == 0)\r\n {\r\n /* note that we don't have a root path */\r\n root_path = FALSE;\r\n \r\n /* no need to look any further */\r\n break;\r\n }\r\n }\r\n\r\n /* if we have a root path, keep the final path separator in the path */\r\n if (root_path)\r\n ++len;\r\n\r\n#ifdef _WIN32\r\n /*\r\n * On DOS, we have a special case: if the path is of the form \"x:\\\",\r\n * where \"x\" is any letter, then we have a root filename and we want to\r\n * include the backslash. \r\n */\r\n if (lastsep == fname + 2\r\n && isalpha(fname[0]) && fname[1] == ':' && fname[2] == '\\\\')\r\n {\r\n /* we have an absolute path - use the full \"x:\\\" sequence */\r\n len = 3;\r\n }\r\n#endif\r\n \r\n /* make sure it fits in our buffer (with a null terminator) */\r\n if (len > pathbuflen - 1)\r\n len = pathbuflen - 1;\r\n\r\n /* copy it and null-terminate it */\r\n memcpy(pathbuf, fname, len);\r\n pathbuf[len] = '\\0';\r\n}", "label": 0, "cwe": null, "length": 643 }, { "index": 835630, "code": "ssl_parse_finished( ssl_context *ssl )\n{\n int ret;\n unsigned int hash_len;\n unsigned char buf[36];\n\n SSL_DEBUG_MSG( 2, ( \"=> parse finished\" ) );\n\n ssl->handshake->calc_finished( ssl, buf, ssl->endpoint ^ 1 );\n\n /*\n * Switch to our negotiated transform and session parameters for inbound data.\n */\n SSL_DEBUG_MSG( 3, ( \"switching to new transform spec for inbound data\" ) );\n ssl->transform_in = ssl->transform_negotiate;\n ssl->session_in = ssl->session_negotiate;\n memset( ssl->in_ctr, 0, 8 );\n\n /*\n * Set the in_msg pointer to the correct location based on IV length\n */\n if( ssl->minor_ver >= SSL_MINOR_VERSION_2 )\n {\n ssl->in_msg = ssl->in_iv + ssl->transform_negotiate->ivlen -\n ssl->transform_negotiate->fixed_ivlen;\n }\n else\n ssl->in_msg = ssl->in_iv;\n\n#if defined(POLARSSL_SSL_HW_RECORD_ACCEL)\n if( ssl_hw_record_activate != NULL)\n {\n if( ( ret = ssl_hw_record_activate( ssl, SSL_CHANNEL_INBOUND ) ) != 0 )\n {\n SSL_DEBUG_RET( 1, \"ssl_hw_record_activate\", ret );\n return( POLARSSL_ERR_SSL_HW_ACCEL_FAILED );\n }\n }\n#endif\n\n if( ( ret = ssl_read_record( ssl ) ) != 0 )\n {\n SSL_DEBUG_RET( 1, \"ssl_read_record\", ret );\n return( ret );\n }\n\n if( ssl->in_msgtype != SSL_MSG_HANDSHAKE )\n {\n SSL_DEBUG_MSG( 1, ( \"bad finished message\" ) );\n return( POLARSSL_ERR_SSL_UNEXPECTED_MESSAGE );\n }\n\n // TODO TLS/1.2 Hash length is determined by cipher suite (Page 63)\n hash_len = ( ssl->minor_ver == SSL_MINOR_VERSION_0 ) ? 36 : 12;\n\n if( ssl->in_msg[0] != SSL_HS_FINISHED ||\n ssl->in_hslen != 4 + hash_len )\n {\n SSL_DEBUG_MSG( 1, ( \"bad finished message\" ) );\n return( POLARSSL_ERR_SSL_BAD_HS_FINISHED );\n }\n\n if( safer_memcmp( ssl->in_msg + 4, buf, hash_len ) != 0 )\n {\n SSL_DEBUG_MSG( 1, ( \"bad finished message\" ) );\n return( POLARSSL_ERR_SSL_BAD_HS_FINISHED );\n }\n\n ssl->verify_data_len = hash_len;\n memcpy( ssl->peer_verify_data, buf, hash_len );\n\n if( ssl->handshake->resume != 0 )\n {\n if( ssl->endpoint == SSL_IS_CLIENT )\n ssl->state = SSL_CLIENT_CHANGE_CIPHER_SPEC;\n\n if( ssl->endpoint == SSL_IS_SERVER )\n ssl->state = SSL_HANDSHAKE_WRAPUP;\n }\n else\n ssl->state++;\n\n SSL_DEBUG_MSG( 2, ( \"<= parse finished\" ) );\n\n return( 0 );\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 681 }, { "index": 767790, "code": "softingcs_probe(struct pcmcia_device *pcmcia)\n{\n\tint ret;\n\tstruct platform_device *pdev;\n\tconst struct softing_platform_data *pdat;\n\tstruct resource *pres;\n\tstruct dev {\n\t\tstruct platform_device pdev;\n\t\tstruct resource res[2];\n\t} *dev;\n\n\t/* find matching platform_data */\n\tpdat = softingcs_find_platform_data(pcmcia->manf_id, pcmcia->card_id);\n\tif (!pdat)\n\t\treturn -ENOTTY;\n\n\t/* setup pcmcia device */\n\tpcmcia->config_flags |= CONF_ENABLE_IRQ | CONF_AUTO_SET_IOMEM |\n\t\tCONF_AUTO_SET_VPP | CONF_AUTO_CHECK_VCC;\n\tret = pcmcia_loop_config(pcmcia, softingcs_probe_config, (void *)pdat);\n\tif (ret)\n\t\tgoto pcmcia_failed;\n\n\tret = pcmcia_enable_device(pcmcia);\n\tif (ret < 0)\n\t\tgoto pcmcia_failed;\n\n\tpres = pcmcia->resource[PCMCIA_IOMEM_0];\n\tif (!pres) {\n\t\tret = -EBADF;\n\t\tgoto pcmcia_bad;\n\t}\n\n\t/* create softing platform device */\n\tdev = kzalloc(sizeof(*dev), GFP_KERNEL);\n\tif (!dev) {\n\t\tret = -ENOMEM;\n\t\tgoto mem_failed;\n\t}\n\tdev->pdev.resource = dev->res;\n\tdev->pdev.num_resources = ARRAY_SIZE(dev->res);\n\tdev->pdev.dev.release = softingcs_pdev_release;\n\n\tpdev = &dev->pdev;\n\tpdev->dev.platform_data = (void *)pdat;\n\tpdev->dev.parent = &pcmcia->dev;\n\tpcmcia->priv = pdev;\n\n\t/* platform device resources */\n\tpdev->resource[0].flags = IORESOURCE_MEM;\n\tpdev->resource[0].start = pres->start;\n\tpdev->resource[0].end = pres->end;\n\n\tpdev->resource[1].flags = IORESOURCE_IRQ;\n\tpdev->resource[1].start = pcmcia->irq;\n\tpdev->resource[1].end = pdev->resource[1].start;\n\n\t/* platform device setup */\n\tspin_lock(&softingcs_index_lock);\n\tpdev->id = softingcs_index++;\n\tspin_unlock(&softingcs_index_lock);\n\tpdev->name = \"softing\";\n\tdev_set_name(&pdev->dev, \"softingcs.%i\", pdev->id);\n\tret = platform_device_register(pdev);\n\tif (ret < 0)\n\t\tgoto platform_failed;\n\n\tdev_info(&pcmcia->dev, \"created %s\\n\", dev_name(&pdev->dev));\n\treturn 0;\n\nplatform_failed:\n\tkfree(dev);\nmem_failed:\npcmcia_bad:\npcmcia_failed:\n\tpcmcia_disable_device(pcmcia);\n\tpcmcia->priv = NULL;\n\treturn ret ?: -ENODEV;\n}", "label": 0, "cwe": null, "length": 590 }, { "index": 79010, "code": "create(char fs_name, struct path *file_path, int dir)\n{\n int dev = get_device(fs_name);\n\n if (dev < 0) {\n /* Bad fs_name */\n return dev;\n }\n\n struct path *next = file_path;\n struct dir_queue_t *current_dir = device_array[dev].root->dirHead;\n fcb *current_file = current_dir->tail;\n\n fcb *newfile;\n struct dir_queue_t *new_dirqueue;\n struct block_queue_t *new_blockqueue;\n\n while (next->next != null) {\n if (current_file == null) {\n /* We reached the end of the directory and didn't find the\n * specified directory in the path. Since create_file does not\n * recursively create directories, this is an error. */\n return ERROR_DIR_NOT_FOUND;\n\n } else if (filename_eq(current_file->filename, next->string)) {\n if (next->next == null) {\n /* End of the given path; this is the file to create. We\n * found the file, so this means it's an error. */\n return ERROR_FILE_ALREADY_EXISTS;\n } else if (!(current_file->bits & FCB_DIR_BITMASK)) {\n /* One of the directories in the path is actually a file.\n * This is also an error. */\n return ERROR_DIR_IS_FILE;\n } else {\n /* We found one of the directories in the given path.\n * Continue recursing. */\n next = next->next;\n current_dir = current_file->dirHead;\n current_file = current_dir->tail;\n }\n\n } else {\n current_file = current_file->next;\n }\n }\n /* If we reach the end of the while loop, it means that the given path\n * already exists, and the given file does not. So create the file.*/\n newfile = malloc_file();\n new_blockqueue = malloc_block_queue();\n block_init_queue(new_blockqueue);\n\n if (dir) {\n new_dirqueue = malloc_dir_queue();\n dir_init_queue(new_dirqueue);\n } else {\n new_dirqueue = null;\n }\n\n block_init_queue(new_blockqueue);\n\n filename_copy(newfile->filename, next->string);\n newfile->bits = dir;\n newfile->dirHead = new_dirqueue;\n newfile->parent_dir = current_dir;\n newfile->block_queue = new_blockqueue;\n newfile->device_num = dev;\n newfile->error = 0;\n\n dir_enqueue(current_dir, newfile);\n\n return ERROR_SUCCESS;\n}", "label": 0, "cwe": null, "length": 554 }, { "index": 871960, "code": "Erase(LookedAhead)\n\nint *LookedAhead;\n{\n struct ka BB, SBB;\n struct ks *SList;\n int Xfirst = 0,Yfirst = 0;\n int Undo = False;\n int Modified = 0;\n int FirstTime = True;\n char TTmp[8];\n char Types[4];\n\n MenuSelect(MenuERASE);\n\n Types[0] = CDBOX;\n Types[1] = CDPOLYGON;\n Types[3] = '\\0';\n\n strcpy(TTmp,Parameters.kpSelectTypes);\n strcpy(Parameters.kpSelectTypes,Types);\n\n ShowPrompt(\"Point to diagonal of rectangle to erase.\");\n\ntop:\n loop {\n switch (PointLoop(LookedAhead)) {\n case PL_ESC:\n case PL_CMD:\n goto quit;\n case PL_UND:\n if (FirstTime)\n goto quit;\n sq_swap();\n EraseBox(&SBB);\n Redisplay(&SBB);\n FBTransfer();\n if (Undo) {\n Undo = False;\n Modified++;\n }\n else {\n Undo = True;\n Modified--;\n }\n continue;\n case PL_PCW:\n Xfirst = KicCursor.kcX;\n Yfirst = KicCursor.kcY;\n FBSetRubberBanding('r');\n break;\n }\n\n loop {\n switch (PointLoop(LookedAhead)) {\n case PL_ESC:\n case PL_CMD:\n goto quit;\n case PL_UND:\n FBSetRubberBanding(0);\n goto top;\n case PL_PCW:\n if (KicCursor.kcX == Xfirst &&\n KicCursor.kcY == Yfirst) continue;\n FBSetRubberBanding(0);\n break;\n }\n break;\n }\n\n BB.kaLeft = min(Xfirst,KicCursor.kcX);\n BB.kaRight = max(Xfirst,KicCursor.kcX);\n BB.kaBottom = min(Yfirst,KicCursor.kcY);\n BB.kaTop = max(Yfirst,KicCursor.kcY);\n\n SList = SelectItems(&BB,False);\n if (SList == NULL) continue;\n SLBB(SList,&SBB);\n SQRestore(False);\n do_erase(SList,&BB);\n SLFree(SList);\n EraseBox(&SBB);\n Redisplay(&SBB);\n FBTransfer();\n Modified++;\n Undo = False;\n FirstTime = False;\n }\n\nquit:\n\n FBSetRubberBanding(0);\n strcpy(Parameters.kpSelectTypes,TTmp);\n SQRestore(False);\n MenuDeselect(MenuERASE);\n ErasePrompt();\n if (Modified)\n Parameters.kpModified = True;\n}", "label": 0, "cwe": null, "length": 596 }, { "index": 685559, "code": "conf_report (void)\n{\n\tstruct conf_binding *cb, *last = NULL;\n\tint i;\n\tchar *current_section = (char *)0;\n\tstruct dumper *dumper, *dnode;\n\n\tdumper = dnode = (struct dumper *)calloc (1, sizeof *dumper);\n\tif (!dumper)\n\t\tgoto mem_fail;\n\n\tfprintf(stderr, \"conf_report: dumping running configuration\");\n\n\tfor (i = 0; i < sizeof conf_bindings / sizeof conf_bindings[0]; i++)\n\t\tfor (cb = LIST_FIRST (&conf_bindings[i]); cb;\n\t\t cb = LIST_NEXT (cb, link)) {\n\t\t\tif (!cb->is_default) {\n\t\t\t\t/* Dump this entry */\n\t\t\t\tif (!current_section ||\n\t\t\t\t strcmp (cb->section, current_section)) {\n\t\t\t\t\tif (current_section) {\n\t\t\t\t\t\tdnode->s = malloc (strlen (current_section) + 3);\n\t\t\t\t\t\tif (!dnode->s)\n\t\t\t\t\t\t\tgoto mem_fail;\n\n\t\t\t\t\t\tsprintf (dnode->s, \"[%s]\", current_section);\n\t\t\t\t\t\tdnode->next\n\t\t\t\t\t\t\t= (struct dumper *)calloc (1, sizeof (struct dumper));\n\t\t\t\t\t\tdnode = dnode->next;\n\t\t\t\t\t\tif (!dnode)\n\t\t\t\t\t\t\tgoto mem_fail;\n\n\t\t\t\t\t\tdnode->s = \"\";\n\t\t\t\t\t\tdnode->next\n\t\t\t\t\t\t\t= (struct dumper *)calloc (1, sizeof (struct dumper));\n\t\t\t\t\t\tdnode = dnode->next;\n\t\t\t\t\t\tif (!dnode)\n\t\t\t\t\t\t\tgoto mem_fail;\n\t\t\t\t\t}\n\t\t\t\t\tcurrent_section = cb->section;\n\t\t\t\t}\n\t\t\t\tdnode->s = cb->tag;\n\t\t\t\tdnode->v = cb->value;\n\t\t\t\tdnode->next = (struct dumper *)calloc (1, sizeof (struct dumper));\n\t\t\t\tdnode = dnode->next;\n\t\t\t\tif (!dnode)\n\t\t\t\t\tgoto mem_fail;\n\t\t\t\tlast = cb;\n\t\t\t}\n\t\t}\n\n\tif (last) {\n\t\tdnode->s = malloc (strlen (last->section) + 3);\n\t\tif (!dnode->s)\n\t\t\tgoto mem_fail;\n\t\tsprintf (dnode->s, \"[%s]\", last->section);\n\t}\n\n\tconf_report_dump (dumper);\n\n\treturn;\n\n mem_fail:\n\twarn(\"conf_report: memory allocation failure.\");\n\twhile ((dnode = dumper) != NULL) {\n\t\tdumper = dumper->next;\n\t\tif (dnode->s)\n\t\t\tfree (dnode->s);\n\t\tfree (dnode);\n\t}\n\treturn;\n}", "label": 0, "cwe": null, "length": 517 }, { "index": 920457, "code": "qpol_policy_add_cond_rule_traceback(qpol_policy_t * policy)\n{\n\tpolicydb_t *db = NULL;\n\tcond_node_t *cond = NULL;\n\tcond_av_list_t *list_ptr = NULL;\n\tqpol_iterator_t *iter = NULL;\n\tavtab_ptr_t rule = NULL;\n\tint error = 0;\n\tuint32_t rules = 0;\n\n\tINFO(policy, \"%s\", \"Building conditional rules tables. (Step 5 of 5)\");\n\tif (!policy) {\n\t\tERR(policy, \"%s\", strerror(EINVAL));\n\t\terrno = EINVAL;\n\t\treturn STATUS_ERR;\n\t}\n\n\tdb = &policy->p->p;\n\n\trules = (QPOL_RULE_ALLOW | QPOL_RULE_AUDITALLOW | QPOL_RULE_DONTAUDIT);\n\tif (!(policy->options & QPOL_POLICY_OPTION_NO_NEVERALLOWS))\n\t\trules |= QPOL_RULE_NEVERALLOW;\n\n\t/* mark all unconditional rules as enabled */\n\tif (qpol_policy_get_avrule_iter(policy, rules, &iter))\n\t\treturn STATUS_ERR;\n\tfor (; !qpol_iterator_end(iter); qpol_iterator_next(iter)) {\n\t\tif (qpol_iterator_get_item(iter, (void **)&rule)) {\n\t\t\terror = errno;\n\t\t\tERR(policy, \"%s\", strerror(error));\n\t\t\terrno = error;\n\t\t\treturn STATUS_ERR;\n\t\t}\n\t\trule->parse_context = NULL;\n\t\trule->merged = QPOL_COND_RULE_ENABLED;\n\t}\n\tqpol_iterator_destroy(&iter);\n\tif (qpol_policy_get_terule_iter(policy, (QPOL_RULE_TYPE_TRANS | QPOL_RULE_TYPE_CHANGE | QPOL_RULE_TYPE_MEMBER), &iter))\n\t\treturn STATUS_ERR;\n\tfor (; !qpol_iterator_end(iter); qpol_iterator_next(iter)) {\n\t\tif (qpol_iterator_get_item(iter, (void **)&rule)) {\n\t\t\terror = errno;\n\t\t\tERR(policy, \"%s\", strerror(error));\n\t\t\terrno = error;\n\t\t\treturn STATUS_ERR;\n\t\t}\n\t\trule->parse_context = NULL;\n\t\trule->merged = QPOL_COND_RULE_ENABLED;\n\t}\n\tqpol_iterator_destroy(&iter);\n\n\tfor (cond = db->cond_list; cond; cond = cond->next) {\n\t\t/* evaluate cond */\n\t\tcond->cur_state = cond_evaluate_expr(db, cond->expr);\n\t\tif (cond->cur_state < 0) {\n\t\t\tERR(policy, \"Error evaluating conditional: %s\", strerror(EILSEQ));\n\t\t\terrno = EILSEQ;\n\t\t\treturn STATUS_ERR;\n\t\t}\n\n\t\t/* walk true list */\n\t\tfor (list_ptr = cond->true_list; list_ptr; list_ptr = list_ptr->next) {\n\t\t\t/* field not used after parse, now stores cond */\n\t\t\tlist_ptr->node->parse_context = (void *)cond;\n\t\t\t/* field not used (except by write),\n\t\t\t * now storing list and enabled flags */\n\t\t\tlist_ptr->node->merged = QPOL_COND_RULE_LIST;\n\t\t\tif (cond->cur_state)\n\t\t\t\tlist_ptr->node->merged |= QPOL_COND_RULE_ENABLED;\n\t\t}\n\n\t\t/* walk false list */\n\t\tfor (list_ptr = cond->false_list; list_ptr; list_ptr = list_ptr->next) {\n\t\t\t/* field not used after parse, now stores cond */\n\t\t\tlist_ptr->node->parse_context = (void *)cond;\n\t\t\t/* field not used (except by write),\n\t\t\t * now storing list and enabled flags */\n\t\t\tlist_ptr->node->merged = 0;\t/* i.e. !QPOL_COND_RULE_LIST */\n\t\t\tif (!cond->cur_state)\n\t\t\t\tlist_ptr->node->merged |= QPOL_COND_RULE_ENABLED;\n\t\t}\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 773 }, { "index": 664238, "code": "start_glib_signal (GMarkupParseContext *context,\n\t\t const gchar *element_name,\n\t\t const gchar **attribute_names,\n\t\t const gchar **attribute_values,\n\t\t ParseContext *ctx,\n\t\t GError **error)\n{\n const gchar *name;\n const gchar *when;\n const gchar *no_recurse;\n const gchar *detailed;\n const gchar *action;\n const gchar *no_hooks;\n const gchar *has_class_closure;\n GIrNodeInterface *iface;\n GIrNodeSignal *signal;\n\n if (!(strcmp (element_name, \"glib:signal\") == 0 &&\n\t(ctx->state == STATE_CLASS ||\n\t ctx->state == STATE_INTERFACE)))\n return FALSE;\n\n if (!introspectable_prelude (context, attribute_names, attribute_values, ctx, STATE_FUNCTION))\n return TRUE;\n\n name = find_attribute (\"name\", attribute_names, attribute_values);\n when = find_attribute (\"when\", attribute_names, attribute_values);\n no_recurse = find_attribute (\"no-recurse\", attribute_names, attribute_values);\n detailed = find_attribute (\"detailed\", attribute_names, attribute_values);\n action = find_attribute (\"action\", attribute_names, attribute_values);\n no_hooks = find_attribute (\"no-hooks\", attribute_names, attribute_values);\n has_class_closure = find_attribute (\"has-class-closure\", attribute_names, attribute_values);\n\n if (name == NULL)\n {\n MISSING_ATTRIBUTE (context, error, element_name, \"name\");\n return FALSE;\n }\n signal = (GIrNodeSignal *)_g_ir_node_new (G_IR_NODE_SIGNAL,\n\t\t\t\t\t ctx->current_module);\n\n ((GIrNode *)signal)->name = g_strdup (name);\n\n signal->run_first = FALSE;\n signal->run_last = FALSE;\n signal->run_cleanup = FALSE;\n if (when == NULL || g_ascii_strcasecmp (when, \"LAST\") == 0)\n signal->run_last = TRUE;\n else if (g_ascii_strcasecmp (when, \"FIRST\") == 0)\n signal->run_first = TRUE;\n else\n signal->run_cleanup = TRUE;\n\n if (no_recurse && strcmp (no_recurse, \"1\") == 0)\n signal->no_recurse = TRUE;\n else\n signal->no_recurse = FALSE;\n if (detailed && strcmp (detailed, \"1\") == 0)\n signal->detailed = TRUE;\n else\n signal->detailed = FALSE;\n if (action && strcmp (action, \"1\") == 0)\n signal->action = TRUE;\n else\n signal->action = FALSE;\n if (no_hooks && strcmp (no_hooks, \"1\") == 0)\n signal->no_hooks = TRUE;\n else\n signal->no_hooks = FALSE;\n if (has_class_closure && strcmp (has_class_closure, \"1\") == 0)\n signal->has_class_closure = TRUE;\n else\n signal->has_class_closure = FALSE;\n\n iface = (GIrNodeInterface *)CURRENT_NODE (ctx);\n iface->members = g_list_append (iface->members, signal);\n\n push_node (ctx, (GIrNode *)signal);\n\n return TRUE;\n}", "label": 0, "cwe": null, "length": 693 }, { "index": 216612, "code": "affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_result, int create)\n{\n\tstruct super_block\t*sb = inode->i_sb;\n\tstruct buffer_head\t*ext_bh;\n\tu32\t\t\t ext;\n\n\tpr_debug(\"%s(%lu, %llu)\\n\", __func__, inode->i_ino,\n\t\t (unsigned long long)block);\n\n\tBUG_ON(block > (sector_t)0x7fffffffUL);\n\n\tif (block >= AFFS_I(inode)->i_blkcnt) {\n\t\tif (block > AFFS_I(inode)->i_blkcnt || !create)\n\t\t\tgoto err_big;\n\t} else\n\t\tcreate = 0;\n\n\t//lock cache\n\taffs_lock_ext(inode);\n\n\text = (u32)block / AFFS_SB(sb)->s_hashsize;\n\tblock -= ext * AFFS_SB(sb)->s_hashsize;\n\text_bh = affs_get_extblock(inode, ext);\n\tif (IS_ERR(ext_bh))\n\t\tgoto err_ext;\n\tmap_bh(bh_result, sb, (sector_t)be32_to_cpu(AFFS_BLOCK(sb, ext_bh, block)));\n\n\tif (create) {\n\t\tu32 blocknr = affs_alloc_block(inode, ext_bh->b_blocknr);\n\t\tif (!blocknr)\n\t\t\tgoto err_alloc;\n\t\tset_buffer_new(bh_result);\n\t\tAFFS_I(inode)->mmu_private += AFFS_SB(sb)->s_data_blksize;\n\t\tAFFS_I(inode)->i_blkcnt++;\n\n\t\t/* store new block */\n\t\tif (bh_result->b_blocknr)\n\t\t\taffs_warning(sb, \"get_block\",\n\t\t\t\t \"block already set (%llx)\",\n\t\t\t\t (unsigned long long)bh_result->b_blocknr);\n\t\tAFFS_BLOCK(sb, ext_bh, block) = cpu_to_be32(blocknr);\n\t\tAFFS_HEAD(ext_bh)->block_count = cpu_to_be32(block + 1);\n\t\taffs_adjust_checksum(ext_bh, blocknr - bh_result->b_blocknr + 1);\n\t\tbh_result->b_blocknr = blocknr;\n\n\t\tif (!block) {\n\t\t\t/* insert first block into header block */\n\t\t\tu32 tmp = be32_to_cpu(AFFS_HEAD(ext_bh)->first_data);\n\t\t\tif (tmp)\n\t\t\t\taffs_warning(sb, \"get_block\", \"first block already set (%d)\", tmp);\n\t\t\tAFFS_HEAD(ext_bh)->first_data = cpu_to_be32(blocknr);\n\t\t\taffs_adjust_checksum(ext_bh, blocknr - tmp);\n\t\t}\n\t}\n\n\taffs_brelse(ext_bh);\n\t//unlock cache\n\taffs_unlock_ext(inode);\n\treturn 0;\n\nerr_big:\n\taffs_error(inode->i_sb, \"get_block\", \"strange block request %llu\",\n\t\t (unsigned long long)block);\n\treturn -EIO;\nerr_ext:\n\t// unlock cache\n\taffs_unlock_ext(inode);\n\treturn PTR_ERR(ext_bh);\nerr_alloc:\n\tbrelse(ext_bh);\n\tclear_buffer_mapped(bh_result);\n\tbh_result->b_bdev = NULL;\n\t// unlock cache\n\taffs_unlock_ext(inode);\n\treturn -ENOSPC;\n}", "label": 0, "cwe": null, "length": 657 }, { "index": 69976, "code": "FindActions(struct lemon *lemp)\n{\n int i,j;\n struct config *cfp;\n struct state *stp;\n struct symbol *sp;\n struct rule *rp;\n\n /* Add all of the reduce actions \n ** A reduce action is added for each element of the followset of\n ** a configuration which has its dot at the extreme right.\n */\n for(i=0; instate; i++){ /* Loop over all states */\n stp = lemp->sorted[i];\n for(cfp=stp->cfp; cfp; cfp=cfp->next){ /* Loop over all configurations */\n if( cfp->rp->nrhs==cfp->dot ){ /* Is dot at extreme right? */\n for(j=0; jnterminal; j++){\n if( SetFind(cfp->fws,j) ){\n /* Add a reduce action to the state \"stp\" which will reduce by the\n ** rule \"cfp->rp\" if the lookahead symbol is \"lemp->symbols[j]\" */\n Action_add(&stp->ap,REDUCE,lemp->symbols[j],(char *)cfp->rp);\n }\n }\n }\n }\n }\n\n /* Add the accepting token */\n if( lemp->start ){\n sp = Symbol_find(lemp->start);\n if( sp==0 ) sp = lemp->rule->lhs;\n }else{\n sp = lemp->rule->lhs;\n }\n /* Add to the first state (which is always the starting state of the\n ** finite state machine) an action to ACCEPT if the lookahead is the\n ** start nonterminal. */\n Action_add(&lemp->sorted[0]->ap,ACCEPT,sp,0);\n\n /* Resolve conflicts */\n for(i=0; instate; i++){\n struct action *ap, *nap;\n struct state *stp;\n stp = lemp->sorted[i];\n /* assert( stp->ap ); */\n stp->ap = Action_sort(stp->ap);\n for(ap=stp->ap; ap && ap->next; ap=ap->next){\n for(nap=ap->next; nap && nap->sp==ap->sp; nap=nap->next){\n /* The two actions \"ap\" and \"nap\" have the same lookahead.\n ** Figure out which one should be used */\n lemp->nconflict += resolve_conflict(ap,nap);\n }\n }\n }\n\n /* Report an error for each rule that can never be reduced. */\n for(rp=lemp->rule; rp; rp=rp->next) rp->canReduce = LEMON_FALSE;\n for(i=0; instate; i++){\n struct action *ap;\n for(ap=lemp->sorted[i]->ap; ap; ap=ap->next){\n if( ap->type==REDUCE ) ap->x.rp->canReduce = LEMON_TRUE;\n }\n }\n for(rp=lemp->rule; rp; rp=rp->next){\n if( rp->canReduce ) continue;\n ErrorMsg(lemp->filename,rp->ruleline,\"This rule can not be reduced.\\n\");\n lemp->errorcnt++;\n }\n}", "label": 0, "cwe": null, "length": 718 }, { "index": 15737, "code": "getFeasibleSuccessors(TerminatorInst &TI,\n SmallVectorImpl &Succs,\n bool AggressiveUndef) {\n Succs.resize(TI.getNumSuccessors());\n if (TI.getNumSuccessors() == 0) return;\n \n if (BranchInst *BI = dyn_cast(&TI)) {\n if (BI->isUnconditional()) {\n Succs[0] = true;\n return;\n }\n \n LatticeVal BCValue;\n if (AggressiveUndef)\n BCValue = getOrInitValueState(BI->getCondition());\n else\n BCValue = getLatticeState(BI->getCondition());\n \n if (BCValue == LatticeFunc->getOverdefinedVal() ||\n BCValue == LatticeFunc->getUntrackedVal()) {\n // Overdefined condition variables can branch either way.\n Succs[0] = Succs[1] = true;\n return;\n }\n\n // If undefined, neither is feasible yet.\n if (BCValue == LatticeFunc->getUndefVal())\n return;\n\n Constant *C = LatticeFunc->GetConstant(BCValue, BI->getCondition(), *this);\n if (!C || !isa(C)) {\n // Non-constant values can go either way.\n Succs[0] = Succs[1] = true;\n return;\n }\n\n // Constant condition variables mean the branch can only go a single way\n Succs[C->isNullValue()] = true;\n return;\n }\n \n if (isa(TI)) {\n // Invoke instructions successors are always executable.\n // TODO: Could ask the lattice function if the value can throw.\n Succs[0] = Succs[1] = true;\n return;\n }\n \n if (isa(TI)) {\n Succs.assign(Succs.size(), true);\n return;\n }\n \n SwitchInst &SI = cast(TI);\n LatticeVal SCValue;\n if (AggressiveUndef)\n SCValue = getOrInitValueState(SI.getCondition());\n else\n SCValue = getLatticeState(SI.getCondition());\n \n if (SCValue == LatticeFunc->getOverdefinedVal() ||\n SCValue == LatticeFunc->getUntrackedVal()) {\n // All destinations are executable!\n Succs.assign(TI.getNumSuccessors(), true);\n return;\n }\n \n // If undefined, neither is feasible yet.\n if (SCValue == LatticeFunc->getUndefVal())\n return;\n \n Constant *C = LatticeFunc->GetConstant(SCValue, SI.getCondition(), *this);\n if (!C || !isa(C)) {\n // All destinations are executable!\n Succs.assign(TI.getNumSuccessors(), true);\n return;\n }\n SwitchInst::CaseIt Case = SI.findCaseValue(cast(C));\n Succs[Case.getSuccessorIndex()] = true;\n}", "label": 0, "cwe": null, "length": 660 }, { "index": 67057, "code": "configure_pcie_bridge(struct pci_dev *pci)\n{\n\tenum { PEX811X, PI7C9X110, XIO2001 };\n\tstatic const struct pci_device_id bridge_ids[] = {\n\t\t{ PCI_VDEVICE(PLX, 0x8111), .driver_data = PEX811X },\n\t\t{ PCI_VDEVICE(PLX, 0x8112), .driver_data = PEX811X },\n\t\t{ PCI_DEVICE(0x12d8, 0xe110), .driver_data = PI7C9X110 },\n\t\t{ PCI_VDEVICE(TI, 0x8240), .driver_data = XIO2001 },\n\t\t{ }\n\t};\n\tstruct pci_dev *bridge;\n\tconst struct pci_device_id *id;\n\tu32 tmp;\n\n\tif (!pci->bus || !pci->bus->self)\n\t\treturn;\n\tbridge = pci->bus->self;\n\n\tid = pci_match_id(bridge_ids, bridge);\n\tif (!id)\n\t\treturn;\n\n\tswitch (id->driver_data) {\n\tcase PEX811X:\t/* PLX PEX8111/PEX8112 PCIe/PCI bridge */\n\t\tpci_read_config_dword(bridge, 0x48, &tmp);\n\t\ttmp |= 1;\t/* enable blind prefetching */\n\t\ttmp |= 1 << 11;\t/* enable beacon generation */\n\t\tpci_write_config_dword(bridge, 0x48, tmp);\n\n\t\tpci_write_config_dword(bridge, 0x84, 0x0c);\n\t\tpci_read_config_dword(bridge, 0x88, &tmp);\n\t\ttmp &= ~(7 << 27);\n\t\ttmp |= 2 << 27;\t/* set prefetch size to 128 bytes */\n\t\tpci_write_config_dword(bridge, 0x88, tmp);\n\t\tbreak;\n\n\tcase PI7C9X110:\t/* Pericom PI7C9X110 PCIe/PCI bridge */\n\t\tpci_read_config_dword(bridge, 0x40, &tmp);\n\t\ttmp |= 1;\t/* park the PCI arbiter to the sound chip */\n\t\tpci_write_config_dword(bridge, 0x40, tmp);\n\t\tbreak;\n\n\tcase XIO2001: /* Texas Instruments XIO2001 PCIe/PCI bridge */\n\t\tpci_read_config_dword(bridge, 0xe8, &tmp);\n\t\ttmp &= ~0xf;\t/* request length limit: 64 bytes */\n\t\ttmp &= ~(0xf << 8);\n\t\ttmp |= 1 << 8;\t/* request count limit: one buffer */\n\t\tpci_write_config_dword(bridge, 0xe8, tmp);\n\t\tbreak;\n\t}\n}", "label": 0, "cwe": null, "length": 576 }, { "index": 122539, "code": "DrealFlattenFigure()\n{\n rdsfig_list *Figure;\n rdsins_list *ScanIns;\n rdsrec_list *ScanRec;\n rdsrec_list *DelRec;\n rdsrec_list **Previous;\n char Layer;\n\n rdsbegin();\n\n for ( ScanIns = DrealFigureRds->INSTANCE;\n ScanIns != (rdsins_list *)NULL;\n ScanIns = ScanIns->NEXT )\n {\n for ( Layer = 0; Layer < RDS_MAX_LAYER; Layer++ )\n {\n ScanRec = ScanIns->LAYERTAB[ Layer ];\n\n ScanIns->LAYERTAB[ Layer ] = (rdsrec_list *)NULL;\n\n while ( ScanRec != (rdsrec_list *)NULL )\n {\n DelRec = ScanRec;\n ScanRec = ScanRec->NEXT;\n\n DrealEraseRectangle( DelRec );\n\n freerdsrec( DelRec, DREAL_SIZE );\n }\n }\n }\n\n Figure = addrdsfig( \"_ludo_\", DREAL_SIZE );\n Figure->INSTANCE = DrealFigureRds->INSTANCE;\n DrealFigureRds->INSTANCE = (rdsins_list *)NULL;\n\n Drealrflattenrdsfig( Figure, RDS_YES, RDS_NO );\n\n for ( Layer = 0; Layer < RDS_MAX_LAYER; Layer++ )\n {\n Previous = &DrealFigureRds->LAYERTAB[ Layer ];\n ScanRec = Figure->LAYERTAB[ Layer ]; \n\n while ( ScanRec != (rdsrec_list *)NULL )\n {\n DREAL_PREVIOUS_L( ScanRec ) = Previous;\n Previous = &ScanRec->NEXT;\n\n DrealInsertRectangle( ScanRec );\n\n if ( ScanRec->NEXT == (rdsrec_list *)NULL )\n {\n ScanRec->NEXT = DrealFigureRds->LAYERTAB[ Layer ];\n DrealFigureRds->LAYERTAB[ Layer ] = Figure->LAYERTAB[ Layer ];\n Figure->LAYERTAB[ Layer ] = (rdsrec_list *)NULL;\n\n if ( ScanRec->NEXT != (rdsrec_list *)NULL )\n {\n DREAL_PREVIOUS_L( ScanRec->NEXT ) = &ScanRec->NEXT;\n }\n\n break;\n }\n\n ScanRec = ScanRec->NEXT;\n }\n }\n\n delrdsfig( \"_ludo_\" );\n\n rdsend();\n}", "label": 0, "cwe": null, "length": 530 }, { "index": 48065, "code": "cdio_open_cdrdao (const char *psz_cue_name)\n{\n CdIo_t *ret;\n _img_private_t *p_data;\n\n cdio_funcs_t _funcs;\n \n memset( &_funcs, 0, sizeof(_funcs) );\n \n _funcs.eject_media = _eject_media_image;\n _funcs.free = _free_image;\n _funcs.get_arg = _get_arg_image;\n _funcs.get_cdtext = get_cdtext_generic;\n _funcs.get_devices = cdio_get_devices_cdrdao;\n _funcs.get_default_device = cdio_get_default_device_cdrdao;\n _funcs.get_disc_last_lsn = get_disc_last_lsn_cdrdao;\n _funcs.get_discmode = _get_discmode_image;\n _funcs.get_drive_cap = _get_drive_cap_image;\n _funcs.get_first_track_num = _get_first_track_num_image;\n _funcs.get_hwinfo = get_hwinfo_cdrdao;\n _funcs.get_media_changed = get_media_changed_image;\n _funcs.get_mcn = _get_mcn_image;\n _funcs.get_num_tracks = _get_num_tracks_image;\n _funcs.get_track_channels = get_track_channels_image;\n _funcs.get_track_copy_permit = get_track_copy_permit_image;\n _funcs.get_track_format = _get_track_format_cdrdao;\n _funcs.get_track_green = _get_track_green_cdrdao;\n _funcs.get_track_lba = _get_lba_track_cdrdao;\n _funcs.get_track_msf = _get_track_msf_image;\n _funcs.get_track_preemphasis = get_track_preemphasis_image;\n _funcs.get_track_pregap_lba = get_track_pregap_lba_image;\n _funcs.get_track_isrc = get_track_isrc_image;\n _funcs.lseek = _lseek_cdrdao;\n _funcs.read = _read_cdrdao;\n _funcs.read_audio_sectors = _read_audio_sectors_cdrdao;\n _funcs.read_data_sectors = read_data_sectors_image;\n _funcs.read_mode1_sector = _read_mode1_sector_cdrdao;\n _funcs.read_mode1_sectors = _read_mode1_sectors_cdrdao;\n _funcs.read_mode2_sector = _read_mode2_sector_cdrdao;\n _funcs.read_mode2_sectors = _read_mode2_sectors_cdrdao;\n _funcs.run_mmc_cmd = NULL;\n _funcs.set_arg = _set_arg_image;\n _funcs.set_speed = cdio_generic_unimplemented_set_speed;\n _funcs.set_blocksize = cdio_generic_unimplemented_set_blocksize;\n\n if (NULL == psz_cue_name) return NULL;\n \n p_data = calloc(1, sizeof (_img_private_t));\n p_data->gen.init = false;\n p_data->psz_cue_name = NULL;\n p_data->gen.data_source = NULL;\n p_data->gen.source_name = NULL;\n\n ret = cdio_new ((void *)p_data, &_funcs);\n\n if (ret == NULL) {\n free(p_data);\n return NULL;\n }\n\n ret->driver_id = DRIVER_CDRDAO;\n if (!cdio_is_tocfile(psz_cue_name)) {\n cdio_debug (\"source name %s is not recognized as a TOC file\", \n\t\tpsz_cue_name);\n free(p_data);\n free(ret);\n return NULL;\n }\n \n _set_arg_image (p_data, \"cue\", psz_cue_name);\n _set_arg_image (p_data, \"source\", psz_cue_name);\n _set_arg_image (p_data, \"access-mode\", \"cdrdao\");\n\n if (_init_cdrdao(p_data)) {\n return ret;\n } else {\n _free_image(p_data);\n free(ret);\n return NULL;\n }\n}", "label": 0, "cwe": null, "length": 854 }, { "index": 81976, "code": "read_file_beacon(struct file *file, char __user *user_buf,\n\t\t\t\t size_t count, loff_t *ppos)\n{\n\tstruct ath5k_hw *ah = file->private_data;\n\tchar buf[500];\n\tunsigned int len = 0;\n\tunsigned int v;\n\tu64 tsf;\n\n\tv = ath5k_hw_reg_read(ah, AR5K_BEACON);\n\tlen += snprintf(buf + len, sizeof(buf) - len,\n\t\t\"%-24s0x%08x\\tintval: %d\\tTIM: 0x%x\\n\",\n\t\t\"AR5K_BEACON\", v, v & AR5K_BEACON_PERIOD,\n\t\t(v & AR5K_BEACON_TIM) >> AR5K_BEACON_TIM_S);\n\n\tlen += snprintf(buf + len, sizeof(buf) - len, \"%-24s0x%08x\\n\",\n\t\t\"AR5K_LAST_TSTP\", ath5k_hw_reg_read(ah, AR5K_LAST_TSTP));\n\n\tlen += snprintf(buf + len, sizeof(buf) - len, \"%-24s0x%08x\\n\\n\",\n\t\t\"AR5K_BEACON_CNT\", ath5k_hw_reg_read(ah, AR5K_BEACON_CNT));\n\n\tv = ath5k_hw_reg_read(ah, AR5K_TIMER0);\n\tlen += snprintf(buf + len, sizeof(buf) - len, \"%-24s0x%08x\\tTU: %08x\\n\",\n\t\t\"AR5K_TIMER0 (TBTT)\", v, v);\n\n\tv = ath5k_hw_reg_read(ah, AR5K_TIMER1);\n\tlen += snprintf(buf + len, sizeof(buf) - len, \"%-24s0x%08x\\tTU: %08x\\n\",\n\t\t\"AR5K_TIMER1 (DMA)\", v, v >> 3);\n\n\tv = ath5k_hw_reg_read(ah, AR5K_TIMER2);\n\tlen += snprintf(buf + len, sizeof(buf) - len, \"%-24s0x%08x\\tTU: %08x\\n\",\n\t\t\"AR5K_TIMER2 (SWBA)\", v, v >> 3);\n\n\tv = ath5k_hw_reg_read(ah, AR5K_TIMER3);\n\tlen += snprintf(buf + len, sizeof(buf) - len, \"%-24s0x%08x\\tTU: %08x\\n\",\n\t\t\"AR5K_TIMER3 (ATIM)\", v, v);\n\n\ttsf = ath5k_hw_get_tsf64(ah);\n\tlen += snprintf(buf + len, sizeof(buf) - len,\n\t\t\"TSF\\t\\t0x%016llx\\tTU: %08x\\n\",\n\t\t(unsigned long long)tsf, TSF_TO_TU(tsf));\n\n\tif (len > sizeof(buf))\n\t\tlen = sizeof(buf);\n\n\treturn simple_read_from_buffer(user_buf, count, ppos, buf, len);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 622 }, { "index": 471787, "code": "_ecore_con_svr_udp_handler(void *data,\n Ecore_Fd_Handler *fd_handler)\n{\n unsigned char buf[READBUFSIZ];\n unsigned char client_addr[256];\n socklen_t client_addr_len = sizeof(client_addr);\n int num;\n Ecore_Con_Server *svr;\n Ecore_Con_Client *cl = NULL;\n\n svr = data;\n\n if (svr->delete_me)\n return ECORE_CALLBACK_RENEW;\n\n if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_WRITE))\n {\n _ecore_con_client_flush(cl);\n return ECORE_CALLBACK_RENEW;\n }\n\n if (!ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))\n return ECORE_CALLBACK_RENEW;\n\n#ifdef _WIN32\n num = fcntl(svr->fd, F_SETFL, O_NONBLOCK);\n if (num >= 0)\n num = recvfrom(svr->fd, (char *)buf, sizeof(buf), 0,\n (struct sockaddr *)&client_addr,\n &client_addr_len);\n\n#else\n num = recvfrom(svr->fd, buf, sizeof(buf), MSG_DONTWAIT,\n (struct sockaddr *)&client_addr,\n &client_addr_len);\n#endif\n\n if (num < 0 && (errno != EAGAIN) && (errno != EINTR))\n {\n ecore_con_event_server_error(svr, strerror(errno));\n if (!svr->delete_me)\n ecore_con_event_client_del(NULL);\n _ecore_con_server_kill(svr);\n return ECORE_CALLBACK_CANCEL;\n }\n\n\n/* Create a new client for use in the client data event */\n cl = calloc(1, sizeof(Ecore_Con_Client));\n EINA_SAFETY_ON_NULL_RETURN_VAL(cl, ECORE_CALLBACK_RENEW);\n\n cl->host_server = svr;\n cl->client_addr = malloc(client_addr_len);\n if (!cl->client_addr)\n {\n free(cl);\n return ECORE_CALLBACK_RENEW;\n }\n cl->client_addr_len = client_addr_len;\n\n memcpy(cl->client_addr, &client_addr, client_addr_len);\n ECORE_MAGIC_SET(cl, ECORE_MAGIC_CON_CLIENT);\n svr->clients = eina_list_append(svr->clients, cl);\n svr->client_count++;\n\n ecore_con_event_client_add(cl);\n ecore_con_event_client_data(cl, buf, num, EINA_TRUE);\n\n return ECORE_CALLBACK_RENEW;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 526 }, { "index": 646312, "code": "l2_got_iframe(struct FsmInst *fi, int event, void *arg)\n{\n\tstruct layer2\t*l2 = fi->userdata;\n\tstruct sk_buff\t*skb = arg;\n\tint\t\tPollFlag, i;\n\tu_int\t\tns, nr;\n\n\ti = l2addrsize(l2);\n\tif (test_bit(FLG_MOD128, &l2->flag)) {\n\t\tPollFlag = ((skb->data[i + 1] & 0x1) == 0x1);\n\t\tns = skb->data[i] >> 1;\n\t\tnr = (skb->data[i + 1] >> 1) & 0x7f;\n\t} else {\n\t\tPollFlag = (skb->data[i] & 0x10);\n\t\tns = (skb->data[i] >> 1) & 0x7;\n\t\tnr = (skb->data[i] >> 5) & 0x7;\n\t}\n\tif (test_bit(FLG_OWN_BUSY, &l2->flag)) {\n\t\tdev_kfree_skb(skb);\n\t\tif (PollFlag)\n\t\t\tenquiry_response(l2);\n\t} else {\n\t\tif (l2->vr == ns) {\n\t\t\tl2->vr++;\n\t\t\tif (test_bit(FLG_MOD128, &l2->flag))\n\t\t\t\tl2->vr %= 128;\n\t\t\telse\n\t\t\t\tl2->vr %= 8;\n\t\t\ttest_and_clear_bit(FLG_REJEXC, &l2->flag);\n\t\t\tif (PollFlag)\n\t\t\t\tenquiry_response(l2);\n\t\t\telse\n\t\t\t\ttest_and_set_bit(FLG_ACK_PEND, &l2->flag);\n\t\t\tskb_pull(skb, l2headersize(l2, 0));\n\t\t\tl2up(l2, DL_DATA_IND, skb);\n\t\t} else {\n\t\t\t/* n(s)!=v(r) */\n\t\t\tdev_kfree_skb(skb);\n\t\t\tif (test_and_set_bit(FLG_REJEXC, &l2->flag)) {\n\t\t\t\tif (PollFlag)\n\t\t\t\t\tenquiry_response(l2);\n\t\t\t} else {\n\t\t\t\tenquiry_cr(l2, REJ, RSP, PollFlag);\n\t\t\t\ttest_and_clear_bit(FLG_ACK_PEND, &l2->flag);\n\t\t\t}\n\t\t}\n\t}\n\tif (legalnr(l2, nr)) {\n\t\tif (!test_bit(FLG_PEER_BUSY, &l2->flag) &&\n\t\t (fi->state == ST_L2_7)) {\n\t\t\tif (nr == l2->vs) {\n\t\t\t\tstop_t200(l2, 13);\n\t\t\t\tmISDN_FsmRestartTimer(&l2->t203, l2->T203,\n\t\t\t\t\t\t EV_L2_T203, NULL, 7);\n\t\t\t} else if (nr != l2->va)\n\t\t\t\trestart_t200(l2, 14);\n\t\t}\n\t\tsetva(l2, nr);\n\t} else {\n\t\tnrerrorrecovery(fi);\n\t\treturn;\n\t}\n\tif (skb_queue_len(&l2->i_queue) && (fi->state == ST_L2_7))\n\t\tmISDN_FsmEvent(fi, EV_L2_ACK_PULL, NULL);\n\tif (test_and_clear_bit(FLG_ACK_PEND, &l2->flag))\n\t\tenquiry_cr(l2, RR, RSP, 0);\n}", "label": 0, "cwe": null, "length": 714 }, { "index": 922611, "code": "gcm_mult( gcm_context *ctx, const unsigned char x[16],\n unsigned char output[16] )\n{\n int i = 0;\n unsigned char z[16];\n unsigned char lo, hi, rem;\n uint64_t zh, zl;\n\n#if defined(POLARSSL_AESNI_C) && defined(POLARSSL_HAVE_X86_64)\n if( aesni_supports( POLARSSL_AESNI_CLMUL ) ) {\n unsigned char h[16];\n\n PUT_UINT32_BE( ctx->HH[8] >> 32, h, 0 );\n PUT_UINT32_BE( ctx->HH[8], h, 4 );\n PUT_UINT32_BE( ctx->HL[8] >> 32, h, 8 );\n PUT_UINT32_BE( ctx->HL[8], h, 12 );\n\n aesni_gcm_mult( output, x, h );\n return;\n }\n#endif\n\n memset( z, 0x00, 16 );\n\n lo = x[15] & 0xf;\n hi = x[15] >> 4;\n\n zh = ctx->HH[lo];\n zl = ctx->HL[lo];\n\n for( i = 15; i >= 0; i-- )\n {\n lo = x[i] & 0xf;\n hi = x[i] >> 4;\n\n if( i != 15 )\n {\n rem = (unsigned char) zl & 0xf;\n zl = ( zh << 60 ) | ( zl >> 4 );\n zh = ( zh >> 4 );\n zh ^= (uint64_t) last4[rem] << 48;\n zh ^= ctx->HH[lo];\n zl ^= ctx->HL[lo];\n\n }\n\n rem = (unsigned char) zl & 0xf;\n zl = ( zh << 60 ) | ( zl >> 4 );\n zh = ( zh >> 4 );\n zh ^= (uint64_t) last4[rem] << 48;\n zh ^= ctx->HH[hi];\n zl ^= ctx->HL[hi];\n }\n\n PUT_UINT32_BE( zh >> 32, output, 0 );\n PUT_UINT32_BE( zh, output, 4 );\n PUT_UINT32_BE( zl >> 32, output, 8 );\n PUT_UINT32_BE( zl, output, 12 );\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 531 }, { "index": 591794, "code": "kernel26_rtc_onInputEvent (Kernel26Rtc* self, GIOChannel* source, GIOCondition condition) {\n\tgboolean result = FALSE;\n\tGIOChannel* _tmp0_ = NULL;\n\tGIOChannel* _tmp1_ = NULL;\n\tGTimeVal now = {0};\n\tGTimeVal _tmp18_ = {0};\n\tglong _tmp19_ = 0L;\n\tg_return_val_if_fail (self != NULL, FALSE);\n\tg_return_val_if_fail (source != NULL, FALSE);\n\t_tmp0_ = source;\n\t_tmp1_ = self->priv->channel;\n\tif (_tmp0_ != _tmp1_) {\n\t\tFsoFrameworkLogger* _tmp2_ = NULL;\n\t\t_tmp2_ = ((FsoFrameworkAbstractObject*) self)->logger;\n\t\tfso_framework_logger_error (_tmp2_, \"Bogus onInputEvent for RTC channel\");\n\t} else {\n\t\tgchar* buf = NULL;\n\t\tgchar* _tmp3_ = NULL;\n\t\tgint buf_length1 = 0;\n\t\tgint _buf_size_ = 0;\n\t\tgssize bytesread = 0L;\n\t\tGIOChannel* _tmp4_ = NULL;\n\t\tgint _tmp5_ = 0;\n\t\tgchar* _tmp6_ = NULL;\n\t\tgint _tmp6__length1 = 0;\n\t\tgssize _tmp7_ = 0L;\n\t\tgssize _tmp8_ = 0L;\n\t\t_tmp3_ = g_new0 (gchar, 1024);\n\t\tbuf = _tmp3_;\n\t\tbuf_length1 = 1024;\n\t\t_buf_size_ = buf_length1;\n\t\t_tmp4_ = source;\n\t\t_tmp5_ = g_io_channel_unix_get_fd (_tmp4_);\n\t\t_tmp6_ = buf;\n\t\t_tmp6__length1 = buf_length1;\n\t\t_tmp7_ = read (_tmp5_, _tmp6_, (gsize) 1024);\n\t\tbytesread = _tmp7_;\n\t\t_tmp8_ = bytesread;\n\t\tif (_tmp8_ == ((gssize) 0)) {\n\t\t\tFsoFrameworkLogger* _tmp9_ = NULL;\n\t\t\tGIOChannel* _tmp10_ = NULL;\n\t\t\tgint _tmp11_ = 0;\n\t\t\tgchar* _tmp12_ = NULL;\n\t\t\tgchar* _tmp13_ = NULL;\n\t\t\t_tmp9_ = ((FsoFrameworkAbstractObject*) self)->logger;\n\t\t\t_tmp10_ = source;\n\t\t\t_tmp11_ = g_io_channel_unix_get_fd (_tmp10_);\n\t\t\t_tmp12_ = g_strdup_printf (\"Could not read from input device fd %d.\", _tmp11_);\n\t\t\t_tmp13_ = _tmp12_;\n\t\t\tfso_framework_logger_warning (_tmp9_, _tmp13_);\n\t\t\t_g_free0 (_tmp13_);\n\t\t} else {\n\t\t\tFsoFrameworkLogger* _tmp14_ = NULL;\n\t\t\tgssize _tmp15_ = 0L;\n\t\t\tgchar* _tmp16_ = NULL;\n\t\t\tgchar* _tmp17_ = NULL;\n\t\t\t_tmp14_ = ((FsoFrameworkAbstractObject*) self)->logger;\n\t\t\t_tmp15_ = bytesread;\n\t\t\t_tmp16_ = g_strdup_printf (\"Read %d bytes from RTC\", (gint) _tmp15_);\n\t\t\t_tmp17_ = _tmp16_;\n\t\t\tfso_framework_logger_debug (_tmp14_, _tmp17_);\n\t\t\t_g_free0 (_tmp17_);\n\t\t}\n\t\tbuf = (g_free (buf), NULL);\n\t}\n\tfree_smartphone_device_realtime_clock_set_wakeup_time ((FreeSmartphoneDeviceRealtimeClock*) self, 0, NULL, NULL);\n\tg_get_current_time (&now);\n\t_tmp18_ = now;\n\t_tmp19_ = _tmp18_.tv_sec;\n\tg_signal_emit_by_name ((FreeSmartphoneDeviceRealtimeClock*) self, \"alarm\", (gint) _tmp19_);\n\tresult = FALSE;\n\treturn result;\n}", "label": 1, "cwe": [ "CWE-120", "CWE-other" ], "length": 855 }, { "index": 264274, "code": "user_update(dynalogin_user_data_t *ud, apr_pool_t *pool)\n{\n\todbc_connection_t *c;\n\tSQLRETURN ret; /* ODBC API return status */\n\tSQLLEN indicator[8];\n\n\tapr_pool_t *_pool;\n\n\tif(apr_pool_create(&_pool, pool) != APR_SUCCESS)\n\t\treturn;\n\n\tchar *_dsn = DB_DSN;\n\n\tif(odbc_build_connection(&c, pool) != APR_SUCCESS)\n\t\treturn;\n\n\t/* bind a parameter with SQLBindParam */\n\tif(odbc_set_uint64(&(ud->counter), c->update_stmt, 1, &indicator[1]) !=\n\t\t\tAPR_SUCCESS)\n\t{\n\t\todbc_error_cleanup(\"SQLBindParameter\", c);\n\t\treturn;\n\t}\n\n\tif(odbc_set_int(&(ud->failure_count), c->update_stmt, 2, &indicator[2]) !=\n\t\tAPR_SUCCESS)\n\t{\n\t\todbc_error_cleanup(\"SQLBindParameter\", c);\n\t\treturn;\n\t}\n\n\tif(odbc_set_int(&(ud->locked), c->update_stmt, 3, &indicator[3]) !=\n\t\t\tAPR_SUCCESS)\n\t{\n\t\todbc_error_cleanup(\"SQLBindParameter\", c);\n\t\treturn;\n\t}\n\n\tif(odbc_set_datetime(&(ud->last_success), c->update_stmt, 4, &indicator[4],\n\t\t\t_pool)\n\t\t\t!= APR_SUCCESS)\n\t{\n\t\todbc_error_cleanup(\"SQLBindParameter\", c);\n\t\treturn;\n\t}\n\n\tif(odbc_set_datetime(&(ud->last_attempt), c->update_stmt, 5, &indicator[5],\n\t\t\t_pool)\n\t\t\t!= APR_SUCCESS)\n\t{\n\t\todbc_error_cleanup(\"SQLBindParameter\", c);\n\t\treturn;\n\t}\n\n\tif(odbc_set_string(ud->last_code, c->update_stmt, 6, &indicator[6]) !=\n\t\t\tAPR_SUCCESS)\n\t{\n\t\todbc_error_cleanup(\"SQLBindParameter\", c);\n\t\treturn;\n\t}\n\n\tif(odbc_set_string(ud->userid, c->update_stmt, 7, &indicator[7]) !=\n\t\t\tAPR_SUCCESS)\n\t{\n\t\todbc_error_cleanup(\"SQLBindParameter\", c);\n\t\treturn;\n\t}\n\n\tif(!SQL_SUCCEEDED(ret = SQLExecute(c->update_stmt)))\n\t{\n\t\todbc_error_cleanup(\"SQLExecute\", c);\n\t\treturn ;\n\t}\n\n\todbc_cleanup(c);\n\n\tapr_pool_destroy(_pool);\n\tsyslog(LOG_DEBUG, \"UPDATED user = %s, count = %ju\", ud->userid, ud->counter);\n\treturn;\n}", "label": 0, "cwe": null, "length": 541 }, { "index": 351064, "code": "cx11646_initsize(struct gspca_dev *gspca_dev)\n{\n\tconst __u8 *cxinit;\n\tstatic const __u8 reg12[] = { 0x08, 0x05, 0x07, 0x04, 0x24 };\n\tstatic const __u8 reg17[] =\n\t\t\t{ 0x0a, 0x00, 0xf2, 0x01, 0x0f, 0x00, 0x97, 0x02 };\n\n\tswitch (gspca_dev->cam.cam_mode[(int) gspca_dev->curr_mode].priv) {\n\tcase 0:\n\t\tcxinit = cx_inits_640;\n\t\tbreak;\n\tcase 1:\n\t\tcxinit = cx_inits_352;\n\t\tbreak;\n\tdefault:\n/*\tcase 2: */\n\t\tcxinit = cx_inits_320;\n\t\tbreak;\n\tcase 3:\n\t\tcxinit = cx_inits_176;\n\t\tbreak;\n\t}\n\treg_w_val(gspca_dev, 0x009a, 0x01);\n\treg_w_val(gspca_dev, 0x0010, 0x10);\n\treg_w(gspca_dev, 0x0012, reg12, 5);\n\treg_w(gspca_dev, 0x0017, reg17, 8);\n\treg_w_val(gspca_dev, 0x00c0, 0x00);\n\treg_w_val(gspca_dev, 0x00c1, 0x04);\n\treg_w_val(gspca_dev, 0x00c2, 0x04);\n\n\treg_w(gspca_dev, 0x0061, cxinit, 8);\n\tcxinit += 8;\n\treg_w(gspca_dev, 0x00ca, cxinit, 8);\n\tcxinit += 8;\n\treg_w(gspca_dev, 0x00d2, cxinit, 8);\n\tcxinit += 8;\n\treg_w(gspca_dev, 0x00da, cxinit, 6);\n\tcxinit += 8;\n\treg_w(gspca_dev, 0x0041, cxinit, 8);\n\tcxinit += 8;\n\treg_w(gspca_dev, 0x0049, cxinit, 8);\n\tcxinit += 8;\n\treg_w(gspca_dev, 0x0051, cxinit, 2);\n\n\treg_r(gspca_dev, 0x0010, 1);\n}", "label": 0, "cwe": null, "length": 547 }, { "index": 494585, "code": "tor_init(int argc, char *argv[])\n{\n char buf[256];\n int i, quiet = 0;\n time_of_process_start = time(NULL);\n if (!connection_array)\n connection_array = smartlist_new();\n if (!closeable_connection_lst)\n closeable_connection_lst = smartlist_new();\n if (!active_linked_connection_lst)\n active_linked_connection_lst = smartlist_new();\n /* Have the log set up with our application name. */\n tor_snprintf(buf, sizeof(buf), \"Tor %s\", get_version());\n log_set_application_name(buf);\n /* Initialize the history structures. */\n rep_hist_init();\n /* Initialize the service cache. */\n rend_cache_init();\n addressmap_init(); /* Init the client dns cache. Do it always, since it's\n * cheap. */\n\n /* We search for the \"quiet\" option first, since it decides whether we\n * will log anything at all to the command line. */\n for (i=1;iHardwareAccel,\n get_options()->AccelName,\n get_options()->AccelDir)) {\n log_err(LD_BUG, \"Unable to initialize OpenSSL. Exiting.\");\n return -1;\n }\n\n return 0;\n}", "label": 0, "cwe": null, "length": 700 }, { "index": 52750, "code": "local_store_delete_folder_sync (CamelStore *store,\n const gchar *folder_name,\n GCancellable *cancellable,\n GError **error)\n{\n\tCamelLocalSettings *local_settings;\n\tCamelSettings *settings;\n\tCamelService *service;\n\tCamelFolderInfo *fi;\n\tCamelFolder *lf;\n\tgchar *str = NULL;\n\tgchar *name;\n\tgchar *path;\n\tgboolean success = TRUE;\n\n\tservice = CAMEL_SERVICE (store);\n\n\tsettings = camel_service_ref_settings (service);\n\n\tlocal_settings = CAMEL_LOCAL_SETTINGS (settings);\n\tpath = camel_local_settings_dup_path (local_settings);\n\n\tg_object_unref (settings);\n\n\t/* remove metadata only */\n\tname = g_build_filename (path, folder_name, NULL);\n\tstr = g_strdup_printf (\"%s.ibex\", name);\n\tif (camel_text_index_remove (str) == -1 && errno != ENOENT && errno != ENOTDIR) {\n\t\tg_set_error (\n\t\t\terror, G_IO_ERROR,\n\t\t\tg_io_error_from_errno (errno),\n\t\t\t_(\"Could not delete folder index file '%s': %s\"),\n\t\t\tstr, g_strerror (errno));\n\t\tsuccess = FALSE;\n\t\tgoto exit;\n\t}\n\n\tg_free (str);\n\tstr = NULL;\n\n\tif ((lf = camel_store_get_folder_sync (store, folder_name, 0, cancellable, NULL))) {\n\t\tCamelObject *object = CAMEL_OBJECT (lf);\n\t\tconst gchar *state_filename;\n\n\t\tstate_filename = camel_object_get_state_filename (object);\n\t\tstr = g_strdup (state_filename);\n\n\t\tcamel_object_set_state_filename (object, NULL);\n\n\t\tg_object_unref (lf);\n\t}\n\n\tif (str == NULL)\n\t\tstr = g_strdup_printf (\"%s.cmeta\", name);\n\n\tif (g_unlink (str) == -1 && errno != ENOENT && errno != ENOTDIR) {\n\t\tg_set_error (\n\t\t\terror, G_IO_ERROR,\n\t\t\tg_io_error_from_errno (errno),\n\t\t\t_(\"Could not delete folder meta file '%s': %s\"),\n\t\t\tstr, g_strerror (errno));\n\t\tsuccess = FALSE;\n\t\tgoto exit;\n\t}\n\n\tfi = camel_folder_info_new ();\n\tfi->full_name = g_strdup (folder_name);\n\tfi->display_name = g_path_get_basename (folder_name);\n\tfi->unread = -1;\n\n\tcamel_store_folder_deleted (store, fi);\n\tcamel_folder_info_free (fi);\n\nexit:\n\tg_free (name);\n\tg_free (path);\n\tg_free (str);\n\n\treturn success;\n}", "label": 0, "cwe": null, "length": 520 }, { "index": 209376, "code": "l2_pull_iqueue(struct FsmInst *fi, int event, void *arg)\n{\n\tstruct layer2\t*l2 = fi->userdata;\n\tstruct sk_buff\t*skb, *nskb;\n\tu_char\t\theader[MAX_L2HEADER_LEN];\n\tu_int\t\ti, p1;\n\n\tif (!cansend(l2))\n\t\treturn;\n\n\tskb = skb_dequeue(&l2->i_queue);\n\tif (!skb)\n\t\treturn;\n\ti = sethdraddr(l2, header, CMD);\n\tif (test_bit(FLG_MOD128, &l2->flag)) {\n\t\theader[i++] = l2->vs << 1;\n\t\theader[i++] = l2->vr << 1;\n\t} else\n\t\theader[i++] = (l2->vr << 5) | (l2->vs << 1);\n\tnskb = skb_realloc_headroom(skb, i);\n\tif (!nskb) {\n\t\tprintk(KERN_WARNING \"%s: no headroom(%d) copy for IFrame\\n\",\n\t\t mISDNDevName4ch(&l2->ch), i);\n\t\tskb_queue_head(&l2->i_queue, skb);\n\t\treturn;\n\t}\n\tif (test_bit(FLG_MOD128, &l2->flag)) {\n\t\tp1 = (l2->vs - l2->va) % 128;\n\t\tl2->vs = (l2->vs + 1) % 128;\n\t} else {\n\t\tp1 = (l2->vs - l2->va) % 8;\n\t\tl2->vs = (l2->vs + 1) % 8;\n\t}\n\tp1 = (p1 + l2->sow) % l2->window;\n\tif (l2->windowar[p1]) {\n\t\tprintk(KERN_WARNING \"%s: l2 try overwrite ack queue entry %d\\n\",\n\t\t mISDNDevName4ch(&l2->ch), p1);\n\t\tdev_kfree_skb(l2->windowar[p1]);\n\t}\n\tl2->windowar[p1] = skb;\n\tmemcpy(skb_push(nskb, i), header, i);\n\tl2down(l2, PH_DATA_REQ, l2_newid(l2), nskb);\n\ttest_and_clear_bit(FLG_ACK_PEND, &l2->flag);\n\tif (!test_and_set_bit(FLG_T200_RUN, &l2->flag)) {\n\t\tmISDN_FsmDelTimer(&l2->t203, 13);\n\t\tmISDN_FsmAddTimer(&l2->t200, l2->T200, EV_L2_T200, NULL, 11);\n\t}\n}", "label": 0, "cwe": null, "length": 560 }, { "index": 101820, "code": "yy_RawLine()\n{ int yypos0= yypos, yythunkpos0= yythunkpos;\n yyprintf((stderr, \"%s\\n\", \"RawLine\"));\n { int yypos1181= yypos, yythunkpos1181= yythunkpos; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l1182;\n l1183:;\t\n { int yypos1184= yypos, yythunkpos1184= yythunkpos;\n { int yypos1185= yypos, yythunkpos1185= yythunkpos; if (!yymatchChar('\\r')) goto l1185; goto l1184;\n l1185:;\t yypos= yypos1185; yythunkpos= yythunkpos1185;\n }\n { int yypos1186= yypos, yythunkpos1186= yythunkpos; if (!yymatchChar('\\n')) goto l1186; goto l1184;\n l1186:;\t yypos= yypos1186; yythunkpos= yythunkpos1186;\n } if (!yymatchDot()) goto l1184; goto l1183;\n l1184:;\t yypos= yypos1184; yythunkpos= yythunkpos1184;\n } if (!yy_Newline()) goto l1182; yyText(yybegin, yyend); if (!(YY_END)) goto l1182; goto l1181;\n l1182:;\t yypos= yypos1181; yythunkpos= yythunkpos1181; yyText(yybegin, yyend); if (!(YY_BEGIN)) goto l1180; if (!yymatchDot()) goto l1180;\n l1187:;\t\n { int yypos1188= yypos, yythunkpos1188= yythunkpos; if (!yymatchDot()) goto l1188; goto l1187;\n l1188:;\t yypos= yypos1188; yythunkpos= yythunkpos1188;\n } yyText(yybegin, yyend); if (!(YY_END)) goto l1180; if (!yy_Eof()) goto l1180;\n }\n l1181:;\t\n yyprintf((stderr, \" ok %s @ %s\\n\", \"RawLine\", yybuf+yypos));\n return 1;\n l1180:;\t yypos= yypos0; yythunkpos= yythunkpos0;\n yyprintf((stderr, \" fail %s @ %s\\n\", \"RawLine\", yybuf+yypos));\n return 0;\n}", "label": 0, "cwe": null, "length": 619 }, { "index": 848243, "code": "GWKCubicSplineNoMasksByteThread( void* pData )\n\n{\n GWKJobStruct* psJob = (GWKJobStruct*) pData;\n GDALWarpKernel *poWK = psJob->poWK;\n int iYMin = psJob->iYMin;\n int iYMax = psJob->iYMax;\n\n int iDstY;\n int nDstXSize = poWK->nDstXSize;\n int nSrcXSize = poWK->nSrcXSize, nSrcYSize = poWK->nSrcYSize;\n\n/* -------------------------------------------------------------------- */\n/* Allocate x,y,z coordinate arrays for transformation ... one */\n/* scanlines worth of positions. */\n/* -------------------------------------------------------------------- */\n double *padfX, *padfY, *padfZ;\n int *pabSuccess;\n\n padfX = (double *) CPLMalloc(sizeof(double) * nDstXSize);\n padfY = (double *) CPLMalloc(sizeof(double) * nDstXSize);\n padfZ = (double *) CPLMalloc(sizeof(double) * nDstXSize);\n pabSuccess = (int *) CPLMalloc(sizeof(int) * nDstXSize);\n\n int nXRadius = poWK->nXRadius;\n double *padfBSpline = (double *)CPLCalloc( nXRadius * 2, sizeof(double) );\n\n/* ==================================================================== */\n/* Loop over output lines. */\n/* ==================================================================== */\n for( iDstY = iYMin; iDstY < iYMax; iDstY++ )\n {\n int iDstX;\n\n/* -------------------------------------------------------------------- */\n/* Setup points to transform to source image space. */\n/* -------------------------------------------------------------------- */\n for( iDstX = 0; iDstX < nDstXSize; iDstX++ )\n {\n padfX[iDstX] = iDstX + 0.5 + poWK->nDstXOff;\n padfY[iDstX] = iDstY + 0.5 + poWK->nDstYOff;\n padfZ[iDstX] = 0.0;\n }\n\n/* -------------------------------------------------------------------- */\n/* Transform the points from destination pixel/line coordinates */\n/* to source pixel/line coordinates. */\n/* -------------------------------------------------------------------- */\n poWK->pfnTransformer( psJob->pTransformerArg, TRUE, nDstXSize,\n padfX, padfY, padfZ, pabSuccess );\n\n/* ==================================================================== */\n/* Loop over pixels in output scanline. */\n/* ==================================================================== */\n for( iDstX = 0; iDstX < nDstXSize; iDstX++ )\n {\n COMPUTE_iSrcOffset(pabSuccess, iDstX, padfX, padfY, poWK, nSrcXSize, nSrcYSize);\n\n/* ==================================================================== */\n/* Loop processing each band. */\n/* ==================================================================== */\n int iBand;\n int iDstOffset;\n\n iDstOffset = iDstX + iDstY * nDstXSize;\n\n for( iBand = 0; iBand < poWK->nBands; iBand++ )\n {\n GWKCubicSplineResampleNoMasksByte( poWK, iBand,\n padfX[iDstX]-poWK->nSrcXOff,\n padfY[iDstX]-poWK->nSrcYOff,\n &poWK->papabyDstImage[iBand][iDstOffset],\n padfBSpline);\n }\n }\n\n/* -------------------------------------------------------------------- */\n/* Report progress to the user, and optionally cancel out. */\n/* -------------------------------------------------------------------- */\n if (psJob->pfnProgress(psJob))\n break;\n }\n\n/* -------------------------------------------------------------------- */\n/* Cleanup and return. */\n/* -------------------------------------------------------------------- */\n CPLFree( padfX );\n CPLFree( padfY );\n CPLFree( padfZ );\n CPLFree( pabSuccess );\n CPLFree( padfBSpline );\n}", "label": 0, "cwe": null, "length": 863 }, { "index": 69737, "code": "explinfbk0(l0,l1,cf,I,p) /* fwd and bac recur; b=0; c<0 */\ndouble l0, l1, *cf, *I;\nINT p;\n{ double y0, y1, f1, f2, f, ml2;\n INT k, ks;\n\n y0 = lf_exp(cf[0]+l0*l0*cf[2]);\n y1 = lf_exp(cf[0]+l1*l1*cf[2]);\n initi0i1(I,cf,y0,y1,l0,l1);\n\n ml2 = MAX(l0*l0,l1*l1);\n ks = 1+(INT)(2*fabs(cf[2])*ml2);\n if (ks<2) ks = 2;\n if (ks>p-3) ks = p;\n\n /* forward recursion for k < ks */\n for (k=2; k1.0e-8)\n { y1 *= l1; y0 *= l0;\n if ((k-p)%2==0) /* add to I[p-2] */\n { f2 *= -2*cf[2]/(k+1);\n I[p-2] += (y1-y0)*f2;\n }\n else /* add to I[p-1] */\n { f1 *= -2*cf[2]/(k+1);\n I[p-1] += (y1-y0)*f1;\n f *= 2*fabs(cf[2])*ml2/(k+1);\n }\n k++;\n }\n \n /* use back recursion for I[ks..(p-3)] */\n for (k=p-3; k>=ks; k--)\n I[k] = (I[k]-2*cf[2]*I[k+2])/(k+1);\n}", "label": 1, "cwe": "CWE-other", "length": 612 }, { "index": 357356, "code": "__connman_ipconfig_newaddr(int index, int family, const char *label,\n\t\t\t\tunsigned char prefixlen, const char *address)\n{\n\tstruct connman_ipdevice *ipdevice;\n\tstruct connman_ipaddress *ipaddress;\n\tenum connman_ipconfig_type type;\n\tGList *list;\n\n\tDBG(\"index %d\", index);\n\n\tipdevice = g_hash_table_lookup(ipdevice_hash, GINT_TO_POINTER(index));\n\tif (ipdevice == NULL)\n\t\treturn;\n\n\tipaddress = connman_ipaddress_alloc(family);\n\tif (ipaddress == NULL)\n\t\treturn;\n\n\tipaddress->prefixlen = prefixlen;\n\tipaddress->local = g_strdup(address);\n\n\tif (g_slist_find_custom(ipdevice->address_list, ipaddress,\n\t\t\t\t\tcheck_duplicate_address)) {\n\t\tconnman_ipaddress_free(ipaddress);\n\t\treturn;\n\t}\n\n\tif (family == AF_INET)\n\t\ttype = CONNMAN_IPCONFIG_TYPE_IPV4;\n\telse if (family == AF_INET6)\n\t\ttype = CONNMAN_IPCONFIG_TYPE_IPV6;\n\telse\n\t\treturn;\n\n\tipdevice->address_list = g_slist_prepend(ipdevice->address_list,\n\t\t\t\t\t\t\t\tipaddress);\n\n\tconnman_info(\"%s {add} address %s/%u label %s family %d\",\n\t\tipdevice->ifname, address, prefixlen, label, family);\n\n\tif (type == CONNMAN_IPCONFIG_TYPE_IPV4)\n\t\t__connman_ippool_newaddr(index, address, prefixlen);\n\n\tif (ipdevice->config_ipv4 != NULL && family == AF_INET)\n\t\tconnman_ipaddress_copy_address(ipdevice->config_ipv4->system,\n\t\t\t\t\tipaddress);\n\n\telse if (ipdevice->config_ipv6 != NULL && family == AF_INET6)\n\t\tconnman_ipaddress_copy_address(ipdevice->config_ipv6->system,\n\t\t\t\t\tipaddress);\n\telse\n\t\treturn;\n\n\tif ((ipdevice->flags & (IFF_RUNNING | IFF_LOWER_UP)) != (IFF_RUNNING | IFF_LOWER_UP))\n\t\treturn;\n\n\tfor (list = g_list_first(ipconfig_list); list;\n\t\t\t\t\t\tlist = g_list_next(list)) {\n\t\tstruct connman_ipconfig *ipconfig = list->data;\n\n\t\tif (index != ipconfig->index)\n\t\t\tcontinue;\n\n\t\tif (type != ipconfig->type)\n\t\t\tcontinue;\n\n\t\tif (ipconfig->ops == NULL)\n\t\t\tcontinue;\n\n\t\tif (ipconfig->ops->ip_bound)\n\t\t\tipconfig->ops->ip_bound(ipconfig);\n\t}\n}", "label": 1, "cwe": "CWE-other", "length": 512 }, { "index": 276035, "code": "bcm_cygnus_afe_config(struct phy_device *phydev)\n{\n\tint rc;\n\n\t/* ensure smdspclk is enabled */\n\trc = phy_write(phydev, MII_BCM54XX_AUX_CTL, 0x0c30);\n\tif (rc < 0)\n\t\treturn rc;\n\n\t/* AFE_VDAC_ICTRL_0 bit 7:4 Iq=1100 for 1g 10bt, normal modes */\n\trc = bcm_phy_write_misc(phydev, 0x39, 0x01, 0xA7C8);\n\tif (rc < 0)\n\t\treturn rc;\n\n\t/* AFE_HPF_TRIM_OTHERS bit11=1, short cascode enable for all modes*/\n\trc = bcm_phy_write_misc(phydev, 0x3A, 0x00, 0x0803);\n\tif (rc < 0)\n\t\treturn rc;\n\n\t/* AFE_TX_CONFIG_1 bit 7:4 Iq=1100 for test modes */\n\trc = bcm_phy_write_misc(phydev, 0x3A, 0x01, 0xA740);\n\tif (rc < 0)\n\t\treturn rc;\n\n\t/* AFE TEMPSEN_OTHERS rcal_HT, rcal_LT 10000 */\n\trc = bcm_phy_write_misc(phydev, 0x3A, 0x03, 0x8400);\n\tif (rc < 0)\n\t\treturn rc;\n\n\t/* AFE_FUTURE_RSV bit 2:0 rccal <2:0>=100 */\n\trc = bcm_phy_write_misc(phydev, 0x3B, 0x00, 0x0004);\n\tif (rc < 0)\n\t\treturn rc;\n\n\t/* Adjust bias current trim to overcome digital offSet */\n\trc = phy_write(phydev, MII_BRCM_CORE_BASE1E, 0x02);\n\tif (rc < 0)\n\t\treturn rc;\n\n\t/* make rcal=100, since rdb default is 000 */\n\trc = bcm_phy_write_exp(phydev, MII_BRCM_CORE_EXPB1, 0x10);\n\tif (rc < 0)\n\t\treturn rc;\n\n\t/* CORE_EXPB0, Reset R_CAL/RC_CAL Engine */\n\trc = bcm_phy_write_exp(phydev, MII_BRCM_CORE_EXPB0, 0x10);\n\tif (rc < 0)\n\t\treturn rc;\n\n\t/* CORE_EXPB0, Disable Reset R_CAL/RC_CAL Engine */\n\trc = bcm_phy_write_exp(phydev, MII_BRCM_CORE_EXPB0, 0x00);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 566 }, { "index": 108564, "code": "f1dream_protection_w(void)\r\n{\r\n\tint indx;\r\n\tint value = 255;\r\n\tint prevpc = activecpu_get_previouspc();\r\n\r\n\tif (prevpc == 0x244c)\r\n\t{\r\n\t\t/* Called once, when a race is started.*/\r\n\t\tindx = ram16[0x3ff0/2];\r\n\t\tram16[0x3fe6/2] = f1dream_2450_lookup[indx];\r\n\t\tram16[0x3fe8/2] = f1dream_2450_lookup[++indx];\r\n\t\tram16[0x3fea/2] = f1dream_2450_lookup[++indx];\r\n\t\tram16[0x3fec/2] = f1dream_2450_lookup[++indx];\r\n\t}\r\n\telse if (prevpc == 0x613a)\r\n\t{\r\n\t\t/* Called for every sprite on-screen.*/\r\n\t\tif (ram16[0x3ff6/2] < 15)\r\n\t\t{\r\n\t\t\tindx = f1dream_613ea_lookup[ram16[0x3ff6/2]] - ram16[0x3ff4/2];\r\n\t\t\tif (indx > 255)\r\n\t\t\t{\r\n\t\t\t\tindx <<= 4;\r\n\t\t\t\tindx += ram16[0x3ff6/2] & 0x00ff;\r\n\t\t\t\tvalue = f1dream_613eb_lookup[indx];\r\n\t\t\t}\r\n\t\t}\r\n\r\n\t\tram16[0x3ff2/2] = value;\r\n\t}\r\n\telse if (prevpc == 0x17b70)\r\n\t{\r\n\t\t/* Called only before a real race, not a time trial.*/\r\n\t\tif (ram16[0x3ff0/2] >= 0x04) indx = 128;\r\n\t\telse if (ram16[0x3ff0/2] > 0x02) indx = 96;\r\n\t\telse if (ram16[0x3ff0/2] == 0x02) indx = 64;\r\n\t\telse if (ram16[0x3ff0/2] == 0x01) indx = 32;\r\n\t\telse indx = 0;\r\n\r\n\t\tindx += ram16[0x3fee/2];\r\n\t\tif (indx < 128)\r\n\t\t{\r\n\t\t\tram16[0x3fe6/2] = f1dream_17b74_lookup[indx];\r\n\t\t\tram16[0x3fe8/2] = f1dream_17b74_lookup[++indx];\r\n\t\t\tram16[0x3fea/2] = f1dream_17b74_lookup[++indx];\r\n\t\t\tram16[0x3fec/2] = f1dream_17b74_lookup[++indx];\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tram16[0x3fe6/2] = 0x00ff;\r\n\t\t\tram16[0x3fe8/2] = 0x00ff;\r\n\t\t\tram16[0x3fea/2] = 0x00ff;\r\n\t\t\tram16[0x3fec/2] = 0x00ff;\r\n\t\t}\r\n\t}\r\n\telse if ((prevpc == 0x27f8) || (prevpc == 0x511a) || (prevpc == 0x5142) || (prevpc == 0x516a))\r\n\t{\r\n\t\t/* The main CPU stuffs the byte for the soundlatch into 0xfffffd.*/\r\n\t\tsoundlatch_w(2,ram16[0x3ffc/2]);\r\n\t}\r\n}", "label": 0, "cwe": null, "length": 771 }, { "index": 614552, "code": "php_stream_filter_append_ex(php_stream_filter_chain *chain, php_stream_filter *filter TSRMLS_DC)\n{\n\tphp_stream *stream = chain->stream;\n\n\tfilter->prev = chain->tail;\n\tfilter->next = NULL;\n\tif (chain->tail) {\n\t\tchain->tail->next = filter;\n\t} else {\n\t\tchain->head = filter;\n\t}\n\tchain->tail = filter;\n\tfilter->chain = chain;\n\n\tif (&(stream->readfilters) == chain && (stream->writepos - stream->readpos) > 0) {\n\t\t/* Let's going ahead and wind anything in the buffer through this filter */\n\t\tphp_stream_bucket_brigade brig_in = { NULL, NULL }, brig_out = { NULL, NULL };\n\t\tphp_stream_bucket_brigade *brig_inp = &brig_in, *brig_outp = &brig_out;\n\t\tphp_stream_filter_status_t status;\n\t\tphp_stream_bucket *bucket;\n\t\tsize_t consumed = 0;\n\n\t\tbucket = php_stream_bucket_new(stream, (char*) stream->readbuf + stream->readpos, stream->writepos - stream->readpos, 0, 0 TSRMLS_CC);\n\t\tphp_stream_bucket_append(brig_inp, bucket TSRMLS_CC);\n\t\tstatus = filter->fops->filter(stream, filter, brig_inp, brig_outp, &consumed, PSFS_FLAG_NORMAL TSRMLS_CC);\n\n\t\tif (stream->readpos + consumed > (uint)stream->writepos || consumed < 0) {\n\t\t\t/* No behaving filter should cause this. */\n\t\t\tstatus = PSFS_ERR_FATAL;\n\t\t}\n\n\t\tswitch (status) {\n\t\t\tcase PSFS_ERR_FATAL:\n\t\t\t\twhile (brig_in.head) {\n\t\t\t\t\tbucket = brig_in.head;\n\t\t\t\t\tphp_stream_bucket_unlink(bucket TSRMLS_CC);\n\t\t\t\t\tphp_stream_bucket_delref(bucket TSRMLS_CC);\n\t\t\t\t}\n\t\t\t\twhile (brig_out.head) {\n\t\t\t\t\tbucket = brig_out.head;\n\t\t\t\t\tphp_stream_bucket_unlink(bucket TSRMLS_CC);\n\t\t\t\t\tphp_stream_bucket_delref(bucket TSRMLS_CC);\n\t\t\t\t}\n\t\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Filter failed to process pre-buffered data\");\n\t\t\t\treturn FAILURE;\n\t\t\tcase PSFS_FEED_ME:\n\t\t\t\t/* We don't actually need data yet,\n\t\t\t\t leave this filter in a feed me state until data is needed. \n\t\t\t\t Reset stream's internal read buffer since the filter is \"holding\" it. */\n\t\t\t\tstream->readpos = 0;\n\t\t\t\tstream->writepos = 0;\n\t\t\t\tbreak;\n\t\t\tcase PSFS_PASS_ON:\n\t\t\t\t/* If any data is consumed, we cannot rely upon the existing read buffer,\n\t\t\t\t as the filtered data must replace the existing data, so invalidate the cache */\n\t\t\t\t/* note that changes here should be reflected in\n\t\t\t\t main/streams/streams.c::php_stream_fill_read_buffer */\n\t\t\t\tstream->writepos = 0;\n\t\t\t\tstream->readpos = 0;\n\n\t\t\t\twhile (brig_outp->head) {\n\t\t\t\t\tbucket = brig_outp->head;\n\t\t\t\t\t/* Grow buffer to hold this bucket if need be.\n\t\t\t\t\t TODO: See warning in main/stream/streams.c::php_stream_fill_read_buffer */\n\t\t\t\t\tif (stream->readbuflen - stream->writepos < bucket->buflen) {\n\t\t\t\t\t\tstream->readbuflen += bucket->buflen;\n\t\t\t\t\t\tstream->readbuf = perealloc(stream->readbuf, stream->readbuflen, stream->is_persistent);\n\t\t\t\t\t}\n\t\t\t\t\tmemcpy(stream->readbuf + stream->writepos, bucket->buf, bucket->buflen);\n\t\t\t\t\tstream->writepos += bucket->buflen;\n\n\t\t\t\t\tphp_stream_bucket_unlink(bucket TSRMLS_CC);\n\t\t\t\t\tphp_stream_bucket_delref(bucket TSRMLS_CC);\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn SUCCESS;\n}", "label": 1, "cwe": [ "CWE-120", "CWE-other" ], "length": 800 }, { "index": 664969, "code": "sbs_read_string_data(struct i2c_client *client, u8 address,\n\t\t\t\tchar *values)\n{\n\tstruct sbs_info *chip = i2c_get_clientdata(client);\n\ts32 ret = 0, block_length = 0;\n\tint retries_length = 1, retries_block = 1;\n\tu8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1];\n\n\tif (chip->pdata) {\n\t\tretries_length = max(chip->pdata->i2c_retry_count + 1, 1);\n\t\tretries_block = max(chip->pdata->i2c_retry_count + 1, 1);\n\t}\n\n\t/* Adapter needs to support these two functions */\n\tif (!i2c_check_functionality(client->adapter,\n\t\t\t\t I2C_FUNC_SMBUS_BYTE_DATA |\n\t\t\t\t I2C_FUNC_SMBUS_I2C_BLOCK)){\n\t\treturn -ENODEV;\n\t}\n\n\t/* Get the length of block data */\n\twhile (retries_length > 0) {\n\t\tret = i2c_smbus_read_byte_data(client, address);\n\t\tif (ret >= 0)\n\t\t\tbreak;\n\t\tretries_length--;\n\t}\n\n\tif (ret < 0) {\n\t\tdev_dbg(&client->dev,\n\t\t\t\"%s: i2c read at address 0x%x failed\\n\",\n\t\t\t__func__, address);\n\t\treturn ret;\n\t}\n\n\t/* block_length does not include NULL terminator */\n\tblock_length = ret;\n\tif (block_length > I2C_SMBUS_BLOCK_MAX) {\n\t\tdev_err(&client->dev,\n\t\t\t\"%s: Returned block_length is longer than 0x%x\\n\",\n\t\t\t__func__, I2C_SMBUS_BLOCK_MAX);\n\t\treturn -EINVAL;\n\t}\n\n\t/* Get the block data */\n\twhile (retries_block > 0) {\n\t\tret = i2c_smbus_read_i2c_block_data(\n\t\t\t\tclient, address,\n\t\t\t\tblock_length + 1, block_buffer);\n\t\tif (ret >= 0)\n\t\t\tbreak;\n\t\tretries_block--;\n\t}\n\n\tif (ret < 0) {\n\t\tdev_dbg(&client->dev,\n\t\t\t\"%s: i2c read at address 0x%x failed\\n\",\n\t\t\t__func__, address);\n\t\treturn ret;\n\t}\n\n\t/* block_buffer[0] == block_length */\n\tmemcpy(values, block_buffer + 1, block_length);\n\tvalues[block_length] = '\\0';\n\n\treturn le16_to_cpu(ret);\n}", "label": 1, "cwe": "CWE-120", "length": 516 }, { "index": 640421, "code": "pit_ioport_write(struct kvm_vcpu *vcpu,\n\t\t\t\tstruct kvm_io_device *this,\n\t\t\t gpa_t addr, int len, const void *data)\n{\n\tstruct kvm_pit *pit = dev_to_pit(this);\n\tstruct kvm_kpit_state *pit_state = &pit->pit_state;\n\tstruct kvm *kvm = pit->kvm;\n\tint channel, access;\n\tstruct kvm_kpit_channel_state *s;\n\tu32 val = *(u32 *) data;\n\tif (!pit_in_range(addr))\n\t\treturn -EOPNOTSUPP;\n\n\tval &= 0xff;\n\taddr &= KVM_PIT_CHANNEL_MASK;\n\n\tmutex_lock(&pit_state->lock);\n\n\tif (val != 0)\n\t\tpr_debug(\"write addr is 0x%x, len is %d, val is 0x%x\\n\",\n\t\t\t (unsigned int)addr, len, val);\n\n\tif (addr == 3) {\n\t\tchannel = val >> 6;\n\t\tif (channel == 3) {\n\t\t\t/* Read-Back Command. */\n\t\t\tfor (channel = 0; channel < 3; channel++) {\n\t\t\t\ts = &pit_state->channels[channel];\n\t\t\t\tif (val & (2 << channel)) {\n\t\t\t\t\tif (!(val & 0x20))\n\t\t\t\t\t\tpit_latch_count(kvm, channel);\n\t\t\t\t\tif (!(val & 0x10))\n\t\t\t\t\t\tpit_latch_status(kvm, channel);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\t/* Select Counter . */\n\t\t\ts = &pit_state->channels[channel];\n\t\t\taccess = (val >> 4) & KVM_PIT_CHANNEL_MASK;\n\t\t\tif (access == 0) {\n\t\t\t\tpit_latch_count(kvm, channel);\n\t\t\t} else {\n\t\t\t\ts->rw_mode = access;\n\t\t\t\ts->read_state = access;\n\t\t\t\ts->write_state = access;\n\t\t\t\ts->mode = (val >> 1) & 7;\n\t\t\t\tif (s->mode > 5)\n\t\t\t\t\ts->mode -= 4;\n\t\t\t\ts->bcd = val & 1;\n\t\t\t}\n\t\t}\n\t} else {\n\t\t/* Write Count. */\n\t\ts = &pit_state->channels[addr];\n\t\tswitch (s->write_state) {\n\t\tdefault:\n\t\tcase RW_STATE_LSB:\n\t\t\tpit_load_count(kvm, addr, val);\n\t\t\tbreak;\n\t\tcase RW_STATE_MSB:\n\t\t\tpit_load_count(kvm, addr, val << 8);\n\t\t\tbreak;\n\t\tcase RW_STATE_WORD0:\n\t\t\ts->write_latch = val;\n\t\t\ts->write_state = RW_STATE_WORD1;\n\t\t\tbreak;\n\t\tcase RW_STATE_WORD1:\n\t\t\tpit_load_count(kvm, addr, s->write_latch | (val << 8));\n\t\t\ts->write_state = RW_STATE_WORD0;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tmutex_unlock(&pit_state->lock);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 611 }, { "index": 917633, "code": "apply_export_clicked(struct w *widgets)\n{\n gchar *pkg_name, *pkg_path, *info, *cmd;\n G_CONST_RETURN gchar *export_dir;\n G_CONST_RETURN gchar *export_user;\n\n export_dir = gtk_entry_get_text(GTK_ENTRY(widgets->export_dir_entry));\n export_user = gtk_entry_get_text(GTK_ENTRY(widgets->export_user_entry));\n\n /* No valid export directory supplied */\n if( export_dir==NULL || strlen(export_dir) < 4 )\n {\n\tinfo = g_strdup_printf(_(\"Error: Directory length is too short.\\n\"));\n\tshow_info(info);\n\tg_free(info);\n\treturn;\n }\n\n /* Create the export directory */\n if( ! file_exists((char *)export_dir) )\n {\n\tif( export_user!=NULL && strlen(export_user) > 1 )\n\t cmd = g_strdup_printf(\"mkdir -p %s && chown %s %s\", export_dir, export_user, export_dir);\n\telse\n\t cmd = g_strdup_printf(\"mkdir -p %s\", export_dir);\n\t\n\tif( ! run_command(cmd) )\n\t{\n\t info = g_strdup_printf(_(\"Error: Can not create export directory.\\n\"));\n\t show_info(info);\n\t g_free(info);\n\t g_free(cmd);\n\t return;\n\t}\n\tg_free(cmd);\n }\n\n /* Adapt the package for windows openvpn-gui */\n if( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widgets->export_to_windows_checkbutton)) )\n {\n\tmake_openvpn_gui_conf();\n\n\tpkg_name = g_strdup_printf(\"gadmin-openvpn-client-data-windows.tar.gz\"); \n\n\t/* Create the tar command that excludes the linux .conf file */\n\tcmd = g_strdup_printf(\"cd %s/server && tar -zcf %s client/ --exclude=*.conf\", OPENVPN_SYSCONF_DIR, pkg_name);\n }\n else /* Create a package for Linux and other systems */\n {\n\tpkg_name = g_strdup_printf(\"gadmin-openvpn-client-data-linux.tar.gz\"); \n\n\t/* Make the Linux tar command */\n\tcmd = g_strdup_printf(\"cd %s/server && tar -zcf %s client/ --exclude=*.ovpn --exclude=passfile\", OPENVPN_SYSCONF_DIR, pkg_name);\n }\n\n /* Tar up the client configuration directory and put it in the server directory. */\n if( ! run_command(cmd) )\n {\n \tinfo = g_strdup_printf(_(\"Error: Could not package the client configuration and certificates.\\n\"));\n show_info(info);\n g_free(info);\n g_free(cmd);\n\tg_free(pkg_name);\n return;\n }\n g_free(cmd);\n\n /* Put the package in the correct directory. */\n pkg_path = g_strdup_printf(\"%s/server/%s\", OPENVPN_SYSCONF_DIR, pkg_name);\n if( ! file_exists(pkg_path) )\n {\n \tinfo = g_strdup_printf(_(\"Error: No client configuration package has been created.\\nIs the tar package installed ?.\\n\"));\n show_info(info);\n \tg_free(info);\n g_free(pkg_path);\n\tg_free(pkg_name);\n \treturn;\n }\n\n /* Export user is supplied and has valid length. Make this user the owner of the package. */\n if( export_user!=NULL && strlen(export_user) > 1 )\n {\n\tcmd = g_strdup_printf(\"cp %s %s && chown %s:%s %s/%s\",\n pkg_path, export_dir, export_user, export_user, export_dir, pkg_name);\n }\n else\n {\n cmd = g_strdup_printf(\"cp %s %s\", pkg_path, export_dir);\n }\n g_free(pkg_name);\n \n if( ! run_command(cmd) )\n {\n\tinfo = g_strdup_printf(_(\"Error: Copying client data package has failed.\\n\"));\n\tshow_info(info);\n\tg_free(info);\n\tg_free(pkg_path);\n\tg_free(cmd);\n\treturn;\n }\n g_free(pkg_path);\n g_free(cmd);\n\n /* Destroy the export window */\n gtk_widget_destroy(widgets->export_window);\n}", "label": 0, "cwe": null, "length": 844 }, { "index": 220946, "code": "print_user_list(void)\n{\n /* even though the BSD version of sa doesn't support sorting of the\n user summary list, why can't we? */\n\n struct hashtab_order ho;\n struct hashtab_elem *he, **entry_array, user_totals;\n struct user_data user_totals_ud;\n long num_users, which, temp;\n char * const empty_string = \"\";\n\n /* Make the summary record. FIXME -- we need some functions so we\n can fabricate these entries without playing with the structure\n internals. */\n\n user_totals_ud.s = stats_totals;\n user_totals.key = empty_string;\n user_totals.data = &user_totals_ud;\n\n /* Count the number of users in the hash table. */\n\n for (he = hashtab_first (user_table, &ho), num_users = 0;\n he != NULL;\n he = hashtab_next (&ho), num_users++)\n ;\n\n num_users++;\t\t\t/* one for the summary entry */\n\n entry_array = (struct hashtab_elem **)\n xmalloc (sizeof (struct hashtab_elem *) * num_users);\n\n which = 0;\n entry_array[which++] = &user_totals;\n\n for (he = hashtab_first (user_table, &ho);\n he != NULL;\n he = hashtab_next (&ho))\n {\n entry_array[which++] = he;\n }\n\n /* The summary entry should always be first, so don't sort it.\n Remember to correct the number of elements to adjust... */\n\n qsort (entry_array + 1, (size_t) num_users - 1,\n sizeof (struct hashtab_elem *), (int (*)()) compare_user_entry);\n\n /* Now we've got a sorted list of user entries. */\n\n for (temp = 0; temp < num_users; temp++)\n {\n char *name;\n struct stats *s;\n struct user_data *ud;\n\n he = entry_array[temp];\n name = hashtab_get_key (he);\n ud = hashtab_get_value (he);\n s = &(ud->s);\n\n if (debugging_enabled)\n {\n fprintf (stddebug, \"t:%-10.10s \", name);\n print_stats_raw (s, stddebug);\n }\n\n printf (\"%-*.*s \", NAME_LEN, NAME_LEN, name);\n print_stats_nicely (s);\n (void)putchar('\\n');\n }\n\n free (entry_array);\n}", "label": 0, "cwe": null, "length": 533 }, { "index": 324480, "code": "mkv_write_packet(AVFormatContext *s, AVPacket *pkt)\n{\n MatroskaMuxContext *mkv = s->priv_data;\n ByteIOContext *pb = s->pb;\n AVCodecContext *codec = s->streams[pkt->stream_index]->codec;\n int keyframe = !!(pkt->flags & PKT_FLAG_KEY);\n int duration = pkt->duration;\n int ret;\n\n // start a new cluster every 5 MB or 5 sec\n if (url_ftell(pb) > mkv->cluster_pos + 5*1024*1024 || pkt->pts > mkv->cluster_pts + 5000) {\n av_log(s, AV_LOG_DEBUG, \"Starting new cluster at offset %\" PRIu64\n \" bytes, pts %\" PRIu64 \"\\n\", url_ftell(pb), pkt->pts);\n end_ebml_master(pb, mkv->cluster);\n\n ret = mkv_add_seekhead_entry(mkv->cluster_seekhead, MATROSKA_ID_CLUSTER, url_ftell(pb));\n if (ret < 0) return ret;\n\n mkv->cluster_pos = url_ftell(pb);\n mkv->cluster = start_ebml_master(pb, MATROSKA_ID_CLUSTER, 0);\n put_ebml_uint(pb, MATROSKA_ID_CLUSTERTIMECODE, pkt->pts);\n mkv->cluster_pts = pkt->pts;\n av_md5_update(mkv->md5_ctx, pkt->data, FFMIN(200, pkt->size));\n }\n\n if (codec->codec_type != CODEC_TYPE_SUBTITLE) {\n mkv_write_block(s, MATROSKA_ID_SIMPLEBLOCK, pkt, keyframe << 7);\n } else if (codec->codec_id == CODEC_ID_SSA) {\n duration = mkv_write_ass_blocks(s, pkt);\n } else {\n ebml_master blockgroup = start_ebml_master(pb, MATROSKA_ID_BLOCKGROUP, mkv_blockgroup_size(pkt->size));\n duration = pkt->convergence_duration;\n mkv_write_block(s, MATROSKA_ID_BLOCK, pkt, 0);\n put_ebml_uint(pb, MATROSKA_ID_BLOCKDURATION, duration);\n end_ebml_master(pb, blockgroup);\n }\n\n if (codec->codec_type == CODEC_TYPE_VIDEO && keyframe) {\n ret = mkv_add_cuepoint(mkv->cues, pkt, mkv->cluster_pos);\n if (ret < 0) return ret;\n }\n\n mkv->duration = FFMAX(mkv->duration, pkt->pts + duration);\n return 0;\n}", "label": 0, "cwe": null, "length": 574 }, { "index": 138668, "code": "FSFlushElement(\n\tFDB *\t\t\tpDb,\n\tLFILE *\t\tpLFile,\n\tUCUR *\t\tupdCur)\n{\n\tRCODE\t\t\trc = FERR_OK;\n\tBTSK *\t\tpStack = updCur->pStack;\n\tFLMBYTE *\tpElmBuf = updCur->pElmBuf;\n\tFLMUINT\t\tuiFlags = updCur->uiFlags;\n\tFLMBOOL\t\tbIsLast = FALSE;\n\n\tif( uiFlags & UCUR_LAST_TIME)\n\t{\n\t\tBBE_SET_LAST( pElmBuf);\n\t}\n\tBBE_SET_RL( pElmBuf, (updCur->uiUsedLen - ELM_DIN_OVHD));\n\n\tif( uiFlags & UCUR_REPLACE)\n\t{\n\t\tFLMBYTE * curElm = CURRENT_ELM( pStack);\n\n\t\tbIsLast = (FLMBYTE)(BBE_IS_LAST( curElm ));\n\n\t\tif( bIsLast && (( uiFlags & UCUR_LAST_TIME ) == 0))\n\t\t{\n\t\t\t// Log the block before modifying it. \n\n\t\t\tif( RC_BAD( rc = FSLogPhysBlk( pDb, pStack)))\n\t\t\t{\n\t\t\t\tgoto Exit;\n\t\t\t}\n\n\t\t\tcurElm = CURRENT_ELM( pStack);\n\t\t\tBBE_CLR_LAST( curElm);\n\t\t}\n\t\telse if( !bIsLast && (uiFlags & UCUR_LAST_TIME))\n\t\t{\n\t\t\t// Log the block before modifying it. \n\n\t\t\tif( RC_BAD( rc = FSLogPhysBlk( pDb, pStack)))\n\t\t\t{\n\t\t\t\tgoto Exit;\n\t\t\t}\n\n\t\t\tcurElm = CURRENT_ELM( pStack );\n\t\t\tBBE_SET_LAST( curElm);\n\t\t}\n\n\t\tif( RC_BAD( rc = FSBtReplace( pDb, pLFile, \n\t\t\t&pStack, pElmBuf, updCur->uiUsedLen)))\n\t\t{\n\t\t\tgoto Exit;\n\t\t}\n\t}\n\telse\n\t{\n\t\tif( RC_BAD( rc = FSBtInsert( pDb, pLFile, &pStack, \n\t\t\tpElmBuf, updCur->uiUsedLen)))\n\t\t{\n\t\t\tgoto Exit;\n\t\t}\n\t}\n\n\tif( BBE_IS_FIRST( pElmBuf))\n\t{\n\t\tBBE_CLR_FIRST( pElmBuf);\n\t}\n\t\t\n\t// Should always setup the pStack to the next element (or LEM)\n\n\tif( RC_BAD( rc = FSBtNextElm( pDb, pLFile, pStack)))\n\t{\n\t\tif( rc != FERR_BT_END_OF_DATA)\n\t\t{\n\t\t\tgoto Exit;\n\t\t}\n\n\t\tupdCur->pStack = pStack;\n\t\trc = FERR_OK;\n\t}\n\n\tif( !(uiFlags & UCUR_LAST_TIME))\n\t{\n\t\t// If you are replacing the current element (continuation),\n\t\t// go to the next element and keep replacing to your\n\t\t// hearts content. Check if the doesContinue flag is set\n\t\t// so that you will replace next time FSFlushElement() is called. \n\n\t\tif( uiFlags & UCUR_REPLACE)\n\t\t{\n\t\t\t// If the element DOES NOT continue then insert next time \n\n\t\t\tif( bIsLast)\n\t\t\t{\n\t\t\t\tupdCur->uiFlags = uiFlags = UCUR_INSERT;\n\t\t\t}\n\t\t}\n\n\t\t// Flags could have just changed above \n\n\t\tif( uiFlags & UCUR_INSERT)\n\t\t{\n\t\t\tif( RC_BAD( rc = FSBtScanTo( pStack, &pElmBuf[ BBE_KEY],\n\t\t\t\t\t\t\t\t\t\t\t\t DIN_KEY_SIZ, 0)))\n\t\t\t{\n\t\t\t\tgoto Exit;\n\t\t\t}\n\t\t}\n\n\t\t// Reset element to build again\n\n\t\tupdCur->uiUsedLen = ELM_DIN_OVHD;\n\t}\n\telse\n\t{\n \t\t// This is the last time - kill additional continuation elements\n\t\t\n\t\tif( uiFlags & UCUR_REPLACE)\n\t\t{\n\t\t\t// Need to delete all other continuation records.\n\n\t\t\twhile( !bIsLast)\n\t\t\t{\n\t\t\t\tbIsLast = (FLMBYTE)(BBE_IS_LAST( CURRENT_ELM( pStack)));\n\t\t\t\t\t\n\t\t\t\tif( RC_BAD( rc = FSBtDelete( pDb, pLFile, &pStack)))\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tupdCur->pStack = pStack;\n\nExit:\n\n\treturn( rc );\n}", "label": 0, "cwe": null, "length": 961 }, { "index": 199743, "code": "i40e_init_pf_fcoe(struct i40e_pf *pf)\n{\n\tstruct i40e_hw *hw = &pf->hw;\n\tu32 val;\n\n\tpf->flags &= ~I40E_FLAG_FCOE_ENABLED;\n\tpf->num_fcoe_qps = 0;\n\tpf->fcoe_hmc_cntx_num = 0;\n\tpf->fcoe_hmc_filt_num = 0;\n\n\tif (!pf->hw.func_caps.fcoe) {\n\t\tdev_dbg(&pf->pdev->dev, \"FCoE capability is disabled\\n\");\n\t\treturn;\n\t}\n\n\tif (!pf->hw.func_caps.dcb) {\n\t\tdev_warn(&pf->pdev->dev,\n\t\t\t \"Hardware is not DCB capable not enabling FCoE.\\n\");\n\t\treturn;\n\t}\n\n\t/* enable FCoE hash filter */\n\tval = i40e_read_rx_ctl(hw, I40E_PFQF_HENA(1));\n\tval |= BIT(I40E_FILTER_PCTYPE_FCOE_OX - 32);\n\tval |= BIT(I40E_FILTER_PCTYPE_FCOE_RX - 32);\n\tval &= I40E_PFQF_HENA_PTYPE_ENA_MASK;\n\ti40e_write_rx_ctl(hw, I40E_PFQF_HENA(1), val);\n\n\t/* enable flag */\n\tpf->flags |= I40E_FLAG_FCOE_ENABLED;\n\tpf->num_fcoe_qps = I40E_DEFAULT_FCOE;\n\n\t/* Reserve 4K DDP contexts and 20K filter size for FCoE */\n\tpf->fcoe_hmc_cntx_num = BIT(I40E_DMA_CNTX_SIZE_4K) *\n\t\t\t\tI40E_DMA_CNTX_BASE_SIZE;\n\tpf->fcoe_hmc_filt_num = pf->fcoe_hmc_cntx_num +\n\t\t\t\tBIT(I40E_HASH_FILTER_SIZE_16K) *\n\t\t\t\tI40E_HASH_FILTER_BASE_SIZE;\n\n\t/* FCoE object: max 16K filter buckets and 4K DMA contexts */\n\tpf->filter_settings.fcoe_filt_num = I40E_HASH_FILTER_SIZE_16K;\n\tpf->filter_settings.fcoe_cntx_num = I40E_DMA_CNTX_SIZE_4K;\n\n\t/* Setup max frame with FCoE_MTU plus L2 overheads */\n\tval = i40e_read_rx_ctl(hw, I40E_GLFCOE_RCTL);\n\tval &= ~I40E_GLFCOE_RCTL_MAX_SIZE_MASK;\n\tval |= ((FCOE_MTU + ETH_HLEN + VLAN_HLEN + ETH_FCS_LEN)\n\t\t << I40E_GLFCOE_RCTL_MAX_SIZE_SHIFT);\n\ti40e_write_rx_ctl(hw, I40E_GLFCOE_RCTL, val);\n\n\tdev_info(&pf->pdev->dev, \"FCoE is supported.\\n\");\n}", "label": 0, "cwe": null, "length": 585 }, { "index": 640252, "code": "qlcnic_83xx_get_reset_instruction_template(struct qlcnic_adapter *p_dev)\n{\n\tstruct qlcnic_hardware_context *ahw = p_dev->ahw;\n\tu32 addr, count, prev_ver, curr_ver;\n\tu8 *p_buff;\n\n\tif (ahw->reset.buff != NULL) {\n\t\tprev_ver = p_dev->fw_version;\n\t\tcurr_ver = qlcnic_83xx_get_fw_version(p_dev);\n\t\tif (curr_ver > prev_ver)\n\t\t\tkfree(ahw->reset.buff);\n\t\telse\n\t\t\treturn 0;\n\t}\n\n\tahw->reset.seq_error = 0;\n\tahw->reset.buff = kzalloc(QLC_83XX_RESTART_TEMPLATE_SIZE, GFP_KERNEL);\n\tif (p_dev->ahw->reset.buff == NULL)\n\t\treturn -ENOMEM;\n\n\tp_buff = p_dev->ahw->reset.buff;\n\taddr = QLC_83XX_RESET_TEMPLATE_ADDR;\n\tcount = sizeof(struct qlc_83xx_reset_hdr) / sizeof(u32);\n\n\t/* Copy template header from flash */\n\tif (qlcnic_83xx_flash_read32(p_dev, addr, p_buff, count)) {\n\t\tdev_err(&p_dev->pdev->dev, \"%s: flash read failed\\n\", __func__);\n\t\treturn -EIO;\n\t}\n\tahw->reset.hdr = (struct qlc_83xx_reset_hdr *)ahw->reset.buff;\n\taddr = QLC_83XX_RESET_TEMPLATE_ADDR + ahw->reset.hdr->hdr_size;\n\tp_buff = ahw->reset.buff + ahw->reset.hdr->hdr_size;\n\tcount = (ahw->reset.hdr->size - ahw->reset.hdr->hdr_size) / sizeof(u32);\n\n\t/* Copy rest of the template */\n\tif (qlcnic_83xx_flash_read32(p_dev, addr, p_buff, count)) {\n\t\tdev_err(&p_dev->pdev->dev, \"%s: flash read failed\\n\", __func__);\n\t\treturn -EIO;\n\t}\n\n\tif (qlcnic_83xx_reset_template_checksum(p_dev))\n\t\treturn -EIO;\n\t/* Get Stop, Start and Init command offsets */\n\tahw->reset.init_offset = ahw->reset.buff + ahw->reset.hdr->init_offset;\n\tahw->reset.start_offset = ahw->reset.buff +\n\t\t\t\t ahw->reset.hdr->start_offset;\n\tahw->reset.stop_offset = ahw->reset.buff + ahw->reset.hdr->hdr_size;\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 542 }, { "index": 79267, "code": "vac_update_relstats(Relation relation,\n\t\t\t\t\tBlockNumber num_pages, double num_tuples,\n\t\t\t\t\tbool hasindex, TransactionId frozenxid)\n{\n\tOid\t\t\trelid = RelationGetRelid(relation);\n\tRelation\trd;\n\tHeapTuple\tctup;\n\tForm_pg_class pgcform;\n\tbool\t\tdirty;\n\n\trd = heap_open(RelationRelationId, RowExclusiveLock);\n\n\t/* Fetch a copy of the tuple to scribble on */\n\tctup = SearchSysCacheCopy1(RELOID, ObjectIdGetDatum(relid));\n\tif (!HeapTupleIsValid(ctup))\n\t\telog(ERROR, \"pg_class entry for relid %u vanished during vacuuming\",\n\t\t\t relid);\n\tpgcform = (Form_pg_class) GETSTRUCT(ctup);\n\n\t/* Apply required updates, if any, to copied tuple */\n\n\tdirty = false;\n\tif (pgcform->relpages != (int32) num_pages)\n\t{\n\t\tpgcform->relpages = (int32) num_pages;\n\t\tdirty = true;\n\t}\n\tif (pgcform->reltuples != (float4) num_tuples)\n\t{\n\t\tpgcform->reltuples = (float4) num_tuples;\n\t\tdirty = true;\n\t}\n\tif (pgcform->relhasindex != hasindex)\n\t{\n\t\tpgcform->relhasindex = hasindex;\n\t\tdirty = true;\n\t}\n\n\t/*\n\t * If we have discovered that there are no indexes, then there's no\n\t * primary key either.\tThis could be done more thoroughly...\n\t */\n\tif (pgcform->relhaspkey && !hasindex)\n\t{\n\t\tpgcform->relhaspkey = false;\n\t\tdirty = true;\n\t}\n\n\t/* We also clear relhasrules and relhastriggers if needed */\n\tif (pgcform->relhasrules && relation->rd_rules == NULL)\n\t{\n\t\tpgcform->relhasrules = false;\n\t\tdirty = true;\n\t}\n\tif (pgcform->relhastriggers && relation->trigdesc == NULL)\n\t{\n\t\tpgcform->relhastriggers = false;\n\t\tdirty = true;\n\t}\n\n\t/*\n\t * relfrozenxid should never go backward. Caller can pass\n\t * InvalidTransactionId if it has no new data.\n\t */\n\tif (TransactionIdIsNormal(frozenxid) &&\n\t\tTransactionIdPrecedes(pgcform->relfrozenxid, frozenxid))\n\t{\n\t\tpgcform->relfrozenxid = frozenxid;\n\t\tdirty = true;\n\t}\n\n\t/* If anything changed, write out the tuple. */\n\tif (dirty)\n\t\theap_inplace_update(rd, ctup);\n\n\theap_close(rd, RowExclusiveLock);\n}", "label": 1, "cwe": "CWE-476", "length": 589 }, { "index": 155917, "code": "FindProcess(pid_t pid, pthread_t tid)\n{\n\tPROC *\tproc;\n\tint\tindex;\n\n\t/*\n\t * See if the process is already in the process list.\n\t * If so, return the found structure.\n\t */\n\tfor (proc = processList; proc; proc = proc->next)\n\t{\n\t\tif ((proc->pid == pid) && (proc->tid == tid) &&\n/*\t\t\t(proc->deathTime == 0) */ 1)\n\t\t{\n\t\t\treturn proc;\n\t\t}\n\t}\n\n\t/*\n\t * Nope, so allocate a new structure either from the free\n\t * list or else using malloc.\n\t */\n\tproc = freeProcessList;\n\n\tif (proc)\n\t{\n\t\tfreeProcessList = proc->next;\n\t}\n\telse\n\t{\n\t\tproc = AllocMemory(sizeof(PROC));\n\n\t\tprocAllocCount++;\n\t}\n\n\t/*\n\t * Initialise some of its columns.\n\t */\n\tproc->next = NULL;\n\tproc->nextThread = NULL;\n\tproc->owner = NULL;\n\tproc->pid = pid;\n\tproc->tid = tid;\n\tproc->isThread = (tid != NO_THREAD_ID);\n\tproc->isNew = TRUE;\n\tproc->isValid = FALSE;\n\tproc->isActive = FALSE;\n\tproc->isShown = FALSE;\n\tproc->hasCommand = FALSE;\n\tproc->isChanged = TRUE;\n\tproc->isAncient = ancientFlag;\n\tproc->state = ' ';\n\tproc->states[0] = '\\0';\n\tproc->deathTime = 0;\n\tproc->startTimeTicks = 0;\n\tproc->startTimeClock = 0;\n\tproc->firstCpuTime = 0;\n\tproc->lastSavedTime = 0;\n\tproc->lastActiveTime = 0;\n\tproc->lastSyncTime = 0;\n\tproc->liveCounter = 0;\n\tproc->percentCpu = 0;\n\tproc->percentMemory = 0;\n\tproc->threadCount = 0;\n\tproc->runOrder = 0;\n\tproc->openFiles = 0;\n\tproc->endCode = 0;\n\tproc->oldSystemRunTime = 0;\n\tproc->oldUserRunTime = 0;\n\tproc->policy = 0;\n\tproc->realTimePriority = 0;\n\tproc->commandLength = 0;\n\tproc->environmentLength = 0;\n\tproc->rootPathLength = 0;\n\tproc->cwdPathLength = 0;\n\tproc->execPathLength = 0;\n\tproc->command = proc->commandBuffer;\n\tproc->environment = emptyString;\n\tproc->rootPath = emptyString;\n\tproc->cwdPath = emptyString;\n\tproc->execPath = emptyString;\n\tproc->stdioPaths[0] = emptyString;\n\tproc->stdioPaths[1] = emptyString;\n\tproc->stdioPaths[2] = emptyString;\n\tproc->program[0] = '\\0';\n\tproc->waitChanSymbol[0] = '\\0';\n\n\t/*\n\t * Initialize all the cpu samples to zero.\n\t */\n\tfor (index = 0; index < PERCENT_SAMPLES; index++)\n\t{\n\t\tproc->cpuTable[index] = 0;\n\t}\n\n\t/*\n\t * Add it to the process list.\n\t */\n\tproc->next = processList;\n\tprocessList = proc;\n\n\t/*\n\t * If this is a thread process then link it into the thread\n\t * list of its main process.\n\t */\n\tif (tid != NO_THREAD_ID)\n\t{\n\t\tPROC * mainProc = FindProcess(pid, NO_THREAD_ID);\n\n\t\tproc->owner = mainProc;\n\t\tproc->nextThread = mainProc->nextThread;\n\t\tmainProc->nextThread = proc;\n\t}\n\n\treturn proc;\n}", "label": 0, "cwe": null, "length": 801 }, { "index": 682782, "code": "cselib_process_insn (rtx insn)\n{\n int i;\n rtx x;\n\n if (find_reg_note (insn, REG_LIBCALL, NULL))\n cselib_current_insn_in_libcall = true;\n cselib_current_insn = insn;\n\n /* Forget everything at a CODE_LABEL, a volatile asm, or a setjmp. */\n if (GET_CODE (insn) == CODE_LABEL\n || (GET_CODE (insn) == CALL_INSN\n\t && find_reg_note (insn, REG_SETJMP, NULL))\n || (GET_CODE (insn) == INSN\n\t && GET_CODE (PATTERN (insn)) == ASM_OPERANDS\n\t && MEM_VOLATILE_P (PATTERN (insn))))\n {\n if (find_reg_note (insn, REG_RETVAL, NULL))\n cselib_current_insn_in_libcall = false;\n clear_table ();\n return;\n }\n\n if (! INSN_P (insn))\n {\n if (find_reg_note (insn, REG_RETVAL, NULL))\n cselib_current_insn_in_libcall = false;\n cselib_current_insn = 0;\n return;\n }\n\n /* If this is a call instruction, forget anything stored in a\n call clobbered register, or, if this is not a const call, in\n memory. */\n if (GET_CODE (insn) == CALL_INSN)\n {\n for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)\n\tif (call_used_regs[i])\n\t cselib_invalidate_regno (i, reg_raw_mode[i]);\n\n if (! CONST_OR_PURE_CALL_P (insn))\n\tcselib_invalidate_mem (callmem);\n }\n\n cselib_record_sets (insn);\n\n#ifdef AUTO_INC_DEC\n /* Clobber any registers which appear in REG_INC notes. We\n could keep track of the changes to their values, but it is\n unlikely to help. */\n for (x = REG_NOTES (insn); x; x = XEXP (x, 1))\n if (REG_NOTE_KIND (x) == REG_INC)\n cselib_invalidate_rtx (XEXP (x, 0));\n#endif\n\n /* Look for any CLOBBERs in CALL_INSN_FUNCTION_USAGE, but only\n after we have processed the insn. */\n if (GET_CODE (insn) == CALL_INSN)\n for (x = CALL_INSN_FUNCTION_USAGE (insn); x; x = XEXP (x, 1))\n if (GET_CODE (XEXP (x, 0)) == CLOBBER)\n\tcselib_invalidate_rtx (XEXP (XEXP (x, 0), 0));\n\n if (find_reg_note (insn, REG_RETVAL, NULL))\n cselib_current_insn_in_libcall = false;\n cselib_current_insn = 0;\n\n if (n_useless_values > MAX_USELESS_VALUES)\n remove_useless_values ();\n}", "label": 0, "cwe": null, "length": 639 }, { "index": 54908, "code": "nvdimm_namespace_common_probe(struct device *dev)\n{\n\tstruct nd_btt *nd_btt = is_nd_btt(dev) ? to_nd_btt(dev) : NULL;\n\tstruct nd_pfn *nd_pfn = is_nd_pfn(dev) ? to_nd_pfn(dev) : NULL;\n\tstruct nd_namespace_common *ndns;\n\tresource_size_t size;\n\n\tif (nd_btt || nd_pfn) {\n\t\tstruct device *host = NULL;\n\n\t\tif (nd_btt) {\n\t\t\thost = &nd_btt->dev;\n\t\t\tndns = nd_btt->ndns;\n\t\t} else if (nd_pfn) {\n\t\t\thost = &nd_pfn->dev;\n\t\t\tndns = nd_pfn->ndns;\n\t\t}\n\n\t\tif (!ndns || !host)\n\t\t\treturn ERR_PTR(-ENODEV);\n\n\t\t/*\n\t\t * Flush any in-progess probes / removals in the driver\n\t\t * for the raw personality of this namespace.\n\t\t */\n\t\tdevice_lock(&ndns->dev);\n\t\tdevice_unlock(&ndns->dev);\n\t\tif (ndns->dev.driver) {\n\t\t\tdev_dbg(&ndns->dev, \"is active, can't bind %s\\n\",\n\t\t\t\t\tdev_name(host));\n\t\t\treturn ERR_PTR(-EBUSY);\n\t\t}\n\t\tif (dev_WARN_ONCE(&ndns->dev, ndns->claim != host,\n\t\t\t\t\t\"host (%s) vs claim (%s) mismatch\\n\",\n\t\t\t\t\tdev_name(host),\n\t\t\t\t\tdev_name(ndns->claim)))\n\t\t\treturn ERR_PTR(-ENXIO);\n\t} else {\n\t\tndns = to_ndns(dev);\n\t\tif (ndns->claim) {\n\t\t\tdev_dbg(dev, \"claimed by %s, failing probe\\n\",\n\t\t\t\tdev_name(ndns->claim));\n\n\t\t\treturn ERR_PTR(-ENXIO);\n\t\t}\n\t}\n\n\tsize = nvdimm_namespace_capacity(ndns);\n\tif (size < ND_MIN_NAMESPACE_SIZE) {\n\t\tdev_dbg(&ndns->dev, \"%pa, too small must be at least %#x\\n\",\n\t\t\t\t&size, ND_MIN_NAMESPACE_SIZE);\n\t\treturn ERR_PTR(-ENODEV);\n\t}\n\n\tif (is_namespace_pmem(&ndns->dev)) {\n\t\tstruct nd_namespace_pmem *nspm;\n\n\t\tnspm = to_nd_namespace_pmem(&ndns->dev);\n\t\tif (!nspm->uuid) {\n\t\t\tdev_dbg(&ndns->dev, \"%s: uuid not set\\n\", __func__);\n\t\t\treturn ERR_PTR(-ENODEV);\n\t\t}\n\t} else if (is_namespace_blk(&ndns->dev)) {\n\t\tstruct nd_namespace_blk *nsblk;\n\n\t\tnsblk = to_nd_namespace_blk(&ndns->dev);\n\t\tif (!nd_namespace_blk_validate(nsblk))\n\t\t\treturn ERR_PTR(-ENODEV);\n\t}\n\n\treturn ndns;\n}", "label": 0, "cwe": null, "length": 593 }, { "index": 728242, "code": "CommandShowAnalysis(char *UNUSED(sz))\n{\n\n int i;\n\n outputl(fAnalyseCube ? _(\"Cube action will be analysed.\") : _(\"Cube action will not be analysed.\"));\n\n outputl(fAnalyseDice ? _(\"Dice rolls will be analysed.\") : _(\"Dice rolls will not be analysed.\"));\n\n if (fAnalyseMove) {\n outputl(_(\"Chequer play will be analysed.\"));\n } else\n outputl(_(\"Chequer play will not be analysed.\"));\n\n outputl(\"\");\n for (i = 0; i < 2; ++i)\n outputf(_(\"Analyse %s's chequerplay and cube decisions: %s\\n\"),\n ap[i].szName, afAnalysePlayers[i] ? _(\"yes\") : _(\"no\"));\n\n outputl(_(\"\\nAnalysis thresholds:\"));\n outputf( /*\" +%.3f %s\\n\"\n * \" +%.3f %s\\n\" */\n \" -%.3f %s\\n\"\n \" -%.3f %s\\n\"\n \" -%.3f %s\\n\"\n \"\\n\"\n \" +%.3f %s\\n\"\n \" +%.3f %s\\n\"\n \" -%.3f %s\\n\"\n \" -%.3f %s\\n\",\n arSkillLevel[SKILL_DOUBTFUL],\n gettext(aszSkillType[SKILL_DOUBTFUL]),\n arSkillLevel[SKILL_BAD],\n gettext(aszSkillType[SKILL_BAD]),\n arSkillLevel[SKILL_VERYBAD],\n gettext(aszSkillType[SKILL_VERYBAD]),\n arLuckLevel[LUCK_VERYGOOD],\n gettext(aszLuckType[LUCK_VERYGOOD]),\n arLuckLevel[LUCK_GOOD],\n gettext(aszLuckType[LUCK_GOOD]),\n arLuckLevel[LUCK_BAD],\n gettext(aszLuckType[LUCK_BAD]), arLuckLevel[LUCK_VERYBAD], gettext(aszLuckType[LUCK_VERYBAD]));\n\n outputl(_(\"\\n\" \"Analysis will be performed with the \" \"following evaluation parameters:\"));\n outputl(_(\" Chequer play:\"));\n ShowEvalSetup(&esAnalysisChequer);\n ShowMoveFilters(aamfAnalysis);\n outputl(_(\" Cube decisions:\"));\n ShowEvalSetup(&esAnalysisCube);\n\n outputl(_(\" Luck analysis:\"));\n ShowEvaluation(&ecLuck);\n\n}", "label": 0, "cwe": null, "length": 523 }, { "index": 619918, "code": "AddStat(common_record_t *raw_record, master_record_t *flow_record ) {\nStatRecord_t\t\t*stat_record;\nuint64_t\t\t\tvalue[2][2];\nint\tj, i;\n\n\t// for every requested -s stat do\n\tfor ( j=0; j> shift;\n\t\t\toffset = StatParameters[stat].element[i].offset0;\n\t\t\tvalue[i][0] = offset ? ((uint64_t *)flow_record)[offset] : 0;\n\n\t\t\t/* \n\t\t\t * make sure each flow is counted once only\n\t\t\t * if src and dst have the same values, count it once only\n\t\t\t */\n\t\t\tif ( i == 1 && value[0][0] == value[1][0] && value[0][1] == value[1][1] ) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tstat_record = stat_hash_lookup(value[i], flow_record->prot, j);\n\t\t\tif ( stat_record ) {\n\t\t\t\tstat_record->counter[INBYTES] \t+= flow_record->dOctets;\n\t\t\t\tstat_record->counter[INPACKETS] += flow_record->dPkts;\n\t\t\n\t\t\t\tif ( TimeMsec_CMP(flow_record->first, flow_record->msec_first, stat_record->first, stat_record->msec_first) == 2) {\n\t\t\t\t\tstat_record->first \t\t= flow_record->first;\n\t\t\t\t\tstat_record->msec_first = flow_record->msec_first;\n\t\t\t\t}\n\t\t\t\tif ( TimeMsec_CMP(flow_record->last, flow_record->msec_last, stat_record->last, stat_record->msec_last) == 1) {\n\t\t\t\t\tstat_record->last \t\t= flow_record->last;\n\t\t\t\t\tstat_record->msec_last \t= flow_record->msec_last;\n\t\t\t\t}\n\t\t\t\tstat_record->counter[FLOWS] += flow_record->aggr_flows ? flow_record->aggr_flows : 1;\n\n\t\t\t} else {\n\t\t\t\tstat_record = stat_hash_insert(value[i], flow_record->prot, j);\n\t\t\n\t\t\t\tstat_record->counter[INBYTES] = flow_record->dOctets;\n\t\t\t\tstat_record->counter[INPACKETS]\t= flow_record->dPkts;\n\t\t\t\tstat_record->first \t\t\t= flow_record->first;\n\t\t\t\tstat_record->msec_first \t\t= flow_record->msec_first;\n\t\t\t\tstat_record->last\t\t\t\t= flow_record->last;\n\t\t\t\tstat_record->msec_last\t\t\t= flow_record->msec_last;\n\t\t\t\tstat_record->record_flags\t\t= flow_record->flags & 0x1;\n\t\t\t\tstat_record->counter[FLOWS]\t\t= flow_record->aggr_flows ? flow_record->aggr_flows : 1;\n\t\t\t}\n\t\t} // for the number of elements in this stat type\n\t} // for every requested -s stat\n\n}", "label": 1, "cwe": "CWE-other", "length": 725 }, { "index": 405038, "code": "ConcatenateColorComponent(const MagickPixelPacket *pixel,\n const ChannelType channel,const ComplianceType compliance,char *tuple)\n{\n char\n component[MaxTextExtent];\n\n MagickRealType\n color;\n\n color=0.0;\n switch (channel)\n {\n case RedChannel:\n {\n color=pixel->red;\n break;\n }\n case GreenChannel:\n {\n color=pixel->green;\n break;\n }\n case BlueChannel:\n {\n color=pixel->blue;\n break;\n }\n case AlphaChannel:\n {\n color=QuantumRange-pixel->opacity;\n break;\n }\n case IndexChannel:\n {\n color=pixel->index;\n break;\n }\n default:\n break;\n }\n if (compliance != SVGCompliance)\n {\n if (pixel->depth > 16)\n {\n (void) FormatLocaleString(component,MaxTextExtent,\"%10lu\",\n (unsigned long) ScaleQuantumToLong(ClampToQuantum(color)));\n (void) ConcatenateMagickString(tuple,component,MaxTextExtent);\n return;\n }\n if (pixel->depth > 8)\n {\n (void) FormatLocaleString(component,MaxTextExtent,\"%5d\",\n ScaleQuantumToShort(ClampToQuantum(color)));\n (void) ConcatenateMagickString(tuple,component,MaxTextExtent);\n return;\n }\n (void) FormatLocaleString(component,MaxTextExtent,\"%3d\",\n ScaleQuantumToChar(ClampToQuantum(color)));\n (void) ConcatenateMagickString(tuple,component,MaxTextExtent);\n return;\n }\n if (channel == OpacityChannel)\n {\n (void) FormatLocaleString(component,MaxTextExtent,\"%g\",\n (double) (QuantumScale*color));\n (void) ConcatenateMagickString(tuple,component,MaxTextExtent);\n return;\n }\n if ((pixel->colorspace == HSLColorspace) ||\n (pixel->colorspace == HSBColorspace))\n {\n (void) FormatLocaleString(component,MaxTextExtent,\"%g%%\",\n (double) (100.0*QuantumScale*color));\n (void) ConcatenateMagickString(tuple,component,MaxTextExtent);\n return;\n }\n if (pixel->depth > 8)\n {\n (void) FormatLocaleString(component,MaxTextExtent,\"%g%%\",\n (double) (100.0*QuantumScale*color));\n (void) ConcatenateMagickString(tuple,component,MaxTextExtent);\n return;\n }\n (void) FormatLocaleString(component,MaxTextExtent,\"%d\",\n ScaleQuantumToChar(ClampToQuantum(color)));\n (void) ConcatenateMagickString(tuple,component,MaxTextExtent);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 609 }, { "index": 506013, "code": "client_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,\n int32_t flags, dict_t *xdata)\n{\n int ret = -1;\n int op_ret = -1;\n int op_errno = ENOTCONN;\n int need_unwind = 0;\n clnt_conf_t *conf = NULL;\n rpc_clnt_procedure_t *proc = NULL;\n clnt_args_t args = {0,};\n char *value = NULL;\n\n\n if (is_client_rpc_init_command (dict, this, &value) == _gf_true) {\n GF_ASSERT (value);\n gf_log (this->name, GF_LOG_INFO, \"client rpc init command\");\n ret = client_set_remote_options (value, this);\n if (ret) {\n (void) client_destroy_rpc (this);\n ret = client_init_rpc (this);\n }\n\n if (!ret) {\n op_ret = 0;\n op_errno = 0;\n }\n need_unwind = 1;\n goto out;\n }\n\n if (is_client_rpc_destroy_command (dict, this) == _gf_true) {\n gf_log (this->name, GF_LOG_INFO, \"client rpc destroy command\");\n ret = client_destroy_rpc (this);\n if (ret) {\n op_ret = 0;\n op_errno = 0;\n }\n need_unwind = 1;\n goto out;\n }\n\n conf = this->private;\n if (!conf || !conf->fops) {\n op_errno = ENOTCONN;\n need_unwind = 1;\n goto out;\n }\n\n args.loc = loc;\n args.xattr = dict;\n args.flags = flags;\n args.xdata = xdata;\n\n proc = &conf->fops->proctable[GF_FOP_SETXATTR];\n if (!proc) {\n gf_log (this->name, GF_LOG_ERROR,\n \"rpc procedure not found for %s\",\n gf_fop_list[GF_FOP_SETXATTR]);\n goto out;\n }\n if (proc->fn) {\n ret = proc->fn (frame, this, &args);\n if (ret) {\n need_unwind = 1;\n }\n }\nout:\n if (need_unwind)\n STACK_UNWIND_STRICT (setxattr, frame, op_ret, op_errno, NULL);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 547 }, { "index": 118624, "code": "WriteEffectParameterSampler(FCDObject* object, xmlNode* parentNode)\r\n{\r\n\tFCDEffectParameterSampler* effectParameterSampler = (FCDEffectParameterSampler*)object;\r\n\r\n\txmlNode* parameterNode = FArchiveXML::WriteEffectParameter(effectParameterSampler, parentNode);\r\n\tconst char* samplerName;\r\n\tswitch (effectParameterSampler->GetSamplerType())\r\n\t{\r\n\tcase FCDEffectParameterSampler::SAMPLER1D: samplerName = DAE_FXCMN_SAMPLER1D_ELEMENT; break;\r\n\tcase FCDEffectParameterSampler::SAMPLER2D: samplerName = DAE_FXCMN_SAMPLER2D_ELEMENT; break;\r\n\tcase FCDEffectParameterSampler::SAMPLER3D: samplerName = DAE_FXCMN_SAMPLER3D_ELEMENT; break;\r\n\tcase FCDEffectParameterSampler::SAMPLERCUBE: samplerName = DAE_FXCMN_SAMPLERCUBE_ELEMENT; break;\r\n\tdefault: samplerName = DAEERR_UNKNOWN_ELEMENT; break;\r\n\t}\r\n\txmlNode* samplerNode = AddChild(parameterNode, samplerName);\r\n\tAddChild(samplerNode, DAE_SOURCE_ELEMENT, effectParameterSampler->GetSurface() != NULL ? effectParameterSampler->GetSurface()->GetReference() : \"\");\r\n\r\n\tswitch (effectParameterSampler->GetSamplerType())\r\n\t{\r\n\tcase FCDEffectParameterSampler::SAMPLER1D:\r\n\t\t{\r\n\t\t\tAddChild(samplerNode, DAE_WRAP_S_ELEMENT, FUDaeTextureWrapMode::ToString(effectParameterSampler->GetWrapS()));\r\n\t\t} break;\r\n\tcase FCDEffectParameterSampler::SAMPLER2D:\r\n\t\t{\r\n\t\t\tAddChild(samplerNode, DAE_WRAP_S_ELEMENT, FUDaeTextureWrapMode::ToString(effectParameterSampler->GetWrapS()));\r\n\t\t\tAddChild(samplerNode, DAE_WRAP_T_ELEMENT, FUDaeTextureWrapMode::ToString(effectParameterSampler->GetWrapT()));\r\n\t\t} break;\r\n\tcase FCDEffectParameterSampler::SAMPLER3D:\r\n\tcase FCDEffectParameterSampler::SAMPLERCUBE:\r\n\t\t{\r\n\t\t\tAddChild(samplerNode, DAE_WRAP_S_ELEMENT, FUDaeTextureWrapMode::ToString(effectParameterSampler->GetWrapS()));\r\n\t\t\tAddChild(samplerNode, DAE_WRAP_T_ELEMENT, FUDaeTextureWrapMode::ToString(effectParameterSampler->GetWrapT()));\r\n\t\t\tAddChild(samplerNode, DAE_WRAP_P_ELEMENT, FUDaeTextureWrapMode::ToString(effectParameterSampler->GetWrapP()));\r\n\t\t} break;\r\n\t}\r\n\r\n\tAddChild(samplerNode, DAE_MIN_FILTER_ELEMENT, FUDaeTextureFilterFunction::ToString(effectParameterSampler->GetMinFilter()));\r\n\tAddChild(samplerNode, DAE_MAG_FILTER_ELEMENT, FUDaeTextureFilterFunction::ToString(effectParameterSampler->GetMagFilter()));\r\n\tAddChild(samplerNode, DAE_MIP_FILTER_ELEMENT, FUDaeTextureFilterFunction::ToString(effectParameterSampler->GetMipFilter()));\r\n\r\n\treturn parameterNode;\r\n}", "label": 0, "cwe": null, "length": 610 }, { "index": 883245, "code": "pixSetUnderTransparency(PIX *pixs,\n l_uint32 val,\n l_int32 debugflag)\n{\nl_int32 isblack, rval, gval, bval;\nPIX *pixr, *pixg, *pixb, *pixalpha, *pixm, *pixt, *pixd;\nPIXA *pixa;\n\n PROCNAME(\"pixSetUnderTransparency\");\n\n if (!pixs || pixGetDepth(pixs) != 32)\n return (PIX *)ERROR_PTR(\"pixs not defined or not 32 bpp\",\n procName, NULL);\n\n pixalpha = pixGetRGBComponent(pixs, L_ALPHA_CHANNEL);\n pixZero(pixalpha, &isblack);\n if (isblack) {\n L_WARNING(\n \"alpha channel is fully transparent; likely invalid; ignoring\",\n procName);\n pixDestroy(&pixalpha);\n return pixCopy(NULL, pixs);\n }\n pixr = pixGetRGBComponent(pixs, COLOR_RED);\n pixg = pixGetRGBComponent(pixs, COLOR_GREEN);\n pixb = pixGetRGBComponent(pixs, COLOR_BLUE);\n\n /* Make a mask from the alpha component with ON pixels\n * wherever the alpha component is fully transparent (0).\n * One can do this:\n * l_int32 *lut = (l_int32 *)CALLOC(256, sizeof(l_int32));\n * lut[0] = 1;\n * pixm = pixMakeMaskFromLUT(pixalpha, lut);\n * FREE(lut);\n * But there's an easier way to set pixels in a mask where\n * the alpha component is 0 ... */\n pixm = pixThresholdToBinary(pixalpha, 1);\n\n if (debugflag) {\n pixa = pixaCreate(0);\n pixSaveTiled(pixs, pixa, 1, 1, 20, 32);\n pixSaveTiled(pixm, pixa, 1, 0, 20, 0);\n pixSaveTiled(pixr, pixa, 1, 1, 20, 0);\n pixSaveTiled(pixg, pixa, 1, 0, 20, 0);\n pixSaveTiled(pixb, pixa, 1, 0, 20, 0);\n pixSaveTiled(pixalpha, pixa, 1, 0, 20, 0);\n }\n\n /* Clean each component and reassemble */\n extractRGBValues(val, &rval, &gval, &bval);\n pixSetMasked(pixr, pixm, rval);\n pixSetMasked(pixg, pixm, gval);\n pixSetMasked(pixb, pixm, bval);\n pixd = pixCreateRGBImage(pixr, pixg, pixb);\n pixSetRGBComponent(pixd, pixalpha, L_ALPHA_CHANNEL);\n\n if (debugflag) {\n pixSaveTiled(pixr, pixa, 1, 1, 20, 0);\n pixSaveTiled(pixg, pixa, 1, 0, 20, 0);\n pixSaveTiled(pixb, pixa, 1, 0, 20, 0);\n pixSaveTiled(pixd, pixa, 1, 1, 20, 0);\n pixt = pixaDisplay(pixa, 0, 0);\n pixWriteTempfile(\"/tmp\", \"rgb.png\", pixt, IFF_PNG, NULL);\n pixDestroy(&pixt);\n pixaDestroy(&pixa);\n }\n\n pixDestroy(&pixr);\n pixDestroy(&pixg);\n pixDestroy(&pixb);\n pixDestroy(&pixm);\n pixDestroy(&pixalpha);\n return pixd;\n}", "label": 0, "cwe": null, "length": 851 }, { "index": 730568, "code": "ath9k_init_priv(struct ath9k_htc_priv *priv,\n\t\t\t u16 devid, char *product,\n\t\t\t u32 drv_info)\n{\n\tstruct ath_hw *ah = NULL;\n\tstruct ath_common *common;\n\tint i, ret = 0, csz = 0;\n\n\tah = kzalloc(sizeof(struct ath_hw), GFP_KERNEL);\n\tif (!ah)\n\t\treturn -ENOMEM;\n\n\tah->dev = priv->dev;\n\tah->hw = priv->hw;\n\tah->hw_version.devid = devid;\n\tah->hw_version.usbdev = drv_info;\n\tah->ah_flags |= AH_USE_EEPROM;\n\tah->reg_ops.read = ath9k_regread;\n\tah->reg_ops.multi_read = ath9k_multi_regread;\n\tah->reg_ops.write = ath9k_regwrite;\n\tah->reg_ops.enable_write_buffer = ath9k_enable_regwrite_buffer;\n\tah->reg_ops.write_flush = ath9k_regwrite_flush;\n\tah->reg_ops.enable_rmw_buffer = ath9k_enable_rmw_buffer;\n\tah->reg_ops.rmw_flush = ath9k_reg_rmw_flush;\n\tah->reg_ops.rmw = ath9k_reg_rmw;\n\tpriv->ah = ah;\n\n\tcommon = ath9k_hw_common(ah);\n\tcommon->ops = &ah->reg_ops;\n\tcommon->ps_ops = &ath9k_htc_ps_ops;\n\tcommon->bus_ops = &ath9k_usb_bus_ops;\n\tcommon->ah = ah;\n\tcommon->hw = priv->hw;\n\tcommon->priv = priv;\n\tcommon->debug_mask = ath9k_debug;\n\tcommon->btcoex_enabled = ath9k_htc_btcoex_enable == 1;\n\tset_bit(ATH_OP_INVALID, &common->op_flags);\n\n\tspin_lock_init(&priv->beacon_lock);\n\tspin_lock_init(&priv->tx.tx_lock);\n\tmutex_init(&priv->mutex);\n\tmutex_init(&priv->htc_pm_lock);\n\ttasklet_init(&priv->rx_tasklet, ath9k_rx_tasklet,\n\t\t (unsigned long)priv);\n\ttasklet_init(&priv->tx_failed_tasklet, ath9k_tx_failed_tasklet,\n\t\t (unsigned long)priv);\n\tINIT_DELAYED_WORK(&priv->ani_work, ath9k_htc_ani_work);\n\tINIT_WORK(&priv->ps_work, ath9k_ps_work);\n\tINIT_WORK(&priv->fatal_work, ath9k_fatal_work);\n\tsetup_timer(&priv->tx.cleanup_timer, ath9k_htc_tx_cleanup_timer,\n\t\t (unsigned long)priv);\n\n\t/*\n\t * Cache line size is used to size and align various\n\t * structures used to communicate with the hardware.\n\t */\n\tath_read_cachesize(common, &csz);\n\tcommon->cachelsz = csz << 2; /* convert to bytes */\n\n\tret = ath9k_hw_init(ah);\n\tif (ret) {\n\t\tath_err(common,\n\t\t\t\"Unable to initialize hardware; initialization status: %d\\n\",\n\t\t\tret);\n\t\tgoto err_hw;\n\t}\n\n\tret = ath9k_init_queues(priv);\n\tif (ret)\n\t\tgoto err_queues;\n\n\tfor (i = 0; i < ATH9K_HTC_MAX_BCN_VIF; i++)\n\t\tpriv->beacon.bslot[i] = NULL;\n\tpriv->beacon.slottime = ATH9K_SLOT_TIME_9;\n\n\tath9k_cmn_init_channels_rates(common);\n\tath9k_cmn_init_crypto(ah);\n\tath9k_init_misc(priv);\n\tath9k_htc_init_btcoex(priv, product);\n\n\treturn 0;\n\nerr_queues:\n\tath9k_hw_deinit(ah);\nerr_hw:\n\n\tkfree(ah);\n\tpriv->ah = NULL;\n\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 783 }, { "index": 872674, "code": "dmg_decode_mish(cli_ctx *ctx, unsigned int *mishblocknum, xmlChar *mish_base64,\n struct dmg_mish_with_stripes *mish_set)\n{\n int ret = CL_CLEAN;\n size_t base64_len, buff_size, decoded_len;\n uint8_t *decoded;\n const uint8_t mish_magic[4] = { 0x6d, 0x69, 0x73, 0x68 };\n\n (*mishblocknum)++;\n base64_len = strlen(mish_base64);\n dmg_parsemsg(\"dmg_decode_mish: len of encoded block %u is %lu\\n\", *mishblocknum, base64_len);\n\n /* speed vs memory, could walk the encoded data and skip whitespace in calculation */\n buff_size = 3 * base64_len / 4 + 4;\n dmg_parsemsg(\"dmg_decode_mish: buffer for mish block %u is %lu\\n\", *mishblocknum, (unsigned long)buff_size);\n decoded = cli_malloc(buff_size);\n if (!decoded)\n return CL_EMEM;\n\n if (sf_base64decode((uint8_t *)mish_base64, base64_len, decoded, buff_size - 1, &decoded_len)) {\n cli_dbgmsg(\"dmg_decode_mish: failed base64 decoding on mish block %u\\n\", *mishblocknum);\n free(decoded);\n return CL_EFORMAT;\n }\n dmg_parsemsg(\"dmg_decode_mish: len of decoded mish block %u is %lu\\n\", *mishblocknum, (unsigned long)decoded_len);\n \n if (decoded_len < sizeof(struct dmg_mish_block)) {\n cli_dbgmsg(\"dmg_decode_mish: block %u too short for valid mish block\\n\", *mishblocknum);\n free(decoded);\n return CL_EFORMAT;\n }\n /* mish check: magic is mish, have to check after conversion from base64\n * mish base64 is bWlzaA [but last character can change last two bytes]\n * won't see that in practice much (affects value of version field) */\n if (memcmp(decoded, mish_magic, 4)) {\n cli_dbgmsg(\"dmg_decode_mish: block %u does not have mish magic\\n\", *mishblocknum);\n free(decoded);\n return CL_EFORMAT;\n }\n\n mish_set->mish = (struct dmg_mish_block *)decoded;\n mish_set->mish->startSector = be64_to_host(mish_set->mish->startSector);\n mish_set->mish->sectorCount = be64_to_host(mish_set->mish->sectorCount);\n mish_set->mish->dataOffset = be64_to_host(mish_set->mish->dataOffset);\n // mish_set->mish->bufferCount = be32_to_host(mish_set->mish->bufferCount);\n mish_set->mish->blockDataCount = be32_to_host(mish_set->mish->blockDataCount);\n\n cli_dbgmsg(\"dmg_decode_mish: startSector = \" STDu64 \" sectorCount = \" STDu64\n \" dataOffset = \" STDu64 \" stripeCount = \" STDu32 \"\\n\",\n mish_set->mish->startSector, mish_set->mish->sectorCount,\n mish_set->mish->dataOffset, mish_set->mish->blockDataCount);\n\n /* decoded length should be mish block + blockDataCount * 40 */\n if (decoded_len < (sizeof(struct dmg_mish_block)\n + mish_set->mish->blockDataCount * sizeof(struct dmg_block_data))) {\n cli_dbgmsg(\"dmg_decode_mish: mish block %u too small\\n\", *mishblocknum);\n free(decoded);\n mish_set->mish = NULL;\n return CL_EFORMAT;\n }\n else if (decoded_len > (sizeof(struct dmg_mish_block)\n + mish_set->mish->blockDataCount * sizeof(struct dmg_block_data))) {\n cli_dbgmsg(\"dmg_decode_mish: mish block %u bigger than needed, continuing\\n\", *mishblocknum);\n }\n\n mish_set->stripes = (struct dmg_block_data *)(decoded + sizeof(struct dmg_mish_block));\n return CL_CLEAN;\n}", "label": 0, "cwe": null, "length": 925 }, { "index": 34499, "code": "openFile(HttpQueue *q)\n{\n HttpRx *rx;\n HttpTx *tx;\n HttpRoute *route;\n HttpConn *conn;\n char *date;\n\n conn = q->conn;\n tx = conn->tx;\n rx = conn->rx;\n route = rx->route;\n\n if (rx->flags & (HTTP_GET | HTTP_HEAD | HTTP_POST)) {\n if (tx->fileInfo.valid && tx->fileInfo.mtime) {\n // TODO - OPT could cache this\n date = httpGetDateString(&tx->fileInfo);\n httpSetHeader(conn, \"Last-Modified\", date);\n }\n if (httpContentNotModified(conn)) {\n httpSetStatus(conn, HTTP_CODE_NOT_MODIFIED);\n httpOmitBody(conn);\n } else {\n httpSetEntityLength(conn, tx->fileInfo.size);\n }\n if (!tx->fileInfo.isReg && !tx->fileInfo.isLink) {\n httpError(conn, HTTP_CODE_NOT_FOUND, \"Can't locate document: %s\", rx->uri);\n \n } else if (tx->fileInfo.size > conn->limits->transmissionBodySize) {\n httpError(conn, HTTP_ABORT | HTTP_CODE_REQUEST_TOO_LARGE,\n \"Http transmission aborted. File size exceeds max body of %,Ld bytes\", conn->limits->transmissionBodySize);\n \n } else if (!(tx->connector == conn->http->sendConnector)) {\n /*\n Open the file if a body must be sent with the response. The file will be automatically closed when \n the request completes.\n */\n if (!(tx->flags & HTTP_TX_NO_BODY)) {\n tx->file = mprOpenFile(tx->filename, O_RDONLY | O_BINARY, 0);\n if (tx->file == 0) {\n if (rx->referrer) {\n httpError(conn, HTTP_CODE_NOT_FOUND, \"Can't open document: %s from %s\", tx->filename, rx->referrer);\n } else {\n httpError(conn, HTTP_CODE_NOT_FOUND, \"Can't open document: %s from %s\", tx->filename);\n }\n }\n }\n }\n\n } else if (rx->flags & (HTTP_OPTIONS | HTTP_TRACE)) {\n httpHandleOptionsTrace(q->conn);\n\n } else if ((rx->flags & (HTTP_PUT | HTTP_DELETE)) && (route->flags & HTTP_ROUTE_PUT_DELETE)) {\n httpOmitBody(conn);\n\n } else {\n httpError(q->conn, HTTP_CODE_BAD_METHOD, \"The \\\"%s\\\" method is not supported by file handler\", rx->method);\n }\n}", "label": 0, "cwe": null, "length": 562 }, { "index": 121211, "code": "srcdkfTimeUpdate(srcdkf_t *f, float32_t *u, float32_t dt) {\n\tint S = f->S;\t\t\t// number of states\n\tint V = f->V;\t\t\t// number of noise variables\n\tint L;\t\t\t\t// number of sigma points\n\tfloat32_t *x = f->x.pData;\t// state estimate\n\tfloat32_t *Xa = f->Xa.pData;\t// augmented sigma points\n\t//\tfloat32_t *xIn = f->xIn;\t// callback buffer\n\t//\tfloat32_t *xOut = f->xOut;\t// callback buffer\n\t//\tfloat32_t *xNoise = f->xNoise;\t// callback buffer\n\tfloat32_t *qrTempS = f->qrTempS.pData;\n\tint i, j;\n\n\tsrcdkfCalcSigmaPoints(f, &f->Sv);\n\tL = f->L;\n\n\t// Xa = f(Xx, Xv, u, dt)\n\t//\tfor (i = 0; i < L; i++) {\n\t//\t\tfor (j = 0; j < S; j++)\n\t//\t\t\txIn[j] = Xa[j*L + i];\n\t//\n\t//\t\tfor (j = 0; j < V; j++)\n\t//\t\t\txNoise[j] = Xa[(S+j)*L + i];\n\t//\n\t//\t\tf->timeUpdate(xIn, xNoise, xOut, u, dt);\n\t//\n\t//\t\tfor (j = 0; j < S; j++)\n\t//\t\t\tXa[j*L + i] = xOut[j];\n\t//\t}\n\tf->timeUpdate(&Xa[0], &Xa[S*L], &Xa[0], u, dt, L);\n\n\t// sum weighted resultant sigma points to create estimated state\n\tf->w0m = (f->hh - (float32_t)(S+V)) / f->hh;\n\tfor (i = 0; i < S; i++) {\n\t\tint rOffset = i*L;\n\n\t\tx[i] = Xa[rOffset + 0] * f->w0m;\n\n\t\tfor (j = 1; j < L; j++) {\n\t\t\tx[i] += Xa[rOffset + j] * f->wim;\n\t\t}\n\t}\n\n\t// update state covariance\n\tfor (i = 0; i < S; i++) {\n\t\tint rOffset = i*(S+V)*2;\n\n\t\tfor (j = 0; j < S+V; j++) {\n\t\t\tqrTempS[rOffset + j] = (Xa[i*L + j + 1] - Xa[i*L + S+V + j + 1]) * f->wic1;\n\t\t\tqrTempS[rOffset + S+V + j] = (Xa[i*L + j + 1] + Xa[i*L + S+V + j + 1] - 2.0f*Xa[i*L + 0]) * f->wic2;\n\t\t}\n\t}\n\n\tqrDecompositionT_f32(&f->qrTempS, NULL, &f->SxT); // with transposition\n\tarm_mat_trans_f32(&f->SxT, &f->Sx);\n}", "label": 0, "cwe": null, "length": 714 }, { "index": 65643, "code": "Set(Object *in, Object *out, int flag)\n{\n char *key = NULL, *get_modid = NULL;\n char *set_modid = NULL;\n#if 0\n int triggerAlways = 0;\n#endif\n int trigger;\n Object old = NULL;\n\n if (SET_LINK)\n {\n#if 0\n\tif (SET_TRIGGER_ALWAYS)\n\t{\n\t if (! DXExtractInteger(SET_TRIGGER_ALWAYS, &triggerAlways) ||\n\t\ttriggerAlways < 0 || triggerAlways > 1)\n\t {\n\t\tDXSetError(ERROR_BAD_PARAMETER, \"#10070\", \"trigger\");\n\t\tgoto error;\n\t }\n\t}\n#endif\n\n\tif (DXGetObjectClass((Object)SET_LINK) != CLASS_STRING)\n\t{\n\t DXSetError(ERROR_BAD_PARAMETER, \"#10200\", \"link\");\n\t goto error;\n\t}\n\n\tget_modid = DXGetString((String)SET_LINK);\n if(DXLoopFirst()) {\n\t const char *last_comp = DXGetModuleComponentName(get_modid, -1);\n\n if(flag == LOCAL) {\n if(strcmp(last_comp, \"GetLocal\") != 0) {\n DXSetError(ERROR_BAD_PARAMETER,\"#10760\", \"SetLocal\", \"GetLocal\");\n goto error;\n }\n\n set_modid = DXGetModuleId();\n\n if(DXCompareModuleMacroBase( set_modid, get_modid ) != OK) {\n DXSetError(ERROR_DATA_INVALID, \"#10762\");\n DXFreeModuleId((Pointer)set_modid);\n goto error;\n }\n else \n DXFreeModuleId((Pointer)set_modid);\n }\n else { /* global */\n if(strcmp(last_comp, \"GetGlobal\") != 0 &&\n strcmp(last_comp, \"Get\") != 0) {\n if(flag == GLOBAL) \n DXSetError(ERROR_BAD_PARAMETER,\n \"#10760\", \"SetGlobal\", \"GetGlobal\");\n else \n DXSetError(ERROR_BAD_PARAMETER, \"#10760\", \n \"Set is now an alias for SetGlobal; SetGlobal\", \"GetGlobal\");\n goto error;\n }\n }\n }\n }\n\n#if 1\n if (SET_KEY)\n {\n\tif (DXGetObjectClass((Object)SET_KEY) != CLASS_STRING)\n\t{\n\t DXSetError(ERROR_BAD_PARAMETER, \"#10200\", \"key\");\n\t goto error;\n\t}\n\n\tkey = DXGetString((String)SET_KEY);\n }\n else\n#endif\n\tkey = get_modid;\n \n if (! key)\n {\n#if 0\n\tDXSetError(ERROR_BAD_PARAMETER, \"#10764\", \"either link or key\");\n#else\n\tDXSetError(ERROR_BAD_PARAMETER, \"#10764\", \"link\");\n#endif\n\tgoto error;\n }\n\n old = DXGetCacheEntry(key, 0, 0);\n\n trigger = !old || (DXGetObjectTag(old) != DXGetObjectTag(SET_OBJECT));\n\n if (trigger)\n {\n\tif (! DXSetCacheEntry(SET_OBJECT, CACHE_PERMANENT, key, 0, 0))\n\t goto error;\n \n#if 0\n\tif (triggerAlways)\n\t DXReadyToRun(get_modid);\n\telse\n#endif\n\t DXReadyToRunNoExecute(key);\n }\n\n DXDelete(old);\n return OK;\n\nerror:\n out[0] = NULL;\n DXDelete(old);\n return ERROR;\n}", "label": 0, "cwe": null, "length": 709 }, { "index": 341527, "code": "get_duration(char *str)\n{\n char *multchar;\n int mult;\n char save;\n int duration;\n\n for(multchar=str; *multchar != '\\0'; multchar++);\n if(multchar != str) { multchar--; }\n if(*multchar == '\\0' || isdigit(*multchar)) { mult = 1; multchar++; }\n else if(*multchar == 'M') { mult = 60; }\n else if(*multchar == 'H') { mult = 60*60; }\n else if(*multchar == 'd') { mult = 60*60*24; }\n else if(*multchar == 'w') { mult = 60*60*24*7; }\n else if(*multchar == 'f') { mult = 60*60*24*7*2; }\n else if(*multchar == 'm') { mult = 60*60*24*30; }\n else if(*multchar == 'y') { mult = 60*60*24*365; }\n else\n {\n fprintf(stderr, \"invalid multiplier: %c\\n\", *multchar);\n fprintf(stderr, \"valid multipliers:\\n\");\n fprintf(stderr, \" %c -> %s (%d)\\n\", 'M', \"Minute\", 60);\n fprintf(stderr, \" %c -> %s (%d)\\n\", 'H', \"Hour\", 60*60);\n fprintf(stderr, \" %c -> %s (%d)\\n\", 'd', \"day\", 60*60*24);\n fprintf(stderr, \" %c -> %s (%d)\\n\", 'w', \"week\", 60*60*24*7);\n fprintf(stderr, \" %c -> %s (%d)\\n\", 'f', \"fortnight\", 60*60*24*7*2);\n fprintf(stderr, \" %c -> %s (%d)\\n\", 'm', \"month\", 60*60*24*30);\n fprintf(stderr, \" %c -> %s (%d)\\n\", 'y', \"year\", 60*60*24*365);\n exit(1);\n }\n save = *multchar;\n *multchar = '\\0';\n duration = strtol(str, NULL, 0) * mult;\n *multchar = save;\n\n return(duration);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 527 }, { "index": 802491, "code": "print_filter(const struct sockaddr_nl *who,\n\t\t\tstruct nlmsghdr *n,\n\t\t\tvoid *arg)\n{\n\tFILE *fp = (FILE*)arg;\n\tstruct tcmsg *t = NLMSG_DATA(n);\n\tint len = n->nlmsg_len;\n\tstruct rtattr * tb[TCA_MAX+1];\n\tstruct filter_util *q;\n\tchar abuf[256];\n\n\tif (n->nlmsg_type != RTM_NEWTFILTER && n->nlmsg_type != RTM_DELTFILTER) {\n\t\tfprintf(stderr, \"Not a filter\\n\");\n\t\treturn 0;\n\t}\n\tlen -= NLMSG_LENGTH(sizeof(*t));\n\tif (len < 0) {\n\t\tfprintf(stderr, \"Wrong len %d\\n\", len);\n\t\treturn -1;\n\t}\n\n\tmemset(tb, 0, sizeof(tb));\n\tparse_rtattr(tb, TCA_MAX, TCA_RTA(t), len);\n\n\tif (tb[TCA_KIND] == NULL) {\n\t\tfprintf(stderr, \"print_filter: NULL kind\\n\");\n\t\treturn -1;\n\t}\n\n\tif (n->nlmsg_type == RTM_DELTFILTER)\n\t\tfprintf(fp, \"deleted \");\n\n\tfprintf(fp, \"filter \");\n\tif (!filter_ifindex || filter_ifindex != t->tcm_ifindex)\n\t\tfprintf(fp, \"dev %s \", ll_index_to_name(t->tcm_ifindex));\n\n\tif (!filter_parent || filter_parent != t->tcm_parent) {\n\t\tif (t->tcm_parent == TC_H_ROOT)\n\t\t\tfprintf(fp, \"root \");\n\t\telse {\n\t\t\tprint_tc_classid(abuf, sizeof(abuf), t->tcm_parent);\n\t\t\tfprintf(fp, \"parent %s \", abuf);\n\t\t}\n\t}\n\tif (t->tcm_info) {\n\t\tf_proto = TC_H_MIN(t->tcm_info);\n\t\t__u32 prio = TC_H_MAJ(t->tcm_info)>>16;\n\t\tif (!filter_protocol || filter_protocol != f_proto) {\n\t\t\tif (f_proto) {\n\t\t\t\tSPRINT_BUF(b1);\n\t\t\t\tfprintf(fp, \"protocol %s \",\n\t\t\t\t\tll_proto_n2a(f_proto, b1, sizeof(b1)));\n\t\t\t}\n\t\t}\n\t\tif (!filter_prio || filter_prio != prio) {\n\t\t\tif (prio)\n\t\t\t\tfprintf(fp, \"pref %u \", prio);\n\t\t}\n\t}\n\tfprintf(fp, \"%s \", rta_getattr_str(tb[TCA_KIND]));\n\tq = get_filter_kind(RTA_DATA(tb[TCA_KIND]));\n\tif (tb[TCA_OPTIONS]) {\n\t\tif (q)\n\t\t\tq->print_fopt(q, fp, tb[TCA_OPTIONS], t->tcm_handle);\n\t\telse\n\t\t\tfprintf(fp, \"[cannot parse parameters]\");\n\t}\n\tfprintf(fp, \"\\n\");\n\n\tif (show_stats && (tb[TCA_STATS] || tb[TCA_STATS2])) {\n\t\tprint_tcstats_attr(fp, tb, \" \", NULL);\n\t\tfprintf(fp, \"\\n\");\n\t}\n\n\tfflush(fp);\n\treturn 0;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 619 }, { "index": 628929, "code": "mavlinkInit(void) {\n\tunsigned long micros, hz;\n\tint i;\n\n\tmemset((void *)&mavlinkData, 0, sizeof(mavlinkData));\n\n\t// register notice function with comm module\n\tcommRegisterNoticeFunc(mavlinkSendNotice);\n\tcommRegisterTelemFunc(mavlinkDo);\n\tcommRegisterRcvrFunc(COMM_STREAM_TYPE_MAVLINK, mavlinkRecvTaskCode);\n\n\tAQ_NOTICE(\"Mavlink init\\n\");\n\n\tmavlinkData.currentParam = CONFIG_NUM_PARAMS;\n\tmavlinkData.wpCount = navGetWaypointCount();\n\tmavlinkData.wpCurrent = mavlinkData.wpCount + 1;\n\tmavlinkData.sys_mode = MAV_MODE_PREFLIGHT;\n\tmavlinkData.sys_state = MAV_STATE_BOOT;\n\tmavlinkData.sys_nav_mode = AQ_NAV_STATUS_INIT;\n\tmavlink_system.sysid = flashSerno(0) % 250;\n\tmavlink_system.compid = MAV_COMP_ID_MISSIONPLANNER;\n\tmavlinkSetSystemType();\n\n\tmavlinkData.streams[MAV_DATA_STREAM_ALL].dfltInterval = AQMAVLINK_STREAM_RATE_ALL;\n\tmavlinkData.streams[MAV_DATA_STREAM_RAW_SENSORS].dfltInterval = AQMAVLINK_STREAM_RATE_RAW_SENSORS;\n\tmavlinkData.streams[MAV_DATA_STREAM_EXTENDED_STATUS].dfltInterval = AQMAVLINK_STREAM_RATE_EXTENDED_STATUS;\n\tmavlinkData.streams[MAV_DATA_STREAM_RC_CHANNELS].dfltInterval = AQMAVLINK_STREAM_RATE_RC_CHANNELS;\n\tmavlinkData.streams[MAV_DATA_STREAM_RAW_CONTROLLER].dfltInterval = AQMAVLINK_STREAM_RATE_RAW_CONTROLLER;\n\tmavlinkData.streams[MAV_DATA_STREAM_POSITION].dfltInterval = AQMAVLINK_STREAM_RATE_POSITION;\n\tmavlinkData.streams[MAV_DATA_STREAM_EXTRA1].dfltInterval = AQMAVLINK_STREAM_RATE_EXTRA1;\n\tmavlinkData.streams[MAV_DATA_STREAM_EXTRA2].dfltInterval = AQMAVLINK_STREAM_RATE_EXTRA2;\n\tmavlinkData.streams[MAV_DATA_STREAM_EXTRA3].dfltInterval = AQMAVLINK_STREAM_RATE_EXTRA3;\n\tmavlinkData.streams[MAV_DATA_STREAM_PROPULSION].dfltInterval = AQMAVLINK_STREAM_RATE_PROPULSION;\n\n\t// turn on streams & spread them out\n\tmicros = timerMicros();\n\tfor (i = 0; i < AQMAVLINK_TOTAL_STREAMS; i++) {\n\t\tmavlinkData.streams[i].interval = mavlinkData.streams[i].dfltInterval;\n\t\tmavlinkData.streams[i].next = micros + 5e6f + i * 5e3f;\n\t\tmavlinkData.streams[i].enable = mavlinkData.streams[i].interval ? 1 : 0;\n\t\thz = mavlinkData.streams[i].interval ? 1e6 / mavlinkData.streams[i].interval : 0;\n\t\tmavlink_msg_data_stream_send(MAVLINK_COMM_0, i, hz, mavlinkData.streams[i].enable);\n\t}\n}", "label": 0, "cwe": null, "length": 657 }, { "index": 265115, "code": "mpegts_base_deactivate_program (MpegTSBase * base, MpegTSBaseProgram * program)\n{\n gint i;\n MpegTSBaseClass *klass = GST_MPEGTS_BASE_GET_CLASS (base);\n\n if (G_UNLIKELY (program->active == FALSE))\n return;\n\n GST_DEBUG_OBJECT (base, \"Deactivating PMT\");\n\n program->active = FALSE;\n\n if (program->pmt) {\n for (i = 0; i < program->pmt->streams->len; ++i) {\n GstMpegTsPMTStream *stream = g_ptr_array_index (program->pmt->streams, i);\n\n mpegts_base_program_remove_stream (base, program, stream->pid);\n\n /* Only unset the is_pes/known_psi bit if the PID isn't used in any other active\n * program */\n if (!mpegts_pid_in_active_programs (base, stream->pid)) {\n switch (stream->stream_type) {\n case GST_MPEG_TS_STREAM_TYPE_PRIVATE_SECTIONS:\n case GST_MPEG_TS_STREAM_TYPE_MHEG:\n case GST_MPEG_TS_STREAM_TYPE_DSM_CC:\n case GST_MPEG_TS_STREAM_TYPE_DSMCC_A:\n case GST_MPEG_TS_STREAM_TYPE_DSMCC_B:\n case GST_MPEG_TS_STREAM_TYPE_DSMCC_C:\n case GST_MPEG_TS_STREAM_TYPE_DSMCC_D:\n case GST_MPEG_TS_STREAM_TYPE_SL_FLEXMUX_SECTIONS:\n case GST_MPEG_TS_STREAM_TYPE_METADATA_SECTIONS:\n /* Set known PSI streams */\n if (base->parse_private_sections)\n MPEGTS_BIT_UNSET (base->known_psi, stream->pid);\n break;\n default:\n MPEGTS_BIT_UNSET (base->is_pes, stream->pid);\n break;\n }\n }\n }\n\n /* remove pcr stream */\n /* FIXME : This might actually be shared with another stream ? */\n mpegts_base_program_remove_stream (base, program, program->pcr_pid);\n if (!mpegts_pid_in_active_programs (base, program->pcr_pid))\n MPEGTS_BIT_UNSET (base->is_pes, program->pcr_pid);\n\n GST_DEBUG (\"program stream_list is now %p\", program->stream_list);\n }\n\n /* Inform subclasses we're deactivating this program */\n if (klass->program_stopped)\n klass->program_stopped (base, program);\n}", "label": 0, "cwe": null, "length": 520 }, { "index": 57005, "code": "start_command_handler (ctrl_t ctrl, gnupg_fd_t listen_fd, gnupg_fd_t fd)\n{\n int rc;\n assuan_context_t ctx = NULL;\n\n rc = assuan_new (&ctx);\n if (rc)\n {\n log_error (\"failed to allocate assuan context: %s\\n\", gpg_strerror (rc));\n agent_exit (2);\n }\n\n if (listen_fd == GNUPG_INVALID_FD && fd == GNUPG_INVALID_FD)\n {\n assuan_fd_t filedes[2];\n\n filedes[0] = assuan_fdopen (0);\n filedes[1] = assuan_fdopen (1);\n rc = assuan_init_pipe_server (ctx, filedes);\n }\n else if (listen_fd != GNUPG_INVALID_FD)\n {\n rc = assuan_init_socket_server (ctx, listen_fd, 0);\n /* FIXME: Need to call assuan_sock_set_nonce for Windows. But\n\t this branch is currently not used. */\n }\n else\n {\n rc = assuan_init_socket_server (ctx, fd, ASSUAN_SOCKET_SERVER_ACCEPTED);\n }\n if (rc)\n {\n log_error (\"failed to initialize the server: %s\\n\",\n gpg_strerror(rc));\n agent_exit (2);\n }\n rc = register_commands (ctx);\n if (rc)\n {\n log_error (\"failed to register commands with Assuan: %s\\n\",\n gpg_strerror(rc));\n agent_exit (2);\n }\n\n assuan_set_pointer (ctx, ctrl);\n ctrl->server_local = xcalloc (1, sizeof *ctrl->server_local);\n ctrl->server_local->assuan_ctx = ctx;\n ctrl->server_local->message_fd = -1;\n ctrl->server_local->use_cache_for_signing = 1;\n ctrl->digest.raw_value = 0;\n\n assuan_set_io_monitor (ctx, io_monitor, NULL);\n\n for (;;)\n {\n rc = assuan_accept (ctx);\n if (gpg_err_code (rc) == GPG_ERR_EOF || rc == -1)\n {\n break;\n }\n else if (rc)\n {\n log_info (\"Assuan accept problem: %s\\n\", gpg_strerror (rc));\n break;\n }\n\n rc = assuan_process (ctx);\n if (rc)\n {\n log_info (\"Assuan processing failed: %s\\n\", gpg_strerror (rc));\n continue;\n }\n }\n\n /* Reset the SCD if needed. */\n agent_reset_scd (ctrl);\n\n /* Reset the pinentry (in case of popup messages). */\n agent_reset_query (ctrl);\n\n /* Cleanup. */\n assuan_release (ctx);\n if (ctrl->server_local->stopme)\n agent_exit (0);\n xfree (ctrl->server_local);\n ctrl->server_local = NULL;\n}", "label": 0, "cwe": null, "length": 624 }, { "index": 807672, "code": "auparse_next_event(auparse_state_t *au)\n{\n\tint rc;\n\tau_event_t event;\n\n\tif (au->parse_state == EVENT_EMITTED) {\n\t\t// If the last call resulted in emitting event data then\n\t\t// clear previous event data in preparation to accumulate\n\t\t// new event data\n\t\taup_list_clear(&au->le);\n\t\tau->parse_state = EVENT_EMPTY;\n\t}\n\n\t// accumulate new event data\n\twhile (1) {\n\t\trc = retrieve_next_line(au);\n\t\tif (debug) printf(\"next_line(%d) '%s'\\n\", rc, au->cur_buf);\n\t\tif (rc == 0) return 0;\t// No data now\n\t\tif (rc == -2) {\n\t\t\t// We're at EOF, did we read any data previously?\n\t\t\t// If so return data available, else return no data\n\t\t\t// available\n\t\t\tif (au->parse_state == EVENT_ACCUMULATING) {\n\t\t\t\tif (debug) printf(\"EOF, EVENT_EMITTED\\n\");\n\t\t\t\tau->parse_state = EVENT_EMITTED;\n\t\t\t\treturn 1; // data is available\n\t\t\t}\n\t\t\treturn 0;\n\t\t}\n\t\tif (rc > 0) {\t // Input available\n\t\t\trnode *r;\n\t\t\tif (extract_timestamp(au->cur_buf, &event)) {\n\t\t\t\tif (debug)\n\t\t\t\t\tprintf(\"Malformed line:%s\\n\",\n\t\t\t\t\t\t\t au->cur_buf);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (au->parse_state == EVENT_EMPTY) {\n\t\t\t\t// First record in new event, initialize event\n\t\t\t\tif (debug)\n\t\t\t\t\tprintf(\n\t\t\t\"First record in new event, initialize event\\n\");\n\t\t\t\taup_list_set_event(&au->le, &event);\n\t\t\t\taup_list_append(&au->le, au->cur_buf,\n\t\t\t\t\t\tau->list_idx, au->line_number);\n\t\t\t\tau->parse_state = EVENT_ACCUMULATING;\n\t\t\t\tau->cur_buf = NULL; \n\t\t\t} else if (events_are_equal(&au->le.e, &event)) {\n\t\t\t\t// Accumulate data into existing event\n\t\t\t\tif (debug)\n\t\t\t\t\tprintf(\n\t\t\t\t \"Accumulate data into existing event\\n\");\n\t\t\t\taup_list_append(&au->le, au->cur_buf,\n\t\t\t\t\t\tau->list_idx, au->line_number);\n\t\t\t\tau->parse_state = EVENT_ACCUMULATING;\n\t\t\t\tau->cur_buf = NULL; \n\t\t\t} else {\n\t\t\t\t// New event, save input for next invocation\n\t\t\t\tif (debug)\n\t\t\t\t\tprintf(\n\t\"New event, save current input for next invocation, EVENT_EMITTED\\n\");\n\t\t\t\tpush_line(au);\n\t\t\t\t// Emit the event, set event cursors to \n\t\t\t\t// initial position\n\t\t\t\taup_list_first(&au->le);\n\t\t\t\taup_list_first_field(&au->le);\n\t\t\t\tau->parse_state = EVENT_EMITTED;\n\t\t\t\tfree((char *)event.host);\n\t\t\t\treturn 1; // data is available\n\t\t\t}\n\t\t\tfree((char *)event.host);\n\t\t\t// Check to see if the event can be emitted due to EOE\n\t\t\t// or something we know is a single record event. At\n\t\t\t// this point, new record should be pointed at 'cur'\n\t\t\tif ((r = aup_list_get_cur(&au->le)) == NULL)\n\t\t\t\tcontinue;\n\t\t\tif (\tr->type == AUDIT_EOE ||\n\t\t\t\tr->type < AUDIT_FIRST_EVENT ||\n\t\t\t\tr->type >= AUDIT_FIRST_ANOM_MSG) {\n\t\t\t\t// Emit the event, set event cursors to \n\t\t\t\t// initial position\n\t\t\t\taup_list_first(&au->le);\n\t\t\t\taup_list_first_field(&au->le);\n\t\t\t\tau->parse_state = EVENT_EMITTED;\n\t\t\t\treturn 1; // data is available\n\t\t\t}\n\t\t} else {\t\t// Read error\n\t\t\treturn -1;\n\t\t}\n\t}\t\n}", "label": 0, "cwe": null, "length": 845 }, { "index": 52993, "code": "add_configuration_dialog(struct w *widgets)\n{\n gchar *utf8=NULL;\n GtkTextBuffer *text_buffer;\n gchar *info;\n GtkWidget *add_conf_vbox, *add_conf_textview;\n\n widgets->add_configuration_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);\n gtk_window_set_position(GTK_WINDOW (widgets->add_configuration_window), GTK_WIN_POS_CENTER);\n\n gtk_widget_set_size_request(widgets->add_configuration_window, 400, 100);\n\n /* Set window information */\n info = g_strdup_printf(_(\"GBINDADMIN %s add a default configuration ?\\n\"), VERSION);\n utf8 = g_locale_to_utf8(info, strlen(info), NULL, NULL, NULL);\n gtk_window_set_title(GTK_WINDOW(widgets->add_configuration_window), utf8);\n g_free(info);\n\n add_conf_vbox = gtk_vbox_new(FALSE, 0);\n gtk_container_add (GTK_CONTAINER (widgets->add_configuration_window), add_conf_vbox);\n\n add_conf_textview = gtk_text_view_new();\n gtk_container_add (GTK_CONTAINER (add_conf_vbox), add_conf_textview);\n\n g_signal_connect(GTK_WINDOW(widgets->add_configuration_window), \"delete_event\", \n\t\t G_CALLBACK(gtk_widget_destroy), NULL);\n\n text_buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(add_conf_textview));\n info = g_strdup_printf(_(\"Could not find all neccesary files in BIND's chroot directory.\\nShould the missing files and directories be added here ? :\\n%s\\n\"), CHROOT_PATH_BUF);\n utf8 = g_locale_to_utf8(info, strlen(info), NULL, NULL, NULL);\n g_free(info);\n if( utf8!=NULL )\n {\n\t/* Strlen error on NULL, thats why.. */\n gtk_text_buffer_set_text(text_buffer, utf8, strlen(utf8));\n g_free(utf8);\n }\n\n GtkWidget *add_conf_hbuttonbox = gtk_hbutton_box_new();\n gtk_box_pack_start(GTK_BOX(add_conf_vbox), add_conf_hbuttonbox, FALSE, FALSE, 0);\n gtk_button_box_set_layout(GTK_BUTTON_BOX(add_conf_hbuttonbox), GTK_BUTTONBOX_SPREAD);\n\n GtkWidget *yes_add_conf_button = gtk_button_new_from_stock(GTK_STOCK_YES);\n gtk_container_add(GTK_CONTAINER(add_conf_hbuttonbox), yes_add_conf_button);\n g_signal_connect_swapped(G_OBJECT(yes_add_conf_button), \"clicked\", \n G_CALLBACK(add_configuration), widgets);\n \n GtkWidget *cancel_add_conf_button = gtk_button_new_from_stock(GTK_STOCK_CANCEL);\n gtk_container_add(GTK_CONTAINER(add_conf_hbuttonbox), cancel_add_conf_button);\n g_signal_connect_swapped(G_OBJECT(cancel_add_conf_button), \"clicked\", \n G_CALLBACK(add_configuration_canceled), widgets);\n\n gtk_widget_show(widgets->add_configuration_window);\n gtk_widget_show(add_conf_vbox);\n gtk_widget_show(add_conf_textview);\n gtk_widget_show(add_conf_hbuttonbox);\n gtk_widget_show(yes_add_conf_button);\n gtk_widget_show(cancel_add_conf_button);\n}", "label": 0, "cwe": null, "length": 632 }, { "index": 478020, "code": "eap_method_ttls_new (WirelessSecurity *ws_parent,\n NMConnection *connection,\n gboolean is_editor,\n gboolean secrets_only)\n{\n\tEAPMethod *parent;\n\tEAPMethodTTLS *method;\n\tGtkWidget *widget;\n\tGtkFileFilter *filter;\n\tNMSetting8021x *s_8021x = NULL;\n\tconst char *filename;\n\n\tparent = eap_method_init (sizeof (EAPMethodTTLS),\n\t validate,\n\t add_to_size_group,\n\t fill_connection,\n\t update_secrets,\n\t destroy,\n\t UIDIR \"/eap-method-ttls.ui\",\n\t \"eap_ttls_notebook\",\n\t \"eap_ttls_anon_identity_entry\",\n\t FALSE);\n\tif (!parent)\n\t\treturn NULL;\n\n\teap_method_nag_init (parent, \"eap_ttls_ca_cert_button\", connection);\n\n\tmethod = (EAPMethodTTLS *) parent;\n\tmethod->sec_parent = ws_parent;\n\tmethod->is_editor = is_editor;\n\n\tif (connection)\n\t\ts_8021x = nm_connection_get_setting_802_1x (connection);\n\n\twidget = GTK_WIDGET (gtk_builder_get_object (parent->builder, \"eap_ttls_ca_cert_button\"));\n\tg_assert (widget);\n\tgtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (widget), TRUE);\n\tgtk_file_chooser_button_set_title (GTK_FILE_CHOOSER_BUTTON (widget),\n\t _(\"Choose a Certificate Authority certificate...\"));\n\tg_signal_connect (G_OBJECT (widget), \"selection-changed\",\n\t (GCallback) wireless_security_changed_cb,\n\t ws_parent);\n\tfilter = eap_method_default_file_chooser_filter_new (FALSE);\n\tgtk_file_chooser_add_filter (GTK_FILE_CHOOSER (widget), filter);\n\tif (connection && s_8021x) {\n\t\tif (nm_setting_802_1x_get_ca_cert_scheme (s_8021x) == NM_SETTING_802_1X_CK_SCHEME_PATH) {\n\t\t\tfilename = nm_setting_802_1x_get_ca_cert_path (s_8021x);\n\t\t\tif (filename)\n\t\t\t\tgtk_file_chooser_set_filename (GTK_FILE_CHOOSER (widget), filename);\n\t\t}\n\t}\n\n\twidget = GTK_WIDGET (gtk_builder_get_object (parent->builder, \"eap_ttls_anon_identity_entry\"));\n\tif (s_8021x && nm_setting_802_1x_get_anonymous_identity (s_8021x))\n\t\tgtk_entry_set_text (GTK_ENTRY (widget), nm_setting_802_1x_get_anonymous_identity (s_8021x));\n\tg_signal_connect (G_OBJECT (widget), \"changed\",\n\t (GCallback) wireless_security_changed_cb,\n\t ws_parent);\n\n\twidget = inner_auth_combo_init (method, connection, s_8021x, secrets_only);\n\tinner_auth_combo_changed_cb (widget, (gpointer) method);\n\n\tif (secrets_only) {\n\t\twidget = GTK_WIDGET (gtk_builder_get_object (parent->builder, \"eap_ttls_anon_identity_label\"));\n\t\tgtk_widget_hide (widget);\n\t\twidget = GTK_WIDGET (gtk_builder_get_object (parent->builder, \"eap_ttls_anon_identity_entry\"));\n\t\tgtk_widget_hide (widget);\n\t\twidget = GTK_WIDGET (gtk_builder_get_object (parent->builder, \"eap_ttls_ca_cert_label\"));\n\t\tgtk_widget_hide (widget);\n\t\twidget = GTK_WIDGET (gtk_builder_get_object (parent->builder, \"eap_ttls_ca_cert_button\"));\n\t\tgtk_widget_hide (widget);\n\t\twidget = GTK_WIDGET (gtk_builder_get_object (parent->builder, \"eap_ttls_inner_auth_label\"));\n\t\tgtk_widget_hide (widget);\n\t\twidget = GTK_WIDGET (gtk_builder_get_object (parent->builder, \"eap_ttls_inner_auth_combo\"));\n\t\tgtk_widget_hide (widget);\n\t}\n\n\treturn method;\n}", "label": 0, "cwe": null, "length": 803 }, { "index": 242503, "code": "pipe_resp_body(struct protstream *pin, struct protstream *pout,\n\t\t\t hdrcache_t resp_hdrs, struct body_t *resp_body,\n\t\t\t int ver1_0, const char **errstr)\n{\n char buf[PROT_BUFSIZE];\n\n if (resp_body->framing == FRAMING_UNKNOWN) {\n\t/* Get message framing */\n\tint r = parse_framing(resp_hdrs, resp_body, errstr);\n\tif (r) return r;\n }\n \n /* Read and pipe the body */\n switch (resp_body->framing) {\n case FRAMING_LENGTH:\n\t/* Read 'len' octets */\n\tif (resp_body->len && !pipe_chunk(pin, pout, resp_body->len)) {\n\t syslog(LOG_ERR, \"prot_read() error\");\n\t *errstr = \"Unable to read body data\";\n\t return HTTP_BAD_GATEWAY;\n\t}\n\tbreak;\n\n case FRAMING_CHUNKED: {\n\tunsigned chunk;\n\tchar *c;\n\n\t/* Read chunks until last-chunk (zero chunk-size) */\n\tdo {\n\t /* Read chunk-size */\n\t prot_NONBLOCK(pin);\n\t c = prot_fgets(buf, PROT_BUFSIZE, pin);\n\t prot_BLOCK(pin);\n\t if (!c) {\n\t\tprot_flush(pout);\n\t\tc = prot_fgets(buf, PROT_BUFSIZE, pin);\n\t }\n\t if (!c || sscanf(buf, \"%x\", &chunk) != 1) {\n\t\t*errstr = \"Unable to read chunk size\";\n\t\treturn HTTP_BAD_GATEWAY;\n\n\t\t/* XXX Do we need to parse chunk-ext? */\n\t }\n\t else if (chunk > resp_body->max - resp_body->len)\n\t\treturn HTTP_TOO_LARGE;\n\t else if (!ver1_0) prot_puts(pout, buf);\n\n\t if (chunk) {\n\t\t/* Read 'chunk' octets */\n\t\tif (!pipe_chunk(pin, pout, chunk)) {\n\t\t syslog(LOG_ERR, \"prot_read() error\");\n\t\t *errstr = \"Unable to read chunk data\";\n\t\t return HTTP_BAD_GATEWAY;\n\t\t}\n\t }\n\t else {\n\t\t/* Read any trailing headers */\n\t\tfor (*c = prot_ungetc(prot_getc(pin), pin);\n\t\t *c != '\\r' && *c != '\\n';\n\t\t *c = prot_ungetc(prot_getc(pin), pin)) {\n\t\t if (!prot_fgets(buf, sizeof(buf), pin)) {\n\t\t\t*errstr = \"Error reading trailer\";\n\t\t\treturn HTTP_BAD_GATEWAY;\n\t\t }\n\t\t else if (!ver1_0) prot_puts(pout, buf);\n\t\t}\n\t }\n\t \n\n\t /* Read CRLF terminating the chunk/trailer */\n\t if (!prot_fgets(buf, sizeof(buf), pin)) {\n\t\t*errstr = \"Missing CRLF following chunk/trailer\";\n\t\treturn HTTP_BAD_GATEWAY;\n\t }\n\t else if (!ver1_0) prot_puts(pout, buf);\n\n\t} while (chunk);\n\n\tbreak;\n }\n\n case FRAMING_CLOSE:\n\t/* Read until EOF */\n\tif (pipe_chunk(pin, pout, UINT_MAX) || !pin->eof)\n\t return HTTP_BAD_GATEWAY;\n\n\tbreak;\n\n default:\n\t/* XXX Should never get here */\n\t*errstr = \"Unknown length of body data\";\n\treturn HTTP_BAD_GATEWAY;\n }\n\n return 0;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 709 }, { "index": 94913, "code": "ds1685_rtc_sysfs_nvram_read(struct file *filp, struct kobject *kobj,\n\t\t\t struct bin_attribute *bin_attr, char *buf,\n\t\t\t loff_t pos, size_t size)\n{\n\tstruct platform_device *pdev =\n\t\tto_platform_device(container_of(kobj, struct device, kobj));\n\tstruct ds1685_priv *rtc = platform_get_drvdata(pdev);\n\tssize_t count;\n\tunsigned long flags = 0;\n\n\tspin_lock_irqsave(&rtc->lock, flags);\n\tds1685_rtc_switch_to_bank0(rtc);\n\n\t/* Read NVRAM in time and bank0 registers. */\n\tfor (count = 0; size > 0 && pos < NVRAM_TOTAL_SZ_BANK0;\n\t count++, size--) {\n\t\tif (count < NVRAM_SZ_TIME)\n\t\t\t*buf++ = rtc->read(rtc, (NVRAM_TIME_BASE + pos++));\n\t\telse\n\t\t\t*buf++ = rtc->read(rtc, (NVRAM_BANK0_BASE + pos++));\n\t}\n\n#ifndef CONFIG_RTC_DRV_DS1689\n\tif (size > 0) {\n\t\tds1685_rtc_switch_to_bank1(rtc);\n\n#ifndef CONFIG_RTC_DRV_DS1685\n\t\t/* Enable burst-mode on DS17x85/DS17x87 */\n\t\trtc->write(rtc, RTC_EXT_CTRL_4A,\n\t\t\t (rtc->read(rtc, RTC_EXT_CTRL_4A) |\n\t\t\t RTC_CTRL_4A_BME));\n\n\t\t/* We need one write to RTC_BANK1_RAM_ADDR_LSB to start\n\t\t * reading with burst-mode */\n\t\trtc->write(rtc, RTC_BANK1_RAM_ADDR_LSB,\n\t\t\t (pos - NVRAM_TOTAL_SZ_BANK0));\n#endif\n\n\t\t/* Read NVRAM in bank1 registers. */\n\t\tfor (count = 0; size > 0 && pos < NVRAM_TOTAL_SZ;\n\t\t count++, size--) {\n#ifdef CONFIG_RTC_DRV_DS1685\n\t\t\t/* DS1685/DS1687 has to write to RTC_BANK1_RAM_ADDR\n\t\t\t * before each read. */\n\t\t\trtc->write(rtc, RTC_BANK1_RAM_ADDR,\n\t\t\t\t (pos - NVRAM_TOTAL_SZ_BANK0));\n#endif\n\t\t\t*buf++ = rtc->read(rtc, RTC_BANK1_RAM_DATA_PORT);\n\t\t\tpos++;\n\t\t}\n\n#ifndef CONFIG_RTC_DRV_DS1685\n\t\t/* Disable burst-mode on DS17x85/DS17x87 */\n\t\trtc->write(rtc, RTC_EXT_CTRL_4A,\n\t\t\t (rtc->read(rtc, RTC_EXT_CTRL_4A) &\n\t\t\t ~(RTC_CTRL_4A_BME)));\n#endif\n\t\tds1685_rtc_switch_to_bank0(rtc);\n\t}\n#endif /* !CONFIG_RTC_DRV_DS1689 */\n\tspin_unlock_irqrestore(&rtc->lock, flags);\n\n\t/*\n\t * XXX: Bug? this appears to cause the function to get executed\n\t * several times in succession. But it's the only way to actually get\n\t * data written out to a file.\n\t */\n\treturn count;\n}", "label": 0, "cwe": null, "length": 649 }, { "index": 690705, "code": "NLOweight() const {\n // If only leading order is required return 1:\n if(_contrib==0) return 1.;\n useMe();\n // Get particle data for QCD particles:\n _parton_a=mePartonData()[0];\n _parton_b=mePartonData()[1];\n // get BeamParticleData objects for PDF's\n _hadron_A=dynamic_ptr_cast::transient_const_pointer>\n (lastParticles().first->dataPtr());\n _hadron_B=dynamic_ptr_cast::transient_const_pointer>\n (lastParticles().second->dataPtr());\n // If necessary swap the particle data vectors so that _xb_a, \n // mePartonData[0], beam[0] relate to the inbound quark: \n if(!(lastPartons().first ->dataPtr()==_parton_a&&\n lastPartons().second->dataPtr()==_parton_b)) {\n swap(_xb_a ,_xb_b);\n swap(_hadron_A,_hadron_B);\n }\n // calculate the PDF's for the Born process\n _oldq = _hadron_A->pdf()->xfx(_hadron_A,_parton_a,scale(),_xb_a)/_xb_a;\n _oldqbar = _hadron_B->pdf()->xfx(_hadron_B,_parton_b,scale(),_xb_b)/_xb_b;\n // Calculate alpha_S\n _alphaS2Pi = _nlo_alphaS_opt==1 ? _fixed_alphaS : SM().alphaS(scale());\n _alphaS2Pi /= 2.*Constants::pi;\n // Calculate the invariant mass of the dilepton pair\n _mll2 = sHat();\n _mu2 = scale();\n // Calculate the integrand\n // q qbar contribution\n double wqqvirt = Vtilde_qq();\n double wqqcollin = Ctilde_qq(x(_xt,1.),1.) + Ctilde_qq(x(_xt,0.),0.);\n double wqqreal = Ftilde_qq(_xt,_v);\n double wqq = wqqvirt+wqqcollin+wqqreal;\n // q g contribution\n double wqgcollin = Ctilde_qg(x(_xt,0.),0.);\n double wqgreal = Ftilde_qg(_xt,_v);\n double wqg = wqgreal+wqgcollin;\n // g qbar contribution\n double wgqbarcollin = Ctilde_gq(x(_xt,1.),1.);\n double wgqbarreal = Ftilde_gq(_xt,_v);\n double wgqbar = wgqbarreal+wgqbarcollin;\n // total\n double wgt = 1.+(wqq+wqg+wgqbar);\n // KMH - 06/08 - This seems to give wrong NLO results for \n // associated Higgs so I'm omitting it.\n // //trick to try and reduce neg wgt contribution\n // if(_xt<1.-_eps)\n // wgt += _a*(1./pow(1.-_xt,_p)-(1.-pow(_eps,1.-_p))/(1.-_p)/(1.-_eps));\n // return the answer\n assert(!isinf(wgt)&&!isnan(wgt));\n return _contrib==1 ? max(0.,wgt) : max(0.,-wgt);\n}", "label": 0, "cwe": null, "length": 783 }, { "index": 645409, "code": "place_buckets2(chd_ph_config_data_t *chd_ph, chd_ph_bucket_t *buckets, chd_ph_item_t * items, \n\t\t\t\t\tcmph_uint32 max_bucket_size, chd_ph_sorted_list_t *sorted_lists, cmph_uint32 max_probes, \n\t\t\t\t\tcmph_uint32 * disp_table)\n{\n\tregister cmph_uint32 i,j, non_placed_bucket;\n\tregister cmph_uint32 curr_bucket;\n\tregister cmph_uint32 probe_num, probe0_num, probe1_num;\n\tcmph_uint32 sorted_list_size;\n#ifdef DEBUG\n\tcmph_uint32 items_list;\n\tcmph_uint32 bucket_id;\n#endif\n\tDEBUGP(\"USING HEURISTIC TO PLACE BUCKETS\\n\");\n\tfor(i = max_bucket_size; i > 0; i--)\n\t{\n\t\tprobe_num = 0;\n\t\tprobe0_num = 0;\n\t\tprobe1_num = 0;\n\t\tsorted_list_size = sorted_lists[i].size;\n\t\twhile(sorted_lists[i].size != 0)\n\t\t{\n\t\t\tcurr_bucket = sorted_lists[i].buckets_list;\n\t\t\tfor(j = 0, non_placed_bucket = 0; j < sorted_lists[i].size; j++)\n\t\t\t{\n\t\t\t\t// if bucket is successfully placed remove it from list\n\t\t\t\tif(place_bucket_probe(chd_ph, buckets, items, probe0_num, probe1_num, curr_bucket, i))\n\t\t\t\t{\t\n\t\t\t\t\tdisp_table[buckets[curr_bucket].bucket_id] = probe0_num + probe1_num * chd_ph->n;\n// \t\t\t\t\tDEBUGP(\"BUCKET %u PLACED --- DISPLACEMENT = %u\\n\", curr_bucket, disp_table[curr_bucket]);\n\t\t\t\t} \n\t\t\t\telse\n\t\t\t\t{\n// \t\t\t\t\tDEBUGP(\"BUCKET %u NOT PLACED\\n\", curr_bucket);\n#ifdef DEBUG\n\t\t\t\t\titems_list = buckets[non_placed_bucket + sorted_lists[i].buckets_list].items_list;\n\t\t\t\t\tbucket_id = buckets[non_placed_bucket + sorted_lists[i].buckets_list].bucket_id;\n#endif\n\t\t\t\t\tbuckets[non_placed_bucket + sorted_lists[i].buckets_list].items_list = buckets[curr_bucket].items_list;\n\t\t\t\t\tbuckets[non_placed_bucket + sorted_lists[i].buckets_list].bucket_id = buckets[curr_bucket].bucket_id;\n#ifdef DEBUG\t\t\n\t\t\t\t\tbuckets[curr_bucket].items_list=items_list;\n\t\t\t\t\tbuckets[curr_bucket].bucket_id=bucket_id;\n#endif\n\t\t\t\t\tnon_placed_bucket++;\n\t\t\t\t}\n\t\t\t\tcurr_bucket++;\n\t\t\t};\n\t\t\tsorted_lists[i].size = non_placed_bucket;\n\t\t\tprobe0_num++;\n\t\t\tif(probe0_num >= chd_ph->n)\n\t\t\t{\n\t\t\t\tprobe0_num -= chd_ph->n;\n\t\t\t\tprobe1_num++;\n\t\t\t};\n\t\t\tprobe_num++;\n\t\t\tif(probe_num >= max_probes || probe1_num >= chd_ph->n)\n\t\t\t{\n\t\t\t\tsorted_lists[i].size = sorted_list_size;\n\t\t\t\treturn 0;\n\t\t\t};\n\t\t};\n\t\tsorted_lists[i].size = sorted_list_size;\n\t};\n\treturn 1;\n}", "label": 0, "cwe": null, "length": 655 }, { "index": 962289, "code": "SerializeWithCachedSizes(\n ::google::protobuf::io::CodedOutputStream* output) const {\n // optional string name = 1;\n if (has_name()) {\n ::google::protobuf::internal::WireFormat::VerifyUTF8String(\n this->name().data(), this->name().length(),\n ::google::protobuf::internal::WireFormat::SERIALIZE);\n ::google::protobuf::internal::WireFormatLite::WriteString(\n 1, this->name(), output);\n }\n \n // optional string extendee = 2;\n if (has_extendee()) {\n ::google::protobuf::internal::WireFormat::VerifyUTF8String(\n this->extendee().data(), this->extendee().length(),\n ::google::protobuf::internal::WireFormat::SERIALIZE);\n ::google::protobuf::internal::WireFormatLite::WriteString(\n 2, this->extendee(), output);\n }\n \n // optional int32 number = 3;\n if (has_number()) {\n ::google::protobuf::internal::WireFormatLite::WriteInt32(3, this->number(), output);\n }\n \n // optional .google.protobuf.FieldDescriptorProto.Label label = 4;\n if (has_label()) {\n ::google::protobuf::internal::WireFormatLite::WriteEnum(\n 4, this->label(), output);\n }\n \n // optional .google.protobuf.FieldDescriptorProto.Type type = 5;\n if (has_type()) {\n ::google::protobuf::internal::WireFormatLite::WriteEnum(\n 5, this->type(), output);\n }\n \n // optional string type_name = 6;\n if (has_type_name()) {\n ::google::protobuf::internal::WireFormat::VerifyUTF8String(\n this->type_name().data(), this->type_name().length(),\n ::google::protobuf::internal::WireFormat::SERIALIZE);\n ::google::protobuf::internal::WireFormatLite::WriteString(\n 6, this->type_name(), output);\n }\n \n // optional string default_value = 7;\n if (has_default_value()) {\n ::google::protobuf::internal::WireFormat::VerifyUTF8String(\n this->default_value().data(), this->default_value().length(),\n ::google::protobuf::internal::WireFormat::SERIALIZE);\n ::google::protobuf::internal::WireFormatLite::WriteString(\n 7, this->default_value(), output);\n }\n \n // optional .google.protobuf.FieldOptions options = 8;\n if (has_options()) {\n ::google::protobuf::internal::WireFormatLite::WriteMessageMaybeToArray(\n 8, this->options(), output);\n }\n \n if (!unknown_fields().empty()) {\n ::google::protobuf::internal::WireFormat::SerializeUnknownFields(\n unknown_fields(), output);\n }\n}", "label": 0, "cwe": null, "length": 616 }, { "index": 815802, "code": "conv_mark_gloss_types(TreeNode *x, GlossState g)\n{\n struct nonterm *nt;\n int nc, i;\n TreeNode *c;\n XGlosstype *gt;\n GlossState ng;\n\n if (x->type == N_NONTERM) {\n\n#if 0\n fprintf(stderr, \"MGT called on nonterm ty=%s gs=%d\\n\", nonterm_names[x->data.nonterm.type], g);\n#endif\n\n nt = &x->data.nonterm;\n nc = nt->nchildren;\n\n switch (nt->type) {\n case MAIN_SELBRI:\n case METALINGUISTIC_MAIN_SELBRI:\n ng = GS_MAIN_SELBRI;\n break;\n case JAI_TAG_TU2:\n case JAI_TU2:\n {\n TreeNode *cjai;\n cjai = child_ref(x, 0);\n if (g != GS_NONE) {\n gt = prop_glosstype(cjai, YES);\n if (g == GS_MAIN_SELBRI || g == GS_JAI) {\n gt->in_selbri = 1;\n } else {\n gt->in_selbri = 0;\n }\n }\n }\n ng = GS_JAI;\n break;\n case SUMTI:\n ng = GS_SUMTI;\n break;\n case FREE:\n case OPERAND_3:\n case MEX_OPERATOR:\n ng = GS_NONE; /* Review later what to do with these ones */\n break;\n case COMPLEX_TENSE_MODAL:\n ng = GS_MODAL;\n break;\n default:\n ng = g;\n break;\n }\n\n for (i=0; ichildren[i];\n conv_mark_gloss_types(c, ng);\n }\n\n } else {\n\n#if 0\n if (x->type == N_BRIVLA) {\n fprintf(stderr, \"MGT called on brivla %s gs=%d\\n\", x->data.brivla.word, g);\n }\n\n if (x->type == N_CMAVO) {\n fprintf(stderr, \"MGT called on cmavo %s gs=%d\\n\", cmavo_table[x->data.cmavo.code].cmavo, g);\n\n }\n#endif\n\n if ((x->type == N_BRIVLA) ||\n (x->type == N_ZEI) ||\n ((x->type == N_CMAVO) &&\n (x->data.cmavo.selmao == NU))) {\n if (g != GS_NONE) {\n gt = prop_glosstype(x, YES);\n /* In something like 'le jai ca cusku' we want to treat\n 'cusku' as a 'verb' rather than a 'noun' when glossing */\n if (g == GS_MAIN_SELBRI || g == GS_JAI) {\n gt->in_selbri = 1;\n } else {\n gt->in_selbri = 0;\n }\n }\n }\n \n }\n}", "label": 0, "cwe": null, "length": 650 }, { "index": 137019, "code": "main(int argc, char *argv[])\n{\n /* Initialize testing framework */\n TestInit(argv[0], NULL, NULL);\n\n /* Tests are generally arranged from least to most complexity... */\n AddTest(\"config\", test_configure, cleanup_configure, \"Configure definitions\", NULL);\n AddTest(\"metadata\", test_metadata, cleanup_metadata, \"Encoding/decoding metadata\", NULL);\n AddTest(\"checksum\", test_checksum, cleanup_checksum, \"Checksum algorithm\", NULL);\n AddTest(\"tst\", test_tst, NULL, \"Ternary Search Trees\", NULL);\n AddTest(\"heap\", test_heap, NULL, \"Memory Heaps\", NULL);\n AddTest(\"skiplist\", test_skiplist, NULL, \"Skip Lists\", NULL);\n AddTest(\"refstr\", test_refstr, NULL, \"Reference Counted Strings\", NULL);\n AddTest(\"file\", test_file, cleanup_file, \"Low-Level File I/O\", NULL);\n AddTest(\"objects\", test_h5o, cleanup_h5o, \"Generic Object Functions\", NULL);\n AddTest(\"h5s\", test_h5s, cleanup_h5s, \"Dataspaces\", NULL);\n AddTest(\"coords\", test_coords, cleanup_coords, \"Dataspace coordinates\", NULL);\n AddTest(\"sohm\", test_sohm, cleanup_sohm, \"Shared Object Header Messages\", NULL);\n AddTest(\"attr\", test_attr, cleanup_attr, \"Attributes\", NULL);\n AddTest(\"select\", test_select, cleanup_select, \"Selections\", NULL);\n AddTest(\"time\", test_time, cleanup_time, \"Time Datatypes\", NULL);\n AddTest(\"reference\", test_reference, cleanup_reference, \"References\", NULL);\n AddTest(\"vltypes\", test_vltypes, cleanup_vltypes, \"Variable-Length Datatypes\", NULL);\n AddTest(\"vlstrings\", test_vlstrings, cleanup_vlstrings, \"Variable-Length Strings\", NULL);\n AddTest(\"iterate\", test_iterate, cleanup_iterate, \"Group & Attribute Iteration\", NULL);\n AddTest(\"array\", test_array, cleanup_array, \"Array Datatypes\", NULL);\n AddTest(\"genprop\", test_genprop, cleanup_genprop, \"Generic Properties\", NULL);\n AddTest(\"unicode\", test_unicode, cleanup_unicode, \"UTF-8 Encoding\", NULL);\n AddTest(\"id\", test_ids, NULL, \"User-Created Identifiers\", NULL);\n AddTest(\"misc\", test_misc, cleanup_misc, \"Miscellaneous\", NULL);\n\n /* Display testing information */\n TestInfo(argv[0]);\n\n /* Parse command line arguments */\n TestParseCmdLine(argc,argv);\n\n /* Perform requested testing */\n PerformTests();\n\n /* Display test summary, if requested */\n if (GetTestSummary())\n TestSummary();\n\n /* Clean up test files, if allowed */\n if (GetTestCleanup() && !getenv(\"HDF5_NOCLEANUP\"))\n TestCleanup();\n\n return (GetTestNumErrs());\n}", "label": 0, "cwe": null, "length": 660 }, { "index": 40476, "code": "CL_ParseServerData (sizebuf_t *msg)\n{\n\tchar\t*str;\n\tint\t\ti;\n\t\n\tCom_DPrintf (\"Serverdata packet received.\\n\");\n//\n// wipe the client_state_t struct\n//\n\tCL_ClearState ();\n\tcls.state = ca_connected;\n\n// parse protocol version number\n\ti = MSG_ReadLong (msg);\n\tcls.serverProtocol = i;\n\n\tcl.servercount = MSG_ReadLong (msg);\n\tcl.attractloop = MSG_ReadByte (msg);\n\n\tif (cl.attractloop) {\n\t\t//cls.serverProtocol = PROTOCOL_VERSION_DEFAULT;\n\t}\n\telse if (i != PROTOCOL_VERSION_DEFAULT && i != PROTOCOL_VERSION_R1Q2) {\n\t\tCom_Error (ERR_DROP, \"Server is using unknown protocol %d.\", i);\n\t}\n\n\t// game directory\n\tstr = MSG_ReadString (msg);\n\tQ_strncpyz (cl.gamedir, str, sizeof(cl.gamedir));\n\tstr = cl.gamedir;\n\n\t// set gamedir\n\tif (!Com_ServerState()) {\n\t\tCvar_SetLatched(\"game\", str);\n\t\tif( FS_NeedRestart() ) {\n\t\t\tCL_RestartFilesystem(true);\n\t\t}\n\t}\n\n\t// parse player entity number\n\tcl.playernum = MSG_ReadShort (msg);\n\n\t// get the full level name\n\tstr = MSG_ReadString (msg);\n\n\tcl.pmp.strafeHack = false;\n\tcl.pmp.speedMultiplier = 1;\n\tcl.pmp.airaccelerate = 0;\n\tcls.protocolVersion = 0;\n\n\tif (cls.serverProtocol == PROTOCOL_VERSION_R1Q2)\n\t{\n\t\ti = MSG_ReadByte(msg);\n\t\tif( i ) {\n\t\t\tCom_Printf(\"'Enhanced' R1Q2 servers are not supported, falling back to protocol 34.\\n\" );\n\t\t\tCL_Disconnect();\t\t\n\t\t\tcls.serverProtocol = PROTOCOL_VERSION_DEFAULT;\n\t\t\tCL_Reconnect_f ();\n\t\t\treturn false;\n\t\t}\n\t\ti = MSG_ReadShort(msg);\n\t\tif (i < PROTOCOL_VERSION_R1Q2_MINIMUM || i > PROTOCOL_VERSION_R1Q2_CURRENT)\n\t\t{\n\t\t\tif (cl.attractloop)\n\t\t\t{\n\t\t\t\tif ( i < PROTOCOL_VERSION_R1Q2_MINIMUM )\n\t\t\t\t\tCom_Printf(\"This demo was recorded with an earlier version of the R1Q2 protocol. It may not play back properly.\\n\");\n\t\t\t\telse\n\t\t\t\t\tCom_Printf(\"This demo was recorded with a later version of the R1Q2 protocol. It may not play back properly.\\n\");\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tif( i < PROTOCOL_VERSION_R1Q2_MINIMUM ) {\n\t\t\t\t\tCom_Printf(\"Server uses OLDER minor R1Q2 protocol version than minimum supported (%i < %i), falling back to protocol 34.\\n\", i, PROTOCOL_VERSION_R1Q2_MINIMUM);\n\t\t\t\t\tCL_Disconnect();\n\t\t\t\t\tcls.serverProtocol = PROTOCOL_VERSION_DEFAULT;\n\t\t\t\t\tCL_Reconnect_f ();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t\tCom_Printf(\"Server uses NEWER minor R1Q2 protocol version (%i > %i), some features will be unavailable.\\n\", i, PROTOCOL_VERSION_R1Q2_CURRENT);\n\t\t\t}\n\t\t}\n\n\t\tif (i >= PROTOCOL_VERSION_R1Q2_STRAFE) {\n\t\t\tMSG_ReadByte(msg);\n\t\t\tcl.pmp.strafeHack = MSG_ReadByte(msg);\n\t\t}\n\n\t\tcl.pmp.speedMultiplier = 2;\n\t\tcls.protocolVersion = i;\n\t}\n\n\n\tif (cl.playernum == -1)\n\t{\t// playing a cinematic or showing a pic, not a level\n\t\tSCR_PlayCinematic (str);\n\t}\n\telse\n\t{\n\t\t// seperate the printfs so the server message can have a color\n\t\tCom_Printf(\"\\n\\n\\35\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\36\\37\\n\\n\");\n\t\tCom_Printf (\"%c%s\\n\", 2, str);\n\n\t\t// need to prep refresh at next oportunity\n\t\tcl.refresh_prepped = false;\n\n if((unsigned)cl.playernum >= MAX_CLIENTS) {\n cl.playernum = ( MAX_CLIENTS - 1 );\n }\n\t}\n\n\treturn true;\n}", "label": 0, "cwe": null, "length": 958 }, { "index": 773703, "code": "brasero_song_props_set_properties (BraseroSongProps *self,\n\t\t\t\t gint track_num,\n\t\t\t\t const gchar *artist,\n\t\t\t\t const gchar *title,\n\t\t\t\t const gchar *composer,\n\t\t\t\t gint isrc,\n\t\t\t\t gint64 length,\n\t\t\t\t gint64 start,\n\t\t\t\t gint64 end,\n\t\t\t\t gint64 gap)\n{\n\tgchar *string;\n\tgdouble secs;\n\n\tif (track_num >= 0) {\n\t\tgchar *tmp;\n\n\t\ttmp = g_strdup_printf (_(\"Song information for track %02i\"), track_num);\n\t\tstring = g_strdup_printf (\"%s\", tmp);\n\t\tg_free (tmp);\n\n\t\tgtk_label_set_markup (GTK_LABEL (self->priv->label), string);\n\t\tg_free (string);\n\t}\n\telse {\n\t\tbrasero_time_button_set_show_frames (BRASERO_TIME_BUTTON (self->priv->start), FALSE);\n\t\tbrasero_time_button_set_show_frames (BRASERO_TIME_BUTTON (self->priv->end), FALSE);\n\n\t\tgtk_widget_hide (self->priv->gap_label);\n\t\tgtk_widget_hide (self->priv->label);\n\t\tgtk_widget_hide (self->priv->gap);\n\t}\n\n\tif (artist)\n\t\tgtk_entry_set_text (GTK_ENTRY (self->priv->artist), artist);\n\tif (title)\n\t\tgtk_entry_set_text (GTK_ENTRY (self->priv->title), title);\n\tif (composer)\n\t\tgtk_entry_set_text (GTK_ENTRY (self->priv->composer), composer);\n\n\tif (isrc) {\n\t\tstring = g_strdup_printf (\"%i\", isrc);\n\t\tgtk_entry_set_text (GTK_ENTRY (self->priv->isrc), string);\n\t\tg_free (string);\n\t}\n\n\tif (gap > 0) {\n\t\tsecs = gap / GST_SECOND;\n\t\tgtk_spin_button_set_value (GTK_SPIN_BUTTON (self->priv->gap), secs);\n\t}\n\telse {\n\t\tgtk_widget_hide (self->priv->gap);\n\t\tgtk_widget_hide (self->priv->gap_label);\n\t}\n\n\tbrasero_time_button_set_max (BRASERO_TIME_BUTTON (self->priv->start), end - 1);\n\tbrasero_time_button_set_value (BRASERO_TIME_BUTTON (self->priv->start), start);\n\n\tg_signal_handlers_block_by_func (self->priv->end,\n\t\t\t\t\t brasero_song_props_end_changed_cb,\n\t\t\t\t\t self);\n\tbrasero_time_button_set_max (BRASERO_TIME_BUTTON (self->priv->end), start + length);\n\tbrasero_time_button_set_value (BRASERO_TIME_BUTTON (self->priv->end), end);\n\tg_signal_handlers_unblock_by_func (self->priv->end,\n\t \t\t\t brasero_song_props_end_changed_cb,\n\t\t\t\t\t self);\n\n\tbrasero_song_props_update_length (self);\n\n\tself->priv->title_set = FALSE;\n\tself->priv->artist_set = FALSE;\n\tself->priv->composer_set = FALSE;\n}", "label": 0, "cwe": null, "length": 596 }, { "index": 838712, "code": "qla4_82xx_get_fdt_info(struct scsi_qla_host *ha)\n{\n#define FLASH_BLK_SIZE_4K 0x1000\n#define FLASH_BLK_SIZE_32K 0x8000\n#define FLASH_BLK_SIZE_64K 0x10000\n\tconst char *loc, *locations[] = { \"MID\", \"FDT\" };\n\tuint16_t cnt, chksum;\n\tuint16_t *wptr;\n\tstruct qla_fdt_layout *fdt;\n\tuint16_t mid = 0;\n\tuint16_t fid = 0;\n\tstruct ql82xx_hw_data *hw = &ha->hw;\n\n\thw->flash_conf_off = FARX_ACCESS_FLASH_CONF;\n\thw->flash_data_off = FARX_ACCESS_FLASH_DATA;\n\n\twptr = (uint16_t *)ha->request_ring;\n\tfdt = (struct qla_fdt_layout *)ha->request_ring;\n\tqla4_82xx_read_optrom_data(ha, (uint8_t *)ha->request_ring,\n\t hw->flt_region_fdt << 2, OPTROM_BURST_SIZE);\n\n\tif (*wptr == __constant_cpu_to_le16(0xffff))\n\t\tgoto no_flash_data;\n\n\tif (fdt->sig[0] != 'Q' || fdt->sig[1] != 'L' || fdt->sig[2] != 'I' ||\n\t fdt->sig[3] != 'D')\n\t\tgoto no_flash_data;\n\n\tfor (cnt = 0, chksum = 0; cnt < sizeof(struct qla_fdt_layout) >> 1;\n\t cnt++)\n\t\tchksum += le16_to_cpu(*wptr++);\n\n\tif (chksum) {\n\t\tDEBUG2(ql4_printk(KERN_INFO, ha, \"Inconsistent FDT detected: \"\n\t\t \"checksum=0x%x id=%c version=0x%x.\\n\", chksum, fdt->sig[0],\n\t\t le16_to_cpu(fdt->version)));\n\t\tgoto no_flash_data;\n\t}\n\n\tloc = locations[1];\n\tmid = le16_to_cpu(fdt->man_id);\n\tfid = le16_to_cpu(fdt->id);\n\thw->fdt_wrt_disable = fdt->wrt_disable_bits;\n\thw->fdt_erase_cmd = flash_conf_addr(hw, 0x0300 | fdt->erase_cmd);\n\thw->fdt_block_size = le32_to_cpu(fdt->block_size);\n\n\tif (fdt->unprotect_sec_cmd) {\n\t\thw->fdt_unprotect_sec_cmd = flash_conf_addr(hw, 0x0300 |\n\t\t fdt->unprotect_sec_cmd);\n\t\thw->fdt_protect_sec_cmd = fdt->protect_sec_cmd ?\n\t\t flash_conf_addr(hw, 0x0300 | fdt->protect_sec_cmd) :\n\t\t flash_conf_addr(hw, 0x0336);\n\t}\n\tgoto done;\n\nno_flash_data:\n\tloc = locations[0];\n\thw->fdt_block_size = FLASH_BLK_SIZE_64K;\ndone:\n\tDEBUG2(ql4_printk(KERN_INFO, ha, \"FDT[%s]: (0x%x/0x%x) erase=0x%x \"\n\t\t\"pro=%x upro=%x wrtd=0x%x blk=0x%x.\\n\", loc, mid, fid,\n\t\thw->fdt_erase_cmd, hw->fdt_protect_sec_cmd,\n\t\thw->fdt_unprotect_sec_cmd, hw->fdt_wrt_disable,\n\t\thw->fdt_block_size));\n}", "label": 0, "cwe": null, "length": 753 }, { "index": 10628, "code": "ast_set_qos(int sockfd, int tos, int cos, const char *desc)\n{\n\tint res = 0;\n\tint set_tos;\n\tint set_tclass;\n\tstruct ast_sockaddr addr;\n\n\t/* If the sock address is IPv6, the TCLASS field must be set. */\n\tset_tclass = !ast_getsockname(sockfd, &addr) && ast_sockaddr_is_ipv6(&addr) ? 1 : 0;\n\n\t/* If the the sock address is IPv4 or (IPv6 set to any address [::]) set TOS bits */\n\tset_tos = (!set_tclass || (set_tclass && ast_sockaddr_is_any(&addr))) ? 1 : 0;\n\n\tif (set_tos) {\n\t\tif ((res = setsockopt(sockfd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos)))) {\n\t\t\tast_log(LOG_WARNING, \"Unable to set %s DSCP TOS value to %d (may be you have no \"\n\t\t\t\t\"root privileges): %s\\n\", desc, tos, strerror(errno));\n\t\t} else if (tos) {\n\t\t\tast_verb(2, \"Using %s TOS bits %d\\n\", desc, tos);\n\t\t}\n\t}\n\n#if defined(IPV6_TCLASS) && defined(IPPROTO_IPV6)\n\tif (set_tclass) {\n\t\tif (!ast_getsockname(sockfd, &addr) && ast_sockaddr_is_ipv6(&addr)) {\n\t\t\tif ((res = setsockopt(sockfd, IPPROTO_IPV6, IPV6_TCLASS, &tos, sizeof(tos)))) {\n\t\t\t\tast_log(LOG_WARNING, \"Unable to set %s DSCP TCLASS field to %d (may be you have no \"\n\t\t\t\t\t\"root privileges): %s\\n\", desc, tos, strerror(errno));\n\t\t\t} else if (tos) {\n\t\t\t\tast_verb(2, \"Using %s TOS bits %d in TCLASS field.\\n\", desc, tos);\n\t\t\t}\n\t\t}\n\t}\n#endif\n\n#ifdef linux\n\tif (setsockopt(sockfd, SOL_SOCKET, SO_PRIORITY, &cos, sizeof(cos))) {\n\t\tast_log(LOG_WARNING, \"Unable to set %s CoS to %d: %s\\n\", desc, cos,\n\t\t\tstrerror(errno));\n\t} else if (cos) {\n\t\tast_verb(2, \"Using %s CoS mark %d\\n\", desc, cos);\n\t}\n#endif\n\n\treturn res;\n}", "label": 0, "cwe": null, "length": 514 }, { "index": 114780, "code": "build_media_from_stmt (GrlMedia *content, sqlite3_stmt *sql_stmt)\n{\n GrlMedia *media = NULL;\n gchar *id;\n gchar *title;\n gchar *url;\n gchar *desc;\n gchar *date;\n gchar *mime;\n guint type;\n guint childcount;\n\n if (content) {\n media = content;\n }\n\n id = (gchar *) sqlite3_column_text (sql_stmt, BOOKMARK_ID);\n title = (gchar *) sqlite3_column_text (sql_stmt, BOOKMARK_TITLE);\n url = (gchar *) sqlite3_column_text (sql_stmt, BOOKMARK_URL);\n desc = (gchar *) sqlite3_column_text (sql_stmt, BOOKMARK_DESC);\n date = (gchar *) sqlite3_column_text (sql_stmt, BOOKMARK_DATE);\n mime = (gchar *) sqlite3_column_text (sql_stmt, BOOKMARK_MIME);\n type = (guint) sqlite3_column_int (sql_stmt, BOOKMARK_TYPE);\n childcount = (guint) sqlite3_column_int (sql_stmt, BOOKMARK_CHILDCOUNT);\n\n if (!media) {\n if (type == BOOKMARK_TYPE_CATEGORY) {\n media = GRL_MEDIA (grl_media_box_new ());\n } else if (mime_is_audio (mime)) {\n media = GRL_MEDIA (grl_media_new ());\n } else if (mime_is_video (mime)) {\n media = GRL_MEDIA (grl_media_new ());\n } else if (mime_is_image (mime)) {\n media = GRL_MEDIA (grl_media_image_new ());\n } else {\n media = GRL_MEDIA (grl_media_new ());\n }\n }\n\n grl_media_set_id (media, id);\n grl_media_set_title (media, title);\n if (url) {\n grl_media_set_url (media, url);\n }\n if (desc) {\n grl_media_set_description (media, desc);\n }\n\n if (date) {\n GDateTime *date_time = grl_date_time_from_iso8601 (date);\n if (date_time) {\n grl_data_set_boxed (GRL_DATA (media),\n GRL_BOOKMARKS_KEY_BOOKMARK_TIME,\n date_time);\n g_date_time_unref (date_time);\n }\n }\n\n if (type == BOOKMARK_TYPE_CATEGORY) {\n grl_media_box_set_childcount (GRL_MEDIA_BOX (media), childcount);\n }\n\n return media;\n}", "label": 0, "cwe": null, "length": 531 }, { "index": 84004, "code": "_decomposeFCD(const UChar *src, const UChar *decompLimit,\n UChar *dest, int32_t &destIndex, int32_t destCapacity,\n const UnicodeSet *nx) {\n const UChar *p;\n uint32_t norm32;\n int32_t reorderStartIndex, length;\n UChar c, c2;\n uint8_t cc, prevCC, trailCC;\n\n /*\n * canonically decompose [src..decompLimit[\n *\n * all characters in this range have some non-zero cc,\n * directly or in decomposition,\n * so that we do not need to check in the following for quick-check limits etc.\n *\n * there _are_ _no_ Hangul syllables or Jamos in here because they are FCD-safe (cc==0)!\n *\n * we also do not need to check for c==0 because we have an established decompLimit\n */\n reorderStartIndex=destIndex;\n prevCC=0;\n\n while(src>_NORM_CC_SHIFT);\n p=NULL;\n } else {\n /* c decomposes, get everything from the variable-length extra data */\n p=_decompose(norm32, length, cc, trailCC);\n if(length==1) {\n /* fastpath a single code unit from decomposition */\n c=*p;\n c2=0;\n p=NULL;\n }\n }\n\n /* append the decomposition to the destination buffer, assume length>0 */\n if((destIndex+length)<=destCapacity) {\n UChar *reorderSplit=dest+destIndex;\n if(p==NULL) {\n /* fastpath: single code point */\n if(cc!=0 && cc0);\n }\n }\n } else {\n /* buffer overflow */\n /* keep incrementing the destIndex for preflighting */\n destIndex+=length;\n }\n\n prevCC=trailCC;\n if(prevCC==0) {\n reorderStartIndex=destIndex;\n }\n }\n\n return prevCC;\n}", "label": 0, "cwe": null, "length": 896 }, { "index": 617764, "code": "DoDrawArc(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord xc, wxCoord yc)\n{\n /* Draws an arc of a circle, centred on (xc, yc), with starting point\n (x1, y1) and ending at (x2, y2). The current pen is used for the outline\n and the current brush for filling the shape.\n\n The arc is drawn in an anticlockwise direction from the start point to\n the end point.\n\n Might be better described as Pie drawing */\n\n if (m_graphics_changed) NewGraphics ();\n wxString s ;\n\n // we need the radius of the circle which has two estimates\n double r1 = sqrt ( double( (x1-xc)*(x1-xc) ) + double( (y1-yc)*(y1-yc) ) );\n double r2 = sqrt ( double( (x2-xc)*(x2-xc) ) + double( (y2-yc)*(y2-yc) ) );\n\n wxASSERT_MSG( (fabs ( r2-r1 ) <= 3), wxT(\"wxSVGFileDC::DoDrawArc Error in getting radii of circle\")) ;\n if ( fabs ( r2-r1 ) > 3 ) //pixels\n {\n s = wxT(\" \\n\") ;\n write(s);\n }\n\n double theta1 = atan2((double)(yc-y1),(double)(x1-xc));\n if ( theta1 < 0 ) theta1 = theta1 + M_PI * 2;\n double theta2 = atan2((double)(yc-y2), (double)(x2-xc));\n if ( theta2 < 0 ) theta2 = theta2 + M_PI * 2;\n if ( theta2 < theta1 ) theta2 = theta2 + M_PI *2 ;\n\n int fArc ; // flag for large or small arc 0 means less than 180 degrees\n if ( fabs(theta2 - theta1) > M_PI ) fArc = 1; else fArc = 0 ;\n\n int fSweep = 0 ; // flag for sweep always 0\n\n s.Printf ( wxT(\" \") + newline ;\n\n\n if (m_OK)\n {\n write(s);\n }\n\n wxASSERT_MSG(!wxSVG_DEBUG, wxT(\"wxSVGFileDC::DoDrawArc Call executed\")) ;\n}", "label": 0, "cwe": null, "length": 615 }, { "index": 555762, "code": "mca_coll_ml_initialize_block(\n ml_memory_block_desc_t *ml_memblock,\n uint32_t num_buffers,\n uint32_t num_banks,\n uint32_t buffer_size,\n int32_t data_offset,\n opal_list_t *bcols_in_use\n )\n{\n int ret = OMPI_SUCCESS;\n uint32_t loop, bank_loop, buff_loop;\n uint64_t addr_offset = 0;\n ml_payload_buffer_desc_t *pbuff_descs = NULL,*pbuff_desc = NULL;\n\n if (NULL == ml_memblock){\n ML_ERROR((\"Memory block not initialized\"));\n ret = OMPI_ERROR;\n goto ERROR;\n }\n\n if (ml_memblock->size_block < (num_buffers * num_banks * buffer_size) ){\n ML_ERROR((\"Not enough memory for all buffers and banks in the memory block\"));\n ret = OMPI_ERROR;\n goto ERROR;\n }\n\n pbuff_descs = (ml_payload_buffer_desc_t*) malloc(sizeof(ml_payload_buffer_desc_t)\n * num_banks * num_buffers);\n\n for(bank_loop = 0; bank_loop < num_banks; bank_loop++)\n for(buff_loop = 0; buff_loop < num_buffers; buff_loop++){\n pbuff_desc = &pbuff_descs[bank_loop*num_buffers + buff_loop];\n\n pbuff_desc->base_data_addr = (void *)\n ((char *)ml_memblock->block->base_addr + addr_offset);\n pbuff_desc->data_addr = (void *)\n ((char *)pbuff_desc->base_data_addr + (size_t)data_offset);\n\n addr_offset+=buffer_size;\n pbuff_desc->buffer_index = BUFFER_INDEX(bank_loop,num_buffers,buff_loop);\n#if 0\n ML_ERROR((\"Setting buffer_index %lld %d %d\", pbuff_desc->buffer_index,\n BANK_FROM_BUFFER_IDX(pbuff_desc->buffer_index),\n BUFFER_FROM_BUFFER_IDX(pbuff_desc->buffer_index)));\n#endif\n pbuff_desc->bank_index=bank_loop;\n pbuff_desc->generation_number=0;\n }\n\n /* Initialize ml memory block */\n ml_memblock->bank_release_counters = (uint32_t *) malloc(sizeof(uint32_t) *\n num_banks);\n if (NULL == ml_memblock->bank_release_counters) {\n ret = OMPI_ERR_OUT_OF_RESOURCE;\n goto ERROR;\n }\n\n ml_memblock->ready_for_memsync = (bool *)malloc(sizeof(bool) * num_banks);\n if (NULL == ml_memblock->ready_for_memsync) {\n ret = OMPI_ERR_OUT_OF_RESOURCE;\n goto ERROR;\n }\n\n ml_memblock->bank_is_busy = (bool *)malloc(sizeof(bool) * num_banks);\n if (NULL == ml_memblock->bank_is_busy) {\n ret = OMPI_ERR_OUT_OF_RESOURCE;\n goto ERROR;\n }\n\n /* Set index for first bank to sync */\n ml_memblock->memsync_counter = 0;\n\n /* gvm FIX:This counter when zero indicates that the bank is ready for\n * recycle. This is initialized to number of bcol components as each bcol is responsible for\n * releasing the buffers of a bank. This initialization will have\n * faulty behavior, example in case of multiple interfaces, when more than\n * one bcol module of the component type is in use.\n */\n for(loop = 0; loop < num_banks; loop++) {\n ml_memblock->bank_release_counters[loop] = 0;\n ml_memblock->ready_for_memsync[loop] = false;\n ml_memblock->bank_is_busy[loop] = false;\n }\n\n /* use first bank and first buffer */\n ml_memblock->next_free_buffer = 0;\n\n ml_memblock->block_addr_offset = addr_offset;\n ml_memblock->num_buffers_per_bank = num_buffers;\n ml_memblock->num_banks = num_banks;\n ml_memblock->size_buffer = buffer_size;\n ml_memblock->buffer_descs = pbuff_descs;\n\n return ret;\n\nERROR:\n /* Free all buffer descriptors */\n if (pbuff_descs){\n free(pbuff_descs);\n }\n\n return ret;\n}", "label": 0, "cwe": null, "length": 898 }, { "index": 872515, "code": "cdj970_put_params(gx_device * pdev, gs_param_list * plist)\n{\n int quality = cdj970->quality;\n int papertype = cdj970->papertype;\n int duplex = cdj970->duplex;\n float mastergamma = cdj970->mastergamma;\n float gammavalc = cdj970->gammavalc;\n float gammavalm = cdj970->gammavalm;\n float gammavaly = cdj970->gammavaly;\n float gammavalk = cdj970->gammavalk;\n float blackcorrect = cdj970->blackcorrect;\n\n int bpp = 0;\n int code = 0;\n\n code = cdj_put_param_int(plist, \"BitsPerPixel\", &bpp, 1, 32, code);\n code = cdj_put_param_int(plist, \"Quality\", &quality, 0, 2, code);\n code = cdj_put_param_int(plist, \"Papertype\", &papertype, 0, 4, code);\n code = cdj_put_param_int(plist, \"Duplex\", &duplex, 0, 2, code);\n code = cdj_put_param_float(plist, \"MasterGamma\", &mastergamma, 0.1, 9.0, code);\n code = cdj_put_param_float(plist, \"GammaValC\", &gammavalc, 0.0, 9.0, code);\n code = cdj_put_param_float(plist, \"GammaValM\", &gammavalm, 0.0, 9.0, code);\n code = cdj_put_param_float(plist, \"GammaValY\", &gammavaly, 0.0, 9.0, code);\n code = cdj_put_param_float(plist, \"GammaValK\", &gammavalk, 0.0, 9.0, code);\n code = cdj_put_param_float(plist, \"BlackCorrect\", &blackcorrect, 0.0,\n 9.0, code);\n\n if (code < 0)\n return code;\n\n code = cdj_put_param_bpp(pdev, plist, bpp, bpp, 0);\n\n if (code < 0)\n return code;\n\n cdj970->quality = quality;\n cdj970->papertype = papertype;\n cdj970->duplex = duplex;\n cdj970->mastergamma = mastergamma;\n cdj970->gammavalc = gammavalc;\n cdj970->gammavalm = gammavalm;\n cdj970->gammavaly = gammavaly;\n cdj970->gammavalk = gammavalk;\n cdj970->blackcorrect = blackcorrect;\n\n return 0;\n}", "label": 0, "cwe": null, "length": 617 }, { "index": 119679, "code": "aic3x_init(struct snd_soc_codec *codec)\n{\n\tstruct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec);\n\n\tsnd_soc_write(codec, AIC3X_PAGE_SELECT, PAGE0_SELECT);\n\tsnd_soc_write(codec, AIC3X_RESET, SOFT_RESET);\n\n\t/* DAC default volume and mute */\n\tsnd_soc_write(codec, LDAC_VOL, DEFAULT_VOL | MUTE_ON);\n\tsnd_soc_write(codec, RDAC_VOL, DEFAULT_VOL | MUTE_ON);\n\n\t/* DAC to HP default volume and route to Output mixer */\n\tsnd_soc_write(codec, DACL1_2_HPLOUT_VOL, DEFAULT_VOL | ROUTE_ON);\n\tsnd_soc_write(codec, DACR1_2_HPROUT_VOL, DEFAULT_VOL | ROUTE_ON);\n\tsnd_soc_write(codec, DACL1_2_HPLCOM_VOL, DEFAULT_VOL | ROUTE_ON);\n\tsnd_soc_write(codec, DACR1_2_HPRCOM_VOL, DEFAULT_VOL | ROUTE_ON);\n\t/* DAC to Line Out default volume and route to Output mixer */\n\tsnd_soc_write(codec, DACL1_2_LLOPM_VOL, DEFAULT_VOL | ROUTE_ON);\n\tsnd_soc_write(codec, DACR1_2_RLOPM_VOL, DEFAULT_VOL | ROUTE_ON);\n\n\t/* unmute all outputs */\n\tsnd_soc_update_bits(codec, LLOPM_CTRL, UNMUTE, UNMUTE);\n\tsnd_soc_update_bits(codec, RLOPM_CTRL, UNMUTE, UNMUTE);\n\tsnd_soc_update_bits(codec, HPLOUT_CTRL, UNMUTE, UNMUTE);\n\tsnd_soc_update_bits(codec, HPROUT_CTRL, UNMUTE, UNMUTE);\n\tsnd_soc_update_bits(codec, HPLCOM_CTRL, UNMUTE, UNMUTE);\n\tsnd_soc_update_bits(codec, HPRCOM_CTRL, UNMUTE, UNMUTE);\n\n\t/* ADC default volume and unmute */\n\tsnd_soc_write(codec, LADC_VOL, DEFAULT_GAIN);\n\tsnd_soc_write(codec, RADC_VOL, DEFAULT_GAIN);\n\t/* By default route Line1 to ADC PGA mixer */\n\tsnd_soc_write(codec, LINE1L_2_LADC_CTRL, 0x0);\n\tsnd_soc_write(codec, LINE1R_2_RADC_CTRL, 0x0);\n\n\t/* PGA to HP Bypass default volume, disconnect from Output Mixer */\n\tsnd_soc_write(codec, PGAL_2_HPLOUT_VOL, DEFAULT_VOL);\n\tsnd_soc_write(codec, PGAR_2_HPROUT_VOL, DEFAULT_VOL);\n\tsnd_soc_write(codec, PGAL_2_HPLCOM_VOL, DEFAULT_VOL);\n\tsnd_soc_write(codec, PGAR_2_HPRCOM_VOL, DEFAULT_VOL);\n\t/* PGA to Line Out default volume, disconnect from Output Mixer */\n\tsnd_soc_write(codec, PGAL_2_LLOPM_VOL, DEFAULT_VOL);\n\tsnd_soc_write(codec, PGAR_2_RLOPM_VOL, DEFAULT_VOL);\n\n\t/* On tlv320aic3104, these registers are reserved and must not be written */\n\tif (aic3x->model != AIC3X_MODEL_3104) {\n\t\t/* Line2 to HP Bypass default volume, disconnect from Output Mixer */\n\t\tsnd_soc_write(codec, LINE2L_2_HPLOUT_VOL, DEFAULT_VOL);\n\t\tsnd_soc_write(codec, LINE2R_2_HPROUT_VOL, DEFAULT_VOL);\n\t\tsnd_soc_write(codec, LINE2L_2_HPLCOM_VOL, DEFAULT_VOL);\n\t\tsnd_soc_write(codec, LINE2R_2_HPRCOM_VOL, DEFAULT_VOL);\n\t\t/* Line2 Line Out default volume, disconnect from Output Mixer */\n\t\tsnd_soc_write(codec, LINE2L_2_LLOPM_VOL, DEFAULT_VOL);\n\t\tsnd_soc_write(codec, LINE2R_2_RLOPM_VOL, DEFAULT_VOL);\n\t}\n\n\tswitch (aic3x->model) {\n\tcase AIC3X_MODEL_3X:\n\tcase AIC3X_MODEL_33:\n\t\taic3x_mono_init(codec);\n\t\tbreak;\n\tcase AIC3X_MODEL_3007:\n\t\tsnd_soc_write(codec, CLASSD_CTRL, 0);\n\t\tbreak;\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 888 }, { "index": 169485, "code": "ceph_pre_init_acls(struct inode *dir, umode_t *mode,\n\t\t struct ceph_acls_info *info)\n{\n\tstruct posix_acl *acl, *default_acl;\n\tsize_t val_size1 = 0, val_size2 = 0;\n\tstruct ceph_pagelist *pagelist = NULL;\n\tvoid *tmp_buf = NULL;\n\tint err;\n\n\terr = posix_acl_create(dir, mode, &default_acl, &acl);\n\tif (err)\n\t\treturn err;\n\n\tif (acl) {\n\t\tint ret = posix_acl_equiv_mode(acl, mode);\n\t\tif (ret < 0)\n\t\t\tgoto out_err;\n\t\tif (ret == 0) {\n\t\t\tposix_acl_release(acl);\n\t\t\tacl = NULL;\n\t\t}\n\t}\n\n\tif (!default_acl && !acl)\n\t\treturn 0;\n\n\tif (acl)\n\t\tval_size1 = posix_acl_xattr_size(acl->a_count);\n\tif (default_acl)\n\t\tval_size2 = posix_acl_xattr_size(default_acl->a_count);\n\n\terr = -ENOMEM;\n\ttmp_buf = kmalloc(max(val_size1, val_size2), GFP_KERNEL);\n\tif (!tmp_buf)\n\t\tgoto out_err;\n\tpagelist = kmalloc(sizeof(struct ceph_pagelist), GFP_KERNEL);\n\tif (!pagelist)\n\t\tgoto out_err;\n\tceph_pagelist_init(pagelist);\n\n\terr = ceph_pagelist_reserve(pagelist, PAGE_SIZE);\n\tif (err)\n\t\tgoto out_err;\n\n\tceph_pagelist_encode_32(pagelist, acl && default_acl ? 2 : 1);\n\n\tif (acl) {\n\t\tsize_t len = strlen(POSIX_ACL_XATTR_ACCESS);\n\t\terr = ceph_pagelist_reserve(pagelist, len + val_size1 + 8);\n\t\tif (err)\n\t\t\tgoto out_err;\n\t\tceph_pagelist_encode_string(pagelist, POSIX_ACL_XATTR_ACCESS,\n\t\t\t\t\t len);\n\t\terr = posix_acl_to_xattr(&init_user_ns, acl,\n\t\t\t\t\t tmp_buf, val_size1);\n\t\tif (err < 0)\n\t\t\tgoto out_err;\n\t\tceph_pagelist_encode_32(pagelist, val_size1);\n\t\tceph_pagelist_append(pagelist, tmp_buf, val_size1);\n\t}\n\tif (default_acl) {\n\t\tsize_t len = strlen(POSIX_ACL_XATTR_DEFAULT);\n\t\terr = ceph_pagelist_reserve(pagelist, len + val_size2 + 8);\n\t\tif (err)\n\t\t\tgoto out_err;\n\t\terr = ceph_pagelist_encode_string(pagelist,\n\t\t\t\t\t\t POSIX_ACL_XATTR_DEFAULT, len);\n\t\terr = posix_acl_to_xattr(&init_user_ns, default_acl,\n\t\t\t\t\t tmp_buf, val_size2);\n\t\tif (err < 0)\n\t\t\tgoto out_err;\n\t\tceph_pagelist_encode_32(pagelist, val_size2);\n\t\tceph_pagelist_append(pagelist, tmp_buf, val_size2);\n\t}\n\n\tkfree(tmp_buf);\n\n\tinfo->acl = acl;\n\tinfo->default_acl = default_acl;\n\tinfo->pagelist = pagelist;\n\treturn 0;\n\nout_err:\n\tposix_acl_release(acl);\n\tposix_acl_release(default_acl);\n\tkfree(tmp_buf);\n\tif (pagelist)\n\t\tceph_pagelist_release(pagelist);\n\treturn err;\n}", "label": 0, "cwe": null, "length": 680 }, { "index": 765029, "code": "dump_stream_format(AVFormatContext *ic, int i, int index, int is_output)\n{\n char buf[256];\n int flags = (is_output ? ic->oformat->flags : ic->iformat->flags);\n AVStream *st = ic->streams[i];\n int g = av_gcd(st->time_base.num, st->time_base.den);\n AVMetadataTag *lang = av_metadata_get(st->metadata, \"language\", NULL, 0);\n avcodec_string(buf, sizeof(buf), st->codec, is_output);\n av_log(NULL, AV_LOG_INFO, \" Stream #%d.%d\", index, i);\n /* the pid is an important information, so we display it */\n /* XXX: add a generic system */\n if (flags & AVFMT_SHOW_IDS)\n av_log(NULL, AV_LOG_INFO, \"[0x%x]\", st->id);\n if (lang)\n av_log(NULL, AV_LOG_INFO, \"(%s)\", lang->value);\n av_log(NULL, AV_LOG_DEBUG, \", %d/%d\", st->time_base.num/g, st->time_base.den/g);\n av_log(NULL, AV_LOG_INFO, \": %s\", buf);\n if (st->sample_aspect_ratio.num && // default\n av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)) {\n AVRational display_aspect_ratio;\n av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,\n st->codec->width*st->sample_aspect_ratio.num,\n st->codec->height*st->sample_aspect_ratio.den,\n 1024*1024);\n av_log(NULL, AV_LOG_INFO, \", PAR %d:%d DAR %d:%d\",\n st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,\n display_aspect_ratio.num, display_aspect_ratio.den);\n }\n if(st->codec->codec_type == CODEC_TYPE_VIDEO){\n if(st->r_frame_rate.den && st->r_frame_rate.num)\n print_fps(av_q2d(st->r_frame_rate), \"tbr\");\n if(st->time_base.den && st->time_base.num)\n print_fps(1/av_q2d(st->time_base), \"tbn\");\n if(st->codec->time_base.den && st->codec->time_base.num)\n print_fps(1/av_q2d(st->codec->time_base), \"tbc\");\n }\n av_log(NULL, AV_LOG_INFO, \"\\n\");\n}", "label": 0, "cwe": null, "length": 531 }, { "index": 45488, "code": "read_ref(char *id, size_t idlen, char *name, size_t namelen)\n{\n\tstruct ref *ref = NULL;\n\tbool tag = FALSE;\n\tbool ltag = FALSE;\n\tbool remote = FALSE;\n\tbool tracked = FALSE;\n\tbool head = FALSE;\n\tint from = 0, to = refs_size - 1;\n\n\tif (!prefixcmp(name, \"refs/tags/\")) {\n\t\tif (!suffixcmp(name, namelen, \"^{}\")) {\n\t\t\tnamelen -= 3;\n\t\t\tname[namelen] = 0;\n\t\t} else {\n\t\t\tltag = TRUE;\n\t\t}\n\n\t\ttag = TRUE;\n\t\tnamelen -= STRING_SIZE(\"refs/tags/\");\n\t\tname\t+= STRING_SIZE(\"refs/tags/\");\n\n\t} else if (!prefixcmp(name, \"refs/remotes/\")) {\n\t\tremote = TRUE;\n\t\tnamelen -= STRING_SIZE(\"refs/remotes/\");\n\t\tname\t+= STRING_SIZE(\"refs/remotes/\");\n\t\ttracked = !strcmp(opt_remote, name);\n\n\t} else if (!prefixcmp(name, \"refs/heads/\")) {\n\t\tnamelen -= STRING_SIZE(\"refs/heads/\");\n\t\tname\t+= STRING_SIZE(\"refs/heads/\");\n\t\tif (!strncmp(opt_head, name, namelen))\n\t\t\treturn OK;\n\n\t} else if (!strcmp(name, \"HEAD\")) {\n\t\thead = TRUE;\n\t\tif (*opt_head) {\n\t\t\tnamelen = strlen(opt_head);\n\t\t\tname\t = opt_head;\n\t\t}\n\t}\n\n\t/* If we are reloading or it's an annotated tag, replace the\n\t * previous SHA1 with the resolved commit id; relies on the fact\n\t * git-ls-remote lists the commit id of an annotated tag right\n\t * before the commit id it points to. */\n\twhile (from <= to) {\n\t\tsize_t pos = (to + from) / 2;\n\t\tint cmp = strcmp(name, refs[pos]->name);\n\n\t\tif (!cmp) {\n\t\t\tref = refs[pos];\n\t\t\tbreak;\n\t\t}\n\n\t\tif (cmp < 0)\n\t\t\tto = pos - 1;\n\t\telse\n\t\t\tfrom = pos + 1;\n\t}\n\n\tif (!ref) {\n\t\tif (!realloc_refs(&refs, refs_size, 1))\n\t\t\treturn ERR;\n\t\tref = calloc(1, sizeof(*ref) + namelen);\n\t\tif (!ref)\n\t\t\treturn ERR;\n\t\tmemmove(refs + from + 1, refs + from,\n\t\t\t(refs_size - from) * sizeof(*refs));\n\t\trefs[from] = ref;\n\t\tstrncpy(ref->name, name, namelen);\n\t\trefs_size++;\n\t}\n\n\tref->head = head;\n\tref->tag = tag;\n\tref->ltag = ltag;\n\tref->remote = remote;\n\tref->tracked = tracked;\n\tstring_copy_rev(ref->id, id);\n\n\tif (head)\n\t\trefs_head = ref;\n\treturn OK;\n}", "label": 0, "cwe": null, "length": 610 }, { "index": 33845, "code": "http_tx(int fd, int s, httpheader *h, size_t len, const uint8_t *buf) {\n h->length = len;\n send_http_status_fd(fd, s);\n send_http_header_fd(fd, s, h);\n\n // select\n #define WRITE_TIMEOUT (50) // TODO make configurable\n int timeout = WRITE_TIMEOUT;\n size_t offset = 0;\n while (timeout > 0) {\n fd_set rd_set, wr_set;\n struct timeval tv;\n\n tv.tv_sec = 0;\n tv.tv_usec = 200000;\n FD_ZERO(&rd_set);\n FD_ZERO(&wr_set);\n FD_SET(fd, &wr_set);\n int ready = select(fd+1, &rd_set, &wr_set, NULL, &tv);\n if(ready < 0) return (-1); // error\n if(!ready) timeout--;\n else {\n#ifndef HAVE_WINDOWS\n int rv = write(fd, buf+offset, len-offset);\n debugmsg(DEBUG_HTTP, \" written (%d/%zu) @%zu on fd:%i\\n\", rv, len-offset, offset, fd);\n#else\n int rv = send(fd, (const char*) (buf+offset), (size_t) (len-offset), 0);\n debugmsg(DEBUG_HTTP, \" written (%d/%lu) @%lu on fd:%i\\n\", rv, (unsigned long)(len-offset), (unsigned long) offset, fd);\n#endif\n if (rv < 0) {\n dlog(DLOG_WARNING, \"HTTP: write to socket failed: %s\\n\", strerror(errno));\n break; // TODO: don't break on EAGAIN, ENOBUFS, ENOMEM or similar\n } else if (rv != len-offset) {\n dlog(DLOG_WARNING, \"HTTP: short-write (%u/%u) @%u on fd:%i\\n\", rv, len-offset, offset, fd);\n timeout = WRITE_TIMEOUT;\n offset += rv;\n } else {\n offset += rv;\n break;\n }\n }\n }\n if (!timeout)\n dlog(DLOG_ERR, \"HTTP: write timeout fd:%i\\n\", fd);\n\n if (offset != len) {\n dlog(DLOG_WARNING, \"HTTP: write to fd:%d failed at (%u/%u) = %.2f%%\\n\", fd, offset, len, (float)offset*100.0/(float)len);\n return (1);\n }\n return (0);\n}", "label": 0, "cwe": null, "length": 537 }, { "index": 402998, "code": "cgraph_analyze_function (struct cgraph_node *node)\n{\n tree save = current_function_decl;\n tree decl = node->decl;\n\n if (node->alias && node->thunk.alias)\n {\n struct cgraph_node *tgt = cgraph_get_node (node->thunk.alias);\n struct cgraph_node *n;\n\n for (n = tgt; n && n->alias;\n\t n = n->analyzed ? cgraph_alias_aliased_node (n) : NULL)\n\tif (n == node)\n\t {\n\t error (\"function %q+D part of alias cycle\", node->decl);\n\t node->alias = false;\n\t return;\n\t }\n if (!VEC_length (ipa_ref_t, node->ref_list.references))\n ipa_record_reference (node, NULL, tgt, NULL, IPA_REF_ALIAS, NULL);\n if (node->same_body_alias)\n\t{ \n\t DECL_VIRTUAL_P (node->decl) = DECL_VIRTUAL_P (node->thunk.alias);\n\t DECL_DECLARED_INLINE_P (node->decl)\n\t = DECL_DECLARED_INLINE_P (node->thunk.alias);\n\t DECL_DISREGARD_INLINE_LIMITS (node->decl)\n\t = DECL_DISREGARD_INLINE_LIMITS (node->thunk.alias);\n\t}\n\n /* Fixup visibility nonsences C++ frontend produce on same body aliases. */\n if (TREE_PUBLIC (node->decl) && node->same_body_alias)\n\t{\n DECL_EXTERNAL (node->decl) = DECL_EXTERNAL (node->thunk.alias);\n\t if (DECL_ONE_ONLY (node->thunk.alias))\n\t {\n\t DECL_COMDAT (node->decl) = DECL_COMDAT (node->thunk.alias);\n\t DECL_COMDAT_GROUP (node->decl) = DECL_COMDAT_GROUP (node->thunk.alias);\n\t if (DECL_ONE_ONLY (node->thunk.alias) && !node->same_comdat_group)\n\t\t{\n\t\t struct cgraph_node *tgt = cgraph_get_node (node->thunk.alias);\n\t\t node->same_comdat_group = tgt;\n\t\t if (!tgt->same_comdat_group)\n\t\t tgt->same_comdat_group = node;\n\t\t else\n\t\t {\n\t\t struct cgraph_node *n;\n\t\t for (n = tgt->same_comdat_group;\n\t\t\t n->same_comdat_group != tgt;\n\t\t\t n = n->same_comdat_group)\n\t\t\t;\n\t\t n->same_comdat_group = node;\n\t\t }\n\t\t}\n\t }\n\t}\n cgraph_mark_reachable_node (cgraph_alias_aliased_node (node));\n if (node->address_taken)\n\tcgraph_mark_address_taken_node (cgraph_alias_aliased_node (node));\n if (cgraph_decide_is_function_needed (node, node->decl))\n\tcgraph_mark_needed_node (node);\n }\n else if (node->thunk.thunk_p)\n {\n cgraph_create_edge (node, cgraph_get_node (node->thunk.alias),\n\t\t\t NULL, 0, CGRAPH_FREQ_BASE);\n }\n else\n {\n current_function_decl = decl;\n push_cfun (DECL_STRUCT_FUNCTION (decl));\n\n assign_assembler_name_if_neeeded (node->decl);\n\n /* Make sure to gimplify bodies only once. During analyzing a\n\t function we lower it, which will require gimplified nested\n\t functions, so we can end up here with an already gimplified\n\t body. */\n if (!gimple_body (decl))\n\tgimplify_function_tree (decl);\n dump_function (TDI_generic, decl);\n\n cgraph_lower_function (node);\n pop_cfun ();\n }\n node->analyzed = true;\n\n current_function_decl = save;\n}", "label": 0, "cwe": null, "length": 781 }, { "index": 512435, "code": "sbagn_(integer *n, integer *nz, integer *ia, integer *ja, doublereal *a,\n integer *iwork, integer *level, integer *nout, integer* ierr)\n{\n /* Local variables */\n static integer i, j, ier, ntn, nto, now, nadd;\n\n (void)level; (void)nout;\n/* ... THE ROUTINES SBINI, SBSIJ, AND SBEND CREATE A SPARSE */\n/* MATRIX STRUCTURE BY MEANS OF A LINKED LIST WHICH IS */\n/* DESTROYED BY SBEND. SBAGN CREATES A NEW LINKED LIST */\n/* SO THAT ELEMENTS MAY BE ADDED TO THE MATRIX AFTER SBEND */\n/* HAS BEEN CALLED. SBAGN SHOULD BE CALLED WITH THE APPRO- */\n/* PRIATE PARAMETERS, AND THEN SBSIJ AND SBEND CAN BE CALLED */\n/* TO ADD THE ELEMENTS AND COMPLETE THE SPARSE MATRIX STRUC- */\n/* TURE. */\n\n/* ... PARAMETER LIST: */\n\n/* N ORDER OF THE SYSTEM */\n/* NZ MAXIMUM NUMBER OF NON-ZERO ELEMENTS */\n/* IN THE SYSTEM */\n/* IA, JA INTEGER ARRAYS OF THE SPARSE */\n/* MATRIX STRUCTURE */\n/* A D.P. ARRAY OF THE SPARSE MATRIX */\n/* STRUCTURE */\n/* IWORK WORK ARRAY OF DIMENSION NZ */\n/* LEVEL OUTPUT LEVEL CONTROL (= LEVELL) */\n/* NOUT OUTPUT FILE NUMBER */\n/* IER ERROR FLAG (= IERR). POSSIBLE RETURNS ARE */\n/* IER = 0, SUCCESSFUL COMPLETION */\n/* = 703, NZ TOO SMALL - NO MORE */\n/* ELEMENTS CAN BE ADDED */\n\n now = ia[*n] - 1;\n nadd = *nz - now;\n ier = 0;\n if (nadd <= 0)\n ier = 703;\n\n if (ier != 0)\n goto L90;\n\n /* ... SHIFT ELEMENTS OF A AND JA DOWN AND ADD ZERO FILL */\n\n nto = now;\n ntn = *nz;\n for (i = 0; i < now; ++i) {\n --nto; --ntn;\n ja[ntn] = ja[nto];\n a[ntn] = a[nto];\n }\n for (i = 0; i < nadd; ++i) {\n ja[i] = 0;\n a[i] = 0.;\n }\n\n /* ... UPDATE IA TO REFLECT DOWNWARD SHIFT IN A AND JA */\n\n for (i = 0; i <= *n; ++i)\n ia[i] += nadd;\n\n /* ... CREATE LINKED LIST */\n\n for (i = nadd; i < *nz; ++i)\n iwork[i] = i + 2;\n\n for (i = 0; i < nadd; ++i)\n iwork[i] = 0;\n\n for (i = 0; i < *n; ++i) {\n j = ia[i + 1] - 2;\n iwork[j] = -i - 1;\n }\n\n /* ... INDICATE IN LAST POSITION OF IA HOW MANY SPACES */\n /* ARE LEFT IN A AND JA FOR ADDITION OF ELEMENTS */\n\n ia[*n] = nadd;\n return 0;\n\n /* ... ERROR RETURN */\n\nL90:\n *ierr = ier;\n return 0;\n}", "label": 0, "cwe": null, "length": 759 }, { "index": 466756, "code": "resolve_overloaded_unification (tree tparms,\n\t\t\t\ttree targs,\n\t\t\t\ttree parm,\n\t\t\t\ttree arg,\n\t\t\t\tunification_kind_t strict,\n\t\t\t\tint sub_strict,\n\t\t\t bool explain_p)\n{\n tree tempargs = copy_node (targs);\n int good = 0;\n tree goodfn = NULL_TREE;\n bool addr_p;\n\n if (TREE_CODE (arg) == ADDR_EXPR)\n {\n arg = TREE_OPERAND (arg, 0);\n addr_p = true;\n }\n else\n addr_p = false;\n\n if (TREE_CODE (arg) == COMPONENT_REF)\n /* Handle `&x' where `x' is some static or non-static member\n function name. */\n arg = TREE_OPERAND (arg, 1);\n\n if (TREE_CODE (arg) == OFFSET_REF)\n arg = TREE_OPERAND (arg, 1);\n\n /* Strip baselink information. */\n if (BASELINK_P (arg))\n arg = BASELINK_FUNCTIONS (arg);\n\n if (TREE_CODE (arg) == TEMPLATE_ID_EXPR)\n {\n /* If we got some explicit template args, we need to plug them into\n\t the affected templates before we try to unify, in case the\n\t explicit args will completely resolve the templates in question. */\n\n int ok = 0;\n tree expl_subargs = TREE_OPERAND (arg, 1);\n arg = TREE_OPERAND (arg, 0);\n\n for (; arg; arg = OVL_NEXT (arg))\n\t{\n\t tree fn = OVL_CURRENT (arg);\n\t tree subargs, elem;\n\n\t if (TREE_CODE (fn) != TEMPLATE_DECL)\n\t continue;\n\n\t ++processing_template_decl;\n\t subargs = get_bindings (fn, DECL_TEMPLATE_RESULT (fn),\n\t\t\t\t expl_subargs, /*check_ret=*/false);\n\t if (subargs && !any_dependent_template_arguments_p (subargs))\n\t {\n\t elem = tsubst (TREE_TYPE (fn), subargs, tf_none, NULL_TREE);\n\t if (try_one_overload (tparms, targs, tempargs, parm,\n\t\t\t\t elem, strict, sub_strict, addr_p, explain_p)\n\t\t && (!goodfn || !same_type_p (goodfn, elem)))\n\t\t{\n\t\t goodfn = elem;\n\t\t ++good;\n\t\t}\n\t }\n\t else if (subargs)\n\t ++ok;\n\t --processing_template_decl;\n\t}\n /* If no templates (or more than one) are fully resolved by the\n\t explicit arguments, this template-id is a non-deduced context; it\n\t could still be OK if we deduce all template arguments for the\n\t enclosing call through other arguments. */\n if (good != 1)\n\tgood = ok;\n }\n else if (TREE_CODE (arg) != OVERLOAD\n\t && TREE_CODE (arg) != FUNCTION_DECL)\n /* If ARG is, for example, \"(0, &f)\" then its type will be unknown\n -- but the deduction does not succeed because the expression is\n not just the function on its own. */\n return false;\n else\n for (; arg; arg = OVL_NEXT (arg))\n if (try_one_overload (tparms, targs, tempargs, parm,\n\t\t\t TREE_TYPE (OVL_CURRENT (arg)),\n\t\t\t strict, sub_strict, addr_p, explain_p)\n\t && (!goodfn || !decls_match (goodfn, OVL_CURRENT (arg))))\n\t{\n\t goodfn = OVL_CURRENT (arg);\n\t ++good;\n\t}\n\n /* [temp.deduct.type] A template-argument can be deduced from a pointer\n to function or pointer to member function argument if the set of\n overloaded functions does not contain function templates and at most\n one of a set of overloaded functions provides a unique match.\n\n So if we found multiple possibilities, we return success but don't\n deduce anything. */\n\n if (good == 1)\n {\n int i = TREE_VEC_LENGTH (targs);\n for (; i--; )\n\tif (TREE_VEC_ELT (tempargs, i))\n\t TREE_VEC_ELT (targs, i) = TREE_VEC_ELT (tempargs, i);\n }\n if (good)\n return true;\n\n return false;\n}", "label": 0, "cwe": null, "length": 917 }, { "index": 46468, "code": "xmlSecDSigCtxDebugDump(xmlSecDSigCtxPtr dsigCtx, FILE* output) {\n xmlSecAssert(dsigCtx != NULL);\n xmlSecAssert(output != NULL);\n\n if(dsigCtx->operation == xmlSecTransformOperationSign) { \n\tfprintf(output, \"= SIGNATURE CONTEXT\\n\");\n } else {\n\tfprintf(output, \"= VERIFICATION CONTEXT\\n\");\n }\n switch(dsigCtx->status) {\n\tcase xmlSecDSigStatusUnknown:\n\t fprintf(output, \"== Status: unknown\\n\");\n\t break;\n\tcase xmlSecDSigStatusSucceeded:\n\t fprintf(output, \"== Status: succeeded\\n\");\n\t break;\n\tcase xmlSecDSigStatusInvalid:\n\t fprintf(output, \"== Status: invalid\\n\");\n\t break;\n }\n fprintf(output, \"== flags: 0x%08x\\n\", dsigCtx->flags);\n fprintf(output, \"== flags2: 0x%08x\\n\", dsigCtx->flags2);\n\n if(dsigCtx->id != NULL) {\n\tfprintf(output, \"== Id: \\\"%s\\\"\\n\", dsigCtx->id);\n }\n \n fprintf(output, \"== Key Info Read Ctx:\\n\");\n xmlSecKeyInfoCtxDebugDump(&(dsigCtx->keyInfoReadCtx), output);\n fprintf(output, \"== Key Info Write Ctx:\\n\");\n xmlSecKeyInfoCtxDebugDump(&(dsigCtx->keyInfoWriteCtx), output);\n\n fprintf(output, \"== Signature Transform Ctx:\\n\");\n xmlSecTransformCtxDebugDump(&(dsigCtx->transformCtx), output);\n\n if(dsigCtx->signMethod != NULL) {\n fprintf(output, \"== Signature Method:\\n\");\n\txmlSecTransformDebugDump(dsigCtx->signMethod, output);\n }\n\n if(dsigCtx->signKey != NULL) {\n fprintf(output, \"== Signature Key:\\n\");\n\txmlSecKeyDebugDump(dsigCtx->signKey, output);\n }\n \n fprintf(output, \"== SignedInfo References List:\\n\");\n xmlSecPtrListDebugDump(&(dsigCtx->signedInfoReferences), output);\n\n fprintf(output, \"== Manifest References List:\\n\");\n xmlSecPtrListDebugDump(&(dsigCtx->manifestReferences), output);\n \n if((dsigCtx->result != NULL) && \n (xmlSecBufferGetData(dsigCtx->result) != NULL)) {\n\n\tfprintf(output, \"== Result - start buffer:\\n\");\n\tfwrite(xmlSecBufferGetData(dsigCtx->result), \n\t xmlSecBufferGetSize(dsigCtx->result), \n\t 1, output);\n\tfprintf(output, \"\\n== Result - end buffer\\n\");\n }\n if(((dsigCtx->flags & XMLSEC_DSIG_FLAGS_STORE_SIGNATURE) != 0) &&\n (xmlSecDSigCtxGetPreSignBuffer(dsigCtx) != NULL) &&\n (xmlSecBufferGetData(xmlSecDSigCtxGetPreSignBuffer(dsigCtx)) != NULL)) {\n \n\tfprintf(output, \"== PreSigned data - start buffer:\\n\");\n\tfwrite(xmlSecBufferGetData(xmlSecDSigCtxGetPreSignBuffer(dsigCtx)), \n\t xmlSecBufferGetSize(xmlSecDSigCtxGetPreSignBuffer(dsigCtx)), \n\t 1, output);\n\tfprintf(output, \"\\n== PreSigned data - end buffer\\n\"); \n }\n}", "label": 0, "cwe": null, "length": 686 }, { "index": 598560, "code": "create_gde_var(AW_root *aw_root, AW_default aw_def,\n char *(*get_sequences)(void *THIS, GBDATA **&the_species,\n uchar **&the_names,\n uchar **&the_sequences,\n long &numberspecies,long &maxalignlen),\n gde_cgss_window_type wt,\n void *THIS)\n{\n gde_cgss.get_sequences= get_sequences;\n gde_cgss.wt = wt;\n gde_cgss.THIS= THIS;\n\n // aw_root->awar_string(\"tmp/gde/helptext\", \"help\", aw_def); // only occurrence\n aw_root->awar_string(AWAR_GDE_ALIGNMENT, \"\", aw_def);\n\n switch (gde_cgss.wt)\n {\n case CGSS_WT_EDIT4:\n aw_root->awar_int(\"gde/top_area_kons\",1,aw_def);\n aw_root->awar_int(\"gde/top_area_remark\",1,aw_def);\n aw_root->awar_int(\"gde/middle_area_kons\",1,aw_def);\n aw_root->awar_int(\"gde/middle_area_remark\",1,aw_def);\n case CGSS_WT_EDIT:\n aw_root->awar_int(\"gde/top_area\",1,aw_def);\n aw_root->awar_int(\"gde/top_area_sai\",1,aw_def);\n aw_root->awar_int(\"gde/top_area_helix\",1,aw_def);\n aw_root->awar_int(\"gde/middle_area\",1,aw_def);\n aw_root->awar_int(\"gde/middle_area_sai\",1,aw_def);\n aw_root->awar_int(\"gde/middle_area_helix\",1,aw_def);\n aw_root->awar_int(\"gde/bottom_area\",1,aw_def);\n aw_root->awar_int(\"gde/bottom_area_sai\",1,aw_def);\n aw_root->awar_int(\"gde/bottom_area_helix\",1,aw_def);\n default:\n break;\n }\n\n aw_root->awar_string(\"presets/use\", \"\", GLOBAL_gb_main);\n \n aw_root->awar_string(AWAR_GDE_FILTER_NAME, \"\", aw_def);\n aw_root->awar_string(AWAR_GDE_FILTER_FILTER, \"\", aw_def);\n aw_root->awar_string(AWAR_GDE_FILTER_ALIGNMENT, \"\", aw_def);\n\n aw_root->awar_int(AWAR_GDE_CUTOFF_STOPCODON, 0, aw_def);\n aw_root->awar_int(AWAR_GDE_SPECIES, 1, aw_def);\n \n aw_root->awar_int(AWAR_GDE_COMPRESSION, COMPRESS_NONINFO_COLUMNS, aw_def);\n\n aw_root->awar(AWAR_GDE_ALIGNMENT)->map(\"presets/use\");\n aw_root->awar(AWAR_GDE_FILTER_ALIGNMENT)->map(\"presets/use\");\n\n DataSet = (NA_Alignment *) Calloc(1,sizeof(NA_Alignment));\n DataSet->rel_offset = 0;\n ParseMenu();\n}", "label": 0, "cwe": null, "length": 663 }, { "index": 171384, "code": "preg_do_eval(char *eval_str, int eval_str_len, char *subject,\n\t\t\t\t\t\tint *offsets, int count, char **result TSRMLS_DC)\n{\n\tzval\t\t retval;\t\t\t/* Return value from evaluation */\n\tchar\t\t*eval_str_end,\t\t/* End of eval string */\n\t\t\t\t*match,\t\t\t\t/* Current match for a backref */\n\t\t\t\t*esc_match,\t\t\t/* Quote-escaped match */\n\t\t\t\t*walk,\t\t\t\t/* Used to walk the code string */\n\t\t\t\t*segment,\t\t\t/* Start of segment to append while walking */\n\t\t\t\t walk_last;\t\t\t/* Last walked character */\n\tint\t\t\t match_len;\t\t\t/* Length of the match */\n\tint\t\t\t esc_match_len;\t\t/* Length of the quote-escaped match */\n\tint\t\t\t result_len;\t\t/* Length of the result of the evaluation */\n\tint\t\t\t backref;\t\t\t/* Current backref */\n\tchar *compiled_string_description;\n\tsmart_str code = {0};\n\t\n\teval_str_end = eval_str + eval_str_len;\n\twalk = segment = eval_str;\n\twalk_last = 0;\n\t\n\twhile (walk < eval_str_end) {\n\t\t/* If found a backreference.. */\n\t\tif ('\\\\' == *walk || '$' == *walk) {\n\t\t\tsmart_str_appendl(&code, segment, walk - segment);\n\t\t\tif (walk_last == '\\\\') {\n\t\t\t\tcode.c[code.len-1] = *walk++;\n\t\t\t\tsegment = walk;\n\t\t\t\twalk_last = 0;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tsegment = walk;\n\t\t\tif (preg_get_backref(&walk, &backref)) {\n\t\t\t\tif (backref < count) {\n\t\t\t\t\t/* Find the corresponding string match and substitute it\n\t\t\t\t\t in instead of the backref */\n\t\t\t\t\tmatch = subject + offsets[backref<<1];\n\t\t\t\t\tmatch_len = offsets[(backref<<1)+1] - offsets[backref<<1];\n\t\t\t\t\tif (match_len) {\n\t\t\t\t\t\tesc_match = php_addslashes(match, match_len, &esc_match_len, 0 TSRMLS_CC);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tesc_match = match;\n\t\t\t\t\t\tesc_match_len = 0;\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tesc_match = \"\";\n\t\t\t\t\tesc_match_len = 0;\n\t\t\t\t}\n\t\t\t\tsmart_str_appendl(&code, esc_match, esc_match_len);\n\n\t\t\t\tsegment = walk;\n\n\t\t\t\t/* Clean up and reassign */\n\t\t\t\tif (esc_match_len)\n\t\t\t\t\tefree(esc_match);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\twalk++;\n\t\twalk_last = walk[-1];\n\t}\n\tsmart_str_appendl(&code, segment, walk - segment);\n\tsmart_str_0(&code);\n\n\tcompiled_string_description = zend_make_compiled_string_description(\"regexp code\" TSRMLS_CC);\n\t/* Run the code */\n\tif (zend_eval_stringl(code.c, code.len, &retval, compiled_string_description TSRMLS_CC) == FAILURE) {\n\t\tefree(compiled_string_description);\n\t\tphp_error_docref(NULL TSRMLS_CC,E_ERROR, \"Failed evaluating code: %s%s\", PHP_EOL, code.c);\n\t\t/* zend_error() does not return in this case */\n\t}\n\tefree(compiled_string_description);\n\tconvert_to_string(&retval);\n\t\n\t/* Save the return value and its length */\n\t*result = estrndup(Z_STRVAL(retval), Z_STRLEN(retval));\n\tresult_len = Z_STRLEN(retval);\n\t\n\t/* Clean up */\n\tzval_dtor(&retval);\n\tsmart_str_free(&code);\n\t\n\treturn result_len;\n}", "label": 0, "cwe": null, "length": 751 }, { "index": 102626, "code": "ti1570_update_rx_cring(struct pa_a1_data *d,\n ti1570_rx_dma_entry_t *rde,\n m_uint32_t atm_hdr,\n m_uint32_t aal5_trailer,\n m_uint32_t err_ind,\n m_uint32_t fbuf_valid)\n{\n m_uint32_t rcr_addr,rcr_end,aal_type,ptr,val;\n ti1570_rcr_entry_t rcre;\n\n if (rde->ctrl & TI1570_RX_DMA_RCR_SELECT) {\n /* RX completion ring with interrupt */\n rcr_addr = d->iregs[TI1570_REG_RCR_WI_ADDR];\n rcr_addr += (d->rcr_wi_pos * sizeof(rcre));\n } else {\n /* RX completion ring without interrupt */\n rcr_addr = d->iregs[TI1570_REG_RCR_WOI_ADDR];\n rcr_addr += (d->rcr_woi_pos * sizeof(rcre));\n }\n\n#if DEBUG_RECEIVE\n TI1570_LOG(d,\"ti1570_update_rx_cring: posting 0x%x at address 0x%x\\n\",\n (rde->sp_ptr << 2),rcr_addr);\n\n physmem_dump_vm(d->vm,rde->sp_ptr<<2,sizeof(ti1570_rx_buffer_t) >> 2);\n#endif\n\n /* we have a RX freeze if the buffer belongs to the host */\n ptr = rcr_addr + OFFSET(ti1570_rcr_entry_t,fbr_entry);\n val = physmem_copy_u32_from_vm(d->vm,ptr);\n\n if (!(val & TI1570_RCR_OWN)) {\n TI1570_LOG(d,\"ti1570_update_rx_cring: RX freeze...\\n\");\n d->iregs[TI1570_REG_STATUS] |= TI1570_STAT_RX_FRZ;\n return;\n }\n\n /* fill the RX completion ring entry and write it back to the host */\n memset(&rcre,0,sizeof(rcre));\n \n /* word 0: atm header from last cell received */\n rcre.atm_hdr = atm_hdr;\n\n /* word 1: error indicator */\n aal_type = rde->ctrl & TI1570_RX_DMA_AAL_TYPE_MASK;\n if (aal_type == TI1570_RX_DMA_AAL_AAL5)\n rcre.error |= TI1570_RCR_AAL5;\n \n rcre.error |= err_ind;\n\n /* word 2: Start of packet */\n if (fbuf_valid)\n rcre.sp_addr = TI1570_RCR_VALID | rde->sp_ptr;\n \n /* word 3: AAL5 trailer */\n rcre.aal5_trailer = aal5_trailer;\n \n /* word 4: OWN + error entry + free-buffer ring pointer */\n rcre.fbr_entry = rde->fbr_entry & TI1570_RX_DMA_FB_PTR_MASK;\n if (err_ind) rcre.fbr_entry |= TI1570_RCR_ERROR;\n\n /* byte-swap and write this back to the host memory */\n rcre.atm_hdr = htonl(rcre.atm_hdr);\n rcre.error = htonl(rcre.error);\n rcre.sp_addr = htonl(rcre.sp_addr);\n rcre.aal5_trailer = htonl(rcre.aal5_trailer);\n rcre.fbr_entry = htonl(rcre.fbr_entry);\n physmem_copy_to_vm(d->vm,&rcre,rcr_addr,sizeof(rcre));\n\n /* clear the active bit of the RX DMA entry */\n rde->ctrl &= ~TI1570_RX_DMA_ACT;\n\n /* update the internal position pointer */\n if (rde->ctrl & TI1570_RX_DMA_RCR_SELECT) {\n rcr_end = d->iregs[TI1570_REG_RX_CRING_SIZE] & TI1570_RCR_SIZE_MASK;\n\n if ((d->rcr_wi_pos++) == rcr_end)\n d->rcr_wi_pos = 0;\n\n /* generate the appropriate IRQ */\n d->iregs[TI1570_REG_STATUS] |= TI1570_STAT_CP_RX;\n dev_pa_a1_update_irq_status(d);\n } else {\n rcr_end = (d->iregs[TI1570_REG_RX_CRING_SIZE] >> 16);\n rcr_end &= TI1570_RCR_SIZE_MASK;\n\n if ((d->rcr_woi_pos++) == rcr_end)\n d->rcr_woi_pos = 0;\n }\n}", "label": 0, "cwe": null, "length": 964 }, { "index": 857189, "code": "eth_link_query_port(struct ib_device *ibdev, u8 port,\n\t\t\t struct ib_port_attr *props, int netw_view)\n{\n\n\tstruct mlx4_ib_dev *mdev = to_mdev(ibdev);\n\tstruct mlx4_ib_iboe *iboe = &mdev->iboe;\n\tstruct net_device *ndev;\n\tenum ib_mtu tmp;\n\tstruct mlx4_cmd_mailbox *mailbox;\n\tint err = 0;\n\tint is_bonded = mlx4_is_bonded(mdev->dev);\n\n\tmailbox = mlx4_alloc_cmd_mailbox(mdev->dev);\n\tif (IS_ERR(mailbox))\n\t\treturn PTR_ERR(mailbox);\n\n\terr = mlx4_cmd_box(mdev->dev, 0, mailbox->dma, port, 0,\n\t\t\t MLX4_CMD_QUERY_PORT, MLX4_CMD_TIME_CLASS_B,\n\t\t\t MLX4_CMD_WRAPPED);\n\tif (err)\n\t\tgoto out;\n\n\tprops->active_width\t= (((u8 *)mailbox->buf)[5] == 0x40) ||\n\t\t\t\t (((u8 *)mailbox->buf)[5] == 0x20 /*56Gb*/) ?\n\t\t\t\t\t IB_WIDTH_4X : IB_WIDTH_1X;\n\tprops->active_speed\t= (((u8 *)mailbox->buf)[5] == 0x20 /*56Gb*/) ?\n\t\t\t\t\t IB_SPEED_FDR : IB_SPEED_QDR;\n\tprops->port_cap_flags\t= IB_PORT_CM_SUP | IB_PORT_IP_BASED_GIDS;\n\tprops->gid_tbl_len\t= mdev->dev->caps.gid_table_len[port];\n\tprops->max_msg_sz\t= mdev->dev->caps.max_msg_sz;\n\tprops->pkey_tbl_len\t= 1;\n\tprops->max_mtu\t\t= IB_MTU_4096;\n\tprops->max_vl_num\t= 2;\n\tprops->state\t\t= IB_PORT_DOWN;\n\tprops->phys_state\t= state_to_phys_state(props->state);\n\tprops->active_mtu\t= IB_MTU_256;\n\tspin_lock_bh(&iboe->lock);\n\tndev = iboe->netdevs[port - 1];\n\tif (ndev && is_bonded) {\n\t\trcu_read_lock(); /* required to get upper dev */\n\t\tndev = netdev_master_upper_dev_get_rcu(ndev);\n\t\trcu_read_unlock();\n\t}\n\tif (!ndev)\n\t\tgoto out_unlock;\n\n\ttmp = iboe_get_mtu(ndev->mtu);\n\tprops->active_mtu = tmp ? min(props->max_mtu, tmp) : IB_MTU_256;\n\n\tprops->state\t\t= (netif_running(ndev) && netif_carrier_ok(ndev)) ?\n\t\t\t\t\tIB_PORT_ACTIVE : IB_PORT_DOWN;\n\tprops->phys_state\t= state_to_phys_state(props->state);\nout_unlock:\n\tspin_unlock_bh(&iboe->lock);\nout:\n\tmlx4_free_cmd_mailbox(mdev->dev, mailbox);\n\treturn err;\n}", "label": 0, "cwe": null, "length": 615 }, { "index": 349507, "code": "__memp_pgread(dbmfp, bhp, can_create)\n\tDB_MPOOLFILE *dbmfp;\n\tBH *bhp;\n\tint can_create;\n{\n\tENV *env;\n\tMPOOLFILE *mfp;\n\tsize_t len, nr;\n\tu_int32_t pagesize;\n\tint ret;\n\n\tenv = dbmfp->env;\n\tmfp = dbmfp->mfp;\n\tpagesize = mfp->pagesize;\n\n\t/* We should never be called with a dirty or unlocked buffer. */\n\tDB_ASSERT(env, !F_ISSET(bhp, BH_DIRTY_CREATE | BH_FROZEN));\n\tDB_ASSERT(env, can_create ||\n\t F_ISSET(bhp, BH_TRASH) || !F_ISSET(bhp, BH_DIRTY));\n\tDB_ASSERT(env, F_ISSET(bhp, BH_EXCLUSIVE));\n\n\t/* Mark the buffer as in transition. */\n\tF_SET(bhp, BH_TRASH);\n\n\t/*\n\t * Temporary files may not yet have been created. We don't create\n\t * them now, we create them when the pages have to be flushed.\n\t */\n\tnr = 0;\n\tif (dbmfp->fhp != NULL) {\n\t\tPERFMON3(env, mpool, read, __memp_fn(dbmfp), bhp->pgno, bhp);\n\t\tif ((ret = __os_io(env, DB_IO_READ, dbmfp->fhp,\n\t\t bhp->pgno, pagesize, 0, pagesize, bhp->buf, &nr)) != 0)\n\t\t\tgoto err;\n\t}\n\n\t/*\n\t * The page may not exist; if it doesn't, nr may well be 0, but we\n\t * expect the underlying OS calls not to return an error code in\n\t * this case.\n\t */\n\tif (nr < pagesize) {\n\t\t/*\n\t\t * Don't output error messages for short reads. In particular,\n\t\t * DB recovery processing may request pages never written to\n\t\t * disk or for which only some part have been written to disk,\n\t\t * in which case we won't find the page. The caller must know\n\t\t * how to handle the error.\n\t\t */\n\t\tif (!can_create) {\n\t\t\tret = DB_PAGE_NOTFOUND;\n\t\t\tgoto err;\n\t\t}\n\n\t\t/* Clear any bytes that need to be cleared. */\n\t\tlen = mfp->clear_len == DB_CLEARLEN_NOTSET ?\n\t\t pagesize : mfp->clear_len;\n\t\tmemset(bhp->buf, 0, len);\n\n#if defined(DIAGNOSTIC) || defined(UMRW)\n\t\t/*\n\t\t * If we're running in diagnostic mode, corrupt any bytes on\n\t\t * the page that are unknown quantities for the caller.\n\t\t */\n\t\tif (len < pagesize)\n\t\t\tmemset(bhp->buf + len, CLEAR_BYTE, pagesize - len);\n#endif\n\t\tSTAT_INC_VERB(env, mpool, page_create,\n\t\t mfp->stat.st_page_create, __memp_fn(dbmfp), bhp->pgno);\n\t} else\n\t\tSTAT_INC_VERB(env, mpool, page_in,\n\t\t mfp->stat.st_page_in, __memp_fn(dbmfp), bhp->pgno);\n\n\t/* Call any pgin function. */\n\tret = mfp->ftype == 0 ? 0 : __memp_pg(dbmfp, bhp->pgno, bhp->buf, 1);\n\n\t/*\n\t * If no errors occurred, the data is now valid, clear the BH_TRASH\n\t * flag.\n\t */\n\tif (ret == 0)\n\t\tF_CLR(bhp, BH_TRASH);\nerr:\treturn (ret);\n}", "label": 0, "cwe": null, "length": 778 }, { "index": 921611, "code": "php_do_chown(INTERNAL_FUNCTION_PARAMETERS, int do_lchown) /* {{{ */\n{\n\tchar *filename;\n\tint filename_len;\n\tzval *user;\n#if !defined(WINDOWS)\n\tuid_t uid;\n\tint ret;\n#endif\n\tphp_stream_wrapper *wrapper;\n\n\tif (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, \"pz/\", &filename, &filename_len, &user) == FAILURE) {\n\t\treturn;\n\t}\n\n\twrapper = php_stream_locate_url_wrapper(filename, NULL, 0 TSRMLS_CC);\n\tif(wrapper != &php_plain_files_wrapper || strncasecmp(\"file://\", filename, 7) == 0) {\n\t\tif(wrapper && wrapper->wops->stream_metadata) {\n\t\t\tint option;\n\t\t\tvoid *value;\n\t\t\tif (Z_TYPE_P(user) == IS_LONG) {\n\t\t\t\toption = PHP_STREAM_META_OWNER;\n\t\t\t\tvalue = &Z_LVAL_P(user);\n\t\t\t} else if (Z_TYPE_P(user) == IS_STRING) {\n\t\t\t\toption = PHP_STREAM_META_OWNER_NAME;\n\t\t\t\tvalue = Z_STRVAL_P(user);\n\t\t\t} else {\n\t\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"parameter 2 should be string or integer, %s given\", zend_zval_type_name(user));\n\t\t\t\tRETURN_FALSE;\n\t\t\t}\n\t\t\tif(wrapper->wops->stream_metadata(wrapper, filename, option, value, NULL TSRMLS_CC)) {\n\t\t\t\tRETURN_TRUE;\n\t\t\t} else {\n\t\t\t\tRETURN_FALSE;\n\t\t\t}\n\t\t} else {\n#if !defined(WINDOWS)\n/* On Windows, we expect regular chown to fail silently by default */\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Can not call chown() for a non-standard stream\");\n#endif\n\t\t\tRETURN_FALSE;\n\t\t}\n\t}\n\n#if defined(WINDOWS)\n\t/* We have no native chown on Windows, nothing left to do if stream doesn't have own implementation */\n\tRETURN_FALSE;\n#else\n\n\tif (Z_TYPE_P(user) == IS_LONG) {\n\t\tuid = (uid_t)Z_LVAL_P(user);\n\t} else if (Z_TYPE_P(user) == IS_STRING) {\n\t\tif(php_get_uid_by_name(Z_STRVAL_P(user), &uid TSRMLS_CC) != SUCCESS) {\n\t\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"Unable to find uid for %s\", Z_STRVAL_P(user));\n\t\t\tRETURN_FALSE;\n\t\t}\n\t} else {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"parameter 2 should be string or integer, %s given\", zend_zval_type_name(user));\n\t\tRETURN_FALSE;\n\t}\n\n\t/* Check the basedir */\n\tif (php_check_open_basedir(filename TSRMLS_CC)) {\n\t\tRETURN_FALSE;\n\t}\n\n\tif (do_lchown) {\n#if HAVE_LCHOWN\n\t\tret = VCWD_LCHOWN(filename, uid, -1);\n#endif\n\t} else {\n\t\tret = VCWD_CHOWN(filename, uid, -1);\n\t}\n\tif (ret == -1) {\n\t\tphp_error_docref(NULL TSRMLS_CC, E_WARNING, \"%s\", strerror(errno));\n\t\tRETURN_FALSE;\n\t}\n\tRETURN_TRUE;\n#endif\n}", "label": 0, "cwe": null, "length": 664 }, { "index": 290408, "code": "chm_limit(struct Client *client_p, struct Client *source_p,\n struct Channel *chptr, int parc, int *parn,\n char **parv, int *errors, int alev, int dir, char c, void *d,\n const char *chname)\n{\n int i, limit;\n char *lstr;\n\n if (alev < CHACCESS_HALFOP)\n {\n if (!(*errors & SM_ERR_NOOPS))\n sendto_one(source_p, form_str(alev == CHACCESS_NOTONCHAN ?\n ERR_NOTONCHANNEL : ERR_CHANOPRIVSNEEDED),\n me.name, source_p->name, chname);\n *errors |= SM_ERR_NOOPS;\n return;\n }\n\n if (dir == MODE_QUERY)\n return;\n\n if ((dir == MODE_ADD) && parc > *parn)\n {\n lstr = parv[(*parn)++];\n\n if ((limit = atoi(lstr)) <= 0)\n return;\n\n ircsprintf(lstr, \"%d\", limit);\n\n /* if somebody sets MODE #channel +ll 1 2, accept latter --fl */\n for (i = 0; i < mode_count; i++)\n {\n if (mode_changes[i].letter == c && mode_changes[i].dir == MODE_ADD)\n mode_changes[i].letter = 0;\n }\n\n mode_changes[mode_count].letter = c;\n mode_changes[mode_count].dir = MODE_ADD;\n mode_changes[mode_count].caps = 0;\n mode_changes[mode_count].nocaps = 0;\n mode_changes[mode_count].mems = ALL_MEMBERS;\n mode_changes[mode_count].id = NULL;\n mode_changes[mode_count++].arg = lstr;\n\n chptr->mode.limit = limit;\n }\n else if (dir == MODE_DEL)\n {\n if (!chptr->mode.limit)\n return;\n\n chptr->mode.limit = 0;\n\n mode_changes[mode_count].letter = c;\n mode_changes[mode_count].dir = MODE_DEL;\n mode_changes[mode_count].caps = 0;\n mode_changes[mode_count].nocaps = 0;\n mode_changes[mode_count].mems = ALL_MEMBERS;\n mode_changes[mode_count].id = NULL;\n mode_changes[mode_count++].arg = NULL;\n }\n}", "label": 1, "cwe": "CWE-other", "length": 513 }, { "index": 114415, "code": "input_data(struct interp_params *params,\n\t\t int first_row, int last_row,\n\t\t struct fcell_triple *points,\n\t\t int fdsmooth, int fdinp,\n\t\t int inp_rows, int inp_cols,\n\t\t double zmin, double inp_ns_res, double inp_ew_res)\n{\n double x, y, sm;\t\t/* input data and smoothing */\n int m1, m2;\t\t\t/* loop counters */\n int ret_val, ret_val1;\t/* return values of G_get_map_row */\n static FCELL *cellinp = NULL;\t/* cell buffer for input data */\n static FCELL *cellsmooth = NULL;\t/* cell buffer for smoothing */\n\n\n if (!cellinp)\n\tcellinp = G_allocate_f_raster_buf();\n if (!cellsmooth)\n\tcellsmooth = G_allocate_f_raster_buf();\n\n for (m1 = 0; m1 <= last_row - first_row; m1++) {\n\tret_val =\n\t G_get_f_raster_row(fdinp, cellinp, inp_rows - m1 - first_row);\n\tif (ret_val < 0) {\n\t fprintf(stderr, \"Cannot get row %d (return value = %d)\\n\", m1,\n\t\t ret_val);\n\t return -1;\n\t}\n\tif (fdsmooth >= 0) {\n\t ret_val1 =\n\t\tG_get_f_raster_row(fdsmooth, cellsmooth,\n\t\t\t\t inp_rows - m1 - first_row);\n\t if (ret_val1 < 0) {\n\t\tfprintf(stderr, \"Cannot get smoothing row\\n\");\n\t }\n\t}\n\ty = params->y_orig + (m1 + first_row - 1 + 0.5) * inp_ns_res;\n\tfor (m2 = 0; m2 < inp_cols; m2++) {\n\t x = params->x_orig + (m2 + 0.5) * inp_ew_res;\n\t /*\n\t * z = cellinp[m2]*params->zmult;\n\t */\n\t if (fdsmooth >= 0)\n\t\tsm = (double)cellsmooth[m2];\n\t else\n\t\tsm = 0.01;\n\n\t points[m1 * inp_cols + m2].x = x - params->x_orig;\n\t points[m1 * inp_cols + m2].y = y - params->y_orig;\n\t if (!G_is_f_null_value(cellinp + m2)) {\n\t\tpoints[m1 * inp_cols + m2].z =\n\t\t cellinp[m2] * params->zmult - zmin;\n\t }\n\t else {\n\t\tG_set_f_null_value(&(points[m1 * inp_cols + m2].z), 1);\n\t }\n\n\t /* fprintf (stdout,\"sm: %f\\n\",sm); */\n\n\t points[m1 * inp_cols + m2].smooth = sm;\n\t}\n }\n return 1;\n}", "label": 0, "cwe": null, "length": 600 }, { "index": 694274, "code": "typecode_to_mformat_code(char typecode)\n{\n#ifdef WORDS_BIGENDIAN\n const int is_big_endian = 1;\n#else\n const int is_big_endian = 0;\n#endif\n size_t intsize;\n int is_signed;\n\n switch (typecode) {\n case 'b':\n return SIGNED_INT8;\n case 'B':\n return UNSIGNED_INT8;\n\n case 'u':\n return UTF32_LE + is_big_endian;\n\n case 'f':\n if (sizeof(float) == 4) {\n const float y = 16711938.0;\n if (memcmp(&y, \"\\x4b\\x7f\\x01\\x02\", 4) == 0)\n return IEEE_754_FLOAT_BE;\n if (memcmp(&y, \"\\x02\\x01\\x7f\\x4b\", 4) == 0)\n return IEEE_754_FLOAT_LE;\n }\n return UNKNOWN_FORMAT;\n\n case 'd':\n if (sizeof(double) == 8) {\n const double x = 9006104071832581.0;\n if (memcmp(&x, \"\\x43\\x3f\\xff\\x01\\x02\\x03\\x04\\x05\", 8) == 0)\n return IEEE_754_DOUBLE_BE;\n if (memcmp(&x, \"\\x05\\x04\\x03\\x02\\x01\\xff\\x3f\\x43\", 8) == 0)\n return IEEE_754_DOUBLE_LE;\n }\n return UNKNOWN_FORMAT;\n\n /* Integers */\n case 'h':\n intsize = sizeof(short);\n is_signed = 1;\n break;\n case 'H':\n intsize = sizeof(short);\n is_signed = 0;\n break;\n case 'i':\n intsize = sizeof(int);\n is_signed = 1;\n break;\n case 'I':\n intsize = sizeof(int);\n is_signed = 0;\n break;\n case 'l':\n intsize = sizeof(long);\n is_signed = 1;\n break;\n case 'L':\n intsize = sizeof(long);\n is_signed = 0;\n break;\n#if HAVE_LONG_LONG\n case 'q':\n intsize = sizeof(PY_LONG_LONG);\n is_signed = 1;\n break;\n case 'Q':\n intsize = sizeof(PY_LONG_LONG);\n is_signed = 0;\n break;\n#endif\n default:\n return UNKNOWN_FORMAT;\n }\n switch (intsize) {\n case 2:\n return UNSIGNED_INT16_LE + is_big_endian + (2 * is_signed);\n case 4:\n return UNSIGNED_INT32_LE + is_big_endian + (2 * is_signed);\n case 8:\n return UNSIGNED_INT64_LE + is_big_endian + (2 * is_signed);\n default:\n return UNKNOWN_FORMAT;\n }\n}", "label": 0, "cwe": null, "length": 608 }, { "index": 763452, "code": "OutputReplacementClasses(int fxdSilfVersion,\n\tstd::vector & vpglfcReplcmt, int cpglfcLinear,\n\tGrcBinaryStream * pbstrm)\n{\n\tlong lClassMapStart = pbstrm->Position();\n\n\t//\tnumber of classes\n\tpbstrm->WriteShort(vpglfcReplcmt.size());\n\t//\tnumber that can be in linear format\n\tpbstrm->WriteShort(cpglfcLinear);\n\n\t//\toffsets to classes--fill in later; for now output (# classes + 1) place holders\n\tstd::vector vnClassOffsets;\n\tlong lOffsetPos = pbstrm->Position();\n\tint ipglfc;\n\tfor (ipglfc = 0; ipglfc <= signed(vpglfcReplcmt.size()); ipglfc++)\n\t{\n\t\tif (fxdSilfVersion < 0x00040000)\n\t\t\tpbstrm->WriteShort(0);\n\t\telse\n\t\t\tpbstrm->WriteInt(0);\n\t}\n\n\t//\tlinear classes (output)\n\tint cTmp = 0;\n\tfor (ipglfc = 0; ipglfc < cpglfcLinear; ipglfc++)\n\t{\n\t\tGdlGlyphClassDefn * pglfc = vpglfcReplcmt[ipglfc];\n\n\t\tvnClassOffsets.push_back(pbstrm->Position() - lClassMapStart);\n\n\t\tAssert(pglfc->ReplcmtOutputClass() || pglfc->GlyphIDCount() <= 1);\n\t\t//Assert(pglfc->ReplcmtOutputID() == cTmp);\n\n\t\tstd::vector vwGlyphs;\n\t\tpglfc->GenerateOutputGlyphList(vwGlyphs);\n\t\t//\tnumber of items and search constants\n\t\t//int n = vwGlyphs.Size();\n\t\t//int nPowerOf2, nLog;\n\t\t//BinarySearchConstants(n, &nPowerOf2, &nLog);\n\t\t//pbstrm->WriteShort(n);\n\t\t//pbstrm->WriteShort(nPowerOf2);\n\t\t//pbstrm->WriteShort(nLog);\n\t\t//pbstrm->WriteShort(n - nPowerOf2);\n\t\t//\tglyph list\n\t\tfor (size_t iw = 0; iw < vwGlyphs.size(); iw++)\n\t\t\tpbstrm->WriteShort(vwGlyphs[iw]);\n\n\t\tcTmp++;\n\t}\n\n\t//\tindexed classes (input)\n\tfor (ipglfc = cpglfcLinear; ipglfc < signed(vpglfcReplcmt.size()); ipglfc++)\n\t{\n\t\tGdlGlyphClassDefn * pglfc = vpglfcReplcmt[ipglfc];\n\n\t\tvnClassOffsets.push_back(pbstrm->Position() - lClassMapStart);\n\n\t\tAssert(pglfc->ReplcmtInputClass());\n\t\tAssert(pglfc->ReplcmtInputID() == cTmp);\n\n\t\tstd::vector vwGlyphs;\n\t\tstd::vector vnIndices;\n\t\tpglfc->GenerateInputGlyphList(vwGlyphs, vnIndices);\n\t\t//\tnumber of items and search constants\n\t\tint n = signed(vwGlyphs.size());\n\t\tint nPowerOf2, nLog;\n\t\tBinarySearchConstants(n, &nPowerOf2, &nLog);\n\t\tpbstrm->WriteShort(n);\n\t\tpbstrm->WriteShort(nPowerOf2);\n\t\tpbstrm->WriteShort(nLog);\n\t\tpbstrm->WriteShort(n - nPowerOf2);\n\t\t//\tglyph list\n\t\tfor (size_t iw = 0; iw < vwGlyphs.size(); iw++)\n\t\t{\n\t\t\tpbstrm->WriteShort(vwGlyphs[iw]);\n\t\t\tpbstrm->WriteShort(vnIndices[iw]);\n\t\t}\n\n\t\tcTmp++;\n\t}\n\n\t//\tfinal offset giving length of block\n\tvnClassOffsets.push_back(pbstrm->Position() - lClassMapStart);\n\n\t//\tNow go back and fill in the offsets.\n\tlong lSavePos = pbstrm->Position();\n\n\tpbstrm->SetPosition(lOffsetPos);\n\tfor (size_t i = 0; i < vnClassOffsets.size(); i++)\n\t{\n\t\tif (fxdSilfVersion < 0x00040000)\n\t\t\tpbstrm->WriteShort(vnClassOffsets[i]);\n\t\telse\n\t\t\tpbstrm->WriteInt(vnClassOffsets[i]);\n\t}\n\n\tpbstrm->SetPosition(lSavePos);\n}", "label": 0, "cwe": null, "length": 990 }, { "index": 557992, "code": "writeATAPI(int pNum, AbstractFile* file, unsigned int BlockSize, ChecksumFunc dataForkChecksum, void* dataForkToken, ResourceKey **resources, NSizResource** nsizIn) {\n AbstractFile* bufferFile;\n BLKXTable* blkx;\n ChecksumToken uncompressedToken;\n NSizResource* nsiz;\n CSumResource csum;\n char* atapi;\n \n memset(&uncompressedToken, 0, sizeof(uncompressedToken));\n \n atapi = (char*) malloc(ATAPI_SIZE * SECTOR_SIZE);\n printf(\"malloc: %p %d\\n\", atapi, ATAPI_SIZE * SECTOR_SIZE); fflush(stdout);\n memcpy(atapi, atapi_data, ATAPI_SIZE * SECTOR_SIZE);\n bufferFile = createAbstractFileFromMemory((void**)&atapi, ATAPI_SIZE * SECTOR_SIZE);\n\n if(BlockSize != SECTOR_SIZE)\n {\n blkx = insertBLKX(file, bufferFile, ATAPI_OFFSET, BlockSize / SECTOR_SIZE, pNum, CHECKSUM_CRC32,\n &BlockCRC, &uncompressedToken, dataForkChecksum, dataForkToken, NULL, 0);\n }\n else\n {\n blkx = insertBLKX(file, bufferFile, ATAPI_OFFSET, ATAPI_SIZE, pNum, CHECKSUM_CRC32,\n &BlockCRC, &uncompressedToken, dataForkChecksum, dataForkToken, NULL, 0);\n }\n\n bufferFile->close(bufferFile);\n free(atapi);\n\n blkx->checksum.data[0] = uncompressedToken.crc;\n \n csum.version = 1;\n csum.type = CHECKSUM_MKBLOCK;\n csum.checksum = uncompressedToken.block;\n\n char pName[100];\n sprintf(pName, \"Macintosh (Apple_Driver_ATAPI : %d)\", pNum + 1);\t\n *resources = insertData(*resources, \"blkx\", pNum, pName, (const char*) blkx, sizeof(BLKXTable) + (blkx->blocksRunCount * sizeof(BLKXRun)), ATTRIBUTE_HDIUTIL);\n *resources = insertData(*resources, \"cSum\", 1, \"\", (const char*) (&csum), sizeof(csum), 0);\n \n nsiz = (NSizResource*) malloc(sizeof(NSizResource));\n memset(nsiz, 0, sizeof(NSizResource));\n nsiz->isVolume = FALSE;\n nsiz->blockChecksum2 = uncompressedToken.block;\n nsiz->partitionNumber = 1;\n nsiz->version = 6;\n nsiz->next = NULL;\n \n if((*nsizIn) == NULL) {\n *nsizIn = nsiz;\n } else {\n nsiz->next = (*nsizIn)->next;\n (*nsizIn)->next = nsiz;\n }\n \n free(blkx);\n\n pNum++;\n\n if(BlockSize != SECTOR_SIZE && (USER_OFFSET - (ATAPI_OFFSET + (BlockSize / SECTOR_SIZE))) > 0)\n pNum = writeFreePartition(pNum, file, ATAPI_OFFSET + (BlockSize / SECTOR_SIZE), USER_OFFSET - (ATAPI_OFFSET + (BlockSize / SECTOR_SIZE)), resources);\n\n return pNum;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 711 }, { "index": 419339, "code": "GRgetchunkinfo(int32 riid, /* IN: sds access id */\n HDF_CHUNK_DEF *chunk_def, /* IN/OUT: chunk definition */\n int32 *flags /* IN/OUT: flags */)\n{\n CONSTR(FUNC, \"GRgetchunkinfo\");\n ri_info_t *ri_ptr = NULL; /* ptr to the image to work with */\n sp_info_block_t info_block; /* special info block */\n int16 special; /* Special code */\n intn i; /* loop variable */\n intn ret_value = SUCCEED; /* return value */\n\n\n /* clear error stack and check validity of args */\n HEclear();\n\n /* Check some args */\n\n /* check the validity of the RI ID */\n if (HAatom_group(riid)!=RIIDGROUP)\n HGOTO_ERROR(DFE_ARGS, FAIL);\n\n /* locate RI's object in hash table */\n if (NULL == (ri_ptr = (ri_info_t *) HAatom_object(riid)))\n HGOTO_ERROR(DFE_RINOTFOUND, FAIL);\n\n /* check if access id exists already */\n if(ri_ptr->img_aid == 0)\n {\n /* now get access id, use read access for now */\n if(GRIgetaid(ri_ptr,DFACC_READ)==FAIL)\n HGOTO_ERROR(DFE_INTERNAL,FAIL);\n }\n else if (ri_ptr->img_aid == FAIL)\n HGOTO_ERROR(DFE_INTERNAL,FAIL);\n\n#ifdef CHK_DEBUG\n fprintf(stderr,\"%s: ri_ptr->img_aid =%d \\n\", FUNC, ri_ptr->img_aid);\n#endif\n\n /* inquire about element */\n ret_value = Hinquire(ri_ptr->img_aid, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &special);\n if (ret_value != FAIL)\n { /* make sure it is chunked element */\n if (special == SPECIAL_CHUNKED)\n { /* get info about chunked element */\n if ((ret_value = HDget_special_info(ri_ptr->img_aid, &info_block)) != FAIL)\n { /* Does user want chunk lengths back? */\n if (chunk_def != NULL)\n {\n /* we assume user has allocat space for chunk lengths */\n /* copy chunk lengths over */\n for (i = 0; i < info_block.ndims; i++)\n {\n chunk_def->chunk_lengths[i] = info_block.cdims[i];\n }\n }\n /* dont forget to free up info is special info block \n This space was allocated by the library */\n HDfree(info_block.cdims);\n\n /* Check to see if compressed */\n switch(info_block.comp_type)\n {\n case COMP_CODE_NONE:\n *flags = HDF_CHUNK;\n break;\n case COMP_CODE_NBIT: \n /* is this an error? \n NBIT can't be set in GRsetchunk(). */\n *flags = (HDF_CHUNK | HDF_NBIT);\n break;\n default:\n *flags = (HDF_CHUNK | HDF_COMP);\n break;\n }\n }\n }\n else /* not special chunked element */\n {\n *flags = HDF_NONE; /* regular GR */\n }\n }\n\n done:\n if (ret_value == FAIL)\n { /* Failure cleanup */\n\n }\n /* Normal cleanup */\n return ret_value;\n}", "label": 0, "cwe": null, "length": 728 }, { "index": 488384, "code": "ggept_ip_seq_append_net(ggep_stream_t *gs,\n\tconst sequence_t *hseq, enum net_type net,\n\tconst char *name, const char *name_tls,\n\tconst gnet_host_t *evec, size_t ecnt, size_t *count, bool cobs)\n{\n\tuchar *tls_bytes = NULL;\n\tunsigned tls_length;\n\tsize_t tls_size = 0, tls_index = 0;\n\tbool status = FALSE;\n\tunsigned flags = 0;\n\tsize_t hcnt;\n\tconst char *current_extension;\n\tsequence_iter_t *iter = NULL;\n\tsize_t max_items = *count;\n\n\tg_assert(gs != NULL);\n\tg_assert(name != NULL);\n\tg_assert(hseq != NULL);\n\n\thcnt = sequence_count(hseq);\n\n\tif (0 == hcnt) {\n\t\tstatus = TRUE;\n\t\tgoto done;\n\t}\n\n\ttls_size = (hcnt + 7) / 8;\n\ttls_bytes = name_tls != NULL ? walloc0(tls_size) : NULL;\n\ttls_index = tls_length = 0;\n\n\t/*\n\t * We only attempt to deflate IPv6 vectors, since IPv4 does not bring\n\t * enough redundancy to be worth it: 180 bytes of data for 30 IPv4\n\t * addresses typically compress to 175 bytes. Hardly interesting.\n\t */\n\n\tflags |= (NET_TYPE_IPV6 == net) ? GGEP_W_DEFLATE : 0;\n\tflags |= cobs ? GGEP_W_COBS : 0;\n\n\t/*\n\t * We use GGEP_W_STRIP to make sure the extension is removed if empty.\n\t */\n\n\tcurrent_extension = name;\n\n\tif (!ggep_stream_begin(gs, name, GGEP_W_STRIP | flags))\n\t\tgoto done;\n\n\titer = sequence_forward_iterator(hseq);\n\n\twhile (sequence_iter_has_next(iter) && tls_index < max_items) {\n\t\thost_addr_t addr;\n\t\tuint16 port;\n\t\tchar buf[18];\n\t\tsize_t len;\n\t\tconst gnet_host_t *h = sequence_iter_next(iter);\n\n\t\tif (net != gnet_host_get_net(h))\n\t\t\tcontinue;\n\n\t\t/*\n\t\t * See whether we need to skip that host.\n\t\t */\n\n\t\tif (evec != NULL) {\n\t\t\tsize_t i;\n\n\t\t\tfor (i = 0; i < ecnt; i++) {\n\t\t\t\tif (gnet_host_eq(h, &evec[i]))\n\t\t\t\t\tgoto next;\n\t\t\t}\n\t\t}\n\n\t\taddr = gnet_host_get_addr(h);\n\t\tport = gnet_host_get_port(h);\n\n\t\thost_ip_port_poke(buf, addr, port, &len);\n\t\tif (!ggep_stream_write(gs, buf, len))\n\t\t\tgoto done;\n\n\t\t/*\n\t\t * Record in bitmask whether host is known to support TLS.\n\t\t */\n\n\t\tif (name_tls != NULL && tls_cache_lookup(addr, port)) {\n\t\t\ttls_bytes[tls_index >> 3] |= 0x80U >> (tls_index & 7);\n\t\t\ttls_length = (tls_index >> 3) + 1;\n\t\t}\n\t\ttls_index++;\n\tnext:\n\t\tcontinue;\n\t}\n\n\tif (!ggep_stream_end(gs))\n\t\tgoto done;\n\n\tif (tls_length > 0) {\n\t\tunsigned gflags = cobs ? GGEP_W_COBS : 0;\n\t\tg_assert(name_tls != NULL);\n\t\tcurrent_extension = name_tls;\n\t\tif (!ggep_stream_pack(gs, name_tls, tls_bytes, tls_length, gflags))\n\t\t\tgoto done;\n\t}\n\n\tstatus = TRUE;\n\ndone:\n\tif (!status) {\n\t\tg_carp(\"unable to add GGEP \\\"%s\\\": %s\",\n\t\t\tcurrent_extension, ggep_errstr());\n\t}\n\n\t*count = tls_index;\n\n\tsequence_iterator_release(&iter);\n\tWFREE_NULL(tls_bytes, tls_size);\n\treturn status;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 796 }, { "index": 469238, "code": "stripe_stack_rename_cbk (call_frame_t *frame, void *cookie, xlator_t *this,\n int32_t op_ret, int32_t op_errno, struct iatt *buf,\n struct iatt *preoldparent, struct iatt *postoldparent,\n struct iatt *prenewparent, struct iatt *postnewparent)\n{\n int32_t callcnt = 0;\n stripe_local_t *local = NULL;\n call_frame_t *prev = NULL;\n\n if (!this || !frame || !frame->local || !cookie) {\n gf_log (\"stripe\", GF_LOG_DEBUG, \"possible NULL deref\");\n goto out;\n }\n\n prev = cookie;\n local = frame->local;\n\n LOCK (&frame->lock);\n {\n callcnt = --local->call_count;\n\n if (op_ret == -1) {\n gf_log (this->name, GF_LOG_DEBUG,\n \"%s returned error %s\",\n prev->this->name, strerror (op_errno));\n local->op_errno = op_errno;\n if ((op_errno != ENOENT) ||\n (prev->this == FIRST_CHILD (this)))\n local->failed = 1;\n }\n\n if (op_ret == 0) {\n local->op_ret = 0;\n\n local->stbuf.ia_blocks += buf->ia_blocks;\n local->preparent.ia_blocks += preoldparent->ia_blocks;\n local->postparent.ia_blocks += postoldparent->ia_blocks;\n local->pre_buf.ia_blocks += prenewparent->ia_blocks;\n local->post_buf.ia_blocks += postnewparent->ia_blocks;\n\n if (local->stbuf.ia_size < buf->ia_size)\n local->stbuf.ia_size = buf->ia_size;\n\n if (local->preparent.ia_size < preoldparent->ia_size)\n local->preparent.ia_size = preoldparent->ia_size;\n\n if (local->postparent.ia_size < postoldparent->ia_size)\n local->postparent.ia_size = postoldparent->ia_size;\n\n if (local->pre_buf.ia_size < prenewparent->ia_size)\n local->pre_buf.ia_size = prenewparent->ia_size;\n\n if (local->post_buf.ia_size < postnewparent->ia_size)\n local->post_buf.ia_size = postnewparent->ia_size;\n }\n }\n UNLOCK (&frame->lock);\n\n if (!callcnt) {\n if (local->failed)\n local->op_ret = -1;\n\n STRIPE_STACK_UNWIND (rename, frame, local->op_ret, local->op_errno,\n &local->stbuf, &local->preparent,\n &local->postparent, &local->pre_buf,\n &local->post_buf);\n }\nout:\n return 0;\n}", "label": 0, "cwe": null, "length": 631 }, { "index": 84470, "code": "add_header_color_line(struct pine *ps, CONF_S **ctmp, char *val, int which)\n{\n struct variable *vtmp;\n SPEC_COLOR_S *hc;\n char\t tmp[100+1];\n int l;\n\n vtmp = &ps->vars[V_VIEW_HDR_COLORS];\n l = strlen(HEADER_WORD);\n\n /* Blank line */\n new_confline(ctmp);\n (*ctmp)->flags\t\t|= CF_NOSELECT | CF_B_LINE;\n\n new_confline(ctmp)->var\t = vtmp;\n (*ctmp)->varnamep\t\t = *ctmp;\n (*ctmp)->keymenu\t\t = &custom_color_setting_keymenu;\n (*ctmp)->help\t\t = config_help(vtmp - ps->vars, 0);\n (*ctmp)->tool\t\t = color_setting_tool;\n (*ctmp)->flags |= (CF_STARTITEM | CF_COLORSAMPLE | CF_POT_SLCTBL);\n if(!pico_usingcolor())\n (*ctmp)->flags |= CF_NOSELECT;\n\n /* which is an index into the variable list */\n (*ctmp)->varmem\t\t = CFC_SET_COLOR(which, 0);\n\n hc = spec_color_from_var(val, 0);\n if(hc && hc->inherit)\n (*ctmp)->flags = (CF_NOSELECT | CF_INHERIT);\n else{\n\t/*\n\t * This isn't quite right because of the assumption that the\n\t * first character of spec fits in one octet. I haven't tried\n\t * to figure out what we're really trying to accomplish\n\t * with all this. It probably doesn't happen in real life.\n\t */\n\tutf8_snprintf(tmp, sizeof(tmp), \"%s%c%.*w Color%*w %s%s\",\n\t\tHEADER_WORD,\n\t\t(hc && hc->spec) ? (islower((unsigned char)hc->spec[0])\n\t\t\t\t\t ? toupper((unsigned char)hc->spec[0])\n\t\t\t\t\t : hc->spec[0]) : '?',\n\t\tMIN(utf8_width((hc && hc->spec && hc->spec[0]) ? hc->spec+1 : \"\"),30-l),\n\t\t(hc && hc->spec && hc->spec[0]) ? hc->spec+1 : \"\",\n\t\tMAX(EQ_COL - COLOR_INDENT -1 -\n\t\t MIN(utf8_width((hc && hc->spec && hc->spec[0]) ? hc->spec+1 : \"\"),30-l)\n\t\t\t - l - 6 - 1, 0), \"\",\n\t\tsample_text(ps,vtmp),\n\t\tcolor_parenthetical(vtmp));\n\ttmp[sizeof(tmp)-1] = '\\0';\n\t(*ctmp)->value\t\t = cpystr(tmp);\n }\n\n (*ctmp)->valoffset\t\t = COLOR_INDENT;\n\n if(hc)\n free_spec_colors(&hc);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 607 }, { "index": 397279, "code": "do_layout()\n{\n wxFlexGridSizer* sizerEdits = new wxFlexGridSizer(2, 2,\n styleguide().getRelatedControlMargin(wxVERTICAL),\n styleguide().getControlLabelMargin());\n\n sizerEdits->Add(label_find, 0, wxALIGN_CENTER_VERTICAL);\n sizerEdits->Add(text_ctrl_find, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL);\n sizerEdits->Add(label_replace, 0, wxALIGN_CENTER_VERTICAL);\n sizerEdits->Add(text_ctrl_replace, 1, wxEXPAND|wxALIGN_CENTER_VERTICAL);\n sizerEdits->AddGrowableCol(1, 1);\n\n wxGridSizer* sizerChecks = new wxGridSizer(2, 2,\n styleguide().getCheckboxSpacing(),\n styleguide().getUnrelatedControlMargin(wxHORIZONTAL));\n if (checkbox_wholeword)\n sizerChecks->Add(checkbox_wholeword);\n if (checkbox_matchcase)\n sizerChecks->Add(checkbox_matchcase);\n if (checkbox_regexp)\n sizerChecks->Add(checkbox_regexp);\n if (checkbox_convertbs)\n sizerChecks->Add(checkbox_convertbs);\n if (checkbox_wrap)\n sizerChecks->Add(checkbox_wrap);\n if (checkbox_fromtop)\n sizerChecks->Add(checkbox_fromtop);\n\n wxBoxSizer* sizerButtons = new wxBoxSizer(wxHORIZONTAL);\n sizerButtons->Add(0, 0, 1, wxEXPAND);\n sizerButtons->Add(button_find);\n sizerButtons->Add(styleguide().getBetweenButtonsMargin(wxHORIZONTAL), 0);\n sizerButtons->Add(button_replace);\n sizerButtons->Add(styleguide().getBetweenButtonsMargin(wxHORIZONTAL), 0);\n sizerButtons->Add(button_replace_all);\n sizerButtons->Add(styleguide().getBetweenButtonsMargin(wxHORIZONTAL), 0);\n sizerButtons->Add(button_replace_in_selection);\n sizerButtons->Add(styleguide().getBetweenButtonsMargin(wxHORIZONTAL), 0);\n sizerButtons->Add(button_close);\n\n wxBoxSizer* sizerControls = new wxBoxSizer(wxVERTICAL);\n sizerControls->Add(sizerEdits, 1, wxEXPAND);\n sizerControls->Add(0, styleguide().getUnrelatedControlMargin(wxVERTICAL));\n sizerControls->Add(sizerChecks);\n\n // use method in base class to set everything up\n layoutSizers(sizerControls, sizerButtons);\n}", "label": 0, "cwe": null, "length": 547 }, { "index": 766547, "code": "Pairpool_push_gapholder (List_T list, T this, int queryjump, int genomejump, bool knownp) {\n List_T listcell;\n Pair_T pair;\n List_T p;\n int n;\n\n if (this->pairctr >= this->npairs) {\n this->pairptr = add_new_pairchunk(this);\n } else if ((this->pairctr % CHUNKSIZE) == 0) {\n for (n = this->npairs - CHUNKSIZE, p = this->pairchunks;\n\t n > this->pairctr; p = p->rest, n -= CHUNKSIZE) ;\n this->pairptr = (struct Pair_T *) p->first;\n debug1(printf(\"Located pair %d at %p\\n\",this->pairctr,this->pairptr));\n } \n pair = this->pairptr++;\n this->pairctr++;\n\n pair->querypos = -1;\n pair->genomepos = -1;\n\n pair->aapos = 0;\n pair->aaphase_g = -1;\n pair->aaphase_e = -1;\n pair->cdna = ' ';\n pair->comp = ' ';\n pair->genome = ' ';\n pair->dynprogindex = 0;\n\n pair->aa_g = ' ';\n pair->aa_e = ' ';\n pair->shortexonp = false;\n pair->gapp = true;\n if (knownp == true) {\n pair->knowngapp = true;\n pair->donor_prob = 2.0;\n pair->acceptor_prob = 2.0;\n } else {\n pair->knowngapp = false;\n pair->donor_prob = 0.0;\n pair->acceptor_prob = 0.0;\n }\n pair->extraexonp = false;\n\n pair->queryjump = queryjump;\n pair->genomejump = genomejump;\n\n pair->state = GOOD;\n pair->protectedp = false;\n pair->disallowedp = false;\n pair->end_intron_p = false;\n\n debug(printf(\"Creating gap %p, queryjump=%d, genomejump=%d\\n\",pair,queryjump,genomejump));\n\n if (this->listcellctr >= this->nlistcells) {\n this->listcellptr = add_new_listcellchunk(this);\n } else if ((this->listcellctr % CHUNKSIZE) == 0) {\n for (n = this->nlistcells - CHUNKSIZE, p = this->listcellchunks;\n\t n > this->listcellctr; p = p->rest, n -= CHUNKSIZE) ;\n this->listcellptr = (struct List_T *) p->first;\n debug1(printf(\"Located listcell %d at %p\\n\",this->listcellctr,this->listcellptr));\n }\n listcell = this->listcellptr++;\n this->listcellctr++;\n\n listcell->first = (void *) pair;\n listcell->rest = list;\n\n return listcell;\n}", "label": 0, "cwe": null, "length": 654 }, { "index": 51311, "code": "scif_disconnect_ep(struct scif_endpt *ep)\n{\n\tstruct scifmsg msg;\n\tstruct scif_endpt *fep = NULL;\n\tstruct scif_endpt *tmpep;\n\tstruct list_head *pos, *tmpq;\n\tint err;\n\n\t/*\n\t * Wake up any threads blocked in send()/recv() before closing\n\t * out the connection. Grabbing and releasing the send/recv lock\n\t * will ensure that any blocked senders/receivers have exited for\n\t * Ring 0 endpoints. It is a Ring 0 bug to call send/recv after\n\t * close. Ring 3 endpoints are not affected since close will not\n\t * be called while there are IOCTLs executing.\n\t */\n\twake_up_interruptible(&ep->sendwq);\n\twake_up_interruptible(&ep->recvwq);\n\tmutex_lock(&ep->sendlock);\n\tmutex_unlock(&ep->sendlock);\n\tmutex_lock(&ep->recvlock);\n\tmutex_unlock(&ep->recvlock);\n\n\t/* Remove from the connected list */\n\tmutex_lock(&scif_info.connlock);\n\tlist_for_each_safe(pos, tmpq, &scif_info.connected) {\n\t\ttmpep = list_entry(pos, struct scif_endpt, list);\n\t\tif (tmpep == ep) {\n\t\t\tlist_del(pos);\n\t\t\tfep = tmpep;\n\t\t\tspin_lock(&ep->lock);\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tif (!fep) {\n\t\t/*\n\t\t * The other side has completed the disconnect before\n\t\t * the end point can be removed from the list. Therefore\n\t\t * the ep lock is not locked, traverse the disconnected\n\t\t * list to find the endpoint and release the conn lock.\n\t\t */\n\t\tlist_for_each_safe(pos, tmpq, &scif_info.disconnected) {\n\t\t\ttmpep = list_entry(pos, struct scif_endpt, list);\n\t\t\tif (tmpep == ep) {\n\t\t\t\tlist_del(pos);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tmutex_unlock(&scif_info.connlock);\n\t\treturn NULL;\n\t}\n\n\tinit_completion(&ep->discon);\n\tmsg.uop = SCIF_DISCNCT;\n\tmsg.src = ep->port;\n\tmsg.dst = ep->peer;\n\tmsg.payload[0] = (u64)ep;\n\tmsg.payload[1] = ep->remote_ep;\n\n\terr = scif_nodeqp_send(ep->remote_dev, &msg);\n\tspin_unlock(&ep->lock);\n\tmutex_unlock(&scif_info.connlock);\n\n\tif (!err)\n\t\t/* Wait for the remote node to respond with SCIF_DISCNT_ACK */\n\t\twait_for_completion_timeout(&ep->discon,\n\t\t\t\t\t SCIF_NODE_ALIVE_TIMEOUT);\n\treturn ep;\n}", "label": 0, "cwe": null, "length": 567 }, { "index": 103854, "code": "ruid_child_init (apr_pool_t *p, server_rec *s)\n{\n\tint ncap;\n\tcap_t cap;\n\tcap_value_t capval[4];\n\n\t/* detect default supplementary group IDs */\n\tif ((startup_groupsnr = getgroups(RUID_MAXGROUPS, startup_groups)) == -1) {\n\t\tstartup_groupsnr = 0;\n\t\tap_log_error (APLOG_MARK, APLOG_ERR, 0, NULL, \"%s ERROR getgroups() failed on child init, ignoring supplementary group IDs\", MODULE_NAME);\n\t}\n\n\t/* setup chroot jailbreak */\n\tif (chroot_used == RUID_CHROOT_USED && cap_mode == RUID_CAP_MODE_KEEP) {\n\t\tif ((root_handle = open(\"/.\", O_RDONLY)) < 0) {\n\t\t\troot_handle = UNSET;\n\t\t\tap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, \"%s CRITICAL ERROR opening root file descriptor failed (%s)\", MODULE_NAME, strerror(errno));\n\t\t} else if (fcntl(root_handle, F_SETFD, FD_CLOEXEC) < 0) {\n\t\t\tap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, \"%s CRITICAL ERROR unable to set close-on-exec flag on root file descriptor (%s)\", MODULE_NAME, strerror(errno));\n\t\t\tif (close(root_handle) < 0)\n\t\t\t\tap_log_error (APLOG_MARK, APLOG_ERR, 0, NULL, \"%s CRITICAL ERROR closing root file descriptor (%d) failed\", MODULE_NAME, root_handle);\n\t\t\troot_handle = UNSET;\n\t\t} else {\n\t\t\t/* register cleanup function */\n\t\t\tapr_pool_cleanup_register(p, (void*)((long)root_handle), ruid_child_exit, apr_pool_cleanup_null);\n\t\t}\n\t} else {\n\t\troot_handle = (chroot_used == RUID_CHROOT_USED ? NONE : UNSET);\n\t}\n\n\t/* init cap with all zeros */\n\tcap = cap_init();\n\n\tcapval[0] = CAP_SETUID;\n\tcapval[1] = CAP_SETGID;\n\tncap = 2;\n\tif (mode_stat_used == RUID_MODE_STAT_USED) {\n\t\tcapval[ncap++] = CAP_DAC_READ_SEARCH;\n\t}\n\tif (root_handle != UNSET) {\n\t\tcapval[ncap++] = CAP_SYS_CHROOT;\n\t}\n\tcap_set_flag(cap, CAP_PERMITTED, ncap, capval, CAP_SET);\n\tif (cap_set_proc(cap) != 0) {\n\t\tap_log_error(APLOG_MARK, APLOG_ERR, 0, NULL, \"%s CRITICAL ERROR %s:cap_set_proc failed\", MODULE_NAME, __func__);\n\t}\n\tcap_free(cap);\n\n\t/* check if process is dumpable */\n\tcoredump = prctl(PR_GET_DUMPABLE);\n}", "label": 0, "cwe": null, "length": 588 }, { "index": 410025, "code": "transaction_list_append_archive (gint archive_store_number)\n{\n gint archive_number;\n gulong newsize;\n guint pos;\n CustomRecord *newrecord;\n gint amount_col;\n CustomList *custom_list;\n gint col_archive;\n gint element_date = 0;\n\n custom_list = transaction_model_get_model ();\n\n if ( custom_list == NULL )\n return;\n\n /* get the new number of the first row in the complete list of row */\n pos = custom_list->num_rows;\n /* increase the table of pointer of struct CustomRecord,\n * 1 for the archive */\n custom_list->num_rows = custom_list -> num_rows + 1;\n newsize = custom_list->num_rows * sizeof(CustomRecord*);\n custom_list->rows = g_realloc(custom_list->rows, newsize);\n\n /* increase too the size of visibles rows, either if that row is not visible,\n * it's the only way to be sure to never go throw the end while filtering */\n custom_list->visibles_rows = g_realloc(custom_list->visibles_rows, newsize);\n\n /* create and fill the record */\n newrecord = g_malloc0 (sizeof (CustomRecord));\n\n archive_number = gsb_data_archive_store_get_archive_number (archive_store_number);\n\n if ( find_element_col ( ELEMENT_DATE ) == 0 )\n element_date = find_element_col_for_archive ( );\n\n newrecord -> visible_col[element_date] = gsb_format_gdate (\n gsb_data_archive_get_beginning_date ( archive_number ) );\n\n if ( ( col_archive = find_element_col_for_archive ( ) ) >= 0 )\n newrecord -> visible_col[col_archive] = g_strdup_printf (\n _(\"%s (%d transactions)\"),\n gsb_data_archive_get_name (archive_number),\n gsb_data_archive_store_get_transactions_number (\n archive_store_number ) );\n\n if ((gsb_data_archive_store_get_balance (archive_store_number)).mantissa < 0)\n amount_col = find_element_col (ELEMENT_DEBIT);\n else\n amount_col = find_element_col (ELEMENT_CREDIT);\n\n newrecord -> visible_col[amount_col] = gsb_real_get_string_with_currency (\n gsb_data_archive_store_get_balance (archive_store_number),\n gsb_data_account_get_currency (\n gsb_data_archive_store_get_account_number ( archive_store_number ) ),\n TRUE);\n newrecord -> transaction_pointer = gsb_data_archive_store_get_structure (\n archive_store_number);\n newrecord -> what_is_line = IS_ARCHIVE;\n newrecord -> row_bg = &archive_background_color;\n\n /* save the newrecord pointer */\n custom_list->rows[pos] = newrecord;\n /* and the pos (number) of the row */\n newrecord->pos = pos;\n}", "label": 0, "cwe": null, "length": 584 }, { "index": 745946, "code": "assign_varying_locations(struct gl_context *ctx,\n\t\t\t struct gl_shader_program *prog,\n\t\t\t gl_shader *producer, gl_shader *consumer)\n{\n /* FINISHME: Set dynamically when geometry shader support is added. */\n unsigned output_index = VERT_RESULT_VAR0;\n unsigned input_index = FRAG_ATTRIB_VAR0;\n\n /* Operate in a total of three passes.\n *\n * 1. Assign locations for any matching inputs and outputs.\n *\n * 2. Mark output variables in the producer that do not have locations as\n * not being outputs. This lets the optimizer eliminate them.\n *\n * 3. Mark input variables in the consumer that do not have locations as\n * not being inputs. This lets the optimizer eliminate them.\n */\n\n invalidate_variable_locations(producer, ir_var_out, VERT_RESULT_VAR0);\n invalidate_variable_locations(consumer, ir_var_in, FRAG_ATTRIB_VAR0);\n\n foreach_list(node, producer->ir) {\n ir_variable *const output_var = ((ir_instruction *) node)->as_variable();\n\n if ((output_var == NULL) || (output_var->mode != ir_var_out)\n\t || (output_var->location != -1))\n\t continue;\n\n ir_variable *const input_var =\n\t consumer->symbols->get_variable(output_var->name);\n\n if ((input_var == NULL) || (input_var->mode != ir_var_in))\n\t continue;\n\n assert(input_var->location == -1);\n\n output_var->location = output_index;\n input_var->location = input_index;\n\n /* FINISHME: Support for \"varying\" records in GLSL 1.50. */\n assert(!output_var->type->is_record());\n\n if (output_var->type->is_array()) {\n\t const unsigned slots = output_var->type->length\n\t * output_var->type->fields.array->matrix_columns;\n\n\t output_index += slots;\n\t input_index += slots;\n } else {\n\t const unsigned slots = output_var->type->matrix_columns;\n\n\t output_index += slots;\n\t input_index += slots;\n }\n }\n\n unsigned varying_vectors = 0;\n\n foreach_list(node, consumer->ir) {\n ir_variable *const var = ((ir_instruction *) node)->as_variable();\n\n if ((var == NULL) || (var->mode != ir_var_in))\n\t continue;\n\n if (var->location == -1) {\n\t if (prog->Version <= 120) {\n\t /* On page 25 (page 31 of the PDF) of the GLSL 1.20 spec:\n\t *\n\t * Only those varying variables used (i.e. read) in\n\t * the fragment shader executable must be written to\n\t * by the vertex shader executable; declaring\n\t * superfluous varying variables in a vertex shader is\n\t * permissible.\n\t *\n\t * We interpret this text as meaning that the VS must\n\t * write the variable for the FS to read it. See\n\t * \"glsl1-varying read but not written\" in piglit.\n\t */\n\n\t linker_error(prog, \"fragment shader varying %s not written \"\n\t\t\t \"by vertex shader\\n.\", var->name);\n\t }\n\n\t /* An 'in' variable is only really a shader input if its\n\t * value is written by the previous stage.\n\t */\n\t var->mode = ir_var_auto;\n } else {\n\t /* The packing rules are used for vertex shader inputs are also used\n\t * for fragment shader inputs.\n\t */\n\t varying_vectors += count_attribute_slots(var->type);\n }\n }\n\n if (ctx->API == API_OPENGLES2 || prog->Version == 100) {\n if (varying_vectors > ctx->Const.MaxVarying) {\n\t linker_error(prog, \"shader uses too many varying vectors \"\n\t\t \"(%u > %u)\\n\",\n\t\t varying_vectors, ctx->Const.MaxVarying);\n\t return false;\n }\n } else {\n const unsigned float_components = varying_vectors * 4;\n if (float_components > ctx->Const.MaxVarying * 4) {\n\t linker_error(prog, \"shader uses too many varying components \"\n\t\t \"(%u > %u)\\n\",\n\t\t float_components, ctx->Const.MaxVarying * 4);\n\t return false;\n }\n }\n\n return true;\n}", "label": 0, "cwe": null, "length": 928 }, { "index": 12090, "code": "_matchFromSet(const UChar *string, const UChar *matchSet, UBool polarity) {\n int32_t matchLen, matchBMPLen, strItr, matchItr;\n UChar32 stringCh, matchCh;\n UChar c, c2;\n\n /* first part of matchSet contains only BMP code points */\n matchBMPLen = 0;\n while((c = matchSet[matchBMPLen]) != 0 && U16_IS_SINGLE(c)) {\n ++matchBMPLen;\n }\n\n /* second part of matchSet contains BMP and supplementary code points */\n matchLen = matchBMPLen;\n while(matchSet[matchLen] != 0) {\n ++matchLen;\n }\n\n for(strItr = 0; (c = string[strItr]) != 0;) {\n ++strItr;\n if(U16_IS_SINGLE(c)) {\n if(polarity) {\n for(matchItr = 0; matchItr < matchLen; ++matchItr) {\n if(c == matchSet[matchItr]) {\n return strItr - 1; /* one matches */\n }\n }\n } else {\n for(matchItr = 0; matchItr < matchLen; ++matchItr) {\n if(c == matchSet[matchItr]) {\n goto endloop;\n }\n }\n return strItr - 1; /* none matches */\n }\n } else {\n /*\n * No need to check for string length before U16_IS_TRAIL\n * because c2 could at worst be the terminating NUL.\n */\n if(U16_IS_SURROGATE_LEAD(c) && U16_IS_TRAIL(c2 = string[strItr])) {\n ++strItr;\n stringCh = U16_GET_SUPPLEMENTARY(c, c2);\n } else {\n stringCh = c; /* unpaired trail surrogate */\n }\n\n if(polarity) {\n for(matchItr = matchBMPLen; matchItr < matchLen;) {\n U16_NEXT(matchSet, matchItr, matchLen, matchCh);\n if(stringCh == matchCh) {\n return strItr - U16_LENGTH(stringCh); /* one matches */\n }\n }\n } else {\n for(matchItr = matchBMPLen; matchItr < matchLen;) {\n U16_NEXT(matchSet, matchItr, matchLen, matchCh);\n if(stringCh == matchCh) {\n goto endloop;\n }\n }\n return strItr - U16_LENGTH(stringCh); /* none matches */\n }\n }\nendloop:\n /* wish C had continue with labels like Java... */;\n }\n\n /* Didn't find it. */\n return -strItr-1;\n}", "label": 0, "cwe": null, "length": 603 }, { "index": 906148, "code": "__ecereMethod___ecereNameSpace__ecere__gfx__ColorDropBox_NotifyTextEntry(struct __ecereNameSpace__ecere__com__Instance * this, struct __ecereNameSpace__ecere__com__Instance * colorDropBox, char * string, unsigned int save)\n{\nstruct __ecereNameSpace__ecere__gui__controls__DataBox * __ecerePointer___ecereNameSpace__ecere__gui__controls__DataBox = (struct __ecereNameSpace__ecere__gui__controls__DataBox *)(this ? (((char *)this) + __ecereClass___ecereNameSpace__ecere__gui__controls__DataBox->offset) : 0);\n\nif(save)\n{\nunsigned int color = 0;\n\nif(((unsigned int (*)(struct __ecereNameSpace__ecere__com__Class *, void *, char * string))__ecereClass___ecereNameSpace__ecere__gfx__Color->_vTbl[__ecereVMethodID_class_OnGetDataFromString])(__ecereClass___ecereNameSpace__ecere__gfx__Color, &color, string))\n((void (*)(struct __ecereNameSpace__ecere__com__Instance *, void * newData, unsigned int closingDropDown))__extension__ ({\nstruct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = this;\n\n__internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__gui__controls__DataBox->_vTbl;\n})[__ecereVMethodID___ecereNameSpace__ecere__gui__controls__DataBox_SetData])(this, &color, 0x0);\n}\nelse\n{\nchar tempString[1024] = \"\";\nunsigned int needClass = 0x0;\nchar * string = ((char * (*)(struct __ecereNameSpace__ecere__com__Class *, void *, char * tempString, void * fieldData, unsigned int * needClass))__ecereClass___ecereNameSpace__ecere__gfx__Color->_vTbl[__ecereVMethodID_class_OnGetString])(__ecereClass___ecereNameSpace__ecere__gfx__Color, &((struct __ecereNameSpace__ecere__gfx__ColorDropBox *)(((char *)colorDropBox + __ecereClass___ecereNameSpace__ecere__gfx__ColorDropBox->offset)))->color, tempString, (((void *)0)), &needClass);\n\n__ecereProp___ecereNameSpace__ecere__gui__controls__DropBox_Set_contents(colorDropBox, string);\n}\nreturn 0x1;\n}", "label": 0, "cwe": null, "length": 575 }, { "index": 363776, "code": "listSort(List root, int (*cmp)(const void*, const void*))\n{\n List p, q, e, tail;\n List list = listBegin(root);\n int insize, nmerges, psize, qsize, i;\n\n /*\n * Silly special case: if `list' was passed in as NULL, return\n * NULL immediately.\n */\n if (!list)\n return;\n\n insize = 1;\n\n while (1) {\n p = list;\n list = NULL;\n tail = NULL;\n\n nmerges = 0; /* count number of merges we do in this pass */\n\n while (p) {\n ++nmerges; /* there exists a merge to be done */\n /* step `insize' places along from p */\n q = p;\n psize = 0;\n for (i = 0; i < insize && q; ++i) {\n ++psize;\n q = listNext(q);\n }\n\n /* if q hasn't fallen off end, we have two lists to merge */\n qsize = insize;\n\n /* now we have two lists; merge them */\n while (psize > 0 || (qsize > 0 && q)) {\n\n /* decide whether next element of merge comes from p or q */\n if (psize == 0) {\n /* p is empty; e must come from q. */\n e = q; q = listNext(q); --qsize;\n } else if (qsize == 0 || !q) {\n /* q is empty; e must come from p. */\n e = p; p = listNext(p); --psize;\n } else if (cmp(p->v,q->v) <= 0) {\n /* First element of p is lower (or same);\n * e must come from p. */\n e = p; p = listNext(p); --psize;\n } else {\n /* First element of q is lower; e must come from q. */\n e = q; q = listNext(q); --qsize;\n }\n\n /* add the next element to the merged list */\n if (tail) {\n tail->n = e;\n } else {\n list = e;\n }\n e->p = tail;\n tail = e;\n }\n\n /* now p has stepped `insize' places along, and q has too */\n p = q;\n }\n tail->n = NULL;\n\n /* If we have done only one merge, we're finished. */\n if (nmerges <= 1) { /* allow for nmerges==0, the empty list case */\n List iterator;\n root->n = list;\n for (iterator = root->n; iterator->n != NULL; iterator = listNext(iterator))\n ;\n root->p = iterator;\n return;\n }\n\n /* Otherwise repeat, merging lists twice the size */\n insize *= 2;\n }\n}", "label": 0, "cwe": null, "length": 645 }, { "index": 676323, "code": "__ecereMethod___ecereNameSpace__eda__TableEditor_ProcessWordListString(struct __ecereNameSpace__ecere__com__Instance * this, char * string, int method, unsigned int id)\n{\nstruct __ecereNameSpace__eda__TableEditor * __ecerePointer___ecereNameSpace__eda__TableEditor = (struct __ecereNameSpace__eda__TableEditor *)(this ? (((char *)this) + __ecereClass___ecereNameSpace__eda__TableEditor->offset) : 0);\nint c;\nunsigned int ch;\nunsigned int lastCh = 0;\nint count = 0;\nint numChars = 0;\nint nb;\nchar word[1024];\nchar asciiWord[1024];\n\nfor(c = 0; ; c += nb)\n{\nch = __ecereFunction___ecereNameSpace__ecere__sys__UTF8GetChar(string + c, &nb);\nif(!ch || __ecereFunction___ecereNameSpace__ecere__sys__CharMatchCategories(ch, 0x380) || (count && __ecereFunction___ecereNameSpace__ecere__sys__CharMatchCategories(ch, 0xF8000 | 0x70 | 0xE | 0x100000) != __ecereFunction___ecereNameSpace__ecere__sys__CharMatchCategories(lastCh, 0xF8000 | 0x70 | 0xE | 0x100000)))\n{\nif(count)\n{\nword[count] = (char)0;\nasciiWord[numChars] = (char)0;\nstrlwr(word);\nstrlwr(asciiWord);\n__ecereMethod___ecereNameSpace__eda__TableEditor_AddWord(this, word, count, method == 1, id);\nif(count > numChars)\n__ecereMethod___ecereNameSpace__eda__TableEditor_AddWord(this, asciiWord, strlen(asciiWord), method == 1, id);\ncount = 0;\nnumChars = 0;\n}\nif(!__ecereFunction___ecereNameSpace__ecere__sys__CharMatchCategories(ch, 0x380))\n{\nint cc;\n\nfor(cc = 0; cc < nb; cc++)\nword[count++] = string[c + cc];\nasciiWord[numChars++] = __ecereNameSpace__eda__ToASCII(ch);\n}\nif(!ch)\nbreak;\n}\nelse\n{\nint cc;\n\nfor(cc = 0; cc < nb; cc++)\nword[count++] = string[c + cc];\nasciiWord[numChars++] = __ecereNameSpace__eda__ToASCII(ch);\n}\nlastCh = ch;\n}\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 565 }, { "index": 808322, "code": "VasySimplifyMarkRead( RtlFigure )\n\n rtlfig_list *RtlFigure;\n{\n rtldecl_list *RtlDeclar;\n rtlport_list *RtlPort;\n rtlsym *RtlSymbol;\n rtlasg_list *RtlAsg;\n rtlbivex_list *ScanBiVex;\n rtlins_list *RtlInst;\n rtlmap_list *RtlMap;\n vexexpr *VexAtom;\n char *AtomName;\n int VexMin;\n int VexMax;\n int VexIndex;\n\n for ( RtlAsg = RtlFigure->ASSIGN;\n RtlAsg != (rtlasg_list *)0;\n RtlAsg = RtlAsg->NEXT )\n {\n VexAtom = RtlAsg->VEX_ATOM;\n AtomName = GetVexAtomValue( VexAtom );\n RtlDeclar = searchrtldecl( RtlFigure, AtomName );\n\n SetVasyRtlDeclarAsg( RtlDeclar ); \n\n VexMin = getvexvectormin( VexAtom );\n VexMax = getvexvectormax( VexAtom );\n\n for ( VexIndex = VexMin; VexIndex <= VexMax; VexIndex++ )\n {\n RtlSymbol = getrtlsymdecl( RtlDeclar, VexIndex );\n SetVasyRtlDeclarAsg( RtlSymbol );\n }\n\n VasySimplifyMarkReadVex( RtlAsg->VEX_DATA );\n\n for ( ScanBiVex = RtlAsg->BIVEX;\n ScanBiVex != (rtlbivex_list *)0;\n ScanBiVex = ScanBiVex->NEXT )\n {\n VasySimplifyMarkReadVex( ScanBiVex->VEX_COND );\n VasySimplifyMarkReadVex( ScanBiVex->VEX_DATA );\n }\n }\n\n for ( RtlInst = RtlFigure->INSTANCE;\n RtlInst != (rtlins_list *)0;\n RtlInst = RtlInst->NEXT )\n {\n for ( RtlMap = RtlInst->MAP;\n RtlMap != (rtlmap_list *)0;\n RtlMap = RtlMap->NEXT )\n {\n VexAtom = RtlMap->VEX_FORMAL;\n\n if ( IsVexNodeAtom( VexAtom ) )\n {\n AtomName = GetVexAtomValue( VexAtom );\n RtlPort = searchrtlmodport( RtlFigure, RtlInst->MODEL, AtomName );\n\n if ( RtlPort->DIR != RTL_DIR_OUT )\n {\n VasySimplifyMarkReadVex( RtlMap->VEX_ACTUAL );\n }\n\n if ( RtlPort->DIR != RTL_DIR_IN )\n {\n VasySimplifyMarkWriteVex( RtlMap->VEX_ACTUAL );\n }\n }\n }\n }\n}", "label": 0, "cwe": null, "length": 679 }, { "index": 476895, "code": "gtk_plot_data_get_gradient_level (GtkPlotData *data, gdouble level, GdkColor *color)\n{\n GdkColor min, max;\n gdouble red, green, blue;\n gdouble h, s, v;\n gdouble h1, s1, v1;\n gdouble h2, s2, v2;\n gdouble value;\n GtkPlotTicks *ticks = &data->gradient->ticks;\n gint i;\n gint start;\n gint end = ticks->nticks;\n\n min = data->color_min;\n max = data->color_max;\n\n if(level > ticks->max) { *color = data->color_gt_max; return; }\n if(level < ticks->min) { *color = data->color_lt_min; return; }\n\n start = ticks->scale == GTK_PLOT_SCALE_LINEAR ? (level - ticks->min) / (ticks->max - ticks->min) * ticks->nticks : 0;\n\n if(data->gradient_custom){\n for(i = MAX(start-2,0); i < end; i++){\n if(level > ticks->values[i].value && level <= ticks->values[i+1].value)\n {\n *color = data->gradient_colors[i];\n return;\n }\n }\n *color = data->color_gt_max;\n return;\n }\n\n/*\n value = -1;\n for(i = MAX(start-2,0); i < end; i++){\n if(level > ticks->values[i].value && level <= ticks->values[i+1].value)\n {\n value = (gdouble)i/(gdouble)end;\n break;\n }\n }\n if(value == -1) value = 1.;\n*/\n\n value = gtk_plot_axis_ticks_transform(data->gradient, level);\n\n\n red = min.red;\n green = min.green;\n blue = min.blue;\n rgb_to_hsv(red, green, blue, &h1, &s1, &v1);\n red = max.red;\n green = max.green;\n blue = max.blue;\n rgb_to_hsv(red, green, blue, &h2, &s2, &v2);\n\n s = MAX(s2,s1);\n v = MAX(v2,v1);\n h = MAX(h2,h1);\n if(data->gradient_mask & GTK_PLOT_GRADIENT_S)\n s = s1 + (s2 - s1) * value;\n if(data->gradient_mask & GTK_PLOT_GRADIENT_V)\n v = v1 + (v2 - v1) * value;\n if(data->gradient_mask & GTK_PLOT_GRADIENT_H)\n h = h1 + (h2 - h1) * value;\n\n hsv_to_rgb(h, MIN(s, 1.0), MIN(v, 1.0), &red, &green, &blue);\n color->red = red;\n color->green = green;\n color->blue = blue;\n gdk_color_alloc(gtk_widget_get_colormap(GTK_WIDGET(data)), color);\n}", "label": 0, "cwe": null, "length": 653 }, { "index": 88143, "code": "pg_get_encoding_from_locale(const char *ctype, bool write_message)\n{\n\tchar\t *sys;\n\tint\t\t\ti;\n\n\t/* Get the CODESET property, and also LC_CTYPE if not passed in */\n\tif (ctype)\n\t{\n\t\tchar\t *save;\n\t\tchar\t *name;\n\n\t\t/* If locale is C or POSIX, we can allow all encodings */\n\t\tif (pg_strcasecmp(ctype, \"C\") == 0 ||\n\t\t\tpg_strcasecmp(ctype, \"POSIX\") == 0)\n\t\t\treturn PG_SQL_ASCII;\n\n\t\tsave = setlocale(LC_CTYPE, NULL);\n\t\tif (!save)\n\t\t\treturn -1;\t\t\t/* setlocale() broken? */\n\t\t/* must copy result, or it might change after setlocale */\n\t\tsave = strdup(save);\n\t\tif (!save)\n\t\t\treturn -1;\t\t\t/* out of memory; unlikely */\n\n\t\tname = setlocale(LC_CTYPE, ctype);\n\t\tif (!name)\n\t\t{\n\t\t\tfree(save);\n\t\t\treturn -1;\t\t\t/* bogus ctype passed in? */\n\t\t}\n\n#ifndef WIN32\n\t\tsys = nl_langinfo(CODESET);\n\t\tif (sys)\n\t\t\tsys = strdup(sys);\n#else\n\t\tsys = win32_langinfo(name);\n#endif\n\n\t\tsetlocale(LC_CTYPE, save);\n\t\tfree(save);\n\t}\n\telse\n\t{\n\t\t/* much easier... */\n\t\tctype = setlocale(LC_CTYPE, NULL);\n\t\tif (!ctype)\n\t\t\treturn -1;\t\t\t/* setlocale() broken? */\n\n\t\t/* If locale is C or POSIX, we can allow all encodings */\n\t\tif (pg_strcasecmp(ctype, \"C\") == 0 ||\n\t\t\tpg_strcasecmp(ctype, \"POSIX\") == 0)\n\t\t\treturn PG_SQL_ASCII;\n\n#ifndef WIN32\n\t\tsys = nl_langinfo(CODESET);\n\t\tif (sys)\n\t\t\tsys = strdup(sys);\n#else\n\t\tsys = win32_langinfo(ctype);\n#endif\n\t}\n\n\tif (!sys)\n\t\treturn -1;\t\t\t\t/* out of memory; unlikely */\n\n\t/* Check the table */\n\tfor (i = 0; encoding_match_list[i].system_enc_name; i++)\n\t{\n\t\tif (pg_strcasecmp(sys, encoding_match_list[i].system_enc_name) == 0)\n\t\t{\n\t\t\tfree(sys);\n\t\t\treturn encoding_match_list[i].pg_enc_code;\n\t\t}\n\t}\n\n\t/* Special-case kluges for particular platforms go here */\n\n#ifdef __darwin__\n\n\t/*\n\t * Current OS X has many locales that report an empty string for CODESET,\n\t * but they all seem to actually use UTF-8.\n\t */\n\tif (strlen(sys) == 0)\n\t{\n\t\tfree(sys);\n\t\treturn PG_UTF8;\n\t}\n#endif\n\n\t/*\n\t * We print a warning if we got a CODESET string but couldn't recognize\n\t * it.\tThis means we need another entry in the table.\n\t */\n\tif (write_message)\n\t{\n#ifdef FRONTEND\n\t\tfprintf(stderr, _(\"could not determine encoding for locale \\\"%s\\\": codeset is \\\"%s\\\"\"),\n\t\t\t\tctype, sys);\n\t\t/* keep newline separate so there's only one translatable string */\n\t\tfputc('\\n', stderr);\n#else\n\t\tereport(WARNING,\n\t\t\t\t(errmsg(\"could not determine encoding for locale \\\"%s\\\": codeset is \\\"%s\\\"\",\n\t\t\t\t\t\tctype, sys),\n\t\t errdetail(\"Please report this to .\")));\n#endif\n\t}\n\n\tfree(sys);\n\treturn -1;\n}", "label": 0, "cwe": null, "length": 746 }, { "index": 456691, "code": "gst_audio_decoder_handle_gap (GstAudioDecoder * dec, GstEvent * event)\n{\n gboolean ret;\n GstClockTime timestamp, duration;\n\n /* Check if there is a caps pending to be pushed */\n if (G_UNLIKELY (dec->priv->do_caps)) {\n if (!gst_audio_decoder_do_caps (dec)) {\n goto not_negotiated;\n }\n }\n\n /* Ensure we have caps first */\n GST_AUDIO_DECODER_STREAM_LOCK (dec);\n if (!GST_AUDIO_INFO_IS_VALID (&dec->priv->ctx.info)) {\n if (!gst_audio_decoder_negotiate_default_caps (dec)) {\n GST_ELEMENT_ERROR (dec, STREAM, FORMAT, (NULL),\n (\"Decoder output not negotiated before GAP event.\"));\n GST_AUDIO_DECODER_STREAM_UNLOCK (dec);\n return FALSE;\n }\n }\n GST_AUDIO_DECODER_STREAM_UNLOCK (dec);\n\n gst_event_parse_gap (event, ×tamp, &duration);\n\n /* time progressed without data, see if we can fill the gap with\n * some concealment data */\n GST_DEBUG_OBJECT (dec,\n \"gap event: plc %d, do_plc %d, position %\" GST_TIME_FORMAT\n \" duration %\" GST_TIME_FORMAT,\n dec->priv->plc, dec->priv->ctx.do_plc,\n GST_TIME_ARGS (timestamp), GST_TIME_ARGS (duration));\n\n if (dec->priv->plc && dec->priv->ctx.do_plc && dec->input_segment.rate > 0.0) {\n GstAudioDecoderClass *klass = GST_AUDIO_DECODER_GET_CLASS (dec);\n GstBuffer *buf;\n\n /* hand subclass empty frame with duration that needs covering */\n buf = gst_buffer_new ();\n GST_BUFFER_TIMESTAMP (buf) = timestamp;\n GST_BUFFER_DURATION (buf) = duration;\n /* best effort, not much error handling */\n gst_audio_decoder_handle_frame (dec, klass, buf);\n ret = TRUE;\n gst_event_unref (event);\n } else {\n GstFlowReturn flowret;\n\n /* sub-class doesn't know how to handle empty buffers,\n * so just try sending GAP downstream */\n flowret = check_pending_reconfigure (dec);\n if (flowret == GST_FLOW_OK) {\n send_pending_events (dec);\n ret = gst_audio_decoder_push_event (dec, event);\n } else {\n ret = FALSE;\n }\n }\n return ret;\n\n /* ERRORS */\nnot_negotiated:\n {\n GST_ELEMENT_ERROR (dec, CORE, NEGOTIATION, (NULL),\n (\"decoder not initialized\"));\n return FALSE;\n }\n}", "label": 0, "cwe": null, "length": 554 }, { "index": 548499, "code": "run_scc_vn (vn_lookup_kind default_vn_walk_kind_)\n{\n size_t i;\n tree param;\n bool changed = true;\n\n default_vn_walk_kind = default_vn_walk_kind_;\n\n init_scc_vn ();\n current_info = valid_info;\n\n for (param = DECL_ARGUMENTS (current_function_decl);\n param;\n param = DECL_CHAIN (param))\n {\n if (gimple_default_def (cfun, param) != NULL)\n\t{\n\t tree def = gimple_default_def (cfun, param);\n\t VN_INFO (def)->valnum = def;\n\t}\n }\n\n for (i = 1; i < num_ssa_names; ++i)\n {\n tree name = ssa_name (i);\n if (name\n\t && VN_INFO (name)->visited == false\n\t && !has_zero_uses (name))\n\tif (!DFS (name))\n\t {\n\t free_scc_vn ();\n\t return false;\n\t }\n }\n\n /* Initialize the value ids. */\n\n for (i = 1; i < num_ssa_names; ++i)\n {\n tree name = ssa_name (i);\n vn_ssa_aux_t info;\n if (!name)\n\tcontinue;\n info = VN_INFO (name);\n if (info->valnum == name\n\t || info->valnum == VN_TOP)\n\tinfo->value_id = get_next_value_id ();\n else if (is_gimple_min_invariant (info->valnum))\n\tinfo->value_id = get_or_alloc_constant_value_id (info->valnum);\n }\n\n /* Propagate until they stop changing. */\n while (changed)\n {\n changed = false;\n for (i = 1; i < num_ssa_names; ++i)\n\t{\n\t tree name = ssa_name (i);\n\t vn_ssa_aux_t info;\n\t if (!name)\n\t continue;\n\t info = VN_INFO (name);\n\t if (TREE_CODE (info->valnum) == SSA_NAME\n\t && info->valnum != name\n\t && info->value_id != VN_INFO (info->valnum)->value_id)\n\t {\n\t changed = true;\n\t info->value_id = VN_INFO (info->valnum)->value_id;\n\t }\n\t}\n }\n\n set_hashtable_value_ids ();\n\n if (dump_file && (dump_flags & TDF_DETAILS))\n {\n fprintf (dump_file, \"Value numbers:\\n\");\n for (i = 0; i < num_ssa_names; i++)\n\t{\n\t tree name = ssa_name (i);\n\t if (name\n\t && VN_INFO (name)->visited\n\t && SSA_VAL (name) != name)\n\t {\n\t print_generic_expr (dump_file, name, 0);\n\t fprintf (dump_file, \" = \");\n\t print_generic_expr (dump_file, SSA_VAL (name), 0);\n\t fprintf (dump_file, \"\\n\");\n\t }\n\t}\n }\n\n return true;\n}", "label": 0, "cwe": null, "length": 635 }, { "index": 196022, "code": "Curl_disconnect(struct connectdata *conn, bool dead_connection)\n{\n struct SessionHandle *data;\n if(!conn)\n return CURLE_OK; /* this is closed and fine already */\n data = conn->data;\n\n if(!data) {\n DEBUGF(fprintf(stderr, \"DISCONNECT without easy handle, ignoring\\n\"));\n return CURLE_OK;\n }\n\n if(conn->dns_entry != NULL) {\n Curl_resolv_unlock(data, conn->dns_entry);\n conn->dns_entry = NULL;\n }\n\n Curl_hostcache_prune(data); /* kill old DNS cache entries */\n\n {\n int has_host_ntlm = (conn->ntlm.state != NTLMSTATE_NONE);\n int has_proxy_ntlm = (conn->proxyntlm.state != NTLMSTATE_NONE);\n\n /* Authentication data is a mix of connection-related and sessionhandle-\n related stuff. NTLM is connection-related so when we close the shop\n we shall forget. */\n\n if(has_host_ntlm) {\n data->state.authhost.done = FALSE;\n data->state.authhost.picked =\n data->state.authhost.want;\n }\n\n if(has_proxy_ntlm) {\n data->state.authproxy.done = FALSE;\n data->state.authproxy.picked =\n data->state.authproxy.want;\n }\n\n if(has_host_ntlm || has_proxy_ntlm)\n data->state.authproblem = FALSE;\n }\n\n /* Cleanup NTLM connection-related data */\n Curl_http_ntlm_cleanup(conn);\n\n /* Cleanup possible redirect junk */\n if(data->req.newurl) {\n free(data->req.newurl);\n data->req.newurl = NULL;\n }\n\n if(conn->handler->disconnect)\n /* This is set if protocol-specific cleanups should be made */\n conn->handler->disconnect(conn, dead_connection);\n\n /* unlink ourselves! */\n infof(data, \"Closing connection %ld\\n\", conn->connection_id);\n Curl_conncache_remove_conn(data->state.conn_cache, conn);\n\n#if defined(USE_LIBIDN)\n if(conn->host.encalloc)\n idn_free(conn->host.encalloc); /* encoded host name buffer, must be freed\n with idn_free() since this was allocated\n by libidn */\n if(conn->proxy.encalloc)\n idn_free(conn->proxy.encalloc); /* encoded proxy name buffer, must be\n freed with idn_free() since this was\n allocated by libidn */\n#elif defined(USE_WIN32_IDN)\n free(conn->host.encalloc); /* encoded host name buffer, must be freed with\n idn_free() since this was allocated by\n curl_win32_idn_to_ascii */\n if(conn->proxy.encalloc)\n free(conn->proxy.encalloc); /* encoded proxy name buffer, must be freed\n with idn_free() since this was allocated by\n curl_win32_idn_to_ascii */\n#endif\n\n Curl_ssl_close(conn, FIRSTSOCKET);\n\n /* Indicate to all handles on the pipe that we're dead */\n if(Curl_multi_pipeline_enabled(data->multi)) {\n signalPipeClose(conn->send_pipe, TRUE);\n signalPipeClose(conn->recv_pipe, TRUE);\n }\n\n conn_free(conn);\n\n Curl_speedinit(data);\n\n return CURLE_OK;\n}", "label": 0, "cwe": null, "length": 697 }, { "index": 368081, "code": "rb_str_inspect(str)\n VALUE str;\n{\n char *p, *pend;\n VALUE result = rb_str_buf_new2(\"\\\"\");\n char s[5];\n\n p = RSTRING(str)->ptr; pend = p + RSTRING(str)->len;\n while (p < pend) {\n\tchar c = *p++;\n\tif (ismbchar(c) && p < pend) {\n\t int len = mbclen(c);\n\t rb_str_buf_cat(result, p - 1, len);\n\t p += len - 1;\n\t}\n\telse if (c == '\"'|| c == '\\\\' || (c == '#' && IS_EVSTR(p, pend))) {\n\t s[0] = '\\\\'; s[1] = c;\n\t rb_str_buf_cat(result, s, 2);\n\t}\n\telse if (ISPRINT(c)) {\n\t s[0] = c;\n\t rb_str_buf_cat(result, s, 1);\n\t}\n\telse if (c == '\\n') {\n\t s[0] = '\\\\'; s[1] = 'n';\n\t rb_str_buf_cat(result, s, 2);\n\t}\n\telse if (c == '\\r') {\n\t s[0] = '\\\\'; s[1] = 'r';\n\t rb_str_buf_cat(result, s, 2);\n\t}\n\telse if (c == '\\t') {\n\t s[0] = '\\\\'; s[1] = 't';\n\t rb_str_buf_cat(result, s, 2);\n\t}\n\telse if (c == '\\f') {\n\t s[0] = '\\\\'; s[1] = 'f';\n\t rb_str_buf_cat(result, s, 2);\n\t}\n\telse if (c == '\\013') {\n\t s[0] = '\\\\'; s[1] = 'v';\n\t rb_str_buf_cat(result, s, 2);\n\t}\n\telse if (c == '\\007') {\n\t s[0] = '\\\\'; s[1] = 'a';\n\t rb_str_buf_cat(result, s, 2);\n\t}\n\telse if (c == 033) {\n\t s[0] = '\\\\'; s[1] = 'e';\n\t rb_str_buf_cat(result, s, 2);\n\t}\n\telse {\n\t sprintf(s, \"\\\\%03o\", c & 0377);\n\t rb_str_buf_cat2(result, s);\n\t}\n }\n rb_str_buf_cat2(result, \"\\\"\");\n\n OBJ_INFECT(result, str);\n return result;\n}", "label": 0, "cwe": null, "length": 526 }, { "index": 694895, "code": "ajSysExecOutnameErrAppendC(const char* cmdlinetxt,\n const char* outfnametxt)\n{\n#ifndef WIN32\n pid_t pid;\n pid_t retval;\n ajint status = 0;\n char *pgm;\n char **argptr;\n ajint i;\n int id;\n\n AjPStr pname = NULL;\n\n if(!ajSysArglistBuildC(cmdlinetxt, &pgm, &argptr))\n\treturn -1;\n\n pname = ajStrNew();\n\n ajStrAssignC(&pname, pgm);\n\n if(!ajSysFileWhich(&pname))\n\tajFatal(\"cannot find program '%S'\", pname);\n\n fflush(stdout);\n\n pid=fork();\n\n if(pid==-1)\n\tajFatal(\"System fork failed\");\n\n if(pid)\n {\n\twhile((retval=waitpid(pid,&status,0))!=pid)\n\t{\n\t if(retval == -1)\n\t\tif(errno != EINTR)\n\t\t break;\n\t}\n }\n else\n {\n\t/* this is the child process */\n\n\tif(!freopen(outfnametxt, \"ab\", stdout))\n\t ajErr(\"Failed to redirect standard output and error to '%s'\",\n outfnametxt);\n close(STDERR_FILENO);\n id = dup(fileno(stdout));\n if(id < 0)\n ajErr(\"Failed to duplicate file descriptor stdout, error:%d %s\",\n errno, strerror(errno));\n\texecv(ajStrGetPtr(pname), argptr);\n\tajExitAbort();\t\t\t/* just in case */\n }\n\n ajStrDel(&pname);\n\n i = 0;\n while(argptr[i])\n {\n\tAJFREE(argptr[i]);\n\t++i;\n }\n AJFREE(argptr);\n\n AJFREE(pgm);\n\n#else\n\n PROCESS_INFORMATION pinf;\n STARTUPINFO si;\n HANDLE fp;\n SECURITY_ATTRIBUTES sa;\n ajint status = -1;\n\n ajDebug (\"Launching process '%s'\\n\", cmdlinetxt);\n \n ZeroMemory(&si, sizeof(si));\n si.cb = sizeof(si);\n si.dwFlags |= STARTF_USESTDHANDLES;\n\n\n sa.nLength = sizeof(SECURITY_ATTRIBUTES);\n sa.bInheritHandle = TRUE;\n sa.lpSecurityDescriptor = NULL;\n\n fp = CreateFile(TEXT(outfnametxt), GENERIC_WRITE, 0 , &sa,\n\t\t OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);\n\n if(fp == INVALID_HANDLE_VALUE)\n ajFatal(\"Cannot open file %s\\n\",outfnametxt);\n\n SetFilePointer(fp, 0, NULL, FILE_END);\n\n si.hStdOutput = fp;\n si.hStdInput = GetStdHandle(STD_INPUT_HANDLE);\n si.hStdError = fp;\n\n \n if(!CreateProcess(NULL, (char *) cmdlinetxt, NULL, NULL, TRUE,\n CREATE_NO_WINDOW, NULL, NULL, &si, &pinf))\n {\n ajFatal(\"CreateProcess failed: %s\", cmdlinetxt);\n }\n \n if(!WaitForSingleObject(pinf.hProcess, INFINITE))\n status = 0;\n else\n status = -1;\n\n CloseHandle(pinf.hProcess);\n CloseHandle(pinf.hThread);\n#endif\n\n return status;\n}", "label": 1, "cwe": "CWE-other", "length": 687 }, { "index": 917210, "code": "log_set_rotationtime(const char *attrname, char *rtime_str, int logtype, char *returntext, int apply)\n{\n\n\tint\trunit= 0;\n\tint value, rtime;\n\tint\trv = LDAP_SUCCESS;\n\tslapdFrontendConfig_t *fe_cfg = getFrontendConfig();\n\t\n\tif ( logtype != SLAPD_ACCESS_LOG &&\n\t\t logtype != SLAPD_ERROR_LOG &&\n\t\t logtype != SLAPD_AUDIT_LOG ) {\n\t PR_snprintf( returntext, SLAPI_DSE_RETURNTEXT_SIZE,\n\t\t\t\t\"%s: invalid log type: %d\", attrname, logtype );\n\t return LDAP_OPERATIONS_ERROR;\n\t}\n\t\n\t/* return if we aren't doing this for real */\n\tif ( !apply || !rtime_str || !*rtime_str) {\n\t return rv;\n\t}\n\n\trtime = atoi(rtime_str);\n\n\tif (0 == rtime) {\n\t rtime = -1;\t/* Value Range: -1 | 1 to PR_INT32_MAX */\n\t}\n\t\n\tswitch (logtype) {\n\t case SLAPD_ACCESS_LOG:\n\t\tLOG_ACCESS_LOCK_WRITE( );\n\t\tloginfo.log_access_rotationtime = rtime;\n\t\trunit = loginfo.log_access_rotationunit;\n\t\tbreak;\n\t case SLAPD_ERROR_LOG:\n\t\tLOG_ERROR_LOCK_WRITE( );\n\t\tloginfo.log_error_rotationtime = rtime;\n\t\trunit = loginfo.log_error_rotationunit;\n\t\tbreak;\n\t case SLAPD_AUDIT_LOG:\n\t\tLOG_AUDIT_LOCK_WRITE( );\n\t\tloginfo.log_audit_rotationtime = rtime;\n\t\trunit = loginfo.log_audit_rotationunit;\n\t\tbreak;\n\t}\n\n\t/* find out the rotation unit we have se right now */\n\tif (runit == LOG_UNIT_MONTHS) {\n\t\tvalue = 31 * 24 * 60 * 60 * rtime;\n\t} else if (runit == LOG_UNIT_WEEKS) {\n\t\tvalue = 7 * 24 * 60 * 60 * rtime;\n\t} else if (runit == LOG_UNIT_DAYS ) {\n\t\tvalue = 24 * 60 * 60 * rtime;\n\t} else if (runit == LOG_UNIT_HOURS) {\n\t\tvalue = 3600 * rtime;\n\t} else if (runit == LOG_UNIT_MINS) {\n\t\tvalue = 60 * rtime;\n\t} else {\n\t\t/* In this case we don't rotate */\n\t\tvalue = -1;\n\t}\n\n\tif (rtime > 0 && value < 0) {\n\t value = PR_INT32_MAX; /* overflown */\n\t}\n\n\tswitch (logtype) {\n\t case SLAPD_ACCESS_LOG:\n\t\t fe_cfg->accesslog_rotationtime = rtime;\n\t\t loginfo.log_access_rotationtime_secs = value;\n\t\t LOG_ACCESS_UNLOCK_WRITE();\n\t\t break;\n\t case SLAPD_ERROR_LOG:\n\t\t fe_cfg->errorlog_rotationtime = rtime;\n\t\t loginfo.log_error_rotationtime_secs = value;\n\t\t LOG_ERROR_UNLOCK_WRITE();\n\t\t break;\n\t case SLAPD_AUDIT_LOG:\n\t\t fe_cfg->auditlog_rotationtime = rtime;\n\t\t loginfo.log_audit_rotationtime_secs = value;\n\t\t LOG_AUDIT_UNLOCK_WRITE();\n\t\t break;\n\t}\n\treturn rv;\n}", "label": 1, "cwe": "CWE-other", "length": 689 }, { "index": 527844, "code": "FoldOrOfFCmps(FCmpInst *LHS, FCmpInst *RHS) {\n if (LHS->getPredicate() == FCmpInst::FCMP_UNO &&\n RHS->getPredicate() == FCmpInst::FCMP_UNO && \n LHS->getOperand(0)->getType() == RHS->getOperand(0)->getType()) {\n if (ConstantFP *LHSC = dyn_cast(LHS->getOperand(1)))\n if (ConstantFP *RHSC = dyn_cast(RHS->getOperand(1))) {\n // If either of the constants are nans, then the whole thing returns\n // true.\n if (LHSC->getValueAPF().isNaN() || RHSC->getValueAPF().isNaN())\n return ConstantInt::getTrue(LHS->getContext());\n \n // Otherwise, no need to compare the two constants, compare the\n // rest.\n return Builder->CreateFCmpUNO(LHS->getOperand(0), RHS->getOperand(0));\n }\n \n // Handle vector zeros. This occurs because the canonical form of\n // \"fcmp uno x,x\" is \"fcmp uno x, 0\".\n if (isa(LHS->getOperand(1)) &&\n isa(RHS->getOperand(1)))\n return Builder->CreateFCmpUNO(LHS->getOperand(0), RHS->getOperand(0));\n \n return 0;\n }\n \n Value *Op0LHS = LHS->getOperand(0), *Op0RHS = LHS->getOperand(1);\n Value *Op1LHS = RHS->getOperand(0), *Op1RHS = RHS->getOperand(1);\n FCmpInst::Predicate Op0CC = LHS->getPredicate(), Op1CC = RHS->getPredicate();\n \n if (Op0LHS == Op1RHS && Op0RHS == Op1LHS) {\n // Swap RHS operands to match LHS.\n Op1CC = FCmpInst::getSwappedPredicate(Op1CC);\n std::swap(Op1LHS, Op1RHS);\n }\n if (Op0LHS == Op1LHS && Op0RHS == Op1RHS) {\n // Simplify (fcmp cc0 x, y) | (fcmp cc1 x, y).\n if (Op0CC == Op1CC)\n return Builder->CreateFCmp((FCmpInst::Predicate)Op0CC, Op0LHS, Op0RHS);\n if (Op0CC == FCmpInst::FCMP_TRUE || Op1CC == FCmpInst::FCMP_TRUE)\n return ConstantInt::get(CmpInst::makeCmpResultType(LHS->getType()), 1);\n if (Op0CC == FCmpInst::FCMP_FALSE)\n return RHS;\n if (Op1CC == FCmpInst::FCMP_FALSE)\n return LHS;\n bool Op0Ordered;\n bool Op1Ordered;\n unsigned Op0Pred = getFCmpCode(Op0CC, Op0Ordered);\n unsigned Op1Pred = getFCmpCode(Op1CC, Op1Ordered);\n if (Op0Ordered == Op1Ordered) {\n // If both are ordered or unordered, return a new fcmp with\n // or'ed predicates.\n return getFCmpValue(Op0Ordered, Op0Pred|Op1Pred, Op0LHS, Op0RHS, Builder);\n }\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 780 }, { "index": 891485, "code": "bus_ibus_impl_registry_init (BusIBusImpl *ibus)\n{\n GList *p;\n GList *components;\n IBusRegistry *registry = ibus_registry_new ();\n\n ibus->registry = NULL;\n ibus->components = NULL;\n ibus->engine_table = g_hash_table_new (g_str_hash, g_str_equal);\n\n if (g_strcmp0 (g_cache, \"none\") == 0) {\n /* Only load registry, but not read and write cache. */\n ibus_registry_load (registry);\n }\n else if (g_strcmp0 (g_cache, \"refresh\") == 0) {\n /* Load registry and overwrite the cache. */\n ibus_registry_load (registry);\n ibus_registry_save_cache (registry, TRUE);\n }\n else if (g_strcmp0 (g_cache, \"auto\") == 0) {\n /* Load registry from cache. If the cache does not exist or\n * it is outdated, then generate it.\n */\n if (ibus_registry_load_cache (registry, FALSE) == FALSE ||\n ibus_registry_check_modification (registry)) {\n\n ibus_object_destroy (IBUS_OBJECT (registry));\n registry = ibus_registry_new ();\n\n if (ibus_registry_load_cache (registry, TRUE) == FALSE ||\n ibus_registry_check_modification (registry)) {\n\n ibus_object_destroy (IBUS_OBJECT (registry));\n registry = ibus_registry_new ();\n ibus_registry_load (registry);\n ibus_registry_save_cache (registry, TRUE);\n }\n }\n }\n\n ibus->registry = registry;\n components = ibus_registry_get_components (registry);\n\n for (p = components; p != NULL; p = p->next) {\n IBusComponent *component = (IBusComponent *) p->data;\n BusComponent *buscomp = bus_component_new (component,\n NULL /* factory */);\n GList *engines = NULL;\n GList *p1;\n\n g_object_ref_sink (buscomp);\n ibus->components = g_list_append (ibus->components, buscomp);\n\n engines = bus_component_get_engines (buscomp);\n for (p1 = engines; p1 != NULL; p1 = p1->next) {\n IBusEngineDesc *desc = (IBusEngineDesc *) p1->data;\n const gchar *name = ibus_engine_desc_get_name (desc);\n if (g_hash_table_lookup (ibus->engine_table, name) == NULL) {\n g_hash_table_insert (ibus->engine_table,\n (gpointer) name,\n desc);\n } else {\n g_message (\"Engine %s is already registered by other component\",\n name);\n }\n }\n g_list_free (engines);\n }\n\n g_list_free (components);\n\n g_signal_connect (ibus->registry,\n \"changed\",\n G_CALLBACK (_registry_changed_cb),\n ibus);\n ibus_registry_start_monitor_changes (ibus->registry);\n}", "label": 0, "cwe": null, "length": 633 }, { "index": 363272, "code": "save_geometry_MD_pdb_format(gchar *FileName)\n{\n \tFILE *file;\n\tgint j;\n\tgboolean OK = TRUE;\n\tgchar* temp = NULL;\n\n\tif(geometriesMD.numberOfGeometries<1) return FALSE;\n \tfile = FOpen(FileName, \"w\");\n\tif(file == NULL)\n\t{\n\t\tgchar buffer[BSIZE];\n\t\tsprintf(buffer,_(\"Sorry, I can not create '%s' file\\n\"),FileName);\n \t\tMessage(buffer,_(\"Error\"),TRUE);\n\t\treturn FALSE;\n\t}\n\tfprintf(file,\"HEADER PROTEIN\\n\");\n\tfprintf(file,\"COMPND UNNAMED\\n\");\n\ttemp = get_time_str();\n\tif(temp) fprintf(file,\"AUTHOR GENERATED BY GABEDIT %d.%d.%d at %s\",MAJOR_VERSION,MINOR_VERSION,MICRO_VERSION,temp);\n\telse fprintf(file,\"AUTHOR GENERATED BY GABEDIT %d.%d.%d\\n\",MAJOR_VERSION,MINOR_VERSION,MICRO_VERSION);\n\tfor(j=0;j pattern,\n bool is_ascii) {\n if ((data->capture_count + 1) * 2 - 1 > RegExpMacroAssembler::kMaxRegister) {\n return IrregexpRegExpTooBig();\n }\n RegExpCompiler compiler(data->capture_count, ignore_case, is_ascii);\n // Wrap the body of the regexp in capture #0.\n RegExpNode* captured_body = RegExpCapture::ToNode(data->tree,\n 0,\n &compiler,\n compiler.accept());\n RegExpNode* node = captured_body;\n bool is_end_anchored = data->tree->IsAnchoredAtEnd();\n bool is_start_anchored = data->tree->IsAnchoredAtStart();\n int max_length = data->tree->max_match();\n if (!is_start_anchored) {\n // Add a .*? at the beginning, outside the body capture, unless\n // this expression is anchored at the beginning.\n RegExpNode* loop_node =\n RegExpQuantifier::ToNode(0,\n RegExpTree::kInfinity,\n false,\n new RegExpCharacterClass('*'),\n &compiler,\n captured_body,\n data->contains_anchor);\n\n if (data->contains_anchor) {\n // Unroll loop once, to take care of the case that might start\n // at the start of input.\n ChoiceNode* first_step_node = new ChoiceNode(2);\n first_step_node->AddAlternative(GuardedAlternative(captured_body));\n first_step_node->AddAlternative(GuardedAlternative(\n new TextNode(new RegExpCharacterClass('*'), loop_node)));\n node = first_step_node;\n } else {\n node = loop_node;\n }\n }\n data->node = node;\n Analysis analysis(ignore_case, is_ascii);\n analysis.EnsureAnalyzed(node);\n if (analysis.has_failed()) {\n const char* error_message = analysis.error_message();\n return CompilationResult(error_message);\n }\n\n NodeInfo info = *node->info();\n\n // Create the correct assembler for the architecture.\n#ifndef V8_INTERPRETED_REGEXP\n // Native regexp implementation.\n\n NativeRegExpMacroAssembler::Mode mode =\n is_ascii ? NativeRegExpMacroAssembler::ASCII\n : NativeRegExpMacroAssembler::UC16;\n\n#if V8_TARGET_ARCH_IA32\n RegExpMacroAssemblerIA32 macro_assembler(mode, (data->capture_count + 1) * 2);\n#elif V8_TARGET_ARCH_X64\n RegExpMacroAssemblerX64 macro_assembler(mode, (data->capture_count + 1) * 2);\n#elif V8_TARGET_ARCH_ARM\n RegExpMacroAssemblerARM macro_assembler(mode, (data->capture_count + 1) * 2);\n#endif\n\n#else // V8_INTERPRETED_REGEXP\n // Interpreted regexp implementation.\n EmbeddedVector codes;\n RegExpMacroAssemblerIrregexp macro_assembler(codes);\n#endif // V8_INTERPRETED_REGEXP\n\n // Inserted here, instead of in Assembler, because it depends on information\n // in the AST that isn't replicated in the Node structure.\n static const int kMaxBacksearchLimit = 1024;\n if (is_end_anchored &&\n !is_start_anchored &&\n max_length < kMaxBacksearchLimit) {\n macro_assembler.SetCurrentPositionFromEnd(max_length);\n }\n\n return compiler.Assemble(¯o_assembler,\n node,\n data->capture_count,\n pattern);\n}", "label": 0, "cwe": null, "length": 755 }, { "index": 618355, "code": "gtk_source_view_move_lines (GtkSourceView *view, gboolean copy, gint step)\n{\n\tGtkTextBuffer *buf;\n\tGtkTextIter s, e;\n\tGtkTextMark *mark;\n\tgboolean down;\n\tgchar *text;\n\n\tbuf = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));\n\n\tif (step == 0 || gtk_text_view_get_editable (GTK_TEXT_VIEW (view)) == FALSE)\n\t\treturn;\n\n\t/* FIXME: for now we just handle a step of one line */\n\n\tdown = step > 0;\n\n\tgtk_text_buffer_get_selection_bounds (buf, &s, &e);\n\n\t/* get the entire lines, including the paragraph terminator */\n\tgtk_text_iter_set_line_offset (&s, 0);\n\tif (!gtk_text_iter_starts_line (&e) ||\n\t gtk_text_iter_get_line (&s) == gtk_text_iter_get_line (&e))\n\t{\n\t\tgtk_text_iter_forward_line (&e);\n\t}\n\n\tif ((!down && (0 == gtk_text_iter_get_line (&s))) ||\n\t (down && (gtk_text_iter_is_end (&e))) ||\n\t (down && (gtk_text_buffer_get_line_count (buf) == gtk_text_iter_get_line (&e))))\n\t{\n\t\treturn;\n\t}\n\n\ttext = gtk_text_buffer_get_slice (buf, &s, &e, TRUE);\n\n\t/* First special case) We are moving up the last line\n\t * of the buffer, check if buffer ends with a paragraph\n\t * delimiter otherwise append a \\n ourselves */\n\tif (gtk_text_iter_is_end (&e))\n\t{\n\t\tGtkTextIter iter;\n\t\titer = e;\n\n\t\tgtk_text_iter_set_line_offset (&iter, 0);\n\t\tif (!gtk_text_iter_ends_line (&iter) &&\n\t\t !gtk_text_iter_forward_to_line_end (&iter))\n\t\t{\n\t\t\tgchar *tmp;\n\n\t\t\ttmp = g_strdup_printf (\"%s\\n\", text);\n\n\t\t\tg_free (text);\n\t\t\ttext = tmp;\n\t\t}\n\t}\n\n\tgtk_text_buffer_begin_user_action (buf);\n\n\tif (!copy)\n\t\tgtk_text_buffer_delete (buf, &s, &e);\n\n\tif (down)\n\t{\n\t\tgtk_text_iter_forward_line (&e);\n\n\t\t/* Second special case) We are moving down the last-but-one line\n\t\t * of the buffer, check if buffer ends with a paragraph\n\t\t * delimiter otherwise prepend a \\n ourselves */\n\t\tif (gtk_text_iter_is_end (&e))\n\t\t{\n\t\t\tGtkTextIter iter;\n\t\t\titer = e;\n\n\t\t\tgtk_text_iter_set_line_offset (&iter, 0);\n\t\t\tif (!gtk_text_iter_ends_line (&iter) &&\n\t\t\t !gtk_text_iter_forward_to_line_end (&iter))\n\t\t\t{\n\t\t\t\tgtk_text_buffer_insert (buf, &e, \"\\n\", -1);\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tgtk_text_iter_backward_line (&e);\n\t}\n\n\t/* use anon mark to be able to select after insertion */\n\tmark = gtk_text_buffer_create_mark (buf, NULL, &e, TRUE);\n\n\tgtk_text_buffer_insert (buf, &e, text, -1);\n\n\tgtk_text_buffer_end_user_action (buf);\n\n\tg_free (text);\n\n\t/* select the moved text */\n\tgtk_text_buffer_get_iter_at_mark (buf, &s, mark);\n\tgtk_text_buffer_select_range (buf, &s, &e);\n\tgtk_text_view_scroll_mark_onscreen (GTK_TEXT_VIEW (view),\n\t\t\t\t\t gtk_text_buffer_get_insert (buf));\n\n\tgtk_text_buffer_delete_mark (buf, mark);\n}", "label": 0, "cwe": null, "length": 724 }, { "index": 737289, "code": "buildshifts(struct lemon *lemp, struct state *stp)\n{\n struct config *cfp; /* For looping thru the config closure of \"stp\" */\n struct config *bcfp; /* For the inner loop on config closure of \"stp\" */\n struct config *newcfg; /* */\n struct symbol *sp; /* Symbol following the dot in configuration \"cfp\" */\n struct symbol *bsp; /* Symbol following the dot in configuration \"bcfp\" */\n struct state *newstp; /* A pointer to a successor state */\n\n /* Each configuration becomes complete after it contibutes to a successor\n ** state. Initially, all configurations are incomplete */\n for(cfp=stp->cfp; cfp; cfp=cfp->next) cfp->status = INCOMPLETE;\n\n /* Loop through all configurations of the state \"stp\" */\n for(cfp=stp->cfp; cfp; cfp=cfp->next){\n if( cfp->status==COMPLETE ) continue; /* Already used by inner loop */\n if( cfp->dot>=cfp->rp->nrhs ) continue; /* Can't shift this config */\n Configlist_reset(); /* Reset the new config set */\n sp = cfp->rp->rhs[cfp->dot]; /* Symbol after the dot */\n\n /* For every configuration in the state \"stp\" which has the symbol \"sp\"\n ** following its dot, add the same configuration to the basis set under\n ** construction but with the dot shifted one symbol to the right. */\n for(bcfp=cfp; bcfp; bcfp=bcfp->next){\n if( bcfp->status==COMPLETE ) continue; /* Already used */\n if( bcfp->dot>=bcfp->rp->nrhs ) continue; /* Can't shift this one */\n bsp = bcfp->rp->rhs[bcfp->dot]; /* Get symbol after dot */\n if( !same_symbol(bsp,sp) ) continue; /* Must be same as for \"cfp\" */\n bcfp->status = COMPLETE; /* Mark this config as used */\n newcfg = Configlist_addbasis(bcfp->rp,bcfp->dot+1);\n Plink_add(&newcfg->bplp,bcfp);\n }\n\n /* Get a pointer to the state described by the basis configuration set\n ** constructed in the preceding loop */\n newstp = getstate(lemp);\n\n /* The state \"newstp\" is reached from the state \"stp\" by a shift action\n ** on the symbol \"sp\" */\n if( sp->type==MULTITERMINAL ){\n int i;\n for(i=0; insubsym; i++){\n Action_add(&stp->ap,SHIFT,sp->subsym[i],(char*)newstp);\n }\n }else{\n Action_add(&stp->ap,SHIFT,sp,(char *)newstp);\n }\n }\n}", "label": 0, "cwe": null, "length": 654 }, { "index": 493957, "code": "load_config(int reload)\n{\n\tstruct ast_flags config_flags = {\n\t\treload && !force_reload_load ? CONFIG_FLAG_FILEUNCHANGED : 0 };\n\tstruct ast_config *cfg;\n\tstruct parking_dp_map old_usage_map = AST_LIST_HEAD_NOLOCK_INIT_VALUE;\n\tstruct parking_dp_map new_usage_map = AST_LIST_HEAD_NOLOCK_INIT_VALUE;\n\n\t/* We are reloading now and have already determined if we will force the reload. */\n\tforce_reload_load = 0;\n\n\tif (!default_parkinglot) {\n\t\t/* Must create the default default parking lot */\n\t\tdefault_parkinglot = build_parkinglot(DEFAULT_PARKINGLOT, NULL);\n\t\tif (!default_parkinglot) {\n\t\t\tast_log(LOG_ERROR, \"Configuration of default default parking lot failed.\\n\");\n\t\t\treturn -1;\n\t\t}\n\t\tast_debug(1, \"Configuration of default default parking lot done.\\n\");\n\t}\n\n\tcfg = ast_config_load2(\"features.conf\", \"features\", config_flags);\n\tif (cfg == CONFIG_STATUS_FILEUNCHANGED) {\n\t\t/* No sense in asking for reload trouble if nothing changed. */\n\t\tast_debug(1, \"features.conf did not change.\\n\");\n\t\treturn 0;\n\t}\n\tif (cfg == CONFIG_STATUS_FILEMISSING\n\t\t|| cfg == CONFIG_STATUS_FILEINVALID) {\n\t\tast_log(LOG_WARNING, \"Could not load features.conf\\n\");\n\t\treturn 0;\n\t}\n\n\t/* Save current parking lot dialplan needs. */\n\tif (build_dialplan_useage_map(&old_usage_map, 0)) {\n\t\tdestroy_dialplan_usage_map(&old_usage_map);\n\n\t\t/* Allow reloading later to see if conditions have improved. */\n\t\tforce_reload_load = 1;\n\t\treturn -1;\n\t}\n\n\tao2_t_callback(parkinglots, OBJ_NODATA, parkinglot_markall_cb, NULL,\n\t\t\"callback to mark all parking lots\");\n\tprocess_config(cfg);\n\tast_config_destroy(cfg);\n\tao2_t_callback(parkinglots, OBJ_NODATA | OBJ_UNLINK, parkinglot_is_marked_cb, NULL,\n\t\t\"callback to remove marked parking lots\");\n\n\t/* Save updated parking lot dialplan needs. */\n\tif (build_dialplan_useage_map(&new_usage_map, 1)) {\n\t\t/*\n\t\t * Yuck, if this failure caused any parking lot dialplan items\n\t\t * to be lost, they will likely remain lost until Asterisk is\n\t\t * restarted.\n\t\t */\n\t\tdestroy_dialplan_usage_map(&old_usage_map);\n\t\tdestroy_dialplan_usage_map(&new_usage_map);\n\t\treturn -1;\n\t}\n\n\t/* Remove no longer needed parking lot dialplan usage. */\n\tremove_dead_dialplan_useage(&old_usage_map, &new_usage_map);\n\n\tdestroy_dialplan_usage_map(&old_usage_map);\n\tdestroy_dialplan_usage_map(&new_usage_map);\n\n\tao2_t_callback(parkinglots, OBJ_NODATA, parkinglot_activate_cb, NULL,\n\t\t\"callback to activate all parking lots\");\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 634 }, { "index": 600954, "code": "brasero_data_vfs_directory_check_symlink_loop (BraseroDataVFS *self,\n\t\t\t\t\t BraseroFileNode *parent,\n\t\t\t\t\t const gchar *uri,\n\t\t\t\t\t GFileInfo *info)\n{\n\tconst gchar *target_uri;\n\tguint target_len;\n\tguint uri_len;\n\n\t/* Of course for a loop to exist, it must be a directory */\n\tif (g_file_info_get_file_type (info) != G_FILE_TYPE_DIRECTORY)\n\t\treturn FALSE;\n\n\ttarget_uri = g_file_info_get_symlink_target (info);\n\tif (!target_uri)\n\t\treturn FALSE;\n\n\t/* if target points to a child that's OK */\n\turi_len = strlen (uri);\n\tif (!strncmp (target_uri, uri, uri_len)\n\t&& target_uri [uri_len] == G_DIR_SEPARATOR)\n\t\treturn FALSE;\n\n\ttarget_len = strlen (target_uri);\n\twhile (parent && !parent->is_root) {\n\t\tBraseroFileNode *next;\n\t\tgchar *parent_uri;\n\t\tguint parent_len;\n\t\tgchar *next_uri;\n\t\tguint next_len;\n\n\t\t/* if the file is not grafted carry on */\n\t\tif (!parent->is_grafted) {\n\t\t\tparent = parent->parent;\n\t\t\tcontinue;\n\t\t}\n\n\t\t/* if the file is a symlink, carry on since that's why it was\n\t\t * grafted. It can't have been added by the user since in this\n\t\t * case we replace the symlink by the target. */\n\t\tif (parent->is_symlink) {\n\t\t\tparent = parent->parent;\n\t\t\tcontinue;\n\t\t}\n\n\t\tparent_uri = brasero_data_project_node_to_uri (BRASERO_DATA_PROJECT (self), parent);\n\t\tparent_len = strlen (parent_uri);\n\n\t\t/* see if target is a parent of that file */\n\t\tif (!strncmp (target_uri, parent_uri, target_len)\n\t\t&& parent_uri [target_len] == G_DIR_SEPARATOR) {\n\t\t\tg_free (parent_uri);\n\t\t\treturn TRUE;\n\t\t}\n\n\t\t/* see if the graft is also the parent of the target */\n\t\tif (!strncmp (parent_uri, target_uri, parent_len)\n\t\t&& target_uri [parent_len] == G_DIR_SEPARATOR) {\n\t\t\tg_free (parent_uri);\n\t\t\treturn TRUE;\n\t\t}\n\n\t\t/* The next graft point must be the natural parent of this one */\n\t\tnext = parent->parent;\n\t\tif (!next || next->is_root || next->is_fake) {\n\t\t\t/* It's not we're done */\n\t\t\tg_free (parent_uri);\n\t\t\tbreak;\n\t\t}\n\n\t\tnext_uri = brasero_data_project_node_to_uri (BRASERO_DATA_PROJECT (self), next);\n\t\tnext_len = strlen (next_uri);\n\n\t\tif (!strncmp (next_uri, parent_uri, next_len)\n\t\t&& parent_uri [next_len] == G_DIR_SEPARATOR) {\n\t\t\t/* It's not the natural parent. We're done */\n\t\t\tg_free (parent_uri);\n\t\t\tbreak;\n\t\t}\n\n\t\t/* retry with the next parent graft point */\n\t\tg_free (parent_uri);\n\t\tparent = next;\n\t}\n\n\treturn FALSE;\n}", "label": 0, "cwe": null, "length": 657 }, { "index": 918001, "code": "fold_builtin_interclass_mathfn (location_t loc, tree fndecl, tree arg)\n{\n enum machine_mode mode;\n\n if (!validate_arg (arg, REAL_TYPE))\n return NULL_TREE;\n\n if (interclass_mathfn_icode (arg, fndecl) != CODE_FOR_nothing)\n return NULL_TREE;\n\n mode = TYPE_MODE (TREE_TYPE (arg));\n\n /* If there is no optab, try generic code. */\n switch (DECL_FUNCTION_CODE (fndecl))\n {\n tree result;\n\n CASE_FLT_FN (BUILT_IN_ISINF):\n {\n\t/* isinf(x) -> isgreater(fabs(x),DBL_MAX). */\n\ttree const isgr_fn = builtin_decl_explicit (BUILT_IN_ISGREATER);\n\ttree const type = TREE_TYPE (arg);\n\tREAL_VALUE_TYPE r;\n\tchar buf[128];\n\n\tget_max_float (REAL_MODE_FORMAT (mode), buf, sizeof (buf));\n\treal_from_string (&r, buf);\n\tresult = build_call_expr (isgr_fn, 2,\n\t\t\t\t fold_build1_loc (loc, ABS_EXPR, type, arg),\n\t\t\t\t build_real (type, r));\n\treturn result;\n }\n CASE_FLT_FN (BUILT_IN_FINITE):\n case BUILT_IN_ISFINITE:\n {\n\t/* isfinite(x) -> islessequal(fabs(x),DBL_MAX). */\n\ttree const isle_fn = builtin_decl_explicit (BUILT_IN_ISLESSEQUAL);\n\ttree const type = TREE_TYPE (arg);\n\tREAL_VALUE_TYPE r;\n\tchar buf[128];\n\n\tget_max_float (REAL_MODE_FORMAT (mode), buf, sizeof (buf));\n\treal_from_string (&r, buf);\n\tresult = build_call_expr (isle_fn, 2,\n\t\t\t\t fold_build1_loc (loc, ABS_EXPR, type, arg),\n\t\t\t\t build_real (type, r));\n\t/*result = fold_build2_loc (loc, UNGT_EXPR,\n\t\t\t\t TREE_TYPE (TREE_TYPE (fndecl)),\n\t\t\t\t fold_build1_loc (loc, ABS_EXPR, type, arg),\n\t\t\t\t build_real (type, r));\n\tresult = fold_build1_loc (loc, TRUTH_NOT_EXPR,\n\t\t\t\t TREE_TYPE (TREE_TYPE (fndecl)),\n\t\t\t\t result);*/\n\treturn result;\n }\n case BUILT_IN_ISNORMAL:\n {\n\t/* isnormal(x) -> isgreaterequal(fabs(x),DBL_MIN) &\n\t islessequal(fabs(x),DBL_MAX). */\n\ttree const isle_fn = builtin_decl_explicit (BUILT_IN_ISLESSEQUAL);\n\ttree const isge_fn = builtin_decl_explicit (BUILT_IN_ISGREATEREQUAL);\n\ttree const type = TREE_TYPE (arg);\n\tREAL_VALUE_TYPE rmax, rmin;\n\tchar buf[128];\n\n\tget_max_float (REAL_MODE_FORMAT (mode), buf, sizeof (buf));\n\treal_from_string (&rmax, buf);\n\tsprintf (buf, \"0x1p%d\", REAL_MODE_FORMAT (mode)->emin - 1);\n\treal_from_string (&rmin, buf);\n\targ = builtin_save_expr (fold_build1_loc (loc, ABS_EXPR, type, arg));\n\tresult = build_call_expr (isle_fn, 2, arg,\n\t\t\t\t build_real (type, rmax));\n\tresult = fold_build2 (BIT_AND_EXPR, integer_type_node, result,\n\t\t\t build_call_expr (isge_fn, 2, arg,\n\t\t\t\t\t build_real (type, rmin)));\n\treturn result;\n }\n default:\n break;\n }\n\n return NULL_TREE;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 733 }, { "index": 47239, "code": "help(struct tab *ctab, char *s)\n{\n\tstruct tab *c;\n\tint width, NCMDS;\n\tchar *t;\n\tchar buf[1024];\n\n\tif (ctab == sitetab)\n\t\tt = \"SITE \";\n\telse\n\t\tt = \"\";\n\twidth = 0, NCMDS = 0;\n\tfor (c = ctab; c->name != NULL; c++) {\n\t\tint len = strlen(c->name);\n\n\t\tif (len > width)\n\t\t\twidth = len;\n\t\tNCMDS++;\n\t}\n\twidth = (width + 8) &~ 7;\n\tif (s == 0) {\n\t\tint i, j, w;\n\t\tint columns, lines;\n\n\t\tlreply(214, \"The following %scommands are recognized %s.\",\n\t\t t, \"(* =>'s unimplemented)\");\n\t\tcolumns = 76 / width;\n\t\tif (columns == 0)\n\t\t\tcolumns = 1;\n\t\tlines = (NCMDS + columns - 1) / columns;\n\t\tfor (i = 0; i < lines; i++) {\n\t\t strlcpy (buf, \" \", sizeof(buf));\n\t\t for (j = 0; j < columns; j++) {\n\t\t\tc = ctab + j * lines + i;\n\t\t\tsnprintf (buf + strlen(buf),\n\t\t\t\t sizeof(buf) - strlen(buf),\n\t\t\t\t \"%s%c\",\n\t\t\t\t c->name,\n\t\t\t\t c->implemented ? ' ' : '*');\n\t\t\tif (c + lines >= &ctab[NCMDS])\n\t\t\t break;\n\t\t\tw = strlen(c->name) + 1;\n\t\t\twhile (w < width) {\n\t\t\t strlcat (buf,\n\t\t\t\t\t \" \",\n\t\t\t\t\t sizeof(buf));\n\t\t\t w++;\n\t\t\t}\n\t\t }\n\t\t lreply(214, \"%s\", buf);\n\t\t}\n\t\treply(214, \"Direct comments to kth-krb-bugs@pdc.kth.se\");\n\t\treturn;\n\t}\n\tstrupr(s);\n\tc = lookup(ctab, s);\n\tif (c == (struct tab *)0) {\n\t\treply(502, \"Unknown command %s.\", s);\n\t\treturn;\n\t}\n\tif (c->implemented)\n\t\treply(214, \"Syntax: %s%s %s\", t, c->name, c->help);\n\telse\n\t\treply(214, \"%s%-*s\\t%s; unimplemented.\", t, width,\n\t\t c->name, c->help);\n}", "label": 0, "cwe": null, "length": 512 }, { "index": 220613, "code": "resizeScene(int width,int height)\n{\n // store focus item field pos (calculated using old cellSize)\n FieldPos focusRectFieldPos = pixToField( m_focusItem->pos() );\n\n bool hasBorder = KLinesRenderer::hasBorderElement();\n\n int minDim = qMin( width, height );\n // border width is hardcoded to be half of cell size.\n // take it into account if it exists\n m_cellSize = hasBorder ? minDim/(FIELD_SIZE+1) : minDim/FIELD_SIZE;\n\n // set it only if current theme supports it\n m_playFieldBorderSize = hasBorder ? m_cellSize/2 : 0;\n\n int boardSize = m_cellSize * FIELD_SIZE;\n if ( m_previewZoneVisible && boardSize +m_playFieldBorderSize*2 + m_cellSize > width) // No space enough for balls preview\n {\n minDim = width;\n m_cellSize = hasBorder ? (minDim - m_cellSize - m_playFieldBorderSize*2)/FIELD_SIZE : (minDim - m_cellSize)/FIELD_SIZE;\n boardSize = m_cellSize * FIELD_SIZE;\n }\n\n\n m_playFieldRect.setX( (width - (m_previewZoneVisible ? m_cellSize : 0))/2 - boardSize/2 - m_playFieldBorderSize );\n m_playFieldRect.setY( height/2 - boardSize/2 - m_playFieldBorderSize );\n\n m_playFieldRect.setWidth( boardSize + m_playFieldBorderSize*2 );\n m_playFieldRect.setHeight( boardSize + m_playFieldBorderSize*2 );\n\n setSceneRect( 0, 0, width, height );\n\n // sets render sizes for cells\n KLinesRenderer::setCellSize( m_cellSize );\n QSize cellSize(m_cellSize, m_cellSize);\n\n // re-render && recalc positions for all balls\n for( int x=0; xsetRenderSize(cellSize);\n m_field[x][y]->setPos( fieldToPix( FieldPos(x,y) ) );\n m_field[x][y]->setColor( m_field[x][y]->color() );\n }\n }\n\n m_focusItem->setRect( QRect(0,0, m_cellSize, m_cellSize) );\n m_focusItem->setPos( fieldToPix( focusRectFieldPos ) );\n\n int previewOriginY = height / 2 - (3 * m_cellSize) / 2;\n int previewOriginX = m_playFieldRect.x() + m_playFieldRect.width();\n m_previewItem->setPos( previewOriginX, previewOriginY );\n m_previewItem->setPreviewColors( m_nextColors );\n\n //kDebug() << \"resize:\" << width << \",\" << height << \"; cellSize:\" << m_cellSize;\n}", "label": 0, "cwe": null, "length": 647 }, { "index": 581278, "code": "mmc_feature_profile2str( int i_feature_profile )\n{\n switch(i_feature_profile) {\n case CDIO_MMC_FEATURE_PROF_NON_REMOVABLE:\n return \"Non-removable\";\n case CDIO_MMC_FEATURE_PROF_REMOVABLE:\n return \"disk Re-writable; with removable media\";\n case CDIO_MMC_FEATURE_PROF_MO_ERASABLE:\n return \"Erasable Magneto-Optical disk with sector erase capability\";\n case CDIO_MMC_FEATURE_PROF_MO_WRITE_ONCE:\n return \"Write Once Magneto-Optical write once\";\n case CDIO_MMC_FEATURE_PROF_AS_MO:\n return \"Advance Storage Magneto-Optical\";\n case CDIO_MMC_FEATURE_PROF_CD_ROM:\n return \"Read only Compact Disc capable\";\n case CDIO_MMC_FEATURE_PROF_CD_R:\n return \"Write once Compact Disc capable\";\n case CDIO_MMC_FEATURE_PROF_CD_RW:\n return \"CD-RW Re-writable Compact Disc capable\";\n case CDIO_MMC_FEATURE_PROF_DVD_ROM:\n return \"Read only DVD\";\n case CDIO_MMC_FEATURE_PROF_DVD_R_SEQ:\n return \"Re-recordable DVD using Sequential recording\";\n case CDIO_MMC_FEATURE_PROF_DVD_RAM:\n return \"Re-writable DVD\";\n case CDIO_MMC_FEATURE_PROF_DVD_RW_RO:\n return \"Re-recordable DVD using Restricted Overwrite\";\n case CDIO_MMC_FEATURE_PROF_DVD_RW_SEQ:\n return \"Re-recordable DVD using Sequential Recording\";\n case CDIO_MMC_FEATURE_PROF_DVD_R_DL_SEQ:\n return \"DVD-R - Double-Layer Sequential Recording\";\n case CDIO_MMC_FEATURE_PROF_DVD_R_DL_JR:\n return \"DVD-R - Double-layer Jump Recording\";\n case CDIO_MMC_FEATURE_PROF_DVD_PRW:\n return \"DVD+RW - DVD Rewritable\";\n case CDIO_MMC_FEATURE_RIGID_RES_OVERW:\n return \"Rigid Restricted Overwrite\";\n case CDIO_MMC_FEATURE_PROF_DVD_PR:\n return \"DVD+R - DVD Recordable\";\n case CDIO_MMC_FEATURE_PROF_DDCD_ROM:\n return \"Read only DDCD\";\n case CDIO_MMC_FEATURE_PROF_DDCD_R:\n return \"DDCD-R Write only DDCD\";\n case CDIO_MMC_FEATURE_PROF_DDCD_RW:\n return \"Re-Write only DDCD\";\n case CDIO_MMC_FEATURE_PROF_DVD_PRW_DL:\n return \"DVD+RW - Double Layer\";\n case CDIO_MMC_FEATURE_PROF_DVD_PR_DL:\n return \"DVD+R Double Layer - DVD Recordable Double Layer\";\n case CDIO_MMC_FEATURE_PROF_BD_ROM:\n return \"Blu Ray BD-ROM\";\n case CDIO_MMC_FEATURE_PROF_BD_SEQ:\n return \"Blu Ray BD-R sequential recording\";\n case CDIO_MMC_FEATURE_PROF_BD_R_RANDOM:\n return \"Blu Ray BD-R random recording\";\n case CDIO_MMC_FEATURE_PROF_BD_RE:\n return \"Blu Ray BD-RE\";\n case CDIO_MMC_FEATURE_PROF_HD_DVD_ROM:\n return \"HD-DVD-ROM\";\n case CDIO_MMC_FEATURE_PROF_HD_DVD_R:\n return \"HD-DVD-R\";\n case CDIO_MMC_FEATURE_PROF_HD_DVD_RAM:\n return \"HD-DVD-RAM\";\n case CDIO_MMC_FEATURE_PROF_NON_CONFORM:\n return \"The Logical Unit does not conform to any Profile\";\n default: \n {\n static char buf[100];\n snprintf(buf, sizeof(buf), \"Unknown Profile %x\", i_feature_profile);\n return buf;\n }\n }\n}", "label": 0, "cwe": null, "length": 784 }, { "index": 69240, "code": "investigate_suckage(glui32 *wid, glui32 *hei)\n{\n winid_t w1, w2;\n\n *wid = 70; *hei = 24; /* sensible defaults if we can't tell */\n\n glk_stylehint_set(wintype_AllTypes, style_User2,\n\t\t stylehint_TextColor, 0x00ff0000);\n glk_stylehint_set(wintype_AllTypes, style_Subheader,\n\t\t stylehint_Weight, 1);\n\n w1 = glk_window_open(0, 0, 0, wintype_TextBuffer, 0);\n if(!w1)\n glk_exit(); /* Run screaming! */\n w2 = glk_window_open(w1, winmethod_Above | winmethod_Fixed, 1,\n\t\t wintype_TextGrid, 0);\n\n if(w2) {\n winid_t o;\n o = glk_window_get_parent(w2);\n glk_window_set_arrangement(o, winmethod_Above | winmethod_Proportional,\n\t\t\t 100, w2);\n glk_window_get_size(w2, wid, hei);\n glk_window_set_arrangement(o, winmethod_Above | winmethod_Fixed,\n\t\t\t 1, w2);\n }\n\n cur_cap[HAS_STATUSLINE] = (w2 != 0);\n cur_cap[HAS_COLOR] = glk_style_distinguish(w1, style_Normal, style_User2);\n cur_cap[HAS_CHARGRAPH] = 0;\n cur_cap[HAS_BOLD] = glk_style_distinguish(w1, style_Normal, style_Subheader);\n cur_cap[HAS_ITALIC] = glk_style_distinguish(w1, style_Normal, style_Emphasized);\n cur_cap[HAS_FIXED] = glk_style_distinguish(w1, style_Normal, style_Preformatted);\n#ifdef GLK_MODULE_SOUND\n cur_cap[HAS_SOUND] = glk_gestalt(gestalt_Sound, 0);\n#else\n cur_cap[HAS_SOUND] = FALSE;\n#endif\n#ifdef GLK_MODULE_IMAGE\n cur_cap[HAS_GRAPHICS] = glk_gestalt(gestalt_Graphics, 0);\n#else\n cur_cap[HAS_GRAPHICS] = FALSE;\n#endif\n cur_cap[HAS_TIMER] = glk_gestalt(gestalt_Timer, 0);\n cur_cap[HAS_MOUSE] = glk_gestalt(gestalt_MouseInput, wintype_TextGrid);\n\n cur_cap[HAS_DEFVAR] = TRUE;\n\n cur_cap[HAS_UNDO] = TRUE;\n cur_cap[HAS_MENU] = FALSE;\n\n if(w1)\n glk_window_close(w1, NULL);\n if(w2)\n glk_window_close(w2, NULL);\n}", "label": 0, "cwe": null, "length": 595 }, { "index": 895550, "code": "glade_gtk_grid_configure_end (GladeFixed *fixed,\n GladeWidget *child,\n GtkWidget *grid)\n{\n GladeGridChild new_child = { child, };\n\n glade_widget_pack_property_get (child, \"left-attach\", &new_child.left_attach);\n glade_widget_pack_property_get (child, \"width\", &new_child.width);\n glade_widget_pack_property_get (child, \"top-attach\", &new_child.top_attach);\n glade_widget_pack_property_get (child, \"height\", &new_child.height);\n\n /* Compare the meaningfull part of the current edit. */\n if (memcmp (&new_child, &grid_edit, sizeof (GladeGridChild)) != 0)\n {\n GValue left_attach_value = { 0, };\n GValue width_attach_value = { 0, };\n GValue top_attach_value = { 0, };\n GValue height_attach_value = { 0, };\n\n GValue new_left_attach_value = { 0, };\n GValue new_width_attach_value = { 0, };\n GValue new_top_attach_value = { 0, };\n GValue new_height_attach_value = { 0, };\n\n GladeProperty *left_attach_prop, *width_attach_prop,\n *top_attach_prop, *height_attach_prop;\n\n left_attach_prop = glade_widget_get_pack_property (child, \"left-attach\");\n width_attach_prop = glade_widget_get_pack_property (child, \"width\");\n top_attach_prop = glade_widget_get_pack_property (child, \"top-attach\");\n height_attach_prop = glade_widget_get_pack_property (child, \"height\");\n\n g_return_val_if_fail (GLADE_IS_PROPERTY (left_attach_prop), FALSE);\n g_return_val_if_fail (GLADE_IS_PROPERTY (width_attach_prop), FALSE);\n g_return_val_if_fail (GLADE_IS_PROPERTY (top_attach_prop), FALSE);\n g_return_val_if_fail (GLADE_IS_PROPERTY (height_attach_prop), FALSE);\n\n glade_property_get_value (left_attach_prop, &new_left_attach_value);\n glade_property_get_value (width_attach_prop, &new_width_attach_value);\n glade_property_get_value (top_attach_prop, &new_top_attach_value);\n glade_property_get_value (height_attach_prop, &new_height_attach_value);\n\n g_value_init (&left_attach_value, G_TYPE_INT);\n g_value_init (&width_attach_value, G_TYPE_INT);\n g_value_init (&top_attach_value, G_TYPE_INT);\n g_value_init (&height_attach_value, G_TYPE_INT);\n\n g_value_set_int (&left_attach_value, grid_edit.left_attach);\n g_value_set_int (&width_attach_value, grid_edit.width);\n g_value_set_int (&top_attach_value, grid_edit.top_attach);\n g_value_set_int (&height_attach_value, grid_edit.height);\n\n glade_command_push_group (_(\"Placing %s inside %s\"),\n glade_widget_get_name (child), \n glade_widget_get_name (GLADE_WIDGET (fixed)));\n glade_command_set_properties\n (left_attach_prop, &left_attach_value, &new_left_attach_value,\n width_attach_prop, &width_attach_value, &new_width_attach_value,\n top_attach_prop, &top_attach_value, &new_top_attach_value,\n height_attach_prop, &height_attach_value, &new_height_attach_value,\n NULL);\n glade_command_pop_group ();\n\n g_value_unset (&left_attach_value);\n g_value_unset (&width_attach_value);\n g_value_unset (&top_attach_value);\n g_value_unset (&height_attach_value);\n g_value_unset (&new_left_attach_value);\n g_value_unset (&new_width_attach_value);\n g_value_unset (&new_top_attach_value);\n g_value_unset (&new_height_attach_value);\n }\n\n return TRUE;\n}", "label": 0, "cwe": null, "length": 821 }, { "index": 82115, "code": "project_id_version (const char *header)\n{\n const char *old_field;\n const char *gettextlibdir;\n char *prog;\n char *argv[4];\n pid_t child;\n int fd[1];\n FILE *fp;\n char *line;\n size_t linesize;\n size_t linelen;\n int exitstatus;\n\n /* Return the old value if present, assuming it was already filled in by\n xgettext. */\n old_field = get_field (header, \"Project-Id-Version\");\n if (old_field != NULL && strcmp (old_field, \"PACKAGE VERSION\") != 0)\n return old_field;\n\n gettextlibdir = getenv (\"GETTEXTLIBDIR\");\n if (gettextlibdir == NULL || gettextlibdir[0] == '\\0')\n gettextlibdir = relocate (LIBDIR \"/gettext\");\n\n prog = xconcatenated_filename (gettextlibdir, \"project-id\", NULL);\n\n /* Call the project-id shell script. */\n argv[0] = \"/bin/sh\";\n argv[1] = prog;\n argv[2] = \"yes\";\n argv[3] = NULL;\n child = create_pipe_in (prog, \"/bin/sh\", argv, DEV_NULL, false, true, false,\n fd);\n if (child == -1)\n goto failed;\n\n /* Retrieve its result. */\n fp = fdopen (fd[0], \"r\");\n if (fp == NULL)\n {\n error (0, errno, _(\"fdopen() failed\"));\n goto failed;\n }\n\n line = NULL; linesize = 0;\n linelen = getline (&line, &linesize, fp);\n if (linelen == (size_t)(-1))\n {\n error (0, 0, _(\"%s subprocess I/O error\"), prog);\n fclose (fp);\n goto failed;\n }\n if (linelen > 0 && line[linelen - 1] == '\\n')\n line[linelen - 1] = '\\0';\n\n fclose (fp);\n\n /* Remove zombie process from process list, and retrieve exit status. */\n exitstatus = wait_subprocess (child, prog, false, false, true, false, NULL);\n if (exitstatus != 0)\n {\n error (0, 0, _(\"%s subprocess failed with exit code %d\"),\n prog, exitstatus);\n goto failed;\n }\n\n return line;\n\nfailed:\n return \"PACKAGE VERSION\";\n}", "label": 0, "cwe": null, "length": 537 }, { "index": 252618, "code": "__do_dbg_dis_enable(int32 do_enable)\n{\n register struct brkpt_t *bpp;\n register struct dispx_t *dxp;\n int32 denum, disentyp;\n char s1[RECLEN];\n\n if (do_enable) strcpy(s1, \"enable\"); else strcpy(s1, \"disable\");\n __get_vtok();\n if (__toktyp == ID)\n {\n disentyp = __get_dbcmdnum(__token, dtyparg, NTYPARGS);\n __get_vtok();\n }\n else disentyp = TYP_BRKPTS;\n\n if (disentyp == TYP_BRKPTS)\n {\n if (__toktyp == TEOF) denum = -2; \n else\n {\n if ((denum = __get_dbg_val()) == -1 || denum < 1)\n {\n __ia_err(1477, \":%s expected breakpoint number %s illegal\", s1,\n __prt_vtok());\n return;\n }\n }\n /* delete break numbered bpnum */\n for (bpp = __bphdr; bpp != NULL; bpp = bpp->bpnxt)\n {\n if (denum == -2 || bpp->bp_num == denum)\n {\n bpp->bp_enable = (do_enable) ? TRUE : FALSE;\n if (denum != -2) goto done;\n }\n }\n if (denum == -2) goto done; \n __ia_err(1479, \":%s breakpoint failed - no breakpoint number %d\",\n s1, denum); \n return;\n }\n /* display case */\n if (__toktyp == TEOF) denum = -2; \n else\n {\n if ((denum = __get_dbg_val()) == -1 || denum < 1)\n {\n __ia_err(1477, \":%s expected auto-display number %s illegal\", s1,\n __prt_vtok());\n return;\n }\n }\n /* delete break numbered bpnum */\n for (dxp = __dispxhdr; dxp != NULL; dxp = dxp->dsp_nxt)\n {\n if (denum == -2 || dxp->dsp_num == denum)\n {\n dxp->dsp_enable = (do_enable) ? TRUE : FALSE;\n if (denum != -2) goto done;\n }\n }\n if (denum == -2) goto done;\n __ia_err(1479, \":%s displays failed - no auto-display number %d\",\n s1, denum); \n return;\n\ndone:\n __chk_extra_atend(TRUE);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 558 }, { "index": 562101, "code": "gdk_pixbuf__ani_image_load_increment (gpointer data,\n\t\t\t\t const guchar *buf, guint size,\n\t\t\t\t GError **error)\n{\n AniLoaderContext *context = (AniLoaderContext *)data;\n \n if (context->n_bytes + size >= context->buffer_size) {\n int drop = context->byte - context->buffer;\n memmove (context->buffer, context->byte, context->n_bytes - drop);\n context->n_bytes -= drop;\n context->byte = context->buffer;\n if (context->n_bytes + size >= context->buffer_size) {\n\t\t\tguchar *tmp;\n context->buffer_size = MAX (context->n_bytes + size, context->buffer_size + 4096);\n#ifdef DEBUG_ANI\n g_print (\"growing buffer to %\" G_GUINT32_FORMAT \"\\n\", context->buffer_size);\n#endif\n tmp = g_try_realloc (context->buffer, context->buffer_size);\n if (!tmp) \n\t\t\t{\n\t\t\t\tg_set_error_literal (error,\n GDK_PIXBUF_ERROR,\n GDK_PIXBUF_ERROR_INSUFFICIENT_MEMORY,\n _(\"Not enough memory to load animation\"));\n\t\t\t\treturn FALSE;\n\t\t\t}\n context->byte = context->buffer = tmp;\n }\n }\n memcpy (context->buffer + context->n_bytes, buf, size);\n context->n_bytes += size;\n\n if (context->data_size == 0) \n\t{\n\t\tguint32 riff_id, chunk_id;\n \n\t\tif (BYTES_LEFT (context) < 12)\n\t\t\treturn TRUE;\n \n\t\triff_id = read_int32 (context);\n\t\tcontext->data_size = read_int32 (context);\n\t\tchunk_id = read_int32 (context);\n \n\t\tif (riff_id != TAG_RIFF || \n\t\t context->data_size == 0 || \n\t\t chunk_id != TAG_ACON) \n\t\t{\n\t\t\tg_set_error_literal (error,\n GDK_PIXBUF_ERROR,\n GDK_PIXBUF_ERROR_CORRUPT_IMAGE,\n _(\"Invalid header in animation\"));\n\t\t\treturn FALSE; \n\t\t}\n\t}\n \n if (context->cp < context->data_size + 8) \n\t{\n\t\tGError *chunk_error = NULL;\n\n\t\twhile (ani_load_chunk (context, &chunk_error)) ;\n\t\tif (chunk_error) \n\t\t{\n\t\t\tg_propagate_error (error, chunk_error);\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\n return TRUE;\n}", "label": 0, "cwe": null, "length": 522 }, { "index": 722959, "code": "driver_init_driver( CoreGraphicsDevice *device,\n GraphicsDeviceFuncs *funcs,\n void *driver_data,\n void *device_data,\n CoreDFB *core )\n{\n MatroxDriverData *mdrv = driver_data;\n\n mdrv->mmio_base = (volatile u8*) dfb_gfxcard_map_mmio( device, 0, -1 );\n if (!mdrv->mmio_base)\n return DFB_IO;\n\n mdrv->device_data = device_data;\n mdrv->maven_fd = -1;\n mdrv->accelerator = dfb_gfxcard_get_accelerator( device );\n\n switch (mdrv->accelerator) {\n case FB_ACCEL_MATROX_MGAG400:\n funcs->CheckState = matroxG400CheckState;\n break;\n\n case FB_ACCEL_MATROX_MGAG200:\n if (!dfb_config->font_format)\n dfb_config->font_format = DSPF_ARGB;\n funcs->CheckState = matroxG200CheckState;\n break;\n\n case FB_ACCEL_MATROX_MGAG100:\n funcs->CheckState = matroxG100CheckState;\n break;\n\n case FB_ACCEL_MATROX_MGA1064SG:\n case FB_ACCEL_MATROX_MGA2164W:\n case FB_ACCEL_MATROX_MGA2164W_AGP:\n funcs->CheckState = matroxOldCheckState;\n break;\n\n case FB_ACCEL_MATROX_MGA2064W:\n funcs->CheckState = matrox2064WCheckState;\n break;\n }\n\n funcs->SetState = matroxSetState;\n funcs->EngineReset = matroxEngineReset;\n funcs->EngineSync = matroxEngineSync;\n funcs->FlushTextureCache = matroxFlushTextureCache;\n funcs->FlushReadCache = matroxFlushReadCache;\n\n funcs->DrawRectangle = matroxDrawRectangle;\n funcs->DrawLine = matroxDrawLine;\n funcs->FillTriangle = matroxFillTriangle;\n funcs->TextureTriangles = matroxTextureTriangles;\n\n /* will be set dynamically: funcs->FillRectangle, funcs->Blit, funcs->StretchBlit */\n\n /* Generic CRTC1 support */\n mdrv->primary = dfb_screens_at( DSCID_PRIMARY );\n\n /* G200/G400/G450/G550 Backend Scaler Support */\n if (mdrv->accelerator == FB_ACCEL_MATROX_MGAG200 ||\n mdrv->accelerator == FB_ACCEL_MATROX_MGAG400)\n dfb_layers_register( mdrv->primary, driver_data, &matroxBesFuncs );\n\n /* G400/G450/G550 CRTC2 support */\n if (mdrv->accelerator == FB_ACCEL_MATROX_MGAG400 &&\n dfb_config->matrox_crtc2)\n {\n mdrv->secondary = dfb_screens_register( device, driver_data,\n &matroxCrtc2ScreenFuncs );\n\n dfb_layers_register( mdrv->secondary, driver_data, &matroxCrtc2Funcs );\n dfb_layers_register( mdrv->secondary, driver_data, &matroxSpicFuncs );\n }\n\n return DFB_OK;\n}", "label": 0, "cwe": null, "length": 716 }, { "index": 523668, "code": "sjlj_emit_function_enter (rtx dispatch_label)\n{\n rtx fn_begin, fc, mem, seq;\n\n fc = cfun->eh->sjlj_fc;\n\n start_sequence ();\n\n /* We're storing this libcall's address into memory instead of\n calling it directly. Thus, we must call assemble_external_libcall\n here, as we can not depend on emit_library_call to do it for us. */\n assemble_external_libcall (eh_personality_libfunc);\n mem = adjust_address (fc, Pmode, sjlj_fc_personality_ofs);\n emit_move_insn (mem, eh_personality_libfunc);\n\n mem = adjust_address (fc, Pmode, sjlj_fc_lsda_ofs);\n if (cfun->uses_eh_lsda)\n {\n char buf[20];\n rtx sym;\n\n ASM_GENERATE_INTERNAL_LABEL (buf, \"LLSDA\", current_function_funcdef_no);\n sym = gen_rtx_SYMBOL_REF (Pmode, ggc_strdup (buf));\n SYMBOL_REF_FLAGS (sym) = SYMBOL_FLAG_LOCAL;\n emit_move_insn (mem, sym);\n }\n else\n emit_move_insn (mem, const0_rtx);\n\n#ifdef DONT_USE_BUILTIN_SETJMP\n {\n rtx x, note;\n x = emit_library_call_value (setjmp_libfunc, NULL_RTX, LCT_RETURNS_TWICE,\n\t\t\t\t TYPE_MODE (integer_type_node), 1,\n\t\t\t\t plus_constant (XEXP (fc, 0),\n\t\t\t\t\t\tsjlj_fc_jbuf_ofs), Pmode);\n\n note = emit_note (NOTE_INSN_EXPECTED_VALUE);\n NOTE_EXPECTED_VALUE (note) = gen_rtx_EQ (VOIDmode, x, const0_rtx);\n\n emit_cmp_and_jump_insns (x, const0_rtx, NE, 0,\n\t\t\t TYPE_MODE (integer_type_node), 0, dispatch_label);\n }\n#else\n expand_builtin_setjmp_setup (plus_constant (XEXP (fc, 0), sjlj_fc_jbuf_ofs),\n\t\t\t dispatch_label);\n#endif\n\n emit_library_call (unwind_sjlj_register_libfunc, LCT_NORMAL, VOIDmode,\n\t\t 1, XEXP (fc, 0), Pmode);\n\n seq = get_insns ();\n end_sequence ();\n\n /* ??? Instead of doing this at the beginning of the function,\n do this in a block that is at loop level 0 and dominates all\n can_throw_internal instructions. */\n\n for (fn_begin = get_insns (); ; fn_begin = NEXT_INSN (fn_begin))\n if (GET_CODE (fn_begin) == NOTE\n\t&& NOTE_LINE_NUMBER (fn_begin) == NOTE_INSN_FUNCTION_BEG)\n break;\n emit_insn_after (seq, fn_begin);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 592 }, { "index": 780084, "code": "wrap_send_fstat_subr (FILE *fp, struct wrap_fstat *fstat)\n{\n\tif (!fp) return -1;\n\n\tif (fstat->valid & WRAP_FSTAT_VALID_FTYPE) {\n\t\tint\t\tc = 0;\n\n\t\tswitch (fstat->ftype) {\n\t\tdefault:\n\t\tcase WRAP_FTYPE_INVALID:\n\t\t\tc = 0;\n\t\t\tbreak;\n\t\tcase WRAP_FTYPE_DIR:\t\tc = 'd'; break;\n\t\tcase WRAP_FTYPE_FIFO:\t\tc = 'p'; break;\n\t\tcase WRAP_FTYPE_CSPEC:\t\tc = 'c'; break;\n\t\tcase WRAP_FTYPE_BSPEC:\t\tc = 'b'; break;\n\t\tcase WRAP_FTYPE_REG:\t\tc = '-'; break;\n\t\tcase WRAP_FTYPE_SLINK:\t\tc = 'l'; break;\n\t\tcase WRAP_FTYPE_SOCK:\t\tc = 's'; break;\n\t\tcase WRAP_FTYPE_REGISTRY:\tc = 'R'; break;\n\t\tcase WRAP_FTYPE_OTHER:\t\tc = 'o'; break;\n\t\t}\n\n\t\tif (c) {\n\t\t\tfprintf (fp, \" f%c\", c);\n\t\t} else {\n\t\t\treturn -1;\n\t\t}\n\t}\n\n\tif (fstat->valid & WRAP_FSTAT_VALID_MODE) {\n\t\tfprintf (fp, \" m%04o\", fstat->mode);\n\t}\n\n\tif (fstat->valid & WRAP_FSTAT_VALID_LINKS) {\n\t\tfprintf (fp, \" l%lu\", fstat->links);\n\t}\n\n\tif (fstat->valid & WRAP_FSTAT_VALID_SIZE) {\n\t\tfprintf (fp, \" s%llu\", fstat->size);\n\t}\n\n\tif (fstat->valid & WRAP_FSTAT_VALID_UID) {\n\t\tfprintf (fp, \" u%lu\", fstat->uid);\n\t}\n\n\tif (fstat->valid & WRAP_FSTAT_VALID_GID) {\n\t\tfprintf (fp, \" g%lu\", fstat->gid);\n\t}\n\n\tif (fstat->valid & WRAP_FSTAT_VALID_ATIME) {\n\t\tfprintf (fp, \" ta%lu\", fstat->atime);\n\t}\n\n\tif (fstat->valid & WRAP_FSTAT_VALID_MTIME) {\n\t\tfprintf (fp, \" tm%lu\", fstat->mtime);\n\t}\n\n\tif (fstat->valid & WRAP_FSTAT_VALID_CTIME) {\n\t\tfprintf (fp, \" tc%lu\", fstat->ctime);\n\t}\n\n\tif (fstat->valid & WRAP_FSTAT_VALID_FILENO) {\n\t\tfprintf (fp, \" i%llu\", fstat->fileno);\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 564 }, { "index": 238098, "code": "FullBleedCapable (PAPER_SIZE ps, FullbleedType *fbType, float *xOverSpray, float *yOverSpray,\n float *fLeftOverSpray, float *fTopOverSpray)\n{\n BYTE sDevIdStr[DevIDBuffSize];\n char *pStr;\n if (pSS->IOMode.bDevID && (pSS->GetDeviceID (sDevIdStr, DevIDBuffSize, FALSE)) == NO_ERROR)\n {\n if ((pStr = strstr ((char *) sDevIdStr, \";S:\")))\n {\n\t\t\tchar byte13 = pStr[18];\n\t\t\tshort value = (byte13 >= '0' && byte13 <= '9') ? byte13 - '0' : \n\t\t\t\t\t ((byte13 >= 'A' && byte13 <= 'F') ? byte13 - 'A' + 10 :\n\t\t\t\t\t ((byte13 >= 'a' && byte13 <= 'f') ? byte13 - 'a' + 10 : -1));\n\t\t\tswitch (ps)\n\t\t\t{\n\t\t\t\tcase PHOTO_SIZE:\n\t\t\t\tcase A6:\n\t\t\t\tcase CARD_4x6:\n\t\t\t\tcase OUFUKU:\n\t\t\t\tcase HAGAKI:\n\t\t\t\tcase A6_WITH_TEAR_OFF_TAB:\n\t\t\t\t{\n\t\t\t\t\t*xOverSpray = (float) 0.216;\n\t\t\t\t\t*yOverSpray = (float) 0.174;\n\n\t\t\t\t\tif (fLeftOverSpray)\n\t\t\t\t\t\t*fLeftOverSpray = (float) 0.098;\n\t\t\t\t\tif (fTopOverSpray)\n\t\t\t\t\t\t*fTopOverSpray = (float) 0.070;\n\n\t\t\t\t\tif (ps == PHOTO_SIZE || ps == A6_WITH_TEAR_OFF_TAB)\n\t\t\t\t\t\t*fbType = fullbleed4EdgeAllMedia;\n\t\t\t\t\telse if ((value != -1) && ((value & 0x03) == 0x03))\n\t\t\t\t\t\t*fbType = fullbleed4EdgeAllMedia;\n\t\t\t\t\telse if ((value != -1) && ((value & 0x01) == 0x01))\n\t\t\t\t\t\t*fbType = fullbleed4EdgePhotoMedia;\n\t\t\t\t\telse if ((value != -1) && ((value & 0x02) == 0x02))\n\t\t\t\t\t\t*fbType = fullbleed4EdgeNonPhotoMedia;\n\t\t\t\t\telse\n\t\t\t\t\t\t*fbType = fullbleed3EdgeAllMedia;\n\n\t\t\t\t\treturn TRUE;\n\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\tbreak;\n\t\t\t}\n }\n }\n\telse\n\t{\n\t\tswitch (ps)\n\t\t{\n\t\t\tcase PHOTO_SIZE:\n\t\t\tcase A6:\n\t\t\tcase CARD_4x6:\n\t\t\tcase OUFUKU:\n\t\t\tcase HAGAKI:\n\t\t\tcase A6_WITH_TEAR_OFF_TAB:\n\t\t\t{\n\t\t\t\t*xOverSpray = (float) 0.216;\n\t\t\t\t*yOverSpray = (float) 0.174;\n\n\t\t\t\tif (fLeftOverSpray)\n\t\t\t\t\t*fLeftOverSpray = (float) 0.098;\n\t\t\t\tif (fTopOverSpray)\n\t\t\t\t\t*fTopOverSpray = (float) 0.070;\n\n\t\t\t\tif (ps == PHOTO_SIZE || ps == A6_WITH_TEAR_OFF_TAB)\n\t\t\t\t\t*fbType = fullbleed4EdgeAllMedia;\n\t\t\t\telse\n\t\t\t\t\t*fbType = fullbleed3EdgeAllMedia;\n\n\t\t\t\treturn TRUE;\n\t\t\t}\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t}\n *xOverSpray = (float) 0;\n *yOverSpray = (float) 0;\n if (fLeftOverSpray)\n *fLeftOverSpray = (float) 0;\n if (fTopOverSpray)\n *fTopOverSpray = (float) 0;\n\t*fbType = fullbleedNotSupported;\n return FALSE;\n}", "label": 0, "cwe": null, "length": 839 }, { "index": 120817, "code": "detect_proxy(struct connectdata *conn)\n{\n char *proxy = NULL;\n\n#ifndef CURL_DISABLE_HTTP\n /* If proxy was not specified, we check for default proxy environment\n * variables, to enable i.e Lynx compliance:\n *\n * http_proxy=http://some.server.dom:port/\n * https_proxy=http://some.server.dom:port/\n * ftp_proxy=http://some.server.dom:port/\n * no_proxy=domain1.dom,host.domain2.dom\n * (a comma-separated list of hosts which should\n * not be proxied, or an asterisk to override\n * all proxy variables)\n * all_proxy=http://some.server.dom:port/\n * (seems to exist for the CERN www lib. Probably\n * the first to check for.)\n *\n * For compatibility, the all-uppercase versions of these variables are\n * checked if the lowercase versions don't exist.\n */\n char *no_proxy=NULL;\n char proxy_env[128];\n\n no_proxy=curl_getenv(\"no_proxy\");\n if(!no_proxy)\n no_proxy=curl_getenv(\"NO_PROXY\");\n\n if(!check_noproxy(conn->host.name, no_proxy)) {\n /* It was not listed as without proxy */\n const char *protop = conn->handler->scheme;\n char *envp = proxy_env;\n char *prox;\n\n /* Now, build _proxy and check for such a one to use */\n while(*protop)\n *envp++ = (char)tolower((int)*protop++);\n\n /* append _proxy */\n strcpy(envp, \"_proxy\");\n\n /* read the protocol proxy: */\n prox=curl_getenv(proxy_env);\n\n /*\n * We don't try the uppercase version of HTTP_PROXY because of\n * security reasons:\n *\n * When curl is used in a webserver application\n * environment (cgi or php), this environment variable can\n * be controlled by the web server user by setting the\n * http header 'Proxy:' to some value.\n *\n * This can cause 'internal' http/ftp requests to be\n * arbitrarily redirected by any external attacker.\n */\n if(!prox && !Curl_raw_equal(\"http_proxy\", proxy_env)) {\n /* There was no lowercase variable, try the uppercase version: */\n Curl_strntoupper(proxy_env, proxy_env, sizeof(proxy_env));\n prox=curl_getenv(proxy_env);\n }\n\n if(prox && *prox) { /* don't count \"\" strings */\n proxy = prox; /* use this */\n }\n else {\n proxy = curl_getenv(\"all_proxy\"); /* default proxy to use */\n if(!proxy)\n proxy=curl_getenv(\"ALL_PROXY\");\n }\n } /* if(!check_noproxy(conn->host.name, no_proxy)) - it wasn't specified\n non-proxy */\n if(no_proxy)\n free(no_proxy);\n\n#else /* !CURL_DISABLE_HTTP */\n\n (void)conn;\n#endif /* CURL_DISABLE_HTTP */\n\n return proxy;\n}", "label": 0, "cwe": null, "length": 654 }, { "index": 13523, "code": "GMT_f_test (double chisq1, GMT_LONG nu1, double chisq2, GMT_LONG nu2, double *prob)\n{\n\t/* Routine to compute the probability that\n\t\ttwo variances are the same.\n\t\tchisq1 is distributed as chisq with\n\t\tnu1 degrees of freedom; ditto for\n\t\tchisq2 and nu2. If these are independent\n\t\tand we form the ratio\n\t\tF = max(chisq1,chisq2)/min(chisq1,chisq2)\n\t\tthen we can ask what is the probability\n\t\tthat an F greater than this would occur\n\t\tby chance. It is this probability that\n\t\tis returned in prob. When prob is small,\n\t\tit is likely that the two chisq represent\n\t\ttwo different populations; the confidence\n\t\tthat the two do not represent the same pop\n\t\tis 1.0 - prob. This is a two-sided test.\n\tThis follows some ideas in Numerical Recipes, CRC Handbook,\n\tand Abramowitz and Stegun. */\n\n\tdouble\tf, df1, df2, p1, p2;\n\n\tif ( chisq1 <= 0.0) {\n\t\tfprintf(stderr,\"GMT_f_test: Chi-Square One <= 0.0\\n\");\n\t\treturn(-1);\n\t}\n\tif ( chisq2 <= 0.0) {\n\t\tfprintf(stderr,\"GMT_f_test: Chi-Square Two <= 0.0\\n\");\n\t\treturn(-1);\n\t}\n\tif (chisq1 > chisq2) {\n\t\tf = chisq1/chisq2;\n\t\tdf1 = (double)nu1;\n\t\tdf2 = (double)nu2;\n\t}\n\telse {\n\t\tf = chisq2/chisq1;\n\t\tdf1 = (double)nu2;\n\t\tdf2 = (double)nu1;\n\t}\n\tif (GMT_inc_beta(0.5*df2, 0.5*df1, df2/(df2+df1*f), &p1) ) {\n\t\tfprintf(stderr,\"GMT_f_test: Trouble on 1st GMT_inc_beta call.\\n\");\n\t\treturn(-1);\n\t}\n\tif (GMT_inc_beta(0.5*df1, 0.5*df2, df1/(df1+df2/f), &p2) ) {\n\t\tfprintf(stderr,\"GMT_f_test: Trouble on 2nd GMT_inc_beta call.\\n\");\n\t\treturn(-1);\n\t}\n\t*prob = p1 + (1.0 - p2);\n\treturn(0);\n}", "label": 0, "cwe": null, "length": 562 }, { "index": 227902, "code": "e1000_get_phy_info_m88(struct e1000_hw *hw)\n{\n\tstruct e1000_phy_info *phy = &hw->phy;\n\ts32 ret_val;\n\tu16 phy_data;\n\tbool link;\n\n\tDEBUGFUNC(\"e1000_get_phy_info_m88\");\n\n\tif (hw->phy.media_type != e1000_media_type_copper) {\n\t\tDEBUGOUT(\"Phy info is only valid for copper media\\n\");\n\t\tret_val = -E1000_ERR_CONFIG;\n\t\tgoto out;\n\t}\n\n\tret_val = e1000_phy_has_link_generic(hw, 1, 0, &link);\n\tif (ret_val)\n\t\tgoto out;\n\n\tif (!link) {\n\t\tDEBUGOUT(\"Phy info is only valid if link is up\\n\");\n\t\tret_val = -E1000_ERR_CONFIG;\n\t\tgoto out;\n\t}\n\n\tret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data);\n\tif (ret_val)\n\t\tgoto out;\n\n\tphy->polarity_correction = (phy_data & M88E1000_PSCR_POLARITY_REVERSAL)\n\t ? true : false;\n\n\tret_val = e1000_check_polarity_m88(hw);\n\tif (ret_val)\n\t\tgoto out;\n\n\tret_val = phy->ops.read_reg(hw, M88E1000_PHY_SPEC_STATUS, &phy_data);\n\tif (ret_val)\n\t\tgoto out;\n\n\tphy->is_mdix = (phy_data & M88E1000_PSSR_MDIX) ? true : false;\n\n\tif ((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS) {\n#if 0\n\t\tret_val = hw->phy.ops.get_cable_length(hw);\n#endif\n\t\tret_val = -E1000_ERR_CONFIG;\n\t\tif (ret_val)\n\t\t\tgoto out;\n\n\t\tret_val = phy->ops.read_reg(hw, PHY_1000T_STATUS, &phy_data);\n\t\tif (ret_val)\n\t\t\tgoto out;\n\n\t\tphy->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS)\n\t\t ? e1000_1000t_rx_status_ok\n\t\t : e1000_1000t_rx_status_not_ok;\n\n\t\tphy->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS)\n\t\t ? e1000_1000t_rx_status_ok\n\t\t : e1000_1000t_rx_status_not_ok;\n\t} else {\n\t\t/* Set values to \"undefined\" */\n\t\tphy->cable_length = E1000_CABLE_LENGTH_UNDEFINED;\n\t\tphy->local_rx = e1000_1000t_rx_status_undefined;\n\t\tphy->remote_rx = e1000_1000t_rx_status_undefined;\n\t}\n\nout:\n\treturn ret_val;\n}", "label": 1, "cwe": "CWE-other", "length": 597 }, { "index": 464790, "code": "open_table_get_mdl_lock(THD *thd, Open_table_context *ot_ctx,\n MDL_request *mdl_request,\n uint flags,\n MDL_ticket **mdl_ticket)\n{\n MDL_request mdl_request_shared;\n\n if (flags & (MYSQL_OPEN_FORCE_SHARED_MDL |\n MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL))\n {\n /*\n MYSQL_OPEN_FORCE_SHARED_MDL flag means that we are executing\n PREPARE for a prepared statement and want to override\n the type-of-operation aware metadata lock which was set\n in the parser/during view opening with a simple shared\n metadata lock.\n This is necessary to allow concurrent execution of PREPARE\n and LOCK TABLES WRITE statement against the same table.\n\n MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL flag means that we open\n the table in order to get information about it for one of I_S\n queries and also want to override the type-of-operation aware\n shared metadata lock which was set earlier (e.g. during view\n opening) with a high-priority shared metadata lock.\n This is necessary to avoid unnecessary waiting and extra\n ER_WARN_I_S_SKIPPED_TABLE warnings when accessing I_S tables.\n\n These two flags are mutually exclusive.\n */\n DBUG_ASSERT(!(flags & MYSQL_OPEN_FORCE_SHARED_MDL) ||\n !(flags & MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL));\n\n mdl_request_shared.init(&mdl_request->key,\n (flags & MYSQL_OPEN_FORCE_SHARED_MDL) ?\n MDL_SHARED : MDL_SHARED_HIGH_PRIO,\n MDL_TRANSACTION);\n mdl_request= &mdl_request_shared;\n }\n\n if (flags & MYSQL_OPEN_FAIL_ON_MDL_CONFLICT)\n {\n /*\n When table is being open in order to get data for I_S table,\n we might have some tables not only open but also locked (e.g. when\n this happens under LOCK TABLES or in a stored function).\n As a result by waiting on a conflicting metadata lock to go away\n we may create a deadlock which won't entirely belong to the\n MDL subsystem and thus won't be detectable by this subsystem's\n deadlock detector.\n To avoid such situation we skip the trouble-making table if\n there is a conflicting lock.\n */\n if (thd->mdl_context.try_acquire_lock(mdl_request))\n return TRUE;\n if (mdl_request->ticket == NULL)\n {\n my_error(ER_WARN_I_S_SKIPPED_TABLE, MYF(0),\n mdl_request->key.db_name(), mdl_request->key.name());\n return TRUE;\n }\n }\n else\n {\n /*\n We are doing a normal table open. Let us try to acquire a metadata\n lock on the table. If there is a conflicting lock, acquire_lock()\n will wait for it to go away. Sometimes this waiting may lead to a\n deadlock, with the following results:\n 1) If a deadlock is entirely within MDL subsystem, it is\n detected by the deadlock detector of this subsystem.\n ER_LOCK_DEADLOCK error is produced. Then, the error handler\n that is installed prior to the call to acquire_lock() attempts\n to request a back-off and retry. Upon success, ER_LOCK_DEADLOCK\n error is suppressed, otherwise propagated up the calling stack.\n 2) Otherwise, a deadlock may occur when the wait-for graph\n includes edges not visible to the MDL deadlock detector.\n One such example is a wait on an InnoDB row lock, e.g. when:\n conn C1 gets SR MDL lock on t1 with SELECT * FROM t1\n conn C2 gets a row lock on t2 with SELECT * FROM t2 FOR UPDATE\n conn C3 gets in and waits on C1 with DROP TABLE t0, t1\n conn C2 continues and blocks on C3 with SELECT * FROM t0\n conn C1 deadlocks by waiting on C2 by issuing SELECT * FROM\n t2 LOCK IN SHARE MODE.\n Such circular waits are currently only resolved by timeouts,\n e.g. @@innodb_lock_wait_timeout or @@lock_wait_timeout.\n */\n MDL_deadlock_handler mdl_deadlock_handler(ot_ctx);\n\n thd->push_internal_handler(&mdl_deadlock_handler);\n bool result= thd->mdl_context.acquire_lock(mdl_request,\n ot_ctx->get_timeout());\n thd->pop_internal_handler();\n\n if (result && !ot_ctx->can_recover_from_failed_open())\n return TRUE;\n }\n *mdl_ticket= mdl_request->ticket;\n return FALSE;\n}", "label": 0, "cwe": null, "length": 977 }, { "index": 24489, "code": "fft_double (\n unsigned NumSamples,\n int InverseTransform,\n double *RealIn,\n double *ImagIn,\n double *RealOut,\n double *ImagOut )\n{\n unsigned NumBits; /* Number of bits needed to store indices */\n unsigned i, j, k, n;\n unsigned BlockSize, BlockEnd;\n\n double angle_numerator = -2.0 * DDC_PI; // this is - to match matlab\n double tr, ti; /* temp real, temp imaginary */\n\n if ( !IsPowerOfTwo(NumSamples) || (NumSamples < 2) )\n {\n fprintf (\n stderr,\n \"Error in fft(): NumSamples=%u is not power of two\\n\",\n NumSamples );\n\n return 0;\n }\n\n if ( InverseTransform )\n angle_numerator = -angle_numerator;\n\n CHECKPOINTERDOUBLE ( RealIn );\n CHECKPOINTERDOUBLE ( RealOut );\n CHECKPOINTERDOUBLE ( ImagOut );\n\n NumBits = NumberOfBitsNeeded ( NumSamples );\n\n /*\n ** Do simultaneous data copy and bit-reversal ordering into outputs...\n */\n\n for ( i=0; i < NumSamples; i++ )\n {\n j = ReverseBits ( i, NumBits );\n RealOut[j] = RealIn[i];\n ImagOut[j] = (ImagIn == NULL) ? 0.0 : ImagIn[i];\n }\n\n /*\n ** Do the FFT itself...\n */\n\n BlockEnd = 1;\n for ( BlockSize = 2; BlockSize <= NumSamples; BlockSize <<= 1 )\n {\n double delta_angle = angle_numerator / (double)BlockSize;\n double sm2 = sin ( -2 * delta_angle );\n double sm1 = sin ( -delta_angle );\n double cm2 = cos ( -2 * delta_angle );\n double cm1 = cos ( -delta_angle );\n double w = 2 * cm1;\n /* double ar[3], ai[3]; replaced array with fixed vals below - labenski */\n double ar0, ar1, ar2, ai0, ai1, ai2;\n\n for ( i=0; i < NumSamples; i += BlockSize )\n {\n ar2 = cm2;\n ar1 = cm1;\n\n ai2 = sm2;\n ai1 = sm1;\n\n for ( j=i, n=0; n < BlockEnd; j++, n++ )\n {\n ar0 = w*ar1 - ar2;\n ar2 = ar1;\n ar1 = ar0;\n\n ai0 = w*ai1 - ai2;\n ai2 = ai1;\n ai1 = ai0;\n\n k = j + BlockEnd;\n tr = ar0*RealOut[k] - ai0*ImagOut[k];\n ti = ar0*ImagOut[k] + ai0*RealOut[k];\n\n RealOut[k] = RealOut[j] - tr;\n ImagOut[k] = ImagOut[j] - ti;\n\n RealOut[j] += tr;\n ImagOut[j] += ti;\n }\n }\n\n BlockEnd = BlockSize;\n }\n\n /*\n ** Need to normalize if inverse transform...\n */\n\n if ( InverseTransform )\n {\n double denom = (double)NumSamples;\n\n for ( i=0; i < NumSamples; i++ )\n {\n RealOut[i] /= denom;\n ImagOut[i] /= denom;\n }\n }\n\n return 1;\n}", "label": 0, "cwe": null, "length": 768 }, { "index": 57029, "code": "should_continue_strong_branching(lp_prob *p, int i, int cand_num,\n double st_time, int total_iters, \n int *should_continue)\n{\n double allowed_time = 0;\n *should_continue = TRUE;\n int min_cands;\n int verbosity = p->par.verbosity;\n //verbosity = 20;\n if (p->bc_level<1) {\n allowed_time = 20*p->comp_times.lp/p->iter_num;\n //allowed_iter = 20*p->lp_stat.lp_total_iter_num/(p->iter_num + 1);\n if (allowed_time < 2) {\n\t allowed_time = 2;\n }\n //allowed_iter = MAX(allowed_iter, 1000);\n min_cands = MIN(cand_num,p->par.strong_branching_cand_num_max);\n } else {\n allowed_time = p->comp_times.lp/2 - p->comp_times.strong_branching;\n //allowed_iter = (int)((p->lp_stat.lp_total_iter_num -\n //\t\t p->lp_stat.str_br_total_iter_num)/2.0);\n min_cands = MIN(cand_num,p->par.strong_branching_cand_num_min);\n }\n PRINT(verbosity,10,(\"allowed_time = %f\\n\",allowed_time));\n if (st_time/(i+1)*cand_num < allowed_time) {\n /* all cands can be evaluated in given time */\n *should_continue = TRUE;\n } else if (i >= min_cands-1 && st_time>allowed_time) {\n /* time is up and min required candidates have been evaluated */\n *should_continue = FALSE;\n } else if (p->par.user_set_max_presolve_iter == TRUE) {\n /* user specified a limit and we wont change it */\n *should_continue = TRUE;\n } else {\n /* we will not be able to evaluate all candidates in given time. we\n * reduce the number of iterations */\n double min_iters = \n (allowed_time-st_time)*total_iters/st_time/(cand_num-i+1);\n if (min_iters<10) {\n /*\n * cant evaluate all candidates in given time with just 10 iters\n * as well. we have a choice: increase iters and do min_cands\n * or do ten iters and try to evaluate max possible num of cands.\n * we like the second option more.\n */\n min_iters = 10;\n }\n if (p->par.use_hot_starts && !p->par.branch_on_cuts) {\n set_itlim_hotstart(p->lp_data, (int) min_iters);\n set_itlim(p->lp_data, (int) min_iters);\n } else {\n set_itlim(p->lp_data, (int) min_iters);\n }\n PRINT(verbosity,6, (\"iteration limit set to %d\\n\", (int )min_iters));\n *should_continue = TRUE;\n }\n PRINT(verbosity,29, (\"strong branching i = %d\\n\",i));\n return 0;\n}", "label": 0, "cwe": null, "length": 659 }, { "index": 627628, "code": "ndarray_init(PyObject *self, PyObject *args, PyObject *kwds)\n{\n NDArrayObject *nd = (NDArrayObject *)self;\n static char *kwlist[] = {\n \"obj\", \"shape\", \"strides\", \"offset\", \"format\", \"flags\", \"getbuf\", NULL\n };\n PyObject *v = NULL; /* initializer: scalar, list, tuple or base object */\n PyObject *shape = NULL; /* size of each dimension */\n PyObject *strides = NULL; /* number of bytes to the next elt in each dim */\n Py_ssize_t offset = 0; /* buffer offset */\n PyObject *format = simple_format; /* struct module specifier: \"B\" */\n int flags = ND_DEFAULT; /* base buffer and ndarray flags */\n\n int getbuf = PyBUF_UNUSED; /* re-exporter: getbuffer request flags */\n\n\n if (!PyArg_ParseTupleAndKeywords(args, kwds, \"O|OOnOii\", kwlist,\n &v, &shape, &strides, &offset, &format, &flags, &getbuf))\n return -1;\n\n /* NDArrayObject is re-exporter */\n if (PyObject_CheckBuffer(v) && shape == NULL) {\n if (strides || offset || format != simple_format ||\n !(flags == ND_DEFAULT || flags == ND_REDIRECT)) {\n PyErr_SetString(PyExc_TypeError,\n \"construction from exporter object only takes 'obj', 'getbuf' \"\n \"and 'flags' arguments\");\n return -1;\n }\n\n getbuf = (getbuf == PyBUF_UNUSED) ? PyBUF_FULL_RO : getbuf;\n\n if (ndarray_init_staticbuf(v, nd, getbuf) < 0)\n return -1;\n\n init_flags(nd->head);\n nd->head->flags |= flags;\n\n return 0;\n }\n\n /* NDArrayObject is the original base object. */\n if (getbuf != PyBUF_UNUSED) {\n PyErr_SetString(PyExc_TypeError,\n \"getbuf argument only valid for construction from exporter \"\n \"object\");\n return -1;\n }\n if (shape == NULL) {\n PyErr_SetString(PyExc_TypeError,\n \"shape is a required argument when constructing from \"\n \"list, tuple or scalar\");\n return -1;\n }\n\n if (flags & ND_VAREXPORT) {\n nd->flags |= ND_VAREXPORT;\n flags &= ~ND_VAREXPORT;\n }\n\n /* Initialize and push the first base buffer onto the linked list. */\n return ndarray_push_base(nd, v, shape, strides, offset, format, flags);\n}", "label": 0, "cwe": null, "length": 569 }, { "index": 898902, "code": "init_run_state(struct fpi_ssm *ssm)\n{\n\tstruct fp_img_dev *dev = ssm->priv;\n\tstruct uru4k_dev *urudev = dev->priv;\n\n\tswitch (ssm->cur_state) {\n\tcase INIT_GET_HWSTAT:\n\t\tsm_read_reg(ssm, REG_HWSTAT);\n\t\tbreak;\n\tcase INIT_CHECK_HWSTAT_REBOOT:\n\t\turudev->last_hwstat = urudev->last_reg_rd[0];\n\t\tif ((urudev->last_hwstat & 0x84) == 0x84)\n\t\t\tfpi_ssm_next_state(ssm);\n\t\telse\n\t\t\tfpi_ssm_jump_to_state(ssm, INIT_CHECK_HWSTAT_POWERDOWN);\n\t\tbreak;\n\tcase INIT_REBOOT_POWER: ;\n\t\tstruct fpi_ssm *rebootsm = fpi_ssm_new(dev->dev, rebootpwr_run_state,\n\t\t\tREBOOTPWR_NUM_STATES);\n\t\trebootsm->priv = dev;\n\t\tfpi_ssm_start_subsm(ssm, rebootsm);\n\t\tbreak;\n\tcase INIT_CHECK_HWSTAT_POWERDOWN:\n\t\tif ((urudev->last_hwstat & 0x80) == 0)\n\t\t\tsm_set_hwstat(ssm, urudev->last_hwstat | 0x80);\n\t\telse\n\t\t\tfpi_ssm_next_state(ssm);\n\t\tbreak;\n\tcase INIT_POWERUP: ;\n\t\tif (!IRQ_HANDLER_IS_RUNNING(urudev)) {\n\t\t\tfpi_ssm_mark_aborted(ssm, -EIO);\n\t\t\tbreak;\n\t\t}\n\t\turudev->irq_cb_data = ssm;\n\t\turudev->irq_cb = init_scanpwr_irq_cb;\n\n\t\tstruct fpi_ssm *powerupsm = fpi_ssm_new(dev->dev, powerup_run_state,\n\t\t\tPOWERUP_NUM_STATES);\n\t\tpowerupsm->priv = dev;\n\t\tfpi_ssm_start_subsm(ssm, powerupsm);\n\t\tbreak;\n\tcase INIT_AWAIT_SCAN_POWER:\n\t\tif (urudev->scanpwr_irq_timeouts < 0) {\n\t\t\tfpi_ssm_next_state(ssm);\n\t\t\tbreak;\n\t\t}\n\n\t\t/* sometimes the 56aa interrupt that we are waiting for never arrives,\n\t\t * so we include this timeout loop to retry the whole process 3 times\n\t\t * if we don't get an irq any time soon. */\n\t\turudev->scanpwr_irq_timeout = fpi_timeout_add(300,\n\t\t\tinit_scanpwr_timeout, ssm);\n\t\tif (!urudev->scanpwr_irq_timeout) {\n\t\t\tfpi_ssm_mark_aborted(ssm, -ETIME);\n\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\tcase INIT_DONE:\n\t\tif (urudev->scanpwr_irq_timeout) {\n\t\t\tfpi_timeout_cancel(urudev->scanpwr_irq_timeout);\n\t\t\turudev->scanpwr_irq_timeout = NULL;\n\t\t}\n\t\turudev->irq_cb_data = NULL;\n\t\turudev->irq_cb = NULL;\n\t\tfpi_ssm_next_state(ssm);\n\t\tbreak;\n\tcase INIT_GET_VERSION:\n\t\tsm_read_regs(ssm, REG_DEVICE_INFO, 16);\n\t\tbreak;\n\tcase INIT_REPORT_VERSION:\n\t\t/* Likely hardware revision, and firmware version.\n\t\t * Not sure which is which. */\n\t\tfp_info(\"Versions %02x%02x and %02x%02x\",\n\t\t\turudev->last_reg_rd[10], urudev->last_reg_rd[11],\n\t\t\turudev->last_reg_rd[4], urudev->last_reg_rd[5]);\n\t\tfpi_ssm_mark_completed(ssm);\n\t\tbreak;\n\t}\n}", "label": 0, "cwe": null, "length": 765 }, { "index": 94698, "code": "blit_setup( int format, int *bytes_per_row, int *pitch, int mode )\r\n{\r\n\tif( mode == 3 )\r\n\t{\r\n\t\tswitch( format )\r\n\t\t{\r\n\t\tcase 0x0001:\r\n\t\t\t*bytes_per_row = 0x1000;\r\n\t\t\t*pitch = 0x1000;\r\n\t\t\tbreak;\r\n\r\n\t\tcase 0x0081:\r\n\t\t\t*bytes_per_row = 4*8;\r\n\t\t\t*pitch = 36*8;\r\n\t\t\tbreak;\r\n\r\n\t\tdefault:\r\n//\t\tcase 0x00f1:\r\n//\t\tcase 0x00f9:\r\n//\t\tcase 0x00fd:\r\n\t\t\t*bytes_per_row = (64 - (format>>2))*0x08;\r\n\t\t\t*pitch = 0x200;\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\telse\r\n\t{\r\n\t\tswitch( format )\r\n\t\t{\r\n\t\tcase 0x00bd: /* Numan Athletics */\r\n\t\t\t*bytes_per_row = 4;\r\n\t\t\t*pitch = 0x120;\r\n\t\t\tbreak;\r\n\t\tcase 0x008d: /* Numan Athletics */\r\n\t\t\t*bytes_per_row = 8;\r\n\t\t\t*pitch = 0x120;\r\n\t\t\tbreak;\r\n\r\n\t\tcase 0x0000: /* Numan (used to clear spriteram) */\r\n//\t\t0000 0000 0000 : src0\r\n//\t\t0000 0001 0000 : dst0\r\n//\t\t003d 75a0 : src (7AEB40)\r\n//\t\t---- ---- : spriteram\r\n//\t\t0800\t\t : numbytes\r\n//\t\t0000\t\t : blit\r\n\t\t\t*bytes_per_row = 0x10;\r\n\t\t\t*pitch = 0;\r\n\t\t\tbreak;\r\n\r\n\t\tcase 0x0001:\r\n\t\t\t*bytes_per_row = 0x1000;\r\n\t\t\t*pitch = 0x1000;\r\n\t\t\tbreak;\r\n\r\n\t\tcase 0x0401: /* F/A */\r\n\t\t\t*bytes_per_row = 4*0x40;\r\n\t\t\t*pitch = 36*0x40;\r\n\t\t\tbreak;\r\n\r\n\t\tdefault:\r\n//\t\tcase 0x00f1:\r\n//\t\tcase 0x0781:\r\n//\t\tcase 0x07c1:\r\n//\t\tcase 0x07e1:\r\n\t\t\t*bytes_per_row = (64 - (format>>5))*0x40;\r\n\t\t\t*pitch = 0x1000;\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n}", "label": 0, "cwe": null, "length": 539 }, { "index": 984190, "code": "flush_wqes(struct nes_device *nesdev, struct nes_qp *nesqp,\n\t\tu32 which_wq, u32 wait_completion)\n{\n\tstruct nes_cqp_request *cqp_request;\n\tstruct nes_hw_cqp_wqe *cqp_wqe;\n\tu32 sq_code = (NES_IWARP_CQE_MAJOR_FLUSH << 16) | NES_IWARP_CQE_MINOR_FLUSH;\n\tu32 rq_code = (NES_IWARP_CQE_MAJOR_FLUSH << 16) | NES_IWARP_CQE_MINOR_FLUSH;\n\tint ret;\n\n\tcqp_request = nes_get_cqp_request(nesdev);\n\tif (cqp_request == NULL) {\n\t\tnes_debug(NES_DBG_QP, \"Failed to get a cqp_request.\\n\");\n\t\treturn;\n\t}\n\tif (wait_completion) {\n\t\tcqp_request->waiting = 1;\n\t\tatomic_set(&cqp_request->refcount, 2);\n\t} else {\n\t\tcqp_request->waiting = 0;\n\t}\n\tcqp_wqe = &cqp_request->cqp_wqe;\n\tnes_fill_init_cqp_wqe(cqp_wqe, nesdev);\n\n\t/* If wqe in error was identified, set code to be put into cqe */\n\tif ((nesqp->term_sq_flush_code) && (which_wq & NES_CQP_FLUSH_SQ)) {\n\t\twhich_wq |= NES_CQP_FLUSH_MAJ_MIN;\n\t\tsq_code = (CQE_MAJOR_DRV << 16) | nesqp->term_sq_flush_code;\n\t\tnesqp->term_sq_flush_code = 0;\n\t}\n\n\tif ((nesqp->term_rq_flush_code) && (which_wq & NES_CQP_FLUSH_RQ)) {\n\t\twhich_wq |= NES_CQP_FLUSH_MAJ_MIN;\n\t\trq_code = (CQE_MAJOR_DRV << 16) | nesqp->term_rq_flush_code;\n\t\tnesqp->term_rq_flush_code = 0;\n\t}\n\n\tif (which_wq & NES_CQP_FLUSH_MAJ_MIN) {\n\t\tcqp_wqe->wqe_words[NES_CQP_QP_WQE_FLUSH_SQ_CODE] = cpu_to_le32(sq_code);\n\t\tcqp_wqe->wqe_words[NES_CQP_QP_WQE_FLUSH_RQ_CODE] = cpu_to_le32(rq_code);\n\t}\n\n\tcqp_wqe->wqe_words[NES_CQP_WQE_OPCODE_IDX] =\n\t\t\tcpu_to_le32(NES_CQP_FLUSH_WQES | which_wq);\n\tcqp_wqe->wqe_words[NES_CQP_WQE_ID_IDX] = cpu_to_le32(nesqp->hwqp.qp_id);\n\n\tnes_post_cqp_request(nesdev, cqp_request);\n\n\tif (wait_completion) {\n\t\t/* Wait for CQP */\n\t\tret = wait_event_timeout(cqp_request->waitq, (cqp_request->request_done != 0),\n\t\t\t\tNES_EVENT_TIMEOUT);\n\t\tnes_debug(NES_DBG_QP, \"Flush SQ QP WQEs completed, ret=%u,\"\n\t\t\t\t\" CQP Major:Minor codes = 0x%04X:0x%04X\\n\",\n\t\t\t\tret, cqp_request->major_code, cqp_request->minor_code);\n\t\tnes_put_cqp_request(nesdev, cqp_request);\n\t}\n}", "label": 0, "cwe": null, "length": 693 }, { "index": 259832, "code": "fli_create_window( Window parent,\n Colormap m,\n const char * wname )\n{\n Window win;\n XClassHint clh;\n char *tmp;\n XTextProperty xtpwname,\n xtpmachine;\n char *label = fl_strdup( wname ? wname : \"\" );\n FL_FORM *mainform = fl_get_app_mainform( );\n\n st_xswa.colormap = m;\n st_wmask |= CWColormap;\n\n /* no decoration means unmanagered windows */\n\n if ( st_wmborder == FL_NOBORDER\n && ( st_xsh.flags & fli_wmstuff.pos_request)\n == fli_wmstuff.pos_request )\n {\n /* Turning this on will make the window truely unmananged, might have\n problems with the input focus and colormaps */\n\n st_xswa.override_redirect = True;\n st_wmask |= CWOverrideRedirect;\n }\n\n /* MWM uses root window's cursor, don't want that */\n\n if ( ( st_wmask & CWCursor ) != CWCursor )\n {\n st_xswa.cursor = fl_get_cursor_byname( FL_DEFAULT_CURSOR );\n st_wmask |= CWCursor;\n }\n\n if ( st_wmborder != FL_FULLBORDER )\n {\n st_xswa.save_under = True;\n st_wmask |= CWSaveUnder;\n\n /* For small transient windows, we don't need backing store */\n\n if ( st_xsh.width < 200 || st_xsh.height < 200 )\n st_xswa.backing_store = NotUseful;\n }\n\n if ( mainform && mainform->window )\n {\n st_xwmh.flags |= WindowGroupHint;\n st_xwmh.window_group = mainform->window;\n }\n\n#if FL_DEBUG >= ML_WARN\n fli_dump_state_info( fl_vmode, \"fli_create_window\" );\n#endif\n\n win = XCreateWindow( flx->display, parent,\n st_xsh.x, st_xsh.y, st_xsh.width, st_xsh.height,\n bwidth, fli_depth( fl_vmode ), InputOutput,\n fli_visual( fl_vmode ), st_wmask, &st_xswa );\n\n if ( fli_cntl.debug > 3 )\n {\n XFlush( flx->display );\n fprintf( stderr, \"****CreateWin OK**** sleeping 1 seconds\\n\" );\n sleep( 1 );\n }\n\n clh.res_name = fl_label_to_res_name( label );\n clh.res_class = \"XForm\";\n\n /* Command property is set elsewhere */\n\n xtpwname.value = 0;\n XStringListToTextProperty( label ? &label : 0, 1, &xtpwname );\n\n XSetWMProperties( flx->display, win, &xtpwname, &xtpwname,\n 0, 0, &st_xsh, &st_xwmh, &clh );\n\n if ( xtpwname.value )\n XFree( xtpwname.value );\n\n xtpmachine.value = 0;\n tmp = get_machine_name( flx->display );\n\n if ( XStringListToTextProperty( &tmp, 1, &xtpmachine ) )\n XSetWMClientMachine( flx->display, win, &xtpmachine );\n\n if ( xtpmachine.value )\n XFree( xtpmachine.value );\n\n fli_create_gc( win );\n\n if ( st_wmborder == FL_TRANSIENT )\n {\n if ( mainform && mainform->window )\n XSetTransientForHint( flx->display, win, mainform->window );\n else\n XSetTransientForHint( flx->display, win, fl_root );\n }\n\n fl_free( label );\n\n return win;\n}", "label": 0, "cwe": null, "length": 828 }, { "index": 148851, "code": "CreateBattleGround(BattleGroundTypeId bgTypeId, bool IsArena, uint32 MinPlayersPerTeam, uint32 MaxPlayersPerTeam, uint32 LevelMin, uint32 LevelMax, char const* BattleGroundName, uint32 MapID, float Team1StartLocX, float Team1StartLocY, float Team1StartLocZ, float Team1StartLocO, float Team2StartLocX, float Team2StartLocY, float Team2StartLocZ, float Team2StartLocO)\n{\n // Create the BG\n BattleGround* bg = NULL;\n switch (bgTypeId)\n {\n case BATTLEGROUND_AV: bg = new BattleGroundAV; break;\n case BATTLEGROUND_WS: bg = new BattleGroundWS; break;\n case BATTLEGROUND_AB: bg = new BattleGroundAB; break;\n case BATTLEGROUND_NA: bg = new BattleGroundNA; break;\n case BATTLEGROUND_BE: bg = new BattleGroundBE; break;\n case BATTLEGROUND_AA: bg = new BattleGroundAA; break;\n case BATTLEGROUND_EY: bg = new BattleGroundEY; break;\n case BATTLEGROUND_RL: bg = new BattleGroundRL; break;\n case BATTLEGROUND_SA: bg = new BattleGroundSA; break;\n case BATTLEGROUND_DS: bg = new BattleGroundDS; break;\n case BATTLEGROUND_RV: bg = new BattleGroundRV; break;\n case BATTLEGROUND_IC: bg = new BattleGroundIC; break;\n case BATTLEGROUND_RB: bg = new BattleGroundRB; break;\n default: bg = new BattleGround; break; // placeholder for non implemented BG\n }\n\n bg->SetMapId(MapID);\n bg->SetTypeID(bgTypeId);\n bg->SetArenaorBGType(IsArena);\n bg->SetMinPlayersPerTeam(MinPlayersPerTeam);\n bg->SetMaxPlayersPerTeam(MaxPlayersPerTeam);\n bg->SetMinPlayers(MinPlayersPerTeam * 2);\n bg->SetMaxPlayers(MaxPlayersPerTeam * 2);\n bg->SetName(BattleGroundName);\n bg->SetTeamStartLoc(ALLIANCE, Team1StartLocX, Team1StartLocY, Team1StartLocZ, Team1StartLocO);\n bg->SetTeamStartLoc(HORDE, Team2StartLocX, Team2StartLocY, Team2StartLocZ, Team2StartLocO);\n bg->SetLevelRange(LevelMin, LevelMax);\n\n // add bg to update list\n AddBattleGround(bg->GetInstanceID(), bg->GetTypeID(), bg);\n\n // return some not-null value, bgTypeId is good enough for me\n return bgTypeId;\n}", "label": 0, "cwe": null, "length": 588 }, { "index": 619053, "code": "write_applesingle(GFile *f, LPCTSTR epsname, LPCTSTR pictname)\n{\n unsigned long resource_length;\n unsigned long data_length;\n unsigned char data[256];\n unsigned char *buffer;\n GFile *epsfile;\n unsigned long len;\n unsigned int count;\n int code = 0;\n\n buffer = (unsigned char *)malloc(COPY_BUF_SIZE);\n if (buffer == (unsigned char *)NULL)\n\treturn -1;\n\n /* get length of data and resources */\n epsfile = gfile_open(epsname, gfile_modeRead);\n if (epsname == NULL) {\n\tfree(buffer);\n\treturn -1;\n }\n data_length = gfile_get_length(epsfile);\n resource_length = write_resource_pict(NULL, pictname);\n\n memset(data, 0, sizeof(data));\n memcpy(data, apple_single_magic, 4);\t/* magic signature */\n put_bigendian_dword(data+4, 0x00020000);\t/* version */\n /* 16 bytes filler */\n put_bigendian_word(data+24, 3); /* 3 entries, finder, data and resource */\n /* finder descriptor */\n put_bigendian_dword(data+26, 9);\t/* finder id */\n put_bigendian_dword(data+30, 62);\t/* offset */\n put_bigendian_dword(data+34, 32);\t/* length */\n /* data descriptor */\n put_bigendian_dword(data+38, 1);\t/* data fork id */\n put_bigendian_dword(data+42, 94);\t/* offset */\n put_bigendian_dword(data+46, data_length);\t/* length */\n /* resource descriptor */\n put_bigendian_dword(data+50, 2);\t/* resource fork id */\n put_bigendian_dword(data+54, 94+data_length);\t/* offset */\n put_bigendian_dword(data+58, resource_length);\t/* length */\n /* finder info */\n memcpy(data+62, \"EPSF\", 4);\t\t/* file type */\n memcpy(data+66, \"MSWD\", 4);\t\t/* file creator */\n data[70] = 1;\t\t\t/* ??? need to check finder info */\n gfile_write(f, data, 94);\n\n /* Copy data fork */\n len = data_length;\n while ( (count = (unsigned int)min(len,COPY_BUF_SIZE)) != 0 ) {\n\tcount = (int)gfile_read(epsfile, buffer, count);\n\tgfile_write(f, buffer, count);\n\tif (count == 0) {\n\t len = 0;\n\t code = -1;\n\t}\n\telse\n\t len -= count;\n }\n gfile_close(epsfile);\n free(buffer);\n if (code < 0)\n\treturn code;\n\n /* Now copy the resource fork */\n if (write_resource_pict(f, pictname) <= 0)\n\treturn -1;\n return 0;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 650 }, { "index": 3246, "code": "mgt_cpu_to_le(int type, void *data)\n{\n\tswitch (type) {\n\tcase OID_TYPE_U32:\n\t\t*(u32 *) data = cpu_to_le32(*(u32 *) data);\n\t\tbreak;\n\tcase OID_TYPE_BUFFER:{\n\t\t\tstruct obj_buffer *buff = data;\n\t\t\tbuff->size = cpu_to_le32(buff->size);\n\t\t\tbuff->addr = cpu_to_le32(buff->addr);\n\t\t\tbreak;\n\t\t}\n\tcase OID_TYPE_BSS:{\n\t\t\tstruct obj_bss *bss = data;\n\t\t\tbss->age = cpu_to_le16(bss->age);\n\t\t\tbss->channel = cpu_to_le16(bss->channel);\n\t\t\tbss->capinfo = cpu_to_le16(bss->capinfo);\n\t\t\tbss->rates = cpu_to_le16(bss->rates);\n\t\t\tbss->basic_rates = cpu_to_le16(bss->basic_rates);\n\t\t\tbreak;\n\t\t}\n\tcase OID_TYPE_BSSLIST:{\n\t\t\tstruct obj_bsslist *list = data;\n\t\t\tint i;\n\t\t\tlist->nr = cpu_to_le32(list->nr);\n\t\t\tfor (i = 0; i < list->nr; i++)\n\t\t\t\tmgt_cpu_to_le(OID_TYPE_BSS, &list->bsslist[i]);\n\t\t\tbreak;\n\t\t}\n\tcase OID_TYPE_FREQUENCIES:{\n\t\t\tstruct obj_frequencies *freq = data;\n\t\t\tint i;\n\t\t\tfreq->nr = cpu_to_le16(freq->nr);\n\t\t\tfor (i = 0; i < freq->nr; i++)\n\t\t\t\tfreq->mhz[i] = cpu_to_le16(freq->mhz[i]);\n\t\t\tbreak;\n\t\t}\n\tcase OID_TYPE_MLME:{\n\t\t\tstruct obj_mlme *mlme = data;\n\t\t\tmlme->id = cpu_to_le16(mlme->id);\n\t\t\tmlme->state = cpu_to_le16(mlme->state);\n\t\t\tmlme->code = cpu_to_le16(mlme->code);\n\t\t\tbreak;\n\t\t}\n\tcase OID_TYPE_MLMEEX:{\n\t\t\tstruct obj_mlmeex *mlme = data;\n\t\t\tmlme->id = cpu_to_le16(mlme->id);\n\t\t\tmlme->state = cpu_to_le16(mlme->state);\n\t\t\tmlme->code = cpu_to_le16(mlme->code);\n\t\t\tmlme->size = cpu_to_le16(mlme->size);\n\t\t\tbreak;\n\t\t}\n\tcase OID_TYPE_ATTACH:{\n\t\t\tstruct obj_attachment *attach = data;\n\t\t\tattach->id = cpu_to_le16(attach->id);\n\t\t\tattach->size = cpu_to_le16(attach->size);\n\t\t\tbreak;\n\t}\n\tcase OID_TYPE_SSID:\n\tcase OID_TYPE_KEY:\n\tcase OID_TYPE_ADDR:\n\tcase OID_TYPE_RAW:\n\t\tbreak;\n\tdefault:\n\t\tBUG();\n\t}\n}", "label": 0, "cwe": null, "length": 591 }, { "index": 639067, "code": "command_stats(object *op, const char *params) {\n player *pl;\n\n if (*params == '\\0') {\n draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR,\n \"Who?\");\n return;\n }\n\n pl = find_player_partial_name(params);\n if (pl == NULL) {\n draw_ext_info(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_ERROR,\n \"No such player.\");\n return;\n }\n\n draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DM,\n \"[Fixed]Statistics for %s:\", pl->ob->name);\n\n draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DM,\n \"[fixed]Str : %-2d H.P. : %-4d MAX : %d\",\n pl->ob->stats.Str, pl->ob->stats.hp, pl->ob->stats.maxhp);\n\n draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DM,\n \"[fixed]Dex : %-2d S.P. : %-4d MAX : %d\",\n pl->ob->stats.Dex, pl->ob->stats.sp, pl->ob->stats.maxsp);\n\n draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DM,\n \"[fixed]Con : %-2d AC : %-4d WC : %d\",\n pl->ob->stats.Con, pl->ob->stats.ac, pl->ob->stats.wc);\n\n draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DM,\n \"[fixed]Int : %-2d Damage : %d\",\n pl->ob->stats.Int, pl->ob->stats.dam);\n\n draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DM,\n \"[fixed]Wis : %-2d EXP : %\"FMT64,\n pl->ob->stats.Wis, pl->ob->stats.exp);\n\n draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DM,\n \"[fixed]Pow : %-2d Grace : %d\",\n pl->ob->stats.Pow, pl->ob->stats.grace);\n\n draw_ext_info_format(NDI_UNIQUE, 0, op, MSG_TYPE_COMMAND, MSG_TYPE_COMMAND_DM,\n \"[fixed]Cha : %-2d Food : %d\",\n pl->ob->stats.Cha, pl->ob->stats.food);\n}", "label": 0, "cwe": null, "length": 583 }, { "index": 914900, "code": "computeLoopDisposition(const SCEV *S, const Loop *L) {\n switch (S->getSCEVType()) {\n case scConstant:\n return LoopInvariant;\n case scTruncate:\n case scZeroExtend:\n case scSignExtend:\n return getLoopDisposition(cast(S)->getOperand(), L);\n case scAddRecExpr: {\n const SCEVAddRecExpr *AR = cast(S);\n\n // If L is the addrec's loop, it's computable.\n if (AR->getLoop() == L)\n return LoopComputable;\n\n // Add recurrences are never invariant in the function-body (null loop).\n if (!L)\n return LoopVariant;\n\n // This recurrence is variant w.r.t. L if L contains AR's loop.\n if (L->contains(AR->getLoop()))\n return LoopVariant;\n\n // This recurrence is invariant w.r.t. L if AR's loop contains L.\n if (AR->getLoop()->contains(L))\n return LoopInvariant;\n\n // This recurrence is variant w.r.t. L if any of its operands\n // are variant.\n for (SCEVAddRecExpr::op_iterator I = AR->op_begin(), E = AR->op_end();\n I != E; ++I)\n if (!isLoopInvariant(*I, L))\n return LoopVariant;\n\n // Otherwise it's loop-invariant.\n return LoopInvariant;\n }\n case scAddExpr:\n case scMulExpr:\n case scUMaxExpr:\n case scSMaxExpr: {\n const SCEVNAryExpr *NAry = cast(S);\n bool HasVarying = false;\n for (SCEVNAryExpr::op_iterator I = NAry->op_begin(), E = NAry->op_end();\n I != E; ++I) {\n LoopDisposition D = getLoopDisposition(*I, L);\n if (D == LoopVariant)\n return LoopVariant;\n if (D == LoopComputable)\n HasVarying = true;\n }\n return HasVarying ? LoopComputable : LoopInvariant;\n }\n case scUDivExpr: {\n const SCEVUDivExpr *UDiv = cast(S);\n LoopDisposition LD = getLoopDisposition(UDiv->getLHS(), L);\n if (LD == LoopVariant)\n return LoopVariant;\n LoopDisposition RD = getLoopDisposition(UDiv->getRHS(), L);\n if (RD == LoopVariant)\n return LoopVariant;\n return (LD == LoopInvariant && RD == LoopInvariant) ?\n LoopInvariant : LoopComputable;\n }\n case scUnknown:\n // All non-instruction values are loop invariant. All instructions are loop\n // invariant if they are not contained in the specified loop.\n // Instructions are never considered invariant in the function body\n // (null loop) because they are defined within the \"loop\".\n if (Instruction *I = dyn_cast(cast(S)->getValue()))\n return (L && !L->contains(I)) ? LoopInvariant : LoopVariant;\n return LoopInvariant;\n case scCouldNotCompute:\n llvm_unreachable(\"Attempt to use a SCEVCouldNotCompute object!\");\n return LoopVariant;\n default: break;\n }\n llvm_unreachable(\"Unknown SCEV kind!\");\n return LoopVariant;\n}", "label": 0, "cwe": null, "length": 748 }, { "index": 899521, "code": "wpa_handle_1_of_2 ( struct wpa_common_ctx *ctx,\n\t\t\t struct eapol_key_pkt *pkt, int is_rsn,\n\t\t\t struct wpa_kie *kie )\n{\n\tint rc;\n\n\t/*\n\t * WPA and RSN do this completely differently.\n\t *\n\t * The idea of encoding the GTK (or PMKID, or various other\n\t * things) into a KDE that looks like an information element\n\t * is an RSN innovation; old WPA code never encapsulates\n\t * things like that. If it looks like an info element, it\n\t * really is (for the WPA IE check in frames 2/4 and 3/4). The\n\t * \"key data encrypted\" bit in the info field is also specific\n\t * to RSN.\n\t *\n\t * So from an old WPA host, 3/4 does not contain an\n\t * encapsulated GTK. The first frame of the GK handshake\n\t * contains it, encrypted, but without a KDE wrapper, and with\n\t * the key ID field (which iPXE doesn't use) shoved away in\n\t * the reserved bits in the info field, and the TxRx bit\n\t * stealing the Install bit's spot.\n\t */\n\n\tif ( is_rsn && ( pkt->info & EAPOL_KEY_INFO_KEY_ENC ) ) {\n\t\trc = wpa_maybe_install_gtk ( ctx,\n\t\t\t\t\t ( union ieee80211_ie * ) pkt->data,\n\t\t\t\t\t pkt->data + pkt->datalen,\n\t\t\t\t\t pkt->rsc );\n\t\tif ( rc < 0 ) {\n\t\t\tDBGC ( ctx, \"WPA %p: failed to install GTK in 1/2: \"\n\t\t\t \"%s\\n\", ctx, strerror ( rc ) );\n\t\t\treturn wpa_fail ( ctx, rc );\n\t\t}\n\t} else {\n\t\trc = kie->decrypt ( &ctx->ptk.kek, pkt->iv, pkt->data,\n\t\t\t\t &pkt->datalen );\n\t\tif ( rc < 0 ) {\n\t\t\tDBGC ( ctx, \"WPA %p: failed to decrypt GTK: %s\\n\",\n\t\t\t ctx, strerror ( rc ) );\n\t\t\treturn rc; /* non-fatal */\n\t\t}\n\t\tif ( pkt->datalen > sizeof ( ctx->gtk.tk ) ) {\n\t\t\tDBGC ( ctx, \"WPA %p: too much GTK data (%d > %zd)\\n\",\n\t\t\t ctx, pkt->datalen, sizeof ( ctx->gtk.tk ) );\n\t\t\treturn wpa_fail ( ctx, -EINVAL );\n\t\t}\n\n\t\tmemcpy ( &ctx->gtk.tk, pkt->data, pkt->datalen );\n\t\twpa_install_gtk ( ctx, pkt->datalen, pkt->rsc );\n\t}\n\n\tDBGC ( ctx, \"WPA %p: received 1/2, looks OK\\n\", ctx );\n\n\treturn wpa_send_final ( ctx, pkt, is_rsn, kie );\n}", "label": 0, "cwe": null, "length": 624 }, { "index": 916930, "code": "notice_events (saver_info *si, Window window, Bool top_p)\n{\n saver_preferences *p = &si->prefs;\n XWindowAttributes attrs;\n unsigned long events;\n Window root, parent, *kids;\n unsigned int nkids;\n int screen_no;\n\n if (XtWindowToWidget (si->dpy, window))\n /* If it's one of ours, don't mess up its event mask. */\n return;\n\n if (!XQueryTree (si->dpy, window, &root, &parent, &kids, &nkids))\n return;\n if (window == root)\n top_p = False;\n\n /* Figure out which screen this window is on, for the diagnostics. */\n for (screen_no = 0; screen_no < si->nscreens; screen_no++)\n if (root == RootWindowOfScreen (si->screens[screen_no].screen))\n break;\n\n XGetWindowAttributes (si->dpy, window, &attrs);\n events = ((attrs.all_event_masks | attrs.do_not_propagate_mask)\n\t & KeyPressMask);\n\n /* Select for SubstructureNotify on all windows.\n Select for KeyPress on all windows that already have it selected.\n\n Note that we can't select for ButtonPress, because of X braindamage:\n only one client at a time may select for ButtonPress on a given\n window, though any number can select for KeyPress. Someone explain\n *that* to me.\n\n So, if the user spends a while clicking the mouse without ever moving\n the mouse or touching the keyboard, we won't know that they've been\n active, and the screensaver will come on. That sucks, but I don't\n know how to get around it.\n\n Since X presents mouse wheels as clicks, this applies to those, too:\n scrolling through a document using only the mouse wheel doesn't\n count as activity... Fortunately, /proc/interrupts helps, on\n systems that have it. Oh, if it's a PS/2 mouse, not serial or USB.\n This sucks!\n */\n XSelectInput (si->dpy, window, SubstructureNotifyMask | events);\n\n if (top_p && p->debug_p && (events & KeyPressMask))\n {\n /* Only mention one window per tree (hack hack). */\n fprintf (stderr, \"%s: %d: selected KeyPress on 0x%lX\\n\",\n blurb(), screen_no, (unsigned long) window);\n top_p = False;\n }\n\n if (kids)\n {\n while (nkids)\n\tnotice_events (si, kids [--nkids], top_p);\n XFree ((char *) kids);\n }\n}", "label": 0, "cwe": null, "length": 587 }, { "index": 853051, "code": "phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,\n\t\t\t unsigned long page_size_mask)\n{\n\tunsigned long pages = 0, next;\n\tunsigned long last_map_addr = end;\n\tint i = pud_index(addr);\n\n\tfor (; i < PTRS_PER_PUD; i++, addr = next) {\n\t\tpud_t *pud = pud_page + pud_index(addr);\n\t\tpmd_t *pmd;\n\t\tpgprot_t prot = PAGE_KERNEL;\n\n\t\tnext = (addr & PUD_MASK) + PUD_SIZE;\n\t\tif (addr >= end) {\n\t\t\tif (!after_bootmem &&\n\t\t\t !e820_any_mapped(addr & PUD_MASK, next, E820_RAM) &&\n\t\t\t !e820_any_mapped(addr & PUD_MASK, next, E820_RESERVED_KERN))\n\t\t\t\tset_pud(pud, __pud(0));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (pud_val(*pud)) {\n\t\t\tif (!pud_large(*pud)) {\n\t\t\t\tpmd = pmd_offset(pud, 0);\n\t\t\t\tlast_map_addr = phys_pmd_init(pmd, addr, end,\n\t\t\t\t\t\t\t page_size_mask, prot);\n\t\t\t\t__flush_tlb_all();\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\t/*\n\t\t\t * If we are ok with PG_LEVEL_1G mapping, then we will\n\t\t\t * use the existing mapping.\n\t\t\t *\n\t\t\t * Otherwise, we will split the gbpage mapping but use\n\t\t\t * the same existing protection bits except for large\n\t\t\t * page, so that we don't violate Intel's TLB\n\t\t\t * Application note (317080) which says, while changing\n\t\t\t * the page sizes, new and old translations should\n\t\t\t * not differ with respect to page frame and\n\t\t\t * attributes.\n\t\t\t */\n\t\t\tif (page_size_mask & (1 << PG_LEVEL_1G)) {\n\t\t\t\tif (!after_bootmem)\n\t\t\t\t\tpages++;\n\t\t\t\tlast_map_addr = next;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tprot = pte_pgprot(pte_clrhuge(*(pte_t *)pud));\n\t\t}\n\n\t\tif (page_size_mask & (1<> PAGE_SHIFT,\n\t\t\t\t\tPAGE_KERNEL_LARGE));\n\t\t\tspin_unlock(&init_mm.page_table_lock);\n\t\t\tlast_map_addr = next;\n\t\t\tcontinue;\n\t\t}\n\n\t\tpmd = alloc_low_page();\n\t\tlast_map_addr = phys_pmd_init(pmd, addr, end, page_size_mask,\n\t\t\t\t\t prot);\n\n\t\tspin_lock(&init_mm.page_table_lock);\n\t\tpud_populate(&init_mm, pud, pmd);\n\t\tspin_unlock(&init_mm.page_table_lock);\n\t}\n\t__flush_tlb_all();\n\n\tupdate_page_count(PG_LEVEL_1G, pages);\n\n\treturn last_map_addr;\n}", "label": 0, "cwe": null, "length": 620 }, { "index": 151187, "code": "prop_request(struct propctx *ctx, const char **names) \n{\n unsigned i, new_values, total_values;\n\n if(!ctx || !names) return SASL_BADPARAM;\n\n /* Count how many we need to add */\n for(new_values=0; names[new_values]; new_values++);\n\n /* Do we need to add ANY? */\n if(!new_values) return SASL_OK;\n\n /* We always want at least one extra to mark the end of the array */\n total_values = new_values + ctx->used_values + 1;\n\n /* Do we need to increase the size of our propval table? */\n if(total_values > ctx->allocated_values) {\n\tunsigned max_in_pool;\n\n\t/* Do we need a larger base pool? */\n\tmax_in_pool = (unsigned) (ctx->mem_base->size / sizeof(struct propval));\n\t\n\tif(total_values <= max_in_pool) {\n\t /* Don't increase the size of the base pool, just use what\n\t we need */\n\t ctx->allocated_values = total_values;\n\t ctx->mem_base->unused =\n\t\tctx->mem_base->size - (sizeof(struct propval)\n\t\t\t\t * ctx->allocated_values);\n \t} else {\n\t /* We need to allocate more! */\n\t unsigned new_alloc_length;\n\t size_t new_size;\n\n\t new_alloc_length = 2 * ctx->allocated_values;\n\t while(total_values > new_alloc_length) {\n\t\tnew_alloc_length *= 2;\n\t }\n\n\t new_size = new_alloc_length * sizeof(struct propval);\n\t ctx->mem_base = resize_proppool(ctx->mem_base, new_size);\n\n\t if(!ctx->mem_base) {\n\t\tctx->values = NULL;\n\t\tctx->allocated_values = ctx->used_values = 0;\n\t\treturn SASL_NOMEM;\n\t }\n\n\t /* It worked! Update the structure! */\n\t ctx->values = (struct propval *)ctx->mem_base->data;\n\t ctx->allocated_values = new_alloc_length;\n\t ctx->mem_base->unused = ctx->mem_base->size\n\t\t- sizeof(struct propval) * ctx->allocated_values;\n\t}\n\n\t/* Clear out new propvals */\n\tmemset(&(ctx->values[ctx->used_values]), 0,\n\t sizeof(struct propval) * (ctx->allocated_values - ctx->used_values));\n\n /* Finish updating the context -- we've extended the list! */\n\t/* ctx->list_end = (char **)(ctx->values + ctx->allocated_values); */\n\t/* xxx test here */\n\tctx->list_end = (char **)(ctx->values + total_values);\n }\n\n /* Now do the copy, or referencing rather */\n for(i=0;iused_values;j++) {\n\t if(!strcmp(ctx->values[j].name, names[i])) {\n\t\tflag = 1;\n\t\tbreak;\n\t }\n\t}\n\n\t/* We already have it... skip! */\n\tif(flag) continue;\n\n\tctx->values[ctx->used_values++].name = names[i];\n }\n\n prop_clear(ctx, 0);\n\n return SASL_OK;\n}", "label": 0, "cwe": null, "length": 673 }, { "index": 48869, "code": "appendString(\n\tconst char *\tpszStr,\n\teColorType\t\teColor,\n\tFLMBOOL\t\t\tbForceColor)\n{\n\tchar\t\tszTmpBuf [80];\n\tFLMUINT\tuiLen;\n\n\t// If we are doing a single line, and we have filled our buffer\n\t// with the maximum visible characters, we are done.\n\n\tif (m_bSingleLineOnly && m_uiVisibleChars == m_uiMaxChars)\n\t{\n\t\tgoto Exit;\n\t}\n\n\t// Output a color change, if any\n\n\tchangeColor( eColor, bForceColor);\n\n\t// Check for a NULL pointer - treat like empty string.\n\n\tif (pszStr)\n\t{\n\n\t\t// Output each character to the buffer. Use the special encoding\n\t\t// format for reserved HTML characters.\n\n\t\tuiLen = 0;\n\t\twhile (*pszStr)\n\t\t{\n\n\t\t\t// Can format any character in six characters in HTML - \"&#xxx;\"\n\t\t\t// xxx is the decimal digit for the character.\n\t\t\t// Therefore, if we have room for less than six characters in\n\t\t\t// the temporary buffer, output what we currently have in the\n\t\t\t// buffer.\n\n\t\t\tif (uiLen + 6 >= sizeof( szTmpBuf))\n\t\t\t{\n\t\t\t\tszTmpBuf [uiLen] = 0;\n\t\t\t\toutputStr( szTmpBuf);\n\n\t\t\t\t// Start filling the temporary buffer again.\n\n\t\t\t\tuiLen = 0;\n\t\t\t}\n\n\t\t\t// Check for reserved characters that need to be encoded.\n\n\t\t\tif ((int)(*pszStr) > 126 ||\n\t\t\t\t *pszStr == '\\\"' ||\n\t\t\t\t *pszStr == '&' ||\n\t\t\t\t *pszStr == '<' ||\n\t\t\t\t *pszStr == '>')\n\t\t\t{\n\t\t\t\tf_sprintf( &szTmpBuf [uiLen], \"&#%d;\", (int)(*pszStr));\n\t\t\t\twhile (szTmpBuf [uiLen])\n\t\t\t\t{\n\t\t\t\t\tuiLen++;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tszTmpBuf [uiLen++] = *pszStr;\n\t\t\t}\n\n\t\t\tif (m_bSingleLineOnly)\n\t\t\t{\n\n\t\t\t\t// If we have reached the maximum visible characters,\n\t\t\t\t// quit outputting.\n\n\t\t\t\tif (++m_uiVisibleChars == m_uiMaxChars)\n\t\t\t\t{\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// Go to the next character\n\n\t\t\tpszStr++;\n\t\t}\n\n\t\t// If there is something in the temporary buffer, output it.\n\n\t\tif (uiLen)\n\t\t{\n\t\t\tszTmpBuf [uiLen] = 0;\n\t\t\toutputStr( szTmpBuf);\n\t\t}\n\t}\n\nExit:\n\n\treturn;\n}", "label": 0, "cwe": null, "length": 558 }, { "index": 629953, "code": "nrrdAxesSplit(Nrrd *nout, const Nrrd *nin,\n unsigned int saxi, size_t sizeFast, size_t sizeSlow) {\n static const char me[]=\"nrrdAxesSplit\", func[]=\"axsplit\";\n unsigned int ai;\n\n if (!(nout && nin)) {\n biffAddf(NRRD, \"%s: got NULL pointer\", me);\n return 1;\n }\n if (!( saxi <= nin->dim-1 )) {\n biffAddf(NRRD, \"%s: given axis (%d) outside valid range [0, %d]\",\n me, saxi, nin->dim-1);\n return 1;\n }\n if (NRRD_DIM_MAX == nin->dim) {\n biffAddf(NRRD, \"%s: given nrrd already at NRRD_DIM_MAX (%d)\",\n me, NRRD_DIM_MAX);\n return 1;\n }\n if (!(sizeFast*sizeSlow == nin->axis[saxi].size)) {\n char stmp[4][AIR_STRLEN_SMALL];\n biffAddf(NRRD, \"%s: # samples along axis %d (%s) != \"\n \"product of fast and slow sizes (%s * %s = %s)\", me, saxi,\n airSprintSize_t(stmp[0], nin->axis[saxi].size),\n airSprintSize_t(stmp[1], sizeFast),\n airSprintSize_t(stmp[2], sizeSlow),\n airSprintSize_t(stmp[3], sizeFast*sizeSlow));\n return 1;\n }\n if (nout != nin) {\n if (_nrrdCopy(nout, nin, (NRRD_BASIC_INFO_COMMENTS_BIT\n | (nrrdStateKeyValuePairsPropagate\n ? 0\n : NRRD_BASIC_INFO_KEYVALUEPAIRS_BIT)))) {\n biffAddf(NRRD, \"%s:\", me);\n return 1;\n }\n }\n nout->dim = 1 + nin->dim;\n for (ai=nin->dim-1; ai>=saxi+1; ai--) {\n _nrrdAxisInfoCopy(&(nout->axis[ai+1]), &(nin->axis[ai]),\n NRRD_AXIS_INFO_NONE);\n }\n /* the ONLY thing we can say about the new axes are their sizes */\n _nrrdAxisInfoInit(&(nout->axis[saxi]));\n _nrrdAxisInfoInit(&(nout->axis[saxi+1]));\n nout->axis[saxi].size = sizeFast;\n nout->axis[saxi+1].size = sizeSlow;\n if (nrrdContentSet_va(nout, func, nin, \"%d,%d,%d\",\n saxi, sizeFast, sizeSlow)) {\n biffAddf(NRRD, \"%s:\", me);\n return 1;\n }\n /* all basic information already copied by nrrdCopy */\n return 0;\n}", "label": 0, "cwe": null, "length": 660 }, { "index": 704001, "code": "convert_addr_from_pdu(Octstr *id, Octstr *addr, long ton, long npi, Octstr *alt_addr_charset)\n{\n long reason = SMPP_ESME_ROK;\n \n if (addr == NULL)\n return reason;\n\n switch(ton) {\n case GSM_ADDR_TON_INTERNATIONAL:\n /*\n * Checks to perform:\n * 1) assume international number has at least 7 chars\n * 2) the whole source addr consist of digits, exception '+' in front\n */\n if (octstr_len(addr) < 7) {\n /* We consider this as a \"non-hard\" condition, since there \"may\"\n * be international numbers routable that are < 7 digits. Think\n * of 2 digit country code + 3 digit emergency code. */\n warning(0, \"SMPP[%s]: Mallformed addr `%s', generally expected at least 7 digits. \",\n octstr_get_cstr(id),\n octstr_get_cstr(addr));\n } else if (octstr_get_char(addr, 0) == '+' &&\n !octstr_check_range(addr, 1, 256, gw_isdigit)) {\n error(0, \"SMPP[%s]: Mallformed addr `%s', expected all digits. \",\n octstr_get_cstr(id),\n octstr_get_cstr(addr));\n reason = SMPP_ESME_RINVSRCADR;\n goto error;\n } else if (octstr_get_char(addr, 0) != '+' &&\n !octstr_check_range(addr, 0, 256, gw_isdigit)) {\n error(0, \"SMPP[%s]: Mallformed addr `%s', expected all digits. \",\n octstr_get_cstr(id),\n octstr_get_cstr(addr));\n reason = SMPP_ESME_RINVSRCADR;\n goto error;\n }\n /* check if we received leading '00', then remove it*/\n if (octstr_search(addr, octstr_imm(\"00\"), 0) == 0)\n octstr_delete(addr, 0, 2);\n\n /* international, insert '+' if not already here */\n if (octstr_get_char(addr, 0) != '+')\n octstr_insert_char(addr, 0, '+');\n\n break;\n case GSM_ADDR_TON_ALPHANUMERIC:\n if (octstr_len(addr) > 11) {\n /* alphanum sender, max. allowed length is 11 (according to GSM specs) */\n error(0, \"SMPP[%s]: Mallformed addr `%s', alphanum length greater 11 chars. \",\n octstr_get_cstr(id),\n octstr_get_cstr(addr));\n reason = SMPP_ESME_RINVSRCADR;\n goto error;\n }\n if (alt_addr_charset) {\n if (octstr_str_case_compare(alt_addr_charset, \"gsm\") == 0)\n\t\tcharset_gsm_to_utf8(addr);\n else if (charset_convert(addr, octstr_get_cstr(alt_addr_charset), SMPP_DEFAULT_CHARSET) != 0)\n error(0, \"Failed to convert address from charset <%s> to <%s>, leave as is.\",\n octstr_get_cstr(alt_addr_charset), SMPP_DEFAULT_CHARSET);\n }\n break;\n default: /* otherwise don't touch addr, user should handle it */\n break;\n }\n \nerror:\n return reason;\n}", "label": 0, "cwe": null, "length": 738 }, { "index": 879194, "code": "coerce_template_parameter_pack (tree parms,\n int parm_idx,\n tree args,\n tree inner_args,\n int arg_idx,\n tree new_args,\n int* lost,\n tree in_decl,\n tsubst_flags_t complain)\n{\n tree parm = TREE_VEC_ELT (parms, parm_idx);\n int nargs = inner_args ? NUM_TMPL_ARGS (inner_args) : 0;\n tree packed_args;\n tree argument_pack;\n tree packed_types = NULL_TREE;\n\n if (arg_idx > nargs)\n arg_idx = nargs;\n\n packed_args = make_tree_vec (nargs - arg_idx);\n\n if (TREE_CODE (TREE_VALUE (parm)) == PARM_DECL\n && uses_parameter_packs (TREE_TYPE (TREE_VALUE (parm))))\n {\n /* When the template parameter is a non-type template\n parameter pack whose type uses parameter packs, we need\n to look at each of the template arguments\n separately. Build a vector of the types for these\n non-type template parameters in PACKED_TYPES. */\n tree expansion \n = make_pack_expansion (TREE_TYPE (TREE_VALUE (parm)));\n packed_types = tsubst_pack_expansion (expansion, args,\n complain, in_decl);\n\n if (packed_types == error_mark_node)\n return error_mark_node;\n\n /* Check that we have the right number of arguments. */\n if (arg_idx < nargs\n && !PACK_EXPANSION_P (TREE_VEC_ELT (inner_args, arg_idx))\n && nargs - arg_idx != TREE_VEC_LENGTH (packed_types))\n {\n int needed_parms \n = TREE_VEC_LENGTH (parms) - 1 + TREE_VEC_LENGTH (packed_types);\n error (\"wrong number of template arguments (%d, should be %d)\",\n nargs, needed_parms);\n return error_mark_node;\n }\n\n /* If we aren't able to check the actual arguments now\n (because they haven't been expanded yet), we can at least\n verify that all of the types used for the non-type\n template parameter pack are, in fact, valid for non-type\n template parameters. */\n if (arg_idx < nargs \n && PACK_EXPANSION_P (TREE_VEC_ELT (inner_args, arg_idx)))\n {\n int j, len = TREE_VEC_LENGTH (packed_types);\n for (j = 0; j < len; ++j)\n {\n tree t = TREE_VEC_ELT (packed_types, j);\n if (invalid_nontype_parm_type_p (t, complain))\n return error_mark_node;\n }\n }\n }\n\n /* Convert the remaining arguments, which will be a part of the\n parameter pack \"parm\". */\n for (; arg_idx < nargs; ++arg_idx)\n {\n tree arg = TREE_VEC_ELT (inner_args, arg_idx);\n tree actual_parm = TREE_VALUE (parm);\n\n if (packed_types && !PACK_EXPANSION_P (arg))\n {\n /* When we have a vector of types (corresponding to the\n non-type template parameter pack that uses parameter\n packs in its type, as mention above), and the\n argument is not an expansion (which expands to a\n currently unknown number of arguments), clone the\n parm and give it the next type in PACKED_TYPES. */\n actual_parm = copy_node (actual_parm);\n TREE_TYPE (actual_parm) = \n TREE_VEC_ELT (packed_types, arg_idx - parm_idx);\n }\n\n if (arg != error_mark_node)\n\targ = convert_template_argument (actual_parm, \n\t\t\t\t\t arg, new_args, complain, parm_idx,\n\t\t\t\t\t in_decl);\n if (arg == error_mark_node)\n (*lost)++;\n TREE_VEC_ELT (packed_args, arg_idx - parm_idx) = arg; \n }\n\n if (TREE_CODE (TREE_VALUE (parm)) == TYPE_DECL\n || TREE_CODE (TREE_VALUE (parm)) == TEMPLATE_DECL)\n argument_pack = cxx_make_type (TYPE_ARGUMENT_PACK);\n else\n {\n argument_pack = make_node (NONTYPE_ARGUMENT_PACK);\n TREE_TYPE (argument_pack) \n = tsubst (TREE_TYPE (TREE_VALUE (parm)), new_args, complain, in_decl);\n TREE_CONSTANT (argument_pack) = 1;\n }\n\n SET_ARGUMENT_PACK_ARGS (argument_pack, packed_args);\n#ifdef ENABLE_CHECKING\n SET_NON_DEFAULT_TEMPLATE_ARGS_COUNT (packed_args,\n\t\t\t\t TREE_VEC_LENGTH (packed_args));\n#endif\n return argument_pack;\n}", "label": 0, "cwe": null, "length": 956 }, { "index": 22756, "code": "first_block_primesieve (mp_ptr bit_array, mp_limb_t n)\n{\n mp_size_t bits, limbs;\n\n ASSERT (n > 4);\n\n bits = n_to_bit(n);\n limbs = bits / GMP_LIMB_BITS + 1;\n\n /* FIXME: We can skip 5 too, filling with a 5-part pattern. */\n MPN_ZERO (bit_array, limbs);\n bit_array[0] = SIEVE_SEED;\n\n if ((bits + 1) % GMP_LIMB_BITS != 0)\n bit_array[limbs-1] |= MP_LIMB_T_MAX << ((bits + 1) % GMP_LIMB_BITS);\n\n if (n > SEED_LIMIT) {\n mp_limb_t mask, index, i;\n\n ASSERT (n > 49);\n\n mask = 1;\n index = 0;\n i = 1;\n do {\n if ((bit_array[index] & mask) == 0)\n\t{\n\t mp_size_t step, lindex;\n\t mp_limb_t lmask;\n\t unsigned maskrot;\n\n\t step = id_to_n(i);\n/*\t lindex = n_to_bit(id_to_n(i)*id_to_n(i)); */\n\t lindex = i*(step+1)-1+(-(i&1)&(i+1));\n/*\t lindex = i*(step+1+(i&1))-1+(i&1); */\n\t if (lindex > bits)\n\t break;\n\n\t step <<= 1;\n\t maskrot = step % GMP_LIMB_BITS;\n\n\t lmask = CNST_LIMB(1) << (lindex % GMP_LIMB_BITS);\n\t do {\n\t bit_array[lindex / GMP_LIMB_BITS] |= lmask;\n\t lmask = lmask << maskrot | lmask >> (GMP_LIMB_BITS - maskrot);\n\t lindex += step;\n\t } while (lindex <= bits);\n\n/*\t lindex = n_to_bit(id_to_n(i)*bit_to_n(i)); */\n\t lindex = i*(i*3+6)+(i&1);\n\n\t lmask = CNST_LIMB(1) << (lindex % GMP_LIMB_BITS);\n\t for ( ; lindex <= bits; lindex += step) {\n\t bit_array[lindex / GMP_LIMB_BITS] |= lmask;\n\t lmask = lmask << maskrot | lmask >> (GMP_LIMB_BITS - maskrot);\n\t };\n\t}\n mask = mask << 1 | mask >> (GMP_LIMB_BITS-1);\n index += mask & 1;\n i++;\n } while (1);\n }\n}", "label": 0, "cwe": null, "length": 584 }, { "index": 182323, "code": "stk_display_fade( int type, int time )\n{\n SDL_Surface *buffer = 0;\n float alpha;\n float alpha_change; /* per ms */\n int leave = 0;\n int ms;\n\n if ( stk_quit_request ) return;\n \n if ( !stk_display_use_fade ) {\n if ( type == STK_FADE_IN )\n stk_display_update( STK_UPDATE_ALL );\n else {\n stk_surface_fill( stk_display, 0, 0, -1, -1, 0x0 );\n stk_display_update( STK_UPDATE_ALL );\n }\n }\n\n /* get screen contents */\n buffer = stk_surface_create( SDL_SWSURFACE, stk_display->w, stk_display->h );\n SDL_SetColorKey( buffer, 0, 0 );\n stk_surface_blit( stk_display, 0, 0, -1, -1, buffer, 0, 0 );\n\n /* compute alpha and alpha change */\n if ( type == STK_FADE_OUT ) {\n alpha = 255;\n alpha_change = -255.0 / time;\n }\n else {\n alpha = 0;\n alpha_change = 255.0 / time;\n }\n\n /* fade */\n stk_timer_reset();\n while ( !leave ) {\n ms = stk_timer_get_time();\n alpha += alpha_change * ms;\n if ( type == STK_FADE_IN && alpha >= 255 ) break;\n if ( type == STK_FADE_OUT && alpha <= 0 ) break;\n /* update */\n stk_surface_fill( stk_display, 0, 0, -1, -1, 0x0 );\n SDL_SetAlpha( buffer, SDL_SRCALPHA, (int)alpha );\n stk_surface_blit( buffer, 0, 0, -1, -1, stk_display, 0, 0);\n stk_display_update( STK_UPDATE_ALL );\n }\n\n /* update screen */\n SDL_SetAlpha( buffer, 0, 0 );\n if ( type == STK_FADE_IN )\n stk_surface_blit( buffer, 0, 0, -1, -1, stk_display, 0, 0 );\n else\n stk_surface_fill( stk_display, 0, 0, -1, -1, 0x0 );\n stk_display_update( STK_UPDATE_ALL );\n stk_surface_free( &buffer );\n}", "label": 0, "cwe": null, "length": 523 }, { "index": 394707, "code": "start_launch_environment (GdmSimpleSlave *slave,\n char *username,\n char *session_id)\n{\n gboolean display_is_local;\n char *display_name;\n char *seat_id;\n char *display_device;\n char *display_hostname;\n char *auth_file;\n gboolean res;\n\n g_debug (\"GdmSimpleSlave: Running greeter\");\n\n display_is_local = FALSE;\n display_name = NULL;\n seat_id = NULL;\n auth_file = NULL;\n display_device = NULL;\n display_hostname = NULL;\n\n g_object_get (slave,\n \"display-is-local\", &display_is_local,\n \"display-name\", &display_name,\n \"display-seat-id\", &seat_id,\n \"display-hostname\", &display_hostname,\n \"display-x11-authority-file\", &auth_file,\n NULL);\n\n g_debug (\"GdmSimpleSlave: Creating greeter for %s %s\", display_name, display_hostname);\n\n if (slave->priv->server != NULL) {\n display_device = gdm_server_get_display_device (slave->priv->server);\n }\n\n /* FIXME: send a signal back to the master */\n\n /* If XDMCP setup pinging */\n slave->priv->ping_interval = DEFAULT_PING_INTERVAL;\n res = gdm_settings_direct_get_int (GDM_KEY_PING_INTERVAL,\n &(slave->priv->ping_interval));\n\n if ( ! display_is_local && res && slave->priv->ping_interval > 0) {\n alarm (slave->priv->ping_interval);\n }\n\n /* Run the init script. gdmslave suspends until script has terminated */\n gdm_slave_run_script (GDM_SLAVE (slave), GDMCONFDIR \"/Init\", GDM_USERNAME);\n\n g_debug (\"GdmSimpleSlave: Creating greeter on %s %s %s\", display_name, display_device, display_hostname);\n slave->priv->greeter_environment = create_environment (session_id,\n username,\n display_name,\n seat_id,\n display_device,\n display_hostname,\n display_is_local);\n g_signal_connect (slave->priv->greeter_environment,\n \"opened\",\n G_CALLBACK (on_greeter_environment_session_opened),\n slave);\n g_signal_connect (slave->priv->greeter_environment,\n \"started\",\n G_CALLBACK (on_greeter_environment_session_started),\n slave);\n g_signal_connect (slave->priv->greeter_environment,\n \"stopped\",\n G_CALLBACK (on_greeter_environment_session_stopped),\n slave);\n g_signal_connect (slave->priv->greeter_environment,\n \"exited\",\n G_CALLBACK (on_greeter_environment_session_exited),\n slave);\n g_signal_connect (slave->priv->greeter_environment,\n \"died\",\n G_CALLBACK (on_greeter_environment_session_died),\n slave);\n g_object_set (slave->priv->greeter_environment,\n \"x11-authority-file\", auth_file,\n NULL);\n\n gdm_launch_environment_start (GDM_LAUNCH_ENVIRONMENT (slave->priv->greeter_environment));\n\n g_free (display_name);\n g_free (seat_id);\n g_free (display_device);\n g_free (display_hostname);\n g_free (auth_file);\n}", "label": 0, "cwe": null, "length": 696 }, { "index": 476651, "code": "__rep_update_req(env, rp)\n\tENV *env;\n\t__rep_control_args *rp;\n{\n\tDBT updbt, vdbt;\n\tDB_LOG *dblp;\n\tDB_LOGC *logc;\n\tDB_LSN lsn;\n\tDB_REP *db_rep;\n\tREP *rep;\n\t__rep_update_args u_args;\n\tFILE_LIST_CTX context;\n\tsize_t updlen;\n\tu_int32_t flag, version;\n\tint ret, t_ret;\n\n\t/*\n\t * Start by allocating 1Meg, which ought to be plenty enough to describe\n\t * all databases in the environment. (If it's not, __rep_walk_dir can\n\t * grow the size.)\n\t *\n\t * The data we send looks like this:\n\t *\t__rep_update_args\n\t *\t__rep_fileinfo_args\n\t *\t__rep_fileinfo_args\n\t *\t...\n\t */\n\tdb_rep = env->rep_handle;\n\trep = db_rep->region;\n\n\tREP_SYSTEM_LOCK(env);\n\tif (F_ISSET(rep, REP_F_INUPDREQ)) {\n\t\tREP_SYSTEM_UNLOCK(env);\n\t\treturn (0);\n\t}\n\tF_SET(rep, REP_F_INUPDREQ);\n\tREP_SYSTEM_UNLOCK(env);\n\n\tdblp = env->lg_handle;\n\tlogc = NULL;\n\n\t/* Reserve space for the update_args, and fill in file info. */\n\tif ((ret = __rep_init_file_list_context(env, rp->rep_version,\n\t F_ISSET(rp, REPCTL_INMEM_ONLY) ? FILE_CTX_INMEM_ONLY : 0,\n\t 1, &context)) != 0)\n\t\tgoto err_noalloc;\n\tif ((ret = __rep_find_dbs(env, &context)) != 0)\n\t\tgoto err;\n\n\t/*\n\t * Now get our first LSN. We send the lsn of the first\n\t * non-archivable log file.\n\t */\n\tflag = DB_SET;\n\tif ((ret = __log_get_stable_lsn(env, &lsn, 0)) != 0) {\n\t\tif (ret != DB_NOTFOUND)\n\t\t\tgoto err;\n\t\t/*\n\t\t * If ret is DB_NOTFOUND then there is no checkpoint\n\t\t * in this log, that is okay, just start at the beginning.\n\t\t */\n\t\tret = 0;\n\t\tflag = DB_FIRST;\n\t}\n\n\t/*\n\t * Now get the version number of the log file of that LSN.\n\t */\n\tif ((ret = __log_cursor(env, &logc)) != 0)\n\t\tgoto err;\n\n\tmemset(&vdbt, 0, sizeof(vdbt));\n\t/*\n\t * Set our log cursor on the LSN we are sending. Or\n\t * to the first LSN if we have no stable LSN.\n\t */\n\tif ((ret = __logc_get(logc, &lsn, &vdbt, flag)) != 0) {\n\t\t/*\n\t\t * We could be racing a fresh master starting up. If we\n\t\t * have no log records, assume an initial LSN and current\n\t\t * log version.\n\t\t */\n\t\tif (ret != DB_NOTFOUND)\n\t\t\tgoto err;\n\t\tINIT_LSN(lsn);\n\t\tversion = DB_LOGVERSION;\n\t} else {\n\t\tif ((ret = __logc_version(logc, &version)) != 0)\n\t\t\tgoto err;\n\t}\n\t/*\n\t * Package up the update information.\n\t */\n\tu_args.first_lsn = lsn;\n\tu_args.first_vers = version;\n\tu_args.num_files = context.count;\n\tif ((ret = __rep_update_marshal(env, rp->rep_version,\n\t &u_args, context.buf, __REP_UPDATE_SIZE, &updlen)) != 0)\n\t\tgoto err;\n\tDB_ASSERT(env, updlen == __REP_UPDATE_SIZE);\n\n\t/*\n\t * We have all the file information now. Send it.\n\t */\n\tDB_INIT_DBT(updbt, context.buf, context.fillptr - context.buf);\n\n\tLOG_SYSTEM_LOCK(env);\n\tlsn = ((LOG *)dblp->reginfo.primary)->lsn;\n\tLOG_SYSTEM_UNLOCK(env);\n\t(void)__rep_send_message(\n\t env, DB_EID_BROADCAST, REP_UPDATE, &lsn, &updbt, 0, 0);\n\nerr:\t__os_free(env, context.buf);\nerr_noalloc:\n\tif (logc != NULL && (t_ret = __logc_close(logc)) != 0 && ret == 0)\n\t\tret = t_ret;\n\tREP_SYSTEM_LOCK(env);\n\tF_CLR(rep, REP_F_INUPDREQ);\n\tREP_SYSTEM_UNLOCK(env);\n\treturn (ret);\n}", "label": 0, "cwe": null, "length": 964 }, { "index": 11701, "code": "ldcomb_driver(struct xstk_t *acc_xsp, struct net_t *np,\n register struct net_pin_t *npp)\n{\n register struct xstk_t *xsp, *tmpxsp;\n int32 lhswid, nd_itpop;\n struct npaux_t *npauxp;\n\n /* --- DBG remove\n if (__debug_flg && __ev_tracing)\n {\n __tr_msg(\"## loading %s driver of wire %s\\n\",\n __to_npptyp(__xs, npp), np->nsym->synam);\n }\n --- */\n if (npp->npproctyp != NP_PROC_INMOD)\n {\n /* SJM 04/17/03 - if XMR does not match - do not combine in */\n if (!__move_to_npprefloc(npp)) return;\n nd_itpop = TRUE;\n }\n else nd_itpop = FALSE;\n\n /* this puts the driving value (normal rhs with rhs width) on stack */\n /* notice tran strength only so error if appears here */\n switch ((byte) npp->npntyp) {\n case NP_CONTA: xsp = __ld_conta_driver(npp); break;\n case NP_TFRWARG: xsp = __ld_tfrwarg_driver(npp); break;\n case NP_VPIPUTV: xsp = __ld_vpiputv_driver(npp); break;\n case NP_GATE: xsp = __ld_gate_driver(npp); break;\n /* these are up to highconn output port drivers */\n case NP_ICONN: xsp = __ld_iconn_up_driver(npp); break;\n case NP_PB_ICONN: xsp = __ld_pb_iconn_up_driver(npp); break;\n /* these are down to lowconn input port drivers */\n case NP_MDPRT: xsp = __ld_modport_down_driver(npp); break;\n case NP_PB_MDPRT: xsp = __ld_pb_modport_down_driver(npp); break;\n default: __case_terr(__FILE__, __LINE__); xsp = NULL; \n }\n if (nd_itpop) __pop_itstk();\n\n /* if lhs of concatenate, must select section out of rhs value */\n if ((npauxp = npp->npaux) != NULL && npauxp->lcbi1 != -1)\n {\n /* loaded value always matches lhs width exactly with z extension */\n /* if too wide just will not rhs psel from section */\n lhswid = npauxp->lcbi1 - npauxp->lcbi2 + 1;\n push_xstk_(tmpxsp, lhswid);\n __rhspsel(tmpxsp->ap, xsp->ap, npauxp->lcbi2, lhswid); \n __rhspsel(tmpxsp->bp, xsp->bp, npauxp->lcbi2, lhswid); \n\n __eval_wire(acc_xsp->ap, tmpxsp->ap, np, npp);\n __pop_xstk();\n }\n else __eval_wire(acc_xsp->ap, xsp->ap, np, npp);\n __pop_xstk();\n}", "label": 1, "cwe": "CWE-476", "length": 677 }, { "index": 68301, "code": "usage(int help, int longopt)\n{\n\tfprintf(stderr,\n\"qrencode version %s\\n\"\n\"Copyright (C) 2006, 2007, 2008, 2009 Kentaro Fukuchi\\n\", VERSION);\n\tif(help) {\n\t\tif(longopt) {\n\t\t\tfprintf(stderr,\n\"Usage: qrencode [OPTION]... [STRING]\\n\"\n\"Encode input data in a QR Code and save as a PNG image.\\n\\n\"\n\" -h, --help display the help message. -h displays only the help of short\\n\"\n\" options.\\n\\n\"\n\" -o FILENAME, --output=FILENAME\\n\"\n\" write PNG image to FILENAME. If '-' is specified, the result\\n\"\n\" will be output to standard output. If -S is given, structured\\n\"\n\" symbols are written to FILENAME-01.png, FILENAME-02.png, ...;\\n\"\n\" if specified, remove a trailing '.png' from FILENAME.\\n\\n\"\n\" -s NUMBER, --size=NUMBER\\n\"\n\" specify the size of dot (pixel). (default=3)\\n\\n\"\n\" -l {LMQH}, --level={LMQH}\\n\"\n\" specify error collectin level from L (lowest) to H (highest).\\n\"\n\" (default=L)\\n\\n\"\n\" -v NUMBER, --symversion=NUMBER\\n\"\n\" specify the version of the symbol. (default=auto)\\n\\n\"\n\" -m NUMBER, --margin=NUMBER\\n\"\n\" specify the width of margin. (default=4)\\n\\n\"\n\" -S, --structured\\n\"\n\" make structured symbols. Version must be specified.\\n\\n\"\n\" -k, --kanji assume that the input text contains kanji (shift-jis).\\n\\n\"\n\" -c, --casesensitive\\n\"\n\" encode lower-case alphabet characters in 8-bit mode. (default)\\n\\n\"\n\" -i, --ignorecase\\n\"\n\" ignore case distinctions and use only upper-case characters.\\n\\n\"\n\" -8, -8bit encode entire data in 8-bit mode. -k, -c and -i will be ignored.\\n\\n\"\n\" -V, --version\\n\"\n\" display the version number and copyrights of the qrencode.\\n\\n\"\n\" [STRING] input data. If it is not specified, data will be taken from\\n\"\n\" standard input.\\n\"\n\t\t\t);\n\t\t} else {\n\t\t\tfprintf(stderr,\n\"Usage: qrencode [OPTION]... [STRING]\\n\"\n\"Encode input data in a QR Code and save as a PNG image.\\n\\n\"\n\" -h display this message.\\n\"\n\" --help display the usage of long options.\\n\"\n\" -o FILENAME write PNG image to FILENAME. If '-' is specified, the result\\n\"\n\" will be output to standard output. If -S is given, structured\\n\"\n\" symbols are written to FILENAME-01.png, FILENAME-02.png, ...;\\n\"\n\" if specified, remove a trailing '.png' from FILENAME.\\n\"\n\" -s NUMBER specify the size of dot (pixel). (default=3)\\n\"\n\" -l {LMQH} specify error collectin level from L (lowest) to H (highest).\\n\"\n\" (default=L)\\n\"\n\" -v NUMBER specify the version of the symbol. (default=auto)\\n\"\n\" -m NUMBER specify the width of margin. (default=4)\\n\"\n\" -S make structured symbols. Version must be specified.\\n\"\n\" -k assume that the input text contains kanji (shift-jis).\\n\"\n\" -c encode lower-case alphabet characters in 8-bit mode. (default)\\n\"\n\" -i ignore case distinctions and use only upper-case characters.\\n\"\n\" -8 encode entire data in 8-bit mode. -k, -c and -i will be ignored.\\n\"\n\" -V display the version number and copyrights of the qrencode.\\n\"\n\" [STRING] input data. If it is not specified, data will be taken from\\n\"\n\" standard input.\\n\"\n\t\t\t);\n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 944 }, { "index": 739330, "code": "update_timer_button_monitor(void)\n\t{\n\tif (timer_button_state == TB_PRESSED)\n\t\treturn;\n\tif ( (_GK.debug_level & DEBUG_TIMER) && net_timed\n\t\t&& timer_button_type != TIMER_TYPE_NONE\n\t\t&& (net_timed->up_event || net_timed->down_event)\n\t )\n\t\tg_print(_(\"update_timer_button net_timed old_state=%d new_state=%d\\n\"),\n\t\t\t net_timed->up_event, net_timed->down_event);\n\tswitch (timer_button_type)\n\t\t{\n\t\tcase TIMER_TYPE_NONE:\n\t\t\tif (timer_button_state == TB_ON)\n\t\t\t\tdraw_timer(timer_panel, (int) (time(0) - net_timer0), 0);\n\t\t\tbreak;\n\n\t\tcase TIMER_TYPE_PPP:\n\t\t\tif (net_timed->up)\n\t\t\t\t{\n\t\t\t\tset_timer_button_state(TB_ON);\n\t\t\t\tcheck_connect_state = FALSE;\n\t\t\t\tif (net_timed->up_event)\n\t\t\t\t\tget_connect_time();\n\t\t\t\t}\n\t\t\telse if (net_timed->down_event)\n\t\t\t\tset_timer_button_state(TB_NORMAL);\n\t\t\tif (check_connect_state)\n\t\t\t\tset_timer_button_state(get_connect_state());\n\n\t\t\tif (net_timed->up)\n\t\t\t\tdraw_timer(timer_panel, (int) (time(0) - net_timer0), 0);\n\t\t\tbreak;\n\n\t\tcase TIMER_TYPE_IPPP:\n\t\t\t/* get all isdn status from get_connect_state because the\n\t\t\t| net_timed->up can be UP even with isdn line not connected.\n\t\t\t*/\n\t\t\tset_timer_button_state(get_connect_state());\n\t\t\tif ( timer_button_state != TB_NORMAL\n\t\t\t\t&& timer_button_old_state == TB_NORMAL\n\t\t\t )\n\t\t\t\ttime(&net_timer0); /* New session just started */\n\t\t\tif (timer_button_state != TB_NORMAL)\n\t\t\t\tdraw_timer(timer_panel, (int) (time(0) - net_timer0), 0);\n\t\t\tbreak;\n\n\t\tcase TIMER_TYPE_SERVER:\n\t\t\t/* Button state is independent of displayed timer\n\t\t\t*/\n\t\t\tdraw_timer(timer_panel, gkrellm_client_server_get_net_timer(), 0);\n\t\t\tbreak;\n\t\t}\n\tif (net_timed && net_timed->up)\n\t\t{\n\t\tnet_timed->day_stats[0].connect_time += 1;\n\t\tnet_timed->week_stats[0].connect_time += 1;\n\t\tnet_timed->month_stats[0].connect_time += 1;\n\t\t}\n\t}", "label": 0, "cwe": null, "length": 518 }, { "index": 128592, "code": "main_window_on_quit (MainWindow* self) {\n\tgchar** list_uris = NULL;\n\tgchar** _tmp0_ = NULL;\n\tgint list_uris_length1 = 0;\n\tgint _list_uris_size_ = 0;\n\tGSettings* settings = NULL;\n\tGSettings* _tmp19_ = NULL;\n\tGSettings* _tmp20_ = NULL;\n\tgchar** _tmp21_ = NULL;\n\tgint _tmp21__length1 = 0;\n\tgboolean _tmp22_ = FALSE;\n\tg_return_if_fail (self != NULL);\n\t_tmp0_ = g_new0 (gchar*, 0 + 1);\n\tlist_uris = _tmp0_;\n\tlist_uris_length1 = 0;\n\t_list_uris_size_ = list_uris_length1;\n\t{\n\t\tGeeList* _doc_list = NULL;\n\t\tGeeList* _tmp1_ = NULL;\n\t\tgint _doc_size = 0;\n\t\tGeeList* _tmp2_ = NULL;\n\t\tgint _tmp3_ = 0;\n\t\tgint _tmp4_ = 0;\n\t\tgint _doc_index = 0;\n\t\t_tmp1_ = main_window_get_documents (self);\n\t\t_doc_list = _tmp1_;\n\t\t_tmp2_ = _doc_list;\n\t\t_tmp3_ = gee_collection_get_size ((GeeCollection*) _tmp2_);\n\t\t_tmp4_ = _tmp3_;\n\t\t_doc_size = _tmp4_;\n\t\t_doc_index = -1;\n\t\twhile (TRUE) {\n\t\t\tgint _tmp5_ = 0;\n\t\t\tgint _tmp6_ = 0;\n\t\t\tgint _tmp7_ = 0;\n\t\t\tDocument* doc = NULL;\n\t\t\tGeeList* _tmp8_ = NULL;\n\t\t\tgint _tmp9_ = 0;\n\t\t\tgpointer _tmp10_ = NULL;\n\t\t\tDocument* _tmp11_ = NULL;\n\t\t\tGFile* _tmp12_ = NULL;\n\t\t\tGFile* _tmp13_ = NULL;\n\t\t\t_tmp5_ = _doc_index;\n\t\t\t_doc_index = _tmp5_ + 1;\n\t\t\t_tmp6_ = _doc_index;\n\t\t\t_tmp7_ = _doc_size;\n\t\t\tif (!(_tmp6_ < _tmp7_)) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t_tmp8_ = _doc_list;\n\t\t\t_tmp9_ = _doc_index;\n\t\t\t_tmp10_ = gee_list_get (_tmp8_, _tmp9_);\n\t\t\tdoc = (Document*) _tmp10_;\n\t\t\t_tmp11_ = doc;\n\t\t\t_tmp12_ = document_get_location (_tmp11_);\n\t\t\t_tmp13_ = _tmp12_;\n\t\t\tif (_tmp13_ != NULL) {\n\t\t\t\tgchar** _tmp14_ = NULL;\n\t\t\t\tgint _tmp14__length1 = 0;\n\t\t\t\tDocument* _tmp15_ = NULL;\n\t\t\t\tGFile* _tmp16_ = NULL;\n\t\t\t\tGFile* _tmp17_ = NULL;\n\t\t\t\tgchar* _tmp18_ = NULL;\n\t\t\t\t_tmp14_ = list_uris;\n\t\t\t\t_tmp14__length1 = list_uris_length1;\n\t\t\t\t_tmp15_ = doc;\n\t\t\t\t_tmp16_ = document_get_location (_tmp15_);\n\t\t\t\t_tmp17_ = _tmp16_;\n\t\t\t\t_tmp18_ = g_file_get_uri (_tmp17_);\n\t\t\t\t_vala_array_add19 (&list_uris, &list_uris_length1, &_list_uris_size_, _tmp18_);\n\t\t\t}\n\t\t\t_g_object_unref0 (doc);\n\t\t}\n\t\t_g_object_unref0 (_doc_list);\n\t}\n\t_tmp19_ = g_settings_new (\"org.gnome.latexila.state.window\");\n\tsettings = _tmp19_;\n\t_tmp20_ = settings;\n\t_tmp21_ = list_uris;\n\t_tmp21__length1 = list_uris_length1;\n\tg_settings_set_strv (_tmp20_, \"documents\", _tmp21_);\n\t_tmp22_ = main_window_close_all_documents (self);\n\tif (_tmp22_) {\n\t\tmain_window_save_state (self);\n\t\tgtk_widget_destroy ((GtkWidget*) self);\n\t}\n\t_g_object_unref0 (settings);\n\tlist_uris = (_vala_array_free (list_uris, list_uris_length1, (GDestroyNotify) g_free), NULL);\n}", "label": 0, "cwe": null, "length": 924 }, { "index": 271919, "code": "_get_user_coords(pgsql_conn_t *pg_conn, slurmdb_user_rec_t *user)\n{\n\tDEF_VARS;\n\tslurmdb_coord_rec_t *coord = NULL;\n\tListIterator itr = NULL;\n\tchar *cond = NULL;\n\n\tif(!user) {\n\t\terror(\"as/pg: _get_user_coord: user not given.\");\n\t\treturn SLURM_ERROR;\n\t}\n\n\tif(!user->coord_accts)\n\t\tuser->coord_accts = list_create(slurmdb_destroy_coord_rec);\n\n\tquery = xstrdup_printf(\n\t\t\"SELECT acct FROM %s WHERE user_name='%s' AND deleted=0\",\n\t\tacct_coord_table, user->name);\n\tresult = DEF_QUERY_RET;\n\tif (!result)\n\t\treturn SLURM_ERROR;\n\n\tFOR_EACH_ROW {\n\t\tcoord = xmalloc(sizeof(slurmdb_coord_rec_t));\n\t\tlist_append(user->coord_accts, coord);\n\t\tcoord->name = xstrdup(ROW(0));\n\t\tcoord->direct = 1;\n\t\tif (cond)\n\t\t\txstrcat(cond, \" OR \");\n\t\txstrfmtcat(cond, \"t2.acct='%s'\", ROW(0));\n\t} END_EACH_ROW;\n\tPQclear(result);\n\n\tif (list_count(user->coord_accts) == 0)\n\t\treturn SLURM_SUCCESS;\n\n\tFOR_EACH_CLUSTER(NULL) {\n\t\tif(query)\n\t\t\txstrcat(query, \" UNION \");\n\t\tquery = xstrdup_printf(\n\t\t\t\"SELECT DISTINCT t1.acct FROM %s.%s AS t1, %s.%s AS t2 \"\n\t\t\t\"WHERE t1.deleted=0 AND t2.deleted=0 AND \"\n\t\t\t\"t1.user_name='' AND (t1.lft>t2.lft AND t1.rgtcoord_accts);\n\t\tFOR_EACH_ROW {\n\t\t\tchar *acct = ROW(0);\n\t\t\twhile((coord = list_next(itr))) {\n\t\t\t\tif(!strcmp(coord->name, acct))\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\tlist_iterator_reset(itr);\n\t\t\tif(coord) /* already in list */\n\t\t\t\tcontinue;\n\n\t\t\tcoord = xmalloc(sizeof(slurmdb_coord_rec_t));\n\t\t\tlist_append(user->coord_accts, coord);\n\t\t\tcoord->name = xstrdup(acct);\n\t\t\tcoord->direct = 0;\n\t\t} END_EACH_ROW;\n\t\tlist_iterator_destroy(itr);\n\t\tPQclear(result);\n\t}\n\treturn SLURM_SUCCESS;\n}", "label": 0, "cwe": null, "length": 579 }, { "index": 865757, "code": "save_codecs_cache (FsMediaType media_type, GList *blueprints)\n{\n gchar *cache_path;\n GList *item;\n gchar *tmp_path;\n int fd;\n int size;\n gchar magic[8] = {0};\n\n cache_path = get_codecs_cache_path (media_type);\n if (!cache_path)\n return FALSE;\n\n\n GST_DEBUG (\"Saving codecs cache to %s\", cache_path);\n\n tmp_path = g_strconcat (cache_path, \".tmpXXXXXX\", NULL);\n fd = g_mkstemp (tmp_path);\n if (fd == -1) {\n gchar *dir;\n\n /* oops, I bet the directory doesn't exist */\n dir = g_path_get_dirname (cache_path);\n g_mkdir_with_parents (dir, 0777);\n g_free (dir);\n\n /* the previous g_mkstemp call overwrote the XXXXXX placeholder ... */\n g_free (tmp_path);\n tmp_path = g_strconcat (cache_path, \".tmpXXXXXX\", NULL);\n fd = g_mkstemp (tmp_path);\n\n if (fd == -1) {\n GST_DEBUG (\"Unable to save codecs cache. g_mkstemp () failed: %s\",\n g_strerror (errno));\n g_free (tmp_path);\n g_free (cache_path);\n return FALSE;\n }\n }\n\n magic[0] = 'F';\n magic[1] = 'S';\n magic[2] = '?';\n magic[3] = 'C';\n\n if (media_type == FS_MEDIA_TYPE_AUDIO) {\n magic[2] = 'A';\n } else if (media_type == FS_MEDIA_TYPE_VIDEO) {\n magic[2] = 'V';\n }\n\n /* version of the binary format */\n magic[4] = '1';\n magic[5] = '1';\n\n if (write (fd, magic, 8) != 8)\n return FALSE;\n\n\n size = g_list_length (blueprints);\n if (write (fd, &size, sizeof (gint)) != sizeof (gint))\n return FALSE;\n\n\n for (item = g_list_first (blueprints);\n item;\n item = g_list_next (item)) {\n CodecBlueprint *codec_blueprint = item->data;\n if (!save_codec_blueprint (fd, codec_blueprint)) {\n GST_WARNING (\"Unable to save codec cache\");\n close (fd);\n g_free (tmp_path);\n g_free (cache_path);\n return FALSE;\n }\n }\n\n\n if (close (fd) < 0) {\n GST_DEBUG (\"Can't close codecs cache file : %s\", g_strerror (errno));\n g_free (tmp_path);\n g_free (cache_path);\n return FALSE;\n }\n\n if (g_file_test (tmp_path, G_FILE_TEST_EXISTS)) {\n#ifdef WIN32\n remove (cache_path);\n#endif\n rename (tmp_path, cache_path);\n }\n\n g_free (tmp_path);\n g_free (cache_path);\n GST_DEBUG (\"Wrote binary codecs cache\");\n return TRUE;\n}", "label": 0, "cwe": null, "length": 656 }, { "index": 733613, "code": "SetProperty (unsigned property, char const *value)\n{\n\tswitch (property) {\n\tcase GCU_PROP_CELL_A:\n\t\tm_a = g_ascii_strtod (value, NULL) * GetScale ();\n\t\tbreak;\n\tcase GCU_PROP_CELL_B:\n\t\tm_b = g_ascii_strtod (value, NULL) * GetScale ();\n\t\tbreak;\n\tcase GCU_PROP_CELL_C:\n\t\tm_c = g_ascii_strtod (value, NULL) * GetScale ();\n\t\tbreak;\n\tcase GCU_PROP_CELL_ALPHA:\n\t\tm_alpha = g_ascii_strtod (value, NULL);\n\t\tbreak;\n\tcase GCU_PROP_CELL_BETA:\n\t\tm_beta = g_ascii_strtod (value, NULL);\n\t\tbreak;\n\tcase GCU_PROP_CELL_GAMMA:\n\t\tm_gamma = g_ascii_strtod (value, NULL);\n\t\tbreak;\n\tcase GCU_PROP_CHEMICAL_NAME_COMMON:\n\t\tm_NameCommon = value;\n\t\tbreak;\n\tcase GCU_PROP_CHEMICAL_NAME_SYSTEMATIC:\n\t\tm_NameSystematic = value;\n\t\tbreak;\n\tcase GCU_PROP_CHEMICAL_NAME_MINERAL:\n\t\tm_NameMineral = value;\n\t\tbreak;\n\tcase GCU_PROP_CHEMICAL_NAME_STRUCTURE:\n\t\tm_NameStructure = value;\n\t\tbreak;\n\tcase GCU_PROP_SPACE_GROUP: {\n\t\tm_SpaceGroup = gcu::SpaceGroup::GetSpaceGroup (value);\n\t\tchar type = (*value == '-')? value[1]: value[0];\n\t\tint id = m_SpaceGroup->GetId ();\n\t\tif (id <= 2)\n\t\t\tm_lattice = triclinic;\n\t\telse if (id <= 15)\n\t\t\tm_lattice = (type == 'P')? monoclinic: base_centered_monoclinic;\n\t\telse if (id <= 74)\n\t\t\tswitch (type) {\n\t\t\tcase 'P':\n\t\t\t\tm_lattice = orthorhombic;\n\t\t\t\tbreak;\n\t\t\tcase 'I':\n\t\t\t\tm_lattice = body_centered_orthorhombic;\n\t\t\t\tbreak;\n\t\t\tcase 'F':\n\t\t\t\tm_lattice = face_centered_orthorhombic;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tm_lattice = base_centered_orthorhombic;\n\t\t\t\tbreak;\n\t\t\t}\n\t\telse if (id <= 142)\n\t\t\tm_lattice = (type == 'P')? tetragonal: body_centered_tetragonal;\n\t\telse if (id <= 194) {\n\t\t\tif (id == 146 || id == 148 || id == 155 || id == 160 || id == 161 || id == 166 || id == 167)\n\t\t\t\tm_lattice = rhombohedral;\n\t\t\telse\n\t\t\t\tm_lattice = hexagonal;\n\t\t} else {\n\t\t\tswitch (type) {\n\t\t\tcase 'P':\n\t\t\t\tm_lattice = cubic;\n\t\t\t\tbreak;\n\t\t\tcase 'I':\n\t\t\t\tm_lattice = body_centered_cubic;\n\t\t\t\tbreak;\n\t\t\tcase 'F':\n\t\t\t\tm_lattice = face_centered_cubic;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tbreak;\n\t}\n\tcase GCU_PROP_DOC_CREATOR:\n\t\tg_free (m_Author);\n\t\tm_Author = g_strdup (value);\n\t\tbreak;\n\tcase GCU_PROP_DOC_CREATOR_EMAIL:\n\t\tg_free (m_Mail);\n\t\tm_Mail = g_strdup (value);\n\t\tbreak;\n\tdefault:\n\t\treturn false;\n\t}\n\treturn true;\n}", "label": 0, "cwe": null, "length": 715 }, { "index": 85599, "code": "sendquery(isc_task_t *task, isc_event_t *event)\n{\n\tdns_request_t *request = NULL;\n\tdns_message_t *message = NULL;\n\tdns_name_t *qname = NULL;\n\tdns_rdataset_t *qrdataset = NULL;\n\tisc_result_t result;\n\tdns_fixedname_t queryname;\n\tisc_buffer_t buf;\n\tisc_buffer_t outbuf;\n\tchar output[10 * 1024];\n\tstatic char host[256];\n\tint c;\n\n\tisc_event_free(&event);\n\n\tprintf(\"Query => \");\n\tc = scanf(\"%255s\", host);\n\tif (c == EOF)\n\t\treturn;\n\n\tdns_fixedname_init(&queryname);\n\tisc_buffer_init(&buf, host, strlen(host));\n\tisc_buffer_add(&buf, strlen(host));\n\tresult = dns_name_fromtext(dns_fixedname_name(&queryname), &buf,\n\t\t\t\t dns_rootname, 0, NULL);\n\tCHECK(\"dns_name_fromtext\", result);\n\n\tresult = dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &message);\n\tif (result != ISC_R_SUCCESS)\n\t\tgoto end;\n\n\tmessage->opcode = dns_opcode_query;\n\tmessage->rdclass = dns_rdataclass_in;\n\tmessage->id = (unsigned short)(random() & 0xFFFF);\n\n\tresult = dns_message_gettempname(message, &qname);\n\tif (result != ISC_R_SUCCESS)\n\t\tgoto end;\n\n\tresult = dns_message_gettemprdataset(message, &qrdataset);\n\tif (result != ISC_R_SUCCESS)\n\t\tgoto end;\n\n\tdns_name_init(qname, NULL);\n\tdns_name_clone(dns_fixedname_name(&queryname), qname);\n\tdns_rdataset_init(qrdataset);\n\tdns_rdataset_makequestion(qrdataset, dns_rdataclass_in,\n\t\t\t\t dns_rdatatype_a);\n\tISC_LIST_APPEND(qname->list, qrdataset, link);\n\tdns_message_addname(message, qname, DNS_SECTION_QUESTION);\n\n\tresult = dns_request_create(requestmgr, message, &address, 0, tsigkey,\n\t\t\t\t TIMEOUT, task, recvresponse,\n\t\tmessage, &request);\n\tCHECK(\"dns_request_create\", result);\n\n\tprintf(\"Submitting query:\\n\");\n\tisc_buffer_init(&outbuf, output, sizeof(output));\n\tresult = dns_message_totext(message, &dns_master_style_debug, 0,\n\t\t\t\t &outbuf);\n\tCHECK(\"dns_message_totext\", result);\n\tprintf(\"%.*s\\n\", (int)isc_buffer_usedlength(&outbuf),\n\t (char *)isc_buffer_base(&outbuf));\n\n\treturn;\n\n end:\n\tif (qname != NULL)\n\t\tdns_message_puttempname(message, &qname);\n\tif (qrdataset != NULL)\n\t\tdns_message_puttemprdataset(message, &qrdataset);\n\tif (message != NULL)\n\t\tdns_message_destroy(&message);\n}", "label": 0, "cwe": null, "length": 579 }, { "index": 343620, "code": "crm_remote_recv(crm_remote_t * remote, int total_timeout /*ms */ , int *disconnected)\n{\n int ret;\n size_t request_len = 0;\n time_t start = time(NULL);\n char *raw_request = NULL;\n int remaining_timeout = 0;\n\n if (total_timeout == 0) {\n total_timeout = 10000;\n } else if (total_timeout < 0) {\n total_timeout = 60000;\n }\n *disconnected = 0;\n\n remaining_timeout = total_timeout;\n while ((remaining_timeout > 0) && !(*disconnected)) {\n\n /* read some more off the tls buffer if we still have time left. */\n crm_trace(\"waiting to receive remote msg, starting timeout %d, remaining_timeout %d\",\n total_timeout, remaining_timeout);\n ret = crm_remote_ready(remote, remaining_timeout);\n raw_request = NULL;\n\n if (ret == 0) {\n crm_err(\"poll timed out (%d ms) while waiting to receive msg\", remaining_timeout);\n return FALSE;\n\n } else if (ret < 0) {\n if (errno != EINTR) {\n crm_debug(\"poll returned error while waiting for msg, rc: %d, errno: %d\", ret,\n errno);\n *disconnected = 1;\n return FALSE;\n }\n crm_debug(\"poll EINTR encountered during poll, retrying\");\n\n } else if (remote->tcp_socket) {\n raw_request = crm_recv_plaintext(remote->tcp_socket, 0, &request_len, disconnected);\n\n#ifdef HAVE_GNUTLS_GNUTLS_H\n } else if (remote->tls_session) {\n raw_request = crm_recv_tls(remote->tls_session, 0, &request_len, disconnected);\n#endif\n } else {\n crm_err(\"Unsupported connection type\");\n }\n\n remaining_timeout = remaining_timeout - ((time(NULL) - start) * 1000);\n\n if (!raw_request) {\n crm_debug(\"Empty msg received after poll\");\n continue;\n }\n\n if (remote->buffer) {\n int old_len = strlen(remote->buffer);\n\n crm_trace(\"Expanding recv buffer from %d to %d\", old_len, old_len + request_len);\n\n remote->buffer = realloc(remote->buffer, old_len + request_len + 1);\n memcpy(remote->buffer + old_len, raw_request, request_len);\n *(remote->buffer + old_len + request_len) = '\\0';\n free(raw_request);\n\n } else {\n remote->buffer = raw_request;\n }\n\n if (strstr(remote->buffer, REMOTE_MSG_TERMINATOR)) {\n return TRUE;\n }\n }\n\n return FALSE;\n}", "label": 0, "cwe": null, "length": 585 }, { "index": 872552, "code": "NK6510_DeleteCalendarNote(gn_data *data, struct gn_statemachine *state)\n{\n\tgn_error error;\n\tunsigned char req[] = { FBUS_FRAME_HEADER,\n\t\t\t\t0x0b, /* delete calendar note */\n\t\t\t\t0x00, 0x00}; /*location */\n\tgn_calnote_list list;\n\tbool own_list = true;\n\n\tif (DRVINSTANCE(state)->pm->flags & PM_EXTCALENDAR)\n\t\treturn NK6510_DeleteCalendarNote_S40_30(data, state);\n\n\tif (data->calnote_list)\n\t\town_list = false;\n\telse {\n\t\tmemset(&list, 0, sizeof(gn_calnote_list));\n\t\tdata->calnote_list = &list;\n\t}\n\n\tif (data->calnote_list->number == 0)\n\t\tNK6510_GetCalendarNotesInfo(data, state, 0x00);\n\n\tif (data->calnote->location < data->calnote_list->number + 1 &&\n\t data->calnote->location > 0) {\n\t\treq[4] = data->calnote_list->location[data->calnote->location - 1] >> 8;\n\t\treq[5] = data->calnote_list->location[data->calnote->location - 1] & 0xff;\n\t} else {\n\t\treturn GN_ERR_INVALIDLOCATION;\n\t}\n\n\tif (own_list)\n\t\tdata->calnote_list = NULL;\n\n\tif (sm_message_send(8, NK6510_MSG_CALENDAR, req, state))\n\t\treturn GN_ERR_NOTREADY;\n\terror = sm_block(NK6510_MSG_CALENDAR, data, state);\n\n\tdprintf(\"%s\\n\", gn_error_print(error));\n\tif (error == GN_ERR_NOTSUPPORTED) {\n\t\tdprintf(\"Rollback to S40_30\\n\");\n\t\t/*\n\t\t * GN_ERR_NOTSUPPORTED most likely means 0xf0 frame. Experience shows that\n\t\t * with high probability we have series40 3rd+ Ed phone.\n\t\t */\n\t\terror = NK6510_DeleteCalendarNote_S40_30(data, state);\n\t\tif (error == GN_ERR_NONE) {\n\t\t\tdprintf(\"Misconfiguration in the phone table detected.\\nPlease report to gnokii ml (gnokii-users@nongnu.org).\\n\");\n\t\t\tdprintf(\"Model %s (%s) is series40 3rd+ Edition.\\n\", DRVINSTANCE(state)->pm->product_name, DRVINSTANCE(state)->pm->model);\n\t\t\tDRVINSTANCE(state)->pm->flags |= PM_DEFAULT_S40_3RD;\n\t\t}\n\t}\n\tif (error == GN_ERR_NONE)\n\t\tmap_del(&location_map, \"calendar\");\n\n\treturn error;\n}", "label": 0, "cwe": null, "length": 559 }, { "index": 104998, "code": "cbf_set_axis_reference_setting (cbf_handle handle, unsigned int reserved,\n const char *axis_id,\n double refsetting)\n{\n cbf_axis_type type;\n\n if (reserved != 0)\n\n return CBF_ARGUMENT;\n\n\n /* Get the axis type */\n\n cbf_failnez (cbf_get_axis_type (handle, axis_id, &type))\n\n if (type != CBF_TRANSLATION_AXIS && type != CBF_ROTATION_AXIS)\n\n return CBF_FORMAT;\n\n\n /* Update the diffrn_scan_axis and\n diffrn_scan_frame_axis categories */\n\n if (type == CBF_TRANSLATION_AXIS)\n {\n cbf_failnez (cbf_require_category (handle, \"diffrn_scan_frame_axis\"))\n cbf_failnez (cbf_require_column (handle, \"axis_id\"))\n cbf_failnez (cbf_require_row (handle, axis_id))\n cbf_failnez (cbf_require_column (handle, \"reference_displacement\"))\n cbf_failnez (cbf_set_doublevalue (handle, \"%-.15g\", refsetting))\n\n cbf_failnez (cbf_require_category (handle, \"diffrn_scan_axis\"))\n cbf_failnez (cbf_require_column (handle, \"axis_id\"))\n cbf_failnez (cbf_require_row (handle, axis_id))\n cbf_failnez (cbf_require_column (handle, \"reference_displacement\"))\n cbf_failnez (cbf_set_doublevalue (handle, \"%-.15g\", refsetting))\n }\n else\n {\n cbf_failnez (cbf_require_category (handle, \"diffrn_scan_frame_axis\"))\n cbf_failnez (cbf_require_column (handle, \"axis_id\"))\n cbf_failnez (cbf_require_row (handle, axis_id))\n cbf_failnez (cbf_require_column (handle, \"reference_angle\"))\n cbf_failnez (cbf_set_doublevalue (handle, \"%-.15g\", refsetting))\n\n cbf_failnez (cbf_require_category (handle, \"diffrn_scan_axis\"))\n cbf_failnez (cbf_require_column (handle, \"axis_id\"))\n cbf_failnez (cbf_require_row (handle, axis_id))\n cbf_failnez (cbf_require_column (handle, \"reference_angle\"))\n cbf_failnez (cbf_set_doublevalue (handle, \"%-.15g\", refsetting))\n }\n\n return 0;\n}", "label": 0, "cwe": null, "length": 546 }, { "index": 529848, "code": "pcxhr_set_format(struct pcxhr_stream *stream)\n{\n\tint err, is_capture, sample_rate, stream_num;\n\tstruct snd_pcxhr *chip;\n\tstruct pcxhr_rmh rmh;\n\tunsigned int header;\n\n\tchip = snd_pcm_substream_chip(stream->substream);\n\tswitch (stream->format) {\n\tcase SNDRV_PCM_FORMAT_U8:\n\t\theader = HEADER_FMT_BASE_LIN;\n\t\tbreak;\n\tcase SNDRV_PCM_FORMAT_S16_LE:\n\t\theader = HEADER_FMT_BASE_LIN |\n\t\t\t HEADER_FMT_16BITS | HEADER_FMT_INTEL;\n\t\tbreak;\n\tcase SNDRV_PCM_FORMAT_S16_BE:\n\t\theader = HEADER_FMT_BASE_LIN | HEADER_FMT_16BITS;\n\t\tbreak;\n\tcase SNDRV_PCM_FORMAT_S24_3LE:\n\t\theader = HEADER_FMT_BASE_LIN |\n\t\t\t HEADER_FMT_24BITS | HEADER_FMT_INTEL;\n\t\tbreak;\n\tcase SNDRV_PCM_FORMAT_S24_3BE:\n\t\theader = HEADER_FMT_BASE_LIN | HEADER_FMT_24BITS;\n\t\tbreak;\n\tcase SNDRV_PCM_FORMAT_FLOAT_LE:\n\t\theader = HEADER_FMT_BASE_FLOAT | HEADER_FMT_INTEL;\n\t\tbreak;\n\tdefault:\n\t\tdev_err(chip->card->dev,\n\t\t\t\"error pcxhr_set_format() : unknown format\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tsample_rate = chip->mgr->sample_rate;\n\tif (sample_rate <= 32000 && sample_rate !=0) {\n\t\tif (sample_rate <= 11025)\n\t\t\theader |= HEADER_FMT_UPTO11;\n\t\telse\n\t\t\theader |= HEADER_FMT_UPTO32;\n\t}\n\tif (stream->channels == 1)\n\t\theader |= HEADER_FMT_MONO;\n\n\tis_capture = stream->pipe->is_capture;\n\tstream_num = is_capture ? 0 : stream->substream->number;\n\n\tpcxhr_init_rmh(&rmh, is_capture ?\n\t\t CMD_FORMAT_STREAM_IN : CMD_FORMAT_STREAM_OUT);\n\tpcxhr_set_pipe_cmd_params(&rmh, is_capture, stream->pipe->first_audio,\n\t\t\t\t stream_num, 0);\n\tif (is_capture) {\n\t\t/* bug with old dsp versions: */\n\t\t/* bit 12 also sets the format of the playback stream */\n\t\tif (DSP_EXT_CMD_SET(chip->mgr))\n\t\t\trmh.cmd[0] |= 1<<10;\n\t\telse\n\t\t\trmh.cmd[0] |= 1<<12;\n\t}\n\trmh.cmd[1] = 0;\n\trmh.cmd_len = 2;\n\tif (DSP_EXT_CMD_SET(chip->mgr)) {\n\t\t/* add channels and set bit 19 if channels>2 */\n\t\trmh.cmd[1] = stream->channels;\n\t\tif (!is_capture) {\n\t\t\t/* playback : add channel mask to command */\n\t\t\trmh.cmd[2] = (stream->channels == 1) ? 0x01 : 0x03;\n\t\t\trmh.cmd_len = 3;\n\t\t}\n\t}\n\trmh.cmd[rmh.cmd_len++] = header >> 8;\n\trmh.cmd[rmh.cmd_len++] = (header & 0xff) << 16;\n\terr = pcxhr_send_msg(chip->mgr, &rmh);\n\tif (err)\n\t\tdev_err(chip->card->dev,\n\t\t\t\"ERROR pcxhr_set_format err=%x;\\n\", err);\n\treturn err;\n}", "label": 0, "cwe": null, "length": 692 }, { "index": 840760, "code": "CMD_All(F_CMD_ARGS)\n{\n\tFvwmWindow *t, **g;\n\tchar *restofline;\n\tWindowConditionMask mask;\n\tchar *flags;\n\tint num, i;\n\tBool does_any_window_match = False;\n\tchar *token;\n\tBool do_reverse = False;\n\tBool use_stack = False;\n\n\twhile (True) /* break when a non-option is found */\n\t{\n\t\ttoken = PeekToken(action, &restofline);\n\t\tif (StrEquals(token, \"Reverse\"))\n\t\t{\n\t\t\tif (!*restofline)\n\t\t\t{\n\t\t\t\t/* if not any more actions, then Reverse\n\t\t\t\t * probably is some user function, so ignore\n\t\t\t\t * it and do the old behaviour */\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tdo_reverse = True;\n\t\t\t\taction = restofline;\n\t\t\t}\n\t\t}\n\t\telse if (StrEquals(token, \"UseStack\"))\n\t\t{\n\t\t\tif (!*restofline)\n\t\t\t{\n\t\t\t\t/* if not any more actions, then UseStack\n\t\t\t\t * probably is some user function, so ignore\n\t\t\t\t * it and do the old behaviour */\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tuse_stack = True;\n\t\t\t\taction = restofline;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\t/* No more options -- continue with flags and\n\t\t\t * commands */\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tflags = CreateFlagString(action, &restofline);\n\tDefaultConditionMask(&mask);\n\tmask.my_flags.use_circulate_hit = 1;\n\tmask.my_flags.use_circulate_hit_icon = 1;\n\tmask.my_flags.use_circulate_hit_shaded = 1;\n\tCreateConditionMask(flags, &mask);\n\tif (flags)\n\t{\n\t\tfree(flags);\n\t}\n\n\tnum = 0;\n\tfor (t = Scr.FvwmRoot.next; t; t = t->next)\n\t{\n\t\tnum++;\n\t}\n\tg = (FvwmWindow **)safemalloc(num * sizeof(FvwmWindow *));\n\tnum = 0;\n\tif (!use_stack)\n\t{\n\t\tfor (t = Scr.FvwmRoot.next; t; t = t->next)\n\t\t{\n\t\t\tif (MatchesConditionMask(t, &mask))\n\t\t\t{\n\t\t\t\tg[num++] = t;\n\t\t\t\tdoes_any_window_match = True;\n\t\t\t}\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor (t = Scr.FvwmRoot.stack_next; t && t != &Scr.FvwmRoot;\n\t\t t = t->stack_next)\n\t\t{\n\t\t\tif (MatchesConditionMask(t, &mask))\n\t\t\t{\n\t\t\t\tg[num++] = t;\n\t\t\t\tdoes_any_window_match = True;\n\t\t\t}\n\t\t}\n\t}\n\tif (do_reverse)\n\t{\n\t\tfor (i = num-1; i >= 0; i--)\n\t\t{\n\t\t\texecute_function_override_window(\n\t\t\t\tcond_rc, exc, restofline, 0, g[i]);\n\t\t}\n\t}\n\telse\n\t{\n\t\tfor (i = 0; i < num; i++)\n\t\t{\n\t\t\texecute_function_override_window(\n\t\t\t\tcond_rc, exc, restofline, 0, g[i]);\n\t\t}\n\t}\n\tif (cond_rc != NULL && cond_rc->rc != COND_RC_BREAK)\n\t{\n\t\tcond_rc->rc = (does_any_window_match == False) ?\n\t\t\tCOND_RC_NO_MATCH : COND_RC_OK;\n\t}\n\tfree(g);\n\tFreeConditionMask(&mask);\n\n\treturn;\n}", "label": 0, "cwe": null, "length": 746 }, { "index": 99741, "code": "expireFile(char *filename, struct stat *sb,\n int *considered, int *unlinked, int *truncated)\n{\n DiskObjectPtr dobject = NULL;\n time_t t;\n int fd, rc;\n long int ret = sb->st_size;\n\n if(!preciseExpiry) {\n t = sb->st_mtime;\n if(t > current_time.tv_sec + 1) {\n do_log(L_WARN, \"File %s has access time in the future.\\n\",\n filename);\n t = current_time.tv_sec;\n }\n \n if(t > current_time.tv_sec - diskCacheUnlinkTime &&\n (sb->st_size < diskCacheTruncateSize ||\n t > current_time.tv_sec - diskCacheTruncateTime))\n return ret;\n }\n \n (*considered)++;\n\n dobject = readDiskObject(filename, sb);\n if(!dobject) {\n do_log(L_ERROR, \"Incorrect disk entry %s -- removing.\\n\",\n scrub(filename));\n rc = unlink(filename);\n if(rc < 0) {\n do_log_error(L_ERROR, errno,\n \"Couldn't unlink %s\", scrub(filename));\n return ret;\n } else {\n (*unlinked)++;\n return 0;\n }\n }\n \n t = dobject->access;\n if(t < 0) t = dobject->age;\n if(t < 0) t = dobject->date;\n \n if(t > current_time.tv_sec)\n do_log(L_WARN, \n \"Disk entry %s (%s) has access time in the future.\\n\",\n scrub(dobject->location), scrub(dobject->filename));\n \n if(t < current_time.tv_sec - diskCacheUnlinkTime) {\n rc = unlink(dobject->filename);\n if(rc < 0) {\n do_log_error(L_ERROR, errno, \"Couldn't unlink %s\",\n scrub(filename));\n } else {\n (*unlinked)++;\n ret = 0;\n }\n } else if(dobject->size > \n diskCacheTruncateSize + 4 * dobject->body_offset && \n t < current_time.tv_sec - diskCacheTruncateTime) {\n /* We need to copy rather than simply truncate in place: the\n latter would confuse a running polipo. */\n fd = open(dobject->filename, O_RDONLY | O_BINARY, 0);\n rc = unlink(dobject->filename);\n if(rc < 0) {\n do_log_error(L_ERROR, errno, \"Couldn't unlink %s\",\n scrub(filename));\n close(fd);\n fd = -1;\n } else {\n (*unlinked)++;\n copyFile(fd, dobject->filename,\n dobject->body_offset + diskCacheTruncateSize);\n close(fd);\n (*unlinked)--;\n (*truncated)++;\n ret = sb->st_size - dobject->body_offset + diskCacheTruncateSize;\n }\n }\n free(dobject->location);\n free(dobject->filename);\n free(dobject);\n return ret;\n}", "label": 0, "cwe": null, "length": 655 }, { "index": 197019, "code": "camera_raw_fb_callback(const uint32_t *buffer, unsigned width, unsigned height, size_t pitch)\n{\n unsigned base_size = 4;\n unsigned h;\n\n if (!tex)\n {\n SYM(glGenTextures)(1, &tex);\n SYM(glBindTexture)(GL_TEXTURE_2D, tex);\n SYM(glTexParameteri)(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n SYM(glTexParameteri)(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n SYM(glTexParameteri)(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);\n SYM(glTexParameteri)(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);\n SYM(glTexImage2D)(GL_TEXTURE_2D, 0, INTERNAL_FORMAT, width, height, 0, TEX_TYPE, TEX_FORMAT, NULL);\n if (!support_unpack_row_length)\n convert_buffer = new uint8_t[width * height * 4];\n }\n else\n SYM(glBindTexture)(GL_TEXTURE_2D, tex);\n\n if (support_unpack_row_length)\n {\n SYM(glPixelStorei)(GL_UNPACK_ROW_LENGTH, pitch / base_size);\n SYM(glTexSubImage2D)(GL_TEXTURE_2D,\n 0, 0, 0, width, height, TEX_TYPE,\n TEX_FORMAT, buffer);\n\n SYM(glPixelStorei)(GL_UNPACK_ROW_LENGTH, 0);\n }\n else\n {\n // No GL_UNPACK_ROW_LENGTH ;(\n unsigned pitch_width = pitch / base_size;\n if (width == pitch_width) // Happy path :D\n {\n SYM(glTexSubImage2D)(GL_TEXTURE_2D,\n 0, 0, 0, width, height, TEX_TYPE,\n TEX_FORMAT, buffer);\n }\n else // Slower path.\n {\n const unsigned line_bytes = width * base_size;\n\n uint8_t *dst = (uint8_t*)convert_buffer; // This buffer is preallocated for this purpose.\n const uint8_t *src = (const uint8_t*)buffer;\n\n for (h = 0; h < height; h++, src += pitch, dst += line_bytes)\n memcpy(dst, src, line_bytes);\n\n SYM(glTexSubImage2D)(GL_TEXTURE_2D,\n 0, 0, 0, width, height, TEX_TYPE,\n TEX_FORMAT, convert_buffer); \n }\n }\n\n SYM(glBindTexture)(GL_TEXTURE_2D, 0);\n}", "label": 0, "cwe": null, "length": 556 }, { "index": 806827, "code": "qBri_cpu_trapped(PISDN_ADAPTER IoAdapter) {\n\tbyte __iomem *base;\n\tword *Xlog;\n\tdword regs[4], TrapID, offset, size;\n\tXdesc xlogDesc;\n\tint factor = (IoAdapter->tasks == 1) ? 1 : 2;\n\n/*\n *\tcheck for trapped MIPS 46xx CPU, dump exception frame\n */\n\n\tbase = DIVA_OS_MEM_ATTACH_CONTROL(IoAdapter);\n\toffset = IoAdapter->ControllerNumber * (IoAdapter->MemorySize >> factor);\n\n\tTrapID = READ_DWORD(&base[0x80]);\n\n\tif ((TrapID == 0x99999999) || (TrapID == 0x99999901))\n\t{\n\t\tdump_trap_frame(IoAdapter, &base[0x90]);\n\t\tIoAdapter->trapped = 1;\n\t}\n\n\tregs[0] = READ_DWORD((base + offset) + 0x70);\n\tregs[1] = READ_DWORD((base + offset) + 0x74);\n\tregs[2] = READ_DWORD((base + offset) + 0x78);\n\tregs[3] = READ_DWORD((base + offset) + 0x7c);\n\tregs[0] &= IoAdapter->MemorySize - 1;\n\n\tif ((regs[0] >= offset)\n\t && (regs[0] < offset + (IoAdapter->MemorySize >> factor) - 1))\n\t{\n\t\tif (!(Xlog = (word *)diva_os_malloc(0, MAX_XLOG_SIZE))) {\n\t\t\tDIVA_OS_MEM_DETACH_CONTROL(IoAdapter, base);\n\t\t\treturn;\n\t\t}\n\n\t\tsize = offset + (IoAdapter->MemorySize >> factor) - regs[0];\n\t\tif (size > MAX_XLOG_SIZE)\n\t\t\tsize = MAX_XLOG_SIZE;\n\t\tmemcpy_fromio(Xlog, &base[regs[0]], size);\n\t\txlogDesc.buf = Xlog;\n\t\txlogDesc.cnt = READ_WORD(&base[regs[1] & (IoAdapter->MemorySize - 1)]);\n\t\txlogDesc.out = READ_WORD(&base[regs[2] & (IoAdapter->MemorySize - 1)]);\n\t\tdump_xlog_buffer(IoAdapter, &xlogDesc);\n\t\tdiva_os_free(0, Xlog);\n\t\tIoAdapter->trapped = 2;\n\t}\n\tDIVA_OS_MEM_DETACH_CONTROL(IoAdapter, base);\n}", "label": 0, "cwe": null, "length": 522 }, { "index": 51189, "code": "gst_ximagesink_set_window_handle (GstVideoOverlay * overlay, guintptr id)\n{\n XID xwindow_id = id;\n GstXImageSink *ximagesink = GST_XIMAGESINK (overlay);\n GstXWindow *xwindow = NULL;\n XWindowAttributes attr;\n\n /* We acquire the stream lock while setting this window in the element.\n We are basically cleaning tons of stuff replacing the old window, putting\n images while we do that would surely crash */\n g_mutex_lock (&ximagesink->flow_lock);\n\n /* If we already use that window return */\n if (ximagesink->xwindow && (xwindow_id == ximagesink->xwindow->win)) {\n g_mutex_unlock (&ximagesink->flow_lock);\n return;\n }\n\n /* If the element has not initialized the X11 context try to do so */\n if (!ximagesink->xcontext &&\n !(ximagesink->xcontext = gst_ximagesink_xcontext_get (ximagesink))) {\n g_mutex_unlock (&ximagesink->flow_lock);\n /* we have thrown a GST_ELEMENT_ERROR now */\n return;\n }\n\n /* If a window is there already we destroy it */\n if (ximagesink->xwindow) {\n gst_ximagesink_xwindow_destroy (ximagesink, ximagesink->xwindow);\n ximagesink->xwindow = NULL;\n }\n\n /* If the xid is 0 we go back to an internal window */\n if (xwindow_id == 0) {\n /* If no width/height caps nego did not happen window will be created\n during caps nego then */\n if (GST_VIDEO_SINK_WIDTH (ximagesink) && GST_VIDEO_SINK_HEIGHT (ximagesink)) {\n xwindow = gst_ximagesink_xwindow_new (ximagesink,\n GST_VIDEO_SINK_WIDTH (ximagesink),\n GST_VIDEO_SINK_HEIGHT (ximagesink));\n }\n } else {\n xwindow = g_new0 (GstXWindow, 1);\n\n xwindow->win = xwindow_id;\n\n /* We get window geometry, set the event we want to receive,\n and create a GC */\n g_mutex_lock (&ximagesink->x_lock);\n XGetWindowAttributes (ximagesink->xcontext->disp, xwindow->win, &attr);\n xwindow->width = attr.width;\n xwindow->height = attr.height;\n xwindow->internal = FALSE;\n if (ximagesink->handle_events) {\n XSelectInput (ximagesink->xcontext->disp, xwindow->win, ExposureMask |\n StructureNotifyMask | PointerMotionMask | KeyPressMask |\n KeyReleaseMask);\n }\n\n xwindow->gc = XCreateGC (ximagesink->xcontext->disp, xwindow->win, 0, NULL);\n g_mutex_unlock (&ximagesink->x_lock);\n }\n\n if (xwindow)\n ximagesink->xwindow = xwindow;\n\n g_mutex_unlock (&ximagesink->flow_lock);\n}", "label": 0, "cwe": null, "length": 656 }, { "index": 124392, "code": "infer_handle_reference_bool(CdlTransaction transaction, CdlValuable valuable, bool goal, int level)\n{\n CYG_REPORT_FUNCNAMETYPE(\"infer_handle_reference_bool\", \"result %d\");\n CYG_REPORT_FUNCARG4XV(transaction, valuable, goal, level);\n\n bool result = false;\n if (0 == valuable) {\n if (!goal) {\n result = true;\n }\n CYG_REPORT_RETVAL(result);\n return result;\n }\n\n // If the valuable should evaluate to true then it must be both active\n // and be either enabled or have a non-zero value.\n if (goal) {\n if (!transaction->is_active(valuable)) {\n if (!CdlInfer::make_active(transaction, valuable, level)) {\n CYG_REPORT_RETVAL(result);\n return result;\n }\n }\n if (CdlInfer::set_valuable_bool(transaction, valuable, true, level)) {\n result = true;\n }\n\n } else {\n // If the valuable should evaluate to false then it must be either\n // inactive or it must be disabled or have a zero value.\n if (!transaction->is_active(valuable)) {\n // The goal is already satisfied, no need to proceed\n result = true;\n CYG_REPORT_RETVAL(result);\n return result;\n }\n \n // There is a choice to be made so two sub-transactions are\n // needed. Disabling is generally preferred to making inactive.\n CdlTransaction value_transaction = transaction->make(transaction->get_conflict());\n CdlTransaction inactive_transaction = 0;\n bool value_result = CdlInfer::set_valuable_bool(value_transaction, valuable, false, level);\n if (value_result && !value_transaction->user_confirmation_required()) {\n value_transaction->commit();\n delete value_transaction;\n value_transaction = 0;\n result = true;\n CYG_REPORT_RETVAL(result);\n return result;\n }\n\n inactive_transaction = transaction->make(transaction->get_conflict());\n bool inactive_result = CdlInfer::make_inactive(inactive_transaction, valuable, level);\n if (!inactive_result) {\n if (value_result) {\n // Changing the value is the only solution.\n inactive_transaction->cancel();\n value_transaction->commit();\n result = true;\n } else {\n inactive_transaction->cancel();\n value_transaction->cancel();\n result = false;\n }\n } else {\n if (!value_result) {\n // Making the valuable inactive is the only solution.\n value_transaction->cancel();\n inactive_transaction->commit();\n result = true;\n } else if (!inactive_transaction->user_confirmation_required()) {\n // Disabling the valuable would require user confirmation, making it inactive does not\n value_transaction->cancel();\n inactive_transaction->commit();\n result = true;\n } else {\n // Both approaches are valid but would require user confirmation.\n // Pick the preferred one.\n if (value_transaction->is_preferable_to(inactive_transaction)) {\n inactive_transaction->cancel();\n value_transaction->commit();\n result = true;\n } else {\n value_transaction->cancel();\n inactive_transaction->commit();\n result = true;\n }\n }\n }\n\n delete value_transaction;\n delete inactive_transaction;\n value_transaction = 0;\n inactive_transaction = 0;\n }\n \n CYG_REPORT_RETVAL(result);\n return result;\n}", "label": 0, "cwe": null, "length": 721 }, { "index": 539548, "code": "__ecereInstMeth___ecereNameSpace__ecere__gui__controls__MenuItem_NotifySelect__00000012(struct __ecereNameSpace__ecere__com__Instance * this, struct __ecereNameSpace__ecere__com__Instance * item, unsigned int mods)\n{\nstruct __ecereNameSpace__ecere__gui__controls__EditBox * __ecerePointer___ecereNameSpace__ecere__gui__controls__EditBox = (struct __ecereNameSpace__ecere__gui__controls__EditBox *)(this ? (((char *)this) + __ecereClass___ecereNameSpace__ecere__gui__controls__EditBox->offset) : 0);\nstruct __ecereNameSpace__ecere__com__Instance * dialog = (dialog = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass___ecereNameSpace__ecere__gui__dialogs__ReplaceDialog), __ecereProp___ecereNameSpace__ecere__gui__Window_Set_master(dialog, __ecereProp___ecereNameSpace__ecere__gui__Window_Get_master(this)), __ecereProp___ecereNameSpace__ecere__gui__Window_Set_isModal(dialog, 0x1), __ecereProp___ecereNameSpace__ecere__gui__dialogs__ReplaceDialog_Set_searchString(dialog, __ecereNameSpace__ecere__gui__controls__searchString), __ecereProp___ecereNameSpace__ecere__gui__dialogs__ReplaceDialog_Set_replaceString(dialog, __ecereNameSpace__ecere__gui__controls__replaceString), __ecereProp___ecereNameSpace__ecere__gui__dialogs__ReplaceDialog_Set_matchCase(dialog, __ecereNameSpace__ecere__gui__controls__matchCase), __ecereProp___ecereNameSpace__ecere__gui__dialogs__ReplaceDialog_Set_wholeWord(dialog, __ecereNameSpace__ecere__gui__controls__wholeWord), __ecereProp___ecereNameSpace__ecere__gui__dialogs__ReplaceDialog_Set_editBox(dialog, this), __ecereNameSpace__ecere__com__eInstance_SetMethod(dialog, \"NotifyDestroyed\", __ecereInstMeth___ecereNameSpace__ecere__gui__dialogs__ReplaceDialog_NotifyDestroyed__00000013), dialog);\n\n__ecereMethod___ecereNameSpace__ecere__gui__Window_Create(dialog);\nreturn 0x1;\n}", "label": 0, "cwe": null, "length": 538 }, { "index": 1001799, "code": "data(const QModelIndex &index, int role) const\n{\n\tif(!index.isValid())\n\t\treturn QVariant();\n\n\tActionTools::ActionInstance *actionInstance = mScript->actionAt(index.row());\n\tif(!actionInstance)\n\t\treturn QVariant();\n\n\tswitch(role)\n\t{\n\tcase ActionDataRole:\n\t\treturn QVariant::fromValue(*actionInstance);\n\tcase ActionIdRole:\n\t\treturn actionInstance->definition()->id();\n\tcase Qt::BackgroundRole:\n\t\t{\n\t\t\tconst QColor &color = actionInstance->color();\n\n\t\t\tif(color.isValid())\n\t\t\t\treturn QBrush(color);\n\n\t\t\treturn QBrush();\n\t\t}\n\tcase Qt::FontRole:\n\t\t{\n\t\t\tif(!actionInstance->definition()->worksUnderThisOS())\n\t\t\t{\n\t\t\t\tQFont font = QApplication::font();\n\n\t\t\t\tfont.setItalic(true);\n\n\t\t\t\treturn font;\n\t\t\t}\n\n\t\t\treturn QFont();\n\t\t}\n\tcase Qt::ForegroundRole:\n\t\t{\n\t\t\tconst QColor &color = actionInstance->color();\n\t\t\tif(color.isValid())\n\t\t\t{\n\t\t\t\tif(color.lightness() < 128)\n\t\t\t\t\treturn QBrush(Qt::white);\n\t\t\t\telse\n\t\t\t\t\treturn QBrush(Qt::black);\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tconst QPalette &palette = QApplication::palette();\n\n\t\t\t\tif(!actionInstance->isEnabled())\n\t\t\t\t\treturn QBrush(palette.color(QPalette::Disabled, QPalette::WindowText));\n\n\t\t\t\treturn QBrush();\n\t\t\t}\n\t\t}\n\t}\n\n\tswitch(index.column())\n\t{\n\tcase ColumnLabel:\n\t\tswitch(role)\n\t\t{\n\t\t\tcase Qt::CheckStateRole:\n\t\t\t\treturn QVariant(actionInstance->isEnabled() ? Qt::Checked : Qt::Unchecked);\n\t\t\tcase Qt::DisplayRole:\n\t\t\t{\n\t\t\t\tQString labelString = actionInstance->label();\n\t\t\t\tif(!labelString.isNull() && !labelString.isEmpty())\n\t\t\t\t\treturn labelString;\n\n\t\t\t\treturn QString(\"%1\").arg(index.row() + 1, 3, 10, QChar('0'));\n\t\t\t}\n\t\t\tcase Qt::EditRole:\n\t\t\t\treturn actionInstance->label();\n\t\t}\n\t\tbreak;\n\tcase ColumnActionName:\n\t\tswitch(role)\n\t\t{\n\t\t\tcase Qt::ToolTipRole:\n\t\t\t\treturn tr(\"Double-clic to edit the action\");\n\t\t\tcase Qt::DisplayRole:\n\t\t\t\treturn actionInstance->definition()->name();\n\t\t\tcase Qt::DecorationRole:\n\t\t\t\treturn QIcon(actionInstance->definition()->icon());\n\t\t\tcase Qt::TextAlignmentRole:\n\t\t\t\treturn Qt::AlignCenter;\n\t\t}\n\t\tbreak;\n\tcase ColumnComment:\n\t\tswitch(role)\n\t\t{\n\t\t\tcase Qt::DisplayRole:\n\t\t\tcase Qt::EditRole:\n\t\t\t\treturn actionInstance->comment();\n\t\t}\n\t\tbreak;\n\t}\n\n\treturn QVariant();\n}", "label": 0, "cwe": null, "length": 547 }, { "index": 869329, "code": "fso_gsm_plus_cala_real_parse (FsoGsmAbstractAtCommand* base, const gchar* response, GError** error) {\n\tFsoGsmPlusCALA * 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\tgint _tmp6_ = 0;\n\tgint _tmp7_ = 0;\n\tGError * _inner_error_ = NULL;\n\tself = (FsoGsmPlusCALA*) base;\n\tg_return_if_fail (response != NULL);\n\t_tmp0_ = response;\n\tFSO_GSM_ABSTRACT_AT_COMMAND_CLASS (fso_gsm_plus_cala_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, \"year\");\n\tself->year = _tmp1_;\n\t_tmp2_ = fso_gsm_abstract_at_command_to_int ((FsoGsmAbstractAtCommand*) self, \"month\");\n\tself->month = _tmp2_;\n\t_tmp3_ = fso_gsm_abstract_at_command_to_int ((FsoGsmAbstractAtCommand*) self, \"day\");\n\tself->day = _tmp3_;\n\t_tmp4_ = fso_gsm_abstract_at_command_to_int ((FsoGsmAbstractAtCommand*) self, \"hour\");\n\tself->hour = _tmp4_;\n\t_tmp5_ = fso_gsm_abstract_at_command_to_int ((FsoGsmAbstractAtCommand*) self, \"minute\");\n\tself->minute = _tmp5_;\n\t_tmp6_ = fso_gsm_abstract_at_command_to_int ((FsoGsmAbstractAtCommand*) self, \"second\");\n\tself->second = _tmp6_;\n\t_tmp7_ = fso_gsm_abstract_at_command_to_int ((FsoGsmAbstractAtCommand*) self, \"tzoffset\");\n\tself->tzoffset = _tmp7_;\n}", "label": 0, "cwe": null, "length": 589 }, { "index": 1015165, "code": "GetExporter(FlowSource_t *fs, uint32_t exporter_id) {\n#define IP_STRING_LEN 40\nchar ipstr[IP_STRING_LEN];\nexporter_v9_domain_t **e = (exporter_v9_domain_t **)&(fs->exporter_data);\n\n\twhile ( *e ) {\n\t\tif ( (*e)->info.id == exporter_id && (*e)->info.version == 9 && \n\t\t\t (*e)->info.ip.v6[0] == fs->ip.v6[0] && (*e)->info.ip.v6[1] == fs->ip.v6[1]) \n\t\t\treturn *e;\n\t\te = &((*e)->next);\n\t}\n\n\tif ( fs->sa_family == AF_INET ) {\n\t\tuint32_t _ip = htonl(fs->ip.v4);\n\t\tinet_ntop(AF_INET, &_ip, ipstr, sizeof(ipstr));\n\t} else if ( fs->sa_family == AF_INET6 ) {\n\t\tuint64_t _ip[2];\n\t\t_ip[0] = htonll(fs->ip.v6[0]);\n\t\t_ip[1] = htonll(fs->ip.v6[1]);\n\t\tinet_ntop(AF_INET6, &_ip, ipstr, sizeof(ipstr));\n\t} else {\n\t\tstrncpy(ipstr, \"\", IP_STRING_LEN);\n\t}\n\n\t// nothing found\n\t*e = (exporter_v9_domain_t *)malloc(sizeof(exporter_v9_domain_t));\n\tif ( !(*e)) {\n\t\tsyslog(LOG_ERR, \"Process_v9: Panic! malloc() %s line %d: %s\", __FILE__, __LINE__, strerror (errno));\n\t\treturn NULL;\n\t}\n\tmemset((void *)(*e), 0, sizeof(exporter_v9_domain_t));\n\t(*e)->info.header.type = ExporterInfoRecordType;\n\t(*e)->info.header.size = sizeof(exporter_info_record_t);\n\t(*e)->info.version \t\t= 9;\n\t(*e)->info.id \t\t\t= exporter_id;\n\t(*e)->info.ip\t\t\t= fs->ip;\n\t(*e)->info.sa_family\t= fs->sa_family;\n\t(*e)->info.sysid \t\t= 0;\n\n\t(*e)->first\t \t\t\t= 1;\n\t(*e)->sequence_failure\t= 0;\n\n\t(*e)->sampler \t = NULL;\n\t(*e)->next\t \t = NULL;\n\n\tFlushInfoExporter(fs, &((*e)->info));\n\n\tdbg_printf(\"Process_v9: New exporter: SysID: %u, Domain: %u, IP: %s\\n\", \n\t\t(*e)->info.sysid, exporter_id, ipstr);\n\tsyslog(LOG_INFO, \"Process_v9: New exporter: SysID: %u, Domain: %u, IP: %s\\n\", \n\t\t(*e)->info.sysid, exporter_id, ipstr);\n\n\n\treturn (*e);\n\n}", "label": 0, "cwe": null, "length": 616 }, { "index": 64837, "code": "k5_try_realm_txt_rr(krb5_context context, const char *prefix, const char *name,\n char **realm)\n{\n krb5_error_code retval = KRB5_ERR_HOST_REALM_UNKNOWN;\n const unsigned char *p, *base;\n char host[MAXDNAME];\n int ret, rdlen, len;\n struct krb5int_dns_state *ds = NULL;\n struct k5buf buf;\n\n /*\n * Form our query, and send it via DNS\n */\n\n k5_buf_init_fixed(&buf, host, sizeof(host));\n if (name == NULL || name[0] == '\\0') {\n k5_buf_add(&buf, prefix);\n } else {\n k5_buf_add_fmt(&buf, \"%s.%s\", prefix, name);\n\n /* Realm names don't (normally) end with \".\", but if the query\n doesn't end with \".\" and doesn't get an answer as is, the\n resolv code will try appending the local domain. Since the\n realm names are absolutes, let's stop that.\n\n But only if a name has been specified. If we are performing\n a search on the prefix alone then the intention is to allow\n the local domain or domain search lists to be expanded.\n */\n\n len = k5_buf_len(&buf);\n if (len > 0 && host[len - 1] != '.')\n k5_buf_add(&buf, \".\");\n }\n if (k5_buf_data(&buf) == NULL)\n return KRB5_ERR_HOST_REALM_UNKNOWN;\n ret = krb5int_dns_init(&ds, host, C_IN, T_TXT);\n if (ret < 0) {\n TRACE_TXT_LOOKUP_NOTFOUND(context, host);\n goto errout;\n }\n\n ret = krb5int_dns_nextans(ds, &base, &rdlen);\n if (ret < 0 || base == NULL)\n goto errout;\n\n p = base;\n if (!INCR_OK(base, rdlen, p, 1))\n goto errout;\n len = *p++;\n *realm = malloc((size_t)len + 1);\n if (*realm == NULL) {\n retval = ENOMEM;\n goto errout;\n }\n strncpy(*realm, (const char *)p, (size_t)len);\n (*realm)[len] = '\\0';\n /* Avoid a common error. */\n if ( (*realm)[len-1] == '.' )\n (*realm)[len-1] = '\\0';\n retval = 0;\n TRACE_TXT_LOOKUP_SUCCESS(context, host, *realm);\n\nerrout:\n if (ds != NULL) {\n krb5int_dns_fini(ds);\n ds = NULL;\n }\n return retval;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 593 }, { "index": 559468, "code": "gdImageFillToBorder (gdImagePtr im, int x, int y, int border, int color)\n{\n\tint lastBorder;\n\t/* Seek left */\n\tint leftLimit, rightLimit;\n\tint i;\n\tint restoreAlphaBleding;\n\n\tif (border < 0) {\n\t\t/* Refuse to fill to a non-solid border */\n\t\treturn;\n\t}\n\n\tleftLimit = (-1);\n\n\trestoreAlphaBleding = im->alphaBlendingFlag;\n\tim->alphaBlendingFlag = 0;\n\n\tif (x >= im->sx) {\n\t\tx = im->sx - 1;\n\t} else if (x < 0) {\n\t\tx = 0;\n\t}\n\tif (y >= im->sy) {\n\t\ty = im->sy - 1;\n\t} else if (y < 0) {\n\t\ty = 0;\n\t}\n\t\n\tfor (i = x; (i >= 0); i--) {\n\t\tif (gdImageGetPixel (im, i, y) == border) {\n\t\t\tbreak;\n\t\t}\n\t\tgdImageSetPixel (im, i, y, color);\n\t\tleftLimit = i;\n\t}\n\tif (leftLimit == (-1)) {\n\t\tim->alphaBlendingFlag = restoreAlphaBleding;\n\t\treturn;\n\t}\n\t/* Seek right */\n\trightLimit = x;\n\tfor (i = (x + 1); (i < im->sx); i++) {\n\t\tif (gdImageGetPixel (im, i, y) == border) {\n\t\t\tbreak;\n\t\t}\n\t\tgdImageSetPixel (im, i, y, color);\n\t\trightLimit = i;\n\t}\n\t/* Look at lines above and below and start paints */\n\t/* Above */\n\tif (y > 0) {\n\t\tlastBorder = 1;\n\t\tfor (i = leftLimit; (i <= rightLimit); i++) {\n\t\t\tint c;\n\t\t\tc = gdImageGetPixel (im, i, y - 1);\n\t\t\tif (lastBorder) {\n\t\t\t\tif ((c != border) && (c != color)) {\n\t\t\t\t\tgdImageFillToBorder (im, i, y - 1, border, color);\n\t\t\t\t\tlastBorder = 0;\n\t\t\t\t}\n\t\t\t} else if ((c == border) || (c == color)) {\n\t\t\t\tlastBorder = 1;\n\t\t\t}\n\t\t}\n\t}\n\t/* Below */\n\tif (y < ((im->sy) - 1)) {\n\t\tlastBorder = 1;\n\t\tfor (i = leftLimit; (i <= rightLimit); i++) {\n\t\t\tint c = gdImageGetPixel (im, i, y + 1);\n\t\t\tif (lastBorder) {\n\t\t\t\tif ((c != border) && (c != color)) {\n\t\t\t\t\tgdImageFillToBorder (im, i, y + 1, border, color);\n\t\t\t\t\tlastBorder = 0;\n\t\t\t\t}\n\t\t\t} else if ((c == border) || (c == color)) {\n\t\t\t\tlastBorder = 1;\n\t\t\t}\n\t\t}\n\t}\n\tim->alphaBlendingFlag = restoreAlphaBleding;\n}", "label": 0, "cwe": null, "length": 661 }, { "index": 912703, "code": "create_mul_imm_cand (gimple gs, tree base_in, tree stride_in, bool speed)\n{\n tree base = NULL_TREE, stride = NULL_TREE, ctype = NULL_TREE;\n double_int index, temp;\n unsigned savings = 0;\n slsr_cand_t c;\n slsr_cand_t base_cand = base_cand_from_table (base_in);\n\n /* Look at all interpretations of the base candidate, if necessary,\n to find information to propagate into this candidate. */\n while (base_cand && !base)\n {\n if (base_cand->kind == CAND_MULT\n\t && TREE_CODE (base_cand->stride) == INTEGER_CST)\n\t{\n\t /* Y = (B + i') * S, S constant\n\t X = Y * c\n\t ============================\n\t X = (B + i') * (S * c) */\n\t base = base_cand->base_expr;\n\t index = base_cand->index;\n\t temp = tree_to_double_int (base_cand->stride)\n\t\t * tree_to_double_int (stride_in);\n\t stride = double_int_to_tree (TREE_TYPE (stride_in), temp);\n\t ctype = base_cand->cand_type;\n\t if (has_single_use (base_in))\n\t savings = (base_cand->dead_savings \n\t\t + stmt_cost (base_cand->cand_stmt, speed));\n\t}\n else if (base_cand->kind == CAND_ADD\n\t && operand_equal_p (base_cand->stride, integer_one_node, 0))\n\t{\n\t /* Y = B + (i' * 1)\n\t X = Y * c\n\t ===========================\n\t X = (B + i') * c */\n\t base = base_cand->base_expr;\n\t index = base_cand->index;\n\t stride = stride_in;\n\t ctype = base_cand->cand_type;\n\t if (has_single_use (base_in))\n\t savings = (base_cand->dead_savings\n\t\t + stmt_cost (base_cand->cand_stmt, speed));\n\t}\n else if (base_cand->kind == CAND_ADD\n\t && base_cand->index.is_one ()\n\t && TREE_CODE (base_cand->stride) == INTEGER_CST)\n\t{\n\t /* Y = B + (1 * S), S constant\n\t X = Y * c\n\t ===========================\n\t X = (B + S) * c */\n\t base = base_cand->base_expr;\n\t index = tree_to_double_int (base_cand->stride);\n\t stride = stride_in;\n\t ctype = base_cand->cand_type;\n\t if (has_single_use (base_in))\n\t savings = (base_cand->dead_savings\n\t\t + stmt_cost (base_cand->cand_stmt, speed));\n\t}\n\n if (base_cand->next_interp)\n\tbase_cand = lookup_cand (base_cand->next_interp);\n else\n\tbase_cand = NULL;\n }\n\n if (!base)\n {\n /* No interpretations had anything useful to propagate, so\n\t produce X = (Y + 0) * c. */\n base = base_in;\n index = double_int_zero;\n stride = stride_in;\n ctype = TREE_TYPE (base_in);\n }\n\n c = alloc_cand_and_find_basis (CAND_MULT, gs, base, index, stride,\n\t\t\t\t ctype, savings);\n return c;\n}", "label": 0, "cwe": null, "length": 735 }, { "index": 360142, "code": "doPersist()\n{\n Q_ASSERT(m_unchangedIndexes.isEmpty());\n Q_ASSERT(m_unchangedPersistentIndexes.isEmpty());\n\n const int columnCount = m_model->columnCount();\n QMutableListIterator it(m_changeList);\n\n // The indexes are defined by the test are described with IndexFinder before anything in the model exists.\n // Now that the indexes should exist, resolve them in the change objects.\n QList changedRanges;\n\n while (it.hasNext())\n {\n PersistentIndexChange change = it.next();\n change.parentFinder.setModel(m_model);\n QModelIndex parent = change.parentFinder.getIndex();\n\n Q_ASSERT(change.startRow >= 0);\n Q_ASSERT(change.startRow <= change.endRow);\n\n if (change.endRow >= m_model->rowCount(parent))\n qDebug() << m_model << parent << change.startRow << change.endRow << parent.data() << m_model->rowCount(parent);\n\n Q_ASSERT(change.endRow < m_model->rowCount(parent));\n\n QModelIndex topLeft = m_model->index( change.startRow, 0, parent );\n QModelIndex bottomRight = m_model->index( change.endRow, columnCount - 1, parent );\n\n // We store the changed ranges so that we know which ranges should not be changed\n changedRanges << QItemSelectionRange(topLeft, bottomRight);\n\n // Store the inital state of the indexes in the model which we expect to change.\n for (int row = change.startRow; row <= change.endRow; ++row )\n {\n for (int column = 0; column < columnCount; ++column)\n {\n QModelIndex idx = m_model->index(row, column, parent);\n Q_ASSERT(idx.isValid());\n change.indexes << idx;\n change.persistentIndexes << QPersistentModelIndex(idx);\n }\n\n // Also store the descendants of changed indexes so that we can verify the effect on them\n QModelIndex idx = m_model->index(row, 0, parent);\n QModelIndexList descs = getDescendantIndexes(idx);\n change.descendantIndexes << descs;\n change.persistentDescendantIndexes << toPersistent(descs);\n }\n it.setValue(change);\n }\n // Any indexes outside of the ranges we expect to be changed are stored\n // so that we can later verify that they remain unchanged.\n m_unchangedIndexes = getUnchangedIndexes(QModelIndex(), changedRanges);\n m_unchangedPersistentIndexes = toPersistent(m_unchangedIndexes);\n}", "label": 0, "cwe": null, "length": 517 }, { "index": 128901, "code": "ensMiscellaneousfeatureadaptorFetchAllbySlicecodes(\n EnsPMiscellaneousfeatureadaptor mfa,\n EnsPSlice slice,\n const AjPList codes,\n AjPList mfs)\n{\n ajuint maxlen = 0U;\n\n AjIList iter = NULL;\n\n AjPStr code = NULL;\n AjPStr constraint = NULL;\n AjPStr csv = NULL;\n\n EnsPDatabaseadaptor dba = NULL;\n\n EnsPMiscellaneousset ms = NULL;\n EnsPMiscellaneoussetadaptor msa = NULL;\n\n if (!mfa)\n return ajFalse;\n\n if (!slice)\n return ajFalse;\n\n if (!codes)\n return ajFalse;\n\n if (!mfs)\n return ajFalse;\n\n dba = ensMiscellaneousfeatureadaptorGetDatabaseadaptor(mfa);\n\n msa = ensRegistryGetMiscellaneoussetadaptor(dba);\n\n csv = ajStrNew();\n\n iter = ajListIterNewread(codes);\n\n while (!ajListIterDone(iter))\n {\n code = (AjPStr) ajListIterGet(iter);\n\n ensMiscellaneoussetadaptorFetchByCode(msa, code, &ms);\n\n if (ms)\n {\n maxlen = (ensMiscellaneoussetGetMaximumlength(ms) > maxlen) ?\n ensMiscellaneoussetGetMaximumlength(ms) : maxlen;\n\n ajFmtPrintAppS(&csv, \"%u, \", ensMiscellaneoussetGetIdentifier(ms));\n\n ensMiscellaneoussetDel(&ms);\n }\n else\n ajWarn(\"ensMiscellaneousfeatureadaptorFetchAllbySlicecodes \"\n \"no Miscellaneous Set with code '%S'.\\n\", code);\n }\n\n ajListIterDel(&iter);\n\n /* Remove the last comma and space from the comma-separated values. */\n\n ajStrCutEnd(&csv, 2);\n\n if (ajStrGetLen(csv) > 0)\n {\n constraint = ajFmtStr(\"misc_feature_misc_set.misc_set_id IN (%S)\",\n csv);\n\n ensFeatureadaptorSetMaximumlength(mfa, maxlen);\n\n ensFeatureadaptorFetchAllbySlice(mfa,\n slice,\n constraint,\n (const AjPStr) NULL,\n mfs);\n\n ensFeatureadaptorSetMaximumlength(mfa, 0);\n\n ajStrDel(&constraint);\n }\n\n ajStrDel(&csv);\n\n return ajTrue;\n}", "label": 0, "cwe": null, "length": 517 }, { "index": 396364, "code": "Compile(RegExpCompileData* data,\n bool ignore_case,\n bool is_multiline,\n Handle pattern,\n bool is_ascii) {\n if ((data->capture_count + 1) * 2 - 1 > RegExpMacroAssembler::kMaxRegister) {\n return IrregexpRegExpTooBig();\n }\n RegExpCompiler compiler(data->capture_count, ignore_case, is_ascii);\n // Wrap the body of the regexp in capture #0.\n RegExpNode* captured_body = RegExpCapture::ToNode(data->tree,\n 0,\n &compiler,\n compiler.accept());\n RegExpNode* node = captured_body;\n if (!data->tree->IsAnchored()) {\n // Add a .*? at the beginning, outside the body capture, unless\n // this expression is anchored at the beginning.\n RegExpNode* loop_node =\n RegExpQuantifier::ToNode(0,\n RegExpTree::kInfinity,\n false,\n new RegExpCharacterClass('*'),\n &compiler,\n captured_body,\n data->contains_anchor);\n\n if (data->contains_anchor) {\n // Unroll loop once, to take care of the case that might start\n // at the start of input.\n ChoiceNode* first_step_node = new ChoiceNode(2);\n first_step_node->AddAlternative(GuardedAlternative(captured_body));\n first_step_node->AddAlternative(GuardedAlternative(\n new TextNode(new RegExpCharacterClass('*'), loop_node)));\n node = first_step_node;\n } else {\n node = loop_node;\n }\n }\n data->node = node;\n Analysis analysis(ignore_case, is_ascii);\n analysis.EnsureAnalyzed(node);\n if (analysis.has_failed()) {\n const char* error_message = analysis.error_message();\n return CompilationResult(error_message);\n }\n\n NodeInfo info = *node->info();\n\n // Create the correct assembler for the architecture.\n#ifdef V8_NATIVE_REGEXP\n // Native regexp implementation.\n\n NativeRegExpMacroAssembler::Mode mode =\n is_ascii ? NativeRegExpMacroAssembler::ASCII\n : NativeRegExpMacroAssembler::UC16;\n\n#if V8_TARGET_ARCH_IA32\n RegExpMacroAssemblerIA32 macro_assembler(mode, (data->capture_count + 1) * 2);\n#elif V8_TARGET_ARCH_X64\n RegExpMacroAssemblerX64 macro_assembler(mode, (data->capture_count + 1) * 2);\n#elif V8_TARGET_ARCH_ARM\n RegExpMacroAssemblerARM macro_assembler(mode, (data->capture_count + 1) * 2);\n#endif\n\n#else // ! V8_NATIVE_REGEXP\n // Interpreted regexp implementation.\n EmbeddedVector codes;\n RegExpMacroAssemblerIrregexp macro_assembler(codes);\n#endif\n\n return compiler.Assemble(¯o_assembler,\n node,\n data->capture_count,\n pattern);\n}", "label": 0, "cwe": null, "length": 608 }, { "index": 204470, "code": "think_capturing_enemy_town()\n{\n\tif( !ai_capture_enemy_town_recno )\n\t\treturn;\n\n\tif( town_array.is_deleted(ai_capture_enemy_town_recno) ||\n\t\t town_array[ai_capture_enemy_town_recno]->nation_recno == nation_recno )\t\t// this town has been captured already\n\t{\n\t\tai_capture_enemy_town_recno = 0;\n\t\treturn;\n\t}\n\n\t//--- check the enemy's mobile defense combat level around the town ---//\n\n\tTown* targetTown = town_array[ai_capture_enemy_town_recno];\n\tint\thasWar;\n\n\tint mobileCombatLevel = mobile_defense_combat_level(targetTown->center_x, targetTown->center_y, targetTown->nation_recno, 0, hasWar);\t\t// 0-don't return immediately even if there is war around this town\n\n\t//---- if we haven't started attacking the town yet -----//\n\n\tif( !ai_capture_enemy_town_start_attack_date )\n\t{\n\t\tif( hasWar==2 )\t\t// we are at war with the nation now\n\t\t\tai_capture_enemy_town_start_attack_date = info.game_date;\n\n\t\tif( info.game_date > ai_capture_enemy_town_plan_date + 90 )\t\t// when 3 months have gone and there still hasn't been any attack on the town, there must be something bad happened to our troop, cancel the entire action\n\t\t\tai_capture_enemy_town_recno = 0;\n\n\t\treturn;\t\t// do nothing if the attack hasn't started yet\n\t}\n\n\t//--------- check if we need reinforcement --------//\n\n\t//-----------------------------------------------------------//\n\t// Check how long we have started attacking because only\n\t// when the it has been started for a while, our force\n\t// will reach the target and the offensive and defensive force\n\t// total can be calculated accurately.\n\t//-----------------------------------------------------------//\n\n\tif( info.game_date - ai_capture_enemy_town_start_attack_date >= 15 )\n\t{\n\t\t//-------- check if we need any reinforcement --------//\n\n\t\tif( mobileCombatLevel > 0 && hasWar==2 )\t\t// we are still in war with the enemy\n\t\t{\n\t\t\tai_attack_target(targetTown->center_x, targetTown->center_y, mobileCombatLevel, 0, 1 ); // 1-just all move there and wait for the units to attack the enemies automatically\n\t\t\treturn;\n\t\t}\n\t}\n\n\t//----- there is currently no war at the town -----//\n\t//\n\t// - either we are defeated or we have destroyed their command base.\n\t//\n\t//--------------------------------------------------//\n\n\tif( hasWar != 2 )\n\t{\n\t\t//---- attack enemy's defending forces on the target town ----//\n\n\t\tint rc = attack_enemy_town_defense(targetTown, ai_capture_enemy_town_use_all_camp);\n\n\t\tif( rc == 1 )\t\t// 1 means a troop has been sent to attack the town\n\t\t{\n\t\t\tai_capture_enemy_town_start_attack_date = 0;\n\t\t\treturn;\n\t\t}\n\n\t\t//---------- reset the vars --------//\n\n\t\tai_capture_enemy_town_recno = 0;\n\t\tai_capture_enemy_town_start_attack_date = 0;\n\n\t\t//--------- other situations --------//\n\n\t\tif( rc == -1 )\t\t// -1 means no defense on the target town, no attacking is needed.\n\t\t{\n\t\t\tstart_capture( targetTown->town_recno );\t\t// call AI functions in OAI_CAPT.CPP to capture the town\n\t\t}\n\t\t\n\t\t// 0 means we don't have enough troop to attack the enemy\n\t}\n}", "label": 0, "cwe": null, "length": 770 }, { "index": 855829, "code": "copy_blkmode_from_reg (rtx tgtblk, rtx srcreg, 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, padding_correction = 0;\n enum machine_mode copy_mode;\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, TYPE_UNSIGNED (type));\n\n /* If the structure doesn't take up a whole number of words, see whether\n SRCREG is padded on the left or on the right. If it's on the left,\n set PADDING_CORRECTION to the number of bits to skip.\n\n In most ABIs, the structure will be returned at the least end of\n the register, which translates to right padding on little-endian\n targets and left padding on big-endian targets. The opposite\n holds if the structure is returned at the most significant\n end of the register. */\n if (bytes % UNITS_PER_WORD != 0\n && (targetm.calls.return_in_msb (type)\n\t ? !BYTES_BIG_ENDIAN\n\t : BYTES_BIG_ENDIAN))\n padding_correction\n = (BITS_PER_WORD - ((bytes % UNITS_PER_WORD) * BITS_PER_UNIT));\n\n /* Copy the structure BITSIZE bits at a time. If the target lives in\n memory, take care of not reading/writing past its end by selecting\n a copy mode suited to BITSIZE. This should always be possible given\n how it is computed.\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\n copy_mode = word_mode;\n if (MEM_P (tgtblk))\n {\n enum machine_mode mem_mode = mode_for_size (bitsize, MODE_INT, 1);\n if (mem_mode != BLKmode)\n\tcopy_mode = mem_mode;\n }\n\n for (bitpos = 0, xbitpos = padding_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 == padding_correction\n\t (the first time through). */\n if (xbitpos % BITS_PER_WORD == 0\n\t || xbitpos == padding_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 bitpos for the destination store (left justified). */\n store_bit_field (dst, bitsize, bitpos % BITS_PER_WORD, 0, 0, copy_mode,\n\t\t extract_bit_field (src, bitsize,\n\t\t\t\t\t xbitpos % BITS_PER_WORD, 1, false,\n\t\t\t\t\t NULL_RTX, copy_mode, copy_mode));\n }\n\n return tgtblk;\n}", "label": 0, "cwe": null, "length": 865 }, { "index": 294209, "code": "set_av_attr(struct ocrdma_dev *dev, struct ocrdma_ah *ah,\n\t\t\tstruct ib_ah_attr *attr, union ib_gid *sgid,\n\t\t\tint pdid, bool *isvlan, u16 vlan_tag)\n{\n\tint status = 0;\n\tstruct ocrdma_eth_vlan eth;\n\tstruct ocrdma_grh grh;\n\tint eth_sz;\n\n\tmemset(ð, 0, sizeof(eth));\n\tmemset(&grh, 0, sizeof(grh));\n\n\t/* VLAN */\n\tif (!vlan_tag || (vlan_tag > 0xFFF))\n\t\tvlan_tag = dev->pvid;\n\tif (vlan_tag || dev->pfc_state) {\n\t\tif (!vlan_tag) {\n\t\t\tpr_err(\"ocrdma%d:Using VLAN with PFC is recommended\\n\",\n\t\t\t\tdev->id);\n\t\t\tpr_err(\"ocrdma%d:Using VLAN 0 for this connection\\n\",\n\t\t\t\tdev->id);\n\t\t}\n\t\teth.eth_type = cpu_to_be16(0x8100);\n\t\teth.roce_eth_type = cpu_to_be16(OCRDMA_ROCE_ETH_TYPE);\n\t\tvlan_tag |= (dev->sl & 0x07) << OCRDMA_VID_PCP_SHIFT;\n\t\teth.vlan_tag = cpu_to_be16(vlan_tag);\n\t\teth_sz = sizeof(struct ocrdma_eth_vlan);\n\t\t*isvlan = true;\n\t} else {\n\t\teth.eth_type = cpu_to_be16(OCRDMA_ROCE_ETH_TYPE);\n\t\teth_sz = sizeof(struct ocrdma_eth_basic);\n\t}\n\t/* MAC */\n\tmemcpy(ð.smac[0], &dev->nic_info.mac_addr[0], ETH_ALEN);\n\tstatus = ocrdma_resolve_dmac(dev, attr, ð.dmac[0]);\n\tif (status)\n\t\treturn status;\n\tah->sgid_index = attr->grh.sgid_index;\n\tmemcpy(&grh.sgid[0], sgid->raw, sizeof(union ib_gid));\n\tmemcpy(&grh.dgid[0], attr->grh.dgid.raw, sizeof(attr->grh.dgid.raw));\n\n\tgrh.tclass_flow = cpu_to_be32((6 << 28) |\n\t\t\t(attr->grh.traffic_class << 24) |\n\t\t\tattr->grh.flow_label);\n\t/* 0x1b is next header value in GRH */\n\tgrh.pdid_hoplimit = cpu_to_be32((pdid << 16) |\n\t\t\t(0x1b << 8) | attr->grh.hop_limit);\n\t/* Eth HDR */\n\tmemcpy(&ah->av->eth_hdr, ð, eth_sz);\n\tmemcpy((u8 *)ah->av + eth_sz, &grh, sizeof(struct ocrdma_grh));\n\tif (*isvlan)\n\t\tah->av->valid |= OCRDMA_AV_VLAN_VALID;\n\tah->av->valid = cpu_to_le32(ah->av->valid);\n\treturn status;\n}", "label": 0, "cwe": null, "length": 623 }, { "index": 781283, "code": "i8xx_irq_handler(int irq, void *arg)\n{\n\tstruct drm_device *dev = arg;\n\tstruct drm_i915_private *dev_priv = dev->dev_private;\n\tu16 iir, new_iir;\n\tu32 pipe_stats[2];\n\tint pipe;\n\tu16 flip_mask =\n\t\tI915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |\n\t\tI915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;\n\tirqreturn_t ret;\n\n\tif (!intel_irqs_enabled(dev_priv))\n\t\treturn IRQ_NONE;\n\n\t/* IRQs are synced during runtime_suspend, we don't require a wakeref */\n\tdisable_rpm_wakeref_asserts(dev_priv);\n\n\tret = IRQ_NONE;\n\tiir = I915_READ16(IIR);\n\tif (iir == 0)\n\t\tgoto out;\n\n\twhile (iir & ~flip_mask) {\n\t\t/* Can't rely on pipestat interrupt bit in iir as it might\n\t\t * have been cleared after the pipestat interrupt was received.\n\t\t * It doesn't set the bit in iir again, but it still produces\n\t\t * interrupts (for non-MSI).\n\t\t */\n\t\tspin_lock(&dev_priv->irq_lock);\n\t\tif (iir & I915_RENDER_COMMAND_PARSER_ERROR_INTERRUPT)\n\t\t\tDRM_DEBUG(\"Command parser error, iir 0x%08x\\n\", iir);\n\n\t\tfor_each_pipe(dev_priv, pipe) {\n\t\t\ti915_reg_t reg = PIPESTAT(pipe);\n\t\t\tpipe_stats[pipe] = I915_READ(reg);\n\n\t\t\t/*\n\t\t\t * Clear the PIPE*STAT regs before the IIR\n\t\t\t */\n\t\t\tif (pipe_stats[pipe] & 0x8000ffff)\n\t\t\t\tI915_WRITE(reg, pipe_stats[pipe]);\n\t\t}\n\t\tspin_unlock(&dev_priv->irq_lock);\n\n\t\tI915_WRITE16(IIR, iir & ~flip_mask);\n\t\tnew_iir = I915_READ16(IIR); /* Flush posted writes */\n\n\t\tif (iir & I915_USER_INTERRUPT)\n\t\t\tnotify_ring(&dev_priv->engine[RCS]);\n\n\t\tfor_each_pipe(dev_priv, pipe) {\n\t\t\tint plane = pipe;\n\t\t\tif (HAS_FBC(dev))\n\t\t\t\tplane = !plane;\n\n\t\t\tif (pipe_stats[pipe] & PIPE_VBLANK_INTERRUPT_STATUS &&\n\t\t\t i8xx_handle_vblank(dev, plane, pipe, iir))\n\t\t\t\tflip_mask &= ~DISPLAY_PLANE_FLIP_PENDING(plane);\n\n\t\t\tif (pipe_stats[pipe] & PIPE_CRC_DONE_INTERRUPT_STATUS)\n\t\t\t\ti9xx_pipe_crc_irq_handler(dev, pipe);\n\n\t\t\tif (pipe_stats[pipe] & PIPE_FIFO_UNDERRUN_STATUS)\n\t\t\t\tintel_cpu_fifo_underrun_irq_handler(dev_priv,\n\t\t\t\t\t\t\t\t pipe);\n\t\t}\n\n\t\tiir = new_iir;\n\t}\n\tret = IRQ_HANDLED;\n\nout:\n\tenable_rpm_wakeref_asserts(dev_priv);\n\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 603 }, { "index": 103108, "code": "rtw_get_cur_max_rate(struct rtw_adapter *adapter)\n{\n\tint i = 0;\n\tconst u8 *p;\n\tu16 rate = 0, max_rate = 0;\n\tstruct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv;\n\tstruct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info;\n\tstruct registry_priv *pregistrypriv = &adapter->registrypriv;\n\tstruct mlme_priv *pmlmepriv = &adapter->mlmepriv;\n\tstruct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network;\n\tstruct ieee80211_ht_cap *pht_capie;\n\tu8 rf_type = 0;\n\tu8 bw_40MHz = 0, short_GI_20 = 0, short_GI_40 = 0;\n\tu16 mcs_rate = 0;\n\n\tp = cfg80211_find_ie(WLAN_EID_HT_CAPABILITY,\n\t\t\t pcur_bss->IEs, pcur_bss->IELength);\n\tif (p && p[1] > 0) {\n\t\tpht_capie = (struct ieee80211_ht_cap *)(p + 2);\n\n\t\tmemcpy(&mcs_rate, &pht_capie->mcs, 2);\n\n\t\t/* bw_40MHz = (pht_capie->cap_info&\n\t\t IEEE80211_HT_CAP_SUP_WIDTH_20_40) ? 1:0; */\n\t\t/* cur_bwmod is updated by beacon, pmlmeinfo is\n\t\t updated by association response */\n\t\tbw_40MHz = (pmlmeext->cur_bwmode &&\n\t\t\t (pmlmeinfo->HT_info.ht_param &\n\t\t\t IEEE80211_HT_PARAM_CHAN_WIDTH_ANY)) ? 1:0;\n\n\t\t/* short_GI = (pht_capie->cap_info & (IEEE80211_HT_CAP\n\t\t _SGI_20|IEEE80211_HT_CAP_SGI_40)) ? 1 : 0; */\n\t\tshort_GI_20 = (pmlmeinfo->ht_cap.cap_info &\n\t\t\t cpu_to_le16(IEEE80211_HT_CAP_SGI_20)) ? 1:0;\n\t\tshort_GI_40 = (pmlmeinfo->ht_cap.cap_info &\n\t\t\t cpu_to_le16(IEEE80211_HT_CAP_SGI_40)) ? 1:0;\n\n\t\trf_type = rtl8723a_get_rf_type(adapter);\n\t\tmax_rate = rtw_mcs_rate23a(rf_type, bw_40MHz &\n\t\t\t\t\t pregistrypriv->cbw40_enable,\n\t\t\t\t\t short_GI_20, short_GI_40,\n\t\t\t\t\t &pmlmeinfo->ht_cap.mcs);\n\t} else {\n\t\twhile (pcur_bss->SupportedRates[i] != 0 &&\n\t\t pcur_bss->SupportedRates[i] != 0xFF) {\n\t\t\trate = pcur_bss->SupportedRates[i] & 0x7F;\n\t\t\tif (rate > max_rate)\n\t\t\t\tmax_rate = rate;\n\t\t\ti++;\n\t\t}\n\n\t\tmax_rate = max_rate * 10 / 2;\n\t}\n\n\treturn max_rate;\n}", "label": 1, "cwe": "CWE-120", "length": 672 }, { "index": 931010, "code": "snippets_load(GKeyFile *sysconfig, GKeyFile *userconfig)\n{\n\tgsize i, j, len = 0, len_keys = 0;\n\tgchar **groups_user, **groups_sys;\n\tgchar **keys_user, **keys_sys;\n\tgchar *value;\n\tGHashTable *tmp;\n\n\t/* keys are strings, values are GHashTables, so use g_free and g_hash_table_destroy */\n\tsnippet_hash =\n\t\tg_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_destroy);\n\n\t/* first read all globally defined auto completions */\n\tgroups_sys = g_key_file_get_groups(sysconfig, &len);\n\tfor (i = 0; i < len; i++)\n\t{\n\t\tif (strcmp(groups_sys[i], \"Keybindings\") == 0)\n\t\t\tcontinue;\n\t\tkeys_sys = g_key_file_get_keys(sysconfig, groups_sys[i], &len_keys, NULL);\n\t\t/* create new hash table for the read section (=> filetype) */\n\t\ttmp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);\n\t\tg_hash_table_insert(snippet_hash, g_strdup(groups_sys[i]), tmp);\n\n\t\tfor (j = 0; j < len_keys; j++)\n\t\t{\n\t\t\tg_hash_table_insert(tmp, g_strdup(keys_sys[j]),\n\t\t\t\t\t\tutils_get_setting_string(sysconfig, groups_sys[i], keys_sys[j], \"\"));\n\t\t}\n\t\tg_strfreev(keys_sys);\n\t}\n\tg_strfreev(groups_sys);\n\n\t/* now read defined completions in user's configuration directory and add / replace them */\n\tgroups_user = g_key_file_get_groups(userconfig, &len);\n\tfor (i = 0; i < len; i++)\n\t{\n\t\tif (strcmp(groups_user[i], \"Keybindings\") == 0)\n\t\t\tcontinue;\n\t\tkeys_user = g_key_file_get_keys(userconfig, groups_user[i], &len_keys, NULL);\n\n\t\ttmp = g_hash_table_lookup(snippet_hash, groups_user[i]);\n\t\tif (tmp == NULL)\n\t\t{\t/* new key found, create hash table */\n\t\t\ttmp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);\n\t\t\tg_hash_table_insert(snippet_hash, g_strdup(groups_user[i]), tmp);\n\t\t}\n\t\tfor (j = 0; j < len_keys; j++)\n\t\t{\n\t\t\tvalue = g_hash_table_lookup(tmp, keys_user[j]);\n\t\t\tif (value == NULL)\n\t\t\t{\t/* value = NULL means the key doesn't yet exist, so insert */\n\t\t\t\tg_hash_table_insert(tmp, g_strdup(keys_user[j]),\n\t\t\t\t\t\tutils_get_setting_string(userconfig, groups_user[i], keys_user[j], \"\"));\n\t\t\t}\n\t\t\telse\n\t\t\t{\t/* old key and value will be freed by destroy function (g_free) */\n\t\t\t\tg_hash_table_replace(tmp, g_strdup(keys_user[j]),\n\t\t\t\t\t\tutils_get_setting_string(userconfig, groups_user[i], keys_user[j], \"\"));\n\t\t\t}\n\t\t}\n\t\tg_strfreev(keys_user);\n\t}\n\tg_strfreev(groups_user);\n}", "label": 0, "cwe": null, "length": 657 }, { "index": 474644, "code": "bnx2x_uio_close_resources(nic_t *nic, NIC_SHUTDOWN_T graceful)\n{\n\tbnx2x_t *bp = (bnx2x_t *) nic->priv;\n\tint rc = 0;\n\n\t/* Check if there is an assoicated bnx2x device */\n\tif (bp == NULL) {\n\t\tLOG_WARN(PFX \"%s: when closing resources there is \"\n\t\t\t \"no assoicated bnx2x\", nic->log_name);\n\t\treturn -EIO;\n\t}\n\n\t/* Clean up allocated memory */\n\n\tif (bp->rx_pkt_ring != NULL) {\n\t\tfree(bp->rx_pkt_ring);\n\t\tbp->rx_pkt_ring = NULL;\n\t}\n\n\t/* Clean up mapped registers */\n\tif (bp->bufs != NULL) {\n\t\trc = munmap(bp->bufs,\n\t\t\t (bp->rx_ring_size + 1) * bp->rx_buffer_size);\n\t\tif (rc != 0)\n\t\t\tLOG_WARN(PFX \"%s: Couldn't unmap bufs\", nic->log_name);\n\t\tbp->bufs = NULL;\n\t}\n\n\tif (bp->tx_ring != NULL) {\n\t\trc = munmap(bp->tx_ring, 4 * nic->page_size);\n\t\tif (rc != 0)\n\t\t\tLOG_WARN(PFX \"%s: Couldn't unmap tx_rings\",\n\t\t\t\t nic->log_name);\n\t\tbp->tx_ring = NULL;\n\t}\n\n\tif (bp->status_blk.def != NULL) {\n\t\trc = munmap(bp->status_blk.def, bp->status_blk_size);\n\t\tif (rc != 0)\n\t\t\tLOG_WARN(PFX \"%s: Couldn't unmap status block\",\n\t\t\t\t nic->log_name);\n\t\tbp->status_blk.def = NULL;\n\t}\n\n\tif (bp->reg != NULL) {\n\t\trc = munmap(bp->reg, BNX2X_BAR_SIZE);\n\t\tif (rc != 0)\n\t\t\tLOG_WARN(PFX \"%s: Couldn't unmap regs\", nic->log_name);\n\t\tbp->reg = NULL;\n\t}\n\n\tif (bp->reg2 != NULL) {\n\t\trc = munmap(bp->reg2, BNX2X_BAR2_SIZE);\n\t\tif (rc != 0)\n\t\t\tLOG_WARN(PFX \"%s: Couldn't unmap regs\", nic->log_name);\n\t\tbp->reg2 = NULL;\n\t}\n\n\tif (bp->bar2_fd != INVALID_FD) {\n\t\tclose(bp->bar2_fd);\n\t\tbp->bar2_fd = INVALID_FD;\n\t}\n\n\tif (bp->bar0_fd != INVALID_FD) {\n\t\tclose(bp->bar0_fd);\n\t\tbp->bar0_fd = INVALID_FD;\n\t}\n\n\tif (nic->fd != INVALID_FD) {\n\t\trc = close(nic->fd);\n\t\tif (rc != 0) {\n\t\t\tLOG_WARN(PFX\n\t\t\t\t \"%s: Couldn't close uio file descriptor: %d\",\n\t\t\t\t nic->log_name, nic->fd);\n\t\t} else {\n\t\t\tLOG_DEBUG(PFX \"%s: Closed uio file descriptor: %d\",\n\t\t\t\t nic->log_name, nic->fd);\n\t\t}\n\n\t\tnic->fd = INVALID_FD;\n\t} else {\n\t\tLOG_WARN(PFX \"%s: Invalid uio file descriptor: %d\",\n\t\t\t nic->log_name, nic->fd);\n\t}\n\n\tbnx2x_set_drv_version_unknown(bp);\n\n\tLOG_INFO(PFX \"%s: Closed all resources\", nic->log_name);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 732 }, { "index": 720931, "code": "sheet_delete_cols (Sheet *sheet, int col, int count,\n\t\t GOUndo **pundo, GOCmdContext *cc)\n{\n\tGnmExprRelocateInfo reloc_info;\n\tint i;\n\tColRowStateList *states = NULL;\n\tint max_count;\n\tgboolean beyond_end;\n\n\tg_return_val_if_fail (IS_SHEET (sheet), TRUE);\n\tg_return_val_if_fail (count > 0, TRUE);\n\n\tmax_count = gnm_sheet_get_max_cols (sheet) - col;\n\tbeyond_end = (count > max_count);\n\tif (beyond_end) {\n\t\t/*\n\t\t * We're trying to delete more than we have (not just to the\n\t\t * very end). We take that as a signal that ranges should\n\t\t * not be sticky at the end.\n\t\t */\n\t\tcount = max_count;\n\t}\n\n\tif (pundo) *pundo = NULL;\n\tschedule_reapply_filters (sheet, pundo);\n\n\tif (pundo) {\n\t\tint last = col + (count - 1);\n\t\tGnmRange r;\n\t\trange_init_cols (&r, sheet, col, last);\n\t\tcombine_undo (pundo, clipboard_copy_range_undo (sheet, &r));\n\t\tstates = colrow_get_states (sheet, TRUE, col, last);\n\t}\n\n\treloc_info.reloc_type = GNM_EXPR_RELOCATE_COLS;\n\treloc_info.sticky_end = !beyond_end;\n\treloc_info.origin.start.col = col;\n\treloc_info.origin.start.row = 0;\n\treloc_info.origin.end.col = col + count - 1;\n\treloc_info.origin.end.row = gnm_sheet_get_last_row (sheet);\n\treloc_info.origin_sheet = reloc_info.target_sheet = sheet;\n\treloc_info.col_offset = gnm_sheet_get_max_cols (sheet); /* force invalidation */\n\treloc_info.row_offset = 0;\n\tparse_pos_init_sheet (&reloc_info.pos, sheet);\n\n\t/* 0. Walk cells in deleted cols and ensure arrays aren't divided. */\n\tif (sheet_range_splits_array (sheet, &reloc_info.origin, NULL,\n\t\t\t\t cc, _(\"Delete Columns\")))\n\t\treturn TRUE;\n\n\t/* 1. Delete the columns (and their cells) */\n\tfor (i = col + count ; --i >= col; )\n\t\tsheet_col_destroy (sheet, i, TRUE);\n\n\t/* Brutally discard auto filter objects. Collect the rest for undo. */\n\tsheet_objects_clear (sheet, &reloc_info.origin, GNM_FILTER_COMBO_TYPE, NULL);\n\tsheet_objects_clear (sheet, &reloc_info.origin, G_TYPE_NONE, pundo);\n\n\t/*\n\t * 1.5 sheet_colrow_delete_finish will flag the remains as changing,\n\t * but we need to mark the cleared area\n\t */\n\tsheet_flag_status_update_range (sheet, &reloc_info.origin);\n\n\t/* 2. Invalidate references to the cells in the deleted columns */\n\tcombine_undo (pundo, dependents_relocate (&reloc_info));\n\n\t/* 3. Fix references to and from the cells which are moving */\n\treloc_info.origin.start.col = col + count;\n\treloc_info.origin.end.col = gnm_sheet_get_last_col (sheet);\n\treloc_info.col_offset = -count;\n\treloc_info.row_offset = 0;\n\tcombine_undo (pundo, dependents_relocate (&reloc_info));\n\n\t/* 4. Move the columns to their new location (from left to right) */\n\tfor (i = col + count ; i <= sheet->cols.max_used; ++i)\n\t\tcolrow_move (sheet, i, 0, i, gnm_sheet_get_last_row (sheet),\n\t\t\t &sheet->cols, i, i - count);\n\n\tsheet_colrow_delete_finish (&reloc_info, TRUE, col, count, pundo);\n\n\tadd_undo_op (pundo, TRUE, sheet_insert_cols,\n\t\t sheet, col, count,\n\t\t states, col);\n\n\treturn FALSE;\n}", "label": 0, "cwe": null, "length": 825 }, { "index": 369676, "code": "HandleModPossess(bool apply, bool Real)\n{\n if (!Real)\n return;\n\n Unit* target = GetTarget();\n\n // not possess yourself\n if (GetCasterGuid() == target->GetObjectGuid())\n return;\n\n Unit* caster = GetCaster();\n if (!caster || caster->GetTypeId() != TYPEID_PLAYER)\n return;\n\n Player* p_caster = (Player*)caster;\n Camera& camera = p_caster->GetCamera();\n\n if (apply)\n {\n target->addUnitState(UNIT_STAT_CONTROLLED);\n\n target->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);\n target->SetCharmerGuid(p_caster->GetObjectGuid());\n target->setFaction(p_caster->getFaction());\n\n // target should became visible at SetView call(if not visible before):\n // otherwise client\\p_caster will ignore packets from the target(SetClientControl for example)\n camera.SetView(target);\n\n p_caster->SetCharm(target);\n p_caster->SetClientControl(target, 1);\n p_caster->SetMover(target);\n\n target->CombatStop(true);\n target->DeleteThreatList();\n target->getHostileRefManager().deleteReferences();\n\n if (CharmInfo* charmInfo = target->InitCharmInfo(target))\n {\n charmInfo->InitPossessCreateSpells();\n charmInfo->SetReactState(REACT_PASSIVE);\n charmInfo->SetCommandState(COMMAND_STAY);\n }\n\n p_caster->PossessSpellInitialize();\n\n if (target->GetTypeId() == TYPEID_UNIT)\n {\n ((Creature*)target)->AIM_Initialize();\n }\n else if (target->GetTypeId() == TYPEID_PLAYER)\n {\n ((Player*)target)->SetClientControl(target, 0);\n }\n }\n else\n {\n p_caster->SetCharm(NULL);\n\n p_caster->SetClientControl(target, 0);\n p_caster->SetMover(NULL);\n\n // there is a possibility that target became invisible for client\\p_caster at ResetView call:\n // it must be called after movement control unapplying, not before! the reason is same as at aura applying\n camera.ResetView();\n\n p_caster->RemovePetActionBar();\n\n // on delete only do caster related effects\n if (m_removeMode == AURA_REMOVE_BY_DELETE)\n return;\n\n target->clearUnitState(UNIT_STAT_CONTROLLED);\n\n target->CombatStop(true);\n target->DeleteThreatList();\n target->getHostileRefManager().deleteReferences();\n\n target->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);\n\n target->SetCharmerGuid(ObjectGuid());\n\n if (target->GetTypeId() == TYPEID_PLAYER)\n {\n ((Player*)target)->setFactionForRace(target->getRace());\n ((Player*)target)->SetClientControl(target, 1);\n }\n else if (target->GetTypeId() == TYPEID_UNIT)\n {\n CreatureInfo const* cinfo = ((Creature*)target)->GetCreatureInfo();\n target->setFaction(cinfo->FactionAlliance);\n }\n\n if (target->GetTypeId() == TYPEID_UNIT)\n {\n ((Creature*)target)->AIM_Initialize();\n target->AttackedBy(caster);\n }\n }\n}", "label": 0, "cwe": null, "length": 718 }, { "index": 317748, "code": "EXTRACTOR_zip_extract_method (struct EXTRACTOR_ExtractContext *ec)\n{\n struct EXTRACTOR_UnzipFile *uf;\n struct EXTRACTOR_UnzipFileInfo fi;\n char fname[256];\n char fcomment[256];\n\n if (NULL == (uf = EXTRACTOR_common_unzip_open (ec)))\n return;\n if ( (EXTRACTOR_UNZIP_OK ==\n\tEXTRACTOR_common_unzip_go_find_local_file (uf,\n\t\t\t\t\t\t \"meta.xml\",\n\t\t\t\t\t\t 2)) ||\n (EXTRACTOR_UNZIP_OK ==\n\tEXTRACTOR_common_unzip_go_find_local_file (uf,\n\t\t\t\t\t\t \"META-INF/MANIFEST.MF\",\n\t\t\t\t\t\t 2)) )\n {\n /* not a normal zip, might be odf, jar, etc. */\n goto CLEANUP;\n }\n if (EXTRACTOR_UNZIP_OK !=\n EXTRACTOR_common_unzip_go_to_first_file (uf))\n { \n /* zip malformed? */\n goto CLEANUP;\n }\n if (0 !=\n ec->proc (ec->cls, \n\t\t\"zip\",\n\t\tEXTRACTOR_METATYPE_MIMETYPE,\n\t\tEXTRACTOR_METAFORMAT_UTF8,\n\t\t\"text/plain\",\n\t\t\"application/zip\",\n\t\tstrlen (\"application/zip\") + 1))\n goto CLEANUP;\n if (EXTRACTOR_UNZIP_OK ==\n EXTRACTOR_common_unzip_get_global_comment (uf,\n\t\t\t\t\t\t fcomment,\n\t\t\t\t\t\t sizeof (fcomment)))\n {\n if ( (0 != strlen (fcomment)) &&\n\t (0 !=\n\t ec->proc (ec->cls, \n\t\t \"zip\",\n\t\t EXTRACTOR_METATYPE_COMMENT,\n\t\t EXTRACTOR_METAFORMAT_C_STRING,\n\t\t \"text/plain\",\n\t\t fcomment,\n\t\t strlen (fcomment) + 1)))\n\tgoto CLEANUP;\n }\n do\n {\n if (EXTRACTOR_UNZIP_OK ==\n\t EXTRACTOR_common_unzip_get_current_file_info (uf,\n\t\t\t\t\t\t\t&fi,\n\t\t\t\t\t\t\tfname,\n\t\t\t\t\t\t\tsizeof (fname),\n\t\t\t\t\t\t\tNULL, 0,\n\t\t\t\t\t\t\tfcomment,\n\t\t\t\t\t\t\tsizeof (fcomment)))\n\t{\n\t if ( (0 != strlen (fname)) &&\n\t (0 !=\n\t\tec->proc (ec->cls, \n\t\t\t \"zip\",\n\t\t\t EXTRACTOR_METATYPE_FILENAME,\n\t\t\t EXTRACTOR_METAFORMAT_C_STRING,\n\t\t\t \"text/plain\",\n\t\t\t fname,\n\t\t\t strlen (fname) + 1)))\n\t goto CLEANUP;\n\t if ( (0 != strlen (fcomment)) &&\n\t (0 !=\n\t\tec->proc (ec->cls, \n\t\t\t \"zip\",\n\t\t\t EXTRACTOR_METATYPE_COMMENT,\n\t\t\t EXTRACTOR_METAFORMAT_C_STRING,\n\t\t\t \"text/plain\",\n\t\t\t fcomment,\n\t\t\t strlen (fcomment) + 1)))\n\t goto CLEANUP;\n\t}\t\t\t\t\t\t \n }\n while (EXTRACTOR_UNZIP_OK ==\n\t EXTRACTOR_common_unzip_go_to_next_file (uf));\n \nCLEANUP:\n (void) EXTRACTOR_common_unzip_close (uf);\n}", "label": 0, "cwe": null, "length": 646 } ]