VulResource / draper /split /draper_1024-*_train.json
xuefen's picture
Upload folder using huggingface_hub
0faab25 verified
[
{
"index": 74270,
"code": "__bld_bidandtran_graph(void)\n{\n register int32 ni, chi;\n register struct net_t *np;\n register struct chanrec_t *chanp;\n int32 si, design_has_trans, start_chanid;\n struct mod_t *mdp;\n struct traux_t *trap;\n\n if (__switch_verbose)\n { \n __cv_msg(\" SWITCH: begin switch channel graph construction.\\n\");\n }\n\n /* need to count number of switch (have tranif or different wire types) */\n bld_trauxs();\n\n /* DBG remove --\n malloc_chain_check(1);\n -- */\n\n /* alloc channel info table - size increased when needed */\n __nxt_chan_id = 0;\n __chantab = (struct chanrec_t *) __my_malloc(1000*sizeof(struct chanrec_t));\n __chanallocsize = 1000;\n design_has_trans = FALSE;\n for (si = 0; si < 7; si++)\n { __stvtxtab[si] = NULL; __stvtxtabend[si] = NULL; }\n __chg_vtxlst_hdr = __chg_vtxlst_end = NULL;\n __off_vtxlst_hdr = __off_vtxlst_end = NULL;\n __vtx_freelst = NULL;\n __edge_freelst = NULL;\n __vtxlst_freelst = NULL;\n\n for (mdp = __modhdr; mdp != NULL; mdp = mdp->mnxt)\n {\n if (mdp->mnnum == 0) continue;\n /* if no trans and no inouts module will have no tran channels */\n if (!mdp->mod_hasbidtran && !mdp->mod_hastran) continue;\n start_chanid = __nxt_chan_id;\n for (ni = 0, np = &(mdp->mnets[0]); ni < mdp->mnnum; ni++, np++) \n {\n if ((trap = np->ntraux) == NULL) continue;\n bld_trgraph(mdp, trap, np);\n design_has_trans = TRUE;\n }\n free_vtx_and_edge_freelsts();\n if (__switch_verbose && __nxt_chan_id > start_chanid)\n {\n __cv_msg(\n \" SWITCH: %d channels in module %s (%d insts, %d nets) built.\\n\",\n __nxt_chan_id - start_chanid,\n mdp->msym->synam, mdp->flatinum, mdp->mnnum);\n }\n }\n\n __num_switch_chans = 0;\n for (chi = 0; chi < __nxt_chan_id; chi++)\n {\n chanp = &(__chantab[chi]);\n if (chanp->chtyp != TRPROC_TRAN && chanp->chan_diffwtyps)\n {\n if (chanp->chtyp == TRPROC_STBID) chanp->chtyp = TRPROC_STWTYPBID;\n else if (chanp->chtyp == TRPROC_BID)\n {\n /* SJM 04/21/01 - internal error if inout only wired trchan non stren */\n __case_terr(__FILE__, __LINE__);\n }\n else __case_terr(__FILE__, __LINE__); \n }\n if (chanp->chtyp == TRPROC_STWTYPBID || chanp->chtyp == TRPROC_TRAN)\n __num_switch_chans++;\n\n /* only check tran channels */\n /* DBG remove --- */\n if (__debug_flg)\n { \n if (!chanp->chan_no_vtxs) chkchannel(chanp);\n }\n /* --- */\n }\n if (__switch_verbose) emit_chan_size_table();\n /* done with tran npps (nlds and ndrvs must now only have hard ones) */\n /* move to list in traux for vpi_ local load/driver processing */\n save_bidandtran_npps();\n if (__debug_flg && design_has_trans)\n {\n __dbg_msg(\"++ dumping all channels after optimization:\\n\");\n/* -- DBG remove -- \n for (mdp = __modhdr; mdp != NULL; mdp = mdp->mnxt)\n {\n if (mdp->mnnum == 0) continue;\n if (!mdp->mod_hasbidtran && !mdp->mod_hastran) continue;\n __dmp_modtrans(mdp);\n }\n--- */\n /* 04/12/00 - */\n for (chi = 0; chi < __nxt_chan_id; chi++)\n {\n chanp = &(__chantab[chi]);\n if (chanp->chan_no_vtxs) __dmp_bidchan(chanp);\n else\n {\n /* dump from vertex although vtx is just used to get back to chan id */\n __push_itstk(chanp->chvitp);\n __dmp_trchan(chanp->chvxp);\n __pop_itstk();\n }\n }\n }\n}",
"label": 0,
"cwe": null,
"length": 1043
},
{
"index": 281222,
"code": "setup_ulist(void){\n Stmt s;\n int prevLevel = 0;\n\n login_check_credentials();\n if( !g.perm.Admin ){\n login_needed();\n return;\n }\n\n style_submenu_element(\"Add\", \"Add User\", \"setup_uedit\");\n style_header(\"User List\");\n cgi_printf(\"<table class=\\\"usetupLayoutTable\\\">\\n\"\n \"<tr><td class=\\\"usetupColumnLayout\\\">\\n\"\n \"<span class=\\\"note\\\">Users:</span>\\n\"\n \"<table class=\\\"usetupUserList\\\">\\n\");\n prevLevel = 0;\n db_prepare(&s,\n \"SELECT uid, login, cap, info, 1 FROM user\"\n \" WHERE login IN ('anonymous','nobody','developer','reader') \"\n \" UNION ALL \"\n \"SELECT uid, login, cap, info, 2 FROM user\"\n \" WHERE login NOT IN ('anonymous','nobody','developer','reader') \"\n \"ORDER BY 5, 2\"\n );\n while( db_step(&s)==SQLITE_ROW ){\n int iLevel = db_column_int(&s, 4);\n const char *zCap = db_column_text(&s, 2);\n const char *zLogin = db_column_text(&s, 1);\n if( iLevel>prevLevel ){\n if( prevLevel>0 ){\n cgi_printf(\"<tr><td colspan=\\\"3\\\"><hr></td></tr>\\n\");\n }\n if( iLevel==1 ){\n cgi_printf(\"<tr>\\n\"\n \" <th class=\\\"usetupListUser\\\"\\n\"\n \" style=\\\"text-align: right;padding-right: 20px;\\\">Category</th>\\n\"\n \" <th class=\\\"usetupListCap\\\"\\n\"\n \" style=\\\"text-align: center;padding-right: 15px;\\\">Capabilities</th>\\n\"\n \" <th class=\\\"usetupListCon\\\"\\n\"\n \" style=\\\"text-align: left;\\\">Notes</th>\\n\"\n \"</tr>\\n\");\n }else{\n cgi_printf(\"<tr>\\n\"\n \" <th class=\\\"usetupListUser\\\"\\n\"\n \" style=\\\"text-align: right;padding-right: 20px;\\\">User&nbsp;ID</th>\\n\"\n \" <th class=\\\"usetupListCap\\\"\\n\"\n \" style=\\\"text-align: center;padding-right: 15px;\\\">Capabilities</th>\\n\"\n \" <th class=\\\"usetupListCon\\\"\\n\"\n \" style=\\\"text-align: left;\\\">Contact&nbsp;Info</th>\\n\"\n \"</tr>\\n\");\n }\n prevLevel = iLevel;\n }\n cgi_printf(\"<tr>\\n\"\n \"<td class=\\\"usetupListUser\\\"\\n\"\n \" style=\\\"text-align: right;padding-right: 20px;white-space:nowrap;\\\">\\n\");\n if( g.perm.Admin && (zCap[0]!='s' || g.perm.Setup) ){\n cgi_printf(\"<a href=\\\"setup_uedit?id=%d\\\">\\n\",(db_column_int(&s,0)));\n }\n cgi_printf(\"%h\\n\",(zLogin));\n if( g.perm.Admin ){\n cgi_printf(\"</a>\\n\");\n }\n cgi_printf(\"</td>\\n\"\n \"<td class=\\\"usetupListCap\\\" style=\\\"text-align: center;padding-right: 15px;\\\">%s</td>\\n\"\n \"<td class=\\\"usetupListCon\\\" style=\\\"text-align: left;\\\">%h</td>\\n\"\n \"</tr>\\n\",(zCap),(db_column_text(&s,3)));\n }\n cgi_printf(\"</table>\\n\"\n \"</td><td class=\\\"usetupColumnLayout\\\">\\n\"\n \"<span class=\\\"note\\\">Notes:</span>\\n\"\n \"<ol>\\n\"\n \"<li><p>The permission flags are as follows:</p>\\n\"\n \"<table>\\n\"\n \"<tr><th valign=\\\"top\\\">a</th>\\n\"\n \" <td><i>Admin:</i> Create and delete users</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">b</th>\\n\"\n \" <td><i>Attach:</i> Add attachments to wiki or tickets</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">c</th>\\n\"\n \" <td><i>Append-Tkt:</i> Append to tickets</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">d</th>\\n\"\n \" <td><i>Delete:</i> Delete wiki and tickets</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">e</th>\\n\"\n \" <td><i>Email:</i> View sensitive data such as EMail addresses</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">f</th>\\n\"\n \" <td><i>New-Wiki:</i> Create new wiki pages</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">g</th>\\n\"\n \" <td><i>Clone:</i> Clone the repository</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">h</th>\\n\"\n \" <td><i>Hyperlinks:</i> Show hyperlinks to detailed\\n\"\n \" repository history</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">i</th>\\n\"\n \" <td><i>Check-In:</i> Commit new versions in the repository</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">j</th>\\n\"\n \" <td><i>Read-Wiki:</i> View wiki pages</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">k</th>\\n\"\n \" <td><i>Write-Wiki:</i> Edit wiki pages</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">l</th>\\n\"\n \" <td><i>Mod-Wiki:</i> Moderator for wiki pages</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">m</th>\\n\"\n \" <td><i>Append-Wiki:</i> Append to wiki pages</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">n</th>\\n\"\n \" <td><i>New-Tkt:</i> Create new tickets</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">o</th>\\n\"\n \" <td><i>Check-Out:</i> Check out versions</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">p</th>\\n\"\n \" <td><i>Password:</i> Change your own password</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">q</th>\\n\"\n \" <td><i>Mod-Tkt:</i> Moderator for tickets</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">r</th>\\n\"\n \" <td><i>Read-Tkt:</i> View tickets</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">s</th>\\n\"\n \" <td><i>Setup/Super-user:</i> Setup and configure this website</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">t</th>\\n\"\n \" <td><i>Tkt-Report:</i> Create new bug summary reports</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">u</th>\\n\"\n \" <td><i>Reader:</i> Inherit privileges of\\n\"\n \" user <tt>reader</tt></td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">v</th>\\n\"\n \" <td><i>Developer:</i> Inherit privileges of\\n\"\n \" user <tt>developer</tt></td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">w</th>\\n\"\n \" <td><i>Write-Tkt:</i> Edit tickets</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">x</th>\\n\"\n \" <td><i>Private:</i> Push and/or pull private branches</td></tr>\\n\"\n \"<tr><th valign=\\\"top\\\">z</th>\\n\"\n \" <td><i>Zip download:</i> Download a baseline via the\\n\"\n \" <tt>/zip</tt> URL even without\\n\"\n \" check<span class=\\\"capability\\\">o</span>ut\\n\"\n \" and <span class=\\\"capability\\\">h</span>istory permissions</td></tr>\\n\"\n \"</table>\\n\"\n \"</li>\\n\"\n \"\\n\"\n \"<li><p>\\n\"\n \"Every user, logged in or not, inherits the privileges of\\n\"\n \"<span class=\\\"usertype\\\">nobody</span>.\\n\"\n \"</p></li>\\n\"\n \"\\n\"\n \"<li><p>\\n\"\n \"Any human can login as <span class=\\\"usertype\\\">anonymous</span> since the\\n\"\n \"password is clearly displayed on the login page for them to type. The\\n\"\n \"purpose of requiring anonymous to log in is to prevent access by spiders.\\n\"\n \"Every logged-in user inherits the combined privileges of\\n\"\n \"<span class=\\\"usertype\\\">anonymous</span> and\\n\"\n \"<span class=\\\"usertype\\\">nobody</span>.\\n\"\n \"</p></li>\\n\"\n \"\\n\"\n \"<li><p>\\n\"\n \"Users with privilege <span class=\\\"capability\\\">v</span> inherit the combined\\n\"\n \"privileges of <span class=\\\"usertype\\\">developer</span>,\\n\"\n \"<span class=\\\"usertype\\\">anonymous</span>, and\\n\"\n \"<span class=\\\"usertype\\\">nobody</span>.\\n\"\n \"</p></li>\\n\"\n \"\\n\"\n \"</ol>\\n\"\n \"</td></tr></table>\\n\");\n style_footer();\n}",
"label": 0,
"cwe": null,
"length": 2192
},
{
"index": 72842,
"code": "ocfs2_figure_insert_type(struct ocfs2_extent_tree *et,\n\t\t\t\t struct buffer_head **last_eb_bh,\n\t\t\t\t struct ocfs2_extent_rec *insert_rec,\n\t\t\t\t int *free_records,\n\t\t\t\t struct ocfs2_insert_type *insert)\n{\n\tint ret;\n\tstruct ocfs2_extent_block *eb;\n\tstruct ocfs2_extent_list *el;\n\tstruct ocfs2_path *path = NULL;\n\tstruct buffer_head *bh = NULL;\n\n\tinsert->ins_split = SPLIT_NONE;\n\n\tel = et->et_root_el;\n\tinsert->ins_tree_depth = le16_to_cpu(el->l_tree_depth);\n\n\tif (el->l_tree_depth) {\n\t\t/*\n\t\t * If we have tree depth, we read in the\n\t\t * rightmost extent block ahead of time as\n\t\t * ocfs2_figure_insert_type() and ocfs2_add_branch()\n\t\t * may want it later.\n\t\t */\n\t\tret = ocfs2_read_extent_block(et->et_ci,\n\t\t\t\t\t ocfs2_et_get_last_eb_blk(et),\n\t\t\t\t\t &bh);\n\t\tif (ret) {\n\t\t\tmlog_errno(ret);\n\t\t\tgoto out;\n\t\t}\n\t\teb = (struct ocfs2_extent_block *) bh->b_data;\n\t\tel = &eb->h_list;\n\t}\n\n\t/*\n\t * Unless we have a contiguous insert, we'll need to know if\n\t * there is room left in our allocation tree for another\n\t * extent record.\n\t *\n\t * XXX: This test is simplistic, we can search for empty\n\t * extent records too.\n\t */\n\t*free_records = le16_to_cpu(el->l_count) -\n\t\tle16_to_cpu(el->l_next_free_rec);\n\n\tif (!insert->ins_tree_depth) {\n\t\tocfs2_figure_contig_type(et, insert, el, insert_rec);\n\t\tocfs2_figure_appending_type(insert, el, insert_rec);\n\t\treturn 0;\n\t}\n\n\tpath = ocfs2_new_path_from_et(et);\n\tif (!path) {\n\t\tret = -ENOMEM;\n\t\tmlog_errno(ret);\n\t\tgoto out;\n\t}\n\n\t/*\n\t * In the case that we're inserting past what the tree\n\t * currently accounts for, ocfs2_find_path() will return for\n\t * us the rightmost tree path. This is accounted for below in\n\t * the appending code.\n\t */\n\tret = ocfs2_find_path(et->et_ci, path, le32_to_cpu(insert_rec->e_cpos));\n\tif (ret) {\n\t\tmlog_errno(ret);\n\t\tgoto out;\n\t}\n\n\tel = path_leaf_el(path);\n\n\t/*\n\t * Now that we have the path, there's two things we want to determine:\n\t * 1) Contiguousness (also set contig_index if this is so)\n\t *\n\t * 2) Are we doing an append? We can trivially break this up\n * into two types of appends: simple record append, or a\n * rotate inside the tail leaf.\n\t */\n\tocfs2_figure_contig_type(et, insert, el, insert_rec);\n\n\t/*\n\t * The insert code isn't quite ready to deal with all cases of\n\t * left contiguousness. Specifically, if it's an insert into\n\t * the 1st record in a leaf, it will require the adjustment of\n\t * cluster count on the last record of the path directly to it's\n\t * left. For now, just catch that case and fool the layers\n\t * above us. This works just fine for tree_depth == 0, which\n\t * is why we allow that above.\n\t */\n\tif (insert->ins_contig == CONTIG_LEFT &&\n\t insert->ins_contig_index == 0)\n\t\tinsert->ins_contig = CONTIG_NONE;\n\n\t/*\n\t * Ok, so we can simply compare against last_eb to figure out\n\t * whether the path doesn't exist. This will only happen in\n\t * the case that we're doing a tail append, so maybe we can\n\t * take advantage of that information somehow.\n\t */\n\tif (ocfs2_et_get_last_eb_blk(et) ==\n\t path_leaf_bh(path)->b_blocknr) {\n\t\t/*\n\t\t * Ok, ocfs2_find_path() returned us the rightmost\n\t\t * tree path. This might be an appending insert. There are\n\t\t * two cases:\n\t\t * 1) We're doing a true append at the tail:\n\t\t *\t-This might even be off the end of the leaf\n\t\t * 2) We're \"appending\" by rotating in the tail\n\t\t */\n\t\tocfs2_figure_appending_type(insert, el, insert_rec);\n\t}\n\nout:\n\tocfs2_free_path(path);\n\n\tif (ret == 0)\n\t\t*last_eb_bh = bh;\n\telse\n\t\tbrelse(bh);\n\treturn ret;\n}",
"label": 0,
"cwe": null,
"length": 1028
},
{
"index": 492109,
"code": "figi2_(integer *nm, integer *n, doublereal *t, \n doublereal *d, doublereal *e, doublereal *z, integer *ierr)\n{\n /* System generated locals */\n integer t_dim1, t_offset, z_dim1, z_offset, i_1, i_2;\n\n /* Builtin functions */\n double sqrt(doublereal);\n\n /* Local variables */\n static doublereal h;\n static integer i, j;\n\n\n\n/* GIVEN A NONSYMMETRIC TRIDIAGONAL MATRIX SUCH THAT THE PRODUCTS */\n/* OF CORRESPONDING PAIRS OF OFF-DIAGONAL ELEMENTS ARE ALL */\n/* NON-NEGATIVE, AND ZERO ONLY WHEN BOTH FACTORS ARE ZERO, THIS */\n/* SUBROUTINE REDUCES IT TO A SYMMETRIC TRIDIAGONAL MATRIX */\n/* USING AND ACCUMULATING DIAGONAL SIMILARITY TRANSFORMATIONS. */\n\n/* ON INPUT */\n\n/* NM MUST BE SET TO THE ROW DIMENSION OF TWO-DIMENSIONAL */\n/* ARRAY PARAMETERS AS DECLARED IN THE CALLING PROGRAM */\n/* DIMENSION STATEMENT. */\n\n/* N IS THE ORDER OF THE MATRIX. */\n\n/* T CONTAINS THE INPUT MATRIX. ITS SUBDIAGONAL IS */\n/* STORED IN THE LAST N-1 POSITIONS OF THE FIRST COLUMN, */\n/* ITS DIAGONAL IN THE N POSITIONS OF THE SECOND COLUMN, */\n/* AND ITS SUPERDIAGONAL IN THE FIRST N-1 POSITIONS OF */\n/* THE THIRD COLUMN. T(1,1) AND T(N,3) ARE ARBITRARY. */\n\n/* ON OUTPUT */\n\n/* T IS UNALTERED. */\n\n/* D CONTAINS THE DIAGONAL ELEMENTS OF THE SYMMETRIC MATRIX. */\n\n/* E CONTAINS THE SUBDIAGONAL ELEMENTS OF THE SYMMETRIC */\n/* MATRIX IN ITS LAST N-1 POSITIONS. E(1) IS NOT SET. */\n\n/* Z CONTAINS THE TRANSFORMATION MATRIX PRODUCED IN */\n/* THE REDUCTION. */\n\n/* IERR IS SET TO */\n/* ZERO FOR NORMAL RETURN, */\n/* N+I IF T(I,1)*T(I-1,3) IS NEGATIVE, */\n/* 2*N+I IF T(I,1)*T(I-1,3) IS ZERO WITH */\n/* ONE FACTOR NON-ZERO. */\n\n/* QUESTIONS AND COMMENTS SHOULD BE DIRECTED TO BURTON S. GARBOW, */\n/* MATHEMATICS AND COMPUTER SCIENCE DIV, ARGONNE NATIONAL LABORATORY \n*/\n\n/* THIS VERSION DATED AUGUST 1983. */\n\n/* ------------------------------------------------------------------ \n*/\n\n /* Parameter adjustments */\n t_dim1 = *nm;\n t_offset = t_dim1 + 1;\n t -= t_offset;\n z_dim1 = *nm;\n z_offset = z_dim1 + 1;\n z -= z_offset;\n --e;\n --d;\n\n /* Function Body */\n *ierr = 0;\n\n i_1 = *n;\n for (i = 1; i <= i_1; ++i) {\n\n i_2 = *n;\n for (j = 1; j <= i_2; ++j) {\n/* L50: */\n z[i + j * z_dim1] = 0.;\n }\n\n if (i == 1) {\n goto L70;\n }\n h = t[i + t_dim1] * t[i - 1 + t_dim1 * 3];\n if (h < 0.) {\n goto L900;\n } else if (h == 0) {\n goto L60;\n } else {\n goto L80;\n }\nL60:\n if (t[i + t_dim1] != 0. || t[i - 1 + t_dim1 * 3] != 0.) {\n goto L1000;\n }\n e[i] = 0.;\nL70:\n z[i + i * z_dim1] = 1.;\n goto L90;\nL80:\n e[i] = sqrt(h);\n z[i + i * z_dim1] = z[i - 1 + (i - 1) * z_dim1] * e[i] / t[i - 1 + \n t_dim1 * 3];\nL90:\n d[i] = t[i + (t_dim1 << 1)];\n/* L100: */\n }\n\n goto L1001;\n/* .......... SET ERROR -- PRODUCT OF SOME PAIR OF OFF-DIAGONAL */\n/* ELEMENTS IS NEGATIVE .......... */\nL900:\n *ierr = *n + i;\n goto L1001;\n/* .......... SET ERROR -- PRODUCT OF SOME PAIR OF OFF-DIAGONAL */\n/* ELEMENTS IS ZERO WITH ONE MEMBER NON-ZERO .......... */\nL1000:\n *ierr = (*n << 1) + i;\nL1001:\n return 0;\n}",
"label": 0,
"cwe": null,
"length": 1093
},
{
"index": 710633,
"code": "tracker_sparql_builder_object (TrackerSparqlBuilder* self, const gchar* s) {\n\tTrackerSparqlBuilderState _tmp0_;\n\tTrackerSparqlBuilderState _tmp1_;\n\tTrackerSparqlBuilderState _tmp2_;\n\tTrackerSparqlBuilderState _tmp3_;\n\tTrackerSparqlBuilderState _tmp4_;\n\tTrackerSparqlBuilderState _tmp5_;\n\tGString* _tmp8_;\n\tGString* _tmp9_;\n\tconst gchar* _tmp10_;\n\tTrackerSparqlBuilderState* _tmp11_;\n\tgint _tmp11__length1;\n\tgint _tmp12_;\n#line 480 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\tg_return_if_fail (self != NULL);\n#line 480 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\tg_return_if_fail (s != NULL);\n#line 480 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\t_tmp0_ = tracker_sparql_builder_get_state (self);\n#line 480 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\t_tmp1_ = _tmp0_;\n#line 480 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\t_tmp2_ = tracker_sparql_builder_get_state (self);\n#line 480 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\t_tmp3_ = _tmp2_;\n#line 480 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\tg_return_if_fail ((_tmp1_ == TRACKER_SPARQL_BUILDER_STATE_PREDICATE) || (_tmp3_ == TRACKER_SPARQL_BUILDER_STATE_OBJECT));\n#line 483 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\t_tmp4_ = tracker_sparql_builder_get_state (self);\n#line 483 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\t_tmp5_ = _tmp4_;\n#line 483 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\tif (_tmp5_ == TRACKER_SPARQL_BUILDER_STATE_OBJECT) {\n#line 1406 \"tracker-builder.c\"\n\t\tGString* _tmp6_;\n\t\tgint _tmp7_;\n#line 484 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\t\t_tmp6_ = self->priv->str;\n#line 484 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\t\tg_string_append (_tmp6_, \" ,\");\n#line 485 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\t\t_tmp7_ = self->priv->states_length1;\n#line 485 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\t\tself->priv->states_length1 = _tmp7_ - 1;\n#line 1417 \"tracker-builder.c\"\n\t}\n#line 487 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\t_tmp8_ = self->priv->str;\n#line 487 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\tg_string_append (_tmp8_, \" \");\n#line 488 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\t_tmp9_ = self->priv->str;\n#line 488 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\t_tmp10_ = s;\n#line 488 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\tg_string_append (_tmp9_, _tmp10_);\n#line 489 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\t_tmp11_ = self->priv->states;\n#line 489 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\t_tmp11__length1 = self->priv->states_length1;\n#line 489 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\t_vala_array_add12 (&self->priv->states, &self->priv->states_length1, &self->priv->_states_size_, TRACKER_SPARQL_BUILDER_STATE_OBJECT);\n#line 491 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\t_tmp12_ = self->priv->_length;\n#line 491 \"/home/martyn/Source/tracker/src/libtracker-sparql/tracker-builder.vala\"\n\ttracker_sparql_builder_set_length (self, _tmp12_ + 1);\n#line 1439 \"tracker-builder.c\"\n}",
"label": 0,
"cwe": null,
"length": 1100
},
{
"index": 696236,
"code": "borg_flow_kill_corridor_2(bool viewable)\n{\n int o_y, o_x;\n int m_x, m_y;\n int f_y,f_x;\n int floors = 0;\n int b_y = 0, b_x = 0;\n int perma_grids = 0;\n\n borg_kill *kill;\n\n /* Efficiency -- Nothing to kill */\n if (!borg_kills_cnt) return (FALSE);\n\n /* Only do this to summoners when they are close*/\n if (borg_kills_summoner == -1) return (FALSE);\n\n /* Do not dig when weak. It takes too long */\n if (borg_skill[BI_STR] < 17) return (FALSE);\n\n\t/* Hungry,starving */\n\tif (borg_skill[BI_ISHUNGRY] || borg_skill[BI_ISWEAK]) return (FALSE);\n\n /* Sometimes we loop on this */\n if (time_this_panel > 500) return (FALSE);\n\n /* Do not dig when confused */\n if (borg_skill[BI_ISCONFUSED]) return (FALSE);\n\n /* Not when darkened */\n if (borg_skill[BI_CURLITE] == 0) return (FALSE);\n\n\t/* Not if sitting in a sea of runes */\n\tif (borg_morgoth_position) return (FALSE);\n\n /* get the summoning monster */\n kill = &borg_kills[borg_kills_summoner];\n\n /* Consider each adjacent spot to monster*/\n for (o_x = -1; o_x <= 1; o_x++)\n {\n for (o_y = -1; o_y <= 1; o_y++)\n {\n borg_grid *ag ;\n\n /* Check grids near monster */\n m_x = kill->x + o_x;\n m_y = kill->y + o_y;\n\n /* grid the grid */\n ag = &borg_grids[m_y][m_x];\n\n /* avoid screen edgeds */\n if (m_x > AUTO_MAX_X-2 ||\n m_x < 2 ||\n m_y > AUTO_MAX_Y-2 ||\n m_y < 2)\n continue;\n\n /* Can't tunnel a non wall or permawall*/\n if (ag->feat != FEAT_NONE && ag->feat < FEAT_MAGMA) continue;\n if (ag->feat >= FEAT_PERM_EXTRA)\n {\n perma_grids ++;\n continue;\n }\n\n /* Do not dig unless we appear strong enough to succeed or we have a digger */\n if (borg_spell_legal(2, 2) ||\n (borg_skill[BI_DIG] > BORG_DIG && borg_items[weapon_swap].tval == TV_DIGGING) ||\n\t\t\t\t(borg_skill[BI_DIG] > BORG_DIG + 20))\n {\n /* digging ought to work */\n }\n else\n {\n /* do not try digging */\n continue;\n }\n\n /* reset floors counter */\n floors = 0;\n\n /* That grid must not have too many floors adjacent */\n for (f_x = -1; f_x <= 1; f_x++)\n {\n for (f_y = -1; f_y <= 1; f_y++)\n {\n /* grid the grid */\n ag = &borg_grids[m_y+f_y][m_x+f_x];\n\n /* check if this neighbor is a floor */\n if (ag->feat == FEAT_FLOOR ||\n ag->feat == FEAT_BROKEN) floors ++;\n }\n }\n\n /* Do not dig if too many floors near. */\n if (floors >=5) continue;\n\n /* Track the good location */\n b_y = m_y;\n b_x = m_x;\n }\n }\n /* NOTE: Perma_grids count the number of grids which contain permawalls.\n * The borg may try to flow to an unknown grid but may get stuck on a perma\n * wall. This will keep him from flowing to a summoner if the summoner is\n * near a perma grid. The real fix would to be in the flow_spread so that\n * he will not flow through perma_grids. I will work on that next.\n */\n if (b_y !=0 && b_x !=0 && perma_grids == 0)\n {\n /* Clear the flow codes */\n borg_flow_clear();\n\n /* Enqueue the grid */\n borg_flow_enqueue_grid(m_y, m_x);\n\n /* Spread the flow */\n borg_flow_spread(15, TRUE, FALSE, TRUE, -1, FALSE);\n\n /* Attempt to Commit the flow */\n if (!borg_flow_commit(\"anti-summon corridor\", GOAL_KILL)) return (FALSE);\n\n /* Take one step */\n if (!borg_flow_old(GOAL_KILL)) return (FALSE);\n\n return (TRUE);\n }\n\n return FALSE;\n}",
"label": 1,
"cwe": "CWE-other",
"length": 1045
},
{
"index": 464303,
"code": "FillPlayersToBG(BattleGround* bg, BattleGroundBracketId bracket_id)\n{\n int32 hordeFree = bg->GetFreeSlotsForTeam(HORDE);\n int32 aliFree = bg->GetFreeSlotsForTeam(ALLIANCE);\n\n // iterator for iterating through bg queue\n GroupsQueueType::const_iterator Ali_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].begin();\n // count of groups in queue - used to stop cycles\n uint32 aliCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_ALLIANCE].size();\n // index to queue which group is current\n uint32 aliIndex = 0;\n for (; aliIndex < aliCount && m_SelectionPools[BG_TEAM_ALLIANCE].AddGroup((*Ali_itr), aliFree); ++aliIndex)\n ++Ali_itr;\n // the same thing for horde\n GroupsQueueType::const_iterator Horde_itr = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].begin();\n uint32 hordeCount = m_QueuedGroups[bracket_id][BG_QUEUE_NORMAL_HORDE].size();\n uint32 hordeIndex = 0;\n for (; hordeIndex < hordeCount && m_SelectionPools[BG_TEAM_HORDE].AddGroup((*Horde_itr), hordeFree); ++hordeIndex)\n ++Horde_itr;\n\n // if ofc like BG queue invitation is set in config, then we are happy\n if (sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_INVITATION_TYPE) == 0)\n return;\n\n /*\n if we reached this code, then we have to solve NP - complete problem called Subset sum problem\n So one solution is to check all possible invitation subgroups, or we can use these conditions:\n 1. Last time when BattleGroundQueue::Update was executed we invited all possible players - so there is only small possibility\n that we will invite now whole queue, because only 1 change has been made to queues from the last BattleGroundQueue::Update call\n 2. Other thing we should consider is group order in queue\n */\n\n // At first we need to compare free space in bg and our selection pool\n int32 diffAli = aliFree - int32(m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount());\n int32 diffHorde = hordeFree - int32(m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount());\n while (abs(diffAli - diffHorde) > 1 && (m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount() > 0 || m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount() > 0))\n {\n // each cycle execution we need to kick at least 1 group\n if (diffAli < diffHorde)\n {\n // kick alliance group, add to pool new group if needed\n if (m_SelectionPools[BG_TEAM_ALLIANCE].KickGroup(diffHorde - diffAli))\n {\n for (; aliIndex < aliCount && m_SelectionPools[BG_TEAM_ALLIANCE].AddGroup((*Ali_itr), (aliFree >= diffHorde) ? aliFree - diffHorde : 0); ++aliIndex)\n ++Ali_itr;\n }\n // if ali selection is already empty, then kick horde group, but if there are less horde than ali in bg - break;\n if (!m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount())\n {\n if (aliFree <= diffHorde + 1)\n break;\n m_SelectionPools[BG_TEAM_HORDE].KickGroup(diffHorde - diffAli);\n }\n }\n else\n {\n // kick horde group, add to pool new group if needed\n if (m_SelectionPools[BG_TEAM_HORDE].KickGroup(diffAli - diffHorde))\n {\n for (; hordeIndex < hordeCount && m_SelectionPools[BG_TEAM_HORDE].AddGroup((*Horde_itr), (hordeFree >= diffAli) ? hordeFree - diffAli : 0); ++hordeIndex)\n ++Horde_itr;\n }\n if (!m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount())\n {\n if (hordeFree <= diffAli + 1)\n break;\n m_SelectionPools[BG_TEAM_ALLIANCE].KickGroup(diffAli - diffHorde);\n }\n }\n // count diffs after small update\n diffAli = aliFree - int32(m_SelectionPools[BG_TEAM_ALLIANCE].GetPlayerCount());\n diffHorde = hordeFree - int32(m_SelectionPools[BG_TEAM_HORDE].GetPlayerCount());\n }\n}",
"label": 0,
"cwe": null,
"length": 1027
},
{
"index": 812382,
"code": "AlterDomainDefault(List *names, Node *defaultRaw)\n{\n\tTypeName *typename;\n\tOid\t\t\tdomainoid;\n\tHeapTuple\ttup;\n\tParseState *pstate;\n\tRelation\trel;\n\tchar\t *defaultValue;\n\tNode\t *defaultExpr = NULL;\t\t/* NULL if no default specified */\n\tDatum\t\tnew_record[Natts_pg_type];\n\tbool\t\tnew_record_nulls[Natts_pg_type];\n\tbool\t\tnew_record_repl[Natts_pg_type];\n\tHeapTuple\tnewtuple;\n\tForm_pg_type typTup;\n\n\t/* Make a TypeName so we can use standard type lookup machinery */\n\ttypename = makeTypeNameFromNameList(names);\n\tdomainoid = typenameTypeId(NULL, typename);\n\n\t/* Look up the domain in the type table */\n\trel = heap_open(TypeRelationId, RowExclusiveLock);\n\n\ttup = SearchSysCacheCopy1(TYPEOID, ObjectIdGetDatum(domainoid));\n\tif (!HeapTupleIsValid(tup))\n\t\telog(ERROR, \"cache lookup failed for type %u\", domainoid);\n\ttypTup = (Form_pg_type) GETSTRUCT(tup);\n\n\t/* Check it's a domain and check user has permission for ALTER DOMAIN */\n\tcheckDomainOwner(tup);\n\n\t/* Setup new tuple */\n\tMemSet(new_record, (Datum) 0, sizeof(new_record));\n\tMemSet(new_record_nulls, false, sizeof(new_record_nulls));\n\tMemSet(new_record_repl, false, sizeof(new_record_repl));\n\n\t/* Store the new default into the tuple */\n\tif (defaultRaw)\n\t{\n\t\t/* Create a dummy ParseState for transformExpr */\n\t\tpstate = make_parsestate(NULL);\n\n\t\t/*\n\t\t * Cook the colDef->raw_expr into an expression. Note: Name is\n\t\t * strictly for error message\n\t\t */\n\t\tdefaultExpr = cookDefault(pstate, defaultRaw,\n\t\t\t\t\t\t\t\t typTup->typbasetype,\n\t\t\t\t\t\t\t\t typTup->typtypmod,\n\t\t\t\t\t\t\t\t NameStr(typTup->typname));\n\n\t\t/*\n\t\t * If the expression is just a NULL constant, we treat the command\n\t\t * like ALTER ... DROP DEFAULT. (But see note for same test in\n\t\t * DefineDomain.)\n\t\t */\n\t\tif (defaultExpr == NULL ||\n\t\t\t(IsA(defaultExpr, Const) &&((Const *) defaultExpr)->constisnull))\n\t\t{\n\t\t\t/* Default is NULL, drop it */\n\t\t\tnew_record_nulls[Anum_pg_type_typdefaultbin - 1] = true;\n\t\t\tnew_record_repl[Anum_pg_type_typdefaultbin - 1] = true;\n\t\t\tnew_record_nulls[Anum_pg_type_typdefault - 1] = true;\n\t\t\tnew_record_repl[Anum_pg_type_typdefault - 1] = true;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t/*\n\t\t\t * Expression must be stored as a nodeToString result, but we also\n\t\t\t * require a valid textual representation (mainly to make life\n\t\t\t * easier for pg_dump).\n\t\t\t */\n\t\t\tdefaultValue = deparse_expression(defaultExpr,\n\t\t\t\t\t\t\t\tdeparse_context_for(NameStr(typTup->typname),\n\t\t\t\t\t\t\t\t\t\t\t\t\tInvalidOid),\n\t\t\t\t\t\t\t\t\t\t\t false, false);\n\n\t\t\t/*\n\t\t\t * Form an updated tuple with the new default and write it back.\n\t\t\t */\n\t\t\tnew_record[Anum_pg_type_typdefaultbin - 1] = CStringGetTextDatum(nodeToString(defaultExpr));\n\n\t\t\tnew_record_repl[Anum_pg_type_typdefaultbin - 1] = true;\n\t\t\tnew_record[Anum_pg_type_typdefault - 1] = CStringGetTextDatum(defaultValue);\n\t\t\tnew_record_repl[Anum_pg_type_typdefault - 1] = true;\n\t\t}\n\t}\n\telse\n\t{\n\t\t/* ALTER ... DROP DEFAULT */\n\t\tnew_record_nulls[Anum_pg_type_typdefaultbin - 1] = true;\n\t\tnew_record_repl[Anum_pg_type_typdefaultbin - 1] = true;\n\t\tnew_record_nulls[Anum_pg_type_typdefault - 1] = true;\n\t\tnew_record_repl[Anum_pg_type_typdefault - 1] = true;\n\t}\n\n\tnewtuple = heap_modify_tuple(tup, RelationGetDescr(rel),\n\t\t\t\t\t\t\t\t new_record, new_record_nulls,\n\t\t\t\t\t\t\t\t new_record_repl);\n\n\tsimple_heap_update(rel, &tup->t_self, newtuple);\n\n\tCatalogUpdateIndexes(rel, newtuple);\n\n\t/* Rebuild dependencies */\n\tGenerateTypeDependencies(typTup->typnamespace,\n\t\t\t\t\t\t\t domainoid,\n\t\t\t\t\t\t\t InvalidOid,\t\t/* typrelid is n/a */\n\t\t\t\t\t\t\t 0, /* relation kind is n/a */\n\t\t\t\t\t\t\t typTup->typowner,\n\t\t\t\t\t\t\t typTup->typinput,\n\t\t\t\t\t\t\t typTup->typoutput,\n\t\t\t\t\t\t\t typTup->typreceive,\n\t\t\t\t\t\t\t typTup->typsend,\n\t\t\t\t\t\t\t typTup->typmodin,\n\t\t\t\t\t\t\t typTup->typmodout,\n\t\t\t\t\t\t\t typTup->typanalyze,\n\t\t\t\t\t\t\t InvalidOid,\n\t\t\t\t\t\t\t false,\t\t/* a domain isn't an implicit array */\n\t\t\t\t\t\t\t typTup->typbasetype,\n\t\t\t\t\t\t\t typTup->typcollation,\n\t\t\t\t\t\t\t defaultExpr,\n\t\t\t\t\t\t\t true);\t\t/* Rebuild is true */\n\n\t/* Clean up */\n\theap_close(rel, NoLock);\n\theap_freetuple(newtuple);\n}",
"label": 1,
"cwe": "CWE-476",
"length": 1110
},
{
"index": 999227,
"code": "inlinable_function_p (fn, id)\n tree fn;\n inline_data *id;\n{\n int inlinable;\n int currfn_insns;\n int max_inline_insns_single = MAX_INLINE_INSNS_SINGLE;\n\n /* If we've already decided this function shouldn't be inlined,\n there's no need to check again. */\n if (DECL_UNINLINABLE (fn))\n return 0;\n\n /* Assume it is not inlinable. */\n inlinable = 0;\n \n /* We may be here either because fn is declared inline or because\n we use -finline-functions. For the second case, we are more\n restrictive. */\n if (DID_INLINE_FUNC (fn))\n max_inline_insns_single = MAX_INLINE_INSNS_AUTO;\n \n /* The number of instructions (estimated) of current function. */\n currfn_insns = DECL_NUM_STMTS (fn) * INSNS_PER_STMT;\n\n /* If we're not inlining things, then nothing is inlinable. */\n if (! flag_inline_trees)\n ;\n /* If we're not inlining all functions and the function was not\n declared `inline', we don't inline it. Don't think of\n disregarding DECL_INLINE when flag_inline_trees == 2; it's the\n front-end that must set DECL_INLINE in this case, because\n dwarf2out loses if a function is inlined that doesn't have\n DECL_INLINE set. */\n else if (! DECL_INLINE (fn))\n ;\n#ifdef INLINER_FOR_JAVA\n /* Synchronized methods can't be inlined. This is a bug. */\n else if (METHOD_SYNCHRONIZED (fn))\n ;\n#endif /* INLINER_FOR_JAVA */\n /* We can't inline functions that are too big. Only allow a single\n function to be of MAX_INLINE_INSNS_SINGLE size. Make special\n allowance for extern inline functions, though. */\n else if (! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn)\n\t && currfn_insns > max_inline_insns_single)\n ;\n /* We can't inline functions that call __builtin_longjmp at all.\n The non-local goto machenery really requires the destination\n be in a different function. If we allow the function calling\n __builtin_longjmp to be inlined into the function calling\n __builtin_setjmp, Things will Go Awry. */\n /* ??? Need front end help to identify \"regular\" non-local goto. */\n else if (find_builtin_longjmp_call (DECL_SAVED_TREE (fn)))\n ;\n /* Refuse to inline alloca call unless user explicitly forced so as this may\n change program's memory overhead drastically when the function using alloca\n is called in loop. In GCC present in SPEC2000 inlining into schedule_block\n cause it to require 2GB of ram instead of 256MB. */\n else if (lookup_attribute (\"always_inline\", DECL_ATTRIBUTES (fn)) == NULL\n\t && find_alloca_call (DECL_SAVED_TREE (fn)))\n ;\n /* All is well. We can inline this function. Traditionally, GCC\n has refused to inline functions using alloca, or functions whose\n values are returned in a PARALLEL, and a few other such obscure\n conditions. We are not equally constrained at the tree level. */\n else\n inlinable = 1;\n\n /* Squirrel away the result so that we don't have to check again. */\n DECL_UNINLINABLE (fn) = ! inlinable;\n\n /* In case we don't disregard the inlining limits and we basically\n can inline this function, investigate further. */\n if (! (*lang_hooks.tree_inlining.disregard_inline_limits) (fn)\n && inlinable\n && currfn_insns > MIN_INLINE_INSNS)\n {\n int sum_insns = (id ? id->inlined_stmts : 0) * INSNS_PER_STMT\n\t\t + currfn_insns;\n /* In the extreme case that we have exceeded the recursive inlining\n limit by a huge factor (128), we just say no. Should not happen\n in real life. */\n if (sum_insns > MAX_INLINE_INSNS * 128)\n\t inlinable = 0;\n /* If we did not hit the extreme limit, we use a linear function\n with slope -1/MAX_INLINE_SLOPE to exceedingly decrease the\n allowable size. We always allow a size of MIN_INLINE_INSNS\n though. */\n else if (sum_insns > MAX_INLINE_INSNS)\n\t{\n\t int max_curr = MAX_INLINE_INSNS_SINGLE\n\t\t\t- (sum_insns - MAX_INLINE_INSNS) / MAX_INLINE_SLOPE;\n\t if (currfn_insns > max_curr)\n\t inlinable = 0;\n\t}\n }\n\n if (inlinable && (*lang_hooks.tree_inlining.cannot_inline_tree_fn) (&fn))\n inlinable = 0;\n\n /* If we don't have the function body available, we can't inline\n it. */\n if (! DECL_SAVED_TREE (fn))\n inlinable = 0;\n\n /* Check again, language hooks may have modified it. */\n if (! inlinable || DECL_UNINLINABLE (fn))\n return 0;\n\n /* Don't do recursive inlining, either. We don't record this in\n DECL_UNINLINABLE; we may be able to inline this function later. */\n if (id)\n {\n size_t i;\n\n for (i = 0; i < VARRAY_ACTIVE_SIZE (id->fns); ++i)\n\tif (VARRAY_TREE (id->fns, i) == fn)\n\t return 0;\n\n if (DECL_INLINED_FNS (fn))\n\t{\n\t int j;\n\t tree inlined_fns = DECL_INLINED_FNS (fn);\n\n\t for (j = 0; j < TREE_VEC_LENGTH (inlined_fns); ++j)\n\t if (TREE_VEC_ELT (inlined_fns, j) == VARRAY_TREE (id->fns, 0))\n\t return 0;\n\t}\n }\n\n /* Return the result. */\n return inlinable;\n}",
"label": 0,
"cwe": null,
"length": 1380
},
{
"index": 29355,
"code": "BufferSync(int flags)\n{\n\tint\t\t\tbuf_id;\n\tint\t\t\tnum_to_scan;\n\tint\t\t\tnum_to_write;\n\tint\t\t\tnum_written;\n\n\t/* Make sure we can handle the pin inside SyncOneBuffer */\n\tResourceOwnerEnlargeBuffers(CurrentResourceOwner);\n\n\t/*\n\t * Loop over all buffers, and mark the ones that need to be written with\n\t * BM_CHECKPOINT_NEEDED. Count them as we go (num_to_write), so that we\n\t * can estimate how much work needs to be done.\n\t *\n\t * This allows us to write only those pages that were dirty when the\n\t * checkpoint began, and not those that get dirtied while it proceeds.\n\t * Whenever a page with BM_CHECKPOINT_NEEDED is written out, either by us\n\t * later in this function, or by normal backends or the bgwriter cleaning\n\t * scan, the flag is cleared. Any buffer dirtied after this point won't\n\t * have the flag set.\n\t *\n\t * Note that if we fail to write some buffer, we may leave buffers with\n\t * BM_CHECKPOINT_NEEDED still set.\tThis is OK since any such buffer would\n\t * certainly need to be written for the next checkpoint attempt, too.\n\t */\n\tnum_to_write = 0;\n\tfor (buf_id = 0; buf_id < NBuffers; buf_id++)\n\t{\n\t\tvolatile BufferDesc *bufHdr = &BufferDescriptors[buf_id];\n\n\t\t/*\n\t\t * Header spinlock is enough to examine BM_DIRTY, see comment in\n\t\t * SyncOneBuffer.\n\t\t */\n\t\tLockBufHdr(bufHdr);\n\n\t\tif (bufHdr->flags & BM_DIRTY)\n\t\t{\n\t\t\tbufHdr->flags |= BM_CHECKPOINT_NEEDED;\n\t\t\tnum_to_write++;\n\t\t}\n\n\t\tUnlockBufHdr(bufHdr);\n\t}\n\n\tif (num_to_write == 0)\n\t\treturn;\t\t\t\t\t/* nothing to do */\n\n\tTRACE_POSTGRESQL_BUFFER_SYNC_START(NBuffers, num_to_write);\n\n\t/*\n\t * Loop over all buffers again, and write the ones (still) marked with\n\t * BM_CHECKPOINT_NEEDED. In this loop, we start at the clock sweep point\n\t * since we might as well dump soon-to-be-recycled buffers first.\n\t *\n\t * Note that we don't read the buffer alloc count here --- that should be\n\t * left untouched till the next BgBufferSync() call.\n\t */\n\tbuf_id = StrategySyncStart(NULL, NULL);\n\tnum_to_scan = NBuffers;\n\tnum_written = 0;\n\twhile (num_to_scan-- > 0)\n\t{\n\t\tvolatile BufferDesc *bufHdr = &BufferDescriptors[buf_id];\n\n\t\t/*\n\t\t * We don't need to acquire the lock here, because we're only looking\n\t\t * at a single bit. It's possible that someone else writes the buffer\n\t\t * and clears the flag right after we check, but that doesn't matter\n\t\t * since SyncOneBuffer will then do nothing. However, there is a\n\t\t * further race condition: it's conceivable that between the time we\n\t\t * examine the bit here and the time SyncOneBuffer acquires lock,\n\t\t * someone else not only wrote the buffer but replaced it with another\n\t\t * page and dirtied it. In that improbable case, SyncOneBuffer will\n\t\t * write the buffer though we didn't need to. It doesn't seem worth\n\t\t * guarding against this, though.\n\t\t */\n\t\tif (bufHdr->flags & BM_CHECKPOINT_NEEDED)\n\t\t{\n\t\t\tif (SyncOneBuffer(buf_id, false) & BUF_WRITTEN)\n\t\t\t{\n\t\t\t\tTRACE_POSTGRESQL_BUFFER_SYNC_WRITTEN(buf_id);\n\t\t\t\tBgWriterStats.m_buf_written_checkpoints++;\n\t\t\t\tnum_written++;\n\n\t\t\t\t/*\n\t\t\t\t * We know there are at most num_to_write buffers with\n\t\t\t\t * BM_CHECKPOINT_NEEDED set; so we can stop scanning if\n\t\t\t\t * num_written reaches num_to_write.\n\t\t\t\t *\n\t\t\t\t * Note that num_written doesn't include buffers written by\n\t\t\t\t * other backends, or by the bgwriter cleaning scan. That\n\t\t\t\t * means that the estimate of how much progress we've made is\n\t\t\t\t * conservative, and also that this test will often fail to\n\t\t\t\t * trigger. But it seems worth making anyway.\n\t\t\t\t */\n\t\t\t\tif (num_written >= num_to_write)\n\t\t\t\t\tbreak;\n\n\t\t\t\t/*\n\t\t\t\t * Perform normal bgwriter duties and sleep to throttle our\n\t\t\t\t * I/O rate.\n\t\t\t\t */\n\t\t\t\tCheckpointWriteDelay(flags,\n\t\t\t\t\t\t\t\t\t (double) num_written / num_to_write);\n\t\t\t}\n\t\t}\n\n\t\tif (++buf_id >= NBuffers)\n\t\t\tbuf_id = 0;\n\t}\n\n\t/*\n\t * Update checkpoint statistics. As noted above, this doesn't include\n\t * buffers written by other backends or bgwriter scan.\n\t */\n\tCheckpointStats.ckpt_bufs_written += num_written;\n\n\tTRACE_POSTGRESQL_BUFFER_SYNC_DONE(NBuffers, num_written, num_to_write);\n}",
"label": 0,
"cwe": null,
"length": 1047
},
{
"index": 257817,
"code": "usage(int help, int longopt, int status)\n{\n\tFILE *out = status ? stderr : stdout;\n\tfprintf(out,\n\"qrencode version %s\\n\"\n\"Copyright (C) 2006-2014 Kentaro Fukuchi\\n\", QRcode_APIVersionString());\n\tif(help) {\n\t\tif(longopt) {\n\t\t\tfprintf(out,\n\"Usage: qrencode [OPTION]... [STRING]\\n\"\n\"Encode input data in a QR Code and save as a PNG or EPS 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 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\" (suffix is removed from FILENAME, if specified)\\n\\n\"\n\" -s NUMBER, --size=NUMBER\\n\"\n\" specify module size in dots (pixels). (default=3)\\n\\n\"\n\" -l {LMQH}, --level={LMQH}\\n\"\n\" specify error correction 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. See SYMBOL VERSIONS for more\\n\"\n\" information. (default=auto)\\n\\n\"\n\" -m NUMBER, --margin=NUMBER\\n\"\n\" specify the width of the margins. (default=4 (2 for Micro QR)))\\n\\n\"\n\" -d NUMBER, --dpi=NUMBER\\n\"\n\" specify the DPI of the generated PNG. (default=72)\\n\\n\"\n\" -t {PNG,PNG32,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}, --type={...}\\n\"\n\" specify the type of the generated image. (default=PNG)\\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\" --rle enable run-length encoding for SVG.\\n\\n\"\n\" -M, --micro encode in a Micro QR Code. (experimental)\\n\\n\"\n\" --foreground=RRGGBB[AA]\\n\"\n\" --background=RRGGBB[AA]\\n\"\n\" specify foreground/background color in hexadecimal notation.\\n\"\n\" 6-digit (RGB) or 8-digit (RGBA) form are supported.\\n\"\n\" Color output support available only in PNG, EPS and SVG.\\n\\n\"\n\" -V, --version\\n\"\n\" display the version number and copyrights of the qrencode.\\n\\n\"\n\" --verbose\\n\"\n\" display verbose information to stderr.\\n\\n\"\n\" [STRING] input data. If it is not specified, data will be taken from\\n\"\n\" standard input.\\n\\n\"\n\"*SYMBOL VERSIONS\\n\"\n\" The symbol versions of QR Code range from Version 1 to Version\\n\"\n\" 40. Each version has a different module configuration or number\\n\"\n\" of modules, ranging from Version 1 (21 x 21 modules) up to\\n\"\n\" Version 40 (177 x 177 modules). Each higher version number\\n\"\n\" comprises 4 additional modules per side by default. See\\n\"\n\" http://www.qrcode.com/en/about/version.html for a detailed\\n\"\n\" version list.\\n\"\n\n\t\t\t);\n\t\t} else {\n\t\t\tfprintf(out,\n\"Usage: qrencode [OPTION]... [STRING]\\n\"\n\"Encode input data in a QR Code and save as a PNG or EPS image.\\n\\n\"\n\" -h display this message.\\n\"\n\" --help display the usage of long options.\\n\"\n\" -o FILENAME write 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\" (suffix is removed from FILENAME, if specified)\\n\"\n\" -s NUMBER specify module size in dots (pixels). (default=3)\\n\"\n\" -l {LMQH} specify error correction 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 the margins. (default=4 (2 for Micro))\\n\"\n\" -d NUMBER specify the DPI of the generated PNG. (default=72)\\n\"\n\" -t {PNG,PNG32,EPS,SVG,ANSI,ANSI256,ASCII,ASCIIi,UTF8,ANSIUTF8}\\n\"\n\" specify the type of the generated image. (default=PNG)\\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\" -M encode in a Micro QR Code.\\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\"\n\" Try \\\"qrencode --help\\\" for more options.\\n\"\n\t\t\t);\n\t\t}\n\t}\n}",
"label": 0,
"cwe": null,
"length": 1416
},
{
"index": 587769,
"code": "ahc_init_scbdata(struct ahc_softc *ahc)\n{\n\tstruct scb_data *scb_data;\n\n\tscb_data = ahc->scb_data;\n\tSLIST_INIT(&scb_data->free_scbs);\n\tSLIST_INIT(&scb_data->sg_maps);\n\n\t/* Allocate SCB resources */\n\tscb_data->scbarray = kzalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC,\n\t\t\t\tGFP_ATOMIC);\n\tif (scb_data->scbarray == NULL)\n\t\treturn (ENOMEM);\n\n\t/* Determine the number of hardware SCBs and initialize them */\n\n\tscb_data->maxhscbs = ahc_probe_scbs(ahc);\n\tif (ahc->scb_data->maxhscbs == 0) {\n\t\tprintk(\"%s: No SCB space found\\n\", ahc_name(ahc));\n\t\treturn (ENXIO);\n\t}\n\n\t/*\n\t * Create our DMA tags. These tags define the kinds of device\n\t * accessible memory allocations and memory mappings we will\n\t * need to perform during normal operation.\n\t *\n\t * Unless we need to further restrict the allocation, we rely\n\t * on the restrictions of the parent dmat, hence the common\n\t * use of MAXADDR and MAXSIZE.\n\t */\n\n\t/* DMA tag for our hardware scb structures */\n\tif (ahc_dma_tag_create(ahc, ahc->parent_dmat, /*alignment*/1,\n\t\t\t /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,\n\t\t\t /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,\n\t\t\t /*highaddr*/BUS_SPACE_MAXADDR,\n\t\t\t /*filter*/NULL, /*filterarg*/NULL,\n\t\t\t AHC_SCB_MAX_ALLOC * sizeof(struct hardware_scb),\n\t\t\t /*nsegments*/1,\n\t\t\t /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,\n\t\t\t /*flags*/0, &scb_data->hscb_dmat) != 0) {\n\t\tgoto error_exit;\n\t}\n\n\tscb_data->init_level++;\n\n\t/* Allocation for our hscbs */\n\tif (ahc_dmamem_alloc(ahc, scb_data->hscb_dmat,\n\t\t\t (void **)&scb_data->hscbs,\n\t\t\t BUS_DMA_NOWAIT, &scb_data->hscb_dmamap) != 0) {\n\t\tgoto error_exit;\n\t}\n\n\tscb_data->init_level++;\n\n\t/* And permanently map them */\n\tahc_dmamap_load(ahc, scb_data->hscb_dmat, scb_data->hscb_dmamap,\n\t\t\tscb_data->hscbs,\n\t\t\tAHC_SCB_MAX_ALLOC * sizeof(struct hardware_scb),\n\t\t\tahc_dmamap_cb, &scb_data->hscb_busaddr, /*flags*/0);\n\n\tscb_data->init_level++;\n\n\t/* DMA tag for our sense buffers */\n\tif (ahc_dma_tag_create(ahc, ahc->parent_dmat, /*alignment*/1,\n\t\t\t /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,\n\t\t\t /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,\n\t\t\t /*highaddr*/BUS_SPACE_MAXADDR,\n\t\t\t /*filter*/NULL, /*filterarg*/NULL,\n\t\t\t AHC_SCB_MAX_ALLOC * sizeof(struct scsi_sense_data),\n\t\t\t /*nsegments*/1,\n\t\t\t /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,\n\t\t\t /*flags*/0, &scb_data->sense_dmat) != 0) {\n\t\tgoto error_exit;\n\t}\n\n\tscb_data->init_level++;\n\n\t/* Allocate them */\n\tif (ahc_dmamem_alloc(ahc, scb_data->sense_dmat,\n\t\t\t (void **)&scb_data->sense,\n\t\t\t BUS_DMA_NOWAIT, &scb_data->sense_dmamap) != 0) {\n\t\tgoto error_exit;\n\t}\n\n\tscb_data->init_level++;\n\n\t/* And permanently map them */\n\tahc_dmamap_load(ahc, scb_data->sense_dmat, scb_data->sense_dmamap,\n\t\t\tscb_data->sense,\n\t\t\tAHC_SCB_MAX_ALLOC * sizeof(struct scsi_sense_data),\n\t\t\tahc_dmamap_cb, &scb_data->sense_busaddr, /*flags*/0);\n\n\tscb_data->init_level++;\n\n\t/* DMA tag for our S/G structures. We allocate in page sized chunks */\n\tif (ahc_dma_tag_create(ahc, ahc->parent_dmat, /*alignment*/8,\n\t\t\t /*boundary*/BUS_SPACE_MAXADDR_32BIT + 1,\n\t\t\t /*lowaddr*/BUS_SPACE_MAXADDR_32BIT,\n\t\t\t /*highaddr*/BUS_SPACE_MAXADDR,\n\t\t\t /*filter*/NULL, /*filterarg*/NULL,\n\t\t\t PAGE_SIZE, /*nsegments*/1,\n\t\t\t /*maxsegsz*/BUS_SPACE_MAXSIZE_32BIT,\n\t\t\t /*flags*/0, &scb_data->sg_dmat) != 0) {\n\t\tgoto error_exit;\n\t}\n\n\tscb_data->init_level++;\n\n\t/* Perform initial CCB allocation */\n\tmemset(scb_data->hscbs, 0,\n\t AHC_SCB_MAX_ALLOC * sizeof(struct hardware_scb));\n\tahc_alloc_scbs(ahc);\n\n\tif (scb_data->numscbs == 0) {\n\t\tprintk(\"%s: ahc_init_scbdata - \"\n\t\t \"Unable to allocate initial scbs\\n\",\n\t\t ahc_name(ahc));\n\t\tgoto error_exit;\n\t}\n\n\t/*\n\t * Reserve the next queued SCB.\n\t */\n\tahc->next_queued_scb = ahc_get_scb(ahc);\n\n\t/*\n\t * Note that we were successful\n\t */\n\treturn (0); \n\nerror_exit:\n\n\treturn (ENOMEM);\n}",
"label": 0,
"cwe": null,
"length": 1214
},
{
"index": 414351,
"code": "generate_limit4(typedecl * d, char * var, typedecl * e)\n{\n stelist * t;\n typedecl * d2; \n \n if (e->gettypeclass() == typedecl::Scalarset\n && e == d)\n generate_limit4(d->getsize(), d->mu_name, var, d->getleft(),FALSE);\n else if (e->gettypeclass() == typedecl::Union\n\t && ((uniontypedecl *)e)->IsUnionWithScalarset())\n {\n for(t=((uniontypedecl *)e)->getunionmembers();\n\t t!= NULL; t=t->next)\n\t{\n\t d2 = (typedecl *)t->s->getvalue();\n\t if (d2 == d)\n\t fprintf(codefile,\n\t\t \"\\n\"\n\t\t \" // refinement -- graph structure for a single scalarset\\n\"\n\t\t \" // as in array S1 of S1\\n\"\n\t\t \" // only if there is more than 1 permutation in class\\n\"\n\t\t \" if (Perm.MTO_class_%s() && count_%s<%d)\\n\"\n\t\t \" {\\n\"\n\t\t \" exists = FALSE;\\n\"\n\t\t \" split = FALSE;\\n\"\n\t\t \" for (k=0; k<%d; k++) // step through class\\n\"\n\t\t \" if (!(*this)[k+%d]%s.isundefined()\\n\"\n\t\t \" &&(*this)[k+%d]%s!=k+%d\\n\"\n\t\t \" &&(*this)[k+%d]%s>=%d\\n\"\n\t\t \" &&(*this)[k+%d]%s<=%d)\\n\"\n\t\t \" exists = TRUE;\\n\"\n\t\t \" if (exists)\\n\"\n\t\t \" {\\n\"\n\t\t \" for (i=0; i<count_%s; i++) // for value priority\\n\"\n\t\t \" {\\n\"\n\t\t \" for (j=0; j<count_%s; j++) // for value priority\\n\"\n\t\t \" {\\n\"\n\t\t \" exists = FALSE;\\n\"\n\t\t \" for (k=0; k<%d; k++) // step through class\\n\"\n\t\t \" goodset_%s[k] = FALSE;\\n\"\n\t\t \" for (k=0; k<%d; k++) // step through class\\n\"\n\t\t \" if (pos_%s[i][k] \\n\"\n\t\t \" && !(*this)[k+%d]%s.isundefined()\\n\"\n\t\t \" && (*this)[k+%d]%s!=k+%d\\n\"\n\t\t \" && (*this)[k+%d]%s>=%d\\n\" // extra checking\n\t\t \" && (*this)[k+%d]%s<=%d\\n\" // extra checking\n\t\t \" && pos_%s[j][(*this)[k+%d]%s-%d])\\n\"\n\t\t \" {\\n\"\n\t\t \" exists = TRUE;\\n\"\n\t\t \" goodset_%s[k] = TRUE;\\n\"\n\t\t \" }\\n\"\n\t\t \" if (exists)\\n\"\n\t\t \" {\\n\"\n\t\t \" split=FALSE;\\n\"\n\t\t \" for (k=0; k<%d; k++)\\n\"\n\t\t \" if ( pos_%s[i][k] && !goodset_%s[k] ) \\n\"\n\t\t \" split= TRUE;\\n\"\n\t\t \" if (split)\\n\"\n\t\t \" {\\n\"\n\t\t \" for (j=count_%s; j>i; j--)\\n\"\n\t\t \" for (k=0; k<%d; k++)\\n\"\n\t\t \" pos_%s[j][k] = pos_%s[j-1][k];\\n\"\n\t\t \" for (k=0; k<%d; k++)\\n\"\n\t\t \" {\\n\"\n\t\t \" if (pos_%s[i][k] && !goodset_%s[k])\\n\"\n\t\t \" pos_%s[i][k] = FALSE;\\n\"\n\t\t \" if (pos_%s[i+1][k] && goodset_%s[k])\\n\"\n\t\t \" pos_%s[i+1][k] = FALSE; \\n\"\n\t\t \" }\\n\"\n\t\t \" count_%s++;\\n\"\n\t\t \" }\\n\"\n\t\t \" }\\n\"\n\t\t \" }\\n\"\n\t\t \" }\\n\"\n\t\t \" }\\n\"\n\t\t \" }\\n\",\n\t\t d->mu_name, d->mu_name, d->getsize(), // MTO_class count_%s<%d\n\t\t d->getsize(), // k-for\n\t\t d->getleft(), var, // (*this)[k]%s\n\t\t d->getleft(), var, d->getleft(), // (*this)[k]%s==k+%d\n\t\t d->getleft(), var, d->getleft(), // (*this)[k]%s<%d\n\t\t d->getleft(), var, d->getright(), // (*this)[k]%s>%d\n\n\t\t d->mu_name, // count_%s\n\t\t d->mu_name, // count_%s\n\t\t d->getsize(), d->mu_name, // k-for goodset_%s\n\t\t d->getsize(), // k-for\n\t\t d->mu_name, // pos_%s\n\t\t d->getleft(), var, // [i+%d]%s.isundefined()\n\t\t d->getleft(), var, d->getleft(), // [i+%d]%s== i+%d\n\t\t d->getleft(), var, d->getleft(), // [i+%d]%s>=%d\n\t\t d->getleft(), var, d->getright(), // [i+%d]%s<=%d\n\t\t d->mu_name, d->getleft(), var, d->getleft(), // pos_%s[j][(*this)[k+%d]%s-%d]\n\t\t d->mu_name, // goodset_%s\n\t\t \n\t\t d->getsize(), // k-for\n\t\t d->mu_name, d->mu_name, // pos_%s goodset_%s\n\t\t d->mu_name, // count_%s\n\t\t d->getsize(), // k-for\n\t\t d->mu_name, d->mu_name, // pos_%s, pos_%s\n\t\t d->getsize(), // k-for\n\t\t \n\t\t d->mu_name, d->mu_name, // pos_%s, goodset_%s\n\t\t d->mu_name, // pos_%s\n\t\t d->mu_name, d->mu_name, // class_%s, goodset_%s\n\t\t d->mu_name, // pos_%s\n\t\t d->mu_name // count_%s\n\t\t );\n\t}\n }\n}",
"label": 0,
"cwe": null,
"length": 1466
},
{
"index": 196997,
"code": "store(pTHX_ stcxt_t *cxt, SV *sv)\n{\n\tSV **svh;\n\tint ret;\n\tint type;\n#ifdef USE_PTR_TABLE\n\tstruct ptr_tbl *pseen = cxt->pseen;\n#else\n\tHV *hseen = cxt->hseen;\n#endif\n\n\tTRACEME((\"store (0x%\"UVxf\")\", PTR2UV(sv)));\n\n\t/*\n\t * If object has already been stored, do not duplicate data.\n\t * Simply emit the SX_OBJECT marker followed by its tag data.\n\t * The tag is always written in network order.\n\t *\n\t * NOTA BENE, for 64-bit machines: the \"*svh\" below does not yield a\n\t * real pointer, rather a tag number (watch the insertion code below).\n\t * That means it probably safe to assume it is well under the 32-bit limit,\n\t * and makes the truncation safe.\n\t *\t\t-- RAM, 14/09/1999\n\t */\n\n#ifdef USE_PTR_TABLE\n\tsvh = (SV **)ptr_table_fetch(pseen, sv);\n#else\n\tsvh = hv_fetch(hseen, (char *) &sv, sizeof(sv), FALSE);\n#endif\n\tif (svh) {\n\t\tI32 tagval;\n\n\t\tif (sv == &PL_sv_undef) {\n\t\t\t/* We have seen PL_sv_undef before, but fake it as\n\t\t\t if we have not.\n\n\t\t\t Not the simplest solution to making restricted\n\t\t\t hashes work on 5.8.0, but it does mean that\n\t\t\t repeated references to the one true undef will\n\t\t\t take up less space in the output file.\n\t\t\t*/\n\t\t\t/* Need to jump past the next hv_store, because on the\n\t\t\t second store of undef the old hash value will be\n\t\t\t SvREFCNT_dec()ed, and as Storable cheats horribly\n\t\t\t by storing non-SVs in the hash a SEGV will ensure.\n\t\t\t Need to increase the tag number so that the\n\t\t\t receiver has no idea what games we're up to. This\n\t\t\t special casing doesn't affect hooks that store\n\t\t\t undef, as the hook routine does its own lookup into\n\t\t\t hseen. Also this means that any references back\n\t\t\t to PL_sv_undef (from the pathological case of hooks\n\t\t\t storing references to it) will find the seen hash\n\t\t\t entry for the first time, as if we didn't have this\n\t\t\t hackery here. (That hseen lookup works even on 5.8.0\n\t\t\t because it's a key of &PL_sv_undef and a value\n\t\t\t which is a tag number, not a value which is\n\t\t\t PL_sv_undef.) */\n\t\t\tcxt->tagnum++;\n\t\t\ttype = svis_SCALAR;\n\t\t\tgoto undef_special_case;\n\t\t}\n\t\t\n#ifdef USE_PTR_TABLE\n\t\ttagval = htonl(LOW_32BITS(((char *)svh)-1));\n#else\n\t\ttagval = htonl(LOW_32BITS(*svh));\n#endif\n\n\t\tTRACEME((\"object 0x%\"UVxf\" seen as #%d\", PTR2UV(sv), ntohl(tagval)));\n\n\t\tPUTMARK(SX_OBJECT);\n\t\tWRITE_I32(tagval);\n\t\treturn 0;\n\t}\n\n\t/*\n\t * Allocate a new tag and associate it with the address of the sv being\n\t * stored, before recursing...\n\t *\n\t * In order to avoid creating new SvIVs to hold the tagnum we just\n\t * cast the tagnum to an SV pointer and store that in the hash. This\n\t * means that we must clean up the hash manually afterwards, but gives\n\t * us a 15% throughput increase.\n\t *\n\t */\n\n\tcxt->tagnum++;\n#ifdef USE_PTR_TABLE\n\tptr_table_store(pseen, sv, INT2PTR(SV*, 1 + cxt->tagnum));\n#else\n\tif (!hv_store(hseen,\n\t\t\t(char *) &sv, sizeof(sv), INT2PTR(SV*, cxt->tagnum), 0))\n\t\treturn -1;\n#endif\n\n\t/*\n\t * Store 'sv' and everything beneath it, using appropriate routine.\n\t * Abort immediately if we get a non-zero status back.\n\t */\n\n\ttype = sv_type(aTHX_ sv);\n\nundef_special_case:\n\tTRACEME((\"storing 0x%\"UVxf\" tag #%d, type %d...\",\n\t\t PTR2UV(sv), cxt->tagnum, type));\n\n\tif (SvOBJECT(sv)) {\n\t\tHV *pkg = SvSTASH(sv);\n\t\tret = store_blessed(aTHX_ cxt, sv, type, pkg);\n\t} else\n\t\tret = SV_STORE(type)(aTHX_ cxt, sv);\n\n\tTRACEME((\"%s (stored 0x%\"UVxf\", refcnt=%d, %s)\",\n\t\tret ? \"FAILED\" : \"ok\", PTR2UV(sv),\n\t\tSvREFCNT(sv), sv_reftype(sv, FALSE)));\n\n\treturn ret;\n}",
"label": 0,
"cwe": null,
"length": 1057
},
{
"index": 780643,
"code": "i915_get_crtc_scanoutpos(struct drm_device *dev, unsigned int pipe,\n\t\t\t\t unsigned int flags, int *vpos, int *hpos,\n\t\t\t\t ktime_t *stime, ktime_t *etime,\n\t\t\t\t const struct drm_display_mode *mode)\n{\n\tstruct drm_i915_private *dev_priv = dev->dev_private;\n\tstruct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];\n\tstruct intel_crtc *intel_crtc = to_intel_crtc(crtc);\n\tint position;\n\tint vbl_start, vbl_end, hsync_start, htotal, vtotal;\n\tbool in_vbl = true;\n\tint ret = 0;\n\tunsigned long irqflags;\n\n\tif (WARN_ON(!mode->crtc_clock)) {\n\t\tDRM_DEBUG_DRIVER(\"trying to get scanoutpos for disabled \"\n\t\t\t\t \"pipe %c\\n\", pipe_name(pipe));\n\t\treturn 0;\n\t}\n\n\thtotal = mode->crtc_htotal;\n\thsync_start = mode->crtc_hsync_start;\n\tvtotal = mode->crtc_vtotal;\n\tvbl_start = mode->crtc_vblank_start;\n\tvbl_end = mode->crtc_vblank_end;\n\n\tif (mode->flags & DRM_MODE_FLAG_INTERLACE) {\n\t\tvbl_start = DIV_ROUND_UP(vbl_start, 2);\n\t\tvbl_end /= 2;\n\t\tvtotal /= 2;\n\t}\n\n\tret |= DRM_SCANOUTPOS_VALID | DRM_SCANOUTPOS_ACCURATE;\n\n\t/*\n\t * Lock uncore.lock, as we will do multiple timing critical raw\n\t * register reads, potentially with preemption disabled, so the\n\t * following code must not block on uncore.lock.\n\t */\n\tspin_lock_irqsave(&dev_priv->uncore.lock, irqflags);\n\n\t/* preempt_disable_rt() should go right here in PREEMPT_RT patchset. */\n\n\t/* Get optional system timestamp before query. */\n\tif (stime)\n\t\t*stime = ktime_get();\n\n\tif (IS_GEN2(dev) || IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) {\n\t\t/* No obvious pixelcount register. Only query vertical\n\t\t * scanout position from Display scan line register.\n\t\t */\n\t\tposition = __intel_get_crtc_scanline(intel_crtc);\n\t} else {\n\t\t/* Have access to pixelcount since start of frame.\n\t\t * We can split this into vertical and horizontal\n\t\t * scanout position.\n\t\t */\n\t\tposition = (I915_READ_FW(PIPEFRAMEPIXEL(pipe)) & PIPE_PIXEL_MASK) >> PIPE_PIXEL_SHIFT;\n\n\t\t/* convert to pixel counts */\n\t\tvbl_start *= htotal;\n\t\tvbl_end *= htotal;\n\t\tvtotal *= htotal;\n\n\t\t/*\n\t\t * In interlaced modes, the pixel counter counts all pixels,\n\t\t * so one field will have htotal more pixels. In order to avoid\n\t\t * the reported position from jumping backwards when the pixel\n\t\t * counter is beyond the length of the shorter field, just\n\t\t * clamp the position the length of the shorter field. This\n\t\t * matches how the scanline counter based position works since\n\t\t * the scanline counter doesn't count the two half lines.\n\t\t */\n\t\tif (position >= vtotal)\n\t\t\tposition = vtotal - 1;\n\n\t\t/*\n\t\t * Start of vblank interrupt is triggered at start of hsync,\n\t\t * just prior to the first active line of vblank. However we\n\t\t * consider lines to start at the leading edge of horizontal\n\t\t * active. So, should we get here before we've crossed into\n\t\t * the horizontal active of the first line in vblank, we would\n\t\t * not set the DRM_SCANOUTPOS_INVBL flag. In order to fix that,\n\t\t * always add htotal-hsync_start to the current pixel position.\n\t\t */\n\t\tposition = (position + htotal - hsync_start) % vtotal;\n\t}\n\n\t/* Get optional system timestamp after query. */\n\tif (etime)\n\t\t*etime = ktime_get();\n\n\t/* preempt_enable_rt() should go right here in PREEMPT_RT patchset. */\n\n\tspin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags);\n\n\tin_vbl = position >= vbl_start && position < vbl_end;\n\n\t/*\n\t * While in vblank, position will be negative\n\t * counting up towards 0 at vbl_end. And outside\n\t * vblank, position will be positive counting\n\t * up since vbl_end.\n\t */\n\tif (position >= vbl_start)\n\t\tposition -= vbl_end;\n\telse\n\t\tposition += vtotal - vbl_end;\n\n\tif (IS_GEN2(dev) || IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) {\n\t\t*vpos = position;\n\t\t*hpos = 0;\n\t} else {\n\t\t*vpos = position / htotal;\n\t\t*hpos = position - (*vpos * htotal);\n\t}\n\n\t/* In vblank? */\n\tif (in_vbl)\n\t\tret |= DRM_SCANOUTPOS_IN_VBLANK;\n\n\treturn ret;\n}",
"label": 0,
"cwe": null,
"length": 1079
},
{
"index": 405386,
"code": "main( int argc, char *argv[]\n#ifdef DSGW_DEBUG\n , char *env[]\n#endif\n )\n{\n /*static char* docdir = \"..\" PATH_SLASH \"html\" PATH_SLASH;*/\n static char* docdir = NULL;\n static char* helpdir = NULL;\n char* docname = NULL;\n char* tfname = NULL;\n int result = 0;\n int manual_file = 0; /* Flag: is the file a documentation file? */\n \n (void)dsgw_init( argc, argv, DSGW_METHOD_GET | DSGW_METHOD_POST );\n\n dsgw_last_op_info = dsgw_get_cgi_var(\"info\", DSGW_CGIVAR_OPTIONAL);\n docname = dsgw_get_cgi_var(\"file\", DSGW_CGIVAR_OPTIONAL);\n if (docname) {\n\t/*If we're handling a help page, forgo the filename check*/\n\tif ( strlen( docname ) > DSGW_MANUALSHORTCUT_LEN && \n\t strncmp( docname, DSGW_MANUALSHORTCUT, \n\t\t DSGW_MANUALSHORTCUT_LEN ) == 0 ) {\n\t manual_file = 1;\n\t}\n\t/*\n\t * Make sure the person isn't trying to get \n\t * some file not in the gateway.\n\t */\n\tif (manual_file == 0 && !dsgw_valid_docname(docname)) {\n\t dsgw_error( DSGW_ERR_BADFILEPATH, docname, \n\t\t\tDSGW_ERROPT_EXIT, 0, NULL );\n\t}\n }\n\n docdir = dsgw_get_docdir();\n \n /*If there is no docname, default to index.html*/\n if (docname == NULL) {\n docname = dsgw_ch_strdup(\"index.html\");\n }\n\n /* I think this is a no op - dsgw_valid_docname will reject \"/\" */\n if (!strcmp (docname, \"/\")) {\n\tprintf( \"Location: %s?context=%s\\n\\n\", \n\t\tdsgw_getvp( DSGW_CGINUM_SEARCH ), context );\n\treturn( result );\n } /* I think this is a no op? else {\n\tchar* p;\n\tif (*docname == '/') ++docname;\n\tdocname = dsgw_ch_strdup( docname );\n\tif (( p = strrchr( docname, '&' )) != NULL ) {\n\t *p++ = '\\0';\n\t if ( strncasecmp( p, \"info=\", 5 ) == 0 ) {\n\t\tdsgw_last_op_info = dsgw_ch_strdup( p + 5 );\n\t\tdsgw_form_unescape( dsgw_last_op_info );\n\t }\n\t}\n } */\n \n if (manual_file) {\n /* check filename */\n char *mandocname = dsgw_ch_strdup(docname + DSGW_MANUALSHORTCUT_LEN);\n if (*mandocname == '/') {\n if (!dsgw_valid_docname(mandocname+1)) {\n dsgw_error( DSGW_ERR_BADFILEPATH, mandocname, \n DSGW_ERROPT_EXIT, 0, NULL );\n }\n } else {\n if (!dsgw_valid_docname(mandocname)) {\n dsgw_error( DSGW_ERR_BADFILEPATH, mandocname, \n DSGW_ERROPT_EXIT, 0, NULL );\n }\n }\n\n\thelpdir = dsgw_file2path ( DSGW_MANROOT, DSGW_MANSUBDIR );\n\ttfname = PR_smprintf(\"%s/%s\", helpdir, mandocname);\n\tfree( helpdir );\n free( mandocname );\n\n } else {\n\ttfname = dsgw_file2path (docdir, docname);\n }\n\n if ( ! doc_is_UTF_8 (tfname)) { /* Redirect the Web server: */\n\tprintf (\"Location: %s%s%s\\n\\n\", \n\t\tdsgw_server_url(), gc->gc_gwnametrans, skip_prefix (docdir, tfname));\n\t/* It's tempting to also redirect if is_UTF_8(gc->gc_charset).\n\t But it would be wrong: the Web server would transmit an\n\t HTTP Content-type with no charset parameter. The header\n\t must include \";charset=UTF-8\". So we transmit it:\n\t*/\n } else { /* Transmit the document: */\n\tconst int erropts = DSGW_ERROPT_EXIT;\n\tauto FILE* docfile;\n\n\tdsgw_send_header();\n#ifdef DSGW_DEBUG\n\tdsgw_logstringarray( \"env\", env ); \n#endif\n\tif ((docfile = fopen(tfname, \"r\")) == NULL) {\n\t dsgw_error( DSGW_ERR_OPENHTMLFILE, tfname, erropts, 0, NULL );\n\t return( -1 );\n\t}\n\tresult = doc_convert( &docfile, NULL, erropts );\n }\n/*\n * XXXmcs: the following free() causes a crash on NT... so don't do it!\n */\n free(tfname);\n\n return result;\n}",
"label": 0,
"cwe": null,
"length": 1095
},
{
"index": 578888,
"code": "cp_parser_type_specifier (cp_parser* parser,\n\t\t\t cp_parser_flags flags,\n\t\t\t cp_decl_specifier_seq *decl_specs,\n\t\t\t bool is_declaration,\n\t\t\t int* declares_class_or_enum,\n\t\t\t bool* is_cv_qualifier)\n{\n tree type_spec = NULL_TREE;\n cp_token *token;\n enum rid keyword;\n cp_decl_spec ds = ds_last;\n\n /* Assume this type-specifier does not declare a new type. */\n if (declares_class_or_enum)\n *declares_class_or_enum = 0;\n /* And that it does not specify a cv-qualifier. */\n if (is_cv_qualifier)\n *is_cv_qualifier = false;\n /* Peek at the next token. */\n token = cp_lexer_peek_token (parser->lexer);\n\n /* If we're looking at a keyword, we can use that to guide the\n production we choose. */\n keyword = token->keyword;\n switch (keyword)\n {\n case RID_ENUM:\n if ((flags & CP_PARSER_FLAGS_NO_TYPE_DEFINITIONS))\n\tgoto elaborated_type_specifier;\n\n /* Look for the enum-specifier. */\n type_spec = cp_parser_enum_specifier (parser);\n /* If that worked, we're done. */\n if (type_spec)\n\t{\n\t if (declares_class_or_enum)\n\t *declares_class_or_enum = 2;\n\t if (decl_specs)\n\t cp_parser_set_decl_spec_type (decl_specs,\n\t\t\t\t\t type_spec,\n\t\t\t\t\t token->location,\n\t\t\t\t\t /*type_definition_p=*/true);\n\t return type_spec;\n\t}\n else\n\tgoto elaborated_type_specifier;\n\n /* Any of these indicate either a class-specifier, or an\n\t elaborated-type-specifier. */\n case RID_CLASS:\n case RID_STRUCT:\n case RID_UNION:\n if ((flags & CP_PARSER_FLAGS_NO_TYPE_DEFINITIONS))\n\tgoto elaborated_type_specifier;\n\n /* Parse tentatively so that we can back up if we don't find a\n\t class-specifier. */\n cp_parser_parse_tentatively (parser);\n /* Look for the class-specifier. */\n type_spec = cp_parser_class_specifier (parser);\n invoke_plugin_callbacks (PLUGIN_FINISH_TYPE, type_spec);\n /* If that worked, we're done. */\n if (cp_parser_parse_definitely (parser))\n\t{\n\t if (declares_class_or_enum)\n\t *declares_class_or_enum = 2;\n\t if (decl_specs)\n\t cp_parser_set_decl_spec_type (decl_specs,\n\t\t\t\t\t type_spec,\n\t\t\t\t\t token->location,\n\t\t\t\t\t /*type_definition_p=*/true);\n\t return type_spec;\n\t}\n\n /* Fall through. */\n elaborated_type_specifier:\n /* We're declaring (not defining) a class or enum. */\n if (declares_class_or_enum)\n\t*declares_class_or_enum = 1;\n\n /* Fall through. */\n case RID_TYPENAME:\n /* Look for an elaborated-type-specifier. */\n type_spec\n\t= (cp_parser_elaborated_type_specifier\n\t (parser,\n\t decl_specs && decl_specs->specs[(int) ds_friend],\n\t is_declaration));\n if (decl_specs)\n\tcp_parser_set_decl_spec_type (decl_specs,\n\t\t\t\t type_spec,\n\t\t\t\t token->location,\n\t\t\t\t /*type_definition_p=*/false);\n return type_spec;\n\n case RID_CONST:\n ds = ds_const;\n if (is_cv_qualifier)\n\t*is_cv_qualifier = true;\n break;\n\n case RID_VOLATILE:\n ds = ds_volatile;\n if (is_cv_qualifier)\n\t*is_cv_qualifier = true;\n break;\n\n case RID_RESTRICT:\n ds = ds_restrict;\n if (is_cv_qualifier)\n\t*is_cv_qualifier = true;\n break;\n\n case RID_COMPLEX:\n /* The `__complex__' keyword is a GNU extension. */\n ds = ds_complex;\n break;\n\n default:\n break;\n }\n\n /* Handle simple keywords. */\n if (ds != ds_last)\n {\n if (decl_specs)\n\t{\n\t ++decl_specs->specs[(int)ds];\n\t decl_specs->any_specifiers_p = true;\n\t}\n return cp_lexer_consume_token (parser->lexer)->u.value;\n }\n\n /* If we do not already have a type-specifier, assume we are looking\n at a simple-type-specifier. */\n type_spec = cp_parser_simple_type_specifier (parser,\n\t\t\t\t\t decl_specs,\n\t\t\t\t\t flags);\n\n /* If we didn't find a type-specifier, and a type-specifier was not\n optional in this context, issue an error message. */\n if (!type_spec && !(flags & CP_PARSER_FLAGS_OPTIONAL))\n {\n cp_parser_error (parser, \"expected type specifier\");\n return error_mark_node;\n }\n\n return type_spec;\n}",
"label": 0,
"cwe": null,
"length": 1044
},
{
"index": 834182,
"code": "__lambda201_ (BoxesEmptyBoxes* self) {\n\tgboolean _tmp0_ = FALSE;\n\tBoxesUIState _tmp1_ = 0;\n\tBoxesUIState _tmp2_ = 0;\n\tgboolean visible = FALSE;\n\tgboolean _tmp8_ = FALSE;\n\tgboolean _tmp9_ = FALSE;\n\tGtkClutterActor* _tmp10_ = NULL;\n\tgboolean _tmp11_ = FALSE;\n\tgboolean _tmp12_ = FALSE;\n#line 66 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t_tmp1_ = boxes_ui_get_ui_state ((BoxesUI*) self);\n#line 66 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t_tmp2_ = _tmp1_;\n#line 66 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\tif (_tmp2_ == BOXES_UI_STATE_COLLECTION) {\n#line 665 \"empty-boxes.c\"\n\t\tBoxesApp* _tmp3_ = NULL;\n\t\tBoxesCollection* _tmp4_ = NULL;\n\t\tGPtrArray* _tmp5_ = NULL;\n\t\tgint _tmp6_ = 0;\n\t\tgint _tmp7_ = 0;\n#line 66 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t\t_tmp3_ = boxes_app_app;\n#line 66 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t\t_tmp4_ = _tmp3_->collection;\n#line 66 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t\t_tmp5_ = _tmp4_->items;\n#line 66 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t\t_tmp6_ = g_ptr_array_get_length (_tmp5_);\n#line 66 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t\t_tmp7_ = _tmp6_;\n#line 66 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t\t_tmp0_ = _tmp7_ == 0;\n#line 683 \"empty-boxes.c\"\n\t} else {\n#line 66 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t\t_tmp0_ = FALSE;\n#line 687 \"empty-boxes.c\"\n\t}\n#line 66 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t_tmp8_ = _tmp0_;\n#line 66 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\tvisible = _tmp8_;\n#line 67 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t_tmp9_ = visible;\n#line 67 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t_tmp10_ = self->priv->gtk_actor;\n#line 67 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\tg_object_get ((ClutterActor*) _tmp10_, \"visible\", &_tmp11_, NULL);\n#line 67 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t_tmp12_ = _tmp11_;\n#line 67 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\tif (_tmp9_ != _tmp12_) {\n#line 703 \"empty-boxes.c\"\n\t\tgint _tmp13_ = 0;\n\t\tgboolean _tmp14_ = FALSE;\n\t\tGtkClutterActor* _tmp15_ = NULL;\n\t\tgint _tmp16_ = 0;\n#line 68 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t\t_tmp14_ = visible;\n#line 68 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t\tif (_tmp14_) {\n#line 68 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t\t\t_tmp13_ = 255;\n#line 714 \"empty-boxes.c\"\n\t\t} else {\n#line 68 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t\t\t_tmp13_ = 0;\n#line 718 \"empty-boxes.c\"\n\t\t}\n#line 68 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t\t_tmp15_ = self->priv->gtk_actor;\n#line 68 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t\t_tmp16_ = _tmp13_;\n#line 68 \"/extra-data/checkout/gnome/gnome-boxes/src/empty-boxes.vala\"\n\t\tboxes_fade_actor ((ClutterActor*) _tmp15_, (guint) _tmp16_);\n#line 726 \"empty-boxes.c\"\n\t}\n}",
"label": 0,
"cwe": null,
"length": 1085
},
{
"index": 157637,
"code": "fi_update_available_forward(rbtree_t *arbt, const struct dl_avail_chunk *ac)\n{\n\tfilesize_t from;\t\t\t\t\t/* Starting point of added chunk */\n\n\tdl_avail_chunk_check(ac);\n\n\tfrom = ac->from;\n\n\tdo {\n\t\tstruct dl_avail_chunk key;\n\t\tstruct dl_avail_chunk *avc;\t\t/* Available chunk */\n\t\trbnode_t *node;\t\t\t\t\t/* Tree node for faster iteration */\n\n\t\tkey.from = from;\n\t\tkey.to = ac->to;\n\n\t\tavc = rbtree_lookup_node(arbt, &key, &node);\n\n\t\tif (NULL == avc) {\n\t\t\tstruct dl_avail_chunk *anew;\n\n\t\t\t/* Chunk overlaps with nothing -> new entry and we're done */\n\n\t\t\tanew = dl_avail_chunk_new(from, ac->to, ac->sources);\n\t\t\trbtree_insert(arbt, anew);\n\t\t\tbreak;\n\t\t}\n\n\t\t/*\n\t\t * Chunk `avc' overlaps with `ac'.\n\t\t * There are six main configurations possible, with case #0 being\n\t\t * handled flexibly (i.e. it can start / end on the same boundaries):\n\t\t *\n\t\t * #0: [=avc=]\n\t\t * [---ac--]\n\t\t *\n\t\t * #1: [====avc====]\n\t\t * [---ac--]\n\t\t *\n\t\t * #2: [====avc====]\n\t\t * [---ac--]\n\t\t *\n\t\t * #3: [====avc====]\n\t\t * [---ac--]\n\t\t *\n\t\t * #4: [====avc====]\n\t\t * [---ac--]\n\t\t *\n\t\t * #5: [====avc====]\n\t\t * [---ac--]\n\t\t *\n\t\t * We want to find the first available chunk which overlaps with `ac'.\n\t\t */\n\n\t\t for (;;) {\n\t\t\tstruct dl_avail_chunk *prev;\n\t\t\trbnode_t *pnode = node;\n\n\t\t\tprev = rbtree_prev_node(arbt, &pnode);\n\t\t\tif (NULL == prev)\n\t\t\t\tbreak;\t\t/* No other available chunk before `avc' */\n\n\t\t\tif (prev->to <= from)\n\t\t\t\tbreak;\t\t/* No overlap with `ac' */\n\n\t\t\tavc = prev;\n\t\t\tnode = pnode;\n\t\t}\n\n\t\t/*\n\t\t * Handle cases #0 and #1 by creating a new available chunk at\n\t\t * the beginning, then handling the overlapping part.\n\t\t */\n\n\t\tif (from < avc->from) {\n\t\t\tstruct dl_avail_chunk *anew;\n\n\t\t\tg_assert(avc->from < ac->to);\t/* Overlaps with `ac' */\n\n\t\t\tanew = dl_avail_chunk_new(from, avc->from, ac->sources);\n\t\t\trbtree_insert(arbt, anew);\n\t\t\tfrom = avc->from;\n\t\t}\n\n\t\t/*\n\t\t * Handle cases #2, #3, #4 and #5 by splitting the existing available\n\t\t * chunk up to the start of the offered chunk `ac', and anything\n\t\t * following the end of `ac'.\n\t\t */\n\n\t\tif (avc->from <= from) {\n\t\t\tstruct dl_avail_chunk *anew;\n\t\t\tfilesize_t to = MIN(avc->to, ac->to);\t/* Upper intersection */\n\t\t\tfilesize_t avc_to = avc->to;\n\t\t\tsize_t sources = avc->sources;\n\n\t\t\tg_assert(avc->to > from);\t\t\t/* Overlaps with `ac' */\n\n\t\t\tif (avc->from == from) {\n\t\t\t\t/* Case #2, or case #0 with matching start */\n\t\t\t\tavc->sources += ac->sources;\t/* For the common part */\n\n\t\t\t\tif (avc->to > ac->to)\t\t\t/* `avc' longer than `ac' */\n\t\t\t\t\tavc->to = ac->to;\t\t\t/* Extra part added below */\n\t\t\t} else {\n\t\t\t\t/* Not case #2 */\n\t\t\t\tavc->to = from;\t\t\t\t\t/* Truncates `avc' */\n\n\t\t\t\t/*\n\t\t\t\t * Insert the common part with added source counts.\n\t\t\t\t */\n\n\t\t\t\tanew = dl_avail_chunk_new(from, to, ac->sources + avc->sources);\n\t\t\t\trbtree_insert(arbt, anew);\n\n\t\t\t\tavc = rbtree_next_node(arbt, &node);\n\t\t\t\tg_soft_assert(avc == anew);\t\t/* The chunk we just inserted */\n\t\t\t}\n\n\t\t\t/* Handle rightmost part of cases #2 and #3 */\n\n\t\t\tif (avc_to > to) {\n\t\t\t\tanew = dl_avail_chunk_new(to, avc_to, sources);\n\t\t\t\trbtree_insert(arbt, anew);\n\n\t\t\t\tavc = rbtree_next_node(arbt, &node);\n\t\t\t\tg_soft_assert(avc == anew);\t\n\n\t\t\t\tbreak;\t\t/* We've consumed the whole `ac' */\n\t\t\t}\n\n\t\t\tfrom = to;\n\t\t}\n\t} while (from < ac->to);\n}",
"label": 0,
"cwe": null,
"length": 1052
},
{
"index": 646087,
"code": "cx18_av_initialize(struct v4l2_subdev *sd)\n{\n\tstruct cx18_av_state *state = to_cx18_av_state(sd);\n\tstruct cx18 *cx = v4l2_get_subdevdata(sd);\n\tint default_volume;\n\tu32 v;\n\n\tcx18_av_loadfw(cx);\n\t/* Stop 8051 code execution */\n\tcx18_av_write4_expect(cx, CXADEC_DL_CTL, 0x03000000,\n\t\t\t\t\t\t 0x03000000, 0x13000000);\n\n\t/* initallize the PLL by toggling sleep bit */\n\tv = cx18_av_read4(cx, CXADEC_HOST_REG1);\n\t/* enable sleep mode - register appears to be read only... */\n\tcx18_av_write4_expect(cx, CXADEC_HOST_REG1, v | 1, v, 0xfffe);\n\t/* disable sleep mode */\n\tcx18_av_write4_expect(cx, CXADEC_HOST_REG1, v & 0xfffe,\n\t\t\t\t\t\t v & 0xfffe, 0xffff);\n\n\t/* initialize DLLs */\n\tv = cx18_av_read4(cx, CXADEC_DLL1_DIAG_CTRL) & 0xE1FFFEFF;\n\t/* disable FLD */\n\tcx18_av_write4(cx, CXADEC_DLL1_DIAG_CTRL, v);\n\t/* enable FLD */\n\tcx18_av_write4(cx, CXADEC_DLL1_DIAG_CTRL, v | 0x10000100);\n\n\tv = cx18_av_read4(cx, CXADEC_DLL2_DIAG_CTRL) & 0xE1FFFEFF;\n\t/* disable FLD */\n\tcx18_av_write4(cx, CXADEC_DLL2_DIAG_CTRL, v);\n\t/* enable FLD */\n\tcx18_av_write4(cx, CXADEC_DLL2_DIAG_CTRL, v | 0x06000100);\n\n\t/* set analog bias currents. Set Vreg to 1.20V. */\n\tcx18_av_write4(cx, CXADEC_AFE_DIAG_CTRL1, 0x000A1802);\n\n\tv = cx18_av_read4(cx, CXADEC_AFE_DIAG_CTRL3) | 1;\n\t/* enable TUNE_FIL_RST */\n\tcx18_av_write4_expect(cx, CXADEC_AFE_DIAG_CTRL3, v, v, 0x03009F0F);\n\t/* disable TUNE_FIL_RST */\n\tcx18_av_write4_expect(cx, CXADEC_AFE_DIAG_CTRL3,\n\t\t\t v & 0xFFFFFFFE, v & 0xFFFFFFFE, 0x03009F0F);\n\n\t/* enable 656 output */\n\tcx18_av_and_or4(cx, CXADEC_PIN_CTRL1, ~0, 0x040C00);\n\n\t/* video output drive strength */\n\tcx18_av_and_or4(cx, CXADEC_PIN_CTRL2, ~0, 0x2);\n\n\t/* reset video */\n\tcx18_av_write4(cx, CXADEC_SOFT_RST_CTRL, 0x8000);\n\tcx18_av_write4(cx, CXADEC_SOFT_RST_CTRL, 0);\n\n\t/*\n\t * Disable Video Auto-config of the Analog Front End and Video PLL.\n\t *\n\t * Since we only use BT.656 pixel mode, which works for both 525 and 625\n\t * line systems, it's just easier for us to set registers\n\t * 0x102 (CXADEC_CHIP_CTRL), 0x104-0x106 (CXADEC_AFE_CTRL),\n\t * 0x108-0x109 (CXADEC_PLL_CTRL1), and 0x10c-0x10f (CXADEC_VID_PLL_FRAC)\n\t * ourselves, than to run around cleaning up after the auto-config.\n\t *\n\t * (Note: my CX23418 chip doesn't seem to let the ACFG_DIS bit\n\t * get set to 1, but OTOH, it doesn't seem to do AFE and VID PLL\n\t * autoconfig either.)\n\t *\n\t * As a default, also turn off Dual mode for ADC2 and set ADC2 to CH3.\n\t */\n\tcx18_av_and_or4(cx, CXADEC_CHIP_CTRL, 0xFFFBFFFF, 0x00120000);\n\n\t/* Setup the Video and and Aux/Audio PLLs */\n\tcx18_av_init(cx);\n\n\t/* set video to auto-detect */\n\t/* Clear bits 11-12 to enable slow locking mode. Set autodetect mode */\n\t/* set the comb notch = 1 */\n\tcx18_av_and_or4(cx, CXADEC_MODE_CTRL, 0xFFF7E7F0, 0x02040800);\n\n\t/* Enable wtw_en in CRUSH_CTRL (Set bit 22) */\n\t/* Enable maj_sel in CRUSH_CTRL (Set bit 20) */\n\tcx18_av_and_or4(cx, CXADEC_CRUSH_CTRL, ~0, 0x00500000);\n\n\t/* Set VGA_TRACK_RANGE to 0x20 */\n\tcx18_av_and_or4(cx, CXADEC_DFE_CTRL2, 0xFFFF00FF, 0x00002000);\n\n\t/*\n\t * Initial VBI setup\n\t * VIP-1.1, 10 bit mode, enable Raw, disable sliced,\n\t * don't clamp raw samples when codes are in use, 1 byte user D-words,\n\t * IDID0 has line #, RP code V bit transition on VBLANK, data during\n\t * blanking intervals\n\t */\n\tcx18_av_write4(cx, CXADEC_OUT_CTRL1, 0x4013252e);\n\n\t/* Set the video input.\n\t The setting in MODE_CTRL gets lost when we do the above setup */\n\t/* EncSetSignalStd(dwDevNum, pEnc->dwSigStd); */\n\t/* EncSetVideoInput(dwDevNum, pEnc->VidIndSelection); */\n\n\t/*\n\t * Analog Front End (AFE)\n\t * Default to luma on ch1/ADC1, chroma on ch2/ADC2, SIF on ch3/ADC2\n\t * bypass_ch[1-3] use filter\n\t * droop_comp_ch[1-3] disable\n\t * clamp_en_ch[1-3] disable\n\t * aud_in_sel ADC2\n\t * luma_in_sel ADC1\n\t * chroma_in_sel ADC2\n\t * clamp_sel_ch[2-3] midcode\n\t * clamp_sel_ch1 video decoder\n\t * vga_sel_ch3 audio decoder\n\t * vga_sel_ch[1-2] video decoder\n\t * half_bw_ch[1-3] disable\n\t * +12db_ch[1-3] disable\n\t */\n\tcx18_av_and_or4(cx, CXADEC_AFE_CTRL, 0xFF000000, 0x00005D00);\n\n/* \tif(dwEnable && dw3DCombAvailable) { */\n/* \tCxDevWrReg(CXADEC_SRC_COMB_CFG, 0x7728021F); */\n/* } else { */\n/* \tCxDevWrReg(CXADEC_SRC_COMB_CFG, 0x6628021F); */\n/* } */\n\tcx18_av_write4(cx, CXADEC_SRC_COMB_CFG, 0x6628021F);\n\tdefault_volume = cx18_av_read(cx, 0x8d4);\n\t/*\n\t * Enforce the legacy volume scale mapping limits to avoid\n\t * -ERANGE errors when initializing the volume control\n\t */\n\tif (default_volume > 228) {\n\t\t/* Bottom out at -96 dB, v4l2 vol range 0x2e00-0x2fff */\n\t\tdefault_volume = 228;\n\t\tcx18_av_write(cx, 0x8d4, 228);\n\t} else if (default_volume < 20) {\n\t\t/* Top out at + 8 dB, v4l2 vol range 0xfe00-0xffff */\n\t\tdefault_volume = 20;\n\t\tcx18_av_write(cx, 0x8d4, 20);\n\t}\n\tdefault_volume = (((228 - default_volume) >> 1) + 23) << 9;\n\tstate->volume->cur.val = state->volume->default_value = default_volume;\n\tv4l2_ctrl_handler_setup(&state->hdl);\n}",
"label": 0,
"cwe": null,
"length": 1802
},
{
"index": 870134,
"code": "reset_hfcpci(struct IsdnCardState *cs)\n{\n\tpci_write_config_word(cs->hw.hfcpci.dev, PCI_COMMAND, PCI_ENA_MEMIO);\t/* enable memory mapped ports, disable busmaster */\n\tcs->hw.hfcpci.int_m2 = 0;\t/* interrupt output off ! */\n\tWrite_hfc(cs, HFCPCI_INT_M2, cs->hw.hfcpci.int_m2);\n\n\tprintk(KERN_INFO \"HFC_PCI: resetting card\\n\");\n\tpci_write_config_word(cs->hw.hfcpci.dev, PCI_COMMAND, PCI_ENA_MEMIO + PCI_ENA_MASTER);\t/* enable memory ports + busmaster */\n\tWrite_hfc(cs, HFCPCI_CIRM, HFCPCI_RESET);\t/* Reset On */\n\tmdelay(10);\n\tWrite_hfc(cs, HFCPCI_CIRM, 0);\t/* Reset Off */\n\tmdelay(10);\n\tif (Read_hfc(cs, HFCPCI_STATUS) & 2)\n\t\tprintk(KERN_WARNING \"HFC-PCI init bit busy\\n\");\n\n\tcs->hw.hfcpci.fifo_en = 0x30;\t/* only D fifos enabled */\n\tWrite_hfc(cs, HFCPCI_FIFO_EN, cs->hw.hfcpci.fifo_en);\n\n\tcs->hw.hfcpci.trm = 0 + HFCPCI_BTRANS_THRESMASK;\t/* no echo connect , threshold */\n\tWrite_hfc(cs, HFCPCI_TRM, cs->hw.hfcpci.trm);\n\n\tWrite_hfc(cs, HFCPCI_CLKDEL, CLKDEL_TE); /* ST-Bit delay for TE-Mode */\n\tcs->hw.hfcpci.sctrl_e = HFCPCI_AUTO_AWAKE;\n\tWrite_hfc(cs, HFCPCI_SCTRL_E, cs->hw.hfcpci.sctrl_e);\t/* S/T Auto awake */\n\tcs->hw.hfcpci.bswapped = 0;\t/* no exchange */\n\tcs->hw.hfcpci.nt_mode = 0;\t/* we are in TE mode */\n\tcs->hw.hfcpci.ctmt = HFCPCI_TIM3_125 | HFCPCI_AUTO_TIMER;\n\tWrite_hfc(cs, HFCPCI_CTMT, cs->hw.hfcpci.ctmt);\n\n\tcs->hw.hfcpci.int_m1 = HFCPCI_INTS_DTRANS | HFCPCI_INTS_DREC |\n\t\tHFCPCI_INTS_L1STATE | HFCPCI_INTS_TIMER;\n\tWrite_hfc(cs, HFCPCI_INT_M1, cs->hw.hfcpci.int_m1);\n\n\t/* Clear already pending ints */\n\tif (Read_hfc(cs, HFCPCI_INT_S1));\n\n\tWrite_hfc(cs, HFCPCI_STATES, HFCPCI_LOAD_STATE | 2);\t/* HFC ST 2 */\n\tudelay(10);\n\tWrite_hfc(cs, HFCPCI_STATES, 2);\t/* HFC ST 2 */\n\tcs->hw.hfcpci.mst_m = HFCPCI_MASTER;\t/* HFC Master Mode */\n\n\tWrite_hfc(cs, HFCPCI_MST_MODE, cs->hw.hfcpci.mst_m);\n\tcs->hw.hfcpci.sctrl = 0x40;\t/* set tx_lo mode, error in datasheet ! */\n\tWrite_hfc(cs, HFCPCI_SCTRL, cs->hw.hfcpci.sctrl);\n\tcs->hw.hfcpci.sctrl_r = 0;\n\tWrite_hfc(cs, HFCPCI_SCTRL_R, cs->hw.hfcpci.sctrl_r);\n\n\t/* Init GCI/IOM2 in master mode */\n\t/* Slots 0 and 1 are set for B-chan 1 and 2 */\n\t/* D- and monitor/CI channel are not enabled */\n\t/* STIO1 is used as output for data, B1+B2 from ST->IOM+HFC */\n\t/* STIO2 is used as data input, B1+B2 from IOM->ST */\n\t/* ST B-channel send disabled -> continuous 1s */\n\t/* The IOM slots are always enabled */\n\tcs->hw.hfcpci.conn = 0x36;\t/* set data flow directions */\n\tWrite_hfc(cs, HFCPCI_CONNECT, cs->hw.hfcpci.conn);\n\tWrite_hfc(cs, HFCPCI_B1_SSL, 0x80);\t/* B1-Slot 0 STIO1 out enabled */\n\tWrite_hfc(cs, HFCPCI_B2_SSL, 0x81);\t/* B2-Slot 1 STIO1 out enabled */\n\tWrite_hfc(cs, HFCPCI_B1_RSL, 0x80);\t/* B1-Slot 0 STIO2 in enabled */\n\tWrite_hfc(cs, HFCPCI_B2_RSL, 0x81);\t/* B2-Slot 1 STIO2 in enabled */\n\n\t/* Finally enable IRQ output */\n\tcs->hw.hfcpci.int_m2 = HFCPCI_IRQ_ENABLE;\n\tWrite_hfc(cs, HFCPCI_INT_M2, cs->hw.hfcpci.int_m2);\n\tif (Read_hfc(cs, HFCPCI_INT_S1));\n}",
"label": 0,
"cwe": null,
"length": 1066
},
{
"index": 832088,
"code": "print_header(void)\n#else\nvoid print_header()\n#endif\n{\n\tif(Eflag)\n\t{\n \t if(!silent) printf(CONTROL_STRING2,\n\t\t\" \", \n\t\t\" \",\n\t\t\" \",\n\t\t\" \",\n\t\t\" \",\n\t\t\" \",\n\t\t\"random\",\t\t\t/*kcollins:2-5-96*/\n\t\t\"random\",\t\t\t/*kcollins:2-5-96*/\n\t\t\"bkwd\",\n\t\t\"record\",\n\t\t\"stride\",\n\t\t\" \",\n\t\t\" \",\n\t\t\" \",\n\t\t\" \"\n#ifdef HAVE_PREAD\n\t\t,\" \",\n\t\t\" \",\n\t\t\" \",\n\t\t\" \"\n#ifdef HAVE_PREADV\n\t\t,\" \",\n\t\t\" \",\n\t\t\" \",\n\t\t\" \"\n#endif\n#endif\n\t\t);\n \tif(!silent) printf(CONTROL_STRING2,\n\t\t\"KB\", \n\t\t\"reclen\",\n\t\t\"write\",\n\t\t\"rewrite\",\n\t\t\"read\",\n\t\t\"reread\",\n\t\t\"read\",\t\t\t\t/*kcollins:2-5-96*/\n\t\t\"write\",\t\t\t/*kcollins:2-5-96*/\n\t\t\"read\",\n\t\t\"rewrite\",\n\t\t\"read\",\n\t\t\"fwrite\",\n\t\t\"frewrite\",\n\t\t\"fread\",\n\t\t\"freread\"\n#ifdef HAVE_PREAD\n\t\t,\"pwrite\",\n\t\t\"repwrite\",\n\t\t\"pread\",\n\t\t\"repread\"\n#ifdef HAVE_PREADV\n\t\t,\"pwritev\",\n\t\t\"repwritev\",\n\t\t\"preadv\",\n\t\t\"repreadv\"\n#endif\n#endif\n\t\t);\n\t}else \n\tif(RWONLYflag){\t\t\t\t/*kcollins 8-21-96*/\n \t if(!silent) printf(CONTROL_STRING4,\t\t/*kcollins 8-21-96*/\n\t\t\" \", \t\t\t\t/*kcollins 8-21-96*/\n\t\t\" \",\t\t\t\t/*kcollins 8-21-96*/\n\t\t\" \",\t\t\t\t/*kcollins 8-21-96*/\n\t\t\" \",\t\t\t\t/*kcollins 8-21-96*/\n\t\t\" \",\t\t\t\t/*kcollins 8-21-96*/\n\t\t\" \"\t\t\t\t/*kcollins 8-21-96*/\n\t\t);\t\t\t\t/*kcollins 8-21-96*/\n \tif(!silent) printf(CONTROL_STRING4,\t\t\t/*kcollins 8-21-96*/\n\t\t\"KB\", \t\t\t\t/*kcollins 8-21-96*/\n\t\t\"reclen\",\t\t\t/*kcollins 8-21-96*/\n\t\t\"write\",\t\t\t/*kcollins 8-21-96*/\n\t\t\"rewrite\",\t\t\t/*kcollins 8-21-96*/\n\t\t\"read\",\t\t\t\t/*kcollins 8-21-96*/\n\t\t\"reread\"\t\t\t/*kcollins 8-21-96*/\n\t\t);\t\t\t\t/*kcollins 8-21-96*/\n\t}else{\n\t if(!(mmapflag || async_flag))\n\t {\n \t \tif(!silent) printf(CONTROL_STRING3,\n\t\t\t\" \", \n\t\t\t\" \",\n\t\t\t\" \",\n\t\t\t\" \",\n\t\t\t\" \",\n\t\t\t\" \",\n\t\t\t\"random\",\t\t\t/*kcollins:2-5-96*/\n\t\t\t\"random\",\t\t\t/*kcollins:2-5-96*/\n\t\t\t\"bkwd\",\n\t\t\t\"record\",\n\t\t\t\"stride\",\n\t\t\t\"\",\n\t\t\t\"\",\n\t\t\t\"\",\n\t\t\t\"\"\n\t\t\t);\n \t\tif(!silent) printf(CONTROL_STRING3,\n\t\t\t\"KB\", \n\t\t\t\"reclen\",\n\t\t\t\"write\",\n\t\t\t\"rewrite\",\n\t\t\t\"read\",\n\t\t\t\"reread\",\n\t\t\t\"read\",\t\t\t\t/*kcollins:2-5-96*/\n\t\t\t\"write\",\t\t\t/*kcollins:2-5-96*/\n\t\t\t\"read\",\n\t\t\t\"rewrite\",\n\t\t\t\"read\",\n\t\t\t\"fwrite\",\n\t\t\t\"frewrite\",\n\t\t\t\"fread\",\n\t\t\t\"freread\" \n\t\t\t);\n\t\t}else\n\t\t{\n \t \t\tif(!silent) printf(CONTROL_STRING3,\n\t\t\t\t\" \", \n\t\t\t\t\" \",\n\t\t\t\t\" \",\n\t\t\t\t\" \",\n\t\t\t\t\" \",\n\t\t\t\t\" \",\n\t\t\t\t\"random\",\t\t\t/*kcollins:2-5-96*/\n\t\t\t\t\"random\",\t\t\t/*kcollins:2-5-96*/\n\t\t\t\t\"bkwd\",\n\t\t\t\t\"record\",\n\t\t\t\t\"stride\",\n\t\t\t\t\"\",\n\t\t\t\t\"\",\n\t\t\t\t\"\",\n\t\t\t\t\"\"\n\t\t\t\t);\n \t\t\tif(!silent) printf(CONTROL_STRING3,\n\t\t\t\t\"KB\", \n\t\t\t\t\"reclen\",\n\t\t\t\t\"write\",\n\t\t\t\t\"rewrite\",\n\t\t\t\t\"read\",\n\t\t\t\t\"reread\",\n\t\t\t\t\"read\",\t\t\t\t/*kcollins:2-5-96*/\n\t\t\t\t\"write\",\t\t\t/*kcollins:2-5-96*/\n\t\t\t\t\"read\",\n\t\t\t\t\"rewrite\",\n\t\t\t\t\"read\",\n\t\t\t\t\"\",\n\t\t\t\t\"\",\n\t\t\t\t\"\",\n\t\t\t\t\"\" \n\t\t\t\t);\n\t\t}\n\t}\n}",
"label": 0,
"cwe": null,
"length": 1150
},
{
"index": 52144,
"code": "do_rx_data_ddp(struct cxgbi_device *cdev,\n\t\t\t\t struct sk_buff *skb)\n{\n\tstruct cxgbi_sock *csk;\n\tstruct sk_buff *lskb;\n\tstruct cpl_rx_data_ddp *rpl = (struct cpl_rx_data_ddp *)skb->data;\n\tunsigned int tid = GET_TID(rpl);\n\tstruct cxgb4_lld_info *lldi = cxgbi_cdev_priv(cdev);\n\tstruct tid_info *t = lldi->tids;\n\tunsigned int status = ntohl(rpl->ddpvld);\n\n\tcsk = lookup_tid(t, tid);\n\tif (unlikely(!csk)) {\n\t\tpr_err(\"can't find connection for tid %u.\\n\", tid);\n\t\tgoto rel_skb;\n\t}\n\n\tlog_debug(1 << CXGBI_DBG_TOE | 1 << CXGBI_DBG_PDU_RX,\n\t\t\"csk 0x%p,%u,0x%lx, skb 0x%p,0x%x, lhdr 0x%p.\\n\",\n\t\tcsk, csk->state, csk->flags, skb, status, csk->skb_ulp_lhdr);\n\n\tspin_lock_bh(&csk->lock);\n\n\tif (unlikely(csk->state >= CTP_PASSIVE_CLOSE)) {\n\t\tlog_debug(1 << CXGBI_DBG_TOE | 1 << CXGBI_DBG_SOCK,\n\t\t\t\"csk 0x%p,%u,0x%lx,%u, bad state.\\n\",\n\t\t\tcsk, csk->state, csk->flags, csk->tid);\n\t\tif (csk->state != CTP_ABORTING)\n\t\t\tgoto abort_conn;\n\t\telse\n\t\t\tgoto discard;\n\t}\n\n\tif (!csk->skb_ulp_lhdr) {\n\t\tpr_err(\"tid 0x%x, rcv RX_DATA_DDP w/o pdu bhs.\\n\", csk->tid);\n\t\tgoto abort_conn;\n\t}\n\n\tlskb = csk->skb_ulp_lhdr;\n\tcsk->skb_ulp_lhdr = NULL;\n\n\tcxgbi_skcb_rx_ddigest(lskb) = ntohl(rpl->ulp_crc);\n\n\tif (ntohs(rpl->len) != cxgbi_skcb_rx_pdulen(lskb))\n\t\tpr_info(\"tid 0x%x, RX_DATA_DDP pdulen %u != %u.\\n\",\n\t\t\tcsk->tid, ntohs(rpl->len), cxgbi_skcb_rx_pdulen(lskb));\n\n\tif (status & (1 << CPL_RX_DDP_STATUS_HCRC_SHIFT)) {\n\t\tpr_info(\"csk 0x%p, lhdr 0x%p, status 0x%x, hcrc bad 0x%lx.\\n\",\n\t\t\tcsk, lskb, status, cxgbi_skcb_flags(lskb));\n\t\tcxgbi_skcb_set_flag(lskb, SKCBF_RX_HCRC_ERR);\n\t}\n\tif (status & (1 << CPL_RX_DDP_STATUS_DCRC_SHIFT)) {\n\t\tpr_info(\"csk 0x%p, lhdr 0x%p, status 0x%x, dcrc bad 0x%lx.\\n\",\n\t\t\tcsk, lskb, status, cxgbi_skcb_flags(lskb));\n\t\tcxgbi_skcb_set_flag(lskb, SKCBF_RX_DCRC_ERR);\n\t}\n\tif (status & (1 << CPL_RX_DDP_STATUS_PAD_SHIFT)) {\n\t\tlog_debug(1 << CXGBI_DBG_PDU_RX,\n\t\t\t\"csk 0x%p, lhdr 0x%p, status 0x%x, pad bad.\\n\",\n\t\t\tcsk, lskb, status);\n\t\tcxgbi_skcb_set_flag(lskb, SKCBF_RX_PAD_ERR);\n\t}\n\tif ((status & (1 << CPL_RX_DDP_STATUS_DDP_SHIFT)) &&\n\t\t!cxgbi_skcb_test_flag(lskb, SKCBF_RX_DATA)) {\n\t\tlog_debug(1 << CXGBI_DBG_PDU_RX,\n\t\t\t\"csk 0x%p, lhdr 0x%p, 0x%x, data ddp'ed.\\n\",\n\t\t\tcsk, lskb, status);\n\t\tcxgbi_skcb_set_flag(lskb, SKCBF_RX_DATA_DDPD);\n\t}\n\tlog_debug(1 << CXGBI_DBG_PDU_RX,\n\t\t\"csk 0x%p, lskb 0x%p, f 0x%lx.\\n\",\n\t\tcsk, lskb, cxgbi_skcb_flags(lskb));\n\n\tcxgbi_skcb_set_flag(lskb, SKCBF_RX_STATUS);\n\tcxgbi_conn_pdu_ready(csk);\n\tspin_unlock_bh(&csk->lock);\n\tgoto rel_skb;\n\nabort_conn:\n\tsend_abort_req(csk);\ndiscard:\n\tspin_unlock_bh(&csk->lock);\nrel_skb:\n\t__kfree_skb(skb);\n}",
"label": 0,
"cwe": null,
"length": 1036
},
{
"index": 563783,
"code": "dict_check_tablespaces_and_store_max_id(\n/*====================================*/\n\tibool\tin_crash_recovery)\t/*!< in: are we doing a crash recovery */\n{\n\tdict_table_t*\tsys_tables;\n\tdict_index_t*\tsys_index;\n\tbtr_pcur_t\tpcur;\n\tconst rec_t*\trec;\n\tulint\t\tmax_space_id;\n\tmtr_t\t\tmtr;\n\n\tmutex_enter(&(dict_sys->mutex));\n\n\tmtr_start(&mtr);\n\n\tsys_tables = dict_table_get_low(\"SYS_TABLES\", DICT_ERR_IGNORE_NONE);\n\tsys_index = UT_LIST_GET_FIRST(sys_tables->indexes);\n\tut_a(!dict_table_is_comp(sys_tables));\n\n\tmax_space_id = mtr_read_ulint(dict_hdr_get(&mtr)\n\t\t\t\t + DICT_HDR_MAX_SPACE_ID,\n\t\t\t\t MLOG_4BYTES, &mtr);\n\tfil_set_max_space_id_if_bigger(max_space_id);\n\n\tbtr_pcur_open_at_index_side(TRUE, sys_index, BTR_SEARCH_LEAF, &pcur,\n\t\t\t\t TRUE, &mtr);\nloop:\n\tbtr_pcur_move_to_next_user_rec(&pcur, &mtr);\n\n\trec = btr_pcur_get_rec(&pcur);\n\n\tif (!btr_pcur_is_on_user_rec(&pcur)) {\n\t\t/* end of index */\n\n\t\tbtr_pcur_close(&pcur);\n\t\tmtr_commit(&mtr);\n\n\t\t/* We must make the tablespace cache aware of the biggest\n\t\tknown space id */\n\n\t\t/* printf(\"Biggest space id in data dictionary %lu\\n\",\n\t\tmax_space_id); */\n\t\tfil_set_max_space_id_if_bigger(max_space_id);\n\n\t\tmutex_exit(&(dict_sys->mutex));\n\n\t\treturn;\n\t}\n\n\tif (!rec_get_deleted_flag(rec, 0)) {\n\n\t\t/* We found one */\n\t\tconst byte*\tfield;\n\t\tulint\t\tlen;\n\t\tulint\t\tspace_id;\n\t\tulint\t\tflags;\n\t\tchar*\t\tname;\n\n\t\tfield = rec_get_nth_field_old(rec, 0, &len);\n\t\tname = mem_strdupl((char*) field, len);\n\n\t\tflags = dict_sys_tables_get_flags(rec);\n\t\tif (UNIV_UNLIKELY(flags == ULINT_UNDEFINED)) {\n\n\t\t\tfield = rec_get_nth_field_old(rec, 5, &len);\n\t\t\tflags = mach_read_from_4(field);\n\n\t\t\tut_print_timestamp(stderr);\n\t\t\tfputs(\" InnoDB: Error: table \", stderr);\n\t\t\tut_print_filename(stderr, name);\n\t\t\tfprintf(stderr, \"\\n\"\n\t\t\t\t\"InnoDB: in InnoDB data dictionary\"\n\t\t\t\t\" has unknown type %lx.\\n\",\n\t\t\t\t(ulong) flags);\n\n\t\t\tgoto loop;\n\t\t}\n\n\t\tfield = rec_get_nth_field_old(rec, 9, &len);\n\t\tut_a(len == 4);\n\n\t\tspace_id = mach_read_from_4(field);\n\n\t\tbtr_pcur_store_position(&pcur, &mtr);\n\n\t\tmtr_commit(&mtr);\n\n\t\tif (space_id == 0) {\n\t\t\t/* The system tablespace always exists. */\n\t\t} else if (in_crash_recovery) {\n\t\t\t/* Check that the tablespace (the .ibd file) really\n\t\t\texists; print a warning to the .err log if not.\n\t\t\tDo not print warnings for temporary tables. */\n\t\t\tibool\tis_temp;\n\n\t\t\tfield = rec_get_nth_field_old(rec, 4, &len);\n\t\t\tif (0x80000000UL & mach_read_from_4(field)) {\n\t\t\t\t/* ROW_FORMAT=COMPACT: read the is_temp\n\t\t\t\tflag from SYS_TABLES.MIX_LEN. */\n\t\t\t\tfield = rec_get_nth_field_old(rec, 7, &len);\n\t\t\t\tis_temp = mach_read_from_4(field)\n\t\t\t\t\t& DICT_TF2_TEMPORARY;\n\t\t\t} else {\n\t\t\t\t/* For tables created with old versions\n\t\t\t\tof InnoDB, SYS_TABLES.MIX_LEN may contain\n\t\t\t\tgarbage. Such tables would always be\n\t\t\t\tin ROW_FORMAT=REDUNDANT. Pretend that\n\t\t\t\tall such tables are non-temporary. That is,\n\t\t\t\tdo not suppress error printouts about\n\t\t\t\ttemporary tables not being found. */\n\t\t\t\tis_temp = FALSE;\n\t\t\t}\n\n\t\t\tfil_space_for_table_exists_in_mem(\n\t\t\t\tspace_id, name, is_temp, TRUE, !is_temp);\n\t\t} else {\n\t\t\t/* It is a normal database startup: create the space\n\t\t\tobject and check that the .ibd file exists. */\n\n\t\t\tfil_open_single_table_tablespace(FALSE, space_id,\n\t\t\t\t\t\t\t flags, name);\n\t\t}\n\n\t\tmem_free(name);\n\n\t\tif (space_id > max_space_id) {\n\t\t\tmax_space_id = space_id;\n\t\t}\n\n\t\tmtr_start(&mtr);\n\n\t\tbtr_pcur_restore_position(BTR_SEARCH_LEAF, &pcur, &mtr);\n\t}\n\n\tgoto loop;\n}",
"label": 0,
"cwe": null,
"length": 1041
},
{
"index": 661352,
"code": "tulip_find_mii(struct net_device *dev, int board_idx)\n{\n\tstruct tulip_private *tp = netdev_priv(dev);\n\tint phyn, phy_idx = 0;\n\tint mii_reg0;\n\tint mii_advert;\n\tunsigned int to_advert, new_bmcr, ane_switch;\n\n\t/* Find the connected MII xcvrs.\n\t Doing this in open() would allow detecting external xcvrs later,\n\t but takes much time. */\n\tfor (phyn = 1; phyn <= 32 && phy_idx < ARRAY_SIZE(tp->phys); phyn++) {\n\t\tint phy = phyn & 0x1f;\n\t\tint mii_status = tulip_mdio_read (dev, phy, MII_BMSR);\n\t\tif ((mii_status & 0x8301) == 0x8001 ||\n\t\t ((mii_status & BMSR_100BASE4) == 0 &&\n\t\t (mii_status & 0x7800) != 0)) {\n\t\t\t/* preserve Becker logic, gain indentation level */\n\t\t} else {\n\t\t\tcontinue;\n\t\t}\n\n\t\tmii_reg0 = tulip_mdio_read (dev, phy, MII_BMCR);\n\t\tmii_advert = tulip_mdio_read (dev, phy, MII_ADVERTISE);\n\t\tane_switch = 0;\n\n\t\t/* if not advertising at all, gen an\n\t\t * advertising value from the capability\n\t\t * bits in BMSR\n\t\t */\n\t\tif ((mii_advert & ADVERTISE_ALL) == 0) {\n\t\t\tunsigned int tmpadv = tulip_mdio_read (dev, phy, MII_BMSR);\n\t\t\tmii_advert = ((tmpadv >> 6) & 0x3e0) | 1;\n\t\t}\n\n\t\tif (tp->mii_advertise) {\n\t\t\ttp->advertising[phy_idx] =\n\t\t\tto_advert = tp->mii_advertise;\n\t\t} else if (tp->advertising[phy_idx]) {\n\t\t\tto_advert = tp->advertising[phy_idx];\n\t\t} else {\n\t\t\ttp->advertising[phy_idx] =\n\t\t\ttp->mii_advertise =\n\t\t\tto_advert = mii_advert;\n\t\t}\n\n\t\ttp->phys[phy_idx++] = phy;\n\n\t\tpr_info(\"tulip%d: MII transceiver #%d config %04x status %04x advertising %04x\\n\",\n\t\t\tboard_idx, phy, mii_reg0, mii_status, mii_advert);\n\n\t\t/* Fixup for DLink with miswired PHY. */\n\t\tif (mii_advert != to_advert) {\n\t\t\tpr_debug(\"tulip%d: Advertising %04x on PHY %d, previously advertising %04x\\n\",\n\t\t\t\t board_idx, to_advert, phy, mii_advert);\n\t\t\ttulip_mdio_write (dev, phy, 4, to_advert);\n\t\t}\n\n\t\t/* Enable autonegotiation: some boards default to off. */\n\t\tif (tp->default_port == 0) {\n\t\t\tnew_bmcr = mii_reg0 | BMCR_ANENABLE;\n\t\t\tif (new_bmcr != mii_reg0) {\n\t\t\t\tnew_bmcr |= BMCR_ANRESTART;\n\t\t\t\tane_switch = 1;\n\t\t\t}\n\t\t}\n\t\t/* ...or disable nway, if forcing media */\n\t\telse {\n\t\t\tnew_bmcr = mii_reg0 & ~BMCR_ANENABLE;\n\t\t\tif (new_bmcr != mii_reg0)\n\t\t\t\tane_switch = 1;\n\t\t}\n\n\t\t/* clear out bits we never want at this point */\n\t\tnew_bmcr &= ~(BMCR_CTST | BMCR_FULLDPLX | BMCR_ISOLATE |\n\t\t\t BMCR_PDOWN | BMCR_SPEED100 | BMCR_LOOPBACK |\n\t\t\t BMCR_RESET);\n\n\t\tif (tp->full_duplex)\n\t\t\tnew_bmcr |= BMCR_FULLDPLX;\n\t\tif (tulip_media_cap[tp->default_port] & MediaIs100)\n\t\t\tnew_bmcr |= BMCR_SPEED100;\n\n\t\tif (new_bmcr != mii_reg0) {\n\t\t\t/* some phys need the ANE switch to\n\t\t\t * happen before forced media settings\n\t\t\t * will \"take.\" However, we write the\n\t\t\t * same value twice in order not to\n\t\t\t * confuse the sane phys.\n\t\t\t */\n\t\t\tif (ane_switch) {\n\t\t\t\ttulip_mdio_write (dev, phy, MII_BMCR, new_bmcr);\n\t\t\t\tudelay (10);\n\t\t\t}\n\t\t\ttulip_mdio_write (dev, phy, MII_BMCR, new_bmcr);\n\t\t}\n\t}\n\ttp->mii_cnt = phy_idx;\n\tif (tp->mtable && tp->mtable->has_mii && phy_idx == 0) {\n\t\tpr_info(\"tulip%d: ***WARNING***: No MII transceiver found!\\n\",\n\t\t\tboard_idx);\n\t\ttp->phys[0] = 1;\n\t}\n}",
"label": 0,
"cwe": null,
"length": 1077
},
{
"index": 858512,
"code": "dwarf2out_decl (tree decl)\n{\n dw_die_ref context_die = comp_unit_die ();\n\n switch (TREE_CODE (decl))\n {\n case ERROR_MARK:\n return;\n\n case FUNCTION_DECL:\n /* What we would really like to do here is to filter out all mere\n\t file-scope declarations of file-scope functions which are never\n\t referenced later within this translation unit (and keep all of ones\n\t that *are* referenced later on) but we aren't clairvoyant, so we have\n\t no idea which functions will be referenced in the future (i.e. later\n\t on within the current translation unit). So here we just ignore all\n\t file-scope function declarations which are not also definitions. If\n\t and when the debugger needs to know something about these functions,\n\t it will have to hunt around and find the DWARF information associated\n\t with the definition of the function.\n\n\t We can't just check DECL_EXTERNAL to find out which FUNCTION_DECL\n\t nodes represent definitions and which ones represent mere\n\t declarations. We have to check DECL_INITIAL instead. That's because\n\t the C front-end supports some weird semantics for \"extern inline\"\n\t function definitions. These can get inlined within the current\n\t translation unit (and thus, we need to generate Dwarf info for their\n\t abstract instances so that the Dwarf info for the concrete inlined\n\t instances can have something to refer to) but the compiler never\n\t generates any out-of-lines instances of such things (despite the fact\n\t that they *are* definitions).\n\n\t The important point is that the C front-end marks these \"extern\n\t inline\" functions as DECL_EXTERNAL, but we need to generate DWARF for\n\t them anyway. Note that the C++ front-end also plays some similar games\n\t for inline function definitions appearing within include files which\n\t also contain `#pragma interface' pragmas.\n\n\t If we are called from dwarf2out_abstract_function output a DIE\n\t anyway. We can end up here this way with early inlining and LTO\n\t where the inlined function is output in a different LTRANS unit\n\t or not at all. */\n if (DECL_INITIAL (decl) == NULL_TREE\n\t && ! DECL_ABSTRACT (decl))\n\treturn;\n\n /* If we're a nested function, initially use a parent of NULL; if we're\n\t a plain function, this will be fixed up in decls_for_scope. If\n\t we're a method, it will be ignored, since we already have a DIE. */\n if (decl_function_context (decl)\n\t /* But if we're in terse mode, we don't care about scope. */\n\t && debug_info_level > DINFO_LEVEL_TERSE)\n\tcontext_die = NULL;\n break;\n\n case VAR_DECL:\n /* Ignore this VAR_DECL if it refers to a file-scope extern data object\n\t declaration and if the declaration was never even referenced from\n\t within this entire compilation unit. We suppress these DIEs in\n\t order to save space in the .debug section (by eliminating entries\n\t which are probably useless). Note that we must not suppress\n\t block-local extern declarations (whether used or not) because that\n\t would screw-up the debugger's name lookup mechanism and cause it to\n\t miss things which really ought to be in scope at a given point. */\n if (DECL_EXTERNAL (decl) && !TREE_USED (decl))\n\treturn;\n\n /* For local statics lookup proper context die. */\n if (TREE_STATIC (decl)\n\t && DECL_CONTEXT (decl)\n\t && TREE_CODE (DECL_CONTEXT (decl)) == FUNCTION_DECL)\n\tcontext_die = lookup_decl_die (DECL_CONTEXT (decl));\n\n /* If we are in terse mode, don't generate any DIEs to represent any\n\t variable declarations or definitions. */\n if (debug_info_level <= DINFO_LEVEL_TERSE)\n\treturn;\n break;\n\n case CONST_DECL:\n if (debug_info_level <= DINFO_LEVEL_TERSE)\n\treturn;\n if (!is_fortran () && !is_ada ())\n\treturn;\n if (TREE_STATIC (decl) && decl_function_context (decl))\n\tcontext_die = lookup_decl_die (DECL_CONTEXT (decl));\n break;\n\n case NAMESPACE_DECL:\n case IMPORTED_DECL:\n if (debug_info_level <= DINFO_LEVEL_TERSE)\n\treturn;\n if (lookup_decl_die (decl) != NULL)\n\treturn;\n break;\n\n case TYPE_DECL:\n /* Don't emit stubs for types unless they are needed by other DIEs. */\n if (TYPE_DECL_SUPPRESS_DEBUG (decl))\n\treturn;\n\n /* Don't bother trying to generate any DIEs to represent any of the\n\t normal built-in types for the language we are compiling. */\n if (DECL_IS_BUILTIN (decl))\n\treturn;\n\n /* If we are in terse mode, don't generate any DIEs for types. */\n if (debug_info_level <= DINFO_LEVEL_TERSE)\n\treturn;\n\n /* If we're a function-scope tag, initially use a parent of NULL;\n\t this will be fixed up in decls_for_scope. */\n if (decl_function_context (decl))\n\tcontext_die = NULL;\n\n break;\n\n default:\n return;\n }\n\n gen_decl_die (decl, NULL, context_die);\n}",
"label": 0,
"cwe": null,
"length": 1129
},
{
"index": 263445,
"code": "map_orig2sub_cm_helper(CM_t *orig_cm, CM_t *sub_cm, CMSubMap_t *submap, int orig_v, int sub_v)\n{\n int sub_nd;\n int orig_nd;\n int is_insert;\n \n /*printf(\"\\nin helper: orig_v: %d sub_v: %d\\n\", orig_v, sub_v);*/\n \n if(orig_v == -1 || sub_v == -1)\n return 0;\n \n /* check to see if we already have this mapping */\n if(submap->o2s_smap[orig_v][0] == sub_v || submap->o2s_smap[orig_v][1] == sub_v)\n return 0;\n \n orig_nd = orig_cm->ndidx[orig_v];\n sub_nd = sub_cm->ndidx[sub_v];\n \n is_insert = FALSE;\n if(sub_cm->sttype[sub_v] == IL_st || sub_cm->sttype[sub_v] == IR_st)\n {\n is_insert = TRUE;\n /* Make sure that neither orig_v nor sub_v is a detached insert state,\n * if either is, we return b/c it's irrelevant, and we don't store that info in the maps */\n if(orig_cm->sttype[(orig_v+1)] == E_st || sub_cm->sttype[(sub_v+1)] == E_st)\n\treturn 0;\n } \n /* 09.14.06 I think that some of the code that checks for cases where we wnat to avoid mapping is unnecessary!,\n * but I'm not sure what...*/\n \n /* Check for a case we want to avoid mapping. We exploit the fact that we know a MATP_nd in a sub_cm MUST be mapped \n * to a corresponding MATP_nd in the original template CM: */\n if(sub_cm->ndtype[sub_nd] == MATP_nd)\n if(orig_cm->ndtype[orig_nd] == MATP_nd && sub_cm->sttype[sub_v] != orig_cm->sttype[orig_v])\n return 0;\n \n /* Fill in submap->o2s_smap */\n if(submap->o2s_smap[orig_v][0] == -1)\n {\n if (submap->o2s_smap[orig_v][1] != -1) \n\tcm_Fail(\"ERROR in map_orig2sub_cm_helper, submap->o2s_smap[%d][0] is -1 but submap->o2s_smap[%d][1] is not, this shouldn't happen.\\n\", orig_v, orig_v);\n else\n\tsubmap->o2s_smap[orig_v][0] = sub_v;\n }\n else if (submap->o2s_smap[orig_v][1] != -1)\n {\n if(submap->o2s_smap[orig_v][0] == sub_v || submap->o2s_smap[orig_v][1] == sub_v)\n\t/* abort!, we already have this mapping */\n\treturn 0; \n else\n\tcm_Fail(\"ERROR in map_orig2sub_cm_helper, submap->o2s_smap[%d][0] is not -1 and submap->o2s_smap[%d][1] is not -1, this shouldn't happen.\\n\", orig_v, orig_v);\n }\n else /* submap->o2s_smap[orig_v][0] != -1 && submap->o2s_smap[orig_v][1] == -1 */\n {\n if(submap->o2s_smap[orig_v][0] == sub_v || submap->o2s_smap[orig_v][1] == sub_v)\n\t/* abort!, we already have this mapping */\n\treturn 0; \n submap->o2s_smap[orig_v][1] = sub_v;\n }\n \n /* now fill in submap->s2o_smap */\n if(submap->s2o_smap[sub_v][0] == -1)\n if (submap->s2o_smap[sub_v][1] != -1)\n cm_Fail(\"ERROR in map_sub2orig_cm_helper, submap->s2o_smap[%d][0] is -1 but submap->s2o_smap[%d][1] is not, this shouldn't happen.\\n\", sub_v, sub_v);\n else\n submap->s2o_smap[sub_v][0] = orig_v;\n else if (submap->s2o_smap[sub_v][1] != -1)\n cm_Fail(\"ERROR in map_sub2orig_cm_helper, submap->s2o_smap[%d][0] is not -1 and submap->s2o_smap[%d][1] is not -1, this shouldn't happen.\\n\", sub_v, sub_v);\n else /* submap->s2o_smap[sub_v][0] != -1 && submap->s2o_smap[sub_v][1] == -1 */\n submap->s2o_smap[sub_v][1] = orig_v;\n return 1;\n}",
"label": 0,
"cwe": null,
"length": 1124
},
{
"index": 30981,
"code": "BinomialCoefficient(const SCEV *It, unsigned K,\n ScalarEvolution &SE,\n const Type* ResultTy) {\n // Handle the simplest case efficiently.\n if (K == 1)\n return SE.getTruncateOrZeroExtend(It, ResultTy);\n\n // We are using the following formula for BC(It, K):\n //\n // BC(It, K) = (It * (It - 1) * ... * (It - K + 1)) / K!\n //\n // Suppose, W is the bitwidth of the return value. We must be prepared for\n // overflow. Hence, we must assure that the result of our computation is\n // equal to the accurate one modulo 2^W. Unfortunately, division isn't\n // safe in modular arithmetic.\n //\n // However, this code doesn't use exactly that formula; the formula it uses\n // is something like the following, where T is the number of factors of 2 in\n // K! (i.e. trailing zeros in the binary representation of K!), and ^ is\n // exponentiation:\n //\n // BC(It, K) = (It * (It - 1) * ... * (It - K + 1)) / 2^T / (K! / 2^T)\n //\n // This formula is trivially equivalent to the previous formula. However,\n // this formula can be implemented much more efficiently. The trick is that\n // K! / 2^T is odd, and exact division by an odd number *is* safe in modular\n // arithmetic. To do exact division in modular arithmetic, all we have\n // to do is multiply by the inverse. Therefore, this step can be done at\n // width W.\n //\n // The next issue is how to safely do the division by 2^T. The way this\n // is done is by doing the multiplication step at a width of at least W + T\n // bits. This way, the bottom W+T bits of the product are accurate. Then,\n // when we perform the division by 2^T (which is equivalent to a right shift\n // by T), the bottom W bits are accurate. Extra bits are okay; they'll get\n // truncated out after the division by 2^T.\n //\n // In comparison to just directly using the first formula, this technique\n // is much more efficient; using the first formula requires W * K bits,\n // but this formula less than W + K bits. Also, the first formula requires\n // a division step, whereas this formula only requires multiplies and shifts.\n //\n // It doesn't matter whether the subtraction step is done in the calculation\n // width or the input iteration count's width; if the subtraction overflows,\n // the result must be zero anyway. We prefer here to do it in the width of\n // the induction variable because it helps a lot for certain cases; CodeGen\n // isn't smart enough to ignore the overflow, which leads to much less\n // efficient code if the width of the subtraction is wider than the native\n // register width.\n //\n // (It's possible to not widen at all by pulling out factors of 2 before\n // the multiplication; for example, K=2 can be calculated as\n // It/2*(It+(It*INT_MIN/INT_MIN)+-1). However, it requires\n // extra arithmetic, so it's not an obvious win, and it gets\n // much more complicated for K > 3.)\n\n // Protection from insane SCEVs; this bound is conservative,\n // but it probably doesn't matter.\n if (K > 1000)\n return SE.getCouldNotCompute();\n\n unsigned W = SE.getTypeSizeInBits(ResultTy);\n\n // Calculate K! / 2^T and T; we divide out the factors of two before\n // multiplying for calculating K! / 2^T to avoid overflow.\n // Other overflow doesn't matter because we only care about the bottom\n // W bits of the result.\n APInt OddFactorial(W, 1);\n unsigned T = 1;\n for (unsigned i = 3; i <= K; ++i) {\n APInt Mult(W, i);\n unsigned TwoFactors = Mult.countTrailingZeros();\n T += TwoFactors;\n Mult = Mult.lshr(TwoFactors);\n OddFactorial *= Mult;\n }\n\n // We need at least W + T bits for the multiplication step\n unsigned CalculationBits = W + T;\n\n // Calculate 2^T, at width T+W.\n APInt DivFactor = APInt(CalculationBits, 1).shl(T);\n\n // Calculate the multiplicative inverse of K! / 2^T;\n // this multiplication factor will perform the exact division by\n // K! / 2^T.\n APInt Mod = APInt::getSignedMinValue(W+1);\n APInt MultiplyFactor = OddFactorial.zext(W+1);\n MultiplyFactor = MultiplyFactor.multiplicativeInverse(Mod);\n MultiplyFactor = MultiplyFactor.trunc(W);\n\n // Calculate the product, at width T+W\n const IntegerType *CalculationTy = IntegerType::get(SE.getContext(),\n CalculationBits);\n const SCEV *Dividend = SE.getTruncateOrZeroExtend(It, CalculationTy);\n for (unsigned i = 1; i != K; ++i) {\n const SCEV *S = SE.getMinusSCEV(It, SE.getConstant(It->getType(), i));\n Dividend = SE.getMulExpr(Dividend,\n SE.getTruncateOrZeroExtend(S, CalculationTy));\n }\n\n // Divide by 2^T\n const SCEV *DivResult = SE.getUDivExpr(Dividend, SE.getConstant(DivFactor));\n\n // Truncate the result, and divide by K! / 2^T.\n\n return SE.getMulExpr(SE.getConstant(MultiplyFactor),\n SE.getTruncateOrZeroExtend(DivResult, ResultTy));\n}",
"label": 0,
"cwe": null,
"length": 1321
},
{
"index": 35127,
"code": "dy_pivot (int xipos, double abarij, double maxabarj)\n\n/*\n This routine handles a single pivot. It first checks that the pivot element\n satisfies a stability test, then calls inv_update to pivot the basis. We\n can still run into trouble, however, if the pivot results in a singular or\n near-singular basis.\n \n NOTE: There is an implicit argument here that's not immediately obvious.\n\tinv_update gets the entering column from a cached result set with the\n\tmost recent call to inv_ftran(*,1) (dy_ftran(*,true), if you prefer).\n\tThe underlying assumption is that this is readily available from when\n\twe ftran'd the entering column to find the leaving variable.\n\n Parameters:\n xipos:\tthe basis position of the entering variable\n abarij:\tthe pivot element (only the absolute value is used)\n maxabarj:\tfor a primal pivot, max{i} |abar<i,j>|,\n\t\tfor a dual pivot, max{j} |abar<i,j>|\n\n Returns:\n dyrOK:\tthe pivot was accomplished without incident (inv_update)\n dyrMADPIV:\tthe pivot element abar<i,j> was rejected as numerically\n\t\tunstable (dy_chkpiv)\n dyrSINGULAR: the pivot attempt resulted in a structurally singular basis\n\t\t(i.e., some diagonal element is zero) (inv_update)\n dyrNUMERIC:\tthe pivot attempt resulted in a numerically singular (unstable)\n\t\tbasis (i.e, some diagonal element is too small compared to\n\t\tother elements in the associated row and column) (inv_update)\n dyrBSPACE:\tglpinv/glpluf ran out of space for the basis representation\n\t\t(inv_update)\n dyrFATAL:\tinternal confusion\n*/\n\n{ int retval ;\n double ratio ;\n dyret_enum retcode ;\n\n const char *rtnnme = \"dy_pivot\" ;\n\n/*\n Check that the pivot element meets the current criterion for numerical\n stability. Arguably this should have been checked by the caller, but that's\n no excuse for not doing it now.\n*/\n ratio = dy_chkpiv(abarij,maxabarj) ;\n if (ratio < 1.0)\n {\n# ifndef DYLP_NDEBUG\n if (dy_opts->print.basis >= 3)\n { dyio_outfmt(dy_logchn,dy_gtxecho,\n\t\t \"\\n %s(%d) pivot aborted; est. pivot stability %g.\",\n\t\t dy_prtlpphase(dy_lp->phase,TRUE),\n\t\t dy_lp->tot.iters,rtnnme,ratio) ; }\n# endif\n return (dyrMADPIV) ; }\n/*\n Make the call to inv_update, then recode the result.\n*/\n retval = inv_update(luf_basis,xipos) ;\n# ifndef DYLP_NDEBUG\n if ((retval == 0 && dy_opts->print.basis >= 5) ||\n (retval > 0 && dy_opts->print.basis >= 3))\n { dyio_outfmt(dy_logchn,dy_gtxecho,\n\t\t\"\\n %s(%d) estimated pivot stability %g; \",\n\t\tdy_prtlpphase(dy_lp->phase,TRUE),dy_lp->tot.iters,ratio) ;\n dyio_outfmt(dy_logchn,dy_gtxecho,\"measured pivot stability %g.\",\n\t luf_basis->min_vrratio) ; }\n# endif\n switch (retval)\n { case 0:\n { retcode = dyrOK ;\n break ; }\n case 1:\n { retcode = dyrSINGULAR ;\n# ifndef DYLP_NDEBUG\n if (dy_opts->print.basis >= 2)\n { dyio_outfmt(dy_logchn,dy_gtxecho,\n\t\t \"\\n %s(%d) singular basis (structural) after pivot.\",\n\t\t dy_prtlpphase(dy_lp->phase,TRUE),dy_lp->tot.iters) ; }\n# endif\n break ; }\n case 2:\n { retcode = dyrNUMERIC ;\n# ifndef DYLP_NDEBUG\n if (dy_opts->print.basis >= 2)\n { dyio_outfmt(dy_logchn,dy_gtxecho,\n\t\t \"\\n %s(%d) singular basis (numeric) after pivot.\",\n\t\t dy_prtlpphase(dy_lp->phase,TRUE),dy_lp->tot.iters) ; }\n# endif\n break ; }\n case 3:\n case 4:\n { retcode = dyrBSPACE ;\n# ifndef DYLP_NDEBUG\n if (dy_opts->print.basis >= 2)\n { dyio_outfmt(dy_logchn,dy_gtxecho,\"\\n %s(%d) out of space (%s)\",\n\t\t dy_prtlpphase(dy_lp->phase,TRUE),dy_lp->tot.iters,\n\t\t (retval == 3)?\"eta matrix limit\":\"sparse vector area\") ; }\n# endif\n break ; }\n default:\n { errmsg(1,rtnnme,__LINE__) ;\n retcode = dyrFATAL ;\n break ; } }\n \n return (retcode) ; }",
"label": 0,
"cwe": null,
"length": 1136
},
{
"index": 354309,
"code": "main(void) {\n\n setlocale(LC_ALL, \"\");\n\n Arc::LogStream logcerr(std::cerr);\n Arc::Logger::getRootLogger().addDestination(logcerr);\n// Arc::Logger::getRootLogger().setThreshold(Arc::WARNING);\n\n //This is an example that shows how the client or the client called \n //by a service, delegates a proxy to a delegation service.\n\n //Note the \"DelegationServiceEndpoint\" should be changed according\n //the actual delegation endpoint.\n Arc::XMLNode sechanlder_nd(\"\\\n <SecHandler name='delegation.handler' id='delegation' event='outgoing'>\\\n <Type>x509</Type>\\\n <Role>delegator</Role>\\\n <!--DelegationServiceEndpoint>https://127.0.0.1:60000/delegation</DelegationServiceEndpoint-->\\\n <DelegationServiceEndpoint>https://glueball.uio.no:60000/delegation</DelegationServiceEndpoint>\\\n <PeerServiceEndpoint>https://127.0.0.1:60000/echo</PeerServiceEndpoint>\\\n <KeyPath>../echo/userkey-nopass.pem</KeyPath>\\\n <CertificatePath>../echo/usercert.pem</CertificatePath>\\\n <!--ProxyPath>/tmp/5612d050.pem</ProxyPath-->\\\n <!--DelegationCredIdentity>/O=KnowARC/OU=UiO/CN=squark.uio.no</DelegationCredIdentity-->\\\n <CACertificatePath>../echo/testcacert.pem</CACertificatePath>\\\n <CACertificatesDir>../echo/certificates</CACertificatesDir>\\\n </SecHandler>\");\n\n /*For the firstly client in the service invocation chain, the credential path\n should be configured for the 'delegator' role delegation handler.\n <KeyPath>../echo/testkey-nopass.pem</KeyPath>\\\n <CertificatePath>../echo/testcert.pem</CertificatePath>\\\n <!--ProxyPath>/tmp/5612d050.pem</ProxyPath-->\\\n Alternatively, For the clients which are called in the intermediate \n service inside the service invocation chain, the the 'Identity' should \n be configured for the 'delegator' role delegation handler. The 'Identity' \n can be parsed from the 'incoming' message context of the service itself \n by service implementation: \n std::string identity= msg->Attributes()->get(\"TLS:IDENTITYDN\");\n Afterwards, the service implementation should change the client \n (the client that this service will call to contact the next intemediate service) \n configuration to add 'DelegationCredIdentity' like the following.\n <DelegationCredIdentity>/O=KnowARC/OU=UiO/CN=squark.uio.no</DelegationCredIdentity>\\\n\n Filling \"DelegationCredIdentity\" element is the only code that is needed for \n the ARC services that need to utilize the delegation functionality (more \n specifically, to launch a more level of delegation).\n */\n\n std::string url_str(\"https://127.0.0.1:60000/echo\");\n Arc::URL url(url_str);\n\n Arc::MCCConfig mcc_cfg;\n mcc_cfg.AddPrivateKey(\"../echo/userkey-nopass.pem\");\n mcc_cfg.AddCertificate(\"../echo/usercert.pem\");\n mcc_cfg.AddCADir(\"../echo/certificates\");\n mcc_cfg.AddCAFile(\"../echo/testcacert.pem\");\n\n //Create a SOAP client\n logger.msg(Arc::INFO, \"Creating a soap client\");\n\n Arc::ClientSOAP *client;\n client = new Arc::ClientSOAP(mcc_cfg,url,60);\n client->AddSecHandler(sechanlder_nd, \"arcshc\");\n\n //Create and send echo request\n logger.msg(Arc::INFO, \"Creating and sending request\");\n Arc::NS echo_ns; echo_ns[\"echo\"]=\"http://www.nordugrid.org/schemas/echo\";\n Arc::PayloadSOAP req(echo_ns);\n req.NewChild(\"echo\").NewChild(\"say\")=\"HELLO\";\n\n Arc::PayloadSOAP* resp = NULL;\n\n std::string str;\n req.GetXML(str);\n std::cout<<\"request: \"<<str<<std::endl;\n Arc::MCC_Status status = client->process(&req,&resp);\n if(!status) {\n logger.msg(Arc::ERROR, \"SOAP invokation failed\");\n }\n if(resp == NULL) {\n logger.msg(Arc::ERROR,\"There was no SOAP response\");\n }\n\n std::string xml;\n resp->GetXML(xml);\n std::cout << \"XML: \"<< xml << std::endl;\n std::cout << \"Response: \" << (std::string)((*resp)[\"echoResponse\"][\"hear\"]) << std::endl;\n\n if(resp) delete resp;\n if(client) delete client;\n\n return 0;\n}",
"label": 1,
"cwe": "CWE-476",
"length": 1042
},
{
"index": 95973,
"code": "__ecereMethod___ecereNameSpace__eda__EDBRow_Select(struct __ecereNameSpace__ecere__com__Instance * this, int move)\n{\nstruct __ecereNameSpace__eda__EDBRow * __ecerePointer___ecereNameSpace__eda__EDBRow = (struct __ecereNameSpace__eda__EDBRow *)(this ? (((char *)this) + __ecereClass___ecereNameSpace__eda__EDBRow->offset) : 0);\nstruct __ecereNameSpace__ecere__com__Instance * edb = __ecerePointer___ecereNameSpace__eda__EDBRow->tbl->db;\n\nif(__ecerePointer___ecereNameSpace__eda__EDBRow->tbl->rowsCount)\n{\nif(__ecerePointer___ecereNameSpace__eda__EDBRow->index)\n{\nswitch(move)\n{\ncase 1:\n__ecerePointer___ecereNameSpace__eda__EDBRow->node = __ecereProp___ecereNameSpace__ecere__sys__BinaryTree_Get_first(&__ecerePointer___ecereNameSpace__eda__EDBRow->index->tree);\n__ecereProp___ecereNameSpace__eda__EDBRow_Set_num(this, __ecerePointer___ecereNameSpace__eda__EDBRow->node ? (unsigned int)__ecerePointer___ecereNameSpace__eda__EDBRow->node->key : 0);\nreturn __ecerePointer___ecereNameSpace__eda__EDBRow->_num != 0;\ncase 3:\n__ecerePointer___ecereNameSpace__eda__EDBRow->node = __ecerePointer___ecereNameSpace__eda__EDBRow->node ? __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_next(__ecerePointer___ecereNameSpace__eda__EDBRow->node) : __ecereProp___ecereNameSpace__ecere__sys__BinaryTree_Get_first(&__ecerePointer___ecereNameSpace__eda__EDBRow->index->tree);\n__ecereProp___ecereNameSpace__eda__EDBRow_Set_num(this, __ecerePointer___ecereNameSpace__eda__EDBRow->node ? (unsigned int)__ecerePointer___ecereNameSpace__eda__EDBRow->node->key : 0);\nreturn __ecerePointer___ecereNameSpace__eda__EDBRow->_num != 0;\ncase 2:\n__ecerePointer___ecereNameSpace__eda__EDBRow->node = __ecereProp___ecereNameSpace__ecere__sys__BinaryTree_Get_last(&__ecerePointer___ecereNameSpace__eda__EDBRow->index->tree);\n__ecereProp___ecereNameSpace__eda__EDBRow_Set_num(this, __ecerePointer___ecereNameSpace__eda__EDBRow->node ? (unsigned int)__ecerePointer___ecereNameSpace__eda__EDBRow->node->key : 0);\nreturn __ecerePointer___ecereNameSpace__eda__EDBRow->_num != 0;\ncase 4:\n__ecerePointer___ecereNameSpace__eda__EDBRow->node = __ecerePointer___ecereNameSpace__eda__EDBRow->node ? __ecereProp___ecereNameSpace__ecere__sys__BTNode_Get_prev(__ecerePointer___ecereNameSpace__eda__EDBRow->node) : __ecereProp___ecereNameSpace__ecere__sys__BinaryTree_Get_last(&__ecerePointer___ecereNameSpace__eda__EDBRow->index->tree);\n__ecereProp___ecereNameSpace__eda__EDBRow_Set_num(this, __ecerePointer___ecereNameSpace__eda__EDBRow->node ? (unsigned int)__ecerePointer___ecereNameSpace__eda__EDBRow->node->key : 0);\nreturn __ecerePointer___ecereNameSpace__eda__EDBRow->_num != 0;\ncase 5:\n__ecerePointer___ecereNameSpace__eda__EDBRow->node = __ecerePointer___ecereNameSpace__eda__EDBRow->index->tree.root;\n__ecereProp___ecereNameSpace__eda__EDBRow_Set_num(this, __ecerePointer___ecereNameSpace__eda__EDBRow->node ? (unsigned int)__ecerePointer___ecereNameSpace__eda__EDBRow->node->key : 0);\nreturn __ecerePointer___ecereNameSpace__eda__EDBRow->_num != 0;\ncase 0:\n__ecereProp___ecereNameSpace__eda__EDBRow_Set_num(this, 0);\nbreak;\n}\n}\nelse\nswitch(move)\n{\ncase 1:\n__ecereProp___ecereNameSpace__eda__EDBRow_Set_num(this, 0);\ncase 3:\nwhile(__ecerePointer___ecereNameSpace__eda__EDBRow->_num < __ecerePointer___ecereNameSpace__eda__EDBRow->tbl->allocatedRowsCount)\n{\n__ecereProp___ecereNameSpace__eda__EDBRow_Set_num(this, __ecerePointer___ecereNameSpace__eda__EDBRow->_num + 1);\nif(__ecerePointer___ecereNameSpace__eda__EDBRow->tbl->rowPositions[__ecerePointer___ecereNameSpace__eda__EDBRow->_num - 1])\nreturn 0x1;\n}\n__ecereProp___ecereNameSpace__eda__EDBRow_Set_num(this, 0);\nbreak;\ncase 2:\n__ecereProp___ecereNameSpace__eda__EDBRow_Set_num(this, __ecerePointer___ecereNameSpace__eda__EDBRow->tbl->allocatedRowsCount + 1);\ncase 4:\nwhile(__ecerePointer___ecereNameSpace__eda__EDBRow->_num)\n{\n__ecereProp___ecereNameSpace__eda__EDBRow_Set_num(this, __ecerePointer___ecereNameSpace__eda__EDBRow->_num - 1);\nif(__ecerePointer___ecereNameSpace__eda__EDBRow->tbl->rowPositions[__ecerePointer___ecereNameSpace__eda__EDBRow->_num - 1])\nreturn 0x1;\n}\nbreak;\ncase 5:\ncase 0:\n__ecereProp___ecereNameSpace__eda__EDBRow_Set_num(this, 0);\nbreak;\n}\n}\nreturn 0x0;\n}",
"label": 0,
"cwe": null,
"length": 1447
},
{
"index": 228995,
"code": "expr_parse_numeric_factor (void)\n{\n /* Handle factors based on lookahead token. */\n switch (expr_parse_lookahead)\n {\n /* Handle straightforward factors first. */\n case TOK_LPAREN:\n expr_parse_match (TOK_LPAREN);\n expr_parse_numeric_expr ();\n expr_parse_match (TOK_RPAREN);\n break;\n\n case TOK_UMINUS:\n expr_parse_match (TOK_UMINUS);\n expr_parse_numeric_factor ();\n expr_eval_action (TOK_UMINUS);\n break;\n\n case TOK_UPLUS:\n expr_parse_match (TOK_UPLUS);\n expr_parse_numeric_factor ();\n break;\n\n case TOK_INTEGER:\n expr_eval_action (TOK_INTEGER);\n expr_parse_match (TOK_INTEGER);\n break;\n\n case TOK_VARIABLE:\n {\n sc_vartype_t token_value, vt_rvalue;\n sc_int type;\n\n expr_current_token_value (&token_value);\n if (!var_get (expr_varset, token_value.string, &type, &vt_rvalue))\n {\n sc_error (\"expr_parse_numeric_factor:\"\n \" undefined variable, %s\\n\", token_value.string);\n longjmp (expr_parse_error, 1);\n }\n if (type != VAR_INTEGER)\n {\n sc_error (\"expr_parse_numeric_factor:\"\n \" string variable in numeric context, %s\\n\",\n token_value.string);\n longjmp (expr_parse_error, 1);\n }\n expr_eval_action (TOK_VARIABLE);\n expr_parse_match (TOK_VARIABLE);\n break;\n }\n\n /* Handle functions as factors. */\n case TOK_ABS:\n /* Parse as \"abs (val)\". */\n expr_parse_match (TOK_ABS);\n expr_parse_match (TOK_LPAREN);\n expr_parse_numeric_expr ();\n expr_parse_match (TOK_RPAREN);\n expr_eval_action (TOK_ABS);\n break;\n\n case TOK_IF:\n /* Parse as \"if (boolean, val1, val2)\". */\n expr_parse_match (TOK_IF);\n expr_parse_match (TOK_LPAREN);\n expr_parse_numeric_expr ();\n expr_parse_match (TOK_COMMA);\n expr_parse_numeric_expr ();\n expr_parse_match (TOK_COMMA);\n expr_parse_numeric_expr ();\n expr_parse_match (TOK_RPAREN);\n expr_eval_action (TOK_IF);\n break;\n\n case TOK_RANDOM:\n /* Parse as \"random (low, high)\". */\n expr_parse_match (TOK_RANDOM);\n expr_parse_match (TOK_LPAREN);\n expr_parse_numeric_expr ();\n expr_parse_match (TOK_COMMA);\n expr_parse_numeric_expr ();\n expr_parse_match (TOK_RPAREN);\n expr_eval_action (TOK_RANDOM);\n break;\n\n case TOK_MAX:\n case TOK_MIN:\n case TOK_EITHER:\n /* Parse as \"<func> (val1[,val2[,val3...]]])\". */\n {\n sc_int token, argument_count;\n\n /* Match up the function name and opening parenthesis. */\n token = expr_parse_lookahead;\n expr_parse_match (token);\n expr_parse_match (TOK_LPAREN);\n\n /* Count variable number of arguments as they are stacked. */\n expr_parse_numeric_expr ();\n argument_count = 1;\n while (expr_parse_lookahead == TOK_COMMA)\n {\n expr_parse_match (TOK_COMMA);\n expr_parse_numeric_expr ();\n argument_count++;\n }\n expr_parse_match (TOK_RPAREN);\n\n /* Push additional value -- the count of arguments. */\n expr_eval_push_integer (argument_count);\n expr_eval_action (token);\n break;\n }\n\n case TOK_INSTR:\n /* Parse as \"instr (val1, val2)\". */\n expr_parse_match (TOK_INSTR);\n expr_parse_match (TOK_LPAREN);\n expr_parse_string_expr ();\n expr_parse_match (TOK_COMMA);\n expr_parse_string_expr ();\n expr_parse_match (TOK_RPAREN);\n expr_eval_action (TOK_INSTR);\n break;\n\n case TOK_LEN:\n /* Parse as \"len (val)\". */\n expr_parse_match (TOK_LEN);\n expr_parse_match (TOK_LPAREN);\n expr_parse_string_expr ();\n expr_parse_match (TOK_RPAREN);\n expr_eval_action (TOK_LEN);\n break;\n\n case TOK_VAL:\n /* Parse as \"val (val)\". */\n expr_parse_match (TOK_VAL);\n expr_parse_match (TOK_LPAREN);\n expr_parse_string_expr ();\n expr_parse_match (TOK_RPAREN);\n expr_eval_action (TOK_VAL);\n break;\n\n case TOK_IDENT:\n /* Unrecognized function-type token. */\n sc_error (\"expr_parse_numeric_factor: syntax error, unknown ident\\n\");\n longjmp (expr_parse_error, 1);\n\n default:\n /* Syntax error. */\n sc_error (\"expr_parse_numeric_factor:\"\n \" syntax error, unexpected token, %ld\\n\", expr_parse_lookahead);\n longjmp (expr_parse_error, 1);\n }\n}",
"label": 0,
"cwe": null,
"length": 1075
},
{
"index": 869709,
"code": "make_subplan(PlannerInfo *root, Query *orig_subquery, SubLinkType subLinkType,\n\t\t\t Node *testexpr, bool isTopQual)\n{\n\tQuery\t *subquery;\n\tbool\t\tsimple_exists = false;\n\tdouble\t\ttuple_fraction;\n\tPlan\t *plan;\n\tPlannerInfo *subroot;\n\tNode\t *result;\n\n\t/*\n\t * Copy the source Query node.\tThis is a quick and dirty kluge to resolve\n\t * the fact that the parser can generate trees with multiple links to the\n\t * same sub-Query node, but the planner wants to scribble on the Query.\n\t * Try to clean this up when we do querytree redesign...\n\t */\n\tsubquery = (Query *) copyObject(orig_subquery);\n\n\t/*\n\t * If it's an EXISTS subplan, we might be able to simplify it.\n\t */\n\tif (subLinkType == EXISTS_SUBLINK)\n\t\tsimple_exists = simplify_EXISTS_query(subquery);\n\n\t/*\n\t * For an EXISTS subplan, tell lower-level planner to expect that only the\n\t * first tuple will be retrieved. For ALL and ANY subplans, we will be\n\t * able to stop evaluating if the test condition fails or matches, so very\n\t * often not all the tuples will be retrieved; for lack of a better idea,\n\t * specify 50% retrieval. For EXPR and ROWCOMPARE subplans, use default\n\t * behavior (we're only expecting one row out, anyway).\n\t *\n\t * NOTE: if you change these numbers, also change cost_subplan() in\n\t * path/costsize.c.\n\t *\n\t * XXX If an ANY subplan is uncorrelated, build_subplan may decide to hash\n\t * its output.\tIn that case it would've been better to specify full\n\t * retrieval. At present, however, we can only check hashability after\n\t * we've made the subplan :-(. (Determining whether it'll fit in work_mem\n\t * is the really hard part.) Therefore, we don't want to be too\n\t * optimistic about the percentage of tuples retrieved, for fear of\n\t * selecting a plan that's bad for the materialization case.\n\t */\n\tif (subLinkType == EXISTS_SUBLINK)\n\t\ttuple_fraction = 1.0;\t/* just like a LIMIT 1 */\n\telse if (subLinkType == ALL_SUBLINK ||\n\t\t\t subLinkType == ANY_SUBLINK)\n\t\ttuple_fraction = 0.5;\t/* 50% */\n\telse\n\t\ttuple_fraction = 0.0;\t/* default behavior */\n\n\t/*\n\t * Generate the plan for the subquery.\n\t */\n\tplan = subquery_planner(root->glob, subquery,\n\t\t\t\t\t\t\troot,\n\t\t\t\t\t\t\tfalse, tuple_fraction,\n\t\t\t\t\t\t\t&subroot);\n\n\t/* And convert to SubPlan or InitPlan format. */\n\tresult = build_subplan(root, plan,\n\t\t\t\t\t\t subroot->parse->rtable, subroot->rowMarks,\n\t\t\t\t\t\t subLinkType, testexpr, true, isTopQual);\n\n\t/*\n\t * If it's a correlated EXISTS with an unimportant targetlist, we might be\n\t * able to transform it to the equivalent of an IN and then implement it\n\t * by hashing.\tWe don't have enough information yet to tell which way is\n\t * likely to be better (it depends on the expected number of executions of\n\t * the EXISTS qual, and we are much too early in planning the outer query\n\t * to be able to guess that). So we generate both plans, if possible, and\n\t * leave it to the executor to decide which to use.\n\t */\n\tif (simple_exists && IsA(result, SubPlan))\n\t{\n\t\tNode\t *newtestexpr;\n\t\tList\t *paramIds;\n\n\t\t/* Make a second copy of the original subquery */\n\t\tsubquery = (Query *) copyObject(orig_subquery);\n\t\t/* and re-simplify */\n\t\tsimple_exists = simplify_EXISTS_query(subquery);\n\t\tAssert(simple_exists);\n\t\t/* See if it can be converted to an ANY query */\n\t\tsubquery = convert_EXISTS_to_ANY(root, subquery,\n\t\t\t\t\t\t\t\t\t\t &newtestexpr, &paramIds);\n\t\tif (subquery)\n\t\t{\n\t\t\t/* Generate the plan for the ANY subquery; we'll need all rows */\n\t\t\tplan = subquery_planner(root->glob, subquery,\n\t\t\t\t\t\t\t\t\troot,\n\t\t\t\t\t\t\t\t\tfalse, 0.0,\n\t\t\t\t\t\t\t\t\t&subroot);\n\n\t\t\t/* Now we can check if it'll fit in work_mem */\n\t\t\tif (subplan_is_hashable(plan))\n\t\t\t{\n\t\t\t\tSubPlan *hashplan;\n\t\t\t\tAlternativeSubPlan *asplan;\n\n\t\t\t\t/* OK, convert to SubPlan format. */\n\t\t\t\thashplan = (SubPlan *) build_subplan(root, plan,\n\t\t\t\t\t\t\t\t\t\t\t\t\t subroot->parse->rtable,\n\t\t\t\t\t\t\t\t\t\t\t\t\t subroot->rowMarks,\n\t\t\t\t\t\t\t\t\t\t\t\t\t ANY_SUBLINK, newtestexpr,\n\t\t\t\t\t\t\t\t\t\t\t\t\t false, true);\n\t\t\t\t/* Check we got what we expected */\n\t\t\t\tAssert(IsA(hashplan, SubPlan));\n\t\t\t\tAssert(hashplan->parParam == NIL);\n\t\t\t\tAssert(hashplan->useHashTable);\n\t\t\t\t/* build_subplan won't have filled in paramIds */\n\t\t\t\thashplan->paramIds = paramIds;\n\n\t\t\t\t/* Leave it to the executor to decide which plan to use */\n\t\t\t\tasplan = makeNode(AlternativeSubPlan);\n\t\t\t\tasplan->subplans = list_make2(result, hashplan);\n\t\t\t\tresult = (Node *) asplan;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}",
"label": 0,
"cwe": null,
"length": 1182
},
{
"index": 338866,
"code": "propagateThroughEdges(Function &F) {\n bool Changed = false;\n DEBUG(dbgs() << \"\\nPropagation through edges\\n\");\n for (const auto &BI : F) {\n const BasicBlock *BB = &BI;\n const BasicBlock *EC = EquivalenceClass[BB];\n\n // Visit all the predecessor and successor edges to determine\n // which ones have a weight assigned already. Note that it doesn't\n // matter that we only keep track of a single unknown edge. The\n // only case we are interested in handling is when only a single\n // edge is unknown (see setEdgeOrBlockWeight).\n for (unsigned i = 0; i < 2; i++) {\n uint64_t TotalWeight = 0;\n unsigned NumUnknownEdges = 0;\n Edge UnknownEdge, SelfReferentialEdge;\n\n if (i == 0) {\n // First, visit all predecessor edges.\n for (auto *Pred : Predecessors[BB]) {\n Edge E = std::make_pair(Pred, BB);\n TotalWeight += visitEdge(E, &NumUnknownEdges, &UnknownEdge);\n if (E.first == E.second)\n SelfReferentialEdge = E;\n }\n } else {\n // On the second round, visit all successor edges.\n for (auto *Succ : Successors[BB]) {\n Edge E = std::make_pair(BB, Succ);\n TotalWeight += visitEdge(E, &NumUnknownEdges, &UnknownEdge);\n }\n }\n\n // After visiting all the edges, there are three cases that we\n // can handle immediately:\n //\n // - All the edge weights are known (i.e., NumUnknownEdges == 0).\n // In this case, we simply check that the sum of all the edges\n // is the same as BB's weight. If not, we change BB's weight\n // to match. Additionally, if BB had not been visited before,\n // we mark it visited.\n //\n // - Only one edge is unknown and BB has already been visited.\n // In this case, we can compute the weight of the edge by\n // subtracting the total block weight from all the known\n // edge weights. If the edges weight more than BB, then the\n // edge of the last remaining edge is set to zero.\n //\n // - There exists a self-referential edge and the weight of BB is\n // known. In this case, this edge can be based on BB's weight.\n // We add up all the other known edges and set the weight on\n // the self-referential edge as we did in the previous case.\n //\n // In any other case, we must continue iterating. Eventually,\n // all edges will get a weight, or iteration will stop when\n // it reaches SampleProfileMaxPropagateIterations.\n if (NumUnknownEdges <= 1) {\n uint64_t &BBWeight = BlockWeights[EC];\n if (NumUnknownEdges == 0) {\n // If we already know the weight of all edges, the weight of the\n // basic block can be computed. It should be no larger than the sum\n // of all edge weights.\n if (TotalWeight > BBWeight) {\n BBWeight = TotalWeight;\n Changed = true;\n DEBUG(dbgs() << \"All edge weights for \" << BB->getName()\n << \" known. Set weight for block: \";\n printBlockWeight(dbgs(), BB););\n }\n if (VisitedBlocks.insert(EC).second)\n Changed = true;\n } else if (NumUnknownEdges == 1 && VisitedBlocks.count(EC)) {\n // If there is a single unknown edge and the block has been\n // visited, then we can compute E's weight.\n if (BBWeight >= TotalWeight)\n EdgeWeights[UnknownEdge] = BBWeight - TotalWeight;\n else\n EdgeWeights[UnknownEdge] = 0;\n VisitedEdges.insert(UnknownEdge);\n Changed = true;\n DEBUG(dbgs() << \"Set weight for edge: \";\n printEdgeWeight(dbgs(), UnknownEdge));\n }\n } else if (SelfReferentialEdge.first && VisitedBlocks.count(EC)) {\n uint64_t &BBWeight = BlockWeights[BB];\n // We have a self-referential edge and the weight of BB is known.\n if (BBWeight >= TotalWeight)\n EdgeWeights[SelfReferentialEdge] = BBWeight - TotalWeight;\n else\n EdgeWeights[SelfReferentialEdge] = 0;\n VisitedEdges.insert(SelfReferentialEdge);\n Changed = true;\n DEBUG(dbgs() << \"Set self-referential edge weight to: \";\n printEdgeWeight(dbgs(), SelfReferentialEdge));\n }\n }\n }\n\n return Changed;\n}",
"label": 0,
"cwe": null,
"length": 1043
},
{
"index": 915212,
"code": "mDNS_DeregisterInterface(mDNS *const m, NetworkInterfaceInfo *set)\n\t{\n\tNetworkInterfaceInfo **p = &m->HostInterfaces;\n\t\n\tmDNSBool revalidate = mDNSfalse;\n\t// If this platform has the \"phantom interfaces\" known bug (e.g. Jaguar), we have to revalidate records every\n\t// time an interface goes away. Otherwise, when you disconnect the Ethernet cable, the system reports that it\n\t// still has an IPv6 address, and if we don't revalidate those records don't get deleted in a timely fashion.\n\tif (m->KnownBugs & mDNS_KnownBug_PhantomInterfaces) revalidate = mDNStrue;\n\n\tmDNS_Lock(m);\n\n\t// Find this record in our list\n\twhile (*p && *p != set) p=&(*p)->next;\n\tif (!*p) { debugf(\"mDNS_DeregisterInterface: NetworkInterfaceInfo not found in list\"); mDNS_Unlock(m); return; }\n\n\t// Unlink this record from our list\n\t*p = (*p)->next;\n\tset->next = mDNSNULL;\n\n\tif (!set->InterfaceActive)\n\t\t{\n\t\t// If this interface not the active member of its set, update the v4/v6Available flags for the active member\n\t\tNetworkInterfaceInfo *intf;\n\t\tfor (intf = m->HostInterfaces; intf; intf = intf->next)\n\t\t\tif (intf->InterfaceActive && intf->InterfaceID == set->InterfaceID)\n\t\t\t\tUpdateInterfaceProtocols(m, intf);\n\t\t}\n\telse\n\t\t{\n\t\tNetworkInterfaceInfo *intf;\n\t\tfor (intf = m->HostInterfaces; intf; intf = intf->next)\n\t\t\tif (intf->InterfaceID == set->InterfaceID)\n\t\t\t\tbreak;\n\t\tif (intf)\n\t\t\t{\n\t\t\tdebugf(\"mDNS_DeregisterInterface: Another representative of InterfaceID %p exists; making it active\",\n\t\t\t\tset->InterfaceID);\n\t\t\tintf->InterfaceActive = mDNStrue;\n\t\t\tUpdateInterfaceProtocols(m, intf);\n\t\t\t\n\t\t\t// See if another representative *of the same type* exists. If not, we mave have gone from\n\t\t\t// dual-stack to v6-only (or v4-only) so we need to reconfirm which records are still valid.\n\t\t\tfor (intf = m->HostInterfaces; intf; intf = intf->next)\n\t\t\t\tif (intf->InterfaceID == set->InterfaceID && intf->ip.type == set->ip.type)\n\t\t\t\t\tbreak;\n\t\t\tif (!intf) revalidate = mDNStrue;\n\t\t\t}\n\t\telse\n\t\t\t{\n\t\t\tCacheRecord *rr;\n\t\t\tDNSQuestion *q;\n\t\t\tmDNSu32 slot;\n\t\t\tdebugf(\"mDNS_DeregisterInterface: Last representative of InterfaceID %p deregistered; marking questions etc. dormant\",\n\t\t\t\tset->InterfaceID);\n\n\t\t\t// 1. Deactivate any questions specific to this interface\n\t\t\tfor (q = m->Questions; q; q=q->next)\n\t\t\t\tif (q->InterfaceID == set->InterfaceID)\n\t\t\t\t\tq->ThisQInterval = 0;\n\n\t\t\t// 2. Flush any cache records received on this interface\n\t\t\trevalidate = mDNSfalse;\t\t// Don't revalidate if we're flushing the records\n\t\t\tfor (slot = 0; slot < CACHE_HASH_SLOTS; slot++)\n\t\t\t\tfor (rr = m->rrcache_hash[slot]; rr; rr=rr->next)\n\t\t\t\t\tif (rr->resrec.InterfaceID == set->InterfaceID)\n\t\t\t\t\t\tPurgeCacheResourceRecord(m, rr);\n\t\t\t}\n\t\t}\n\n\t// If we were advertising on this interface, deregister those address and reverse-lookup records now\n\tif (set->Advertise)\n\t\tmDNS_DeadvertiseInterface(m, set);\n\n\t// If we have any cache records received on this interface that went away, then re-verify them.\n\t// In some versions of OS X the IPv6 address remains on an interface even when the interface is turned off,\n\t// giving the false impression that there's an active representative of this interface when there really isn't.\n\t// Don't need to do this when shutting down, because *all* interfaces are about to go away\n\tif (revalidate && !m->mDNS_shutdown)\n\t\t{\n\t\tmDNSu32 slot;\n\t\tCacheRecord *rr;\n\t\tm->NextCacheCheck = m->timenow;\n\t\tfor (slot = 0; slot < CACHE_HASH_SLOTS; slot++)\n\t\t\tfor (rr = m->rrcache_hash[slot]; rr; rr=rr->next)\n\t\t\t\tif (rr->resrec.InterfaceID == set->InterfaceID)\n\t\t\t\t\tmDNS_Reconfirm_internal(m, rr, kDefaultReconfirmTimeForCableDisconnect);\n\t\t}\n\n\tmDNS_Unlock(m);\n\t}",
"label": 0,
"cwe": null,
"length": 1031
},
{
"index": 550740,
"code": "ssl_io_filter_input(ap_filter_t *f,\n apr_bucket_brigade *bb,\n ap_input_mode_t mode,\n apr_read_type_e block,\n apr_off_t readbytes)\n{\n apr_status_t status;\n bio_filter_in_ctx_t *inctx = f->ctx;\n const char *start = inctx->buffer; /* start of block to return */\n apr_size_t len = sizeof(inctx->buffer); /* length of block to return */\n int is_init = (mode == AP_MODE_INIT);\n\n if (f->c->aborted) {\n /* XXX: Ok, if we aborted, we ARE at the EOS. We also have\n * aborted. This 'double protection' is probably redundant,\n * but also effective against just about anything.\n */\n apr_bucket *bucket = apr_bucket_eos_create(f->c->bucket_alloc);\n APR_BRIGADE_INSERT_TAIL(bb, bucket);\n return APR_ECONNABORTED;\n }\n\n if (!inctx->ssl) {\n SSLConnRec *sslconn = myConnConfig(f->c);\n if (sslconn->non_ssl_request == NON_SSL_SEND_HDR_SEP) {\n apr_bucket *bucket = apr_bucket_immortal_create(CRLF, 2, f->c->bucket_alloc);\n APR_BRIGADE_INSERT_TAIL(bb, bucket);\n sslconn->non_ssl_request = NON_SSL_SET_ERROR_MSG;\n return APR_SUCCESS;\n }\n return ap_get_brigade(f->next, bb, mode, block, readbytes);\n }\n\n /* XXX: we don't currently support anything other than these modes. */\n if (mode != AP_MODE_READBYTES && mode != AP_MODE_GETLINE &&\n mode != AP_MODE_SPECULATIVE && mode != AP_MODE_INIT) {\n return APR_ENOTIMPL;\n }\n\n inctx->mode = mode;\n inctx->block = block;\n\n /* XXX: we could actually move ssl_io_filter_handshake to an\n * ap_hook_process_connection but would still need to call it for\n * AP_MODE_INIT for protocols that may upgrade the connection\n * rather than have SSLEngine On configured.\n */\n if ((status = ssl_io_filter_handshake(inctx->filter_ctx)) != APR_SUCCESS) {\n return ssl_io_filter_error(f, bb, status);\n }\n\n if (is_init) {\n /* protocol module needs to handshake before sending\n * data to client (e.g. NNTP or FTP)\n */\n return APR_SUCCESS;\n }\n\n if (inctx->mode == AP_MODE_READBYTES ||\n inctx->mode == AP_MODE_SPECULATIVE) {\n /* Protected from truncation, readbytes < MAX_SIZE_T\n * FIXME: No, it's *not* protected. -- jre */\n if (readbytes < len) {\n len = (apr_size_t)readbytes;\n }\n status = ssl_io_input_read(inctx, inctx->buffer, &len);\n }\n else if (inctx->mode == AP_MODE_GETLINE) {\n const char *pos;\n\n /* Satisfy the read directly out of the buffer if possible;\n * invoking ssl_io_input_getline will mean the entire buffer\n * is copied once (unnecessarily) for each GETLINE call. */\n if (inctx->cbuf.length\n && (pos = memchr(inctx->cbuf.value, APR_ASCII_LF,\n inctx->cbuf.length)) != NULL) {\n start = inctx->cbuf.value;\n len = 1 + pos - start; /* +1 to include LF */\n /* Buffer contents now consumed. */\n inctx->cbuf.value += len;\n inctx->cbuf.length -= len;\n status = APR_SUCCESS;\n }\n else {\n /* Otherwise fall back to the hard way. */\n status = ssl_io_input_getline(inctx, inctx->buffer, &len);\n }\n }\n else {\n /* We have no idea what you are talking about, so return an error. */\n status = APR_ENOTIMPL;\n }\n\n /* It is possible for mod_ssl's BIO to be used outside of the\n * direct control of mod_ssl's input or output filter -- notably,\n * when mod_ssl initiates a renegotiation. Switching the BIO mode\n * back to \"blocking\" here ensures such operations don't fail with\n * SSL_ERROR_WANT_READ. */\n inctx->block = APR_BLOCK_READ;\n\n /* Handle custom errors. */\n if (status != APR_SUCCESS) {\n return ssl_io_filter_error(f, bb, status);\n }\n\n /* Create a transient bucket out of the decrypted data. */\n if (len > 0) {\n apr_bucket *bucket =\n apr_bucket_transient_create(start, len, f->c->bucket_alloc);\n APR_BRIGADE_INSERT_TAIL(bb, bucket);\n }\n\n return APR_SUCCESS;\n}",
"label": 1,
"cwe": [
"CWE-119",
"CWE-120"
],
"length": 1055
},
{
"index": 16960,
"code": "find_zone_movable_pfns_for_nodes(void)\n{\n\tint i, nid;\n\tunsigned long usable_startpfn;\n\tunsigned long kernelcore_node, kernelcore_remaining;\n\t/* save the state before borrow the nodemask */\n\tnodemask_t saved_node_state = node_states[N_MEMORY];\n\tunsigned long totalpages = early_calculate_totalpages();\n\tint usable_nodes = nodes_weight(node_states[N_MEMORY]);\n\tstruct memblock_region *r;\n\n\t/* Need to find movable_zone earlier when movable_node is specified. */\n\tfind_usable_zone_for_movable();\n\n\t/*\n\t * If movable_node is specified, ignore kernelcore and movablecore\n\t * options.\n\t */\n\tif (movable_node_is_enabled()) {\n\t\tfor_each_memblock(memory, r) {\n\t\t\tif (!memblock_is_hotpluggable(r))\n\t\t\t\tcontinue;\n\n\t\t\tnid = r->nid;\n\n\t\t\tusable_startpfn = PFN_DOWN(r->base);\n\t\t\tzone_movable_pfn[nid] = zone_movable_pfn[nid] ?\n\t\t\t\tmin(usable_startpfn, zone_movable_pfn[nid]) :\n\t\t\t\tusable_startpfn;\n\t\t}\n\n\t\tgoto out2;\n\t}\n\n\t/*\n\t * If movablecore=nn[KMG] was specified, calculate what size of\n\t * kernelcore that corresponds so that memory usable for\n\t * any allocation type is evenly spread. If both kernelcore\n\t * and movablecore are specified, then the value of kernelcore\n\t * will be used for required_kernelcore if it's greater than\n\t * what movablecore would have allowed.\n\t */\n\tif (required_movablecore) {\n\t\tunsigned long corepages;\n\n\t\t/*\n\t\t * Round-up so that ZONE_MOVABLE is at least as large as what\n\t\t * was requested by the user\n\t\t */\n\t\trequired_movablecore =\n\t\t\troundup(required_movablecore, MAX_ORDER_NR_PAGES);\n\t\trequired_movablecore = min(totalpages, required_movablecore);\n\t\tcorepages = totalpages - required_movablecore;\n\n\t\trequired_kernelcore = max(required_kernelcore, corepages);\n\t}\n\n\t/*\n\t * If kernelcore was not specified or kernelcore size is larger\n\t * than totalpages, there is no ZONE_MOVABLE.\n\t */\n\tif (!required_kernelcore || required_kernelcore >= totalpages)\n\t\tgoto out;\n\n\t/* usable_startpfn is the lowest possible pfn ZONE_MOVABLE can be at */\n\tusable_startpfn = arch_zone_lowest_possible_pfn[movable_zone];\n\nrestart:\n\t/* Spread kernelcore memory as evenly as possible throughout nodes */\n\tkernelcore_node = required_kernelcore / usable_nodes;\n\tfor_each_node_state(nid, N_MEMORY) {\n\t\tunsigned long start_pfn, end_pfn;\n\n\t\t/*\n\t\t * Recalculate kernelcore_node if the division per node\n\t\t * now exceeds what is necessary to satisfy the requested\n\t\t * amount of memory for the kernel\n\t\t */\n\t\tif (required_kernelcore < kernelcore_node)\n\t\t\tkernelcore_node = required_kernelcore / usable_nodes;\n\n\t\t/*\n\t\t * As the map is walked, we track how much memory is usable\n\t\t * by the kernel using kernelcore_remaining. When it is\n\t\t * 0, the rest of the node is usable by ZONE_MOVABLE\n\t\t */\n\t\tkernelcore_remaining = kernelcore_node;\n\n\t\t/* Go through each range of PFNs within this node */\n\t\tfor_each_mem_pfn_range(i, nid, &start_pfn, &end_pfn, NULL) {\n\t\t\tunsigned long size_pages;\n\n\t\t\tstart_pfn = max(start_pfn, zone_movable_pfn[nid]);\n\t\t\tif (start_pfn >= end_pfn)\n\t\t\t\tcontinue;\n\n\t\t\t/* Account for what is only usable for kernelcore */\n\t\t\tif (start_pfn < usable_startpfn) {\n\t\t\t\tunsigned long kernel_pages;\n\t\t\t\tkernel_pages = min(end_pfn, usable_startpfn)\n\t\t\t\t\t\t\t\t- start_pfn;\n\n\t\t\t\tkernelcore_remaining -= min(kernel_pages,\n\t\t\t\t\t\t\tkernelcore_remaining);\n\t\t\t\trequired_kernelcore -= min(kernel_pages,\n\t\t\t\t\t\t\trequired_kernelcore);\n\n\t\t\t\t/* Continue if range is now fully accounted */\n\t\t\t\tif (end_pfn <= usable_startpfn) {\n\n\t\t\t\t\t/*\n\t\t\t\t\t * Push zone_movable_pfn to the end so\n\t\t\t\t\t * that if we have to rebalance\n\t\t\t\t\t * kernelcore across nodes, we will\n\t\t\t\t\t * not double account here\n\t\t\t\t\t */\n\t\t\t\t\tzone_movable_pfn[nid] = end_pfn;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tstart_pfn = usable_startpfn;\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * The usable PFN range for ZONE_MOVABLE is from\n\t\t\t * start_pfn->end_pfn. Calculate size_pages as the\n\t\t\t * number of pages used as kernelcore\n\t\t\t */\n\t\t\tsize_pages = end_pfn - start_pfn;\n\t\t\tif (size_pages > kernelcore_remaining)\n\t\t\t\tsize_pages = kernelcore_remaining;\n\t\t\tzone_movable_pfn[nid] = start_pfn + size_pages;\n\n\t\t\t/*\n\t\t\t * Some kernelcore has been met, update counts and\n\t\t\t * break if the kernelcore for this node has been\n\t\t\t * satisfied\n\t\t\t */\n\t\t\trequired_kernelcore -= min(required_kernelcore,\n\t\t\t\t\t\t\t\tsize_pages);\n\t\t\tkernelcore_remaining -= size_pages;\n\t\t\tif (!kernelcore_remaining)\n\t\t\t\tbreak;\n\t\t}\n\t}\n\n\t/*\n\t * If there is still required_kernelcore, we do another pass with one\n\t * less node in the count. This will push zone_movable_pfn[nid] further\n\t * along on the nodes that still have memory until kernelcore is\n\t * satisfied\n\t */\n\tusable_nodes--;\n\tif (usable_nodes && required_kernelcore > usable_nodes)\n\t\tgoto restart;\n\nout2:\n\t/* Align start of ZONE_MOVABLE on all nids to MAX_ORDER_NR_PAGES */\n\tfor (nid = 0; nid < MAX_NUMNODES; nid++)\n\t\tzone_movable_pfn[nid] =\n\t\t\troundup(zone_movable_pfn[nid], MAX_ORDER_NR_PAGES);\n\nout:\n\t/* restore the node_state */\n\tnode_states[N_MEMORY] = saved_node_state;\n}",
"label": 0,
"cwe": null,
"length": 1297
},
{
"index": 1005651,
"code": "ExecUpdate(TupleTableSlot *slot,\n\t\t ItemPointer tupleid,\n\t\t TupleTableSlot *planSlot,\n\t\t DestReceiver *dest,\n\t\t EState *estate)\n{\n\tHeapTuple\ttuple;\n\tResultRelInfo *resultRelInfo;\n\tRelation\tresultRelationDesc;\n\tHTSU_Result result;\n\tItemPointerData update_ctid;\n\tTransactionId update_xmax;\n\n\t/*\n\t * abort the operation if not running transactions\n\t */\n\tif (IsBootstrapProcessingMode())\n\t\telog(ERROR, \"cannot UPDATE during bootstrap\");\n\n\t/*\n\t * get the heap tuple out of the tuple table slot, making sure we have a\n\t * writable copy\n\t */\n\ttuple = ExecMaterializeSlot(slot);\n\n\t/*\n\t * get information on the (current) result relation\n\t */\n\tresultRelInfo = estate->es_result_relation_info;\n\tresultRelationDesc = resultRelInfo->ri_RelationDesc;\n\n\t/* BEFORE ROW UPDATE Triggers */\n\tif (resultRelInfo->ri_TrigDesc &&\n\t\tresultRelInfo->ri_TrigDesc->n_before_row[TRIGGER_EVENT_UPDATE] > 0)\n\t{\n\t\tHeapTuple\tnewtuple;\n\n\t\tnewtuple = ExecBRUpdateTriggers(estate, resultRelInfo,\n\t\t\t\t\t\t\t\t\t\ttupleid, tuple);\n\n\t\tif (newtuple == NULL)\t/* \"do nothing\" */\n\t\t\treturn;\n\n\t\tif (newtuple != tuple)\t/* modified by Trigger(s) */\n\t\t{\n\t\t\t/*\n\t\t\t * Put the modified tuple into a slot for convenience of routines\n\t\t\t * below. We assume the tuple was allocated in per-tuple memory\n\t\t\t * context, and therefore will go away by itself. The tuple table\n\t\t\t * slot should not try to clear it.\n\t\t\t */\n\t\t\tTupleTableSlot *newslot = estate->es_trig_tuple_slot;\n\n\t\t\tif (newslot->tts_tupleDescriptor != slot->tts_tupleDescriptor)\n\t\t\t\tExecSetSlotDescriptor(newslot, slot->tts_tupleDescriptor);\n\t\t\tExecStoreTuple(newtuple, newslot, InvalidBuffer, false);\n\t\t\tslot = newslot;\n\t\t\ttuple = newtuple;\n\t\t}\n\t}\n\n\t/*\n\t * Check the constraints of the tuple\n\t *\n\t * If we generate a new candidate tuple after EvalPlanQual testing, we\n\t * must loop back here and recheck constraints. (We don't need to redo\n\t * triggers, however. If there are any BEFORE triggers then trigger.c\n\t * will have done heap_lock_tuple to lock the correct tuple, so there's no\n\t * need to do them again.)\n\t */\nlreplace:;\n\tif (resultRelationDesc->rd_att->constr)\n\t\tExecConstraints(resultRelInfo, slot, estate);\n\n\t/*\n\t * replace the heap tuple\n\t *\n\t * Note: if es_crosscheck_snapshot isn't InvalidSnapshot, we check that\n\t * the row to be updated is visible to that snapshot, and throw a can't-\n\t * serialize error if not.\tThis is a special-case behavior needed for\n\t * referential integrity updates in serializable transactions.\n\t */\n\tresult = heap_update(resultRelationDesc, tupleid, tuple,\n\t\t\t\t\t\t &update_ctid, &update_xmax,\n\t\t\t\t\t\t estate->es_output_cid,\n\t\t\t\t\t\t estate->es_crosscheck_snapshot,\n\t\t\t\t\t\t true /* wait for commit */ );\n\tswitch (result)\n\t{\n\t\tcase HeapTupleSelfUpdated:\n\t\t\t/* already deleted by self; nothing to do */\n\t\t\treturn;\n\n\t\tcase HeapTupleMayBeUpdated:\n\t\t\tbreak;\n\n\t\tcase HeapTupleUpdated:\n\t\t\tif (IsXactIsoLevelSerializable)\n\t\t\t\tereport(ERROR,\n\t\t\t\t\t\t(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),\n\t\t\t\t\t\t errmsg(\"could not serialize access due to concurrent update\")));\n\t\t\telse if (!ItemPointerEquals(tupleid, &update_ctid))\n\t\t\t{\n\t\t\t\tTupleTableSlot *epqslot;\n\n\t\t\t\tepqslot = EvalPlanQual(estate,\n\t\t\t\t\t\t\t\t\t resultRelInfo->ri_RangeTableIndex,\n\t\t\t\t\t\t\t\t\t &update_ctid,\n\t\t\t\t\t\t\t\t\t update_xmax);\n\t\t\t\tif (!TupIsNull(epqslot))\n\t\t\t\t{\n\t\t\t\t\t*tupleid = update_ctid;\n\t\t\t\t\tslot = ExecFilterJunk(estate->es_junkFilter, epqslot);\n\t\t\t\t\ttuple = ExecMaterializeSlot(slot);\n\t\t\t\t\tgoto lreplace;\n\t\t\t\t}\n\t\t\t}\n\t\t\t/* tuple already deleted; nothing to do */\n\t\t\treturn;\n\n\t\tdefault:\n\t\t\telog(ERROR, \"unrecognized heap_update status: %u\", result);\n\t\t\treturn;\n\t}\n\n\tIncrReplaced();\n\t(estate->es_processed)++;\n\n\t/*\n\t * Note: instead of having to update the old index tuples associated with\n\t * the heap tuple, all we do is form and insert new index tuples. This is\n\t * because UPDATEs are actually DELETEs and INSERTs, and index tuple\n\t * deletion is done later by VACUUM (see notes in ExecDelete).\tAll we do\n\t * here is insert new index tuples. -cim 9/27/89\n\t */\n\n\t/*\n\t * insert index entries for tuple\n\t *\n\t * Note: heap_update returns the tid (location) of the new tuple in the\n\t * t_self field.\n\t *\n\t * If it's a HOT update, we mustn't insert new index entries.\n\t */\n\tif (resultRelInfo->ri_NumIndices > 0 && !HeapTupleIsHeapOnly(tuple))\n\t\tExecInsertIndexTuples(slot, &(tuple->t_self), estate, false);\n\n\t/* AFTER ROW UPDATE Triggers */\n\tExecARUpdateTriggers(estate, resultRelInfo, tupleid, tuple);\n\n\t/* Process RETURNING if present */\n\tif (resultRelInfo->ri_projectReturning)\n\t\tExecProcessReturning(resultRelInfo->ri_projectReturning,\n\t\t\t\t\t\t\t slot, planSlot, dest);\n}",
"label": 0,
"cwe": null,
"length": 1218
},
{
"index": 577973,
"code": "main_orig( int argc, char *argv[] )\n\n{\n /* resulting name for ops file\n */\n char ops_file[MAX_LENGTH] = \"\";\n /* same for fct file \n */\n char fct_file[MAX_LENGTH] = \"\";\n \n gcmd_line.cnflayer = -1;\n gcmd_line.cnfout = -1;\n gcmd_line.solverOut = FALSE;\n gcmd_line.prune = FALSE;\n gcmd_line.binary_clause_only = 0;\n strcpy(gcmd_line.cnfFileName, \"CNF\");\n gcmd_line.makeCNF = 0;\n\n /* command line treatment\n */\n if ( argc == 1 || ( argc == 2 && *++argv[0] == '?' ) ) {\n bb_usage();\n exit( 1 );\n }\n if ( !process_command_line( argc, argv ) ) {\n printf(\"\\n\\nEXIT: bad arguments detected\\n\\n\");\n bb_usage(); \n exit( 1 );\n }\n\n\n /* make file names\n */\n\n /* one input name missing\n */\n if ( !gcmd_line.ops_file_name || \n !gcmd_line.fct_file_name ) {\n fprintf(stdout, \"\\nbb: two input files needed\\n\\n\");\n bb_usage(); \n exit( 1 );\n }\n /* add path info, complete file names will be stored in\n * ops_file and fct_file \n */\n sprintf(ops_file, \"%s%s\", gcmd_line.path, gcmd_line.ops_file_name);\n sprintf(fct_file, \"%s%s\", gcmd_line.path, gcmd_line.fct_file_name);\n\n\n /* parse the input files\n */\n\n /* start parse & instantiation timing\n */\n times( &start ); \n /* domain file (ops)\n */\n if ( gcmd_line.display_info >= 1 ) {\n printf(\"\\nbb: parsing domain file\");\n } \n /* it is important for the pddl language to define the domain before \n * reading the problem \n */\n load_ops_file( ops_file );\n /* problem file (facts)\n */ \n if ( gcmd_line.display_info >= 1 ) {\n printf(\" ... done.\\nbb: parsing problem file\"); \n }\n load_fct_file( fct_file );\n if ( gcmd_line.display_info >= 1 ) {\n printf(\" ... done.\\n\\n\");\n }\n\n /* This is needed to get all types.\n */\n build_orig_constant_list();\n\n /* last step of parsing: see if it's a STRIPS domain!\n */\n if ( !make_strips_domain() ) {\n printf(\"\\n\\nEXIT: bb: this is not a STRIPS problem! can't be handled by this version.\\n\\n\");\n exit( 1 );\n }\n\n /* now instantiate operators; \n */\n\n /* start by collecting all strings and thereby encoding \n * the domain in integers.\n */\n encode_domain_in_integers();\n\n /* inertia preprocessing:\n * - collect inertia information\n * - split initial state into\n * - types for unary inertia\n * - array containing all inertia relations\n * - array containing non - static relations\n * - encode unary inertia in op preconds into types\n */\n do_inertia_preprocessing();\n\n /* unify inertia preconds with initial state,\n * then multiply remaining parameters;\n * create one ActionTemplate for each possible parameter combination\n *\n * --- the actual instantiation part, creating all possible instances ---\n */\n build_action_templates();\n\n times(&end);\n TIME( gtempl_time );\n\n times(&start);\n\n /* perform a simple reachabilty analysis\n * (added facts fixpoint)\n * to find out which facts can (at most) be made true in domain\n */\n perform_reachability_analysis();\n\n times(&end);\n TIME( greach_time );\n\n times(&start);\n\n /* as a last step, collect relevant facts (deleted ini's and\n * added non ini's) and remove others from domain\n */\n collect_relevant_facts();\n\n times(&end);\n TIME( grelev_time );\n \n output_planner_info(); \n return 0; \n \n times(&start);\n \n /* now build globally accessible connectivity graph\n */\n build_connectivity_graph();\n\n /* insert bit vectors for fast lookup\n *\n * (NOTE: bit vector sizes are static across graph here;\n * (in difference to IPP) -- otherwise pre-computation \n * not possible as done in these parts)\n */\n insert_bit_vectors();\n \n\n times(&end);\n TIME( gconn_time );\n\n /* output CNF file */\n times(&start);\n do_cnf_output(gcmd_line.makeCNF);\n times(&end);\n TIME ( gcnf_time );\n \n output_planner_info();\n\n if ( gcmd_line.makeCNF != 0 ) /* output solution file */\n exit(create_solution());\n exit( SAT );\n}",
"label": 1,
"cwe": [
"CWE-119",
"CWE-120"
],
"length": 1072
},
{
"index": 232785,
"code": "dessertMeshifTable_container_load(netsnmp_container * container)\n{\n dessertMeshifTable_rowreq_ctx *rowreq_ctx;\n dessert_meshif_t *meshif;\n size_t count = 0;\n\n char inPkts[I64CHARSZ+1];\n char outPkts[I64CHARSZ+1];\n char inOctets[I64CHARSZ+1];\n char outOctets[I64CHARSZ+1];\n\n /*\n * temporary storage for index values\n */\n /*\n * meshifIndex(1)///()//L/a/w/e/r/d/h\n */\n long meshifIndex = -1;\n\n dessert_debug(\"dessertMeshifTable_container_load called\");\n DEBUGMSGTL((\"verbose:dessertMeshifTable:dessertMeshifTable_container_load\", \"called\\n\"));\n\n\n\n\t/*\n\t * TODO:351:M: |-> Load/update data in the dessertMeshifTable container.\n\t * loop over your dessertMeshifTable data, allocate a rowreq context,\n\t * set the index(es) [and data, optionally] and insert into\n\t * the container.\n\t */\n pthread_rwlock_rdlock(&dessert_cfglock);\n\tDL_FOREACH(dessert_meshiflist_get(), meshif){\n\n\t\tmeshifIndex = ++count;\n\n\t\t/*\n\t\t * TODO:352:M: | |-> set indexes in new dessertMeshifTable rowreq context.\n\t\t * data context will be set from the param (unless NULL,\n\t\t * in which case a new data context will be allocated)\n\t\t */\n\t\trowreq_ctx = dessertMeshifTable_allocate_rowreq_ctx(NULL);\n\t\tif (NULL == rowreq_ctx) {\n\t\t\tsnmp_log(LOG_ERR, \"memory allocation failed\\n\");\n\t\t\tpthread_rwlock_unlock(&dessert_cfglock);\n\t\t\treturn MFD_RESOURCE_UNAVAILABLE;\n\t\t}\n\n\t\tif (MFD_SUCCESS != dessertMeshifTable_indexes_set(rowreq_ctx,\n\t\t\t\tmeshifIndex)) {\n\t\t\tsnmp_log(LOG_ERR, \"error setting index while loading \"\n\t\t\t\t\"dessertMeshifTable data.\\n\");\n\t\t\tdessertMeshifTable_release_rowreq_ctx(rowreq_ctx);\n\t\t\tcontinue;\n\t\t}\n\n\t\t/*\n\t\t * TODO:352:r: | |-> populate dessertMeshifTable data context.\n\t\t * Populate data context here. (optionally, delay until row prep)\n\t\t */\n\n\t\trowreq_ctx->data.meshifName_len = strlen(meshif->if_name);\n\t\tstrcpy(rowreq_ctx->data.meshifName, meshif->if_name);\n\n\t\trowreq_ctx->data.meshifMacAddress_len = 6;\n\t\tmemcpy(rowreq_ctx->data.meshifMacAddress, meshif->hwaddr, 6);\n\n\t\tpthread_mutex_lock(&(meshif->cnt_mutex));\n\n\t\trowreq_ctx->data.meshifInPkts.low = meshif->ipkts & 0xffffffff;\n\t\trowreq_ctx->data.meshifInPkts.high = meshif->ipkts >> 32;\n\n\t\trowreq_ctx->data.meshifOutPkts.low = meshif->opkts & 0xffffffff;\n\t\trowreq_ctx->data.meshifOutPkts.high = meshif->opkts >> 32;\n\n\t\trowreq_ctx->data.meshifInOctets.low = meshif->ibytes & 0xffffffff;\n\t\trowreq_ctx->data.meshifInOctets.high = meshif->ibytes >> 32;\n\n\t\trowreq_ctx->data.meshifOutOctets.low = meshif->obytes & 0xffffffff;\n\t\trowreq_ctx->data.meshifOutOctets.high = meshif->obytes >> 32;\n\n\n\t\tprintU64(inPkts, &rowreq_ctx->data.meshifInPkts);\n\t\tprintU64(outPkts, &rowreq_ctx->data.meshifOutPkts);\n\t\tprintU64(inOctets, &rowreq_ctx->data.meshifInOctets);\n\t\tprintU64(outOctets, &rowreq_ctx->data.meshifOutOctets);\n\n\n\t\tdessert_debug(\"inPkts [%s] [%u]\", inPkts, meshif->ipkts);\n\t\tdessert_debug(\"outPkts [%s] [%u]\", outPkts, meshif->opkts);\n\t\tdessert_debug(\"inOctets [%s] [%u]\", inOctets, meshif->ibytes);\n\t\tdessert_debug(\"outOctets [%s] [%u]\", outOctets,meshif->obytes);\n\n\n\t\tpthread_mutex_unlock(&(meshif->cnt_mutex));\n\n\t\t/*\n\t\t * insert into table container\n\t\t */\n\t\tCONTAINER_INSERT(container, rowreq_ctx);\n\t}\n\tpthread_rwlock_unlock(&dessert_cfglock);\n\n\n\n DEBUGMSGT((\"verbose:dessertMeshifTable:dessertMeshifTable_container_load\", \"inserted %d records\\n\", count));\n\n if (meshifIndex == -1) return MFD_RESOURCE_UNAVAILABLE;\n\n return MFD_SUCCESS;\n}",
"label": 1,
"cwe": [
"CWE-119",
"CWE-120"
],
"length": 1058
},
{
"index": 344316,
"code": "data_out_phase0(struct AdapterCtlBlk *acb, struct ScsiReqBlk *srb,\n\t\tu16 *pscsi_status)\n{\n\tstruct DeviceCtlBlk *dcb = srb->dcb;\n\tu16 scsi_status = *pscsi_status;\n\tu32 d_left_counter = 0;\n\tdprintkdbg(DBG_0, \"data_out_phase0: (0x%p) <%02i-%i>\\n\",\n\t\tsrb->cmd, srb->cmd->device->id, (u8)srb->cmd->device->lun);\n\n\t/*\n\t * KG: We need to drain the buffers before we draw any conclusions!\n\t * This means telling the DMA to push the rest into SCSI, telling\n\t * SCSI to push the rest to the bus.\n\t * However, the device might have been the one to stop us (phase\n\t * change), and the data in transit just needs to be accounted so\n\t * it can be retransmitted.)\n\t */\n\t/* \n\t * KG: Stop DMA engine pushing more data into the SCSI FIFO\n\t * If we need more data, the DMA SG list will be freshly set up, anyway\n\t */\n\tdprintkdbg(DBG_PIO, \"data_out_phase0: \"\n\t\t\"DMA{fifocnt=0x%02x fifostat=0x%02x} \"\n\t\t\"SCSI{fifocnt=0x%02x cnt=0x%06x status=0x%04x} total=0x%06x\\n\",\n\t\tDC395x_read8(acb, TRM_S1040_DMA_FIFOCNT),\n\t\tDC395x_read8(acb, TRM_S1040_DMA_FIFOSTAT),\n\t\tDC395x_read8(acb, TRM_S1040_SCSI_FIFOCNT),\n\t\tDC395x_read32(acb, TRM_S1040_SCSI_COUNTER), scsi_status,\n\t\tsrb->total_xfer_length);\n\tDC395x_write8(acb, TRM_S1040_DMA_CONTROL, STOPDMAXFER | CLRXFIFO);\n\n\tif (!(srb->state & SRB_XFERPAD)) {\n\t\tif (scsi_status & PARITYERROR)\n\t\t\tsrb->status |= PARITY_ERROR;\n\n\t\t/*\n\t\t * KG: Right, we can't just rely on the SCSI_COUNTER, because this\n\t\t * is the no of bytes it got from the DMA engine not the no it \n\t\t * transferred successfully to the device. (And the difference could\n\t\t * be as much as the FIFO size, I guess ...)\n\t\t */\n\t\tif (!(scsi_status & SCSIXFERDONE)) {\n\t\t\t/*\n\t\t\t * when data transfer from DMA FIFO to SCSI FIFO\n\t\t\t * if there was some data left in SCSI FIFO\n\t\t\t */\n\t\t\td_left_counter =\n\t\t\t (u32)(DC395x_read8(acb, TRM_S1040_SCSI_FIFOCNT) &\n\t\t\t\t 0x1F);\n\t\t\tif (dcb->sync_period & WIDE_SYNC)\n\t\t\t\td_left_counter <<= 1;\n\n\t\t\tdprintkdbg(DBG_KG, \"data_out_phase0: FIFO contains %i %s\\n\"\n\t\t\t\t\"SCSI{fifocnt=0x%02x cnt=0x%08x} \"\n\t\t\t\t\"DMA{fifocnt=0x%04x cnt=0x%02x ctr=0x%08x}\\n\",\n\t\t\t\tDC395x_read8(acb, TRM_S1040_SCSI_FIFOCNT),\n\t\t\t\t(dcb->sync_period & WIDE_SYNC) ? \"words\" : \"bytes\",\n\t\t\t\tDC395x_read8(acb, TRM_S1040_SCSI_FIFOCNT),\n\t\t\t\tDC395x_read32(acb, TRM_S1040_SCSI_COUNTER),\n\t\t\t\tDC395x_read8(acb, TRM_S1040_DMA_FIFOCNT),\n\t\t\t\tDC395x_read8(acb, TRM_S1040_DMA_FIFOSTAT),\n\t\t\t\tDC395x_read32(acb, TRM_S1040_DMA_CXCNT));\n\t\t}\n\t\t/*\n\t\t * calculate all the residue data that not yet tranfered\n\t\t * SCSI transfer counter + left in SCSI FIFO data\n\t\t *\n\t\t * .....TRM_S1040_SCSI_COUNTER (24bits)\n\t\t * The counter always decrement by one for every SCSI byte transfer.\n\t\t * .....TRM_S1040_SCSI_FIFOCNT ( 5bits)\n\t\t * The counter is SCSI FIFO offset counter (in units of bytes or! words)\n\t\t */\n\t\tif (srb->total_xfer_length > DC395x_LASTPIO)\n\t\t\td_left_counter +=\n\t\t\t DC395x_read32(acb, TRM_S1040_SCSI_COUNTER);\n\n\t\t/* Is this a good idea? */\n\t\t/*clear_fifo(acb, \"DOP1\"); */\n\t\t/* KG: What is this supposed to be useful for? WIDE padding stuff? */\n\t\tif (d_left_counter == 1 && dcb->sync_period & WIDE_SYNC\n\t\t && scsi_bufflen(srb->cmd) % 2) {\n\t\t\td_left_counter = 0;\n\t\t\tdprintkl(KERN_INFO,\n\t\t\t\t\"data_out_phase0: Discard 1 byte (0x%02x)\\n\",\n\t\t\t\tscsi_status);\n\t\t}\n\t\t/*\n\t\t * KG: Oops again. Same thinko as above: The SCSI might have been\n\t\t * faster than the DMA engine, so that it ran out of data.\n\t\t * In that case, we have to do just nothing! \n\t\t * But: Why the interrupt: No phase change. No XFERCNT_2_ZERO. Or?\n\t\t */\n\t\t/*\n\t\t * KG: This is nonsense: We have been WRITING data to the bus\n\t\t * If the SCSI engine has no bytes left, how should the DMA engine?\n\t\t */\n\t\tif (d_left_counter == 0) {\n\t\t\tsrb->total_xfer_length = 0;\n\t\t} else {\n\t\t\t/*\n\t\t\t * if transfer not yet complete\n\t\t\t * there were some data residue in SCSI FIFO or\n\t\t\t * SCSI transfer counter not empty\n\t\t\t */\n\t\t\tlong oldxferred =\n\t\t\t srb->total_xfer_length - d_left_counter;\n\t\t\tconst int diff =\n\t\t\t (dcb->sync_period & WIDE_SYNC) ? 2 : 1;\n\t\t\tsg_update_list(srb, d_left_counter);\n\t\t\t/* KG: Most ugly hack! Apparently, this works around a chip bug */\n\t\t\tif ((srb->segment_x[srb->sg_index].length ==\n\t\t\t diff && scsi_sg_count(srb->cmd))\n\t\t\t || ((oldxferred & ~PAGE_MASK) ==\n\t\t\t\t(PAGE_SIZE - diff))\n\t\t\t ) {\n\t\t\t\tdprintkl(KERN_INFO, \"data_out_phase0: \"\n\t\t\t\t\t\"Work around chip bug (%i)?\\n\", diff);\n\t\t\t\td_left_counter =\n\t\t\t\t srb->total_xfer_length - diff;\n\t\t\t\tsg_update_list(srb, d_left_counter);\n\t\t\t\t/*srb->total_xfer_length -= diff; */\n\t\t\t\t/*srb->virt_addr += diff; */\n\t\t\t\t/*if (srb->cmd->use_sg) */\n\t\t\t\t/* srb->sg_index++; */\n\t\t\t}\n\t\t}\n\t}\n\tif ((*pscsi_status & PHASEMASK) != PH_DATA_OUT) {\n\t\tcleanup_after_transfer(acb, srb);\n\t}\n}",
"label": 0,
"cwe": null,
"length": 1598
},
{
"index": 943596,
"code": "as_mysql_monthly_rollup(mysql_conn_t *mysql_conn,\n\t\t\t\t char *cluster_name,\n\t\t\t\t time_t start, time_t end,\n\t\t\t\t uint16_t archive_data)\n{\n\tint rc = SLURM_SUCCESS;\n\tstruct tm start_tm;\n\ttime_t curr_start = start;\n\ttime_t curr_end;\n\ttime_t now = time(NULL);\n\tchar *query = NULL;\n\tuint16_t track_wckey = slurm_get_track_wckey();\n\n\tif (!localtime_r(&curr_start, &start_tm)) {\n\t\terror(\"Couldn't get localtime from month start %ld\",\n\t\t curr_start);\n\t\treturn SLURM_ERROR;\n\t}\n\tstart_tm.tm_sec = 0;\n\tstart_tm.tm_min = 0;\n\tstart_tm.tm_hour = 0;\n\tstart_tm.tm_mday = 1;\n\tstart_tm.tm_mon++;\n\tstart_tm.tm_isdst = -1;\n\tcurr_end = mktime(&start_tm);\n\n\twhile (curr_start < end) {\n\t\tdebug3(\"curr month is now %ld-%ld\", curr_start, curr_end);\n/* \t\tinfo(\"start %s\", ctime(&curr_start)); */\n/* \t\tinfo(\"end %s\", ctime(&curr_end)); */\n\t\tquery = xstrdup_printf(\n\t\t\t\"insert into \\\"%s_%s\\\" (creation_time, \"\n\t\t\t\"mod_time, id_assoc, \"\n\t\t\t\"time_start, alloc_cpu_secs) select \"\n\t\t\t\"%ld, %ld, id_assoc, \"\n\t\t\t\"%ld, @ASUM:=SUM(alloc_cpu_secs) from \\\"%s_%s\\\" where \"\n\t\t\t\"(time_start < %ld && time_start >= %ld) \"\n\t\t\t\"group by id_assoc on duplicate key update \"\n\t\t\t\"mod_time=%ld, alloc_cpu_secs=@ASUM;\",\n\t\t\tcluster_name, assoc_month_table, now, now, curr_start,\n\t\t\tcluster_name, assoc_day_table,\n\t\t\tcurr_end, curr_start, now);\n\t\t/* We group on deleted here so if there are no entries\n\t\t we don't get an error, just nothing is returned.\n\t\t Else we get a bunch of NULL's\n\t\t*/\n\t\txstrfmtcat(query,\n\t\t\t \"insert into \\\"%s_%s\\\" (creation_time, \"\n\t\t\t \"mod_time, time_start, cpu_count, \"\n\t\t\t \"alloc_cpu_secs, down_cpu_secs, pdown_cpu_secs, \"\n\t\t\t \"idle_cpu_secs, over_cpu_secs, resv_cpu_secs) \"\n\t\t\t \"select %ld, %ld, \"\n\t\t\t \"%ld, @CPU:=MAX(cpu_count), \"\n\t\t\t \"@ASUM:=SUM(alloc_cpu_secs), \"\n\t\t\t \"@DSUM:=SUM(down_cpu_secs), \"\n\t\t\t \"@PDSUM:=SUM(pdown_cpu_secs), \"\n\t\t\t \"@ISUM:=SUM(idle_cpu_secs), \"\n\t\t\t \"@OSUM:=SUM(over_cpu_secs), \"\n\t\t\t \"@RSUM:=SUM(resv_cpu_secs) from \\\"%s_%s\\\" where \"\n\t\t\t \"(time_start < %ld && time_start >= %ld) \"\n\t\t\t \"group by deleted \"\n\t\t\t \"on duplicate key update \"\n\t\t\t \"mod_time=%ld, cpu_count=@CPU, \"\n\t\t\t \"alloc_cpu_secs=@ASUM, down_cpu_secs=@DSUM, \"\n\t\t\t \"pdown_cpu_secs=@PDSUM, idle_cpu_secs=@ISUM, \"\n\t\t\t \"over_cpu_secs=@OSUM, resv_cpu_secs=@RSUM;\",\n\t\t\t cluster_name, cluster_month_table,\n\t\t\t now, now, curr_start,\n\t\t\t cluster_name, cluster_day_table,\n\t\t\t curr_end, curr_start, now);\n\t\tif (track_wckey) {\n\t\t\txstrfmtcat(query,\n\t\t\t\t \"insert into \\\"%s_%s\\\" \"\n\t\t\t\t \"(creation_time, mod_time, \"\n\t\t\t\t \"id_wckey, time_start, alloc_cpu_secs) \"\n\t\t\t\t \"select %ld, %ld, id_wckey, %ld, \"\n\t\t\t\t \"@ASUM:=SUM(alloc_cpu_secs) \"\n\t\t\t\t \"from \\\"%s_%s\\\" where (time_start < %ld && \"\n\t\t\t\t \"time_start >= %ld) \"\n\t\t\t\t \"group by id_wckey on duplicate key update \"\n\t\t\t\t \"mod_time=%ld, alloc_cpu_secs=@ASUM;\",\n\t\t\t\t cluster_name, wckey_month_table,\n\t\t\t\t now, now, curr_start,\n\t\t\t\t cluster_name, wckey_day_table,\n\t\t\t\t curr_end, curr_start, now);\n\t\t}\n\t\tdebug3(\"%d(%s:%d) query\\n%s\",\n\t\t mysql_conn->conn, THIS_FILE, __LINE__, query);\n\t\trc = mysql_db_query(mysql_conn, query);\n\t\txfree(query);\n\t\tif (rc != SLURM_SUCCESS) {\n\t\t\terror(\"Couldn't add day rollup\");\n\t\t\treturn SLURM_ERROR;\n\t\t}\n\n\t\tcurr_start = curr_end;\n\t\tif (!localtime_r(&curr_start, &start_tm)) {\n\t\t\terror(\"Couldn't get localtime from month start %ld\",\n\t\t\t curr_start);\n\t\t}\n\t\tstart_tm.tm_sec = 0;\n\t\tstart_tm.tm_min = 0;\n\t\tstart_tm.tm_hour = 0;\n\t\tstart_tm.tm_mday = 1;\n\t\tstart_tm.tm_mon++;\n\t\tstart_tm.tm_isdst = -1;\n\t\tcurr_end = mktime(&start_tm);\n\t}\n\n\t/* go check to see if we archive and purge */\n\trc = _process_purge(mysql_conn, cluster_name, archive_data,\n\t\t\t SLURMDB_PURGE_MONTHS);\n\n\treturn rc;\n}",
"label": 0,
"cwe": null,
"length": 1127
},
{
"index": 48969,
"code": "lpfc_sli_abort_taskmgmt(struct lpfc_vport *vport, struct lpfc_sli_ring *pring,\n\t\t\tuint16_t tgt_id, uint64_t lun_id, lpfc_ctx_cmd cmd)\n{\n\tstruct lpfc_hba *phba = vport->phba;\n\tstruct lpfc_scsi_buf *lpfc_cmd;\n\tstruct lpfc_iocbq *abtsiocbq;\n\tstruct lpfc_nodelist *ndlp;\n\tstruct lpfc_iocbq *iocbq;\n\tIOCB_t *icmd;\n\tint sum, i, ret_val;\n\tunsigned long iflags;\n\tstruct lpfc_sli_ring *pring_s4;\n\tuint32_t ring_number;\n\n\tspin_lock_irq(&phba->hbalock);\n\n\t/* all I/Os are in process of being flushed */\n\tif (phba->hba_flag & HBA_FCP_IOQ_FLUSH) {\n\t\tspin_unlock_irq(&phba->hbalock);\n\t\treturn 0;\n\t}\n\tsum = 0;\n\n\tfor (i = 1; i <= phba->sli.last_iotag; i++) {\n\t\tiocbq = phba->sli.iocbq_lookup[i];\n\n\t\tif (lpfc_sli_validate_fcp_iocb(iocbq, vport, tgt_id, lun_id,\n\t\t\t\t\t cmd) != 0)\n\t\t\tcontinue;\n\n\t\t/*\n\t\t * If the iocbq is already being aborted, don't take a second\n\t\t * action, but do count it.\n\t\t */\n\t\tif (iocbq->iocb_flag & LPFC_DRIVER_ABORTED)\n\t\t\tcontinue;\n\n\t\t/* issue ABTS for this IOCB based on iotag */\n\t\tabtsiocbq = __lpfc_sli_get_iocbq(phba);\n\t\tif (abtsiocbq == NULL)\n\t\t\tcontinue;\n\n\t\ticmd = &iocbq->iocb;\n\t\tabtsiocbq->iocb.un.acxri.abortType = ABORT_TYPE_ABTS;\n\t\tabtsiocbq->iocb.un.acxri.abortContextTag = icmd->ulpContext;\n\t\tif (phba->sli_rev == LPFC_SLI_REV4)\n\t\t\tabtsiocbq->iocb.un.acxri.abortIoTag =\n\t\t\t\t\t\t\t iocbq->sli4_xritag;\n\t\telse\n\t\t\tabtsiocbq->iocb.un.acxri.abortIoTag = icmd->ulpIoTag;\n\t\tabtsiocbq->iocb.ulpLe = 1;\n\t\tabtsiocbq->iocb.ulpClass = icmd->ulpClass;\n\t\tabtsiocbq->vport = vport;\n\n\t\t/* ABTS WQE must go to the same WQ as the WQE to be aborted */\n\t\tabtsiocbq->fcp_wqidx = iocbq->fcp_wqidx;\n\t\tif (iocbq->iocb_flag & LPFC_IO_FCP)\n\t\t\tabtsiocbq->iocb_flag |= LPFC_USE_FCPWQIDX;\n\t\tif (iocbq->iocb_flag & LPFC_IO_FOF)\n\t\t\tabtsiocbq->iocb_flag |= LPFC_IO_FOF;\n\n\t\tlpfc_cmd = container_of(iocbq, struct lpfc_scsi_buf, cur_iocbq);\n\t\tndlp = lpfc_cmd->rdata->pnode;\n\n\t\tif (lpfc_is_link_up(phba) &&\n\t\t (ndlp && ndlp->nlp_state == NLP_STE_MAPPED_NODE))\n\t\t\tabtsiocbq->iocb.ulpCommand = CMD_ABORT_XRI_CN;\n\t\telse\n\t\t\tabtsiocbq->iocb.ulpCommand = CMD_CLOSE_XRI_CN;\n\n\t\t/* Setup callback routine and issue the command. */\n\t\tabtsiocbq->iocb_cmpl = lpfc_sli_abort_fcp_cmpl;\n\n\t\t/*\n\t\t * Indicate the IO is being aborted by the driver and set\n\t\t * the caller's flag into the aborted IO.\n\t\t */\n\t\tiocbq->iocb_flag |= LPFC_DRIVER_ABORTED;\n\n\t\tif (phba->sli_rev == LPFC_SLI_REV4) {\n\t\t\tring_number = MAX_SLI3_CONFIGURED_RINGS +\n\t\t\t\t\t iocbq->fcp_wqidx;\n\t\t\tpring_s4 = &phba->sli.ring[ring_number];\n\t\t\t/* Note: both hbalock and ring_lock must be set here */\n\t\t\tspin_lock_irqsave(&pring_s4->ring_lock, iflags);\n\t\t\tret_val = __lpfc_sli_issue_iocb(phba, pring_s4->ringno,\n\t\t\t\t\t\t\tabtsiocbq, 0);\n\t\t\tspin_unlock_irqrestore(&pring_s4->ring_lock, iflags);\n\t\t} else {\n\t\t\tret_val = __lpfc_sli_issue_iocb(phba, pring->ringno,\n\t\t\t\t\t\t\tabtsiocbq, 0);\n\t\t}\n\n\n\t\tif (ret_val == IOCB_ERROR)\n\t\t\t__lpfc_sli_release_iocbq(phba, abtsiocbq);\n\t\telse\n\t\t\tsum++;\n\t}\n\tspin_unlock_irq(&phba->hbalock);\n\treturn sum;\n}",
"label": 0,
"cwe": null,
"length": 1138
},
{
"index": 19312,
"code": "ctags_visitor_to_string (ValaIterable* seq, const gchar* sep) {\n\tgchar* result = NULL;\n\tGString* _tmp0_;\n\tGString* str;\n\tgboolean first;\n\tGString* _tmp14_;\n\tconst gchar* _tmp15_;\n\tgchar* _tmp16_;\n#line 64 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\tg_return_val_if_fail (seq != NULL, NULL);\n#line 64 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\tg_return_val_if_fail (sep != NULL, NULL);\n#line 65 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t_tmp0_ = g_string_new (\"\");\n#line 65 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\tstr = _tmp0_;\n#line 66 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\tfirst = TRUE;\n#line 548 \"ctags-visitor.c\"\n\t{\n\t\tValaIterable* _tmp1_;\n\t\tValaIterator* _tmp2_ = NULL;\n\t\tValaIterator* _type_it;\n#line 67 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t_tmp1_ = seq;\n#line 67 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t_tmp2_ = vala_iterable_iterator (_tmp1_);\n#line 67 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t_type_it = _tmp2_;\n#line 67 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\twhile (TRUE) {\n#line 561 \"ctags-visitor.c\"\n\t\t\tValaIterator* _tmp3_;\n\t\t\tgboolean _tmp4_ = FALSE;\n\t\t\tValaIterator* _tmp5_;\n\t\t\tgpointer _tmp6_ = NULL;\n\t\t\tValaDataType* type;\n\t\t\tgboolean _tmp7_;\n\t\t\tGString* _tmp10_;\n\t\t\tValaDataType* _tmp11_;\n\t\t\tgchar* _tmp12_ = NULL;\n\t\t\tgchar* _tmp13_;\n#line 67 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t_tmp3_ = _type_it;\n#line 67 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t_tmp4_ = vala_iterator_next (_tmp3_);\n#line 67 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\tif (!_tmp4_) {\n#line 67 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t\tbreak;\n#line 580 \"ctags-visitor.c\"\n\t\t\t}\n#line 67 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t_tmp5_ = _type_it;\n#line 67 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t_tmp6_ = vala_iterator_get (_tmp5_);\n#line 67 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\ttype = (ValaDataType*) _tmp6_;\n#line 68 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t_tmp7_ = first;\n#line 68 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\tif (_tmp7_) {\n#line 69 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t\tfirst = FALSE;\n#line 594 \"ctags-visitor.c\"\n\t\t\t} else {\n\t\t\t\tGString* _tmp8_;\n\t\t\t\tconst gchar* _tmp9_;\n#line 71 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t\t_tmp8_ = str;\n#line 71 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t\t_tmp9_ = sep;\n#line 71 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t\tg_string_append (_tmp8_, _tmp9_);\n#line 604 \"ctags-visitor.c\"\n\t\t\t}\n#line 73 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t_tmp10_ = str;\n#line 73 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t_tmp11_ = type;\n#line 73 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t_tmp12_ = vala_data_type_to_qualified_string (_tmp11_, NULL);\n#line 73 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t_tmp13_ = _tmp12_;\n#line 73 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\tg_string_append (_tmp10_, _tmp13_);\n#line 73 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t_g_free0 (_tmp13_);\n#line 67 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t_vala_code_node_unref0 (type);\n#line 620 \"ctags-visitor.c\"\n\t\t}\n#line 67 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t_vala_iterator_unref0 (_type_it);\n#line 624 \"ctags-visitor.c\"\n\t}\n#line 75 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t_tmp14_ = str;\n#line 75 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t_tmp15_ = _tmp14_->str;\n#line 75 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t_tmp16_ = g_strdup (_tmp15_);\n#line 75 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\tresult = _tmp16_;\n#line 75 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t_g_string_free0 (str);\n#line 75 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\treturn result;\n#line 638 \"ctags-visitor.c\"\n}",
"label": 0,
"cwe": null,
"length": 1826
},
{
"index": 162804,
"code": "flmUpdateDbStats(\n\tDB_STATS *\tpDestDb,\n\tDB_STATS *\tpSrcDb\n\t)\n{\n\tRCODE\t\t\t\trc = FERR_OK;\n\tFLMUINT\t\t\tuiSrcLFile;\n\tFLMUINT\t\t\tuiDestLFile;\n\tLFILE_STATS *\tpDestLFile;\n\tLFILE_STATS *\tpSrcLFile;\n\tFLMUINT\t\t\tuiLowLFileStart;\n\tFLMUINT\t\t\tuiSaveNumLFiles;\n\n\tflmUpdateRTransStats( &pDestDb->ReadTransStats,\n\t\t\t\t\t\t\t\t &pSrcDb->ReadTransStats);\n\t\t\t\t\t\t\t\t \n\tflmUpdateUTransStats( &pDestDb->UpdateTransStats,\n\t\t\t\t\t\t\t\t &pSrcDb->UpdateTransStats);\n\t\t\t\t\t\t\t\t \n\tpDestDb->bHaveStats = TRUE;\n\tpDestDb->ui64NumCursors += pSrcDb->ui64NumCursors;\n\tpDestDb->ui64NumCursorReads += pSrcDb->ui64NumCursorReads;\n\t\n\tflmUpdateCountTimeStats( &pDestDb->RecordAdds,\n\t\t\t\t\t\t\t\t\t &pSrcDb->RecordAdds);\n\t\t\t\t\t\t\t\t\t \n\tflmUpdateCountTimeStats( &pDestDb->RecordDeletes,\n\t\t\t\t\t\t\t\t\t &pSrcDb->RecordDeletes);\n\t\t\t\t\t\t\t\t\t \n\tflmUpdateCountTimeStats( &pDestDb->RecordModifies,\n\t\t\t\t\t\t\t\t\t &pSrcDb->RecordModifies);\n\t\t\t\t\t\t\t\t\t \n\tpDestDb->ui64NumRecordReads += pSrcDb->ui64NumRecordReads;\n\t\n\tflmUpdateBlockIOStats( &pDestDb->LFHBlockStats,\n\t\t\t\t\t\t\t\t &pSrcDb->LFHBlockStats);\n\t\t\t\t\t\t\t\t \n\tflmUpdateBlockIOStats( &pDestDb->AvailBlockStats,\n\t\t\t\t\t\t\t\t &pSrcDb->AvailBlockStats);\n\t\t\t\t\t\t\t\t \n\tflmUpdateDiskIOStats( &pDestDb->LogHdrWrites,\n\t\t\t\t\t\t\t\t &pSrcDb->LogHdrWrites);\n\t\t\t\t\t\t\t\t \n\tflmUpdateDiskIOStats( &pDestDb->LogBlockWrites,\n\t\t\t\t\t\t\t\t &pSrcDb->LogBlockWrites);\n\t\t\t\t\t\t\t\t \n\tflmUpdateDiskIOStats( &pDestDb->LogBlockRestores,\n\t\t\t\t\t\t\t\t &pSrcDb->LogBlockRestores);\n\t\t\t\t\t\t\t\t \n\tflmUpdateDiskIOStats( &pDestDb->LogBlockReads,\n\t\t\t\t\t\t\t\t &pSrcDb->LogBlockReads);\n\t\t\t\t\t\t\t\t \n\tpDestDb->uiLogBlockChkErrs += pSrcDb->uiLogBlockChkErrs;\n\tpDestDb->uiReadErrors += pSrcDb->uiReadErrors;\n\tpDestDb->uiWriteErrors += pSrcDb->uiWriteErrors;\n\t\n\tflmUpdateCountTimeStats( &pDestDb->LockStats.NoLocks, \n\t\t\t\t\t\t\t\t\t &pSrcDb->LockStats.NoLocks);\n\t\t\t\t\t\t\t\t\t \n\tflmUpdateCountTimeStats( &pDestDb->LockStats.WaitingForLock,\n\t\t\t\t\t\t\t\t\t &pSrcDb->LockStats.WaitingForLock);\n\t\t\t\t\t\t\t\t\t \n\tflmUpdateCountTimeStats( &pDestDb->LockStats.HeldLock,\n\t\t\t\t\t\t\t\t\t &pSrcDb->LockStats.HeldLock);\n\n\t// Go through the LFILE statistics.\n\n\tfor (uiDestLFile = 0, uiSrcLFile = 0, uiLowLFileStart = 0,\n\t\t\tpSrcLFile = pSrcDb->pLFileStats;\n\t\t\tuiSrcLFile < pSrcDb->uiNumLFileStats;\n\t\t\tuiSrcLFile++, pSrcLFile++)\n\t{\n\t\tif (!pSrcLFile->bHaveStats)\n\t\t\tcontinue;\n\n\t\t// Find or add the store in the destination store array.\n\n\t\tuiSaveNumLFiles = pDestDb->uiNumLFileStats;\n\t\tif (RC_BAD( rc = flmStatGetLFile( pDestDb, pSrcLFile->uiLFileNum,\n\t\t\t\t\t\t\t\t\t(FLMUINT)((pSrcLFile->uiFlags & LFILE_IS_INDEX)\n\t\t\t\t\t\t\t\t\t\t\t\t? (FLMUINT)LF_INDEX\n\t\t\t\t\t\t\t\t\t\t\t\t: (FLMUINT)LF_CONTAINER),\n\t\t\t\t\t\t\t\t\tuiLowLFileStart, &pDestLFile, NULL,\n\t\t\t\t\t\t\t\t\t&uiLowLFileStart)))\n\t\t{\n\t\t\tgoto Exit;\n\t\t}\n\n\t\tif (uiLowLFileStart < pDestDb->uiNumLFileStats - 1)\n\t\t{\n\t\t\tuiLowLFileStart++;\n\t\t}\n\n\t\t// If we created the LFILE, all we have to do is copy the\n\t\t// LFILE statistics. It will be quicker.\n\n\t\tif (uiSaveNumLFiles != pDestDb->uiNumLFileStats)\n\t\t{\n\t\t\tf_memcpy( pDestLFile, pSrcLFile, sizeof( LFILE_STATS));\n\t\t}\n\t\telse\n\t\t{\n\n\t\t\t// LFILE was already present, need to go through and\n\t\t\t// update the statistics. \n\n\t\t\tflmUpdateLFileStats( pDestLFile, pSrcLFile);\n\t\t}\n\t}\n\nExit:\n\n\treturn( rc);\n}",
"label": 0,
"cwe": null,
"length": 1038
},
{
"index": 943139,
"code": "ctags_visitor_get_access (ValaSymbol* sym) {\n\tgchar* result = NULL;\n\tValaSymbol* _tmp0_;\n\tValaSymbolAccessibility _tmp1_;\n\tValaSymbolAccessibility _tmp2_;\n#line 55 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\tg_return_val_if_fail (sym != NULL, NULL);\n#line 56 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t_tmp0_ = sym;\n#line 56 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t_tmp1_ = vala_symbol_get_access (_tmp0_);\n#line 56 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t_tmp2_ = _tmp1_;\n#line 56 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\tswitch (_tmp2_) {\n#line 56 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\tcase VALA_SYMBOL_ACCESSIBILITY_PRIVATE:\n#line 469 \"ctags-visitor.c\"\n\t\t{\n\t\t\tgchar* _tmp3_;\n#line 57 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t_tmp3_ = g_strdup (\"private\");\n#line 57 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\tresult = _tmp3_;\n#line 57 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\treturn result;\n#line 478 \"ctags-visitor.c\"\n\t\t}\n#line 56 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\tcase VALA_SYMBOL_ACCESSIBILITY_INTERNAL:\n#line 482 \"ctags-visitor.c\"\n\t\t{\n\t\t\tgchar* _tmp4_;\n#line 58 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t_tmp4_ = g_strdup (\"internal\");\n#line 58 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\tresult = _tmp4_;\n#line 58 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\treturn result;\n#line 491 \"ctags-visitor.c\"\n\t\t}\n#line 56 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\tcase VALA_SYMBOL_ACCESSIBILITY_PROTECTED:\n#line 495 \"ctags-visitor.c\"\n\t\t{\n\t\t\tgchar* _tmp5_;\n#line 59 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t_tmp5_ = g_strdup (\"protected\");\n#line 59 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\tresult = _tmp5_;\n#line 59 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\treturn result;\n#line 504 \"ctags-visitor.c\"\n\t\t}\n#line 56 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\tcase VALA_SYMBOL_ACCESSIBILITY_PUBLIC:\n#line 508 \"ctags-visitor.c\"\n\t\t{\n\t\t\tgchar* _tmp6_;\n#line 60 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\t_tmp6_ = g_strdup (\"public\");\n#line 60 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\tresult = _tmp6_;\n#line 60 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\t\treturn result;\n#line 517 \"ctags-visitor.c\"\n\t\t}\n\t\tdefault:\n#line 56 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\t\tbreak;\n#line 522 \"ctags-visitor.c\"\n\t}\n#line 62 \"/tmp/buildd/anjuta-3.10.2/plugins/symbol-db/anjuta-tags/ctags-visitor.vala\"\n\tg_assert_not_reached ();\n#line 526 \"ctags-visitor.c\"\n}",
"label": 0,
"cwe": null,
"length": 1151
},
{
"index": 525871,
"code": "findprefix(struct cnfa * cnfa,\n\t\t struct colormap * cm,\n\t\t chr *string,\n\t\t size_t *slength)\n{\n\tint\t\t\tst;\n\tint\t\t\tnextst;\n\tcolor\t\tthiscolor;\n\tchr\t\t\tc;\n\tstruct carc *ca;\n\n\t/*\n\t * The \"pre\" state must have only BOS/BOL outarcs, else pattern isn't\n\t * anchored left. If we have both BOS and BOL, they must go to the same\n\t * next state.\n\t */\n\tst = cnfa->pre;\n\tnextst = -1;\n\tfor (ca = cnfa->states[st]; ca->co != COLORLESS; ca++)\n\t{\n\t\tif (ca->co == cnfa->bos[0] || ca->co == cnfa->bos[1])\n\t\t{\n\t\t\tif (nextst == -1)\n\t\t\t\tnextst = ca->to;\n\t\t\telse if (nextst != ca->to)\n\t\t\t\treturn REG_NOMATCH;\n\t\t}\n\t\telse\n\t\t\treturn REG_NOMATCH;\n\t}\n\tif (nextst == -1)\n\t\treturn REG_NOMATCH;\n\n\t/*\n\t * Scan through successive states, stopping as soon as we find one with\n\t * more than one acceptable transition character (either multiple colors\n\t * on out-arcs, or a color with more than one member chr).\n\t *\n\t * We could find a state with multiple out-arcs that are all labeled with\n\t * the same singleton color; this comes from patterns like \"^ab(cde|cxy)\".\n\t * In that case we add the chr \"c\" to the output string but then exit the\n\t * loop with nextst == -1. This leaves a little bit on the table: if the\n\t * pattern is like \"^ab(cde|cdy)\", we won't notice that \"d\" could be added\n\t * to the prefix. But chasing multiple parallel state chains doesn't seem\n\t * worth the trouble.\n\t */\n\tdo\n\t{\n\t\tst = nextst;\n\t\tnextst = -1;\n\t\tthiscolor = COLORLESS;\n\t\tfor (ca = cnfa->states[st]; ca->co != COLORLESS; ca++)\n\t\t{\n\t\t\t/* We ignore lookahead constraints */\n\t\t\tif (ca->co >= cnfa->ncolors)\n\t\t\t\tcontinue;\n\t\t\t/* We can also ignore BOS/BOL arcs */\n\t\t\tif (ca->co == cnfa->bos[0] || ca->co == cnfa->bos[1])\n\t\t\t\tcontinue;\n\t\t\t/* ... but EOS/EOL arcs terminate the search */\n\t\t\tif (ca->co == cnfa->eos[0] || ca->co == cnfa->eos[1])\n\t\t\t{\n\t\t\t\tthiscolor = COLORLESS;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (thiscolor == COLORLESS)\n\t\t\t{\n\t\t\t\t/* First plain outarc */\n\t\t\t\tthiscolor = ca->co;\n\t\t\t\tnextst = ca->to;\n\t\t\t}\n\t\t\telse if (thiscolor == ca->co)\n\t\t\t{\n\t\t\t\t/* Another plain outarc for same color */\n\t\t\t\tnextst = -1;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t/* More than one plain outarc color terminates the search */\n\t\t\t\tthiscolor = COLORLESS;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\t/* Done if we didn't find exactly one color on plain outarcs */\n\t\tif (thiscolor == COLORLESS)\n\t\t\tbreak;\n\t\t/* The color must be a singleton */\n\t\tif (cm->cd[thiscolor].nchrs != 1)\n\t\t\tbreak;\n\n\t\t/*\n\t\t * Identify the color's sole member chr and add it to the prefix\n\t\t * string. In general the colormap data structure doesn't provide a\n\t\t * way to find color member chrs, except by trying GETCOLOR() on each\n\t\t * possible chr value, which won't do at all. However, for the cases\n\t\t * we care about it should be sufficient to test the \"firstchr\" value,\n\t\t * that is the first chr ever added to the color. There are cases\n\t\t * where this might no longer be a member of the color (so we do need\n\t\t * to test), but none of them are likely to arise for a character that\n\t\t * is a member of a common prefix. If we do hit such a corner case,\n\t\t * we just fall out without adding anything to the prefix string.\n\t\t */\n\t\tc = cm->cd[thiscolor].firstchr;\n\t\tif (GETCOLOR(cm, c) != thiscolor)\n\t\t\tbreak;\n\n\t\tstring[(*slength)++] = c;\n\n\t\t/* Advance to next state, but only if we have a unique next state */\n\t} while (nextst != -1);\n\n\t/*\n\t * If we ended at a state that only has EOS/EOL outarcs leading to the\n\t * \"post\" state, then we have an exact-match string. Note this is true\n\t * even if the string is of zero length.\n\t */\n\tnextst = -1;\n\tfor (ca = cnfa->states[st]; ca->co != COLORLESS; ca++)\n\t{\n\t\tif (ca->co == cnfa->eos[0] || ca->co == cnfa->eos[1])\n\t\t{\n\t\t\tif (nextst == -1)\n\t\t\t\tnextst = ca->to;\n\t\t\telse if (nextst != ca->to)\n\t\t\t{\n\t\t\t\tnextst = -1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\t\t\tnextst = -1;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (nextst == cnfa->post)\n\t\treturn REG_EXACT;\n\n\t/*\n\t * Otherwise, if we were unable to identify any prefix characters, say\n\t * NOMATCH --- the pattern is anchored left, but doesn't specify any\n\t * particular first character.\n\t */\n\tif (*slength > 0)\n\t\treturn REG_PREFIX;\n\n\treturn REG_NOMATCH;\n}",
"label": 0,
"cwe": null,
"length": 1270
},
{
"index": 179432,
"code": "DropTableSpace(DropTableSpaceStmt *stmt)\n{\n#ifdef HAVE_SYMLINK\n\tchar\t *tablespacename = stmt->tablespacename;\n\tHeapScanDesc scandesc;\n\tRelation\trel;\n\tHeapTuple\ttuple;\n\tScanKeyData entry[1];\n\tOid\t\t\ttablespaceoid;\n\n\t/*\n\t * Find the target tuple\n\t */\n\trel = heap_open(TableSpaceRelationId, RowExclusiveLock);\n\n\tScanKeyInit(&entry[0],\n\t\t\t\tAnum_pg_tablespace_spcname,\n\t\t\t\tBTEqualStrategyNumber, F_NAMEEQ,\n\t\t\t\tCStringGetDatum(tablespacename));\n\tscandesc = heap_beginscan(rel, SnapshotNow, 1, entry);\n\ttuple = heap_getnext(scandesc, ForwardScanDirection);\n\n\tif (!HeapTupleIsValid(tuple))\n\t{\n\t\tif (!stmt->missing_ok)\n\t\t{\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_UNDEFINED_OBJECT),\n\t\t\t\t\t errmsg(\"tablespace \\\"%s\\\" does not exist\",\n\t\t\t\t\t\t\ttablespacename)));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tereport(NOTICE,\n\t\t\t\t\t(errmsg(\"tablespace \\\"%s\\\" does not exist, skipping\",\n\t\t\t\t\t\t\ttablespacename)));\n\t\t\t/* XXX I assume I need one or both of these next two calls */\n\t\t\theap_endscan(scandesc);\n\t\t\theap_close(rel, NoLock);\n\t\t}\n\t\treturn;\n\t}\n\n\ttablespaceoid = HeapTupleGetOid(tuple);\n\n\t/* Must be tablespace owner */\n\tif (!pg_tablespace_ownercheck(tablespaceoid, GetUserId()))\n\t\taclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_TABLESPACE,\n\t\t\t\t\t tablespacename);\n\n\t/* Disallow drop of the standard tablespaces, even by superuser */\n\tif (tablespaceoid == GLOBALTABLESPACE_OID ||\n\t\ttablespaceoid == DEFAULTTABLESPACE_OID)\n\t\taclcheck_error(ACLCHECK_NO_PRIV, ACL_KIND_TABLESPACE,\n\t\t\t\t\t tablespacename);\n\n\t/*\n\t * Remove the pg_tablespace tuple (this will roll back if we fail below)\n\t */\n\tsimple_heap_delete(rel, &tuple->t_self);\n\n\theap_endscan(scandesc);\n\n\t/*\n\t * Remove any comments on this tablespace.\n\t */\n\tDeleteSharedComments(tablespaceoid, TableSpaceRelationId);\n\n\t/*\n\t * Remove dependency on owner.\n\t */\n\tdeleteSharedDependencyRecordsFor(TableSpaceRelationId, tablespaceoid, 0);\n\n\t/*\n\t * Acquire TablespaceCreateLock to ensure that no TablespaceCreateDbspace\n\t * is running concurrently.\n\t */\n\tLWLockAcquire(TablespaceCreateLock, LW_EXCLUSIVE);\n\n\t/*\n\t * Try to remove the physical infrastructure.\n\t */\n\tif (!destroy_tablespace_directories(tablespaceoid, false))\n\t{\n\t\t/*\n\t\t * Not all files deleted? However, there can be lingering empty files\n\t\t * in the directories, left behind by for example DROP TABLE, that\n\t\t * have been scheduled for deletion at next checkpoint (see comments\n\t\t * in mdunlink() for details).\tWe could just delete them immediately,\n\t\t * but we can't tell them apart from important data files that we\n\t\t * mustn't delete. So instead, we force a checkpoint which will clean\n\t\t * out any lingering files, and try again.\n\t\t */\n\t\tRequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT);\n\t\tif (!destroy_tablespace_directories(tablespaceoid, false))\n\t\t{\n\t\t\t/* Still not empty, the files must be important then */\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),\n\t\t\t\t\t errmsg(\"tablespace \\\"%s\\\" is not empty\",\n\t\t\t\t\t\t\ttablespacename)));\n\t\t}\n\t}\n\n\t/* Record the filesystem change in XLOG */\n\t{\n\t\txl_tblspc_drop_rec xlrec;\n\t\tXLogRecData rdata[1];\n\n\t\txlrec.ts_id = tablespaceoid;\n\t\trdata[0].data = (char *) &xlrec;\n\t\trdata[0].len = sizeof(xl_tblspc_drop_rec);\n\t\trdata[0].buffer = InvalidBuffer;\n\t\trdata[0].next = NULL;\n\n\t\t(void) XLogInsert(RM_TBLSPC_ID, XLOG_TBLSPC_DROP, rdata);\n\t}\n\n\t/*\n\t * Note: because we checked that the tablespace was empty, there should be\n\t * no need to worry about flushing shared buffers or free space map\n\t * entries for relations in the tablespace.\n\t */\n\n\t/*\n\t * Force synchronous commit, to minimize the window between removing the\n\t * files on-disk and marking the transaction committed. It's not great\n\t * that there is any window at all, but definitely we don't want to make\n\t * it larger than necessary.\n\t */\n\tForceSyncCommit();\n\n\t/*\n\t * Allow TablespaceCreateDbspace again.\n\t */\n\tLWLockRelease(TablespaceCreateLock);\n\n\t/* We keep the lock on pg_tablespace until commit */\n\theap_close(rel, NoLock);\n#else\t\t\t\t\t\t\t/* !HAVE_SYMLINK */\n\tereport(ERROR,\n\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t errmsg(\"tablespaces are not supported on this platform\")));\n#endif /* HAVE_SYMLINK */\n}",
"label": 0,
"cwe": null,
"length": 1120
},
{
"index": 139369,
"code": "ReadBlock( int block_index, void *buffer,\n int xoff, int yoff, \n int xsize, int ysize )\n\n{\n int pixel_size = DataTypeSize(GetType());\n\n/* -------------------------------------------------------------------- */\n/* Default window if needed. */\n/* -------------------------------------------------------------------- */\n if( xoff == -1 && yoff == -1 && xsize == -1 && ysize == -1 )\n {\n xoff = 0;\n yoff = 0;\n xsize = GetBlockWidth();\n ysize = GetBlockHeight();\n }\n\n/* -------------------------------------------------------------------- */\n/* Validate Window */\n/* -------------------------------------------------------------------- */\n if( xoff < 0 || xoff + xsize > GetBlockWidth()\n || yoff < 0 || yoff + ysize > GetBlockHeight() )\n {\n ThrowPCIDSKException( \n \"Invalid window in ReadBloc(): xoff=%d,yoff=%d,xsize=%d,ysize=%d\",\n xoff, yoff, xsize, ysize );\n }\n\n if( block_index < 0 || block_index >= tile_count )\n {\n ThrowPCIDSKException( \"Requested non-existant block (%d)\", \n block_index );\n }\n\n/* -------------------------------------------------------------------- */\n/* Does this tile exist? If not return a zeroed buffer. */\n/* -------------------------------------------------------------------- */\n uint64 tile_offset;\n int tile_size;\n\n GetTileInfo( block_index, tile_offset, tile_size );\n\n if( tile_size == 0 )\n {\n memset( buffer, 0, GetBlockWidth() * GetBlockHeight() * pixel_size );\n return 1;\n }\n\n/* -------------------------------------------------------------------- */\n/* The simpliest case it an uncompressed direct and complete */\n/* tile read into the destination buffer. */\n/* -------------------------------------------------------------------- */\n if( xoff == 0 && xsize == GetBlockWidth() \n && yoff == 0 && ysize == GetBlockHeight() \n && tile_size == xsize * ysize * pixel_size \n && compression == \"NONE\" )\n {\n vfile->ReadFromFile( buffer, tile_offset, tile_size );\n\n // Do byte swapping if needed.\n if( needs_swap )\n SwapPixels( buffer, pixel_type, xsize * ysize );\n\n return 1;\n }\n\n/* -------------------------------------------------------------------- */\n/* Load uncompressed data, one scanline at a time, into the */\n/* target buffer. */\n/* -------------------------------------------------------------------- */\n if( compression == \"NONE\" )\n {\n int iy;\n\n for( iy = 0; iy < ysize; iy++ )\n {\n vfile->ReadFromFile( ((uint8 *) buffer) \n + iy * xsize * pixel_size,\n tile_offset \n + ((iy+yoff)*block_width + xoff) * pixel_size,\n xsize * pixel_size );\n }\n \n // Do byte swapping if needed.\n if( needs_swap )\n SwapPixels( buffer, pixel_type, xsize * ysize );\n \n return 1;\n }\n\n/* -------------------------------------------------------------------- */\n/* Load the whole compressed data into a working buffer. */\n/* -------------------------------------------------------------------- */\n PCIDSKBuffer oCompressedData( tile_size );\n PCIDSKBuffer oUncompressedData( pixel_size * block_width * block_height );\n\n vfile->ReadFromFile( oCompressedData.buffer, tile_offset, tile_size );\n \n/* -------------------------------------------------------------------- */\n/* Handle decompression. */\n/* -------------------------------------------------------------------- */\n if( compression == \"RLE\" )\n {\n RLEDecompressBlock( oCompressedData, oUncompressedData );\n }\n else if( strncmp(compression.c_str(),\"JPEG\",4) == 0 )\n {\n JPEGDecompressBlock( oCompressedData, oUncompressedData );\n }\n else\n {\n ThrowPCIDSKException( \n \"Unable to read tile of unsupported compression type: %s\",\n compression.c_str() );\n }\n\n/* -------------------------------------------------------------------- */\n/* Swap if necessary. TODO: there is some reason to doubt that */\n/* the old implementation properly byte swapped compressed */\n/* data. Perhaps this should be conditional? */\n/* -------------------------------------------------------------------- */\n if( needs_swap )\n SwapPixels( oUncompressedData.buffer, pixel_type, \n GetBlockWidth() * GetBlockHeight() );\n\n/* -------------------------------------------------------------------- */\n/* Copy out the desired subwindow. */\n/* -------------------------------------------------------------------- */\n int iy;\n \n for( iy = 0; iy < ysize; iy++ )\n {\n memcpy( ((uint8 *) buffer) + iy * xsize * pixel_size,\n oUncompressedData.buffer \n + ((iy+yoff)*block_width + xoff) * pixel_size,\n xsize * pixel_size );\n }\n\n return 1;\n}",
"label": 0,
"cwe": null,
"length": 1027
},
{
"index": 15430,
"code": "sprom_extract_r123(struct ssb_sprom *out, const u16 *in)\n{\n\tu16 loc[3];\n\n\tif (out->revision == 3)\t\t\t/* rev 3 moved MAC */\n\t\tloc[0] = SSB_SPROM3_IL0MAC;\n\telse {\n\t\tloc[0] = SSB_SPROM1_IL0MAC;\n\t\tloc[1] = SSB_SPROM1_ET0MAC;\n\t\tloc[2] = SSB_SPROM1_ET1MAC;\n\t}\n\tsprom_get_mac(out->il0mac, &in[SPOFF(loc[0])]);\n\tif (out->revision < 3) { \t/* only rev 1-2 have et0, et1 */\n\t\tsprom_get_mac(out->et0mac, &in[SPOFF(loc[1])]);\n\t\tsprom_get_mac(out->et1mac, &in[SPOFF(loc[2])]);\n\t}\n\tSPEX(et0phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET0A, 0);\n\tSPEX(et1phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET1A,\n\t SSB_SPROM1_ETHPHY_ET1A_SHIFT);\n\tSPEX(et0mdcport, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET0M, 14);\n\tSPEX(et1mdcport, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET1M, 15);\n\tSPEX(board_rev, SSB_SPROM1_BINF, SSB_SPROM1_BINF_BREV, 0);\n\tSPEX(board_type, SSB_SPROM1_SPID, 0xFFFF, 0);\n\tif (out->revision == 1)\n\t\tSPEX(country_code, SSB_SPROM1_BINF, SSB_SPROM1_BINF_CCODE,\n\t\t SSB_SPROM1_BINF_CCODE_SHIFT);\n\tSPEX(ant_available_a, SSB_SPROM1_BINF, SSB_SPROM1_BINF_ANTA,\n\t SSB_SPROM1_BINF_ANTA_SHIFT);\n\tSPEX(ant_available_bg, SSB_SPROM1_BINF, SSB_SPROM1_BINF_ANTBG,\n\t SSB_SPROM1_BINF_ANTBG_SHIFT);\n\tSPEX(pa0b0, SSB_SPROM1_PA0B0, 0xFFFF, 0);\n\tSPEX(pa0b1, SSB_SPROM1_PA0B1, 0xFFFF, 0);\n\tSPEX(pa0b2, SSB_SPROM1_PA0B2, 0xFFFF, 0);\n\tSPEX(pa1b0, SSB_SPROM1_PA1B0, 0xFFFF, 0);\n\tSPEX(pa1b1, SSB_SPROM1_PA1B1, 0xFFFF, 0);\n\tSPEX(pa1b2, SSB_SPROM1_PA1B2, 0xFFFF, 0);\n\tSPEX(gpio0, SSB_SPROM1_GPIOA, SSB_SPROM1_GPIOA_P0, 0);\n\tSPEX(gpio1, SSB_SPROM1_GPIOA, SSB_SPROM1_GPIOA_P1,\n\t SSB_SPROM1_GPIOA_P1_SHIFT);\n\tSPEX(gpio2, SSB_SPROM1_GPIOB, SSB_SPROM1_GPIOB_P2, 0);\n\tSPEX(gpio3, SSB_SPROM1_GPIOB, SSB_SPROM1_GPIOB_P3,\n\t SSB_SPROM1_GPIOB_P3_SHIFT);\n\tSPEX(maxpwr_a, SSB_SPROM1_MAXPWR, SSB_SPROM1_MAXPWR_A,\n\t SSB_SPROM1_MAXPWR_A_SHIFT);\n\tSPEX(maxpwr_bg, SSB_SPROM1_MAXPWR, SSB_SPROM1_MAXPWR_BG, 0);\n\tSPEX(itssi_a, SSB_SPROM1_ITSSI, SSB_SPROM1_ITSSI_A,\n\t SSB_SPROM1_ITSSI_A_SHIFT);\n\tSPEX(itssi_bg, SSB_SPROM1_ITSSI, SSB_SPROM1_ITSSI_BG, 0);\n\tSPEX(boardflags_lo, SSB_SPROM1_BFLLO, 0xFFFF, 0);\n\n\tSPEX(alpha2[0], SSB_SPROM1_CCODE, 0xff00, 8);\n\tSPEX(alpha2[1], SSB_SPROM1_CCODE, 0x00ff, 0);\n\n\t/* Extract the antenna gain values. */\n\tout->antenna_gain.a0 = sprom_extract_antgain(out->revision, in,\n\t\t\t\t\t\t SSB_SPROM1_AGAIN,\n\t\t\t\t\t\t SSB_SPROM1_AGAIN_BG,\n\t\t\t\t\t\t SSB_SPROM1_AGAIN_BG_SHIFT);\n\tout->antenna_gain.a1 = sprom_extract_antgain(out->revision, in,\n\t\t\t\t\t\t SSB_SPROM1_AGAIN,\n\t\t\t\t\t\t SSB_SPROM1_AGAIN_A,\n\t\t\t\t\t\t SSB_SPROM1_AGAIN_A_SHIFT);\n\tif (out->revision >= 2)\n\t\tsprom_extract_r23(out, in);\n}",
"label": 0,
"cwe": null,
"length": 1120
},
{
"index": 406400,
"code": "SelectConfigFiles(const char *userDoption, const char *progname)\n{\n\tchar\t *configdir;\n\tchar\t *fname;\n\tstruct stat stat_buf;\n\n\t/* configdir is -D option, or $PGDATA if no -D */\n\tif (userDoption)\n\t\tconfigdir = make_absolute_path(userDoption);\n\telse\n\t\tconfigdir = make_absolute_path(getenv(\"PGDATA\"));\n\n\t/*\n\t * Find the configuration file: if config_file was specified on the\n\t * command line, use it, else use configdir/postgresql.conf. In any case\n\t * ensure the result is an absolute path, so that it will be interpreted\n\t * the same way by future backends.\n\t */\n\tif (ConfigFileName)\n\t\tfname = make_absolute_path(ConfigFileName);\n\telse if (configdir)\n\t{\n\t\tfname = guc_malloc(FATAL,\n\t\t\t\t\t\t strlen(configdir) + strlen(CONFIG_FILENAME) + 2);\n\t\tsprintf(fname, \"%s/%s\", configdir, CONFIG_FILENAME);\n\t}\n\telse\n\t{\n\t\twrite_stderr(\"%s does not know where to find the server configuration file.\\n\"\n\t\t\t\t\t \"You must specify the --config-file or -D invocation \"\n\t\t\t\t\t \"option or set the PGDATA environment variable.\\n\",\n\t\t\t\t\t progname);\n\t\treturn false;\n\t}\n\n\t/*\n\t * Set the ConfigFileName GUC variable to its final value, ensuring that\n\t * it can't be overridden later.\n\t */\n\tSetConfigOption(\"config_file\", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);\n\tfree(fname);\n\n\t/*\n\t * Now read the config file for the first time.\n\t */\n\tif (stat(ConfigFileName, &stat_buf) != 0)\n\t{\n\t\twrite_stderr(\"%s cannot access the server configuration file \\\"%s\\\": %s\\n\",\n\t\t\t\t\t progname, ConfigFileName, strerror(errno));\n\t\tfree(configdir);\n\t\treturn false;\n\t}\n\n\t/*\n\t * Read the configuration file for the first time. This time only the\n\t * data_directory parameter is picked up to determine the data directory,\n\t * so that we can read the PG_AUTOCONF_FILENAME file next time.\n\t */\n\tProcessConfigFile(PGC_POSTMASTER);\n\n\t/*\n\t * If the data_directory GUC variable has been set, use that as DataDir;\n\t * otherwise use configdir if set; else punt.\n\t *\n\t * Note: SetDataDir will copy and absolute-ize its argument, so we don't\n\t * have to.\n\t */\n\tif (data_directory)\n\t\tSetDataDir(data_directory);\n\telse if (configdir)\n\t\tSetDataDir(configdir);\n\telse\n\t{\n\t\twrite_stderr(\"%s does not know where to find the database system data.\\n\"\n\t\t\t\t\t \"This can be specified as \\\"data_directory\\\" in \\\"%s\\\", \"\n\t\t\t\t\t \"or by the -D invocation option, or by the \"\n\t\t\t\t\t \"PGDATA environment variable.\\n\",\n\t\t\t\t\t progname, ConfigFileName);\n\t\treturn false;\n\t}\n\n\t/*\n\t * Reflect the final DataDir value back into the data_directory GUC var.\n\t * (If you are wondering why we don't just make them a single variable,\n\t * it's because the EXEC_BACKEND case needs DataDir to be transmitted to\n\t * child backends specially. XXX is that still true? Given that we now\n\t * chdir to DataDir, EXEC_BACKEND can read the config file without knowing\n\t * DataDir in advance.)\n\t */\n\tSetConfigOption(\"data_directory\", DataDir, PGC_POSTMASTER, PGC_S_OVERRIDE);\n\n\t/*\n\t * Now read the config file a second time, allowing any settings in the\n\t * PG_AUTOCONF_FILENAME file to take effect. (This is pretty ugly, but\n\t * since we have to determine the DataDir before we can find the autoconf\n\t * file, the alternatives seem worse.)\n\t */\n\tProcessConfigFile(PGC_POSTMASTER);\n\n\t/*\n\t * If timezone_abbreviations wasn't set in the configuration file, install\n\t * the default value. We do it this way because we can't safely install a\n\t * \"real\" value until my_exec_path is set, which may not have happened\n\t * when InitializeGUCOptions runs, so the bootstrap default value cannot\n\t * be the real desired default.\n\t */\n\tpg_timezone_abbrev_initialize();\n\n\t/*\n\t * Figure out where pg_hba.conf is, and make sure the path is absolute.\n\t */\n\tif (HbaFileName)\n\t\tfname = make_absolute_path(HbaFileName);\n\telse if (configdir)\n\t{\n\t\tfname = guc_malloc(FATAL,\n\t\t\t\t\t\t strlen(configdir) + strlen(HBA_FILENAME) + 2);\n\t\tsprintf(fname, \"%s/%s\", configdir, HBA_FILENAME);\n\t}\n\telse\n\t{\n\t\twrite_stderr(\"%s does not know where to find the \\\"hba\\\" configuration file.\\n\"\n\t\t\t\t\t \"This can be specified as \\\"hba_file\\\" in \\\"%s\\\", \"\n\t\t\t\t\t \"or by the -D invocation option, or by the \"\n\t\t\t\t\t \"PGDATA environment variable.\\n\",\n\t\t\t\t\t progname, ConfigFileName);\n\t\treturn false;\n\t}\n\tSetConfigOption(\"hba_file\", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);\n\tfree(fname);\n\n\t/*\n\t * Likewise for pg_ident.conf.\n\t */\n\tif (IdentFileName)\n\t\tfname = make_absolute_path(IdentFileName);\n\telse if (configdir)\n\t{\n\t\tfname = guc_malloc(FATAL,\n\t\t\t\t\t\t strlen(configdir) + strlen(IDENT_FILENAME) + 2);\n\t\tsprintf(fname, \"%s/%s\", configdir, IDENT_FILENAME);\n\t}\n\telse\n\t{\n\t\twrite_stderr(\"%s does not know where to find the \\\"ident\\\" configuration file.\\n\"\n\t\t\t\t\t \"This can be specified as \\\"ident_file\\\" in \\\"%s\\\", \"\n\t\t\t\t\t \"or by the -D invocation option, or by the \"\n\t\t\t\t\t \"PGDATA environment variable.\\n\",\n\t\t\t\t\t progname, ConfigFileName);\n\t\treturn false;\n\t}\n\tSetConfigOption(\"ident_file\", fname, PGC_POSTMASTER, PGC_S_OVERRIDE);\n\tfree(fname);\n\n\tfree(configdir);\n\n\treturn true;\n}",
"label": 1,
"cwe": [
"CWE-120",
"CWE-other"
],
"length": 1284
},
{
"index": 543467,
"code": "bldGetNextElm(\n\tREBUILD_STATE *\tpRebuildState,\n\tSTATE_INFO *\t\tpStateInfo,\n\tFLMBOOL *\t\t\tpbGotNextElmRV,\n\tFLMBOOL *\t\t\tpbGotNewBlockRV)\n{\n\tRCODE\t\t\t\t\trc = FERR_OK;\n\tFLMUINT\t\t\t\tuiSaveDrn;\n\tFLMUINT\t\t\t\tuiBytesRead;\n\tFLMUINT\t\t\t\tuiBlkAddress;\n\tFLMBYTE *\t\t\tpBlk = pStateInfo->pBlk;\n\tHDR_INFO *\t\t\tpHdrInfo = pRebuildState->pHdrInfo;\n\teCorruptionType\teCorruptionCode;\n\tFLMUINT\t\t\t\tuiSaveBlkAddress = pStateInfo->uiBlkAddress;\n\n\t*pbGotNextElmRV = FALSE;\n\tuiSaveDrn = pStateInfo->uiElmDrn;\n\n\t// See if we need to go to the next block to get the element\n\n\tpStateInfo->uiElmOffset += pStateInfo->uiElmLen;\n\tif (pStateInfo->uiElmOffset >= pStateInfo->uiEndOfBlock)\n\t{\n\t\t// Get the next block\n\n\t\t*pbGotNewBlockRV = TRUE;\n\t\tuiBlkAddress = (FLMUINT)FB2UD( &pBlk [BH_NEXT_BLK]);\n\t\trc = pRebuildState->pSFileHdl->readBlock( uiBlkAddress, \n\t\t\t\t\t\t\t\t\t\t pHdrInfo->FileHdr.uiBlockSize,\n\t\t\t\t\t\t\t\t\t\t pBlk, &uiBytesRead);\n\t\tif( uiBytesRead < pHdrInfo->FileHdr.uiBlockSize)\n\t\t{\n\t\t\trc = RC_SET( FERR_IO_END_OF_FILE);\n\t\t}\n\n\t\tif( RC_BAD( rc))\n\t\t{\n\t\t\tRCODE\t\tTempRc;\n\n\t\t\tif( rc == FERR_IO_END_OF_FILE ||\n\t\t\t\t rc == FERR_IO_PATH_NOT_FOUND ||\n\t\t\t\t rc == FERR_IO_INVALID_PATH)\n\t\t\t{\n\t\t\t\trc = FERR_OK;\n\t\t\t}\n\n\t\t\tif( RC_BAD( TempRc = bldReportReason( pRebuildState,\n\t\t\t\t\t\t\t\t\t\tFLM_BAD_BLK_HDR_NEXT, uiSaveBlkAddress,\n\t\t\t\t\t\t\t\t\t\t0, 0, 0xFFFF, 0)))\n\t\t\t{\n\t\t\t\tif( RC_OK( rc))\n\t\t\t\t{\n\t\t\t\t\trc = TempRc;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tgoto Exit;\n\t\t}\n\n\t\t// Make sure it is the right type of block\n\n\t\telse if( (RC_BAD( rc = bldCheckBlock( pStateInfo, pRebuildState->pHdrInfo,\n\t\t\tuiBlkAddress, uiSaveBlkAddress, &eCorruptionCode))) || (eCorruptionCode != FLM_NO_CORRUPTION))\n\t\t{\n\t\t\tif (eCorruptionCode != FLM_NO_CORRUPTION)\n\t\t\t{\n\t\t\t\t(void)bldReportReason( pRebuildState, eCorruptionCode,\n\t\t\t\t\t\t\t\t\t\tuiBlkAddress, 0, 0,\n\t\t\t\t\t\t\t\t\t 0xFFFF, 0);\n\t\t\t}\n\n\t\t\tgoto Exit;\n\t\t}\n\t}\n\n\t// Verify other things about the element\n\n\tif( (eCorruptionCode = flmVerifyElement( pStateInfo, FLM_CHK_FIELDS)) != FLM_NO_CORRUPTION)\n\t{\n\t\trc = bldReportReason( pRebuildState, eCorruptionCode,\n\t\t\t\t\t\t\tpStateInfo->uiBlkAddress, pStateInfo->uiElmOffset,\n\t\t\t\t\t\t\tpStateInfo->uiElmDrn, 0xFFFF, 0);\n\t\tgoto Exit;\n\t}\n\n\t// This had better not be a LEM element\n\n\tif( pStateInfo->uiCurKeyLen == 0)\n\t{\n\t\trc = bldReportReason( pRebuildState, FLM_BAD_LEM,\n\t\t\t\t\t\t\tpStateInfo->uiBlkAddress, pStateInfo->uiElmOffset,\n\t\t\t\t\t\t\tpStateInfo->uiElmDrn, 0xFFFF, 0);\n\t\tgoto Exit;\n\t}\n\n\t// This element had better not be the first element\n\n\tif( BBE_IS_FIRST( pStateInfo->pElm))\n\t{\n\t\trc = bldReportReason( pRebuildState, FLM_BAD_FIRST_ELM_FLAG,\n\t\t\t\t\t\t\tpStateInfo->uiBlkAddress, pStateInfo->uiElmOffset,\n\t\t\t\t\t\t\tpStateInfo->uiElmDrn, 0xFFFF, 0);\n\t\tgoto Exit;\n\t}\n\n\t// Must stay on the same DRN while processing the record\n\n\tif (pStateInfo->uiElmDrn != uiSaveDrn)\n\t{\n\t\trc = bldReportReason( pRebuildState, FLM_BAD_CONT_ELM_KEY,\n\t\t\t\t\t\t\tpStateInfo->uiBlkAddress, pStateInfo->uiElmOffset,\n\t\t\t\t\t\t\tpStateInfo->uiElmDrn, 0xFFFF, 0);\n\t\tgoto Exit;\n\t}\n\n\t*pbGotNextElmRV = TRUE;\n\nExit:\n\n\treturn( rc);\n}",
"label": 0,
"cwe": null,
"length": 1054
},
{
"index": 695432,
"code": "formrdesc(const char *relationName, Oid relationReltype,\n\t\t bool hasoids, int natts, FormData_pg_attribute *att)\n{\n\tRelation\trelation;\n\tint\t\t\ti;\n\tbool\t\thas_not_null;\n\n\t/*\n\t * allocate new relation desc, clear all fields of reldesc\n\t */\n\trelation = (Relation) palloc0(sizeof(RelationData));\n\trelation->rd_targblock = InvalidBlockNumber;\n\trelation->rd_fsm_nblocks = InvalidBlockNumber;\n\trelation->rd_vm_nblocks = InvalidBlockNumber;\n\n\t/* make sure relation is marked as having no open file yet */\n\trelation->rd_smgr = NULL;\n\n\t/*\n\t * initialize reference count: 1 because it is nailed in cache\n\t */\n\trelation->rd_refcnt = 1;\n\n\t/*\n\t * all entries built with this routine are nailed-in-cache; none are for\n\t * new or temp relations.\n\t */\n\trelation->rd_isnailed = true;\n\trelation->rd_createSubid = InvalidSubTransactionId;\n\trelation->rd_newRelfilenodeSubid = InvalidSubTransactionId;\n\trelation->rd_istemp = false;\n\trelation->rd_islocaltemp = false;\n\n\t/*\n\t * initialize relation tuple form\n\t *\n\t * The data we insert here is pretty incomplete/bogus, but it'll serve to\n\t * get us launched. RelationCacheInitializePhase2() will read the real\n\t * data from pg_class and replace what we've done here. Note in particular\n\t * that relowner is left as zero; this cues RelationCacheInitializePhase2\n\t * that the real data isn't there yet.\n\t */\n\trelation->rd_rel = (Form_pg_class) palloc0(CLASS_TUPLE_SIZE);\n\n\tnamestrcpy(&relation->rd_rel->relname, relationName);\n\trelation->rd_rel->relnamespace = PG_CATALOG_NAMESPACE;\n\trelation->rd_rel->reltype = relationReltype;\n\n\t/*\n\t * It's important to distinguish between shared and non-shared relations,\n\t * even at bootstrap time, to make sure we know where they are stored.\tAt\n\t * present, all relations that formrdesc is used for are not shared.\n\t */\n\trelation->rd_rel->relisshared = false;\n\n\t/*\n\t * Likewise, we must know if a relation is temp ... but formrdesc is not\n\t * used for any temp relations.\n\t */\n\trelation->rd_rel->relistemp = false;\n\n\trelation->rd_rel->relpages = 1;\n\trelation->rd_rel->reltuples = 1;\n\trelation->rd_rel->relkind = RELKIND_RELATION;\n\trelation->rd_rel->relhasoids = hasoids;\n\trelation->rd_rel->relnatts = (int16) natts;\n\n\t/*\n\t * initialize attribute tuple form\n\t *\n\t * Unlike the case with the relation tuple, this data had better be right\n\t * because it will never be replaced. The input values must be correctly\n\t * defined by macros in src/include/catalog/ headers.\n\t */\n\trelation->rd_att = CreateTemplateTupleDesc(natts, hasoids);\n\trelation->rd_att->tdrefcount = 1;\t/* mark as refcounted */\n\n\trelation->rd_att->tdtypeid = relationReltype;\n\trelation->rd_att->tdtypmod = -1;\t/* unnecessary, but... */\n\n\t/*\n\t * initialize tuple desc info\n\t */\n\thas_not_null = false;\n\tfor (i = 0; i < natts; i++)\n\t{\n\t\tmemcpy(relation->rd_att->attrs[i],\n\t\t\t &att[i],\n\t\t\t ATTRIBUTE_FIXED_PART_SIZE);\n\t\thas_not_null |= att[i].attnotnull;\n\t\t/* make sure attcacheoff is valid */\n\t\trelation->rd_att->attrs[i]->attcacheoff = -1;\n\t}\n\n\t/* initialize first attribute's attcacheoff, cf RelationBuildTupleDesc */\n\trelation->rd_att->attrs[0]->attcacheoff = 0;\n\n\t/* mark not-null status */\n\tif (has_not_null)\n\t{\n\t\tTupleConstr *constr = (TupleConstr *) palloc0(sizeof(TupleConstr));\n\n\t\tconstr->has_not_null = true;\n\t\trelation->rd_att->constr = constr;\n\t}\n\n\t/*\n\t * initialize relation id from info in att array (my, this is ugly)\n\t */\n\tRelationGetRelid(relation) = relation->rd_att->attrs[0]->attrelid;\n\trelation->rd_rel->relfilenode = RelationGetRelid(relation);\n\n\t/*\n\t * initialize the relation lock manager information\n\t */\n\tRelationInitLockInfo(relation);\t\t/* see lmgr.c */\n\n\t/*\n\t * initialize physical addressing information for the relation\n\t */\n\tRelationInitPhysicalAddr(relation);\n\n\t/*\n\t * initialize the rel-has-index flag, using hardwired knowledge\n\t */\n\tif (IsBootstrapProcessingMode())\n\t{\n\t\t/* In bootstrap mode, we have no indexes */\n\t\trelation->rd_rel->relhasindex = false;\n\t}\n\telse\n\t{\n\t\t/* Otherwise, all the rels formrdesc is used for have indexes */\n\t\trelation->rd_rel->relhasindex = true;\n\t}\n\n\t/*\n\t * add new reldesc to relcache\n\t */\n\tRelationCacheInsert(relation);\n\n\t/* It's fully valid */\n\trelation->rd_isvalid = true;\n}",
"label": 0,
"cwe": null,
"length": 1163
},
{
"index": 955794,
"code": "tracker_sparql_backend_real_update (TrackerSparqlConnection* base, const gchar* sparql, gint priority, GCancellable* cancellable, GError** error) {\n\tTrackerSparqlBackend * self;\n\tgint _tmp0_ = 0;\n\tconst gchar* _tmp1_ = NULL;\n\tTrackerSparqlConnection* _tmp2_ = NULL;\n\tTrackerSparqlConnection* _tmp4_ = NULL;\n\tconst gchar* _tmp5_ = NULL;\n\tgint _tmp6_ = 0;\n\tGCancellable* _tmp7_ = NULL;\n\tGError * _inner_error_ = NULL;\n#line 92 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\tself = (TrackerSparqlBackend*) base;\n#line 92 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\tg_return_if_fail (sparql != NULL);\n#line 93 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t_tmp0_ = priority;\n#line 93 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t_tmp1_ = sparql;\n#line 93 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\tg_debug (\"tracker-backend.vala:93: %s(priority:%d): '%s'\", \"Tracker.Sparql.Backend.update\", _tmp0_, _tmp1_);\n#line 94 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t_tmp2_ = self->priv->bus;\n#line 94 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\tif (_tmp2_ == NULL) {\n#line 1014 \"tracker-backend.c\"\n\t\tGError* _tmp3_ = NULL;\n#line 95 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t\t_tmp3_ = g_error_new_literal (TRACKER_SPARQL_ERROR, TRACKER_SPARQL_ERROR_UNSUPPORTED, \"Update support not available for direct-only connection\");\n#line 95 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t\t_inner_error_ = _tmp3_;\n#line 95 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t\tif (((_inner_error_->domain == TRACKER_SPARQL_ERROR) || (_inner_error_->domain == G_IO_ERROR)) || (_inner_error_->domain == G_DBUS_ERROR)) {\n#line 95 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t\t\tg_propagate_error (error, _inner_error_);\n#line 95 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t\t\treturn;\n#line 1026 \"tracker-backend.c\"\n\t\t} else {\n#line 95 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\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#line 95 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t\t\tg_clear_error (&_inner_error_);\n#line 95 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t\t\treturn;\n#line 1034 \"tracker-backend.c\"\n\t\t}\n\t}\n#line 97 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t_tmp4_ = self->priv->bus;\n#line 97 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t_tmp5_ = sparql;\n#line 97 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t_tmp6_ = priority;\n#line 97 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t_tmp7_ = cancellable;\n#line 97 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\ttracker_sparql_connection_update (_tmp4_, _tmp5_, _tmp6_, _tmp7_, &_inner_error_);\n#line 97 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\tif (_inner_error_ != NULL) {\n#line 97 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t\tif (((_inner_error_->domain == TRACKER_SPARQL_ERROR) || (_inner_error_->domain == G_IO_ERROR)) || (_inner_error_->domain == G_DBUS_ERROR)) {\n#line 97 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t\t\tg_propagate_error (error, _inner_error_);\n#line 97 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t\t\treturn;\n#line 1055 \"tracker-backend.c\"\n\t\t} else {\n#line 97 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\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#line 97 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t\t\tg_clear_error (&_inner_error_);\n#line 97 \"/home/martyn/Source/checkout/gnome/tracker/src/libtracker-sparql-backend/tracker-backend.vala\"\n\t\t\treturn;\n#line 1063 \"tracker-backend.c\"\n\t\t}\n\t}\n}",
"label": 0,
"cwe": null,
"length": 1444
},
{
"index": 583727,
"code": "check_all (void)\n{\n if (verbose)\n fprintf (stderr, \"4.1 Wrap 128 bits of Key Data with a 128-bit KEK\\n\");\n check\n (GCRY_CIPHER_AES128,\n \"\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0A\\x0B\\x0C\\x0D\\x0E\\x0F\", 16,\n \"\\x00\\x11\\x22\\x33\\x44\\x55\\x66\\x77\\x88\\x99\\xAA\\xBB\\xCC\\xDD\\xEE\\xFF\", 16,\n \"\\x1F\\xA6\\x8B\\x0A\\x81\\x12\\xB4\\x47\\xAE\\xF3\\x4B\\xD8\\xFB\\x5A\\x7B\\x82\"\n \"\\x9D\\x3E\\x86\\x23\\x71\\xD2\\xCF\\xE5\", 24);\n\n if (verbose)\n fprintf (stderr, \"4.2 Wrap 128 bits of Key Data with a 192-bit KEK\\n\");\n check\n (GCRY_CIPHER_AES192,\n \"\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0A\\x0B\\x0C\\x0D\\x0E\\x0F\"\n \"\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\", 24,\n \"\\x00\\x11\\x22\\x33\\x44\\x55\\x66\\x77\\x88\\x99\\xAA\\xBB\\xCC\\xDD\\xEE\\xFF\", 16,\n \"\\x96\\x77\\x8B\\x25\\xAE\\x6C\\xA4\\x35\\xF9\\x2B\\x5B\\x97\\xC0\\x50\\xAE\\xD2\"\n \"\\x46\\x8A\\xB8\\xA1\\x7A\\xD8\\x4E\\x5D\", 24);\n\n if (verbose)\n fprintf (stderr, \"4.3 Wrap 128 bits of Key Data with a 256-bit KEK\\n\");\n check\n (GCRY_CIPHER_AES256,\n \"\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0A\\x0B\\x0C\\x0D\\x0E\\x0F\"\n \"\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1A\\x1B\\x1C\\x1D\\x1E\\x1F\", 32,\n \"\\x00\\x11\\x22\\x33\\x44\\x55\\x66\\x77\\x88\\x99\\xAA\\xBB\\xCC\\xDD\\xEE\\xFF\", 16,\n \"\\x64\\xE8\\xC3\\xF9\\xCE\\x0F\\x5B\\xA2\\x63\\xE9\\x77\\x79\\x05\\x81\\x8A\\x2A\"\n \"\\x93\\xC8\\x19\\x1E\\x7D\\x6E\\x8A\\xE7\", 24);\n\n if (verbose)\n fprintf (stderr, \"4.4 Wrap 192 bits of Key Data with a 192-bit KEK\\n\");\n check\n (GCRY_CIPHER_AES192,\n \"\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0A\\x0B\\x0C\\x0D\\x0E\\x0F\"\n \"\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\", 24,\n \"\\x00\\x11\\x22\\x33\\x44\\x55\\x66\\x77\\x88\\x99\\xAA\\xBB\\xCC\\xDD\\xEE\\xFF\"\n \"\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\", 24,\n \"\\x03\\x1D\\x33\\x26\\x4E\\x15\\xD3\\x32\\x68\\xF2\\x4E\\xC2\\x60\\x74\\x3E\\xDC\"\n \"\\xE1\\xC6\\xC7\\xDD\\xEE\\x72\\x5A\\x93\\x6B\\xA8\\x14\\x91\\x5C\\x67\\x62\\xD2\", 32);\n\n if (verbose)\n fprintf (stderr, \"4.5 Wrap 192 bits of Key Data with a 256-bit KEK\\n\");\n check\n (GCRY_CIPHER_AES256,\n \"\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0A\\x0B\\x0C\\x0D\\x0E\\x0F\"\n \"\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1A\\x1B\\x1C\\x1D\\x1E\\x1F\", 32,\n \"\\x00\\x11\\x22\\x33\\x44\\x55\\x66\\x77\\x88\\x99\\xAA\\xBB\\xCC\\xDD\\xEE\\xFF\"\n \"\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\", 24,\n \"\\xA8\\xF9\\xBC\\x16\\x12\\xC6\\x8B\\x3F\\xF6\\xE6\\xF4\\xFB\\xE3\\x0E\\x71\\xE4\"\n \"\\x76\\x9C\\x8B\\x80\\xA3\\x2C\\xB8\\x95\\x8C\\xD5\\xD1\\x7D\\x6B\\x25\\x4D\\xA1\", 32);\n\n if (verbose)\n fprintf (stderr, \"4.6 Wrap 256 bits of Key Data with a 256-bit KEK\\n\");\n check\n (GCRY_CIPHER_AES,\n \"\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0A\\x0B\\x0C\\x0D\\x0E\\x0F\"\n \"\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1A\\x1B\\x1C\\x1D\\x1E\\x1F\", 32,\n \"\\x00\\x11\\x22\\x33\\x44\\x55\\x66\\x77\\x88\\x99\\xAA\\xBB\\xCC\\xDD\\xEE\\xFF\"\n \"\\x00\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\x08\\x09\\x0A\\x0B\\x0C\\x0D\\x0E\\x0F\", 32,\n \"\\x28\\xC9\\xF4\\x04\\xC4\\xB8\\x10\\xF4\\xCB\\xCC\\xB3\\x5C\\xFB\\x87\\xF8\\x26\"\n \"\\x3F\\x57\\x86\\xE2\\xD8\\x0E\\xD3\\x26\\xCB\\xC7\\xF0\\xE7\\x1A\\x99\\xF4\\x3B\"\n \"\\xFB\\x98\\x8B\\x9B\\x7A\\x02\\xDD\\x21\", 40);\n}",
"label": 0,
"cwe": null,
"length": 1495
},
{
"index": 578055,
"code": "run_ijs_server(COMM_HANDLE *handle, const char *remote_host,\n u_long32 job_id,\n int nostdin, int noshell,\n int is_rsh, int is_qlogin, ternary_t force_pty,\n int *p_exit_status, dstring *p_err_msg)\n{\n int ret = 0, ret_val = 0;\n THREAD_HANDLE *pthread_tty_to_commlib = NULL;\n THREAD_HANDLE *pthread_commlib_to_tty = NULL;\n THREAD_LIB_HANDLE *thread_lib_handle = NULL;\n cl_raw_list_t *cl_com_log_list = NULL;\n\n DENTER(TOP_LAYER, \"run_ijs_server\");\n\n if (handle == NULL || p_err_msg == NULL || p_exit_status == NULL || remote_host == NULL) {\n return 1;\n }\n g_comm_handle = handle;\n g_hostname = strdup(remote_host);\n\n cl_com_log_list = cl_com_get_log_list();\n if (cl_com_log_list == NULL) {\n return 2;\n }\n\n g_nostdin = nostdin;\n g_noshell = noshell;\n\n /*\n * qrsh without command and qlogin both have is_rsh == 0 and is_qlogin == 1\n * qrsh with command and qsh don't need to set terminal mode.\n * If the user requested a pty we also have to set terminal mode.\n * But only if stdout is still connected to a tty and not redirected\n * to a file or a pipe.\n */\n if (isatty(STDOUT_FILENO) == 1 &&\n ((force_pty == UNSET && is_rsh == 0 && is_qlogin == 1) || force_pty == YES)) {\n /*\n * Set this terminal to raw mode, just output everything, don't interpret\n * it. Let the pty on the client side interpret the characters.\n */\n ret = terminal_enter_raw_mode();\n if (ret != 0) {\n sge_dstring_sprintf(p_err_msg, \"can't set terminal to raw mode: %s (%d)\",\n strerror(ret), ret);\n return 3;\n }\n }\n\n /*\n * Setup thread list and create two worker threads\n */\n thread_init_lib(&thread_lib_handle);\n /*\n * From here on, we have to cleanup the list in case of errors, this is\n * why we \"goto cleanup\" in case of error.\n */\n\n DPRINTF((\"creating worker threads\\n\"));\n DPRINTF((\"creating tty_to_commlib thread\\n\"));\n ret = create_thread(thread_lib_handle, &pthread_tty_to_commlib, cl_com_log_list,\n \"tty_to_commlib thread\", 1, tty_to_commlib);\n if (ret != CL_RETVAL_OK) {\n sge_dstring_sprintf(p_err_msg, \"can't create tty_to_commlib thread: %s\",\n cl_get_error_text(ret));\n ret_val = 4;\n goto cleanup;\n }\n\n DPRINTF((\"creating commlib_to_tty thread\\n\"));\n ret = create_thread(thread_lib_handle, &pthread_commlib_to_tty, cl_com_log_list,\n \"commlib_to_tty thread\", 1, commlib_to_tty);\n if (ret != CL_RETVAL_OK) {\n sge_dstring_sprintf(p_err_msg, \"can't create commlib_to_tty thread: %s\",\n cl_get_error_text(ret));\n ret_val = 5;\n goto cleanup;\n }\n\n /*\n * From here on, the two worker threads are doing all the work.\n * This main thread is just waiting until the client closes the \n * connection to us, which causes the commlib_to_tty thread to \n * exit. Then it closes the tty_to_commlib thread, too, and \n * cleans up everything.\n */\n DPRINTF((\"waiting for end of commlib_to_tty thread\\n\"));\n thread_join(pthread_commlib_to_tty);\n\n DPRINTF((\"shutting down tty_to_commlib thread\\n\"));\n thread_shutdown(pthread_tty_to_commlib);\n\n /*\n * Close stdin to awake the tty_to_commlib-thread from the select() call.\n * thread_shutdown() doesn't work on all architectures.\n */\n close(STDIN_FILENO);\n\n DPRINTF((\"waiting for end of tty_to_commlib thread\\n\"));\n thread_join(pthread_tty_to_commlib);\ncleanup:\n /*\n * Set our terminal back to 'unraw' mode. Should be done automatically\n * by OS on process end, but we want to be sure.\n */\n ret = terminal_leave_raw_mode();\n DPRINTF((\"terminal_leave_raw_mode() returned %s (%d)\\n\", strerror(ret), ret));\n if (ret != 0) {\n sge_dstring_sprintf(p_err_msg, \"error resetting terminal mode: %s (%d)\", strerror(ret));\n ret_val = 7; \n }\n\n *p_exit_status = g_exit_status;\n\n thread_cleanup_lib(&thread_lib_handle);\n DRETURN(ret_val);\n}",
"label": 0,
"cwe": null,
"length": 1104
},
{
"index": 19986,
"code": "Init() {\n\n static ClassDocumentation<ClusterDecayer> documentation\n (\"This class is responsible for the two-body decays of normal clusters\");\n\n static Reference<ClusterDecayer,HadronSelector> \n interfaceHadronSelector(\"HadronSelector\", \n \"A reference to the HadronSelector object\", \n &Herwig::ClusterDecayer::_hadronsSelector,\n\t\t\t false, false, true, false);\n\n //ClDir for light, Bottom, Charm and exotic (e.g Susy) quarks\n\n static Switch<ClusterDecayer,bool> interfaceClDirLight\n (\"ClDirLight\",\n \"Cluster direction for light quarks\",\n &ClusterDecayer::_clDirLight, true, false, false);\n static SwitchOption interfaceClDirLightPreserve\n (interfaceClDirLight,\n \"Preserve\",\n \"Preserve the direction of the quark from the perturbative stage\"\n \" as the direction of the meson produced from it\",\n true);\n static SwitchOption interfaceClDirLightIsotropic\n (interfaceClDirLight,\n \"Isotropic\",\n \"Assign the direction of the meson randomly\",\n false);\n\n static Switch<ClusterDecayer,bool> interfaceClDirBottom\n (\"ClDirBottom\",\n \"Cluster direction for bottom quarks\",\n &ClusterDecayer::_clDirBottom, true, false, false);\n static SwitchOption interfaceClDirBottomPreserve\n (interfaceClDirBottom,\n \"Preserve\",\n \"Preserve the direction of the quark from the perturbative stage\"\n \" as the direction of the meson produced from it\",\n true);\n static SwitchOption interfaceClDirBottomIsotropic\n (interfaceClDirBottom,\n \"Isotropic\",\n \"Assign the direction of the meson randomly\",\n false);\n\n static Switch<ClusterDecayer,bool> interfaceClDirCharm\n (\"ClDirCharm\",\n \"Cluster direction for charm quarks\",\n &ClusterDecayer::_clDirCharm, true, false, false);\n static SwitchOption interfaceClDirCharmPreserve\n (interfaceClDirCharm,\n \"Preserve\",\n \"Preserve the direction of the quark from the perturbative stage\"\n \" as the direction of the meson produced from it\",\n true);\n static SwitchOption interfaceClDirCharmIsotropic\n (interfaceClDirCharm,\n \"Isotropic\",\n \"Assign the direction of the meson randomly\",\n false);\n\n static Switch<ClusterDecayer,bool> interfaceClDirExotic\n (\"ClDirExotic\",\n \"Cluster direction for exotic quarks\",\n &ClusterDecayer::_clDirExotic, true, false, false);\n static SwitchOption interfaceClDirExoticPreserve\n (interfaceClDirExotic,\n \"Preserve\",\n \"Preserve the direction of the quark from the perturbative stage\"\n \" as the direction of the meson produced from it\",\n true);\n static SwitchOption interfaceClDirExoticIsotropic\n (interfaceClDirExotic,\n \"Isotropic\",\n \"Assign the direction of the meson randomly\",\n false);\n\n // ClSmr for ligth, Bottom, Charm and exotic (e.g. Susy) quarks\n static Parameter<ClusterDecayer,double> \n interfaceClSmrLight (\"ClSmrLight\", \"cluster direction Gaussian smearing for light quark\",\n &ClusterDecayer::_clSmrLight, 0, 0.0 , 0.0 , 2.0,false,false,false);\n static Parameter<ClusterDecayer,double> \n interfaceClSmrBottom (\"ClSmrBottom\", \"cluster direction Gaussian smearing for b quark\",\n &ClusterDecayer::_clSmrBottom, 0, 0.0 , 0.0 , 2.0,false,false,false); \nstatic Parameter<ClusterDecayer,double> \n interfaceClSmrCharm (\"ClSmrCharm\", \"cluster direction Gaussian smearing for c quark\",\n &ClusterDecayer::_clSmrCharm, 0, 0.0 , 0.0 , 2.0,false,false,false); \nstatic Parameter<ClusterDecayer,double> \n interfaceClSmrExotic (\"ClSmrExotic\", \"cluster direction Gaussian smearing for exotic quark\",\n &ClusterDecayer::_clSmrExotic, 0, 0.0 , 0.0 , 2.0,false,false,false); \n \n static Switch<ClusterDecayer,bool> interfaceOnShell\n (\"OnShell\",\n \"Whether or not the hadrons produced should by on shell or generated using the\"\n \" mass generator.\",\n &ClusterDecayer::_onshell, false, false, false);\n static SwitchOption interfaceOnShellOnShell\n (interfaceOnShell,\n \"Yes\",\n \"Produce the hadrons on shell\",\n true);\n static SwitchOption interfaceOnShellOffShell\n (interfaceOnShell,\n \"No\",\n \"Generate the masses using the mass generator.\",\n false);\n\n static Parameter<ClusterDecayer,unsigned int> interfaceMassTry\n (\"MassTry\",\n \"The number attempts to generate the masses of the hadrons produced\"\n \" in the cluster decay.\",\n &ClusterDecayer::_masstry, 20, 1, 50,\n false, false, Interface::limited);\n\n}",
"label": 0,
"cwe": null,
"length": 1159
},
{
"index": 850088,
"code": "ath9k_hw_wow_enable(struct ath_hw *ah, u32 pattern_enable)\n{\n\tu32 wow_event_mask;\n\tu32 keep_alive, magic_pattern, host_pm_ctrl;\n\n\twow_event_mask = ah->wow.wow_event_mask;\n\n\t/*\n\t * AR_PMCTRL_HOST_PME_EN - Override PME enable in configuration\n\t * space and allow MAC to generate WoW anyway.\n\t *\n\t * AR_PMCTRL_PWR_PM_CTRL_ENA - ???\n\t *\n\t * AR_PMCTRL_AUX_PWR_DET - PCI core SYS_AUX_PWR_DET signal,\n\t * needs to be set for WoW in PCI mode.\n\t *\n\t * AR_PMCTRL_WOW_PME_CLR - WoW Clear Signal going to the MAC.\n\t *\n\t * Set the power states appropriately and enable PME.\n\t *\n\t * Set and clear WOW_PME_CLEAR for the chip\n\t * to generate next wow signal.\n\t */\n\tREG_SET_BIT(ah, AR_PCIE_PM_CTRL, AR_PMCTRL_HOST_PME_EN |\n\t\t \t\t\t AR_PMCTRL_PWR_PM_CTRL_ENA |\n\t\t \t\t\t AR_PMCTRL_AUX_PWR_DET |\n\t\t \t\t\t AR_PMCTRL_WOW_PME_CLR);\n\tREG_CLR_BIT(ah, AR_PCIE_PM_CTRL, AR_PMCTRL_WOW_PME_CLR);\n\n\t/*\n\t * Random Backoff.\n\t *\n\t * 31:28 in AR_WOW_PATTERN : Indicates the number of bits used in the\n\t * contention window. For value N,\n\t * the random backoff will be selected between\n\t * 0 and (2 ^ N) - 1.\n\t */\n\tREG_SET_BIT(ah, AR_WOW_PATTERN,\n\t\t AR_WOW_BACK_OFF_SHIFT(AR_WOW_PAT_BACKOFF));\n\n\t/*\n\t * AIFS time, Slot time, Keep Alive count.\n\t */\n\tREG_SET_BIT(ah, AR_WOW_COUNT, AR_WOW_AIFS_CNT(AR_WOW_CNT_AIFS_CNT) |\n\t\t \t\t AR_WOW_SLOT_CNT(AR_WOW_CNT_SLOT_CNT) |\n\t\t \t\t AR_WOW_KEEP_ALIVE_CNT(AR_WOW_CNT_KA_CNT));\n\t/*\n\t * Beacon timeout.\n\t */\n\tif (pattern_enable & AH_WOW_BEACON_MISS)\n\t\tREG_WRITE(ah, AR_WOW_BCN_TIMO, AR_WOW_BEACON_TIMO);\n\telse\n\t\tREG_WRITE(ah, AR_WOW_BCN_TIMO, AR_WOW_BEACON_TIMO_MAX);\n\n\t/*\n\t * Keep alive timeout in ms.\n\t */\n\tif (!pattern_enable)\n\t\tREG_WRITE(ah, AR_WOW_KEEP_ALIVE_TIMO, AR_WOW_KEEP_ALIVE_NEVER);\n\telse\n\t\tREG_WRITE(ah, AR_WOW_KEEP_ALIVE_TIMO, KAL_TIMEOUT * 32);\n\n\t/*\n\t * Keep alive delay in us.\n\t */\n\tREG_WRITE(ah, AR_WOW_KEEP_ALIVE_DELAY, KAL_DELAY * 1000);\n\n\t/*\n\t * Create keep alive pattern to respond to beacons.\n\t */\n\tath9k_wow_create_keep_alive_pattern(ah);\n\n\t/*\n\t * Configure keep alive register.\n\t */\n\tkeep_alive = REG_READ(ah, AR_WOW_KEEP_ALIVE);\n\n\t/* Send keep alive timeouts anyway */\n\tkeep_alive &= ~AR_WOW_KEEP_ALIVE_AUTO_DIS;\n\n\tif (pattern_enable & AH_WOW_LINK_CHANGE) {\n\t\tkeep_alive &= ~AR_WOW_KEEP_ALIVE_FAIL_DIS;\n\t\twow_event_mask |= AR_WOW_KEEP_ALIVE_FAIL;\n\t} else {\n\t\tkeep_alive |= AR_WOW_KEEP_ALIVE_FAIL_DIS;\n\t}\n\n\tREG_WRITE(ah, AR_WOW_KEEP_ALIVE, keep_alive);\n\n\t/*\n\t * We are relying on a bmiss failure, ensure we have\n\t * enough threshold to prevent false positives.\n\t */\n\tREG_RMW_FIELD(ah, AR_RSSI_THR, AR_RSSI_THR_BM_THR,\n\t\t AR_WOW_BMISSTHRESHOLD);\n\n\tif (pattern_enable & AH_WOW_BEACON_MISS) {\n\t\twow_event_mask |= AR_WOW_BEACON_FAIL;\n\t\tREG_SET_BIT(ah, AR_WOW_BCN_EN, AR_WOW_BEACON_FAIL_EN);\n\t} else {\n\t\tREG_CLR_BIT(ah, AR_WOW_BCN_EN, AR_WOW_BEACON_FAIL_EN);\n\t}\n\n\t/*\n\t * Enable the magic packet registers.\n\t */\n\tmagic_pattern = REG_READ(ah, AR_WOW_PATTERN);\n\tmagic_pattern |= AR_WOW_MAC_INTR_EN;\n\n\tif (pattern_enable & AH_WOW_MAGIC_PATTERN_EN) {\n\t\tmagic_pattern |= AR_WOW_MAGIC_EN;\n\t\twow_event_mask |= AR_WOW_MAGIC_PAT_FOUND;\n\t} else {\n\t\tmagic_pattern &= ~AR_WOW_MAGIC_EN;\n\t}\n\n\tREG_WRITE(ah, AR_WOW_PATTERN, magic_pattern);\n\n\t/*\n\t * Enable pattern matching for packets which are less\n\t * than 256 bytes.\n\t */\n\tREG_WRITE(ah, AR_WOW_PATTERN_MATCH_LT_256B,\n\t\t AR_WOW_PATTERN_SUPPORTED);\n\n\t/*\n\t * Set the power states appropriately and enable PME.\n\t */\n\thost_pm_ctrl = REG_READ(ah, AR_PCIE_PM_CTRL);\n\thost_pm_ctrl |= AR_PMCTRL_PWR_STATE_D1D3 |\n\t\t\tAR_PMCTRL_HOST_PME_EN |\n\t\t\tAR_PMCTRL_PWR_PM_CTRL_ENA;\n\thost_pm_ctrl &= ~AR_PCIE_PM_CTRL_ENA;\n\n\tif (AR_SREV_9462(ah)) {\n\t\t/*\n\t\t * This is needed to prevent the chip waking up\n\t\t * the host within 3-4 seconds with certain\n\t\t * platform/BIOS.\n\t\t */\n\t\thost_pm_ctrl &= ~AR_PMCTRL_PWR_STATE_D1D3;\n\t\thost_pm_ctrl |= AR_PMCTRL_PWR_STATE_D1D3_REAL;\n\t}\n\n\tREG_WRITE(ah, AR_PCIE_PM_CTRL, host_pm_ctrl);\n\n\t/*\n\t * Enable sequence number generation when asleep.\n\t */\n\tREG_CLR_BIT(ah, AR_STA_ID1, AR_STA_ID1_PRESERVE_SEQNUM);\n\n\t/* To bring down WOW power low margin */\n\tREG_SET_BIT(ah, AR_PCIE_PHY_REG3, BIT(13));\n\n\tath9k_hw_wow_set_arwr_reg(ah);\n\n\tif (ath9k_hw_mci_is_enabled(ah))\n\t\tREG_WRITE(ah, AR_RTC_KEEP_AWAKE, 0x2);\n\n\t/* HW WoW */\n\tREG_CLR_BIT(ah, AR_PCU_MISC_MODE3, BIT(5));\n\n\tath9k_hw_set_powermode_wow_sleep(ah);\n\tah->wow.wow_event_mask = wow_event_mask;\n}",
"label": 0,
"cwe": null,
"length": 1379
},
{
"index": 26781,
"code": "print_synth_via(const char* name,\n unsigned int val)\n{\n printf(\"%s\", name);\n START;\n FM (0, 5, 0, 4, \"VIA WinChip (C6)\");\n FM (0, 5, 0, 8, \"VIA WinChip 2 (C6-2)\");\n FM (0, 6, 0, 6, \"VIA C3 (Samuel WinChip C5A core)\");\n FM (0, 6, 0, 6, \"VIA C3 (Samuel WinChip C5A core)\");\n FMS(0, 6, 0, 7, 0, \"VIA C3 (Samuel 2 WinChip C5B core) / Eden ESP 4000/5000/6000\");\n FMS(0, 6, 0, 7, 1, \"VIA C3 (Samuel 2 WinChip C5B core) / Eden ESP 4000/5000/6000\");\n FMS(0, 6, 0, 7, 2, \"VIA C3 (Samuel 2 WinChip C5B core) / Eden ESP 4000/5000/6000\");\n FMS(0, 6, 0, 7, 3, \"VIA C3 (Samuel 2 WinChip C5B core) / Eden ESP 4000/5000/6000\");\n FMS(0, 6, 0, 7, 4, \"VIA C3 (Samuel 2 WinChip C5B core) / Eden ESP 4000/5000/6000\");\n FMS(0, 6, 0, 7, 5, \"VIA C3 (Samuel 2 WinChip C5B core) / Eden ESP 4000/5000/6000\");\n FMS(0, 6, 0, 7, 6, \"VIA C3 (Samuel 2 WinChip C5B core) / Eden ESP 4000/5000/6000\");\n FMS(0, 6, 0, 7, 7, \"VIA C3 (Samuel 2 WinChip C5B core) / Eden ESP 4000/5000/6000\");\n FM (0, 6, 0, 7, \"VIA C3 (Ezra WinChip C5C core)\");\n FM (0, 6, 0, 8, \"VIA C3 (Ezra-T WinChip C5N core)\");\n FMS(0, 6, 0, 9, 0, \"VIA C3 / Eden ESP 7000/8000/10000 (Nehemiah WinChip C5XL core)\");\n FMS(0, 6, 0, 9, 1, \"VIA C3 / Eden ESP 7000/8000/10000 (Nehemiah WinChip C5XL core)\");\n FMS(0, 6, 0, 9, 2, \"VIA C3 / Eden ESP 7000/8000/10000 (Nehemiah WinChip C5XL core)\");\n FMS(0, 6, 0, 9, 3, \"VIA C3 / Eden ESP 7000/8000/10000 (Nehemiah WinChip C5XL core)\");\n FMS(0, 6, 0, 9, 4, \"VIA C3 / Eden ESP 7000/8000/10000 (Nehemiah WinChip C5XL core)\");\n FMS(0, 6, 0, 9, 5, \"VIA C3 / Eden ESP 7000/8000/10000 (Nehemiah WinChip C5XL core)\");\n FMS(0, 6, 0, 9, 6, \"VIA C3 / Eden ESP 7000/8000/10000 (Nehemiah WinChip C5XL core)\");\n FMS(0, 6, 0, 9, 7, \"VIA C3 / Eden ESP 7000/8000/10000 (Nehemiah WinChip C5XL core)\");\n FM (0, 6, 0, 9, \"VIA C3 / C3-M / Eden-N (Antaur WinChip C5P core)\");\n FM (0, 6, 0,10, \"VIA C7 / C7-M (Esther WinChip C5J core)\");\n FM (0, 6, 0,13, \"VIA C7 / C7-M / C7-D (Esther unknown core)\");\n FM (0, 6, 0,15, \"VIA Nano (Isaiah)\");\n F (0, 6, \"VIA C3 / C3-M / C7 / C7-M / Eden ESP 7000/8000/10000 / Nano (unknown model)\");\n DEFAULT (\"unknown\");\n printf(\"\\n\");\n}",
"label": 0,
"cwe": null,
"length": 1179
},
{
"index": 301398,
"code": "exec_move_row(PLpgSQL_execstate *estate,\n\t\t\t PLpgSQL_rec *rec,\n\t\t\t PLpgSQL_row *row,\n\t\t\t HeapTuple tup, TupleDesc tupdesc)\n{\n\t/*\n\t * Record is simple - just copy the tuple and its descriptor into the\n\t * record variable\n\t */\n\tif (rec != NULL)\n\t{\n\t\t/*\n\t\t * Copy input first, just in case it is pointing at variable's value\n\t\t */\n\t\tif (HeapTupleIsValid(tup))\n\t\t\ttup = heap_copytuple(tup);\n\t\telse if (tupdesc)\n\t\t{\n\t\t\t/* If we have a tupdesc but no data, form an all-nulls tuple */\n\t\t\tbool\t *nulls;\n\n\t\t\tnulls = (bool *) palloc(tupdesc->natts * sizeof(bool));\n\t\t\tmemset(nulls, true, tupdesc->natts * sizeof(bool));\n\n\t\t\ttup = heap_form_tuple(tupdesc, NULL, nulls);\n\n\t\t\tpfree(nulls);\n\t\t}\n\n\t\tif (tupdesc)\n\t\t\ttupdesc = CreateTupleDescCopy(tupdesc);\n\n\t\t/* Free the old value ... */\n\t\tif (rec->freetup)\n\t\t{\n\t\t\theap_freetuple(rec->tup);\n\t\t\trec->freetup = false;\n\t\t}\n\t\tif (rec->freetupdesc)\n\t\t{\n\t\t\tFreeTupleDesc(rec->tupdesc);\n\t\t\trec->freetupdesc = false;\n\t\t}\n\n\t\t/* ... and install the new */\n\t\tif (HeapTupleIsValid(tup))\n\t\t{\n\t\t\trec->tup = tup;\n\t\t\trec->freetup = true;\n\t\t}\n\t\telse\n\t\t\trec->tup = NULL;\n\n\t\tif (tupdesc)\n\t\t{\n\t\t\trec->tupdesc = tupdesc;\n\t\t\trec->freetupdesc = true;\n\t\t}\n\t\telse\n\t\t\trec->tupdesc = NULL;\n\n\t\treturn;\n\t}\n\n\t/*\n\t * Row is a bit more complicated in that we assign the individual\n\t * attributes of the tuple to the variables the row points to.\n\t *\n\t * NOTE: this code used to demand row->nfields ==\n\t * HeapTupleHeaderGetNatts(tup->t_data), but that's wrong. The tuple\n\t * might have more fields than we expected if it's from an\n\t * inheritance-child table of the current table, or it might have fewer if\n\t * the table has had columns added by ALTER TABLE. Ignore extra columns\n\t * and assume NULL for missing columns, the same as heap_getattr would do.\n\t * We also have to skip over dropped columns in either the source or\n\t * destination.\n\t *\n\t * If we have no tuple data at all, we'll assign NULL to all columns of\n\t * the row variable.\n\t */\n\tif (row != NULL)\n\t{\n\t\tint\t\t\ttd_natts = tupdesc ? tupdesc->natts : 0;\n\t\tint\t\t\tt_natts;\n\t\tint\t\t\tfnum;\n\t\tint\t\t\tanum;\n\n\t\tif (HeapTupleIsValid(tup))\n\t\t\tt_natts = HeapTupleHeaderGetNatts(tup->t_data);\n\t\telse\n\t\t\tt_natts = 0;\n\n\t\tanum = 0;\n\t\tfor (fnum = 0; fnum < row->nfields; fnum++)\n\t\t{\n\t\t\tPLpgSQL_var *var;\n\t\t\tDatum\t\tvalue;\n\t\t\tbool\t\tisnull;\n\t\t\tOid\t\t\tvaltype;\n\n\t\t\tif (row->varnos[fnum] < 0)\n\t\t\t\tcontinue;\t\t/* skip dropped column in row struct */\n\n\t\t\tvar = (PLpgSQL_var *) (estate->datums[row->varnos[fnum]]);\n\n\t\t\twhile (anum < td_natts && tupdesc->attrs[anum]->attisdropped)\n\t\t\t\tanum++;\t\t\t/* skip dropped column in tuple */\n\n\t\t\tif (anum < td_natts)\n\t\t\t{\n\t\t\t\tif (anum < t_natts)\n\t\t\t\t\tvalue = SPI_getbinval(tup, tupdesc, anum + 1, &isnull);\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tvalue = (Datum) 0;\n\t\t\t\t\tisnull = true;\n\t\t\t\t}\n\t\t\t\tvaltype = SPI_gettypeid(tupdesc, anum + 1);\n\t\t\t\tanum++;\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tvalue = (Datum) 0;\n\t\t\t\tisnull = true;\n\n\t\t\t\t/*\n\t\t\t\t * InvalidOid is OK because exec_assign_value doesn't care\n\t\t\t\t * about the type of a source NULL\n\t\t\t\t */\n\t\t\t\tvaltype = InvalidOid;\n\t\t\t}\n\n\t\t\texec_assign_value(estate, (PLpgSQL_datum *) var,\n\t\t\t\t\t\t\t value, valtype, &isnull);\n\t\t}\n\n\t\treturn;\n\t}\n\n\telog(ERROR, \"unsupported target\");\n}",
"label": 0,
"cwe": null,
"length": 1026
},
{
"index": 204113,
"code": "_ReadData( void* pvReadBuffer, const uint32_t nBufferSize, uint32_t& nRead )\n{\n uint32_t nBytesRead; // Number of bytes read from the IPC channel (packet length).\n uint32_t nDataLen; // User data length extracted from packet.\n uint16_t nSeqNum, nLastSeqNum; // Message sequence number: 0-63.\n uint16_t nFragSeqNum, nLastFragSeqNum; // Fragment sequence number: 0-63.\n int nMessageType = 0; // Message type (see packet info).\n uint8_t pRecvBuf[offsetof(PACKET, _data) + PKT_USERDATA_MAX];// Buffer for received packet.\n uint8_t pUDataBuf[PKT_USERDATA_MAX]; // User data extracted from packet.\n error_t retCode; // Return code.\n bool bCanRead; // Indicates if read operation will block or not.\n\n\n assert( m_pIPCServent != NULL );\n\n\n // Initialize local variables.\n nLastFragSeqNum = nLastSeqNum = INVALID_SEQNUM;\n nRead = 0; // Reset total message bytes counter.\n do\n {\n // --------------------------------------\n // Verify if data is available for read.\n // --------------------------------------\n if( (retCode = m_pIPCServent->CanRead( bCanRead )) != GOGOCM_UIS__NOERROR )\n {\n // Error checking if we can read.\n return retCode;\n }\n if( !bCanRead )\n {\n pal_sleep(33); // Sleep 33 milliseconds.\n continue;\n }\n\n\n // Reset number of user data extracted from packet.\n nDataLen = 0;\n\n // ----------------------------------\n // Read packet from the IPC channel.\n // ----------------------------------\n retCode = m_pIPCServent->Read( (void*)pRecvBuf, sizeof(pRecvBuf), nBytesRead );\n if( retCode == GOGOCM_UIS__NOERROR && nBytesRead > 0 )\n {\n // --------------------------------------------------------------------\n // Extract user data from packet, and put it into temporary user data\n // buffer.\n // --------------------------------------------------------------------\n nDataLen = ExtractPacketData( (PACKET*)pRecvBuf, pUDataBuf, &nMessageType, &nSeqNum, &nFragSeqNum );\n if( nDataLen == 0 )\n {\n // Bad packet or invalid data.\n return GOGOCM_UIS_BADPACKET;\n }\n\n\n // ----------------------------------------------------\n // Verify that message sequence number hasn't changed.\n // ----------------------------------------------------\n if( nLastSeqNum != INVALID_SEQNUM && nSeqNum != nLastSeqNum )\n {\n // Message sequence number change (meaning we've got another message).\n // This should NOT happen in this logic.\n // End of earlier message should have been detected before changing\n // message.\n // This is a serious error, as this packet data will be lost and\n // a de-synchronization will now occur forever...\n return GOGOCM_UIS_IPCDESYNCHRONIZED;\n }\n else\n nLastSeqNum = nSeqNum;\n\n\n // ------------------------------------------------------------\n // Verify that message fragment sequence number is sequential.\n // ------------------------------------------------------------\n if( nLastFragSeqNum != INVALID_SEQNUM && nFragSeqNum != (nLastFragSeqNum + 1) )\n {\n // Message fragments are not ordered.\n // ASSERTION: Pipe IPCs are assumed fifo. If using an IPC\n // other than pipe, correct this logic to allow\n // packet fragment re-ordering.\n return GOGOCM_UIS_PACKETSNOTORDERED;\n }\n else\n nLastFragSeqNum = nFragSeqNum;\n\n\n // --------------------------------------------------------------------\n // Verify that user data read won't overflow the provided read buffer.\n // --------------------------------------------------------------------\n if( (nRead + nDataLen) > nBufferSize )\n {\n // User did not provide enough buffer size to receive entire message.\n return GOGOCM_UIS_READBUFFERTOOSMALL;\n }\n\n\n // -----------------------------------------\n // Append user data to the provided buffer.\n // -----------------------------------------\n memcpy( ((uint8_t*)pvReadBuffer) + nRead, pUDataBuf, nDataLen );\n\n\n // Increase the number of user data bytes received.\n nRead += nDataLen;\n }\n\n }\n while( retCode == GOGOCM_UIS__NOERROR &&\n nMessageType != PKT_MSGTYPE_NONFRAGDATA &&\n nMessageType != PKT_MSGTYPE_FRAGDATALAST );\n\n\n // Read operation finished.\n return retCode;\n}",
"label": 0,
"cwe": null,
"length": 1034
},
{
"index": 66666,
"code": "trx_write_serialisation_history(\n/*============================*/\n\ttrx_t*\t\ttrx)\t/*!< in: transaction */\n{\n\tmtr_t\t\tmtr;\n\ttrx_rseg_t*\trseg;\n\ttrx_sysf_t*\tsys_header = NULL;\n\n\tut_ad(!mutex_own(&kernel_mutex));\n\n\trseg = trx->rseg;\n\n\tmtr_start(&mtr);\n\n\t/* Change the undo log segment states from TRX_UNDO_ACTIVE\n\tto some other state: these modifications to the file data\n\tstructure define the transaction as committed in the file\n\tbased domain, at the serialization point of the log sequence\n\tnumber lsn obtained below. */\n\n\tif (trx->update_undo != NULL) {\n\t\tpage_t*\t\tundo_hdr_page;\n\t\ttrx_undo_t*\tundo = trx->update_undo;\n\n\t\t/* We have to hold the rseg mutex because update\n\t\tlog headers have to be put to the history list in the\n\t\t(serialisation) order of the UNDO trx number. This is\n\t\trequired for the purge in-memory data structures too. */\n\n\t\tmutex_enter(&rseg->mutex);\n\n\t\t/* Assign the transaction serialisation number and also\n\t\tupdate the purge min binary heap if this is the first\n\t\tUNDO log being written to the assigned rollback segment. */\n\n\t\ttrx_serialisation_number_get(trx);\n\n\t\t/* It is not necessary to obtain trx->undo_mutex here\n\t\tbecause only a single OS thread is allowed to do the\n\t\ttransaction commit for this transaction. */\n\n\t\tundo_hdr_page = trx_undo_set_state_at_finish(undo, &mtr);\n\n\t\ttrx_undo_update_cleanup(trx, undo_hdr_page, &mtr);\n\t} else {\n\t\tmutex_enter(&rseg->mutex);\n\t}\n\n\tif (trx->insert_undo != NULL) {\n\t\ttrx_undo_set_state_at_finish(trx->insert_undo, &mtr);\n\t}\n\n\tmutex_exit(&rseg->mutex);\n\n\t/* Update the latest MySQL binlog name and offset info\n\tin trx sys header if MySQL binlogging is on or the database\n\tserver is a MySQL replication slave */\n\n\tif (trx->mysql_log_file_name\n\t && trx->mysql_log_file_name[0] != '\\0') {\n\t\tif (!sys_header) {\n\t\t\tsys_header = trx_sysf_get(&mtr);\n\t\t}\n\n\t\ttrx_sys_update_mysql_binlog_offset(\n\t\t\tsys_header,\n\t\t\ttrx->mysql_log_file_name,\n\t\t\ttrx->mysql_log_offset,\n\t\t\tTRX_SYS_MYSQL_LOG_INFO, &mtr);\n\n\t\ttrx->mysql_log_file_name = NULL;\n\t}\n\n\tif (trx->mysql_master_log_file_name[0] != '\\0') {\n\t\t/* This database server is a MySQL replication slave */\n\t\tif (!sys_header) {\n\t\t\tsys_header = trx_sysf_get(&mtr);\n\t\t}\n\n\t\ttrx_sys_update_mysql_binlog_offset(\n\t\t\tsys_header,\n\t\t\ttrx->mysql_master_log_file_name,\n\t\t\ttrx->mysql_master_log_pos,\n\t\t\tTRX_SYS_MYSQL_MASTER_LOG_INFO, &mtr);\n\t\ttrx->mysql_master_log_file_name = \"\";\n\t}\n\n\tif (trx->css_mysql_master_log_file_name[0] != '\\0') {\n\t\t/* This database server is a MySQL replication slave */\n\t\tif (!sys_header) {\n\t\t\tsys_header = trx_sysf_get(&mtr);\n\t\t}\n\n\t\ttrx_sys_update_mysql_binlog_offset(\n\t\t\tsys_header,\n\t\t\ttrx->css_mysql_relay_log_file_name,\n\t\t\ttrx->css_mysql_relay_log_pos,\n\t\t\tTRX_SYS_CSS_COMMIT_RELAY_LOG_INFO, &mtr);\n\n\t\ttrx_sys_update_mysql_binlog_offset(\n\t\t\tsys_header,\n\t\t\ttrx->css_mysql_master_log_file_name,\n\t\t\ttrx->css_mysql_master_log_pos,\n\t\t\tTRX_SYS_CSS_COMMIT_MASTER_LOG_INFO, &mtr);\n\n\t\ttrx_sys_update_mysql_binlog_offset(\n\t\t\tsys_header,\n\t\t\ttrx->css_mysql_relay_log_file_name,\n\t\t\ttrx->css_mysql_relay_log_pos,\n\t\t\tTRX_SYS_CSS_MYSQL_RELAY_LOG_INFO, &mtr);\n\n\t\ttrx_sys_update_mysql_binlog_offset(\n\t\t\tsys_header,\n\t\t\ttrx->css_mysql_master_log_file_name,\n\t\t\ttrx->css_mysql_master_log_pos,\n\t\t\tTRX_SYS_CSS_MYSQL_MASTER_LOG_INFO, &mtr);\n\n\t\ttrx->css_mysql_master_log_file_name = \"\";\n\t}\n\n\t/* The following call commits the mini-transaction, making the\n\twhole transaction committed in the file-based world, at this\n\tlog sequence number. The transaction becomes 'durable' when\n\twe write the log to disk, but in the logical sense the commit\n\tin the file-based data structures (undo logs etc.) happens\n\there.\n\n\tNOTE that transaction numbers, which are assigned only to\n\ttransactions with an update undo log, do not necessarily come\n\tin exactly the same order as commit lsn's, if the transactions\n\thave different rollback segments. To get exactly the same\n\torder we should hold the kernel mutex up to this point,\n\tadding to the contention of the kernel mutex. However, if\n\ta transaction T2 is able to see modifications made by\n\ta transaction T1, T2 will always get a bigger transaction\n\tnumber and a bigger commit lsn than T1. */\n\n\t/*--------------*/\n\tmtr_commit(&mtr);\n\t/*--------------*/\n\n\treturn(mtr.end_lsn);\n}",
"label": 0,
"cwe": null,
"length": 1141
},
{
"index": 374067,
"code": "ReadObj(TABMAPObjectBlock *poObjBlock)\n{\n m_nCoordBlockPtr = poObjBlock->ReadInt32();\n m_nCoordDataSize = poObjBlock->ReadInt32();\n\n if (m_nCoordDataSize & 0x80000000)\n {\n m_bSmooth = TRUE;\n m_nCoordDataSize &= 0x7FFFFFFF; //Take smooth flag out of the value\n }\n else\n {\n m_bSmooth = FALSE;\n }\n\n#ifdef TABDUMP\n printf(\"TABMAPObjPLine::ReadObj: m_nCoordDataSize = %d @ %d\\n\", \n m_nCoordDataSize, m_nCoordBlockPtr);\n#endif\n\n // Number of line segments applies only to MULTIPLINE/REGION but not PLINE\n if (m_nType == TAB_GEOM_PLINE_C ||\n m_nType == TAB_GEOM_PLINE )\n {\n m_numLineSections = 1;\n }\n else if (m_nType == TAB_GEOM_V800_REGION ||\n m_nType == TAB_GEOM_V800_REGION_C ||\n m_nType == TAB_GEOM_V800_MULTIPLINE ||\n m_nType == TAB_GEOM_V800_MULTIPLINE_C )\n {\n /* V800 REGIONS/MULTIPLINES use an int32 */\n m_numLineSections = poObjBlock->ReadInt32();\n /* ... followed by 33 unknown bytes */\n poObjBlock->ReadInt32();\n poObjBlock->ReadInt32();\n poObjBlock->ReadInt32();\n poObjBlock->ReadInt32();\n poObjBlock->ReadInt32();\n poObjBlock->ReadInt32();\n poObjBlock->ReadInt32();\n poObjBlock->ReadInt32();\n poObjBlock->ReadByte();\n }\n else\n {\n /* V300 and V450 REGIONS/MULTIPLINES use an int16 */\n m_numLineSections = poObjBlock->ReadInt16();\n }\n\n#ifdef TABDUMP\n printf(\"PLINE/REGION: id=%d, type=%d, \"\n \"CoordBlockPtr=%d, CoordDataSize=%d, numLineSect=%d, bSmooth=%d\\n\",\n m_nId, m_nType, m_nCoordBlockPtr, m_nCoordDataSize, \n m_numLineSections, m_bSmooth);\n#endif\n\n if (IsCompressedType())\n {\n // Region center/label point, relative to compr. coord. origin\n // No it's not relative to the Object block center\n m_nLabelX = poObjBlock->ReadInt16();\n m_nLabelY = poObjBlock->ReadInt16();\n\n // Compressed coordinate origin (present only in compressed case!)\n m_nComprOrgX = poObjBlock->ReadInt32();\n m_nComprOrgY = poObjBlock->ReadInt32();\n\n m_nLabelX += m_nComprOrgX;\n m_nLabelY += m_nComprOrgY;\n\n m_nMinX = m_nComprOrgX + poObjBlock->ReadInt16(); // Read MBR\n m_nMinY = m_nComprOrgY + poObjBlock->ReadInt16();\n m_nMaxX = m_nComprOrgX + poObjBlock->ReadInt16();\n m_nMaxY = m_nComprOrgY + poObjBlock->ReadInt16();\n }\n else\n {\n // Region center/label point, relative to compr. coord. origin\n // No it's not relative to the Object block center\n m_nLabelX = poObjBlock->ReadInt32();\n m_nLabelY = poObjBlock->ReadInt32();\n\n m_nMinX = poObjBlock->ReadInt32(); // Read MBR\n m_nMinY = poObjBlock->ReadInt32();\n m_nMaxX = poObjBlock->ReadInt32();\n m_nMaxY = poObjBlock->ReadInt32();\n }\n\n\n if ( ! IsCompressedType() )\n {\n // Init. Compr. Origin to a default value in case type is ever changed\n m_nComprOrgX = (m_nMinX + m_nMaxX) / 2;\n m_nComprOrgY = (m_nMinY + m_nMaxY) / 2;\n }\n\n m_nPenId = poObjBlock->ReadByte(); // Pen index\n\n if (m_nType == TAB_GEOM_REGION ||\n m_nType == TAB_GEOM_REGION_C ||\n m_nType == TAB_GEOM_V450_REGION ||\n m_nType == TAB_GEOM_V450_REGION_C ||\n m_nType == TAB_GEOM_V800_REGION ||\n m_nType == TAB_GEOM_V800_REGION_C )\n {\n m_nBrushId = poObjBlock->ReadByte(); // Brush index... REGION only\n }\n else\n {\n m_nBrushId = 0;\n }\n\n if (CPLGetLastErrorNo() != 0)\n return -1;\n\n return 0;\n}",
"label": 0,
"cwe": null,
"length": 1104
},
{
"index": 690570,
"code": "irda_usb_receive(struct urb *urb)\n{\n\tstruct sk_buff *skb = (struct sk_buff *) urb->context;\n\tstruct irda_usb_cb *self; \n\tstruct irda_skb_cb *cb;\n\tstruct sk_buff *newskb;\n\tstruct sk_buff *dataskb;\n\tstruct urb *next_urb;\n\tunsigned int len, docopy;\n\n\tpr_debug(\"%s(), len=%d\\n\", __func__, urb->actual_length);\n\t\n\t/* Find ourselves */\n\tcb = (struct irda_skb_cb *) skb->cb;\n\tIRDA_ASSERT(cb != NULL, return;);\n\tself = (struct irda_usb_cb *) cb->context;\n\tIRDA_ASSERT(self != NULL, return;);\n\n\t/* If the network is closed or the device gone, stop everything */\n\tif ((!self->netopen) || (!self->present)) {\n\t\tpr_debug(\"%s(), Network is gone!\\n\", __func__);\n\t\t/* Don't re-submit the URB : will stall the Rx path */\n\t\treturn;\n\t}\n\t\n\t/* Check the status */\n\tif (urb->status != 0) {\n\t\tswitch (urb->status) {\n\t\tcase -EILSEQ:\n\t\t\tself->netdev->stats.rx_crc_errors++;\n\t\t\t/* Also precursor to a hot-unplug on UHCI. */\n\t\t\t/* Fallthrough... */\n\t\tcase -ECONNRESET:\n\t\t\t/* Random error, if I remember correctly */\n\t\t\t/* uhci_cleanup_unlink() is going to kill the Rx\n\t\t\t * URB just after we return. No problem, at this\n\t\t\t * point the URB will be idle ;-) - Jean II */\n\t\tcase -ESHUTDOWN:\n\t\t\t/* That's usually a hot-unplug. Submit will fail... */\n\t\tcase -ETIME:\n\t\t\t/* Usually precursor to a hot-unplug on OHCI. */\n\t\tdefault:\n\t\t\tself->netdev->stats.rx_errors++;\n\t\t\tpr_debug(\"%s(), RX status %d, transfer_flags 0x%04X\\n\",\n\t\t\t\t __func__, urb->status, urb->transfer_flags);\n\t\t\tbreak;\n\t\t}\n\t\t/* If we received an error, we don't want to resubmit the\n\t\t * Rx URB straight away but to give the USB layer a little\n\t\t * bit of breathing room.\n\t\t * We are in the USB thread context, therefore there is a\n\t\t * danger of recursion (new URB we submit fails, we come\n\t\t * back here).\n\t\t * With recent USB stack (2.6.15+), I'm seeing that on\n\t\t * hot unplug of the dongle...\n\t\t * Lowest effective timer is 10ms...\n\t\t * Jean II */\n\t\tself->rx_defer_timer.function = irda_usb_rx_defer_expired;\n\t\tself->rx_defer_timer.data = (unsigned long) urb;\n\t\tmod_timer(&self->rx_defer_timer,\n\t\t\t jiffies + msecs_to_jiffies(10));\n\n\t\treturn;\n\t}\n\t\n\t/* Check for empty frames */\n\tif (urb->actual_length <= self->header_length) {\n\t\tnet_warn_ratelimited(\"%s(), empty frame!\\n\", __func__);\n\t\tgoto done;\n\t}\n\n\t/* \n\t * Remember the time we received this frame, so we can\n\t * reduce the min turn time a bit since we will know\n\t * how much time we have used for protocol processing\n\t */\n\tself->stamp = ktime_get();\n\n\t/* Check if we need to copy the data to a new skb or not.\n\t * For most frames, we use ZeroCopy and pass the already\n\t * allocated skb up the stack.\n\t * If the frame is small, it is more efficient to copy it\n\t * to save memory (copy will be fast anyway - that's\n\t * called Rx-copy-break). Jean II */\n\tdocopy = (urb->actual_length < IRDA_RX_COPY_THRESHOLD);\n\n\t/* Allocate a new skb */\n\tif (self->capability & IUC_STIR421X)\n\t\tnewskb = dev_alloc_skb(docopy ? urb->actual_length :\n\t\t\t\t IRDA_SKB_MAX_MTU +\n\t\t\t\t USB_IRDA_STIR421X_HEADER);\n\telse\n\t\tnewskb = dev_alloc_skb(docopy ? urb->actual_length :\n\t\t\t\t IRDA_SKB_MAX_MTU);\n\n\tif (!newskb) {\n\t\tself->netdev->stats.rx_dropped++;\n\t\t/* We could deliver the current skb, but this would stall\n\t\t * the Rx path. Better drop the packet... Jean II */\n\t\tgoto done; \n\t}\n\n\t/* Make sure IP header get aligned (IrDA header is 5 bytes) */\n\t/* But IrDA-USB header is 1 byte. Jean II */\n\t//skb_reserve(newskb, USB_IRDA_HEADER - 1);\n\n\tif(docopy) {\n\t\t/* Copy packet, so we can recycle the original */\n\t\tskb_copy_from_linear_data(skb, newskb->data, urb->actual_length);\n\t\t/* Deliver this new skb */\n\t\tdataskb = newskb;\n\t\t/* And hook the old skb to the URB\n\t\t * Note : we don't need to \"clean up\" the old skb,\n\t\t * as we never touched it. Jean II */\n\t} else {\n\t\t/* We are using ZeroCopy. Deliver old skb */\n\t\tdataskb = skb;\n\t\t/* And hook the new skb to the URB */\n\t\tskb = newskb;\n\t}\n\n\t/* Set proper length on skb & remove USB-IrDA header */\n\tskb_put(dataskb, urb->actual_length);\n\tskb_pull(dataskb, self->header_length);\n\n\t/* Ask the networking layer to queue the packet for the IrDA stack */\n\tdataskb->dev = self->netdev;\n\tskb_reset_mac_header(dataskb);\n\tdataskb->protocol = htons(ETH_P_IRDA);\n\tlen = dataskb->len;\n\tnetif_rx(dataskb);\n\n\t/* Keep stats up to date */\n\tself->netdev->stats.rx_bytes += len;\n\tself->netdev->stats.rx_packets++;\n\ndone:\n\t/* Note : at this point, the URB we've just received (urb)\n\t * is still referenced by the USB layer. For example, if we\n\t * have received a -ECONNRESET, uhci_cleanup_unlink() will\n\t * continue to process it (in fact, cleaning it up).\n\t * If we were to submit this URB, disaster would ensue.\n\t * Therefore, we submit our idle URB, and put this URB in our\n\t * idle slot....\n\t * Jean II */\n\t/* Note : with this scheme, we could submit the idle URB before\n\t * processing the Rx URB. I don't think it would buy us anything as\n\t * we are running in the USB thread context. Jean II */\n\tnext_urb = self->idle_rx_urb;\n\n\t/* Recycle Rx URB : Now, the idle URB is the present one */\n\turb->context = NULL;\n\tself->idle_rx_urb = urb;\n\n\t/* Submit the idle URB to replace the URB we've just received.\n\t * Do it last to avoid race conditions... Jean II */\n\tirda_usb_submit(self, skb, next_urb);\n}",
"label": 0,
"cwe": null,
"length": 1526
},
{
"index": 827630,
"code": "row_sel_field_store_in_mysql_format(\n/*================================*/\n\tbyte*\t\tdest,\t/*!< in/out: buffer where to store; NOTE\n\t\t\t\tthat BLOBs are not in themselves\n\t\t\t\tstored here: the caller must allocate\n\t\t\t\tand copy the BLOB into buffer before,\n\t\t\t\tand pass the pointer to the BLOB in\n\t\t\t\t'data' */\n\tconst mysql_row_templ_t* templ,\n\t\t\t\t/*!< in: MySQL column template.\n\t\t\t\tIts following fields are referenced:\n\t\t\t\ttype, is_unsigned, mysql_col_len,\n\t\t\t\tmbminlen, mbmaxlen */\n\tconst byte*\tdata,\t/*!< in: data to store */\n\tulint\t\tlen)\t/*!< in: length of the data */\n{\n\tbyte*\tptr;\n\n\tut_ad(len != UNIV_SQL_NULL);\n\tUNIV_MEM_ASSERT_RW(data, len);\n\tUNIV_MEM_ASSERT_W(dest, templ->mysql_col_len);\n\tUNIV_MEM_INVALID(dest, templ->mysql_col_len);\n\n\tswitch (templ->type) {\n\t\tconst byte*\tfield_end;\n\t\tbyte*\t\tpad;\n\tcase DATA_INT:\n\t\t/* Convert integer data from Innobase to a little-endian\n\t\tformat, sign bit restored to normal */\n\n\t\tptr = dest + len;\n\n\t\tfor (;;) {\n\t\t\tptr--;\n\t\t\t*ptr = *data;\n\t\t\tif (ptr == dest) {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tdata++;\n\t\t}\n\n\t\tif (!templ->is_unsigned) {\n\t\t\tdest[len - 1] = (byte) (dest[len - 1] ^ 128);\n\t\t}\n\n\t\tut_ad(templ->mysql_col_len == len);\n\t\tbreak;\n\n\tcase DATA_VARCHAR:\n\tcase DATA_VARMYSQL:\n\tcase DATA_BINARY:\n\t\tfield_end = dest + templ->mysql_col_len;\n\n\t\tif (templ->mysql_type == DATA_MYSQL_TRUE_VARCHAR) {\n\t\t\t/* This is a >= 5.0.3 type true VARCHAR. Store the\n\t\t\tlength of the data to the first byte or the first\n\t\t\ttwo bytes of dest. */\n\n\t\t\tdest = row_mysql_store_true_var_len(\n\t\t\t\tdest, len, templ->mysql_length_bytes);\n\t\t\t/* Copy the actual data. Leave the rest of the\n\t\t\tbuffer uninitialized. */\n\t\t\tmemcpy(dest, data, len);\n\t\t\tbreak;\n\t\t}\n\n\t\t/* Copy the actual data */\n\t\tut_memcpy(dest, data, len);\n\n\t\t/* Pad with trailing spaces. */\n\n\t\tpad = dest + len;\n\n\t\tut_ad(templ->mbminlen <= templ->mbmaxlen);\n\n\t\t/* We treat some Unicode charset strings specially. */\n\t\tswitch (templ->mbminlen) {\n\t\tcase 4:\n\t\t\t/* InnoDB should never have stripped partial\n\t\t\tUTF-32 characters. */\n\t\t\tut_a(!(len & 3));\n\t\t\tbreak;\n\t\tcase 2:\n\t\t\t/* A space char is two bytes,\n\t\t\t0x0020 in UCS2 and UTF-16 */\n\n\t\t\tif (UNIV_UNLIKELY(len & 1)) {\n\t\t\t\t/* A 0x20 has been stripped from the column.\n\t\t\t\tPad it back. */\n\n\t\t\t\tif (pad < field_end) {\n\t\t\t\t\t*pad++ = 0x20;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\trow_mysql_pad_col(templ->mbminlen, pad, field_end - pad);\n\t\tbreak;\n\n\tcase DATA_BLOB:\n\t\t/* Store a pointer to the BLOB buffer to dest: the BLOB was\n\t\talready copied to the buffer in row_sel_store_mysql_rec */\n\n\t\trow_mysql_store_blob_ref(dest, templ->mysql_col_len, data,\n\t\t\t\t\t len);\n\t\tbreak;\n\n\tcase DATA_MYSQL:\n\t\tmemcpy(dest, data, len);\n\n\t\tut_ad(templ->mysql_col_len >= len);\n\t\tut_ad(templ->mbmaxlen >= templ->mbminlen);\n\n\t\tut_ad(templ->mbmaxlen > templ->mbminlen\n\t\t || templ->mysql_col_len == len);\n\t\t/* The following assertion would fail for old tables\n\t\tcontaining UTF-8 ENUM columns due to Bug #9526. */\n\t\tut_ad(!templ->mbmaxlen\n\t\t || !(templ->mysql_col_len % templ->mbmaxlen));\n\t\tut_ad(len * templ->mbmaxlen >= templ->mysql_col_len);\n\n\t\tif (templ->mbminlen == 1 && templ->mbmaxlen != 1) {\n\t\t\t/* Pad with spaces. This undoes the stripping\n\t\t\tdone in row0mysql.c, function\n\t\t\trow_mysql_store_col_in_innobase_format(). */\n\n\t\t\tmemset(dest + len, 0x20, templ->mysql_col_len - len);\n\t\t}\n\t\tbreak;\n\n\tdefault:\n#ifdef UNIV_DEBUG\n\tcase DATA_SYS_CHILD:\n\tcase DATA_SYS:\n\t\t/* These column types should never be shipped to MySQL. */\n\t\tut_ad(0);\n\n\tcase DATA_CHAR:\n\tcase DATA_FIXBINARY:\n\tcase DATA_FLOAT:\n\tcase DATA_DOUBLE:\n\tcase DATA_DECIMAL:\n\t\t/* Above are the valid column types for MySQL data. */\n#endif /* UNIV_DEBUG */\n\t\tut_ad(templ->mysql_col_len == len);\n\t\tmemcpy(dest, data, len);\n\t}\n}",
"label": 1,
"cwe": "CWE-other",
"length": 1097
},
{
"index": 84398,
"code": "execmd_recurs(voccxdef *ctx, objnum actor, objnum verb,\r\n objnum dobj, objnum prep, objnum iobj,\r\n int validate_dobj, int validate_iobj)\r\n{\r\n int err;\r\n int newstyle;\r\n uchar tpl[VOCTPL2SIZ];\r\n vocoldef dobjv;\r\n vocoldef iobjv;\r\n voccxdef ctx_copy;\r\n runsdef *orig_sp;\r\n runsdef *orig_bp;\r\n\r\n /*\r\n * Save the stack and base pointers as they are on entry. Since\r\n * exe1cmd() is being called recursively, it won't automatically clear\r\n * the stack after it's done as it would at the top level; this means\r\n * that an aborted frame can be left on the stack if we throw an\r\n * 'exit' or 'abort' in the course of executing the command. To make\r\n * sure we don't leave any aborted frames on the stack before\r\n * returning to our caller, we simply need to restore the stack and\r\n * frame pointers on the way out as they were on the way in. \r\n */\r\n orig_sp = ctx->voccxrun->runcxsp;\r\n orig_bp = ctx->voccxrun->runcxbp;\r\n\r\n /* make a copy of the voc context, so that changes aren't permanent */\r\n ctx_copy = *ctx;\r\n ctx = &ctx_copy;\r\n\r\n /* \r\n * there are no unknown words in the recursive command, since the\r\n * command was prepared directly from resolved objects \r\n */\r\n ctx->voccxunknown = 0;\r\n\r\n /* set up the vocoldef structure for the direct object, if present */\r\n if (dobj != MCMONINV)\r\n {\r\n dobjv.vocolobj = dobj;\r\n dobjv.vocolfst = dobjv.vocollst = \"\";\r\n dobjv.vocolflg = 0;\r\n }\r\n\r\n /* set up the vocoldef structure for the indirect object, if present */\r\n if (iobj != MCMONINV)\r\n {\r\n iobjv.vocolobj = iobj;\r\n iobjv.vocolfst = iobjv.vocollst = \"\";\r\n iobjv.vocolflg = 0;\r\n }\r\n \r\n /* figure out which template we need, based on the objects provided */\r\n if (dobj == MCMONINV)\r\n {\r\n uint actofs;\r\n uint tplofs;\r\n \r\n /* \r\n * No objects were provided - use the verb's \"action\" method.\r\n * Make sure that there is in fact an \"action\" method. \r\n */\r\n exe_get_tpl(ctx, verb, &tplofs, &actofs);\r\n if (actofs != 0)\r\n {\r\n /* execute the \"action\" method */\r\n err = exe1cmd(ctx, actor, verb, 0, &prep, 0, FALSE,\r\n 0, FALSE, TRUE, validate_dobj, validate_iobj,\r\n 0, 0, 0, FALSE, 0);\r\n }\r\n else\r\n {\r\n /* indicate that the sentence structure wasn't understood */\r\n err = ERR_PRS_SENT_UNK;\r\n }\r\n }\r\n else if (iobj == MCMONINV)\r\n {\r\n /* \r\n * No indirect object was provided, but a direct object is\r\n * present - use the one-object template. First, look up the\r\n * template. \r\n */\r\n if (voctplfnd(ctx, verb, MCMONINV, tpl, &newstyle))\r\n {\r\n /* execute the command */\r\n err = exe1cmd(ctx, actor, verb, &dobjv, &prep, 0, FALSE,\r\n tpl, newstyle, TRUE, validate_dobj, validate_iobj,\r\n &dobjv, 0, 1, FALSE, 0);\r\n }\r\n else\r\n {\r\n /* indicate that the sentence structure wasn't understood */\r\n err = ERR_PRS_SENT_UNK;\r\n }\r\n }\r\n else\r\n {\r\n /* \r\n * Both a direct and indirect object were provided - find the\r\n * two-object template for the given preposition.\r\n */\r\n if (voctplfnd(ctx, verb, prep, tpl, &newstyle))\r\n {\r\n /* execute the command */\r\n err = exe1cmd(ctx, actor, verb, &dobjv, &prep, &iobjv, FALSE,\r\n tpl, newstyle, TRUE, validate_dobj, validate_iobj,\r\n &dobjv, 0, 1, FALSE, 0);\r\n }\r\n else\r\n {\r\n /* indicate that the sentence structure wasn't understood */\r\n err = ERR_PRS_SENT_UNK;\r\n }\r\n }\r\n\r\n /* \r\n * if the error was EXITPRECMD, change it to EXIT - EXITPRECMD is a\r\n * special flag indicating that we exited from a preCommand\r\n * function, which is different than normal exiting internally but\r\n * not to the game \r\n */\r\n if (err == ERR_RUNEXITPRECMD)\r\n err = ERR_RUNEXIT;\r\n\r\n /*\r\n * restore the original stack and base pointers, to ensure that we\r\n * don't leave any aborted frames on the stack \r\n */\r\n ctx->voccxrun->runcxsp = orig_sp;\r\n ctx->voccxrun->runcxbp = orig_bp;\r\n\r\n /* return the result code */\r\n return err;\r\n}",
"label": 0,
"cwe": null,
"length": 1208
},
{
"index": 1003799,
"code": "write(DcmOutputStream &outStream,\n const E_TransferSyntax oxfer,\n const E_EncodingType enctype,\n DcmWriteCache *wcache,\n const E_GrpLenEncoding glenc,\n const E_PaddingEncoding padenc,\n const Uint32 padlen,\n const Uint32 subPadlen,\n Uint32 instanceLength,\n const E_FileWriteMode writeMode)\n /*\n * This function writes data values which are contained in this to the stream which is\n * passed as first argument. With regard to the writing of information, the other parameters\n * which are passed are accounted for. The function will return EC_Normal, if the information\n * from all elements of this data set has been written to the buffer, and it will return some\n * other (error) value if there was an error.\n *\n * Parameters:\n * outStream - [inout] The stream that the information will be written to.\n * oxfer - [in] The transfer syntax which shall be used.\n * enctype - [in] Encoding type for sequences. Specifies how sequences will be handled.\n * glenc - [in] Encoding type for group length. Specifies what will be done with group length tags.\n * padenc - [in] Encoding type for padding. Specifies what will be done with padding tags.\n * padlen - [in] The length up to which the dataset shall be padded, if padding is desired.\n * subPadlen - [in] For sequences (i.e. sub elements), the length up to which item shall be padded,\n * if padding is desired.\n * instanceLength - [in] Number of extra bytes added to the item/dataset length used when computing the\n * padding. This parameter is for instance used to pass the length of the file meta\n * header from the DcmFileFormat to the DcmDataset object.\n * writeMode - [in] Write file with or without meta header. Also allows for updating the information\n * in the file meta information header.\n */\n{\n /* if the transfer state of this is not initialized, this is an illegal call */\n if (getTransferState() == ERW_notInitialized)\n errorFlag = EC_IllegalCall;\n else\n {\n /* if this is not an illegal call, do something */\n\n /* assign data set and the meta information header to local variables */\n DcmDataset *dataset = getDataset();\n DcmMetaInfo *metainfo = getMetaInfo();\n /* Determine the transfer syntax which shall be used. Either we use the one which was passed, */\n /* or (if it's an unknown tranfer syntax) we use the data set's original transfer syntax. */\n E_TransferSyntax outxfer = oxfer;\n if (outxfer == EXS_Unknown && dataset)\n outxfer = dataset->getOriginalXfer();\n /* check if the stream reported an error so far */\n errorFlag = outStream.status();\n /* check if we can actually write data to the stream; in certain cases we cannot. */\n if (outxfer == EXS_Unknown || outxfer == EXS_BigEndianImplicit)\n errorFlag = EC_IllegalCall;\n else if (itemList->empty())\n errorFlag = EC_CorruptedData;\n else if (errorFlag.good() && getTransferState() != ERW_ready)\n {\n /* in this case we can write data to the stream */\n\n /* if this function was called for the first time for the dataset object, the transferState is */\n /* still set to ERW_init. In this case, we need to validate the meta header information, set the */\n /* item list pointer to the fist element and we need to set the transfer state to ERW_inWork. */\n if (getTransferState() == ERW_init)\n {\n validateMetaInfo(outxfer, writeMode);\n itemList->seek(ELP_first);\n setTransferState(ERW_inWork);\n }\n /* if the transfer state is set to ERW_inWork, we need to write the */\n /* information which is included in this to the buffer which was passed. */\n if (getTransferState() == ERW_inWork)\n {\n /* write meta header information */\n errorFlag = metainfo->write(outStream, outxfer, enctype, wcache);\n /* recalculate the instance length */\n instanceLength += metainfo->calcElementLength(outxfer, enctype);\n /* if everything is ok, write the data set */\n if (errorFlag.good())\n errorFlag = dataset->write(outStream, outxfer, enctype, wcache, glenc, padenc, padlen,\n subPadlen, instanceLength);\n /* if everything is ok, set the transfer state to ERW_ready */\n if (errorFlag.good())\n setTransferState(ERW_ready);\n }\n }\n /* in case the transfer syntax which shall be used is indeed the */\n /* BigEndianImplicit transfer syntax dump some error information */\n if (outxfer == EXS_BigEndianImplicit)\n DCMDATA_ERROR(\"DcmFileFormat::write() Illegal TransferSyntax (BigEndianImplicit) used\");\n }\n /* return result value */\n return errorFlag;\n}",
"label": 0,
"cwe": null,
"length": 1150
},
{
"index": 408183,
"code": "gsb_form_fill_by_transaction ( gint transaction_number,\n gint is_transaction,\n gboolean grab_focus )\n{\n gint mother_number;\n gint account_number;\n gint focus_to;\n gint is_split;\n GSList *tmp_list;\n\n devel_debug_int (transaction_number);\n\n if ( !transaction_number )\n return FALSE;\n\n /* get the account */\n account_number = gsb_data_mix_get_account_number (transaction_number, is_transaction);\n mother_number = gsb_data_mix_get_mother_transaction_number (transaction_number, is_transaction);\n is_split = gsb_data_mix_get_split_of_transaction (transaction_number, is_transaction);\n\n /* if here account number = -1, it's because it's a white line or there were a problem ; \n * in all case, get the current account number */\n if (account_number == -1)\n account_number = gsb_form_get_account_number ();\n\n /* show and prepare the form */\n gsb_form_show ( TRUE );\n\n if ( !is_transaction )\n {\n\t/* we need to set up the part of scheduler form here because changing the account\n\t * button will change the form */\n gsb_form_scheduler_set ( transaction_number );\n }\n\n /* if the transaction is the white line, we set the date and necessary stuff and go away\n * for that use the button_press function, so clicking on a form's field or do enter/double click\n * on white line will do the same */\n if ( transaction_number == -1 )\n {\n GtkWidget *date_entry;\n\n /* if we can't touch the focus, it's because we just select a transaction, and\n * for now, select the white line, so keep the form blank */\n if ( !grab_focus )\n return FALSE;\n\n date_entry = gsb_form_widget_get_widget (TRANSACTION_FORM_DATE);\n\n if ( gsb_form_widget_check_empty (date_entry))\n /* for now, transaction_number_in_form is NULL so can call the next function\n * wich will prepare the form for a new transaction */\n gsb_form_button_press_event ( date_entry,\n NULL,\n GINT_TO_POINTER (TRANSACTION_FORM_DATE));\n\n gtk_editable_select_region ( GTK_EDITABLE (date_entry), 0, -1);\n gtk_widget_grab_focus ( GTK_WIDGET (date_entry));\n\n return FALSE;\n }\n\n /* set the number of the transaction in the form, can be -2, -3...\n * for white line split\n * that must be defined before gsb_form_change_sensitive_buttons\n * because without that number, others functions cannot get the account\n * number for an execution of scheduled in the home page\n * but after gsb_form_show because it will set that value to 0...*/\n g_object_set_data ( G_OBJECT ( transaction_form ),\n\t\t\t\"transaction_number_in_form\",\n\t\t\tGINT_TO_POINTER (transaction_number));\n\n gsb_form_change_sensitive_buttons (TRUE);\n\n /* by default, a function before changed all the form from non sensitive to sensitive,\n * but for split or split child, some widgets need to be unsensitive/hidden */\n gsb_form_set_sensitive (is_split, mother_number);\n\n /* fill what is necessary in the form */\n tmp_list = gsb_form_widget_get_list ();\n\n while (tmp_list)\n {\n struct_element *element;\n\n element = tmp_list -> data;\n\n if (mother_number\n &&\n transaction_number < 0)\n {\n /* we are on a split white line, we fill only few fields\n * with the element_number of the mother */\n switch (element -> element_number)\n {\n case TRANSACTION_FORM_DATE:\n case TRANSACTION_FORM_VALUE_DATE:\n case TRANSACTION_FORM_PARTY:\n case TRANSACTION_FORM_TYPE:\n case TRANSACTION_FORM_CHEQUE:\n case TRANSACTION_FORM_DEVISE:\n case TRANSACTION_FORM_BANK:\n gsb_form_fill_element ( element -> element_number,\n account_number,\n mother_number,\n is_transaction );\n break;\n }\n }\n else\n /* normal transaction */\n gsb_form_fill_element ( element -> element_number,\n account_number,\n transaction_number,\n is_transaction );\n\n tmp_list = tmp_list -> next;\n }\n\n /* for a transaction, need to check if marked R, and do some stuff with that */\n if (is_transaction)\n {\n gint contra_transaction_number;\n\n /* get the contra transaction */\n contra_transaction_number = gsb_data_transaction_get_contra_transaction_number ( transaction_number );\n\n /* if the transaction is marked R and splitted, cannot change the amounts */\n if ( gsb_data_transaction_get_marked_transaction (transaction_number) == OPERATION_RAPPROCHEE\n && mother_number == 0 )\n {\n gtk_widget_set_sensitive ( gsb_form_widget_get_widget (TRANSACTION_FORM_DEBIT), FALSE );\n gtk_widget_set_sensitive ( gsb_form_widget_get_widget (TRANSACTION_FORM_CREDIT), FALSE );\n }\n\n /* if the contra transaction is marked R, cannot change category and amounts */\n if ( contra_transaction_number > 0\n &&\n gsb_data_transaction_get_marked_transaction (contra_transaction_number) == OPERATION_RAPPROCHEE )\n {\n gtk_widget_set_sensitive ( gsb_form_widget_get_widget (TRANSACTION_FORM_DEBIT), FALSE );\n gtk_widget_set_sensitive ( gsb_form_widget_get_widget (TRANSACTION_FORM_CREDIT), FALSE );\n\n /* if it's a transfer, we cannot change too the category */\n gtk_widget_set_sensitive ( gsb_form_widget_get_widget (TRANSACTION_FORM_CATEGORY), FALSE );\n }\n }\n\n /* we take focus only if asked */\n if (grab_focus)\n {\n GtkWidget *widget;\n\n /* the form is full, if it's not a split, we give the focus to the date\n * else, we give the focus to the first free form element */\n if (mother_number)\n focus_to = gsb_form_widget_next_element ( account_number,\n\t\t\t\t\t\t TRANSACTION_FORM_DATE,\n\t\t\t\t\t\t GSB_RIGHT );\n else\n focus_to = TRANSACTION_FORM_DATE;\n\n widget = gsb_form_widget_get_widget ( focus_to );\n gtk_editable_select_region ( GTK_EDITABLE ( widget ), 0, -1 );\n if ( !is_transaction && gtk_widget_is_focus ( widget ) )\n gsb_form_widget_entry_get_focus ( widget, NULL, GINT_TO_POINTER ( focus_to ) );\n else\n gtk_widget_grab_focus ( widget );\n\n }\n\n return FALSE;\n}",
"label": 0,
"cwe": null,
"length": 1364
},
{
"index": 123048,
"code": "cluster_rel(Oid tableOid, Oid indexOid, bool recheck, bool verbose,\n\t\t\tint freeze_min_age, int freeze_table_age)\n{\n\tRelation\tOldHeap;\n\n\t/* Check for user-requested abort. */\n\tCHECK_FOR_INTERRUPTS();\n\n\t/*\n\t * We grab exclusive access to the target rel and index for the duration\n\t * of the transaction.\t(This is redundant for the single-transaction\n\t * case, since cluster() already did it.) The index lock is taken inside\n\t * check_index_is_clusterable.\n\t */\n\tOldHeap = try_relation_open(tableOid, AccessExclusiveLock);\n\n\t/* If the table has gone away, we can skip processing it */\n\tif (!OldHeap)\n\t\treturn;\n\n\t/*\n\t * Since we may open a new transaction for each relation, we have to check\n\t * that the relation still is what we think it is.\n\t *\n\t * If this is a single-transaction CLUSTER, we can skip these tests. We\n\t * *must* skip the one on indisclustered since it would reject an attempt\n\t * to cluster a not-previously-clustered index.\n\t */\n\tif (recheck)\n\t{\n\t\tHeapTuple\ttuple;\n\t\tForm_pg_index indexForm;\n\n\t\t/* Check that the user still owns the relation */\n\t\tif (!pg_class_ownercheck(tableOid, GetUserId()))\n\t\t{\n\t\t\trelation_close(OldHeap, AccessExclusiveLock);\n\t\t\treturn;\n\t\t}\n\n\t\t/*\n\t\t * Silently skip a temp table for a remote session. Only doing this\n\t\t * check in the \"recheck\" case is appropriate (which currently means\n\t\t * somebody is executing a database-wide CLUSTER), because there is\n\t\t * another check in cluster() which will stop any attempt to cluster\n\t\t * remote temp tables by name.\tThere is another check in cluster_rel\n\t\t * which is redundant, but we leave it for extra safety.\n\t\t */\n\t\tif (RELATION_IS_OTHER_TEMP(OldHeap))\n\t\t{\n\t\t\trelation_close(OldHeap, AccessExclusiveLock);\n\t\t\treturn;\n\t\t}\n\n\t\tif (OidIsValid(indexOid))\n\t\t{\n\t\t\t/*\n\t\t\t * Check that the index still exists\n\t\t\t */\n\t\t\tif (!SearchSysCacheExists1(RELOID, ObjectIdGetDatum(indexOid)))\n\t\t\t{\n\t\t\t\trelation_close(OldHeap, AccessExclusiveLock);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t/*\n\t\t\t * Check that the index is still the one with indisclustered set.\n\t\t\t */\n\t\t\ttuple = SearchSysCache1(INDEXRELID, ObjectIdGetDatum(indexOid));\n\t\t\tif (!HeapTupleIsValid(tuple))\t\t/* probably can't happen */\n\t\t\t{\n\t\t\t\trelation_close(OldHeap, AccessExclusiveLock);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tindexForm = (Form_pg_index) GETSTRUCT(tuple);\n\t\t\tif (!indexForm->indisclustered)\n\t\t\t{\n\t\t\t\tReleaseSysCache(tuple);\n\t\t\t\trelation_close(OldHeap, AccessExclusiveLock);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tReleaseSysCache(tuple);\n\t\t}\n\t}\n\n\t/*\n\t * We allow VACUUM FULL, but not CLUSTER, on shared catalogs. CLUSTER\n\t * would work in most respects, but the index would only get marked as\n\t * indisclustered in the current database, leading to unexpected behavior\n\t * if CLUSTER were later invoked in another database.\n\t */\n\tif (OidIsValid(indexOid) && OldHeap->rd_rel->relisshared)\n\t\tereport(ERROR,\n\t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t\t errmsg(\"cannot cluster a shared catalog\")));\n\n\t/*\n\t * Don't process temp tables of other backends ... their local buffer\n\t * manager is not going to cope.\n\t */\n\tif (RELATION_IS_OTHER_TEMP(OldHeap))\n\t{\n\t\tif (OidIsValid(indexOid))\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t errmsg(\"cannot cluster temporary tables of other sessions\")));\n\t\telse\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),\n\t\t\t\terrmsg(\"cannot vacuum temporary tables of other sessions\")));\n\t}\n\n\t/*\n\t * Also check for active uses of the relation in the current transaction,\n\t * including open scans and pending AFTER trigger events.\n\t */\n\tCheckTableNotInUse(OldHeap, OidIsValid(indexOid) ? \"CLUSTER\" : \"VACUUM\");\n\n\t/* Check heap and index are valid to cluster on */\n\tif (OidIsValid(indexOid))\n\t\tcheck_index_is_clusterable(OldHeap, indexOid, recheck, AccessExclusiveLock);\n\n\t/*\n\t * All predicate locks on the tuples or pages are about to be made\n\t * invalid, because we move tuples around.\tPromote them to relation\n\t * locks. Predicate locks on indexes will be promoted when they are\n\t * reindexed.\n\t */\n\tTransferPredicateLocksToHeapRelation(OldHeap);\n\n\t/* rebuild_relation does all the dirty work */\n\trebuild_relation(OldHeap, indexOid, freeze_min_age, freeze_table_age,\n\t\t\t\t\t verbose);\n\n\t/* NB: rebuild_relation does heap_close() on OldHeap */\n}",
"label": 0,
"cwe": null,
"length": 1101
},
{
"index": 864104,
"code": "BitSearch(CoderInfo *coderInfo,\n int *quant) /* Quantized spectral values */\n /*\n This function inputs a vector of quantized spectral data, quant[][], and returns a vector,\n 'book_vector[]' that describes how to group together the scalefactor bands into a smaller\n number of sections. There are MAX_SCFAC_BANDS elements in book_vector (equal to 49 in the\n case of long blocks and 112 for short blocks), and each element has a huffman codebook\n number assigned to it.\n\n For a quick and simple algorithm, this function performs a binary\n search across the sfb's (scale factor bands). On the first approach, it calculates the\n needed amount of bits if every sfb were its own section and transmitted its own huffman\n codebook value side information (equal to 9 bits for a long block, 7 for a short). The\n next iteration combines adjacent sfb's, and calculates the bit rate for length two sfb\n sections. If any wider two-sfb section requires fewer bits than the sum of the two\n single-sfb sections (below it in the binary tree), then the wider section will be chosen.\n This process occurs until the sections are split into three uniform parts, each with an\n equal amount of sfb's contained.\n\n The binary tree is stored as a two-dimensional array. Since this tree is not full, (there\n are only 49 nodes, not 2^6 = 64), the numbering is a little complicated. If the tree were\n full, the top node would be 1. It's children would be 2 and 3. But, since this tree\n is not full, the top row of three nodes are numbered {4,5,6}. The row below it is\n {8,9,10,11,12,13}, and so on.\n\n The binary tree is called bit_stats[112][3]. There are 112 total nodes (some are not\n used since it's not full). bit_stats[x][0] holds the bit totals needed for the sfb sectioning\n strategy represented by the node x in the tree. bit_stats[x][1] holds the optimal huffman\n codebook table that minimizes the bit rate, given the sectioning boundaries dictated by node x.\n*/\n\n{\n int i,j,k;\n int hop;\n int min_book_choice[112][3];\n int bit_stats[240][3];\n int total_bit_count;\n int levels;\n int pow2levels;\n int fracpow2lev;\n\n /* Set local pointer to coderInfo book_vector */\n int* book_vector = coderInfo -> book_vector;\n\n levels = (int) ((log((double)coderInfo->nr_of_sfb)/log((double)2.0))+1);\n\n/* #define SLOW */\n\n#ifdef SLOW\n for(i = 0; i < 5; i++) {\n#else\n i = 0;\n#endif\n hop = 1 << i;\n\n NoiselessBitCount(coderInfo, quant, hop, min_book_choice);\n\n /* load up the (not-full) binary search tree with the min_book_choice values */\n k=0;\n total_bit_count = 0;\n\n\tpow2levels = 1 << (levels - i);\n\tfracpow2lev = pow2levels + (coderInfo->nr_of_sfb >> i);\n\n for (j=pow2levels; j < fracpow2lev; j++)\n {\n bit_stats[j][0] = min_book_choice[k][0]; /* the minimum bit cost for this section */\n bit_stats[j][1] = min_book_choice[k][1]; /* used with this huffman book number */\n\n#ifdef SLOW\n if (i>0){ /* not on the lowest level, grouping more than one signle scalefactor band per section*/\n if (bit_stats[j][0] < bit_stats[2*j][0] + bit_stats[2*j+1][0]){\n\n /* it is cheaper to combine surrounding sfb secionts into one larger huffman book section */\n for(n=k;n<k+hop;n++) { /* write the optimal huffman book value for the new larger section */\n if ( (book_vector[n]!=INTENSITY_HCB)&&(book_vector[n]!=INTENSITY_HCB2) ) { /* Don't merge with IS bands */\n book_vector[n] = bit_stats[j][1];\n }\n }\n } else { /* it was cheaper to transmit the smaller huffman table sections */\n bit_stats[j][0] = bit_stats[2*j][0] + bit_stats[2*j+1][0];\n }\n\t } else\n#endif\n\t { /* during the first stage of the iteration, all sfb's are individual sections */\n if ( (book_vector[k]!=INTENSITY_HCB)&&(book_vector[k]!=INTENSITY_HCB2) ) {\n book_vector[k] = bit_stats[j][1]; /* initially, set all sfb's to their own optimal section table values */\n }\n }\n total_bit_count = total_bit_count + bit_stats[j][0];\n k=k+hop;\n }\n#ifdef SLOW\n }\n#endif\n /* book_vector[k] = book_vector[k-1]; */\n return(total_bit_count);\n}",
"label": 1,
"cwe": "CWE-other",
"length": 1154
},
{
"index": 393354,
"code": "mq_swift_checkpoint(mqueue_t *q, bool initial)\n{\n\tint elapsed = q->swift_elapsed;\t/* Elapsed since we were scheduled */\n\tint target_to_lowmark;\n\tint flushed_till_next_timer;\n\tint added_till_next_timer;\n\tfloat period_ratio;\n\tint added;\n\tint needed;\n\tint extra;\n\n\tg_assert(q->flags & MQ_FLOWC);\n\n\tq->swift_ev = NULL;\t\t\t\t/* Event fired, we may not reinstall it */\n\n\t/*\n\t * We do not necessarily leave the flow-control state when q->size\n\t * drops below q->lowat for TCP queues, where we want to reach a\n\t * state where we're not in the middle of sending one large message.\n\t *\n\t * When we're below the low watermark, there's nothing for us to do.\n\t */\n\n\tif (q->size <= q->lowat)\n\t\tgoto done;\n\n\t/*\n\t * For next period, the elapsed time will be...\n\t */\n\n\tq->swift_elapsed = node_flowc_swift_period(q->node) * 1000;\n\tq->swift_elapsed = MAX(q->swift_elapsed, 1);\n\n\t/*\n\t * Compute target to reach the low watermark, and then the amount we\n\t * will have flushed by the time we reach the next timer, at the\n\t * present TX rate, as well as the data that will have been added to\n\t * the queue.\n\t */\n\n\tperiod_ratio = (float) q->swift_elapsed / (float) elapsed;\n\ttarget_to_lowmark = q->size - q->lowat;\n\tadded = q->size - q->last_size + q->flowc_written;\n\n\tflushed_till_next_timer = (int) (q->flowc_written * period_ratio);\n\tadded_till_next_timer = added <= 0 ? 0 : (int) (added * period_ratio);\n\n\t/*\n\t * Now compute the amount of bytes we need to forcefully drop to be\n\t * able to leave flow-control when the next timer fires...\n\t */\n\n\textra = target_to_lowmark -\n\t\t(flushed_till_next_timer - added_till_next_timer);\n\n\tif (extra <= 0) {\n\t\t/*\n\t\t * We should be able to fully flush the queue by next timer at the\n\t\t * present average fill and flushing rates. So needed could be 0.\n\t\t * However, to account for the bursty nature of the traffic,\n\t\t * take a margin...\n\t\t */\n\n\t\tneeded = target_to_lowmark / 3;\n\t} else {\n\t\t/*\n\t\t * We won't be able to reach the low watermark at the present rates.\n\t\t * We need to remove the extra traffic present in the queue, plus\n\t\t * add a margin: we assume we'll only be able to flush 75% of what\n\t\t * we flushed currently.\n\t\t */\n\n\t\tneeded = extra + flushed_till_next_timer / 4;\n\t}\n\n\tif (initial) {\n\t\t/*\n\t\t * First time we're in \"swift\" mode.\n\t\t *\n\t\t * Purge pending queries, since they are getting quite old.\n\t\t * Leave our queries in for now (they have hops=0).\n\t\t */\n\n\t\tgnutella_header_set_function(&q->header, GTA_MSG_SEARCH);\n\t\tgnutella_header_set_hops(&q->header, 1);\n\t\tgnutella_header_set_ttl(&q->header, GNET_PROPERTY(max_ttl));\n\n\t\tif (needed > 0)\n\t\t\tmake_room_header(q, (char*) &q->header, PMSG_P_DATA, needed, NULL);\n\n\t\t/*\n\t\t * Whether or not we were able to make enough room at this point\n\t\t * is not important, for the initial checkpoint. Indeed, since\n\t\t * we are now in \"swift\" mode, more query messages will be dropped\n\t\t * at the next iteration, since we'll start dropping query hits,\n\t\t * and hits are more prioritary than queries.\n\t\t */\n\n\t} else {\n\t\tint ttl;\n\n\t\t/*\n\t\t * We're going to drop query hits...\n\t\t *\n\t\t * We start with the lowest prioritary query hit: low hops count\n\t\t * and high TTL, and we progressively increase until we can drop\n\t\t * the amount we need to drop.\n\t\t *\n\t\t * Note that we will never be able to drop the partially written\n\t\t * message at the tail of the queue, even if it is less prioritary\n\t\t * than our comparison point.\n\t\t */\n\n\t\tgnutella_header_set_function(&q->header, GTA_MSG_SEARCH_RESULTS);\n\n\t\t/*\n\t\t * Loop until we reach hops=hard_ttl_limit or we have finished\n\t\t * removing enough data from the queue.\n\t\t */\n\n\t\tfor (ttl = GNET_PROPERTY(hard_ttl_limit); ttl >= 0; ttl--) {\n\t\t\tint old_size;\n\n\t\t\tif (needed <= 0)\n\t\t\t\tbreak;\n\n\t\t\told_size = q->size;\n\t\t\tgnutella_header_set_hops(&q->header,\n\t\t\t\tGNET_PROPERTY(hard_ttl_limit) - ttl);\n\t\t\tgnutella_header_set_ttl(&q->header, ttl);\n\n\t\t\tif (\n\t\t\t\tmake_room_header(q, (char*) &q->header, PMSG_P_DATA,\n\t\t\t\t\tneeded, NULL)\n\t\t\t)\n\t\t\t\tbreak;\n\n\t\t\tneeded -= (old_size - q->size);\t\t/* Amount we removed */\n\t\t}\n\t}\n\ndone:\n\tmq_update_flowc(q);\t\t/* May cause us to leave \"swift\" mode */\n\n\t/*\n\t * Re-install for next time, if still in \"swift\" mode.\n\t *\n\t * Subsequent calls after the initial call all go through\n\t * mq_swift_timer() anyway.\n\t */\n\n\tif (q->flags & MQ_SWIFT) {\n\t\tq->flowc_written = 0;\n\t\tq->last_size = q->size;\n\t\tq->swift_ev = cq_main_insert(q->swift_elapsed, mq_swift_timer, q);\n\t}\n}",
"label": 0,
"cwe": null,
"length": 1243
},
{
"index": 482696,
"code": "journal_unmap_buffer(journal_t *journal, struct buffer_head *bh,\n\t\t\t\tint partial_page)\n{\n\ttransaction_t *transaction;\n\tstruct journal_head *jh;\n\tint may_free = 1;\n\n\tBUFFER_TRACE(bh, \"entry\");\n\n\t/*\n\t * It is safe to proceed here without the j_list_lock because the\n\t * buffers cannot be stolen by try_to_free_buffers as long as we are\n\t * holding the page lock. --sct\n\t */\n\n\tif (!buffer_jbd(bh))\n\t\tgoto zap_buffer_unlocked;\n\n\t/* OK, we have data buffer in journaled mode */\n\twrite_lock(&journal->j_state_lock);\n\tjbd_lock_bh_state(bh);\n\tspin_lock(&journal->j_list_lock);\n\n\tjh = jbd2_journal_grab_journal_head(bh);\n\tif (!jh)\n\t\tgoto zap_buffer_no_jh;\n\n\t/*\n\t * We cannot remove the buffer from checkpoint lists until the\n\t * transaction adding inode to orphan list (let's call it T)\n\t * is committed. Otherwise if the transaction changing the\n\t * buffer would be cleaned from the journal before T is\n\t * committed, a crash will cause that the correct contents of\n\t * the buffer will be lost. On the other hand we have to\n\t * clear the buffer dirty bit at latest at the moment when the\n\t * transaction marking the buffer as freed in the filesystem\n\t * structures is committed because from that moment on the\n\t * block can be reallocated and used by a different page.\n\t * Since the block hasn't been freed yet but the inode has\n\t * already been added to orphan list, it is safe for us to add\n\t * the buffer to BJ_Forget list of the newest transaction.\n\t *\n\t * Also we have to clear buffer_mapped flag of a truncated buffer\n\t * because the buffer_head may be attached to the page straddling\n\t * i_size (can happen only when blocksize < pagesize) and thus the\n\t * buffer_head can be reused when the file is extended again. So we end\n\t * up keeping around invalidated buffers attached to transactions'\n\t * BJ_Forget list just to stop checkpointing code from cleaning up\n\t * the transaction this buffer was modified in.\n\t */\n\ttransaction = jh->b_transaction;\n\tif (transaction == NULL) {\n\t\t/* First case: not on any transaction. If it\n\t\t * has no checkpoint link, then we can zap it:\n\t\t * it's a writeback-mode buffer so we don't care\n\t\t * if it hits disk safely. */\n\t\tif (!jh->b_cp_transaction) {\n\t\t\tJBUFFER_TRACE(jh, \"not on any transaction: zap\");\n\t\t\tgoto zap_buffer;\n\t\t}\n\n\t\tif (!buffer_dirty(bh)) {\n\t\t\t/* bdflush has written it. We can drop it now */\n\t\t\t__jbd2_journal_remove_checkpoint(jh);\n\t\t\tgoto zap_buffer;\n\t\t}\n\n\t\t/* OK, it must be in the journal but still not\n\t\t * written fully to disk: it's metadata or\n\t\t * journaled data... */\n\n\t\tif (journal->j_running_transaction) {\n\t\t\t/* ... and once the current transaction has\n\t\t\t * committed, the buffer won't be needed any\n\t\t\t * longer. */\n\t\t\tJBUFFER_TRACE(jh, \"checkpointed: add to BJ_Forget\");\n\t\t\tmay_free = __dispose_buffer(jh,\n\t\t\t\t\tjournal->j_running_transaction);\n\t\t\tgoto zap_buffer;\n\t\t} else {\n\t\t\t/* There is no currently-running transaction. So the\n\t\t\t * orphan record which we wrote for this file must have\n\t\t\t * passed into commit. We must attach this buffer to\n\t\t\t * the committing transaction, if it exists. */\n\t\t\tif (journal->j_committing_transaction) {\n\t\t\t\tJBUFFER_TRACE(jh, \"give to committing trans\");\n\t\t\t\tmay_free = __dispose_buffer(jh,\n\t\t\t\t\tjournal->j_committing_transaction);\n\t\t\t\tgoto zap_buffer;\n\t\t\t} else {\n\t\t\t\t/* The orphan record's transaction has\n\t\t\t\t * committed. We can cleanse this buffer */\n\t\t\t\tclear_buffer_jbddirty(bh);\n\t\t\t\t__jbd2_journal_remove_checkpoint(jh);\n\t\t\t\tgoto zap_buffer;\n\t\t\t}\n\t\t}\n\t} else if (transaction == journal->j_committing_transaction) {\n\t\tJBUFFER_TRACE(jh, \"on committing transaction\");\n\t\t/*\n\t\t * The buffer is committing, we simply cannot touch\n\t\t * it. If the page is straddling i_size we have to wait\n\t\t * for commit and try again.\n\t\t */\n\t\tif (partial_page) {\n\t\t\tjbd2_journal_put_journal_head(jh);\n\t\t\tspin_unlock(&journal->j_list_lock);\n\t\t\tjbd_unlock_bh_state(bh);\n\t\t\twrite_unlock(&journal->j_state_lock);\n\t\t\treturn -EBUSY;\n\t\t}\n\t\t/*\n\t\t * OK, buffer won't be reachable after truncate. We just set\n\t\t * j_next_transaction to the running transaction (if there is\n\t\t * one) and mark buffer as freed so that commit code knows it\n\t\t * should clear dirty bits when it is done with the buffer.\n\t\t */\n\t\tset_buffer_freed(bh);\n\t\tif (journal->j_running_transaction && buffer_jbddirty(bh))\n\t\t\tjh->b_next_transaction = journal->j_running_transaction;\n\t\tjbd2_journal_put_journal_head(jh);\n\t\tspin_unlock(&journal->j_list_lock);\n\t\tjbd_unlock_bh_state(bh);\n\t\twrite_unlock(&journal->j_state_lock);\n\t\treturn 0;\n\t} else {\n\t\t/* Good, the buffer belongs to the running transaction.\n\t\t * We are writing our own transaction's data, not any\n\t\t * previous one's, so it is safe to throw it away\n\t\t * (remember that we expect the filesystem to have set\n\t\t * i_size already for this truncate so recovery will not\n\t\t * expose the disk blocks we are discarding here.) */\n\t\tJ_ASSERT_JH(jh, transaction == journal->j_running_transaction);\n\t\tJBUFFER_TRACE(jh, \"on running transaction\");\n\t\tmay_free = __dispose_buffer(jh, transaction);\n\t}\n\nzap_buffer:\n\t/*\n\t * This is tricky. Although the buffer is truncated, it may be reused\n\t * if blocksize < pagesize and it is attached to the page straddling\n\t * EOF. Since the buffer might have been added to BJ_Forget list of the\n\t * running transaction, journal_get_write_access() won't clear\n\t * b_modified and credit accounting gets confused. So clear b_modified\n\t * here.\n\t */\n\tjh->b_modified = 0;\n\tjbd2_journal_put_journal_head(jh);\nzap_buffer_no_jh:\n\tspin_unlock(&journal->j_list_lock);\n\tjbd_unlock_bh_state(bh);\n\twrite_unlock(&journal->j_state_lock);\nzap_buffer_unlocked:\n\tclear_buffer_dirty(bh);\n\tJ_ASSERT_BH(bh, !buffer_jbddirty(bh));\n\tclear_buffer_mapped(bh);\n\tclear_buffer_req(bh);\n\tclear_buffer_new(bh);\n\tclear_buffer_delay(bh);\n\tclear_buffer_unwritten(bh);\n\tbh->b_bdev = NULL;\n\treturn may_free;\n}",
"label": 0,
"cwe": null,
"length": 1518
},
{
"index": 636847,
"code": "aclinit_main()\n{\n\tSlapi_PBlock\t\t*pb;\n\tint\t\t\t\t\trv;\n\tSlapi_DN\t\t\t*sdn;\n\tvoid \t\t\t\t*node;\n\n\tif (acl_initialized) {\n\t\t/* There is no need to do anything more */\n\t\treturn 0;\n\t}\n\n\t/* Initialize the LIBACCESS ACL library */\n\tif (ACL_Init() != 0) {\n\t\tslapi_log_error(SLAPI_LOG_FATAL, plugin_name,\n\t\t\t \"ACL Library Initialization failed\\n\");\n\t\treturn 1;\n\t}\n\t\n\t/* register all the LASes supported by the DS */\n\tif (ACL_ERR == __aclinit__RegisterLases()) {\n\t\t/* Error is already logged */\n\t\treturn 1;\n\t}\n\n\t/* Register all the Attrs */\n\tif (ACL_ERR == __aclinit__RegisterAttributes()) {\n\t\t/* Error is already logged */\n\t\treturn 1;\n\t}\n\n\t/*\n\t * Register to get backend state changes so we can add/remove\n\t * acis from backends that come up and go down.\n\t*/\n\n\tslapi_register_backend_state_change((void *) NULL, acl_be_state_change_fnc);\n\t\n\n\t/* register the extensions */\n\t/* ONREPL Moved to the acl_init function because extensions\n need to be registered before any operations are issued\n if ( 0 != acl_init_ext() ) {\n\t\tslapi_log_error ( SLAPI_LOG_FATAL, plugin_name,\n\t\t\t\"Unable to initialize the extensions\\n\");\n\t\treturn 1;\n\t} */\n\n\t/* create the mutex array */\n\tif ( 0 != aclext_alloc_lockarray ( ) ) {\n\t\tslapi_log_error ( SLAPI_LOG_FATAL, plugin_name,\n\t\t\t\"Unable to create the mutext array\\n\");\n\t\treturn 1;\n\t}\n\n /* Allocate the pool */\n\tif ( 0 != acl_create_aclpb_pool () ) {\n\t\tslapi_log_error ( SLAPI_LOG_FATAL, plugin_name,\n\t\t\t\"Unable to create the acl private pool\\n\");\n\t\treturn 1;\n\t}\n\n\t/*\n\t * Now read all the ACLs from all the backends and put it\n\t * in a list\n\t */\n\t/* initialize the ACLLIST sub-system */\n\tif ( 0 != (rv = acllist_init ( ))) {\n\t\tslapi_log_error ( SLAPI_LOG_FATAL, plugin_name,\n\t\t\t\t\"Unable to initialize the plugin:%d\\n\", rv );\n\t\treturn 1;\n\t}\n\n\t/* Initialize the anonymous profile i.e., generate it */\n\trv = aclanom_init ();\n\n\tpb = slapi_pblock_new();\n\t\n\t/*\n\t * search for the aci_attr_type attributes of all entries.\n\t *\n\t * slapi_get_fist_suffix() and slapi_get_next_suffix() do not return the \n\t * rootdse entry so we search for acis in there explicitly here.\n\t*/\n\n\tsdn = slapi_sdn_new_ndn_byval(\"\");\n\tslapi_log_error ( SLAPI_LOG_ACL, plugin_name,\n\t\t\t\t\"Searching for all acis(scope base) at suffix ''\\n\");\n\taclinit_search_and_update_aci ( 0,\t\t/* thisbeonly */\n\t\t\t\t\t\t\t\t\t\tsdn,\t/* base */\n\t\t\t\t\t\t\t\t\t\tNULL,\t/* be name*/\n\t\t\t\t\t\t\t\t\t\tLDAP_SCOPE_BASE, ACL_ADD_ACIS,\n\t\t\t\t\t\t\t\t\t\tDO_TAKE_ACLCACHE_WRITELOCK);\n\tslapi_sdn_free(&sdn);\t\n\n\tsdn = slapi_get_first_suffix( &node, 1 );\n\twhile (sdn)\n\t{\n\t\tslapi_log_error ( SLAPI_LOG_ACL, plugin_name,\n\t\t\t\t\"Searching for all acis(scope subtree) at suffix '%s'\\n\", \n\t\t\t\t\tslapi_sdn_get_dn(sdn) );\n\t\taclinit_search_and_update_aci ( 0,\t\t/* thisbeonly */\n\t\t\t\t\t\t\t\t\t\tsdn,\t/* base */\n\t\t\t\t\t\t\t\t\t\tNULL,\t/* be name*/\n\t\t\t\t\t\t\t\t\t\tLDAP_SCOPE_SUBTREE, ACL_ADD_ACIS,\n\t\t\t\t\t\t\t\t\t\tDO_TAKE_ACLCACHE_WRITELOCK);\n\t\tsdn = slapi_get_next_suffix( &node, 1 );\n\t}\n\n\t/* Initialize it. */\n\tacl_initialized = 1;\n\n\t/* generate the signatures */\n\tacl_set_aclsignature ( aclutil_gen_signature ( 100 ) );\n\n\t/* Initialize the user-group cache */\n\trv = aclgroup_init ( );\n\n\taclanom_gen_anomProfile (DO_TAKE_ACLCACHE_READLOCK);\n\n\t/* Register both of the proxied authorization controls (version 1 and 2) */\n\tslapi_register_supported_control( LDAP_CONTROL_PROXYAUTH,\n\t\t\tSLAPI_OPERATION_SEARCH | SLAPI_OPERATION_COMPARE\n\t\t\t| SLAPI_OPERATION_ADD | SLAPI_OPERATION_DELETE\n\t\t\t| SLAPI_OPERATION_MODIFY | SLAPI_OPERATION_MODDN\n\t\t\t| SLAPI_OPERATION_EXTENDED );\n\tslapi_register_supported_control( LDAP_CONTROL_PROXIEDAUTH,\n\t\t\tSLAPI_OPERATION_SEARCH | SLAPI_OPERATION_COMPARE\n\t\t\t| SLAPI_OPERATION_ADD | SLAPI_OPERATION_DELETE\n\t\t\t| SLAPI_OPERATION_MODIFY | SLAPI_OPERATION_MODDN\n\t\t\t| SLAPI_OPERATION_EXTENDED );\n\n\tslapi_pblock_destroy ( pb );\n\treturn 0;\n}",
"label": 0,
"cwe": null,
"length": 1063
}
]