[ { "index": 993584, "code": "get_bg_tile_info(int tile_index)\r\n{\r\n\tint attr = colorram[tile_index];\r\n\tint code = videoram[tile_index] + (gfxbank << 12) + ((attr & 0x07) << 8) + ((attr & 0x80) << 4);\r\n\tint color = (gfxbank << 5) + (attr >> 3);\r\n\r\n\tSET_TILE_INFO(0, code, color, 0)\r\n}", "label": 0, "cwe": null, "length": 95 }, { "index": 565662, "code": "LoadSettings()\n{\n ConfigManager *cfg = Manager::Get()->GetConfigManager(_T(\"autosave\"));\n\n bool doProjects = cfg->ReadBool(_T(\"do_project\"));\n bool doSources = cfg->ReadBool(_T(\"do_sources\"));\n XRCCTRL(*this, \"do_project\", wxCheckBox)->SetValue(doProjects);\n XRCCTRL(*this, \"do_sources\", wxCheckBox)->SetValue(doSources);\n XRCCTRL(*this, \"do_workspace\", wxCheckBox)->SetValue(cfg->ReadBool(_T(\"do_workspace\"), true));\n XRCCTRL(*this, \"all_projects\", wxCheckBox)->SetValue(cfg->ReadBool(_T(\"all_projects\"), true));\n int minsProjects = std::max(cfg->ReadInt(_T(\"project_mins\"), 1), 1);\n int minsSources = std::max(cfg->ReadInt(_T(\"source_mins\"), 1), 1);\n XRCCTRL(*this, \"project_mins\", wxTextCtrl)->SetValue(wxString::Format(_T(\"%d\"), minsProjects));\n XRCCTRL(*this, \"source_mins\", wxTextCtrl)->SetValue(wxString::Format(_T(\"%d\"), minsSources));\n\n XRCCTRL(*this, \"do_workspace\", wxCheckBox)->Enable(doProjects);\n XRCCTRL(*this, \"all_projects\", wxCheckBox)->Enable(doProjects);\n XRCCTRL(*this, \"project_mins\", wxTextCtrl)->Enable(doProjects);\n\n XRCCTRL(*this, \"source_mins\", wxTextCtrl)->Enable(doSources);\n\n XRCCTRL(*this, \"method\", wxChoice)->SetSelection(cfg->ReadInt(_T(\"method\"), 2));\n}", "label": 0, "cwe": null, "length": 356 }, { "index": 682306, "code": "rs_dotProd(const double *u, const double *v, int dim) const\n{\n double result = 0;\n for (int i = 0; i < dim; ++i){\n result += u[i] * v[i];\n }\n return(result);\n}", "label": 0, "cwe": null, "length": 60 }, { "index": 83177, "code": "archive_read_support_compression_xz(struct archive *_a)\n{\n struct archive_read *a = (struct archive_read *)_a;\n struct archive_read_filter_bidder *bidder = __archive_read_get_bidder(a);\n\n archive_clear_error(_a);\n if (bidder == NULL)\n return (ARCHIVE_FATAL);\n\n bidder->data = NULL;\n bidder->bid = xz_bidder_bid;\n bidder->init = xz_bidder_init;\n bidder->options = NULL;\n bidder->free = NULL;\n#if HAVE_LZMA_H && HAVE_LIBLZMA\n return (ARCHIVE_OK);\n#else\n archive_set_error(_a, ARCHIVE_ERRNO_MISC,\n \"Using external unxz program for xz decompression\");\n return (ARCHIVE_WARN);\n#endif\n}", "label": 0, "cwe": null, "length": 171 }, { "index": 921594, "code": "L8()\n{register object *base=vs_base;\n\tregister object *sup=base+VM8; VC8\n\tvs_check;\n\t{object V57;\n\tobject V58;\n\tV57=(base[0]);\n\tV58=(base[1]);\n\tvs_top=sup;\n\tgoto TTL;\nTTL:;\n\tbase[3]= (V57);\n\tvs_top=(vs_base=base+3)+1;\n\tLintern();\n\tvs_top=sup;\n\tbase[2]= vs_base[0];\n\tvs_top=(vs_base=base+2)+1;\n\treturn;\n\t}\n}", "label": 0, "cwe": null, "length": 123 }, { "index": 11332, "code": "merrev(x, y, prj, phi, theta)\n\nconst double x, y;\nstruct prjprm *prj;\ndouble *phi, *theta;\n\n{\n if (prj->flag != PRJSET) {\n if (vimosmerset(prj)) return 1;\n }\n\n *phi = x*prj->w[1];\n *theta = 2.0*atandeg (exp(y/prj->r0)) - 90.0;\n\n return 0;\n}", "label": 0, "cwe": null, "length": 112 }, { "index": 109563, "code": "widget_browse_keyhandler( input_key key )\n{\n switch( key ) {\n\n#if 0\n case INPUT_KEY_Resize:\t/* Fake keypress used on window resize */\n widget_browse_draw( NULL );\n break;\n#endif\n\n case INPUT_KEY_Escape:\n case INPUT_JOYSTICK_FIRE_2:\n widget_end_widget( WIDGET_FINISHED_CANCEL );\n return;\n\n case INPUT_KEY_Down:\n case INPUT_KEY_6:\n case INPUT_KEY_j:\n case INPUT_JOYSTICK_DOWN:\n if( highlight < block_count - 1 ) {\n highlight++;\n if( highlight >= top_line + 18 ) top_line += 18;\n show_blocks();\n }\n break;\n \n case INPUT_KEY_Up:\n case INPUT_KEY_7:\n case INPUT_KEY_k:\n case INPUT_JOYSTICK_UP:\n if( highlight > 0 ) { \n highlight--;\n if( highlight < top_line )\n\t{\n\t top_line -= 18;\n\t if( top_line < 0 ) top_line = 0;\n\t}\n show_blocks();\n }\n break;\n\n case INPUT_KEY_Page_Up:\n highlight -= 18; if( highlight < 0 ) highlight = 0;\n top_line -= 18; if( top_line < 0 ) top_line = 0;\n show_blocks();\n break;\n\n case INPUT_KEY_Page_Down:\n highlight += 18;\n if( highlight >= block_count ) highlight = block_count - 1;\n top_line += 18;\n if( top_line >= block_count ) {\n top_line = block_count - 18;\n if( top_line < 0 ) top_line = 0;\n }\n show_blocks();\n break;\n\n case INPUT_KEY_Home:\n highlight = top_line = 0;\n show_blocks();\n break;\n\n case INPUT_KEY_End:\n highlight = block_count - 1;\n top_line = block_count - 18; if( top_line < 0 ) top_line = 0;\n show_blocks();\n break;\n\n case INPUT_KEY_Return:\n case INPUT_KEY_KP_Enter:\n case INPUT_JOYSTICK_FIRE_1:\n widget_end_widget( WIDGET_FINISHED_OK );\n return;\n\n default:\t/* Keep gcc happy */\n break;\n\n }\n}", "label": 0, "cwe": null, "length": 489 }, { "index": 735879, "code": "clutter_text_set_selection (ClutterText *self,\n gssize start_pos,\n gssize end_pos)\n{\n guint n_chars;\n\n g_return_if_fail (CLUTTER_IS_TEXT (self));\n\n n_chars = clutter_text_buffer_get_length (get_buffer (self));\n if (end_pos < 0)\n end_pos = n_chars;\n\n start_pos = MIN (n_chars, start_pos);\n end_pos = MIN (n_chars, end_pos);\n\n clutter_text_set_positions (self, start_pos, end_pos);\n}", "label": 0, "cwe": null, "length": 117 }, { "index": 924361, "code": "operator*(const Matrix& m1, const Matrix& m2)\n{\n\tif(m1.Ncols != m2.Nrows){\n\t\tcerr << \"cannot multiply \" << m2.Nrows << \" x \" << m2.Ncols << \n\t\t\" Matrix by \" << m1.Nrows << \" x \" << m1.Ncols << \" Matrix\" << endl;\n\t\texit(1);\n\t}\n\tMatrix result(m1.Nrows, m2.Ncols);\n\t\n\tint i, j, rc;\n\tfor(i = 0; i < m1.Nrows; i++)\n\t\tfor(j = 0; j < m2.Ncols; j++){\n\t\t\tresult.row[i][j] = 0;\n\t\t\tfor(rc = 0; rc < m1.Ncols; rc++)\n\t\t\t\tresult.row[i][j] += m1.row[i][rc] * m2[rc][j];\n\t\t}\n\t\n\treturn result;\n}", "label": 0, "cwe": null, "length": 193 }, { "index": 338495, "code": "m_parse(char *cmd_line, int n_fields, char **value)\n{\n\tint field_number;\n\tchar *token;\n\n\ttoken = strtok(0, \" \t\\n\");\n\tif (token == 0) {\n\t\tfputs(\"Please enter: field-number value > \", stdout);\n\t\tfgets(cmd_line, 80, stdin);\n\t\ttoken = strtok(cmd_line, \" \t\\n\");\n\t\tif (token == 0)\n\t\t\treturn 0;\n\t}\n\tfield_number = strtol(token, 0, 0);\n\tif (field_number < 1 || field_number > n_fields) {\n\t\tfputs(\"Invalid field number\\n\", stderr);\n\t\treturn 0;\n\t}\n\t*value = strtok(0, \" \t\\n\");\n\tif (*value == 0) {\n\t\tfputs(\"Not enough arguments\\n\", stderr);\n\t\treturn 0;\n\t}\n\tif (strtok(0, \" \t\\n\")) {\n\t\tfputs(\"Too many arguments\\n\", stderr);\n\t\treturn 0;\n\t}\n\treturn field_number;\n}", "label": 0, "cwe": null, "length": 216 }, { "index": 112790, "code": "of_get_phy_id(struct device_node *device, u32 *phy_id)\n{\n\tstruct property *prop;\n\tconst char *cp;\n\tunsigned int upper, lower;\n\n\tof_property_for_each_string(device, \"compatible\", prop, cp) {\n\t\tif (sscanf(cp, \"ethernet-phy-id%4x.%4x\", &upper, &lower) == 2) {\n\t\t\t*phy_id = ((upper & 0xFFFF) << 16) | (lower & 0xFFFF);\n\t\t\treturn 0;\n\t\t}\n\t}\n\treturn -EINVAL;\n}", "label": 0, "cwe": null, "length": 120 }, { "index": 100260, "code": "restore_focus()\n{\n#ifdef _DEBUG\n std::cout << \"Admin::restore_focus : \" << m_url << std::endl;\n#endif\n\n int page = m_notebook->get_current_page();\n SKELETON::View* view = dynamic_cast< View* >( m_notebook->get_nth_page( page ) );\n if( view ) view->focus_view();\n}", "label": 0, "cwe": null, "length": 81 }, { "index": 116548, "code": "hasImage( int size ) const\n{\n foreach( const Meta::AlbumPtr &album, m_albums )\n {\n if( album->hasImage( size ) )\n return true;\n }\n return false;\n}", "label": 0, "cwe": null, "length": 49 }, { "index": 914980, "code": "_unregister_extend(extend_registration_block *eptr)\n{\n extend_registration_block *prev;\n\n netsnmp_assert(eptr);\n for (prev = ereg_head; prev && prev->next != eptr; prev = prev->next)\n\t;\n if (prev) {\n netsnmp_assert(eptr == prev->next);\n\tprev->next = eptr->next;\n } else {\n netsnmp_assert(eptr == ereg_head);\n\tereg_head = eptr->next;\n }\n\n netsnmp_table_data_delete_table(eptr->dinfo);\n free(eptr->root_oid);\n free(eptr);\n}", "label": 0, "cwe": null, "length": 135 }, { "index": 71132, "code": "ipvlan_xmit_mode_l3(struct sk_buff *skb, struct net_device *dev)\n{\n\tconst struct ipvl_dev *ipvlan = netdev_priv(dev);\n\tvoid *lyr3h;\n\tstruct ipvl_addr *addr;\n\tint addr_type;\n\n\tlyr3h = ipvlan_get_L3_hdr(skb, &addr_type);\n\tif (!lyr3h)\n\t\tgoto out;\n\n\taddr = ipvlan_addr_lookup(ipvlan->port, lyr3h, addr_type, true);\n\tif (addr)\n\t\treturn ipvlan_rcv_frame(addr, &skb, true);\n\nout:\n\tskb->dev = ipvlan->phy_dev;\n\treturn ipvlan_process_outbound(skb, ipvlan);\n}", "label": 0, "cwe": null, "length": 145 }, { "index": 66722, "code": "getSingleCP(const UnicodeString& s) {\n //if (s.length() < 1) {\n // throw new IllegalArgumentException(\"Can't use zero-length strings in UnicodeSet\");\n //}\n if (s.length() > 2) return -1;\n if (s.length() == 1) return s.charAt(0);\n\n // at this point, len = 2\n UChar32 cp = s.char32At(0);\n if (cp > 0xFFFF) { // is surrogate pair\n return cp;\n }\n return -1;\n}", "label": 0, "cwe": null, "length": 123 }, { "index": 705529, "code": "f2fs_acl_create(struct inode *dir, umode_t *mode,\n\t\tstruct posix_acl **default_acl, struct posix_acl **acl,\n\t\tstruct page *dpage)\n{\n\tstruct posix_acl *p;\n\tstruct posix_acl *clone;\n\tint ret;\n\n\t*acl = NULL;\n\t*default_acl = NULL;\n\n\tif (S_ISLNK(*mode) || !IS_POSIXACL(dir))\n\t\treturn 0;\n\n\tp = __f2fs_get_acl(dir, ACL_TYPE_DEFAULT, dpage);\n\tif (!p || p == ERR_PTR(-EOPNOTSUPP)) {\n\t\t*mode &= ~current_umask();\n\t\treturn 0;\n\t}\n\tif (IS_ERR(p))\n\t\treturn PTR_ERR(p);\n\n\tclone = f2fs_acl_clone(p, GFP_NOFS);\n\tif (!clone)\n\t\tgoto no_mem;\n\n\tret = f2fs_acl_create_masq(clone, mode);\n\tif (ret < 0)\n\t\tgoto no_mem_clone;\n\n\tif (ret == 0)\n\t\tposix_acl_release(clone);\n\telse\n\t\t*acl = clone;\n\n\tif (!S_ISDIR(*mode))\n\t\tposix_acl_release(p);\n\telse\n\t\t*default_acl = p;\n\n\treturn 0;\n\nno_mem_clone:\n\tposix_acl_release(clone);\nno_mem:\n\tposix_acl_release(p);\n\treturn -ENOMEM;\n}", "label": 0, "cwe": null, "length": 276 }, { "index": 739807, "code": "GdipSetTextureTransform (GpTexture *texture, GDIPCONST GpMatrix *matrix)\n{\n\tif ((texture == NULL) || (matrix == NULL)) {\n\t\treturn InvalidParameter;\n\t}\n\n\tgdip_cairo_matrix_copy(&texture->matrix, matrix);\n\ttexture->base.changed = TRUE;\n\n\treturn Ok;\n}", "label": 0, "cwe": null, "length": 69 }, { "index": 28677, "code": "toString(TypeObject* value) const\n{\n\tCSetObject* cobj = static_cast(value);\n\t::std::set::const_iterator it(cobj->set.begin()), end(cobj->set.end());\n\t::std::ostringstream out;\n\n\tout << \"Set<\";\n\n\twhile (it != end) {\n\t\tit->element->dump(out);\n\n\t\tif (++it != end) {\n\t\t\tout<< \", \";\n\t\t}\n\t}\n\n\tout << \">\";\n\n\treturn out.str();\n}", "label": 0, "cwe": null, "length": 104 }, { "index": 687481, "code": "psDoText(f,i,j,z,ah,av)\nINT f, i, j;\nINT ah, av;\nchar *z;\n{ INT w, h, k;\n if (f==1) fprintf(psfile,\"F1\\n\");\n psTextDim(f,z,&w,&h);\n /* i -= w*(ah+1)/2; */\n j += h*(av+1)/2;\n putc('(',psfile);\n for (k=0; ksw_cidx, cq->sw_pidx);\n\tmemset(&cqe, 0, sizeof(cqe));\n\tcqe.header = cpu_to_be32(CQE_STATUS_V(T4_ERR_SWFLUSH) |\n\t\t\t\t CQE_OPCODE_V(swcqe->opcode) |\n\t\t\t\t CQE_TYPE_V(1) |\n\t\t\t\t CQE_SWCQE_V(1) |\n\t\t\t\t CQE_QPID_V(wq->sq.qid));\n\tCQE_WRID_SQ_IDX(&cqe) = swcqe->idx;\n\tcqe.bits_type_ts = cpu_to_be64(CQE_GENBIT_V((u64)cq->gen));\n\tcq->sw_queue[cq->sw_pidx] = cqe;\n\tt4_swcq_produce(cq);\n}", "label": 0, "cwe": null, "length": 232 }, { "index": 58789, "code": "add_child_rel_equivalences(PlannerInfo *root,\n\t\t\t\t\t\t AppendRelInfo *appinfo,\n\t\t\t\t\t\t RelOptInfo *parent_rel,\n\t\t\t\t\t\t RelOptInfo *child_rel)\n{\n\tListCell *lc1;\n\n\tforeach(lc1, root->eq_classes)\n\t{\n\t\tEquivalenceClass *cur_ec = (EquivalenceClass *) lfirst(lc1);\n\t\tListCell *lc2;\n\n\t\t/*\n\t\t * If this EC contains a constant, then it's not useful for sorting\n\t\t * or driving an inner index-scan, so we skip generating child EMs.\n\t\t *\n\t\t * If this EC contains a volatile expression, then generating child\n\t\t * EMs would be downright dangerous. We rely on a volatile EC having\n\t\t * only one EM.\n\t\t */\n\t\tif (cur_ec->ec_has_const || cur_ec->ec_has_volatile)\n\t\t\tcontinue;\n\n\t\t/* No point in searching if parent rel not mentioned in eclass */\n\t\tif (!bms_is_subset(parent_rel->relids, cur_ec->ec_relids))\n\t\t\tcontinue;\n\n\t\tforeach(lc2, cur_ec->ec_members)\n\t\t{\n\t\t\tEquivalenceMember *cur_em = (EquivalenceMember *) lfirst(lc2);\n\n\t\t\t/* Does it reference (only) parent_rel? */\n\t\t\tif (bms_equal(cur_em->em_relids, parent_rel->relids))\n\t\t\t{\n\t\t\t\t/* Yes, generate transformed child version */\n\t\t\t\tExpr\t *child_expr;\n\n\t\t\t\tchild_expr = (Expr *)\n\t\t\t\t\tadjust_appendrel_attrs((Node *) cur_em->em_expr,\n\t\t\t\t\t\t\t\t\t\t appinfo);\n\t\t\t\t(void) add_eq_member(cur_ec, child_expr, child_rel->relids,\n\t\t\t\t\t\t\t\t\t true, cur_em->em_datatype);\n\t\t\t}\n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 379 }, { "index": 968, "code": "clear_uri_item (uri_item* list, int nitems, int32_t id)\n{\n\tint i;\n\n\tfor (i = 0; i < nitems; i++) {\n\t\tif (list [i].id != id)\n\t\t\tcontinue;\n\t\tlist [i].id = -1;\n\t\tlist [i].start_time = -1;\n\t\treturn;\n\t}\n}", "label": 0, "cwe": null, "length": 79 }, { "index": 72830, "code": "writeOffset(byte* buf,\n int32_t offset,\n TiffType tiffType,\n ByteOrder byteOrder)\n {\n uint32_t rc = 0;\n switch(tiffType) {\n case ttUnsignedShort:\n case ttSignedShort:\n if (static_cast(offset) > 0xffff) throw Error(26);\n rc = s2Data(buf, static_cast(offset), byteOrder);\n break;\n case ttUnsignedLong:\n case ttSignedLong:\n rc = l2Data(buf, static_cast(offset), byteOrder);\n break;\n default:\n throw Error(27);\n break;\n }\n return rc;\n }", "label": 0, "cwe": null, "length": 157 }, { "index": 98771, "code": "stk8312_set_mode(struct stk8312_data *data, u8 mode)\n{\n\tint ret;\n\tstruct i2c_client *client = data->client;\n\n\tif (mode == data->mode)\n\t\treturn 0;\n\n\tret = i2c_smbus_write_byte_data(client, STK8312_REG_MODE, mode);\n\tif (ret < 0) {\n\t\tdev_err(&client->dev, \"failed to change sensor mode\\n\");\n\t\treturn ret;\n\t}\n\n\tdata->mode = mode;\n\tif (mode & STK8312_MODE_ACTIVE) {\n\t\t/* Need to run OTP sequence before entering active mode */\n\t\tusleep_range(1000, 5000);\n\t\tret = stk8312_otp_init(data);\n\t}\n\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 159 }, { "index": 314459, "code": "gray_hline( TRaster *raster, TCoord x, TCoord y, TPos area, int acount, Bool zero_non_zero_rule)\n{\n\tEVG_Span* span;\n\tint count;\n\tint coverage;\n\n\tx += (TCoord)raster->min_ex;\n\tif (x>=raster->max_ex) return;\n\ty += (TCoord)raster->min_ey;\n\n\t/* compute the coverage line's coverage, depending on the */\n\t/* outline fill rule */\n\t/* */\n\t/* the coverage percentage is area/(PIXEL_BITS*PIXEL_BITS*2) */\n\t/* */\n\tcoverage = (int)( area >> ( PIXEL_BITS * 2 + 1 - 8 ) );\n\t\t\t\t\t\t\t\t\t/* use range 0..256 */\n\tif ( coverage < 0 )\n\tcoverage = -coverage;\n\n\tif (zero_non_zero_rule) {\n\t\t/* normal non-zero winding rule */\n\t\tif ( coverage >= 256 )\n\t\t\tcoverage = 255;\n\t} else {\n\t\tcoverage &= 511;\n\n\t\tif ( coverage > 256 )\n\t\t\tcoverage = 512 - coverage;\n\t\telse if ( coverage == 256 )\n\t\t\tcoverage = 255;\n\t}\n\n\tif ( coverage ) {\n\t\t/* see if we can add this span to the current list */\n\t\tcount = raster->num_gray_spans;\n\t\tspan = raster->gray_spans + count - 1;\n\t\tif ( count > 0 &&\n\t\t\t(int)span->x + span->len == (int)x &&\n\t\t\tspan->coverage == coverage )\n\t\t{\n\t\t\tspan->len = (unsigned short)( span->len + acount );\n\t\t\treturn;\n\t\t}\n\n\t\tif (count >= FT_MAX_GRAY_SPANS ) {\n\t\t\traster->render_span(y, count, raster->gray_spans, raster->render_span_data );\n\t\t\traster->num_gray_spans = 0;\n\n\t\t\tcount = 0;\n\t\t\tspan = raster->gray_spans;\n\t\t} else\n\t\t\tspan++;\n\n\t\t/* add a gray span to the current list */\n\t\tspan->x = (short)x;\n\t\tspan->len = (unsigned short)acount;\n\t\tspan->coverage = (unsigned char)coverage;\n\t\traster->num_gray_spans++;\n\t}\n}", "label": 0, "cwe": null, "length": 498 }, { "index": 567085, "code": "mcam_vb_queue_setup(struct vb2_queue *vq,\n\t\tconst void *parg, unsigned int *nbufs,\n\t\tunsigned int *num_planes, unsigned int sizes[],\n\t\tvoid *alloc_ctxs[])\n{\n\tconst struct v4l2_format *fmt = parg;\n\tstruct mcam_camera *cam = vb2_get_drv_priv(vq);\n\tint minbufs = (cam->buffer_mode == B_DMA_contig) ? 3 : 2;\n\n\tif (fmt && fmt->fmt.pix.sizeimage < cam->pix_format.sizeimage)\n\t\treturn -EINVAL;\n\tsizes[0] = fmt ? fmt->fmt.pix.sizeimage : cam->pix_format.sizeimage;\n\t*num_planes = 1; /* Someday we have to support planar formats... */\n\tif (*nbufs < minbufs)\n\t\t*nbufs = minbufs;\n\tif (cam->buffer_mode == B_DMA_contig)\n\t\talloc_ctxs[0] = cam->vb_alloc_ctx;\n\telse if (cam->buffer_mode == B_DMA_sg)\n\t\talloc_ctxs[0] = cam->vb_alloc_ctx_sg;\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 243 }, { "index": 49304, "code": "makeonly() {\n\n bool result = ( ! only() );\n\n if ( result ) {\n --*p;\n p = new int(1);\n }\n\n return result;\n\n}", "label": 0, "cwe": null, "length": 42 }, { "index": 61128, "code": "amdgpu_bo_set_tiling_flags(struct amdgpu_bo *bo, u64 tiling_flags)\n{\n\tif (AMDGPU_TILING_GET(tiling_flags, TILE_SPLIT) > 6)\n\t\treturn -EINVAL;\n\n\tbo->tiling_flags = tiling_flags;\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 63 }, { "index": 542981, "code": "compareGtRange(const void *a,const void *b)\n{\n const GtRange *vala, *valb;\n\n vala = (GtRange *) a;\n valb = (GtRange *) b;\n if (vala->start < valb->start)\n {\n makeerrormsg(vala,valb,\"<\");\n return -1;\n }\n if (vala->start > valb->start)\n {\n makeerrormsg(vala,valb,\">\");\n return 1;\n }\n if (vala->end < valb->end)\n {\n makeerrormsg(vala,valb,\"<\");\n return -1;\n }\n if (vala->end > valb->end)\n {\n makeerrormsg(vala,valb,\">\");\n return 1;\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 183 }, { "index": 227258, "code": "storeUfsDirCloseSwapLog(SwapDir * sd)\n{\n ufsinfo_t *ufsinfo = (ufsinfo_t *) sd->fsdata;\n if (ufsinfo->swaplog_fd < 0)\t/* not open */\n\treturn;\n file_close(ufsinfo->swaplog_fd);\n debug(47, 3) (\"Cache Dir #%d log closed on FD %d\\n\",\n\tsd->index, ufsinfo->swaplog_fd);\n ufsinfo->swaplog_fd = -1;\n n_ufs_dirs--;\n assert(n_ufs_dirs >= 0);\n if (0 == n_ufs_dirs)\n\tsafe_free(ufs_dir_index);\n}", "label": 0, "cwe": null, "length": 145 }, { "index": 88825, "code": "PG_ThemeWidget(PG_Widget* parent, const PG_Rect& r, bool bCreateSurface, const std::string& style) : PG_Widget(parent, r, bCreateSurface) {\n\tInit(style);\n}", "label": 0, "cwe": null, "length": 45 }, { "index": 1001804, "code": "HashFindPhonePhrase( ChewingData *pgdata, const uint16_t phoneSeq[], HASH_ITEM *pItemLast )\n{\n\tHASH_ITEM *pNow = pItemLast ?\n\t\t\tpItemLast->next :\n\t\t\tpgdata->static_data.hashtable[ HashFunc( phoneSeq ) ];\n\n\tfor ( ; pNow; pNow = pNow->next )\n\t\tif ( PhoneSeqTheSame( pNow->data.phoneSeq, phoneSeq ) )\n\t\t\treturn pNow;\n\treturn NULL;\n}", "label": 0, "cwe": null, "length": 104 }, { "index": 752470, "code": "unmarshalReturnedValues(cdrStream& _n)\n{\n arg_1 = new LifeCycleService::Keys;\n (LifeCycleService::Keys&)arg_1 <<= _n;\n arg_2 = new LifeCycleService::PropertyList;\n (LifeCycleService::PropertyList&)arg_2 <<= _n;\n\n}", "label": 0, "cwe": null, "length": 70 }, { "index": 573827, "code": "has_source(CdlValueSource source) const\n{\n CYG_REPORT_FUNCNAMETYPE(\"CdlValuable::has_source\", \"result %d\");\n CYG_REPORT_FUNCARG2XV(this, source);\n CYG_PRECONDITION_THISC();\n\n bool result = value.has_source(source);\n CYG_REPORT_RETVAL(result);\n return result;\n}", "label": 0, "cwe": null, "length": 77 }, { "index": 599230, "code": "ipw_wx_get_preamble(struct net_device *dev,\n\t\t\t struct iw_request_info *info,\n\t\t\t union iwreq_data *wrqu, char *extra)\n{\n\tstruct ipw_priv *priv = libipw_priv(dev);\n\tmutex_lock(&priv->mutex);\n\tif (priv->config & CFG_PREAMBLE_LONG)\n\t\tsnprintf(wrqu->name, IFNAMSIZ, \"long (1)\");\n\telse\n\t\tsnprintf(wrqu->name, IFNAMSIZ, \"auto (0)\");\n\tmutex_unlock(&priv->mutex);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 118 }, { "index": 41928, "code": "gst_h264_parse_get_string (GstH264Parse * parse, gboolean format, gint code)\n{\n if (format) {\n switch (code) {\n case GST_H264_PARSE_FORMAT_AVC:\n return \"avc\";\n case GST_H264_PARSE_FORMAT_BYTE:\n return \"byte-stream\";\n case GST_H264_PARSE_FORMAT_AVC3:\n return \"avc3\";\n default:\n return \"none\";\n }\n } else {\n switch (code) {\n case GST_H264_PARSE_ALIGN_NAL:\n return \"nal\";\n case GST_H264_PARSE_ALIGN_AU:\n return \"au\";\n default:\n return \"none\";\n }\n }\n}", "label": 0, "cwe": null, "length": 147 }, { "index": 615452, "code": "auto_unlock_keyring_location (CK_ATTRIBUTE_PTR attrs, CK_ULONG n_attrs)\n{\n\tCK_ATTRIBUTE_PTR attr;\n\n\tif (is_login_keyring (attrs, n_attrs))\n\t\treturn NULL;\n\n\tattr = gkm_attributes_find (attrs, n_attrs, CKA_ID);\n\tif (attr == NULL)\n\t\treturn NULL;\n\n\t/*\n\t * COMPAT: Format it into a string. This is done this way for compatibility\n\t * with old gnome-keyring releases. In the future this may change.\n\t */\n\n\treturn g_strdup_printf (\"LOCAL:/keyrings/%s.keyring\", (gchar*)attr->pValue);\n}", "label": 0, "cwe": null, "length": 131 }, { "index": 419584, "code": "search(ht_search_request *search, FileOfs start, FileOfs end)\n{\n\tif (collapsed) return NULL;\n\treturn ht_layer_sub::search(search, start, end);\n}", "label": 0, "cwe": null, "length": 39 }, { "index": 963917, "code": "_gtk_marshal_VOID__OBJECT_OBJECT_OBJECTv (GClosure *closure,\n GValue *return_value,\n gpointer instance,\n va_list args,\n gpointer marshal_data,\n int n_params,\n GType *param_types)\n{\n typedef void (*GMarshalFunc_VOID__OBJECT_OBJECT_OBJECT) (gpointer instance,\n gpointer arg_0,\n gpointer arg_1,\n gpointer arg_2,\n gpointer data);\n GCClosure *cc = (GCClosure*) closure;\n gpointer data1, data2;\n GMarshalFunc_VOID__OBJECT_OBJECT_OBJECT callback;\n gpointer arg0;\n gpointer arg1;\n gpointer arg2;\n va_list args_copy;\n\n G_VA_COPY (args_copy, args);\n arg0 = (gpointer) va_arg (args_copy, gpointer);\n if (arg0 != NULL)\n arg0 = g_object_ref (arg0);\n arg1 = (gpointer) va_arg (args_copy, gpointer);\n if (arg1 != NULL)\n arg1 = g_object_ref (arg1);\n arg2 = (gpointer) va_arg (args_copy, gpointer);\n if (arg2 != NULL)\n arg2 = g_object_ref (arg2);\n va_end (args_copy);\n\n if (G_CCLOSURE_SWAP_DATA (closure))\n {\n data1 = closure->data;\n data2 = instance;\n }\n else\n {\n data1 = instance;\n data2 = closure->data;\n }\n callback = (GMarshalFunc_VOID__OBJECT_OBJECT_OBJECT) (marshal_data ? marshal_data : cc->callback);\n\n callback (data1,\n arg0,\n arg1,\n arg2,\n data2);\n if (arg0 != NULL)\n g_object_unref (arg0);\n if (arg1 != NULL)\n g_object_unref (arg1);\n if (arg2 != NULL)\n g_object_unref (arg2);\n}", "label": 0, "cwe": null, "length": 424 }, { "index": 157753, "code": "AH_Msg_ReadMessage(AH_MSG *msg,\n GWEN_MSGENGINE *e,\n const char *gtype,\n GWEN_BUFFER *mbuf,\n GWEN_DB_NODE *gr,\n unsigned int flags) {\n unsigned int segments;\n unsigned int errors;\n int rv;\n\n segments=0;\n errors=0;\n\n while(GWEN_Buffer_GetBytesLeft(mbuf)) {\n rv=AH_Msg_ReadSegment(msg, e, gtype, mbuf, gr, flags);\n if (rv==-2) {\n DBG_INFO(AQHBCI_LOGDOMAIN, \"here\");\n return -1;\n }\n else if (rv==-1) {\n DBG_INFO(AQHBCI_LOGDOMAIN, \"here\");\n\n DBG_ERROR(AQHBCI_LOGDOMAIN, \"Error here:\");\n GWEN_Buffer_Dump(mbuf, 2);\n#ifdef AH_MSG_HEAVY_DEBUG\n return -1;\n#endif\n if (GWEN_MsgEngine_SkipSegment(e, mbuf, '?', '\\'')) {\n DBG_ERROR(AQHBCI_LOGDOMAIN, \"Error skipping segment\");\n return -1;\n }\n errors++;\n }\n segments++;\n } /* while */\n\n DBG_DEBUG(AQHBCI_LOGDOMAIN, \"Parsed %d segments (%d had errors)\",\n segments, errors);\n return 0;\n}", "label": 0, "cwe": null, "length": 288 }, { "index": 748125, "code": "CopyGetAttnums(TupleDesc tupDesc, Relation rel, List *attnamelist)\n{\n\tList\t *attnums = NIL;\n\n\tif (attnamelist == NIL)\n\t{\n\t\t/* Generate default column list */\n\t\tForm_pg_attribute *attr = tupDesc->attrs;\n\t\tint\t\t\tattr_count = tupDesc->natts;\n\t\tint\t\t\ti;\n\n\t\tfor (i = 0; i < attr_count; i++)\n\t\t{\n\t\t\tif (attr[i]->attisdropped)\n\t\t\t\tcontinue;\n\t\t\tattnums = lappend_int(attnums, i + 1);\n\t\t}\n\t}\n\telse\n\t{\n\t\t/* Validate the user-supplied list and extract attnums */\n\t\tListCell *l;\n\n\t\tforeach(l, attnamelist)\n\t\t{\n\t\t\tchar\t *name = strVal(lfirst(l));\n\t\t\tint\t\t\tattnum;\n\t\t\tint\t\t\ti;\n\n\t\t\t/* Lookup column name */\n\t\t\tattnum = InvalidAttrNumber;\n\t\t\tfor (i = 0; i < tupDesc->natts; i++)\n\t\t\t{\n\t\t\t\tif (tupDesc->attrs[i]->attisdropped)\n\t\t\t\t\tcontinue;\n\t\t\t\tif (namestrcmp(&(tupDesc->attrs[i]->attname), name) == 0)\n\t\t\t\t{\n\t\t\t\t\tattnum = tupDesc->attrs[i]->attnum;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (attnum == InvalidAttrNumber)\n\t\t\t{\n\t\t\t\tif (rel != NULL)\n\t\t\t\t\tereport(ERROR,\n\t\t\t\t\t\t\t(errcode(ERRCODE_UNDEFINED_COLUMN),\n\t\t\t\t\terrmsg(\"column \\\"%s\\\" of relation \\\"%s\\\" does not exist\",\n\t\t\t\t\t\t name, RelationGetRelationName(rel))));\n\t\t\t\telse\n\t\t\t\t\tereport(ERROR,\n\t\t\t\t\t\t\t(errcode(ERRCODE_UNDEFINED_COLUMN),\n\t\t\t\t\t\t\t errmsg(\"column \\\"%s\\\" does not exist\",\n\t\t\t\t\t\t\t\t\tname)));\n\t\t\t}\n\t\t\t/* Check for duplicates */\n\t\t\tif (list_member_int(attnums, attnum))\n\t\t\t\tereport(ERROR,\n\t\t\t\t\t\t(errcode(ERRCODE_DUPLICATE_COLUMN),\n\t\t\t\t\t\t errmsg(\"column \\\"%s\\\" specified more than once\",\n\t\t\t\t\t\t\t\tname)));\n\t\t\tattnums = lappend_int(attnums, attnum);\n\t\t}\n\t}\n\n\treturn attnums;\n}", "label": 0, "cwe": null, "length": 472 }, { "index": 350015, "code": "globus_i_gsi_proxy_utils_pwstdin_callback(\n char * buf, \n int num, \n int w)\n{\n int i;\n\n setvbuf(stdin, (char *)NULL, _IONBF, 0);\n if (!(fgets(buf, num, stdin))) {\n fprintf(stderr, \"Failed to read pass-phrase from stdin\\n\");\n return -1;\n }\n i = strlen(buf);\n if (buf[i-1] == '\\n') {\n buf[i-1] = '\\0';\n i--;\n }\n return i; \n\n}", "label": 0, "cwe": null, "length": 127 }, { "index": 618192, "code": "pcf8523_set_pm(struct i2c_client *client, u8 pm)\n{\n\tu8 value;\n\tint err;\n\n\terr = pcf8523_read(client, REG_CONTROL3, &value);\n\tif (err < 0)\n\t\treturn err;\n\n\tvalue = (value & ~REG_CONTROL3_PM_MASK) | pm;\n\n\terr = pcf8523_write(client, REG_CONTROL3, value);\n\tif (err < 0)\n\t\treturn err;\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 99 }, { "index": 107487, "code": "exfat_vbr_add_checksum(const void* sector, size_t size, uint32_t sum)\n{\n\tsize_t i;\n\n\tfor (i = 0; i < size; i++)\n\t\tsum = ((sum << 31) | (sum >> 1)) + ((const uint8_t*) sector)[i];\n\treturn sum;\n}", "label": 0, "cwe": null, "length": 70 }, { "index": 588705, "code": "end()\n{\n if(!last_stimulus) {\n cout << \"warning: Ignoring stimulus (string) option because there's no stimulus defined.\";\n return;\n }\n\n switch( options_entered & (STIM_SQW | STIM_TRI | STIM_ASY | STIM_ATTRIBUTE))\n {\n case STIM_SQW:\n if(verbose)\n\tcout << \"created sqw stimulus\\n\";\n break;\n\n case STIM_ASY:\n if(verbose)\n\tcout << \"created asy stimulus\\n\";\n last_stimulus->start();\n break;\n\n case STIM_ATTRIBUTE:\n if(verbose)\n\tcout << \"created attribute stimulus\\n\";\n last_stimulus->start();\n break;\n\n case STIM_TRI:\n if(verbose)\n\tcout << \"creating tri stimulus\\n\";\n break;\n\n }\n\n last_stimulus = 0;\n}", "label": 0, "cwe": null, "length": 184 }, { "index": 819, "code": "matroska_aac_profile(char *codec_id)\n{\n static const char * const aac_profiles[] = { \"MAIN\", \"LC\", \"SSR\" };\n int profile;\n\n for (profile=0; profile= 64 && ALIGNMENT_OF(s) == ALIGNMENT_OF(d)) {\n while (ALIGNMENT_OF(s) != 0 && l > 0) {\n *d ^= *s;\n s += 1;\n d += 1;\n l -= 1;\n }\n while (l >= sizeof(long)) {\n *((long *) d) ^= *((long *) s);\n s += sizeof(long);\n d += sizeof(long);\n l -= sizeof(long);\n }\n }\n while (l > 0) {\n *d ^= *s;\n s += 1;\n d += 1;\n l -= 1;\n }\n return Val_unit;\n}", "label": 0, "cwe": null, "length": 215 }, { "index": 559631, "code": "cleanup_mime(struct mailmime * mime)\n{\n mime->mm_mime_start = NULL;\n mime->mm_length = 0;\n if (mime->mm_body != NULL) {\n mailmime_data_free(mime->mm_body);\n mime->mm_body = NULL;\n }\n switch (mime->mm_type) {\n case MAILMIME_SINGLE:\n mime->mm_data.mm_single = NULL;\n break;\n case MAILMIME_MULTIPLE:\n {\n clistiter * cur;\n \n for(cur = clist_begin(mime->mm_data.mm_multipart.mm_mp_list) ;\n cur != NULL ; cur = clist_next(cur)) {\n struct mailmime * submime;\n \n submime = clist_content(cur);\n cleanup_mime(submime);\n }\n }\n break;\n case MAILMIME_MESSAGE:\n if (mime->mm_data.mm_message.mm_msg_mime != NULL) \n cleanup_mime(mime->mm_data.mm_message.mm_msg_mime);\n break;\n }\n}", "label": 0, "cwe": null, "length": 214 }, { "index": 262729, "code": "xsh_star_flux_list_create( int size )\n{\n xsh_star_flux_list * result = NULL ;\n\n /* Create the list */\n XSH_CALLOC( result, xsh_star_flux_list, 1 ) ;\n result->header = NULL ;\n result->size = size ;\n XSH_CALLOC( result->lambda, double, size ) ;\n XSH_CALLOC( result->flux, double, size ) ;\n\n cleanup:\n return result ;\n}", "label": 0, "cwe": null, "length": 98 }, { "index": 796909, "code": "embed_nulls(int fd, void *buf, int row, RASTER_MAP_TYPE map_type,\n\t\t int null_is_zero, int with_mask)\n{\n struct fileinfo *fcb = &G__.fileinfo[fd];\n int i;\n\n /* this is because without null file the nulls can be only due to 0's\n in data row or mask */\n if (null_is_zero && !fcb->null_file_exists\n\t&& (G__.auto_mask <= 0 || !with_mask))\n\treturn 1;\n\n get_null_value_row(fd, G__.null_buf, row, with_mask);\n\n for (i = 0; i < G__.window.cols; i++) {\n\t/* also check for nulls which might be already embedded by quant\n\t rules in case of fp map. */\n\tif (G__.null_buf[i] || G_is_null_value(buf, map_type)) {\n\t /* G__set_[f/d]_null_value() sets it to 0 is the embedded mode\n\t is not set and calls G_set_[f/d]_null_value() otherwise */\n\t G__set_null_value(buf, 1, null_is_zero, map_type);\n\t}\n\tbuf = G_incr_void_ptr(buf, G_raster_size(map_type));\n }\n\n return 1;\n}", "label": 0, "cwe": null, "length": 276 }, { "index": 9275, "code": "print_comment(FILE *file, CloogOptions *options,\n\t\t\t const char *fmt, ...)\n{\n va_list args;\n\n va_start(args, fmt);\n if (options->language == LANGUAGE_FORTRAN) {\n fprintf(file, \"! \");\n vfprintf(file, fmt, args);\n fprintf(file, \"\\n\");\n } else {\n fprintf(file, \"/* \");\n vfprintf(file, fmt, args);\n fprintf(file, \" */\\n\");\n }\n}", "label": 0, "cwe": null, "length": 99 }, { "index": 992610, "code": "update_read_multi_draw_nine_grid_order(STREAM* s, ORDER_INFO* orderInfo, MULTI_DRAW_NINE_GRID_ORDER* multi_draw_nine_grid)\n{\n\tif (orderInfo->fieldFlags & ORDER_FIELD_01)\n\t\tupdate_read_coord(s, &multi_draw_nine_grid->srcLeft, orderInfo->deltaCoordinates);\n\n\tif (orderInfo->fieldFlags & ORDER_FIELD_02)\n\t\tupdate_read_coord(s, &multi_draw_nine_grid->srcTop, orderInfo->deltaCoordinates);\n\n\tif (orderInfo->fieldFlags & ORDER_FIELD_03)\n\t\tupdate_read_coord(s, &multi_draw_nine_grid->srcRight, orderInfo->deltaCoordinates);\n\n\tif (orderInfo->fieldFlags & ORDER_FIELD_04)\n\t\tupdate_read_coord(s, &multi_draw_nine_grid->srcBottom, orderInfo->deltaCoordinates);\n\n\tif (orderInfo->fieldFlags & ORDER_FIELD_05)\n\t\tstream_read_uint16(s, multi_draw_nine_grid->bitmapId);\n\n\tif (orderInfo->fieldFlags & ORDER_FIELD_06)\n\t\tstream_read_uint8(s, multi_draw_nine_grid->nDeltaEntries);\n\n\tif (orderInfo->fieldFlags & ORDER_FIELD_07)\n\t{\n\t\tstream_read_uint16(s, multi_draw_nine_grid->cbData);\n\t\tstream_seek(s, multi_draw_nine_grid->cbData);\n\t}\n}", "label": 0, "cwe": null, "length": 281 }, { "index": 452462, "code": "py_is_tree(PyObject *self, PyObject *args)\n{\n\tPyObject *entry, *mode, *result;\n\tlong lmode;\n\n\tif (!PyArg_ParseTuple(args, \"O\", &entry))\n\t\treturn NULL;\n\n\tmode = PyObject_GetAttrString(entry, \"mode\");\n\tif (!mode)\n\t\treturn NULL;\n\n\tif (mode == Py_None) {\n\t\tresult = Py_False;\n\t} else {\n\t\tlmode = PyInt_AsLong(mode);\n\t\tif (lmode == -1 && PyErr_Occurred()) {\n\t\t\tPy_DECREF(mode);\n\t\t\treturn NULL;\n\t\t}\n\t\tresult = PyBool_FromLong(S_ISDIR((mode_t)lmode));\n\t}\n\tPy_INCREF(result);\n\tPy_DECREF(mode);\n\treturn result;\n}", "label": 0, "cwe": null, "length": 152 }, { "index": 416706, "code": "get_baa_by_block_id(List *baa_list, int loopno)\n{\n BlockAlignArray *baa = NULL;\n List *li;\n\n for (li = baa_list; li != NULL; li = li->next) {\n baa = li->data;\n if (baa->block->no == loopno)\n break;\n }\n\n return baa;\n}", "label": 0, "cwe": null, "length": 85 }, { "index": 336838, "code": "ksLookupByString(KeySet *ks, const char *value, option_t options)\n{\n\tcursor_t init=0;\n\tKey *current=0;\n\n\tif (!ks) return 0;\n\n\tif (options & KDB_O_SORT)\n\t{\n\t\tksSort (ks);\n\t\tksRewind (ks);\n\t}\n\telse if (!(options & KDB_O_NOALL) && ks->flags & KS_FLAG_DIRTY) ksSort(ks);\n\n\tif (!(options & KDB_O_NOALL))\n\t{\n\t\tksRewind (ks);\n\t\tinit=ksGetCursor(ks);\n\t}\n\n\tif (!value) return 0;\n\n\twhile ((current=ksNext(ks)) != 0)\n\t{\n\t\tif (!keyIsString(current)) continue;\n\n\t\t/*fprintf (stderr, \"Compare %s with %s\\n\", keyValue(current), value);*/\n\n\t\tif ((options & KDB_O_NOCASE) && \n\t\t\t!kdbiStrCaseCmp(keyValue(current),value)) break;\n\t\telse if (!strcmp(keyValue(current),value)) break;\n\t}\n\n\t/* reached end of KeySet */\n\tif (!(options & KDB_O_NOALL))\n\t{\n\t\tksSetCursor (ks, init);\n\t}\n\n\treturn current;\n}", "label": 0, "cwe": null, "length": 263 }, { "index": 395261, "code": "yy_Note()\n{ int yypos0= yypos, yythunkpos0= yythunkpos; yyDo(yyPush, 2, 0);\n yyprintf((stderr, \"%s\\n\", \"Note\")); yyText(yybegin, yyend); if (!( extension(EXT_NOTES) )) goto l1305; if (!yy_NonindentSpace()) goto l1305; if (!yy_RawNoteReference()) goto l1305; yyDo(yySet, -2, 0); if (!yymatchChar(':')) goto l1305; if (!yy_Sp()) goto l1305; if (!yy_StartList()) goto l1305; yyDo(yySet, -1, 0); if (!yy_RawNoteBlock()) goto l1305; yyDo(yy_1_Note, yybegin, yyend);\n l1306:;\t\n { int yypos1307= yypos, yythunkpos1307= yythunkpos;\n { int yypos1308= yypos, yythunkpos1308= yythunkpos; if (!yy_Indent()) goto l1307; yypos= yypos1308; yythunkpos= yythunkpos1308;\n } if (!yy_RawNoteBlock()) goto l1307; yyDo(yy_2_Note, yybegin, yyend); goto l1306;\n l1307:;\t yypos= yypos1307; yythunkpos= yythunkpos1307;\n } yyDo(yy_3_Note, yybegin, yyend);\n yyprintf((stderr, \" ok %s @ %s\\n\", \"Note\", yybuf+yypos)); yyDo(yyPop, 2, 0);\n return 1;\n l1305:;\t yypos= yypos0; yythunkpos= yythunkpos0;\n yyprintf((stderr, \" fail %s @ %s\\n\", \"Note\", yybuf+yypos));\n return 0;\n}", "label": 0, "cwe": null, "length": 462 }, { "index": 992209, "code": "on_actor_mapped (ClutterActor *actor,\n GParamSpec *pspec,\n ClutterDropAction *self)\n{\n if (CLUTTER_ACTOR_IS_MAPPED (actor))\n {\n if (self->priv->stage == NULL)\n self->priv->stage = clutter_actor_get_stage (actor);\n\n drop_action_register (self);\n }\n else\n drop_action_unregister (self);\n}", "label": 0, "cwe": null, "length": 91 }, { "index": 89148, "code": "tf_isetrealdelay(double dly, void*obj)\n{\n vpiHandle sys = (vpiHandle)obj;\n p_pli_data pli = vpi_get_userdata(sys);\n s_cb_data cb;\n s_vpi_time ti = {vpiSimTime};\n\n /* Scale delay to SimTime */\n ivl_u64_t delay = ((dly\n\t\t\t / pow(10, tf_gettimeunit() - tf_gettimeprecision()))\n\t\t\t + 0.5);\n ti.high = delay >> 32 & 0xffffffff;\n ti.low = delay & 0xffffffff;\n\n cb.reason = cbAfterDelay;\n cb.cb_rtn = callback;\n cb.obj = sys;\n cb.time = &ti;\n cb.user_data = (char *)pli;\n\n vpi_register_cb(&cb);\n\n if (pli_trace)\n\t fprintf(pli_trace, \"tf_isetrealdelay(%f, %p) --> %d\\n\",\n\t\t dly, obj, 0);\n\n return 0;\n}", "label": 0, "cwe": null, "length": 218 }, { "index": 784672, "code": "threeCharKeyHashToHash( const QString & serialized, bool base64Protection )\n{\n QHash toReturn;\n if (!serialized.startsWith(HASH_PREFIX)) {\n Log::addError( \"Serializer\", QCoreApplication::translate(\"Serializer\", \"Can not deserialize to QHash.\") );\n return toReturn;\n }\n QString ser = serialized.mid( QString(HASH_PREFIX).length() );\n QStringList list = ser.split( separator() );\n QStringListIterator it(list);\n QString val;\n QString k;\n if (base64Protection) {\n while (it.hasNext()) {\n val = it.next();\n if (it.hasNext()) {\n k = it.next();\n toReturn.insert( val, QByteArray::fromBase64( k.toUtf8() ) );\n }\n }\n } else {\n while (it.hasNext()) {\n val = it.next().toUtf8();\n if (it.hasNext()) {\n k = it.next();\n toReturn.insert( val, k );\n }\n }\n }\n return toReturn;\n}", "label": 0, "cwe": null, "length": 217 }, { "index": 311691, "code": "CU_set_error(CU_ErrorCode error)\n{\n if ((error != CUE_SUCCESS) && (g_error_action == CUEA_ABORT)) {\n#ifndef CUNIT_DO_NOT_DEFINE_UNLESS_BUILDING_TESTS\n fprintf(stderr, _(\"\\nAborting due to error #%d: %s\\n\"),\n (int)error,\n get_error_desc(error));\n exit((int)error);\n#else\n test_exit(error);\n#endif\n }\n\n g_error_number = error;\n}", "label": 0, "cwe": null, "length": 101 }, { "index": 499409, "code": "hasIntegerTypes() const {\n for (unsigned i = 0, e = TypeVec.size(); i != e; ++i)\n if (isInteger(TypeVec[i]))\n return true;\n return false;\n}", "label": 0, "cwe": null, "length": 47 }, { "index": 19761, "code": "outgrin(node *root, node *outgrnode)\n{ /* checks if outgroup node is a child of root */\n node *p;\n\n p = root->next;\n while (p != root) {\n if (p->back == outgrnode)\n return true;\n p = p->next;\n }\n return false;\n}", "label": 0, "cwe": null, "length": 76 }, { "index": 200282, "code": "wrong_exception_type(PyObject *exc)\n{\n PyObject *type = PyObject_GetAttrString(exc, \"__class__\");\n if (type != NULL) {\n PyObject *name = PyObject_GetAttrString(type, \"__name__\");\n Py_DECREF(type);\n if (name != NULL) {\n PyObject *string = PyObject_Str(name);\n Py_DECREF(name);\n if (string != NULL) {\n PyErr_Format(PyExc_TypeError,\n \"don't know how to handle %.400s in error callback\",\n PyString_AS_STRING(string));\n Py_DECREF(string);\n }\n }\n }\n}", "label": 0, "cwe": null, "length": 124 }, { "index": 856343, "code": "CreateNPCFactions()\n{\n\tFaction *f;\n\tAString *temp;\n\tif(Globals->CITY_MONSTERS_EXIST) {\n\t\tf = new Faction(factionseq++);\n\t\tguardfaction = f->num;\n\t\ttemp = new AString(\"The Guardsmen\");\n\t\tf->SetName(temp);\n\t\tf->SetNPC();\n\t\tf->lastorders = 0;\n\t\tfactions.Add(f);\n\t} else\n\t\tguardfaction = 0;\n\t// Only create the monster faction if wandering monsters or lair\n\t// monsters exist.\n\tif(Globals->LAIR_MONSTERS_EXIST || Globals->WANDERING_MONSTERS_EXIST) {\n\t\tf = new Faction(factionseq++);\n\t\tmonfaction = f->num;\n\t\ttemp = new AString(\"Creatures\");\n\t\tf->SetName(temp);\n\t\tf->SetNPC();\n\t\tf->lastorders = 0;\n\t\tfactions.Add(f);\n\t} else\n\t\tmonfaction = 0;\n}", "label": 0, "cwe": null, "length": 206 }, { "index": 651200, "code": "locked_process_and_cache_put_action(int f, void *context) {\n\tLocked_process_and_cache_put_action_info& info=\n\t\t*static_cast(context);\n\n\tconst String* body_from_disk=info.scope->body_from_disk;\n\t// body->process \n\tTry_catch_result result=try_catch(*info.r, \n\t\tprocess_cache_body_code, info.body_code,\n\t\tinfo.catch_code, body_from_disk!=0 /*we have something old=we can handle=recover later*/);\n\n\tif(result.exception_should_be_handled) {\n\t\tif(*result.exception_should_be_handled==CACHE_EXCEPTION_HANDLED_CACHE_NAME) {\n\t\t\tassert(body_from_disk);\n\t\t\tinfo.processed_code=body_from_disk;\n\t\t} else\n\t\t\tthrow Exception(PARSER_RUNTIME,\n\t\t\t\tresult.exception_should_be_handled,\n\t\t\t\t\"$\"EXCEPTION_VAR_NAME\".\"EXCEPTION_HANDLED_PART_NAME\" value must be \"\n\t\t\t\t\"either boolean or string '\"CACHE_EXCEPTION_HANDLED_CACHE_NAME\"'\");\n\t} else\n\t\tinfo.processed_code=&result.processed_code.as_string();\n\n\t// expiration time not spoiled by ^cache(0) or something?\n\tif(info.scope->expires > time(0)) {\n\t\t// string -serialize> buffer\n\t\tString::Cm serialized=info.processed_code->serialize(\n\t\t\tsizeof(Data_string_serialized_prolog));\n\t\tData_string_serialized_prolog& prolog=\n\t\t\t*reinterpret_cast(serialized.str);\n\t\tprolog.version=DATA_STRING_SERIALIZED_VERSION;\n\t\tprolog.expires=info.scope->expires;\n\t\t\n\t\t// buffer -write> file\n\t\twrite(f, serialized.str, serialized.length);\n\t} else // expired!\n\t\tinfo.scope->expires=0; // flag it so that could be easily checked by caller\n}", "label": 0, "cwe": null, "length": 381 }, { "index": 18946, "code": "conv_get_locale_charset_no_utf8(void)\n{\n\tstatic CharSet cur_charset = -1;\n\tconst gchar *cur_locale;\n\tconst gchar *p;\n\tgchar *tmp;\n\tgint i;\n\n\tif (prefs_common.broken_are_utf8)\n\t\treturn conv_get_locale_charset();\n\n\tif (cur_charset != -1)\n\t\treturn cur_charset;\n\n\tcur_locale = conv_get_current_locale();\n\tif (!cur_locale) {\n\t\tcur_charset = C_US_ASCII;\n\t\treturn cur_charset;\n\t}\n\n\tif (strcasestr(cur_locale, \"UTF-8\")) {\n\t\ttmp = g_strdup(cur_locale);\n\t\t*(strcasestr(tmp, \".UTF-8\")) = '\\0';\n\t\tcur_locale = tmp;\n\t}\n\n\tif ((p = strcasestr(cur_locale, \"@euro\")) && p[5] == '\\0') {\n\t\tcur_charset = C_ISO_8859_15;\n\t\treturn cur_charset;\n\t}\n\n\tfor (i = 0; i < sizeof(locale_table) / sizeof(locale_table[0]); i++) {\n\t\tconst gchar *p;\n\n\t\t/* \"ja_JP.EUC\" matches with \"ja_JP.eucJP\", \"ja_JP.EUC\" and\n\t\t \"ja_JP\". \"ja_JP\" matches with \"ja_JP.xxxx\" and \"ja\" */\n\t\tif (!g_ascii_strncasecmp(cur_locale, locale_table[i].locale,\n\t\t\t\t strlen(locale_table[i].locale))) {\n\t\t\tcur_charset = locale_table[i].charset;\n\t\t\treturn cur_charset;\n\t\t} else if ((p = strchr(locale_table[i].locale, '_')) &&\n\t\t\t !strchr(p + 1, '.')) {\n\t\t\tif (strlen(cur_locale) == 2 &&\n\t\t\t !g_ascii_strncasecmp(cur_locale, locale_table[i].locale, 2)) {\n\t\t\t\tcur_charset = locale_table[i].charset;\n\t\t\t\treturn cur_charset;\n\t\t\t}\n\t\t}\n\t}\n\n\tcur_charset = C_AUTO;\n\treturn cur_charset;\n}", "label": 0, "cwe": null, "length": 409 }, { "index": 328882, "code": "gt_clipboard_set_text (GtkClipboard *clipboard, char *format, const gchar *text, gint len)\n{\n GtkTargetList *list;\n GList *l;\n GtkTargetEntry *targets;\n gint n_targets, i;\n\n list = gtk_target_list_new (NULL, 0);\n if (format)\n \tgtk_target_list_add (list, gdk_atom_intern(format, false), 0, 0);\n gtk_target_list_add_text_targets (list, 0);\n\n n_targets = g_list_length(list->list);\n targets = g_new0 (GtkTargetEntry, n_targets);\n for (l = list->list, i = 0; l; l = l->next, i++)\n {\n GtkTargetPair *pair = (GtkTargetPair *)l->data;\n targets[i].target = gdk_atom_name (pair->target);\n }\n \n if (len < 0)\n len = strlen (text);\n \n gtk_clipboard_set_with_data (clipboard, \n\t\t\t targets, n_targets,\n\t\t\t cb_get_text, cb_clear_text,\n\t\t\t g_strndup (text, len));\n gtk_clipboard_set_can_store (clipboard, NULL, 0);\n\n for (i = 0; i < n_targets; i++)\n g_free (targets[i].target);\n g_free (targets);\n gtk_target_list_unref (list);\n}", "label": 0, "cwe": null, "length": 295 }, { "index": 834996, "code": "x509_get_sig( unsigned char **p,\n const unsigned char *end,\n x509_buf *sig )\n{\n int ret;\n size_t len;\n\n if( ( end - *p ) < 1 )\n return( POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE +\n POLARSSL_ERR_ASN1_OUT_OF_DATA );\n\n sig->tag = **p;\n\n if( ( ret = asn1_get_tag( p, end, &len, ASN1_BIT_STRING ) ) != 0 )\n return( POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE + ret );\n\n\n if( --len < 1 || *(*p)++ != 0 )\n return( POLARSSL_ERR_X509_CERT_INVALID_SIGNATURE );\n\n sig->len = len;\n sig->p = *p;\n\n *p += len;\n\n return( 0 );\n}", "label": 0, "cwe": null, "length": 182 }, { "index": 43176, "code": "gf_sg_proto_new(GF_SceneGraph *inScene, u32 ProtoID, char *name, Bool unregistered)\n{\n\tGF_Proto *tmp;\n\tif (!inScene) return NULL;\n\n\t/*make sure we don't define a proto already defined in this scope*/\n\tif (!unregistered) {\n\t\ttmp = gf_sg_find_proto(inScene, ProtoID, name);\n\t\tif (tmp) return NULL;\n\t}\n\n\tGF_SAFEALLOC(tmp, GF_Proto)\n\tif (!tmp) return NULL;\n\n\ttmp->proto_fields = gf_list_new();\n\ttmp->node_code = gf_list_new();\n\ttmp->parent_graph = inScene;\n\ttmp->sub_graph = gf_sg_new_subscene(inScene);\n\ttmp->instances = gf_list_new();\n\n\tif (name) \n\t\ttmp->Name = gf_strdup(name);\n\telse\n\t\ttmp->Name = gf_strdup(\"Unnamed Proto\");\n\ttmp->ID = ProtoID;\n\tif (!unregistered) {\n\t\tgf_list_add(inScene->protos, tmp);\n\t} else {\n\t\tgf_list_add(inScene->unregistered_protos, tmp);\n\t}\n\treturn tmp;\n}", "label": 0, "cwe": null, "length": 232 }, { "index": 335949, "code": "removeAllEffects(void)\n {\n // Iterate over effects to remove controllers\n EffectMap::iterator i, iend;\n iend = mEffects.end();\n for (i = mEffects.begin(); i != iend; ++i)\n {\n if (i->second.controller)\n {\n ControllerManager::getSingleton().destroyController(i->second.controller);\n }\n }\n\n mEffects.clear();\n }", "label": 0, "cwe": null, "length": 88 }, { "index": 756105, "code": "calculateDiamondPoint(MapField* a, MapField* b, MapField* c, MapField* d) {\n int x = 0;\n int y = 0;\n double xd = (b->getx() - a->getx())/2;\n double yd = (d->gety() - a->gety())/2;\n x = static_cast(xd) + a->getx();\n y = static_cast(yd) + a->gety();\n MapField* e = map.getField(x, y);\n if(placeFuel) {\n e->temp3 = calculateDiamondValueFuel(a, b, c, d);\n setFieldValueFuel(e);\n \n }\n if(placeMaterial) {\n e->temp4 = calculateDiamondValueMaterial(a, b, c, d);\n setFieldValueMaterial(e);\n }\n return e;\n}", "label": 0, "cwe": null, "length": 191 }, { "index": 878163, "code": "read_bit()\n{\n\tbool ret = (*ptr&(128>>usedBits));\n\tif ( ++usedBits == 8 ) advanceToNextByte();\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 34 }, { "index": 102872, "code": "gretl_quadrule_matrix_new (int n, int method, \n\t\t\t\t\t double a, double b,\n\t\t\t\t\t int *err)\n{\n gretl_matrix *m;\n\n if (method < QUAD_GHERMITE || method >= QUAD_INVALID) {\n\t*err = E_DATA;\n\treturn NULL;\n }\n\n if (n < 0) {\n\t*err = E_DATA;\n\treturn NULL;\n } else if (n == 0) {\n\treturn gretl_null_matrix_new();\n }\n\n m = gretl_zero_matrix_new(n, 2);\n\n if (m == NULL) {\n\t*err = E_ALLOC;\n } else {\n\tdouble *x = m->val;\n\tdouble *w = x + n;\n\n\t*err = gauss_quad_basic(n, method, x, w);\n\n\tif (!*err) {\n\t if (method == QUAD_LEGENDRE) {\n\t\tif (na(a) && na(b)) {\n\t\t ; /* default */\n\t\t} else if (a == -1.0 && b == 1.0) {\n\t\t ; /* default */\n\t\t} else {\n\t\t *err = legendre_scale(n, x, w, a, b);\n\t\t}\n\t } else if (method == QUAD_GHERMITE) {\n#if 1 /* FIXME: change this */\n\t\thermite_scale(n, x, w, 0.0, 1.0);\n#else\n\t\tif (!na(a) && !na(b)) {\n\t\t hermite_scale(n, x, w, a, b);\n\t\t}\n#endif\n\t }\n\t}\n }\n\n if (*err && m != NULL) {\n\tgretl_matrix_free(m);\n\tm = NULL;\n }\n\n return m;\n}", "label": 0, "cwe": null, "length": 369 }, { "index": 802114, "code": "HasQuestDropForPlayer(Player const* player) const\n{\n for (LootStoreItemList::const_iterator i = ExplicitlyChanced.begin(); i != ExplicitlyChanced.end(); ++i)\n if (player->HasQuestForItem(i->itemid))\n { return true; }\n for (LootStoreItemList::const_iterator i = EqualChanced.begin(); i != EqualChanced.end(); ++i)\n if (player->HasQuestForItem(i->itemid))\n { return true; }\n return false;\n}", "label": 0, "cwe": null, "length": 113 }, { "index": 689338, "code": "GdipCloneFontFamily (GpFontFamily *fontFamily, GpFontFamily **clonedFontFamily)\n{\n\tGpFontFamily *result;\n\n\tif (!fontFamily || !clonedFontFamily)\n\t\treturn InvalidParameter;\n\n\tgdip_createFontFamily (&result);\n\tif (!result)\n\t\treturn OutOfMemory;\n\n\tresult->height = fontFamily->height;\n\tresult->linespacing = fontFamily->linespacing;\n\tresult->celldescent = fontFamily->celldescent;\n\tresult->cellascent = fontFamily->cellascent;\n\n\tif (fontFamily->pattern) {\n\t\tresult->pattern = FcPatternDuplicate (fontFamily->pattern);\n\t\tresult->allocated = TRUE;\n\t}\n\n\t*clonedFontFamily = result;\n\treturn Ok;\n}", "label": 0, "cwe": null, "length": 160 }, { "index": 262935, "code": "artwork_prep(void)\r\n{\r\n\tstruct artwork_piece *piece;\r\n\r\n\t/* mark everything dirty */\r\n\tunderlay_invalid = screenrect;\r\n\toverlay_invalid = screenrect;\r\n\tbezel_invalid = screenrect;\r\n\r\n\t/* loop through all the pieces, generating the scaled bitmaps */\r\n\tfor (piece = artwork_list; piece; piece = piece->next)\r\n\t{\r\n\t\t/* scale to the artwork's intended dimensions */\r\n\t\tif (!scale_bitmap(piece, piece->bounds.max_x - piece->bounds.min_x + 1, piece->bounds.max_y - piece->bounds.min_y + 1))\r\n\t\t\treturn 1;\r\n\r\n\t\t/* trim the bitmap down if transparent */\r\n\t\ttrim_bitmap(piece);\r\n\r\n\t\t/* do we intersect the game rect? */\r\n\t\tpiece->intersects_game = 0;\r\n\t\tif (piece->bounds.max_x > gamerect.min_x && piece->bounds.min_x < gamerect.max_x &&\r\n\t\t\tpiece->bounds.max_y > gamerect.min_y && piece->bounds.min_y < gamerect.max_y)\r\n\t\t\tpiece->intersects_game = 1;\r\n\t}\r\n\treturn 0;\r\n}", "label": 0, "cwe": null, "length": 230 }, { "index": 496731, "code": "kernel_netlink_init(void)\n{\n\tunsigned long groups;\n\n\t/* Start with a netlink address lookup */\n\tnetlink_address_lookup();\n\n\t/*\n\t * Prepare netlink kernel broadcast channel\n\t * subscribtion. We subscribe to LINK and ADDR\n\t * netlink broadcast messages.\n\t */\n\tgroups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR | RTMGRP_IPV6_IFADDR;\n\tnetlink_socket(&nl_kernel, groups);\n\n\tif (nl_kernel.fd > 0) {\n\t\tlog_message(LOG_INFO, \"Registering Kernel netlink reflector\");\n\t\tnl_kernel.thread = thread_add_read(master, kernel_netlink, &nl_kernel, nl_kernel.fd,\n\t\t\t\t\t\t NETLINK_TIMER);\n\t} else\n\t\tlog_message(LOG_INFO, \"Error while registering Kernel netlink reflector channel\");\n\n\t/* Prepare netlink command channel. */\n\tnetlink_socket(&nl_cmd, 0);\n\tif (nl_cmd.fd > 0)\n\t\tlog_message(LOG_INFO, \"Registering Kernel netlink command channel\");\n\telse\n\t\tlog_message(LOG_INFO, \"Error while registering Kernel netlink cmd channel\");\n}", "label": 0, "cwe": null, "length": 229 }, { "index": 480306, "code": "AddPathNode( unsigned key, PathNode* root )\r\n{\r\n\tif ( hashTable[key] ) {\r\n\t\tPathNode* p = hashTable[key];\r\n\t\twhile( true ) {\r\n\t\t\tint dir = (root->state < p->state) ? 0 : 1;\r\n\t\t\tif ( p->child[dir] ) {\r\n\t\t\t\tp = p->child[dir];\r\n\t\t\t}\r\n\t\t\telse {\r\n\t\t\t\tp->child[dir] = root;\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\telse {\r\n\t\thashTable[key] = root;\r\n\t}\r\n}", "label": 0, "cwe": null, "length": 115 }, { "index": 583147, "code": "FileSize(char *path)\n#else\nint FileSize(path)\n char *path;\n#endif\n{\n char *npath;\n struct stat buf;\n\n /* expand environment variables */\n npath = (char *)ExpandMacro(path, NULL, NULL, 0, NULL, NULL);\n /* make sure the file exists */\n if( stat(npath, &buf) <0 ){\n free(npath);\n return(-1);\n }\n else{\n free(npath);\n return(buf.st_size);\n }\n}", "label": 0, "cwe": null, "length": 110 }, { "index": 788281, "code": "__cell_release(struct dm_bio_prison *prison,\n\t\t\t struct dm_bio_prison_cell *cell,\n\t\t\t struct bio_list *inmates)\n{\n\trb_erase(&cell->node, &prison->cells);\n\n\tif (inmates) {\n\t\tif (cell->holder)\n\t\t\tbio_list_add(inmates, cell->holder);\n\t\tbio_list_merge(inmates, &cell->bios);\n\t}\n}", "label": 0, "cwe": null, "length": 86 }, { "index": 451108, "code": "gzip_probe_format(CHAR16 *kname)\n{\n\tUINT8 buf[4];\n\tEFI_STATUS status;\n\tINTN ret = -1;\n\tUINTN size;\n\tfops_fd_t fd;\n\n\tstatus = fops_open(kname, &fd);\n\tif (EFI_ERROR(status)) return -1;\n\n\tsize = sizeof(buf);\n\tstatus = fops_read(fd, buf, &size);\n\n\tif (EFI_ERROR(status) || size != sizeof(buf)) goto error;\n\n\tret = gzip_probe(buf, sizeof(buf));\nerror:\n\tfops_close(fd);\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 113 }, { "index": 600277, "code": "run(void)\n{\n do {\n tdialogbox::run();\n } while ( !action );\n}", "label": 0, "cwe": null, "length": 24 }, { "index": 104477, "code": "NsWaitQueueShutdown(Ns_Time *toPtr)\n{\n TaskQueue *queuePtr, *nextPtr;\n int status;\n \n /*\n * Clear out list of any remaining task queues.\n */\n\n Ns_MutexLock(&lock);\n queuePtr = firstQueuePtr;\n firstQueuePtr = NULL;\n Ns_MutexUnlock(&lock);\n\n /*\n * Join all queues possible within total allowed time.\n */\n\n status = NS_OK;\n while (status == NS_OK && queuePtr != NULL) {\n\tnextPtr = queuePtr->nextPtr;\n\tNs_MutexLock(&queuePtr->lock);\n\twhile (status == NS_OK && !queuePtr->stopped) {\n\t status = Ns_CondTimedWait(&queuePtr->cond, &queuePtr->lock, toPtr);\n\t}\n\tNs_MutexUnlock(&queuePtr->lock);\n\tif (status == NS_OK) {\n\t JoinQueue(queuePtr);\n\t}\n\tqueuePtr = nextPtr;\n }\n if (status != NS_OK) {\n\tNs_Log(Warning, \"timeout waiting for event queue shutdown\");\n }\n}", "label": 0, "cwe": null, "length": 234 }, { "index": 75703, "code": "set_remainder( void const * const buf,\n const unsigned int size, const GP &xencoding )\n{\n gremainder.resize(size,1);\n if(size)\n memcpy(remainder,buf,size);\n encoding=xencoding;\n encodetype=XOTHER;\n}", "label": 0, "cwe": null, "length": 60 }, { "index": 838483, "code": "link_pblocks(Module_table* mhead)\n{\n int pnum;\n Block** pblocks;\n Block* bptr;\n Boolean have_pblock = FALSE;\n\n pnum = get_max_block_no(mhead->block_head) + 1;\n if ((pblocks = calloc(pnum, sizeof(Block*))) == NULL) {\n\tfatal(\"Can't alloc memory.\");\n }\n\n for (bptr = mhead->block_head; bptr != NULL; bptr = bptr->next) {\n\tif (bptr->kind == PBLOCK) {\n\t have_pblock = TRUE;\n\t pblocks[bptr->no] = bptr;\n\t}\n }\n\n if (have_pblock) {\n\tlink_pblock_in_blocks(mhead->block_head, pblocks, pnum);\n }\n\n free(pblocks);\n}", "label": 0, "cwe": null, "length": 181 }, { "index": 39801, "code": "snd_pcm_file_writei(snd_pcm_t *pcm, const void *buffer, snd_pcm_uframes_t size)\n{\n\tsnd_pcm_file_t *file = pcm->private_data;\n\tsnd_pcm_channel_area_t areas[pcm->channels];\n\tsnd_pcm_sframes_t n = snd_pcm_writei(file->gen.slave, buffer, size);\n\tif (n > 0) {\n\t\tsnd_pcm_areas_from_buf(pcm, areas, (void*) buffer);\n\t\tsnd_pcm_file_add_frames(pcm, areas, 0, n);\n\t}\n\treturn n;\n}", "label": 0, "cwe": null, "length": 121 }, { "index": 440910, "code": "dht_flush (call_frame_t *frame, xlator_t *this, fd_t *fd)\n{\n xlator_t *subvol = NULL;\n int op_errno = -1;\n dht_local_t *local = NULL;\n\n\n VALIDATE_OR_GOTO (frame, err);\n VALIDATE_OR_GOTO (this, err);\n VALIDATE_OR_GOTO (fd, err);\n\n local = dht_local_init (frame, NULL, fd, GF_FOP_FLUSH);\n if (!local) {\n op_errno = ENOMEM;\n goto err;\n }\n\n subvol = local->cached_subvol;\n if (!subvol) {\n gf_log (this->name, GF_LOG_DEBUG,\n \"no cached subvolume for fd=%p\", fd);\n op_errno = EINVAL;\n goto err;\n }\n\n local->call_cnt = 1;\n\n STACK_WIND (frame, dht_flush_cbk,\n subvol, subvol->fops->flush, fd);\n\n return 0;\n\nerr:\n op_errno = (op_errno == -1) ? errno : op_errno;\n DHT_STACK_UNWIND (flush, frame, -1, op_errno);\n\n return 0;\n}", "label": 0, "cwe": null, "length": 263 }, { "index": 121791, "code": "print_unload_info(struct seq_file *m, struct module *mod)\n{\n\tstruct module_use *use;\n\tint printed_something = 0;\n\n\tseq_printf(m, \" %i \", module_refcount(mod));\n\n\t/*\n\t * Always include a trailing , so userspace can differentiate\n\t * between this and the old multi-field proc format.\n\t */\n\tlist_for_each_entry(use, &mod->source_list, source_list) {\n\t\tprinted_something = 1;\n\t\tseq_printf(m, \"%s,\", use->source->name);\n\t}\n\n\tif (mod->init != NULL && mod->exit == NULL) {\n\t\tprinted_something = 1;\n\t\tseq_puts(m, \"[permanent],\");\n\t}\n\n\tif (!printed_something)\n\t\tseq_puts(m, \"-\");\n}", "label": 0, "cwe": null, "length": 163 }, { "index": 81709, "code": "print_gdbmi_async_record(gdbmi_async_record_ptr param)\n{\n int result;\n\n if (!param)\n return 0;\n\n result = print_token(param->token);\n if (result == -1)\n return -1;\n\n result = print_gdbmi_async_record_choice(param->async_record);\n if (result == -1)\n return -1;\n\n result = print_gdbmi_async_class(param->async_class);\n if (result == -1)\n return -1;\n\n result = print_gdbmi_result(param->result);\n if (result == -1)\n return -1;\n\n return 0;\n}", "label": 0, "cwe": null, "length": 138 }, { "index": 108620, "code": "readTopLevelFolders(mail::callback::folderList &callback1,\n\t\t\t\t mail::callback &callback2)\n{\n\tvector folders;\n\n\tfolders.push_back(&inbox);\n\n\tcallback1.success(folders);\n\tcallback2.success(\"OK\");\n}", "label": 0, "cwe": null, "length": 52 }, { "index": 528718, "code": "ompi_grequest_invoke_query(ompi_request_t *request,\n ompi_status_public_t *status)\n{\n int rc = OMPI_SUCCESS;\n ompi_grequest_t *g = (ompi_grequest_t*) request;\n\n /* MPI-2:8.2 does not say what to do with the return value from\n the query function (i.e., the int return value from the C\n function or the ierr argument from the Fortran function).\n Making the command decision here to ignore it. If the handler\n wants to pass an error back, it should set it in the MPI_ERROR\n field in the status (which is always kept, regardless if the\n top-level function was invoked with MPI_STATUS[ES]_IGNORE or\n not). */\n if (NULL != g->greq_query.c_query) {\n if (g->greq_funcs_are_c) {\n rc = g->greq_query.c_query(g->greq_state, status);\n } else {\n MPI_Fint ierr;\n MPI_Fint fstatus[sizeof(MPI_Status) / sizeof(int)];\n g->greq_query.f_query((MPI_Aint*)g->greq_state, fstatus, &ierr);\n MPI_Status_f2c(fstatus, status);\n rc = OMPI_FINT_2_INT(ierr);\n }\n }\n\n return rc;\n}", "label": 0, "cwe": null, "length": 294 }, { "index": 85369, "code": "buffer_to_contiguous(char *mem, Py_buffer *src, char order)\n{\n Py_buffer dest;\n Py_ssize_t *strides;\n int ret;\n\n assert(src->ndim >= 1);\n assert(src->shape != NULL);\n assert(src->strides != NULL);\n\n strides = PyMem_Malloc(src->ndim * (sizeof *src->strides));\n if (strides == NULL) {\n PyErr_NoMemory();\n return -1;\n }\n\n /* initialize dest */\n dest = *src;\n dest.buf = mem;\n /* shape is constant and shared: the logical representation of the\n array is unaltered. */\n\n /* The physical representation determined by strides (and possibly\n suboffsets) may change. */\n dest.strides = strides;\n if (order == 'C' || order == 'A') {\n init_strides_from_shape(&dest);\n }\n else {\n init_fortran_strides_from_shape(&dest);\n }\n\n dest.suboffsets = NULL;\n\n ret = copy_buffer(&dest, src);\n\n PyMem_Free(strides);\n return ret;\n}", "label": 0, "cwe": null, "length": 244 }, { "index": 99693, "code": "GetDfltLogLevelForDevice( const string& sLogDevice )\n{\n if( sLogDevice == STR_LOGDEV_CONSOLE )\n return CFG_DFLT_LOGLEVEL_CONSOLE;\n\n if( sLogDevice == STR_LOGDEV_STDERR )\n return CFG_DFLT_LOGLEVEL_STDERR;\n\n if( sLogDevice == STR_LOGDEV_FILE )\n return CFG_DFLT_LOGLEVEL_FILE;\n\n if( sLogDevice == STR_LOGDEV_SYSLOG )\n return CFG_DFLT_LOGLEVEL_SYSLOG;\n\n // Should assert(false) - here -\n return CFG_DFLT_LOGLEVEL;\n}", "label": 0, "cwe": null, "length": 122 }, { "index": 652225, "code": "trace_begin()\n{\n std::ostream &o = out(dbg::tracing, m_src);\n o << indent(tracing);\n indent_depth++;\n o << TRACE_IN;\n if (m_name)\n {\n o << m_name;\n }\n else\n {\n print_pos_short(o, m_pos);\n }\n if (m_src && strcmp(m_src, \"\"))\n {\n o << \" (for \\\"\" << m_src << \"\\\")\";\n }\n o << std::endl;\n\n m_triggered = true;\n}", "label": 0, "cwe": null, "length": 114 }, { "index": 34106, "code": "_g_utf8_strstr (const char *haystack,\n\t\tconst char *needle)\n{\n\tconst char *s;\n\tgsize i;\n\tgsize haystack_len = g_utf8_strlen (haystack, -1);\n\tgsize needle_len = g_utf8_strlen (needle, -1);\n\tint needle_size = strlen (needle);\n\n\ts = haystack;\n\tfor (i = 0; i <= haystack_len - needle_len; i++) {\n\t\tif (strncmp (s, needle, needle_size) == 0)\n\t\t\treturn s;\n\t\ts = g_utf8_next_char(s);\n\t}\n\n\treturn NULL;\n}", "label": 0, "cwe": null, "length": 130 }, { "index": 200482, "code": "OnListBoxSearchDoubleClick(wxCommandEvent& event)\n{\n StatementHistory::Position item =\n (StatementHistory::Position)event.GetClientData();\n if ((int)item < 0)\n return;\n sqlM = historyM->get(item);\n EndModal(wxID_OK);\n}", "label": 0, "cwe": null, "length": 60 }, { "index": 369782, "code": "gst_video_balance_class_init (GstVideoBalanceClass * klass)\n{\n GObjectClass *gobject_class = (GObjectClass *) klass;\n GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;\n\n GST_DEBUG_CATEGORY_INIT (videobalance_debug, \"videobalance\", 0,\n \"videobalance\");\n\n gobject_class->finalize = gst_video_balance_finalize;\n gobject_class->set_property = gst_video_balance_set_property;\n gobject_class->get_property = gst_video_balance_get_property;\n\n g_object_class_install_property (gobject_class, PROP_CONTRAST,\n g_param_spec_double (\"contrast\", \"Contrast\", \"contrast\",\n 0.0, 2.0, DEFAULT_PROP_CONTRAST,\n GST_PARAM_CONTROLLABLE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));\n g_object_class_install_property (gobject_class, PROP_BRIGHTNESS,\n g_param_spec_double (\"brightness\", \"Brightness\", \"brightness\", -1.0, 1.0,\n DEFAULT_PROP_BRIGHTNESS,\n GST_PARAM_CONTROLLABLE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));\n g_object_class_install_property (gobject_class, PROP_HUE,\n g_param_spec_double (\"hue\", \"Hue\", \"hue\", -1.0, 1.0, DEFAULT_PROP_HUE,\n GST_PARAM_CONTROLLABLE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));\n g_object_class_install_property (gobject_class, PROP_SATURATION,\n g_param_spec_double (\"saturation\", \"Saturation\", \"saturation\", 0.0, 2.0,\n DEFAULT_PROP_SATURATION,\n GST_PARAM_CONTROLLABLE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));\n\n trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_video_balance_set_caps);\n trans_class->transform_ip =\n GST_DEBUG_FUNCPTR (gst_video_balance_transform_ip);\n trans_class->before_transform =\n GST_DEBUG_FUNCPTR (gst_video_balance_before_transform);\n}", "label": 0, "cwe": null, "length": 436 }, { "index": 439369, "code": "dropTable(const std::string &tableName)\n{\n\tMRPT_START\n\n\titerator it = m_tables.find(tableName);\n\tif (it==m_tables.end())\n\t\tTHROW_EXCEPTION_CUSTOM_MSG1(\"Table '%s' was not found\",tableName.c_str())\n\n\tm_tables.erase(it);\n\n\n\tMRPT_END\n}", "label": 0, "cwe": null, "length": 65 }, { "index": 545288, "code": "__repmgr_check_master_listener(env)\n\tENV *env;\n{\n\tDB_REP *db_rep;\n\tREP *rep;\n\tREPMGR_SITE *master;\n\tdb_timespec t;\n\tu_int32_t flags;\n\tint ret;\n\n\tdb_rep = env->rep_handle;\n\trep = db_rep->region;\n\tret = 0;\n\n\t/*\n\t * We only check for a master listener if m_listener_chk is set.\n\t * The field is only set when __repmgr_bust_connection() previously\n\t * detected the loss of our connection to the master listener.\n\t * If rep->master_id is invalid, wait until it is ready to check.\n\t */\n\tif (!FLD_ISSET((db_rep)->region->config, REP_C_AUTOTAKEOVER) ||\n\t !timespecisset(&db_rep->m_listener_chk) ||\n\t !IS_VALID_EID(rep->master_id))\n\t\treturn (0);\n\n\t__os_gettime(env, &t, 1);\n\tif (timespeccmp(&t, &db_rep->m_listener_chk, >=)) {\n\t\tmaster = SITE_FROM_EID(db_rep->region->master_id);\n\t\tif (master->ref.conn.out == NULL &&\n\t\t master->ref.conn.in == NULL) {\n\t\t\tflags = ELECT_F_EVENT_NOTIFY;\n\t\t\tif (FLD_ISSET(db_rep->region->config, REP_C_ELECTIONS))\n\t\t\t\tLF_SET(ELECT_F_IMMED | ELECT_F_FAST);\n\t\t\telse\n\t\t\t\tRPRINT(env, (env, DB_VERB_REPMGR_MISC,\n\t\t\t\t \"Master failure, but no elections\"));\n\n\t\t\tret = __repmgr_init_election(env, flags);\n\t\t}\n\t\t/*\n\t\t * If the delay has expired reset m_listener_chk. We reset\n\t\t * it whether or not the master listener process comes back\n\t\t * so that we will not continue checking for a master listener\n\t\t * indefinitely.\n\t\t */\n\t\ttimespecclear(&db_rep->m_listener_chk);\n\t}\n\treturn (ret);\n}", "label": 0, "cwe": null, "length": 419 }, { "index": 540614, "code": "lua_lessthan(lua_State *L, int idx1, int idx2)\n{\n cTValue *o1 = index2adr(L, idx1);\n cTValue *o2 = index2adr(L, idx2);\n if (o1 == niltv(L) || o2 == niltv(L)) {\n return 0;\n } else if (tvisint(o1) && tvisint(o2)) {\n return intV(o1) < intV(o2);\n } else if (tvisnumber(o1) && tvisnumber(o2)) {\n return numberVnum(o1) < numberVnum(o2);\n } else {\n TValue *base = lj_meta_comp(L, o1, o2, 0);\n if ((uintptr_t)base <= 1) {\n return (int)(uintptr_t)base;\n } else {\n L->top = base+2;\n lj_vm_call(L, base, 1+1);\n L->top -= 2;\n return tvistruecond(L->top+1);\n }\n }\n}", "label": 0, "cwe": null, "length": 238 }, { "index": 957459, "code": "_sfree(int d, void *ptr)\n{\n if (_dma_mem_size) {\n return mpool_free(_dma_pool, ptr);\n }\n if (_pgfree(ptr) < 0) {\n kfree(ptr);\n }\n}", "label": 0, "cwe": null, "length": 52 }, { "index": 28990, "code": "value_take_test_object (GValue* value, gpointer v_object) {\n\tTestObject* old;\n#line 5 \"/home/treitter/collabora/folks/tests/folks/object-cache.vala\"\n\tg_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, TYPE_TEST_OBJECT));\n#line 5 \"/home/treitter/collabora/folks/tests/folks/object-cache.vala\"\n\told = value->data[0].v_pointer;\n#line 5 \"/home/treitter/collabora/folks/tests/folks/object-cache.vala\"\n\tif (v_object) {\n#line 5 \"/home/treitter/collabora/folks/tests/folks/object-cache.vala\"\n\t\tg_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, TYPE_TEST_OBJECT));\n#line 5 \"/home/treitter/collabora/folks/tests/folks/object-cache.vala\"\n\t\tg_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));\n#line 5 \"/home/treitter/collabora/folks/tests/folks/object-cache.vala\"\n\t\tvalue->data[0].v_pointer = v_object;\n#line 591 \"object-cache.c\"\n\t} else {\n#line 5 \"/home/treitter/collabora/folks/tests/folks/object-cache.vala\"\n\t\tvalue->data[0].v_pointer = NULL;\n#line 595 \"object-cache.c\"\n\t}\n#line 5 \"/home/treitter/collabora/folks/tests/folks/object-cache.vala\"\n\tif (old) {\n#line 5 \"/home/treitter/collabora/folks/tests/folks/object-cache.vala\"\n\t\ttest_object_unref (old);\n#line 601 \"object-cache.c\"\n\t}\n}", "label": 1, "cwe": "CWE-476", "length": 386 }, { "index": 750989, "code": "ProdListScl (\n Obj listL,\n Obj listR )\n{\n Obj listP; /* product, result */\n Obj elmP; /* one element of product list */\n Obj elmL; /* one element of left operand */\n Int len; /* length */\n Int i; /* loop variable */\n\n /* make the result list */\n len = LEN_LIST( listL );\n listP = NEW_PLIST( (IS_MUTABLE_OBJ(listL) || IS_MUTABLE_OBJ(listR))\n ? T_PLIST :T_PLIST+IMMUTABLE, len );\n SET_LEN_PLIST( listP, len );\n\n /* loop over the entries and multiply */\n for ( i = 1; i <= len; i++ ) {\n elmL = ELMV0_LIST( listL, i );\n if (elmL) {\n elmP = PROD( elmL, listR );\n SET_ELM_PLIST( listP, i, elmP );\n CHANGED_BAG( listP );\n }\n }\n\n if (len == 0)\n SET_FILT_LIST( listP, FN_IS_EMPTY );\n else if (IS_PLIST( listL ))\n {\n if (HAS_FILT_LIST(listL, FN_IS_DENSE))\n SET_FILT_LIST( listP, FN_IS_DENSE );\n else if (HAS_FILT_LIST(listL, FN_IS_NDENSE))\n SET_FILT_LIST( listP, FN_IS_NDENSE );\n }\n /* return the result */\n return listP;\n}", "label": 0, "cwe": null, "length": 351 }, { "index": 452981, "code": "cpp_init_builtins (cpp_reader *pfile, int hosted)\n{\n const struct builtin *b;\n size_t n = ARRAY_SIZE (builtin_array);\n\n if (CPP_OPTION (pfile, traditional))\n n -= 2;\n\n for(b = builtin_array; b < builtin_array + n; b++)\n {\n cpp_hashnode *hp = cpp_lookup (pfile, b->name, b->len);\n hp->type = NT_MACRO;\n hp->flags |= NODE_BUILTIN | NODE_WARN;\n hp->value.builtin = b->value;\n }\n\n if (CPP_OPTION (pfile, cplusplus))\n _cpp_define_builtin (pfile, \"__cplusplus 1\");\n else if (CPP_OPTION (pfile, lang) == CLK_ASM)\n _cpp_define_builtin (pfile, \"__ASSEMBLER__ 1\");\n else if (CPP_OPTION (pfile, lang) == CLK_STDC94)\n _cpp_define_builtin (pfile, \"__STDC_VERSION__ 199409L\");\n else if (CPP_OPTION (pfile, c99))\n _cpp_define_builtin (pfile, \"__STDC_VERSION__ 199901L\");\n\n if (hosted)\n _cpp_define_builtin (pfile, \"__STDC_HOSTED__ 1\");\n else\n _cpp_define_builtin (pfile, \"__STDC_HOSTED__ 0\");\n\n if (CPP_OPTION (pfile, objc))\n _cpp_define_builtin (pfile, \"__OBJC__ 1\");\n}", "label": 0, "cwe": null, "length": 325 }, { "index": 117306, "code": "PrintArraySize(struct Type * arrayType, char * string)\n{\nchar size[256];\n\nsize[0] = '\\0';\nstrcat(size, \"[\");\nif(arrayType->enumClass)\nstrcat(size, arrayType->enumClass->string);\nelse if(arrayType->arraySizeExp)\nPrintExpression(arrayType->arraySizeExp, size);\nstrcat(size, \"]\");\nstrcat(string, size);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 85 }, { "index": 265730, "code": "outputLineDirective (const TSourceLoc& line)\n{\n\tif (line.line <= 0 || !current)\n\t\treturn;\n\tif (SafeEquals(line.file, m_LastLineOutput.file) && std::abs(line.line - m_LastLineOutput.line) < 4) // don't sprinkle too many #line directives ;)\n\t\treturn;\n\tstd::stringstream& out = current->getActiveOutput();\n\tout << '\\n';\n\tcurrent->indent(); // without this we could dry the code out further to put the preceeding CRLF in the shared function\n\tOutputLineDirective(out, line);\n\tm_LastLineOutput = line;\n}", "label": 0, "cwe": null, "length": 130 }, { "index": 796973, "code": "glade_text_button_key_press_event (GtkEntry *entry,\n\t\t\t\t GdkEventKey *key_event,\n\t\t\t\t GladeTextButton *button)\n{\n\tif (key_event->keyval == GDK_Escape)\n\t{\n\t\tg_object_get (entry,\n\t\t\t \"editing-canceled\", TRUE,\n\t\t\t NULL);\n\t\tgtk_cell_editable_editing_done (GTK_CELL_EDITABLE (button));\n\t\tgtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (button));\n\t\t\n\t\treturn TRUE;\n\t}\n\n\t/* override focus */\n\tif (key_event->keyval == GDK_Up || key_event->keyval == GDK_Down)\n\t{\n\t\tgtk_cell_editable_editing_done (GTK_CELL_EDITABLE (button));\n\t\tgtk_cell_editable_remove_widget (GTK_CELL_EDITABLE (button));\t\t\n\t\treturn TRUE;\n\t}\t\n\treturn FALSE;\n}", "label": 0, "cwe": null, "length": 173 }, { "index": 260457, "code": "find_older_paragraph(OUTPUTHISTORY *h, z_ucs *index)\n{\n bool has_wrapped;\n\n if ( (h == NULL) || (h->z_history_buffer_size == 0) )\n return NULL;\n\n has_wrapped = (index == h->z_history_buffer_front_index ? false : true);\n\n while (*index != '\\n')\n if ((index = decrement_buffer_pointer(h, index, &has_wrapped)) == NULL)\n return NULL;\n\n return index;\n}", "label": 0, "cwe": null, "length": 107 }, { "index": 411116, "code": "enumerator_with_object_i(VALUE val, VALUE memo, int argc, VALUE *argv)\n{\n if (argc <= 1)\n\treturn rb_yield_values(2, val, memo);\n\n return rb_yield_values(2, rb_ary_new4(argc, argv), memo);\n}", "label": 0, "cwe": null, "length": 57 }, { "index": 23113, "code": "txtstore(int new_entry,char * txtstr)\n\n\n/*!\nReturn Value: -1 = Error, # = Text ID\n\n\nParameters:\n\nType Name IO Description\n---- ---- -- ----------- */\n#ifdef DOC\nint new_entry ;/* I New entry flag.\n 1 = Start new entry\n 0 = Continue previous entry */\nchar * txtstr ;/* I String to write. */\n#endif\n\n\n/*!\nDescription:\n\n`txtstore` stores a text string in the text table and returns an\nID for it. If the `new_entry` flag is set a new ID is created and\nreturned, otherwise `txtstr` is appended to the previous entry.\n\n!*/\n\n#undef TITLE\n#define TITLE \"txtstore\"\n\n{\n int index;\n\n /* Check for file open */\n if (fd == NULL)\n {\n /* Text storage file not open */\n COMERR_SET(ERR_TXTUT_FNOTOPEN);\n return(-1);\n }\n\n /* Check for string beginning with internal delimeter */\n if ( !strncmp(txtstr, \".!#ID#\",6))\n {\n /* String begins with internal delimeter string */\n COMERR_SET(ERR_TXTUT_DELIM);\n return(-1);\n }\n\n /* Check for new entry */\n if (new_entry)\n {\n Lastid++;\n fprintf(fd,\".!#ID#%d\\n\",Lastid);\n }\n\n /* Check for multiple \\n's */\n index = strlen(txtstr) - 1;\n if (txtstr[index] == '\\n') txtstr[index] = '\\0';\n\n /* Write text string */\n fprintf(fd,\"%s\\n\",txtstr);\n\n /* Return */\n return(Lastid);\n}", "label": 0, "cwe": null, "length": 369 }, { "index": 359965, "code": "xsetfont(xdisplay * d, CONST char *font_name)\n{\n\n if (d->font_struct != (XFontStruct *) NULL) {\n\tXFreeFont(d->display, d->font_struct);\n }\n d->font_struct = XLoadQueryFont(d->display, font_name);\n XSetFont(d->display, d->gc, d->font_struct->fid);\n if (!d->font_struct) {\n\tfprintf(stderr, \"could not load font: %s\\n\", font_name);\n\texit(-1);\n }\n return (d->font_struct->max_bounds.ascent +\n\t d->font_struct->max_bounds.descent);\n}", "label": 0, "cwe": null, "length": 137 }, { "index": 16719, "code": "file_read(struct archive *a, void *client_data, const void **buff)\n{\n\tstruct read_file_data *mine = (struct read_file_data *)client_data;\n\tssize_t bytes_read;\n\n\t/* TODO: If a recent lseek() operation has left us\n\t * mis-aligned, read and return a short block to try to get\n\t * us back in alignment. */\n\n\t/* TODO: Someday, try mmap() here; if that succeeds, give\n\t * the entire file to libarchive as a single block. That\n\t * could be a lot faster than block-by-block manual I/O. */\n\n\t/* TODO: We might be able to improve performance on pipes and\n\t * sockets by setting non-blocking I/O and just accepting\n\t * whatever we get here instead of waiting for a full block\n\t * worth of data. */\n\n\t*buff = mine->buffer;\n\tfor (;;) {\n\t\tbytes_read = read(mine->fd, mine->buffer, mine->block_size);\n\t\tif (bytes_read < 0) {\n\t\t\tif (errno == EINTR)\n\t\t\t\tcontinue;\n\t\t\telse if (mine->filename_type == FNT_STDIN)\n\t\t\t\tarchive_set_error(a, errno,\n\t\t\t\t \"Error reading stdin\");\n\t\t\telse if (mine->filename_type == FNT_MBS)\n\t\t\t\tarchive_set_error(a, errno,\n\t\t\t\t \"Error reading '%s'\", mine->filename.m);\n\t\t\telse\n\t\t\t\tarchive_set_error(a, errno,\n\t\t\t\t \"Error reading '%S'\", mine->filename.w);\n\t\t}\n\t\treturn (bytes_read);\n\t}\n}", "label": 1, "cwe": [ "CWE-120", "CWE-other" ], "length": 330 }, { "index": 300129, "code": "igb_write_uc_addr_list(struct net_device *netdev)\n{\n\tstruct igb_adapter *adapter = netdev_priv(netdev);\n\tstruct e1000_hw *hw = &adapter->hw;\n\tunsigned int vfn = adapter->vfs_allocated_count;\n\tunsigned int rar_entries = hw->mac.rar_entry_count - (vfn + 1);\n\tint count = 0;\n\n\t/* return ENOMEM indicating insufficient memory for addresses */\n\tif (netdev_uc_count(netdev) > rar_entries)\n\t\treturn -ENOMEM;\n\n\tif (!netdev_uc_empty(netdev) && rar_entries) {\n\t\tstruct netdev_hw_addr *ha;\n\n\t\tnetdev_for_each_uc_addr(ha, netdev) {\n\t\t\tif (!rar_entries)\n\t\t\t\tbreak;\n\t\t\tigb_rar_set_qsel(adapter, ha->addr,\n\t\t\t\t\t rar_entries--,\n\t\t\t\t\t vfn);\n\t\t\tcount++;\n\t\t}\n\t}\n\t/* write the addresses in reverse order to avoid write combining */\n\tfor (; rar_entries > 0 ; rar_entries--) {\n\t\twr32(E1000_RAH(rar_entries), 0);\n\t\twr32(E1000_RAL(rar_entries), 0);\n\t}\n\twrfl();\n\n\treturn count;\n}", "label": 0, "cwe": null, "length": 251 }, { "index": 390904, "code": "mx51_ecspi_reset(struct spi_imx_data *spi_imx)\n{\n\t/* drain receive buffer */\n\twhile (mx51_ecspi_rx_available(spi_imx))\n\t\treadl(spi_imx->base + MXC_CSPIRXDATA);\n}", "label": 0, "cwe": null, "length": 54 }, { "index": 20319, "code": "re_compile_pattern (pattern, length, bufp)\n const char *pattern;\n size_t length;\n struct re_pattern_buffer *bufp;\n{\n reg_errcode_t ret;\n\n /* GNU code is written to assume at least RE_NREGS registers will be set\n (and at least one extra will be -1). */\n bufp->regs_allocated = REGS_UNALLOCATED;\n\n /* And GNU code determines whether or not to get register information\n by passing null for the REGS argument to re_match, etc., not by\n setting no_sub. */\n bufp->no_sub = 0;\n\n /* Match anchors at newline. */\n bufp->newline_anchor = 1;\n\n ret = regex_compile (pattern, length, re_syntax_options, bufp);\n\n if (!ret)\n return NULL;\n return gettext (re_error_msgid[(int) ret]);\n}", "label": 0, "cwe": null, "length": 194 }, { "index": 79402, "code": "show_hca(struct device *device, struct device_attribute *attr,\n\t\t\tchar *buf)\n{\n\tstruct ipath_ibdev *dev =\n\t\tcontainer_of(device, struct ipath_ibdev, ibdev.dev);\n\tint ret;\n\n\tret = dev->dd->ipath_f_get_boardname(dev->dd, buf, 128);\n\tif (ret < 0)\n\t\tgoto bail;\n\tstrcat(buf, \"\\n\");\n\tret = strlen(buf);\n\nbail:\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 97 }, { "index": 251573, "code": "virtual_chdir_file(const char *path, int (*p_chdir)(const char *path TSRMLS_DC) TSRMLS_DC) /* {{{ */\n{\n\tint length = strlen(path);\n\tchar *temp;\n\tint retval;\n\tTSRM_ALLOCA_FLAG(use_heap)\n\n\tif (length == 0) {\n\t\treturn 1; /* Can't cd to empty string */\n\t}\t\n\twhile(--length >= 0 && !IS_SLASH(path[length])) {\n\t}\n\n\tif (length == -1) {\n\t\t/* No directory only file name */\n\t\terrno = ENOENT;\n\t\treturn -1;\n\t}\n\n\tif (length == COPY_WHEN_ABSOLUTE(path) && IS_ABSOLUTE_PATH(path, length+1)) { /* Also use trailing slash if this is absolute */\n\t\tlength++;\n\t}\n\ttemp = (char *) tsrm_do_alloca(length+1, use_heap);\n\tmemcpy(temp, path, length);\n\ttemp[length] = 0;\n#if VIRTUAL_CWD_DEBUG\n\tfprintf (stderr, \"Changing directory to %s\\n\", temp);\n#endif\n\tretval = p_chdir(temp TSRMLS_CC);\n\ttsrm_free_alloca(temp, use_heap);\n\treturn retval;\n}", "label": 0, "cwe": null, "length": 243 }, { "index": 17097, "code": "ajFeatoutPrintwikiFormat(AjPFile outf)\n{\n ajint i = 0;\n ajint j = 0;\n AjPStr namestr = NULL;\n\n ajFmtPrintF(outf, \"{| class=\\\"wikitable sortable\\\" border=\\\"2\\\"\\n\");\n ajFmtPrintF(outf, \"|-\\n\");\n ajFmtPrintF(outf, \"!Format!!Nuc!!Pro!!\"\n \"class=\\\"unsortable\\\"|Description\\n\");\n\n for(i=1; featOutFormatDef[i].Name; i++)\n {\n if(!featOutFormatDef[i].Alias)\n {\n ajFmtPrintF(outf, \"|-\\n\");\n ajStrAssignC(&namestr, featOutFormatDef[i].Name);\n\n\n for(j=i+1; featOutFormatDef[j].Name; j++)\n {\n if(featOutFormatDef[j].Write == featOutFormatDef[i].Write)\n {\n ajFmtPrintAppS(&namestr, \" %s\", featOutFormatDef[j].Name);\n if(!featOutFormatDef[j].Alias) \n {\n ajWarn(\"Feature output format '%s' same as '%s' \"\n \"but not alias\",\n featOutFormatDef[j].Name,\n featOutFormatDef[i].Name);\n }\n }\n }\n ajFmtPrintF(outf, \"|%S||%B||%B||%s\\n\",\n\t\t\tnamestr,\n\t\t\tfeatOutFormatDef[i].Nucleotide,\n\t\t\tfeatOutFormatDef[i].Protein,\n\t\t\tfeatOutFormatDef[i].Desc);\n }\n }\n\n ajFmtPrintF(outf, \"|}\\n\\n\");\n\n ajStrDel(&namestr);\n\n return;\n}", "label": 0, "cwe": null, "length": 371 }, { "index": 328607, "code": "changed()\n{\n#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)\n /* The text of the preediting area is inserted, but this doesn't\n * mean a change of the buffer yet. That is delayed until the\n * text is committed. (this means preedit becomes empty) */\n if (im_is_preediting() && !xim_changed_while_preediting)\n\treturn;\n xim_changed_while_preediting = FALSE;\n#endif\n\n if (!curbuf->b_changed)\n {\n\tint\tsave_msg_scroll = msg_scroll;\n\n\t/* Give a warning about changing a read-only file. This may also\n\t * check-out the file, thus change \"curbuf\"! */\n\tchange_warning(0);\n\n\t/* Create a swap file if that is wanted.\n\t * Don't do this for \"nofile\" and \"nowrite\" buffer types. */\n\tif (curbuf->b_may_swap\n#ifdef FEAT_QUICKFIX\n\t\t&& !bt_dontwrite(curbuf)\n#endif\n\t\t)\n\t{\n\t ml_open_file(curbuf);\n\n\t /* The ml_open_file() can cause an ATTENTION message.\n\t * Wait two seconds, to make sure the user reads this unexpected\n\t * message. Since we could be anywhere, call wait_return() now,\n\t * and don't let the emsg() set msg_scroll. */\n\t if (need_wait_return && emsg_silent == 0)\n\t {\n\t\tout_flush();\n\t\tui_delay(2000L, TRUE);\n\t\twait_return(TRUE);\n\t\tmsg_scroll = save_msg_scroll;\n\t }\n\t}\n\tcurbuf->b_changed = TRUE;\n\tml_setflags(curbuf);\n#ifdef FEAT_WINDOWS\n\tcheck_status(curbuf);\n\tredraw_tabline = TRUE;\n#endif\n#ifdef FEAT_TITLE\n\tneed_maketitle = TRUE;\t /* set window title later */\n#endif\n }\n ++curbuf->b_changedtick;\n}", "label": 0, "cwe": null, "length": 408 }, { "index": 876220, "code": "__ecereNameSpace__ecere__sys__MakePathRelative(char * path, char * to, char * destination)\n{\nint len;\n\nif(!path[0])\nmemmove(destination, path, strlen(path) + 1);\nelse\n{\nchar pathPart[4384LL], pathRest[797];\nchar toPart[4384LL], toRest[797];\nunsigned int different = 0x0;\n\nstrcpy(pathRest, path);\nstrcpy(toRest, to);\ndestination[0] = '\\0';\nfor(; toRest[0]; )\n{\n__ecereNameSpace__ecere__sys__SplitDirectory(toRest, toPart, toRest);\nif(!different)\n__ecereNameSpace__ecere__sys__SplitDirectory(pathRest, pathPart, pathRest);\nif(different || ((__ecereNameSpace__ecere__com__GetRuntimePlatform() == 1) ? (strcasecmp) : strcmp)(toPart, pathPart))\n{\ndifferent = 0x1;\nstrcat(destination, \"..\");\nstrcat(destination, ((__ecereNameSpace__ecere__com__GetRuntimePlatform() == 1) ? \"\\\\\" : \"/\"));\n}\n}\nif(different)\n__ecereNameSpace__ecere__sys__PathCat(destination, pathPart);\nfor(; pathRest[0]; )\n{\n__ecereNameSpace__ecere__sys__SplitDirectory(pathRest, pathPart, pathRest);\n__ecereNameSpace__ecere__sys__PathCat(destination, pathPart);\n}\n}\nlen = strlen(destination);\nif(len > 1 && (destination[len - 1] == '/' || destination[len - 1] == '\\\\'))\ndestination[--len] = '\\0';\nreturn destination;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 360 }, { "index": 182, "code": "__hypotl(long double x, long double y)\n{\n\tlong double z;\n\tz = __ieee754_hypotl(x,y);\n\tif(__builtin_expect(!__finitel(z), 0)\n\t && __finitel(x) && __finitel(y) && _LIB_VERSION != _IEEE_)\n\t return __kernel_standard_l(x, y, 204); /* hypot overflow */\n\n\treturn z;\n}", "label": 0, "cwe": null, "length": 89 }, { "index": 41415, "code": "C8Bits_SAddWordIntoExpVec( Int *v, UInt1 *w, Int e, \n Int ebits, UInt expm, \n Obj *ro, Obj *pow, Int lpow ) {\n\n UInt1 * wend = w + (INT_INTOBJ((((Obj*)(w))[-1])) - 1);\n Int i;\n Int ex;\n Int start = 0;\n\n for( ; w <= wend; w++ ) {\n i = ((*w) >> ebits) + 1; \n v[ i ] += ((*w) & expm) * e; /* overflow check necessary? */\n if ( INT_INTOBJ(ro[i]) <= v[i] ) {\n ex = v[i] / INT_INTOBJ(ro[i]);\n v[i] -= ex * INT_INTOBJ(ro[i]);\n if ( i <= lpow && pow[i] && 0 < NPAIRS_WORD(pow[i]) ) {\n start = C8Bits_SAddWordIntoExpVec( \n v, (UInt1*)DATA_WORD(pow[i]), ex,\n ebits, expm, ro, pow, lpow );\n }\n }\n if( start < i && v[i] ) start = i;\n }\n return start;\n}", "label": 0, "cwe": null, "length": 281 }, { "index": 399770, "code": "loc_delallrtlport( ScanPort )\n\n rtlport_list *ScanPort;\n{\n rtlport_list *Delete;\n\n while ( ScanPort != (rtlport_list *)0 )\n {\n Delete = ScanPort;\n ScanPort = ScanPort->NEXT;\n\n freevexexpr( Delete->VEX_ATOM );\n\n freertlport( Delete );\n }\n}", "label": 0, "cwe": null, "length": 80 }, { "index": 601275, "code": "fx_greyscale(gdImage *src, char *options)\n{\n\tint x, y;\n\t\n\tMSG(\"Greyscaling image.\");\n\t\n\tfor(y = 0; y < gdImageSY(src); y++)\n\t\tfor(x = 0; x < gdImageSX(src); x++)\n\t\t{\n\t\t\tuint8_t c = GREY(gdImageGetPixel(src, x, y));\n\t\t\tgdImageSetPixel(src, x, y, RGB(c, c, c));\n\t\t}\n\t\n\treturn(src);\n}", "label": 0, "cwe": null, "length": 111 }, { "index": 145014, "code": "bcm2048_parse_ps_match_b(struct bcm2048_device *bdev, int i)\n{\n\tint crc, index, ps_id, ps_group;\n\n\tcrc = bcm2048_rds_block_crc(bdev, i);\n\n\tif (crc == BCM2048_RDS_CRC_UNRECOVARABLE)\n\t\treturn -EIO;\n\n\t/* Block B Radio PS match */\n\tif ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) ==\n\t\tBCM2048_RDS_BLOCK_B) {\n\t\tps_id = bdev->rds_info.radio_text[i+1] &\n\t\t\tBCM2048_RDS_BLOCK_MASK;\n\t\tps_group = bdev->rds_info.radio_text[i+1] &\n\t\t\tBCM2048_RDS_GROUP_AB_MASK;\n\n\t\t/*\n\t\t * Poor RSSI will lead to RDS data corruption\n\t\t * So using 3 (same) sequential values to justify major changes\n\t\t */\n\t\tif (ps_group != bdev->rds_info.rds_ps_group) {\n\t\t\tif (crc == BCM2048_RDS_CRC_NONE) {\n\t\t\t\tbdev->rds_info.rds_ps_group_cnt++;\n\t\t\t\tif (bdev->rds_info.rds_ps_group_cnt > 2) {\n\t\t\t\t\tbdev->rds_info.rds_ps_group = ps_group;\n\t\t\t\t\tbdev->rds_info.rds_ps_group_cnt\t= 0;\n\t\t\t\t\tdev_err(&bdev->client->dev,\n\t\t\t\t\t\t\"RDS PS Group change!\\n\");\n\t\t\t\t} else {\n\t\t\t\t\treturn -EIO;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tbdev->rds_info.rds_ps_group_cnt = 0;\n\t\t\t}\n\t\t}\n\n\t\tif (ps_id == BCM2048_RDS_PS) {\n\t\t\tindex = bdev->rds_info.radio_text[i+2] &\n\t\t\t\tBCM2048_RDS_PS_INDEX;\n\t\t\tindex <<= 1;\n\t\t\treturn index;\n\t\t}\n\t}\n\n\treturn -EIO;\n}", "label": 0, "cwe": null, "length": 419 }, { "index": 706882, "code": "semaphore_add (int value)\n{\n\tstruct sembuf sbuf;\n\n\tsbuf.sem_num = 0;\n\tsbuf.sem_op = value;\n\tsbuf.sem_flg = SEM_UNDO;\n\tif (semop(semid, &sbuf, 1) == -1) {\n\t\tsemaphore_error (\"semop\");\n\t}\n}", "label": 0, "cwe": null, "length": 69 }, { "index": 109645, "code": "PC090OJ_vh_start(int gfxnum,int x_offset,int y_offset,int use_buffer)\r\n{\r\n\t/* use the given gfx set */\r\n\tPC090OJ_gfxnum = gfxnum;\r\n\r\n\tPC090OJ_xoffs = x_offset;\r\n\tPC090OJ_yoffs = y_offset;\r\n\r\n\tPC090OJ_buffer = use_buffer;\r\n\r\n\tPC090OJ_ram = auto_malloc(PC090OJ_RAM_SIZE);\r\n\tPC090OJ_ram_buffered = auto_malloc(PC090OJ_RAM_SIZE);\r\n\r\n\tif (!PC090OJ_ram || !PC090OJ_ram_buffered)\r\n\t\treturn 1;\r\n\r\n\tmemset(PC090OJ_ram,0,PC090OJ_RAM_SIZE);\r\n\tmemset(PC090OJ_ram_buffered,0,PC090OJ_RAM_SIZE);\r\n\r\n\tstate_save_register_UINT16(\"PC090OJ\", 0, \"memory\", PC090OJ_ram, PC090OJ_RAM_SIZE/2);\r\n\tstate_save_register_UINT16(\"PC090OJb\", 0, \"memory\", PC090OJ_ram_buffered, PC090OJ_RAM_SIZE/2);\r\n\tstate_save_register_UINT16(\"PC090OJc\", 0, \"register\", &PC090OJ_ctrl, 1);\r\n\r\n//\tstate_save_register_func_postload(PC090OJ_restore);\r\n\r\n\treturn 0;\r\n}", "label": 0, "cwe": null, "length": 277 }, { "index": 445568, "code": "main(int argc, char *argv[])\n{\n\tint *array = NULL;\n\tint length = 0;\n\tFILE *fh;\n\tint data;\n\n\tif (argc != 2) {\n\t\tprintf(\"usage: %s \\n\", argv[0]);\n\t\treturn 1;\n\t}\n\n\t/* Initialize data. */\n\tprintf(\"attempting to sort file: %s\\n\", argv[1]);\n\n\tfh = fopen(argv[1], \"r\");\n\tif (fh == NULL) {\n\t\tprintf(\"error opening file\\n\");\n\t\treturn 0;\n\t}\n\n\twhile (fscanf(fh, \"%d\", &data) != EOF) {\n\t\t++length;\n\t\tarray = (int *) realloc(array, length * sizeof(int));\n\t\tarray[length - 1] = data;\n\t\tdisplay(array, length);\n\t}\n\tfclose(fh);\n\tprintf(\"%d elements read\\n\", length);\n\n\tdisplay(array, length);\n\tquicksort(array, 0, length - 1);\n\tdisplay(array, length);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 209 }, { "index": 114355, "code": "cmdline_parser_release (struct gengetopt_args_info *args_info)\n{\n unsigned int i;\n free_string_field (&(args_info->profile_arg));\n free_string_field (&(args_info->profile_orig));\n \n \n for (i = 0; i < args_info->inputs_num; ++i)\n free (args_info->inputs [i]);\n\n if (args_info->inputs_num)\n free (args_info->inputs);\n\n clear_given (args_info);\n}", "label": 0, "cwe": null, "length": 101 }, { "index": 512416, "code": "Bootstrapper_process_C4_Model(Bootstrapper *bs,\n C4_Model *model, gboolean generate_bsdp_code,\n gboolean generate_sdp_code){\n register gint i;\n register Optimal *optimal = Optimal_create(model, NULL,\n Optimal_Type_SCORE\n |Optimal_Type_PATH\n |Optimal_Type_REDUCED_SPACE,\n TRUE);\n register Heuristic *heuristic;\n register SDP *sdp;\n register GPtrArray *codegen_list, *optimal_list;\n register Codegen *codegen;\n g_message(\"Bootstrapper processing model [%s]\", model->name);\n Bootstrapper_process_Optimal(bs, optimal);\n if(generate_bsdp_code){\n heuristic = Heuristic_create(model);\n optimal_list = Heuristic_get_Optimal_list(heuristic);\n for(i = 0; i < optimal_list->len; i++)\n Bootstrapper_process_Optimal(bs, optimal_list->pdata[i]);\n Heuristic_destroy(heuristic);\n g_ptr_array_free(optimal_list, TRUE);\n }\n if(generate_sdp_code){\n sdp = SDP_create(model);\n codegen_list = SDP_get_codegen_list(sdp);\n for(i = 0; i < codegen_list->len; i++){\n codegen = codegen_list->pdata[i];\n Bootstrapper_add_codegen(bs, codegen);\n }\n g_ptr_array_free(codegen_list, TRUE);\n SDP_destroy(sdp);\n }\n Optimal_destroy(optimal);\n return;\n }", "label": 0, "cwe": null, "length": 333 }, { "index": 951316, "code": "_equalCreatePolicyStmt(const CreatePolicyStmt *a, const CreatePolicyStmt *b)\n{\n\tCOMPARE_STRING_FIELD(policy_name);\n\tCOMPARE_NODE_FIELD(table);\n\tCOMPARE_STRING_FIELD(cmd_name);\n\tCOMPARE_NODE_FIELD(roles);\n\tCOMPARE_NODE_FIELD(qual);\n\tCOMPARE_NODE_FIELD(with_check);\n\n\treturn true;\n}", "label": 0, "cwe": null, "length": 71 }, { "index": 196768, "code": "dog_hunger(struct monst *mtmp, struct edog *edog)\n{\n if (monstermoves > edog->hungrytime + 500)\n {\n if (!carnivorous(mtmp->data) && !herbivorous(mtmp->data))\n {\n edog->hungrytime = monstermoves + 500;\n /* but not too high; it might polymorph */\n }\n else if (!edog->mhpmax_penalty)\n {\n /* starving pets are limited in healing */\n int newmhpmax = mtmp->mhpmax / 3;\n mtmp->mconf = 1;\n edog->mhpmax_penalty = mtmp->mhpmax - newmhpmax;\n mtmp->mhpmax = newmhpmax;\n if (mtmp->mhp > mtmp->mhpmax)\n {\n mtmp->mhp = mtmp->mhpmax;\n }\n if (mtmp->mhp < 1)\n {\n goto dog_died;\n }\n if (cansee(mtmp->mx, mtmp->my))\n {\n pline(\"%s is confused from hunger.\", Monnam(mtmp));\n }\n else if (couldsee(mtmp->mx, mtmp->my))\n {\n beg(mtmp);\n }\n else\n {\n You_feel(\"worried about %s.\", y_monnam(mtmp));\n }\n stop_occupation();\n }\n else if (monstermoves > edog->hungrytime + 750 || mtmp->mhp < 1)\n {\ndog_died:\n if (mtmp->mleashed && mtmp != u.usteed)\n {\n Your(\"leash goes slack.\");\n }\n else if (cansee(mtmp->mx, mtmp->my))\n {\n pline(\"%s starves.\", Monnam(mtmp));\n }\n else\n {\n You_feel(\"%s for a moment.\",\n Hallucination ? \"bummed\" : \"sad\");\n }\n mondied(mtmp);\n return true;\n }\n }\n return false;\n}", "label": 0, "cwe": null, "length": 464 }, { "index": 681394, "code": "_removeChild(Request& r, MethodParams& params) {\n\txmlNode& oldChild=as_node(params, 0, \"refChild must be node\");\n\n\tVXnode& vnode=GET_SELF(r, VXnode);\n\tVXdoc& vxdoc=vnode.get_vxdoc();\n\txmlDoc& xmldoc=vxdoc.get_xmldoc();\n//\txmlNode& selfNode=vnode.get_xmlnode();\n\t\n\tif(oldChild.doc!=&xmldoc)\n\t\tthrow Exception(\"xml.dom\",\n\t\t\t0,\n\t\t\t\"WRONG_DOCUMENT_ERR\");\n\n\txmlUnlinkNode(&oldChild);\n\t// write out result\n\twriteNode(r, vxdoc, &oldChild);\n}", "label": 0, "cwe": null, "length": 142 }, { "index": 426634, "code": "create_truncate(const char *name, const char *pag1)\n{\n char *fn;\n FILE *f;\n\n fn = concat(name, pag1, (char *) 0);\n f = Fopen(fn, \"w\", TEMPORARYOPEN);\n free(fn);\n if (f == NULL) {\n\tsyswarn(\"unable to create/truncate %s\", pag1);\n\treturn false;\n } else\n Fclose(f);\n return true;\n}", "label": 0, "cwe": null, "length": 99 }, { "index": 908747, "code": "p_init_sensitive(GapOnionMainGlobalParams *gpp)\n{\n GtkWidget *wgt;\n gboolean l_sensitive;\n\n l_sensitive = TRUE;\n if(gpp->vin.select_mode > 3)\n {\n /* insensitive for select modes (4,5,6) that are lists of stacknumbers or all_visible layers */\n l_sensitive = FALSE;\n }\n wgt = gpp->oni__checkbutton_select_case;\n if(wgt)\n {\n gtk_widget_set_sensitive(wgt, l_sensitive);\n }\n wgt = gpp->oni__checkbutton_select_invert;\n if(wgt)\n {\n gtk_widget_set_sensitive(wgt, l_sensitive);\n }\n\n l_sensitive = TRUE;\n if(gpp->vin.select_mode == 6)\n {\n /* the pattern entry is insensitive if all_visible layers (6) is selected */\n l_sensitive = FALSE;\n }\n wgt = gpp->oni__entry_select_string;\n if(wgt)\n {\n gtk_widget_set_sensitive(wgt, l_sensitive);\n }\n}", "label": 0, "cwe": null, "length": 228 }, { "index": 173391, "code": "readport_internal( libspectrum_word port )\n{\n struct peripheral_data_t callback_info;\n\n /* Trigger the debugger if wanted */\n if( debugger_mode != DEBUGGER_MODE_INACTIVE )\n debugger_check( DEBUGGER_BREAKPOINT_TYPE_PORT_READ, port );\n\n /* If we're doing RZX playback, get a byte from the RZX file */\n if( rzx_playback ) {\n\n libspectrum_error error;\n libspectrum_byte value;\n\n error = libspectrum_rzx_playback( rzx, &value );\n if( error ) {\n rzx_stop_playback( 1 );\n\n /* Add a null event to mean we pick up the RZX state change in\n\t z80_do_opcodes() */\n event_add( tstates, event_type_null );\n return readport_internal( port );\n }\n\n return value;\n }\n\n /* If we're not doing RZX playback, get the byte normally */\n callback_info.port = port;\n callback_info.attached = 0;\n callback_info.value = 0xff;\n\n g_slist_foreach( ports, read_peripheral, &callback_info );\n\n if( !callback_info.attached )\n callback_info.value = machine_current->unattached_port();\n\n /* If we're RZX recording, store this byte */\n if( rzx_recording ) rzx_store_byte( callback_info.value );\n\n return callback_info.value;\n}", "label": 0, "cwe": null, "length": 294 }, { "index": 799411, "code": "device_remove_sys_dev_entry(struct device *dev)\n{\n\tstruct kobject *kobj = device_to_dev_kobj(dev);\n\tchar devt_str[15];\n\n\tif (kobj) {\n\t\tformat_dev_t(devt_str, dev->devt);\n\t\tsysfs_remove_link(kobj, devt_str);\n\t}\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 67 }, { "index": 870930, "code": "pproxy_set_add_array(pproxy_set_t *ps, gnet_host_t *proxies, int proxy_count)\n{\n\tint i;\n\n\tpproxy_set_check(ps);\n\n\tfor (i = 0; i < proxy_count; i++) {\n\t\tif (hash_list_contains(ps->proxies, &proxies[i])) {\n\t\t\thash_list_moveto_head(ps->proxies, &proxies[i]);\n\t\t} else {\n\t\t\thash_list_prepend(ps->proxies, gnet_host_dup(&proxies[i]));\n\t\t}\n\t}\n\n\tpproxy_set_trim(ps);\n\tps->last_update = tm_time();\n}", "label": 0, "cwe": null, "length": 131 }, { "index": 671172, "code": "network_connection_option(network_handle nh, const char *option, Var * value)\n{\n CONNECTION_OPTION_GET(NETWORK_CO_TABLE, nh, option, value);\n}", "label": 0, "cwe": null, "length": 35 }, { "index": 543885, "code": "satipc_set_pid(adapter *ad, uint16_t pid)\n{\n\tsatipc *sip;\n\tsip = get_satip(ad->id);\n\tint aid = ad->id;\n\tif (sip->err) // error reported, return error\n\t\treturn 0;\n\tLOG(\"satipc: set_pid for adapter %d, pid %d, err %d\", aid, pid, sip->err);\n\tif (sip->err) // error reported, return error\n\t\treturn 0;\n\tsip->apid[sip->lap] = pid;\n\tsip->lap++;\n\treturn aid + 100;\n}", "label": 0, "cwe": null, "length": 126 }, { "index": 877624, "code": "_replyFinished()\n {\n Q_Q( NetworkAccessManagerProxy );\n QNetworkReply *reply = static_cast( q->sender() );\n\n KUrl url = reply->request().url();\n QList callbacks = urlMap.values( url );\n urlMap.remove( url );\n QByteArray data = reply->readAll();\n data.detach(); // detach so the bytes are not deleted before methods are invoked\n foreach( const CallBackData *cb, callbacks )\n {\n // There may have been a redirect.\n KUrl redirectUrl = q->getRedirectUrl( reply );\n\n // Check if there's no redirect.\n if( redirectUrl.isEmpty() )\n {\n QByteArray sig = QMetaObject::normalizedSignature( cb->method );\n sig.remove( 0, 1 ); // remove first char, which is the member code (see qobjectdefs.h)\n // and let Qt's meta object system handle the rest.\n if( cb->receiver )\n {\n bool success( false );\n const QMetaObject *mo = cb->receiver.data()->metaObject();\n int methodIndex = mo->indexOfSlot( sig );\n if( methodIndex != -1 )\n {\n Error err = { reply->error(), reply->errorString() };\n QMetaMethod method = mo->method( methodIndex );\n success = method.invoke( cb->receiver.data(),\n cb->type,\n Q_ARG( KUrl, reply->request().url() ),\n Q_ARG( QByteArray, data ),\n Q_ARG( NetworkAccessManagerProxy::Error, err ) );\n }\n\n if( !success )\n {\n debug() << QString( \"Failed to invoke method %1 of %2\" )\n .arg( QString(sig) ).arg( mo->className() );\n }\n }\n }\n else\n {\n debug() << \"the server is redirecting the request to: \" << redirectUrl;\n\n // Let's try to fetch the data again, but this time from the new url.\n QNetworkReply *newReply = q->getData( redirectUrl, cb->receiver.data(), cb->method, cb->type );\n\n emit q->requestRedirected( url, redirectUrl );\n emit q->requestRedirected( reply, newReply );\n }\n }\n\n qDeleteAll( callbacks );\n reply->deleteLater();\n }", "label": 0, "cwe": null, "length": 501 }, { "index": 552345, "code": "mpx_mmap(unsigned long len)\n{\n\tstruct mm_struct *mm = current->mm;\n\tunsigned long addr, populate;\n\n\t/* Only bounds table can be allocated here */\n\tif (len != mpx_bt_size_bytes(mm))\n\t\treturn -EINVAL;\n\n\tdown_write(&mm->mmap_sem);\n\taddr = do_mmap(NULL, 0, len, PROT_READ | PROT_WRITE,\n\t\t\tMAP_ANONYMOUS | MAP_PRIVATE, VM_MPX, 0, &populate);\n\tup_write(&mm->mmap_sem);\n\tif (populate)\n\t\tmm_populate(addr, populate);\n\n\treturn addr;\n}", "label": 0, "cwe": null, "length": 127 }, { "index": 833463, "code": "_dbus_dvb_id_bus_schedule_Next (DVBIDBusSchedule* self, GVariant* parameters, GDBusMethodInvocation* invocation) {\n\tGError* error = NULL;\n\tGVariantIter _arguments_iter;\n\tguint32 event_id = 0U;\n\tGVariant* _tmp427_;\n\tGDBusMessage* _reply_message;\n\tGVariant* _reply;\n\tGVariantBuilder _reply_builder;\n\tguint32 result;\n\tg_variant_iter_init (&_arguments_iter, parameters);\n\t_tmp427_ = g_variant_iter_next_value (&_arguments_iter);\n\tevent_id = g_variant_get_uint32 (_tmp427_);\n\tg_variant_unref (_tmp427_);\n\tresult = dvb_id_bus_schedule_Next (self, event_id, &error);\n\tif (error) {\n\t\tg_dbus_method_invocation_return_gerror (invocation, error);\n\t\treturn;\n\t}\n\t_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));\n\tg_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);\n\tg_variant_builder_add_value (&_reply_builder, g_variant_new_uint32 (result));\n\t_reply = g_variant_builder_end (&_reply_builder);\n\tg_dbus_message_set_body (_reply_message, _reply);\n\tg_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);\n\tg_object_unref (invocation);\n\tg_object_unref (_reply_message);\n}", "label": 0, "cwe": null, "length": 311 }, { "index": 113793, "code": "field_cmp_ulong(void *a, void *b, OPERATOR op)\n{\n\tswitch (op) {\n\tcase GT:\n\t\treturn (*(u_long *)a > *(u_long *)b);\n\tcase GTEQ:\n\t\treturn (*(u_long *)a >= *(u_long *)b);\n\tcase LT:\n\t\treturn (*(u_long *)a < *(u_long *)b);\n\tcase LTEQ:\n\t\treturn (*(u_long *)a <= *(u_long *)b);\n\tcase NEQ:\n\t\treturn (*(u_long *)a != *(u_long *)b);\n\tcase EQ:\n\t\treturn (*(u_long *)a == *(u_long *)b);\n\tcase WC:\n\tcase NWC:\n\t\tbreak;\n\t}\n\n\tabort();\n\t/* NOTREACHED */\n}", "label": 0, "cwe": null, "length": 150 }, { "index": 325989, "code": "DefineProperBufferLength() const\n{\n if (mXMax < mXMin || mYMax < mYMin || mZMax < mZMin) return 0;\n PixelFormat pixelInfo = ImageHelper::GetPixelFormatValue(mReader.GetFile());\n //unsigned short samplesPerPixel = pixelInfo.GetSamplesPerPixel();\n int bytesPerPixel = pixelInfo.GetPixelSize();\n return (mYMax - mYMin)*(mXMax - mXMin)*(mZMax - mZMin)*bytesPerPixel;\n}", "label": 0, "cwe": null, "length": 113 }, { "index": 652012, "code": "pre_FctDef (CT_FctDef *node) {\n CObjectInfo *func = node->Object ();\n\n if (func && func->FunctionInfo ()) {\n func_stack.push (func->FunctionInfo ());\n local_id = 0;\n }\n else\n prune ();\n}", "label": 0, "cwe": null, "length": 62 }, { "index": 92021, "code": "shctx_new_cb(SSL *ssl, SSL_SESSION *sess)\n{\n\tunsigned char encsess[sizeof(struct shsess_packet)+SHSESS_MAX_DATA_LEN];\n\tstruct shsess_packet *packet = (struct shsess_packet *)encsess;\n\tunsigned char *p;\n\tint data_len, sid_length, sid_ctx_length;\n\n\n\t/* Session id is already stored in to key and session id is known\n\t * so we dont store it to keep size.\n\t */\n\tsid_length = sess->session_id_length;\n\tsess->session_id_length = 0;\n\tsid_ctx_length = sess->sid_ctx_length;\n\tsess->sid_ctx_length = 0;\n\n\t/* check if buffer is large enough for the ASN1 encoded session */\n\tdata_len = i2d_SSL_SESSION(sess, NULL);\n\tif (data_len > SHSESS_MAX_DATA_LEN)\n\t\tgoto err;\n\n\t/* process ASN1 session encoding before the lock */\n\tp = packet->data;\n\ti2d_SSL_SESSION(sess, &p);\n\n\tmemcpy(packet->hdr.id, sess->session_id, sid_length);\n\tif (sid_length < SSL_MAX_SSL_SESSION_ID_LENGTH)\n\t\tmemset(&packet->hdr.id[sid_length], 0, SSL_MAX_SSL_SESSION_ID_LENGTH-sid_length);\n\n\tshared_context_lock();\n\n\t/* store to cache */\n\tshsess_store(packet->hdr.id, packet->data, data_len);\n\n\tshared_context_unlock();\n\nerr:\n\t/* reset original length values */\n\tsess->session_id_length = sid_length;\n\tsess->sid_ctx_length = sid_ctx_length;\n\n\treturn 0; /* do not increment session reference count */\n}", "label": 0, "cwe": null, "length": 329 }, { "index": 78265, "code": "Fd_Domain_2(WamWord list_word, WamWord r_word)\n{\n WamWord word, tag_mask;\n WamWord save_list_word;\n WamWord *lst_adr;\n\n\n DEREF(list_word, word, tag_mask);\n if (tag_mask == TAG_REF_MASK || tag_mask == TAG_INT_MASK || \n tag_mask == TAG_FDV_MASK)\n return fd_domain_r(word, r_word);\n\n save_list_word = list_word;\n for (;;)\n {\n DEREF(list_word, word, tag_mask);\n\n if (tag_mask == TAG_REF_MASK)\n\tPl_Err_Instantiation();\n\n if (word == NIL_WORD)\n\tbreak;\n\n if (tag_mask != TAG_LST_MASK)\n\tPl_Err_Type(type_list, save_list_word);\n\n lst_adr = UnTag_LST(word);\n if (!fd_domain_r(Car(lst_adr), r_word))\n\treturn FALSE;\n\n list_word = Cdr(lst_adr);\n }\n\n return TRUE;\n}", "label": 0, "cwe": null, "length": 213 }, { "index": 462257, "code": "Fold(vector& vec, unsigned int nbits)\n {\n if(nbits= nbits)\n vec.erase(transform(vec.begin(),vec.begin()+vec.size()/2,\n vec.begin()+vec.size()/2, vec.begin(), bit_or()), vec.end());\n }", "label": 0, "cwe": null, "length": 122 }, { "index": 374988, "code": "write_flush(avrftdi_t* pdata)\n{\n\tunsigned char buf[6];\n\n\tlog_debug(\"Setting pin direction (0x%04x) and value (0x%04x)\\n\",\n\t pdata->pin_direction, pdata->pin_value);\n\n\tbuf[0] = SET_BITS_LOW;\n\tbuf[1] = (pdata->pin_value) & 0xff;\n\tbuf[2] = (pdata->pin_direction) & 0xff;\n\tbuf[3] = SET_BITS_HIGH;\n\tbuf[4] = ((pdata->pin_value) >> 8) & 0xff;\n\tbuf[5] = ((pdata->pin_direction) >> 8) & 0xff;\n\n#ifndef DRYRUN\n\tE(ftdi_write_data(pdata->ftdic, buf, 6) != 6, pdata->ftdic);\n\n#endif\n\n\tlog_trace(\"Set pins command: %02x %02x %02x %02x %02x %02x\\n\",\n\t buf[0], buf[1], buf[2], buf[3], buf[4], buf[5]);\n\n\t/* we need to flush here, because set_pin is used as reset.\n\t * if we want to sleep reset periods, we must be certain the\n\t * avr has got the reset signal when we start sleeping.\n\t * (it may be stuck in the USB stack or some USB hub)\n\t *\n\t * Add.: purge does NOT flush. It clears. Also, it is unkown, when the purge\n\t * command actually arrives at the chip.\n\t * Use read pin status command as sync.\n\t */\n#ifndef DRYRUN\n\t//E(ftdi_usb_purge_buffers(pdata->ftdic), pdata->ftdic);\n\n\tunsigned char cmd[] = { GET_BITS_LOW, SEND_IMMEDIATE };\n\tE(ftdi_write_data(pdata->ftdic, cmd, sizeof(cmd)) != sizeof(cmd), pdata->ftdic);\n\t\n\tint num = 0;\n\tdo\n\t{\n\t\tint n = ftdi_read_data(pdata->ftdic, buf, sizeof(buf));\n\t\tif(n > 0)\n\t\t\tnum += n;\n\t\tE(n < 0, pdata->ftdic);\n\t} while(num < 1);\n\t\n\tif(num > 1)\n\t\tlog_warn(\"Read %d extra bytes\\n\", num-1);\n#endif\n\n\treturn 0;\n\n}", "label": 0, "cwe": null, "length": 491 }, { "index": 57275, "code": "nrrdIterValue(NrrdIter *iter) {\n double ret = 0.0;\n\n if (iter) {\n ret = iter->load(iter->data);\n if (iter->nrrd || iter->ownNrrd) {\n iter->data += iter->size;\n if (iter->left) {\n iter->left -= 1;\n } else {\n iter->data = (char *)(_NRRD_ITER_NRRD(iter)->data);\n iter->left = nrrdElementNumber(_NRRD_ITER_NRRD(iter))-1;\n }\n }\n }\n return ret;\n}", "label": 0, "cwe": null, "length": 138 }, { "index": 79381, "code": "cdf_file_summary_info(struct magic_set *ms, const cdf_stream_t *sst)\n{\n\tcdf_summary_info_header_t si;\n\tcdf_property_info_t *info;\n\tsize_t count;\n\tint m;\n\n\tif (cdf_unpack_summary_info(sst, &si, &info, &count) == -1)\n\t\treturn -1;\n\n\tif (NOTMIME(ms)) {\n\t\tif (file_printf(ms, \"CDF V2 Document\") == -1)\n\t\t\treturn -1;\n\n\t\tif (file_printf(ms, \", %s Endian\",\n\t\t si.si_byte_order == 0xfffe ? \"Little\" : \"Big\") == -1)\n\t\t\treturn -1;\n\t\tswitch (si.si_os) {\n\t\tcase 2:\n\t\t\tif (file_printf(ms, \", Os: Windows, Version %d.%d\",\n\t\t\t si.si_os_version & 0xff, si.si_os_version >> 8)\n\t\t\t == -1)\n\t\t\t\treturn -1;\n\t\t\tbreak;\n\t\tcase 1:\n\t\t\tif (file_printf(ms, \", Os: MacOS, Version %d.%d\",\n\t\t\t si.si_os_version >> 8, si.si_os_version & 0xff)\n\t\t\t == -1)\n\t\t\t\treturn -1;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tif (file_printf(ms, \", Os %d, Version: %d.%d\", si.si_os,\n\t\t\t si.si_os_version & 0xff, si.si_os_version >> 8)\n\t\t\t == -1)\n\t\t\t\treturn -1;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tm = cdf_file_property_info(ms, info, count);\n\tfree(info);\n\n\treturn m;\n}", "label": 0, "cwe": null, "length": 339 }, { "index": 987560, "code": "wil_read_file_ioblob(struct file *file, char __user *user_buf,\n\t\t\t\t size_t count, loff_t *ppos)\n{\n\tenum { max_count = 4096 };\n\tstruct debugfs_blob_wrapper *blob = file->private_data;\n\tloff_t pos = *ppos;\n\tsize_t available = blob->size;\n\tvoid *buf;\n\tsize_t ret;\n\n\tif (pos < 0)\n\t\treturn -EINVAL;\n\n\tif (pos >= available || !count)\n\t\treturn 0;\n\n\tif (count > available - pos)\n\t\tcount = available - pos;\n\tif (count > max_count)\n\t\tcount = max_count;\n\n\tbuf = kmalloc(count, GFP_KERNEL);\n\tif (!buf)\n\t\treturn -ENOMEM;\n\n\twil_memcpy_fromio_32(buf, (const volatile void __iomem *)blob->data +\n\t\t\t pos, count);\n\n\tret = copy_to_user(user_buf, buf, count);\n\tkfree(buf);\n\tif (ret == count)\n\t\treturn -EFAULT;\n\n\tcount -= ret;\n\t*ppos = pos + count;\n\n\treturn count;\n}", "label": 0, "cwe": null, "length": 220 }, { "index": 52086, "code": "expand_string_assignment (string, quoted)\n char *string;\n int quoted;\n{\n WORD_DESC td;\n WORD_LIST *value;\n\n if (string == 0 || *string == '\\0')\n return ((WORD_LIST *)NULL);\n\n expand_no_split_dollar_star = 1;\n\n td.flags = W_ASSIGNRHS;\n td.word = savestring (string);\n value = call_expand_word_internal (&td, quoted, 0, (int *)NULL, (int *)NULL);\n FREE (td.word);\n\n expand_no_split_dollar_star = 0;\n\n if (value)\n {\n if (value->word)\n\t{\n\t remove_quoted_nulls (value->word->word);\n\t value->word->flags &= ~W_HASQUOTEDNULL;\n\t}\n dequote_list (value);\n }\n return (value);\n}", "label": 0, "cwe": null, "length": 184 }, { "index": 536727, "code": "locate(const Coordinate& p, const LineString *l)\n{\n\tconst CoordinateSequence* pt=l->getCoordinatesRO();\n\tif (! l->isClosed()) {\n\t\tif ((p==pt->getAt(0)) || (p==pt->getAt(pt->getSize()-1))) {\n\t\t\treturn Location::BOUNDARY;\n\t\t}\n\t}\n\tif (CGAlgorithms::isOnLine(p,pt))\n\t\treturn Location::INTERIOR;\n\treturn Location::EXTERIOR;\n}", "label": 0, "cwe": null, "length": 100 }, { "index": 621, "code": "create_ui (unsigned int child)\n{\n const gchar *filename = INPUT_PAD_UI_FILE;\n GError *error = NULL;\n GtkWidget *window = NULL;\n GtkAction *close_item;\n GtkBuilder *builder = gtk_builder_new ();\n\n if (!filename ||\n !g_file_test (filename, G_FILE_TEST_EXISTS)) {\n g_error (\"File Not Found: %s\\n\", filename ? filename : \"(null)\");\n return NULL;\n }\n\n gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);\n gtk_builder_add_from_file (builder, filename, &error);\n if (error) {\n g_error (\"ERROR: %s\\n\",\n error ? error->message ? error->message : \"\" : \"\");\n g_error_free (error);\n return NULL;\n }\n\n window = GTK_WIDGET (gtk_builder_get_object (builder, \"TopWindow\"));\n INPUT_PAD_GTK_WINDOW (window)->child = child;\n gtk_window_set_icon_from_file (GTK_WINDOW (window),\n DATAROOTDIR \"/pixmaps/input-pad.png\",\n &error);\n error = NULL;\n gtk_window_set_default_icon_from_file (DATAROOTDIR \"/pixmaps/input-pad.png\",\n &error);\n g_signal_connect (G_OBJECT (window), \"delete_event\",\n G_CALLBACK (on_window_close), NULL);\n\n close_item = GTK_ACTION (gtk_builder_get_object (builder, \"Close\"));\n g_signal_connect (G_OBJECT (close_item), \"activate\",\n G_CALLBACK (on_close_activate), (gpointer) window);\n\n create_code_point_dialog_ui (builder, window);\n create_about_dialog_ui (builder, window);\n create_contents_dialog_ui (builder, window);\n#ifdef NEW_CUSTOM_CHAR_TABLE\n create_custom_char_view_ui (builder, window);\n#else\n create_char_notebook_ui (builder, window);\n#endif\n create_all_char_view_ui (builder, window);\n create_keyboard_layout_ui (builder, window);\n\n gtk_builder_connect_signals (builder, NULL);\n g_object_unref (G_OBJECT (builder));\n\n return window;\n}", "label": 0, "cwe": null, "length": 432 }, { "index": 928939, "code": "updateCallback53(uint8 *&dataptr, Channel &channel, uint8 value) {\n uint8 value2 = *dataptr++;\n\n if (value & 1) {\n _unkValue11 = value2;\n\n // Channel 7, op1: Level Key Scaling / Total Level\n writeOPL(0x51, checkValue(value2 + _unkValue7 + _unkValue12));\n }\n\n if (value & 2) {\n _unkValue13 = value2;\n\n // Channel 8, op2: Level Key Scaling / Total Level\n writeOPL(0x55, checkValue(value2 + _unkValue10 + _unkValue14));\n }\n\n if (value & 4) {\n _unkValue16 = value2;\n\n // Channel 8, op1: Level Key Scaling / Total Level\n writeOPL(0x52, checkValue(value2 + _unkValue9 + _unkValue15));\n }\n\n if (value & 8) {\n _unkValue17 = value2;\n\n // Channel 7, op2: Level Key Scaling / Total Level\n writeOPL(0x54, checkValue(value2 + _unkValue8 + _unkValue18));\n }\n\n if (value & 16) {\n _unkValue19 = value2;\n\n // Channel 6, op2: Level Key Scaling / Total Level\n writeOPL(0x53, checkValue(value2 + _unkValue6 + _unkValue20));\n }\n\n return 0;\n}", "label": 0, "cwe": null, "length": 335 }, { "index": 94337, "code": "fuse_writepage_locked(struct page *page)\n{\n\tstruct address_space *mapping = page->mapping;\n\tstruct inode *inode = mapping->host;\n\tstruct fuse_conn *fc = get_fuse_conn(inode);\n\tstruct fuse_inode *fi = get_fuse_inode(inode);\n\tstruct fuse_req *req;\n\tstruct page *tmp_page;\n\tint error = -ENOMEM;\n\n\tset_page_writeback(page);\n\n\treq = fuse_request_alloc_nofs(1);\n\tif (!req)\n\t\tgoto err;\n\n\t/* writeback always goes to bg_queue */\n\t__set_bit(FR_BACKGROUND, &req->flags);\n\ttmp_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);\n\tif (!tmp_page)\n\t\tgoto err_free;\n\n\terror = -EIO;\n\treq->ff = fuse_write_file_get(fc, fi);\n\tif (!req->ff)\n\t\tgoto err_nofile;\n\n\tfuse_write_fill(req, req->ff, page_offset(page), 0);\n\n\tcopy_highpage(tmp_page, page);\n\treq->misc.write.in.write_flags |= FUSE_WRITE_CACHE;\n\treq->misc.write.next = NULL;\n\treq->in.argpages = 1;\n\treq->num_pages = 1;\n\treq->pages[0] = tmp_page;\n\treq->page_descs[0].offset = 0;\n\treq->page_descs[0].length = PAGE_SIZE;\n\treq->end = fuse_writepage_end;\n\treq->inode = inode;\n\n\tinc_wb_stat(&inode_to_bdi(inode)->wb, WB_WRITEBACK);\n\tinc_zone_page_state(tmp_page, NR_WRITEBACK_TEMP);\n\n\tspin_lock(&fc->lock);\n\tlist_add(&req->writepages_entry, &fi->writepages);\n\tlist_add_tail(&req->list, &fi->queued_writes);\n\tfuse_flush_writepages(inode);\n\tspin_unlock(&fc->lock);\n\n\tend_page_writeback(page);\n\n\treturn 0;\n\nerr_nofile:\n\t__free_page(tmp_page);\nerr_free:\n\tfuse_request_free(req);\nerr:\n\tend_page_writeback(page);\n\treturn error;\n}", "label": 0, "cwe": null, "length": 413 }, { "index": 95607, "code": "mcc_gen_new(krb5_context context, krb5_ccache *id)\n{\n krb5_mcache *m;\n\n m = mcc_alloc(NULL);\n\n if (m == NULL) {\n\tkrb5_set_error_message(context, KRB5_CC_NOMEM,\n\t\t\t N_(\"malloc: out of memory\", \"\"));\n\treturn KRB5_CC_NOMEM;\n }\n\n (*id)->data.data = m;\n (*id)->data.length = sizeof(*m);\n\n return 0;\n}", "label": 0, "cwe": null, "length": 104 }, { "index": 32627, "code": "krb5_timestamp_to_sfstring(krb5_timestamp timestamp, char *buffer, size_t buflen, char *pad)\n{\n struct tm *tmp;\n size_t i;\n size_t ndone;\n time_t timestamp2 = timestamp;\n struct tm tmbuf;\n\n static const char * const sftime_format_table[] = {\n \"%c\", /* Default locale-dependent date and time */\n \"%d %b %Y %T\", /* dd mon yyyy hh:mm:ss */\n \"%x %X\", /* locale-dependent short format */\n \"%x %T\", /* locale-dependent date + hh:mm:ss */\n \"%x %R\", /* locale-dependent date + hh:mm */\n \"%Y-%m-%dT%H:%M:%S\", /* ISO 8601 date + time */\n \"%Y-%m-%dT%H:%M\", /* ISO 8601 date + hh:mm */\n \"%Y%m%d%H%M%S\", /* ISO 8601 date + time, basic */\n \"%Y%m%d%H%M\" /* ISO 8601 date + hh:mm, basic */\n };\n static const unsigned int sftime_format_table_nents =\n sizeof(sftime_format_table)/sizeof(sftime_format_table[0]);\n\n#ifdef HAVE_LOCALTIME_R\n tmp = localtime_r(×tamp2, &tmbuf);\n#else\n memcpy((tmp = &tmbuf), localtime(×tamp2), sizeof(tmbuf));\n#endif\n ndone = 0;\n for (i=0; iread_proc (pixels, 1, line, handle);\n\t\tio->seek_proc (handle, delta, SEEK_CUR);\n#if FREEIMAGE_COLORORDER == FREEIMAGE_COLORORDER_RGB\n \t\tfor(int x = 0; x < width; x++) {\n\t\t\tINPLACESWAP(pixels[FI_RGBA_RED],pixels[FI_RGBA_BLUE]);\n\t\t\tpixels += bytespp;\n\t\t}\n#endif\n\t}\n\t\n\t// enable transparency\n\tFreeImage_SetTransparent (dib, (desc.ddpfPixelFormat.dwFlags & DDPF_ALPHAPIXELS) ? TRUE : FALSE);\n\n\tif (!(desc.ddpfPixelFormat.dwFlags & DDPF_ALPHAPIXELS) && bpp == 32) {\n\t\t// no transparency: convert to 24-bit\n\t\tFIBITMAP *old = dib;\n\t\tdib = FreeImage_ConvertTo24Bits (old);\n\t\tFreeImage_Unload (old);\n\t}\n\treturn dib;\n}", "label": 0, "cwe": null, "length": 491 }, { "index": 188365, "code": "extractRow (int i,\n\t\t\t\t\tconst CoinPresolveMatrix *mtx) const\n{\n const CoinBigIndex *rowStarts = mtx->getRowStarts() ;\n const int *colIndices = mtx->getColIndicesByRow() ;\n const double *coeffs = mtx->getElementsByRow() ;\n const int rowLen = mtx->hinrow_[i] ;\n const CoinBigIndex &ii = rowStarts[i] ;\n return (new CoinPackedVector(rowLen,&colIndices[ii],&coeffs[ii])) ;\n}", "label": 0, "cwe": null, "length": 115 }, { "index": 550732, "code": "parse_subset_params(char *dset)\n{\n struct subset_t *s = NULL;\n register char *brace;\n\n if (!disable_compact_subset && ((brace = HDstrrchr(dset, '[')) != NULL)) {\n *brace++ = '\\0';\n\n s = (struct subset_t *)HDcalloc(1, sizeof(struct subset_t));\n parse_hsize_list(brace, &s->start);\n\n while (*brace && *brace != ';')\n brace++;\n\n if (*brace) brace++;\n\n parse_hsize_list(brace, &s->stride);\n\n while (*brace && *brace != ';')\n brace++;\n\n if (*brace) brace++;\n\n parse_hsize_list(brace, &s->count);\n\n while (*brace && *brace != ';')\n brace++;\n\n if (*brace) brace++;\n\n parse_hsize_list(brace, &s->block);\n }\n\n return s;\n}", "label": 0, "cwe": null, "length": 195 }, { "index": 309718, "code": "permutation_apply(const int* perm, int Nperm, const void* inarray,\n\t\t\t\t\t void* outarray, int elemsize) {\n\tvoid* temparr = NULL;\n\tint i;\n\tconst char* cinput;\n\tchar* coutput;\n\n\tif (inarray == outarray) {\n\t\ttemparr = malloc(elemsize * Nperm);\n\t\tcoutput = temparr;\n\t} else\n\t\tcoutput = outarray;\n\n\tcinput = inarray;\n\tfor (i=0; iitemsCheckable) {\n return d->singleSelection ? QTreeWidget::SingleSelection : QTreeWidget::MultiSelection;\n } else {\n return QTreeWidget::selectionMode();\n }\n}", "label": 0, "cwe": null, "length": 54 }, { "index": 457578, "code": "pefile_digest_pe(const void *pebuf, unsigned int pelen,\n\t\t\t struct pefile_context *ctx)\n{\n\tstruct crypto_shash *tfm;\n\tstruct shash_desc *desc;\n\tsize_t digest_size, desc_size;\n\tvoid *digest;\n\tint ret;\n\n\tkenter(\",%u\", ctx->digest_algo);\n\n\t/* Allocate the hashing algorithm we're going to need and find out how\n\t * big the hash operational data will be.\n\t */\n\ttfm = crypto_alloc_shash(hash_algo_name[ctx->digest_algo], 0, 0);\n\tif (IS_ERR(tfm))\n\t\treturn (PTR_ERR(tfm) == -ENOENT) ? -ENOPKG : PTR_ERR(tfm);\n\n\tdesc_size = crypto_shash_descsize(tfm) + sizeof(*desc);\n\tdigest_size = crypto_shash_digestsize(tfm);\n\n\tif (digest_size != ctx->digest_len) {\n\t\tpr_debug(\"Digest size mismatch (%zx != %x)\\n\",\n\t\t\t digest_size, ctx->digest_len);\n\t\tret = -EBADMSG;\n\t\tgoto error_no_desc;\n\t}\n\tpr_debug(\"Digest: desc=%zu size=%zu\\n\", desc_size, digest_size);\n\n\tret = -ENOMEM;\n\tdesc = kzalloc(desc_size + digest_size, GFP_KERNEL);\n\tif (!desc)\n\t\tgoto error_no_desc;\n\n\tdesc->tfm = tfm;\n\tdesc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;\n\tret = crypto_shash_init(desc);\n\tif (ret < 0)\n\t\tgoto error;\n\n\tret = pefile_digest_pe_contents(pebuf, pelen, ctx, desc);\n\tif (ret < 0)\n\t\tgoto error;\n\n\tdigest = (void *)desc + desc_size;\n\tret = crypto_shash_final(desc, digest);\n\tif (ret < 0)\n\t\tgoto error;\n\n\tpr_debug(\"Digest calc = [%*ph]\\n\", ctx->digest_len, digest);\n\n\t/* Check that the PE file digest matches that in the MSCODE part of the\n\t * PKCS#7 certificate.\n\t */\n\tif (memcmp(digest, ctx->digest, ctx->digest_len) != 0) {\n\t\tpr_debug(\"Digest mismatch\\n\");\n\t\tret = -EKEYREJECTED;\n\t} else {\n\t\tpr_debug(\"The digests match!\\n\");\n\t}\n\nerror:\n\tkfree(desc);\nerror_no_desc:\n\tcrypto_free_shash(tfm);\n\tkleave(\" = %d\", ret);\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 506 }, { "index": 518471, "code": "PyvtkDataSetAttributes_SetCopyAttribute(PyObject *self, PyObject *args)\n{\n vtkPythonArgs ap(self, args, \"SetCopyAttribute\");\n vtkObjectBase *vp = ap.GetSelfPointer(self, args);\n vtkDataSetAttributes *op = static_cast(vp);\n\n int temp0;\n int temp1;\n int temp2 = vtkDataSetAttributes::ALLCOPY;\n PyObject *result = NULL;\n\n if (op && ap.CheckArgCount(2, 3) &&\n ap.GetValue(temp0) &&\n ap.GetValue(temp1) &&\n (ap.NoArgsLeft() || ap.GetValue(temp2)))\n {\n if (ap.IsBound())\n {\n op->SetCopyAttribute(temp0, temp1, temp2);\n }\n else\n {\n op->vtkDataSetAttributes::SetCopyAttribute(temp0, temp1, temp2);\n }\n\n if (!ap.ErrorOccurred())\n {\n result = ap.BuildNone();\n }\n }\n\n return result;\n}", "label": 0, "cwe": null, "length": 213 }, { "index": 16959, "code": "sys_poll_togui(void) /* returns 1 if did anything */\n{\n if (sys_nogui)\n return (0);\n /* see if there is stuff still in the buffer, if so we\n must have fallen behind, so just try to clear that. */\n if (sys_flushtogui())\n return (1);\n /* if the flush wasn't complete, wait. */\n if (sys_guibufhead > sys_guibuftail)\n return (0);\n \n /* check for queued updates */\n if (sys_flushqueue())\n return (1);\n \n return (0);\n}", "label": 0, "cwe": null, "length": 132 }, { "index": 75853, "code": "register_acpi_bus_type(struct acpi_bus_type *type)\n{\n\tif (acpi_disabled)\n\t\treturn -ENODEV;\n\tif (type && type->match && type->find_companion) {\n\t\tdown_write(&bus_type_sem);\n\t\tlist_add_tail(&type->list, &bus_type_list);\n\t\tup_write(&bus_type_sem);\n\t\tprintk(KERN_INFO PREFIX \"bus type %s registered\\n\", type->name);\n\t\treturn 0;\n\t}\n\treturn -ENODEV;\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 105387, "code": "heapmem(Vmalloc_t * vm, Void_t * caddr,\n\t\t size_t csize, size_t nsize, Vmdisc_t * disc)\n#else\nstatic Void_t *heapmem(vm, caddr, csize, nsize, disc)\nVmalloc_t *vm;\t\t\t/* region doing allocation from */\nVoid_t *caddr;\t\t\t/* current low address */\nsize_t csize;\t\t\t/* current size */\nsize_t nsize;\t\t\t/* new size */\nVmdisc_t *disc;\t\t\t/* discipline structure */\n#endif\n{\n NOTUSED(vm);\n NOTUSED(disc);\n\n if (csize == 0)\n\treturn vmalloc(Vmheap, nsize);\n else if (nsize == 0)\n\treturn vmfree(Vmheap, caddr) >= 0 ? caddr : NIL(Void_t *);\n else\n\treturn vmresize(Vmheap, caddr, nsize, 0);\n}", "label": 0, "cwe": null, "length": 205 }, { "index": 570985, "code": "dialog_doc_metadata_transform_str_to_float (const GValue *string_value,\n\t\t\t\t\t GValue *float_value)\n{\n\tgnm_float x;\n\tgchar const *str;\n\tGnmValue *conversion;\n\n\tg_return_if_fail (G_VALUE_HOLDS_STRING (string_value));\n\tg_return_if_fail (G_VALUE_HOLDS_FLOAT (float_value));\n\n\tstr = g_value_get_string (string_value);\n\tconversion = format_match_number (str, NULL, NULL);\n\tif (conversion) {\n\t\tx = value_get_as_float (conversion);\n\t\tvalue_release (conversion);\n\t} else\n\t\tx = 0.;\n\n\tg_value_set_float (float_value, x);\n}", "label": 0, "cwe": null, "length": 138 }, { "index": 131708, "code": "parse_printf (const struct parser_table* entry, char **argv, int *arg_ptr)\n{\n const char *format;\n if (collect_arg(argv, arg_ptr, &format))\n {\n struct format_val fmt;\n open_stdout(&fmt);\n return insert_fprintf (&fmt, entry, pred_fprintf, format);\n }\n return false;\n}", "label": 0, "cwe": null, "length": 77 }, { "index": 810985, "code": "parse_xml_acl_index_element_end(void *data, const char *element)\n{\n char *el, *err;\n Acl_index *ad;\n Parse_xml_acs_state *state;\n\n if (parse_xmlns_name(element, NULL, &el) == -1) {\n\tparse_xml_set_error(ds_xprintf(\"Invalid namespace: %s\", element));\n\treturn;\n }\n\n ad = *(Acl_index **) data;\n\n if (parse_xml_is_error(NULL))\n\treturn;\n\n err = \"\";\n if (streq(el, \"acl_index\")) {\n\tif (parse_xml_pop((void **) &state) == PARSE_XML_ERROR)\n\t goto err;\n\tif (state->code != ACS_PARSE_ACL_INDEX || parse_xml_is_not_empty())\n\t goto err;\n\tfree(state);\n }\n else if (streq(el, \"acl_map\")) {\n\tif (parse_xml_pop((void **) &state) == PARSE_XML_ERROR)\n\t goto err;\n\tif (state->code != ACS_PARSE_ACL_MAP)\n\t goto err;\n\tif (state->object.services == NULL)\n\t goto err;\n\tfree(state);\n }\n else if (streq(el, \"services\")) {\n\tif (parse_xml_pop((void **) &state) == PARSE_XML_ERROR)\n\t goto err;\n\tif (state->code != ACS_PARSE_SERVICES)\n\t goto err;\n\tif (state->object.services->service == NULL)\n\t goto err;\n\tfree(state);\n }\n else if (streq(el, \"delegate\")) {\n\t/* Do nothing. */\n }\n else if (streq(el, \"service\")) {\n\t/* Do nothing. */\n }\n else {\n\terr = ds_xprintf(\"Unknown element: %s\", el);\n\tgoto err;\n }\n\n return;\n\n err:\n parse_xml_set_error(err);\n}", "label": 0, "cwe": null, "length": 374 }, { "index": 211149, "code": "sci_start_rx(struct uart_port *port)\n{\n\tunsigned short ctrl;\n\n\tctrl = serial_port_in(port, SCSCR) | port_rx_irq_mask(port);\n\n\tif (port->type == PORT_SCIFA || port->type == PORT_SCIFB)\n\t\tctrl &= ~SCSCR_RDRQE;\n\n\tserial_port_out(port, SCSCR, ctrl);\n}", "label": 0, "cwe": null, "length": 73 }, { "index": 47846, "code": "H5B2_size(H5B2_t *bt2, hid_t dxpl_id, hsize_t *btree_size)\n{\n H5B2_hdr_t\t*hdr; /* Pointer to the B-tree header */\n herr_t ret_value = SUCCEED; /* Return value */\n\n FUNC_ENTER_NOAPI(FAIL)\n\n /* Check arguments. */\n HDassert(bt2);\n HDassert(btree_size);\n\n /* Set the shared v2 B-tree header's file context for this operation */\n bt2->hdr->f = bt2->f;\n\n /* Get the v2 B-tree header */\n hdr = bt2->hdr;\n\n /* Add size of header to B-tree metadata total */\n *btree_size += hdr->hdr_size;\n\n /* Iterate through records */\n if(hdr->root.node_nrec > 0) {\n /* Check for root node being a leaf */\n if(hdr->depth == 0)\n *btree_size += hdr->node_size;\n else\n /* Iterate through nodes */\n if(H5B2_node_size(hdr, dxpl_id, hdr->depth, &hdr->root, btree_size) < 0)\n HGOTO_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL, \"node iteration failed\")\n } /* end if */\n\ndone:\n FUNC_LEAVE_NOAPI(ret_value)\n}", "label": 0, "cwe": null, "length": 294 }, { "index": 22445, "code": "ListColorInfo(FILE *file,\n ExceptionInfo *exception)\n{\n char\n tuple[MaxTextExtent];\n\n const char\n *path;\n\n const ColorInfo\n **color_info;\n\n register ssize_t\n i;\n\n size_t\n number_colors;\n\n /*\n List name and attributes of each color in the list.\n */\n if (file == (const FILE *) NULL)\n file=stdout;\n color_info=GetColorInfoList(\"*\",&number_colors,exception);\n if (color_info == (const ColorInfo **) NULL)\n return(MagickFalse);\n path=(const char *) NULL;\n for (i=0; i < (ssize_t) number_colors; i++)\n {\n if (color_info[i]->stealth != MagickFalse)\n continue;\n if ((path == (const char *) NULL) ||\n (LocaleCompare(path,color_info[i]->path) != 0))\n {\n if (color_info[i]->path != (char *) NULL)\n (void) FormatLocaleFile(file,\"\\nPath: %s\\n\\n\",color_info[i]->path);\n (void) FormatLocaleFile(file,\n \"Name Color \"\n \" Compliance\\n\");\n (void) FormatLocaleFile(file,\n \"-------------------------------------------------\"\n \"------------------------------\\n\");\n }\n path=color_info[i]->path;\n (void) FormatLocaleFile(file,\"%-21.21s \",color_info[i]->name);\n GetColorTuple(&color_info[i]->color,MagickFalse,tuple);\n (void) FormatLocaleFile(file,\"%-45.45s \",tuple);\n if ((color_info[i]->compliance & SVGCompliance) != 0)\n (void) FormatLocaleFile(file,\"SVG \");\n if ((color_info[i]->compliance & X11Compliance) != 0)\n (void) FormatLocaleFile(file,\"X11 \");\n if ((color_info[i]->compliance & XPMCompliance) != 0)\n (void) FormatLocaleFile(file,\"XPM \");\n (void) FormatLocaleFile(file,\"\\n\");\n }\n color_info=(const ColorInfo **) RelinquishMagickMemory((void *) color_info);\n (void) fflush(file);\n return(MagickTrue);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 482 }, { "index": 685451, "code": "ReadTriangulate( string * const & s) {\n using namespace Fem2D;\n KN xy;\n char c;\n int nv;\n for(int step=0;step<2;step++)\n {\n nv=0;\n ifstream f(s->c_str());\n if(!f) {cerr <<\" Error openning file \" << *s << endl;\n ExecError(\"Openning file \");}\n while (f.good())\n {\n R2 P;\n f >> P ;\n if (!f.good()) break;\n if (step) xy[nv]=P;\n nv++;\n while (f.get(c) && (c!='\\n' && c!='\\r' ) ) (void) 0; // eat until control (new line\n } \n if (!step && nv ) xy.init(nv); // alloc the array \n }\n if(verbosity)\n cout << \" we read \" << nv << \" coordinates xy \"<< endl;\n \n Mesh * m=new Mesh(nv,xy); \n m->MakeQuadTree();\n// m->decrement(); // 07/2008 FH auto del ptr\n // delete s; modif mars 2006 auto del ptr\n return m;\n \n}", "label": 0, "cwe": null, "length": 276 }, { "index": 39307, "code": "bLoadIncludes( void )\n{\n wxString os1, os2;\n size_t sz1;\n\n // Need at least a title line, 2 components and an include directive\n if( m_osaNetLst.GetCount( ) < 4 ) return( TRUE );\n\n // Scan circuit description for include directives\n for( sz1=0; sz1spriteExists (keyTable[index].picKey)) {\n count++;\n }\n\n if ((count == 0) && (QString(keyTable[index].picKey) != QString(\"brick\"))) {\n\treturn count;\n }\n\n if (frame < 0) {\n\treturn count;\t\t// This element cannot have more than one frame.\n }\n\n count = 0;\n QString pixmapKey = QString(keyTable[index].picKey) +\n QString(keyTable[index].frameSuffix);\n while (r->spriteExists (pixmapKey.arg (frame))) {\n\tcount++;\n\tframe++;\n }\n\n return count;\n}", "label": 0, "cwe": null, "length": 188 }, { "index": 423402, "code": "mca_atomic_basic_finalize(void)\n{\n void* ptr = NULL;\n\n ptr = (void*) atomic_lock_sync;\n MCA_MEMHEAP_CALL(private_free(ptr));\n atomic_lock_sync = NULL;\n\n ptr = (void*) atomic_lock_turn;\n MCA_MEMHEAP_CALL(private_free(ptr));\n atomic_lock_turn = NULL;\n\n if (local_lock_sync) {\n free((void*) local_lock_sync);\n local_lock_sync = NULL;\n }\n\n if (local_lock_turn) {\n free((void*) local_lock_turn);\n local_lock_turn = NULL;\n }\n\n return OSHMEM_SUCCESS;\n}", "label": 0, "cwe": null, "length": 132 }, { "index": 117270, "code": "KillConnection() {\n\tClientFramework::KillConnection();\n\n\t// last_disconnect = globalreg->timestamp.tv_sec;\n\n\t// Kill all our faked packet sources\n\tfor (map::iterator i = virtual_src_map.begin();\n\t\t i != virtual_src_map.end(); ++i) {\n\t\tpst_packetsource *psrc = \n\t\t\tglobalreg->sourcetracker->FindLivePacketSourceUUID(i->first);\n\t\tKisPacketSource *src = psrc->strong_source;\n\t\tif (src != NULL) {\n\t\t\tglobalreg->sourcetracker->RemoveLivePacketSource(src);\n\t\t\tdelete src;\n\t\t}\n\t}\n\n\tvirtual_src_map.erase(virtual_src_map.begin(), virtual_src_map.end());\n\n\treturn 1;\n}", "label": 0, "cwe": null, "length": 157 }, { "index": 303733, "code": "get_pci_irq(struct pci_dev *dev,\n\t\t\t\tconst struct pciserial_board *board)\n{\n\tif (board->flags & FL_NOIRQ)\n\t\treturn 0;\n\telse\n\t\treturn dev->irq;\n}", "label": 0, "cwe": null, "length": 45 }, { "index": 752781, "code": "apic_update_ppr(struct kvm_lapic *apic)\n{\n\tu32 tpr, isrv, ppr, old_ppr;\n\tint isr;\n\n\told_ppr = kvm_apic_get_reg(apic, APIC_PROCPRI);\n\ttpr = kvm_apic_get_reg(apic, APIC_TASKPRI);\n\tisr = apic_find_highest_isr(apic);\n\tisrv = (isr != -1) ? isr : 0;\n\n\tif ((tpr & 0xf0) >= (isrv & 0xf0))\n\t\tppr = tpr & 0xff;\n\telse\n\t\tppr = isrv & 0xf0;\n\n\tapic_debug(\"vlapic %p, ppr 0x%x, isr 0x%x, isrv 0x%x\",\n\t\t apic, ppr, isr, isrv);\n\n\tif (old_ppr != ppr) {\n\t\tapic_set_reg(apic, APIC_PROCPRI, ppr);\n\t\tif (ppr < old_ppr)\n\t\t\tkvm_make_request(KVM_REQ_EVENT, apic->vcpu);\n\t}\n}", "label": 0, "cwe": null, "length": 239 }, { "index": 764931, "code": "cas_cleanup(void *data)\n{\n\tserver_rec *s = (server_rec *) data;\n\tap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, \"entering cas_cleanup()\");\n\n#if (defined (OPENSSL_THREADS) && APR_HAS_THREADS)\n\tif(CRYPTO_get_locking_callback() == cas_ssl_locking_callback)\n\t\tCRYPTO_set_locking_callback(NULL);\n#ifdef OPENSSL_NO_THREADID\n\tif(CRYPTO_get_id_callback() == cas_ssl_id_callback)\n\t\tCRYPTO_set_id_callback(NULL);\n#else\n\tif(CRYPTO_THREADID_get_callback() == cas_ssl_id_callback)\n\t\tCRYPTO_THREADID_set_callback(NULL);\n#endif /* OPENSSL_NO_THREADID */\n\n#endif /* defined(OPENSSL_THREADS) && APR_HAS_THREADS */\n\tcurl_global_cleanup();\n\tap_log_error(APLOG_MARK, APLOG_DEBUG, 0, s, \"exiting cas_cleanup()\");\n\treturn APR_SUCCESS;\n}", "label": 0, "cwe": null, "length": 184 }, { "index": 39334, "code": "match_hostname_elem(const char *hostname, int helem_len,\n\t\t\t const char *match, int melem_len)\n{\n\tif (!helem_len && !melem_len)\n\t\treturn 0;\n\n\tif (!helem_len || !melem_len)\n\t\treturn -1;\n\n\n\tif (match[0] == '*') {\n\t\tint i;\n\n\t\tfor (i = 1 ; i <= helem_len; i++) {\n\t\t\tif (!match_hostname_elem(hostname + i, helem_len - i,\n\t\t\t\t\t\t match + 1, melem_len - 1))\n\t\t\t\treturn 0;\n\t\t}\n\t\treturn -1;\n\t}\n\n\t/* From the NetBSD (5.1) man page for ctype(3):\n Values of type char or signed char must first be cast to unsigned char,\n\t to ensure that the values are within the correct range. The result\n\t should then be cast to int to avoid warnings from some compilers.\n\t We do indeed get warning \"array subscript has type 'char'\" without\n\t the casts. Ick. */\n\tif (toupper((int)(unsigned char)hostname[0]) ==\n\t toupper((int)(unsigned char)match[0]))\n\t\treturn match_hostname_elem(hostname + 1, helem_len - 1,\n\t\t\t\t\t match + 1, melem_len - 1);\n\n\treturn -1;\n}", "label": 0, "cwe": null, "length": 283 }, { "index": 380142, "code": "setUIDsAndAETitle(DcmUniqueIdentifier& studyUID, DcmUniqueIdentifier& seriesUID, const char *aetitle)\n{\n if (aetitle==NULL) return EC_IllegalCall;\n\n studyInstanceUID = studyUID;\n seriesInstanceUID = seriesUID;\n return retrieveAETitle.putString(aetitle);\n}", "label": 0, "cwe": null, "length": 75 }, { "index": 94332, "code": "_shell_remove_all_custom_widgets (GnomeControlCenterPrivate *priv)\n{\n GtkBox *box;\n GtkWidget *widget;\n guint i;\n\n /* remove from the header */\n box = GTK_BOX (W (priv->builder, \"topright\"));\n for (i = 0; i < priv->custom_widgets->len; i++)\n {\n widget = g_ptr_array_index (priv->custom_widgets, i);\n gtk_container_remove (GTK_CONTAINER (box), widget);\n }\n g_ptr_array_set_size (priv->custom_widgets, 0);\n}", "label": 0, "cwe": null, "length": 120 }, { "index": 793586, "code": "find_intrinsic(const char *s)\n\t \t\t\t/* given name */\n#else /* K&R style */\nfind_intrinsic(s)\n\tchar *s;\t\t\t/* given name */\n#endif /* HAVE_STDC */\n{\n\tunsigned i, h;\n\tunsigned long hnum;\n\n\thnum = kwd_hash(s);\n\tfor(;;) {\n\t h=hnum%INTRINS_HASHSZ;\n\t if( (i=intrins_hashtab[h]) == EMPTY )\n\t break;\t\t/* Not found */\n\n\t\t\t\t/* Something found: see if a match */\n\t if( strcmp(s,intrinsic[i].name) == 0\n#ifndef STANDARD_INTRINSICS\n\t &&\n\t ((intrinsic[i].intrins_flags&(I_EXTRA|I_VMS|I_UNIX))==0 ||\n\t ((intrinsic[i].intrins_flags&I_EXTRA) && intrinsic_set_extra) ||\n\t ((intrinsic[i].intrins_flags&I_UNIX) && intrinsic_set_unix) ||\n\t ((intrinsic[i].intrins_flags&I_VMS) && intrinsic_set_vms)\n\t ) \n#endif\n\t ) {\n\n\t return &intrinsic[i];\n\t }\n\t else {\t\t/* No match: try next */\n\t hnum = rehash(hnum);\n\t }\n\t}\n\t\t\t\t/* Not an intrinsic function */\n\treturn (IntrinsInfo *)NULL;\n}", "label": 0, "cwe": null, "length": 276 }, { "index": 640506, "code": "add_to_migration(obj)\n struct obj *obj;\n{\n if (obj->where != OBJ_FREE)\n\tpanic(\"add_to_migration: obj not free\");\n\n obj->where = OBJ_MIGRATING;\n obj->nobj = migrating_objs;\n migrating_objs = obj;\n}", "label": 0, "cwe": null, "length": 60 }, { "index": 613792, "code": "which_bucket(unsigned int duration, unsigned long nr_iowaiters)\n{\n\tint bucket = 0;\n\n\t/*\n\t * We keep two groups of stats; one with no\n\t * IO pending, one without.\n\t * This allows us to calculate\n\t * E(duration)|iowait\n\t */\n\tif (nr_iowaiters)\n\t\tbucket = BUCKETS/2;\n\n\tif (duration < 10)\n\t\treturn bucket;\n\tif (duration < 100)\n\t\treturn bucket + 1;\n\tif (duration < 1000)\n\t\treturn bucket + 2;\n\tif (duration < 10000)\n\t\treturn bucket + 3;\n\tif (duration < 100000)\n\t\treturn bucket + 4;\n\treturn bucket + 5;\n}", "label": 0, "cwe": null, "length": 159 }, { "index": 644776, "code": "implements(Class *class, Class *test) {\n ClassBlock *test_cb = CLASS_CB(test);\n int i;\n\n for(i = 0; i < test_cb->interfaces_count; i++)\n if((class == test_cb->interfaces[i]) ||\n implements(class, test_cb->interfaces[i]))\n return TRUE;\n\n if(test_cb->super)\n return implements(class, test_cb->super);\n\n return FALSE;\n}", "label": 0, "cwe": null, "length": 91 }, { "index": 973046, "code": "set_time_format(void)\n{\n\tGKeyFile *keyfile = g_key_file_new();\n\tg_key_file_load_from_file(keyfile, config_global, G_KEY_FILE_NONE, NULL);\n\t\n\tgint value = g_key_file_get_integer(keyfile, \"Global\", \"TimeType\", NULL);\n\t\n\tg_key_file_free(keyfile);\n\t\n\tif (value == 24)\n\t{\n\t\tGtkWidget *combo = GTK_WIDGET (gtk_builder_get_object (gxml, \"ampm_combo\"));\n\t\tGtkWidget *hour = GTK_WIDGET (gtk_builder_get_object (gxml, \"hour_spin\"));\n\t\t\n\t\tgtk_widget_hide(GTK_WIDGET(combo));\n\t\t\n\t\tgtk_spin_button_set_range(GTK_SPIN_BUTTON(hour), 0, 23);\n\t}\n\telse if (value == 12)\n\t{\n\t\tGtkWidget *combo = GTK_WIDGET (gtk_builder_get_object (gxml, \"ampm_combo\"));\n\t\tGtkWidget *hour = GTK_WIDGET (gtk_builder_get_object (gxml, \"hour_spin\"));\n\t\t\n\t\tgtk_widget_show(GTK_WIDGET(combo));\n\t\t\n\t\tgtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0);\n\t\t\n\t\tgtk_spin_button_set_range(GTK_SPIN_BUTTON(hour), 0, 11);\n\t}\n\telse\n\t{\n\t\tGKeyFile *keyfile = g_key_file_new();\n\t\tg_key_file_load_from_file(keyfile, config_global, G_KEY_FILE_NONE, NULL);\n\t\t\n\t\tg_key_file_set_integer(keyfile, \"Global\", \"TimeType\", 24);\n\t\t\n\t\tg_key_file_free(keyfile);\n\t\t\n\t\tGtkWidget *combo = GTK_WIDGET (gtk_builder_get_object (gxml, \"ampm_combo\"));\n\t\tGtkWidget *hour = GTK_WIDGET (gtk_builder_get_object (gxml, \"hour_spin\"));\n\t\t\n\t\tgtk_widget_hide(GTK_WIDGET(combo));\n\t\t\n\t\tgtk_spin_button_set_range(GTK_SPIN_BUTTON(hour), 0, 23);\n\t}\n}", "label": 0, "cwe": null, "length": 394 }, { "index": 14419, "code": "ipa_prop_write_all_agg_replacement (void)\n{\n struct cgraph_node *node;\n struct output_block *ob;\n unsigned int count = 0;\n lto_symtab_encoder_iterator lsei;\n lto_symtab_encoder_t encoder;\n\n if (!ipa_node_agg_replacements)\n return;\n\n ob = create_output_block (LTO_section_ipcp_transform);\n encoder = ob->decl_state->symtab_node_encoder;\n ob->cgraph_node = NULL;\n for (lsei = lsei_start_function_in_partition (encoder); !lsei_end_p (lsei);\n lsei_next_function_in_partition (&lsei))\n {\n node = lsei_cgraph_node (lsei);\n if (cgraph_function_with_gimple_body_p (node)\n\t && ipa_get_agg_replacements_for_node (node) != NULL)\n\tcount++;\n }\n\n streamer_write_uhwi (ob, count);\n\n for (lsei = lsei_start_function_in_partition (encoder); !lsei_end_p (lsei);\n lsei_next_function_in_partition (&lsei))\n {\n node = lsei_cgraph_node (lsei);\n if (cgraph_function_with_gimple_body_p (node)\n\t && ipa_get_agg_replacements_for_node (node) != NULL)\n\twrite_agg_replacement_chain (ob, node);\n }\n streamer_write_char_stream (ob->main_stream, 0);\n produce_asm (ob, NULL);\n destroy_output_block (ob);\n}", "label": 0, "cwe": null, "length": 319 }, { "index": 493279, "code": "mdio_sync(unsigned int ioaddr, int bits)\n{\n\tunsigned int mdio_addr = ioaddr + Wn4_PhysicalMgmt;\n\n\t/* Establish sync by sending at least 32 logic ones. */\n\twhile (-- bits >= 0) {\n\t\toutw(MDIO_DATA_WRITE1, mdio_addr);\n\t\toutw(MDIO_DATA_WRITE1 | MDIO_SHIFT_CLK, mdio_addr);\n\t}\n}", "label": 0, "cwe": null, "length": 88 }, { "index": 102905, "code": "update(unsigned char ch)\n{\n incByteCount();\n\n //pack 64 bytes into 16 longs\n inb[byteNr++] = (uint32_t)ch;\n if (byteNr >= 4)\n {\n //note the little-endianness\n uint32_t val =\n inb[3] << 24 | inb[2] << 16 | inb[1] << 8 | inb[0];\n inBuf[longNr++] = val;\n byteNr = 0;\n }\n if (longNr >= 16)\n {\n transform();\n longNr = 0;\n }\n}", "label": 0, "cwe": null, "length": 141 }, { "index": 377443, "code": "cmaes_PerturbSolutionInto( cmaes_t *t, double *rgx, double const *xmean, double eps)\n{\n int i, j, N=t->sp.N;\n double sum; \n\n if (rgx == 0)\n rgx = new_double(N);\n if (xmean == 0)\n FATAL(\"cmaes_PerturbSolutionInto(): xmean was not given\",0,0,0);\n\n for (i = 0; i < N; ++i)\n t->rgdTmp[i] = t->rgD[i] * random_Gauss(&t->rand);\n /* add mutation (sigma * B * (D*z)) */\n for (i = 0; i < N; ++i) {\n for (j = 0, sum = 0.; j < N; ++j)\n sum += t->B[i][j] * t->rgdTmp[j];\n rgx[i] = xmean[i] + eps * t->sigma * sum;\n }\n return rgx;\n}", "label": 0, "cwe": null, "length": 234 }, { "index": 613642, "code": "getAverageRon(VimosImage *image)\n{\n\n double meanRon;\n int i;\n VimosFloatArray *ronList;\n\n\n /*\n * Estimate the readout noise for each individual port and calculate\n * the average readout noise.\n */\n\n if (!(ronList = getImageRon(image)))\n return -1;\n\n for (i=0; ilen; i++) printf(\"*** %f ***\\n\", ronList->data[i]);\n\n meanRon = computeAverageFloat(ronList->data, ronList->len);\n\n\n /*\n * Cleanup\n */\n\n deleteFloatArray(ronList);\n\n return meanRon;\n\n}", "label": 0, "cwe": null, "length": 142 }, { "index": 343712, "code": "use_cream_pie(struct obj *obj)\n{\n bool wasblind = Blind;\n bool wascreamed = u.ucreamed;\n bool several = false;\n\n if (obj->quan > 1L)\n {\n several = true;\n obj = splitobj(obj, 1L);\n }\n if (Hallucination)\n {\n You(\"give yourself a facial.\");\n }\n else\n {\n pline(\"You immerse your %s in %s%s.\", body_part(FACE),\n several ? \"one of \" : \"\",\n several ? makeplural(the(xname(obj))) : the(xname(obj)));\n }\n if (can_blnd(NULL, &youmonst, AT_WEAP, obj))\n {\n int blindinc = rnd(25);\n u.ucreamed += blindinc;\n make_blinded(Blinded + (long)blindinc, false);\n if (!Blind || (Blind && wasblind))\n {\n pline(\"There's %ssticky goop all over your %s.\",\n wascreamed ? \"more \" : \"\",\n body_part(FACE));\n }\n else /* Blind && !wasblind */\n {\n You_cant(\"see through all the sticky goop on your %s.\",\n body_part(FACE));\n }\n }\n if (obj->unpaid)\n {\n verbalize(\"You used it, you bought it!\");\n bill_dummy_object(obj);\n }\n obj_extract_self(obj);\n delobj(obj);\n return 0;\n}", "label": 0, "cwe": null, "length": 329 }, { "index": 584815, "code": "mj(A a)\n{\n P p;\n I m=0,j=a->t?2:1,l,k;C *s=a->t?Fs:\" %d\";p.i=a->p;\n DO(a->n,if(!a->t)k=SH(p.i[i]);\n else{l=mfmt(b,s,p.f[i]);k=l-bd();if(k>j)j=k<10?k:10;k=l-k;}if(k>m)m=k);\n R m+=3+--j,gf((F)m+(F)j/10);\n}", "label": 1, "cwe": [ "CWE-120", "CWE-other" ], "length": 122 }, { "index": 629951, "code": "operator() (const Node& lhs, const Node& rhs) const\n\t\t{\n\t\t\treturn lhs.board == rhs.board\n\t\t\t&& lhs.myIdx == rhs.myIdx\n\t\t\t&& lhs.opIdx == rhs.opIdx;\n\t\t}", "label": 0, "cwe": null, "length": 52 }, { "index": 96518, "code": "dictiter_new(PyDictObject *dict, PyTypeObject *itertype)\n{\n dictiterobject *di;\n di = PyObject_GC_New(dictiterobject, itertype);\n if (di == NULL)\n return NULL;\n Py_INCREF(dict);\n di->di_dict = dict;\n di->di_used = dict->ma_used;\n di->di_pos = 0;\n di->len = dict->ma_used;\n if (itertype == &PyDictIterItem_Type) {\n di->di_result = PyTuple_Pack(2, Py_None, Py_None);\n if (di->di_result == NULL) {\n Py_DECREF(di);\n return NULL;\n }\n }\n else\n di->di_result = NULL;\n _PyObject_GC_TRACK(di);\n return (PyObject *)di;\n}", "label": 0, "cwe": null, "length": 174 }, { "index": 381887, "code": "mark_full_partition_used_with_parts(partition_info *part_info,\n uint32 part_id)\n{\n uint32 start= part_id * part_info->num_subparts;\n uint32 end= start + part_info->num_subparts; \n DBUG_ENTER(\"mark_full_partition_used_with_parts\");\n\n for (; start != end; start++)\n {\n DBUG_PRINT(\"info\", (\"1:Mark subpartition %u as used\", start));\n bitmap_set_bit(&part_info->used_partitions, start);\n }\n DBUG_VOID_RETURN;\n}", "label": 0, "cwe": null, "length": 117 }, { "index": 841277, "code": "cp_type_qual_from_rid (tree rid)\n{\n if (rid == ridpointers[(int) RID_CONST])\n return TYPE_QUAL_CONST;\n else if (rid == ridpointers[(int) RID_VOLATILE])\n return TYPE_QUAL_VOLATILE;\n else if (rid == ridpointers[(int) RID_RESTRICT])\n return TYPE_QUAL_RESTRICT;\n\n abort ();\n return TYPE_UNQUALIFIED;\n}", "label": 0, "cwe": null, "length": 91 }, { "index": 544229, "code": "hvc_open(struct tty_struct *tty, struct file * filp)\n{\n\tstruct hvc_struct *hp = tty->driver_data;\n\tunsigned long flags;\n\tint rc = 0;\n\n\tspin_lock_irqsave(&hp->port.lock, flags);\n\t/* Check and then increment for fast path open. */\n\tif (hp->port.count++ > 0) {\n\t\tspin_unlock_irqrestore(&hp->port.lock, flags);\n\t\thvc_kick();\n\t\treturn 0;\n\t} /* else count == 0 */\n\tspin_unlock_irqrestore(&hp->port.lock, flags);\n\n\ttty_port_tty_set(&hp->port, tty);\n\n\tif (hp->ops->notifier_add)\n\t\trc = hp->ops->notifier_add(hp, hp->data);\n\n\t/*\n\t * If the notifier fails we return an error. The tty layer\n\t * will call hvc_close() after a failed open but we don't want to clean\n\t * up there so we'll clean up here and clear out the previously set\n\t * tty fields and return the kref reference.\n\t */\n\tif (rc) {\n\t\ttty_port_tty_set(&hp->port, NULL);\n\t\ttty->driver_data = NULL;\n\t\ttty_port_put(&hp->port);\n\t\tprintk(KERN_ERR \"hvc_open: request_irq failed with rc %d.\\n\", rc);\n\t} else\n\t\t/* We are ready... raise DTR/RTS */\n\t\tif (C_BAUD(tty))\n\t\t\tif (hp->ops->dtr_rts)\n\t\t\t\thp->ops->dtr_rts(hp, 1);\n\n\t/* Force wakeup of the polling thread */\n\thvc_kick();\n\n\treturn rc;\n}", "label": 0, "cwe": null, "length": 360 }, { "index": 358902, "code": "FX_StopAllSounds\n (\n void\n )\n\n {\n int status;\n\n status = MV_KillAllVoices();\n if ( status != MV_Ok )\n {\n FX_SetErrorCode( FX_MultiVocError );\n return( FX_Warning );\n }\n\n return( FX_Ok );\n }", "label": 0, "cwe": null, "length": 70 }, { "index": 1003564, "code": "write_SInt16Number(int d, char *p) {\n\tif (d > 32767)\n\t\treturn 1;\n\telse if (d < -32768)\n\t\treturn 1;\n\t((INR8 *)p)[0] = (INR8)(d >> 8);\n\t((ORD8 *)p)[1] = (ORD8)(d);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 83 }, { "index": 31309, "code": "reformat_new_entries (struct spec_entry *entries, int calign_cli, int align_cli, \n int maxwidth_cli)\n{\n struct spec_entry *entry;\n for (entry = entries; entry; entry = entry->next)\n {\n int calign = -1, align = -1, maxwidth = -1;\n char *name = NULL, *desc = NULL;\n size_t name_len = 0, desc_len = 0;\n split_entry (entry->text, &name, &name_len, &desc, &desc_len);\n free (entry->text);\n\n /* Specify sane defaults if we need to */\n if (calign_cli == -1 || align_cli == -1)\n {\n struct spec_section *section;\n calign = calign_cli;\n align = align_cli;\n for (section = entry->entry_sections; \n section && section != entry->entry_sections_tail;\n section = section->next)\n {\n if (!strcmp (section->name, \"Individual utilities\"))\n {\n if (calign == -1)\n calign = 48 + 1;\n if (align == -1)\n align = 50 + 1;\n break;\n }\n }\n if (calign == -1)\n calign = 32 + 1;\n if (align == -1)\n align = 34 + 1;\n }\n else\n {\n calign = calign_cli;\n align = align_cli;\n }\n\n if (maxwidth_cli == -1)\n maxwidth = 79;\n\n format_entry (name, name_len, desc, desc_len, calign, align, \n maxwidth, &entry->text, &entry->text_len);\n }\n}", "label": 0, "cwe": null, "length": 380 }, { "index": 177547, "code": "phrase_found (GtrWindow * window, gint occurrences)\n{\n GtrStatusbar *statusbar;\n\n statusbar = GTR_STATUSBAR (gtr_window_get_statusbar (window));\n\n if (occurrences > 1)\n {\n gtr_statusbar_flash_message (statusbar,\n 0,\n ngettext\n (\"Found and replaced %d occurrence\",\n \"Found and replaced %d occurrences\",\n occurrences), occurrences);\n }\n else\n {\n if (occurrences == 1)\n gtr_statusbar_flash_message (statusbar,\n 0,\n _(\"Found and replaced one occurrence\"));\n else\n gtr_statusbar_flash_message (statusbar, 0, \" \");\n }\n}", "label": 0, "cwe": null, "length": 155 }, { "index": 663898, "code": "MkStructDeclaration(struct __ecereNameSpace__ecere__sys__OldList * specifiers, struct __ecereNameSpace__ecere__sys__OldList * declarators, struct Specifier * extStorage)\n{\nstruct Declaration * decl = (decl = __ecereNameSpace__ecere__com__eInstance_New(__ecereClass_Declaration), decl->type = 0, decl->declarators = declarators, decl->specifiers = specifiers, decl->extStorage = extStorage, decl->loc = yylloc, decl);\n\nif(specifiers != (((void *)0)))\n{\nunsigned int gotType = 0x0;\nstruct Specifier * spec, * next;\n\nfor(spec = specifiers->first; spec; spec = next)\n{\nnext = spec->next;\nif(gotType && declarators == (((void *)0)) && ((spec->type == 1 && spec->name) || spec->type == 0))\n{\nchar * s = (((void *)0));\n\nif(spec->type == 1)\n{\nchar * colon = __ecereFunction___ecereNameSpace__ecere__sys__RSearchString(spec->name, \"::\", strlen(spec->name), 0x1, 0x0);\n\ns = colon ? colon + 2 : spec->name;\n}\nelse if(spec->type == 0)\n{\nif(spec->specifier == INT64)\ns = \"int64\";\n}\nif(s)\n{\ndecl->declarators = declarators = MkListOne(MkStructDeclarator(MkDeclaratorIdentifier(MkIdentifier(s)), (((void *)0))));\n__ecereMethod___ecereNameSpace__ecere__sys__OldList_Remove(specifiers, spec);\nFreeSpecifier(spec);\nspec = (((void *)0));\n}\n}\nif(spec && spec->type != 5)\ngotType = 0x1;\n}\n}\nreturn decl;\n}", "label": 0, "cwe": null, "length": 401 }, { "index": 994770, "code": "travlock (void)\n{\n int i;\n for (i=0; irefSize; i++)\n if (L->refArray[i].status == LOCK)\n markobject(&L->refArray[i].o);\n}", "label": 0, "cwe": null, "length": 53 }, { "index": 116027, "code": "midgard_reflector_property_get_default_value (MidgardReflectorProperty *self, const gchar *property)\n{\n\tg_return_val_if_fail (self != NULL, NULL);\n\tg_return_val_if_fail (property != NULL, NULL);\t\n\tg_return_val_if_fail (self->priv->klass != NULL, NULL);\n\n\tMgdSchemaPropertyAttr *prop_attr = \n\t\tmidgard_core_class_get_property_attr (MIDGARD_DBOBJECT_CLASS (self->priv->klass), property);\n\tif (prop_attr == NULL)\n\t\treturn NULL;\n\t\n\tif (!prop_attr->default_value)\n\t\treturn NULL;\n\n\tGValue *value = g_new0 (GValue, 1);\n\tg_value_init (value, G_VALUE_TYPE (prop_attr->default_value));\n\tg_value_copy (prop_attr->default_value, value);\n\n\treturn value;\n}", "label": 0, "cwe": null, "length": 173 }, { "index": 958891, "code": "seahorse_pgp_key_canonize_id (const gchar *keyid)\n{\n\tgchar *str;\n\tGQuark id;\n\t\n\tstr = seahorse_pgp_key_calc_id (keyid, 0);\n\tg_return_val_if_fail (str, 0);\n\t\n\tid = g_quark_from_string (str);\n\tg_free (str);\n\t\n\treturn id;\n}", "label": 0, "cwe": null, "length": 79 }, { "index": 65601, "code": "test_reset_default__resetting_filepaths_clears_previous_conflicts(void)\n{\n\tconst git_index_entry *conflict_entry[3];\n\tgit_strarray after;\n\n\tchar *paths[] = { \"conflicts-one.txt\" };\n\tchar *after_shas[] = { \"1f85ca51b8e0aac893a621b61a9c2661d6aa6d81\" };\n\n\tinitialize(\"mergedrepo\");\n\n\t_pathspecs.strings = paths;\n\t_pathspecs.count = 1;\n\tafter.strings = after_shas;\n\tafter.count = 1;\n\n\tcl_git_pass(git_index_conflict_get(&conflict_entry[0], &conflict_entry[1],\n\t\t&conflict_entry[2], _index, \"conflicts-one.txt\"));\n\n\tcl_git_pass(git_revparse_single(&_target, _repo, \"9a05ccb\"));\n\tcl_git_pass(git_reset_default(_repo, _target, &_pathspecs));\n\n\tassert_content_in_index(&_pathspecs, true, &after);\n\n\tcl_assert_equal_i(GIT_ENOTFOUND, git_index_conflict_get(&conflict_entry[0],\n\t\t&conflict_entry[1], &conflict_entry[2], _index, \"conflicts-one.txt\"));\n}", "label": 0, "cwe": null, "length": 257 }, { "index": 698018, "code": "FormRequestSimple (boost::function2 callback_): callback(callback_)\n{\n // nothing\n}", "label": 0, "cwe": null, "length": 28 }, { "index": 94419, "code": "ground_term(Term t)\n{\n if (VARIABLE(t))\n return FALSE;\n else {\n int i;\n for (i = 0; i < ARITY(t); i++)\n if (!ground_term(ARG(t,i)))\n\treturn FALSE;\n return TRUE;\n }\n}", "label": 0, "cwe": null, "length": 61 }, { "index": 81782, "code": "ibnlMakeNode(IBNodeType type, int numPorts, char *devName, char* name) {\n#ifdef DEBUG\n printf(\" Making Node:%s dev:%s ports:%d\\n\", name, devName, numPorts);\n#endif\n gp_curInstDef = new IBSysInst(name, devName, numPorts, type);\n gp_curSysDef->addInst(gp_curInstDef);\n }", "label": 0, "cwe": null, "length": 87 }, { "index": 508934, "code": "parseheredoc(void)\n{\n\tstruct heredoc *here;\n\tunion node *n;\n\n\there = heredoclist;\n\theredoclist = NULL;\n\n\twhile (here) {\n\t\tsetprompt_if(needprompt, 2);\n\t\treadtoken1(pgetc(), here->here->type == NHERE ? SQSYNTAX : DQSYNTAX,\n\t\t\t\there->eofmark, here->striptabs);\n\t\tn = stzalloc(sizeof(struct narg));\n\t\tn->narg.type = NARG;\n\t\t/*n->narg.next = NULL; - stzalloc did it */\n\t\tn->narg.text = wordtext;\n\t\tn->narg.backquote = backquotelist;\n\t\there->here->nhere.doc = n;\n\t\there = here->next;\n\t}\n}", "label": 0, "cwe": null, "length": 174 }, { "index": 754603, "code": "cp_parser_objc_protocol_qualifiers (cp_parser* parser)\n{\n tree quals = NULL_TREE, node;\n cp_token *token = cp_lexer_peek_token (parser->lexer);\n\n node = token->u.value;\n\n while (node && TREE_CODE (node) == IDENTIFIER_NODE\n\t && (node == ridpointers [(int) RID_IN]\n\t || node == ridpointers [(int) RID_OUT]\n\t || node == ridpointers [(int) RID_INOUT]\n\t || node == ridpointers [(int) RID_BYCOPY]\n\t || node == ridpointers [(int) RID_BYREF]\n\t || node == ridpointers [(int) RID_ONEWAY]))\n {\n quals = tree_cons (NULL_TREE, node, quals);\n cp_lexer_consume_token (parser->lexer);\n token = cp_lexer_peek_token (parser->lexer);\n node = token->u.value;\n }\n\n return quals;\n}", "label": 0, "cwe": null, "length": 207 }, { "index": 299582, "code": "proxyAuthentication(const QNetworkProxy& proxy, QAuthenticator* authenticator)\n{\n Q_UNUSED(proxy);\n kDebug(7102) << \"Authenticator received -- realm:\" << authenticator->realm() << \"user:\"\n << authenticator->user();\n\n AuthInfo info;\n info.url = m_proxyURL;\n info.realmValue = authenticator->realm();\n info.verifyPath = true; //### whatever\n info.username = authenticator->user();\n\n const bool haveCachedCredentials = checkCachedAuthentication(info);\n\n // if m_socketProxyAuth is a valid pointer then authentication has been attempted before,\n // and it was not successful. see below and saveProxyAuthenticationForSocket().\n if (!haveCachedCredentials || m_socketProxyAuth) {\n // Save authentication info if the connection succeeds. We need to disconnect\n // this after saving the auth data (or an error) so we won't save garbage afterwards!\n connect(m_control, SIGNAL(connected()), this, SLOT(saveProxyAuthentication()));\n //### fillPromptInfo(&info);\n info.prompt = i18n(\"You need to supply a username and a password for \"\n \"the proxy server listed below before you are allowed \"\n \"to access any sites.\");\n info.keepPassword = true;\n info.commentLabel = i18n(\"Proxy:\");\n info.comment = i18n(\"%1 at %2\", info.realmValue, m_proxyURL.host());\n const bool dataEntered = openPasswordDialog(info, i18n(\"Proxy Authentication Failed.\"));\n if (!dataEntered) {\n kDebug(7102) << \"looks like the user canceled proxy authentication.\";\n error(ERR_USER_CANCELED, m_proxyURL.host());\n return;\n }\n }\n authenticator->setUser(info.username);\n authenticator->setPassword(info.password);\n authenticator->setOption(QLatin1String(\"keepalive\"), info.keepPassword);\n\n if (m_socketProxyAuth) {\n *m_socketProxyAuth = *authenticator;\n } else {\n m_socketProxyAuth = new QAuthenticator(*authenticator);\n }\n\n m_proxyURL.setUser(info.username);\n m_proxyURL.setPassword(info.password);\n}", "label": 0, "cwe": null, "length": 462 }, { "index": 862283, "code": "RemoveLine(int line) {\n\tstarts.RemovePartition(line);\n\tif (perLine) {\n\t\tperLine->RemoveLine(line);\n\t}\n}", "label": 0, "cwe": null, "length": 31 }, { "index": 45819, "code": "print_info_set_edge_to_above_footer (PrintInformation *pi, double e_f)\n{\n\tg_return_if_fail (pi != NULL);\n\tprint_info_load_defaults (pi);\n\tg_return_if_fail (pi->page_setup != NULL);\n\n\tpi->edge_to_above_footer = e_f;\n}", "label": 0, "cwe": null, "length": 59 }, { "index": 710179, "code": "print_func_def(ast *a){\n\t#ifdef GEN_TEST_DEBUG\n\tprintf(\"\");\n\t#endif\n\tif (a->data.func_def.thread_generated == 0){\n\t\tprint_func_def_nominal(a);\n\t} else {\n\t\tprint_func_def_thread_gen(a);\n\t}\n}", "label": 0, "cwe": null, "length": 59 }, { "index": 12762, "code": "symbol_int_callback(struct urb *urb)\n{\n\tstruct usb_serial_port *port = urb->context;\n\tstruct symbol_private *priv = usb_get_serial_port_data(port);\n\tunsigned char *data = urb->transfer_buffer;\n\tint status = urb->status;\n\tint result;\n\tint data_length;\n\n\tswitch (status) {\n\tcase 0:\n\t\t/* success */\n\t\tbreak;\n\tcase -ECONNRESET:\n\tcase -ENOENT:\n\tcase -ESHUTDOWN:\n\t\t/* this urb is terminated, clean up */\n\t\tdev_dbg(&port->dev, \"%s - urb shutting down with status: %d\\n\",\n\t\t\t__func__, status);\n\t\treturn;\n\tdefault:\n\t\tdev_dbg(&port->dev, \"%s - nonzero urb status received: %d\\n\",\n\t\t\t__func__, status);\n\t\tgoto exit;\n\t}\n\n\tusb_serial_debug_data(&port->dev, __func__, urb->actual_length, data);\n\n\t/*\n\t * Data from the device comes with a 1 byte header:\n\t *\n\t * ...\n\t */\n\tif (urb->actual_length > 1) {\n\t\tdata_length = data[0];\n\t\tif (data_length > (urb->actual_length - 1))\n\t\t\tdata_length = urb->actual_length - 1;\n\t\ttty_insert_flip_string(&port->port, &data[1], data_length);\n\t\ttty_flip_buffer_push(&port->port);\n\t} else {\n\t\tdev_dbg(&port->dev, \"%s - short packet\\n\", __func__);\n\t}\n\nexit:\n\tspin_lock(&priv->lock);\n\n\t/* Continue trying to always read if we should */\n\tif (!priv->throttled) {\n\t\tresult = usb_submit_urb(port->interrupt_in_urb, GFP_ATOMIC);\n\t\tif (result)\n\t\t\tdev_err(&port->dev,\n\t\t\t \"%s - failed resubmitting read urb, error %d\\n\",\n\t\t\t\t\t\t\t__func__, result);\n\t} else\n\t\tpriv->actually_throttled = true;\n\tspin_unlock(&priv->lock);\n}", "label": 0, "cwe": null, "length": 424 }, { "index": 588061, "code": "find_matching_files_in_directory (const std::string& directory,\n const Glib::PatternSpec& pattern,\n vector& result)\n{\n\tvector tmp_files;\n\n\tget_files_in_directory (directory, tmp_files);\n\tresult.reserve(tmp_files.size());\n\n\tfor (vector::iterator file_iter = tmp_files.begin();\n\t\t\tfile_iter != tmp_files.end();\n\t\t\t++file_iter)\n\t{\n\t\tif (!pattern.match(*file_iter)) continue;\n\n\t\tstd::string full_path(directory);\n\t\tfull_path = Glib::build_filename (full_path, *file_iter);\n\n\t\tresult.push_back(full_path);\n\t}\n}", "label": 0, "cwe": null, "length": 130 }, { "index": 737967, "code": "sese_build_liveouts_use (sese region, bitmap liveouts, basic_block bb,\n\t\t\t tree use)\n{\n unsigned ver;\n basic_block def_bb;\n\n if (TREE_CODE (use) != SSA_NAME)\n return;\n\n ver = SSA_NAME_VERSION (use);\n def_bb = gimple_bb (SSA_NAME_DEF_STMT (use));\n\n if (!def_bb\n || !bb_in_sese_p (def_bb, region)\n || bb_in_sese_p (bb, region))\n return;\n\n bitmap_set_bit (liveouts, ver);\n}", "label": 0, "cwe": null, "length": 121 }, { "index": 110213, "code": "ReadStateChunk(EMUFILE* is, SFORMAT *sf, int size)\r\n{\r\n\tSFORMAT *tmp;\r\n\tint temp = is->ftell();\r\n\r\n\twhile(is->ftell()fread(toa,4)<4)\r\n\t\t\treturn false;\r\n\r\n\t\tread32le(&tsize,is);\r\n\r\n\t\tif((tmp=CheckS(sf,tsize,toa)))\r\n\t\t{\r\n\t\t\tif(tmp->s&FCEUSTATE_INDIRECT)\r\n\t\t\t\tis->fread(*(char **)tmp->v,tmp->s&(~FCEUSTATE_FLAGS));\r\n\t\t\telse\r\n\t\t\t\tis->fread((char *)tmp->v,tmp->s&(~FCEUSTATE_FLAGS));\r\n\r\n#ifndef LSB_FIRST\r\n\t\t\tif(tmp->s&RLSB)\r\n\t\t\t\tFlipByteOrder((uint8*)tmp->v,tmp->s&(~FCEUSTATE_FLAGS));\r\n#endif\r\n\t\t}\r\n\t\telse\r\n\t\t\tis->fseek(tsize,SEEK_CUR);\r\n\t} // while(...)\r\n\treturn true;\r\n}", "label": 1, "cwe": "CWE-other", "length": 225 }, { "index": 77905, "code": "gtk_source_completion_words_get_start_iter (GtkSourceCompletionProvider *provider,\n GtkSourceCompletionContext *context,\n GtkSourceCompletionProposal *proposal,\n GtkTextIter *iter)\n{\n\tgchar *word;\n\tglong nb_chars;\n\n\tgtk_source_completion_context_get_iter (context, iter);\n\n\tword = get_word_at_iter (iter);\n\tg_return_val_if_fail (word != NULL, FALSE);\n\n\tnb_chars = g_utf8_strlen (word, -1);\n\tgtk_text_iter_backward_chars (iter, nb_chars);\n\n\tg_free (word);\n\treturn TRUE;\n}", "label": 0, "cwe": null, "length": 118 }, { "index": 843217, "code": "gst_cmml_dec_convert (GstPad * pad,\n GstFormat src_fmt, gint64 src_val, GstFormat * dest_fmt, gint64 * dest_val)\n{\n GstCmmlDec *dec = GST_CMML_DEC (GST_PAD_PARENT (pad));\n gboolean res = FALSE;\n\n switch (src_fmt) {\n case GST_FORMAT_DEFAULT:\n switch (*dest_fmt) {\n case GST_FORMAT_TIME:\n {\n *dest_val = gst_annodex_granule_to_time (src_val, dec->granulerate_n,\n dec->granulerate_d, dec->granuleshift);\n res = TRUE;\n break;\n }\n default:\n break;\n }\n break;\n default:\n break;\n }\n\n return res;\n}", "label": 0, "cwe": null, "length": 164 }, { "index": 413871, "code": "NSSCKFWC_SetAttributeValue\n(\n NSSCKFWInstance *fwInstance,\n CK_SESSION_HANDLE hSession,\n CK_OBJECT_HANDLE hObject,\n CK_ATTRIBUTE_PTR pTemplate,\n CK_ULONG ulCount\n)\n{\n CK_RV error = CKR_OK;\n NSSCKFWSession *fwSession;\n NSSCKFWObject *fwObject;\n CK_ULONG i;\n\n if (!fwInstance) {\n error = CKR_CRYPTOKI_NOT_INITIALIZED;\n goto loser;\n }\n \n fwSession = nssCKFWInstance_ResolveSessionHandle(fwInstance, hSession);\n if (!fwSession) {\n error = CKR_SESSION_HANDLE_INVALID;\n goto loser;\n }\n\n fwObject = nssCKFWInstance_ResolveObjectHandle(fwInstance, hObject);\n if (!fwObject) {\n error = CKR_OBJECT_HANDLE_INVALID;\n goto loser;\n }\n\n if( (CK_ATTRIBUTE_PTR)CK_NULL_PTR == pTemplate ) {\n error = CKR_ARGUMENTS_BAD;\n goto loser;\n }\n\n for (i=0; i < ulCount; i++) {\n NSSItem value;\n\n value.data = pTemplate[i].pValue;\n value.size = pTemplate[i].ulValueLen;\n\n error = nssCKFWObject_SetAttribute(fwObject, fwSession, \n pTemplate[i].type, &value);\n\n if( CKR_OK != error ) {\n goto loser;\n }\n }\n\n return CKR_OK;\n\n loser:\n switch( error ) {\n case CKR_SESSION_CLOSED:\n /* destroy session? */\n break;\n case CKR_DEVICE_REMOVED:\n /* (void)nssCKFWToken_Destroy(fwToken); */\n break;\n case CKR_ATTRIBUTE_READ_ONLY:\n case CKR_ATTRIBUTE_TYPE_INVALID:\n case CKR_ATTRIBUTE_VALUE_INVALID:\n case CKR_CRYPTOKI_NOT_INITIALIZED:\n case CKR_DEVICE_ERROR:\n case CKR_DEVICE_MEMORY:\n case CKR_FUNCTION_FAILED:\n case CKR_GENERAL_ERROR:\n case CKR_HOST_MEMORY:\n case CKR_OBJECT_HANDLE_INVALID:\n case CKR_SESSION_HANDLE_INVALID:\n case CKR_SESSION_READ_ONLY:\n case CKR_TEMPLATE_INCONSISTENT:\n case CKR_TOKEN_WRITE_PROTECTED:\n break;\n default:\n case CKR_OK:\n error = CKR_GENERAL_ERROR;\n break;\n }\n\n return error;\n}", "label": 0, "cwe": null, "length": 511 }, { "index": 121776, "code": "lpphy_calibrate_rc(struct b43_wldev *dev)\n{\n\tstruct b43_phy_lp *lpphy = dev->phy.lp;\n\n\tif (dev->phy.rev >= 2) {\n\t\tlpphy_rev2plus_rc_calib(dev);\n\t} else if (!lpphy->rc_cap) {\n\t\tif (b43_current_band(dev->wl) == IEEE80211_BAND_2GHZ)\n\t\t\tlpphy_rev0_1_rc_calib(dev);\n\t} else {\n\t\tlpphy_set_rc_cap(dev);\n\t}\n}", "label": 0, "cwe": null, "length": 118 }, { "index": 167093, "code": "nautilus_view_get_nautilus_window_slot (NautilusView *view)\n{\n\tg_assert (view->details->slot != NULL);\n\n\treturn view->details->slot;\n}", "label": 0, "cwe": null, "length": 37 }, { "index": 962377, "code": "fl_set_folder( FL_OBJECT * ob,\n FL_FORM * form )\n{\n FLI_TABFOLDER_SPEC *sp;\n int i,\n done;\n\n if ( ! IsFolderClass( ob ) )\n {\n M_err( \"fl_set_folder\", \"%s is not tabfolder\",\n ob ? ob->label : \"null\" );\n return;\n }\n\n sp = ob->spec;\n for ( done = i = 0; ! done && i < sp->nforms; i++ )\n if ( sp->forms[ i ] == form )\n {\n program_switch( sp->title[ i ], i );\n done = 1;\n }\n}", "label": 0, "cwe": null, "length": 145 }, { "index": 779011, "code": "cut_test_result_get_folded_diff (CutTestResult *result)\n{\n CutTestResultPrivate *priv;\n const gchar *diff;\n\n priv = CUT_TEST_RESULT_GET_PRIVATE(result);\n\n if (priv->folded_diff)\n return priv->folded_diff;\n\n diff = cut_test_result_get_diff(result);\n if (cut_diff_readable_need_fold(diff)) {\n priv->folded_diff =\n cut_diff_readable_folded(priv->expected, priv->actual);\n }\n\n return priv->folded_diff;\n}", "label": 0, "cwe": null, "length": 110 }, { "index": 104484, "code": "hexToInteger() {\n\tint n = 0; // position in string\n\tint m = 0; // position in digit[] to shift\n\tint count; // loop index\n\tint intValue = 0; // integer value of hex string\n\tint digit[5]; // hold values to convert\n\twhile (n < 4) {\n\t\tif ((*this)[n]=='\\0')\n\t\t\tbreak;\n\t\tif ((*this)[n] > '0' && (*this)[n] < '9' )\n\t\t\tdigit[n] = (*this)[n] & 0x0f;\n\t\telse if (((*this)[n] >='a' && (*this)[n] <= 'f') || ((*this)[n] >='A' && (*this)[n] <= 'F'))\n\t\t\tdigit[n] = ((*this)[n] & 0x0f) + 9;\n\t\telse break;\n\t\tn++;\n\t}\n\tcount = n;\n\tm = n - 1;\n\tn = 0;\n\twhile(n < count) {\n\t\t// digit[n] is value of hex digit at position n\n\t\t// (m << 2) is the number of positions to shift\n\t\t// OR the bits into return value\n\t\tintValue = intValue | (digit[n] << (m << 2));\n\t\tm--;\n\t\tn++;\n\t}\n\treturn (intValue);\n}", "label": 0, "cwe": null, "length": 296 }, { "index": 327373, "code": "cbf_rewind_getopt_option ( cbf_getopt_handle handle ) {\n\n if ( !handle ) return CBF_ARGUMENT;\n \n handle->optind = 0 ;\n \n if ( handle->optind >= handle->optstructs_size) return CBF_NOTFOUND;\n \n return 0;\n \n }", "label": 0, "cwe": null, "length": 70 }, { "index": 714204, "code": "write_coff_program( struct prog_info *pi, int address, unsigned int data){\n\n unsigned char *pByte;\n\n if ( !GET_ARG(pi->args, ARG_COFF) )\n return;\n\n /* Coff output keeps track of binary data in memory buffers, address is in bytes not words */\n if ( ci->pRomMemory ) {\n/* JEG\tif ( address <= pi->device->flash_size ) { */ /* JEG 4-23-03 */\n\t\tif ( address <= pi->device->flash_size*2 ) {\n pByte = (unsigned char *)(ci->pRomMemory + address); /* point to low byte in memory */\n *pByte++ = (data & 0xff); /* low byte */\n *pByte = ((data >> 8) & 0xff); /* high byte */\n\n if ( address >= ci->MaxRomAddress )\n ci->MaxRomAddress = address; /* keep high water mark */\n } else {\n pi->error_count++;\n/* JEG\t\tfprintf(stderr, \"Error: FLASH address %d exceeds max range %d\", address, pi->device->flash_size ); */\n\t\t\tfprintf(stderr, \"Error: FLASH address %d exceeds max range %d\", address, pi->device->flash_size*2 );\n }\n }\n}", "label": 0, "cwe": null, "length": 279 }, { "index": 27138, "code": "it_output(index)\n\t int index;\n{\n\tif (object[index]->attributes & ANIMATE) {\n\t\treturn sentence_output(index, FALSE);\n\t} else {\n\t\tif (object[index]->attributes & PLURAL) {\n\t\t\treturn (cstring_resolve(\"THEM_WORD\")->value);\n\t\t} else {\n\t\t\treturn (cstring_resolve(\"IT_WORD\")->value);\n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 80 }, { "index": 416147, "code": "iscsit_remove_cmd_from_connection_recovery(\n\tstruct iscsi_cmd *cmd,\n\tstruct iscsi_session *sess)\n{\n\tstruct iscsi_conn_recovery *cr;\n\n\tif (!cmd->cr) {\n\t\tpr_err(\"struct iscsi_conn_recovery pointer for ITT: 0x%08x\"\n\t\t\t\" is NULL!\\n\", cmd->init_task_tag);\n\t\tBUG();\n\t}\n\tcr = cmd->cr;\n\n\tlist_del_init(&cmd->i_conn_node);\n\treturn --cr->cmd_count;\n}", "label": 0, "cwe": null, "length": 104 }, { "index": 336047, "code": "cmd_selection_format_toggle_font_style_cb (GnmCellIter const *iter, csftfs *closure)\n{\n\tif (iter->cell && iter->cell->value && VALUE_IS_STRING (iter->cell->value)) {\n\t\tconst GOFormat *fmt = VALUE_FMT (iter->cell->value);\n\t\tif (fmt && go_format_is_markup (fmt)) {\n\t\t\tconst PangoAttrList *old_markup =\n\t\t\t\tgo_format_get_markup (fmt);\n\t\t\tPangoAttrList *new_markup = pango_attr_list_copy ((PangoAttrList *)old_markup);\n\t\t\tPangoAttrList *other = pango_attr_list_filter\n\t\t\t\t(new_markup,\n\t\t\t\t (PangoAttrFilterFunc) cmd_selection_format_toggle_font_style_filter,\n\t\t\t\t &closure->pt);\n\t\t\tif (other != NULL) {\n\t\t\t\tGnmSheetRange *sr;\n\t\t\t\tGnmRange r;\n\t\t\t\trange_init_cellpos (&r, &iter->pp.eval);\n\t\t\t\tsr = gnm_sheet_range_new (iter->pp.sheet, &r);\n\t\t\t\tclosure->undo = go_undo_combine (closure->undo,\n\t\t\t\t\t\t\t\t sheet_range_set_markup_undo (sr, new_markup));\n\t\t\t}\n\t\t\tpango_attr_list_unref (new_markup);\n\t\t\tpango_attr_list_unref (other);\n\t\t}\n\t}\n\treturn NULL;\n}", "label": 0, "cwe": null, "length": 269 }, { "index": 433160, "code": "compile_expr(CueCodeGenerator *cg, CueAstExpr *expr)\n{\n switch (expr->type) {\n case CUE_AST_EXPR_NAME:\n {\n _fmt(cg, \"%s\", expr->v.name.id);\n break;\n }\n case CUE_AST_EXPR_STR:\n {\n _fmt(cg, \"%s\", expr->v.str.value);\n break;\n }\n case CUE_AST_EXPR_INTEGER:\n {\n _fmt(cg, \"%s\", expr->v.integer.value);\n break;\n }\n case CUE_AST_EXPR_BOOLEAN:\n {\n _fmt(cg, \"%d\", expr->v.boolean.value ? 1 : 0);\n break;\n }\n case CUE_AST_EXPR_GET_ATTR:\n {\n _fmt(cg, \"(\");\n compile_expr(cg, expr->v.get_attr.target);\n _fmt(cg, \")->%s\", expr->v.get_attr.attr);\n break;\n }\n case CUE_AST_EXPR_CALL:\n {\n CueListNode *node = expr->v.call.args->head;\n compile_expr(cg, expr->v.call.target);\n _fmt(cg, \"(\");\n while (node != NULL) {\n compile_expr(cg, (CueAstExpr*)node->data);\n if (node->next) _fmt(cg, \", \");\n node = node->next;\n }\n _fmt(cg, \")\");\n break;\n }\n };\n}", "label": 0, "cwe": null, "length": 312 }, { "index": 986181, "code": "SelectItem(w, n)\nWidget w;\nint n;\n{\n CcWnnObject obj = (CcWnnObject)w;\n int ret = 0;\n\n if (obj->ccWnn.state == normal_state) return -1;\n\n if (obj->ccWnn.jcbuf == NULL) {\n\tret = -1;\n } else if (n >= 0) {\n\tret = insertSelection(obj, n);\n\tif (obj->ccWnn.textchanged) {\n\t XtCallCallbackList((Widget)obj,\n\t\t\t obj->inputConv.textchangecallback,\n\t\t\t (XtPointer)NULL);\n\t obj->ccWnn.textchanged = False;\n\t}\n }\n\n obj->ccWnn.state = normal_state;\n return ret;\n}", "label": 0, "cwe": null, "length": 161 }, { "index": 31952, "code": "set_amount( gpointer pObj, gnc_numeric value )\n{\n budget_amount_info_t* info = (budget_amount_info_t*)pObj;\n\n g_return_if_fail( pObj != NULL );\n\n gnc_budget_set_account_period_value( info->budget, info->account, info->period_num, value );\n}", "label": 0, "cwe": null, "length": 65 }, { "index": 713013, "code": "pf_normal_map_new(const struct pf_parameter *parameter)\n{\n struct pf_normal_map *pfnm;\n struct pf_map *base_map;\n struct pf_parameter *params;\n struct pf_normal_node *node;\n\n pfnm = fc_malloc(sizeof(*pfnm));\n base_map = &pfnm->base_map;\n params = &base_map->params;\n#ifdef PF_DEBUG\n /* Set the mode, used for cast check. */\n base_map->mode = PF_NORMAL;\n#endif /* PF_DEBUG */\n\n /* Allocate the map. */\n pfnm->lattice = fc_calloc(MAP_INDEX_SIZE, sizeof(struct pf_normal_node));\n pfnm->queue = pq_create(INITIAL_QUEUE_SIZE);\n\n /* 'get_MC' or 'get_costs' callback must be set. */\n fc_assert_ret_val(NULL != parameter->get_MC\n || NULL != parameter->get_costs, NULL);\n\n /* Copy parameters. */\n *params = *parameter;\n\n /* Initialize virtual function table. */\n base_map->destroy = pf_normal_map_destroy;\n base_map->get_move_cost = pf_normal_map_move_cost;\n base_map->get_path = pf_normal_map_path;\n base_map->get_position = pf_normal_map_position;\n if (NULL != params->get_costs) {\n base_map->iterate = pf_jumbo_map_iterate;\n } else {\n base_map->iterate = pf_normal_map_iterate;\n }\n\n /* Initialise the iterator. */\n base_map->tile = params->start_tile;\n\n /* Initialise starting node. */\n node = pfnm->lattice + tile_index(params->start_tile);\n pf_normal_node_init(pfnm, node, params->start_tile);\n /* This makes calculations of turn/moves_left more convenient, but we\n * need to subtract this value before we return cost to the user. Note\n * that cost may be negative if moves_left_initially > move_rate\n * (see pf_turns()). */\n node->cost = pf_move_rate(params) - pf_moves_left_initially(params);\n node->extra_cost = 0;\n node->dir_to_here = PF_DIR_NONE;\n node->status = NS_PROCESSED;\n\n return PF_MAP(pfnm);\n}", "label": 0, "cwe": null, "length": 479 }, { "index": 128980, "code": "CL_AllocDlight (int key)\r\n{\r\n\tint\t\ti;\r\n\tcdlight_t\t*dl;\r\n\r\n// first look for an exact key match\r\n\tif (key)\r\n\t{\r\n\t\tdl = cl_dlights;\r\n\t\tfor (i=0 ; ikey == key)\r\n\t\t\t{\r\n\t\t\t\tmemset (dl, 0, sizeof(*dl));\r\n\t\t\t\tdl->key = key;\r\n\t\t\t\treturn dl;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n// then look for anything else\r\n\tdl = cl_dlights;\r\n\tfor (i=0 ; idie < cl.time)\r\n\t\t{\r\n\t\t\tmemset (dl, 0, sizeof(*dl));\r\n\t\t\tdl->key = key;\r\n\t\t\treturn dl;\r\n\t\t}\r\n\t}\r\n\r\n\tdl = &cl_dlights[0];\r\n\tmemset (dl, 0, sizeof(*dl));\r\n\tdl->key = key;\r\n\treturn dl;\r\n}", "label": 0, "cwe": null, "length": 217 }, { "index": 328024, "code": "ffi_test_15(char* x, char* y) {\n if (strcmp(x, y))\n return \"foo\";\n else\n return \"bar\";\n}", "label": 0, "cwe": null, "length": 36 }, { "index": 273688, "code": "ca0132_volume_get(struct snd_kcontrol *kcontrol,\n\t\t\t\tstruct snd_ctl_elem_value *ucontrol)\n{\n\tstruct hda_codec *codec = snd_kcontrol_chip(kcontrol);\n\tstruct ca0132_spec *spec = codec->spec;\n\thda_nid_t nid = get_amp_nid(kcontrol);\n\tint ch = get_amp_channels(kcontrol);\n\tlong *valp = ucontrol->value.integer.value;\n\n\t/* store the left and right volume */\n\tif (ch & 1) {\n\t\t*valp = spec->vnode_lvol[nid - VNODE_START_NID];\n\t\tvalp++;\n\t}\n\tif (ch & 2) {\n\t\t*valp = spec->vnode_rvol[nid - VNODE_START_NID];\n\t\tvalp++;\n\t}\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 170 }, { "index": 108878, "code": "send(const void *data, int size, const CL_IPAddress &dest)\n{\n\tsockaddr addr;\n\tint len;\n\n\tdest.get_addrinfo(proto, addr, len, impl->domain);\n\t\n\tint result = ::sendto(\n\t\timpl->sock,\n\t\t(const char *) data,\n\t\tsize,\n\t\t0,\n\t\t&addr,\n\t\tlen);\n\tif (result < 0) throw CL_Error(\"CL_Socket::send failed\");\n\n\tif (impl->write) impl->write->start_listen();\n\treturn result;\n}", "label": 0, "cwe": null, "length": 110 }, { "index": 242011, "code": "frsw_unlink_vc(frsw_conn_t *vc)\n{\n if (vc) {\n if (vc->next)\n vc->next->pprev = vc->pprev;\n\n if (vc->pprev)\n *(vc->pprev) = vc->next;\n }\n}", "label": 0, "cwe": null, "length": 63 }, { "index": 983301, "code": "dcache_dir_lseek(struct file *file, loff_t offset, int whence)\n{\n\tstruct dentry *dentry = file->f_path.dentry;\n\tmutex_lock(&d_inode(dentry)->i_mutex);\n\tswitch (whence) {\n\t\tcase 1:\n\t\t\toffset += file->f_pos;\n\t\tcase 0:\n\t\t\tif (offset >= 0)\n\t\t\t\tbreak;\n\t\tdefault:\n\t\t\tmutex_unlock(&d_inode(dentry)->i_mutex);\n\t\t\treturn -EINVAL;\n\t}\n\tif (offset != file->f_pos) {\n\t\tfile->f_pos = offset;\n\t\tif (file->f_pos >= 2) {\n\t\t\tstruct list_head *p;\n\t\t\tstruct dentry *cursor = file->private_data;\n\t\t\tloff_t n = file->f_pos - 2;\n\n\t\t\tspin_lock(&dentry->d_lock);\n\t\t\t/* d_lock not required for cursor */\n\t\t\tlist_del(&cursor->d_child);\n\t\t\tp = dentry->d_subdirs.next;\n\t\t\twhile (n && p != &dentry->d_subdirs) {\n\t\t\t\tstruct dentry *next;\n\t\t\t\tnext = list_entry(p, struct dentry, d_child);\n\t\t\t\tspin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);\n\t\t\t\tif (simple_positive(next))\n\t\t\t\t\tn--;\n\t\t\t\tspin_unlock(&next->d_lock);\n\t\t\t\tp = p->next;\n\t\t\t}\n\t\t\tlist_add_tail(&cursor->d_child, p);\n\t\t\tspin_unlock(&dentry->d_lock);\n\t\t}\n\t}\n\tmutex_unlock(&d_inode(dentry)->i_mutex);\n\treturn offset;\n}", "label": 0, "cwe": null, "length": 331 }, { "index": 736600, "code": "__memp_stat_print(env, flags)\n\tENV *env;\n\tu_int32_t flags;\n{\n\tu_int32_t orig_flags;\n\tint ret;\n\n\torig_flags = flags;\n\tLF_CLR(DB_STAT_CLEAR | DB_STAT_SUBSYSTEM);\n\tif (flags == 0 || LF_ISSET(DB_STAT_ALL)) {\n\t\tret = __memp_print_stats(env,\n\t\t LF_ISSET(DB_STAT_ALL) ? flags : orig_flags);\n\t\tif (flags == 0 || ret != 0)\n\t\t\treturn (ret);\n\t}\n\n\tif (LF_ISSET(DB_STAT_ALL | DB_STAT_MEMP_HASH) &&\n\t (ret = __memp_print_all(env, orig_flags)) != 0)\n\t\treturn (ret);\n\n\treturn (0);\n}", "label": 0, "cwe": null, "length": 153 }, { "index": 796318, "code": "vl_mser_new (int ndims, int const* dims)\n{\n VlMserFilt* f ;\n int *strides, k ;\n\n f = vl_calloc (sizeof(VlMserFilt), 1) ;\n\n f-> ndims = ndims ;\n f-> dims = vl_malloc (sizeof(int) * ndims) ;\n f-> subs = vl_malloc (sizeof(int) * ndims) ;\n f-> dsubs = vl_malloc (sizeof(int) * ndims) ;\n f-> strides = vl_malloc (sizeof(int) * ndims) ;\n\n /* shortcuts */\n strides = f-> strides ;\n\n /* copy dims to f->dims */\n for(k = 0 ; k < ndims ; ++k) {\n f-> dims [k] = dims [k] ;\n }\n\n /* compute strides to move into the N-dimensional image array */\n strides [0] = 1 ;\n for(k = 1 ; k < ndims ; ++k) {\n strides [k] = strides [k-1] * dims [k-1] ;\n }\n\n /* total number of pixels */\n f-> nel = strides [ndims-1] * dims [ndims-1] ;\n\n /* dof of ellipsoids */\n f-> dof = ndims * (ndims + 1) / 2 + ndims ;\n\n /* more buffers */\n f-> perm = vl_malloc (sizeof(vl_uint) * f-> nel) ;\n f-> joins = vl_malloc (sizeof(vl_uint) * f-> nel) ;\n f-> r = vl_malloc (sizeof(VlMserReg) * f-> nel) ;\n\n f-> er = 0 ;\n f-> rer = 0 ;\n f-> mer = 0 ;\n f-> rmer = 0 ;\n f-> ell = 0 ;\n f-> rell = 0 ;\n\n /* other parameters */\n f-> delta = 5 ;\n f-> max_area = 0.75 ;\n f-> min_area = 3.0 / f-> nel ;\n f-> max_variation = 0.25 ;\n f-> min_diversity = 0.2 ;\n\n return f ;\n}", "label": 0, "cwe": null, "length": 496 }, { "index": 68550, "code": "ad7879_gpio_set_value(struct gpio_chip *chip,\n\t\t\t\t unsigned gpio, int value)\n{\n\tstruct ad7879 *ts = container_of(chip, struct ad7879, gc);\n\n\tmutex_lock(&ts->mutex);\n\tif (value)\n\t\tts->cmd_crtl2 |= AD7879_GPIO_DATA;\n\telse\n\t\tts->cmd_crtl2 &= ~AD7879_GPIO_DATA;\n\n\tad7879_write(ts, AD7879_REG_CTRL2, ts->cmd_crtl2);\n\tmutex_unlock(&ts->mutex);\n}", "label": 0, "cwe": null, "length": 109 }, { "index": 780204, "code": "folderview_run_processing_cb(GtkAction *action, gpointer data)\n{\n\tFolderView *folderview = (FolderView *)data;\n\tGtkCMCTree *ctree = GTK_CMCTREE(folderview->ctree);\n\tFolderItem *item;\n\n\tif (!folderview->selected) return;\n\n\titem = gtk_cmctree_node_get_row_data(ctree, folderview->selected);\n\tcm_return_if_fail(item != NULL);\n\tcm_return_if_fail(item->folder != NULL);\n\n\titem->processing_pending = TRUE;\n\tfolder_item_apply_processing(item);\n\titem->processing_pending = FALSE;\n}", "label": 0, "cwe": null, "length": 120 }, { "index": 407520, "code": "radeon_ttm_tt_populate(struct ttm_tt *ttm)\n{\n\tstruct radeon_ttm_tt *gtt = radeon_ttm_tt_to_gtt(ttm);\n\tstruct radeon_device *rdev;\n\tunsigned i;\n\tint r;\n\tbool slave = !!(ttm->page_flags & TTM_PAGE_FLAG_SG);\n\n\tif (ttm->state != tt_unpopulated)\n\t\treturn 0;\n\n\tif (gtt && gtt->userptr) {\n\t\tttm->sg = kzalloc(sizeof(struct sg_table), GFP_KERNEL);\n\t\tif (!ttm->sg)\n\t\t\treturn -ENOMEM;\n\n\t\tttm->page_flags |= TTM_PAGE_FLAG_SG;\n\t\tttm->state = tt_unbound;\n\t\treturn 0;\n\t}\n\n\tif (slave && ttm->sg) {\n\t\tdrm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages,\n\t\t\t\t\t\t gtt->ttm.dma_address, ttm->num_pages);\n\t\tttm->state = tt_unbound;\n\t\treturn 0;\n\t}\n\n\trdev = radeon_get_rdev(ttm->bdev);\n#if IS_ENABLED(CONFIG_AGP)\n\tif (rdev->flags & RADEON_IS_AGP) {\n\t\treturn ttm_agp_tt_populate(ttm);\n\t}\n#endif\n\n#ifdef CONFIG_SWIOTLB\n\tif (swiotlb_nr_tbl()) {\n\t\treturn ttm_dma_populate(>t->ttm, rdev->dev);\n\t}\n#endif\n\n\tr = ttm_pool_populate(ttm);\n\tif (r) {\n\t\treturn r;\n\t}\n\n\tfor (i = 0; i < ttm->num_pages; i++) {\n\t\tgtt->ttm.dma_address[i] = pci_map_page(rdev->pdev, ttm->pages[i],\n\t\t\t\t\t\t 0, PAGE_SIZE,\n\t\t\t\t\t\t PCI_DMA_BIDIRECTIONAL);\n\t\tif (pci_dma_mapping_error(rdev->pdev, gtt->ttm.dma_address[i])) {\n\t\t\twhile (i--) {\n\t\t\t\tpci_unmap_page(rdev->pdev, gtt->ttm.dma_address[i],\n\t\t\t\t\t PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);\n\t\t\t\tgtt->ttm.dma_address[i] = 0;\n\t\t\t}\n\t\t\tttm_pool_unpopulate(ttm);\n\t\t\treturn -EFAULT;\n\t\t}\n\t}\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 497 }, { "index": 83997, "code": "CreatePath( HDF5GroupObjects *poH5Object )\n{\n char pszPath[8192];\n char pszUnderscoreSpaceInName[8192];\n char *popszPath;\n int i;\n char **papszPath;\n\n/* -------------------------------------------------------------------- */\n/* Recurse to the root path */\n/* -------------------------------------------------------------------- */\n pszPath[0]='\\0';\n if( poH5Object->poHparent !=NULL ) {\n popszPath=CreatePath( poH5Object->poHparent );\n strcpy( pszPath,popszPath );\n }\n\n/* -------------------------------------------------------------------- */\n/* add name to the path */\n/* -------------------------------------------------------------------- */\n if( !EQUAL( poH5Object->pszName,\"/\" ) ){\n strcat( pszPath,\"/\" );\n strcat( pszPath,poH5Object->pszName );\n }\n\n/* -------------------------------------------------------------------- */\n/* fill up path for each object */\n/* -------------------------------------------------------------------- */\n if( poH5Object->pszPath == NULL ) {\n\n if( strlen( poH5Object->pszName ) == 1 ) {\n strcat(pszPath, poH5Object->pszName );\n strcpy(pszUnderscoreSpaceInName, poH5Object->pszName);\n }\n else {\n/* -------------------------------------------------------------------- */\n/* Change space for underscore */\n/* -------------------------------------------------------------------- */\n papszPath = CSLTokenizeString2( pszPath,\n \" \", CSLT_HONOURSTRINGS );\n\n strcpy(pszUnderscoreSpaceInName,papszPath[0]);\n for( i=1; i < CSLCount( papszPath ); i++ ) {\n strcat( pszUnderscoreSpaceInName, \"_\" );\n strcat( pszUnderscoreSpaceInName, papszPath[ i ] );\n }\n CSLDestroy(papszPath);\n\n }\n poH5Object->pszUnderscorePath =\n CPLStrdup( pszUnderscoreSpaceInName );\n poH5Object->pszPath = CPLStrdup( pszPath );\n }\n\n return( poH5Object->pszPath );\n}", "label": 0, "cwe": null, "length": 454 }, { "index": 508448, "code": "gimple_duplicate_stmt_histograms (struct function *fun, gimple stmt,\n\t\t\t\t struct function *ofun, gimple ostmt)\n{\n histogram_value val;\n for (val = gimple_histogram_value (ofun, ostmt); val != NULL; val = val->hvalue.next)\n {\n histogram_value new_val = gimple_alloc_histogram_value (fun, val->type, NULL, NULL);\n memcpy (new_val, val, sizeof (*val));\n new_val->hvalue.stmt = stmt;\n new_val->hvalue.counters = XNEWVAR (gcov_type, sizeof (*new_val->hvalue.counters) * new_val->n_counters);\n memcpy (new_val->hvalue.counters, val->hvalue.counters, sizeof (*new_val->hvalue.counters) * new_val->n_counters);\n gimple_add_histogram_value (fun, stmt, new_val);\n }\n}", "label": 1, "cwe": "CWE-120", "length": 196 }, { "index": 119466, "code": "collwcsym (s, len)\n wchar_t *s;\n int len;\n{\n register struct _collwcsym *csp;\n\n for (csp = posix_collwcsyms; csp->name; csp++)\n {\n if (STREQN(csp->name, s, len) && csp->name[len] == L'\\0')\n\treturn (csp->code);\n }\n if (len == 1)\n return s[0];\n return INVALID;\n}", "label": 0, "cwe": null, "length": 107 }, { "index": 88533, "code": "elf_memory(char *image, size_t size) {\n Elf *elf;\n\n elf_assert(_elf_init.e_magic == ELF_MAGIC);\n if (_elf_version == EV_NONE) {\n\tseterr(ERROR_VERSION_UNSET);\n\treturn NULL;\n }\n else if (size == 0 || image == NULL) {\n\t/* TODO: set error code? */\n\treturn NULL;\n }\n\n if (!(elf = (Elf*)malloc(sizeof(Elf)))) {\n\tseterr(ERROR_MEM_ELF);\n\treturn NULL;\n }\n *elf = _elf_init;\n elf->e_size = elf->e_dsize = size;\n elf->e_data = elf->e_rawdata = image;\n elf->e_readable = 1;\n elf->e_disabled = 1;\n elf->e_memory = 1;\n\n _elf_check_type(elf, size);\n return elf;\n}", "label": 0, "cwe": null, "length": 183 }, { "index": 465555, "code": "SetDefaultColor(Field field, int n)\n{\n RegularArray array;\n float \t color[3];\n float \t delta[3];\n\n color[0] = 0.5; color[1] = 0.7; color[2] = 1.0;\n delta[0] = 0.0; delta[1] = 0.0; delta[2] = 0.0;\n\n array = DXNewRegularArray(TYPE_FLOAT, 3, n, (Pointer)color, (Pointer)delta);\n if (! array)\n\treturn ERROR;\n\n DXSetComponentValue(field, \"colors\", (Object)array);\n\n return OK;\n}", "label": 0, "cwe": null, "length": 145 }, { "index": 753848, "code": "JustDied(Unit* pKiller) override\n {\n // Make Eranikus evade in order to despawn all the summons\n if (Creature* pEranikus = m_creature->GetMap()->GetCreature(m_eranikusGuid))\n {\n pEranikus->AI()->EnterEvadeMode();\n }\n\n npc_escortAI::JustDied(pKiller);\n }", "label": 0, "cwe": null, "length": 90 }, { "index": 106468, "code": "InitDefmoduleCode(\n void *theEnv,\n FILE *initFP,\n int imageID,\n int maxIndices)\n {\n#if MAC_MCW || IBM_MCW || MAC_XCD\n#pragma unused(maxIndices)\n#endif\n\n if (EnvGetNextDefmodule(theEnv,NULL) != NULL)\n { fprintf(initFP,\" SetListOfDefmodules(theEnv,(void *) %s%d_1);\\n\",DefmodulePrefix(),imageID); }\n else\n { fprintf(initFP,\" SetListOfDefmodules(theEnv,NULL);\\n\"); }\n fprintf(initFP,\" EnvSetCurrentModule(theEnv,(void *) EnvGetNextDefmodule(theEnv,NULL));\\n\");\n }", "label": 0, "cwe": null, "length": 147 }, { "index": 103764, "code": "FindObjectIndex(JSObjectArray *array, JSObject *obj)\n{\n size_t i;\n\n if (array) {\n i = array->length;\n do {\n\n if (array->vector[--i] == obj)\n return i;\n } while (i != 0);\n }\n\n return NO_PARENT_INDEX;\n}", "label": 0, "cwe": null, "length": 70 }, { "index": 94220, "code": "gdraw_32_on_8_nomag_dithered_nomask(GXDisplay *gdisp, GImage *image, GRect *src) {\n int i,j;\n struct _GImage *base = image->list_len==0?image->u.image:image->u.images[0];\n uint32 *pt, index;\n uint8 *ipt;\n short *r_d, *g_d, *b_d;\n register int rd, gd, bd;\n const struct gcol *pos;\n\n for ( i=src->width-1; i>=0; --i )\n\tgdisp->gg.red_dith[i]= gdisp->gg.green_dith[i] = gdisp->gg.blue_dith[i] = 0;\n\n for ( i=src->y; iy+src->height; ++i ) {\n\tpt = (uint32 *) (base->data + i*base->bytes_per_line) + src->x;\n\tipt = (uint8 *) (gdisp->gg.img->data) + (i-src->y)*gdisp->gg.img->bytes_per_line;\n\trd = gd = bd = 0;\n\tr_d = gdisp->gg.red_dith; g_d = gdisp->gg.green_dith; b_d = gdisp->gg.blue_dith;\n\tfor ( j=src->width-1; j>=0; --j ) {\n\t index = *pt++;\n\t rd += *r_d + COLOR_RED(index); if ( rd<0 ) rd=0; else if ( rd>255 ) rd = 255;\n\t gd += *g_d + COLOR_GREEN(index); if ( gd<0 ) gd=0; else if ( gd>255 ) gd = 255;\n\t bd += *b_d + COLOR_BLUE(index); if ( bd<0 ) bd=0; else if ( bd>255 ) bd = 255;\n\t pos = _GImage_GetIndexedPixel(COLOR_CREATE(rd,gd,bd),gdisp->cs.rev);\n\t *ipt++ = pos->pixel;\n\t *r_d++ = rd = (rd - pos->red)/2;\n\t *g_d++ = gd = (gd - pos->green)/2;\n\t *b_d++ = bd = (bd - pos->blue)/2;\n\t}\n }\n}", "label": 0, "cwe": null, "length": 491 }, { "index": 51706, "code": "qfilt_get_bv_i(Filter *filt, IndexReader *ir)\n{\n BitVector *bv = bv_new_capa(ir->max_doc(ir));\n Searcher *sea = isea_new(ir);\n Weight *weight = q_weight(QF(filt)->query, sea);\n Scorer *scorer = weight->scorer(weight, ir);\n if (scorer) {\n while (scorer->next(scorer)) {\n bv_set(bv, scorer->doc);\n }\n scorer->destroy(scorer);\n }\n weight->destroy(weight);\n free(sea);\n return bv;\n}", "label": 0, "cwe": null, "length": 132 }, { "index": 683074, "code": "read_leshort (FILE* fp, int offset)\n{\n char buf[2];\n if (fseek (fp, offset, SEEK_SET) != 0 ||\n fread (buf, sizeof(char), 2, fp) != 2)\n {\n return -1;\n }\n return ((buf[1] & 0xFF) << 8) | (buf[0] & 0xFF);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 91 }, { "index": 102110, "code": "FcTypecheckValue (FcConfigParse *parse, FcType value, FcType type)\n{\n if (value == FcTypeInteger)\n\tvalue = FcTypeDouble;\n if (type == FcTypeInteger)\n\ttype = FcTypeDouble;\n if (value != type)\n {\n\tif ((value == FcTypeLangSet && type == FcTypeString) ||\n\t (value == FcTypeString && type == FcTypeLangSet) ||\n\t (value == FcTypeInteger && type == FcTypeRange) ||\n\t (value == FcTypeDouble && type == FcTypeRange))\n\t return;\n\tif (type == FcTypeUnknown)\n\t return;\n\t/* It's perfectly fine to use user-define elements in expressions,\n\t * so don't warn in that case. */\n\tif (value == FcTypeUnknown)\n\t return;\n\tFcConfigMessage (parse, FcSevereWarning, \"saw %s, expected %s\",\n\t\t\t FcTypeName (value), FcTypeName (type));\n }\n}", "label": 0, "cwe": null, "length": 228 }, { "index": 874804, "code": "istgt_iscsi_get_authinfo(CONN_Ptr conn, const char *authuser)\n{\n\tchar *authfile = NULL;\n\tint ag_tag;\n\tint rc;\n\n\tSESS_MTX_LOCK(conn);\n\tif (conn->sess->lu != NULL) {\n\t\tag_tag = conn->sess->lu->auth_group;\n\t} else {\n\t\tag_tag = -1;\n\t}\n\tSESS_MTX_UNLOCK(conn);\n\tif (ag_tag < 0) {\n\t\tMTX_LOCK(&conn->istgt->mutex);\n\t\tag_tag = conn->istgt->discovery_auth_group;\n\t\tMTX_UNLOCK(&conn->istgt->mutex);\n\t}\n\tISTGT_TRACELOG(ISTGT_TRACE_DEBUG, \"ag_tag=%d\\n\", ag_tag);\n\n\tMTX_LOCK(&conn->istgt->mutex);\n\tauthfile = xstrdup(conn->istgt->authfile);\n\tMTX_UNLOCK(&conn->istgt->mutex);\n\n\trc = istgt_chap_get_authinfo(&conn->auth, authfile, authuser, ag_tag);\n\tif (rc < 0) {\n\t\tISTGT_ERRLOG(\"chap_get_authinfo() failed\\n\");\n\t\txfree(authfile);\n\t\treturn -1;\n\t}\n\txfree(authfile);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 272 }, { "index": 544159, "code": "vp6_filter(VP56Context *s, uint8_t *dst, uint8_t *src,\n int offset1, int offset2, int stride,\n VP56mv mv, int mask, int select, int luma)\n{\n int filter4 = 0;\n int x8 = mv.x & mask;\n int y8 = mv.y & mask;\n\n if (luma) {\n x8 *= 2;\n y8 *= 2;\n filter4 = s->filter_mode;\n if (filter4 == 2) {\n if (s->max_vector_length &&\n (FFABS(mv.x) > s->max_vector_length ||\n FFABS(mv.y) > s->max_vector_length)) {\n filter4 = 0;\n } else if (s->sample_variance_threshold\n && (vp6_block_variance(src+offset1, stride)\n < s->sample_variance_threshold)) {\n filter4 = 0;\n }\n }\n }\n\n if ((y8 && (offset2-offset1)*s->flip<0) || (!y8 && offset1 > offset2)) {\n offset1 = offset2;\n }\n\n if (filter4) {\n if (!y8) { /* left or right combine */\n vp6_filter_hv4(dst, src+offset1, stride, 1,\n vp6_block_copy_filter[select][x8]);\n } else if (!x8) { /* above or below combine */\n vp6_filter_hv4(dst, src+offset1, stride, stride,\n vp6_block_copy_filter[select][y8]);\n } else {\n s->dsp.vp6_filter_diag4(dst, src+offset1+((mv.x^mv.y)>>31), stride,\n vp6_block_copy_filter[select][x8],\n vp6_block_copy_filter[select][y8]);\n }\n } else {\n if (!x8 || !y8) {\n s->dsp.put_h264_chroma_pixels_tab[0](dst, src+offset1, stride, 8, x8, y8);\n } else {\n vp6_filter_diag2(s, dst, src+offset1 + ((mv.x^mv.y)>>31), stride, x8, y8);\n }\n }\n}", "label": 0, "cwe": null, "length": 490 }, { "index": 52297, "code": "gtk_sheet_draw_border (GtkSheet *sheet, GtkSheetRange new_range)\n{\n GtkWidget *widget;\n GdkRectangle area;\n gint i;\n gint x,y,width,height;\n\n widget = GTK_WIDGET(sheet);\n\n x=COLUMN_LEFT_XPIXEL(sheet,new_range.col0);\n y=ROW_TOP_YPIXEL(sheet,new_range.row0);\n width=COLUMN_LEFT_XPIXEL(sheet,new_range.coli)-x+ \n sheet->column[new_range.coli].width;\n height=ROW_TOP_YPIXEL(sheet,new_range.rowi)-y+\n sheet->row[new_range.rowi].height;\n\n area.x=COLUMN_LEFT_XPIXEL(sheet, MIN_VISIBLE_COLUMN(sheet));\n area.y=ROW_TOP_YPIXEL(sheet, MIN_VISIBLE_ROW(sheet));\n area.width=sheet->sheet_window_width;\n area.height=sheet->sheet_window_height;\n\n if(x<0) {\n width=width+x;\n x=0;\n }\n if(width>area.width) width=area.width+10;\n if(y<0) {\n height=height+y;\n y=0;\n }\n if(height>area.height) height=area.height+10;\n\n gdk_gc_set_clip_rectangle(sheet->xor_gc, &area);\n\n for(i=-1; i<=1; ++i)\n gdk_draw_rectangle (sheet->sheet_window,\n \t sheet->xor_gc,\n FALSE,\n\t x+i,y+i,\n\t width-2*i,height-2*i);\n\n gdk_gc_set_clip_rectangle(sheet->xor_gc, NULL);\n \n gtk_sheet_draw_corners(sheet, new_range);\n\n}", "label": 0, "cwe": null, "length": 337 }, { "index": 918125, "code": "hdf_read_2 (struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)\n{\n long outlen = 0;\n int coffset;\n\n if (offset == 0)\n hfd->cache_valid = 0;\n coffset = isincache (hfd, offset, len);\n if (coffset >= 0) {\n memcpy (buffer, hfd->cache + coffset, len);\n return len;\n }\n hfd->cache_offset = offset;\n if (offset + CACHE_SIZE > hfd->offset + (hfd->physsize - hfd->virtual_size))\n hfd->cache_offset = hfd->offset + (hfd->physsize - hfd->virtual_size) - CACHE_SIZE;\n hdf_seek (hfd, hfd->cache_offset);\n poscheck (hfd, CACHE_SIZE);\n if (hfd->handle_valid == HDF_HANDLE_LINUX)\n outlen = fread (hfd->cache, 1, CACHE_SIZE, hfd->handle->h);\n else if (hfd->handle_valid == HDF_HANDLE_ZFILE)\n outlen = zfile_fread (hfd->cache, 1, CACHE_SIZE, hfd->handle->zf);\n hfd->cache_valid = 0;\n if (outlen != CACHE_SIZE)\n return 0;\n hfd->cache_valid = 1;\n coffset = isincache (hfd, offset, len);\n if (coffset >= 0) {\n memcpy (buffer, hfd->cache + coffset, len);\n return len;\n }\n write_log (\"hdf_read: cache bug! offset=0x%llx len=%d\\n\", offset, len);\n hfd->cache_valid = 0;\n return 0;\n}", "label": 0, "cwe": null, "length": 394 }, { "index": 141244, "code": "is_edr(xfile *xf) {\n\t\n\tif (xf->len < 16)\n\t\treturn 0;\n\n\t/* See if it has the right file ID */\n\tif (strncmp(\"EDR DATA1\", (char *)xf->buf, 16) == 0)\n\t\treturn 1;\n\treturn 0;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-469" ], "length": 69 }, { "index": 912762, "code": "rtl8188e_fill_fake_txdesc(struct adapter *adapt, u8 *desc, u32 BufferLen, u8 ispspoll, u8 is_btqosnull)\n{\n\tstruct tx_desc *ptxdesc;\n\n\t/* Clear all status */\n\tptxdesc = (struct tx_desc *)desc;\n\tmemset(desc, 0, TXDESC_SIZE);\n\n\t/* offset 0 */\n\tptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); /* own, bFirstSeg, bLastSeg; */\n\n\tptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ)<txdw0 |= cpu_to_le32(BufferLen&0x0000ffff); /* Buffer size + command header */\n\n\t/* offset 4 */\n\tptxdesc->txdw1 |= cpu_to_le32((QSLT_MGNT<txdw1 |= cpu_to_le32(NAVUSEHDR);\n\t} else {\n\t\tptxdesc->txdw4 |= cpu_to_le32(BIT(7)); /* Hw set sequence number */\n\t\tptxdesc->txdw3 |= cpu_to_le32((8 << 28)); /* set bit3 to 1. Suugested by TimChen. 2009.12.29. */\n\t}\n\n\tif (is_btqosnull)\n\t\tptxdesc->txdw2 |= cpu_to_le32(BIT(23)); /* BT NULL */\n\n\t/* offset 16 */\n\tptxdesc->txdw4 |= cpu_to_le32(BIT(8));/* driver uses rate */\n\n\t/* USB interface drop packet if the checksum of descriptor isn't correct. */\n\t/* Using this checksum can let hardware recovery from packet bulk out error (e.g. Cancel URC, Bulk out error.). */\n\trtl8188eu_cal_txdesc_chksum(ptxdesc);\n}", "label": 0, "cwe": null, "length": 478 }, { "index": 41547, "code": "runTestCase(svutListener * listener,svutTestFilter * filter)\n{\n\tsvutStatusInfo res;\n\t//send notification\n\tif (listener != NULL)\n\t\tlistener->onTestCaseStart(*this);\n\n\t//done the job\n\tfor (svutTestMethodPtrList::iterator it = tests.begin();it!=tests.end();++it)\n\t{\n\t\t//check if need to execute the methode\n\t\tif (filter == NULL || filter->accept(this->getName(),(*it)->getName()))\n\t\t{\n\t\t\t//send notification\n\t\t\tif (listener != NULL)\n\t\t\t\tlistener->onTestMethodStart(*this,**it);\n\n\t\t\t//run the method\n\t\t\tres = this->runTestMethod(*it);\n\n\t\t\t//send notification\n\t\t\tif (listener != NULL)\n\t\t\t\tlistener->onTestMethodEnd(*this,**it,res);\n\t\t}\n\t}\n\n\t//send notification\n\tif (listener != NULL)\n\t\tlistener->onTestCaseEnd(*this);\n}", "label": 0, "cwe": null, "length": 203 }, { "index": 116528, "code": "reordertips()\n{\n /* Reorders nodep[] and indexing to match species order from first tree */\n /* Assumes tree has spp tips and nayme[] has spp elements, and that there is a\n * one-to-one mapping between tip names and the names in nayme[].\n */\n\n long i, j;\n node *t;\n\n for (i = 0; i < spp-1; i++) {\n for (j = i + 1; j < spp; j++) {\n if (samename(nayme[i], nodep[j]->nayme)) {\n /* switch the pointers in\n * nodep[] and set index accordingly for each node. */\n t = nodep[i];\n \n nodep[i] = nodep[j];\n nodep[i]->index = i+1;\n \n nodep[j] = t;\n nodep[j]->index = j+1;\n \n break; /* next i */\n }\n }\n }\n}", "label": 0, "cwe": null, "length": 214 }, { "index": 625683, "code": "ReadDMXConfig(void)\n{\n int lumpnum;\n unsigned int len;\n char *data;\n\n // TODO: This should be chosen based on gamemode == commercial:\n\n lumpnum = W_CheckNumForName(\"DMXGUS\");\n\n if (lumpnum < 0)\n {\n lumpnum = W_GetNumForName(\"DMXGUSC\");\n }\n\n len = W_LumpLength(lumpnum);\n data = Z_Malloc(len + 1, PU_STATIC, NULL);\n W_ReadLump(lumpnum, data);\n\n return data;\n}", "label": 0, "cwe": null, "length": 126 }, { "index": 54121, "code": "cmpc_rfkill_block(void *data, bool blocked)\n{\n\tacpi_status status;\n\tacpi_handle handle;\n\tunsigned long long state;\n\tbool is_blocked;\n\n\thandle = data;\n\tstatus = cmpc_get_rfkill_wlan(handle, &state);\n\tif (ACPI_FAILURE(status))\n\t\treturn -ENODEV;\n\t/* Check if we really need to call cmpc_set_rfkill_wlan */\n\tis_blocked = state & 1 ? false : true;\n\tif (is_blocked != blocked) {\n\t\tstate = blocked ? 0 : 1;\n\t\tstatus = cmpc_set_rfkill_wlan(handle, state);\n\t\tif (ACPI_FAILURE(status))\n\t\t\treturn -ENODEV;\n\t}\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 147 }, { "index": 793082, "code": "ixgbe_dcb_config_tx_data_arbiter_82599(struct ixgbe_hw *hw,\n\t\t\t\t\t u16 *refill,\n\t\t\t\t\t u16 *max,\n\t\t\t\t\t u8 *bwg_id,\n\t\t\t\t\t u8 *prio_type,\n\t\t\t\t\t u8 *prio_tc)\n{\n\tu32 reg;\n\tu8 i;\n\n\t/*\n\t * Disable the arbiter before changing parameters\n\t * (always enable recycle mode; SP; arb delay)\n\t */\n\treg = IXGBE_RTTPCS_TPPAC | IXGBE_RTTPCS_TPRM |\n\t (IXGBE_RTTPCS_ARBD_DCB << IXGBE_RTTPCS_ARBD_SHIFT) |\n\t IXGBE_RTTPCS_ARBDIS;\n\tIXGBE_WRITE_REG(hw, IXGBE_RTTPCS, reg);\n\n\t/* Map all traffic classes to their UP */\n\treg = 0;\n\tfor (i = 0; i < MAX_USER_PRIORITY; i++)\n\t\treg |= (prio_tc[i] << (i * IXGBE_RTTUP2TC_UP_SHIFT));\n\tIXGBE_WRITE_REG(hw, IXGBE_RTTUP2TC, reg);\n\n\t/* Configure traffic class credits and priority */\n\tfor (i = 0; i < MAX_TRAFFIC_CLASS; i++) {\n\t\treg = refill[i];\n\t\treg |= (u32)(max[i]) << IXGBE_RTTPT2C_MCL_SHIFT;\n\t\treg |= (u32)(bwg_id[i]) << IXGBE_RTTPT2C_BWG_SHIFT;\n\n\t\tif (prio_type[i] == prio_group)\n\t\t\treg |= IXGBE_RTTPT2C_GSP;\n\n\t\tif (prio_type[i] == prio_link)\n\t\t\treg |= IXGBE_RTTPT2C_LSP;\n\n\t\tIXGBE_WRITE_REG(hw, IXGBE_RTTPT2C(i), reg);\n\t}\n\n\t/*\n\t * Configure Tx packet plane (recycle mode; SP; arb delay) and\n\t * enable arbiter\n\t */\n\treg = IXGBE_RTTPCS_TPPAC | IXGBE_RTTPCS_TPRM |\n\t (IXGBE_RTTPCS_ARBD_DCB << IXGBE_RTTPCS_ARBD_SHIFT);\n\tIXGBE_WRITE_REG(hw, IXGBE_RTTPCS, reg);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 494 }, { "index": 513447, "code": "list_shift_unlocked(List *list)\n{\n\tvoid *item;\n\n\tif (!list)\n\t\treturn set_errnull(EINVAL);\n\n\tif (!list->length)\n\t\treturn set_errnull(EINVAL);\n\n\titem = list->list[0];\n\tlist->list[0] = NULL;\n\n\tif (!list_remove_unlocked(list, 0))\n\t{\n\t\tlist->list[0] = item;\n\t\treturn NULL;\n\t}\n\n\treturn item;\n}", "label": 0, "cwe": null, "length": 90 }, { "index": 903193, "code": "trav_table_addlink(trav_table_t *table, haddr_t objno, const char *path)\n{\n size_t i; /* Local index variable */\n\n for(i = 0; i < table->nobjs; i++) {\n if(table->objs[i].objno == objno) {\n size_t n;\n\n /* already inserted? */\n if(HDstrcmp(table->objs[i].name, path) == 0)\n return;\n\n /* allocate space if necessary */\n if(table->objs[i].nlinks == (unsigned)table->objs[i].sizelinks) {\n table->objs[i].sizelinks = MAX(1, table->objs[i].sizelinks * 2);\n table->objs[i].links = (trav_link_t*)HDrealloc(table->objs[i].links, table->objs[i].sizelinks * sizeof(trav_link_t));\n } /* end if */\n\n /* insert it */\n n = table->objs[i].nlinks++;\n table->objs[i].links[n].new_name = (char *)HDstrdup(path);\n\n return;\n } /* end for */\n } /* end for */\n\n HDassert(0 && \"object not in table?!?\");\n}", "label": 0, "cwe": null, "length": 264 }, { "index": 121199, "code": "gt_match_iterator_sw_new(GtEncseq *es1, GtEncseq *es2,\n GtScoreFunction *sf,\n unsigned long min_len,\n unsigned long max_edist,\n GT_UNUSED GtError *err)\n{\n GtMatchIterator *mi;\n GtMatchIteratorSW *mis;\n gt_assert(es1 && es2 && sf);\n gt_error_check(err);\n\n mi = gt_match_iterator_create(gt_match_iterator_sw_class());\n mis = (GtMatchIteratorSW*) mi;\n mis->pvt = gt_calloc(1, sizeof (GtMatchIteratorSWMembers));\n mis->pvt->es1 = gt_encseq_ref(es1);\n mis->pvt->es2 = gt_encseq_ref(es2);\n mis->pvt->sf = gt_score_function_ref(sf);\n mis->pvt->min_len = min_len;\n mis->pvt->max_edist = max_edist;\n mis->pvt->firstali = true;\n return mi;\n}", "label": 0, "cwe": null, "length": 222 }, { "index": 241658, "code": "gvfs_udisks2_volume_monitor_constructor (GType type,\n guint n_construct_properties,\n GObjectConstructParam *construct_properties)\n{\n GObject *ret = NULL;\n GObjectClass *parent_class;\n\n if (the_volume_monitor != NULL)\n {\n ret = g_object_ref (the_volume_monitor);\n goto out;\n }\n\n parent_class = G_OBJECT_CLASS (g_type_class_peek_parent (g_type_class_peek (type)));\n ret = parent_class->constructor (type,\n n_construct_properties,\n construct_properties);\n\n the_volume_monitor = GVFS_UDISKS2_VOLUME_MONITOR (ret);\n\n out:\n return ret;\n}", "label": 0, "cwe": null, "length": 138 }, { "index": 3601, "code": "doc_attr(VALUE vself, VALUE vname){\n VALUE vdoc;\n ESTDOC *doc;\n const char *value;\n vdoc = rb_iv_get(vself, VNDATA);\n Data_Get_Struct(vdoc, ESTDOC, doc);\n Check_Type(vname, T_STRING);\n value = est_doc_attr(doc, StringValuePtr(vname));\n return value ? rb_str_new2(value) : Qnil;\n}", "label": 0, "cwe": null, "length": 92 }, { "index": 989896, "code": "call_init( int track )\n{\n\tswitch ( info.type )\n\t{\n\tcase 'B':\n\t\tr.a = track;\n\t\trun_routine( info.init_addr );\n\t\tbreak;\n\n\tcase 'C':\n\t\tr.a = 0x70;\n\t\tr.x = info.music_addr&0xFF;\n\t\tr.y = info.music_addr >> 8;\n\t\trun_routine( info.play_addr + 3 );\n\t\tr.a = 0;\n\t\tr.x = track;\n\t\trun_routine( info.play_addr + 3 );\n\t\tbreak;\n\t}\n}", "label": 0, "cwe": null, "length": 115 }, { "index": 138911, "code": "uListIndex (ULIST *ul, const void *key, int (*compareFunc)(const void *, const void*)) {\n void **p = uListIn(ul, key, compareFunc);\n return p ? (p - ul->items) : -1;\n}", "label": 0, "cwe": null, "length": 59 }, { "index": 438018, "code": "icalproperty_new_impl(icalproperty_kind kind)\n{\n icalproperty* prop;\n\n if (!icalproperty_kind_is_valid(kind))\n return NULL;\n\n if ( ( prop = (icalproperty*) malloc(sizeof(icalproperty))) == 0) {\n\ticalerror_set_errno(ICAL_NEWFAILED_ERROR);\n\treturn 0;\n }\n \n strcpy(prop->id,\"prop\");\n\n prop->kind = kind;\n prop->parameters = pvl_newlist();\n prop->parameter_iterator = 0;\n prop->value = 0;\n prop->x_name = 0;\n prop->parent = 0;\n\n return prop;\n}", "label": 1, "cwe": "CWE-120", "length": 136 }, { "index": 347800, "code": "MotionBounds(const BBox &b,\n bool useInverse) const {\n if (!actuallyAnimated) \n return useInverse ? Inverse(*startTransform)(b) : (*startTransform)(b);\n BBox ret;\n const int nSteps = 128;\n for (int i = 0; i < nSteps; ++i) {\n Transform t;\n float time = Lerp(float(i)/float(nSteps-1), startTime, endTime);\n Interpolate(time, &t);\n if (useInverse) t = Inverse(t);\n ret = Union(ret, t(b));\n }\n return ret;\n}", "label": 0, "cwe": null, "length": 134 }, { "index": 218731, "code": "default_sort_size (void)\n{\n /* Let SIZE be MEM, but no more than the maximum object size,\n total memory, or system resource limits. Don't bother to check\n for values like RLIM_INFINITY since in practice they are not much\n less than SIZE_MAX. */\n size_t size = SIZE_MAX;\n struct rlimit rlimit;\n if (getrlimit (RLIMIT_DATA, &rlimit) == 0 && rlimit.rlim_cur < size)\n size = rlimit.rlim_cur;\n#ifdef RLIMIT_AS\n if (getrlimit (RLIMIT_AS, &rlimit) == 0 && rlimit.rlim_cur < size)\n size = rlimit.rlim_cur;\n#endif\n\n /* Leave a large safety margin for the above limits, as failure can\n occur when they are exceeded. */\n size /= 2;\n\n#ifdef RLIMIT_RSS\n /* Leave a 1/16 margin for RSS to leave room for code, stack, etc.\n Exceeding RSS is not fatal, but can be quite slow. */\n if (getrlimit (RLIMIT_RSS, &rlimit) == 0 && rlimit.rlim_cur / 16 * 15 < size)\n size = rlimit.rlim_cur / 16 * 15;\n#endif\n\n /* Let MEM be available memory or 1/8 of total memory, whichever\n is greater. */\n double avail = physmem_available ();\n double total = physmem_total ();\n double mem = MAX (avail, total / 8);\n\n /* Leave a 1/4 margin for physical memory. */\n if (total * 0.75 < size)\n size = total * 0.75;\n\n /* Return the minimum of MEM and SIZE, but no less than\n MIN_SORT_SIZE. Avoid the MIN macro here, as it is not quite\n right when only one argument is floating point. */\n if (mem < size)\n size = mem;\n return MAX (size, MIN_SORT_SIZE);\n}", "label": 0, "cwe": null, "length": 441 }, { "index": 7490, "code": "callbacks_move_layer_up_button_clicked (GtkButton *button, gpointer user_data) {\n\tgint index=callbacks_get_selected_row_index();\n\tif (index < 0) {\n\t\tshow_no_layers_warning ();\n\t\treturn;\n\t}\n\tif (index > 0) {\n\t\tgerbv_change_layer_order (mainProject, index, index - 1);\n\t\tcallbacks_update_layer_tree ();\n\t\tcallbacks_select_row (index - 1);\n\t\tif (screenRenderInfo.renderType <= GERBV_RENDER_TYPE_GDK_XOR) {\n\t\t\trender_refresh_rendered_image_on_screen();\n\t\t}\n\t\telse {\n\t\t\trender_recreate_composite_surface (screen.drawing_area);\n\t\t\tcallbacks_force_expose_event_for_screen ();\n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 156 }, { "index": 1007384, "code": "NBC_Sched_unpack(void *inbuf, char tmpinbuf, int count, MPI_Datatype datatype, void *outbuf, char tmpoutbuf, NBC_Schedule *schedule) {\n int size;\n char* ptr;\n NBC_Fn_type type = UNPACK;\n NBC_Args_unpack unpack_args;\n \n /* get size of actual schedule */\n NBC_GET_SIZE(*schedule, size);\n /*printf(\"schedule is %i bytes\\n\", size);*/\n *schedule = (NBC_Schedule)realloc(*schedule, size+sizeof(NBC_Fn_type)+sizeof(NBC_Args_unpack));\n if(*schedule == NULL) { printf(\"Error in realloc()\\n\"); return NBC_OOR; }\n \n /* store the passed arguments */\n unpack_args.inbuf=inbuf;\n unpack_args.tmpinbuf=tmpinbuf;\n unpack_args.count=count;\n unpack_args.datatype=datatype;\n unpack_args.outbuf=outbuf;\n unpack_args.tmpoutbuf=tmpoutbuf;\n\n /* append to the round-schedule */\n ptr = (char*)*schedule + size;\n NBC_PUT_BYTES(ptr,type);\n NBC_PUT_BYTES(ptr,unpack_args);\n\n /* increase number of elements in round-schedule */\n NBC_INC_NUM_ROUND(*schedule);\n NBC_DEBUG(10, \"adding unpack - ends at byte %i\\n\", (int)(size+sizeof(NBC_Fn_type)+sizeof(NBC_Args_unpack)));\n\n /* increase size of schedule */\n NBC_INC_SIZE(*schedule, sizeof(NBC_Fn_type)+sizeof(NBC_Args_unpack));\n\n return NBC_OK;\n}", "label": 0, "cwe": null, "length": 332 }, { "index": 905613, "code": "truncate_file_tree(const char *dir)\n{\n fflush(stderr);\n pid_t pid;\n switch(pid=fork())\n {\n case(0): // child\n SignalHook::Ignore(SIGINT);\n SignalHook::Ignore(SIGTSTP);\n SignalHook::Ignore(SIGQUIT);\n SignalHook::Ignore(SIGHUP);\n execlp(\"rm\",\"rm\",\"-rf\",dir,(char*)NULL);\n perror(\"execlp(rm)\");\n fflush(stderr);\n _exit(1);\n case(-1): // error\n perror(\"fork()\");\n return;\n default: // parent\n (new ProcWait(pid))->Auto(); // don't wait for termination\n }\n}", "label": 0, "cwe": null, "length": 150 }, { "index": 934708, "code": "nis_cat (PyObject *self, PyObject *args, PyObject *kwdict)\n{\n char *domain = NULL;\n char *map;\n struct ypall_callback cb;\n struct ypcallback_data data;\n PyObject *dict;\n int err;\n static char *kwlist[] = {\"map\", \"domain\", NULL};\n\n if (!PyArg_ParseTupleAndKeywords(args, kwdict, \"s|s:cat\",\n kwlist, &map, &domain))\n return NULL;\n if (!domain && ((err = yp_get_default_domain(&domain)) != 0))\n return nis_error(err);\n dict = PyDict_New ();\n if (dict == NULL)\n return NULL;\n cb.foreach = (foreachfunc)nis_foreach;\n data.dict = dict;\n map = nis_mapname (map, &data.fix);\n cb.data = (char *)&data;\n data.state = PyEval_SaveThread();\n err = yp_all (domain, map, &cb);\n PyEval_RestoreThread(data.state);\n if (err != 0) {\n Py_DECREF(dict);\n return nis_error(err);\n }\n return dict;\n}", "label": 0, "cwe": null, "length": 252 }, { "index": 294760, "code": "set_proxy_resolver (SoupSession *session, SoupURI *uri,\n\t\t SoupProxyURIResolver *soup_resolver,\n\t\t GProxyResolver *g_resolver)\n{\n\tSoupSessionPrivate *priv = SOUP_SESSION_GET_PRIVATE (session);\n\n\tG_GNUC_BEGIN_IGNORE_DEPRECATIONS;\n\tsoup_session_remove_feature_by_type (session, SOUP_TYPE_PROXY_URI_RESOLVER);\n\tG_GNUC_END_IGNORE_DEPRECATIONS;\n\tg_clear_object (&priv->proxy_resolver);\n\tg_clear_pointer (&priv->proxy_uri, soup_uri_free);\n\tpriv->proxy_use_default = FALSE;\n\n\tif (uri) {\n\t\tchar *uri_string;\n\n\t\tpriv->proxy_uri = soup_uri_copy (uri);\n\t\turi_string = soup_uri_to_string (uri, FALSE);\n\t\tpriv->proxy_resolver = g_simple_proxy_resolver_new (uri_string, NULL);\n\t\tg_free (uri_string);\n\t} else if (soup_resolver) {\n\t\tG_GNUC_BEGIN_IGNORE_DEPRECATIONS;\n\t\tif (SOUP_IS_PROXY_RESOLVER_DEFAULT (soup_resolver))\n\t\t\tpriv->proxy_resolver = g_object_ref (g_proxy_resolver_get_default ());\n\t\telse\n\t\t\tpriv->proxy_resolver = soup_proxy_resolver_wrapper_new (soup_resolver);\n\t\tG_GNUC_END_IGNORE_DEPRECATIONS;\n\t} else if (g_resolver)\n\t\tpriv->proxy_resolver = g_object_ref (g_resolver);\n}", "label": 0, "cwe": null, "length": 280 }, { "index": 399909, "code": "des_encrypt_file(FILE *input, FILE *output, char *password) {\n\n uint64_t subkeys[16];\n memset(subkeys, 0, 16 * sizeof(uint64_t));\n uint64_t key = keygen(password, subkeys);\n fprintf(stdout, \"Your DES encryption key is %10lx\\n\", key);\n fprintf(stdout, \"To decrypt the file with another program \"\n \"you will need this key.\\n\");\n\n uint64_t buffer[1];\n size_t c;\n uint64_t working;\n size_t block = 1;\n\n fseek(input, 0, SEEK_END);\n size_t filesize = ftell(input) / 8;\n fseek(input, 0, SEEK_SET);\n\n while( ( c = fread((void*)buffer, sizeof(char), 8, input) ) !=0 ) {\n\n if(c == 8 ) {\n working = encrypt(buffer[0], subkeys);\n fwrite((void*)&working, sizeof(char), 8, output);\n }\n\n /*\n Introduce padding for undersize block (should also add a padding block \n if the plaintext fits exactly\n */\n else {\n ((unsigned char*)buffer)[c-1] = (unsigned char) (1 << 7);\n for(int i = c; i < 8; i++) {\n ((unsigned char*)buffer)[i] = 0;\n }\n working = encrypt(buffer[0], subkeys);\n fwrite((void*)&working, sizeof(char), 8, output);\n }\n\n if(block % 1000 == 0) {\n fprintf(stdout, \"\\r[%zd / %zd blocks encrypted (%.2lf%%)]\", \n block, filesize, (double) block / filesize * 100.0);\n fflush(stdout);\n }\n block++;\n }\n fprintf(stdout, \"\\r[%zd / %zd blocks encrypted (%.2lf%%)]\\n\", \n filesize, filesize, 100.0);\n}", "label": 1, "cwe": "CWE-other", "length": 421 }, { "index": 109844, "code": "ei_decode_atom_as(const char *buf, int *index, char* p, int destlen,\n\t\t erlang_char_encoding want_enc,\n\t\t erlang_char_encoding* was_encp,\n\t\t erlang_char_encoding* res_encp)\n{\n const char *s = buf + *index;\n const char *s0 = s;\n int len;\n erlang_char_encoding got_enc;\n \n switch (get8(s)) {\n case ERL_ATOM_EXT:\n\tlen = get16be(s);\n\tgot_enc = ERLANG_LATIN1;\n\tbreak;\n case ERL_SMALL_ATOM_EXT:\n\tlen = get8(s);\n\tgot_enc = ERLANG_LATIN1;\n\tbreak;\n case ERL_ATOM_UTF8_EXT:\n\tlen = get16be(s);\n\tgot_enc = ERLANG_UTF8;\n\tbreak;\n case ERL_SMALL_ATOM_UTF8_EXT:\n\tlen = get8(s);\n\tgot_enc = ERLANG_UTF8;\n\tbreak;\n default:\n\treturn -1;\n }\n \n if ((want_enc & got_enc) || want_enc == ERLANG_ASCII) {\n\tint i, found_non_ascii = 0;\n\tif (len >= destlen)\n\t return -1;\n\tfor (i=0; iiteration_tag()) {\n return true;\n }else{\n _evaliter = _sim->iteration_tag();\n return false;\n }\n}", "label": 0, "cwe": null, "length": 46 }, { "index": 641025, "code": "exists( const KUrl & url, bool source, QWidget* window )\n{\n if ( url.isLocalFile() )\n return QFile::exists( url.toLocalFile() );\n NetAccess kioNet;\n return kioNet.statInternal( url, 0 /*no details*/,\n source ? SourceSide : DestinationSide, window );\n}", "label": 0, "cwe": null, "length": 73 }, { "index": 18197, "code": "param(std::string name, int init, int minVal, int maxVal) {\n OpParam par;\n par._name = name;\n par._gimpType.type = GIMP_PDB_INT32;\n par._gimpType.data.d_int32 = init;\n par._guiType = OpParam::IntSlider;\n par._minInt = minVal;\n par._maxInt = maxVal;\n par._numDecimals = 0;\n _params.push_back(par);\n}", "label": 0, "cwe": null, "length": 107 }, { "index": 173967, "code": "gdl_dock_object_register_init (void)\n{\n#ifdef GDL_DISABLE_DEPRECATED\n const size_t n_default = 4;\n#else\n const size_t n_default = 5;\n#endif\n guint i = 0;\n struct DockRegisterItem default_items[n_default];\n\n if (dock_register)\n return;\n\n dock_register\n = g_array_new (FALSE, FALSE, sizeof (struct DockRegisterItem));\n\n /* add known types */\n default_items[0].nick = \"dock\";\n default_items[0].type = (gpointer) GDL_TYPE_DOCK;\n default_items[1].nick = \"item\";\n default_items[1].type = (gpointer) GDL_TYPE_DOCK_ITEM;\n default_items[2].nick = \"paned\";\n default_items[2].type = (gpointer) GDL_TYPE_DOCK_PANED;\n default_items[3].nick = \"notebook\";\n default_items[3].type = (gpointer) GDL_TYPE_DOCK_NOTEBOOK;\n#ifndef GDL_DISABLE_DEPRECATED\n default_items[4].nick = \"placeholder\";\n default_items[4].type = (gpointer) GDL_TYPE_DOCK_PLACEHOLDER;\n#endif\n\n for (i = 0; i < n_default; i++)\n g_array_append_val (dock_register, default_items[i]);\n}", "label": 0, "cwe": null, "length": 287 }, { "index": 102770, "code": "gt_randomcodes_countocc_setnull(GtRandomcodestab *rct)\n{\n rct->leftborder = NULL;\n rct->countocc_small = NULL;\n rct->leftborder_samples = NULL;\n rct->countocc_exceptions = NULL;\n rct->differentcodes = 0;\n rct->lastincremented_idx = 0;\n rct->lastincremented_valueptr = NULL;\n rct->hashmap_addcount = 0;\n rct->hashmap_incrementcount = 0;\n rct->all_incrementcount = 0;\n rct->hashmap_getcount = 0;\n rct->outfilenameleftborder = NULL;\n#ifdef _LP64\n GT_INITARRAY(&rct->bitchangepoints,GtUlong);\n#endif\n}", "label": 0, "cwe": null, "length": 175 }, { "index": 430147, "code": "array_getcoordinate(t_glist *glist,\n char *elem, int xonset, int yonset, int wonset, int indx,\n t_float basex, t_float basey, t_float xinc,\n t_fielddesc *xfielddesc, t_fielddesc *yfielddesc, t_fielddesc *wfielddesc,\n t_float *xp, t_float *yp, t_float *wp)\n{\n t_float xval, yval, ypix, wpix;\n if (xonset >= 0)\n xval = *(t_float *)(elem + xonset);\n else xval = indx * xinc;\n if (yonset >= 0)\n yval = *(t_float *)(elem + yonset);\n else yval = 0;\n ypix = glist_ytopixels(glist, basey +\n fielddesc_cvttocoord(yfielddesc, yval));\n if (wonset >= 0)\n {\n /* found \"w\" field which controls linewidth. */\n t_float wval = *(t_float *)(elem + wonset);\n wpix = glist_ytopixels(glist, basey + \n fielddesc_cvttocoord(yfielddesc, yval) +\n fielddesc_cvttocoord(wfielddesc, wval)) - ypix;\n if (wpix < 0)\n wpix = -wpix;\n }\n else wpix = 1;\n *xp = glist_xtopixels(glist, basex +\n fielddesc_cvttocoord(xfielddesc, xval));\n *yp = ypix;\n *wp = wpix;\n}", "label": 0, "cwe": null, "length": 384 }, { "index": 363847, "code": "load_default_elevator_module(void)\n{\n\tstruct elevator_type *e;\n\n\tif (!chosen_elevator[0])\n\t\treturn;\n\n\tspin_lock(&elv_list_lock);\n\te = elevator_find(chosen_elevator);\n\tspin_unlock(&elv_list_lock);\n\n\tif (!e)\n\t\trequest_module(\"%s-iosched\", chosen_elevator);\n}", "label": 0, "cwe": null, "length": 68 }, { "index": 21432, "code": "fileRead (const char* const filename)\n{\n m_filename = filename;\n\n frnetorderstream fs (m_filename.c_str(), std::ios::out | std::ios::in | std::ios::binary);\n\n if (fs.fail()) {\n sys_error (ERR_WARNING, \"Unable to open file %s [fileRead]\", m_filename.c_str());\n return false;\n }\n\n if (! headerRead(fs))\n return false;\n\n allocArrays ();\n\n if (! arrayDataRead(fs))\n return false;;\n\n if (! labelsRead (fs))\n return false;\n\n return true;\n}", "label": 0, "cwe": null, "length": 127 }, { "index": 824222, "code": "loadCallerList( void ) {\n\tstruct sProfile *psProfile = NULL;\n\tGList *psList;\n\tgchar *pnDummy = NULL;\n\n\twhile ( nWorkExt != 0 ) {\n\t\tGTK_FLUSH;\n\t}\n\tnWorkExt = 1;\n\n\tif ( bAllProfiles == TRUE ) {\n\t\tfor ( psList = getProfiles(); psList != NULL; psList = psList -> next ) {\n\t\t\tpsProfile = psList -> data;\n\n\t\t\tif ( psProfile != NULL ) {\n\t\t\t\tpnDummy = g_strdup_printf( \"%s/%s/callerlist.csv\", getProfilesDir(), psProfile -> pnName );\n\t\t\t\tparseCsvFile( pnDummy, psProfile -> pnName );\n\t\t\t\tg_free( pnDummy );\n\t\t\t}\n\t\t}\n\t} else {\n\t\tparseCsvFile( getCallerList( psCallMonitorProfile ), psCallMonitorProfile -> pnName );\n\t}\n\n\tif ( bAllProfiles == TRUE || psCallMonitorProfile == getActiveProfile() ) {\n\t\tnWorkExt++;\n\t\tCREATE_THREAD( \"faxvoicebox\", updateFaxVoiceBox, NULL );\n\t}\n\n\tnWorkExt--;\n}", "label": 0, "cwe": null, "length": 236 }, { "index": 728629, "code": "tenEstimateLinear3D(Nrrd *nten, Nrrd **nterrP, Nrrd **nB0P,\n const Nrrd *const *_ndwi, unsigned int dwiLen,\n const Nrrd *_nbmat, int knownB0,\n double thresh, double soft, double b) {\n static const char me[]=\"tenEstimateLinear3D\";\n Nrrd *ndwi;\n airArray *mop;\n int amap[4] = {-1, 0, 1, 2};\n\n if (!(_ndwi)) {\n biffAddf(TEN, \"%s: got NULL pointer\", me);\n return 1;\n }\n mop = airMopNew();\n ndwi = nrrdNew();\n airMopAdd(mop, ndwi, (airMopper)nrrdNuke, airMopAlways);\n if (nrrdJoin(ndwi, (const Nrrd*const*)_ndwi, dwiLen, 0, AIR_TRUE)) {\n biffMovef(TEN, NRRD, \"%s: trouble joining inputs\", me);\n airMopError(mop); return 1;\n }\n\n nrrdAxisInfoCopy(ndwi, _ndwi[0], amap, NRRD_AXIS_INFO_NONE);\n if (tenEstimateLinear4D(nten, nterrP, nB0P,\n ndwi, _nbmat, knownB0, thresh, soft, b)) {\n biffAddf(TEN, \"%s: trouble\", me);\n airMopError(mop); return 1;\n }\n\n airMopOkay(mop);\n return 0;\n}", "label": 0, "cwe": null, "length": 372 }, { "index": 41412, "code": "sanei_hp_accessor_choice_maxsize (HpAccessorChoice this)\n{\n HpChoice\tchoice;\n SANE_Int\tsize\t= 0;\n\n for (choice = this->choices; choice; choice = choice->next)\n if ((SANE_Int)strlen(choice->name) >= size)\n\t size = strlen(choice->name) + 1;\n return size;\n}", "label": 0, "cwe": null, "length": 81 }, { "index": 572202, "code": "named_acl_type_by_name(char *type)\n{\n\n if ( !strcasecmp(type, \"urlregex\") )\n\treturn(ACL_URLREGEX);\n if ( !strcasecmp(type, \"pathregex\") )\n\treturn(ACL_PATHREGEX);\n if ( !strcasecmp(type, \"urlregexi\") )\n\treturn(ACL_URLREGEXI);\n if ( !strcasecmp(type, \"pathregexi\") )\n\treturn(ACL_PATHREGEXI);\n if ( !strcasecmp(type, \"usercharset\") )\n\treturn(ACL_USERCHARSET);\n if ( !strcasecmp(type, \"src_ip\") )\n\treturn(ACL_SRC_IP);\n if ( !strcasecmp(type, \"dst_ip\") )\n\treturn(ACL_DST_IP);\n if ( !strcasecmp(type, \"method\") )\n\treturn(ACL_METHOD);\n if ( !strcasecmp(type, \"port\") )\n\treturn(ACL_PORT);\n if ( !strcasecmp(type, \"dstdom\") )\n\treturn(ACL_DSTDOM);\n if ( !strcasecmp(type, \"dstdom_regex\") )\n\treturn(ACL_DSTDOMREGEX);\n if ( !strcasecmp(type, \"srcdom\") )\n\treturn(ACL_SRCDOM);\n if ( !strcasecmp(type, \"srcdom_regex\") )\n\treturn(ACL_SRCDOMREGEX);\n if ( !strcasecmp(type, \"time\") )\n\treturn(ACL_TIME);\n if ( !strcasecmp(type, \"content_type\") )\n\treturn(ACL_CONTENT_TYPE);\n if ( !strcasecmp(type, \"username\") )\n\treturn(ACL_USERNAME);\n if ( !strcasecmp(type, \"header_substr\") )\n\treturn(ACL_HEADER_SUBSTR);\n return((char)-1);\n}", "label": 0, "cwe": null, "length": 337 }, { "index": 125310, "code": "_mmc_detect_change(struct mmc_host *host, unsigned long delay,\n\t\t\t\tbool cd_irq)\n{\n#ifdef CONFIG_MMC_DEBUG\n\tunsigned long flags;\n\tspin_lock_irqsave(&host->lock, flags);\n\tWARN_ON(host->removed);\n\tspin_unlock_irqrestore(&host->lock, flags);\n#endif\n\n\t/*\n\t * If the device is configured as wakeup, we prevent a new sleep for\n\t * 5 s to give provision for user space to consume the event.\n\t */\n\tif (cd_irq && !(host->caps & MMC_CAP_NEEDS_POLL) &&\n\t\tdevice_can_wakeup(mmc_dev(host)))\n\t\tpm_wakeup_event(mmc_dev(host), 5000);\n\n\thost->detect_change = 1;\n\tmmc_schedule_delayed_work(&host->detect, delay);\n}", "label": 0, "cwe": null, "length": 162 }, { "index": 986208, "code": "_find_arg(struct command *com, int opt)\n{\n\tstruct arg_props *a;\n\tint i, arg;\n\n\tfor (i = 0; i < com->num_args; i++) {\n\t\targ = com->valid_args[i];\n\t\ta = _cmdline.arg_props + arg;\n\n\t\t/*\n\t\t * opt should equal either the\n\t\t * short arg, or the index into\n\t\t * the_args.\n\t\t */\n\t\tif ((a->short_arg && (opt == a->short_arg)) ||\n\t\t (!a->short_arg && (opt == (arg + 128))))\n\t\t\treturn arg;\n\t}\n\n\treturn -1;\n}", "label": 0, "cwe": null, "length": 132 }, { "index": 841962, "code": "spellCheckerCorrected( const QString &old, int pos, const QString &corr )\n{\n if( old!= corr )\n {\n setSelection ( pos, old.length() );\n insert( corr );\n setSelection ( pos, corr.length() );\n }\n}", "label": 0, "cwe": null, "length": 57 }, { "index": 274732, "code": "Resize(vtkIdType sz)\n{\n vtkHyperPoint *newArray;\n vtkIdType newSize, i;\n\n if (sz >= this->Size)\n {\n newSize = this->Size + \n this->Extend*(((sz-this->Size)/this->Extend)+1);\n }\n else\n {\n newSize = sz;\n }\n\n newArray = new vtkHyperPoint[newSize];\n\n for (i=0; iArray[i];\n }\n\n this->Size = newSize;\n delete [] this->Array;\n this->Array = newArray;\n\n return this->Array;\n}", "label": 0, "cwe": null, "length": 140 }, { "index": 910794, "code": "DSDPSetSchurMatOps(DSDP dsdp,struct DSDPSchurMat_Ops* sops, void* mdata){\n int info;\n DSDPFunctionBegin;\n info=DSDPSchurMatSetData(&dsdp->M,sops,mdata);DSDPCHKERR(info);\n DSDPFunctionReturn(0); \n}", "label": 0, "cwe": null, "length": 82 }, { "index": 849424, "code": "ltc_ecc_is_valid_idx(int n)\n{\n int x;\n\n for (x = 0; ltc_ecc_sets[x].size != 0; x++);\n /* -1 is a valid index --- indicating that the domain params were supplied by the user */\n if ((n >= -1) && (n < x)) {\n return 1;\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 86 }, { "index": 803739, "code": "lpass_platform_pcmops_open(struct snd_pcm_substream *substream)\n{\n\tstruct snd_pcm_runtime *runtime = substream->runtime;\n\tstruct snd_soc_pcm_runtime *soc_runtime = substream->private_data;\n\tint ret;\n\n\tsnd_soc_set_runtime_hwparams(substream, &lpass_platform_pcm_hardware);\n\n\truntime->dma_bytes = lpass_platform_pcm_hardware.buffer_bytes_max;\n\n\tret = snd_pcm_hw_constraint_integer(runtime,\n\t\t\tSNDRV_PCM_HW_PARAM_PERIODS);\n\tif (ret < 0) {\n\t\tdev_err(soc_runtime->dev, \"%s() setting constraints failed: %d\\n\",\n\t\t\t\t__func__, ret);\n\t\treturn -EINVAL;\n\t}\n\n\tsnd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 163 }, { "index": 870053, "code": "panel_toplevel_position_is_writable (PanelToplevel *toplevel)\n{\n\tif (panel_lockdown_get_panels_locked_down_s () ||\n\t !(g_settings_is_writable (toplevel->priv->settings,\n\t\t\t\t PANEL_TOPLEVEL_SCREEN_KEY) &&\n\t g_settings_is_writable (toplevel->priv->settings,\n\t\t\t\t PANEL_TOPLEVEL_MONITOR_KEY) &&\n\t g_settings_is_writable (toplevel->priv->settings,\n\t\t\t\t PANEL_TOPLEVEL_ORIENTATION_KEY)))\n\t\treturn FALSE;\n\n\t/* For expanded panels we don't really have to check x and y */\n\tif (panel_toplevel_get_expand (toplevel))\n\t\treturn TRUE;\n\n\treturn (g_settings_is_writable (toplevel->priv->settings,\n\t\t\t\t\tPANEL_TOPLEVEL_X_KEY) &&\n\t\tg_settings_is_writable (toplevel->priv->settings,\n\t\t\t\t\tPANEL_TOPLEVEL_Y_KEY) &&\n\t\tg_settings_is_writable (toplevel->priv->settings,\n\t\t\t\t\tPANEL_TOPLEVEL_X_RIGHT_KEY) &&\n\t\tg_settings_is_writable (toplevel->priv->settings,\n\t\t\t\t\tPANEL_TOPLEVEL_Y_BOTTOM_KEY) &&\n\t\tg_settings_is_writable (toplevel->priv->settings,\n\t\t\t\t\tPANEL_TOPLEVEL_X_CENTERED_KEY) &&\n\t\tg_settings_is_writable (toplevel->priv->settings,\n\t\t\t\t\tPANEL_TOPLEVEL_Y_CENTERED_KEY));\n}", "label": 0, "cwe": null, "length": 276 }, { "index": 351758, "code": "test_message_with_cmd(MAILSTREAM *stream, long int msgno, char *cmd,\n\t\t long char_limit,\t/* limit testing to this many chars from body */\n\t\t int *exitval)\n{\n PIPE_S *tpipe;\n gf_io_t pc;\n int status = 0, flags, err = 0;\n char *resultfile = NULL, *pipe_err;\n\n if(cmd && cmd[0]){\n\t\n\tflags = PIPE_WRITE | PIPE_NOSHELL | PIPE_STDERR | PIPE_NONEWMAIL;\n\n\tdprint((7, \"test_message_with_cmd(msgno=%ld cmd=%s)\\n\",\n\t\tmsgno, cmd));\n\n\tif((tpipe = cmd_pipe_open(cmd, &resultfile, flags, &pc))){\n\n\t prime_raw_pipe_getc(stream, msgno, char_limit, FT_PEEK);\n\t gf_filter_init();\n\t gf_link_filter(gf_nvtnl_local, NULL);\n\t if((pipe_err = gf_pipe(raw_pipe_getc, pc)) != NULL){\n\t\tq_status_message1(SM_ORDER|SM_DING, 3, 3,\n\t\t\t\t \"Internal Error: %.200s\", pipe_err);\n\t\terr++;\n\t }\n\n\t /*\n\t * Don't call new_mail in close_system_pipe because we're probably\n\t * already here from new_mail and we don't want to get loopy.\n\t */\n\t status = close_system_pipe(&tpipe, exitval, pipe_callback);\n\n\t /*\n\t * This is a place where the command can put its output, which we\n\t * are not interested in.\n\t */\n\t if(resultfile){\n\t\tour_unlink(resultfile);\n\t\tfs_give((void **) &resultfile);\n\t }\n\n\t return((err || status) ? -1 : 0);\n\t}\n }\n\n return(-1);\n}", "label": 0, "cwe": null, "length": 381 }, { "index": 358481, "code": "iks_make_auth (iksid *id, const char *pass, const char *sid)\n{\n\tiks *x, *y;\n\n\tx = iks_new (\"iq\");\n\tiks_insert_attrib (x, \"type\", \"set\");\n\ty = iks_insert (x, \"query\");\n\tiks_insert_attrib (y, \"xmlns\", IKS_NS_AUTH);\n\tiks_insert_cdata (iks_insert (y, \"username\"), id->user, 0);\n\tiks_insert_cdata (iks_insert (y, \"resource\"), id->resource, 0);\n\tif(sid) {\n\t\tchar buf[41];\n\t\tiksha *sha;\n\t\tsha = iks_sha_new ();\n\t\tiks_sha_hash (sha, (const unsigned char*)sid, strlen (sid), 0);\n\t\tiks_sha_hash (sha, (const unsigned char*)pass, strlen (pass), 1);\n\t\tiks_sha_print (sha, buf);\n\t\tiks_sha_delete (sha);\n\t\tiks_insert_cdata (iks_insert (y, \"digest\"), buf, 40);\n\t} else {\n\t\tiks_insert_cdata (iks_insert (y, \"password\"), pass, 0);\n\t}\n\treturn x;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 256 }, { "index": 127794, "code": "ycck_cmyk_convert (j_decompress_ptr cinfo,\n\t\t JSAMPIMAGE input_buf, JDIMENSION input_row,\n\t\t JSAMPARRAY output_buf, int num_rows)\n{\n my_cconvert_ptr cconvert = (my_cconvert_ptr) cinfo->cconvert;\n register int y, cb, cr;\n register JSAMPROW outptr;\n register JSAMPROW inptr0, inptr1, inptr2, inptr3;\n register JDIMENSION col;\n JDIMENSION num_cols = cinfo->output_width;\n /* copy these pointers into registers if possible */\n register JSAMPLE * range_limit = cinfo->sample_range_limit;\n register int * Crrtab = cconvert->Cr_r_tab;\n register int * Cbbtab = cconvert->Cb_b_tab;\n register IJG_INT32 * Crgtab = cconvert->Cr_g_tab;\n register IJG_INT32 * Cbgtab = cconvert->Cb_g_tab;\n SHIFT_TEMPS\n\n while (--num_rows >= 0) {\n inptr0 = input_buf[0][input_row];\n inptr1 = input_buf[1][input_row];\n inptr2 = input_buf[2][input_row];\n inptr3 = input_buf[3][input_row];\n input_row++;\n outptr = *output_buf++;\n for (col = 0; col < num_cols; col++) {\n y = GETJSAMPLE(inptr0[col]);\n cb = GETJSAMPLE(inptr1[col]);\n cr = GETJSAMPLE(inptr2[col]);\n /* Range-limiting is essential due to noise introduced by DCT losses. */\n outptr[0] = range_limit[MAXJSAMPLE - (y + Crrtab[cr])];\t/* red */\n outptr[1] = range_limit[MAXJSAMPLE - (y +\t\t\t/* green */\n\t\t\t ((int) RIGHT_SHIFT(Cbgtab[cb] + Crgtab[cr],\n\t\t\t\t\t\t SCALEBITS)))];\n outptr[2] = range_limit[MAXJSAMPLE - (y + Cbbtab[cb])];\t/* blue */\n /* K passes through unchanged */\n outptr[3] = inptr3[col];\t/* don't need GETJSAMPLE here */\n outptr += 4;\n }\n }\n}", "label": 0, "cwe": null, "length": 501 }, { "index": 933156, "code": "process_request_echo(int fd, int pid, struct sockaddr_in *from_addr, struct sockaddr_in *to_addr)\n{\n\tchar buf[BUFSIZE];\n\tint len;\n\t\n\twhile ((len = read(fd, buf, sizeof(buf))) > 0) {\n\t\tprint_read(pid, from_addr, to_addr, len);\n\t\tif (writen(fd, buf, len) != len)\n\t\t\tbreak;\n\t\tprint_write(pid, to_addr, from_addr, len);\n\t}\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-other" ], "length": 99 }, { "index": 796033, "code": "write_typecode(CodingSpool *s, uint8_t type)\n{\n s->typeSpool |= (type & 3) << (14 - s->typeSpoolLength);\n s->typeSpoolLength += 2;\n if (s->typeSpoolLength == 16) {\n bytestream_put_le16(s->pout, s->typeSpool);\n bytestream_put_buffer(s->pout, s->argumentSpool,\n s->args - s->argumentSpool);\n s->typeSpoolLength = 0;\n s->typeSpool = 0;\n s->args = s->argumentSpool;\n }\n}", "label": 0, "cwe": null, "length": 147 }, { "index": 109655, "code": "ena_com_destroy_io_sq(struct ena_com_dev *ena_dev,\n\t\t\t\t struct ena_com_io_sq *io_sq)\n{\n\tstruct ena_com_admin_queue *admin_queue = &ena_dev->admin_queue;\n\tstruct ena_admin_aq_destroy_sq_cmd destroy_cmd;\n\tstruct ena_admin_acq_destroy_sq_resp_desc destroy_resp;\n\tu8 direction;\n\tint ret;\n\n\tmemset(&destroy_cmd, 0x0, sizeof(destroy_cmd));\n\n\tif (io_sq->direction == ENA_COM_IO_QUEUE_DIRECTION_TX)\n\t\tdirection = ENA_ADMIN_SQ_DIRECTION_TX;\n\telse\n\t\tdirection = ENA_ADMIN_SQ_DIRECTION_RX;\n\n\tdestroy_cmd.sq.sq_identity |= (direction <<\n\t\tENA_ADMIN_SQ_SQ_DIRECTION_SHIFT) &\n\t\tENA_ADMIN_SQ_SQ_DIRECTION_MASK;\n\n\tdestroy_cmd.sq.sq_idx = io_sq->idx;\n\tdestroy_cmd.aq_common_descriptor.opcode = ENA_ADMIN_DESTROY_SQ;\n\n\tret = ena_com_execute_admin_command(admin_queue,\n\t\t\t\t\t (struct ena_admin_aq_entry *)&destroy_cmd,\n\t\t\t\t\t sizeof(destroy_cmd),\n\t\t\t\t\t (struct ena_admin_acq_entry *)&destroy_resp,\n\t\t\t\t\t sizeof(destroy_resp));\n\n\tif (unlikely(ret && (ret != -ENODEV)))\n\t\tpr_err(\"failed to destroy io sq error: %d\\n\", ret);\n\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 278 }, { "index": 844075, "code": "drawOn(SDL_Surface *screen)\n{\n if (m_time > 0) {\n m_time--;\n if (m_picture) {\n m_picture->drawOn(screen);\n }\n }\n}", "label": 0, "cwe": null, "length": 43 }, { "index": 913333, "code": "get_Vref()\n{\n\tunsigned int new_value = value.get();\n Vref_high = ((Processor *)cpu)->get_Vdd();\n \tVref_low = 0.0;\n vr_Rhigh = (8 + (16 - (new_value & 0x0f))) * 2000.;\n vr_Rlow = (new_value & 0x0f) * 2000.;\n if (! (new_value & VRR)) // High range ?\n vr_Rlow += 16000.;\n\n vr_Vref = (Vref_high - Vref_low) * vr_Rlow / (vr_Rhigh + vr_Rlow) + Vref_low;\n if (verbose)\n {\n cout << \"VRCON::put Rhigh=\" <stolen);\t/* not frozen */\n\t/* reset */\n\tmemset(mb->buf, 0, mb->capacity);\n\tmb->size = 0;\n }\n}", "label": 0, "cwe": null, "length": 73 }, { "index": 488916, "code": "cofix ()\n{\n\n union fix *fixp_arch;\n\n fixp_arch = fixp;\n\n while (IF == fixp->if1.major)\n fixp--;\n\n if (fixp == (union fix *) fixst)\n {\n error_message (3001);\n return (-1);\n }\n if (WHILE == fixp->while1.major)\n {\n struct cont1 *cp;\n\n if (NULL == fixp->while1.cnext)\n\t{\n#ifdef DEBUG\n\t printfx (\"continue in while fixed\\n\");\n#endif\n\t fixp->while1.cnext = (struct cont1 *) \n\t allocate (sizeof (struct cont1), BLOCK);\n\t fixp->while1.cnext->adr = kodp;\n\t fixp->while1.cnext->next = NULL;\n\t}\n else\n\t{\n\t cp = fixp->while1.cnext;\n\t while (NULL != cp->next)\n\t cp = cp->next;\n\n#ifdef DEBUG\n\t printfx (\"continue in while fixed\\n\");\n#endif\n\t cp->next = (struct cont1 *) \n\t allocate (sizeof (struct cont1), BLOCK);\n\t cp->next->adr = kodp;\n\t cp->next->next = NULL;\n\t}\n }\n if (FOR == fixp->for1.major)\n {\n struct cont1 *cp;\n\n if (NULL == fixp->for1.cnext)\n\t{\n#ifdef DEBUG\n\t printfx (\"continue in for fixed\\n\");\n#endif\n\t fixp->for1.cnext = (struct cont1 *) \n\t allocate (sizeof (struct cont1), BLOCK);\n\t fixp->for1.cnext->adr = kodp;\n\t fixp->for1.cnext->next = NULL;\n\t}\n else\n\t{\n\t cp = fixp->for1.cnext;\n\t while (NULL != cp->next)\n\t cp = cp->next;\n#ifdef DEBUG\n\t printfx (\"continue in for fixed\\n\");\n#endif\n\t cp->next = (struct cont1 *)\n\t allocate (sizeof (struct cont1), BLOCK);\n\t cp->next->adr = kodp;\n\t cp->next->next = NULL;\n\t}\n }\n fixp = fixp_arch;\n return (0);\n}", "label": 0, "cwe": null, "length": 479 }, { "index": 94601, "code": "neon_immediate_valid_for_shift (rtx op, enum machine_mode mode,\n\t\t\t\trtx *modconst, int *elementwidth,\n\t\t\t\tbool isleftshift)\n{\n unsigned int innersize = GET_MODE_SIZE (GET_MODE_INNER (mode));\n unsigned int n_elts = CONST_VECTOR_NUNITS (op), i;\n unsigned HOST_WIDE_INT last_elt = 0;\n unsigned HOST_WIDE_INT maxshift;\n\n /* Split vector constant out into a byte vector. */\n for (i = 0; i < n_elts; i++)\n {\n rtx el = CONST_VECTOR_ELT (op, i);\n unsigned HOST_WIDE_INT elpart;\n\n if (GET_CODE (el) == CONST_INT)\n elpart = INTVAL (el);\n else if (GET_CODE (el) == CONST_DOUBLE)\n return 0;\n else\n gcc_unreachable ();\n\n if (i != 0 && elpart != last_elt)\n return 0;\n\n last_elt = elpart;\n }\n\n /* Shift less than element size. */\n maxshift = innersize * 8;\n\n if (isleftshift)\n {\n /* Left shift immediate value can be from 0 to -1. */\n if (last_elt >= maxshift)\n return 0;\n }\n else\n {\n /* Right shift immediate value can be from 1 to . */\n if (last_elt == 0 || last_elt > maxshift)\n\treturn 0;\n }\n\n if (elementwidth)\n *elementwidth = innersize * 8;\n\n if (modconst)\n *modconst = CONST_VECTOR_ELT (op, 0);\n\n return 1;\n}", "label": 0, "cwe": null, "length": 375 }, { "index": 104756, "code": "httpStatusLineSet(HttpStatusLine * sline, http_version_t version, http_status status, const char *reason)\n{\n assert(sline);\n sline->version = version;\n sline->status = status;\n /* Note: no xstrdup for 'reason', assumes constant 'reasons' */\n sline->reason = reason;\n}", "label": 1, "cwe": "CWE-476", "length": 75 }, { "index": 5297, "code": "fillWithAI(const QString & filename)\n{\n\tTRACE(\"bool LoadGame::fillWithAI(QString filename %s)\",qPrintable(filename));\n\n\tif ( !_engine->checkGamePlayers( filename ) ) {\n\t\tint nplay = _engine->getNumFillPlayers();\n\t\tTRACE(\"LoadGame::fillWithAI nplay %d\",nplay);\n\t\tif( nplay > 0 ) {\n\t\t\t//QTimer::singleShot( (nplay+2)* 1000, this, SLOT( slot_ready() ) );\n\t\t\tfor( int i = 0; i < nplay; i++ ) {\n\t\t\t\t_readyIn = false;\n\t\t\t\tTRACE(\"ai %d\",i);\n\t\t\t\taddInternalAI();\t\n\t\t\t\twhile( !_readyIn ){\n\t\t\t\t\tqApp->processEvents();\n\t\t\t\t}\n\t\t\t}\t\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n}", "label": 0, "cwe": null, "length": 183 }, { "index": 10843, "code": "operator[] (const uint32_t index)\r\n\t{\r\n\r\n\t\t// Check if index is > length (e.g. past null char)\r\n\t\tif(index > this->length)\r\n\t\t{\r\n\t\t\t//! @todo Add assert No bounds checking!\r\n\r\n\t\t\t// Index is out of bounds, the best we can do is return\r\n\t\t\t// something is in bounds, so let's return\r\n\t\t\t// the last char. This could cause unexpected behaviour,\r\n\t\t\t// so an assert() needs to be added!\r\n\t\t\treturn this->cStr[0];\r\n\t\t}\r\n\r\n\t\treturn this->cStr[index];\r\n\t}", "label": 0, "cwe": null, "length": 129 }, { "index": 67158, "code": "list_retrieve_callback(void* arg,globus_ftp_control_handle_t*,globus_object_t *error,globus_byte_t* /* buffer */,globus_size_t /* length */,globus_off_t /* offset */,globus_bool_t /* eof */) {\n GridFTP_Commands *it = (GridFTP_Commands*)arg;\n globus_mutex_lock(&(it->data_lock));\n it->last_action_time=time(NULL);\n if(it->check_abort(error)) {\n it->free_data_buffer();\n globus_mutex_unlock(&(it->data_lock));\n return;\n };\n globus_bool_t eodf;\n globus_size_t size;\n if(it->dir_list_pointer == it->dir_list.end()) {\n it->virt_offset=0;\n it->transfer_mode=false;\n it->free_data_buffer();\n logger.msg(Arc::VERBOSE, \"Closing channel (list)\");\n it->send_response(\"226 Transfer completed.\\r\\n\");\n globus_mutex_unlock(&(it->data_lock));\n return;\n };\n globus_ftp_control_local_send_eof(&(it->handle),GLOBUS_TRUE);\n ++(it->dir_list_pointer);\n if(it->dir_list_pointer == it->dir_list.end()) {\n size=0; eodf=GLOBUS_TRUE;\n }\n else {\n size=make_list_string(*(it->dir_list_pointer),it->list_mode,\n it->data_buffer[0].data,it->data_buffer_size,\n it->list_name_prefix.c_str());\n eodf=GLOBUS_FALSE;\n };\n globus_result_t res;\n res=globus_ftp_control_data_write(&(it->handle),\n (globus_byte_t*)(it->data_buffer[0].data),\n size,it->list_offset,eodf,\n &list_retrieve_callback,it);\n if(res != GLOBUS_SUCCESS) {\n it->free_data_buffer();\n it->force_abort();\n globus_mutex_unlock(&(it->data_lock));\n return;\n };\n globus_mutex_unlock(&(it->data_lock));\n}", "label": 0, "cwe": null, "length": 439 }, { "index": 718854, "code": "calculate_AtAb(const NEWMAT::ColumnVector& b,\n const std::vector& isz,\n const std::vector& csz,\n const Spline3D& sp,\n const Memen_H_Helper& hlpr,\n NEWMAT::ColumnVector& grad)\nconst\n{\n grad = 0;\n double *db=static_cast(b.Store()); // double[] representation of coefficients\n double *dg=static_cast(grad.Store()); // double[] representation of gradient\n std::vector ci(3,0); // Index of coefficient\n std::vector first(3,0); // index of first overlapping coefficient\n std::vector last(3,0); // Index of last overlapping coefficient\n unsigned int li=0; // Linear index of coefficient \n for (ci[2]=0; ci[2]bad) {\n\t*bs->pos = 0;\n\ttext = bs->text;\n } else\n\ttext = \"out of memory\\n\";\n\n if (clp->internal->error_handler != 0)\n\t(*clp->internal->error_handler)(text);\n else\n\tfputs(text, stderr);\n}", "label": 0, "cwe": null, "length": 99 }, { "index": 351745, "code": "setColor(const QColor &color)\n{\n m_Color = color;\n QPixmap pixmap(iconSize());\n pixmap.fill(m_Color);\n setIcon(QIcon(pixmap));\n}", "label": 0, "cwe": null, "length": 34 }, { "index": 874981, "code": "gst_element_factory_can_accept_any_caps_in_direction (GstElementFactory *\n factory, const GstCaps * caps, GstPadDirection direction)\n{\n GList *templates;\n\n g_return_val_if_fail (factory != NULL, FALSE);\n g_return_val_if_fail (caps != NULL, FALSE);\n\n templates = factory->staticpadtemplates;\n\n while (templates) {\n GstStaticPadTemplate *template = (GstStaticPadTemplate *) templates->data;\n\n if (template->direction == direction) {\n GstCaps *templcaps = gst_static_caps_get (&template->static_caps);\n\n if (gst_caps_can_intersect (caps, templcaps)) {\n gst_caps_unref (templcaps);\n return TRUE;\n }\n gst_caps_unref (templcaps);\n }\n templates = g_list_next (templates);\n }\n\n return FALSE;\n}", "label": 0, "cwe": null, "length": 178 }, { "index": 496772, "code": "http_end_txn(struct session *s)\n{\n\tstruct http_txn *txn = &s->txn;\n\n\t/* these ones will have been dynamically allocated */\n\tpool_free2(pool2_requri, txn->uri);\n\tpool_free2(pool2_capture, txn->cli_cookie);\n\tpool_free2(pool2_capture, txn->srv_cookie);\n\tpool_free2(apools.sessid, txn->sessid);\n\n\ttxn->sessid = NULL;\n\ttxn->uri = NULL;\n\ttxn->srv_cookie = NULL;\n\ttxn->cli_cookie = NULL;\n\n\tif (txn->req.cap) {\n\t\tstruct cap_hdr *h;\n\t\tfor (h = s->fe->req_cap; h; h = h->next)\n\t\t\tpool_free2(h->pool, txn->req.cap[h->index]);\n\t\tmemset(txn->req.cap, 0, s->fe->nb_req_cap * sizeof(void *));\n\t}\n\n\tif (txn->rsp.cap) {\n\t\tstruct cap_hdr *h;\n\t\tfor (h = s->fe->rsp_cap; h; h = h->next)\n\t\t\tpool_free2(h->pool, txn->rsp.cap[h->index]);\n\t\tmemset(txn->rsp.cap, 0, s->fe->nb_rsp_cap * sizeof(void *));\n\t}\n\n}", "label": 0, "cwe": null, "length": 262 }, { "index": 102524, "code": "rosh_prompt(int iargc, char *iargv[])\n{\n int rv;\n char cmdstr[ROSH_CMD_SZ];\n char ipwdstr[ROSH_PATH_SZ];\n char do_exit;\n char **argv;\n int argc;\n\n rv = 0;\n do_exit = false;\n if (!getcwd(ipwdstr, ROSH_PATH_SZ))\n\tstrcpy(ipwdstr, \"./\");\n if (iargc > 1)\n\tdo_exit = rosh_command(iargc - 1, &iargv[1], ipwdstr);\n while (!(do_exit)) {\n\t/* Extra preceeding newline */\n\tprintf(\"\\nrosh: \");\n\t/* Read a line from console */\n\tif (fgets(cmdstr, ROSH_CMD_SZ, stdin)) {\n\t argc = rosh_str2argv(&argv, cmdstr);\n\t do_exit = rosh_command(argc, argv, ipwdstr);\n\t rosh_free_argv(&argv);\n\t} else {\n\t do_exit = false;\n\t}\n }\n return rv;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-other" ], "length": 217 }, { "index": 275749, "code": "bacon_video_widget_set_show_cursor (BaconVideoWidget * bvw,\n gboolean show_cursor)\n{\n GdkWindow *window;\n\n g_return_if_fail (BACON_IS_VIDEO_WIDGET (bvw));\n\n bvw->priv->cursor_shown = show_cursor;\n window = gtk_widget_get_window (GTK_WIDGET (bvw));\n\n if (!window) {\n return;\n }\n\n if (show_cursor == FALSE) {\n totem_gdk_window_set_invisible_cursor (window);\n } else {\n gdk_window_set_cursor (window, bvw->priv->cursor);\n }\n}", "label": 0, "cwe": null, "length": 127 }, { "index": 819245, "code": "odf_number_style (GsfXMLIn *xin, xmlChar const **attrs)\n{\n\tOOParseState *state = (OOParseState *)xin->user_state;\n\tchar const *name = NULL;\n\n\tfor (; attrs != NULL && attrs[0] && attrs[1] ; attrs += 2)\n\t\tif (gsf_xml_in_namecmp (xin, CXML2C (attrs[0]), OO_NS_STYLE, \"name\"))\n\t\t\tname = CXML2C (attrs[1]);\n\n\tg_return_if_fail (state->cur_format.accum == NULL);\n\n\tstate->cur_format.accum = g_string_new (NULL);\n\tstate->cur_format.name = g_strdup (name);\n\tstate->cur_format.percentage = FALSE;\n\tstate->cur_format.percent_sign_seen = FALSE;\n\tstate->conditions = NULL;\n\tstate->cond_formats = NULL;\n}", "label": 0, "cwe": null, "length": 177 }, { "index": 259253, "code": "basler_sff_registry_find_by_csr_guid (dc1394basler_sff_guid_t* csr_guid)\n{\n uint32_t i;\n if (csr_guid == NULL)\n return NULL;\n\n for(i = 0; i < sff_feature_registry_size; i++) {\n if (!memcmp (&(sff_feature_registry[i].csr_guid), csr_guid, sizeof(dc1394basler_sff_guid_t)))\n return &(sff_feature_registry[i]);\n }\n return NULL;\n}", "label": 0, "cwe": null, "length": 107 }, { "index": 704742, "code": "snapshot_lowmem(void)\n{\n extern void _start(void);\n\n lowmem_len = (size_t)_start;\n lowmem = malloc(lowmem_len);\n if (lowmem) {\n\tprintf(\"Snapshotting lowmem... \");\n\tcli();\n\tmemcpy(lowmem, zero_addr, lowmem_len);\n\tsti();\n\tprintf(\"ok\\n\");\n }\n}", "label": 1, "cwe": "CWE-120", "length": 73 }, { "index": 744919, "code": "MARK_print_v1(const void *ip, const struct xt_entry_target *target,\n int numeric)\n{\n\tconst struct xt_mark_target_info_v1 *markinfo =\n\t\t(const struct xt_mark_target_info_v1 *)target->data;\n\n\tswitch (markinfo->mode) {\n\tcase XT_MARK_SET:\n\t\tprintf(\" MARK set\");\n\t\tbreak;\n\tcase XT_MARK_AND:\n\t\tprintf(\" MARK and\");\n\t\tbreak;\n\tcase XT_MARK_OR: \n\t\tprintf(\" MARK or\");\n\t\tbreak;\n\t}\n\tprint_mark(markinfo->mark);\n}", "label": 0, "cwe": null, "length": 111 }, { "index": 763732, "code": "add_handlers()\n{\n add_read_handler(\"packets\", read_param, (void *)0);\n add_task_handlers(&_task);\n}", "label": 0, "cwe": null, "length": 29 }, { "index": 749697, "code": "tpg_free(struct tpg_data *tpg)\n{\n\tunsigned pat;\n\tunsigned plane;\n\n\tfor (pat = 0; pat < TPG_MAX_PAT_LINES; pat++)\n\t\tfor (plane = 0; plane < TPG_MAX_PLANES; plane++) {\n\t\t\tvfree(tpg->lines[pat][plane]);\n\t\t\ttpg->lines[pat][plane] = NULL;\n\t\t\tif (plane == 0)\n\t\t\t\tcontinue;\n\t\t\tvfree(tpg->downsampled_lines[pat][plane]);\n\t\t\ttpg->downsampled_lines[pat][plane] = NULL;\n\t\t}\n\tfor (plane = 0; plane < TPG_MAX_PLANES; plane++) {\n\t\tvfree(tpg->contrast_line[plane]);\n\t\tvfree(tpg->black_line[plane]);\n\t\tvfree(tpg->random_line[plane]);\n\t\ttpg->contrast_line[plane] = NULL;\n\t\ttpg->black_line[plane] = NULL;\n\t\ttpg->random_line[plane] = NULL;\n\t}\n}", "label": 0, "cwe": null, "length": 216 }, { "index": 27800, "code": "bfa_lps_sm_online(struct bfa_lps_s *lps, enum bfa_lps_event event)\n{\n\tbfa_trc(lps->bfa, lps->bfa_tag);\n\tbfa_trc(lps->bfa, event);\n\n\tswitch (event) {\n\tcase BFA_LPS_SM_LOGOUT:\n\t\tif (bfa_reqq_full(lps->bfa, lps->reqq)) {\n\t\t\tbfa_sm_set_state(lps, bfa_lps_sm_logowait);\n\t\t\tbfa_reqq_wait(lps->bfa, lps->reqq, &lps->wqe);\n\t\t} else {\n\t\t\tbfa_sm_set_state(lps, bfa_lps_sm_logout);\n\t\t\tbfa_lps_send_logout(lps);\n\t\t}\n\t\tbfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,\n\t\t\tBFA_PL_EID_LOGO, 0, \"Logout\");\n\t\tbreak;\n\n\tcase BFA_LPS_SM_RX_CVL:\n\t\tbfa_sm_set_state(lps, bfa_lps_sm_init);\n\n\t\t/* Let the vport module know about this event */\n\t\tbfa_lps_cvl_event(lps);\n\t\tbfa_plog_str(lps->bfa->plog, BFA_PL_MID_LPS,\n\t\t\tBFA_PL_EID_FIP_FCF_CVL, 0, \"FCF Clear Virt. Link Rx\");\n\t\tbreak;\n\n\tcase BFA_LPS_SM_SET_N2N_PID:\n\t\tif (bfa_reqq_full(lps->bfa, lps->reqq)) {\n\t\t\tbfa_sm_set_state(lps, bfa_lps_sm_online_n2n_pid_wait);\n\t\t\tbfa_reqq_wait(lps->bfa, lps->reqq, &lps->wqe);\n\t\t} else\n\t\t\tbfa_lps_send_set_n2n_pid(lps);\n\t\tbreak;\n\n\tcase BFA_LPS_SM_OFFLINE:\n\tcase BFA_LPS_SM_DELETE:\n\t\tbfa_sm_set_state(lps, bfa_lps_sm_init);\n\t\tbreak;\n\n\tdefault:\n\t\tbfa_sm_fault(lps->bfa, event);\n\t}\n}", "label": 0, "cwe": null, "length": 464 }, { "index": 711831, "code": "build( void )\n{\n // ----------------------------------------\n // 1) Generate sample points from gaussians\n // ----------------------------------------\n // NB : Extreme points (at abscissa MIN_X and MAX_X) will be generated, we need to erase the list first\n _points->erase( true );\n \n ae_list_node* node = NULL;\n \n for ( int16_t i = 0 ; i <= _sampling ; i++ )\n {\n ae_point_2d* new_point = new ae_point_2d( X_MIN + (double)i * (X_MAX - X_MIN) / (double)_sampling, 0.0 );\n node = _gaussians->get_first();\n \n while ( node )\n {\n new_point->y += node->get_obj()->compute_y( new_point->x );\n \n node = node->get_next();\n }\n \n _points->add( new_point );\n }\n \n \n // --------------------\n // 2) Add custom points\n // --------------------\n #warning Environment custom points not yet implemented\n \n \n \n // ---------------------------------------\n // 3) Simplify (get rid of useless points)\n // ---------------------------------------\n add_lower_bound( Y_MIN );\n add_upper_bound( Y_MAX );\n simplify();\n \n \n // ---------------------------------------\n // 4) Compute areas (total and by feature)\n // ---------------------------------------\n _compute_area();\n \n \n // -------------------------------------------------------------------\n // 5) If needed, create a copy of the initial state of the gaussians\n // -------------------------------------------------------------------\n if ( _initial_gaussians == NULL && (_var_method != NO_VAR || is_noise_allowed()) )\n {\n _initial_gaussians = new ae_list();\n \n int32_t nb_gaussians = _gaussians->get_nb_elts();\n ae_list_node* gaussian_node = _gaussians->get_first();\n ae_gaussian* gaussian = NULL;\n for ( int16_t i = 0 ; i < nb_gaussians ; i++ )\n {\n gaussian = gaussian_node->get_obj();\n \n _initial_gaussians->add( new ae_gaussian( *gaussian ) );\n \n gaussian_node = gaussian_node->get_next();\n }\n }\n}", "label": 0, "cwe": null, "length": 489 }, { "index": 854479, "code": "IntrFuncExprBegin (\n Int narg,\n Int nloc,\n Obj nams,\n Int startLine)\n{\n /* ignore or code */\n if ( IntrReturning > 0 ) { return; }\n if ( IntrIgnoring > 0 ) { return; }\n if ( IntrCoding > 0 ) {\n IntrCoding++;\n CodeFuncExprBegin( narg, nloc, nams, startLine );\n return;\n }\n\n /* switch to coding mode now */\n CodeBegin();\n IntrCoding = 1;\n\n /* code a function expression */\n CodeFuncExprBegin( narg, nloc, nams, startLine );\n}", "label": 0, "cwe": null, "length": 151 }, { "index": 585532, "code": "geneve_socket_create(struct net *net, __be16 port,\n\t\t\t\t\t\tbool ipv6, u32 flags)\n{\n\tstruct geneve_net *gn = net_generic(net, geneve_net_id);\n\tstruct geneve_sock *gs;\n\tstruct socket *sock;\n\tstruct udp_tunnel_sock_cfg tunnel_cfg;\n\tint h;\n\n\tgs = kzalloc(sizeof(*gs), GFP_KERNEL);\n\tif (!gs)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tsock = geneve_create_sock(net, ipv6, port, flags);\n\tif (IS_ERR(sock)) {\n\t\tkfree(gs);\n\t\treturn ERR_CAST(sock);\n\t}\n\n\tgs->sock = sock;\n\tgs->refcnt = 1;\n\tfor (h = 0; h < VNI_HASH_SIZE; ++h)\n\t\tINIT_HLIST_HEAD(&gs->vni_list[h]);\n\n\t/* Initialize the geneve udp offloads structure */\n\tgs->udp_offloads.port = port;\n\tgs->udp_offloads.callbacks.gro_receive = geneve_gro_receive;\n\tgs->udp_offloads.callbacks.gro_complete = geneve_gro_complete;\n\tgeneve_notify_add_rx_port(gs);\n\n\t/* Mark socket as an encapsulation socket */\n\ttunnel_cfg.sk_user_data = gs;\n\ttunnel_cfg.encap_type = 1;\n\ttunnel_cfg.encap_rcv = geneve_udp_encap_recv;\n\ttunnel_cfg.encap_destroy = NULL;\n\tsetup_udp_tunnel_sock(net, sock, &tunnel_cfg);\n\tlist_add(&gs->list, &gn->sock_list);\n\treturn gs;\n}", "label": 0, "cwe": null, "length": 316 }, { "index": 703267, "code": "duplicate_eh_regions (struct function *ifun,\n\t\t eh_region copy_region, int outer_lp,\n\t\t duplicate_eh_regions_map map, void *map_data)\n{\n struct duplicate_eh_regions_data data;\n eh_region outer_region;\n\n#ifdef ENABLE_CHECKING\n verify_eh_tree (ifun);\n#endif\n\n data.label_map = map;\n data.label_map_data = map_data;\n data.eh_map = pointer_map_create ();\n\n outer_region = get_eh_region_from_lp_number (outer_lp);\n\n /* Copy all the regions in the subtree. */\n if (copy_region)\n duplicate_eh_regions_1 (&data, copy_region, outer_region);\n else\n {\n eh_region r;\n for (r = ifun->eh->region_tree; r ; r = r->next_peer)\n\tduplicate_eh_regions_1 (&data, r, outer_region);\n }\n\n#ifdef ENABLE_CHECKING\n verify_eh_tree (cfun);\n#endif\n\n return data.eh_map;\n}", "label": 0, "cwe": null, "length": 215 }, { "index": 309027, "code": "perf_event_wakeup(struct perf_event *event)\n{\n\tring_buffer_wakeup(event);\n\n\tif (event->pending_kill) {\n\t\tkill_fasync(perf_event_fasync(event), SIGIO, event->pending_kill);\n\t\tevent->pending_kill = 0;\n\t}\n}", "label": 0, "cwe": null, "length": 59 }, { "index": 122606, "code": "php_native_ed2k_download_cmd(PHP_VALUE_NODE *result)\n{\n\tPHP_SCOPE_ITEM *si = get_scope_item(g_current_scope, \"__param_0\");\n\tif ( !si || (si->var->value.type != PHP_VAL_STRING)) {\n\t\tphp_report_error(PHP_ERROR, \"Invalid or missing argument 1 (file link)\");\n\t\treturn;\n\t}\n\tchar *str_link = si->var->value.str_val;\n\t\n\tsi = get_scope_item(g_current_scope, \"__param_1\");\n\tif ( !si || (si->var->value.type != PHP_VAL_STRING)) {\n\t\tphp_report_error(PHP_ERROR, \"Invalid or missing argument 2 (category)\");\n\t\treturn;\n\t}\n\n\tcast_value_dnum(&si->var->value);\n\tint cat = si->var->value.int_val;\n\n\tbool cmd_result = CPhPLibContext::g_curr_context->WebServer()->Send_DownloadEd2k_Cmd(\n\t\twxString(char2unicode(str_link)), cat);\n\tif ( result ) {\n\t\tcast_value_bool(result);\n\t\tresult->int_val = cmd_result;\n\t}\n}", "label": 0, "cwe": null, "length": 229 }, { "index": 86551, "code": "writeExifDigest()\n {\n#ifdef EXV_HAVE_XMP_TOOLKIT\n (*xmpData_)[\"Xmp.tiff.NativeDigest\"] = computeExifDigest(true);\n (*xmpData_)[\"Xmp.exif.NativeDigest\"] = computeExifDigest(false);\n#endif\n }", "label": 0, "cwe": null, "length": 63 }, { "index": 108742, "code": "GetIntegrationPointAndWeight(unsigned int i, VectorType & pt, Float & w, unsigned int order) const\n{\n // default integration order\n if( order == 0 || order > 5 )\n {\n order = DefaultIntegrationOrder;\n }\n\n pt.set_size(3);\n\n /**\n * We provide implementation for 5 different integration rules\n * as defined in chapter 24 - Implementation of Iso-P Truangular\n * Elements, of http://titan.colorado.edu/courses.d/IFEM.d/.\n *\n * Note that the order parameter here does not correspond to the\n * actual order of integration, but rather the degree of polynomials\n * that are exactly integrated. In addition, there are two integration\n * rules for polynomials of 2nd degree. In order to allow using both of\n * them, we assign the index number 3 to the second one. Note that this\n * does not mean that the rule is capable of integrating the polynomials\n * of 3rd degree. It's just an index of a rule.\n */\n pt.copy_in(Element2DC0LinearTriangular::trigGaussRuleInfo[order][i]);\n\n // We scale the weight by 0.5, to take into account\n // the factor that must be applied when integrating.\n w = 0.5 * Element2DC0LinearTriangular::trigGaussRuleInfo[order][i][3];\n}", "label": 0, "cwe": null, "length": 315 }, { "index": 649704, "code": "mei_txe_aliveness_poll(struct mei_device *dev, u32 expected)\n{\n\tstruct mei_txe_hw *hw = to_txe_hw(dev);\n\tktime_t stop, start;\n\n\tstart = ktime_get();\n\tstop = ktime_add(start, ms_to_ktime(SEC_ALIVENESS_WAIT_TIMEOUT));\n\tdo {\n\t\thw->aliveness = mei_txe_aliveness_get(dev);\n\t\tif (hw->aliveness == expected) {\n\t\t\tdev->pg_event = MEI_PG_EVENT_IDLE;\n\t\t\tdev_dbg(dev->dev, \"aliveness settled after %lld usecs\\n\",\n\t\t\t\tktime_to_us(ktime_sub(ktime_get(), start)));\n\t\t\treturn 0;\n\t\t}\n\t\tusleep_range(20, 50);\n\t} while (ktime_before(ktime_get(), stop));\n\n\tdev->pg_event = MEI_PG_EVENT_IDLE;\n\tdev_err(dev->dev, \"aliveness timed out\\n\");\n\treturn -ETIME;\n}", "label": 0, "cwe": null, "length": 200 }, { "index": 483833, "code": "on_selected_toggled (GtkCellRendererToggle *renderer,\n const gchar *path_string,\n gpointer user_data)\n{\n GduWindow *window = GDU_WINDOW (user_data);\n GtkTreeIter iter;\n\n if (!gtk_tree_model_get_iter_from_string (GTK_TREE_MODEL (window->model),\n &iter,\n path_string))\n goto out;\n\n gdu_device_tree_model_toggle_selected (window->model, &iter);\n\n update_all (window);\n\n out:\n ;\n}", "label": 0, "cwe": null, "length": 106 }, { "index": 789961, "code": "tdb1_unlock(struct tdb_context *tdb, int list, int ltype)\n{\n\t/* a global lock allows us to avoid per chain locks */\n\tif (tdb->file->allrecord_lock.count &&\n\t (ltype == tdb->file->allrecord_lock.ltype || ltype == F_RDLCK)) {\n\t\tif (tdb->file->allrecord_lock.owner != tdb) {\n\t\t\ttdb->last_error = owner_conflict(tdb, \"tdb1_unlock\");\n\t\t\treturn -1;\n\t\t}\n\t\treturn 0;\n\t}\n\n\tif (tdb->file->allrecord_lock.count) {\n\t\ttdb->last_error = TDB_ERR_LOCK;\n\t\treturn -1;\n\t}\n\n\treturn tdb1_nest_unlock(tdb, lock_offset(list), ltype);\n}", "label": 0, "cwe": null, "length": 172 }, { "index": 207715, "code": "Open(const char *pszNewName, int bTestOpen)\n{\n FILE * fp;\n char szHeader[1000];\n \n /* open the source file */\n fp = VSIFOpen(pszNewName, \"r\");\n if (fp == NULL) {\n if (!bTestOpen)\n CPLError(CE_Failure, CPLE_OpenFailed, \n \"Failed to open VFK file `%s'\",\n pszNewName);\n \n return FALSE;\n }\n\n /* If we aren't sure it is VFK, load a header chunk and check \n for signs it is VFK */\n if (bTestOpen) {\n size_t nRead = VSIFRead(szHeader, 1, sizeof(szHeader), fp);\n if (nRead <= 0) {\n VSIFClose(fp);\n return FALSE;\n }\n szHeader[MIN(nRead, sizeof(szHeader))-1] = '\\0';\n \n // TODO: improve check\n if (strncmp(szHeader, \"&HVERZE;\", 8) != 0) {\n VSIFClose(fp);\n return FALSE;\n } \n }\n\n /* We assume now that it is VFK. Close and instantiate a\n VFKReader on it. */\n VSIFClose(fp);\n\n pszName = CPLStrdup(pszNewName);\n \n poReader = CreateVFKReader(pszNewName);\n if (poReader == NULL) {\n CPLError(CE_Failure, CPLE_AppDefined, \n \"File %s appears to be VFK but the VFK reader can't\"\n \"be instantiated\",\n pszNewName);\n return FALSE;\n }\n \n /* read data blocks, i.e. &B */\n poReader->ReadDataBlocks();\n \n /* get list of layers */\n papoLayers = (OGRVFKLayer **) CPLCalloc(sizeof(OGRVFKLayer *), poReader->GetDataBlockCount());\n \n for (int iLayer = 0; iLayer < poReader->GetDataBlockCount(); iLayer++) {\n papoLayers[iLayer] = CreateLayerFromBlock(poReader->GetDataBlock(iLayer));\n nLayers++;\n }\n \n return TRUE;\n}", "label": 0, "cwe": null, "length": 473 }, { "index": 158663, "code": "tua6100_attach(struct dvb_frontend *fe, int addr, struct i2c_adapter *i2c)\n{\n\tstruct tua6100_priv *priv = NULL;\n\tu8 b1 [] = { 0x80 };\n\tu8 b2 [] = { 0x00 };\n\tstruct i2c_msg msg [] = { { .addr = addr, .flags = 0, .buf = b1, .len = 1 },\n\t\t\t\t { .addr = addr, .flags = I2C_M_RD, .buf = b2, .len = 1 } };\n\tint ret;\n\n\tif (fe->ops.i2c_gate_ctrl)\n\t\tfe->ops.i2c_gate_ctrl(fe, 1);\n\tret = i2c_transfer (i2c, msg, 2);\n\tif (fe->ops.i2c_gate_ctrl)\n\t\tfe->ops.i2c_gate_ctrl(fe, 0);\n\n\tif (ret != 2)\n\t\treturn NULL;\n\n\tpriv = kzalloc(sizeof(struct tua6100_priv), GFP_KERNEL);\n\tif (priv == NULL)\n\t\treturn NULL;\n\n\tpriv->i2c_address = addr;\n\tpriv->i2c = i2c;\n\n\tmemcpy(&fe->ops.tuner_ops, &tua6100_tuner_ops, sizeof(struct dvb_tuner_ops));\n\tfe->tuner_priv = priv;\n\treturn fe;\n}", "label": 0, "cwe": null, "length": 287 }, { "index": 590052, "code": "heloResponse(int n, string s)\n{\n\tswitch (n / 100) {\n\tcase 1:\n\tcase 2:\n\tcase 3:\n\t\tstarttls();\n\t\treturn;\n\t}\n\n\terror(s);\n}", "label": 0, "cwe": null, "length": 44 }, { "index": 949735, "code": "reuse()\n{\n if (tag_value < -1) // borrowed storage\n {\n if (storage)\n {\n REPORT\n Real* s = new Real [storage]; MatrixErrorNoSpace(s);\n MONITOR_REAL_NEW(\"Make (reuse)\",storage,s)\n BlockCopy(storage, store, s); store = s;\n }\n else { REPORT MiniCleanUp(); } // CleanUp\n tag_value = 0; return true;\n }\n if (tag_value < 0 ) { REPORT return false; }\n if (tag_value <= 1 ) { REPORT return true; }\n REPORT tag_value--; return false;\n}", "label": 0, "cwe": null, "length": 141 }, { "index": 784165, "code": "summary_open_msg(SummaryView *summaryview)\n{\n\tif (!summaryview->selected) return;\n\t\n\t/* CLAWS: if separate message view, don't open a new window\n\t * but rather use the current separated message view */\n\tsummary_display_msg_full(summaryview, summaryview->selected, \n\t\t\t\t TRUE, FALSE);\n}", "label": 0, "cwe": null, "length": 71 }, { "index": 464285, "code": "exact_sel(int cmd, dico_key_t key, const char *dict_word)\n{\n switch (cmd) {\n case DICO_SELECT_BEGIN:\n\tbreak;\n\n case DICO_SELECT_RUN:\n\treturn utf8_strcasecmp(key->word, (char*)dict_word) == 0;\n\n case DICO_SELECT_END:\n\tbreak;\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 77 }, { "index": 381064, "code": "da_unique (struct darray * arr, da_map_func_t free_func)\n{\n size_t c;\n\n c = 1;\n while (c < arr->len) {\n if (arr->cmp (arr->content [c - 1], arr->content[c]) == 0)\n da_remove_at (arr, c, free_func);\n else\n c++;\n }\n}", "label": 0, "cwe": null, "length": 85 }, { "index": 59914, "code": "odf_hf_item_start (GsfXMLIn *xin)\n{\n OOParseState *state = (OOParseState *)xin->user_state;\n\n if (xin->content->str != NULL && *xin->content->str != 0) {\n\t oo_text_p_t *ptr = state->text_p_stack->data;\n\t odf_text_p_add_text (state, xin->content->str + ptr->offset);\n\t ptr->offset = strlen (xin->content->str);\n }\t\n}", "label": 0, "cwe": null, "length": 110 }, { "index": 45298, "code": "eval_action( action_t &action, const state_t &state ) const\n{\n ValueMap vm;\n vm[app_] = 0;\n state_t dummy;\n std::list* rewardEffs = action.get_reward_effs();\n\n for (std::list::iterator it_eff = rewardEffs->begin(); \n it_eff != rewardEffs->end(); it_eff++)\n {\n (*it_eff)->affect( state, dummy, &vm);\n }\n\n return vm[app_];\n}", "label": 0, "cwe": null, "length": 116 }, { "index": 59016, "code": "bgav_mpv_find_startcode( const uint8_t *p,\n const uint8_t *end )\n {\n const uint8_t * ptr;\n /* Subtract 3 because we want to get the *whole* code */\n int len = end - p - 3;\n\n if(len <= 0) /* Reached end */\n return NULL;\n \n while(1)\n {\n ptr = first_zero_byte(p, len);\n \n if(!ptr) /* Reached end */\n break;\n\n if((ptr[1] == 0x00) && (ptr[2] == 0x01)) /* Found startcode */\n return ptr;\n \n /* Skip this zero byte */\n p = ptr+1;\n\n len = end - p - 3;\n \n if(len <= 0) /* Reached end */\n break;\n }\n return NULL;\n }", "label": 0, "cwe": null, "length": 190 }, { "index": 197615, "code": "ipr_log_ext_vpd_compact(char *prefix, struct ipr_hostrcb *hostrcb,\n\t\t\t\t struct ipr_ext_vpd *vpd)\n{\n\tipr_log_vpd_compact(prefix, hostrcb, &vpd->vpd);\n\tipr_hcam_err(hostrcb, \"%s WWN: %08X%08X\\n\", prefix,\n\t\t be32_to_cpu(vpd->wwid[0]), be32_to_cpu(vpd->wwid[1]));\n}", "label": 0, "cwe": null, "length": 108 }, { "index": 5689, "code": "player_quit()\n{\n\t// to let other player know a player quit voluntarily, not by error condition\n\terr_when( id != MSG_PLAYER_QUIT );\n\t// packet structure : \n\n\tshort *shortPtr = (short *)data_buf;\n\tif( shortPtr[1])\n\t\tnews_array.multi_retire(*shortPtr);\n\telse\n\t\tnews_array.multi_quit_game(*shortPtr);\n}", "label": 1, "cwe": "CWE-other", "length": 90 }, { "index": 754745, "code": "p_set_userdata_processingstatus_check_videofile(GapStoryVideoFileRef *vref_list, GapVideoIndexCreatorProgressParams *vipp)\n{\n gboolean l_file_is_videofile;\n gint32 numberOfFiles;\n gint32 filesCount;\n GapStoryVideoFileRef *vref;\n \n \n numberOfFiles = 0;\n vipp->numberOfVideos = 0;\n for(vref = vref_list; vref != NULL; vref = vref->next)\n {\n numberOfFiles++;\n vipp->numberOfVideos++;\n\n }\n\n filesCount = 0;\n for(vref = vref_list; vref != NULL; vref = vref->next)\n {\n if(gap_debug)\n {\n printf(\"filesCount:%d numberOfFiles:%d\\n\"\n ,(int)filesCount\n ,(int)numberOfFiles\n );\n }\n\n if(vipp->progress_bar_sub)\n {\n gtk_progress_bar_set_text(GTK_PROGRESS_BAR(vipp->progress_bar_sub), _(\"counting and checking videofiles\"));\n gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(vipp->progress_bar_sub)\n , CLAMP(((gdouble)filesCount / (gdouble)numberOfFiles), 0.0, 1.0)\n );\n while(g_main_context_iteration(NULL, FALSE));\n \n \n if(vipp->cancel_immedeiate_request == TRUE)\n {\n p_vipp_dlg_destroy(NULL, vipp);\n return;\n }\n \n }\n filesCount++;\n \n l_file_is_videofile = FALSE;\n if(g_file_test(vref->videofile, G_FILE_TEST_EXISTS))\n {\n l_file_is_videofile = p_check_videofile(vref->videofile, vref->seltrack, vref->preferred_decoder);\n\n if(gap_debug)\n {\n printf(\"FILE_EXISTS:%s\\n .. is_vieofile:%d\\n\"\n , vref->videofile\n , (int)l_file_is_videofile\n );\n }\n }\n\n if (l_file_is_videofile)\n {\n p_set_vref_userdata(vref, _(\"unprocessed\"));\n vipp->numberOfValidVideos++;\n }\n else\n {\n p_set_vref_userdata(vref, NULL);\n }\n }\n\n\n}", "label": 0, "cwe": null, "length": 492 }, { "index": 977806, "code": "wil_tx_desc_offload_setup(struct vring_tx_desc *d,\n\t\t\t\t struct sk_buff *skb){\n\tint protocol;\n\n\tif (skb->ip_summed != CHECKSUM_PARTIAL)\n\t\treturn 0;\n\n\td->dma.b11 = ETH_HLEN; /* MAC header length */\n\n\tswitch (skb->protocol) {\n\tcase cpu_to_be16(ETH_P_IP):\n\t\tprotocol = ip_hdr(skb)->protocol;\n\t\td->dma.b11 |= BIT(DMA_CFG_DESC_TX_OFFLOAD_CFG_L3T_IPV4_POS);\n\t\tbreak;\n\tcase cpu_to_be16(ETH_P_IPV6):\n\t\tprotocol = ipv6_hdr(skb)->nexthdr;\n\t\tbreak;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\n\tswitch (protocol) {\n\tcase IPPROTO_TCP:\n\t\td->dma.d0 |= (2 << DMA_CFG_DESC_TX_0_L4_TYPE_POS);\n\t\t/* L4 header len: TCP header length */\n\t\td->dma.d0 |=\n\t\t(tcp_hdrlen(skb) & DMA_CFG_DESC_TX_0_L4_LENGTH_MSK);\n\t\tbreak;\n\tcase IPPROTO_UDP:\n\t\t/* L4 header len: UDP header length */\n\t\td->dma.d0 |=\n\t\t(sizeof(struct udphdr) & DMA_CFG_DESC_TX_0_L4_LENGTH_MSK);\n\t\tbreak;\n\tdefault:\n\t\treturn -EINVAL;\n\t}\n\n\td->dma.ip_length = skb_network_header_len(skb);\n\t/* Enable TCP/UDP checksum */\n\td->dma.d0 |= BIT(DMA_CFG_DESC_TX_0_TCP_UDP_CHECKSUM_EN_POS);\n\t/* Calculate pseudo-header */\n\td->dma.d0 |= BIT(DMA_CFG_DESC_TX_0_PSEUDO_HEADER_CALC_EN_POS);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 349 }, { "index": 24565, "code": "get_subseg_info (segT seg, subsegT subseg)\n{\n subseg_map *subseg_e;\n\n for (subseg_e = sseg_map; subseg_e; subseg_e = subseg_e->next)\n {\n if (seg == subseg_e->seg && subseg == subseg_e->subseg)\n\tbreak;\n }\n return subseg_e;\n}", "label": 0, "cwe": null, "length": 85 }, { "index": 681986, "code": "cx24110_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)\n{\n\tstruct cx24110_state *state = fe->demodulator_priv;\n\n\tif(cx24110_readreg(state,0x10)&0x40) {\n\t\t/* the RS error counter has finished one counting window */\n\t\tcx24110_writereg(state,0x10,0x60); /* select the byer reg */\n\t\t(void)(cx24110_readreg(state, 0x12) |\n\t\t\t(cx24110_readreg(state, 0x13) << 8) |\n\t\t\t(cx24110_readreg(state, 0x14) << 16));\n\t\tcx24110_writereg(state,0x10,0x70); /* select the bler reg */\n\t\tstate->lastbler=cx24110_readreg(state,0x12)|\n\t\t\t(cx24110_readreg(state,0x13)<<8)|\n\t\t\t(cx24110_readreg(state,0x14)<<16);\n\t\tcx24110_writereg(state,0x10,0x20); /* start new count window */\n\t}\n\t*ucblocks = state->lastbler;\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 260 }, { "index": 444442, "code": "normalize(NormalStream & os) const\n{\n\tif (wid_.empty())\n\t\tos << \"[kern]\";\n\telse\n\t\tos << \"[kern \" << from_utf8(wid_.asLatexString()) << ']';\n}", "label": 0, "cwe": null, "length": 49 }, { "index": 731444, "code": "ses_do_win(wp)\n win_T\t*wp;\n{\n if (wp->w_buffer->b_fname == NULL\n#ifdef FEAT_QUICKFIX\n\t /* When 'buftype' is \"nofile\" can't restore the window contents. */\n\t || bt_nofile(wp->w_buffer)\n#endif\n )\n\treturn (ssop_flags & SSOP_BLANK);\n if (wp->w_buffer->b_help)\n\treturn (ssop_flags & SSOP_HELP);\n return TRUE;\n}", "label": 0, "cwe": null, "length": 105 }, { "index": 209517, "code": "com90io_found(struct net_device *dev)\n{\n\tstruct arcnet_local *lp;\n\tint ioaddr = dev->base_addr;\n\tint err;\n\n\t/* Reserve the irq */\n\tif (request_irq(dev->irq, arcnet_interrupt, 0,\n\t\t\t\"arcnet (COM90xx-IO)\", dev)) {\n\t\tarc_printk(D_NORMAL, dev, \"Can't get IRQ %d!\\n\", dev->irq);\n\t\treturn -ENODEV;\n\t}\n\t/* Reserve the I/O region */\n\tif (!request_region(dev->base_addr, ARCNET_TOTAL_SIZE,\n\t\t\t \"arcnet (COM90xx-IO)\")) {\n\t\tfree_irq(dev->irq, dev);\n\t\treturn -EBUSY;\n\t}\n\n\tlp = netdev_priv(dev);\n\tlp->card_name = \"COM90xx I/O\";\n\tlp->hw.command = com90io_command;\n\tlp->hw.status = com90io_status;\n\tlp->hw.intmask = com90io_setmask;\n\tlp->hw.reset = com90io_reset;\n\tlp->hw.owner = THIS_MODULE;\n\tlp->hw.copy_to_card = com90io_copy_to_card;\n\tlp->hw.copy_from_card = com90io_copy_from_card;\n\n\tlp->config = (0x16 | IOMAPflag) & ~ENABLE16flag;\n\tarcnet_outb(lp->config, ioaddr, COM9026_REG_RW_CONFIG);\n\n\t/* get and check the station ID from offset 1 in shmem */\n\n\tdev->dev_addr[0] = get_buffer_byte(dev, 1);\n\n\terr = register_netdev(dev);\n\tif (err) {\n\t\tarcnet_outb(arcnet_inb(ioaddr, COM9026_REG_RW_CONFIG) & ~IOMAPflag,\n\t\t\t ioaddr, COM9026_REG_RW_CONFIG);\n\t\tfree_irq(dev->irq, dev);\n\t\trelease_region(dev->base_addr, ARCNET_TOTAL_SIZE);\n\t\treturn err;\n\t}\n\n\tarc_printk(D_NORMAL, dev, \"COM90IO: station %02Xh found at %03lXh, IRQ %d.\\n\",\n\t\t dev->dev_addr[0], dev->base_addr, dev->irq);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 454 }, { "index": 184800, "code": "print_link_conf(netdissect_options *ndo, const struct link_conf_tipc_pkthdr *ap)\n{\n\tu_int32_t w0, w1, w5;\n\tu_int user;\n\tu_int hsize;\n\tu_int msize;\n\tu_int mtype;\n\tu_int node_sig;\n\tu_int prev_node;\n\tu_int dest_domain;\n\tu_int ntwrk_id;\n\tu_int media_id;\n\n\tND_TCHECK(ap->prev_node);\n\tw0 = EXTRACT_32BITS(&ap->w0);\n\tuser = TIPC_USER(w0);\n\thsize = TIPC_HSIZE(w0);\n\tmsize = TIPC_MSIZE(w0);\n\tw1 = EXTRACT_32BITS(&ap->w1);\n\tmtype = TIPC_MTYPE(w1);\n\tprev_node = EXTRACT_32BITS(&ap->prev_node);\n\tdest_domain = EXTRACT_32BITS(&ap->dest_domain);\n\tprev_node = EXTRACT_32BITS(&ap->prev_node);\n\n\tND_PRINT((ndo, \"TIPC v%u.0 %u.%u.%u > %u.%u.%u, headerlength %u bytes, MessageSize %u bytes, %s, messageType %s\",\n\t TIPC_VER(w0),\n\t TIPC_ZONE(prev_node), TIPC_CLUSTER(prev_node), TIPC_NODE(prev_node),\n\t TIPC_ZONE(dest_domain), TIPC_CLUSTER(dest_domain), TIPC_NODE(dest_domain),\n\t hsize*4, msize,\n\t tok2str(tipcuser_values, \"unknown\", user),\n\t tok2str(tipc_linkconf_mtype_values, \"Unknown\", mtype)));\n\tif (ndo->ndo_vflag) {\n\t\tND_TCHECK(ap->w5);\n\t\tnode_sig = TIPC_NODE_SIG(w1);\n\t\tntwrk_id = EXTRACT_32BITS(&ap->ntwrk_id);\n\t\tw5 = EXTRACT_32BITS(&ap->w5);\n\t\tmedia_id = TIPC_MEDIA_ID(w5);\n\t\tND_PRINT((ndo, \"\\n\\tNodeSignature %u, network_id %u, media_id %u\",\n\t\t node_sig, ntwrk_id, media_id));\n\t}\n\treturn;\n\ntrunc:\n\tND_PRINT((ndo, \"[|TIPC]\"));\n}", "label": 0, "cwe": null, "length": 467 }, { "index": 719872, "code": "ReadAnimations(Mesh *mesh)\n{\n\tif (!AtEnd())\n\t{\n\t\tuint16_t id = ReadHeader();\n\t\twhile (!AtEnd() && id == M_ANIMATION)\n\t\t{\n\t\t\tAnimation *anim = new Animation(mesh);\n\t\t\tanim->name = ReadLine();\n\t\t\tanim->length = Read();\n\t\t\t\n\t\t\tReadAnimation(anim);\n\n\t\t\tmesh->animations.push_back(anim);\n\n\t\t\tif (!AtEnd())\n\t\t\t\tid = ReadHeader();\n\t\t}\n\t\tif (!AtEnd())\n\t\t\tRollbackHeader();\n\t}\n}", "label": 0, "cwe": null, "length": 113 }, { "index": 100419, "code": "set_one_color (PropsID props, gchar *key, GtkWidget *picker)\n{\n\tGdkColor color;\n\tgchar *str;\n\tgtk_color_button_get_color (GTK_COLOR_BUTTON (picker), &color);\n\tstr = anjuta_util_string_from_color (color.red,\n\t\t\t\t\t\t\t\t\t\t color.green,\n\t\t\t\t\t\t\t\t\t\t color.blue);\n\tif(str)\n\t{\n\t\tsci_prop_set_with_key (props, key, str);\n\t\tg_free (str);\n\t}\n}", "label": 0, "cwe": null, "length": 92 }, { "index": 402267, "code": "keydb_rebuild_caches (int noisy)\n{\n int i, rc;\n\n for (i=0; i < used_resources; i++)\n {\n if (all_resources[i].secret)\n continue;\n switch (all_resources[i].type)\n {\n case KEYDB_RESOURCE_TYPE_NONE: /* ignore */\n break;\n case KEYDB_RESOURCE_TYPE_KEYRING:\n rc = keyring_rebuild_cache (all_resources[i].token,noisy);\n if (rc)\n log_error (_(\"failed to rebuild keyring cache: %s\\n\"),\n g10_errstr (rc));\n break;\n }\n }\n}", "label": 0, "cwe": null, "length": 134 }, { "index": 462906, "code": "fill_cmd_enable_message_channel_receive (uint8_t channel_number,\n uint8_t channel_operation,\n fiid_obj_t obj_cmd_rq)\n{\n if (!IPMI_CHANNEL_NUMBER_VALID (channel_number)\n || !IPMI_CHANNEL_OPERATION_VALID (channel_operation)\n || !fiid_obj_valid (obj_cmd_rq))\n {\n SET_ERRNO (EINVAL);\n return (-1);\n }\n\n if (FIID_OBJ_TEMPLATE_COMPARE (obj_cmd_rq, tmpl_cmd_enable_message_channel_receive_rq) < 0)\n {\n ERRNO_TRACE (errno);\n return (-1);\n }\n\n FILL_FIID_OBJ_CLEAR (obj_cmd_rq);\n FILL_FIID_OBJ_SET (obj_cmd_rq, \"cmd\", IPMI_CMD_ENABLE_MESSAGE_CHANNEL_RECEIVE);\n FILL_FIID_OBJ_SET (obj_cmd_rq, \"channel_number\", channel_number);\n FILL_FIID_OBJ_SET (obj_cmd_rq, \"reserved1\", 0);\n FILL_FIID_OBJ_SET (obj_cmd_rq, \"channel_operation\", channel_operation);\n FILL_FIID_OBJ_SET (obj_cmd_rq, \"reserved2\", 0);\n return (0);\n}", "label": 0, "cwe": null, "length": 242 }, { "index": 79372, "code": "print_error_host(const uint8_t code,\n const knot_packet_t *packet,\n const style_t *style)\n{\n\tconst char *rcode_str = \"NULL\";\n\tchar type[32] = \"NULL\";\n\tchar *owner;\n\n\tknot_lookup_table_t *rcode;\n\n\towner = knot_dname_to_str(knot_packet_qname(packet));\n\tif (style->style.ascii_to_idn != NULL) {\n\t\tstyle->style.ascii_to_idn(&owner);\n\t}\n\trcode = knot_lookup_by_id(knot_rcode_names, code);\n\tif (rcode != NULL) {\n\t\trcode_str = rcode->name;\n\t}\n\tknot_rrtype_to_string(knot_packet_qtype(packet), type, sizeof(type));\n\n\tif (code == KNOT_RCODE_NOERROR) {\n\t\tprintf(\"Host %s has no %s record\\n\", owner, type);\n\t} else {\n\t\tprintf(\"Host %s type %s error: %s\\n\", owner, type, rcode_str);\n\t}\n\n\tfree(owner);\n}", "label": 0, "cwe": null, "length": 213 }, { "index": 809495, "code": "i40e_set_features(struct net_device *netdev,\n\t\t\t netdev_features_t features)\n{\n\tstruct i40e_netdev_priv *np = netdev_priv(netdev);\n\tstruct i40e_vsi *vsi = np->vsi;\n\tstruct i40e_pf *pf = vsi->back;\n\tbool need_reset;\n\n\tif (features & NETIF_F_HW_VLAN_CTAG_RX)\n\t\ti40e_vlan_stripping_enable(vsi);\n\telse\n\t\ti40e_vlan_stripping_disable(vsi);\n\n\tneed_reset = i40e_set_ntuple(pf, features);\n\n\tif (need_reset)\n\t\ti40e_do_reset(pf, BIT_ULL(__I40E_PF_RESET_REQUESTED));\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 152 }, { "index": 413398, "code": "LRE_DidCloneVirtReg(unsigned New, unsigned Old) {\n // Cloning a register we haven't even heard about yet? Just ignore it.\n if (!ExtraRegInfo.inBounds(Old))\n return;\n\n // LRE may clone a virtual register because dead code elimination causes it to\n // be split into connected components. The new components are much smaller\n // than the original, so they should get a new chance at being assigned.\n // same stage as the parent.\n ExtraRegInfo[Old].Stage = RS_Assign;\n ExtraRegInfo.grow(New);\n ExtraRegInfo[New] = ExtraRegInfo[Old];\n}", "label": 0, "cwe": null, "length": 142 }, { "index": 857878, "code": "i40e_parse_ieee_tlv(struct i40e_lldp_org_tlv *tlv,\n\t\t\t\tstruct i40e_dcbx_config *dcbcfg)\n{\n\tu32 ouisubtype;\n\tu8 subtype;\n\n\touisubtype = ntohl(tlv->ouisubtype);\n\tsubtype = (u8)((ouisubtype & I40E_LLDP_TLV_SUBTYPE_MASK) >>\n\t\t I40E_LLDP_TLV_SUBTYPE_SHIFT);\n\tswitch (subtype) {\n\tcase I40E_IEEE_SUBTYPE_ETS_CFG:\n\t\ti40e_parse_ieee_etscfg_tlv(tlv, dcbcfg);\n\t\tbreak;\n\tcase I40E_IEEE_SUBTYPE_ETS_REC:\n\t\ti40e_parse_ieee_etsrec_tlv(tlv, dcbcfg);\n\t\tbreak;\n\tcase I40E_IEEE_SUBTYPE_PFC_CFG:\n\t\ti40e_parse_ieee_pfccfg_tlv(tlv, dcbcfg);\n\t\tbreak;\n\tcase I40E_IEEE_SUBTYPE_APP_PRI:\n\t\ti40e_parse_ieee_app_tlv(tlv, dcbcfg);\n\t\tbreak;\n\tdefault:\n\t\tbreak;\n\t}\n}", "label": 0, "cwe": null, "length": 245 }, { "index": 224282, "code": "am_reconstruct_url(request_rec *r)\n{\n char *url;\n\n /* This function will construct an full url for a given path relative to\n * the root of the web site. To configure what hostname and port this\n * function will use, see the UseCanonicalName configuration directive.\n */\n url = ap_construct_url(r->pool, r->unparsed_uri, r);\n\n ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,\n \"reconstruct_url: url==\\\"%s\\\", unparsed_uri==\\\"%s\\\"\", url,\n r->unparsed_uri);\n return url;\n}", "label": 0, "cwe": null, "length": 135 }, { "index": 250669, "code": "html_list(\n struct Blob *ob,\n struct Blob *text,\n int flags,\n void *opaque\n){\n char ol[] = \"ol\";\n char ul[] = \"ul\";\n char *tag = (flags & MKD_LIST_ORDERED) ? ol : ul;\n INTER_BLOCK(ob);\n blob_appendf(ob, \"<%s>\\n\", tag);\n BLOB_APPEND_BLOB(ob, text);\n blob_appendf(ob, \"\\n\", tag);\n}", "label": 0, "cwe": null, "length": 105 }, { "index": 82032, "code": "A_IceGuyChase(mobj_t * actor)\n{\n fixed_t dist;\n fixed_t an;\n mobj_t *mo;\n\n A_Chase(actor);\n if (P_Random() < 128)\n {\n dist = ((P_Random() - 128) * actor->radius) >> 7;\n an = (actor->angle + ANG90) >> ANGLETOFINESHIFT;\n\n mo = P_SpawnMobj(actor->x + FixedMul(dist, finecosine[an]),\n actor->y + FixedMul(dist, finesine[an]),\n actor->z + 60 * FRACUNIT,\n MT_ICEGUY_WISP1 + (P_Random() & 1));\n if (mo)\n {\n mo->momx = actor->momx;\n mo->momy = actor->momy;\n mo->momz = actor->momz;\n mo->target = actor;\n }\n }\n}", "label": 0, "cwe": null, "length": 210 }, { "index": 983960, "code": "m32_gen_access(struct m32_data *d,cpu_gen_t *cpu,\n m_uint32_t offset,u_int op_size,u_int op_type,\n m_uint64_t *data)\n{\n switch(offset) {\n /* Action Specification */\n case 0x0:\n if (op_type == MTS_WRITE)\n m32_action_req(d,*data);\n return NULL;\n\n /* Configuration memory */\n default:\n switch(op_size) {\n case 4:\n if (op_type == MTS_READ)\n *data = m32_get_cfgw(d,offset);\n else\n m32_set_cfgw(d,offset,*data);\n break;\n\n case 1:\n if (op_type == MTS_READ) {\n *data = m32_get_cfgw(d,offset & ~0x03);\n *data >>= (24 - ((offset & 0x03) << 3));\n *data &= 0xFF;\n } else {\n printf(\"UNSUPPORTED(1)!!!!\\n\");\n }\n break;\n\n case 2:\n if (op_type == MTS_READ) {\n *data = m32_get_cfgw(d,offset & ~0x03);\n *data >>= (16 - ((offset & 0x03) << 3));\n *data &= 0xFFFF;\n } else {\n printf(\"UNSUPPORTED(2)!!!!\\n\");\n }\n break;\n\n case 8:\n if (op_type == MTS_READ) {\n *data = (m_uint64_t)m32_get_cfgw(d,offset) << 32;\n *data |= m32_get_cfgw(d,offset+4);\n } else {\n printf(\"UNSUPPORTED(8)!!!!\\n\");\n }\n break;\n\n default:\n printf(\"UNSUPPORTED (size=%u)!!!\\n\",op_size);\n }\n }\n\n return NULL;\n}", "label": 0, "cwe": null, "length": 409 }, { "index": 231487, "code": "loadableobject_decode(const fn_call& fn)\n{\n as_object* ptr = ensure(fn);\n\n if (!fn.nargs) return as_value(false);\n\n typedef std::map ValuesMap;\n ValuesMap vals;\n\n const int version = getSWFVersion(fn);\n const std::string qs = fn.arg(0).to_string(version);\n\n if (qs.empty()) return as_value();\n\n typedef boost::char_separator Sep;\n typedef boost::tokenizer Tok;\n Tok t1(qs, Sep(\"&\"));\n\n VM& vm = getVM(fn);\n\n for (Tok::iterator tit=t1.begin(); tit!=t1.end(); ++tit) {\n\n const std::string& nameval = *tit;\n\n std::string name;\n std::string value;\n\n size_t eq = nameval.find(\"=\");\n if (eq == std::string::npos) name = nameval;\n else {\n name = nameval.substr(0, eq);\n value = nameval.substr(eq + 1);\n }\n\n URL::decode(name);\n URL::decode(value);\n\n if (!name.empty()) ptr->set_member(getURI(vm, name), value);\n }\n\n return as_value(); \n}", "label": 0, "cwe": null, "length": 271 }, { "index": 101384, "code": "xdr_krb5_string_attr(XDR *xdrs, krb5_string_attr *objp)\n{\n\tif (!xdr_nullstring(xdrs, &objp->key))\n\t\treturn FALSE;\n\tif (!xdr_nullstring(xdrs, &objp->value))\n\t\treturn FALSE;\n\tif (xdrs->x_op == XDR_DECODE &&\n\t (objp->key == NULL || objp->value == NULL))\n\t\treturn FALSE;\n\treturn TRUE;\n}", "label": 0, "cwe": null, "length": 98 }, { "index": 404630, "code": "us_mtc_increment( us_mtc_t *self )\n{\n uint8_t lim = us_mtc_max_frame[self->m_fmt];\n if ( self->m_frame < lim - 1 )\n {\n self->m_frame++;\n }\n else\n {\n self->m_frame = 0;\n if ( self->m_second < 60 - 1 )\n {\n self->m_second++;\n }\n else\n {\n self->m_second = 0;\n if ( self->m_minute < 60 - 1 )\n {\n self->m_minute++;\n }\n else\n {\n self->m_minute = 0;\n if ( self->m_hour < 24 - 1 )\n {\n self->m_hour++;\n }\n else\n {\n self->m_hour = 0;\n }\n }\n }\n }\n if ( us_mtc_is_drop[self->m_fmt] )\n {\n bool min_is_divisible_by_ten = false;\n if ( ( self->m_minute % 10 ) == 0 )\n min_is_divisible_by_ten = true;\n if ( self->m_frame == 0 && self->m_second == 0 && !min_is_divisible_by_ten )\n {\n self->m_frame = 2;\n }\n }\n}", "label": 0, "cwe": null, "length": 285 }, { "index": 331909, "code": "do_load(unsigned char *data, unsigned long size, fileio_prop_t *prop)\n{\n long len;\n\n len = fill_prop(data, size, prop);\n if (len < 0)\n return -1;\n \n prop->data = (unsigned char *)malloc(prop->size);\n if (prop->data == NULL)\n return -1;\n\n memcpy(prop->data, data, prop->size);\n\n return prop->size;\n}", "label": 1, "cwe": "CWE-120", "length": 96 }, { "index": 542245, "code": "getGenericPartialLocationString(const UnicodeString &tzid, UBool isShort,\n UDate date, UBool commonlyUsedOnly, UnicodeString &result) const {\n result.remove();\n if (fTzidToStrings.count() <= 0) {\n return result;\n }\n\n UnicodeString canonicalID;\n UErrorCode status = U_ZERO_ERROR;\n TimeZone::getCanonicalID(tzid, canonicalID, status);\n if (U_FAILURE(status)) {\n // Unknown ID, so no corresponding meta data.\n return result;\n }\n\n UnicodeString mzid;\n ZoneMeta::getMetazoneID(canonicalID, date, mzid);\n\n if (!mzid.isEmpty()) {\n ZoneStrings *zstrings = (ZoneStrings*)fTzidToStrings.get(canonicalID);\n if (zstrings != NULL) {\n zstrings->getGenericPartialLocationString(mzid, isShort, commonlyUsedOnly, result);\n }\n }\n return result;\n}", "label": 0, "cwe": null, "length": 212 }, { "index": 936135, "code": "e_fm2_custom_file_dup(const E_Fm2_Custom_File *cf)\n{\n E_Fm2_Custom_File *copy;\n\n if (!cf) return NULL;\n\n copy = calloc(1, sizeof(*copy));\n if (!copy) return NULL;\n\n memcpy(copy, cf, sizeof(*copy));\n copy->icon.icon = eina_stringshare_add(cf->icon.icon);\n copy->label = eina_stringshare_add(cf->label);\n copy->dir = _e_fm2_custom_dir_dup(cf->dir);\n return copy;\n}", "label": 0, "cwe": null, "length": 116 }, { "index": 912309, "code": "PCSound_Init(pcsound_callback_func callback_func)\n{\n char *driver_name;\n int i;\n\n if (pcsound_driver != NULL)\n {\n return 1;\n }\n\n // Check if the environment variable is set\n\n driver_name = getenv(\"PCSOUND_DRIVER\");\n\n if (driver_name != NULL)\n {\n for (i=0; drivers[i] != NULL; ++i)\n {\n if (!strcmp(drivers[i]->name, driver_name))\n {\n // Found the driver!\n\n if (drivers[i]->init_func(callback_func))\n {\n pcsound_driver = drivers[i];\n }\n else\n {\n printf(\"Failed to initialize PC sound driver: %s\\n\",\n drivers[i]->name);\n break;\n }\n }\n }\n }\n else\n {\n // Try all drivers until we find a working one\n\n for (i=0; drivers[i] != NULL; ++i)\n {\n if (drivers[i]->init_func(callback_func)) \n {\n pcsound_driver = drivers[i];\n break;\n }\n }\n }\n \n if (pcsound_driver != NULL)\n {\n printf(\"Using PC sound driver: %s\\n\", pcsound_driver->name);\n return 1;\n }\n else\n {\n printf(\"Failed to find a working PC sound driver.\\n\");\n return 0;\n }\n}", "label": 1, "cwe": "CWE-other", "length": 299 }, { "index": 576961, "code": "construct_IntSet_array(int anum, int range)\n{\n int i;\n IntSet *array;\n\n array = (IntSet *)calloc(anum, sizeof(IntSet));\n if (array == NULL) {\n abort();\n }\n for (i = 0; i < anum; i++) {\n construct_IntSet(array[i], range);\n clear_IntSet(array[i]);\n }\n return array;\n}", "label": 0, "cwe": null, "length": 90 }, { "index": 3789, "code": "gdome_xml_el_getAttribute (GdomeElement *self, GdomeDOMString *name, GdomeException *exc)\n{\n Gdome_xml_Element *priv = (Gdome_xml_Element *)self;\n xmlChar *value = NULL;\n\txmlNs *ns = NULL;\n\tgchar **strs;\n\n g_return_val_if_fail (priv != NULL, NULL);\n g_return_val_if_fail (GDOME_XML_IS_EL (priv), NULL);\n g_return_val_if_fail (name != NULL, NULL);\n g_return_val_if_fail (exc != NULL, NULL);\n\n\tvalue = xmlGetProp (priv->n, name->str);\n\n\tif (value != NULL)\n\t\treturn gdome_xml_str_mkref_own (value);\n\telse {\n\t\tstrs = g_strsplit((gchar *)name->str, \":\", 0);\n\t\tif (xmlStrEqual(strs[0], \"xmlns\"))\n\t\t\tns = gdome_xmlGetNsDecl(priv->n, strs[1]);\n\t\tg_strfreev(strs);\n\t\tif (ns != NULL)\n\t\t\treturn gdome_xml_str_mkref_dup ((gchar *)ns->href);\n\t\telse\n\t\t\treturn gdome_xml_str_mkref_dup (\"\");\n\t}\n}", "label": 0, "cwe": null, "length": 260 }, { "index": 86350, "code": "columns_spinbutton_changed_cb (GtkSpinButton *widget,\n\t\t\t gpointer user_data)\n{\n\tGthImagePrintJob *self = user_data;\n\tint i;\n\n\tself->priv->n_columns = gtk_spin_button_get_value_as_int (widget);\n\tfor (i = 0; i < self->priv->n_images; i++)\n\t\tgth_image_info_reset (self->priv->images[i]);\n\tgth_image_print_job_update_preview (self);\n}", "label": 0, "cwe": null, "length": 95 }, { "index": 684431, "code": "InitStatBar( void )\n{\n wxString os1;\n int ia1[ ePANE_LAST+1 ];\n\n // Create the status bar\n CreateStatusBar( ePANE_LAST+1 );\n\n // Disable the status bar pane used to display menu and toolbar help\n SetStatusBarPane( -1 );\n\n // Determine the status bar field widths\n ia1[ ePANE_MESG ] = -1; // Variable width\n ia1[ ePANE_SIMR ] = 144; // Fixed width\n ia1[ ePANE_VIEW ] = 116; // Fixed width\n SetStatusWidths( ePANE_LAST+1, ia1 );\n\n // Get the viewer application name from the configuration object\n m_poCfg->SetPath( wxT(\"/Viewer\") );\n m_poCfg->Read( wxT(\"Name\"), &os1, CLP_GWAVE );\n\n // Set status bar text\n SetStatusText( wxT(\" Welcome message\") , ePANE_MESG );\n SetStatusText( wxT(\" Simulator : None\"), ePANE_SIMR );\n SetStatusText( wxT(\" Viewer : \") + os1 , ePANE_VIEW );\n}", "label": 0, "cwe": null, "length": 256 }, { "index": 577297, "code": "newSymbol(const C *str,S prevsym)\n{\n int mw;\n SBS cur,prev;\n S res;\n\n mw=((12+strlen(str))>>2)&~0x01;\n for(cur=&SymBlockListHead,prev=cur;cur=cur->next;prev=cur)\n {\n if (cur->size-cur->idx>=mw) break;\n }\n if(!cur)\n {\n allocNewBlock(mw);\n prev=&SymBlockListHead;\n cur=prev->next;\n }\n res=(S)(cur->buf+cur->idx);\n res->s=prevsym->s,prevsym->s=res,strcpy(res->n,str);\n\n /* See if we need to move block to Full list. */\n cur->idx += mw;\n ++cur->count;\n if(cur->size-cur->idxnext=cur->next;\n cur->next=FullSymBlockList;\n FullSymBlockList=cur;\n }\n\n /* See if we need to grow hash table. */\n if(SymHashTable->nb*SBS_TRIGGERRATIO<++SymHashTable->ni)growSymHashTable();\n\n R res;\n}", "label": 0, "cwe": null, "length": 265 }, { "index": 85748, "code": "Settings_GetLowerCaseArg(const char *inarg, char *outarg) {\n\n int len = strlen(inarg);\n strcpy(outarg,inarg);\n\n if ( (len > 0) && (inarg[len-1] >='A') \n && (inarg[len-1] <= 'Z') )\n outarg[len-1]= outarg[len-1]-'A'+'a';\n}", "label": 1, "cwe": "CWE-120", "length": 87 }, { "index": 7874, "code": "OneOrMore(ParseFunc parse_func, State *state) {\n if (parse_func(state)) {\n while (parse_func(state)) {\n }\n return true;\n }\n return false;\n}", "label": 0, "cwe": null, "length": 43 }, { "index": 28357, "code": "rtw_efuse_access23a(struct rtw_adapter *padapter, u8 bWrite, u16 start_addr,\n\t\t\tu16 cnts, u8 *data)\n{\n\tint i = 0;\n\tu16 real_content_len = 0, max_available_size = 0;\n\tint res = _FAIL;\n\tint (*rw8)(struct rtw_adapter *, u16, u8*);\n\n\tEFUSE_GetEfuseDefinition23a(padapter, EFUSE_WIFI,\n\t\t\t\t TYPE_EFUSE_REAL_CONTENT_LEN,\n\t\t\t\t (void *)&real_content_len);\n\tEFUSE_GetEfuseDefinition23a(padapter, EFUSE_WIFI,\n\t\t\t\t TYPE_AVAILABLE_EFUSE_BYTES_TOTAL,\n\t\t\t\t (void *)&max_available_size);\n\n\tif (start_addr > real_content_len)\n\t\treturn _FAIL;\n\n\tif (true == bWrite) {\n\t\tif ((start_addr + cnts) > max_available_size)\n\t\t\treturn _FAIL;\n\t\trw8 = &efuse_write8;\n\t} else\n\t\trw8 = &efuse_read8;\n\n\tEfuse_PowerSwitch(padapter, bWrite, true);\n\n\t/* e-fuse one byte read/write */\n\tfor (i = 0; i < cnts; i++) {\n\t\tif (start_addr >= real_content_len) {\n\t\t\tres = _FAIL;\n\t\t\tbreak;\n\t\t}\n\n\t\tres = rw8(padapter, start_addr++, data++);\n\t\tif (res == _FAIL)\n\t\t\tbreak;\n\t}\n\n\tEfuse_PowerSwitch(padapter, bWrite, false);\n\n\treturn res;\n}", "label": 0, "cwe": null, "length": 319 }, { "index": 44303, "code": "create_name_for_language (const char *code)\n{\n\tchar **str;\n\tchar *name = NULL;\n\tconst char *langname, *localename;\n\tint len;\n\n\tg_return_val_if_fail (iso_639_table != NULL, NULL);\n\tg_return_val_if_fail (iso_3166_table != NULL, NULL);\n\n\tstr = g_strsplit (code, \"_\", -1);\n\tlen = g_strv_length (str);\n\tg_return_val_if_fail (len != 0, NULL);\n\n\tlangname = (const char *) g_hash_table_lookup (iso_639_table, str[0]);\n\n\tif (len == 1 && langname != NULL)\n\t{\n\t\tname = g_strdup (dgettext (ISO_639_DOMAIN, langname));\n\t}\n\telse if (len == 2 && langname != NULL)\n\t{\n\t\tgchar *locale_code = g_ascii_strdown (str[1], -1);\n\n\t\tlocalename = (const char *) g_hash_table_lookup (iso_3166_table, locale_code);\n\t\tg_free (locale_code);\n\n\t\tif (localename != NULL)\n\t\t{\n\t\t\t/* Translators: the first %s is the language name, and\n\t\t\t * the second %s is the locale name. Example:\n\t\t\t * \"French (France)\"\n\t\t\t */\n\t\t\tname = g_strdup_printf (C_(\"language\", \"%s (%s)\"),\n\t\t\t\t\t\tdgettext (ISO_639_DOMAIN, langname),\n\t\t\t\t\t\tdgettext (ISO_3166_DOMAIN, localename));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tname = g_strdup_printf (C_(\"language\", \"%s (%s)\"),\n\t\t\t\t\t\tdgettext (ISO_639_DOMAIN, langname), str[1]);\n\t\t}\n\t}\n\telse\n\t{\n\t\t/* Translators: this refers to an unknown language code\n\t\t * (one which isn't in our built-in list).\n\t\t */\n\t\tname = g_strdup_printf (C_(\"language\", \"Unknown (%s)\"), code);\n\t}\n\n\tg_strfreev (str);\n\n\treturn name;\n}", "label": 0, "cwe": null, "length": 425 }, { "index": 265453, "code": "rtx_mem_access_p (rtx x)\n{\n int i, j;\n const char *fmt;\n enum rtx_code code;\n\n if (x == 0)\n return false;\n\n if (MEM_P (x))\n return true;\n\n code = GET_CODE (x);\n fmt = GET_RTX_FORMAT (code);\n for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)\n {\n if (fmt[i] == 'e')\n\t{\n\t if (rtx_mem_access_p (XEXP (x, i)))\n return true;\n }\n else if (fmt[i] == 'E')\n\tfor (j = 0; j < XVECLEN (x, i); j++)\n\t {\n\t if (rtx_mem_access_p (XVECEXP (x, i, j)))\n return true;\n }\n }\n return false;\n}", "label": 0, "cwe": null, "length": 197 }, { "index": 546291, "code": "es_gl_swapBuffers(sdl_data *sd, int len, char *buff)\n{ \n char *bp, *start;\n int sendlen;\n Uint32 ts;\n \n if(!sd->use_smp) \n SDL_GL_SwapBuffers();\n else\n gl_dispatch(sd, SDL_GL_SwapBuffersFunc, len, buff);\n \n /* Timer is removed it a bad idea anyway \n (works if vsync is on only I believe) */\n \n bp = start = sdl_get_temp_buff(sd, 4);\n ts = 0; \n put32be(bp, ts);\n sendlen = bp - start;\n sdl_send(sd, sendlen);\n}", "label": 0, "cwe": null, "length": 147 }, { "index": 377317, "code": "toggleState(FluxboxWindow &win, Atom state, WinClient &client) {\n if (state == m_net->wm_state_sticky) { // sticky\n win.stick();\n } else if (state == m_net->wm_state_shaded){ // shaded\n win.shade();\n } else if (state == m_net->wm_state_maximized_horz ) { // maximized Horizontal\n win.maximizeHorizontal();\n } else if (state == m_net->wm_state_maximized_vert) { // maximized Vertical\n win.maximizeVertical();\n } else if (state == m_net->wm_state_fullscreen) { // fullscreen\n win.setFullscreen(!win.isFullscreen()); // toggle current state\n } else if (state == m_net->wm_state_hidden) { // minimized\n if(win.isIconic())\n win.deiconify();\n else\n win.iconify();\n } else if (state == m_net->wm_state_skip_taskbar) { // taskbar\n win.setIconHidden(!win.isIconHidden());\n } else if (state == m_net->wm_state_below) { // bottom layer\n if (win.layerNum() == ResourceLayer::BOTTOM)\n win.moveToLayer(ResourceLayer::NORMAL);\n else\n win.moveToLayer(ResourceLayer::BOTTOM);\n\n } else if (state == m_net->wm_state_above) { // top layer\n if (win.layerNum() == ResourceLayer::ABOVE_DOCK)\n win.moveToLayer(ResourceLayer::NORMAL);\n else\n win.moveToLayer(ResourceLayer::ABOVE_DOCK);\n } else if (state == m_net->wm_state_modal) { // modal\n client.setStateModal(!client.isStateModal());\n }\n\n}", "label": 0, "cwe": null, "length": 367 }, { "index": 808229, "code": "SetIncrementalResetCommand(\n void *theEnv)\n {\n int oldValue;\n DATA_OBJECT argPtr;\n\n oldValue = EnvGetIncrementalReset(theEnv);\n\n /*============================================*/\n /* Check for the correct number of arguments. */\n /*============================================*/\n\n if (EnvArgCountCheck(theEnv,\"set-incremental-reset\",EXACTLY,1) == -1)\n { return(oldValue); }\n\n /*=========================================*/\n /* The incremental reset behavior can't be */\n /* changed when rules are loaded. */\n /*=========================================*/\n\n if (EnvGetNextDefrule(theEnv,NULL) != NULL)\n {\n PrintErrorID(theEnv,\"INCRRSET\",1,FALSE);\n EnvPrintRouter(theEnv,WERROR,\"The incremental reset behavior cannot be changed with rules loaded.\\n\");\n SetEvaluationError(theEnv,TRUE);\n return(oldValue);\n }\n\n /*==================================================*/\n /* The symbol FALSE disables incremental reset. Any */\n /* other value enables incremental reset. */\n /*==================================================*/\n\n EnvRtnUnknown(theEnv,1,&argPtr);\n\n if ((argPtr.value == EnvFalseSymbol(theEnv)) && (argPtr.type == SYMBOL))\n { EnvSetIncrementalReset(theEnv,FALSE); }\n else\n { EnvSetIncrementalReset(theEnv,TRUE); }\n\n /*=======================*/\n /* Return the old value. */\n /*=======================*/\n\n return(oldValue);\n }", "label": 0, "cwe": null, "length": 309 }, { "index": 685378, "code": "liblo10k1lf_dsp_config_set_patch_count(liblo10k1_file_dsp_setup_t *c, int count)\n{\t\t\n\tint i;\n\t/* alloc patches list */\n\tliblo10k1_dsp_patch_t **tmp = NULL;\n\t\n\tif (count > 0) {\n\t\ttmp = (liblo10k1_dsp_patch_t **)malloc(sizeof(liblo10k1_dsp_patch_t *) * count);\n\t\tif (!tmp)\n\t\t\treturn LD10K1_ERR_NO_MEM;\n\t\t\t\n\t\tmemset(tmp, 0, sizeof(liblo10k1_dsp_patch_t *) * count);\n\t}\n\t\n\tif (c->patches) {\n\t\tfor (i = 0; i < c->patch_count; i++) {\n\t\t\tif (c->patches[i])\n\t\t\t\tliblo10k1_patch_free(c->patches[i]);\n\t\t}\n\t\tfree(c->patches);\n\t}\n\t\n\tc->patch_count = count;\n\tc->patches = tmp;\n\treturn 0;\n}", "label": 1, "cwe": "CWE-120", "length": 208 }, { "index": 99557, "code": "copyIndexedAToIndexed(Layer& layer, uint i, uint j, int k, int l,\n\t\tQImage& image, int m, int n)\n{\n\tuchar src = layer.image_tiles[j][i].pixelIndex(k, l);\n\tuchar src_a = layer.alpha_tiles[j][i].pixelIndex(k, l);\n\tsrc_a = INT_MULT(src_a, layer.opacity);\n\n\tif (layer.apply_mask == 1 &&\n\t\t\tlayer.mask_tiles.size() > (int)j &&\n\t\t\tlayer.mask_tiles[j].size() > (int)i)\n\t\tsrc_a = INT_MULT(src_a, layer.mask_tiles[j][i].pixelIndex(k, l));\n\n\tif (src_a > 127)\n\t\tsrc++;\n\telse\n\t\tsrc = 0;\n\nimage.setPixel(m, n, src);\n}", "label": 0, "cwe": null, "length": 167 }, { "index": 264751, "code": "load_module (RuleInfo *info,\n gboolean initialize)\n{\n\tModuleInfo *module_info = NULL;\n\n\tif (modules) {\n\t\tmodule_info = g_hash_table_lookup (modules, info->module_path);\n\t}\n\n\tif (!module_info) {\n\t\tGModule *module;\n\n\t\t/* Load the module */\n\t\tmodule = g_module_open (info->module_path, G_MODULE_BIND_LOCAL);\n\n\t\tif (!module) {\n\t\t\tg_warning (\"Could not load module '%s': %s\",\n\t\t\t info->module_path,\n\t\t\t g_module_error ());\n\t\t\treturn NULL;\n\t\t}\n\n\t\tg_module_make_resident (module);\n\n\t\tmodule_info = g_slice_new0 (ModuleInfo);\n\t\tmodule_info->module = module;\n\n\t\tif (!g_module_symbol (module, EXTRACTOR_FUNCTION, (gpointer *) &module_info->extract_func)) {\n\t\t\tg_warning (\"Could not load module '%s': Function %s() was not found, is it exported?\",\n\t\t\t g_module_name (module), EXTRACTOR_FUNCTION);\n\t\t\tg_slice_free (ModuleInfo, module_info);\n\t\t\treturn NULL;\n\t\t}\n\n\t\tg_module_symbol (module, INIT_FUNCTION, (gpointer *) &module_info->init_func);\n\t\tg_module_symbol (module, SHUTDOWN_FUNCTION, (gpointer *) &module_info->shutdown_func);\n\n\t\t/* Add it to the cache */\n\t\tif (G_UNLIKELY (!modules)) {\n\t\t\t/* Key is an intern string, so\n\t\t\t * pointer comparison suffices\n\t\t\t */\n\t\t\tmodules = g_hash_table_new (NULL, NULL);\n\t\t}\n\n\t\tg_hash_table_insert (modules, (gpointer) info->module_path, module_info);\n\t}\n\n\tif (module_info && initialize &&\n\t !module_info->initialized) {\n\t\tif (module_info->init_func) {\n\t\t\tGError *error = NULL;\n\n\t\t\tif (!(module_info->init_func) (&module_info->thread_awareness, &error)) {\n\t\t\t\tg_critical (\"Could not initialize module %s: %s\",\n\t\t\t\t\t g_module_name (module_info->module),\n\t\t\t\t\t (error) ? error->message : \"No error given\");\n\n\t\t\t\tif (error) {\n\t\t\t\t\tg_error_free (error);\n\t\t\t\t}\n\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t} else {\n\t\t\tmodule_info->thread_awareness = TRACKER_MODULE_MAIN_THREAD;\n\t\t}\n\n\t\tmodule_info->initialized = TRUE;\n\t}\n\n\treturn module_info;\n}", "label": 0, "cwe": null, "length": 506 }, { "index": 689870, "code": "_down_cb(void *data,\n Evas *e __UNUSED__,\n Evas_Object *obj __UNUSED__,\n void *event_info)\n{\n Evas_Event_Mouse_Down *ev = event_info;\n Evas_Object *fl = data;\n Evas_Coord x, y, w, h;\n\n ELM_FLIP_DATA_GET(fl, sd);\n\n if (ev->button != 1) return;\n if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;\n if (sd->animator)\n {\n ecore_animator_del(sd->animator);\n sd->animator = NULL;\n }\n sd->down = EINA_TRUE;\n sd->started = EINA_FALSE;\n evas_object_geometry_get(data, &x, &y, &w, &h);\n sd->x = ev->canvas.x - x;\n sd->y = ev->canvas.y - y;\n sd->w = w;\n sd->h = h;\n sd->down_x = sd->x;\n sd->down_y = sd->y;\n}", "label": 0, "cwe": null, "length": 232 }, { "index": 415824, "code": "createBoard() const\n{\n\tChess::Board* board = Chess::BoardFactory::create(variant());\n\tif (board == 0)\n\t\treturn 0;\n\n\tbool ok = true;\n\n\tQString fen(startingFenString());\n\tif (!fen.isEmpty())\n\t\tok = board->setFenString(fen);\n\telse\n\t{\n\t\tboard->reset();\n\t\tok = !board->isRandomVariant();\n\t}\n\tif (!ok)\n\t{\n\t\tdelete board;\n\t\treturn 0;\n\t}\n\n\treturn board;\n}", "label": 0, "cwe": null, "length": 107 }, { "index": 458721, "code": "SetMWM_INFO(Window window)\n{\n\tstruct mwminfo\n\t{\n\t\tlong props[2];\n\t\t/* prop[0]: flags */\n\t\t/* prop[1]: win */\n\t} motif_wm_info;\n\tstatic char set_yorn='n';\n\n\tif (set_yorn=='y')\n\t{\n\t\treturn;\n\t}\n\n\tif (Scr.bo.is_modality_evil)\n\t{\n\t\t/* Set Motif WM_INFO atom to make motif relinquish\n\t\t * broken handling of modal dialogs */\n\t\tmotif_wm_info.props[0] = 2;\n\t\tmotif_wm_info.props[1] = window;\n\t\tXChangeProperty(\n\t\t\tdpy,Scr.Root, _XA_MOTIF_WM, _XA_MOTIF_WM,32,\n\t\t\tPropModeReplace, (unsigned char *)&motif_wm_info, 2);\n\t\tset_yorn='y';\n\t}\n\n\treturn;\n}", "label": 0, "cwe": null, "length": 194 }, { "index": 353578, "code": "sha512_context_endstream(struct SHA512_CONTEXT *c, SHA512_WORD l)\n{\n\tunsigned char buf[16];\n\tsize_t i;\n\tstatic const unsigned char zero[SHA512_BLOCK_SIZE-8];\n\n\tbuf[0]=0x80;\n\tsha512_context_hashstream(c, &buf, 1);\n\twhile (c->blk_ptr != SHA512_BLOCK_SIZE-16)\n\t{\n\t\tif (c->blk_ptr > SHA512_BLOCK_SIZE-16)\n\t\t{\n\t\t\tsha512_context_hashstream(c, zero,\n\t\t\t\tSHA512_BLOCK_SIZE - c->blk_ptr);\n\t\t\tcontinue;\n\t\t}\n\t\tsha512_context_hashstream(c, zero,\n\t\t\tSHA512_BLOCK_SIZE-16-c->blk_ptr);\n\t}\n\n\tl *= 8;\n\n\tfor (i=0; i<16; i++)\n\t{\n\t\tbuf[15-i]=l;\n\t\tl >>= 8;\n\t}\n\n\tsha512_context_hashstream(c, buf, sizeof(buf));\n}", "label": 0, "cwe": null, "length": 202 }, { "index": 806389, "code": "table_merge(tableobject *a, PyObject *b, int override)\n{\n /* Do it the generic, slower way */\n PyObject *keys = PyMapping_Keys(b);\n PyObject *iter;\n PyObject *key, *value, *skey, *svalue;\n int status;\n\n if (keys == NULL)\n return -1;\n\n iter = PyObject_GetIter(keys);\n Py_DECREF(keys);\n if (iter == NULL)\n return -1;\n \n for (key = PyIter_Next(iter); key; key = PyIter_Next(iter)) {\n\n skey = PyObject_Str(key);\n if (skey == NULL) {\n Py_DECREF(iter);\n Py_DECREF(key);\n return -1;\n }\n if (!override && apr_table_get(a->table, PyString_AsString(skey)) != NULL) {\n Py_DECREF(key);\n Py_DECREF(skey);\n continue;\n }\n\n value = PyObject_GetItem(b, key);\n if (value == NULL) {\n Py_DECREF(iter);\n Py_DECREF(key);\n Py_DECREF(skey);\n return -1;\n }\n svalue = PyObject_Str(value);\n if (svalue == NULL) {\n Py_DECREF(iter);\n Py_DECREF(key);\n Py_DECREF(skey);\n Py_DECREF(value);\n return -1;\n }\n status = table_ass_subscript(a, skey, svalue);\n Py_DECREF(key);\n Py_DECREF(value);\n Py_DECREF(skey);\n Py_DECREF(svalue);\n if (status < 0) {\n Py_DECREF(iter);\n return -1;\n }\n }\n Py_DECREF(iter);\n if (PyErr_Occurred())\n /* Iterator completed, via error */\n return -1;\n \n return 0;\n}", "label": 0, "cwe": null, "length": 375 }, { "index": 24113, "code": "api_cede (pTHX)\n{\n struct coro_transfer_args ta;\n\n prepare_cede (aTHX_ &ta);\n\n if (ecb_expect_true (ta.prev != ta.next))\n {\n TRANSFER (ta, 1);\n return 1;\n }\n else\n return 0;\n}", "label": 0, "cwe": null, "length": 71 }, { "index": 444867, "code": "SiS300SetupForSolidFill(struct sis_video_info *ivideo, u32 color, int rop)\n{\n\tSiS300SetupPATFG(color)\n\tSiS300SetupDSTRect(ivideo->video_linelength, 0xffff)\n\tSiS300SetupDSTColorDepth(ivideo->DstColor);\n\tSiS300SetupROP(sisPatALUConv[rop])\n\tSiS300SetupCMDFlag(PATFG)\n}", "label": 0, "cwe": null, "length": 93 }, { "index": 769035, "code": "_talloc_array(const void *ctx, size_t el_size, unsigned count, const char *name)\n{\n\tif (count >= MAX_TALLOC_SIZE/el_size) {\n\t\treturn NULL;\n\t}\n\treturn _talloc_named_const(ctx, el_size * count, name);\n}", "label": 0, "cwe": null, "length": 57 }, { "index": 77455, "code": "client_cbk_fetchspec (void *data)\n{\n gf_log (THIS->name, GF_LOG_WARNING,\n \"this function should not be called\");\n return 0;\n}", "label": 0, "cwe": null, "length": 39 }, { "index": 178177, "code": "lpfc_fdmi_port_attr_os_devname(struct lpfc_vport *vport,\n\t\t\t struct lpfc_fdmi_attr_def *ad)\n{\n\tstruct Scsi_Host *shost = lpfc_shost_from_vport(vport);\n\tstruct lpfc_fdmi_attr_entry *ae;\n\tuint32_t len, size;\n\n\tae = (struct lpfc_fdmi_attr_entry *)&ad->AttrValue;\n\tmemset(ae, 0, 256);\n\n\tsnprintf(ae->un.AttrString, sizeof(ae->un.AttrString),\n\t\t \"/sys/class/scsi_host/host%d\", shost->host_no);\n\tlen = strnlen((char *)ae->un.AttrString,\n\t\t\t sizeof(ae->un.AttrString));\n\tlen += (len & 3) ? (4 - (len & 3)) : 4;\n\tsize = FOURBYTES + len;\n\tad->AttrLen = cpu_to_be16(size);\n\tad->AttrType = cpu_to_be16(RPRT_OS_DEVICE_NAME);\n\treturn size;\n}", "label": 0, "cwe": null, "length": 213 }, { "index": 408842, "code": "tr_median3(const saidx_t *ISAd, saidx_t *v1, saidx_t *v2, saidx_t *v3) {\n saidx_t *t;\n if(ISAd[*v1] > ISAd[*v2]) { SWAP(v1, v2); }\n if(ISAd[*v2] > ISAd[*v3]) {\n if(ISAd[*v1] > ISAd[*v3]) { return v1; }\n else { return v3; }\n }\n return v2;\n}", "label": 0, "cwe": null, "length": 119 }, { "index": 749103, "code": "cp_suspend (struct pci_dev *pdev, pm_message_t state)\n{\n\tstruct net_device *dev = pci_get_drvdata(pdev);\n\tstruct cp_private *cp = netdev_priv(dev);\n\tunsigned long flags;\n\n\tif (!netif_running(dev))\n\t\treturn 0;\n\n\tnetif_device_detach (dev);\n\tnetif_stop_queue (dev);\n\n\tspin_lock_irqsave (&cp->lock, flags);\n\n\t/* Disable Rx and Tx */\n\tcpw16 (IntrMask, 0);\n\tcpw8 (Cmd, cpr8 (Cmd) & (~RxOn | ~TxOn));\n\n\tspin_unlock_irqrestore (&cp->lock, flags);\n\n\tpci_save_state(pdev);\n\tpci_enable_wake(pdev, pci_choose_state(pdev, state), cp->wol_enabled);\n\tpci_set_power_state(pdev, pci_choose_state(pdev, state));\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 175 }, { "index": 979122, "code": "is_equal(const ExecutionPath *e) const {\n const Nullpointer *c = static_cast(e);\n return (varname == c->varname && null == c->null);\n }", "label": 0, "cwe": null, "length": 45 }, { "index": 928806, "code": "handle_error_source(struct pcie_device *aerdev,\n\tstruct pci_dev *dev,\n\tstruct aer_err_info *info)\n{\n\tint pos;\n\n\tif (info->severity == AER_CORRECTABLE) {\n\t\t/*\n\t\t * Correctable error does not need software intervention.\n\t\t * No need to go through error recovery process.\n\t\t */\n\t\tpos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ERR);\n\t\tif (pos)\n\t\t\tpci_write_config_dword(dev, pos + PCI_ERR_COR_STATUS,\n\t\t\t\t\tinfo->status);\n\t} else\n\t\tdo_recovery(dev, info->severity);\n}", "label": 0, "cwe": null, "length": 125 }, { "index": 126325, "code": "OnButtonBrowseApplication(wxCommandEvent& event)\n{\n\twxString title;\n\tint id = 0;\n\tswitch ( event.GetId() ) {\n\t\tcase IDC_BROWSEV:\n\t\t\tid = IDC_VIDEOPLAYER;\n\t\t\ttitle = _(\"Browse for videoplayer\");\n\t\t\tbreak;\n\t\tcase IDC_SELBROWSER:\n\t\t\tid = IDC_BROWSERSELF;\n\t\t\ttitle = _(\"Select browser\");\n\t\t\tbreak;\n// ADUNANZA BEGIN\t\t\t\n\t\tcase IDC_ADU_SELIRCPROGRAM:\n\t\t\tid = IDC_ADU_IRCPROGRAM;\n\t\t\ttitle = _(\"Select IRC program\");\n\t\t\tbreak;\n// ADUNANZA END\t\t\t\n\t\tdefault:\n\t\t\twxFAIL;\n\t\t\treturn;\n\t}\n\twxString wildcard = CFormat(_(\"Executable%s\"))\n#ifdef __WXMSW__\n\t\t% wxT(\" (*.exe)|*.exe\");\n#else\n\t\t% wxT(\"|*\");\n#endif\n\n\twxString str = wxFileSelector( title, wxEmptyString, wxEmptyString,\n\t\twxEmptyString, wildcard, 0, this );\n\n\tif ( !str.IsEmpty() ) {\n\t\twxTextCtrl* widget = CastChild( id, wxTextCtrl );\n\t\twidget->SetValue( str );\n\t}\n}", "label": 0, "cwe": null, "length": 241 }, { "index": 958345, "code": "gfs2_blk2rgrpd(struct gfs2_sbd *sdp, u64 blk, bool exact)\n{\n\tstruct rb_node *n, *next;\n\tstruct gfs2_rgrpd *cur;\n\n\tspin_lock(&sdp->sd_rindex_spin);\n\tn = sdp->sd_rindex_tree.rb_node;\n\twhile (n) {\n\t\tcur = rb_entry(n, struct gfs2_rgrpd, rd_node);\n\t\tnext = NULL;\n\t\tif (blk < cur->rd_addr)\n\t\t\tnext = n->rb_left;\n\t\telse if (blk >= cur->rd_data0 + cur->rd_data)\n\t\t\tnext = n->rb_right;\n\t\tif (next == NULL) {\n\t\t\tspin_unlock(&sdp->sd_rindex_spin);\n\t\t\tif (exact) {\n\t\t\t\tif (blk < cur->rd_addr)\n\t\t\t\t\treturn NULL;\n\t\t\t\tif (blk >= cur->rd_data0 + cur->rd_data)\n\t\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\treturn cur;\n\t\t}\n\t\tn = next;\n\t}\n\tspin_unlock(&sdp->sd_rindex_spin);\n\n\treturn NULL;\n}", "label": 0, "cwe": null, "length": 232 }, { "index": 716995, "code": "detect_text_lines(pix * pp, int mo) {\n\n if (JOB->cfg.verbose)\n fprintf(stderr, \"# detect.c detect_text_lines (vvv=16 for more info)\\n\");\n if (mo & 4){\n if (JOB->cfg.verbose) fprintf(stderr, \"# zoning\\n# ... \");\n detect_lines2(pp, 0, 0, pp->x, pp->y, 0);\t// later replaced by better algo\n } else \n detect_lines1(pp, 0, 0, pp->x, pp->y);\t// old algo\n\n if(JOB->cfg.verbose) fprintf(stderr,\"\\n\");\n return 0;\n}", "label": 0, "cwe": null, "length": 146 }, { "index": 90854, "code": "wr_struct(FILE *outfile, chainp var_list)\n#endif\n{\n int last_type = -1;\n int did_one = 0;\n chainp this_var;\n\n for (this_var = var_list; this_var; this_var = this_var -> nextp) {\n\tNamep var = (Namep) this_var -> datap;\n\tint type;\n\tchar *comment = NULL;\n\n\tif (var == (Namep) NULL)\n\t err (\"wr_struct: null variable\");\n\telse if (var -> tag != TNAME)\n\t erri (\"wr_struct: bad tag on variable '%d'\",\n\t\t var -> tag);\n\n\ttype = var -> vtype;\n\n\tif (last_type == type && did_one)\n\t nice_printf (outfile, \", \");\n\telse {\n\t if (did_one)\n\t\tnice_printf (outfile, \";\\n\");\n\t nice_printf (outfile, \"%s \",\n\t\t c_type_decl (type, var -> vclass == CLPROC));\n\t} /* else */\n\n/* Character type is really a string type. Put out a '*' for parameters\n with unknown length and functions returning character */\n\n\tif (var -> vtype == TYCHAR && (!ISICON ((var -> vleng))\n\t\t|| var -> vclass == CLPROC))\n\t nice_printf (outfile, \"*\");\n\n\tvar -> vstg = STGAUTO;\n\tout_name (outfile, var);\n\tif (var -> vclass == CLPROC)\n\t nice_printf (outfile, \"()\");\n\telse if (var -> vdim)\n\t comment = wr_ardecls(outfile, var->vdim,\n\t\t\t\tvar->vtype == TYCHAR && ISICON(var->vleng)\n\t\t\t\t? var->vleng->constblock.Const.ci : 1L);\n\telse if (var -> vtype == TYCHAR && var -> vclass != CLPROC &&\n\t ISICON ((var -> vleng)))\n\t nice_printf (outfile, \"[%ld]\",\n\t\t var -> vleng -> constblock.Const.ci);\n\n\tif (comment)\n\t nice_printf (outfile, \"%s\", comment);\n\tdid_one = 1;\n\tlast_type = type;\n } /* for this_var */\n\n if (did_one)\n\tnice_printf (outfile, \";\\n\");\n}", "label": 1, "cwe": "CWE-476", "length": 459 }, { "index": 787747, "code": "ath10k_wmi_op_gen_pdev_suspend(struct ath10k *ar, u32 suspend_opt)\n{\n\tstruct wmi_pdev_suspend_cmd *cmd;\n\tstruct sk_buff *skb;\n\n\tskb = ath10k_wmi_alloc_skb(ar, sizeof(*cmd));\n\tif (!skb)\n\t\treturn ERR_PTR(-ENOMEM);\n\n\tcmd = (struct wmi_pdev_suspend_cmd *)skb->data;\n\tcmd->suspend_opt = __cpu_to_le32(suspend_opt);\n\n\treturn skb;\n}", "label": 0, "cwe": null, "length": 100 }, { "index": 686547, "code": "GGadgetIsEnabled(GGadget *g) {\n if ( g->state==gs_invisible )\nreturn( !g->was_disabled );\nreturn( g->state==gs_enabled );\n}", "label": 0, "cwe": null, "length": 41 }, { "index": 585924, "code": "_sort_by_groups(void *void1, void *void2)\n{\n\tint diff;\n\tsinfo_data_t *sinfo1 = (sinfo_data_t *) void1;\n\tsinfo_data_t *sinfo2 = (sinfo_data_t *) void2;\n\tchar *val1 = \"\", *val2 = \"\";\n\n\tif (sinfo1->part_info && sinfo1->part_info->allow_groups)\n\t\tval1 = sinfo1->part_info->allow_groups;\n\tif (sinfo2->part_info && sinfo2->part_info->allow_groups)\n\t\tval2 = sinfo2->part_info->allow_groups;\n\tdiff = strcmp(val1, val2);\n\n\tif (reverse_order)\n\t\tdiff = -diff;\n\treturn diff;\n}", "label": 0, "cwe": null, "length": 155 }, { "index": 127002, "code": "component_added_handler (gpointer p)\n{\n\tCallbackPara *para = (CallbackPara*)p;\n\tjobject global_ac = para->global_ac;\n\n\tJNIEnv *jniEnv = jaw_util_get_jni_env();\n\tJawImpl* jaw_impl = jaw_impl_get_instance(jniEnv, global_ac);\n\t\n\tAtkObject* atk_obj = ATK_OBJECT(jaw_impl);\n\tif (atk_object_get_role(atk_obj) == ATK_ROLE_TOOL_TIP) {\n\t\tatk_object_notify_state_change(atk_obj, ATK_STATE_SHOWING, 1);\n\t}\n\n\tfree_callback_para(para);\n\n\treturn FALSE;\n}", "label": 0, "cwe": null, "length": 127 }, { "index": 233702, "code": "list_iter_after_tail(list_t *list)\n{\n\tlist_iter_t *iter;\n\n\tif (list) {\n\t\tlist_check(list);\n\n\t\tWALLOC(iter);\n\t\titer->magic = LIST_ITER_MAGIC;\n\t\titer->list = list;\n\n\t\titer->next = NULL;\n\t\titer->prev = list->tail;\n\t\titer->data = NULL;\n\n\t\titer->stamp = list->stamp;\n\t\tlist->refcount++;\n\t} else {\n\t\titer = NULL;\n\t}\n\n\treturn iter;\n}", "label": 0, "cwe": null, "length": 101 }, { "index": 82320, "code": "write_hdr(Agraph_t * g, iochan_t * ofile, int top)\n{\n char *name, *sep, *kind, *strict;\n int root = 0;\n\n Attrs_not_written_flag = AGATTRWF(g);\n strict = \"\";\n if (NOT(top) && agparent(g))\n\tkind = \"sub\";\n else {\n\troot = 1;\n\tif (g->desc.directed)\n\t kind = \"di\";\n\telse\n\t kind = \"\";\n\tif (agisstrict(g))\n\t strict = \"strict \";\n\tTailport = agattr(g, AGEDGE, TAILPORT_ID, NIL(char *));\n\tHeadport = agattr(g, AGEDGE, HEADPORT_ID, NIL(char *));\n }\n name = agnameof(g);\n sep = \" \";\n if (!name || name[0] == LOCALNAMEPREFIX)\n\tsep = name = \"\";\n CHKRV(indent(g, ofile));\n CHKRV(ioput(g, ofile, strict));\n\n /* output \"graph\" only for root graphs or graphs with names */\n if (*name || root) {\n\tCHKRV(ioput(g, ofile, kind));\n\tCHKRV(ioput(g, ofile, \"graph \"));\n }\n if (name[0])\n\tCHKRV(write_canonstr(g, ofile, name));\n CHKRV(ioput(g, ofile, sep));\n CHKRV(ioput(g, ofile, \"{\\n\"));\n Level++;\n CHKRV(write_dicts(g, ofile, top));\n AGATTRWF(g) = TRUE;\n return 0;\n}", "label": 0, "cwe": null, "length": 342 }, { "index": 792017, "code": "posix_timers_register_clock(const clockid_t clock_id,\n\t\t\t\t struct k_clock *new_clock)\n{\n\tif ((unsigned) clock_id >= MAX_CLOCKS) {\n\t\tprintk(KERN_WARNING \"POSIX clock register failed for clock_id %d\\n\",\n\t\t clock_id);\n\t\treturn;\n\t}\n\n\tif (!new_clock->clock_get) {\n\t\tprintk(KERN_WARNING \"POSIX clock id %d lacks clock_get()\\n\",\n\t\t clock_id);\n\t\treturn;\n\t}\n\tif (!new_clock->clock_getres) {\n\t\tprintk(KERN_WARNING \"POSIX clock id %d lacks clock_getres()\\n\",\n\t\t clock_id);\n\t\treturn;\n\t}\n\n\tposix_clocks[clock_id] = *new_clock;\n}", "label": 0, "cwe": null, "length": 146 }, { "index": 66248, "code": "ftp_recv_response_ignore_message(struct stream_t *stream)\n{\n struct ftp_response_t *ftp_response;\n int status_code;\n\n ftp_response = new_ftp_response_t();\n status_code = ftp_recv_response(stream,ftp_response);\n if(!is_ftp_OK(status_code) && ftp_response->lines) {\n\tdisplay(MSDL_ERR,\"%s\",ftp_response->lines->p);\n }\n free_ftp_response_t(ftp_response);\n \n return status_code;\n}", "label": 0, "cwe": null, "length": 100 }, { "index": 73431, "code": "boxaDestroy(BOXA **pboxa)\n{\nl_int32 i;\nBOXA *boxa;\n\n PROCNAME(\"boxaDestroy\");\n\n if (pboxa == NULL) {\n L_WARNING(\"ptr address is null!\", procName);\n return;\n }\n\n if ((boxa = *pboxa) == NULL)\n return;\n\n /* Decrement the ref count. If it is 0, destroy the boxa. */\n boxa->refcount--;\n if (boxa->refcount <= 0) {\n for (i = 0; i < boxa->n; i++)\n boxDestroy(&boxa->box[i]);\n FREE(boxa->box);\n FREE(boxa);\n }\n\n *pboxa = NULL;\n return;\n}", "label": 0, "cwe": null, "length": 173 }, { "index": 152202, "code": "fl_subimage_offsets(int a, int aw, int b, int bw, int &obw)\n{\n int off;\n int ob;\n\n if (b >= a) {\n ob = b;\n off = 0;\n } else {\n ob = a;\n off = a - b;\n }\n\n bw -= off;\n\n if (ob + bw <= a + aw) {\n obw = bw;\n } else {\n obw = (a + aw) - ob;\n }\n\n return off;\n}", "label": 0, "cwe": null, "length": 114 }, { "index": 760580, "code": "FunctionDone() {\n HandleScope scope;\n FunctionInfoWrapper info =\n FunctionInfoWrapper::cast(\n result_->GetElementNoExceptionThrown(current_parent_index_));\n current_parent_index_ = info.GetParentIndex();\n }", "label": 0, "cwe": null, "length": 48 }, { "index": 830483, "code": "adf_enable_error_correction(struct adf_accel_dev *accel_dev)\n{\n\tstruct adf_hw_device_data *hw_device = accel_dev->hw_device;\n\tstruct adf_bar *misc_bar = &GET_BARS(accel_dev)[ADF_DH895XCC_PMISC_BAR];\n\tvoid __iomem *csr = misc_bar->virt_addr;\n\tunsigned int val, i;\n\n\t/* Enable Accel Engine error detection & correction */\n\tfor (i = 0; i < hw_device->get_num_aes(hw_device); i++) {\n\t\tval = ADF_CSR_RD(csr, ADF_DH895XCC_AE_CTX_ENABLES(i));\n\t\tval |= ADF_DH895XCC_ENABLE_AE_ECC_ERR;\n\t\tADF_CSR_WR(csr, ADF_DH895XCC_AE_CTX_ENABLES(i), val);\n\t\tval = ADF_CSR_RD(csr, ADF_DH895XCC_AE_MISC_CONTROL(i));\n\t\tval |= ADF_DH895XCC_ENABLE_AE_ECC_PARITY_CORR;\n\t\tADF_CSR_WR(csr, ADF_DH895XCC_AE_MISC_CONTROL(i), val);\n\t}\n\n\t/* Enable shared memory error detection & correction */\n\tfor (i = 0; i < hw_device->get_num_accels(hw_device); i++) {\n\t\tval = ADF_CSR_RD(csr, ADF_DH895XCC_UERRSSMSH(i));\n\t\tval |= ADF_DH895XCC_ERRSSMSH_EN;\n\t\tADF_CSR_WR(csr, ADF_DH895XCC_UERRSSMSH(i), val);\n\t\tval = ADF_CSR_RD(csr, ADF_DH895XCC_CERRSSMSH(i));\n\t\tval |= ADF_DH895XCC_ERRSSMSH_EN;\n\t\tADF_CSR_WR(csr, ADF_DH895XCC_CERRSSMSH(i), val);\n\t}\n}", "label": 0, "cwe": null, "length": 391 }, { "index": 578728, "code": "jas_matrix_asl(jas_matrix_t *matrix, int n)\n{\n\tint i;\n\tint j;\n\tjas_seqent_t *rowstart;\n\tint rowstep;\n\tjas_seqent_t *data;\n\n\trowstep = jas_matrix_rowstep(matrix);\n\tfor (i = matrix->numrows_, rowstart = matrix->rows_[0]; i > 0; --i,\n\t rowstart += rowstep) {\n\t\tfor (j = matrix->numcols_, data = rowstart; j > 0; --j,\n\t\t ++data) {\n\t\t\t*data <<= n;\n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 127 }, { "index": 983925, "code": "phone_feat_id(const cst_phoneset *ps,const char* featname)\n{\n int i;\n\n for (i=0; ps->featnames[i]; i++)\n\tif (cst_streq(ps->featnames[i],featname))\n\t return i;\n\n /* Wonder if I should print an error here or not */\n return 0;\n}", "label": 0, "cwe": null, "length": 75 }, { "index": 766762, "code": "register_tracepoint_module_notifier(struct notifier_block *nb)\n{\n\tstruct tp_module *tp_mod;\n\tint ret;\n\n\tmutex_lock(&tracepoint_module_list_mutex);\n\tret = blocking_notifier_chain_register(&tracepoint_notify_list, nb);\n\tif (ret)\n\t\tgoto end;\n\tlist_for_each_entry(tp_mod, &tracepoint_module_list, list)\n\t\t(void) nb->notifier_call(nb, MODULE_STATE_COMING, tp_mod);\nend:\n\tmutex_unlock(&tracepoint_module_list_mutex);\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 923605, "code": "node_from_call (RestProxyCall *call, GError **error)\n{\n static RestXmlParser *parser = NULL;\n RestXmlNode *node;\n\n if (call == NULL)\n return NULL;\n\n if (parser == NULL)\n parser = rest_xml_parser_new ();\n\n if (!SOUP_STATUS_IS_SUCCESSFUL (rest_proxy_call_get_status_code (call))) {\n g_set_error (error, SW_SERVICE_ERROR, SW_SERVICE_ERROR_REMOTE_ERROR,\n \"HTTP error: %s (%d)\",\n rest_proxy_call_get_status_message (call),\n rest_proxy_call_get_status_code (call));\n return NULL;\n }\n\n node = rest_xml_parser_parse_from_data (parser,\n rest_proxy_call_get_payload (call),\n rest_proxy_call_get_payload_length (call));\n\n /* Invalid XML, or incorrect root */\n if (node == NULL || !g_str_equal (node->name, \"rsp\")) {\n g_set_error (error, SW_SERVICE_ERROR, SW_SERVICE_ERROR_REMOTE_ERROR,\n \"malformed remote response: %s\",\n rest_proxy_call_get_payload (call));\n if (node)\n rest_xml_node_unref (node);\n return NULL;\n }\n\n if (g_strcmp0 (rest_xml_node_get_attr (node, \"stat\"), \"ok\") != 0) {\n RestXmlNode *err;\n err = rest_xml_node_find (node, \"err\");\n g_set_error (error, SW_SERVICE_ERROR, SW_SERVICE_ERROR_REMOTE_ERROR,\n \"remote SmugMug error: %s\", err ?\n rest_xml_node_get_attr (err, \"msg\") : \"unknown\");\n rest_xml_node_unref (node);\n return NULL;\n }\n\n return node;\n}", "label": 0, "cwe": null, "length": 358 }, { "index": 885321, "code": "irafgetc (irafheader, offset, nc)\n\nchar\t*irafheader;\t/* IRAF image header */\nint\toffset;\t\t/* Number of bytes to skip before string */\nint\tnc;\t\t/* Maximum number of characters in string */\n\n{\n char *ctemp, *cheader;\n int i;\n\n cheader = irafheader;\n ctemp = (char *) calloc (nc+1, 1);\n if (ctemp == NULL) {\n\t(void)fprintf(stderr, \"IRAFGETC Cannot allocate %d-byte variable\\n\",\n\t\tnc+1);\n\treturn (NULL);\n\t}\n for (i = 0; i < nc; i++) {\n\tctemp[i] = cheader[offset+i];\n\tif (ctemp[i] > 0 && ctemp[i] < 32)\n\t ctemp[i] = ' ';\n\t}\n\n return (ctemp);\n}", "label": 0, "cwe": null, "length": 194 }, { "index": 59193, "code": "jc42_remove(struct i2c_client *client)\n{\n\tstruct jc42_data *data = i2c_get_clientdata(client);\n\n\t/* Restore original configuration except hysteresis */\n\tif ((data->config & ~JC42_CFG_HYST_MASK) !=\n\t (data->orig_config & ~JC42_CFG_HYST_MASK)) {\n\t\tint config;\n\n\t\tconfig = (data->orig_config & ~JC42_CFG_HYST_MASK)\n\t\t | (data->config & JC42_CFG_HYST_MASK);\n\t\ti2c_smbus_write_word_swapped(client, JC42_REG_CONFIG, config);\n\t}\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 132 }, { "index": 39089, "code": "e_fm2_uri_path_list_get(const Eina_List *uri_list)\n{\n E_Fm2_Uri *uri;\n const Eina_List *l;\n Eina_List *path_list = NULL;\n char current_hostname[_POSIX_HOST_NAME_MAX];\n const char *uri_str;\n\n if (gethostname(current_hostname, _POSIX_HOST_NAME_MAX) == -1)\n current_hostname[0] = '\\0';\n\n EINA_LIST_FOREACH(uri_list, l, uri_str)\n {\n if (!(uri = _e_fm2_uri_parse(uri_str)))\n continue;\n\n if (!uri->hostname || !strcmp(uri->hostname, \"localhost\")\n || !strcmp(uri->hostname, current_hostname))\n {\n path_list = eina_list_append(path_list, uri->path);\n }\n else\n eina_stringshare_del(uri->path);\n\n eina_stringshare_del(uri->hostname);\n E_FREE(uri);\n }\n\n return path_list;\n}", "label": 0, "cwe": null, "length": 205 }, { "index": 979692, "code": "jinit_merged_upsampler (oe_j_decompress_ptr cinfo)\n{\n my_upsample_ptr upsample;\n\n upsample = (my_upsample_ptr)\n (*cinfo->mem->alloc_small) ((oe_j_common_ptr) cinfo, OE_JPOOL_IMAGE,\n\t\t\t\tSIZEOF(my_upsampler));\n cinfo->upsample = (struct openexif_jpeg_upsampler *) upsample;\n upsample->pub.start_pass = start_pass_merged_upsample;\n upsample->pub.need_context_rows = FALSE;\n\n upsample->out_row_width = cinfo->output_width * cinfo->out_color_components;\n\n if (cinfo->max_v_samp_factor == 2) {\n upsample->pub.upsample = merged_2v_upsample;\n upsample->upmethod = h2v2_merged_upsample;\n /* Allocate a spare row buffer */\n upsample->spare_row = (OE_JSAMPROW)\n (*cinfo->mem->alloc_large) ((oe_j_common_ptr) cinfo, OE_JPOOL_IMAGE,\n\t\t(size_t) (upsample->out_row_width * SIZEOF(OE_JSAMPLE)));\n } else {\n upsample->pub.upsample = merged_1v_upsample;\n upsample->upmethod = h2v1_merged_upsample;\n /* No spare row needed */\n upsample->spare_row = NULL;\n }\n\n build_ycc_rgb_table(cinfo);\n}", "label": 0, "cwe": null, "length": 314 }, { "index": 967278, "code": "do_one_cpu(unsigned int cpu, struct cpufreq_policy *new_pol,\n\t\tunsigned long freq, unsigned int pc)\n{\n\tswitch (pc) {\n\tcase 0:\n\t\treturn cpufreq_set_frequency(cpu, freq);\n\n\tcase 1:\n\t\t/* if only one value of a policy is to be changed, we can\n\t\t * use a \"fast path\".\n\t\t */\n\t\tif (new_pol->min)\n\t\t\treturn cpufreq_modify_policy_min(cpu, new_pol->min);\n\t\telse if (new_pol->max)\n\t\t\treturn cpufreq_modify_policy_max(cpu, new_pol->max);\n\t\telse if (new_pol->governor)\n\t\t\treturn cpufreq_modify_policy_governor(cpu, new_pol->governor);\n\n\tdefault:\n\t\t/* slow path */\n\t\treturn do_new_policy(cpu, new_pol);\n\t}\n}", "label": 0, "cwe": null, "length": 172 }, { "index": 365762, "code": "get(input_ty *p)\n{\n input_file_ty *this;\n int c;\n\n this = (input_file_ty *)p;\n c = getc(this->fp);\n if (c == EOF)\n {\n if (ferror(this->fp))\n fatal_intl_read(this->fn->str_text);\n return INPUT_EOF;\n }\n return c;\n}", "label": 1, "cwe": [ "CWE-120", "CWE-other" ], "length": 82 }, { "index": 1014631, "code": "mime_entity_remove_part(MIMEEntity *e, int i)\n{\n MIMEEntity *m;\n\n gw_assert(e != NULL);\n gw_assert(i >= 0);\n gw_assert(i < gwlist_len(e->multiparts));\n \n \n m = gwlist_get(e->multiparts, i);\n gwlist_delete(e->multiparts, i, 1);\n if (m == e->start) e->start = NULL;\n\n mime_entity_destroy(m);\n}", "label": 1, "cwe": "CWE-476", "length": 100 }, { "index": 114702, "code": "vivid_thread_sdr_cap_tick(struct vivid_dev *dev)\n{\n\tstruct vivid_buffer *sdr_cap_buf = NULL;\n\n\tdprintk(dev, 1, \"SDR Capture Thread Tick\\n\");\n\n\t/* Drop a certain percentage of buffers. */\n\tif (dev->perc_dropped_buffers &&\n\t prandom_u32_max(100) < dev->perc_dropped_buffers)\n\t\treturn;\n\n\tspin_lock(&dev->slock);\n\tif (!list_empty(&dev->sdr_cap_active)) {\n\t\tsdr_cap_buf = list_entry(dev->sdr_cap_active.next,\n\t\t\t\t\t struct vivid_buffer, list);\n\t\tlist_del(&sdr_cap_buf->list);\n\t}\n\tspin_unlock(&dev->slock);\n\n\tif (sdr_cap_buf) {\n\t\tsdr_cap_buf->vb.sequence = dev->sdr_cap_seq_count;\n\t\tvivid_sdr_cap_process(dev, sdr_cap_buf);\n\t\tv4l2_get_timestamp(&sdr_cap_buf->vb.timestamp);\n\t\tsdr_cap_buf->vb.timestamp.tv_sec += dev->time_wrap_offset;\n\t\tvb2_buffer_done(&sdr_cap_buf->vb.vb2_buf, dev->dqbuf_error ?\n\t\t\t\tVB2_BUF_STATE_ERROR : VB2_BUF_STATE_DONE);\n\t\tdev->dqbuf_error = false;\n\t}\n}", "label": 0, "cwe": null, "length": 268 }, { "index": 53921, "code": "cbc_aes_decrypt(struct blkcipher_desc *desc,\n\t\t\t struct scatterlist *dst, struct scatterlist *src,\n\t\t\t unsigned int nbytes)\n{\n\tstruct aes_ctx *ctx = blk_aes_ctx(desc->tfm);\n\tstruct blkcipher_walk walk;\n\tint err;\n\tint ts_state;\n\n\tpadlock_reset_key(&ctx->cword.encrypt);\n\n\tblkcipher_walk_init(&walk, dst, src, nbytes);\n\terr = blkcipher_walk_virt(desc, &walk);\n\n\tts_state = irq_ts_save();\n\twhile ((nbytes = walk.nbytes)) {\n\t\tpadlock_xcrypt_cbc(walk.src.virt.addr, walk.dst.virt.addr,\n\t\t\t\t ctx->D, walk.iv, &ctx->cword.decrypt,\n\t\t\t\t nbytes / AES_BLOCK_SIZE);\n\t\tnbytes &= AES_BLOCK_SIZE - 1;\n\t\terr = blkcipher_walk_done(desc, &walk, nbytes);\n\t}\n\n\tirq_ts_restore(ts_state);\n\n\tpadlock_store_cword(&ctx->cword.encrypt);\n\n\treturn err;\n}", "label": 0, "cwe": null, "length": 210 }, { "index": 307180, "code": "ddf_MatrixCanonicalize(ddf_MatrixPtr *M, ddf_rowset *impl_linset, ddf_rowset *redset, \nddf_rowindex *newpos, ddf_ErrorType *error) /* 094 */\n{\n/* This is to find a canonical representation of a matrix *M by \n recognizing all implicit linearities and all redundancies. \n All implicit linearities will be returned by *impl_linset and\n redundancies will be returned by *redset.\n*/\n ddf_rowrange i,k,m;\n ddf_rowindex newpos1,revpos;\n ddf_rowset redset1;\n ddf_boolean success=ddf_TRUE;\n \n m=(*M)->rowsize;\n set_initialize(redset, m);\n revpos=(long *)calloc(m+1,sizeof(long));\n \n success=ddf_MatrixCanonicalizeLinearity(M, impl_linset, newpos, error);\n\n if (!success) goto _L99; \n \n for (i=1; i<=m; i++){\n k=(*newpos)[i];\n if (k>0) revpos[k]=i; /* inverse of *newpos[] */\n }\n \n success=ddf_MatrixRedundancyRemove(M, &redset1, &newpos1, error); /* 094 */\n \n if (!success) goto _L99;\n\n for (i=1; i<=m; i++){\n k=(*newpos)[i];\n if (k>0) {\n (*newpos)[i]=newpos1[k];\n if (newpos1[k]<0) (*newpos)[i]=-revpos[-newpos1[k]]; /* update the certificate of its duplicate removal. */\n if (set_member(k,redset1)) set_addelem(*redset, i);\n }\n }\n\n_L99:\n set_free(redset1);\n free(newpos1);\n free(revpos);\n return success;\n}", "label": 0, "cwe": null, "length": 420 }, { "index": 421938, "code": "initLocaleFromName(const UnicodeString& id, Locale& result)\n{\n enum { BUFLEN = 128 }; // larger than ever needed\n\n if (id.isBogus() || id.length() >= BUFLEN) {\n result.setToBogus();\n } else {\n /*\n * We need to convert from a UnicodeString to char * in order to\n * create a Locale.\n *\n * Problem: Locale ID strings may contain '@' which is a variant\n * character and cannot be handled by invariant-character conversion.\n *\n * Hack: Since ICU code can handle locale IDs with multiple encodings\n * of '@' (at least for EBCDIC; it's not known to be a problem for\n * ASCII-based systems),\n * we use regular invariant-character conversion for everything else\n * and manually convert U+0040 into a compiler-char-constant '@'.\n * While this compilation-time constant may not match the runtime\n * encoding of '@', it should be one of the encodings which ICU\n * recognizes.\n *\n * There should be only at most one '@' in a locale ID.\n */\n char buffer[BUFLEN];\n int32_t prev, i;\n prev = 0;\n for(;;) {\n i = id.indexOf((UChar)0x40, prev);\n if(i < 0) {\n // no @ between prev and the rest of the string\n id.extract(prev, INT32_MAX, buffer + prev, BUFLEN - prev, US_INV);\n break; // done\n } else {\n // normal invariant-character conversion for text between @s\n id.extract(prev, i - prev, buffer + prev, BUFLEN - prev, US_INV);\n // manually \"convert\" U+0040 at id[i] into '@' at buffer[i]\n buffer[i] = '@';\n prev = i + 1;\n }\n }\n result = Locale::createFromName(buffer);\n }\n return result;\n}", "label": 0, "cwe": null, "length": 428 }, { "index": 409271, "code": "_sx_raw_write(sx_t s, char *buf, int len) {\n /* siltently drop it if we're closing or closed */\n if(s->state >= state_CLOSING) {\n log_debug(ZONE, \"stream closed, dropping outgoing raw data\");\n return 1;\n }\n\n _sx_debug(ZONE, \"queuing for write: %.*s\", len, buf);\n\n /* ready to go */\n jqueue_push(s->wbufq, _sx_buffer_new(buf, len, NULL, NULL), 0);\n\n /* things to write */\n s->want_write = 1;\n\n return 0;\n}", "label": 0, "cwe": null, "length": 139 }, { "index": 629247, "code": "usnic_transport_sock_to_str(char *buf, int buf_sz,\n\t\t\t\t\tstruct socket *sock)\n{\n\tint err;\n\tuint32_t addr;\n\tuint16_t port;\n\tint proto;\n\n\tmemset(buf, 0, buf_sz);\n\terr = usnic_transport_sock_get_addr(sock, &proto, &addr, &port);\n\tif (err)\n\t\treturn 0;\n\n\treturn scnprintf(buf, buf_sz, \"Proto:%u Addr:%pI4h Port:%hu\",\n\t\t\tproto, &addr, port);\n}", "label": 0, "cwe": null, "length": 107 }, { "index": 405338, "code": "list_pollers(FILE *out)\n{\n\tint p;\n\tint last, next;\n\tint usable;\n\tstruct poller *bp;\n\n\tfprintf(out, \"Available polling systems :\\n\");\n\n\tusable = 0;\n\tbp = NULL;\n\tlast = next = -1;\n\twhile (1) {\n\t\tfor (p = 0; p < nbpollers; p++) {\n\t\t\tif ((next < 0 || pollers[p].pref > next)\n\t\t\t && (last < 0 || pollers[p].pref < last)) {\n\t\t\t\tnext = pollers[p].pref;\n\t\t\t\tif (!bp || (pollers[p].pref > bp->pref))\n\t\t\t\t\tbp = &pollers[p];\n\t\t\t}\n\t\t}\n\n\t\tif (next == -1)\n\t\t\tbreak;\n\n\t\tfor (p = 0; p < nbpollers; p++) {\n\t\t\tif (pollers[p].pref == next) {\n\t\t\t\tfprintf(out, \" %10s : \", pollers[p].name);\n\t\t\t\tif (pollers[p].pref == 0)\n\t\t\t\t\tfprintf(out, \"disabled, \");\n\t\t\t\telse\n\t\t\t\t\tfprintf(out, \"pref=%3d, \", pollers[p].pref);\n\t\t\t\tif (pollers[p].test(&pollers[p])) {\n\t\t\t\t\tfprintf(out, \" test result OK\");\n\t\t\t\t\tif (next > 0)\n\t\t\t\t\t\tusable++;\n\t\t\t\t} else {\n\t\t\t\t\tfprintf(out, \" test result FAILED\");\n\t\t\t\t\tif (bp == &pollers[p])\n\t\t\t\t\t\tbp = NULL;\n\t\t\t\t}\n\t\t\t\tfprintf(out, \"\\n\");\n\t\t\t}\n\t\t}\n\t\tlast = next;\n\t\tnext = -1;\n\t};\n\tfprintf(out, \"Total: %d (%d usable), will use %s.\\n\", nbpollers, usable, bp ? bp->name : \"none\");\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 378 }, { "index": 762920, "code": "atk_value_get_minimum_value (AtkValue *obj,\n GValue *value)\n{\n AtkValueIface *iface;\n\n g_return_if_fail (value != NULL);\n g_return_if_fail (ATK_IS_VALUE (obj));\n\n iface = ATK_VALUE_GET_IFACE (obj);\n\n if (iface->get_minimum_value)\n {\n if (G_IS_VALUE (value))\n g_value_unset (value);\n else\n memset (value, 0, sizeof (*value));\n\n (iface->get_minimum_value) (obj, value);\n }\n}", "label": 0, "cwe": null, "length": 122 }, { "index": 15126, "code": "nfs4_xdr_dec_destroy_clientid(struct rpc_rqst *rqstp,\n\t\t\t\t\tstruct xdr_stream *xdr,\n\t\t\t\t\tvoid *res)\n{\n\tstruct compound_hdr hdr;\n\tint status;\n\n\tstatus = decode_compound_hdr(xdr, &hdr);\n\tif (!status)\n\t\tstatus = decode_destroy_clientid(xdr, res);\n\treturn status;\n}", "label": 0, "cwe": null, "length": 73 }, { "index": 46854, "code": "config_set_onoff(const char *attrname, char *value, int *configvalue, char *errorbuf, int apply)\n{\n int retVal = LDAP_SUCCESS;\n slapi_onoff_t newval = -1;\n#ifndef ATOMIC_GETSET_ONOFF\n slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();\n#endif \n \n if ( config_value_is_null( attrname, value, errorbuf, 1 )) {\n return LDAP_OPERATIONS_ERROR;\n }\n \n CFG_ONOFF_LOCK_WRITE(slapdFrontendConfig);\n if (strcasecmp(value, \"on\") && strcasecmp(value, \"off\")) {\n PR_snprintf ( errorbuf, SLAPI_DSE_RETURNTEXT_SIZE,\n \"%s: invalid value \\\"%s\\\". Valid values are \\\"on\\\" or \\\"off\\\".\",\n attrname, value );\n retVal = LDAP_OPERATIONS_ERROR;\n }\n \n if ( !apply ) {\n /* we can return now if we aren't applying the changes */\n return retVal;\n }\n \n if ( strcasecmp ( value, \"on\" ) == 0 ) {\n newval = LDAP_ON;\n } else if ( strcasecmp ( value, \"off\" ) == 0 ) {\n newval = LDAP_OFF;\n }\n \n#ifdef ATOMIC_GETSET_ONOFF\n PR_AtomicSet(configvalue, newval);\n#else\n *configvalue = newval;\n#endif\n CFG_ONOFF_UNLOCK_WRITE(slapdFrontendConfig); \n\n return retVal;\n}", "label": 0, "cwe": null, "length": 324 }, { "index": 573059, "code": "Names(const std::vector& names) {\n if(!valid_) return;\n XMLNode req = soap_.Child();\n for(;;) {\n XMLNode prop = req[\"wsrf-rp:ResourceProperty\"];\n if(!prop) break;\n prop.Destroy();\n };\n for(std::vector::const_iterator i = names.begin();i!=names.end();++i) {\n XMLNode new_node = req.NewChild(\"wsrf-rp:ResourceProperty\");\n new_node=*i;\n };\n}", "label": 0, "cwe": null, "length": 114 }, { "index": 883849, "code": "isOSSSequencer(const QByteArray& lastElement)\n{\n if (lastElement.startsWith(\"sequencer\")) {\n /* OSS global sequencer devices */\n m_driver = Solid::AudioInterface::OpenSoundSystem;\n m_name = QLatin1String(\"OSS Sequencer Device\");\n m_deviceFile = m_device->property(\"DEVNAME\").toString();\n return true;\n }\n return false;\n}", "label": 0, "cwe": null, "length": 86 }, { "index": 930271, "code": "sql_type(String &res) const\n{\n char buffer[255];\n String set_item(buffer, sizeof(buffer), res.charset());\n\n res.length(0);\n res.append(STRING_WITH_LEN(\"set(\"));\n\n bool flag=0;\n uint *len= typelib->type_lengths;\n for (const char **pos= typelib->type_names; *pos; pos++, len++)\n {\n uint dummy_errors;\n if (flag)\n res.append(',');\n /* convert to res.charset() == utf8, then quote */\n set_item.copy(*pos, *len, charset(), res.charset(), &dummy_errors);\n append_unescaped(&res, set_item.ptr(), set_item.length());\n flag= 1;\n }\n res.append(')');\n}", "label": 0, "cwe": null, "length": 161 }, { "index": 363363, "code": "col_validate_property(const char *property)\n{\n TRACE_FLOW_STRING(\"col_validate_property\", \"Entry point.\");\n /* Only alpha numeric characters are allowed in names of the properties */\n int invalid = 0;\n const char *check;\n\n check = property;\n while (*check != '\\0') {\n /* It turned out that limiting collection charcters is bad */\n if ((*check < ' ') || (*check == '!')) {\n invalid = 1;\n break;\n }\n check++;\n }\n TRACE_FLOW_NUMBER(\"col_validate_property. Returning \", invalid);\n return invalid;\n}", "label": 0, "cwe": null, "length": 126 }, { "index": 517997, "code": "rk_strunvis(char *dst, const char *src)\n{\n\tchar c;\n\tchar *start = dst;\n\tint state = 0;\n\n\t_DIAGASSERT(src != NULL);\n\t_DIAGASSERT(dst != NULL);\n\n\twhile ((c = *src++) != '\\0') {\n\tagain:\n\t\tswitch (rk_unvis(dst, (unsigned char)c, &state, 0)) {\n\t\tcase UNVIS_VALID:\n\t\t\tdst++;\n\t\t\tbreak;\n\t\tcase UNVIS_VALIDPUSH:\n\t\t\tdst++;\n\t\t\tgoto again;\n\t\tcase 0:\n\t\tcase UNVIS_NOCHAR:\n\t\t\tbreak;\n\t\tdefault:\n\t\t\treturn (-1);\n\t\t}\n\t}\n\tif (unvis(dst, (unsigned char)c, &state, UNVIS_END) == UNVIS_VALID)\n\t\tdst++;\n\t*dst = '\\0';\n\treturn (dst - start);\n}", "label": 0, "cwe": null, "length": 174 }, { "index": 135409, "code": "cpu_set_range(PLPA_NAME(cpu_set_t) *out, int min, int max)\n{\n int i;\n PLPA_CPU_ZERO(out);\n for (i = min; i <= max && i < PLPA_BITMASK_CPU_MAX; ++i) {\n PLPA_CPU_SET(i, out);\n }\n}", "label": 0, "cwe": null, "length": 69 }, { "index": 123463, "code": "insert(Buffer * buf, docstring const & def, string const & requires)\n{\n\t//lyxerr << \"MacroTable::insert, def: \" << to_utf8(def) << endl;\n\tMathMacroTemplate mac(buf, def);\n\tMacroData data(buf, mac);\n\tdata.requires() = requires;\n\tinsert(mac.name(), data);\n}", "label": 0, "cwe": null, "length": 72 }, { "index": 996917, "code": "filter_add_drop_host_rule(const struct record *rec, filter_t *filter)\n{\n rule_t *rule;\n\n\trecord_check(rec);\n g_assert(filter != NULL);\n\n rule = filter_new_ip_rule(rec->results_set->addr, -1,\n \t\tfilter_get_drop_target(), RULE_FLAG_ACTIVE);\n\n filter_prepend_rule(filter, rule);\n}", "label": 0, "cwe": null, "length": 72 }, { "index": 50621, "code": "wrhelp(void)\n{\n int32 i;\n\n for (i = 0; *txhelp[i] != '\\0'; i++) __crit_msg(\"%s\\n\", txhelp[i]);\n}", "label": 0, "cwe": null, "length": 40 }, { "index": 771108, "code": "bnad_mac_addr_set_locked(struct bnad *bnad, const u8 *mac_addr)\n{\n\tint ret;\n\n\tif (!is_valid_ether_addr(mac_addr))\n\t\treturn -EADDRNOTAVAIL;\n\n\t/* If datapath is down, pretend everything went through */\n\tif (!bnad->rx_info[0].rx)\n\t\treturn 0;\n\n\tret = bna_rx_ucast_set(bnad->rx_info[0].rx, mac_addr);\n\tif (ret != BNA_CB_SUCCESS)\n\t\treturn -EADDRNOTAVAIL;\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 118 }, { "index": 88754, "code": "recalculateNormals(IMeshBuffer* buffer, bool smooth, bool angleWeighted) const\r\n{\r\n\tif (!buffer)\r\n\t\treturn;\r\n\r\n\tconst u32 vtxcnt = buffer->getVertexCount();\r\n\tconst u32 idxcnt = buffer->getIndexCount();\r\n\tconst u16* idx = buffer->getIndices();\r\n\r\n\tif (!smooth)\r\n\t{\r\n\t\tfor (u32 i=0; igetPosition(idx[i+0]);\r\n\t\t\tconst core::vector3df& v2 = buffer->getPosition(idx[i+1]);\r\n\t\t\tconst core::vector3df& v3 = buffer->getPosition(idx[i+2]);\r\n\t\t\tconst core::vector3df normal = core::plane3d(v1, v2, v3).Normal;\r\n\t\t\tbuffer->getNormal(idx[i+0]) = normal;\r\n\t\t\tbuffer->getNormal(idx[i+1]) = normal;\r\n\t\t\tbuffer->getNormal(idx[i+2]) = normal;\r\n\t\t}\r\n\t}\r\n\telse\r\n\t{\r\n\t\tu32 i;\r\n\r\n\t\tfor ( i = 0; i!= vtxcnt; ++i )\r\n\t\t\tbuffer->getNormal(i).set( 0.f, 0.f, 0.f );\r\n\r\n\t\tfor ( i=0; igetPosition(idx[i+0]);\r\n\t\t\tconst core::vector3df& v2 = buffer->getPosition(idx[i+1]);\r\n\t\t\tconst core::vector3df& v3 = buffer->getPosition(idx[i+2]);\r\n\t\t\tcore::vector3df normal = core::plane3d(v1, v2, v3).Normal;\r\n\r\n\t\t\tif (angleWeighted)\r\n\t\t\t\tnormal *= getAngleWeight(v1,v2,v3);\r\n\r\n\t\t\tbuffer->getNormal(idx[i+0]) += normal;\r\n\t\t\tbuffer->getNormal(idx[i+1]) += normal;\r\n\t\t\tbuffer->getNormal(idx[i+2]) += normal;\r\n\t\t}\r\n\r\n\t\tfor ( i = 0; i!= vtxcnt; ++i )\r\n\t\t\tbuffer->getNormal(i).normalize();\r\n\t}\r\n}", "label": 0, "cwe": null, "length": 458 }, { "index": 690791, "code": "an(str)\nregister const char *str;\n{\n\tchar *buf = nextobuf();\n\n\tbuf[0] = '\\0';\n\n\tif (strncmpi(str, \"the \", 4) &&\n\t strcmp(str, \"molten lava\") &&\n\t strcmp(str, \"iron bars\") &&\n\t strcmp(str, \"ice\")) {\n\t\tif (index(vowels, *str) &&\n\t\t strncmp(str, \"one-\", 4) &&\n\t\t strncmp(str, \"useful\", 6) &&\n\t\t strncmp(str, \"unicorn\", 7) &&\n\t\t strncmp(str, \"uranium\", 7) &&\n\t\t strncmp(str, \"eucalyptus\", 10))\n\t\t\tStrcpy(buf, \"an \");\n\t\telse\n\t\t\tStrcpy(buf, \"a \");\n\t}\n\n\tStrcat(buf, str);\n\treturn buf;\n}", "label": 0, "cwe": null, "length": 172 }, { "index": 684051, "code": "xio_close_win(struct xio_win *xw, int dpy_too)\n{\n struct xio *xio = xw->xio;\n\n XDestroyWindow(xio->dpy, xw->win);\n dl_remove(xw->node);\n free(xw);\n\n if (dpy_too && dl_empty(xio->windows))\n\txio_close_dpy(xio);\n}", "label": 0, "cwe": null, "length": 86 }, { "index": 194577, "code": "Decode(DataElement const &in, DataElement &out)\n{\n // First let's see if we can do a fast-path:\n if( !NeedByteSwap &&\n !RequestPaddedCompositePixelCode &&\n PI == PhotometricInterpretation::MONOCHROME2 &&\n !PlanarConfiguration && !RequestPlanarConfiguration &&\n GetPixelFormat().GetBitsAllocated() != 12 &&\n !NeedOverlayCleanup )\n {\n assert( this->GetPixelFormat() != PixelFormat::UINT12 );\n assert( this->GetPixelFormat() != PixelFormat::INT12 );\n out = in;\n return true;\n }\n // else\n const ByteValue *bv = in.GetByteValue();\n assert( bv );\n std::stringstream is;\n is.write(bv->GetPointer(), bv->GetLength());\n std::stringstream os;\n bool r = DecodeByStreams(is, os);\n if(!r) return false;\n assert( r );\n\n std::string str = os.str();\n //std::string::size_type check = str.size();\n\n out = in;\n\n if( this->GetPixelFormat() == PixelFormat::UINT12 ||\n this->GetPixelFormat() == PixelFormat::INT12 )\n {\n size_t len = str.size() * 16 / 12;\n char * copy = new char[len];//why use an array, and not a vector?\n bool b = Unpacker12Bits::Unpack(copy, &str[0], str.size() );\n assert( b );\n (void)b;\n VL::Type lenSize = (VL::Type)len;\n out.SetByteValue( copy, lenSize );\n delete[] copy;\n\n this->GetPixelFormat().SetBitsAllocated( 16 );\n }\n else\n {\n VL::Type strSize = (VL::Type) str.size();\n out.SetByteValue( &str[0], strSize);\n }\n\n return r;\n}", "label": 0, "cwe": null, "length": 416 }, { "index": 49988, "code": "gtkpod_warning_hig(GtkMessageType icon, const gchar *primary_text, const gchar *secondary_text) {\n g_return_if_fail (GTKPOD_IS_APP(gtkpod_app));\n GTKPOD_APP_GET_INTERFACE (gtkpod_app)->gtkpod_warning_hig(gtkpod_app, icon, primary_text, secondary_text);\n}", "label": 0, "cwe": null, "length": 70 }, { "index": 80830, "code": "manageDockWidget(QDockWidget *dock, Item *item)\n{\n // As of Qt 4.4.3 setting a shortcut to a QDockWidget has no effect,\n // because a QDockWidget does not grab it, even while displaying an underscore\n // in the title for the given shortcut letter.\n // Still it is useful to set the shortcut, because if QDockWidgets are tabbed,\n // the tab automatically gets the same text as the QDockWidget title, including the shortcut.\n // And for the QTabBar the shortcut does work, it gets grabbed as usual.\n // Having the QDockWidget without a shortcut and resetting the tab text with a title including\n // the shortcut does not work, the tab text is instantly reverted to the QDockWidget title\n // (see also manageTabBar()).\n // All in all QDockWidgets and shortcuts are a little broken for now.\n QString content = dock->windowTitle();\n if (content.isEmpty())\n return;\n\n Item *it = new Item;\n item->addChild(it);\n it->m_widget = dock;\n it->m_content = KAccelString(content, KAccelManagerAlgorithm::STANDARD_ACCEL);\n}", "label": 0, "cwe": null, "length": 258 }, { "index": 813560, "code": "nes_setup_mmap_qp(struct nes_qp *nesqp, struct nes_vnic *nesvnic,\n\t\tint sq_size, int rq_size)\n{\n\tvoid *mem;\n\tstruct nes_device *nesdev = nesvnic->nesdev;\n\n\tnesqp->qp_mem_size = (sizeof(struct nes_hw_qp_wqe) * sq_size) +\n\t\t\t(sizeof(struct nes_hw_qp_wqe) * rq_size) +\n\t\t\tmax((u32)sizeof(struct nes_qp_context), ((u32)256)) +\n\t\t\t256; /* this is Q2 */\n\t/* Round up to a multiple of a page */\n\tnesqp->qp_mem_size += PAGE_SIZE - 1;\n\tnesqp->qp_mem_size &= ~(PAGE_SIZE - 1);\n\n\tmem = pci_alloc_consistent(nesdev->pcidev, nesqp->qp_mem_size,\n\t\t\t&nesqp->hwqp.sq_pbase);\n\tif (!mem)\n\t\treturn -ENOMEM;\n\tnes_debug(NES_DBG_QP, \"PCI consistent memory for \"\n\t\t\t\"host descriptor rings located @ %p (pa = 0x%08lX.) size = %u.\\n\",\n\t\t\tmem, (unsigned long)nesqp->hwqp.sq_pbase, nesqp->qp_mem_size);\n\n\tmemset(mem, 0, nesqp->qp_mem_size);\n\n\tnesqp->hwqp.sq_vbase = mem;\n\tmem += sizeof(struct nes_hw_qp_wqe) * sq_size;\n\n\tnesqp->hwqp.rq_vbase = mem;\n\tnesqp->hwqp.rq_pbase = nesqp->hwqp.sq_pbase +\n\t\t\tsizeof(struct nes_hw_qp_wqe) * sq_size;\n\tmem += sizeof(struct nes_hw_qp_wqe) * rq_size;\n\n\tnesqp->hwqp.q2_vbase = mem;\n\tnesqp->hwqp.q2_pbase = nesqp->hwqp.rq_pbase +\n\t\t\tsizeof(struct nes_hw_qp_wqe) * rq_size;\n\tmem += 256;\n\tmemset(nesqp->hwqp.q2_vbase, 0, 256);\n\n\tnesqp->nesqp_context = mem;\n\tnesqp->nesqp_context_pbase = nesqp->hwqp.q2_pbase + 256;\n\tmemset(nesqp->nesqp_context, 0, sizeof(*nesqp->nesqp_context));\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 496 }, { "index": 329881, "code": "recvTalk(const Talk& tk)\n{\n if (tk->isDefaultFrom()) {\n return IGNORED;\n }\n IdPersonMap::const_iterator P = m_people.find(tk->getFrom());\n if ((P == m_people.end()) || (P->second == NULL)) {\n getPerson(tk->getFrom()); // force a LOOK if necessary\n debug() << \"creating sight-person-redispatch for \" << tk->getFrom();\n \n Sight sight;\n sight->setArgs1(tk);\n sight->setTo(getAccount()->getId());\n \n SightPersonRedispatch *spr = new SightPersonRedispatch(getConnection(), tk->getFrom(), sight);\n SightPerson.connect(sigc::mem_fun(spr, &SightPersonRedispatch::onSightPerson));\n \n return WILL_REDISPATCH;\n }\n \n const std::vector& args = tk->getArgs();\n if (args.empty() || !args.front()->hasAttr(\"say\")) {\n error() << \"received sound(talk) with no / bad args\";\n return HANDLED;\n }\n\n std::string speech = args.front()->getAttr(\"say\").asString();\n \n if (args.front()->hasAttr(\"loc\")) {\n std::string loc = args.front()->getAttr(\"loc\").asString();\n IdRoomMap::const_iterator room = m_rooms.find(loc);\n \n if (room != m_rooms.end()) {\n room->second->handleSoundTalk(P->second, speech);\n } else {\n warning() << \"lobby got sound(talk) with unknown loc: \" << loc;\n }\n } else {\n // no location, hence assume it's one-to-one chat\n PrivateTalk.emit(P->second, speech);\n }\n\n return HANDLED;\n}", "label": 0, "cwe": null, "length": 377 }, { "index": 438325, "code": "common_configuration_init()\n{\n /* Load the global gnuitrc.common file. */\n char *configfile = xmalloc(strlen(termdir) + 1 +\n\t\t\t strlen(SYSTEM_CONFIGFILE_PREFIX) +\n\t\t\t sizeof(\"common\") + 1);\n strcpy(configfile, termdir);\n strcat(configfile, SYSTEM_CONFIGFILE_PREFIX);\n strcat(configfile, \"common\");\n\n if (configuration_init(configfile) == 0)\n {\n\t/* Give up if global gnuitrc.common is not found. */\n\tconfiguration_fatal_error(configfile);\n\texit(1);\n }\n}", "label": 0, "cwe": null, "length": 124 }, { "index": 387296, "code": "EnvQuery(Local property,\n const AccessorInfo& info) {\n String::Utf8Value key(property);\n if (getenv(*key)) {\n HandleScope scope;\n return scope.Close(Integer::New(None));\n }\n return Handle();\n}", "label": 0, "cwe": null, "length": 57 }, { "index": 22121, "code": "runApplication( const KUrl& , const QString & _serviceFile )\n{\n KService s( _serviceFile );\n if ( !s.isValid() )\n // The error message was already displayed, so we can just quit here\n // ### KDE4: is this still the case?\n return false;\n\n KUrl::List lst;\n return KRun::run( s, lst, 0 /*TODO - window*/ );\n}", "label": 0, "cwe": null, "length": 93 }, { "index": 46640, "code": "PmlRequestSetRetry( int deviceid, int channelid, PmlObject_t obj, int count, int delay )\n{\n int stat=ERROR, r;\n\n if(count <= 0)\n {\n count = 10;\n }\n if(delay <= 0)\n {\n delay = 1;\n }\n while( 1 )\n {\n if ((r = PmlRequestSet(deviceid, channelid, obj)) == ERROR)\n goto bugout;\n if (PmlGetStatus(obj) == PML_ERROR_ACTION_CAN_NOT_BE_PERFORMED_NOW && count > 0)\n {\n sleep(delay);\n count--;\n continue;\n }\n break;\n }\n\n /* Check PML result. */\n if (PmlGetStatus(obj) & PML_ERROR)\n {\n DBG(6, \"PML set failed: oid=%s count=%d delay=%d %s %d\\n\", obj->oid, count, delay, __FILE__, __LINE__);\n goto bugout;\n }\n\n stat = OK; \n\nbugout:\n return stat; /* OK = valid I/O result AND PML result */\n}", "label": 0, "cwe": null, "length": 247 }, { "index": 254173, "code": "core_get_backend(const char *name)\n{\n\tstruct target_backend *tb;\n\n\tmutex_lock(&backend_mutex);\n\tlist_for_each_entry(tb, &backend_list, list) {\n\t\tif (!strcmp(tb->ops->name, name))\n\t\t\tgoto found;\n\t}\n\tmutex_unlock(&backend_mutex);\n\treturn NULL;\nfound:\n\tif (tb->ops->owner && !try_module_get(tb->ops->owner))\n\t\ttb = NULL;\n\tmutex_unlock(&backend_mutex);\n\treturn tb;\n}", "label": 0, "cwe": null, "length": 97 }, { "index": 629826, "code": "gmsg_size_valid(const void *msg, uint16 *size)\n{\n\tuint32 raw_size = gnutella_header_get_size(msg);\n\tuint16 payload_size = (uint16) (raw_size & GTA_SIZE_MASK);\n\t\n\tif (raw_size == payload_size)\n\t\tgoto ok;\n\n\tif (raw_size & GTA_SIZE_MARKED) {\n\t\tuint32 flags = raw_size & ~GTA_SIZE_MASK;\n\t\tflags &= ~GTA_SIZE_MARKED;\n\n\t\t*size = payload_size;\n\n\t\tif (flags == 0)\n\t\t\treturn GMSG_VALID_MARKED;\n\n\t\t/*\n\t\t * We don't know how to handle flags yet -- they are undefined.\n\t\t * However, the message IS valid and could be relayed possibly.\n\t\t * But we cannot interpret it.\n\t\t */\n\n\t\treturn GMSG_VALID_NO_PROCESS;\n\t}\n\n\treturn GMSG_INVALID;\n\nok:\n\t*size = payload_size;\n\treturn GMSG_VALID;\n}", "label": 0, "cwe": null, "length": 190 }, { "index": 548952, "code": "get_message_context( char **msgid )\n{\n static const char magic[] = \"#msgctxt#\";\n char *id, *context;\n\n if (strncmp( *msgid, magic, sizeof(magic) - 1 )) return NULL;\n context = *msgid + sizeof(magic) - 1;\n if (!(id = strchr( context, '#' ))) return NULL;\n *id = 0;\n *msgid = id + 1;\n return context;\n}", "label": 0, "cwe": null, "length": 100 }, { "index": 997878, "code": "nvs_vpd_write ( struct nvs_device *nvs, unsigned int field,\n\t\t\t const void *data, size_t len ) {\n\tstruct nvs_vpd_device *nvsvpd =\n\t\tcontainer_of ( nvs, struct nvs_vpd_device, nvs );\n\tstruct pci_device *pci = nvsvpd->vpd.pci;\n\tunsigned int address;\n\tsize_t max_len;\n\tint rc;\n\n\t/* Locate VPD field */\n\tif ( ( rc = pci_vpd_find ( &nvsvpd->vpd, field, &address,\n\t\t\t\t &max_len ) ) != 0 ) {\n\t\tDBGC ( pci, PCI_FMT \" NVS VPD could not locate field \"\n\t\t PCI_VPD_FIELD_FMT \": %s\\n\", PCI_ARGS ( pci ),\n\t\t PCI_VPD_FIELD_ARGS ( field ), strerror ( rc ) );\n\t\treturn rc;\n\t}\n\n\t/* Sanity check */\n\tif ( len > max_len ) {\n\t\tDBGC ( pci, PCI_FMT \" NVS VPD cannot write %#02zx bytes \"\n\t\t \"beyond field \" PCI_VPD_FIELD_FMT \" at [%04x,%04zx)\\n\",\n\t\t PCI_ARGS ( pci ), len, PCI_VPD_FIELD_ARGS ( field ),\n\t\t address, ( address + max_len ) );\n\t\treturn -ENXIO;\n\t}\n\n\t/* Write field */\n\tif ( ( rc = pci_vpd_write ( &nvsvpd->vpd, address, data,\n\t\t\t\t len ) ) != 0 ) {\n\t\tDBGC ( pci, PCI_FMT \" NVS VPD could not write field \"\n\t\t PCI_VPD_FIELD_FMT \" at [%04x,%04zx): %s\\n\",\n\t\t PCI_ARGS ( pci ), PCI_VPD_FIELD_ARGS ( field ),\n\t\t address, ( address + len ), strerror ( rc ) );\n\t\treturn rc;\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 381 }, { "index": 951551, "code": "mnt3svc_init (xlator_t *nfsx)\n{\n struct mount3_state *mstate = NULL;\n struct nfs_state *nfs = NULL;\n dict_t *options = NULL;\n char *portstr = NULL;\n int ret = -1;\n\n if (!nfsx || !nfsx->private)\n return NULL;\n\n nfs = (struct nfs_state *)nfsx->private;\n\n gf_log (GF_MNT, GF_LOG_DEBUG, \"Initing Mount v3 state\");\n mstate = (struct mount3_state *)nfs->mstate;\n if (!mstate) {\n gf_log (GF_MNT, GF_LOG_ERROR, \"Mount v3 state init failed\");\n goto err;\n }\n\n mnt3prog.private = mstate;\n options = dict_new ();\n\n ret = gf_asprintf (&portstr, \"%d\", GF_MOUNTV3_PORT);\n if (ret == -1)\n goto err;\n\n ret = dict_set_dynstr (options, \"transport.socket.listen-port\", portstr);\n if (ret == -1)\n goto err;\n ret = dict_set_str (options, \"transport-type\", \"socket\");\n if (ret == -1) {\n gf_log (GF_NFS, GF_LOG_ERROR, \"dict_set_str error\");\n goto err;\n }\n\n if (nfs->allow_insecure) {\n ret = dict_set_str (options, \"rpc-auth-allow-insecure\", \"on\");\n if (ret == -1) {\n gf_log (GF_NFS, GF_LOG_ERROR, \"dict_set_str error\");\n goto err;\n }\n ret = dict_set_str (options, \"rpc-auth.ports.insecure\", \"on\");\n if (ret == -1) {\n gf_log (GF_NFS, GF_LOG_ERROR, \"dict_set_str error\");\n goto err;\n }\n }\n\n rpcsvc_create_listeners (nfs->rpcsvc, options, nfsx->name);\n if (ret == -1) {\n gf_log (GF_NFS, GF_LOG_ERROR, \"Unable to create listeners\");\n dict_unref (options);\n goto err;\n }\n\n return &mnt3prog;\nerr:\n return NULL;\n}", "label": 0, "cwe": null, "length": 484 }, { "index": 540958, "code": "parameterOption ( std::string check ) const\n{\n int numberItems = static_cast(definedKeyWords_.size());\n if (!numberItems) {\n return -1;\n } else {\n int whichItem = 0;\n unsigned int it;\n for (it = 0; it < definedKeyWords_.size(); it++) {\n std::string thisOne = definedKeyWords_[it];\n std::string::size_type shriekPos = thisOne.find('!');\n size_t length1 = thisOne.length();\n size_t length2 = length1;\n if ( shriekPos != std::string::npos ) {\n //contains '!'\n length2 = shriekPos;\n thisOne = thisOne.substr(0, shriekPos) +\n thisOne.substr(shriekPos + 1);\n length1 = thisOne.length();\n }\n if (check.length() <= length1 && length2 <= check.length()) {\n unsigned int i;\n for (i = 0; i < check.length(); i++) {\n if (tolower(thisOne[i]) != tolower(check[i]))\n break;\n }\n if (i < check.length()) {\n whichItem++;\n } else if (i >= length2) {\n break;\n }\n } else {\n whichItem++;\n }\n }\n if (whichItem < numberItems)\n return whichItem;\n else\n return -1;\n }\n}", "label": 0, "cwe": null, "length": 311 }, { "index": 590461, "code": "operator<< (ostream& out, const basic_string& str)\n{\n cxxtools::Utf8Codec codec;\n char to[64];\n cxxtools::MBState state;\n\n cxxtools::Utf8Codec::result r;\n const cxxtools::Char* from = str.data();\n cxxtools::String::size_type size = str.size();\n\n do{\n const cxxtools::Char* from_next;\n\n char* to_next = to;\n r = codec.out(state, from, from + size, from_next, to, to + sizeof(to), to_next);\n\n if (r == cxxtools::Utf8Codec::error)\n {\n out.setstate(std::ios::failbit);\n break;\n }\n\n out.write(to, to_next - to);\n\n size -= (from_next - from);\n from = from_next;\n\n } while (out.good() && r == cxxtools::Utf8Codec::partial);\n\n return out;\n}\n\n\n}", "label": 0, "cwe": null, "length": 216 }, { "index": 887079, "code": "cvtThumbMultiply(MCInst &Inst, unsigned Opcode,\n const SmallVectorImpl &Operands) {\n // The second source operand must be the same register as the destination\n // operand.\n if (Operands.size() == 6 &&\n (((ARMOperand*)Operands[3])->getReg() !=\n ((ARMOperand*)Operands[5])->getReg()) &&\n (((ARMOperand*)Operands[3])->getReg() !=\n ((ARMOperand*)Operands[4])->getReg())) {\n Error(Operands[3]->getStartLoc(),\n \"destination register must match source register\");\n return false;\n }\n ((ARMOperand*)Operands[3])->addRegOperands(Inst, 1);\n ((ARMOperand*)Operands[1])->addCCOutOperands(Inst, 1);\n ((ARMOperand*)Operands[4])->addRegOperands(Inst, 1);\n // If we have a three-operand form, use that, else the second source operand\n // is just the destination operand again.\n if (Operands.size() == 6)\n ((ARMOperand*)Operands[5])->addRegOperands(Inst, 1);\n else\n Inst.addOperand(Inst.getOperand(0));\n ((ARMOperand*)Operands[2])->addCondCodeOperands(Inst, 2);\n\n return true;\n}", "label": 0, "cwe": null, "length": 305 }, { "index": 35053, "code": "AddPoints(Team team, uint32 points)\n{\n BattleGroundTeamIndex team_index = GetTeamIndexByTeamId(team);\n m_TeamScores[team_index] += points;\n m_honorScoreTicks[team_index] += points;\n if (m_honorScoreTicks[team_index] >= m_honorTicks)\n {\n RewardHonorToTeam(GetBonusHonorFromKill(1), team);\n m_honorScoreTicks[team_index] -= m_honorTicks;\n }\n}", "label": 0, "cwe": null, "length": 109 }, { "index": 489403, "code": "huge_zonelist(struct vm_area_struct *vma, unsigned long addr,\n\t\t\t\tgfp_t gfp_flags, struct mempolicy **mpol,\n\t\t\t\tnodemask_t **nodemask)\n{\n\tstruct zonelist *zl;\n\n\t*mpol = get_vma_policy(vma, addr);\n\t*nodemask = NULL;\t/* assume !MPOL_BIND */\n\n\tif (unlikely((*mpol)->mode == MPOL_INTERLEAVE)) {\n\t\tzl = node_zonelist(interleave_nid(*mpol, vma, addr,\n\t\t\t\thuge_page_shift(hstate_vma(vma))), gfp_flags);\n\t} else {\n\t\tzl = policy_zonelist(gfp_flags, *mpol, numa_node_id());\n\t\tif ((*mpol)->mode == MPOL_BIND)\n\t\t\t*nodemask = &(*mpol)->v.nodes;\n\t}\n\treturn zl;\n}", "label": 0, "cwe": null, "length": 189 }, { "index": 209542, "code": "set_shadow_color_by_pixel(unsigned char which, Pixel p)\n{\n ASSERT(which <= 7); // which = 0-7 [SHADOW_TOP_LEFT - SHADOW_BOTTOM_RIGHT]\n\n fshadow.color[which] = p;\n fshadow.shadow[which] = fshadow.do_shadow = 1;\n}", "label": 0, "cwe": null, "length": 66 }, { "index": 63037, "code": "sigmaHat() {\n\n // CKM factor. Secondary width for W+ or W-.\n double sigma = sigma0 * couplingsPtr->V2CKMid(abs(id1), abs(id2));\n int idUp = (abs(id1)%2 == 0) ? id1 : id2;\n sigma *= (idUp > 0) ? openFracPos : openFracNeg;\n\n // Answer.\n return sigma; \n\n}", "label": 0, "cwe": null, "length": 98 }, { "index": 941267, "code": "Ipcress_prepare_PCR(Ipcress *ipcress){\n register PCR *pcr = PCR_create(Ipcress_report_product, ipcress,\n ipcress->mismatches,\n ipcress->seed_length);\n register gsize memory_usage;\n register gint experiment_count = 0, word_count;\n register gchar *id, *primer_a, *primer_b;\n register gint min_product_len, max_product_len;\n /* Read as many experiments as possible into memory */\n while((word_count = LineParse_word(ipcress->input_lp)) != EOF){\n if(word_count == 0)\n continue;\n if(word_count != 5)\n g_error(\"Bad line in ipcress file with [%d] fields\",\n word_count);\n id = ipcress->input_lp->word->pdata[0];\n primer_a = ipcress->input_lp->word->pdata[1];\n primer_b = ipcress->input_lp->word->pdata[2];\n g_strup(primer_a);\n g_strup(primer_b);\n min_product_len = atoi(ipcress->input_lp->word->pdata[3]);\n max_product_len = atoi(ipcress->input_lp->word->pdata[4]);\n memory_usage = PCR_add_experiment(pcr, id, primer_a, primer_b,\n min_product_len, max_product_len);\n experiment_count++;\n if(memory_usage > (ipcress->memory_limit << 20)){\n break;\n }\n }\n if(!experiment_count){\n PCR_destroy(pcr);\n return NULL;\n }\n g_message(\"Loaded [%d] experiments\", experiment_count);\n PCR_prepare(pcr);\n return pcr;\n }", "label": 1, "cwe": "CWE-other", "length": 358 }, { "index": 481332, "code": "apol_domain_trans_table_new(apol_policy_t * policy)\n{\n\tapol_domain_trans_table_t *new_table = NULL;\n\tint error;\n\n\tif (!policy) {\n\t\tERR(policy, \"%s\", strerror(EINVAL));\n\t\terrno = EINVAL;\n\t\treturn NULL;\n\t}\n\n\tnew_table = (apol_domain_trans_table_t *) calloc(1, sizeof(apol_domain_trans_table_t));\n\tif (!new_table) {\n\t\tERR(policy, \"%s\", strerror(ENOMEM));\n\t\terror = ENOMEM;\n\t\tgoto cleanup;\n\t}\n\n\tif (!(new_table->domain_table = apol_bst_create(dom_node_cmp, dom_node_free))) {\n\t\tERR(policy, \"%s\", strerror(ENOMEM));\n\t\terror = ENOMEM;\n\t\tgoto cleanup;\n\t}\n\tif (!(new_table->entrypoint_table = apol_bst_create(ep_node_cmp, ep_node_free))) {\n\t\tERR(policy, \"%s\", strerror(ENOMEM));\n\t\terror = ENOMEM;\n\t\tgoto cleanup;\n\t}\n\n\treturn new_table;\n cleanup:\n\tdomain_trans_table_destroy(&new_table);\n\terrno = error;\n\treturn NULL;\n}", "label": 0, "cwe": null, "length": 224 }, { "index": 34785, "code": "read_config(void)\n{\n\tunsigned char sha1[20];\n\tconst char *head_ref;\n\tint flag;\n\tif (default_remote_name) /* did this already */\n\t\treturn;\n\tdefault_remote_name = xstrdup(\"origin\");\n\tcurrent_branch = NULL;\n\thead_ref = resolve_ref(\"HEAD\", sha1, 0, &flag);\n\tif (head_ref && (flag & REF_ISSYMREF) &&\n\t !prefixcmp(head_ref, \"refs/heads/\")) {\n\t\tcurrent_branch =\n\t\t\tmake_branch(head_ref + strlen(\"refs/heads/\"), 0);\n\t}\n\tgit_config(handle_config, NULL);\n\talias_all_urls();\n}", "label": 0, "cwe": null, "length": 131 }, { "index": 579138, "code": "child_offset_to_generated_offset (GArray *group,\n gint offset)\n{\n\tgint accum_offset = 0;\n\tgint i;\n\n\tg_return_val_if_fail (group != NULL, -1);\n\n\tfor (i = 0; i < group->len && i < offset; i++) {\n\t\tNode *node = &g_array_index (group, Node, i);\n\n\t\taccum_offset += node->n_generated;\n\t}\n\n\treturn accum_offset;\n}", "label": 0, "cwe": null, "length": 95 }, { "index": 10834, "code": "fso_framework_kernel_removeModule (const gchar* filename, gboolean wait, gboolean force, GError** error) {\n\tguint flags = 0U;\n\tgboolean _tmp0_ = FALSE;\n\tgboolean _tmp2_ = FALSE;\n\tglong ok = 0L;\n\tconst gchar* _tmp4_ = NULL;\n\tguint _tmp5_ = 0U;\n\tglong _tmp6_ = 0L;\n\tglong _tmp7_ = 0L;\n\tGError * _inner_error_ = NULL;\n\tg_return_if_fail (filename != NULL);\n\tflags = (guint) (O_EXCL | O_NONBLOCK);\n\t_tmp0_ = wait;\n\tif (_tmp0_) {\n\t\tguint _tmp1_ = 0U;\n\t\t_tmp1_ = flags;\n\t\tflags = _tmp1_ & (~O_NONBLOCK);\n\t}\n\t_tmp2_ = force;\n\tif (_tmp2_) {\n\t\tguint _tmp3_ = 0U;\n\t\t_tmp3_ = flags;\n\t\tflags = _tmp3_ | O_TRUNC;\n\t}\n\t_tmp4_ = filename;\n\t_tmp5_ = flags;\n\t_tmp6_ = delete_module (_tmp4_, _tmp5_);\n\tok = _tmp6_;\n\t_tmp7_ = ok;\n\tif (_tmp7_ != ((glong) 0)) {\n\t\tgint _tmp8_ = 0;\n\t\tconst gchar* _tmp9_ = NULL;\n\t\tconst gchar* _tmp10_ = NULL;\n\t\tgchar* _tmp11_ = NULL;\n\t\tgchar* _tmp12_ = NULL;\n\t\tGError* _tmp13_ = NULL;\n\t\tGError* _tmp14_ = NULL;\n\t\t_tmp8_ = errno;\n\t\t_tmp9_ = g_strerror (_tmp8_);\n\t\t_tmp10_ = string_to_string (_tmp9_);\n\t\t_tmp11_ = g_strconcat (\"Can't insert module: \", _tmp10_, NULL);\n\t\t_tmp12_ = _tmp11_;\n\t\t_tmp13_ = g_error_new_literal (SYSTEM_ERROR, SYSTEM_ERROR_ERROR, _tmp12_);\n\t\t_tmp14_ = _tmp13_;\n\t\t_g_free0 (_tmp12_);\n\t\t_inner_error_ = _tmp14_;\n\t\tg_propagate_error (error, _inner_error_);\n\t\treturn;\n\t}\n}", "label": 0, "cwe": null, "length": 497 }, { "index": 59215, "code": "mkd_css(Document *d, char **res)\n{\n Cstring f;\n\n if ( res && *res && d && d->compiled ) {\n\tCREATE(f);\n\tRESERVE(f, 100);\n\tstylesheets(d->code, &f);\n\t\t\t\n\t\t\t/* HACK ALERT! HACK ALERT! HACK ALERT! */\n\t*res = T(f);\t/* we know that a T(Cstring) is a character pointer */\n\t\t\t/* so we can simply pick it up and carry it away, */\n\treturn S(f);\t/* leaving the husk of the Ctring on the stack */\n\t\t\t/* END HACK ALERT */\n }\n return EOF;\n}", "label": 1, "cwe": "CWE-other", "length": 139 }, { "index": 122661, "code": "eet_data_put_int(Eet_Dictionary *ed __UNUSED__,\n const void *src,\n int *size_ret)\n{\n int *s, *d;\n\n d = (int *)malloc(sizeof(int));\n if (!d)\n return NULL;\n\n s = (int *)src;\n *d = *s;\n CONV32(*d);\n *size_ret = sizeof(int);\n return d;\n}", "label": 0, "cwe": null, "length": 92 }, { "index": 870640, "code": "isFloat(const std::string &s)\n{\n // every number that contains a . is a float\n if (s.find(\".\" , 0) != std::string::npos)\n return true;\n // scientific notation\n return(s.find(\"E-\", 0) != std::string::npos\n || s.find(\"e-\", 0) != std::string::npos);\n}", "label": 0, "cwe": null, "length": 84 }, { "index": 660245, "code": "__check_block_validity(struct inode *inode, const char *func,\n\t\t\t\tunsigned int line,\n\t\t\t\tstruct ext4_map_blocks *map)\n{\n\tif (!ext4_data_block_valid(EXT4_SB(inode->i_sb), map->m_pblk,\n\t\t\t\t map->m_len)) {\n\t\text4_error_inode(inode, func, line, map->m_pblk,\n\t\t\t\t \"lblock %lu mapped to illegal pblock \"\n\t\t\t\t \"(length %d)\", (unsigned long) map->m_lblk,\n\t\t\t\t map->m_len);\n\t\treturn -EFSCORRUPTED;\n\t}\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 128 }, { "index": 481930, "code": "dict_insert(dict* d, dict_entry* e)\n{\n unsigned i;\n for (i = e->hash % d->size; d->table[i]; i = (i + 1) % d->size) ;\n d->table[i] = e;\n ++d->count;\n}", "label": 0, "cwe": null, "length": 65 }, { "index": 55746, "code": "trinity_program_power_level(struct radeon_device *rdev,\n\t\t\t\t\tstruct trinity_pl *pl, u32 index)\n{\n\tstruct trinity_power_info *pi = trinity_get_pi(rdev);\n\n\tif (index >= SUMO_MAX_HARDWARE_POWERLEVELS)\n\t\treturn;\n\n\ttrinity_set_divider_value(rdev, index, pl->sclk);\n\ttrinity_set_vid(rdev, index, pl->vddc_index);\n\ttrinity_set_ss_dividers(rdev, index, pl->ss_divider_index);\n\ttrinity_set_ds_dividers(rdev, index, pl->ds_divider_index);\n\ttrinity_set_allos_gnb_slow(rdev, index, pl->allow_gnb_slow);\n\ttrinity_set_force_nbp_state(rdev, index, pl->force_nbp_state);\n\ttrinity_set_display_wm(rdev, index, pl->display_wm);\n\ttrinity_set_vce_wm(rdev, index, pl->vce_wm);\n\ttrinity_set_at(rdev, index, pi->at[index]);\n}", "label": 0, "cwe": null, "length": 216 }, { "index": 533673, "code": "_var_numeric_to_sx_var(gchar *name, gnc_numeric *num, GHashTable *sx_var_hash)\n{\n gpointer p_var;\n if (!g_hash_table_lookup_extended(sx_var_hash, name, NULL, &p_var))\n {\n p_var = (gpointer)gnc_sx_variable_new(name);\n g_hash_table_insert(sx_var_hash, g_strdup(name), p_var);\n }\n ((GncSxVariable*)p_var)->value = *num;\n}", "label": 0, "cwe": null, "length": 106 }, { "index": 716230, "code": "flush()\n{\n if (transactions.size() > 0) {\n for (transactions_list::iterator i = transactions.begin();\n\t i != transactions.end();\n\t i++) {\n if ((*i)->entry) {\n\tfor (transactions_list::iterator j = (*i)->entry->transactions.begin();\n\t j != (*i)->entry->transactions.end();\n\t j++) {\n\t transaction_xdata_t& xdata = transaction_xdata(**j);\n\t if (! (xdata.dflags & TRANSACTION_HANDLED) &&\n\t (! (xdata.dflags & TRANSACTION_RECEIVED) ?\n\t ! ((*j)->flags & (TRANSACTION_AUTO | TRANSACTION_VIRTUAL)) :\n\t also_matching)) {\n\t xdata.dflags |= TRANSACTION_HANDLED;\n\t item_handler::operator()(**j);\n\t }\n\t}\n } else {\n\t// This code should only be reachable from the \"output\"\n\t// command, since that is the only command which attempts to\n\t// output auto or period entries.\n\ttransaction_xdata_t& xdata = transaction_xdata(**i);\n\tif (! (xdata.dflags & TRANSACTION_HANDLED) &&\n\t ! ((*i)->flags & TRANSACTION_AUTO)) {\n\t xdata.dflags |= TRANSACTION_HANDLED;\n\t item_handler::operator()(**i);\n\t}\n }\n }\n }\n\n item_handler::flush();\n}", "label": 0, "cwe": null, "length": 282 }, { "index": 279225, "code": "clear_dialed_interfaces(struct ast_channel *chan)\n{\n\tstruct ast_datastore *di_datastore;\n\n\tast_channel_lock(chan);\n\tif ((di_datastore = ast_channel_datastore_find(chan, &dialed_interface_info, NULL))) {\n\t\tif (option_debug) {\n\t\t\tast_log(LOG_DEBUG, \"Removing dialed interfaces datastore on %s since we're bridging\\n\", ast_channel_name(chan));\n\t\t}\n\t\tif (!ast_channel_datastore_remove(chan, di_datastore)) {\n\t\t\tast_datastore_free(di_datastore);\n\t\t}\n\t}\n\tast_channel_unlock(chan);\n}", "label": 0, "cwe": null, "length": 121 }, { "index": 34436, "code": "aim_search_address(aim_session_t *sess, aim_conn_t *conn,\n\tconst char *address)\n{\n\taim_frame_t *fr;\n\taim_snacid_t snacid;\n\n\tif (!sess || !conn || !address)\n\t\treturn -EINVAL;\n\n\tif (!(fr = aim_tx_new(sess, conn, AIM_FRAMETYPE_FLAP, 0x02,\n\t\t\t\t10 + strlen(address))))\n\t\treturn -ENOMEM;\n\n\tsnacid = aim_cachesnac(sess, 0x000a, 0x0002, 0x0000, strdup(address),\n\t\tstrlen(address) + 1);\n\taim_putsnac(&fr->data, 0x000a, 0x0002, 0x0000, snacid);\n\n\taimbs_putraw(&fr->data, address, strlen(address));\n\n\taim_tx_enqueue(sess, fr);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 187 }, { "index": 661007, "code": "stop ()\n{\n//\n// Sevior: Once again we have to ignore this if the idle is already stopped.\n// UT_ASSERT(m_id > 0);\n\tif(m_id > 0)\n\t{\n#ifndef TOOLKIT_COCOA\n\t\tgboolean b = g_idle_remove_by_data(this);\n\t\tUT_UNUSED(b);\n\t\tUT_ASSERT(TRUE == b);\n#else\n\t\tUT_ASSERT (UT_NOT_IMPLEMENTED);\n#endif\n\t}\n\tm_id = -1;\n}", "label": 0, "cwe": null, "length": 98 }, { "index": 48540, "code": "opvp_alloc_string(char **destin, const char *source)\n{\n if (!destin) return NULL;\n\n if (*destin) {\n if (source) {\n *destin = realloc(*destin, strlen(source)+1);\n } else {\n free(*destin);\n *destin = NULL;\n }\n } else {\n if (source) {\n *destin = malloc(strlen(source)+1);\n }\n }\n if (*destin && source) {\n if (*destin != source) {\n strcpy(*destin, source);\n }\n }\n\n return *destin;\n}", "label": 0, "cwe": null, "length": 134 }, { "index": 89593, "code": "getCursorPosition(int &r, int &c)\n{\n\tr += getRowAligned();\n\tc += getColAligned();\n\n\tCursesContainer *parent=getParent();\n\tif (parent)\n\t\treturn parent->getCursorPosition(r, c);\n\n\treturn 1;\n}", "label": 0, "cwe": null, "length": 51 }, { "index": 622832, "code": "ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)\n{\n\tstruct addrinfo hints;\n\tstruct addrinfo\t*res;\n\tchar *s;\n\tchar *host;\n\tchar *port;\n\tint\te;\n\n\ts = ast_strdupa(str);\n\tif (!ast_sockaddr_split_hostport(s, &host, &port, flags)) {\n\t\treturn 0;\n\t}\n\n\tmemset(&hints, 0, sizeof(hints));\n\t/* Hint to get only one entry from getaddrinfo */\n\thints.ai_socktype = SOCK_DGRAM;\n\n#ifdef AI_NUMERICSERV\n\thints.ai_flags = AI_NUMERICHOST | AI_NUMERICSERV;\n#else\n\thints.ai_flags = AI_NUMERICHOST;\n#endif\n\tif ((e = getaddrinfo(host, port, &hints, &res))) {\n\t\tif (e != EAI_NONAME) { /* if this was just a host name rather than a ip address, don't print error */\n\t\t\tast_log(LOG_ERROR, \"getaddrinfo(\\\"%s\\\", \\\"%s\\\", ...): %s\\n\",\n\t\t\t\thost, S_OR(port, \"(null)\"), gai_strerror(e));\n\t\t}\n\t\treturn 0;\n\t}\n\n\t/*\n\t * I don't see how this could be possible since we're not resolving host\n\t * names. But let's be careful...\n\t */\n\tif (res->ai_next != NULL) {\n\t\tast_log(LOG_WARNING, \"getaddrinfo() returned multiple \"\n\t\t\t\"addresses. Ignoring all but the first.\\n\");\n\t}\n\n\tif (addr) {\n\t\taddr->len = res->ai_addrlen;\n\t\tmemcpy(&addr->ss, res->ai_addr, addr->len);\n\t}\n\n\tfreeaddrinfo(res);\n\n\treturn 1;\n}", "label": 1, "cwe": "CWE-120", "length": 362 }, { "index": 414906, "code": "embPdbResidueIndexC(const AjPPdb pdb, char chn, AjPInt *idx)\n{\n ajuint chnn = 0U;\n \n if(!ajPdbChnidToNum(chn, pdb, &chnn))\n {\n\tajWarn(\"Chain not found in embPdbResidueIndexC\");\n\n\treturn ajFalse;\n }\n \n if(!embPdbResidueIndexI(pdb, chnn, idx))\n\treturn ajFalse;\n\n return ajTrue;\n}", "label": 0, "cwe": null, "length": 108 }, { "index": 579927, "code": "ecp_check_pubkey_sw( const ecp_group *grp, const ecp_point *pt )\n{\n int ret;\n mpi YY, RHS;\n\n /* pt coordinates must be normalized for our checks */\n if( mpi_cmp_int( &pt->X, 0 ) < 0 ||\n mpi_cmp_int( &pt->Y, 0 ) < 0 ||\n mpi_cmp_mpi( &pt->X, &grp->P ) >= 0 ||\n mpi_cmp_mpi( &pt->Y, &grp->P ) >= 0 )\n return( POLARSSL_ERR_ECP_INVALID_KEY );\n\n mpi_init( &YY ); mpi_init( &RHS );\n\n /*\n * YY = Y^2\n * RHS = X (X^2 + A) + B = X^3 + A X + B\n */\n MPI_CHK( mpi_mul_mpi( &YY, &pt->Y, &pt->Y ) ); MOD_MUL( YY );\n MPI_CHK( mpi_mul_mpi( &RHS, &pt->X, &pt->X ) ); MOD_MUL( RHS );\n\n /* Special case for A = -3 */\n if( grp->A.p == NULL )\n {\n MPI_CHK( mpi_sub_int( &RHS, &RHS, 3 ) ); MOD_SUB( RHS );\n }\n else\n {\n MPI_CHK( mpi_add_mpi( &RHS, &RHS, &grp->A ) ); MOD_ADD( RHS );\n }\n\n MPI_CHK( mpi_mul_mpi( &RHS, &RHS, &pt->X ) ); MOD_MUL( RHS );\n MPI_CHK( mpi_add_mpi( &RHS, &RHS, &grp->B ) ); MOD_ADD( RHS );\n\n if( mpi_cmp_mpi( &YY, &RHS ) != 0 )\n ret = POLARSSL_ERR_ECP_INVALID_KEY;\n\ncleanup:\n\n mpi_free( &YY ); mpi_free( &RHS );\n\n return( ret );\n}", "label": 0, "cwe": null, "length": 440 }, { "index": 409546, "code": "create_column_info( const GncSqlColumnTableEntry* table_row, GncSqlBasicColumnType type,\ngint size, gboolean is_unicode )\n{\n GncSqlColumnInfo* info;\n\n info = g_new0( GncSqlColumnInfo, 1 );\n g_assert( info != NULL );\n info->name = g_strdup( table_row->col_name );\n info->type = type;\n info->size = size;\n info->is_primary_key = ((table_row->flags & COL_PKEY) != 0) ? TRUE : FALSE;\n info->null_allowed = ((table_row->flags & COL_NNUL) != 0) ? FALSE : TRUE;\n info->is_unicode = is_unicode;\n info->is_autoinc = ((table_row->flags & COL_AUTOINC) != 0) ? TRUE : FALSE;\n\n return info;\n}", "label": 0, "cwe": null, "length": 183 }, { "index": 717160, "code": "i2c_smbus_read_word_data(const struct i2c_client *client, u8 command)\n{\n\tunion i2c_smbus_data data;\n\tint status;\n\n\tstatus = i2c_smbus_xfer(client->adapter, client->addr, client->flags,\n\t\t\t\tI2C_SMBUS_READ, command,\n\t\t\t\tI2C_SMBUS_WORD_DATA, &data);\n\treturn (status < 0) ? status : data.word;\n}", "label": 0, "cwe": null, "length": 97 }, { "index": 236480, "code": "qat_uclo_map_ae(struct icp_qat_fw_loader_handle *handle, int max_ae)\n{\n\tint i, ae;\n\tint mflag = 0;\n\tstruct icp_qat_uclo_objhandle *obj_handle = handle->obj_handle;\n\n\tfor (ae = 0; ae <= max_ae; ae++) {\n\t\tif (!test_bit(ae,\n\t\t\t (unsigned long *)&handle->hal_handle->ae_mask))\n\t\t\tcontinue;\n\t\tfor (i = 0; i < obj_handle->uimage_num; i++) {\n\t\t\tif (!test_bit(ae, (unsigned long *)\n\t\t\t&obj_handle->ae_uimage[i].img_ptr->ae_assigned))\n\t\t\t\tcontinue;\n\t\t\tmflag = 1;\n\t\t\tif (qat_uclo_init_ae_data(obj_handle, ae, i))\n\t\t\t\treturn -EINVAL;\n\t\t}\n\t}\n\tif (!mflag) {\n\t\tpr_err(\"QAT: uimage uses AE not set\");\n\t\treturn -EINVAL;\n\t}\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 214 }, { "index": 619369, "code": "add_signal(int signal)\n{\n int ret = -1;\n\n if (n_sigs != SGE_MAXSIG) {\n char err_str[256];\n ret = 0;\n\n n_sigs++;\n sig_queue[free_sig] = signal;\n free_sig = NEXT_INDEX(free_sig);\n\n sprintf(err_str, \"queued signal %s\", sge_sys_sig2str(signal));\n shepherd_trace(err_str);\n } \n return ret;\n}", "label": 0, "cwe": null, "length": 98 }, { "index": 434446, "code": "bf_encode_base64(Var arglist, Byte next, void *vdata, Objid progr)\n{\n int len;\n size_t length;\n const char *in = binary_to_raw_bytes(arglist.v.list[1].v.str, &len);\n if (NULL == in) {\n\tfree_var(arglist);\n\treturn make_error_pack(E_INVARG);\n }\n char *out = base64_encode(in, (size_t)len, &length);\n if (NULL == out) { /* only happens if the encoder can't malloc */\n\tfree_var(arglist);\n\treturn make_error_pack(E_INVARG);\n }\n static Stream *s = 0;\n if (!s)\n\ts = new_stream(100);\n TRY_STREAM {\n\tstream_add_raw_bytes_to_binary(s, out, (int)length);\n }\n EXCEPT (stream_too_big) {\n\tfree_str(out);\n\tfree_var(arglist);\n\treturn make_space_pack();\n }\n ENDTRY_STREAM;\n Var ret;\n ret.type = TYPE_STR;\n ret.v.str = str_dup(reset_stream(s));\n free_str(out);\n free_var(arglist);\n return make_var_pack(ret);\n}", "label": 0, "cwe": null, "length": 246 }, { "index": 45705, "code": "xfs_ialloc_compute_maxlevels(\n\txfs_mount_t\t*mp)\t\t/* file system mount structure */\n{\n\tint\t\tlevel;\n\tuint\t\tmaxblocks;\n\tuint\t\tmaxleafents;\n\tint\t\tminleafrecs;\n\tint\t\tminnoderecs;\n\n\tmaxleafents = (1LL << XFS_INO_AGINO_BITS(mp)) >>\n\t\tXFS_INODES_PER_CHUNK_LOG;\n\tminleafrecs = mp->m_alloc_mnr[0];\n\tminnoderecs = mp->m_alloc_mnr[1];\n\tmaxblocks = (maxleafents + minleafrecs - 1) / minleafrecs;\n\tfor (level = 1; maxblocks > 1; level++)\n\t\tmaxblocks = (maxblocks + minnoderecs - 1) / minnoderecs;\n\tmp->m_in_maxlevels = level;\n}", "label": 0, "cwe": null, "length": 183 }, { "index": 252767, "code": "__bitmap_or(unsigned long *dst, const unsigned long *bitmap1,\n\t\t\t\tconst unsigned long *bitmap2, int bits)\n{\n\tint k;\n\tint nr = BITS_TO_LONGS(bits);\n\n\tfor (k = 0; k < nr; k++)\n\t\tdst[k] = bitmap1[k] | bitmap2[k];\n}", "label": 0, "cwe": null, "length": 68 }, { "index": 947945, "code": "ipmi_sel_print_event_file(struct ipmi_intf * intf, struct sel_event_record * evt, FILE * fp)\n{\n\tchar * description;\n\n\tif (fp == NULL)\n\t\treturn;\n\n\tipmi_get_event_desc(intf, evt, &description);\n\n\tfprintf(fp, \"0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x 0x%02x # %s #0x%02x %s\\n\",\n\t\tevt->sel_type.standard_type.evm_rev,\n\t\tevt->sel_type.standard_type.sensor_type,\n\t\tevt->sel_type.standard_type.sensor_num,\n\t\tevt->sel_type.standard_type.event_type | (evt->sel_type.standard_type.event_dir << 7),\n\t\tevt->sel_type.standard_type.event_data[0],\n\t\tevt->sel_type.standard_type.event_data[1],\n\t\tevt->sel_type.standard_type.event_data[2],\n ( \n\t\t\t(evt->sel_type.standard_type.sensor_type >=0xC0 && evt->sel_type.standard_type.sensor_type < 0xF0)\n\t\t\t? \n \t\tipmi_sel_get_oem_sensor_type_offset(ipmi_get_oem(intf),evt->sel_type.standard_type.sensor_type, evt->sel_type.standard_type.event_data[0])\n\t\t\t:\n\t\t\tipmi_sel_get_sensor_type_offset(evt->sel_type.standard_type.sensor_type, evt->sel_type.standard_type.event_data[0])\n ),\n\t\tevt->sel_type.standard_type.sensor_num,\n\t\t(description != NULL) ? description : \"Unknown\");\n\n\tif (description != NULL)\n\t\tfree(description);\n}", "label": 0, "cwe": null, "length": 348 }, { "index": 684383, "code": "sense() const\n{\n if ( lb_ == ub_ ) return 'E';\n else if ( lb_ == -COIN_DBL_MAX && ub_ == COIN_DBL_MAX ) return 'N';\n else if ( lb_ == -COIN_DBL_MAX ) return 'L';\n else if ( ub_ == COIN_DBL_MAX ) return 'G';\n else return 'R';\n}", "label": 0, "cwe": null, "length": 93 }, { "index": 609650, "code": "adt7316_show_DA_CD_Vref_bypass(struct device *dev,\n\t\tstruct device_attribute *attr,\n\t\tchar *buf)\n{\n\tstruct iio_dev *dev_info = dev_to_iio_dev(dev);\n\tstruct adt7316_chip_info *chip = iio_priv(dev_info);\n\n\tif ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)\n\t\treturn -EPERM;\n\n\treturn sprintf(buf, \"%d\\n\",\n\t\t!!(chip->dac_config & ADT7316_VREF_BYPASS_DAC_CD));\n}", "label": 1, "cwe": "CWE-120", "length": 113 }, { "index": 125373, "code": "unusedEdge() const\n{\n int e;\n\n for (e=0; e<3; e++) if (edge[e]==NULL) return e;\n\n cout << \"No unused edge found at\" << *this << '\\n';\n return -1;\n}", "label": 0, "cwe": null, "length": 57 }, { "index": 114376, "code": "print_dom_list(struct domain_list *list)\n{\nstruct\tdomain_list\t*next;\n\n while(list) {\n\tnext = list->next;\n\tif ( list->domain ) verb_printf(\"\\tDomain: %s\\n\", list->domain);\n\tlist = next;\n }\n}", "label": 0, "cwe": null, "length": 57 }, { "index": 336251, "code": "rc_stringlist_add(RC_STRINGLIST *list, const char *value)\n{\n\tRC_STRING *s = xmalloc(sizeof(*s));\n\n\ts->value = xstrdup(value);\n\tTAILQ_INSERT_TAIL(list, s, entries);\n\treturn s;\n}", "label": 0, "cwe": null, "length": 55 }, { "index": 27746, "code": "cityopt_callback(Widget w, XtPointer client_data,\n XtPointer call_data)\n{\n struct city_dialog *pdialog = (struct city_dialog *)client_data;\n struct city *pcity = pdialog->pcity;\n int i;\n\n if(cityopt_shell) {\n XtDestroyWidget(cityopt_shell);\n }\n cityopt_shell=create_cityopt_dialog(city_name(pcity));\n /* Doing this here makes the \"No\"'s centered consistently */\n for(i=0; iid;\n\n xaw_set_relative_position(pdialog->shell, cityopt_shell, 15, 15);\n XtPopup(cityopt_shell, XtGrabNone);\n}", "label": 0, "cwe": null, "length": 317 }, { "index": 118911, "code": "graphof(Agedge_t *e)\n{\n if (!e)\n return NULL;\n if (AGTYPE(e) == AGRAPH)\n\treturn (Agraph_t*)e; /* graph of protoedge is itself recast */\n return agraphof(agtail(e));\n}", "label": 0, "cwe": null, "length": 59 }, { "index": 579473, "code": "mode_attribute (MOID_T * p)\n{\n if (IS (p, REF_SYMBOL)) {\n return (REF_SYMBOL);\n } else if (IS (p, PROC_SYMBOL)) {\n return (PROC_SYMBOL);\n } else if (IS (p, UNION_SYMBOL)) {\n return (UNION_SYMBOL);\n } else if (p == MODE (INT)) {\n return (MODE_INT);\n } else if (p == MODE (LONG_INT)) {\n return (MODE_LONG_INT);\n } else if (p == MODE (LONGLONG_INT)) {\n return (MODE_LONGLONG_INT);\n } else if (p == MODE (REAL)) {\n return (MODE_REAL);\n } else if (p == MODE (LONG_REAL)) {\n return (MODE_LONG_REAL);\n } else if (p == MODE (LONGLONG_REAL)) {\n return (MODE_LONGLONG_REAL);\n } else if (p == MODE (COMPLEX)) {\n return (MODE_COMPLEX);\n } else if (p == MODE (LONG_COMPLEX)) {\n return (MODE_LONG_COMPLEX);\n } else if (p == MODE (LONGLONG_COMPLEX)) {\n return (MODE_LONGLONG_COMPLEX);\n } else if (p == MODE (BOOL)) {\n return (MODE_BOOL);\n } else if (p == MODE (CHAR)) {\n return (MODE_CHAR);\n } else if (p == MODE (BITS)) {\n return (MODE_BITS);\n } else if (p == MODE (LONG_BITS)) {\n return (MODE_LONG_BITS);\n } else if (p == MODE (LONGLONG_BITS)) {\n return (MODE_LONGLONG_BITS);\n } else if (p == MODE (BYTES)) {\n return (MODE_BYTES);\n } else if (p == MODE (LONG_BYTES)) {\n return (MODE_LONG_BYTES);\n } else if (p == MODE (FILE)) {\n return (MODE_FILE);\n } else if (p == MODE (FORMAT)) {\n return (MODE_FORMAT);\n } else if (p == MODE (PIPE)) {\n return (MODE_PIPE);\n } else if (p == MODE (SOUND)) {\n return (MODE_SOUND);\n } else {\n return (MODE_NO_CHECK);\n }\n}", "label": 0, "cwe": null, "length": 469 }, { "index": 505849, "code": "core_bound(ScmTreeCore *tc, ScmTreeCoreBoundOp op, int pop)\n{\n Node *root = ROOT(tc);\n if (root) {\n Node *n = (op == SCM_TREE_CORE_MIN)? leftmost(root) : rightmost(root);\n if (pop) {\n n = delete_node(tc, n);\n tc->num_entries--;\n }\n return n;\n } else {\n return NULL;\n }\n}", "label": 0, "cwe": null, "length": 97 }, { "index": 17380, "code": "getSyncOutSkipFactor(uint16_t& skipFactor)\n{\n\tCMT3LOG(\"L3: getSyncOutSkipFactor\\n\");\n\tCMT3EXITLOG;\n\n\tMessage snd(CMT_MID_REQSYNCOUTSETTINGS,1);\n\tMessage rcv;\n\n\tsnd.setBusId(CMT_BID_MASTER);\n\n\tsnd.setDataByte(CMT_PARAM_SYNCOUT_SKIPFACTOR);\n\tm_serial.writeMessage(&snd);\n\tm_lastResult = m_serial.waitForMessage(&rcv,CMT_MID_REQSYNCOUTSETTINGSACK,0,true);\n\tif (m_lastResult != XRV_OK)\n\t\treturn m_lastResult;\n\tif (m_logging)\n\t\tm_logFile.writeMessage(&rcv);\n\tHANDLE_ERR_RESULT;\n\tskipFactor = rcv.getDataShort(1);\n\n\treturn m_lastResult = XRV_OK;\n}", "label": 0, "cwe": null, "length": 163 }, { "index": 144014, "code": "treeTraceNode (const AjPTree thys, ajint num)\n{\n ajint ileft = 0;\n ajint iright = 0;\n ajint iup = 0;\n ajint idown = 0;\n const AjPTree p;\n\n ajDebug(\"node %d:%x '%S' '%S'\\n\",\n\t num, thys, thys->Name, treeFollowPath);\n\n for (p=thys;p->Up; p=p->Up)\n\tiup++;\n\n for (p=thys;p->Down; p=p->Down)\n\tidown++;\n\n for (p=thys;p->Left; p=p->Left)\n\tileft++;\n\n for (p=thys;p->Right; p=p->Right)\n\tileft++;\n\n ajDebug(\" Up: %8x %d\\n\", thys->Up, iup);\n ajDebug(\" Down: %8x %d\\n\", thys->Down, idown);\n ajDebug(\" Right: %8x %d\\n\", thys->Right, iright);\n ajDebug(\" Left: %8x %d\\n\", thys->Left, ileft);\n\n if (thys->Data)\n {\n\tif (thys->Down)\n\t ajDebug(\" (Down link %p and data %x %f)\\n\",\n\t\t thys->Down, thys->Data, *(double *)thys->Data);\n\telse\n\t ajDebug(\" End node data: %x %f\\n\",\n\t\t thys->Data, *(double *)thys->Data);\n }\n else if (!thys->Down)\n {\n\tajDebug(\" No data, no down link: ** broken node %x **\\n\", thys);\n }\n\n return;\n}", "label": 0, "cwe": null, "length": 387 }, { "index": 527763, "code": "symmetric_encryption_xfer(int csock, int s_in, int s_out) {\n\tchar tmp[100];\n\tchar *cipher, *keyfile, *q;\n\n\tif (! enc_str) {\n\t\treturn;\n\t}\n\tcipher = (char *) malloc(strlen(enc_str) + 100);\n\tq = strchr(enc_str, ':');\n\tif (!q) return;\n\t*q = '\\0';\n\tif (getenv(\"X11VNC_USE_ULTRADSM_IV\")) {\n\t\tsprintf(cipher, \"rev:%s\", enc_str);\n\t} else {\n\t\tsprintf(cipher, \"noultra:rev:%s\", enc_str);\n\t}\n\tkeyfile = strdup(q+1);\n\t*q = ':';\n\n\n\t/* TBD: s_in != s_out */\n\tif (s_out) {}\n\n\tsprintf(tmp, \"fd=%d,%d\", s_in, csock);\n\n\tenc_do(cipher, keyfile, \"-1\", tmp);\n}", "label": 0, "cwe": null, "length": 195 }, { "index": 501757, "code": "qobjatype(Object o, char *match)\n{\n switch (DXGetObjectClass(o)) { \n case CLASS_ARRAY:\n\tswitch (DXGetArrayClass((Array)o)) {\n\t case CLASS_ARRAY:\t return !strcmp(match, \"array\");\n\t case CLASS_REGULARARRAY: return !strcmp(match, \"regulararray\");\n\t case CLASS_PATHARRAY: return !strcmp(match, \"patharray\");\n\t case CLASS_PRODUCTARRAY: return !strcmp(match, \"productarray\");\n\t case CLASS_MESHARRAY: return !strcmp(match, \"mesharray\");\n\t case CLASS_CONSTANTARRAY: return !strcmp(match, \"constantarray\");\n\t default: \t\t return 0;\n\t}\n default: \t\t\t return 0;\n }\n /* notreached */\n}", "label": 0, "cwe": null, "length": 161 }, { "index": 212553, "code": "mark_addressable (tree x)\n{\n while (handled_component_p (x))\n x = TREE_OPERAND (x, 0);\n if (TREE_CODE (x) == MEM_REF\n && TREE_CODE (TREE_OPERAND (x, 0)) == ADDR_EXPR)\n x = TREE_OPERAND (TREE_OPERAND (x, 0), 0);\n if (TREE_CODE (x) != VAR_DECL\n && TREE_CODE (x) != PARM_DECL\n && TREE_CODE (x) != RESULT_DECL)\n return;\n TREE_ADDRESSABLE (x) = 1;\n}", "label": 0, "cwe": null, "length": 129 }, { "index": 240522, "code": "bgav_track_remove_video_stream(bgav_track_t * track, int stream)\n {\n /* Remove this stream from the subtitle streams as well */\n int i;\n for(i = 0; i < track->num_subtitle_streams; i++)\n {\n if(track->subtitle_streams[i].data.subtitle.video_stream ==\n &track->video_streams[stream])\n track->subtitle_streams[i].data.subtitle.video_stream = NULL;\n }\n \n remove_stream(track->video_streams, stream, track->num_video_streams);\n track->num_video_streams--;\n }", "label": 0, "cwe": null, "length": 118 }, { "index": 699926, "code": "usedActions() const\n\t{\n\t\tQSet result;\n\t\tint actionCount = mActionFactory->actionDefinitionCount();\n\t\tQStringList actions;\n\n\t\tfor(int actionIndex = 0; actionIndex < actionCount; ++actionIndex)\n\t\t\tactions << mActionFactory->actionDefinition(actionIndex)->id();\n\n\t\t//First add all the actions contained in the script, then search in all data fields that are in code mode\n\t\tforeach(ActionInstance *actionInstance, mActionInstances)\n\t\t{\n\t\t\tresult << actionInstance->definition()->index();\n\n\t\t\tconst ParametersData ¶metersData = actionInstance->parametersData();\n\t\t\tforeach(const Parameter ¶meter, parametersData)\n\t\t\t{\n\t\t\t\tforeach(const SubParameter &subParameter, parameter.subParameters())\n\t\t\t\t{\n\t\t\t\t\tif(subParameter.isCode())\n\t\t\t\t\t{\n\t\t\t\t\t\tconst QString &value = subParameter.value().toString();\n\n\t\t\t\t\t\tfor(int actionIdIndex = 0; actionIdIndex < actions.count(); ++actionIdIndex)\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tif(value.contains(actions.at(actionIdIndex)))\n\t\t\t\t\t\t\t\tresult << actionIdIndex;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn result;\n\t}", "label": 0, "cwe": null, "length": 245 }, { "index": 739894, "code": "fat_cache_merge(struct inode *inode,\n\t\t\t\t\t struct fat_cache_id *new)\n{\n\tstruct fat_cache *p;\n\n\tlist_for_each_entry(p, &MSDOS_I(inode)->cache_lru, cache_list) {\n\t\t/* Find the same part as \"new\" in cluster-chain. */\n\t\tif (p->fcluster == new->fcluster) {\n\t\t\tBUG_ON(p->dcluster != new->dcluster);\n\t\t\tif (new->nr_contig > p->nr_contig)\n\t\t\t\tp->nr_contig = new->nr_contig;\n\t\t\treturn p;\n\t\t}\n\t}\n\treturn NULL;\n}", "label": 0, "cwe": null, "length": 130 }, { "index": 11729, "code": "Load(std::FILE* in)\n{\n size_t start = std::ftell(in);\n size_t read = 0;\n \n read += std::fread(&m_coding, sizeof(m_coding), 1, in);\n read += std::fread(&m_numScoreComponent, sizeof(m_numScoreComponent), 1, in);\n read += std::fread(&m_containsAlignmentInfo, sizeof(m_containsAlignmentInfo), 1, in);\n read += std::fread(&m_maxRank, sizeof(m_maxRank), 1, in);\n read += std::fread(&m_maxPhraseLength, sizeof(m_maxPhraseLength), 1, in);\n \n if(m_coding == REnc)\n {\n m_sourceSymbols.load(in);\n \n size_t size;\n read += std::fread(&size, sizeof(size_t), 1, in);\n m_lexicalTableIndex.resize(size);\n read += std::fread(&m_lexicalTableIndex[0], sizeof(size_t), size, in);\n \n read += std::fread(&size, sizeof(size_t), 1, in);\n m_lexicalTable.resize(size);\n read += std::fread(&m_lexicalTable[0], sizeof(SrcTrg), size, in);\n }\n \n m_targetSymbols.load(in);\n \n m_symbolTree = new CanonicalHuffman(in);\n \n read += std::fread(&m_multipleScoreTrees, sizeof(m_multipleScoreTrees), 1, in);\n if(m_multipleScoreTrees)\n {\n m_scoreTrees.resize(m_numScoreComponent);\n for(size_t i = 0; i < m_numScoreComponent; i++)\n m_scoreTrees[i] = new CanonicalHuffman(in);\n }\n else\n {\n m_scoreTrees.resize(1);\n m_scoreTrees[0] = new CanonicalHuffman(in);\n }\n \n if(m_containsAlignmentInfo)\n m_alignTree = new CanonicalHuffman(in);\n \n size_t end = std::ftell(in);\n return end - start;\n}", "label": 0, "cwe": null, "length": 451 }, { "index": 56334, "code": "clutter_keyframe_transition_set_modes (ClutterKeyframeTransition *transition,\n guint n_modes,\n const ClutterAnimationMode *modes)\n{\n ClutterKeyframeTransitionPrivate *priv;\n guint i;\n\n g_return_if_fail (CLUTTER_IS_KEYFRAME_TRANSITION (transition));\n g_return_if_fail (n_modes > 0);\n g_return_if_fail (modes != NULL);\n\n priv = transition->priv;\n\n if (priv->frames == NULL)\n clutter_keyframe_transition_init_frames (transition, n_modes);\n else\n g_return_if_fail (n_modes == priv->frames->len - 1);\n\n for (i = 0; i < n_modes; i++)\n {\n KeyFrame *frame = &g_array_index (priv->frames, KeyFrame, i);\n\n frame->mode = modes[i];\n }\n}", "label": 1, "cwe": "CWE-476", "length": 185 }, { "index": 9678, "code": "qcaspi_set_ringparam(struct net_device *dev, struct ethtool_ringparam *ring)\n{\n\tstruct qcaspi *qca = netdev_priv(dev);\n\n\tif ((ring->rx_pending) ||\n\t (ring->rx_mini_pending) ||\n\t (ring->rx_jumbo_pending))\n\t\treturn -EINVAL;\n\n\tif (netif_running(dev))\n\t\tqcaspi_netdev_close(dev);\n\n\tqca->txr.count = max_t(u32, ring->tx_pending, TX_RING_MIN_LEN);\n\tqca->txr.count = min_t(u16, qca->txr.count, TX_RING_MAX_LEN);\n\n\tif (netif_running(dev))\n\t\tqcaspi_netdev_open(dev);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 150 }, { "index": 932350, "code": "undionly_shutdown ( int flags ) {\n\t/* If we are shutting down to boot an OS, clear the \"keep PXE\n\t * stack\" flag.\n\t */\n\tif ( flags & SHUTDOWN_BOOT )\n\t\tpreloaded_undi.flags &= ~UNDI_FL_KEEP_ALL;\n}", "label": 0, "cwe": null, "length": 60 }, { "index": 768022, "code": "fimc_m2m_enum_fmt_mplane(struct file *file, void *priv,\n\t\t\t\t struct v4l2_fmtdesc *f)\n{\n\tstruct fimc_fmt *fmt;\n\n\tfmt = fimc_find_format(NULL, NULL, get_m2m_fmt_flags(f->type),\n\t\t\t f->index);\n\tif (!fmt)\n\t\treturn -EINVAL;\n\n\tstrncpy(f->description, fmt->name, sizeof(f->description) - 1);\n\tf->pixelformat = fmt->fourcc;\n\treturn 0;\n}", "label": 1, "cwe": "CWE-120", "length": 109 }, { "index": 573790, "code": "calcolaStima(float input_avail,\n uint32& firstPublish,\n uint32 publishInterval,\n uint32 pubkRTK,\n bool sameIP,\n uint32 now) {\n\n\tfloat avail = input_avail;\n\n\t// int32 kRTK = theApp->rm->kadRepublishTimeK;\n\tint32 kRTK = theApp->get_kadRepublishTimeK();\n\n\t// Using this increment style, we can guess also if clients use different publish rates.\n\tfloat inc = (float) pubkRTK / kRTK;\n\t\n\t// Only old clients, with republishtimek == 24hrs don't publish their republishtimek.\n\tif (inc == (float) 0.0) {\n \t\tinc = HR2S(24) / kRTK;\t\n\t}\n\n\tif (publishInterval > kRTK) {\n\t\tavail = (float) 0.0;\n\t\tfirstPublish = now;\n\t}\n\n\twhile ( ((now-firstPublish) > kRTK) && \n\t (avail > (float) 2.0) ) {\n\t\tavail--;\n\t\tfirstPublish += ((uint32)(kRTK/avail));\n\t}\n\n\t// Some client seem to send duplicate publish to already contacted clients.\n\t// In 90% of the times we avoid this here.\n\tif (!sameIP) {\n\t\tavail += inc;\n\t}\n\n\treturn avail;\n}", "label": 0, "cwe": null, "length": 306 }, { "index": 117767, "code": "DrawInfos(\t\tbtSoftBody* psb,\n\t\t\t\t\t\t\t\t\t\t\t btIDebugDraw* idraw,\n\t\t\t\t\t\t\t\t\t\t\t bool masses,\n\t\t\t\t\t\t\t\t\t\t\t bool areas,\n\t\t\t\t\t\t\t\t\t\t\t bool /*stress*/)\n{\n\tfor(int i=0;im_nodes.size();++i)\n\t{\n\t\tconst btSoftBody::Node&\tn=psb->m_nodes[i];\n\t\tchar\t\t\t\t\ttext[2048]={0};\n\t\tchar\t\t\t\t\tbuff[1024];\n\t\tif(masses)\n\t\t{\n\t\t\tsprintf(buff,\" M(%.2f)\",1/n.m_im);\n\t\t\tstrcat(text,buff);\n\t\t}\n\t\tif(areas)\n\t\t{\n\t\t\tsprintf(buff,\" A(%.2f)\",n.m_area);\n\t\t\tstrcat(text,buff);\n\t\t}\n\t\tif(text[0]) idraw->draw3dText(n.m_x,text);\n\t}\n}", "label": 0, "cwe": null, "length": 173 }, { "index": 93199, "code": "unescape_path_component (gchar * comp)\n{\n guint len = strlen (comp);\n guint i;\n\n for (i = 0; i + 2 < len; i++)\n if (comp[i] == '%') {\n int a, b;\n\n a = hex_to_int (comp[i + 1]);\n b = hex_to_int (comp[i + 2]);\n\n /* The a||b check is to ensure that the byte is not '\\0' */\n if (a >= 0 && b >= 0 && (a || b)) {\n comp[i] = (gchar) (a * 16 + b);\n memmove (comp + i + 1, comp + i + 3, len - i - 3);\n len -= 2;\n comp[len] = '\\0';\n }\n }\n}", "label": 0, "cwe": null, "length": 182 }, { "index": 872705, "code": "mpl_num_set(mp_int *a, int *num)\n{\n unsigned int ix;\n int db, nset = 0;\n mp_digit cur;\n unsigned char reg;\n\n ARGCHK(a != NULL, MP_BADARG);\n\n for(ix = 0; ix < USED(a); ix++) {\n cur = DIGIT(a, ix);\n \n for(db = 0; db < sizeof(mp_digit); db++) {\n reg = (unsigned char)(cur >> (CHAR_BIT * db));\n\n nset += bitc[reg];\n }\n }\n\n if(num)\n *num = nset;\n\n return MP_OKAY;\n\n}", "label": 0, "cwe": null, "length": 141 }, { "index": 267496, "code": "phi1z (\n double eccent,\t/* Eccentricity angle in radians\t\t*/\n double qs,\t\t/* Angle in radians\t\t\t\t*/\n long *flag)\t/* Error flag number\t\t\t\t*/\n{\ndouble eccnts;\ndouble dphi;\ndouble con;\ndouble com;\ndouble sinpi;\ndouble cospi;\ndouble phi;\nlong i;\n\n phi = asinz(.5 * qs);\n if (eccent < EPSLN) \n return(phi);\n eccnts = eccent * eccent; \n for (i = 1; i <= 25; i++)\n {\n tsincos(phi,&sinpi,&cospi);\n con = eccent * sinpi; \n com = 1.0 - con * con;\n dphi = .5 * com * com / cospi * (qs / (1.0 - eccnts) - sinpi / com + \n .5 / eccent * log ((1.0 - con) / (1.0 + con)));\n phi = phi + dphi;\n if (fabs(dphi) <= 1e-7)\n return(phi);\n }\n p_error (\"Convergence error\",\"phi1z-conv\");\n *flag = 001;\n return(ERROR);\n}", "label": 0, "cwe": null, "length": 272 }, { "index": 424830, "code": "ath_close(struct hci_uart *hu)\n{\n\tstruct ath_struct *ath = hu->priv;\n\n\tBT_DBG(\"hu %p\", hu);\n\n\tskb_queue_purge(&ath->txq);\n\n\tkfree_skb(ath->rx_skb);\n\n\tcancel_work_sync(&ath->ctxtsw);\n\n\thu->priv = NULL;\n\tkfree(ath);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 75 }, { "index": 830761, "code": "btusb_recv_bulk(struct btusb_data *data, void *buffer, int count)\n{\n\tstruct sk_buff *skb;\n\tint err = 0;\n\n\tspin_lock(&data->rxlock);\n\tskb = data->acl_skb;\n\n\twhile (count) {\n\t\tint len;\n\n\t\tif (!skb) {\n\t\t\tskb = bt_skb_alloc(HCI_MAX_FRAME_SIZE, GFP_ATOMIC);\n\t\t\tif (!skb) {\n\t\t\t\terr = -ENOMEM;\n\t\t\t\tbreak;\n\t\t\t}\n\n\t\t\tbt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;\n\t\t\tbt_cb(skb)->expect = HCI_ACL_HDR_SIZE;\n\t\t}\n\n\t\tlen = min_t(uint, bt_cb(skb)->expect, count);\n\t\tmemcpy(skb_put(skb, len), buffer, len);\n\n\t\tcount -= len;\n\t\tbuffer += len;\n\t\tbt_cb(skb)->expect -= len;\n\n\t\tif (skb->len == HCI_ACL_HDR_SIZE) {\n\t\t\t__le16 dlen = hci_acl_hdr(skb)->dlen;\n\n\t\t\t/* Complete ACL header */\n\t\t\tbt_cb(skb)->expect = __le16_to_cpu(dlen);\n\n\t\t\tif (skb_tailroom(skb) < bt_cb(skb)->expect) {\n\t\t\t\tkfree_skb(skb);\n\t\t\t\tskb = NULL;\n\n\t\t\t\terr = -EILSEQ;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\tif (bt_cb(skb)->expect == 0) {\n\t\t\t/* Complete frame */\n\t\t\thci_recv_frame(data->hdev, skb);\n\t\t\tskb = NULL;\n\t\t}\n\t}\n\n\tdata->acl_skb = skb;\n\tspin_unlock(&data->rxlock);\n\n\treturn err;\n}", "label": 0, "cwe": null, "length": 328 }, { "index": 170968, "code": "testInputAudio(struct node *node)\n{\n\tstruct v4l2_input vinput;\n\tunsigned i = 0;\n\tint ret;\n\n\tif (node->audio_inputs && node->inputs == 0)\n\t\treturn fail(\"audio inputs found but no video inputs?!\\n\");\n\n\tfor (i = 0; i < node->inputs; i++) {\n\t\tret = doioctl(node, VIDIOC_S_INPUT, &i);\n\t\tif (ret)\n\t\t\treturn fail(\"could not select input %d\\n\", i);\n\t\tvinput.index = i;\n\t\tret = doioctl(node, VIDIOC_ENUMINPUT, &vinput);\n\t\tif (ret)\n\t\t\treturn fail(\"could not enumerate input %d\\n\", i);\n\t\tif (checkInputAudioSet(node, vinput.audioset))\n\t\t\treturn fail(\"invalid audioset for input %d\\n\", i);\n\t}\n\treturn node->audio_inputs ? 0 : ENOTTY;\n}", "label": 0, "cwe": null, "length": 196 }, { "index": 849689, "code": "PowPerm42 (\n Obj opL,\n Obj opR )\n{\n Obj cnj; /* handle of the conjugation (res) */\n UInt degC; /* degree of the conjugation */\n UInt4 * ptC; /* pointer to the conjugation */\n UInt degL; /* degree of the left operand */\n UInt4 * ptL; /* pointer to the left operand */\n UInt degR; /* degree of the right operand */\n UInt2 * ptR; /* pointer to the right operand */\n UInt p; /* loop variable */\n\n /* compute the size of the result and allocate a bag */\n degL = DEG_PERM4(opL);\n degR = DEG_PERM2(opR);\n degC = degL < degR ? degR : degL;\n cnj = NEW_PERM4( degC );\n\n /* set up the pointers */\n ptL = ADDR_PERM4(opL);\n ptR = ADDR_PERM2(opR);\n ptC = ADDR_PERM4(cnj);\n\n /* its faster if the both permutations have the same size */\n if ( degL == degR ) {\n for ( p = 0; p < degC; p++ )\n ptC[ ptR[p] ] = ptR[ ptL[p] ];\n }\n\n /* otherwise we have to use the macro 'IMAGE' three times */\n else {\n for ( p = 0; p < degC; p++ )\n ptC[ IMAGE(p,ptR,degR) ] = IMAGE( IMAGE(p,ptL,degL), ptR, degR );\n }\n\n /* return the result */\n return cnj;\n}", "label": 0, "cwe": null, "length": 391 }, { "index": 591045, "code": "static_raw_y0z1 (int cell_x, int cell_y, int cell_z,\nint shell, static_polytope *polytope)\n{\nint n, n_x, n_y, n_z;\nint k;\n\nn = polytope->n_cells;\n\n/*********************************************\n * find neighbours in cells along y0z1 edges *\n *********************************************/\n\nn_y = -shell + cell_y;\nif (n_y < 0 || n_y > n - 1) return;\n\nn_z = shell + cell_z;\nif (n_z < 0 || n_z > n - 1) return;\n\nfor (k = -shell + 1; k <= shell - 1; k++)\n {\n n_x = k + cell_x;\n if (n_x < 0 || n_x > n - 1) continue;\n\n if (static_inside_local (k, -shell, shell, polytope) == TRUE)\n static_neighbour_get (n_x, n_y, n_z, polytope);\n }\n}", "label": 0, "cwe": null, "length": 219 }, { "index": 19252, "code": "lkb_add_ordered(struct list_head *new, struct list_head *head,\n\t\t\t int mode)\n{\n\tstruct dlm_lkb *lkb = NULL;\n\n\tlist_for_each_entry(lkb, head, lkb_statequeue)\n\t\tif (lkb->lkb_rqmode < mode)\n\t\t\tbreak;\n\n\t__list_add(new, lkb->lkb_statequeue.prev, &lkb->lkb_statequeue);\n}", "label": 0, "cwe": null, "length": 88 }, { "index": 723058, "code": "print_paths(gs_main_instance * minst)\n{\n outprintf(minst->heap, \"%s\", help_paths);\n gs_main_set_lib_paths(minst);\n {\n uint count = r_size(&minst->lib_path.list);\n uint i;\n int pos = 100;\n char fsepr[3];\n\n fsepr[0] = ' ', fsepr[1] = gp_file_name_list_separator,\n fsepr[2] = 0;\n for (i = 0; i < count; ++i) {\n const ref *prdir =\n minst->lib_path.list.value.refs + i;\n uint len = r_size(prdir);\n const char *sepr = (i == count - 1 ? \"\" : fsepr);\n\n if (1 + pos + strlen(sepr) + len > 76)\n outprintf(minst->heap, \"\\n \"), pos = 2;\n outprintf(minst->heap, \" \");\n /*\n * This is really ugly, but it's necessary because some\n * platforms rely on all console output being funneled through\n * outprintf. We wish we could just do:\n fwrite(prdir->value.bytes, 1, len, minst->fstdout);\n */\n {\n const char *p = (const char *)prdir->value.bytes;\n uint j;\n\n for (j = len; j; j--)\n outprintf(minst->heap, \"%c\", *p++);\n }\n outprintf(minst->heap, \"%s\", sepr);\n pos += 1 + len + strlen(sepr);\n }\n }\n outprintf(minst->heap, \"\\n\");\n outprintf(minst->heap, \"%s\", help_fontconfig);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 382 }, { "index": 90020, "code": "go_style_finalize (GObject *obj)\n{\n\tGOStyle *style = GO_STYLE (obj);\n\n\tif (GO_STYLE_FILL_IMAGE == style->fill.type &&\n\t style->fill.image.image != NULL)\n\t\tg_object_unref (style->fill.image.image);\n\n\tif (style->font.font != NULL) {\n\t\tgo_font_unref (style->font.font);\n\t\tstyle->font.font = NULL;\n\t}\n\n\tif (style->marker.mark != NULL) {\n\t\tg_object_unref (style->marker.mark);\n\t\tstyle->marker.mark = NULL;\n\t}\n\n\t(parent_klass->finalize) (obj);\n}", "label": 0, "cwe": null, "length": 125 }, { "index": 23918, "code": "ghost_chasing (pacmangamestruct * pp, ghoststruct * g)\n{\n int posdirs[DIRVECS], nrdirs = 0, i, dir = 0, highest = -100000,\n thisvecx, thisvecy, thisvec;\n\n nrdirs = ghost_get_posdirs (pp, posdirs, g);\n#if 0\n g->ndirs = nrdirs;\n#endif\n for (i = 0; i < DIRVECS; i++)\n if (posdirs[i] == True)\n dir = i;\n\n if (nrdirs == 0)\n dir = (g->lastbox + 2) % DIRVECS;\n else if (nrdirs > 1)\n for (i = 0; i < DIRVECS; i++) {\n if (posdirs[i] == False)\n continue;\n thisvecx = (pp->pacman.col - g->col) * dirvecs[i].dx;\n thisvecy = (pp->pacman.row - g->row) * dirvecs[i].dy;\n thisvec = thisvecx + thisvecy;\n if (thisvec >= highest) {\n dir = i;\n highest = thisvec;\n }\n }\n\n g->nextrow = g->row + dirvecs[dir].dy;\n g->nextcol = g->col + dirvecs[dir].dx;\n g->lastbox = dir;\n}", "label": 0, "cwe": null, "length": 310 }, { "index": 217538, "code": "void_buffer(CRESULT *_object)\n{\n\tint i;\n\n\t//fprintf(stderr, \"void_buffer\\n\");\n\n\tif (THIS->info.nfield == 0)\n\t\treturn;\n\n\tfor (i = 0; i < THIS->info.nfield; i++)\n\t\tGB.StoreVariant(NULL, &THIS->buffer[i]);\n\t\t\n\tBARRAY_clear_all(THIS->changed, THIS->info.nfield);\n}", "label": 0, "cwe": null, "length": 83 }, { "index": 841189, "code": "_nrrdResampleLineFillUpdate(NrrdResampleContext *rsmc) {\n unsigned int axIdx;\n NrrdResampleAxis *axis;\n nrrdResample_t *line;\n\n if (rsmc->flag[flagPadValue]\n || rsmc->flag[flagLineAllocate]) {\n\n for (axIdx=0; axIdxdim; axIdx++) {\n axis = rsmc->axis + axIdx;\n if (axis->kernel) {\n line = (nrrdResample_t*)(axis->nline->data);\n line[axis->sizeIn] = AIR_CAST(nrrdResample_t, rsmc->padValue);\n }\n }\n\n rsmc->flag[flagPadValue] = AIR_FALSE;\n rsmc->flag[flagLineAllocate] = AIR_FALSE;\n rsmc->flag[flagLineFill] = AIR_TRUE;\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 212 }, { "index": 545660, "code": "test_meet_array(void)\n{\n printf(\"\\nmeet array %s\\n\",num_incomplete ? \"\" : \"(* expected)\");\n LOOP {\n int i, dim = 6;\n oct_t* o[NB_MEET], *oo;\n ap_abstract0_t* p[NB_MEET], *pp, *ppp;\n for (i=0;iinterface, \"free\");\n\tkfree(dev->name);\n\tkfree(dev->buf);\n\tkfree(dev);\n}", "label": 0, "cwe": null, "length": 36 }, { "index": 321878, "code": "draw_line(float x1, float y1, float x2, float y2, Uint32 color, int width)\n{\n\tfloat rr, gg, bb;\n\trr = (color & 0xff0000) >> 16;\n\tgg = (color & 0xff00) >> 8;\n\tbb = color & 0xff;\n\n\tif (!use_open_gl) {\n\t\tdraw_line_sdl(Screen, x1, y1, x2, y2, rr, gg, bb, width);\n\t} else {\n\t\tdraw_line_opengl(x1, y1, x2, y2, rr, gg, bb, width);\n\t}\n}", "label": 0, "cwe": null, "length": 140 }, { "index": 465359, "code": "firstIslamicStartYearFromGrego(int32_t year) {\n // ad hoc conversion, improve under #10752\n // rough est for now, ok for grego 1846-2138,\n // otherwise occasionally wrong (for 3% of years)\n int cycle, offset, shift = 0;\n if (year >= 1977) {\n cycle = (year - 1977) / 65;\n offset = (year - 1977) % 65;\n shift = 2*cycle + ((offset >= 32)? 1: 0);\n } else {\n cycle = (year - 1976) / 65 - 1;\n offset = -(year - 1976) % 65;\n shift = 2*cycle + ((offset <= 32)? 1: 0);\n }\n return year - 579 + shift;\n}", "label": 0, "cwe": null, "length": 193 }, { "index": 489780, "code": "kdbMount(KDB *handle, const Key *mountpoint, const KeySet *config)\n{\n\tchar *mountpoint_slash;\n\tconst char *key_name;\n\tconst char *backend;\n\tsize_t size;\n\tKDB *h;\n\tTrie *trie;\n\tKeySet *c;\n\n\tkey_name=keyName(mountpoint);\n\tbackend=keyValue(mountpoint);\n\n\tsize = kdbiStrLen(key_name);\n\tmountpoint_slash = malloc (size + 1);\n\tstrcpy (mountpoint_slash, key_name);\n\tmountpoint_slash [size-1] = '/';\n\tmountpoint_slash [size] = 0;\n\n\th=kdbOpenBackend(backend,mountpoint_slash,c=ksDup(config));\n\tif (!h) {\n\t\tfree(mountpoint_slash);\n\t\tksDel(c);\n\t\treturn -1;\n\t}\n\ttrie=insert_trie(kdbhGetTrie(handle), mountpoint_slash, h);\n\tkdbhSetTrie(handle,trie);\n\n\tfree(mountpoint_slash);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 217 }, { "index": 544804, "code": "traverse(tree, table, bit, count, direction)\n struct tree *tree;\n struct table *table;\n int *bit;\n unsigned count;\n int direction;\n{\n if(tree) {\n bit[count++]=direction;\n\n if(leaf(tree)) {\n unsigned i;\n\n for(i=0U; ich].bit[i]=bit[i];\n (table+1)[tree->ch].size=count;\n } else {\n traverse(tree->node[0], table, bit, count, 0);\n traverse(tree->node[1], table, bit, count, 1);\n }\n }\n}", "label": 0, "cwe": null, "length": 145 }, { "index": 256196, "code": "processKey(const Curses::Key &key)\n{\n\tif (GlobalKeys::processKey(key, currentScreen, NULL))\n\t\treturn true;\n\n\tvector &keyVector=getKeyVector();\n\tvector::iterator b, e;\n\n\tb=keyVector.begin();\n\te=keyVector.end();\n\n\twhile (b != e)\n\t{\n\t\tif (key == *b->shortcutKey)\n\t\t{\n\t\t\tvector *>::iterator\n\t\t\t\tib=buttons.begin(), ie=buttons.end();\n\n\t\t\twhile (ib != ie)\n\t\t\t{\n\t\t\t\tif ( (*ib)->getObject()->menuName ==\n\t\t\t\t b->menuEntry->menuName)\n\t\t\t\t{\n\t\t\t\t\t(*ib)->requestFocus();\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\t++ib;\n\t\t\t}\n\t\t\tb->menuEntry->action->go();\n\t\t\treturn true;\n\t\t}\n\n\t\t++b;\n\t}\n\n\treturn false;\n}", "label": 0, "cwe": null, "length": 192 }, { "index": 59836, "code": "setSelection(pos_type beg, pos_type end) const\n{\n\tif (pos_ >= beg && pos_ <= end)\n\t\tsel_beg = pos_;\n\telse if (beg > pos_ && beg <= end_)\n\t\tsel_beg = beg;\n\telse\n\t\tsel_beg = -1;\n\n\tif (end_ >= beg && end_ <= end)\n\t\tsel_end = end_;\n\telse if (end < end_ && end >= pos_)\n\t\tsel_end = end;\n\telse\n\t\tsel_end = -1;\n}", "label": 0, "cwe": null, "length": 111 }, { "index": 57625, "code": "string_index_of_nth_char (const gchar* self, glong c) {\n\tgint result = 0;\n\tglong _tmp0_ = 0L;\n\tgchar* _tmp1_ = NULL;\n\tg_return_val_if_fail (self != NULL, 0);\n\t_tmp0_ = c;\n\t_tmp1_ = g_utf8_offset_to_pointer (self, _tmp0_);\n\tresult = (gint) (_tmp1_ - ((gchar*) self));\n\treturn result;\n}", "label": 0, "cwe": null, "length": 104 }, { "index": 198145, "code": "setMisspelledColor(const QColor& color)\n{\n\tif (m_misspelled != color) {\n\t\tm_misspelled = color;\n\t\tif (m_enabled) {\n\t\t\trehighlight();\n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 49 }, { "index": 882453, "code": "mono_image_get_generic_field_token (MonoDynamicImage *assembly, MonoReflectionFieldBuilder *fb)\n{\n\tMonoDynamicTable *table;\n\tMonoType *custom = NULL, *type;\n\tguint32 *values;\n\tguint32 token, pclass, parent, sig;\n\tgchar *name;\n\n\ttoken = GPOINTER_TO_UINT (mono_g_hash_table_lookup (assembly->handleref_managed, fb));\n\tif (token)\n\t\treturn token;\n\n\t/* FIXME: is this call necessary? */\n\tmono_class_from_mono_type (mono_reflection_type_get_handle (fb->typeb));\n\tname = mono_string_to_utf8 (fb->name);\n\n\t/*FIXME this is one more layer of ugliness due how types are created.*/\n\tinit_type_builder_generics (fb->type);\n\n\t/* fb->type does not include the custom modifiers */\n\t/* FIXME: We should do this in one place when a fieldbuilder is created */\n\ttype = mono_reflection_type_get_handle ((MonoReflectionType*)fb->type);\n\tif (fb->modreq || fb->modopt)\n\t\ttype = custom = add_custom_modifiers (assembly, type, fb->modreq, fb->modopt);\n\n\tsig = fieldref_encode_signature (assembly, NULL, type);\n\tg_free (custom);\n\n\tparent = create_generic_typespec (assembly, (MonoReflectionTypeBuilder *) fb->typeb);\n\tg_assert ((parent & MONO_TYPEDEFORREF_MASK) == MONO_TYPEDEFORREF_TYPESPEC);\n\t\n\tpclass = MONO_MEMBERREF_PARENT_TYPESPEC;\n\tparent >>= MONO_TYPEDEFORREF_BITS;\n\n\ttable = &assembly->tables [MONO_TABLE_MEMBERREF];\n\n\tif (assembly->save) {\n\t\talloc_table (table, table->rows + 1);\n\t\tvalues = table->values + table->next_idx * MONO_MEMBERREF_SIZE;\n\t\tvalues [MONO_MEMBERREF_CLASS] = pclass | (parent << MONO_MEMBERREF_PARENT_BITS);\n\t\tvalues [MONO_MEMBERREF_NAME] = string_heap_insert (&assembly->sheap, name);\n\t\tvalues [MONO_MEMBERREF_SIGNATURE] = sig;\n\t}\n\n\ttoken = MONO_TOKEN_MEMBER_REF | table->next_idx;\n\ttable->next_idx ++;\n\tmono_g_hash_table_insert (assembly->handleref_managed, fb, GUINT_TO_POINTER(token));\n\tg_free (name);\n\treturn token;\n}", "label": 0, "cwe": null, "length": 482 }, { "index": 873370, "code": "UArray_multiplyScalarDouble_(UArray *self, double value)\n{\n\tUARRAY_FOREACHASSIGN(self, i, v, v * value);\n}", "label": 0, "cwe": null, "length": 32 }, { "index": 440295, "code": "reqtimeout_after_headers(request_rec *r)\n{\n reqtimeout_srv_cfg *cfg;\n reqtimeout_con_cfg *ccfg =\n ap_get_module_config(r->connection->conn_config, &reqtimeout_module);\n\n if (ccfg == NULL || r->method_number == M_CONNECT) {\n /* either disabled for this connection or a CONNECT request */\n return OK;\n }\n cfg = ap_get_module_config(r->connection->base_server->module_config,\n &reqtimeout_module);\n AP_DEBUG_ASSERT(cfg != NULL);\n\n ccfg->timeout_at = 0;\n ccfg->max_timeout_at = 0;\n ccfg->type = \"body\";\n if (cfg->body_timeout != UNSET) {\n ccfg->new_timeout = cfg->body_timeout;\n ccfg->new_max_timeout = cfg->body_max_timeout;\n ccfg->min_rate = cfg->body_min_rate;\n ccfg->rate_factor = cfg->body_rate_factor;\n }\n else {\n ccfg->new_timeout = MRT_DEFAULT_BODY_TIMEOUT;\n ccfg->new_max_timeout = MRT_DEFAULT_BODY_MAX_TIMEOUT;\n ccfg->min_rate = MRT_DEFAULT_BODY_MIN_RATE;\n ccfg->rate_factor = default_body_rate_factor;\n }\n return OK;\n}", "label": 0, "cwe": null, "length": 277 }, { "index": 795555, "code": "bool_repr(PyObject *self)\n{\n PyObject *s;\n\n if (self == Py_True)\n s = true_str ? true_str :\n (true_str = PyUnicode_InternFromString(\"True\"));\n else\n s = false_str ? false_str :\n (false_str = PyUnicode_InternFromString(\"False\"));\n Py_XINCREF(s);\n return s;\n}", "label": 0, "cwe": null, "length": 80 }, { "index": 485325, "code": "myiodisc_memiofread(void *chan, char *buf, int bufsize)\n{\n const char *ptr;\n char *optr;\n char c;\n int l;\n rdr_t *s;\n\n if (bufsize == 0) return 0;\n s = (rdr_t *) chan;\n if (s->cur >= s->len)\n return 0;\n l = 0;\n ptr = s->data + s->cur;\n optr = buf;\n do {\n *optr++ = c = *ptr++;\n l++;\n } while (c && (c != '\\n') && (l < bufsize));\n s->cur += l;\n return l;\n}", "label": 0, "cwe": null, "length": 155 }, { "index": 799854, "code": "Init(const char *textForm) {\n\tClear();\n\t// Test done is two parts to avoid possibility of overstepping the memory\n\t// if memcmp implemented strangely. Must be 4 bytes at least at destination.\n\tif ((0 == memcmp(textForm, \"/* X\", 4)) && (0 == memcmp(textForm, \"/* XPM */\", 9))) {\n\t\t// Build the lines form out of the text form\n\t\tstd::vector linesForm = LinesFormFromTextForm(textForm);\n\t\tif (!linesForm.empty()) {\n\t\t\tInit(&linesForm[0]);\n\t\t}\n\t} else {\n\t\t// It is really in line form\n\t\tInit(reinterpret_cast(textForm));\n\t}\n}", "label": 0, "cwe": null, "length": 158 }, { "index": 84268, "code": "msgno_part_deleted(MAILSTREAM *stream, long int rawno, char *part)\n{\n char *p;\n int expbits;\n\n /*\n * Is this attachment or any of it's parents in the\n * MIME structure marked for deletion?\n */\n for(p = part; p && *p; p = strindex(++p, '.')){\n\tif(*p == '.')\n\t *p = '\\0';\n\n\t(void) msgno_exceptions(stream, rawno, part, &expbits, FALSE);\n\tif(!*p)\n\t *p = '.';\n\n\tif(expbits & MSG_EX_DELETE)\n\t return(TRUE);\n }\n\n /* Finally, check if the whole message body's deleted */\n return(msgno_exceptions(stream, rawno, \"\", &expbits, FALSE)\n\t ? (expbits & MSG_EX_DELETE) : FALSE);\n}", "label": 0, "cwe": null, "length": 179 }, { "index": 413807, "code": "rb_home_dir(const char *user, VALUE result)\n{\n const char *dir;\n char *buf;\n#if defined DOSISH || defined __CYGWIN__\n char *p, *bend;\n#endif\n long dirlen;\n rb_encoding *enc;\n\n if (!user || !*user) {\n\tif (!(dir = getenv(\"HOME\"))) {\n\t rb_raise(rb_eArgError, \"couldn't find HOME environment -- expanding `~'\");\n\t}\n\tdirlen = strlen(dir);\n\trb_str_resize(result, dirlen);\n\tmemcpy(buf = RSTRING_PTR(result), dir, dirlen);\n }\n else {\n#ifdef HAVE_PWD_H\n\tstruct passwd *pwPtr = getpwnam(user);\n\tif (!pwPtr) {\n\t endpwent();\n\t rb_raise(rb_eArgError, \"user %s doesn't exist\", user);\n\t}\n\tdirlen = strlen(pwPtr->pw_dir);\n\trb_str_resize(result, dirlen);\n\tmemcpy(buf = RSTRING_PTR(result), pwPtr->pw_dir, dirlen + 1);\n\tendpwent();\n#else\n\treturn Qnil;\n#endif\n }\n enc = rb_filesystem_encoding();\n rb_enc_associate(result, enc);\n#if defined DOSISH || defined __CYGWIN__\n for (bend = (p = buf) + dirlen; p < bend; Inc(p, bend, enc)) {\n\tif (*p == '\\\\') {\n\t *p = '/';\n\t}\n }\n#endif\n return result;\n}", "label": 1, "cwe": [ "CWE-120", "CWE-other" ], "length": 317 }, { "index": 535799, "code": "increment_turn(void)\n{\n int i;\n\n compute_seen();\n\n newlife_flag=0;\n\n if (quitflag) return;\n\n newroom();\n\n if (winflag || deadflag || endflag) return;\n\n if (was_metaverb) return; /* No time should pass during a metaverb. */\n\n turncnt++;\n /* Now increment the time counter */\n if (delta_time>0) {\n if (PURE_TIME) \n add_time(agt_rand(min_delta(),delta_time)); \n else /* if !PURE_TIME */\n add_time(delta_time);\n }\n\n for(i=0;i<=CNT_NUM;i++)\n if (agt_counter[i]>=0) ++agt_counter[i];\n creatloop(i)\n if (creature[i].location==loc+first_room && creature[i].hostile &&\n\tcreature[i].timethresh>0) \n { \n\tparse_rec tmpcreat; /* Used for creature messages */\n\tmake_parserec(i+first_creat,&tmpcreat); \n\tcurr_creat_rec=&tmpcreat;\n\n\tif (++creature[i].timecounter>=creature[i].timethresh)\n\t { /* Creature attacks */\n\t sysmsg(16,\"$The_c$$c_name$ suddenly attacks $you_obj$!\");\n\t sysmsg(creature[i].gender==0 ? 17 : 18,\n\t\t \" $You$ try to defend $your$self, but $the_c$$c_name$ \"\n\t\t \"kills $you_obj$ anyhow.\");\n\t deadflag=1;\n\t }\n\telse /* 'Angrier' messages */\n\t if (creature[i].timethresh>0 && \n\t creature[i].timecounter>creature[i].timethresh-3)\n\t sysmsg(15,\"$The_c$$c_name$ seems to be getting angrier.\");\n }\n}", "label": 1, "cwe": "CWE-other", "length": 382 }, { "index": 636218, "code": "netsnmp_data_list_add_node(netsnmp_data_list **head, netsnmp_data_list *node)\n{\n netsnmp_data_list *ptr;\n\n netsnmp_assert(NULL != head);\n netsnmp_assert(NULL != node);\n netsnmp_assert(NULL != node->name);\n\n DEBUGMSGTL((\"data_list\",\"adding key '%s'\\n\", node->name));\n\n if (!*head) {\n *head = node;\n return;\n }\n\n if (0 == strcmp(node->name, (*head)->name)) {\n netsnmp_assert(!\"list key == is unique\"); /* always fail */\n snmp_log(LOG_WARNING,\n \"WARNING: adding duplicate key '%s' to data list\\n\",\n node->name);\n }\n\n for (ptr = *head; ptr->next != NULL; ptr = ptr->next) {\n netsnmp_assert(NULL != ptr->name);\n if (0 == strcmp(node->name, ptr->name)) {\n netsnmp_assert(!\"list key == is unique\"); /* always fail */\n snmp_log(LOG_WARNING,\n \"WARNING: adding duplicate key '%s' to data list\\n\",\n node->name);\n }\n }\n\n netsnmp_assert(NULL != ptr);\n if (ptr) /* should always be true */\n ptr->next = node;\n}", "label": 1, "cwe": [ "CWE-476", "CWE-other" ], "length": 287 }, { "index": 553233, "code": "JNI_CallNonvirtualVoidMethodA(JNIEnv *env, jobject this, jclass clazz, jmethodID methodID, uint64_t *args)\n{\n\tenter_vm_from_jni();\n\n\tif (transform_method_for_nonvirtual_call(this, clazz, &methodID))\n\t\treturn; /* rethrow */\n\n\tunsigned long packed_args[methodID->args_count];\n\n\tpacked_args[0] = (unsigned long) this;\n\tpack_args(methodID, packed_args + 1, args);\n\n\tvm_call_method_this_a(methodID, this, packed_args, NULL);\n}", "label": 0, "cwe": null, "length": 114 }, { "index": 950868, "code": "vl_rand_permute_indexes (VlRand *self, vl_index *array, vl_size size)\n{\n vl_index i, j, tmp;\n for (i = size - 1 ; i > 0; i--) {\n /* Pick a random index j in the range 0, i + 1 and swap it with i */\n j = (vl_int) vl_rand_uindex (self, i + 1) ;\n tmp = array[i] ; array[i] = array[j] ; array[j] = tmp ;\n }\n}", "label": 0, "cwe": null, "length": 117 }, { "index": 4686, "code": "gal_a11y_e_cell_action_do_action (AtkAction *action,\n gint index)\n{\n\tGalA11yECell *cell = GAL_A11Y_E_CELL (action);\n\tActionInfo *info = _gal_a11y_e_cell_get_action_info (cell, index);\n\n\tif (!is_valid (ATK_OBJECT (action)))\n\t\treturn FALSE;\n\n\tif (info == NULL)\n\t\treturn FALSE;\n\tg_return_val_if_fail (info->do_action_func, FALSE);\n\tif (cell->action_idle_handler)\n\t\treturn FALSE;\n\tcell->action_func = info->do_action_func;\n\tg_object_ref (cell);\n\tcell->action_idle_handler = g_idle_add (idle_do_action, cell);\n\n\treturn TRUE;\n}", "label": 0, "cwe": null, "length": 149 }, { "index": 940148, "code": "OnMouseWheelBackward()\n{\n this->FindPokedRenderer(\n this->Interactor->GetEventPosition()[0], \n this->Interactor->GetEventPosition()[1]);\n vtkCamera* camera = this->CurrentRenderer->GetActiveCamera();\n if (!camera)\n {\n return;\n }\n this->Interaction = ZOOMING;\n this->Superclass::OnMouseWheelBackward();\n this->Interaction = NONE;\n}", "label": 0, "cwe": null, "length": 97 }, { "index": 548870, "code": "stroke(GfxState *state) {\n SplashPath *path;\n\n if (state->getStrokeColorSpace()->isNonMarking()) {\n return;\n }\n path = convertPath(state, state->getPath());\n splash->stroke(path);\n delete path;\n}", "label": 0, "cwe": null, "length": 58 }, { "index": 105450, "code": "connect(const CASocketAddr & psa,UINT32 retry,UINT32 time)\n\t{\n//\t\tCAMsg::printMsg(LOG_DEBUG,\"Socket:connect\\n\");\n\t\tif(m_bSocketIsClosed&&create()!=E_SUCCESS)\n\t\t\t{\n\t\t\t\treturn E_UNKNOWN;\n\t\t\t}\n#ifdef _DEBUG\n\t\tsockets++;\n#endif\n\t\tint err=0;\n\t\tconst SOCKADDR* addr=psa.LPSOCKADDR();\n\t\tint addr_len=psa.getSize();\n\t\tfor(UINT32 i=0;iLen)\n return ret;\n\n cp = str->Ptr;\n\n while (*cp)\n {\n ret[tolower((int)*cp)] = 1;\n ret[toupper((int)*cp++)] = 1;\n }\n\n return ret;\n}", "label": 0, "cwe": null, "length": 101 }, { "index": 447705, "code": "checkAdd(const PatPile * pile, const QList & oldCards, const QList & newCards) const\n{\n if ( pile->pileRole() == PatPile::Tableau )\n {\n return oldCards.isEmpty()\n || newCards.first()->rank() == oldCards.last()->rank() - 1;\n }\n else\n {\n return oldCards.last()->suit() == newCards.first()->suit()\n && ( newCards.first()->rank() == oldCards.last()->rank() + 1\n || ( oldCards.last()->rank() == KCardDeck::King\n && newCards.first()->rank() == KCardDeck::Ace ) );\n }\n}", "label": 0, "cwe": null, "length": 151 }, { "index": 27824, "code": "ConvertInstTo3Addr(MachineBasicBlock::iterator &mi,\n MachineBasicBlock::iterator &nmi,\n MachineFunction::iterator &mbbi,\n unsigned RegB, unsigned Dist) {\n MachineInstr *NewMI = TII->convertToThreeAddress(mbbi, mi, LV);\n if (NewMI) {\n DEBUG(dbgs() << \"2addr: CONVERTING 2-ADDR: \" << *mi);\n DEBUG(dbgs() << \"2addr: TO 3-ADDR: \" << *NewMI);\n bool Sunk = false;\n\n if (NewMI->findRegisterUseOperand(RegB, false, TRI))\n // FIXME: Temporary workaround. If the new instruction doesn't\n // uses RegB, convertToThreeAddress must have created more\n // then one instruction.\n Sunk = Sink3AddrInstruction(mbbi, NewMI, RegB, mi);\n\n mbbi->erase(mi); // Nuke the old inst.\n\n if (!Sunk) {\n DistanceMap.insert(std::make_pair(NewMI, Dist));\n mi = NewMI;\n nmi = llvm::next(mi);\n }\n return true;\n }\n\n return false;\n}", "label": 0, "cwe": null, "length": 260 }, { "index": 269355, "code": "isImmutable(const QString &name) const\n{\n KConfigSkeletonItem *item = findItem(name);\n return !item || item->isImmutable();\n}", "label": 0, "cwe": null, "length": 34 }, { "index": 20310, "code": "print_fs(filesystem *fs)\n{\n\tuint32 i;\n\tuint8 *ibm;\n\n\tprintf(\"%d blocks (%d free, %d reserved), first data block: %d\\n\",\n\t fs->sb.s_blocks_count, fs->sb.s_free_blocks_count,\n\t fs->sb.s_r_blocks_count, fs->sb.s_first_data_block);\n\tprintf(\"%d inodes (%d free)\\n\", fs->sb.s_inodes_count,\n\t fs->sb.s_free_inodes_count);\n\tprintf(\"block size = %d, frag size = %d\\n\",\n\t fs->sb.s_log_block_size ? (fs->sb.s_log_block_size << 11) : 1024,\n\t fs->sb.s_log_frag_size ? (fs->sb.s_log_frag_size << 11) : 1024);\n\tprintf(\"number of groups: %d\\n\",GRP_NBGROUPS(fs));\n\tprintf(\"%d blocks per group,%d frags per group,%d inodes per group\\n\",\n\t fs->sb.s_blocks_per_group, fs->sb.s_frags_per_group,\n\t fs->sb.s_inodes_per_group);\n\tprintf(\"Size of inode table: %d blocks\\n\",\n\t\t(int)(fs->sb.s_inodes_per_group * sizeof(inode) / BLOCKSIZE));\n\tfor (i = 0; i < GRP_NBGROUPS(fs); i++) {\n\t\tprintf(\"Group No: %d\\n\", i+1);\n\t\tprintf(\"block bitmap: block %d,inode bitmap: block %d, inode table: block %d\\n\",\n\t\t get_gd(fs, i)->bg_block_bitmap,\n\t\t get_gd(fs, i)->bg_inode_bitmap,\n\t\t get_gd(fs, i)->bg_inode_table);\n\t\tprintf(\"block bitmap allocation:\\n\");\n\t\tprint_bm(GRP_GET_GROUP_BBM(fs, i),fs->sb.s_blocks_per_group);\n\t\tprintf(\"inode bitmap allocation:\\n\");\n\t\tibm = GRP_GET_GROUP_IBM(fs, i);\n\t\tprint_bm(ibm, fs->sb.s_inodes_per_group);\n\t\tfor (i = 1; i <= fs->sb.s_inodes_per_group; i++)\n\t\t\tif (allocated(ibm, i))\n\t\t\t\tprint_inode(fs, i);\n\t}\n}", "label": 0, "cwe": null, "length": 468 }, { "index": 826882, "code": "isNull() const\n{\n return lineEdit()->text() == d->m_nullString;\n}", "label": 0, "cwe": null, "length": 21 }, { "index": 121483, "code": "startReadFromGps() {\n if (Log::enabledDbg()) Log::dbg(\"Starting thread to read gpx from garmin device: \"+this->displayName);\n\n this->workType = READFROMGPS;\n this->threadState = 1;\n\n if (startThread()) {\n return 1;\n }\n\n return 0;\n}", "label": 0, "cwe": null, "length": 76 }, { "index": 443763, "code": "store_serialno (const char *line)\n{\n const char *s;\n char *p;\n\n for (s=line; hexdigitp (s); s++)\n ;\n p = xmalloc (s + 1 - line);\n memcpy (p, line, s-line);\n p[s-line] = 0;\n return p;\n}", "label": 0, "cwe": null, "length": 75 }, { "index": 324864, "code": "param_array_get(char *buffer, const struct kernel_param *kp)\n{\n\tint i, off, ret;\n\tconst struct kparam_array *arr = kp->arr;\n\tstruct kernel_param p = *kp;\n\n\tfor (i = off = 0; i < (arr->num ? *arr->num : arr->max); i++) {\n\t\tif (i)\n\t\t\tbuffer[off++] = ',';\n\t\tp.arg = arr->elem + arr->elemsize * i;\n\t\tcheck_kparam_locked(p.mod);\n\t\tret = arr->ops->get(buffer + off, &p);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t\toff += ret;\n\t}\n\tbuffer[off] = '\\0';\n\treturn off;\n}", "label": 0, "cwe": null, "length": 154 }, { "index": 974574, "code": "_priv_gst_pad_invalidate_cache (GstPad * pad)\n{\n GstPadPushCache *cache;\n gpointer *cache_ptr;\n\n GST_LOG_OBJECT (pad, \"Invalidating pad cache\");\n\n /* we hold the pad lock here so we can get the peer and it stays\n * alive during this call */\n if (GST_PAD_IS_SINK (pad)) {\n if (!(pad = GST_PAD_PEER (pad)))\n return;\n }\n\n cache_ptr = (gpointer *) & pad->abidata.ABI.priv->cache_ptr;\n\n /* try to get the cached data */\n do {\n cache = g_atomic_pointer_get (cache_ptr);\n /* now try to replace the pointer with INVALID. If nothing is busy with this\n * caps, we get the cache and clean it up. If something is busy, we replace\n * with INVALID so that when the function finishes and tries to put the\n * cache back, it'll fail and cleanup */\n } while (!g_atomic_pointer_compare_and_exchange (cache_ptr, cache,\n PAD_CACHE_INVALID));\n\n if (G_LIKELY (cache && cache != PAD_CACHE_INVALID))\n pad_free_cache (cache);\n}", "label": 0, "cwe": null, "length": 250 }, { "index": 11662, "code": "vu_float(t_vu *x, t_floatarg rms)\n{\n int i;\n\n if(rms <= IEM_VU_MINDB)\n x->x_rms = 0;\n else if(rms >= IEM_VU_MAXDB)\n x->x_rms = IEM_VU_STEPS;\n else\n {\n int i = (int)(2.0*(rms + IEM_VU_OFFSET));\n x->x_rms = iemgui_vu_db2i[i];\n }\n i = (int)(100.0*rms + 10000.5);\n rms = 0.01*(t_float)(i - 10000);\n x->x_fr = rms;\n outlet_float(x->x_out_rms, rms);\n x->x_updaterms = 1;\n sys_queuegui(x, x->x_gui.x_glist, vu_draw_update);\n}", "label": 0, "cwe": null, "length": 196 }, { "index": 377570, "code": "__Pyx_INC_MEMVIEW(__Pyx_memviewslice *memslice, int have_gil, int lineno)\n{\n int first_time;\n struct __pyx_memoryview_obj *memview = memslice->memview;\n if (!memview || (PyObject *) memview == Py_None)\n return; /* allow uninitialized memoryview assignment */\n if (__pyx_get_slice_count(memview) < 0)\n __pyx_fatalerror(\"Acquisition count is %d (line %d)\",\n __pyx_get_slice_count(memview), lineno);\n first_time = __pyx_add_acquisition_count(memview) == 0;\n if (first_time) {\n if (have_gil) {\n Py_INCREF((PyObject *) memview);\n } else {\n PyGILState_STATE _gilstate = PyGILState_Ensure();\n Py_INCREF((PyObject *) memview);\n PyGILState_Release(_gilstate);\n }\n }\n}", "label": 0, "cwe": null, "length": 201 }, { "index": 724926, "code": "__part_lsn_reset(dbp, ip)\n\tDB *dbp;\n\tDB_THREAD_INFO *ip;\n{\n\tDB **pdbp;\n\tDB_PARTITION *part;\n\tu_int32_t i;\n\tint ret;\n\n\tpart = dbp->p_internal;\n\tpdbp = part->handles;\n\tret = 0;\n\n\tfor (i = 0; ret == 0 && i < part->nparts; i++, pdbp++)\n\t\tret = __db_lsn_reset((*pdbp)->mpf, ip);\n\n\treturn (ret);\n}", "label": 0, "cwe": null, "length": 109 }, { "index": 31402, "code": "reorder_divs(__isl_take isl_mat *div,\n\t__isl_take isl_reordering *r)\n{\n\tint i, j;\n\tisl_mat *mat;\n\tint extra;\n\n\tif (!div || !r)\n\t\tgoto error;\n\n\textra = isl_space_dim(r->dim, isl_dim_all) + div->n_row - r->len;\n\tmat = isl_mat_alloc(div->ctx, div->n_row, div->n_col + extra);\n\tif (!mat)\n\t\tgoto error;\n\n\tfor (i = 0; i < div->n_row; ++i) {\n\t\tisl_seq_cpy(mat->row[i], div->row[i], 2);\n\t\tisl_seq_clr(mat->row[i] + 2, mat->n_col - 2);\n\t\tfor (j = 0; j < r->len; ++j)\n\t\t\tisl_int_set(mat->row[i][2 + r->pos[j]],\n\t\t\t\t div->row[i][2 + j]);\n\t}\n\n\tisl_reordering_free(r);\n\tisl_mat_free(div);\n\treturn mat;\nerror:\n\tisl_reordering_free(r);\n\tisl_mat_free(div);\n\treturn NULL;\n}", "label": 1, "cwe": "CWE-other", "length": 242 }, { "index": 905858, "code": "Send() {\n Channel::Time();\n if (!msgs.empty()) {\n\tstruct evbuffer *evb = msgs.front();\n\tmsgs.pop_front();\n\tAddress addr(peer_mac, pkttype, myifindex);\n\tif (!peer_channel) {\n\t // Broadcast handshake\n\t addr.set_mac(brmac);\n\t addr.set_pkttype(PACKET_BROADCAST);\n\t}\n\tSendTo(sock, addr, evb);\n\tevbuffer_free(evb);\n }\n last_send_time = NOW;\n evtimer_del(&evsendeth);\n evtimer_add(&evsendeth,tint2tv(NextSendTime()-NOW));\n}", "label": 0, "cwe": null, "length": 126 }, { "index": 121631, "code": "kmc_press_trigger_button_blocking(int fd)\n{\n\tprintf(\"Recording ...\\n\");\n\n\tkmc_press_trigger_button_blocking(fd);\n\n\twhile ( kmc_get_record_ready(fd) == 1) {\n\t\t/* This does not work right... */\n\t\t//printf(\".\");\n\t\tsleep(1);\n\t}\n\tprintf(\"Done\\n\");\n}", "label": 0, "cwe": null, "length": 67 }, { "index": 854, "code": "ref_path_table_lookup(const char *thepath)\n{\n H5O_info_t oi;\n\n /* Allow lookups on the root group, even though it doesn't have any link info */\n if(HDstrcmp(thepath, \"/\")) {\n H5L_info_t li;\n\n /* Check for external link first, so we don't return the OID of an object in another file */\n if(H5Lget_info(thefile, thepath, &li, H5P_DEFAULT) < 0)\n return HADDR_UNDEF;\n\n /* UD links can't be followed, so they always \"dangle\" like soft links. */\n if(li.type >= H5L_TYPE_UD_MIN)\n return HADDR_UNDEF;\n } /* end if */\n\n /* Get the object info now */\n /* (returns failure for dangling soft links) */\n if(H5Oget_info_by_name(thefile, thepath, &oi, H5P_DEFAULT) < 0)\n return HADDR_UNDEF;\n\n /* Return OID */\n return(oi.addr);\n}", "label": 0, "cwe": null, "length": 228 }, { "index": 930111, "code": "PrintSelf(ostream& os, vtkIndent indent)\n{\n os << indent << \"Target Texture Size: \"\n << this->TargetTextureSize[0] << \", \"\n << this->TargetTextureSize[1] << endl;\n \n os << indent << \"Maximum Number Of Planes: \";\n if ( this->MaximumNumberOfPlanes > 0 )\n {\n os << this->MaximumNumberOfPlanes << endl;\n }\n else\n {\n os << \"\" << endl;\n }\n \n os << indent << \"Maximum Storage Size: \" \n << this->MaximumStorageSize << endl;\n \n this->Superclass::PrintSelf(os,indent);\n}", "label": 0, "cwe": null, "length": 147 }, { "index": 959043, "code": "unpack_RGBA_INT8(const void *src, GLfloat dst[][4], GLuint n)\n{\n const GLbyte *s = (const GLbyte *) src;\n GLuint i;\n for (i = 0; i < n; i++) {\n dst[i][RCOMP] = (GLfloat) s[i*4+0];\n dst[i][GCOMP] = (GLfloat) s[i*4+1];\n dst[i][BCOMP] = (GLfloat) s[i*4+2];\n dst[i][ACOMP] = (GLfloat) s[i*4+3];\n }\n}", "label": 0, "cwe": null, "length": 127 }, { "index": 384522, "code": "bch_btree_check(struct cache_set *c)\n{\n\tstruct btree_op op;\n\n\tbch_btree_op_init(&op, SHRT_MAX);\n\n\treturn btree_root(check_recurse, c, &op);\n}", "label": 0, "cwe": null, "length": 47 }, { "index": 205870, "code": "gribskov_conversion_method(block, matrix)\n Block *block;\n Matrix *matrix;\n{\n char sijname[SMALL_BUFF_LENGTH], *blimps_dir;\n struct float_qij *sij_matrix;\n FILE *fp;\n\n /* load the substitution matrix */\n blimps_dir = getenv(\"BLIMPS_DIR\");\n if (blimps_dir != NULL)\n {\n sprintf(sijname, \"%s/docs/default.sij\", blimps_dir);\n }\n else\n {\n sprintf(sijname, \"default.sij\");\n }\n\n sij_matrix = load_qij(fp);\n fclose(fp);\n if (sij_matrix == NULL) \n {\n sprintf(ErrorBuffer,\n\t \"gribskov_conversion_method: default.sij matrix missing, Cannot continue.\\n\");\n ErrorReport(FATAL_ERR_LVL);\n }\n\n /* check to see if the block has sequence weights */\n normalize(block); /* Make weights sum to number of sequences */\n make_gribs(block, matrix, sij_matrix); \n\n}", "label": 1, "cwe": "CWE-other", "length": 224 }, { "index": 109894, "code": "createMixOnCDConfiguration(const UINT8* strFileName)\n{\n\tXERCES_CPP_NAMESPACE::DOMDocument* doc = createDOMDocument();\n\t//Neasty but cool...\n\tbool bForLast=false;\n\tif(strFileName!=NULL&&strncmp((char*)strFileName,\"last\",4)==0)\n\t\t\tbForLast=true;\n\tbuildDefaultConfig(doc,bForLast);\n\tsaveToFile(doc, strFileName);\n\treturn E_SUCCESS;\n}", "label": 0, "cwe": null, "length": 87 }, { "index": 1009442, "code": "safe_dcl(graph_t * g, int obj_kind, char *name, char *def)\n{\n attrsym_t *a = agattr(g,obj_kind,name, NULL);\n if (!a)\t/* attribute does not exist */\t\t\n\ta = agattr(g,obj_kind,name,def);\n return a;\n}", "label": 0, "cwe": null, "length": 67 }, { "index": 320456, "code": "change_nearest_vertex(Path,X,Y,NewX,NewY,Type)\n\n/* Translate the path vertex nearest X,Y to NewX-X,NewY-Y. */\nstruct p *Path;\nint X,Y,NewX,NewY;\nint Type;\n{\n double dx,dy,d,mind;\n struct p *p;\n int i,indx = 0;\n\n mind = 1e30;\n for (p = Path,i = 0; p; p = p->pSucc,i++) {\n dx = p->pX - X;\n dy = p->pY - Y;\n d = dx*dx + dy*dy;\n if (d < mind) {\n mind = d;\n indx = i;\n }\n }\n if (indx == 0 && Type == CDPOLYGON) {\n for (p = Path; p && p->pSucc; p = p->pSucc) ;\n if (Path->pX == p->pX And Path->pY == p->pY) {\n if (Parameters.kpStretchType != STR_TB)\n p->pX += NewX - X;\n if (Parameters.kpStretchType != STR_RL)\n p->pY += NewY - Y;\n }\n }\n for (p = Path, i = 0; i < indx; p = p->pSucc,i++) ;\n if (Parameters.kpStretchType != STR_TB)\n p->pX += NewX - X;\n if (Parameters.kpStretchType != STR_RL)\n p->pY += NewY - Y;\n}", "label": 0, "cwe": null, "length": 350 }, { "index": 873457, "code": "bitmap_free(MY_BITMAP *map)\n{\n DBUG_ENTER(\"bitmap_free\");\n if (map->bitmap)\n {\n if (map->mutex)\n mysql_mutex_destroy(map->mutex);\n\n my_free(map->bitmap);\n map->bitmap=0;\n }\n DBUG_VOID_RETURN;\n}", "label": 0, "cwe": null, "length": 65 }, { "index": 3135, "code": "adau1977_set_bias_level(struct snd_soc_codec *codec,\n\tenum snd_soc_bias_level level)\n{\n\tstruct adau1977 *adau1977 = snd_soc_codec_get_drvdata(codec);\n\tint ret = 0;\n\n\tswitch (level) {\n\tcase SND_SOC_BIAS_ON:\n\t\tbreak;\n\tcase SND_SOC_BIAS_PREPARE:\n\t\tbreak;\n\tcase SND_SOC_BIAS_STANDBY:\n\t\tif (snd_soc_codec_get_bias_level(codec) == SND_SOC_BIAS_OFF)\n\t\t\tret = adau1977_power_enable(adau1977);\n\t\tbreak;\n\tcase SND_SOC_BIAS_OFF:\n\t\tret = adau1977_power_disable(adau1977);\n\t\tbreak;\n\t}\n\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 151 }, { "index": 76087, "code": "qlcnic_port_eswitch_cfg_capability(struct qlcnic_adapter *adapter)\n{\n\tbool ret = false;\n\n\tif (qlcnic_84xx_check(adapter)) {\n\t\tret = true;\n\t} else if (qlcnic_83xx_check(adapter)) {\n\t\tif (adapter->ahw->extra_capability[0] &\n\t\t QLCNIC_FW_CAPABILITY_2_PER_PORT_ESWITCH_CFG)\n\t\t\tret = true;\n\t\telse\n\t\t\tret = false;\n\t}\n\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 104 }, { "index": 430975, "code": "build_conc_ProcedureCall (int lno, pIIR_Identifier label,\n\t\t\t bool pp, pIIR_ProcedureCallStatement pcs)\n{\n if (pcs == NULL)\n return NULL;\n\n pIIR_ExpressionList sens = NULL;\n for (pIIR_AssociationList al = pcs->actual_parameter_part; al; al = al->rest)\n if (al->first)\n get_implicit_signals (sens, al->first->actual);\n \n pIIR_SequentialStatementList stats =\n mIIR_SequentialStatementList (pcs->pos, pcs, NULL);\n stats->rest =\n mIIR_SequentialStatementList (lno,\n\t\t\t\t mIIR_WaitStatement (lno,\n\t\t\t\t\t\t NULL,\n\t\t\t\t\t\t NULL,\n\t\t\t\t\t\t sens),\n\t\t\t\t NULL);\n\n pIIR_ImplicitProcessStatement p = mIIR_ImplicitProcessStatement (lno, label, pp,\n\t\t\t\t\t\t\t\t stats);\n // p->orig_statement = pcs;\n add_decl (p);\n return p;\n}", "label": 0, "cwe": null, "length": 224 }, { "index": 21632, "code": "apply(gm_symtab_entry* sym, int symtab_type) {\n ast_extra_info* info = sym->find_info(GPS_TAG_BB_USAGE);\n if (info == NULL) return true; // no information\n\n gps_syminfo* syminfo = (gps_syminfo*) info;\n if (syminfo->is_scalar()) {\n // ignore iterator and graph\n if (sym->getType()->is_graph() || sym->getType()->is_node_edge_iterator()) {\n return true;\n }\n\n if (symtab_type == GM_SYMTAB_ARG) {\n syminfo->set_is_argument(true);\n scalar.insert(sym);\n //} else if (syminfo->is_used_in_multiple_BB() && syminfo->is_scoped_global()) {\n } else if (syminfo->is_scoped_global()) {\n scalar.insert(sym);\n } else {\n // temporary variables. can be ignored\n }\n } else {\n if (sym->getType()->is_node_property()) {\n prop.insert(sym);\n } else if (sym->getType()->is_edge_property()) {\n edge_prop.insert(sym);\n } else {\n printf(\"sym = %s\\n\", sym->getId()->get_genname());\n assert(false);\n }\n\n /*\n if (syminfo->is_argument())\n {\n prop.insert(sym);\n }\n else if (syminfo->is_used_in_multiple_BB()){\n prop.insert(sym);\n } else {\n //assert(false);\n prop.insert(sym);\n }\n */\n }\n\n return true;\n }", "label": 0, "cwe": null, "length": 335 }, { "index": 702985, "code": "nfs_read_completion(struct nfs_pgio_header *hdr)\n{\n\tunsigned long bytes = 0;\n\n\tif (test_bit(NFS_IOHDR_REDO, &hdr->flags))\n\t\tgoto out;\n\twhile (!list_empty(&hdr->pages)) {\n\t\tstruct nfs_page *req = nfs_list_entry(hdr->pages.next);\n\t\tstruct page *page = req->wb_page;\n\t\tunsigned long start = req->wb_pgbase;\n\t\tunsigned long end = req->wb_pgbase + req->wb_bytes;\n\n\t\tif (test_bit(NFS_IOHDR_EOF, &hdr->flags)) {\n\t\t\t/* note: regions of the page not covered by a\n\t\t\t * request are zeroed in nfs_readpage_async /\n\t\t\t * readpage_async_filler */\n\t\t\tif (bytes > hdr->good_bytes) {\n\t\t\t\t/* nothing in this request was good, so zero\n\t\t\t\t * the full extent of the request */\n\t\t\t\tzero_user_segment(page, start, end);\n\n\t\t\t} else if (hdr->good_bytes - bytes < req->wb_bytes) {\n\t\t\t\t/* part of this request has good bytes, but\n\t\t\t\t * not all. zero the bad bytes */\n\t\t\t\tstart += hdr->good_bytes - bytes;\n\t\t\t\tWARN_ON(start < req->wb_pgbase);\n\t\t\t\tzero_user_segment(page, start, end);\n\t\t\t}\n\t\t}\n\t\tbytes += req->wb_bytes;\n\t\tif (test_bit(NFS_IOHDR_ERROR, &hdr->flags)) {\n\t\t\tif (bytes <= hdr->good_bytes)\n\t\t\t\tnfs_page_group_set_uptodate(req);\n\t\t} else\n\t\t\tnfs_page_group_set_uptodate(req);\n\t\tnfs_list_remove_request(req);\n\t\tnfs_readpage_release(req);\n\t}\nout:\n\thdr->release(hdr);\n}", "label": 0, "cwe": null, "length": 369 }, { "index": 1068, "code": "moveLiveRegsBefore(const MachineBasicBlock &MBB,\n MachineBasicBlock::const_iterator Before) {\n // Initialize if we never queried in this block.\n if (!LiveRegsValid) {\n LiveRegs.init(TRI);\n LiveRegs.addLiveOuts(&MBB, true);\n LiveRegPos = MBB.end();\n LiveRegsValid = true;\n }\n // Move backward just before the \"Before\" position.\n while (LiveRegPos != Before) {\n --LiveRegPos;\n LiveRegs.stepBackward(*LiveRegPos);\n }\n}", "label": 0, "cwe": null, "length": 122 }, { "index": 952468, "code": "intel_runtime_pm_put(struct drm_i915_private *dev_priv)\n{\n\tstruct drm_device *dev = dev_priv->dev;\n\tstruct device *device = &dev->pdev->dev;\n\n\tassert_rpm_wakelock_held(dev_priv);\n\tif (atomic_dec_and_test(&dev_priv->pm.wakeref_count))\n\t\tatomic_inc(&dev_priv->pm.atomic_seq);\n\n\tpm_runtime_mark_last_busy(device);\n\tpm_runtime_put_autosuspend(device);\n}", "label": 0, "cwe": null, "length": 93 }, { "index": 901482, "code": "check(QString& errorMsg, QString& errorItem)\n{\n int v;\n v = ui.maxListEdit->text().toUInt();\n if ((v <1) || (v >500)) {\n errorMsg = inRangeError(1, 500);\n errorItem = QString(\"maxListEdit\");\n return false;\n }\n\n v = ui.symbolCount->text().toInt();\n if ((v <1) || (v >50)) {\n errorMsg = inRangeError(1, 50);\n errorItem = QString(\"symbolCount\");\n return false;\n }\n\n v = ui.symbolLength->text().toInt();\n if ((v <1) || (v >1000)) {\n errorMsg = inRangeError(1, 1000);\n errorItem = QString(\"symbolLength\");\n return false;\n }\n\n v = ui.precisionEdit->text().toInt();\n if ((v <1) || (v >5)) {\n errorMsg = inRangeError(1, 5);\n errorItem = QString(\"precisionEdit\");\n return false;\n }\n\n v = ui.contextEdit->text().toInt();\n if ((v <1) || (v >500)) {\n errorMsg = inRangeError(1, 500);\n errorItem = QString(\"contextEdit\");\n return false;\n }\n\n return true;\n}", "label": 0, "cwe": null, "length": 286 }, { "index": 957619, "code": "nhmex_sbox_hw_config(struct intel_uncore_box *box, struct perf_event *event)\n{\n\tstruct hw_perf_event *hwc = &event->hw;\n\tstruct hw_perf_event_extra *reg1 = &hwc->extra_reg;\n\tstruct hw_perf_event_extra *reg2 = &hwc->branch_reg;\n\n\t/* only TO_R_PROG_EV event uses the match/mask register */\n\tif ((hwc->config & NHMEX_PMON_CTL_EV_SEL_MASK) !=\n\t NHMEX_S_EVENT_TO_R_PROG_EV)\n\t\treturn 0;\n\n\tif (box->pmu->pmu_idx == 0)\n\t\treg1->reg = NHMEX_S0_MSR_MM_CFG;\n\telse\n\t\treg1->reg = NHMEX_S1_MSR_MM_CFG;\n\treg1->idx = 0;\n\treg1->config = event->attr.config1;\n\treg2->config = event->attr.config2;\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 202 }, { "index": 558962, "code": "accept ()\n{\n\ttrace_with_mask(\"IPv4Socket::accept\",SOCKTRACE);\n\n\tsocklen_t length = 0;\n\tSA* remote_address = NULL;\n\thandler_t new_fd;\n\n\tdisable_handler (new_fd);\n\n\tif ( getDomain() == AF_UNIX ) {\n\t\tlength = sizeof(struct sockaddr_in);\n\t\tremote_address = (SA*) new SA_IN;\n\t}\n\telse /* AF_INET */\n\t{\n\t\tremote_address = (SA*) new SA_UN;\n\t\tlength = sizeof(struct sockaddr_un);\n\t}\n\tmemset(remote_address, 0, length);\n\n#if !defined (_CYGWIN32__)\n\tnew_fd = ::accept(m_fd, remote_address, &length);\n#else\n\tnew_fd = ::accept(m_fd, remote_address, (int*)&length);\n#endif\n\n\tif (!is_valid_handler (new_fd)) {\n\t\tEL((ASSAERR,\"::accept() failed (new_fd=%d)\\n\", new_fd));\n\t\tclose();\n\t\treturn NULL;\n\t}\n\tif (length == sizeof(SA_IN)) {\n\t\tSA_IN* sa_in = (SA_IN*) remote_address;\n\n\t\tDL((SOCK,\"Accepted new TCP connection from Addr %s, port %d\\n\",\n\t\t inet_ntoa(sa_in->sin_addr), ntohs( sa_in->sin_port)));\n\t}\n\telse {\n#if !defined(WIN32)\n\t\tSA_UN* sa_un = (SA_UN*) remote_address;\n\t\tDL((SOCK,\"Accepted new UNIX connection from %s\\n\", sa_un->sun_path));\n#endif\n\t}\n\tdelete remote_address;\n\n\tIPv4Socket* s = new IPv4Socket (new_fd);\n\ts->clear ();\n\ts->turnOptionOn (Socket::nonblocking);\n\treturn s;\n}", "label": 0, "cwe": null, "length": 356 }, { "index": 690224, "code": "gar_free_srch(struct gar_subfile *f)\n{\n\tint i;\n\tif (f->countries) {\n\t\tfor (i = 0; i < f->ccount; i++) {\n\t\t\tif (f->countries[i])\n\t\t\t\tfree(f->countries[i]);\n\t\t}\n\t\tf->ccount = 0;\n\t\tfree(f->countries);\n\t\tf->countries = NULL;\n\t}\n\n\tif (f->regions) {\n\t\tfor (i = 0; i < f->rcount; i++) {\n\t\t\tif (f->regions[i])\n\t\t\t\tgar_free_region_def(f->regions[i]);\n\t\t}\n\t\tf->rcount = 0;\n\t\tfree(f->regions);\n\t\tf->regions = NULL;\n\t}\n\n\tif (f->cities) {\n\t\tfor (i = 0; i < f->cicount; i++) {\n\t\t\tif (f->cities[i])\n\t\t\t\tgar_free_city_def(f->cities[i]);\n\t\t}\n\t\tf->cicount = 0;\n\t\tfree(f->cities);\n\t\tf->cities = NULL;\n\t}\n\n\tif (f->zips) {\n\t\tfor (i = 0; i < f->czips; i++) {\n\t\t\tif (f->zips[i])\n\t\t\t\tgar_free_zip_def(f->zips[i]);\n\t\t}\n\t\tf->czips = 0;\n\t\tfree(f->zips);\n\t\tf->zips = NULL;\n\t}\n}", "label": 0, "cwe": null, "length": 302 }, { "index": 43944, "code": "_tilebuf_setup(Tilebuf *tb)\n{\n E_FREE(tb->tiles.tiles);\n\n tb->tiles.w = (tb->outbuf_w + (tb->tile_size.w - 1)) / tb->tile_size.w;\n tb->tiles.h = (tb->outbuf_h + (tb->tile_size.h - 1)) / tb->tile_size.h;\n\n tb->tiles.tiles = malloc(tb->tiles.w * tb->tiles.h * sizeof(Tilebuf_Tile));\n\n if (!tb->tiles.tiles)\n {\n tb->tiles.w = 0;\n tb->tiles.h = 0;\n return;\n }\n memset(tb->tiles.tiles, 0, tb->tiles.w * tb->tiles.h * sizeof(Tilebuf_Tile));\n}", "label": 0, "cwe": null, "length": 161 }, { "index": 382254, "code": "atcommand_gvgon(const int fd, struct map_session_data* sd, AtCommandType command, const char* message)\n{\n\tnullpo_retr(-1, sd);\n\n\tif (!map[sd->bl.m].flag.gvg) {\n\t\tmap[sd->bl.m].flag.gvg = 1;\n\t\tclif_send0199(sd->bl.m, 3);\n\t\tclif_displaymessage(fd, msg_txt(34));\n\t\tmap_field_setting();\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 104 }, { "index": 317267, "code": "uri_list_to_gslist(char *uri_list)\n{\n\tGSList *list = NULL;\n\n\twhile (*uri_list)\n\t{\n\t\tchar\t*linebreak;\n\t\tchar\t*uri;\n\t\tint\tlength;\n\n\t\tlinebreak = strchr(uri_list, 13);\n\n\t\tif (!linebreak || linebreak[1] != 10)\n\t\t{\n\t\t\tinfobox(term_window, \"Incorrect or missing line break \"\n\t\t\t\t\"in text/uri-list data\\n\");\n\t\t\treturn list;\n\t\t}\n\n\t\tlength = linebreak - uri_list;\n\n\t\tif (length && uri_list[0] != '#')\n\t\t{\n\t\t\turi = g_malloc(sizeof(char) * (length + 1));\n\t\t\tstrncpy(uri, uri_list, length);\n\t\t\turi[length] = 0;\n\t\t\tlist = g_slist_append(list, uri);\n\t\t}\n\n\t\turi_list = linebreak + 2;\n\t}\n\n\treturn list;\n}", "label": 0, "cwe": null, "length": 195 }, { "index": 788663, "code": "item_event_callback (EelCanvasItem *item,\n\t\t GdkEvent *event,\n\t\t gpointer data)\n{\n\tNautilusCanvasContainer *container;\n\tNautilusCanvasIcon *icon;\n\n\tcontainer = NAUTILUS_CANVAS_CONTAINER (data);\n\n\ticon = NAUTILUS_CANVAS_ITEM (item)->user_data;\n\tg_assert (icon != NULL);\n\n\tswitch (event->type) {\n\tcase GDK_BUTTON_PRESS:\n\t\tif (handle_canvas_button_press (container, icon, &event->button)) {\n\t\t\t/* Stop the event from being passed along further. Returning\n\t\t\t * TRUE ain't enough. \n\t\t\t */\n\t\t\treturn TRUE;\n\t\t}\n\t\treturn FALSE;\n\tdefault:\n\t\treturn FALSE;\n\t}\n}", "label": 0, "cwe": null, "length": 145 }, { "index": 270609, "code": "thompson(struct jmt *jmt, struct lens *lens,\n struct state **s, struct state **f) {\n ind_t l = lens_index(jmt, lens);\n struct state *sA = lens_state(jmt, l);\n ensure(l < jmt->lenses.used, jmt);\n\n *s = make_state(jmt);\n *f = make_state(jmt);\n ERR_BAIL(jmt);\n\n if (lens->recursive) {\n /* A nonterminal */\n add_new_trans(jmt, *s, *f, l);\n add_new_trans(jmt, *s, sA, CALL);\n } else if (sA == NULL) {\n /* A terminal that never matches epsilon */\n add_new_trans(jmt, *s, *f, l);\n } else {\n /* A terminal that matches epsilon */\n add_new_trans(jmt, *s, *f, l);\n add_new_trans(jmt, *s, sA, CALL);\n add_new_trans(jmt, *s, *f, l+1);\n }\n error:\n return;\n}", "label": 0, "cwe": null, "length": 240 }, { "index": 166815, "code": "goto_file_line (AnjutaPlugin *plugin, const gchar *filename, gint lineno)\n{\n\tIAnjutaDocumentManager *docman;\n\tGFile* file;\n\t\n\tg_return_if_fail (filename != NULL);\n\t\t\n\tDEBUG_PRINT (\"going to: file %s, line %d\", filename, lineno);\n\t\n\t/* Go to file and line number */\n\tdocman = anjuta_shell_get_interface (plugin->shell, IAnjutaDocumentManager,\n\t\t\t\t\t\t\t\t\t\t NULL);\n\tfile = g_file_new_for_path (filename);\n\tianjuta_document_manager_goto_file_line (docman, file, lineno, NULL);\n\t\n\tg_object_unref (file);\n}", "label": 0, "cwe": null, "length": 136 }, { "index": 652084, "code": "getCoordFromString(VisuDataNode *dataNode, VisuData *dataObj,\n\t\t\t\t VisuNode *node)\n{\n GString *str;\n gchar *value;\n\n g_return_val_if_fail(VISU_IS_DATA_NODE_TYPE(dataNode) &&\n\t\t VISU_IS_DATA(dataObj) && node, (gchar*)0);\n\n /* Check if the given property has an association with the given VisuData. */\n DBG_fprintf(stderr, \"Visu Data: get label for node coordinates.\\n\");\n\n /* Set the format attribute. */\n str = g_string_new(\"\");\n g_string_append_printf(str, \"( %g ; %g ; %g )\",\n\t\t\t node->xyz[0], node->xyz[1], node->xyz[2]);\n value = str->str;\n g_string_free(str, FALSE);\n\n DBG_fprintf(stderr, \"Visu Data: get values '%s'.\\n\", value);\n return value;\n}", "label": 0, "cwe": null, "length": 203 }, { "index": 215050, "code": "snd_rme32_info_inputtype_control(struct snd_kcontrol *kcontrol,\n\t\t\t\t struct snd_ctl_elem_info *uinfo)\n{\n\tstruct rme32 *rme32 = snd_kcontrol_chip(kcontrol);\n\tstatic const char * const texts[4] = {\n\t\t\"Optical\", \"Coaxial\", \"Internal\", \"XLR\"\n\t};\n\tint num_items;\n\n\tswitch (rme32->pci->device) {\n\tcase PCI_DEVICE_ID_RME_DIGI32:\n\tcase PCI_DEVICE_ID_RME_DIGI32_8:\n\t\tnum_items = 3;\n\t\tbreak;\n\tcase PCI_DEVICE_ID_RME_DIGI32_PRO:\n\t\tnum_items = 4;\n\t\tbreak;\n\tdefault:\n\t\tsnd_BUG();\n\t\treturn -EINVAL;\n\t}\n\treturn snd_ctl_enum_info(uinfo, 1, num_items, texts);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 175 }, { "index": 983421, "code": "GetOrigin (const wfa_t *wfa, tlist_t **state_list, int searchstate)\n/*\n * Get origin of the root state of the LCTree in the wfa-tree\n * (only makes sense if the LCTree is a real subtree of the wfa-tree).\n * the path from the root of the wfa-tree to the root of the LCTree\n * is stored in a descending ordered tlist_t-list.\n *\n * wfa - pointer on wfa-tree to search in\n * state_list - pointer on pointer on head of origin list\n * searchstate - state to search for\n */\n{\n int pos = wfa->root_state;\n \n if (pos != searchstate)\n {\n while (pos != searchstate)\n {\n\t int i = 0;\n\t /* store position */\n\t InsertDesList (state_list, pos, 1);\n\t /* search for subtree with searchstate */\n\t while (i < MAXLABELS)\n\t {\n\t if (ischild (wfa->tree [pos][i]) && wfa->tree [pos][i] >= searchstate)\n\t {\n\t pos = wfa->tree [pos][i];\n\t i = MAXLABELS; /* terminate while-loop */\n\t }\n\t else i++;\n\t }\n }\n InsertDesList (state_list, pos, 1); /* add searchstate to list */\n }\n}", "label": 0, "cwe": null, "length": 305 }, { "index": 75243, "code": "re_clear_eol(EditLine *el, int fx, int sx, int diff)\n{\n\n\tELRE_DEBUG(1, (__F, \"re_clear_eol sx %d, fx %d, diff %d\\n\",\n\t sx, fx, diff));\n\n\tif (fx < 0)\n\t\tfx = -fx;\n\tif (sx < 0)\n\t\tsx = -sx;\n\tif (fx > diff)\n\t\tdiff = fx;\n\tif (sx > diff)\n\t\tdiff = sx;\n\n\tELRE_DEBUG(1, (__F, \"re_clear_eol %d\\n\", diff));\n\tterminal_clear_EOL(el, diff);\n}", "label": 0, "cwe": null, "length": 135 }, { "index": 926884, "code": "base_erase(OFListLinkBase * pos)\n{\n assert(pos && pos != afterLast);\n OFListLinkBase * tmp = pos->next;;\n pos->next->prev=pos->prev;\n pos->prev->next=pos->next;\n delete pos;\n listSize--;\n return tmp;\n}", "label": 0, "cwe": null, "length": 66 }, { "index": 657904, "code": "build_sockopts(sockopt_t *sockopts, int *rcvbufsz, int *sndbufsz)\n{\n\tsize_t so = 0;\n\n\tif (*rcvbufsz)\n\t{\n\t\tsockopts[so].level = SOL_SOCKET;\n\t\tsockopts[so].optname = SO_RCVBUF;\n\t\tsockopts[so].optval = rcvbufsz;\n\t\tsockopts[so].optlen = sizeof(int);\n\t\tso++;\n\t}\n\n\tif (*sndbufsz)\n\t{\n\t\tsockopts[so].level = SOL_SOCKET;\n\t\tsockopts[so].optname = SO_SNDBUF;\n\t\tsockopts[so].optval = sndbufsz;\n\t\tsockopts[so].optlen = sizeof(int);\n\t\tso++;\n\t}\n\n\tsockopts[so].optval = NULL;\n\n\treturn sockopts;\n}", "label": 0, "cwe": null, "length": 177 }, { "index": 767682, "code": "addInfo(const std::string &name,\n const std::string &value) throw()\n{\n m_what.append(\"; \");\n m_what.append(name);\n m_what.append(\"='\");\n m_what.append(value);\n m_what.append(\"'\");\n return *this;\n}", "label": 0, "cwe": null, "length": 63 }, { "index": 40027, "code": "updatePeerIpHistory(IpAddress& ip)\n{\n time_t t = time ( NULL );\n std::map::iterator i = peerIpHistory.find (ip);\n\n bool dispPeer = false;\n if (i != peerIpHistory.end())\n {\n dispPeer = t - i->second > LOGHIST_EXPIRATION_DELAY;\n i->second = t;\n }\n else\n {\n peerIpHistory[ip]=t;\n dispPeer = true;\n }\n\n if (dispPeer)\n NVJ_LOG->append(NVJ_INFO,std::string (\"WebServer: Connection from IP: \") + ip.str());\n}", "label": 0, "cwe": null, "length": 141 }, { "index": 88200, "code": "validate(const char *pString_)\n{\n if (MSView::model()!=0)\n {\n MSTime aTime;\n if (aTime.set(pString_,timeZone())==MSError::MSSuccess)\n {\n\tif (minimumValue().isSet()==MSTrue&&maximumValue().isSet()==MSTrue)\n\t {\n\t if (aTime>=minimumValue()&&aTime<=maximumValue())\n\t {\n\t value()=aTime;\n\t return MSTrue;\n\t }\n\t }\n\telse if (minimumValue().isSet()==MSTrue)\n\t {\n\t if (aTime>=minimumValue())\n\t {\n\t value()=aTime;\n\t return MSTrue;\n\t }\n\t }\n\telse if (maximumValue().isSet()==MSTrue)\n\t {\n\t if (aTime<=maximumValue())\n\t {\n\t value()=aTime;\n\t return MSTrue;\n\t }\n\t }\n\telse\n\t {\n\t value()=aTime;\n\t return MSTrue;\n\t }\n }\n }\n return MSFalse;\n}", "label": 0, "cwe": null, "length": 227 }, { "index": 771476, "code": "drl(key,dv,mi)\nchar *key;\nINT *dv, *mi;\n{ INT i, nd;\n nd = readilist(dv,key,0,mi[MDEG],0);\n for (i=0; imi[MDIM]))\n ERROR((\"drl: Invalid derivatives %s\",key));\n dv[i]--;\n }\n return(nd);\n}", "label": 0, "cwe": null, "length": 101 }, { "index": 438184, "code": "containsQuestionLt(const Char *s, size_t n)\n{\n for (; n > 1; n--, s++)\n if (*s == '?' && s[1] == '>')\n return 1;\n return 0;\n}", "label": 0, "cwe": null, "length": 51 }, { "index": 74019, "code": "decode_atom (const char **in)\n{\n\tregister const char *inptr = *in;\n\tconst char *atom = NULL;\n\t\n\tif (!is_atom (*inptr))\n\t\treturn NULL;\n\t\n\tatom = inptr++;\n\twhile (is_atom (*inptr))\n\t\tinptr++;\n\t\n\t*in = inptr;\n\t\n\treturn atom;\n}", "label": 0, "cwe": null, "length": 72 }, { "index": 12188, "code": "gigolo_bookmark_edit_dialog_set_property(GObject *object, guint prop_id,\n\t\t\t\t\t\t\t\t\t\t\t\t const GValue *value, GParamSpec *pspec)\n{\n \tGigoloBookmarkEditDialog *dialog = GIGOLO_BOOKMARK_EDIT_DIALOG(object);\n \tGigoloBookmarkEditDialogPrivate *priv = GIGOLO_BOOKMARK_EDIT_DIALOG_GET_PRIVATE(dialog);\n\n\tswitch (prop_id)\n {\n case PROP_BOOKMARK_INIT:\n\t\tpriv->bookmark_init = g_value_get_object(value);\n\t\tinit_values(dialog);\n\t\tbreak;\n case PROP_BOOKMARK_UPDATE:\n\t\tpriv->bookmark_update = g_value_get_object(value);\n\t\tupdate_bookmark(dialog);\n\t\tbreak;\n case PROP_MODE:\n {\n\t\tconst gchar *title;\n\t\tconst gchar *stock_id;\n\t\tconst gchar *button_stock_id;\n\t\tgint mode = g_value_get_int(value);\n\n\t\tswitch (mode)\n\t\t{\n\t\t\tcase GIGOLO_BE_MODE_CREATE:\n\t\t\t{\n\t\t\t\ttitle = _(\"Create Bookmark\");\n\t\t\t\tbutton_stock_id = stock_id = GTK_STOCK_ADD;\n\t\t\t\tcombo_set_active(priv->type_combo, 0);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase GIGOLO_BE_MODE_EDIT:\n\t\t\t{\n\t\t\t\ttitle = _(\"Edit Bookmark\");\n\t\t\t\tstock_id = GTK_STOCK_EDIT;\n\t\t\t\tbutton_stock_id = GTK_STOCK_OK;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tcase GIGOLO_BE_MODE_CONNECT:\n\t\t\tdefault:\n\t\t\t{\n\t\t\t\ttitle = _(\"Connect to Server\");\n\t\t\t\tbutton_stock_id = stock_id = GTK_STOCK_CONNECT;\n\t\t\t\tcombo_set_active(priv->type_combo, 0);\n\t\t\t\tgtk_widget_hide(priv->name_label);\n\t\t\t\tgtk_widget_hide(priv->name_entry);\n\t\t\t\tgtk_widget_hide(priv->color_label);\n\t\t\t\tgtk_widget_hide(priv->color_chooser);\n\t\t\t\tgtk_widget_hide(priv->autoconnect_label);\n\t\t\t\tgtk_widget_hide(priv->autoconnect_checkbtn);\n\t\t\t\tgtk_widget_hide(priv->separator);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tgtk_window_set_title(GTK_WINDOW(dialog), title);\n\t\tgtk_window_set_icon_name(GTK_WINDOW(dialog), stock_id);\n\t\tgtk_dialog_add_buttons(GTK_DIALOG(dialog), button_stock_id, GTK_RESPONSE_OK, NULL);\n\t\tpriv->dialog_type = mode;\n\n\t\tsetup_for_type(dialog);\n break;\n }\n default:\n G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);\n break;\n }\n}", "label": 0, "cwe": null, "length": 487 }, { "index": 325940, "code": "H5O_free(H5O_t *oh)\n{\n unsigned\tu; /* Local index variable */\n\n FUNC_ENTER_NOAPI_NOINIT_NOERR\n\n /* check args */\n HDassert(oh);\n\n /* Destroy chunks */\n if(oh->chunk) {\n for(u = 0; u < oh->nchunks; u++)\n oh->chunk[u].image = H5FL_BLK_FREE(chunk_image, oh->chunk[u].image);\n\n oh->chunk = (H5O_chunk_t *)H5FL_SEQ_FREE(H5O_chunk_t, oh->chunk);\n } /* end if */\n\n /* Destroy messages */\n if(oh->mesg) {\n for(u = 0; u < oh->nmesgs; u++) {\n#ifndef NDEBUG\n /* Verify that message is clean, unless it could have been marked\n * dirty by decoding */\n if(oh->ndecode_dirtied && oh->mesg[u].dirty)\n oh->ndecode_dirtied--;\n else\n HDassert(oh->mesg[u].dirty == 0);\n#endif /* NDEBUG */\n\n H5O_msg_free_mesg(&oh->mesg[u]);\n } /* end for */\n\n /* Make sure we accounted for all the messages dirtied by decoding */\n HDassert(!oh->ndecode_dirtied);\n\n oh->mesg = (H5O_mesg_t *)H5FL_SEQ_FREE(H5O_mesg_t, oh->mesg);\n } /* end if */\n\n /* destroy object header */\n oh = H5FL_FREE(H5O_t, oh);\n\n FUNC_LEAVE_NOAPI(SUCCEED)\n}", "label": 0, "cwe": null, "length": 353 }, { "index": 60692, "code": "isUnsupportedTerm(void) {\n char *term = getenv(\"TERM\");\n\n if (term) {\n int j;\n for (j = 0; unsupported_term[j]; j++) {\n if (strcmp(term, unsupported_term[j]) == 0) {\n return 1;\n }\n }\n }\n return 0;\n}", "label": 1, "cwe": "CWE-other", "length": 73 }, { "index": 943540, "code": "Farsight_DumpPipeline _ANSI_ARGS_((ClientData clientData, Tcl_Interp *interp,\n int objc, Tcl_Obj *CONST objv[]))\n{\n\n // We verify the arguments\n if( objc != 2) {\n Tcl_WrongNumArgs (interp, 1, objv, \"filename\");\n return TCL_ERROR;\n }\n\n if (pipeline)\n GST_DEBUG_BIN_TO_DOT_FILE (pipeline, GST_DEBUG_GRAPH_SHOW_ALL, Tcl_GetString (objv[1]));\n if (test_pipeline)\n GST_DEBUG_BIN_TO_DOT_FILE (test_pipeline, GST_DEBUG_GRAPH_SHOW_ALL, Tcl_GetString (objv[1]));\n\n return TCL_OK;\n}", "label": 0, "cwe": null, "length": 147 }, { "index": 639280, "code": "file_dialog_entry_enter_cb(const gchar *path, gpointer data)\n{\n\tGenericDialog *gd = data;\n\n\tfile_dialog_entry_cb(NULL, data);\n\n\tif (gd->default_cb) gd->default_cb(gd, gd->data);\n}", "label": 0, "cwe": null, "length": 50 }, { "index": 97559, "code": "Read(const Arguments& args) {\n HandleScope scope;\n\n if (args.Length() < 4) {\n return ThrowException(Exception::TypeError(\n String::New(\"Takes 4 parameters\")));\n }\n\n FD_ARG(args[0])\n\n if (!Buffer::HasInstance(args[1])) {\n return ThrowException(Exception::TypeError(\n String::New(\"Second argument should be a buffer\")));\n }\n\n Local buffer_obj = args[1]->ToObject();\n char *buffer_data = Buffer::Data(buffer_obj);\n size_t buffer_length = Buffer::Length(buffer_obj);\n\n size_t off = args[2]->Int32Value();\n if (off >= buffer_length) {\n return ThrowException(Exception::Error(\n String::New(\"Offset is out of bounds\")));\n }\n\n size_t len = args[3]->Int32Value();\n if (off + len > buffer_length) {\n return ThrowException(Exception::Error(\n String::New(\"Length is extends beyond buffer\")));\n }\n\n#ifdef __POSIX__\n ssize_t bytes_read = read(fd, (char*)buffer_data + off, len);\n\n if (bytes_read < 0) {\n if (errno == EAGAIN || errno == EINTR) return Null();\n return ThrowException(ErrnoException(errno, \"read\"));\n }\n#else // __MINGW32__\n // read() doesn't work for overlapped sockets (the only usable\n // type of sockets) so recv() is used here.\n ssize_t bytes_read = recv(_get_osfhandle(fd), (char*)buffer_data + off, len, 0);\n\n if (bytes_read < 0) {\n int wsaErrno = WSAGetLastError();\n if (wsaErrno == WSAEWOULDBLOCK || wsaErrno == WSAEINTR) return Null();\n return ThrowException(ErrnoException(wsaErrno, \"read\"));\n }\n#endif\n\n return scope.Close(Integer::New(bytes_read));\n}", "label": 0, "cwe": null, "length": 421 }, { "index": 417374, "code": "configured_ident(git_signature **out, const git_repository *repo)\n{\n\tif (repo->ident_name && repo->ident_email)\n\t\treturn git_signature_now(out, repo->ident_name, repo->ident_email);\n\n\t/* if not configured let us fall-through to the next method */\n\treturn -1;\n}", "label": 0, "cwe": null, "length": 65 }, { "index": 391603, "code": "get_validity_info (PKT_public_key *pk, PKT_user_id *uid)\n{\n int trustlevel;\n\n if (!pk)\n return '?'; /* Just in case a NULL PK is passed. */\n\n trustlevel = get_validity (pk, uid);\n if( trustlevel & TRUST_FLAG_REVOKED )\n\treturn 'r';\n return trust_letter ( trustlevel );\n}", "label": 0, "cwe": null, "length": 86 }, { "index": 530626, "code": "new_thread(void)\n{\n thread_data *thread = g_new(thread_data, 1);\n gint start_pipe[2];\n gint end_pipe[2];\n GError *err = NULL;\n\n if (pipe(start_pipe) < 0) {\n perror(\"pipe(start_pipe)\");\n goto start_pipe_error;\n }\n\n if (pipe(end_pipe) < 0) {\n perror(\"pipe(end_pipe)\");\n goto end_pipe_error;\n }\n\n thread->start_read = g_io_channel_unix_new(start_pipe[0]);\n g_io_channel_set_encoding(thread->start_read, NULL, NULL);\n\n thread->start_write = g_io_channel_unix_new(start_pipe[1]);\n g_io_channel_set_encoding(thread->start_write, NULL, NULL);\n\n thread->end_read = g_io_channel_unix_new(end_pipe[0]);\n g_io_channel_set_encoding(thread->end_read, NULL, NULL);\n\n thread->end_write = g_io_channel_unix_new(end_pipe[1]);\n g_io_channel_set_encoding(thread->end_write, NULL, NULL);\n\n g_thread_create((GThreadFunc) thread_func, thread, TRUE, &err);\n if (err != NULL) {\n g_printerr(\"%s\\n\", err->message);\n g_error_free(err);\n goto thread_error;\n }\n\n return thread;\n\n thread_error:\n g_io_channel_shutdown(thread->start_read, FALSE, NULL);\n g_io_channel_shutdown(thread->start_write, FALSE, NULL);\n g_io_channel_shutdown(thread->end_read, FALSE, NULL);\n g_io_channel_shutdown(thread->end_write, FALSE, NULL);\n\n end_pipe_error:\n close(start_pipe[0]);\n close(start_pipe[1]);\n\n start_pipe_error:\n return NULL;\n}", "label": 0, "cwe": null, "length": 365 }, { "index": 346411, "code": "search(searcher *sp)\n{\n erec value;\n unsigned long taboffset = 0;\n\n if (sp->aborted)\n\treturn false;\n\n for (;;) {\n\t/* go to next location */\n\tif (sp->run++ == MAXRUN) {\n\t sp->tabno++;\n\t sp->run = 0;\n\t taboffset = sp->tabno * conf.tsize;\n\t}\n\n\tsp->place = ((sp->shorthash + sp->run) % conf.tsize) + taboffset;\n\tdebug(\"search @ %ld\", (long) sp->place);\n\n\t/* get the value */\n\tif ((options.exists_incore != INCORE_NO) && (sp->place < conf.tsize)) {\n\t debug(\"search: in core\");\n\t memcpy(&value, &((erec *)etab.core)[sp->place], sizeof(erec)); \n\t} else {\n\t off_t dest;\n\t dest = sp->place * sizeof(erec);\n\n\t /* read it */\n\t errno = 0;\n\t if (pread(etab.fd, &value, sizeof(erec), dest) != sizeof(erec)) {\n\t\tif (errno != 0) {\n\t\t debug(\"search: read failed\");\n\t\t etab.pos = -1;\n\t\t sp->aborted = 1;\n\t\t return false;\n\t\t} else {\n\t\t memset(&value, '\\0', sizeof(erec));\n\t\t}\n\t }\n\n\t /* and finish up */\n\t etab.pos += sizeof(erec);\n\t}\n\n\t/* Check for an empty record */\n\tif (!memcmp(&value, &empty_rec, sizeof(erec))) {\n\t debug(\"search: empty slot\");\n\t return false;\n\t}\n\n\t/* check the value */\n\tdebug(\"got 0x%.*s\", DBZ_INTERNAL_HASH_SIZE, value.hash);\n\tif (!memcmp(&value.hash, &sp->hash, DBZ_INTERNAL_HASH_SIZE)) {\n\t return true;\n\t}\n }\n /* NOTREACHED */\n}", "label": 0, "cwe": null, "length": 415 }, { "index": 41048, "code": "prevTradeDate(const MSDate& aDate_,const MSResourceCodeSet& rCodeSet_)\n{\n if(aDate_.isSet()==MSFalse) return MSDate::nullDate();\n\n MSDate aDate(aDate_);\n MSGUARD(holidaySetMutex);\n\n do\n {\n --aDate;\n }\n while (_isValidTradeDate(aDate,holidaySet(),rCodeSet_)!=MSTrue);\n return aDate;\n}", "label": 0, "cwe": null, "length": 97 }, { "index": 466976, "code": "get_register_name(num)\n int num;\n{\n if (num == -1)\n\treturn '\"';\n else if (num < 10)\n\treturn num + '0';\n else if (num == DELETION_REGISTER)\n\treturn '-';\n#ifdef FEAT_CLIPBOARD\n else if (num == STAR_REGISTER)\n\treturn '*';\n else if (num == PLUS_REGISTER)\n\treturn '+';\n#endif\n else\n {\n#ifdef EBCDIC\n\tint i;\n\n\t/* EBCDIC is really braindead ... */\n\ti = 'a' + (num - 10);\n\tif (i > 'i')\n\t i += 7;\n\tif (i > 'r')\n\t i += 8;\n\treturn i;\n#else\n\treturn num + 'a' - 10;\n#endif\n }\n}", "label": 0, "cwe": null, "length": 163 }, { "index": 367552, "code": "assemble_static_space (size)\n int size;\n{\n char name[12];\n const char *namestring;\n rtx x;\n\n#if 0\n if (flag_shared_data)\n data_section ();\n#endif\n\n ASM_GENERATE_INTERNAL_LABEL (name, \"LF\", const_labelno);\n ++const_labelno;\n namestring = ggc_strdup (name);\n\n x = gen_rtx_SYMBOL_REF (Pmode, namestring);\n\n#ifdef ASM_OUTPUT_ALIGNED_DECL_LOCAL\n ASM_OUTPUT_ALIGNED_DECL_LOCAL (asm_out_file, NULL_TREE, name, size,\n\t\t\t\t BIGGEST_ALIGNMENT);\n#else\n#ifdef ASM_OUTPUT_ALIGNED_LOCAL\n ASM_OUTPUT_ALIGNED_LOCAL (asm_out_file, name, size, BIGGEST_ALIGNMENT);\n#else\n {\n /* Round size up to multiple of BIGGEST_ALIGNMENT bits\n so that each uninitialized object starts on such a boundary. */\n /* Variable `rounded' might or might not be used in ASM_OUTPUT_LOCAL. */\n int rounded ATTRIBUTE_UNUSED\n = ((size + (BIGGEST_ALIGNMENT / BITS_PER_UNIT) - 1)\n\t / (BIGGEST_ALIGNMENT / BITS_PER_UNIT)\n\t * (BIGGEST_ALIGNMENT / BITS_PER_UNIT));\n ASM_OUTPUT_LOCAL (asm_out_file, name, size, rounded);\n }\n#endif\n#endif\n return x;\n}", "label": 0, "cwe": null, "length": 276 }, { "index": 982363, "code": "comparecase(const FXchar* s1,const FXchar* s2,FXint n){\n register FXint c1,c2;\n if(0emulate_terminal,\n d->terminal_row,\n d->terminal_col,\n d->terminal_cursor,\n d->terminal_delayed_wrap,\n len);\n\n ___printf (\"\\\"\");\n\n for (i=0; i= 127)\n ___printf (\"\\\\x%02x\", buf[i]);\n else\n ___printf (\"%c\", buf[i]);\n\n ___printf (\"\\\"\\n\");\n }\n\n#endif\n\n if (d->emulate_terminal)\n {\n d->emulate_terminal = 0;\n e = lineeditor_output_terminal_emulate (d, buf, len);\n d->emulate_terminal = 1;\n }\n else\n e = extensible_string_insert\n (&d->output_char,\n d->output_char.length,\n len,\n buf);\n\n#ifdef USE_WIN32\n e = lineeditor_output_drain (d);/******************************/\n#endif\n\n return e;\n}", "label": 0, "cwe": null, "length": 350 }, { "index": 123012, "code": "on_button_add_field()\n{\n //Get the chosen fields:\n type_list_field_items fields_list = offer_field_list(m_table_name, this);\n for(type_list_field_items::iterator iter_chosen = fields_list.begin(); iter_chosen != fields_list.end(); ++iter_chosen)\n {\n sharedptr field = *iter_chosen;\n if(!field)\n continue;\n\n //Add the field details to the layout treeview:\n Gtk::TreeModel::iterator iter = append_appropriate_row();\n\n if(iter)\n {\n Gtk::TreeModel::Row row = *iter;\n row[m_ColumnsFields.m_col_layout_item] = field;\n\n //Scroll to, and select, the new row:\n Glib::RefPtr refTreeSelection = m_treeview_fields->get_selection();\n if(refTreeSelection)\n refTreeSelection->select(iter);\n\n m_treeview_fields->scroll_to_row( Gtk::TreeModel::Path(iter) );\n\n treeview_fill_sequences(m_model_fields, m_ColumnsFields.m_col_sequence); //The document should have checked this already, but it does not hurt to check again.\n }\n }\n}", "label": 0, "cwe": null, "length": 252 }, { "index": 32553, "code": "HandleStanza(const XmlElement * stanza) {\n if (stanza->Name() != QN_PRESENCE)\n return false;\n QueueStanza(stanza);\n return true;\n}", "label": 0, "cwe": null, "length": 42 }, { "index": 640807, "code": "Pa2OssFormat( PaSampleFormat paFormat, int *ossFormat )\n{\n switch( paFormat )\n {\n case paUInt8:\n *ossFormat = AFMT_U8;\n break;\n case paInt8:\n *ossFormat = AFMT_S8;\n break;\n case paInt16:\n *ossFormat = AFMT_S16_NE;\n break;\n default:\n return paInternalError; /* This shouldn't happen */\n }\n\n return paNoError;\n}", "label": 0, "cwe": null, "length": 110 }, { "index": 141211, "code": "wti_nps_set_config(StonithPlugin * s, StonithNVpair *list)\n{\n\tstruct pluginDevice*\tnps;\n\tStonithNamesToGet\tnamestocopy [] =\n\t{\t{ST_IPADDR,\tNULL}\n\t,\t{ST_PASSWD,\tNULL}\n\t,\t{NULL,\t\tNULL}\n\t};\n\tint\trc;\n\n\tif (Debug) {\n\t\tLOG(PIL_DEBUG, \"%s: called.\\n\", __FUNCTION__);\n\t}\n\n\tERRIFWRONGDEV(s,S_OOPS);\n\n\tnps = (struct pluginDevice*) s;\n\n\tif ((rc = OurImports->CopyAllValues(namestocopy, list)) != S_OK) {\n\t\treturn rc;\n\t}\n\tnps->device = namestocopy[0].s_value;\n\tnps->passwd = namestocopy[1].s_value;\n\treturn S_OK;\t\n}", "label": 0, "cwe": null, "length": 184 }, { "index": 704810, "code": "producer(void *arg) {\n\tlong i, index;\n\tlong id;\n\tstruct producer_info *info;\n\n\tinfo = arg;\n\n\tid = gwthread_self();\n\tindex = info->start_index;\n\tfor (i = 0; i < NUM_ITEMS_PER_PRODUCER; ++i, ++index)\n\t\tgwlist_produce(info->list, new_item(id, i, index));\n\tgwlist_remove_producer(info->list);\n}", "label": 0, "cwe": null, "length": 89 }, { "index": 607567, "code": "dsp_rx_off_member(struct dsp *dsp)\n{\n\tstruct mISDN_ctrl_req\tcq;\n\tint rx_off = 1;\n\n\tmemset(&cq, 0, sizeof(cq));\n\n\tif (!dsp->features_rx_off)\n\t\treturn;\n\n\t/* not disabled */\n\tif (!dsp->rx_disabled)\n\t\trx_off = 0;\n\t/* software dtmf */\n\telse if (dsp->dtmf.software)\n\t\trx_off = 0;\n\t/* echo in software */\n\telse if (dsp->echo.software)\n\t\trx_off = 0;\n\t/* bridge in software */\n\telse if (dsp->conf && dsp->conf->software)\n\t\trx_off = 0;\n\t/* data is not required by user space and not required\n\t * for echo dtmf detection, soft-echo, soft-bridging */\n\n\tif (rx_off == dsp->rx_is_off)\n\t\treturn;\n\n\tif (!dsp->ch.peer) {\n\t\tif (dsp_debug & DEBUG_DSP_CORE)\n\t\t\tprintk(KERN_DEBUG \"%s: no peer, no rx_off\\n\",\n\t\t\t __func__);\n\t\treturn;\n\t}\n\tcq.op = MISDN_CTRL_RX_OFF;\n\tcq.p1 = rx_off;\n\tif (dsp->ch.peer->ctrl(dsp->ch.peer, CONTROL_CHANNEL, &cq)) {\n\t\tprintk(KERN_DEBUG \"%s: 2nd CONTROL_CHANNEL failed\\n\",\n\t\t __func__);\n\t\treturn;\n\t}\n\tdsp->rx_is_off = rx_off;\n\tif (dsp_debug & DEBUG_DSP_CORE)\n\t\tprintk(KERN_DEBUG \"%s: %s set rx_off = %d\\n\",\n\t\t __func__, dsp->name, rx_off);\n}", "label": 0, "cwe": null, "length": 340 }, { "index": 121523, "code": "B64ToAscii(unsigned char *in, int length)\n{\n for(int offset=0; offset 11)\n\t{\n\t if(ch > 37)\n\t\tch += 'a' - 38;\n\t else\n\t\tch += 'A' - 12;\n\t} else\n\t ch = B642AsciiTable[ ch ];\n\t\n\tin[offset] = ch;\n }\n}", "label": 0, "cwe": null, "length": 98 }, { "index": 371602, "code": "CalcFov (float fov_x, float width, float height)\n{\n\tif (fov_x < 1 || fov_x > 179)\n\t\tCom_Error (ERR_DROP, \"Bad fov: %f\", fov_x);\n\n\twidth = width/(float)tan(fov_x/360*M_PI);\n\n\treturn (float)atan2(height, width)*360/M_PI;\n}", "label": 0, "cwe": null, "length": 78 }, { "index": 158690, "code": "dlm_end_recovery(struct dlm_ctxt *dlm)\n{\n\tspin_lock(&dlm->spinlock);\n\tBUG_ON(!(dlm->reco.state & DLM_RECO_STATE_ACTIVE));\n\tdlm->reco.state &= ~DLM_RECO_STATE_ACTIVE;\n\tspin_unlock(&dlm->spinlock);\n\tprintk(KERN_NOTICE \"o2dlm: End recovery on domain %s\\n\", dlm->name);\n\twake_up(&dlm->reco.event);\n}", "label": 0, "cwe": null, "length": 99 }, { "index": 568046, "code": "GetBucketNeighbors(vtkNeighborPoints* buckets,\n const int ijk[3], const int ndivs[3],\n int level)\n{\n int i, j, k, min, max, minLevel[3], maxLevel[3];\n int nei[3];\n //\n // Initialize\n //\n buckets->Reset();\n //\n // If at this bucket, just place into list\n //\n if ( level == 0 ) \n {\n buckets->InsertNextPoint(ijk);\n return;\n }\n //\n // Create permutations of the ijk indices that are at the level\n // required. If these are legal buckets, add to list for searching.\n //\n for ( i=0; i<3; i++ ) \n {\n min = ijk[i] - level;\n max = ijk[i] + level;\n minLevel[i] = ( min > 0 ? min : 0);\n maxLevel[i] = ( max < (ndivs[i]-1) ? max : (ndivs[i]-1));\n }\n\n for ( i= minLevel[0]; i <= maxLevel[0]; i++ ) \n {\n for ( j= minLevel[1]; j <= maxLevel[1]; j++ ) \n {\n for ( k= minLevel[2]; k <= maxLevel[2]; k++ ) \n {\n if (i == (ijk[0] + level) || i == (ijk[0] - level) ||\n j == (ijk[1] + level) || j == (ijk[1] - level) ||\n k == (ijk[2] + level) || k == (ijk[2] - level) ) \n {\n nei[0]=i; nei[1]=j; nei[2]=k;\n buckets->InsertNextPoint(nei);\n }\n }\n }\n }\n\n return;\n}", "label": 0, "cwe": null, "length": 420 }, { "index": 474279, "code": "addAvailability(const DayAvailability &availability)\n{\n Q_ASSERT(d->m_UserCalendar);\n Q_ASSERT(IN_RANGE(availability.weekDay(), Qt::Monday, Qt::Sunday));\n\n d->m_UserCalendar->addAvailabilities(availability);\n\n // find the day item\n QStandardItem *dayItem = 0;\n for(int i = 0; i < invisibleRootItem()->rowCount(); ++i) {\n if (invisibleRootItem()->child(i)->data(WeekDayRole).toInt() == availability.weekDay()) {\n dayItem = invisibleRootItem()->child(i);\n break;\n }\n }\n\n // at this point there MUST be a valid dayItem. If not, something really bad happened.\n Q_ASSERT(dayItem);\n\n // delete the placeholder item, if exists\n if (dayItem->hasChildren() && dayItem->child(0)->data(AvailIdRole).toInt() == -1)\n dayItem->removeRow(0);\n\n // Insert the TimeRanges\n for(int i = 0; i < availability.timeRangeCount(); ++i) {\n TimeRange range = availability.timeRangeAt(i);\n QStandardItem *timeItem = new QStandardItem(tkTr(Trans::Constants::FROM_1_TO_2).arg(range.from.toString()).arg(range.to.toString()));\n timeItem->setData(availability.weekDay(), WeekDayRole);\n timeItem->setData(range.from, HourFromRole);\n timeItem->setData(range.to, HourToRole);\n timeItem->setToolTip(timeItem->text());\n dayItem->appendRow(timeItem);\n }\n dayItem->sortChildren(0);\n\n}", "label": 1, "cwe": "CWE-476", "length": 346 }, { "index": 318204, "code": "ossl_ec_key_dsa_sign_asn1(VALUE self, VALUE data)\n{\n EC_KEY *ec;\n unsigned int buf_len;\n VALUE str;\n\n Require_EC_KEY(self, ec);\n StringValue(data);\n\n if (EC_KEY_get0_private_key(ec) == NULL)\n\tossl_raise(eECError, \"Private EC key needed!\");\n\n str = rb_str_new(0, ECDSA_size(ec) + 16);\n if (ECDSA_sign(0, (unsigned char *) RSTRING_PTR(data), RSTRING_LENINT(data), (unsigned char *) RSTRING_PTR(str), &buf_len, ec) != 1)\n ossl_raise(eECError, \"ECDSA_sign\");\n\n rb_str_resize(str, buf_len);\n\n return str;\n}", "label": 0, "cwe": null, "length": 162 }, { "index": 487551, "code": "bytes_to_kb_long(u_long bytes, char *kb)\n{\n\tif(bytes < 1048576)\n\t\tsprintf(kb,\"%.3fk\",(float)(bytes) / 1024.0);\n\telse\n\t\tsprintf(kb,\"%.3fM\",(float)(bytes) / 1048576.0);\n}", "label": 1, "cwe": "CWE-120", "length": 67 }, { "index": 542996, "code": "_e_spectrum_smart_resize(Evas_Object *o, Evas_Coord w, Evas_Coord h)\n{\n E_Spectrum *sp;\n\n sp = evas_object_smart_data_get(o);\n if (!sp) return;\n\n evas_object_image_fill_set(sp->o_spectrum, 0, 0, w, h);\n\n evas_object_resize(sp->o_spectrum, w, h);\n evas_object_resize(sp->o_event, w, h);\n evas_object_resize(sp->o_cursor, w, h);\n}", "label": 0, "cwe": null, "length": 114 }, { "index": 942783, "code": "m_get_context(pIIR_AttrArrayFunc a, ContextInfo &ctxt, RegionStack &rstack, \n\t bool target, int level)\n{\n pAccessDescriptor p = NULL;\n if (a->array != NULL)\n p = get_context(a->array, ctxt, rstack, false, level);\n else if (a->array_type != NULL)\n p = get_context(a->array_type, ctxt, rstack, false, level);\n\n return p;\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 70, "code": "do_mirror(struct work_struct *work)\n{\n\tstruct mirror_set *ms = container_of(work, struct mirror_set,\n\t\t\t\t\t kmirrord_work);\n\tstruct bio_list reads, writes, failures;\n\tunsigned long flags;\n\n\tspin_lock_irqsave(&ms->lock, flags);\n\treads = ms->reads;\n\twrites = ms->writes;\n\tfailures = ms->failures;\n\tbio_list_init(&ms->reads);\n\tbio_list_init(&ms->writes);\n\tbio_list_init(&ms->failures);\n\tspin_unlock_irqrestore(&ms->lock, flags);\n\n\tdm_rh_update_states(ms->rh, errors_handled(ms));\n\tdo_recovery(ms);\n\tdo_reads(ms, &reads);\n\tdo_writes(ms, &writes);\n\tdo_failures(ms, &failures);\n}", "label": 0, "cwe": null, "length": 160 }, { "index": 444255, "code": "hw_fast_io_fail_handler(vector strvec)\n{\n\tchar * buff;\n\tstruct hwentry * hwe = VECTOR_LAST_SLOT(conf->hwtable);\n\n\tbuff = set_value(strvec);\n\tif (strlen(buff) == 3 && !strcmp(buff, \"off\"))\n\t\thwe->fast_io_fail = -1;\n\telse if (sscanf(buff, \"%d\", &hwe->fast_io_fail) != 1 ||\n\t\t hwe->fast_io_fail < -1)\n\t\thwe->fast_io_fail = 0;\n\n\tFREE(buff);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 117 }, { "index": 766, "code": "handle_upload_file_status() {\n char path[MAXPATHLEN], buf[MAXPATHLEN], log_name[MAXPATHLEN], *p, log_buf[256];\n std::string filename;\n int status;\n\n relative_to_absolute(\"\", path);\n DirScanner dirscan(path);\n while (dirscan.scan(filename)) {\n strlcpy(buf, filename.c_str(), sizeof(buf));\n if (strstr(buf, UPLOAD_FILE_STATUS_PREFIX) != buf) continue;\n strlcpy(log_name, buf+strlen(UPLOAD_FILE_STATUS_PREFIX), sizeof(log_name));\n FILE* f = boinc_fopen(filename.c_str(), \"r\");\n if (!f) {\n fprintf(stderr,\n \"%s handle_file_upload_status: can't open %s\\n\",\n boinc_msg_prefix(buf, sizeof(buf)), filename.c_str()\n );\n continue;\n }\n p = fgets(buf, sizeof(buf), f);\n fclose(f);\n if (p && parse_int(buf, \"\", status)) {\n UPLOAD_FILE_STATUS uf;\n uf.name = std::string(log_name);\n uf.status = status;\n upload_file_status.push_back(uf);\n } else {\n fprintf(stderr, \"%s handle_upload_file_status: can't parse %s\\n\",\n boinc_msg_prefix(log_buf, sizeof(log_buf)), buf\n );\n }\n }\n}", "label": 0, "cwe": null, "length": 281 }, { "index": 55796, "code": "chat_triggerevent(struct chat_data *cd)\n{\n\tnullpo_retr(0, cd);\n\n\tif(cd->users >= cd->trigger && cd->npc_event[0])\n\t\tnpc_event_do(cd->npc_event);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 53 }, { "index": 621395, "code": "process_file(tcp_port_monitor_collection_t *p_collection, const char *file)\n{\n\tFILE *fp;\n\tchar buf[256];\n\tchar local_addr[40];\n\tchar remote_addr[40];\n\ttcp_connection_t conn;\n\tunsigned long inode, uid, state;\n\n\tif ((fp = fopen(file, \"r\")) == NULL) {\n\t\treturn;\n\t}\n\n\t/* ignore field name line */\n\tfgets(buf, 255, fp);\n\n\t/* read all tcp connections */\n\twhile (fgets(buf, sizeof(buf), fp) != NULL) {\n\n\t\tif (sscanf(buf,\n\t\t\t\t\"%*d: %39[0-9a-fA-F]:%hx %39[0-9a-fA-F]:%hx %lx %*x:%*x %*x:%*x %*x %lu %*d %lu\",\n\t\t\t\tlocal_addr, &conn.local_port,\n\t\t\t\tremote_addr, &conn.remote_port,\n\t\t\t\t(unsigned long *) &state, (unsigned long *) &uid,\n\t\t\t\t(unsigned long *) &inode) != 7) {\n\t\t\tfprintf(stderr, \"/proc/net/tcp: bad file format\\n\");\n\t\t}\n\t\t/** TCP_ESTABLISHED equals 1, but is not (always??) included **/\n\t\t//if ((inode == 0) || (state != TCP_ESTABLISHED)) {\n\t\tif((inode == 0) || (state != 1)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tstring_to_addr(&conn.local_addr, local_addr);\n\t\tstring_to_addr(&conn.remote_addr, remote_addr);\n\n\t\t/* show the connection to each port monitor. */\n\t\tfor_each_tcp_port_monitor_in_collection(p_collection,\n\t\t\t&show_connection_to_tcp_port_monitor, (void *) &conn);\n\t}\n\n\tfclose(fp);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-other" ], "length": 368 }, { "index": 398968, "code": "symb_init_gui(void)\n{\n int i, code;\n\n for (i = 0; default_symb_table[i].name[0]; i++) {\n\tcode = get_symb_code(default_symb_table[i].name);\n\ti_set_color(default_symb_table[i].name, Symb[code].r, Symb[code].g,\n\t\t Symb[code].b);\n\ti_set_on(default_symb_table[i].name, Symb[code].on);\n }\n}", "label": 0, "cwe": null, "length": 99 }, { "index": 444210, "code": "nSigma(long N,BranchingInfo den) {\n return obsBranching == 0.0 ?\n 0.0 :\n (simBranching(N,den) - obsBranching) \n / sqrt(sqr(simError(N,den)) + sqr(obsError));\n}", "label": 0, "cwe": null, "length": 61 }, { "index": 9041, "code": "http_get_parse(struct soap *soap)\n{\n#ifndef WITH_LEAN\n time_t t;\n struct tm T, *pT;\n#endif\n struct http_get_data *data = (struct http_get_data*)soap_lookup_plugin(soap, http_get_id);\n if (!data)\n return SOAP_PLUGIN_ERROR;\n#ifndef WITH_LEAN\n time(&t);\n#ifdef HAVE_LOCALTIME_R\n pT = localtime_r(&t, &T);\n#else\n pT = localtime(&t);\n#endif\n /* updates should be in mutex, but we don't mind some inaccuracy in the count to preserve performance */\n data->day[pT->tm_yday]++;\n data->day[(pT->tm_yday + 1) % 365] = 0;\n data->hour[pT->tm_hour]++;\n data->hour[(pT->tm_hour + 1) % 24] = 0;\n data->min[pT->tm_min]++;\n data->min[(pT->tm_min + 1) % 60] = 0;\n#endif\n soap->error = data->fparse(soap); /* parse HTTP header */\n if (soap->error == SOAP_OK)\n { /* update should be in mutex, but we don't mind some inaccuracy in the count */\n data->stat_post++;\n }\n else if (soap->error == SOAP_GET_METHOD && data->fget)\n { soap->error = SOAP_OK;\n if ((soap->error = data->fget(soap))) /* call user-defined HTTP GET handler */\n { /* update should be in mutex, but we don't mind some inaccuracy in the count */\n data->stat_fail++;\n return soap->error;\n }\n /* update should be in mutex, but we don't mind some inaccuracy in the count */\n data->stat_get++;\n return SOAP_STOP; /* stop processing the request and do not return SOAP Fault */\n }\n else\n { /* update should be in mutex, but we don't mind some inaccuracy in the count */\n data->stat_fail++;\n }\n return soap->error;\n}", "label": 0, "cwe": null, "length": 452 }, { "index": 692374, "code": "exo_icon_view_enable_model_drag_source (ExoIconView *icon_view,\n GdkModifierType start_button_mask,\n const GtkTargetEntry *targets,\n gint n_targets,\n GdkDragAction actions)\n{\n g_return_if_fail (EXO_IS_ICON_VIEW (icon_view));\n\n gtk_drag_source_set (GTK_WIDGET (icon_view), 0, NULL, 0, actions);\n\n clear_source_info (icon_view);\n icon_view->priv->start_button_mask = start_button_mask;\n icon_view->priv->source_targets = gtk_target_list_new (targets, n_targets);\n icon_view->priv->source_actions = actions;\n\n icon_view->priv->source_set = TRUE;\n\n unset_reorderable (icon_view);\n}", "label": 0, "cwe": null, "length": 160 }, { "index": 137166, "code": "_e2_about_dialog_response_cb (GtkDialog *dialog, gint response,\n\tE2_Sextet *data)\n{\n\tgchar *command;\n\tswitch (response)\n\t{\n\t\tcase E2_RESPONSE_USER1:\t//read button click\n\t\t\tif (data->d == data->a)\t//check whether a file-headiong is used\n\t\t\t\tcommand = g_strconcat(_A(5),\".\",_A(101), NULL);\t//file.view\n\t\t\telse\n\t\t\t\tcommand = g_strconcat(_A(5),\".\",_A(103), NULL);\t//file.view_at\n\t\t\te2_action_run_simple (command, (gchar *)data->d);\n\t\t\tg_free (command);\n\t\t\tbreak;\n\t\tdefault:\n\t\t//cleanup the strings constructed when dialog set up\n\t\t\tF_FREE (data->a);\n\t\t\tg_free (data->b);\n\t\t\tg_free (data->c);\n\t\t\te2_utils_sextet_destroy (data);\n\t\t\tgtk_widget_destroy (GTK_WIDGET (dialog));\n\t\t\tbreak;\n\t}\n}", "label": 0, "cwe": null, "length": 219 }, { "index": 74951, "code": "bb_get_last_path_component_nostrip(const char *path)\n{\n\tchar *slash = strrchr(path, '/');\n\n\tif (!slash || (slash == path && !slash[1]))\n\t\treturn (char*)path;\n\n\treturn slash + 1;\n}", "label": 0, "cwe": null, "length": 53 }, { "index": 690784, "code": "qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)\n{\n if (_c == QMetaObject::InvokeMetaMethod) {\n Q_ASSERT(staticMetaObject.cast(_o));\n GEditor *_t = static_cast(_o);\n switch (_id) {\n case 0: _t->cursorMoved(); break;\n case 1: _t->textChanged(); break;\n case 2: _t->marginClicked((*reinterpret_cast< int(*)>(_a[1]))); break;\n case 3: _t->marginDoubleClicked((*reinterpret_cast< int(*)>(_a[1]))); break;\n case 4: _t->blinkTimerTimeout(); break;\n case 5: _t->scrollTimerTimeout(); break;\n case 6: _t->unflash(); break;\n case 7: _t->docTextChangedLater(); break;\n case 8: _t->ensureCursorVisible(); break;\n default: ;\n }\n }\n}", "label": 0, "cwe": null, "length": 225 }, { "index": 138049, "code": "Remove(Player* player, bool remove)\n{\n DETAIL_LOG(\"MAP: Removing player '%s' from bg '%u' of map '%s' before relocating to other map\", player->GetName(), GetInstanceId(), GetMapName());\n Map::Remove(player, remove);\n}", "label": 0, "cwe": null, "length": 59 }, { "index": 709242, "code": "hash_list_list(hash_list_t *hl)\n{\n\tGList *l = NULL;\n\tlink_t *lk;\n\n\thash_list_check(hl);\n\n\tfor (lk = elist_last(&hl->list); lk != NULL; lk = elist_prev(lk)) {\n\t\tstruct hash_list_item *item = ITEM(lk);\n\n\t\tl = g_list_prepend(l, deconstify_pointer(item->key));\n\t}\n\n\treturn l;\n}", "label": 0, "cwe": null, "length": 89 }, { "index": 32109, "code": "totalize(struct fa *fa) {\n int r;\n struct state *crash = add_state(fa, 0);\n\n E(crash == NULL);\n F(mark_reachable(fa));\n sort_transition_intervals(fa);\n\n r = add_crash_trans(fa, crash, crash, UCHAR_MIN, UCHAR_MAX);\n if (r < 0)\n return -1;\n\n list_for_each(s, fa->initial) {\n int next = UCHAR_MIN;\n int tused = s->tused;\n for (int i=0; i < tused; i++) {\n uchar min = s->trans[i].min, max = s->trans[i].max;\n if (min > next) {\n r = add_crash_trans(fa, s, crash, next, min - 1);\n if (r < 0)\n return -1;\n }\n if (max + 1 > next)\n next = max + 1;\n }\n if (next <= UCHAR_MAX) {\n r = add_crash_trans(fa, s, crash, next, UCHAR_MAX);\n if (r < 0)\n return -1;\n }\n }\n return 0;\n error:\n return -1;\n}", "label": 0, "cwe": null, "length": 269 }, { "index": 875933, "code": "ajFloat3dPut(AjPFloat3d *thys,\n\t\t ajuint elem1, ajuint elem2, ajuint elem3, float v)\n{\n if(!thys || !*thys)\n\tajErr(\"Attempt to write to illegal array value [%d][%d][%d]\\n\",elem1,\n\t elem2,elem3);\n\n if(elem1 < (*thys)->Res)\n {\n\tif(elem1>=(*thys)->Len)\n\t (*thys)->Len = elem1+1;\n\tif(!(*thys)->Ptr[elem1])\n\t (*thys)->Ptr[elem1] = ajFloat2dNew();\n\treturn ajFloat2dPut(&(*thys)->Ptr[elem1],elem2,elem3,v);\n }\n\n arrFloat3dResize(thys, elem1);\n\n if(!(*thys)->Ptr[elem1])\n\t(*thys)->Ptr[elem1] = ajFloat2dNew();\n\n ajFloat2dPut(&(*thys)->Ptr[elem1],elem2,elem3,v);\n\n return ajTrue;\n}", "label": 1, "cwe": "CWE-476", "length": 237 }, { "index": 574622, "code": "glp_add_arc(glp_graph *G, int i, int j)\n{ glp_arc *a;\n if (!(1 <= i && i <= G->nv))\n xerror(\"glp_add_arc: i = %d; tail vertex number out of range\\n\"\n , i);\n if (!(1 <= j && j <= G->nv))\n xerror(\"glp_add_arc: j = %d; head vertex number out of range\\n\"\n , j);\n if (G->na == NA_MAX)\n xerror(\"glp_add_arc: too many arcs\\n\");\n a = dmp_get_atom(G->pool, sizeof(glp_arc));\n a->tail = G->v[i];\n a->head = G->v[j];\n if (G->a_size == 0)\n a->data = NULL;\n else\n { a->data = dmp_get_atom(G->pool, G->a_size);\n memset(a->data, 0, G->a_size);\n }\n a->temp = NULL;\n a->t_prev = NULL;\n a->t_next = G->v[i]->out;\n if (a->t_next != NULL) a->t_next->t_prev = a;\n a->h_prev = NULL;\n a->h_next = G->v[j]->in;\n if (a->h_next != NULL) a->h_next->h_prev = a;\n G->v[i]->out = G->v[j]->in = a;\n G->na++;\n return a;\n}", "label": 0, "cwe": null, "length": 336 }, { "index": 330408, "code": "ata_scsi_slave_config(struct scsi_device *sdev)\n{\n\tstruct ata_port *ap = ata_shost_to_port(sdev->host);\n\tstruct ata_device *dev = __ata_scsi_find_dev(ap, sdev);\n\tint rc = 0;\n\n\tata_scsi_sdev_config(sdev);\n\n\tif (dev)\n\t\trc = ata_scsi_dev_config(sdev, dev);\n\n\treturn rc;\n}", "label": 0, "cwe": null, "length": 85 }, { "index": 46868, "code": "read_sample_1column_file(GabeditFileChooser *SelecFile, gint response_id)\n{\n \tgchar t[BSIZE];\n \tgboolean OK = TRUE;\n\tgint numberOfStates = 0;\n\tgdouble* energies = NULL;\n\tgdouble* intensities = NULL;\n\tgchar *FileName;\n \tFILE *fd;\n\tgdouble a;\n\tgdouble b = 1;\n\tint ne = 0;\n\n\tif(response_id != GTK_RESPONSE_OK) return FALSE;\n \tFileName = gabedit_file_chooser_get_current_file(SelecFile);\n\n \tfd = FOpen(FileName, \"rb\");\n\tif(!fd) return FALSE;\n\n \twhile(!feof(fd))\n\t{\n\t \tif(!fgets(t,BSIZE,fd))break;\n\t\tne = sscanf(t,\"%lf\",&a);\n\t\tif(ne==1)\n\t\t{\n\t\t\tnumberOfStates++;\n\t\t\tenergies = g_realloc(energies, numberOfStates*sizeof(gdouble));\n\t\t\tintensities = g_realloc(intensities, numberOfStates*sizeof(gdouble));\n\t\t\tenergies[numberOfStates-1] = a;\n\t\t\tintensities[numberOfStates-1] = b;\n\t\t}\n \t}\n\n\tif(numberOfStates>0)\n\t{\n\t\tcreateDOSSpectrumWin(numberOfStates, energies, intensities);\n\t}\n\telse\n\t{\n\t\tOK = FALSE;\n\t\tmessageErrorFreq(FileName);\n\t}\n\n\n\tif(energies) g_free(energies);\n\tif(intensities) g_free(intensities);\n\tfclose(fd);\n\treturn OK;\n}", "label": 0, "cwe": null, "length": 320 }, { "index": 206240, "code": "main (int argc,\n char *argv[])\n{\n\tGError *error = NULL;\n\tconst gchar *password;\n\tGKeyFile *file;\n\tgboolean ret;\n\tgchar *contents;\n\tgsize length;\n\n\tg_set_prgname (\"dump-keyring0-format\");\n\tgcry_check_version (GCRYPT_VERSION);\n\n\tif (argc < 2 || argc > 3) {\n\t\tg_printerr (\"usage: %s file.keyring [output]\\n\", g_get_prgname ());\n\t\treturn 2;\n\t}\n\n\tif (!g_file_get_contents (argv[1], &contents, &length, &error)) {\n\t\tg_printerr (\"%s: %s\\n\", g_get_prgname (), error->message);\n\t\tg_error_free (error);\n\t\treturn 1;\n\t}\n\n\tfile = g_key_file_new ();\n\tpassword = getpass (\"Password: \");\n\n\ttransform_keyring_binary_to_text (contents, length, password, file);\n\tg_free (contents);\n\n\tcontents = g_key_file_to_data (file, &length, &error);\n\tg_key_file_free (file);\n\n\tif (contents == NULL) {\n\t\tg_printerr (\"%s: couldn't encode: %s\", g_get_prgname (), error->message);\n\t\tg_error_free (error);\n\t\treturn 1;\n\t}\n\n\tret = TRUE;\n\tif (argc == 3)\n\t\tret = g_file_set_contents (argv[2], contents, length, &error);\n\telse\n\t\tg_print (\"%s\", contents);\n\tg_free (contents);\n\n\tif (!ret) {\n\t\tg_printerr (\"%s: %s\", g_get_prgname (), error->message);\n\t\tg_error_free (error);\n\t\treturn 1;\n\t}\n\n\treturn 0;\n}", "label": 1, "cwe": "CWE-other", "length": 356 }, { "index": 590658, "code": "store_debug_level(struct device_driver *d,\n\t\t\t\t const char *buf, size_t count)\n{\n\tu32 val;\n\tint ret;\n\n\tret = kstrtou32(buf, 0, &val);\n\tif (ret)\n\t\tIPW_DEBUG_INFO(\": %s is not in hex or decimal form.\\n\", buf);\n\telse\n\t\tipw2100_debug_level = val;\n\n\treturn strnlen(buf, count);\n}", "label": 0, "cwe": null, "length": 88 }, { "index": 759680, "code": "cpm_dump(PyObject *self, PyObject *args, PyObject *kwds)\n{\n static char *kwlist[] = {\"obj\", \"file\", \"protocol\", NULL};\n PyObject *ob, *file, *res = NULL;\n Picklerobject *pickler = 0;\n int proto = 0;\n\n if (!( PyArg_ParseTupleAndKeywords(args, kwds, \"OO|i\", kwlist,\n &ob, &file, &proto)))\n goto finally;\n\n if (!( pickler = newPicklerobject(file, proto)))\n goto finally;\n\n if (dump(pickler, ob) < 0)\n goto finally;\n\n Py_INCREF(Py_None);\n res = Py_None;\n\n finally:\n Py_XDECREF(pickler);\n\n return res;\n}", "label": 0, "cwe": null, "length": 166 }, { "index": 583240, "code": "mbfl_filt_conv_any_hz_flush(mbfl_convert_filter *filter)\n{\n\t/* back to latin */\n\tif ((filter->status & 0xff00) != 0) {\n\t\tCK((*filter->output_function)(0x7e, filter->data));\t\t/* ~ */\n\t\tCK((*filter->output_function)(0x7d, filter->data));\t\t/* '{' */\n\t}\n\tfilter->status &= 0xff;\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 100 }, { "index": 227427, "code": "gnc_tree_model_account_types_get_path (GtkTreeModel * tree_model,\n GtkTreeIter * iter)\n{\n GncTreeModelAccountTypes *model = GNC_TREE_MODEL_ACCOUNT_TYPES(tree_model);\n GtkTreePath *path;\n\n g_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT_TYPES (model), NULL);\n g_return_val_if_fail (iter != NULL, NULL);\n g_return_val_if_fail (iter->stamp == model->stamp, NULL);\n\n path = gtk_tree_path_new ();\n\n gtk_tree_path_append_index (path, GPOINTER_TO_INT (iter->user_data));\n\n return path;\n}", "label": 0, "cwe": null, "length": 133 }, { "index": 109262, "code": "checkPathHandling(const OFString& input, const OFString& normalized,\n const OFString& combined, const OFString& file = \"file\")\n{\n OFString tmpString;\n OFString slashFile;\n slashFile = PATH_SEPARATOR;\n slashFile += \"file\";\n\n OFStandard::normalizeDirName(tmpString, input);\n OFCHECK_EQUAL(tmpString, normalized);\n\n OFStandard::combineDirAndFilename(tmpString, input, file);\n OFCHECK_EQUAL(tmpString, combined);\n\n OFStandard::combineDirAndFilename(tmpString, input, PATH_SEPARATOR + file);\n OFCHECK_EQUAL(tmpString, slashFile);\n}", "label": 0, "cwe": null, "length": 133 }, { "index": 205690, "code": "main (int argc, char **argv)\n{\n\tGMainLoop *loop;\n\tSoupServer *server;\n\tSoupURI *uri;\n\tSoupAuthDomain *auth_domain;\n\n\ttest_init (argc, argv, no_test_entry);\n\n\tserver = soup_test_server_new (FALSE);\n\tg_signal_connect (server, \"request_started\",\n\t\t\t G_CALLBACK (request_started_callback), NULL);\n\tsoup_server_add_handler (server, NULL,\n\t\t\t\t server_callback, NULL, NULL);\n\n\tauth_domain = soup_auth_domain_basic_new (\n\t\tSOUP_AUTH_DOMAIN_REALM, \"server-auth-test\",\n\t\tSOUP_AUTH_DOMAIN_ADD_PATH, \"/Basic\",\n\t\tSOUP_AUTH_DOMAIN_ADD_PATH, \"/Any\",\n\t\tSOUP_AUTH_DOMAIN_REMOVE_PATH, \"/Any/Not\",\n\t\tSOUP_AUTH_DOMAIN_BASIC_AUTH_CALLBACK, basic_auth_callback,\n\t\tNULL);\n\tsoup_server_add_auth_domain (server, auth_domain);\n\tg_object_unref (auth_domain);\n\n\tauth_domain = soup_auth_domain_digest_new (\n\t\tSOUP_AUTH_DOMAIN_REALM, \"server-auth-test\",\n\t\tSOUP_AUTH_DOMAIN_ADD_PATH, \"/Digest\",\n\t\tSOUP_AUTH_DOMAIN_ADD_PATH, \"/Any\",\n\t\tSOUP_AUTH_DOMAIN_REMOVE_PATH, \"/Any/Not\",\n\t\tSOUP_AUTH_DOMAIN_DIGEST_AUTH_CALLBACK, digest_auth_callback,\n\t\tNULL);\n\tsoup_server_add_auth_domain (server, auth_domain);\n\tg_object_unref (auth_domain);\n\n\tloop = g_main_loop_new (NULL, TRUE);\n\n\tif (run_tests) {\n\t\turi = soup_uri_new (\"http://127.0.0.1\");\n\t\tsoup_uri_set_port (uri, soup_server_get_port (server));\n\t\tdo_auth_tests (uri);\n\t\tsoup_uri_free (uri);\n\t} else {\n\t\tg_print (\"Listening on port %d\\n\", soup_server_get_port (server));\n\t\tg_main_loop_run (loop);\n\t}\n\n\tg_main_loop_unref (loop);\n\tsoup_test_server_quit_unref (server);\n\n\tif (run_tests)\n\t\ttest_cleanup ();\n\treturn errors != 0;\n}", "label": 0, "cwe": null, "length": 419 }, { "index": 804743, "code": "check(THD *thd)\n{\n var->do_deprecated_warning(thd);\n if (var->is_readonly())\n {\n my_error(ER_INCORRECT_GLOBAL_LOCAL_VAR, MYF(0), var->name.str, \"read only\");\n return -1;\n }\n if (var->check_type(type))\n {\n int err= type == OPT_GLOBAL ? ER_LOCAL_VARIABLE : ER_GLOBAL_VARIABLE;\n my_error(err, MYF(0), var->name.str);\n return -1;\n }\n if ((type == OPT_GLOBAL && check_global_access(thd, SUPER_ACL)))\n return 1;\n /* value is a NULL pointer if we are using SET ... = DEFAULT */\n if (!value)\n return 0;\n\n if ((!value->fixed &&\n value->fix_fields(thd, &value)) || value->check_cols(1))\n return -1;\n if (var->check_update_type(value->result_type()))\n {\n my_error(ER_WRONG_TYPE_FOR_VAR, MYF(0), var->name.str);\n return -1;\n }\n return var->check(thd, this) ? -1 : 0;\n}", "label": 0, "cwe": null, "length": 253 }, { "index": 392861, "code": "pk_gst_structure_to_provide (GstStructure *s)\n{\n\tGString *string;\n\tguint i, num_fields;\n\tGList *fields, *l;\n\n\tnum_fields = gst_structure_n_fields (s);\n\tfields = NULL;\n\n\tfor (i = 0; i < num_fields; i++) {\n\t\tconst gchar *field_name;\n\n\t\tfield_name = gst_structure_nth_field_name (s, i);\n\t\tif (pk_gst_field_get_type (field_name) < 0) {\n\t\t\tg_message (\"PackageKit: ignoring field named %s\", field_name);\n\t\t\tcontinue;\n\t\t}\n\n\t\tfields = g_list_insert_sorted (fields, g_strdup (field_name), (GCompareFunc) pk_gst_fields_type_compare);\n\t}\n\n\tstring = g_string_new(\"\");\n\tfor (l = fields; l != NULL; l = l->next) {\n\t\tgchar *field_name;\n\t\tGType type;\n\n\t\tfield_name = l->data;\n\n\t\ttype = gst_structure_get_field_type (s, field_name);\n\t\tg_message (\"PackageKit: field is: %s, type: %s\", field_name, g_type_name (type));\n\n\t\tif (type == G_TYPE_INT) {\n\t\t\tint value;\n\n\t\t\tgst_structure_get_int (s, field_name, &value);\n\t\t\tg_string_append_printf (string, \"(%s=%d)\", field_name, value);\n\t\t} else if (type == G_TYPE_BOOLEAN) {\n\t\t\tint value;\n\n\t\t\tgst_structure_get_boolean (s, field_name, &value);\n\t\t\tg_string_append_printf (string, \"(%s=%s)\", field_name, value ? \"true\" : \"false\");\n\t\t} else if (type == G_TYPE_STRING) {\n\t\t\tconst gchar *value;\n\n\t\t\tvalue = gst_structure_get_string (s, field_name);\n\t\t\tg_string_append_printf (string, \"(%s=%s)\", field_name, value);\n\t\t} else {\n\t\t\tg_warning (\"PackageKit: unhandled type! %s\", g_type_name (type));\n\t\t}\n\n\t\tg_free (field_name);\n\t}\n\n\tg_list_free (fields);\n\n\treturn g_string_free (string, FALSE);\n}", "label": 0, "cwe": null, "length": 450 }, { "index": 350707, "code": "gog_renderer_request_update (GogRenderer *renderer)\n{\n\tg_return_if_fail (GOG_IS_RENDERER (renderer));\n\n\tif (renderer->needs_update)\n\t\treturn;\n\trenderer->needs_update = TRUE;\n\tg_signal_emit (G_OBJECT (renderer),\n\t\trenderer_signals [RENDERER_SIGNAL_REQUEST_UPDATE], 0);\n}", "label": 0, "cwe": null, "length": 67 }, { "index": 85358, "code": "get_bool_value(OFBool defaultvalue)\n{\n OFBool result = defaultvalue;\n const char *val = get_value();\n if (val == NULL) return result;\n OFString pstring(val);\n OFString ostring;\n size_t len = pstring.length();\n unsigned char c;\n for (size_t i = 0; i= 'a') && (c <= 'z')) ostring += OFstatic_cast(char, toupper(c));\n else if ((c >= 'A') && (c <= 'Z')) ostring += c;\n else if ((c >= '0') && (c <= '9')) ostring += c;\n else if (c == '_') ostring += c;\n }\n\n if (ostring == \"YES\") result = OFTrue; else\n if (ostring == \"1\") result = OFTrue; else\n if (ostring == \"TRUE\") result = OFTrue; else\n if (ostring == \"ON\") result = OFTrue; else\n if (ostring == \"NO\") result = OFFalse; else\n if (ostring == \"0\") result = OFFalse; else\n if (ostring == \"FALSE\")result = OFFalse; else\n if (ostring == \"OFF\") result = OFFalse;\n return result;\n}", "label": 0, "cwe": null, "length": 310 }, { "index": 116272, "code": "addid(IDLIST **listp, SQLINTEGER id, SQLINTEGER val)\n\n{\n if (!*listp || (*listp)->n >= IDLISTSIZE)\n if ((*listp = newidlist(*listp)) == NULL)\n return;\n (*listp)->ids[(*listp)->n] = id;\n (*listp)->vals[(*listp)->n++] = val;\n}", "label": 0, "cwe": null, "length": 87 }, { "index": 910663, "code": "encodeExpandBuffer (OOCTXT* pctxt, ASN1UINT nbytes)\n{\n if (pctxt->buffer.dynamic)\n {\n /* If dynamic encoding is enabled, expand the current buffer to */\n /* allow encoding to continue. */\n\n pctxt->buffer.size += ASN1MAX (ASN_K_ENCBUFSIZ, nbytes);\n\n pctxt->buffer.data = (ASN1OCTET*) memHeapRealloc\n (&pctxt->pMsgMemHeap, pctxt->buffer.data, pctxt->buffer.size);\n \n if (!pctxt->buffer.data) return (ASN_E_NOMEM);\n\n return (ASN_OK);\n }\n\n return (ASN_E_BUFOVFLW);\n}", "label": 0, "cwe": null, "length": 152 }, { "index": 935002, "code": "find_control(u16 control_index,\n\tstruct hpi_control_cache *p_cache, struct hpi_control_cache_info **pI)\n{\n\tif (!control_cache_alloc_check(p_cache)) {\n\t\tHPI_DEBUG_LOG(VERBOSE,\n\t\t\t\"control_cache_alloc_check() failed %d\\n\",\n\t\t\tcontrol_index);\n\t\treturn 0;\n\t}\n\n\t*pI = p_cache->p_info[control_index];\n\tif (!*pI) {\n\t\tHPI_DEBUG_LOG(VERBOSE, \"Uncached Control %d\\n\",\n\t\t\tcontrol_index);\n\t\treturn 0;\n\t} else {\n\t\tHPI_DEBUG_LOG(VERBOSE, \"find_control() type %d\\n\",\n\t\t\t(*pI)->control_type);\n\t}\n\treturn 1;\n}", "label": 0, "cwe": null, "length": 152 }, { "index": 364980, "code": "timblogiw_g_input(struct file *file, void *priv,\n\tunsigned int *input)\n{\n\tstruct video_device *vdev = video_devdata(file);\n\n\tdev_dbg(&vdev->dev, \"%s: Entry\\n\", __func__);\n\n\t*input = 0;\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 64 }, { "index": 467758, "code": "calculate_mem_align(resource_size_t *aligns,\n\t\t\t\t\t\t int max_order)\n{\n\tresource_size_t align = 0;\n\tresource_size_t min_align = 0;\n\tint order;\n\n\tfor (order = 0; order <= max_order; order++) {\n\t\tresource_size_t align1 = 1;\n\n\t\talign1 <<= (order + 20);\n\n\t\tif (!align)\n\t\t\tmin_align = align1;\n\t\telse if (ALIGN(align + min_align, min_align) < align1)\n\t\t\tmin_align = align1 >> 1;\n\t\talign += aligns[order];\n\t}\n\n\treturn min_align;\n}", "label": 0, "cwe": null, "length": 127 }, { "index": 71665, "code": "update_cr8_intercept(struct kvm_vcpu *vcpu)\n{\n\tint max_irr, tpr;\n\n\tif (!kvm_x86_ops->update_cr8_intercept)\n\t\treturn;\n\n\tif (!vcpu->arch.apic)\n\t\treturn;\n\n\tif (vcpu->arch.apicv_active)\n\t\treturn;\n\n\tif (!vcpu->arch.apic->vapic_addr)\n\t\tmax_irr = kvm_lapic_find_highest_irr(vcpu);\n\telse\n\t\tmax_irr = -1;\n\n\tif (max_irr != -1)\n\t\tmax_irr >>= 4;\n\n\ttpr = kvm_lapic_get_cr8(vcpu);\n\n\tkvm_x86_ops->update_cr8_intercept(vcpu, tpr, max_irr);\n}", "label": 0, "cwe": null, "length": 158 }, { "index": 504057, "code": "hns_get_pauseparam(struct net_device *net_dev,\n\t\t\t struct ethtool_pauseparam *param)\n{\n\tstruct hns_nic_priv *priv = netdev_priv(net_dev);\n\tstruct hnae_ae_ops *ops;\n\n\tops = priv->ae_handle->dev->ops;\n\n\tif (ops->get_pauseparam)\n\t\tops->get_pauseparam(priv->ae_handle, ¶m->autoneg,\n\t\t\t\t\t ¶m->rx_pause, ¶m->tx_pause);\n}", "label": 0, "cwe": null, "length": 102 }, { "index": 840097, "code": "date_to_string (gpointer object, QofParam *getter)\n{\n Timespec ts = ((query_date_getter)getter->param_getfcn)(object, getter);\n\n if (ts.tv_sec || ts.tv_nsec)\n return g_strdup (gnc_print_date (ts));\n\n return NULL;\n}", "label": 0, "cwe": null, "length": 65 }, { "index": 80583, "code": "set_git_work_tree(const char *new_work_tree)\n{\n\tif (git_work_tree_initialized) {\n\t\tnew_work_tree = real_path(new_work_tree);\n\t\tif (strcmp(new_work_tree, work_tree))\n\t\t\tdie(\"internal error: work tree has already been set\\n\"\n\t\t\t \"Current worktree: %s\\nNew worktree: %s\",\n\t\t\t work_tree, new_work_tree);\n\t\treturn;\n\t}\n\tgit_work_tree_initialized = 1;\n\twork_tree = xstrdup(real_path(new_work_tree));\n}", "label": 0, "cwe": null, "length": 107 }, { "index": 53242, "code": "add_key(void)\n{\n\tstruct sort_key **pkey = &key_list;\n\twhile (*pkey)\n\t\tpkey = &((*pkey)->next_key);\n\treturn *pkey = xzalloc(sizeof(struct sort_key));\n}", "label": 0, "cwe": null, "length": 48 }, { "index": 63858, "code": "add_definition (char *component, char *file, char *function, int from_line,\n int to_line, int level, int force)\n{\n struct LogDef n;\n int r;\n\n if (logdefs_size == logdefs_len)\n resize_logdefs ();\n memset (&n, 0, sizeof (n));\n if (strlen (component) == 0)\n component = (char *) \".*\";\n r = regcomp (&n.component_regex, (const char *) component, REG_NOSUB);\n if (r != 0)\n {\n return r;\n }\n if (strlen (file) == 0)\n file = (char *) \".*\";\n r = regcomp (&n.file_regex, (const char *) file, REG_NOSUB);\n if (r != 0)\n {\n regfree (&n.component_regex);\n return r;\n }\n if ((NULL == function) || (strlen (function) == 0))\n function = (char *) \".*\";\n r = regcomp (&n.function_regex, (const char *) function, REG_NOSUB);\n if (r != 0)\n {\n regfree (&n.component_regex);\n regfree (&n.file_regex);\n return r;\n }\n n.from_line = from_line;\n n.to_line = to_line;\n n.level = level;\n n.force = force;\n logdefs[logdefs_len++] = n;\n return 0;\n}", "label": 0, "cwe": null, "length": 316 }, { "index": 911912, "code": "format_int(char *t, int64_t i)\n{\n int sign;\n\n if (i < 0) {\n sign = -1;\n i = -i;\n } else\n sign = 1;\n\n do {\n *--t = \"0123456789\"[i % 10];\n } while (i /= 10);\n if (sign < 0)\n *--t = '-';\n return (t);\n}", "label": 0, "cwe": null, "length": 96 }, { "index": 834539, "code": "kimage_load_normal_segment(struct kimage *image,\n\t\t\t\t\t struct kexec_segment *segment)\n{\n\tunsigned long maddr;\n\tsize_t ubytes, mbytes;\n\tint result;\n\tunsigned char __user *buf = NULL;\n\tunsigned char *kbuf = NULL;\n\n\tresult = 0;\n\tif (image->file_mode)\n\t\tkbuf = segment->kbuf;\n\telse\n\t\tbuf = segment->buf;\n\tubytes = segment->bufsz;\n\tmbytes = segment->memsz;\n\tmaddr = segment->mem;\n\n\tresult = kimage_set_destination(image, maddr);\n\tif (result < 0)\n\t\tgoto out;\n\n\twhile (mbytes) {\n\t\tstruct page *page;\n\t\tchar *ptr;\n\t\tsize_t uchunk, mchunk;\n\n\t\tpage = kimage_alloc_page(image, GFP_HIGHUSER, maddr);\n\t\tif (!page) {\n\t\t\tresult = -ENOMEM;\n\t\t\tgoto out;\n\t\t}\n\t\tresult = kimage_add_page(image, page_to_pfn(page)\n\t\t\t\t\t\t\t\t<< PAGE_SHIFT);\n\t\tif (result < 0)\n\t\t\tgoto out;\n\n\t\tptr = kmap(page);\n\t\t/* Start with a clear page */\n\t\tclear_page(ptr);\n\t\tptr += maddr & ~PAGE_MASK;\n\t\tmchunk = min_t(size_t, mbytes,\n\t\t\t\tPAGE_SIZE - (maddr & ~PAGE_MASK));\n\t\tuchunk = min(ubytes, mchunk);\n\n\t\t/* For file based kexec, source pages are in kernel memory */\n\t\tif (image->file_mode)\n\t\t\tmemcpy(ptr, kbuf, uchunk);\n\t\telse\n\t\t\tresult = copy_from_user(ptr, buf, uchunk);\n\t\tkunmap(page);\n\t\tif (result) {\n\t\t\tresult = -EFAULT;\n\t\t\tgoto out;\n\t\t}\n\t\tubytes -= uchunk;\n\t\tmaddr += mchunk;\n\t\tif (image->file_mode)\n\t\t\tkbuf += mchunk;\n\t\telse\n\t\t\tbuf += mchunk;\n\t\tmbytes -= mchunk;\n\t}\nout:\n\treturn result;\n}", "label": 1, "cwe": "CWE-120", "length": 425 }, { "index": 576409, "code": "usb_dump_device_descriptor(char *start, char *end,\n\t\t\t\tconst struct usb_device_descriptor *desc)\n{\n\tu16 bcdUSB = le16_to_cpu(desc->bcdUSB);\n\tu16 bcdDevice = le16_to_cpu(desc->bcdDevice);\n\n\tif (start > end)\n\t\treturn start;\n\tstart += sprintf(start, format_device1,\n\t\t\t bcdUSB >> 8, bcdUSB & 0xff,\n\t\t\t desc->bDeviceClass,\n\t\t\t class_decode(desc->bDeviceClass),\n\t\t\t desc->bDeviceSubClass,\n\t\t\t desc->bDeviceProtocol,\n\t\t\t desc->bMaxPacketSize0,\n\t\t\t desc->bNumConfigurations);\n\tif (start > end)\n\t\treturn start;\n\tstart += sprintf(start, format_device2,\n\t\t\t le16_to_cpu(desc->idVendor),\n\t\t\t le16_to_cpu(desc->idProduct),\n\t\t\t bcdDevice >> 8, bcdDevice & 0xff);\n\treturn start;\n}", "label": 0, "cwe": null, "length": 195 }, { "index": 336077, "code": "checkforreplay ( void )\n{\n if ( !actmap->replayinfo )\n return;\n\n int rpnum = 0;\n int s = actmap->actplayer + 1;\n if ( s >= 8 )\n s = 0;\n while ( s != actmap->actplayer ) {\n if ( actmap->replayinfo->map[s] && actmap->replayinfo->guidata[s] )\n rpnum++;\n\n if ( s < 7 )\n s++;\n else\n s = 0;\n }\n\n\n if ( actmap->replayinfo && rpnum && (actmap->player[ actmap->actplayer ].stat == Player::human || actmap->player[ actmap->actplayer ].stat == Player::supervisor) )\n if (choice_dlg(\"run replay of last turn ?\",\"~y~es\",\"~n~o\") == 1) {\n \n MainScreenWidget::StandardActionLocker locker( mainScreenWidget, MainScreenWidget::LockOptions::Menu );\n ReplayGuiIconHandleHandler guiIconHandler;\n \n int s = actmap->actplayer + 1;\n if ( s >= 8 )\n s = 0;\n while ( s != actmap->actplayer ) {\n if ( s >= 8 )\n s = 0;\n\n runSpecificReplay(s, actmap->actplayer );\n\n if ( s < 7 )\n s++;\n else\n s = 0;\n }\n\n\n }\n}", "label": 0, "cwe": null, "length": 331 }, { "index": 501314, "code": "eab_parse_qp_email (const gchar *string,\n gchar **name,\n gchar **email)\n{\n\tstruct _camel_header_address *address;\n\tgboolean res = FALSE;\n\n\taddress = camel_header_address_decode (string, \"UTF-8\");\n\n\tif (!address)\n\t\treturn FALSE;\n\n /* report success only when we have filled both name and email address */\n\tif (address->type == CAMEL_HEADER_ADDRESS_NAME && address->name && *address->name && address->v.addr && *address->v.addr) {\n *name = g_strdup (address->name);\n *email = g_strdup (address->v.addr);\n\t\tres = TRUE;\n\t}\n\n\tcamel_header_address_unref (address);\n\n\treturn res;\n}", "label": 0, "cwe": null, "length": 151 }, { "index": 737904, "code": "rocker_port_ctrl_vlan_bridge(struct rocker_port *rocker_port,\n\t\t\t\t\tstruct switchdev_trans *trans,\n\t\t\t\t\tint flags,\n\t\t\t\t\tconst struct rocker_ctrl *ctrl,\n\t\t\t\t\t__be16 vlan_id)\n{\n\tenum rocker_of_dpa_table_id goto_tbl =\n\t\tROCKER_OF_DPA_TABLE_ID_ACL_POLICY;\n\tu32 group_id = ROCKER_GROUP_L2_FLOOD(vlan_id, 0);\n\tu32 tunnel_id = 0;\n\tint err;\n\n\tif (!rocker_port_is_bridged(rocker_port))\n\t\treturn 0;\n\n\terr = rocker_flow_tbl_bridge(rocker_port, trans, flags,\n\t\t\t\t ctrl->eth_dst, ctrl->eth_dst_mask,\n\t\t\t\t vlan_id, tunnel_id,\n\t\t\t\t goto_tbl, group_id, ctrl->copy_to_cpu);\n\n\tif (err)\n\t\tnetdev_err(rocker_port->dev, \"Error (%d) ctrl FLOOD\\n\", err);\n\n\treturn err;\n}", "label": 0, "cwe": null, "length": 189 }, { "index": 94020, "code": "coreAboutToClose()\n{\n _errorMsg.clear();\n if (_formPlaceHolder->isDirty()) {\n bool ok = _formPlaceHolder->saveCurrentEpisode();\n if (!ok) {\n _errorMsg = tr(\"Unable to save current episode, form: %1\")\n .arg(_formPlaceHolder->currentFormLabel());\n LOG_ERROR(_errorMsg);\n }\n return ok;\n }\n return true;\n}", "label": 0, "cwe": null, "length": 90 }, { "index": 27098, "code": "memory_probe_store(struct device *dev, struct device_attribute *attr,\n\t\t const char *buf, size_t count)\n{\n\tu64 phys_addr;\n\tint nid;\n\tint i, ret;\n\tunsigned long pages_per_block = PAGES_PER_SECTION * sections_per_block;\n\n\tret = kstrtoull(buf, 0, &phys_addr);\n\tif (ret)\n\t\treturn ret;\n\n\tif (phys_addr & ((pages_per_block << PAGE_SHIFT) - 1))\n\t\treturn -EINVAL;\n\n\tfor (i = 0; i < sections_per_block; i++) {\n\t\tnid = memory_add_physaddr_to_nid(phys_addr);\n\t\tret = add_memory(nid, phys_addr,\n\t\t\t\t PAGES_PER_SECTION << PAGE_SHIFT);\n\t\tif (ret)\n\t\t\tgoto out;\n\n\t\tphys_addr += MIN_MEMORY_BLOCK_SIZE;\n\t}\n\n\tret = count;\nout:\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 181 }, { "index": 233468, "code": "NsTclNsvSetObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj **objv)\n{\n Array *arrayPtr;\n\n if (objc == 3) {\n \treturn NsTclNsvGetObjCmd(arg, interp, objc, objv);\n } else if (objc != 4) {\n \tTcl_WrongNumArgs(interp, 1, objv, \"array key ?value?\");\n\treturn TCL_ERROR;\n }\n arrayPtr = LockArray(arg, interp, objv[1], 1);\n SetVar(arrayPtr, objv[2], objv[3]);\n UnlockArray(arrayPtr);\n Tcl_SetObjResult(interp, objv[3]);\n return TCL_OK;\n}", "label": 0, "cwe": null, "length": 160 }, { "index": 755015, "code": "adjustZeroCmp(SelectionDAG &DAG, SDLoc DL, Comparison &C) {\n if (C.ICmpType == SystemZICMP::UnsignedOnly)\n return;\n\n auto *ConstOp1 = dyn_cast(C.Op1.getNode());\n if (!ConstOp1)\n return;\n\n int64_t Value = ConstOp1->getSExtValue();\n if ((Value == -1 && C.CCMask == SystemZ::CCMASK_CMP_GT) ||\n (Value == -1 && C.CCMask == SystemZ::CCMASK_CMP_LE) ||\n (Value == 1 && C.CCMask == SystemZ::CCMASK_CMP_LT) ||\n (Value == 1 && C.CCMask == SystemZ::CCMASK_CMP_GE)) {\n C.CCMask ^= SystemZ::CCMASK_CMP_EQ;\n C.Op1 = DAG.getConstant(0, DL, C.Op1.getValueType());\n }\n}", "label": 0, "cwe": null, "length": 206 }, { "index": 582447, "code": "print_bitfield(const unsigned char * bf, int n, int invert, int loglevel) {\n\tint i = 0;\n\tif (loglevel < 0) {\n\t\twhile (i 0 && user[l-1] == '\\n')\n\tuser[l-1] = 0;\n l = strlen(passwd);\n if (l > 0 && passwd[l-1] == '\\n')\n\tpasswd[l-1] = 0;\n\n return (1);\n}", "label": 1, "cwe": "CWE-other", "length": 302 }, { "index": 21444, "code": "Perl_reg_named_buff_iter(pTHX_ REGEXP * const rx, const SV * const lastkey,\n const U32 flags)\n{\n PERL_ARGS_ASSERT_REG_NAMED_BUFF_ITER;\n PERL_UNUSED_ARG(lastkey);\n\n if (flags & RXapif_FIRSTKEY)\n return reg_named_buff_firstkey(rx, flags);\n else if (flags & RXapif_NEXTKEY)\n return reg_named_buff_nextkey(rx, flags);\n else {\n Perl_croak(aTHX_ \"panic: Unknown flags %d in named_buff_iter\", (int)flags);\n return NULL;\n }\n}", "label": 0, "cwe": null, "length": 130 }, { "index": 618682, "code": "OGR_ST_GetRGBFromString( OGRStyleToolH hST, const char *pszColor, \n int *pnRed, int *pnGreen, int *pnBlue,\n int *pnAlpha )\n{\n\n VALIDATE_POINTER1( hST, \"OGR_ST_GetRGBFromString\", FALSE );\n VALIDATE_POINTER1( pnRed, \"OGR_ST_GetRGBFromString\", FALSE );\n VALIDATE_POINTER1( pnGreen, \"OGR_ST_GetRGBFromString\", FALSE );\n VALIDATE_POINTER1( pnBlue, \"OGR_ST_GetRGBFromString\", FALSE );\n VALIDATE_POINTER1( pnAlpha, \"OGR_ST_GetRGBFromString\", FALSE );\n\n return ((OGRStyleTool *) hST)->GetRGBFromString(pszColor, *pnRed, *pnGreen,\n *pnBlue, *pnAlpha );\n}", "label": 0, "cwe": null, "length": 177 }, { "index": 710121, "code": "gkm_crypto_wrap_key (GkmSession *session, CK_MECHANISM_PTR mech, GkmObject *wrapper,\n GkmObject *wrapped, CK_BYTE_PTR output, CK_ULONG_PTR n_output)\n{\n\tg_return_val_if_fail (GKM_IS_SESSION (session), CKR_GENERAL_ERROR);\n\tg_return_val_if_fail (GKM_IS_OBJECT (wrapper), CKR_GENERAL_ERROR);\n\tg_return_val_if_fail (GKM_IS_OBJECT (wrapped), CKR_GENERAL_ERROR);\n\tg_return_val_if_fail (mech, CKR_GENERAL_ERROR);\n\tg_return_val_if_fail (n_output, CKR_GENERAL_ERROR);\n\n\tif (!gkm_object_has_attribute_ulong (wrapper, session, CKA_ALLOWED_MECHANISMS, mech->mechanism))\n\t\treturn CKR_KEY_TYPE_INCONSISTENT;\n\n\tif (!gkm_object_has_attribute_boolean (wrapper, session, CKA_WRAP, TRUE))\n\t\treturn CKR_KEY_FUNCTION_NOT_PERMITTED;\n\n\tswitch (mech->mechanism) {\n\tcase CKM_AES_CBC_PAD:\n\t\treturn gkm_aes_mechanism_wrap (session, mech, wrapper, wrapped,\n\t\t output, n_output);\n\tcase CKM_G_NULL:\n\t\treturn gkm_null_mechanism_wrap (session, mech, wrapper, wrapped,\n\t\t output, n_output);\n\tdefault:\n\t\treturn CKR_MECHANISM_INVALID;\n\t}\n}", "label": 0, "cwe": null, "length": 282 }, { "index": 61081, "code": "externalinterface_available(const fn_call& fn)\n{\n \n movie_root& m = getRoot(fn);\n bool mode = false;\n\n // If we're not running under a browser as a plugin, then just\n // return, as ExternalInterface is only available as a plugin.\n if (m.getHostFD() < 0) {\n return false;\n }\n \n switch (m.getAllowScriptAccess()) {\n case movie_root::SCRIPT_ACCESS_NEVER:\n mode = false;\n break;\n \n case movie_root::SCRIPT_ACCESS_SAME_DOMAIN:\n {\n const RunResources& r = m.runResources();\n const std::string& baseurl = r.streamProvider().baseURL().str();\n char hostname[MAXHOSTNAMELEN];\n std::memset(hostname, 0, MAXHOSTNAMELEN);\n \n if (::gethostname(hostname, MAXHOSTNAMELEN) != 0) {\n mode = false;\n }\n \n // The hostname is empty if running the standalone Gnash from\n // a terminal, so we can assume the default of sameDomain applies.\n URL localPath(hostname, baseurl);\n // If the URL has a file protocol, then \n if (r.streamProvider().allow(localPath)) {\n return as_value(true);\n }\n if (localPath.hostname().empty()) {\n mode = false;\n } else {\n StringNoCaseEqual noCaseCompare;\n \n if (!noCaseCompare(localPath.hostname(), hostname)) {\n log_security(_(\"ExternalInterface path %s is outside \"\n \"the SWF domain %s. Cannot access this \"\n \"object.\"), localPath, hostname);\n mode = false;\n }\n }\n break;\n }\n \n case movie_root::SCRIPT_ACCESS_ALWAYS:\n mode = true;\n break;\n }\n \n return as_value(mode);\n}", "label": 0, "cwe": null, "length": 386 }, { "index": 746955, "code": "vdi_v_pline(VDI_Workstation *vwk)\n{\n int n,ni;\n unsigned long col;\n RECT cor;\n int planes = (vwk->inq.attr.planes < 8) ? vwk->inq.attr.planes : 8;\n \n \n ADEBUG (\"ovdisis: vdi_line.c: vdi_v_pline: fb = 0x%x\\n\", vwk->fb);\n \n /* Lock visual before operation */\n VISUAL_MUTEX(vwk, VISUAL_MUTEX_LOCK);\n\n /* Setup write mode */\n VISUAL_SET_WRITE_MODE(vwk, vwk->write_mode);\n\n ni = gem2tos_color(planes, vwk->line_a.color);\n col = get_color(vwk, ni);\n \n for(n=0 ; n < (int)vdipb->contrl[N_PTSIN]-1 ; n++)\n {\n cor.x1 = (int)vdipb->ptsin[0+n*2];\n cor.y1 = (int)vdipb->ptsin[1+n*2];\n cor.x2 = (int)vdipb->ptsin[2+n*2];\n cor.y2 = (int)vdipb->ptsin[3+n*2];\n if(do_lineclip(&cor, &vwk->clip))\n {\n if(cor.y1 == cor.y2)\n {\n VISUAL_HLINE(vwk, cor.x1, cor.x2, cor.y1, col);\n }\n else\n {\n VISUAL_LINE(vwk, cor.x1, cor.y1, cor.x2, cor.y2, col);\n }\n }\n }\n\n /* Unlock visual after operation */\n VISUAL_MUTEX(vwk, VISUAL_MUTEX_UNLOCK);\n\n vdipb->contrl[N_PTSOUT] = 0;\n vdipb->contrl[N_INTOUT] = 0;\n}", "label": 0, "cwe": null, "length": 407 }, { "index": 602758, "code": "ata_host_alloc_pinfo(struct device *dev,\n\t\t\t\t const struct ata_port_info * const * ppi,\n\t\t\t\t int n_ports)\n{\n\tconst struct ata_port_info *pi;\n\tstruct ata_host *host;\n\tint i, j;\n\n\thost = ata_host_alloc(dev, n_ports);\n\tif (!host)\n\t\treturn NULL;\n\n\tfor (i = 0, j = 0, pi = NULL; i < host->n_ports; i++) {\n\t\tstruct ata_port *ap = host->ports[i];\n\n\t\tif (ppi[j])\n\t\t\tpi = ppi[j++];\n\n\t\tap->pio_mask = pi->pio_mask;\n\t\tap->mwdma_mask = pi->mwdma_mask;\n\t\tap->udma_mask = pi->udma_mask;\n\t\tap->flags |= pi->flags;\n\t\tap->link.flags |= pi->link_flags;\n\t\tap->ops = pi->port_ops;\n\n\t\tif (!host->ops && (pi->port_ops != &ata_dummy_port_ops))\n\t\t\thost->ops = pi->port_ops;\n\t}\n\n\treturn host;\n}", "label": 1, "cwe": "CWE-476", "length": 224 }, { "index": 215874, "code": "on_click_change_stash_password (GtkMenuItem *mi, gpointer data)\n{\n\tint idx = GPOINTER_TO_INT (data);\n\n\tif (test_crypt_dir_and_moan (cryptPoints[idx].GetCryptDir ())) return FALSE;\n\n\tPasswordChangeDialog *dialog = new PasswordChangeDialog (cryptPoints[idx].GetCryptDir (),\n\t\t\tcryptPoints[idx].GetMountDir ());\n\tdialog->Show ();\n\treturn FALSE;\n}", "label": 0, "cwe": null, "length": 88 }, { "index": 513184, "code": "IRET16(bxInstruction_c *i)\n{\n Bit16u ip, cs_raw, flags;\n\n invalidate_prefetch_q();\n\n#if BX_SUPPORT_VMX\n if (!BX_CPU_THIS_PTR in_vmx_guest || !VMEXIT(VMX_VM_EXEC_CTRL1_NMI_VMEXIT))\n#endif\n BX_CPU_THIS_PTR disable_NMI = 0;\n\n#if BX_DEBUGGER\n BX_CPU_THIS_PTR show_flag |= Flag_iret;\n#endif\n\n RSP_SPECULATIVE;\n\n if (v8086_mode()) {\n // IOPL check in stack_return_from_v86()\n iret16_stack_return_from_v86(i);\n goto done;\n }\n\n if (protected_mode()) {\n iret_protected(i);\n goto done;\n }\n\n ip = pop_16();\n cs_raw = pop_16(); // #SS has higher priority\n flags = pop_16();\n\n // CS.LIMIT can't change when in real/v8086 mode\n if(ip > BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.limit_scaled) {\n BX_ERROR((\"IRET16: instruction pointer not within code segment limits\"));\n exception(BX_GP_EXCEPTION, 0, 0);\n }\n\n load_seg_reg(&BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS], cs_raw);\n RIP = (Bit32u) ip;\n write_flags(flags, /* change IOPL? */ 1, /* change IF? */ 1);\n\ndone:\n RSP_COMMIT;\n\n BX_INSTR_FAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_IRET,\n BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value, EIP);\n}", "label": 0, "cwe": null, "length": 360 }, { "index": 491274, "code": "_get_status_updates (SwMySpaceItemView *item_view)\n{\n SwMySpaceItemViewPrivate *priv = GET_PRIVATE (item_view);\n GHashTable *params = NULL;\n SwSet *set;\n SwService *service;\n\n service = sw_item_view_get_service (SW_ITEM_VIEW (item_view));\n\n if (!sw_service_has_dynamic_cap (service, CREDENTIALS_VALID))\n return;\n\n set = sw_item_set_new ();\n\n if (g_str_equal (priv->query, \"own\"))\n _get_user_status_updates (item_view, set);\n else if (g_str_equal (priv->query, \"feed\"))\n _get_friends_status_updates (item_view, set);\n else\n g_error (G_STRLOC \": Unexpected query '%s'\", priv->query);\n\n if (params)\n g_hash_table_unref (params);\n}", "label": 0, "cwe": null, "length": 179 }, { "index": 56586, "code": "timeline_marker_new_progress (const gchar *name,\n gdouble progress)\n{\n TimelineMarker *marker = g_slice_new (TimelineMarker);\n\n marker->name = g_strdup (name);\n marker->quark = g_quark_from_string (marker->name);\n marker->is_relative = TRUE;\n marker->data.progress = CLAMP (progress, 0.0, 1.0);\n\n return marker;\n}", "label": 0, "cwe": null, "length": 91 }, { "index": 704839, "code": "board_init() {\n const char *tee = memchr(display, 'T', screen_width);\n if (tee == NULL) {\n errexit(' ', \"Can't determine board width.\");\n }\n info_col = tee - display;\n const char *spc = memchr(display, ' ', screen_width);\n if (spc[-1] == '7' && isalpha(spc[-2]))\n spc--;\n board_width = pmin(spc, tee-1) - display;\n if (board_width % 2 == 0) {\n errexit(2, \"Invalid width of %d.5 chars.\", board_width/2);\n }\n board_width = (board_width + 1) / 2;\n if (board_width <= 5) {\n errexit(board_width+1, \"Board unreasonably thin.\");\n }\n if (board_width > 80) {\n errexit(board_width, \"Board unreasonably wide.\");\n }\n for (int i = 1; i < screen_height; i++) {\n if (D(i, 0) == 'z') {\n board_height = i;\n break;\n }\n }\n if (board_height == 0) {\n errexit(' ', \"Can't determine board height.\");\n }\n if (board_height <= 5) {\n errexit(board_height+1, \"Board unreasonably short.\");\n }\n if (board_height > 50) {\n errexit(board_height, \"Board unreasonably tall.\");\n }\n if (D(board_height-1, 0) != '-' && D(board_height-1, 2) != '-') {\n errexit('L', \"Can't find lower left corner of board.\");\n }\n int fnum = get_frame_no();\n if (fnum != 1) {\n errexit('t', \"Starting at frame %d instead of 1.\", fnum);\n }\n\n find_airports();\n fprintf(logff, \"Board is %d by %d and the info column is %d.\\n\",\n board_width, board_height, info_col);\n\n return true;\n}", "label": 1, "cwe": "CWE-other", "length": 459 }, { "index": 7127, "code": "write_viminfo_marks(fp_out)\n FILE\t*fp_out;\n{\n int\t\tcount;\n buf_T\t*buf;\n int\t\tis_mark_set;\n int\t\ti;\n#ifdef FEAT_WINDOWS\n win_T\t*win;\n tabpage_T\t*tp;\n\n /*\n * Set b_last_cursor for the all buffers that have a window.\n */\n FOR_ALL_TAB_WINDOWS(tp, win)\n\tset_last_cursor(win);\n#else\n\tset_last_cursor(curwin);\n#endif\n\n fputs(_(\"\\n# History of marks within files (newest to oldest):\\n\"), fp_out);\n count = 0;\n for (buf = firstbuf; buf != NULL; buf = buf->b_next)\n {\n\t/*\n\t * Only write something if buffer has been loaded and at least one\n\t * mark is set.\n\t */\n\tif (buf->b_marks_read)\n\t{\n\t if (buf->b_last_cursor.lnum != 0)\n\t\tis_mark_set = TRUE;\n\t else\n\t {\n\t\tis_mark_set = FALSE;\n\t\tfor (i = 0; i < NMARKS; i++)\n\t\t if (buf->b_namedm[i].lnum != 0)\n\t\t {\n\t\t\tis_mark_set = TRUE;\n\t\t\tbreak;\n\t\t }\n\t }\n\t if (is_mark_set && buf->b_ffname != NULL\n\t\t && buf->b_ffname[0] != NUL && !removable(buf->b_ffname))\n\t {\n\t\thome_replace(NULL, buf->b_ffname, IObuff, IOSIZE, TRUE);\n\t\tfprintf(fp_out, \"\\n> \");\n\t\tviminfo_writestring(fp_out, IObuff);\n\t\twrite_one_mark(fp_out, '\"', &buf->b_last_cursor);\n\t\twrite_one_mark(fp_out, '^', &buf->b_last_insert);\n\t\twrite_one_mark(fp_out, '.', &buf->b_last_change);\n#ifdef FEAT_JUMPLIST\n\t\t/* changelist positions are stored oldest first */\n\t\tfor (i = 0; i < buf->b_changelistlen; ++i)\n\t\t write_one_mark(fp_out, '+', &buf->b_changelist[i]);\n#endif\n\t\tfor (i = 0; i < NMARKS; i++)\n\t\t write_one_mark(fp_out, 'a' + i, &buf->b_namedm[i]);\n\t\tcount++;\n\t }\n\t}\n }\n\n return count;\n}", "label": 0, "cwe": null, "length": 511 }, { "index": 746234, "code": "most_deregister_aim(struct most_aim *aim)\n{\n\tstruct most_aim_obj *aim_obj;\n\tstruct most_c_obj *c, *tmp;\n\tstruct most_inst_obj *i, *i_tmp;\n\n\tif (!aim) {\n\t\tpr_err(\"Bad driver\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\taim_obj = aim->context;\n\tif (!aim_obj) {\n\t\tpr_info(\"driver not registered.\\n\");\n\t\treturn -EINVAL;\n\t}\n\tlist_for_each_entry_safe(i, i_tmp, &instance_list, list) {\n\t\tlist_for_each_entry_safe(c, tmp, &i->channel_list, list) {\n\t\t\tif (c->aim0.ptr == aim || c->aim1.ptr == aim)\n\t\t\t\taim->disconnect_channel(\n\t\t\t\t\tc->iface, c->channel_id);\n\t\t\tif (c->aim0.ptr == aim)\n\t\t\t\tc->aim0.ptr = NULL;\n\t\t\tif (c->aim1.ptr == aim)\n\t\t\t\tc->aim1.ptr = NULL;\n\t\t}\n\t}\n\tlist_del(&aim_obj->list);\n\tdestroy_most_aim_obj(aim_obj);\n\tpr_info(\"deregistering application interfacing module %s\\n\", aim->name);\n\treturn 0;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 255 }, { "index": 903301, "code": "oc_frag_recon_inter_c(unsigned char *_dst,\n const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]){\n int i;\n for(i=0;i<8;i++){\n int j;\n for(j=0;j<8;j++)_dst[j]=OC_CLAMP255(_residue[i*8+j]+_src[j]);\n _dst+=_ystride;\n _src+=_ystride;\n }\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 99 }, { "index": 883231, "code": "check_tables_version(JCR *jcr, B_DB *mdb)\n{\n uint32_t bacula_db_version = 0;\n const char *query = \"SELECT VersionId FROM Version\";\n\n bacula_db_version = 0;\n if (!db_sql_query(mdb, query, db_int_handler, (void *)&bacula_db_version)) {\n Jmsg(jcr, M_FATAL, 0, \"%s\", mdb->errmsg);\n return false;\n }\n if (bacula_db_version != BDB_VERSION) {\n Mmsg(mdb->errmsg, \"Version error for database \\\"%s\\\". Wanted %d, got %d\\n\",\n mdb->get_db_name(), BDB_VERSION, bacula_db_version);\n Jmsg(jcr, M_FATAL, 0, \"%s\", mdb->errmsg);\n return false;\n }\n return true;\n}", "label": 0, "cwe": null, "length": 184 }, { "index": 377512, "code": "motionNotify(const XEvent *event_)\n{\n if (isProtected()==MSFalse && (acceptFocus()==MSFalse||inputFocus()==this))\n {\n if (event_->xmotion.is_hint==NotifyNormal&&(event_->xmotion.state&Button1Mask)==Button1Mask)\n {\n\tif (event_->xmotion.x<0||event_->xmotion.x>width()||\n\t event_->xmotion.y<0||event_->xmotion.y>height())\n\t { disarm(); }\n\telse if (armed()==MSFalse)\n\t {\n\t if ((event_->xmotion.x>=0&&event_->xmotion.x<=width())&&\n\t (event_->xmotion.y>=0&&event_->xmotion.y<=height()))\n\t { arm(); }\n\t }\n }\n }\n}", "label": 0, "cwe": null, "length": 164 }, { "index": 280705, "code": "renderMachineInstr(raw_ostream &os,\n const MachineInstr *mi) const {\n std::string s;\n raw_string_ostream oss(s);\n oss << *mi;\n\n os << escapeChars(oss.str());\n }", "label": 0, "cwe": null, "length": 50 }, { "index": 45122, "code": "addPage(QWidget *page,\n const QString &itemName,\n const QString &pixmapName,\n const QString &header,\n bool manage)\n{\n Q_ASSERT(page);\n if (!page) {\n return 0;\n }\n\n KPageWidgetItem* item = d->addPageInternal(page, itemName, pixmapName, header);\n if (manage) {\n d->manager->addWidget(page);\n }\n\n if (d->shown && manage) {\n // update the default button if the dialog is shown\n bool is_default = isButtonEnabled(Default) && d->manager->isDefault();\n enableButton(Default,!is_default);\n }\n return item;\n}", "label": 0, "cwe": null, "length": 142 }, { "index": 824608, "code": "iTIFFExpandComplexInt(void* line_buffer, int count, int cpx_int)\n{\n count *= 2;\n\n // conversion will be done in-place\n\n if (cpx_int == 1)\n {\n // convert short to float, expanding from 16 to 32 bits\n short* short_buffer = (short*)line_buffer;\n float* float_buffer = (float*)line_buffer;\n\n float_buffer += count-1; // from end to start\n short_buffer += count-1;\n\n for (int i = 0; i < count; i++)\n *float_buffer-- = (float)(*short_buffer--);\n }\n else\n {\n // convert int to float, same size not expanding \n int* int_buffer = (int*)line_buffer;\n float* float_buffer = (float*)line_buffer;\n\n for (int i = 0; i < count; i++)\n *float_buffer++ = (float)(*int_buffer++);\n }\n}", "label": 0, "cwe": null, "length": 213 }, { "index": 651951, "code": "grealloc(void* ptr, size_t size)\n{\n\tSlot* slot = slotlist;\n\tchar* new_area;\n\tchar* old_area = ptr;\n\tint i;\n\tint cpy_size;\n\tif (size%ALIGNMENT != 0)\n\t\tsize = size + ALIGNMENT - size%ALIGNMENT;\n\tif (ptr == NULL)\n\t\treturn gmalloc(size);\n\tif (size == 0)\n\t{\n\t\tgfree(ptr);\n\t\treturn NULL;\n\t}\n\twhile(slot+1 != ptr)\n\t{\n\t\tif (slot == NULL)\n\t\t\treturn NULL; // not found...\n\t\tslot = slot->next;\n\t}\n\tnew_area = gmalloc(size);\n\tcpy_size = size < slot->size ? size : slot->size;\n\tfor(i=0; iUse = 1U;\n\n pthis->Identifier = qcv->Identifier;\n\n pthis->Adaptor = qcv->Adaptor;\n\n pthis->Qcalignment = ensQcalignmentNewRef(qcv->Qcalignment);\n\n pthis->Analysis = ensAnalysisNewRef(qcv->Analysis);\n\n pthis->QuerySequence = ensQcsequenceNewRef(qcv->QuerySequence);\n pthis->QueryStart = qcv->QueryStart;\n pthis->QueryEnd = qcv->QueryEnd;\n\n if (qcv->QueryString)\n pthis->QueryString = ajStrNewRef(qcv->QueryString);\n\n pthis->TargetSequence = ensQcsequenceNewRef(qcv->TargetSequence);\n pthis->TargetStart = qcv->TargetStart;\n pthis->TargetEnd = qcv->TargetEnd;\n\n if (qcv->TargetString)\n pthis->TargetString = ajStrNewRef(qcv->TargetString);\n\n pthis->Class = qcv->Class;\n pthis->Type = qcv->Type;\n pthis->State = qcv->State;\n\n return pthis;\n}", "label": 0, "cwe": null, "length": 299 }, { "index": 156941, "code": "suunto_dive_match(struct dive *dive, const char *name, int len, char *buf)\n{\n\treturn\tMATCH(\".o2pct\", percent, &dive->cylinder[0].gasmix.o2) ||\n\t\tMATCH(\".hepct_0\", percent, &dive->cylinder[0].gasmix.he) ||\n\t\tMATCH(\".o2pct_2\", percent, &dive->cylinder[1].gasmix.o2) ||\n\t\tMATCH(\".hepct_1\", percent, &dive->cylinder[1].gasmix.he) ||\n\t\tMATCH(\".o2pct_3\", percent, &dive->cylinder[2].gasmix.o2) ||\n\t\tMATCH(\".hepct_2\", percent, &dive->cylinder[2].gasmix.he) ||\n\t\tMATCH(\".o2pct_4\", percent, &dive->cylinder[3].gasmix.o2) ||\n\t\tMATCH(\".hepct_3\", percent, &dive->cylinder[3].gasmix.he) ||\n\t\tMATCH(\".cylindersize\", cylindersize, &dive->cylinder[0].type.size) ||\n\t\tMATCH(\".cylinderworkpressure\", pressure, &dive->cylinder[0].type.workingpressure) ||\n\t\t0;\n}", "label": 0, "cwe": null, "length": 303 }, { "index": 75898, "code": "svg_parse_named_color(SVG_Color *col, char *attribute_content)\n{\n\tu32 i, count;\n\tcount = sizeof(predefined_colors) / sizeof(struct predef_col);\n\tfor (i=0; ired = INT2FIX(predefined_colors[i].r) / 255;\n\t\t\tcol->green = INT2FIX(predefined_colors[i].g) / 255;\n\t\t\tcol->blue = INT2FIX(predefined_colors[i].b) / 255;\n\t\t\tcol->type = SVG_COLOR_RGBCOLOR;\n\t\t\treturn;\n\t\t}\n\t}\n\tcount = sizeof(system_colors) / sizeof(struct sys_col);\n\tfor (i=0; itype = system_colors[i].type;\n\t\t\treturn;\n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 197 }, { "index": 746108, "code": "wusbhc_create(struct wusbhc *wusbhc)\n{\n\tint result = 0;\n\n\t/* set defaults. These can be overwritten using sysfs attributes. */\n\twusbhc->trust_timeout = WUSB_TRUST_TIMEOUT_MS;\n\twusbhc->phy_rate = UWB_PHY_RATE_INVALID - 1;\n\twusbhc->dnts_num_slots = 4;\n\twusbhc->dnts_interval = 2;\n\twusbhc->retry_count = WUSB_RETRY_COUNT_INFINITE;\n\n\tmutex_init(&wusbhc->mutex);\n\tresult = wusbhc_mmcie_create(wusbhc);\n\tif (result < 0)\n\t\tgoto error_mmcie_create;\n\tresult = wusbhc_devconnect_create(wusbhc);\n\tif (result < 0)\n\t\tgoto error_devconnect_create;\n\tresult = wusbhc_rh_create(wusbhc);\n\tif (result < 0)\n\t\tgoto error_rh_create;\n\tresult = wusbhc_sec_create(wusbhc);\n\tif (result < 0)\n\t\tgoto error_sec_create;\n\treturn 0;\n\nerror_sec_create:\n\twusbhc_rh_destroy(wusbhc);\nerror_rh_create:\n\twusbhc_devconnect_destroy(wusbhc);\nerror_devconnect_create:\n\twusbhc_mmcie_destroy(wusbhc);\nerror_mmcie_create:\n\treturn result;\n}", "label": 0, "cwe": null, "length": 276 }, { "index": 772352, "code": "server_export_object (Server *server,\n GError **error)\n{\n gboolean ret;\n ret = FALSE;\n server->auth_agent_registration_id = g_dbus_connection_register_object (server->system_bus,\n server->object_path,\n server->interface_info,\n &auth_agent_vtable,\n server,\n NULL, /* user_data GDestroyNotify */\n error);\n if (server->auth_agent_registration_id > 0)\n ret = TRUE;\n return ret;\n}", "label": 0, "cwe": null, "length": 104 }, { "index": 452904, "code": "wai_token_encoding(struct webauth_context *ctx,\n const struct webauth_token *token,\n const struct wai_encoding **rules, const void **data)\n{\n int s;\n\n switch (token->type) {\n case WA_TOKEN_APP:\n *rules = wai_token_app_encoding;\n *data = &token->token.app;\n break;\n case WA_TOKEN_CRED:\n *rules = wai_token_cred_encoding;\n *data = &token->token.cred;\n break;\n case WA_TOKEN_ERROR:\n *rules = wai_token_error_encoding;\n *data = &token->token.error;\n break;\n case WA_TOKEN_ID:\n *rules = wai_token_id_encoding;\n *data = &token->token.id;\n break;\n case WA_TOKEN_LOGIN:\n *rules = wai_token_login_encoding;\n *data = &token->token.login;\n break;\n case WA_TOKEN_PROXY:\n *rules = wai_token_proxy_encoding;\n *data = &token->token.proxy;\n break;\n case WA_TOKEN_REQUEST:\n *rules = wai_token_request_encoding;\n *data = &token->token.request;\n break;\n case WA_TOKEN_WEBKDC_FACTOR:\n *rules = wai_token_webkdc_factor_encoding;\n *data = &token->token.webkdc_factor;\n break;\n case WA_TOKEN_WEBKDC_PROXY:\n *rules = wai_token_webkdc_proxy_encoding;\n *data = &token->token.webkdc_proxy;\n break;\n case WA_TOKEN_WEBKDC_SERVICE:\n *rules = wai_token_webkdc_service_encoding;\n *data = &token->token.webkdc_service;\n break;\n case WA_TOKEN_UNKNOWN:\n case WA_TOKEN_ANY:\n default:\n s = WA_ERR_INVALID;\n wai_error_set(ctx, s, \"unknown token type %d\", token->type);\n return s;\n }\n return WA_ERR_NONE;\n}", "label": 0, "cwe": null, "length": 422 }, { "index": 704190, "code": "memcg_event_wake(wait_queue_t *wait, unsigned mode,\n\t\t\t int sync, void *key)\n{\n\tstruct mem_cgroup_event *event =\n\t\tcontainer_of(wait, struct mem_cgroup_event, wait);\n\tstruct mem_cgroup *memcg = event->memcg;\n\tunsigned long flags = (unsigned long)key;\n\n\tif (flags & POLLHUP) {\n\t\t/*\n\t\t * If the event has been detached at cgroup removal, we\n\t\t * can simply return knowing the other side will cleanup\n\t\t * for us.\n\t\t *\n\t\t * We can't race against event freeing since the other\n\t\t * side will require wqh->lock via remove_wait_queue(),\n\t\t * which we hold.\n\t\t */\n\t\tspin_lock(&memcg->event_list_lock);\n\t\tif (!list_empty(&event->list)) {\n\t\t\tlist_del_init(&event->list);\n\t\t\t/*\n\t\t\t * We are in atomic context, but cgroup_event_remove()\n\t\t\t * may sleep, so we have to call it in workqueue.\n\t\t\t */\n\t\t\tschedule_work(&event->remove);\n\t\t}\n\t\tspin_unlock(&memcg->event_list_lock);\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 244 }, { "index": 58764, "code": "check_detectedlink_end(t_hts_callbackarg * carg, httrackp * opt) {\n char *base = (char *) CALLBACKARG_USERDEF(carg);\n\n fprintf(stderr, \"Unplugged ..\\n\");\n if (base != NULL) {\n free(base);\n base = NULL;\n }\n\n /* Call parent functions if multiple callbacks are chained. */\n if (CALLBACKARG_PREV_FUN(carg, end) != NULL) {\n return CALLBACKARG_PREV_FUN(carg, end) (CALLBACKARG_PREV_CARG(carg), opt);\n }\n\n return 1; /* success */\n}", "label": 0, "cwe": null, "length": 133 }, { "index": 650773, "code": "system_name_write( us_test_trie_schema_entry_t *US_UNUSED( self ) )\n{\n us_log_debug( \"%s: \", __FUNCTION__ );\n us_log_info( \"new system name: %s \", device_name );\n return true;\n}", "label": 0, "cwe": null, "length": 54 }, { "index": 568197, "code": "spl_lot_handler(xmlNodePtr node, gpointer data)\n{\n struct split_pdata *pdata = data;\n GncGUID *id = dom_tree_to_guid(node);\n GNCLot *lot;\n\n g_return_val_if_fail(id, FALSE);\n\n lot = gnc_lot_lookup (id, pdata->book);\n if (!lot && gnc_transaction_xml_v2_testing &&\n !guid_equal (id, guid_null ()))\n {\n lot = gnc_lot_new (pdata->book);\n gnc_lot_set_guid (lot, *id);\n }\n\n gnc_lot_add_split (lot, pdata->split);\n\n g_free(id);\n\n return TRUE;\n}", "label": 0, "cwe": null, "length": 141 }, { "index": 68309, "code": "resourceoutWriteBasic(AjPFile outf, const AjPResource resource)\n{\n if(!outf)\n return ajFalse;\n\n ajFmtPrintF(outf, \"%-8s%S\\n\", \"ID\", resource->Id);\n ajFmtPrintF(outf, \"%-8s%S\\n\", \"Name\", resource->Name);\n if(ajStrGetLen(resource->Url))\n ajFmtPrintF(outf, \"%-8s%S\\n\", \"URL\", resource->Url);\n\n ajFmtPrintF(outf, \"\\n\");\n\n return ajTrue;\n}", "label": 0, "cwe": null, "length": 123 }, { "index": 342717, "code": "class_dealloc(PyClassObject *op)\n{\n _PyObject_GC_UNTRACK(op);\n if (op->cl_weakreflist != NULL)\n PyObject_ClearWeakRefs((PyObject *) op);\n Py_DECREF(op->cl_bases);\n Py_DECREF(op->cl_dict);\n Py_XDECREF(op->cl_name);\n Py_XDECREF(op->cl_getattr);\n Py_XDECREF(op->cl_setattr);\n Py_XDECREF(op->cl_delattr);\n PyObject_GC_Del(op);\n}", "label": 0, "cwe": null, "length": 100 }, { "index": 579865, "code": "bnxt_timer(unsigned long data)\n{\n\tstruct bnxt *bp = (struct bnxt *)data;\n\tstruct net_device *dev = bp->dev;\n\n\tif (!netif_running(dev))\n\t\treturn;\n\n\tif (atomic_read(&bp->intr_sem) != 0)\n\t\tgoto bnxt_restart_timer;\n\n\tif (bp->link_info.link_up && (bp->flags & BNXT_FLAG_PORT_STATS) &&\n\t bp->stats_coal_ticks) {\n\t\tset_bit(BNXT_PERIODIC_STATS_SP_EVENT, &bp->sp_event);\n\t\tschedule_work(&bp->sp_task);\n\t}\nbnxt_restart_timer:\n\tmod_timer(&bp->timer, jiffies + bp->current_interval);\n}", "label": 0, "cwe": null, "length": 144 }, { "index": 1019322, "code": "e1000_setup_copper_link_80003es2lan(struct e1000_hw *hw)\n{\n\tu32 ctrl;\n\ts32 ret_val;\n\tu16 reg_data;\n\n\tctrl = er32(CTRL);\n\tctrl |= E1000_CTRL_SLU;\n\tctrl &= ~(E1000_CTRL_FRCSPD | E1000_CTRL_FRCDPX);\n\tew32(CTRL, ctrl);\n\n\t/* Set the mac to wait the maximum time between each\n\t * iteration and increase the max iterations when\n\t * polling the phy; this fixes erroneous timeouts at 10Mbps.\n\t */\n\tret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 4),\n\t\t\t\t\t\t 0xFFFF);\n\tif (ret_val)\n\t\treturn ret_val;\n\tret_val = e1000_read_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),\n\t\t\t\t\t\t ®_data);\n\tif (ret_val)\n\t\treturn ret_val;\n\treg_data |= 0x3F;\n\tret_val = e1000_write_kmrn_reg_80003es2lan(hw, GG82563_REG(0x34, 9),\n\t\t\t\t\t\t reg_data);\n\tif (ret_val)\n\t\treturn ret_val;\n\tret_val =\n\t e1000_read_kmrn_reg_80003es2lan(hw,\n\t\t\t\t\t E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,\n\t\t\t\t\t ®_data);\n\tif (ret_val)\n\t\treturn ret_val;\n\treg_data |= E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING;\n\tret_val =\n\t e1000_write_kmrn_reg_80003es2lan(hw,\n\t\t\t\t\t E1000_KMRNCTRLSTA_OFFSET_INB_CTRL,\n\t\t\t\t\t reg_data);\n\tif (ret_val)\n\t\treturn ret_val;\n\n\tret_val = e1000_copper_link_setup_gg82563_80003es2lan(hw);\n\tif (ret_val)\n\t\treturn ret_val;\n\n\treturn e1000e_setup_copper_link(hw);\n}", "label": 0, "cwe": null, "length": 425 }, { "index": 657590, "code": "build_categories_directory_read_cb (gchar *xmldata, gpointer user_data)\n{\n xmlDocPtr doc;\n xmlNodePtr node;\n\n if (!xmldata) {\n g_critical (\"Failed to build category directory (1)\");\n return;\n }\n\n doc = xmlReadMemory (xmldata, strlen (xmldata), NULL, NULL,\n XML_PARSE_RECOVER | XML_PARSE_NOBLANKS);\n if (!doc) {\n g_critical (\"Failed to build category directory (2)\");\n goto free_resources;\n }\n\n node = xmlDocGetRootElement (doc);\n if (!node) {\n g_critical (\"Failed to build category directory (3)\");\n goto free_resources;\n }\n\n if (xmlStrcmp (node->name, (const xmlChar *) \"categories\")) {\n g_critical (\"Failed to build category directory (4)\");\n goto free_resources;\n }\n\n node = node->xmlChildrenNode;\n if (!node) {\n g_critical (\"Failed to build category directory (5)\");\n goto free_resources;\n }\n\n parse_categories (doc, node, user_data);\n\n free_resources:\n xmlFreeDoc (doc);\n}", "label": 0, "cwe": null, "length": 239 }, { "index": 12084, "code": "visit(Try* node)\n{\n\tIR& try_start = m_builder->push(OP_TRY);\n\n\tnode->getBlock()->accept(*this);\n\n\tIR& try_jmp = m_builder->push(OP_JMP); // It's all ok, jump to finally block\n\n\tNodeList& catches = node->getCatches()->getNodes();\n\tNodeList::const_iterator it(catches.begin()), end(catches.end());\n\n\ttry_start.op1 = Operand(JMP_ADDR, m_builder->getSize());\n\n\twhile (it != end) {\n\t\tIR& catch_start = m_builder->push(OP_CATCH);\n\n\t\t(*it)->accept(*this);\n\n\t\tcatch_start.op1 = createOp(static_cast(*it)->getVar());\n\t\t++it;\n\t}\n\n\ttry_jmp.op1 = Operand(JMP_ADDR, m_builder->getSize());\n\n\tif (node->hasFinally()) {\n\t\tnode->getFinally()->accept(*this);\n\t}\n\n\tm_builder->push(OP_ETRY);\n}", "label": 0, "cwe": null, "length": 199 }, { "index": 78576, "code": "list_delete_current( List *list )\n{\n\tif ( list->cur_entry == 0 || list->cur_entry == list->head || list->cur_entry == list->tail ) return 0;\n\tlist_delete_entry( list, list->cur_entry );\n\treturn 1;\n}", "label": 0, "cwe": null, "length": 58 }, { "index": 203908, "code": "formReply(const AHCommand& c, const XData& data, const QString& sessionId)\n{\n\tAHCommand r(c.node(), data, sessionId);\n\tr.setStatus(AHCommand::Executing);\n\treturn r;\n}", "label": 0, "cwe": null, "length": 44 }, { "index": 378155, "code": "CallAsFunction(v8::Handle recv, int argc,\n v8::Handle argv[]) {\n i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate();\n ON_BAILOUT(isolate, \"v8::Object::CallAsFunction()\",\n return Local());\n LOG_API(isolate, \"Object::CallAsFunction\");\n ENTER_V8(isolate);\n i::HandleScope scope(isolate);\n i::Handle obj = Utils::OpenHandle(this);\n i::Handle recv_obj = Utils::OpenHandle(*recv);\n STATIC_ASSERT(sizeof(v8::Handle) == sizeof(i::Object**));\n i::Object*** args = reinterpret_cast(argv);\n i::Handle fun = i::Handle();\n if (obj->IsJSFunction()) {\n fun = i::Handle::cast(obj);\n } else {\n EXCEPTION_PREAMBLE(isolate);\n i::Handle delegate =\n i::Execution::TryGetFunctionDelegate(obj, &has_pending_exception);\n EXCEPTION_BAILOUT_CHECK(isolate, Local());\n fun = i::Handle::cast(delegate);\n recv_obj = obj;\n }\n EXCEPTION_PREAMBLE(isolate);\n i::Handle returned =\n i::Execution::Call(fun, recv_obj, argc, args, &has_pending_exception);\n EXCEPTION_BAILOUT_CHECK(isolate, Local());\n return Utils::ToLocal(scope.CloseAndEscape(returned));\n}", "label": 0, "cwe": null, "length": 349 }, { "index": 928108, "code": "gretl_list_add (const int *orig, const int *add, int *err)\n{\n int n_orig = orig[0];\n int n_add = add[0];\n int i, j, k;\n int *big;\n\n *err = 0;\n\n big = gretl_list_new(n_orig + n_add);\n if (big == NULL) {\n\t*err = E_ALLOC;\n\treturn NULL;\n }\n\n for (i=0; i<=n_orig; i++) {\n\tbig[i] = orig[i];\n }\n\n k = orig[0];\n\n for (i=1; i<=n_add; i++) {\n\tfor (j=1; j<=n_orig; j++) {\n\t if (add[i] == orig[j]) {\n\t\t/* a \"new\" var was already present */\n\t\tfree(big);\n\t\t*err = E_ADDDUP;\n\t\treturn NULL;\n\t }\n\t}\n\tbig[0] += 1;\n\tbig[++k] = add[i];\n }\n\n if (big[0] == n_orig) {\n\tfree(big);\n\tbig = NULL;\n\t*err = E_NOADD;\n }\n\n return big;\n}", "label": 0, "cwe": null, "length": 255 }, { "index": 227011, "code": "ctcp_gen_ping_response(char *timestamp)\n{\n\tchar *out_msg = NULL;\n\tint out_msg_len;\n\n\tout_msg_len =\n\t\tctcp_command[CTCP_PING].length + 3 +\n\t\t(timestamp ? strlen(timestamp) : 0);\n\n\tout_msg = (char *)calloc((out_msg_len + 1), sizeof(char));\n\n\tout_msg[0] = '\\001';\n\tstrcat(out_msg, ctcp_command[CTCP_PING].data);\n\tout_msg[ctcp_command[CTCP_PING].length + 1] = ' ';\n\n\tstrcat(out_msg, timestamp);\n\n\tout_msg[out_msg_len - 1] = '\\001';\n\n\treturn out_msg;\n}", "label": 0, "cwe": null, "length": 139 }, { "index": 735055, "code": "nvkm_client_notify_put(struct nvkm_client *client, int index)\n{\n\tif (index < ARRAY_SIZE(client->notify)) {\n\t\tif (client->notify[index]) {\n\t\t\tnvkm_notify_put(&client->notify[index]->n);\n\t\t\treturn 0;\n\t\t}\n\t}\n\treturn -ENOENT;\n}", "label": 0, "cwe": null, "length": 67 }, { "index": 654118, "code": "soap_in_ns1__lusol(struct soap *soap, const char *tag, struct ns1__lusol *a, const char *type)\n{\n\tsize_t soap_flag_a = 1;\n\tsize_t soap_flag_b = 1;\n\tif (soap_element_begin_in(soap, tag, 0, type))\n\t\treturn NULL;\n\ta = (struct ns1__lusol *)soap_id_enter(soap, soap->id, a, SOAP_TYPE_ns1__lusol, sizeof(struct ns1__lusol), 0, NULL, NULL, NULL);\n\tif (!a)\n\t\treturn NULL;\n\tsoap_default_ns1__lusol(soap, a);\n\tif (soap->body && !*soap->href)\n\t{\n\t\tfor (;;)\n\t\t{\tsoap->error = SOAP_TAG_MISMATCH;\n\t\t\tif (soap_flag_a && soap->error == SOAP_TAG_MISMATCH)\n\t\t\t\tif (soap_in_PointerTomatrix(soap, \"a\", &a->a, \"xsd:double[]\"))\n\t\t\t\t{\tsoap_flag_a--;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\tif (soap_flag_b && soap->error == SOAP_TAG_MISMATCH)\n\t\t\t\tif (soap_in_PointerTovector(soap, \"b\", &a->b, \"xsd:double\"))\n\t\t\t\t{\tsoap_flag_b--;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\tif (soap->error == SOAP_TAG_MISMATCH)\n\t\t\t\tsoap->error = soap_ignore_element(soap);\n\t\t\tif (soap->error == SOAP_NO_TAG)\n\t\t\t\tbreak;\n\t\t\tif (soap->error)\n\t\t\t\treturn NULL;\n\t\t}\n\t\tif (soap_element_end_in(soap, tag))\n\t\t\treturn NULL;\n\t}\n\telse\n\t{\ta = (struct ns1__lusol *)soap_id_forward(soap, soap->href, (void*)a, 0, SOAP_TYPE_ns1__lusol, 0, sizeof(struct ns1__lusol), 0, NULL);\n\t\tif (soap->body && soap_element_end_in(soap, tag))\n\t\t\treturn NULL;\n\t}\n\treturn a;\n}", "label": 0, "cwe": null, "length": 434 }, { "index": 6975, "code": "meanresp(double *sta,double *stimuli, unsigned long Nn,unsigned long fsize,int locator[],unsigned long Nspikes, unsigned long Ntrials)\n{\n unsigned long i,k;\n double temp;\n for(i=1;i<=Nn;i++) sta[i]=0;\n double rbar;\n rbar=(double)Nspikes/(double)Ntrials;\n for(k=1;k<=Ntrials;k++){\n temp= ((double)locator[k]-rbar)/(double)Ntrials;\n for(i=1;i<=Nn;i++){\n sta[i]+=stimuli[(k-1)*fsize+i]*temp;\n }\n }\n}", "label": 0, "cwe": null, "length": 147 }, { "index": 590509, "code": "qlcnic_83xx_enable_flash_write(struct qlcnic_adapter *adapter)\n{\n\tint ret;\n\tu32 cmd;\n\tcmd = adapter->ahw->fdt.write_statusreg_cmd;\n\tqlcnic_83xx_wrt_reg_indirect(adapter, QLC_83XX_FLASH_ADDR,\n\t\t\t\t (QLC_83XX_FLASH_FDT_WRITE_DEF_SIG | cmd));\n\tqlcnic_83xx_wrt_reg_indirect(adapter, QLC_83XX_FLASH_WRDATA,\n\t\t\t\t adapter->ahw->fdt.write_enable_bits);\n\tqlcnic_83xx_wrt_reg_indirect(adapter, QLC_83XX_FLASH_CONTROL,\n\t\t\t\t QLC_83XX_FLASH_SECOND_ERASE_MS_VAL);\n\tret = qlcnic_83xx_poll_flash_status_reg(adapter);\n\tif (ret)\n\t\treturn -EIO;\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 177 }, { "index": 40819, "code": "SVCmd_Softmap_f (void)\n{\n\tif (gi.argc() < 3) {\n\t\tgi.cprintf(NULL, PRINT_HIGH, \"Usage: sv softmap \\n\");\n\t\treturn;\n\t}\n\tif (lights_camera_action) {\n\t\tgi.cprintf(NULL, PRINT_HIGH, \"Please dont use sv softmap during LCA\\n\");\n\t\treturn;\n\t}\n\n\tQ_strncpyz(level.nextmap, gi.argv(2), sizeof(level.nextmap));\n\tgi.bprintf(PRINT_HIGH, \"Console is setting map: %s\\n\", level.nextmap);\n\tdosoft = 1;\n\tEndDMLevel();\n\treturn;\n}", "label": 0, "cwe": null, "length": 138 }, { "index": 14837, "code": "mp4ff_read_stsz(mp4ff_t *f)\n{\n mp4ff_read_char(f); /* version */\n mp4ff_read_int24(f); /* flags */\n f->track[f->total_tracks - 1]->stsz_sample_size = mp4ff_read_int32(f);\n f->track[f->total_tracks - 1]->stsz_sample_count = mp4ff_read_int32(f);\n\n if (f->track[f->total_tracks - 1]->stsz_sample_size == 0)\n {\n int32_t i;\n f->track[f->total_tracks - 1]->stsz_table =\n (int32_t*)malloc(f->track[f->total_tracks - 1]->stsz_sample_count*sizeof(int32_t));\n\n for (i = 0; i < f->track[f->total_tracks - 1]->stsz_sample_count; i++)\n {\n f->track[f->total_tracks - 1]->stsz_table[i] = mp4ff_read_int32(f);\n }\n }\n\n return 0;\n}", "label": 0, "cwe": null, "length": 227 }, { "index": 499627, "code": "smsc95xx_phy_update_flowcontrol(struct usbnet *dev, u8 duplex,\n\t\t\t\t\t u16 lcladv, u16 rmtadv)\n{\n\tu32 flow, afc_cfg = 0;\n\n\tint ret = smsc95xx_read_reg(dev, AFC_CFG, &afc_cfg);\n\tif (ret < 0)\n\t\treturn ret;\n\n\tif (duplex == DUPLEX_FULL) {\n\t\tu8 cap = mii_resolve_flowctrl_fdx(lcladv, rmtadv);\n\n\t\tif (cap & FLOW_CTRL_RX)\n\t\t\tflow = 0xFFFF0002;\n\t\telse\n\t\t\tflow = 0;\n\n\t\tif (cap & FLOW_CTRL_TX)\n\t\t\tafc_cfg |= 0xF;\n\t\telse\n\t\t\tafc_cfg &= ~0xF;\n\n\t\tnetif_dbg(dev, link, dev->net, \"rx pause %s, tx pause %s\\n\",\n\t\t\t\t cap & FLOW_CTRL_RX ? \"enabled\" : \"disabled\",\n\t\t\t\t cap & FLOW_CTRL_TX ? \"enabled\" : \"disabled\");\n\t} else {\n\t\tnetif_dbg(dev, link, dev->net, \"half duplex\\n\");\n\t\tflow = 0;\n\t\tafc_cfg |= 0xF;\n\t}\n\n\tret = smsc95xx_write_reg(dev, FLOW, flow);\n\tif (ret < 0)\n\t\treturn ret;\n\n\treturn smsc95xx_write_reg(dev, AFC_CFG, afc_cfg);\n}", "label": 0, "cwe": null, "length": 300 }, { "index": 474365, "code": "select_param_kind(HTK_Param *p, short dst_type_arg)\n{\n int *vmark;\n int vlen;\n int i;\n short new_type;\n\n /* prepare work area */\n vmark = (int *)mymalloc(sizeof(int) * p->veclen);\n vlen = p->veclen;\n for (i=0;iheader.sampsize = p->veclen * sizeof(VECT);\n p->header.samptype = new_type | (p->header.samptype & F_BASEMASK);\n \n#ifdef DEBUG\n {\n char pbuf[80];\n printf(\"new param made: %s\\n\", param_code2str(pbuf, p->header.samptype, FALSE));\n }\n#endif\n \n /* free work area */\n free(vmark);\n\n return(TRUE);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 258 }, { "index": 459272, "code": "dc1394_avt_set_mirror(dc1394camera_t *camera, dc1394bool_t on_off)\n{\n dc1394error_t err;\n uint32_t curval;\n\n /* ON / OFF : Bit 6 */\n curval = on_off << 25;\n\n /* Set mirror mode */\n err=dc1394_set_adv_control_register(camera,REG_CAMERA_AVT_MIRROR_IMAGE, curval);\n DC1394_ERR_RTN(err,\"Could not set AVT mirror image\");\n\n return DC1394_SUCCESS;\n}", "label": 0, "cwe": null, "length": 114 }, { "index": 805996, "code": "e_utf8_to_iconv_string_sized (iconv_t ic,\n const gchar *string,\n gint bytes)\n{\n\tgchar *new, *ob;\n\tconst gchar *ib;\n\tgsize ibl, obl;\n\n\tif (!string) return NULL;\n\n\tif (ic == (iconv_t) -1) {\n\t\tgint len;\n\t\tconst gchar *u;\n\t\tgunichar uc;\n\n\t\tnew = (gchar *) g_new (guchar, bytes * 4 + 1);\n\t\tu = string;\n\t\tlen = 0;\n\n\t\twhile ((u) && (u - string < bytes)) {\n\t\t\tu = e_unicode_get_utf8 (u, &uc);\n\t\t\tnew[len++] = uc & 0xff;\n\t\t}\n\t\tnew[len] = '\\0';\n\t\treturn new;\n\t}\n\n\tib = string;\n\tibl = bytes;\n\tnew = ob = g_new (char, ibl * 4 + 4);\n\tobl = ibl * 4;\n\n\twhile (ibl > 0) {\n\t\tcamel_iconv (ic, &ib, &ibl, &ob, &obl);\n\t\tif (ibl > 0) {\n\t\t\tgint len;\n\t\t\tif ((*ib & 0x80) == 0x00) len = 1;\n\t\t\telse if ((*ib &0xe0) == 0xc0) len = 2;\n\t\t\telse if ((*ib &0xf0) == 0xe0) len = 3;\n\t\t\telse if ((*ib &0xf8) == 0xf0) len = 4;\n\t\t\telse {\n\t\t\t\tg_warning (\"Invalid UTF-8 sequence\");\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tib += len;\n\t\t\tibl = bytes - (ib - string);\n\t\t\tif (ibl > bytes) ibl = 0;\n\n\t\t\t/* FIXME This is wrong. What if the destination\n\t\t\t * charset is 16 or 32 bit? */\n\t\t\t*ob++ = '_';\n\t\t\tobl--;\n\t\t}\n\t}\n\n\t/* Make sure to terminate with plenty of padding */\n\tmemset (ob, 0, 4);\n\n\treturn new;\n}", "label": 0, "cwe": null, "length": 460 }, { "index": 19357, "code": "par_length(char *data)\n{\n\tint i = 0, b_count = 1;\n\n\tfor(;;) {\n\t\tif(data[i] == ')') {\n\t\t\tb_count--;\n\t\t\tif(!b_count)\n\t\t\t\treturn(i);\n\t\t}\n\t\telse if(data[i] == '(')\n\t\t\tb_count++;\n\t\telse if(data[i] == '\\0')\n\t\t\treturn(-1);\n\t\ti++;\n\t}\n}", "label": 0, "cwe": null, "length": 85 }, { "index": 176728, "code": "interaction (struct imclient *context, sasl_interact_t *t, char *user)\n{\n char result[1024];\n struct stringlist *cur;\n \n assert(context);\n assert(t);\n\n cur = malloc(sizeof(struct stringlist));\n if(!cur) {\n t->len=0;\n t->result=NULL;\n return;\n }\n\n cur->str = NULL;\n cur->next = context->interact_results;\n context->interact_results = cur;\n\n if ((t->id == SASL_CB_USER || t->id == SASL_CB_AUTHNAME) \n && user && user[0]) {\n t->len = strlen(user);\n cur->str = xstrdup(user);\n } else {\n printf(\"%s: \", t->prompt);\n if (t->id == SASL_CB_PASS) {\n\t char *ptr = cyrus_getpass(\"\");\n\t strlcpy(result, ptr, sizeof(result));\n } else {\n\t if (!fgets(result, sizeof(result)-1, stdin)) return;\n\t result[strlen(result) - 1] = '\\0';\n }\n\n t->len = strlen(result);\n cur->str = (char *) xmalloc(t->len+1);\n memset(cur->str, 0, t->len+1);\n memcpy(cur->str, result, t->len);\n }\n\n t->result = cur->str;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 300 }, { "index": 354251, "code": "new_fluid_inst_zone(char* name)\n{\n\tint size;\n\tfluid_inst_zone_t* zone = NULL;\n\tzone = FLUID_NEW(fluid_inst_zone_t);\n\tif (zone == NULL) {\n\t\tFLUID_LOG(FLUID_ERR, \"Out of memory\");\n\t\treturn NULL;\n\t}\n\tzone->next = NULL;\n\tsize = 1 + FLUID_STRLEN(name);\n\tzone->name = FLUID_MALLOC(size);\n\tif (zone->name == NULL) {\n\t\tFLUID_LOG(FLUID_ERR, \"Out of memory\");\n\t\tFLUID_FREE(zone);\n\t\treturn NULL;\n\t}\n\tFLUID_STRCPY(zone->name, name);\n\tzone->sample = NULL;\n\tzone->keylo = 0;\n\tzone->keyhi = 128;\n\tzone->vello = 0;\n\tzone->velhi = 128;\n\n\t/* Flag the generators as unused.\n\t * This also sets the generator values to default, but they will be overwritten anyway, if used.*/\n\tfluid_gen_set_default_values(&zone->gen[0]);\n\tzone->mod=NULL; /* list of modulators */\n\treturn zone;\n}", "label": 0, "cwe": null, "length": 244 }, { "index": 110016, "code": "init(void)\n{\n // Return early if slowdown timer not selected\n if ((SIM->get_param_enum(BXPN_CLOCK_SYNC)->get() != BX_CLOCK_SYNC_SLOWDOWN) &&\n (SIM->get_param_enum(BXPN_CLOCK_SYNC)->get() != BX_CLOCK_SYNC_BOTH))\n return;\n\n BX_INFO((\"using 'slowdown' timer synchronization method\"));\n s.MAXmultiplier=MAXMULT;\n s.Q=Qval;\n\n if(s.MAXmultiplier<1)\n s.MAXmultiplier=1;\n\n s.start_time=sectousec(time(NULL));\n s.start_emulated_time = bx_pc_system.time_usec();\n s.lasttime=0;\n if (s.timer_handle == BX_NULL_TIMER_HANDLE) {\n s.timer_handle=bx_pc_system.register_timer(this, timer_handler, 100 , 1, 1,\n \"slowdown_timer\");\n }\n bx_pc_system.deactivate_timer(s.timer_handle);\n bx_pc_system.activate_timer(s.timer_handle,(Bit32u)s.Q,0);\n}", "label": 0, "cwe": null, "length": 216 }, { "index": 43674, "code": "GdipSetPenColor (GpPen *pen, ARGB argb)\n{\n\tif (!pen)\n\t\treturn InvalidParameter;\n\n\tpen->changed = pen->changed ? TRUE : (pen->color != argb);\n\tpen->color = argb;\n\n\tif (pen->changed && pen->brush && (pen->brush->vtable->type == BrushTypeSolidColor))\n\t\treturn GdipSetSolidFillColor ((GpSolidFill*)pen->brush, argb);\n\n\treturn Ok;\n}", "label": 0, "cwe": null, "length": 106 }, { "index": 759019, "code": "peek (void)\n{\n if (this->start_ != 0 && this->ptr_ != this->end_)\n return *this->ptr_;\n return -1;\n}", "label": 0, "cwe": null, "length": 39 }, { "index": 72611, "code": "cb_change_theme()\n{\n Menu *menu;\n theme_load( theme_names[config.theme_id] );\n hint_set_bkgnd( mbkgnd );\n /* apply the new background to all items */\n list_reset( menus );\n while ( ( menu = list_next( menus ) ) ) {\n menu_set_bkgnd( menu, mbkgnd );\n menu_set_fonts( menu, mcfont, mfont, mhfont );\n }\n stk_surface_blit( mbkgnd, 0,0,-1,-1, stk_display, 0,0 );\n stk_display_update( STK_UPDATE_ALL );\n}", "label": 0, "cwe": null, "length": 133 }, { "index": 597045, "code": "do_kernel_range_flush(void *info)\n{\n\tstruct flush_tlb_info *f = info;\n\tunsigned long addr;\n\n\t/* flush range by one by one 'invlpg' */\n\tfor (addr = f->flush_start; addr < f->flush_end; addr += PAGE_SIZE)\n\t\t__flush_tlb_single(addr);\n}", "label": 0, "cwe": null, "length": 69 }, { "index": 316190, "code": "Streak_Neighbor(StreakVars *svars, VECTOR_TYPE *v)\n{\n int found;\n\n if (! svars->inside0)\n {\n\tfound = (*(svars->I0->currentVectorGrp->Neighbor))(svars->I0, v);\n\tif (found != 1)\n\t return found;\n }\n\n if (! svars->inside1)\n {\n\tfound = (*(svars->I1->currentVectorGrp->Neighbor))(svars->I1, v);\n\tif (found != 1)\n\t return found;\n }\n\n return 1;\n}", "label": 0, "cwe": null, "length": 126 }, { "index": 297635, "code": "setIgnoredErrors(const QList &errors)\n{\n d->ignoredErrors.clear();\n //### Quadratic runtime, woohoo! Use a QSet if that should ever be an issue.\n foreach(KSslError::Error e, errors)\n if (!isErrorIgnored(e))\n d->ignoredErrors.append(e);\n}", "label": 0, "cwe": null, "length": 78 }, { "index": 399430, "code": "local_ldap_auth_by_dn(Uri *url, char *username, char *password,\n\t\t\t\t\t struct timeval *timeout, Dsvec *avas)\n{\n int attrsonly, n, scope;\n char *user_dn;\n char *attrs[100];\n LDAP *ld;\n\n if ((ld = do_init(url->host, url->port)) == NULL)\n\treturn(-1);\n\n if (*url->path == '/')\n\tuser_dn = url->path + 1;\n else\n\tuser_dn = url->path;\n\n log_msg((LOG_TRACE_LEVEL, \"Authenticating by binding to \\\"%s\\\"\", user_dn));\n\n if (do_bind(ld, user_dn, password) == -1) {\n\tlog_msg((LOG_ERROR_LEVEL, \"Bind to \\\"%s\\\" failed\", user_dn));\n\tldap_unbind(ld);\n\treturn(0);\n }\n log_msg((LOG_DEBUG_LEVEL, \"Bind to \\\"%s\\\" succeeded\", user_dn));\n\n if (avas != NULL) {\n\tscope = LDAP_SCOPE_BASE;\n\tattrsonly = 0;\n\tattrs[0] = \"*\";\t\t/* Get all attributes */\n\tattrs[1] = NULL;\n\tn = fetch_entry(ld, user_dn, scope, NULL, NULL,\n\t\t\t\t\tattrs, attrsonly, NULL, NULL, timeout, -1, NULL, avas);\n\tif (n == -1) {\n\t log_msg((LOG_ERROR_LEVEL, \"Can't read entry for DN %s\", user_dn));\n\t ldap_unbind(ld);\n\t return(-1);\n\t}\n\telse if (n > 1) {\n\t log_msg((LOG_WARN_LEVEL, \"Too many results for DN %s\", user_dn));\n\t ldap_unbind(ld);\n\t return(-1);\n\t}\n\tlog_msg((LOG_DEBUG_LEVEL, \"Read entry for DN %s\", user_dn));\n }\n\n ldap_unbind(ld);\n\n return(1);\n}", "label": 0, "cwe": null, "length": 396 }, { "index": 766923, "code": "compare(const Expr& e1, const Expr& e2) {\n // Quick equality check (operator== is implemented independently\n // and more efficiently)\n if(e1 == e2) return 0;\n \n if(e1.d_expr == NULL) return -1;\n if(e2.d_expr == NULL) return 1;\n\n // Both are non-Null. Check for constant\n bool e1c = e1.isConstant();\n if (e1c != e2.isConstant()) {\n return e1c ? -1 : 1;\n }\n\n // Compare the indices\n return (e1.getIndex() < e2.getIndex())? -1 : 1;\n}", "label": 0, "cwe": null, "length": 149 }, { "index": 407164, "code": "camel_imapx_command_compare (CamelIMAPXCommand *ic1,\n CamelIMAPXCommand *ic2)\n{\n\tg_return_val_if_fail (CAMEL_IS_IMAPX_COMMAND (ic1), 0);\n\tg_return_val_if_fail (CAMEL_IS_IMAPX_COMMAND (ic2), 0);\n\n\tif (ic1->pri == ic2->pri)\n\t\treturn 0;\n\n\treturn (ic1->pri < ic2->pri) ? -1 : 1;\n}", "label": 0, "cwe": null, "length": 108 }, { "index": 303979, "code": "attachPointStaticProperties(as_object& o)\n{\n Global_as& gl = getGlobal(o);\n o.init_member(\"distance\", gl.createFunction(point_distance), 0);\n o.init_member(\"interpolate\", gl.createFunction(point_interpolate), 0);\n o.init_member(\"polar\", gl.createFunction(point_polar), 0);\n}", "label": 0, "cwe": null, "length": 74 }, { "index": 1016314, "code": "displaySlice(OutputDev *out, double hDPI, double vDPI,\n\t\t\tint rotate, GBool useMediaBox, GBool crop,\n\t\t\tint sliceX, int sliceY, int sliceW, int sliceH,\n\t\t\tGBool printing, Catalog *catalog,\n\t\t\tGBool (*abortCheckCbk)(void *data),\n\t\t\tvoid *abortCheckCbkData,\n GBool (*annotDisplayDecideCbk)(Annot *annot, void *user_data),\n void *annotDisplayDecideCbkData) {\n Gfx *gfx;\n Object obj;\n Annots *annotList;\n int i;\n \n if (!out->checkPageSlice(this, hDPI, vDPI, rotate, useMediaBox, crop,\n\t\t\t sliceX, sliceY, sliceW, sliceH,\n\t\t\t printing, catalog,\n\t\t\t abortCheckCbk, abortCheckCbkData)) {\n return;\n }\n\n gfx = createGfx(out, hDPI, vDPI, rotate, useMediaBox, crop,\n\t\t sliceX, sliceY, sliceW, sliceH,\n\t\t printing, catalog,\n\t\t abortCheckCbk, abortCheckCbkData,\n\t\t annotDisplayDecideCbk, annotDisplayDecideCbkData);\n\n contents.fetch(xref, &obj);\n if (!obj.isNull()) {\n gfx->saveState();\n gfx->display(&obj);\n gfx->restoreState();\n }\n obj.free();\n\n // draw annotations\n annotList = new Annots(xref, catalog, getAnnots(&obj));\n obj.free();\n \n if (annotList->getNumAnnots() > 0) {\n if (globalParams->getPrintCommands()) {\n printf(\"***** Annotations\\n\");\n }\n for (i = 0; i < annotList->getNumAnnots(); ++i) {\n Annot *annot = annotList->getAnnot(i);\n if ((annotDisplayDecideCbk &&\n (*annotDisplayDecideCbk)(annot, annotDisplayDecideCbkData)) || \n !annotDisplayDecideCbk) {\n annotList->getAnnot(i)->draw(gfx, printing);\n\t}\n }\n out->dump();\n }\n delete annotList;\n\n delete gfx;\n}", "label": 0, "cwe": null, "length": 488 }, { "index": 473995, "code": "snic_del_host(struct Scsi_Host *shost)\n{\n\tif (!shost->work_q)\n\t\treturn;\n\n\tdestroy_workqueue(shost->work_q);\n\tshost->work_q = NULL;\n\tscsi_remove_host(shost);\n}", "label": 0, "cwe": null, "length": 52 }, { "index": 355069, "code": "build_addition_foreach (char *key, Addition *addition, GSList **additions)\n{\n\tif (addition->parent != NULL)\n\t\t*additions = g_slist_append (*additions, addition);\n\telse\n\t\tg_free (addition);\n}", "label": 0, "cwe": null, "length": 58 }, { "index": 541824, "code": "textiowrapper_flush(textio *self, PyObject *args)\n{\n CHECK_ATTACHED(self);\n CHECK_CLOSED(self);\n self->telling = self->seekable;\n if (_textiowrapper_writeflush(self) < 0)\n return NULL;\n return _PyObject_CallMethodId(self->buffer, &PyId_flush, NULL);\n}", "label": 0, "cwe": null, "length": 76 }, { "index": 563415, "code": "check_coalesce_subset(__isl_keep isl_map *map, int i, int j,\n\tstruct isl_tab **tabs)\n{\n\tint known;\n\tisl_mat *div_i, *div_j, *div;\n\tint *exp1 = NULL;\n\tint *exp2 = NULL;\n\tisl_ctx *ctx;\n\tint subset;\n\n\tif (map->p[i]->n_div == map->p[j]->n_div)\n\t\treturn 0;\n\tif (map->p[j]->n_div < map->p[i]->n_div)\n\t\treturn check_coalesce_subset(map, j, i, tabs);\n\n\tknown = isl_basic_map_divs_known(map->p[i]);\n\tif (known < 0 || !known)\n\t\treturn known;\n\n\tctx = isl_map_get_ctx(map);\n\n\tdiv_i = isl_basic_map_get_divs(map->p[i]);\n\tdiv_j = isl_basic_map_get_divs(map->p[j]);\n\n\tif (!div_i || !div_j)\n\t\tgoto error;\n\n\texp1 = isl_alloc_array(ctx, int, div_i->n_row);\n\texp2 = isl_alloc_array(ctx, int, div_j->n_row);\n\tif ((div_i->n_row && !exp1) || (div_j->n_row && !exp2))\n\t\tgoto error;\n\n\tdiv = isl_merge_divs(div_i, div_j, exp1, exp2);\n\tif (!div)\n\t\tgoto error;\n\n\tif (div->n_row == div_j->n_row)\n\t\tsubset = coalesce_subset(map, i, j, tabs, div, exp1);\n\telse\n\t\tsubset = 0;\n\n\tisl_mat_free(div);\n\n\tisl_mat_free(div_i);\n\tisl_mat_free(div_j);\n\n\tfree(exp2);\n\tfree(exp1);\n\n\treturn subset;\nerror:\n\tisl_mat_free(div_i);\n\tisl_mat_free(div_j);\n\tfree(exp1);\n\tfree(exp2);\n\treturn -1;\n}", "label": 0, "cwe": null, "length": 386 }, { "index": 236463, "code": "do_check (GConfDefaults *mechanism,\n gboolean mandatory,\n const gchar **includes,\n DBusGMethodInvocation *context)\n{\n\tActionData *adata;\n\n\tstart_operation ();\n\n\tadata = g_new0 (ActionData, 1);\n\tadata->mechanism = g_object_ref (mechanism);\n\tadata->context = context;\n\tadata->includes = g_strdupv ((gchar **)includes);\n\tadata->actions_ready_callback = check_permissions_only;\n\tadata->auth_obtained_callback = NULL;\n\tadata->data = NULL;\n\tadata->destroy = NULL;\n\n\tif (mandatory) {\n\t\tadata->annotation_key = \"org.gnome.gconf.defaults.set-mandatory.prefix\";\n\t\tadata->default_action = \"org.gnome.gconf.defaults.set-mandatory\";\n\t}\n\telse {\n\t\tadata->annotation_key = \"org.gnome.gconf.defaults.set-system.prefix\";\n\t\tadata->default_action = \"org.gnome.gconf.defaults.set-system\";\n\t}\n\n\tpolkit_authority_enumerate_actions (mechanism->priv->auth,\n\t\t\t\t\t NULL,\n\t\t\t\t\t actions_ready_cb,\n\t\t\t\t\t adata);\n}", "label": 0, "cwe": null, "length": 243 }, { "index": 96943, "code": "convert_path(char *dst, char *src)\n{\n\tint i;\n\n\ti = 0;\n\twhile (src[i] != 0)\n\t{\n#ifdef _WIN32\n\t\tif (src[i] == '/')\n\t\t{\n\t\t\tdst[i] = '\\\\';\n\t\t}\n#else\n\t\tif (src[i] == '\\\\')\n\t\t{\n\t\t\tdst[i] = '/';\n\t\t}\n#endif\n\t\telse\n\t\t{\n\t\t\tdst[i] = src[i];\n\t\t}\n\n\t\ti++;\n\t}\n\tdst[i] = 0;\n}", "label": 0, "cwe": null, "length": 112 }, { "index": 16174, "code": "write_temp_fp(const char *p, size_t n, void *vp)\n{\n\tif (fwrite(p, n, 1, (FILE *)vp) != 1)\n\t\t; /* ignored */\n}", "label": 0, "cwe": null, "length": 44 }, { "index": 800920, "code": "compute_spline_deltas(stp_curve_t *curve)\n{\n if (curve->piecewise)\n compute_spline_deltas_piecewise(curve);\n else\n compute_spline_deltas_dense(curve);\n}", "label": 0, "cwe": null, "length": 47 }, { "index": 611643, "code": "bf_task_stack(Var arglist, Byte next, void *vdata, Objid progr)\n{\n int nargs = arglist.v.list[0].v.num;\n int id = arglist.v.list[1].v.num;\n int line_numbers_too = (nargs >= 2 && is_true(arglist.v.list[2]));\n vm the_vm = find_suspended_task(id);\n Objid owner = (the_vm ? progr_of_cur_verb(the_vm) : NOTHING);\n\n free_var(arglist);\n if (!the_vm)\n\treturn make_error_pack(E_INVARG);\n if (!is_wizard(progr) && progr != owner)\n\treturn make_error_pack(E_PERM);\n\n return make_var_pack(make_stack_list(the_vm->activ_stack, 0,\n\t\t\t\t\t the_vm->top_activ_stack, 1,\n\t\t\t\t\t the_vm->root_activ_vector,\n\t\t\t\t\t line_numbers_too));\n}", "label": 0, "cwe": null, "length": 192 }, { "index": 78132, "code": "put_string(const char *s)\n{\n for(; *s != 0; s++)\n {\n if(*s == '\\n') put_char(ZSCII_NEWLINE);\n else put_char(*s);\n }\n}", "label": 0, "cwe": null, "length": 48 }, { "index": 861302, "code": "agdelrec(void *arg_obj, char *name)\n{\n Agobj_t *obj;\n Agrec_t *rec;\n Agraph_t *g;\n\n obj = (Agobj_t *) arg_obj;\n g = agraphof(obj);\n rec = aggetrec(obj, name, FALSE);\n if (rec) {\n\tlistdelrec(obj, rec);\t/* zap it from the circular list */\n\tswitch (obj->tag.objtype) {\t/* refresh any stale pointers */\n\tcase AGRAPH:\n\t objdelrec(g, obj, rec);\n\t break;\n\tcase AGNODE:\n\tcase AGINEDGE:\n\tcase AGOUTEDGE:\n\t agapply(agroot(g), obj, objdelrec, rec, FALSE);\n\t break;\n\t}\n\tagstrfree(g, rec->name);\n\tagfree(g, rec);\n\treturn SUCCESS;\n } else\n\treturn FAILURE;\n}", "label": 0, "cwe": null, "length": 185 }, { "index": 331359, "code": "ar_card_get_name_by_id_snprintf (char *buffer,\n gsize bufsize,\n int card_id)\n{\n int suit, rank, len;\n\n suit = card_id / 13;\n rank = card_id % 13;\n\n if (G_LIKELY (suit < 4)) {\n len = g_snprintf (buffer, bufsize, \"%s-%s\",\n suites + suite_offsets[suit],\n ranks + rank_offsets[rank]);\n } else {\n len = g_snprintf (buffer, bufsize, \"%s\",\n extra_cards + extra_card_offsets[rank]);\n }\n\n return len;\n}", "label": 0, "cwe": null, "length": 132 }, { "index": 28584, "code": "__grant_blocked_reserve_locks (xlator_t *this, pl_inode_t *pl_inode,\n struct list_head *granted)\n{\n int bl_ret = 0;\n posix_lock_t *bl = NULL;\n posix_lock_t *tmp = NULL;\n\n struct list_head blocked_list;\n\n INIT_LIST_HEAD (&blocked_list);\n list_splice_init (&pl_inode->blocked_reservelks, &blocked_list);\n\n list_for_each_entry_safe (bl, tmp, &blocked_list, list) {\n\n list_del_init (&bl->list);\n\n bl_ret = __lock_reservelk (this, pl_inode, bl, 1);\n\n if (bl_ret == 0) {\n list_add (&bl->list, granted);\n }\n }\n return;\n}", "label": 0, "cwe": null, "length": 167 }, { "index": 491399, "code": "cr_input_peek_byte2 (CRInput * a_this, gulong a_offset, gboolean * a_eof)\n{\n guchar result = 0;\n enum CRStatus status = CR_ERROR;\n\n g_return_val_if_fail (a_this && PRIVATE (a_this), 0);\n\n if (a_eof)\n *a_eof = FALSE;\n\n status = cr_input_peek_byte (a_this, CR_SEEK_CUR, a_offset, &result);\n\n if ((status == CR_END_OF_INPUT_ERROR)\n && a_eof)\n *a_eof = TRUE;\n\n return result;\n}", "label": 0, "cwe": null, "length": 124 }, { "index": 90986, "code": "get_hex_spec () const throw ()\n{\n\tstd::ostringstream os;\n\tos << \"#\" << std::hex << std::setfill ('0');\n\tos << std::setw (2) << CLAMP (int (red * 255.0), 0, 255);\n\tos << std::setw (2) << CLAMP (int (green * 255.0), 0, 255);\n\tos << std::setw (2) << CLAMP (int (blue * 255.0), 0, 255);\n\treturn os.str ();\n}", "label": 0, "cwe": null, "length": 115 }, { "index": 623327, "code": "userManager()\n{\n if (!_userManagerDialog) {\n _userManagerDialog = new UserManagerDialog(this);\n _userManagerDialog->setModal(true);\n _userManagerDialog->initialize();\n }\n QSize size = QDesktopWidget().availableGeometry(_userManagerDialog).size();\n _userManagerDialog->resize(size*0.75);\n _userManagerDialog->show();\n _userManagerDialog->initializeAfterShowing();\n Utils::centerWidget(_userManagerDialog, this->wizard());\n}", "label": 0, "cwe": null, "length": 97 }, { "index": 17557, "code": "_midgard_sql_query_result_get_column_names (MidgardQueryResult *result, guint *n_names, GError **error)\n{\n\tMidgardSqlQueryResult *self = MIDGARD_SQL_QUERY_RESULT (result);\n\t/* No model, no columns. Return NULL and set error */\n\tif (self->model == NULL || self->n_columns == 0) {\n\t\tg_set_error (error, MIDGARD_VALIDATION_ERROR, MIDGARD_VALIDATION_ERROR_INTERNAL,\n\t\t\t\t\"QueryResult holds empty data model\"); \n\t\treturn NULL;\n\t}\n\n\t*n_names = 0;\n\tif (self->n_columns == 0)\n\t\treturn NULL;\n\n\tGdaDataModel *model = GDA_DATA_MODEL (self->model);\n\t*n_names = gda_data_model_get_n_columns (model);\n\tgchar **names = g_new (gchar *, *n_names + 1);\n\n\tguint i;\n\tfor (i = 0; i < *n_names; i++) {\n\t\tnames[i] = (gchar *) gda_data_model_get_column_name (model, i);\n\t}\n\t\n\treturn names;\n}", "label": 0, "cwe": null, "length": 233 }, { "index": 735167, "code": "GetCFBundleDirectory(const char* config,\n bool contentOnly)\n{\n std::string fpath;\n fpath += this->GetOutputName(config, false);\n fpath += \".\";\n const char *ext = this->GetProperty(\"BUNDLE_EXTENSION\");\n if (!ext)\n {\n ext = \"bundle\";\n }\n fpath += ext;\n fpath += \"/Contents\";\n if(!contentOnly)\n fpath += \"/MacOS\";\n return fpath;\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 54146, "code": "n2int(n)\nstruct n n;\n{\n\tif(n.type == UNDEF)\n\t\treturn UNDEF;\n\telse if(n.type == INT)\n\t\treturn n.val.i;\n\telse\n\t\treturn n.val.f;\n}", "label": 0, "cwe": null, "length": 45 }, { "index": 802109, "code": "print_matrix ARGS3((a,rows,cols),\nREAL **a,\nint rows, int cols)\n{\n int i,j;\n\n for ( i = 0 ; i < rows ; i++ )\n { msg[0] = 0;\n for ( j = 0 ; j < cols ; j++ )\n sprintf(msg+strlen(msg),\"%10.6f \",(DOUBLE)a[i][j]);\n strcat(msg,\"\\n\");\n outstring(msg);\n }\n}", "label": 0, "cwe": null, "length": 102 }, { "index": 476803, "code": "draw(GtkWidget * w, cairo_t * cr)\n#else\ngint XAP_UnixFrameImpl::_fe::expose(GtkWidget * w, GdkEventExpose* pExposeEvent)\n#endif\n{\n\tXAP_UnixFrameImpl * pUnixFrameImpl = static_cast(g_object_get_data(G_OBJECT(w), \"user_data\"));\n\tFV_View * pView = static_cast(pUnixFrameImpl->getFrame()->getCurrentView());\n#if GTK_CHECK_VERSION(3,0,0)\n\tGdkEventExpose *pExposeEvent = reinterpret_cast(gtk_get_current_event());\n#endif\n/* Jean: commenting out next lines since the zoom update code does draw only\n * part of what needs to be updated. */\n//\tif((pUnixFrameImpl->m_bDoZoomUpdate) || (pUnixFrameImpl->m_iZoomUpdateID != 0))\n//\t{\n//\t\treturn TRUE;\n//\t}\n\tif(pView)\n\t{\n\t\tGR_Graphics * pGr = pView->getGraphics ();\n\t\tUT_Rect rClip;\n\t\tif (pGr->getPaintCount () > 0)\n\t\t\treturn TRUE;\n\t\txxx_UT_DEBUGMSG((\"Expose area: x %d y %d width %d height %d \\n\",pExposeEvent->area.x,pExposeEvent->area.y,pExposeEvent->area.width,pExposeEvent->area.height));\n\t\trClip.left = pGr->tlu(pExposeEvent->area.x);\n\t\trClip.top = pGr->tlu(pExposeEvent->area.y);\n\t\trClip.width = pGr->tlu(pExposeEvent->area.width)+1;\n\t\trClip.height = pGr->tlu(pExposeEvent->area.height)+1;\n#if GTK_CHECK_VERSION(3,0,0)\n\t\tstatic_cast(pGr)->setCairo(cr);\n\t\tpView->draw(&rClip);\n\t\tstatic_cast(pGr)->setCairo(NULL);\n#else\n\t\tpView->draw(&rClip);\n#endif\n\t}\n\treturn FALSE;\n}", "label": 0, "cwe": null, "length": 443 }, { "index": 149658, "code": "dht_file_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this,\n int op_ret, int op_errno, struct iatt *prebuf,\n struct iatt *postbuf)\n{\n dht_local_t *local = NULL;\n call_frame_t *prev = NULL;\n int ret = -1;\n\n local = frame->local;\n prev = cookie;\n\n local->op_errno = op_errno;\n if ((op_ret == -1) && (op_errno != ENOENT)) {\n gf_log (this->name, GF_LOG_DEBUG,\n \"subvolume %s returned -1 (%s)\",\n prev->this->name, strerror (op_errno));\n goto out;\n }\n\n if (local->call_cnt != 1)\n goto out;\n\n local->rebalance.target_op_fn = dht_setattr2;\n\n /* Phase 2 of migration */\n if ((op_ret == -1) || IS_DHT_MIGRATION_PHASE2 (postbuf)) {\n ret = dht_rebalance_complete_check (this, frame);\n if (!ret)\n return 0;\n }\n\n /* At the end of the migration process, whatever 'attr' we\n have on source file will be migrated to destination file\n in one shot, hence we don't need to check for in progress\n state here (ie, PHASE1) */\nout:\n DHT_STRIP_PHASE1_FLAGS (postbuf);\n DHT_STRIP_PHASE1_FLAGS (prebuf);\n DHT_STACK_UNWIND (setattr, frame, op_ret, op_errno,\n prebuf, postbuf);\n\n return 0;\n}", "label": 0, "cwe": null, "length": 357 }, { "index": 22837, "code": "quit (BarData *bar_data)\n{\n annotate_quit ();\n quit_pdf_saver ();\n stop_recorder ();\n\n /* Dis-allocate all the BarData structure. */\n if (bar_data)\n {\n if (bar_data->color)\n {\n g_free (bar_data->color);\n bar_data->color = NULL;\n }\n }\n\n gtk_main_quit ();\n return TRUE;\n}", "label": 0, "cwe": null, "length": 87 }, { "index": 624631, "code": "_fash_gl_add(Fash_Glyph *fash, int item, RGBA_Font_Glyph *glyph)\n{\n int grp, maj, min;\n\n // 24bits for unicode - v6 up to E01EF (chrs) & 10FFFD for private use (plane 16)\n grp = (item >> 16) & 0xff;\n maj = (item >> 8) & 0xff;\n min = item & 0xff;\n if (!fash->bucket[grp])\n fash->bucket[grp] = calloc(1, sizeof(Fash_Glyph_Map2));\n EINA_SAFETY_ON_NULL_RETURN(fash->bucket[grp]);\n if (!fash->bucket[grp]->bucket[maj])\n fash->bucket[grp]->bucket[maj] = calloc(1, sizeof(Fash_Glyph_Map));\n EINA_SAFETY_ON_NULL_RETURN(fash->bucket[grp]->bucket[maj]);\n fash->bucket[grp]->bucket[maj]->item[min] = glyph;\n}", "label": 0, "cwe": null, "length": 223 }, { "index": 771274, "code": "set_param_by_index(int i, std::string& value, int offset)\n{\n switch (MODEL_BUILT_IN_MOS6::param_count() - 1 - i) {\n case 0: level = value; break; //6\n case 1: lambda0 = value; break;\n case 2: unreachable(); break;\n case 3: unreachable(); break;\n case 4: unreachable(); break;\n case 5: unreachable(); break;\n case 6: unreachable(); break;\n case 7: mos_level = value; break;\n case 8: kv = value; break;\n case 9: nv = value; break;\n case 10: kc = value; break;\n case 11: nc = value; break;\n case 12: nvth = value; break;\n case 13: ps = value; break;\n case 14: gamma1 = value; break;\n case 15: sigma = value; break;\n case 16: lambda0 = value; break;\n case 17: lambda1 = value; break;\n default: MODEL_BUILT_IN_MOS123::set_param_by_index(i, value, offset); break;\n }\n}", "label": 0, "cwe": null, "length": 262 }, { "index": 260050, "code": "init_task(struct lbp *l)\n{\n float scale;\n float scale_max = fminf((float)l->width / l->data.feature_width, (float)l->height / l->data.feature_height);\n float scale_min = (float)l->para.min_face_width / l->data.feature_width;\n\n for (scale = scale_min; scale < scale_max; scale *= l->para.scaling_factor) {\n int x, y;\n float scaled_width = l->data.feature_width * scale;\n float scaled_height = l->data.feature_height * scale;\n int step_x = scaled_width / l->para.step_scale_x;\n int step_y = scaled_height / l->para.step_scale_y;\n for (x = 0; (x + scaled_width) < (l->width - 1); x += step_x) {\n for (y = 0; (y + scaled_height) < (l->height - 1); y += step_y) {\n struct lbp_task t;\n t.x = x;\n t.y = y;\n t.scale = scale;\n l->tasks.push_back(t);\n }\n }\n }\n}", "label": 0, "cwe": null, "length": 252 }, { "index": 728407, "code": "gtr_message_table_model_get_value (GtkTreeModel * self,\n GtkTreeIter * iter,\n gint column, GValue * value)\n{\n GtrMsg *msg;\n gchar *text;\n GtrMsgStatus status;\n gint i;\n\n g_return_if_fail (iter->stamp == GTR_MESSAGE_TABLE_MODEL (self)->stamp);\n\n msg = GTR_MSG (iter->user_data);\n\n switch (column)\n {\n case GTR_MESSAGE_TABLE_MODEL_ICON_COLUMN:\n g_value_init (value, G_TYPE_STRING);\n\n status = gtr_msg_get_status (msg);\n\n if (status == GTR_MSG_STATUS_UNTRANSLATED)\n text = TABLE_UNTRANSLATED_ICON;\n else if (status == GTR_MSG_STATUS_FUZZY)\n text = TABLE_FUZZY_ICON;\n else\n text = TABLE_TRANSLATED_ICON;\n\n g_value_set_string (value, text);\n break;\n\n case GTR_MESSAGE_TABLE_MODEL_ID_COLUMN:\n g_value_init (value, G_TYPE_INT);\n\n i = GPOINTER_TO_INT (iter->user_data2);\n g_value_set_int (value, i + 1);\n break;\n\n case GTR_MESSAGE_TABLE_MODEL_ORIGINAL_COLUMN:\n g_value_init (value, G_TYPE_STRING);\n\n text = g_strdup (gtr_msg_get_msgid (msg));\n g_value_set_string (value, text);\n g_free (text);\n break;\n\n case GTR_MESSAGE_TABLE_MODEL_TRANSLATION_COLUMN:\n g_value_init (value, G_TYPE_STRING);\n\n text = g_strdup (gtr_msg_get_msgstr (msg));\n g_value_set_string (value, text);\n g_free (text);\n break;\n\n case GTR_MESSAGE_TABLE_MODEL_STATUS_COLUMN:\n g_value_init (value, G_TYPE_INT);\n\n status = gtr_msg_get_status (msg);\n g_value_set_int (value, status);\n break;\n\n case GTR_MESSAGE_TABLE_MODEL_POINTER_COLUMN:\n g_value_init (value, G_TYPE_POINTER);\n\n g_value_set_pointer (value, msg);\n break;\n\n default:\n break;\n }\n\n}", "label": 0, "cwe": null, "length": 451 }, { "index": 950071, "code": "data( int role ) const\n{\n if( isNoLabelItem() )\n {\n switch( role )\n {\n case Qt::DisplayRole:\n return i18nc( \"No labels are assigned to the given item are any of its subitems\", \"No Labels\" );\n case Qt::DecorationRole:\n return KIcon( \"label-amarok\" );\n }\n return QVariant();\n }\n else if( m_parentCollection )\n {\n static const QString counting = i18n( \"Counting...\" );\n switch( role )\n {\n case Qt::DisplayRole:\n case PrettyTreeRoles::FilterRole:\n case PrettyTreeRoles::SortRole:\n return m_parentCollection->prettyName();\n case Qt::DecorationRole:\n return m_parentCollection->icon();\n case PrettyTreeRoles::ByLineRole:\n if( m_isCounting )\n return counting;\n if( m_trackCount < 0 )\n {\n m_isCounting = true;\n\n Collections::QueryMaker *qm = m_parentCollection->queryMaker();\n connect( qm, SIGNAL(newResultReady(QStringList)),\n SLOT(tracksCounted(QStringList)) );\n\n qm->setAutoDelete( true )\n ->setQueryType( Collections::QueryMaker::Custom )\n ->addReturnFunction( Collections::QueryMaker::Count, Meta::valUrl )\n ->run();\n\n return counting;\n }\n return i18np( \"1 track\", \"%1 tracks\", m_trackCount );\n case PrettyTreeRoles::HasCapacityRole:\n return m_parentCollection->hasCapacity();\n case PrettyTreeRoles::UsedCapacityRole:\n return m_parentCollection->usedCapacity();\n case PrettyTreeRoles::TotalCapacityRole:\n return m_parentCollection->totalCapacity();\n case PrettyTreeRoles::DecoratorRoleCount:\n return decoratorActions().size();\n case PrettyTreeRoles::DecoratorRole:\n QVariant v;\n v.setValue( decoratorActions() );\n return v;\n }\n }\n return QVariant();\n}", "label": 0, "cwe": null, "length": 425 }, { "index": 563286, "code": "trace(cmd_options *opt)\n{\n\n switch(opt->value) {\n\n case TRACE_LOGOFF_CMD:\n get_trace().disableLogging();\n cout << \"Logging to file disabled\" << endl;\n break;\n case TRACE_INFO_CMD:\n get_trace().showInfo();\n break;\n default:\n cout << \" Invalid set option\\n\";\n }\n\n}", "label": 0, "cwe": null, "length": 75 }, { "index": 580291, "code": "local_value(struct uct *u, struct board *b, coord_t coord, enum stone color)\n{\n\t/* Tactical evaluation of move @coord by color @color, given\n\t * simulation end position @b. I.e., a move is tactically good\n\t * if the resulting group stays on board until the game end. */\n\t/* We can also take into account surrounding stones, e.g. to\n\t * encourage taking off external liberties during a semeai. */\n\tdouble val = board_local_value(u->local_tree_neival, b, coord, color);\n\treturn (color == S_WHITE) ? 1.f - val : val;\n}", "label": 0, "cwe": null, "length": 137 }, { "index": 418501, "code": "dtmf_indication(dword Id, PLCI *plci, byte *msg, word length)\n{\n\tword i, j, n;\n\n\tdbug(1, dprintf(\"[%06lx] %s,%d: dtmf_indication\",\n\t\t\tUnMapId(Id), (char *)(FILE_), __LINE__));\n\n\tn = 0;\n\tfor (i = 1; i < length; i++)\n\t{\n\t\tj = 0;\n\t\twhile ((j < DTMF_DIGIT_MAP_ENTRIES)\n\t\t && ((msg[i] != dtmf_digit_map[j].code)\n\t\t\t || ((dtmf_digit_map[j].listen_mask & plci->dtmf_rec_active) == 0)))\n\t\t{\n\t\t\tj++;\n\t\t}\n\t\tif (j < DTMF_DIGIT_MAP_ENTRIES)\n\t\t{\n\n\t\t\tif ((dtmf_digit_map[j].listen_mask & DTMF_TONE_LISTEN_ACTIVE_FLAG)\n\t\t\t && (plci->tone_last_indication_code == DTMF_SIGNAL_NO_TONE)\n\t\t\t && (dtmf_digit_map[j].character != DTMF_SIGNAL_UNIDENTIFIED_TONE))\n\t\t\t{\n\t\t\t\tif (n + 1 == i)\n\t\t\t\t{\n\t\t\t\t\tfor (i = length; i > n + 1; i--)\n\t\t\t\t\t\tmsg[i] = msg[i - 1];\n\t\t\t\t\tlength++;\n\t\t\t\t\ti++;\n\t\t\t\t}\n\t\t\t\tmsg[++n] = DTMF_SIGNAL_UNIDENTIFIED_TONE;\n\t\t\t}\n\t\t\tplci->tone_last_indication_code = dtmf_digit_map[j].character;\n\n\t\t\tmsg[++n] = dtmf_digit_map[j].character;\n\t\t}\n\t}\n\tif (n != 0)\n\t{\n\t\tmsg[0] = (byte) n;\n\t\tsendf(plci->appl, _FACILITY_I, Id & 0xffffL, 0, \"wS\", SELECTOR_DTMF, msg);\n\t}\n}", "label": 0, "cwe": null, "length": 400 }, { "index": 1005300, "code": "midgard_config_list_files(gboolean user)\n{\n\tgchar *config_dir;\n\n\tif(user) {\n\t\t\n\t\tgchar *_umcd = g_strconcat(\".\", MIDGARD_PACKAGE_NAME, NULL);\n\t\tconfig_dir = g_build_path (G_DIR_SEPARATOR_S,\n\t\t\t\tg_get_home_dir(), _umcd, \"conf.d\", NULL);\n\t\tg_free (_umcd);\n\t\tif (!g_file_test (config_dir, G_FILE_TEST_IS_DIR)){\n\t\t\tg_error(\"Config directory '%s' doesn't exist\",\n\t\t\t\t\tconfig_dir);\n\t\t\tg_free (config_dir);\n\t\t\treturn NULL;\n\t\t} \n\n\t} else {\n\t\t\n\t\tconfig_dir = __get_default_confdir();\n\t}\n\n\tGError *error = NULL;\n\tGSList *list = NULL;\n\tGSList *l = NULL;\n\tgchar **filenames = NULL;\n\tguint i = 0;\n\tGDir *dir = g_dir_open(config_dir, 0, &error);\n\n\tg_free (config_dir);\n\n\tif (dir == NULL) \n\t\treturn filenames;\n\t\n\tconst gchar *file = g_dir_read_name(dir);\n\twhile (file != NULL) {\n\t\tif(!g_str_has_prefix(file, \".\")\n\t\t\t\t&& (!g_str_has_prefix(file, \"#\"))\n\t\t\t\t&& (!g_str_has_suffix(file, \"~\"))\n\t\t\t\t&& (!g_str_has_suffix(file, \"example\"))) {\n\t\t\tlist = g_slist_append(list, (gpointer)g_strdup(file));\n\t\t\ti++;\n\t\t}\n\t\tfile = g_dir_read_name(dir);\n\t}\n\n\tg_dir_close(dir);\n\t\n\tfilenames = g_new(gchar *, i+1);\n\n\ti = 0;\n\tfor(l = list; l != NULL; l = l->next, i++) \n\t\tfilenames[i] = (gchar *)l->data;\n\n\tfilenames[i] = NULL;\t\t\n\t\n\tg_slist_free (list);\n\n\treturn filenames;\n}", "label": 0, "cwe": null, "length": 390 }, { "index": 297174, "code": "gate_duplicate_computed_gotos (void)\n{\n if (targetm.cannot_modify_jumps_p ())\n return false;\n return (optimize > 0\n\t && flag_expensive_optimizations\n\t && ! optimize_function_for_size_p (cfun));\n}", "label": 0, "cwe": null, "length": 57 }, { "index": 771518, "code": "usbSetReport(union filedescriptor *fdp, int reportType, char *buffer, int len)\n{\n int bytesSent;\n\n if(!usesReportIDs){\n buffer++; /* skip dummy report ID */\n len--;\n }\n bytesSent = usb_control_msg((usb_dev_handle *)fdp->pfd, USB_TYPE_CLASS |\n\t\t\t\tUSB_RECIP_INTERFACE | USB_ENDPOINT_OUT, USBRQ_HID_SET_REPORT,\n\t\t\t\treportType << 8 | buffer[0], 0, buffer, len, 5000);\n if(bytesSent != len){\n if(bytesSent < 0)\n fprintf(stderr, \"Error sending message: %s\\n\", usb_strerror());\n return USB_ERROR_IO;\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 159 }, { "index": 870190, "code": "on_resolution_changed (GtkComboBox *box, gpointer data)\n{\n CcDisplayPanel *self = data;\n int old_width, old_height;\n int x,y;\n int width;\n int height;\n\n if (!self->priv->current_output)\n return;\n\n gnome_rr_output_info_get_geometry (self->priv->current_output, &x, &y, &old_width, &old_height);\n\n if (get_mode (self->priv->resolution_combo, &width, &height, NULL, NULL))\n {\n gnome_rr_output_info_set_geometry (self->priv->current_output, x, y, width, height);\n\n if (width == 0 || height == 0)\n gnome_rr_output_info_set_active (self->priv->current_output, FALSE);\n else\n gnome_rr_output_info_set_active (self->priv->current_output, TRUE);\n }\n\n realign_outputs_after_resolution_change (self, self->priv->current_output, old_width, old_height);\n\n rebuild_rotation_combo (self);\n\n foo_scroll_area_invalidate (FOO_SCROLL_AREA (self->priv->area));\n}", "label": 0, "cwe": null, "length": 236 }, { "index": 357105, "code": "PyInit_time(void)\n{\n PyObject *m;\n m = PyModule_Create(&timemodule);\n if (m == NULL)\n return NULL;\n\n /* Set, or reset, module variables like time.timezone */\n PyInit_timezone(m);\n\n if (!initialized) {\n PyStructSequence_InitType(&StructTimeType,\n &struct_time_type_desc);\n\n /* initialize ClockInfoType */\n PyStructSequence_InitType(&ClockInfoType, &ClockInfo_desc);\n Py_INCREF(&ClockInfoType);\n PyModule_AddObject(m, \"clock_info\", (PyObject*)&ClockInfoType);\n\n#ifdef MS_WINDOWS\n winver.dwOSVersionInfoSize = sizeof(winver);\n if (!GetVersionEx((OSVERSIONINFO*)&winver)) {\n Py_DECREF(m);\n PyErr_SetFromWindowsErr(0);\n return NULL;\n }\n#endif\n }\n Py_INCREF(&StructTimeType);\n PyModule_AddObject(m, \"struct_time\", (PyObject*) &StructTimeType);\n initialized = 1;\n return m;\n}", "label": 0, "cwe": null, "length": 220 }, { "index": 368004, "code": "test_is_selected(char *name) {\n char buf[256];\n int l = strlen(name);\n\n if (config.tests == NULL) return 1;\n buf[0] = ',';\n memcpy(buf+1,name,l);\n buf[l+1] = ',';\n buf[l+2] = '\\0';\n return strstr(config.tests,buf) != NULL;\n}", "label": 0, "cwe": null, "length": 80 }, { "index": 107037, "code": "gkrellm_decal_scroll_text_get_size(GkrellmDecal *d, gint *w, gint *h)\n\t{\n\tif (!d)\n\t\treturn;\n\tif (w)\n\t\t*w = d->scroll_width;\n\tif (h)\n\t\t*h = d->scroll_height\n\t\t\t\t\t+ ((d->flags & DF_SCROLL_TEXT_V_LOOP) ? d->y_ink : 0);\n\t}", "label": 0, "cwe": null, "length": 89 }, { "index": 900001, "code": "debug_compare_object (sc_gameref_t from, sc_gameref_t with, sc_int object)\n{\n const sc_objectstate_t *from_object = from->objects + object;\n const sc_objectstate_t *with_object = with->objects + object;\n\n return from_object->unmoved == with_object->unmoved\n && from_object->static_unmoved == with_object->static_unmoved\n && from_object->position == with_object->position\n && from_object->parent == with_object->parent\n && from_object->openness == with_object->openness\n && from_object->state == with_object->state\n && from_object->seen == with_object->seen;\n}", "label": 0, "cwe": null, "length": 149 }, { "index": 65189, "code": "FilenameToId(const std::string& filename, std::string* id,\n size_t* index) const {\n Pathname pathname(filename);\n unsigned tempdex;\n if (1 != sscanf(pathname.extension().c_str(), \".%u\", &tempdex))\n return false;\n\n *index = static_cast(tempdex);\n\n size_t buffer_size = pathname.basename().length() + 1;\n char* buffer = new char[buffer_size];\n decode(buffer, buffer_size, pathname.basename().data(),\n pathname.basename().length(), '%');\n id->assign(buffer);\n delete [] buffer;\n return true;\n}", "label": 0, "cwe": null, "length": 135 }, { "index": 877548, "code": "main (gint argc, gchar * argv[])\n{\n GThread *threads[MAX_THREADS];\n gint num_threads;\n gint t;\n\n gst_init (&argc, &argv);\n\n g_mutex_init (&fdlock);\n timer = g_timer_new ();\n\n if (argc != 2) {\n g_print (\"usage: %s \\n\", argv[0]);\n exit (-1);\n }\n\n num_threads = atoi (argv[1]);\n\n set = gst_poll_new (TRUE);\n\n for (t = 0; t < num_threads; t++) {\n GError *error = NULL;\n\n threads[t] = g_thread_try_new (\"pollstresstest\", run_test,\n GINT_TO_POINTER (t), &error);\n\n if (error) {\n printf (\"ERROR: g_thread_try_new() %s\\n\", error->message);\n exit (-1);\n }\n }\n printf (\"main(): Created %d threads.\\n\", t);\n\n for (t = 0; t < num_threads; t++) {\n g_thread_join (threads[t]);\n }\n\n gst_poll_free (set);\n\n return 0;\n}", "label": 0, "cwe": null, "length": 246 }, { "index": 767838, "code": "locateTextAutomaton(locate_text_nfa * nfa, unsigned char c) {\n switch(nfa->state) {\n /* first state locating only white spaces */\n case STATE_FIRST_WHITESPACE:\n if(isspace(c)) {\n nfa->startIdx = nfa->stopIdx = nfa->i + 1;\n } else if (c == ',') {\n nfa->state = STATE_COMMA;\n } else if (c == '\"') {\n nfa->startIdx = nfa->i + 1;\n nfa->state = STATE_TEXT_QUOTED;\n } else {\n nfa->startIdx = nfa->i;\n nfa->stopIdx = nfa->i + 1;\n nfa->state = STATE_TEXT;\n }\n break;\n /* state locating any text inside \"\" */\n case STATE_TEXT_QUOTED:\n if(c == '\"') {\n nfa->state = STATE_LAST_WHITESPACE;\n nfa->stopIdx = nfa->i;\n }\n break;\n /* locate text ignoring quotes */\n case STATE_TEXT:\n if (c == ',') {\n nfa->state = STATE_COMMA;\n } else if (!isspace(c)) {\n nfa->stopIdx = nfa->i + 1;\n }\n break;\n /* locating text after last quote */\n case STATE_LAST_WHITESPACE:\n if (c == ',') {\n nfa->state = STATE_COMMA;\n } else if (!isspace(c)) {\n nfa->state = STATE_ERROR;\n }\n break;\n\n default:\n break;\n }\n\n /* if it is terminating state, break from for loop */\n if ((nfa->state == STATE_COMMA) || (nfa->state == STATE_ERROR)) {\n return FALSE;\n } else {\n return TRUE;\n }\n}", "label": 0, "cwe": null, "length": 402 }, { "index": 242007, "code": "wm8991_hw_params(struct snd_pcm_substream *substream,\n\t\t\t struct snd_pcm_hw_params *params,\n\t\t\t struct snd_soc_dai *dai)\n{\n\tstruct snd_soc_codec *codec = dai->codec;\n\tu16 audio1 = snd_soc_read(codec, WM8991_AUDIO_INTERFACE_1);\n\n\taudio1 &= ~WM8991_AIF_WL_MASK;\n\t/* bit size */\n\tswitch (params_width(params)) {\n\tcase 16:\n\t\tbreak;\n\tcase 20:\n\t\taudio1 |= WM8991_AIF_WL_20BITS;\n\t\tbreak;\n\tcase 24:\n\t\taudio1 |= WM8991_AIF_WL_24BITS;\n\t\tbreak;\n\tcase 32:\n\t\taudio1 |= WM8991_AIF_WL_32BITS;\n\t\tbreak;\n\t}\n\n\tsnd_soc_write(codec, WM8991_AUDIO_INTERFACE_1, audio1);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 186 }, { "index": 785216, "code": "prunknowncreatedata(node *np, FILE* fp)\n{\n unsigned long ve;\n switch(np->opcode)\n {\n case INTERSECTION:\n prunknowncreatedata(np->lval, fp);\n prunknowncreatedata(np->rval, fp);\n return;\n case US_ID: return; /* nothing to do */\n case US_SCALAR:\n ve=varextern(np->rval->constant,np->rval->opcode);\n fprintf(fp,\"\\t\\t{%d,0,%lu,\",np->rval->width,ve);\n break;\n case US_ARRVAR: /* an array doesn't itself have a value */\n ve=varextern(np->rval->constant,np->rval->opcode);\n fprintf(fp,\"\\t\\t{%d,1,%lu,{ick_ieg277,ick_ies277},0},\\n\",\n\t np->rval->width,ve);\n return;\n case US_ELEM: /* these two cases are actually treated the same way, */\n case US_EXPR: /* because expressions can be assigned to */\n fprintf(fp,\"\\t\\t{%d,0,0,\",np->rval->width);\n break;\n default: ick_lose(IE778, emitlineno, (const char*) NULL);\n }\n if(createsused)\n fprintf(fp,\"{ick_og%lx,ick_os%lx},\",\n\t (unsigned long)np->rval,(unsigned long)np->rval);\n else\n fprintf(fp,\"{0,0},\");\n prexpr(np->rval,fp,0);\n fprintf(fp,\"},\\n\");\n}", "label": 0, "cwe": null, "length": 348 }, { "index": 789212, "code": "emacs(int c)\n{\n el_status_t s;\n el_keymap_t *kp;\n\n /* Save point before interpreting input character 'c'. */\n old_point = rl_point;\n\n if (rl_meta_chars && ISMETA(c)) {\n\ttty_push(UNMETA(c));\n return meta();\n }\n\n for (kp = Map; kp->Function; kp++) {\n if (kp->Key == c)\n break;\n }\n s = kp->Function ? kp->Function() : insert_char(c);\n if (!el_pushed) {\n /* No pushback means no repeat count; hacky, but true. */\n Repeat = NO_ARG;\n }\n\n return s;\n}", "label": 0, "cwe": null, "length": 148 }, { "index": 296040, "code": "mlx4_ib_mad_cleanup(struct mlx4_ib_dev *dev)\n{\n\tstruct ib_mad_agent *agent;\n\tint p, q;\n\n\tfor (p = 0; p < dev->num_ports; ++p) {\n\t\tfor (q = 0; q <= 1; ++q) {\n\t\t\tagent = dev->send_agent[p][q];\n\t\t\tif (agent) {\n\t\t\t\tdev->send_agent[p][q] = NULL;\n\t\t\t\tib_unregister_mad_agent(agent);\n\t\t\t}\n\t\t}\n\n\t\tif (dev->sm_ah[p])\n\t\t\tib_destroy_ah(dev->sm_ah[p]);\n\t}\n}", "label": 0, "cwe": null, "length": 135 }, { "index": 344371, "code": "_upload_call_message_wrote_data_cb (SoupMessage *msg,\n SoupBuffer *chunk,\n RestProxyCallUploadClosure *closure)\n{\n closure->uploaded = closure->uploaded + chunk->length;\n\n if (closure->uploaded < msg->request_body->length)\n closure->callback (closure->call,\n msg->request_body->length,\n closure->uploaded,\n NULL,\n closure->weak_object,\n closure->userdata);\n}", "label": 0, "cwe": null, "length": 96 }, { "index": 22391, "code": "playlist_load (const char * filename, char * * title,\n Index * * filenames_p, Index * * tuples_p)\n{\n AUDDBG (\"Loading playlist %s.\\n\", filename);\n\n PluginHandle * plugin = get_plugin (filename, FALSE);\n if (! plugin)\n return FALSE;\n\n PlaylistPlugin * pp = plugin_get_header (plugin);\n g_return_val_if_fail (pp && PLUGIN_HAS_FUNC (pp, load), FALSE);\n\n VFSFile * file = vfs_fopen (filename, \"r\");\n if (! file)\n return FALSE;\n\n Index * filenames = index_new ();\n Index * tuples = index_new ();\n bool_t success = pp->load (filename, file, title, filenames, tuples);\n\n vfs_fclose (file);\n\n if (! success)\n {\n index_free (filenames);\n index_free (tuples);\n return FALSE;\n }\n\n if (index_count (tuples))\n g_return_val_if_fail (index_count (tuples) == index_count (filenames),\n FALSE);\n else\n {\n index_free (tuples);\n tuples = NULL;\n }\n\n * filenames_p = filenames;\n * tuples_p = tuples;\n return TRUE;\n}", "label": 0, "cwe": null, "length": 257 }, { "index": 959958, "code": "Crossfire_Object_InsertInto(Crossfire_Object *who, PyObject *args) {\n /* Note that this function uses the METH_O calling convention. */\n Crossfire_Object *op = (Crossfire_Object*)args;\n object *myob;\n\n EXISTCHECK(who);\n TYPEEXISTCHECK(op);\n\n /* we can only insert removed object, so first remove it\n * from it's current container\n */\n if (!cf_object_get_flag(who->obj, FLAG_REMOVED)) {\n cf_object_remove(who->obj);\n }\n myob = cf_object_insert_in_ob(who->obj, op->obj);\n\n return Crossfire_Object_wrap(myob);\n}", "label": 0, "cwe": null, "length": 145 }, { "index": 37416, "code": "splitout_queryargs(request_rec *r, int qsappend, int qsdiscard)\n{\n char *q;\n int split;\n\n /* don't touch, unless it's a scheme for which a query string makes sense.\n * See RFC 1738 and RFC 2368.\n */\n if (is_absolute_uri(r->filename, &split)\n && !split) {\n r->args = NULL; /* forget the query that's still flying around */\n return;\n }\n\n if ( qsdiscard ) {\n r->args = NULL; /* Discard query string */\n rewritelog((r, 2, NULL, \"discarding query string\"));\n }\n\n q = ap_strchr(r->filename, '?');\n if (q != NULL) {\n char *olduri;\n apr_size_t len;\n\n olduri = apr_pstrdup(r->pool, r->filename);\n *q++ = '\\0';\n if (qsappend) {\n r->args = apr_pstrcat(r->pool, q, \"&\", r->args, NULL);\n }\n else {\n r->args = apr_pstrdup(r->pool, q);\n }\n\n len = strlen(r->args);\n if (!len) {\n r->args = NULL;\n }\n else if (r->args[len-1] == '&') {\n r->args[len-1] = '\\0';\n }\n\n rewritelog((r, 3, NULL, \"split uri=%s -> uri=%s, args=%s\", olduri,\n r->filename, r->args ? r->args : \"\"));\n }\n\n return;\n}", "label": 0, "cwe": null, "length": 357 }, { "index": 137171, "code": "del_gammap(\ngammap *s\n) {\n\tif (s->grey != NULL)\n\t\ts->grey->del(s->grey);\n\tif (s->igrey != NULL)\n\t\ts->igrey->del(s->igrey);\n\tif (s->map != NULL)\n\t\ts->map->del(s->map);\n\n\tfree(s);\n}", "label": 0, "cwe": null, "length": 74 }, { "index": 5954, "code": "rfc822_encode_domain_int(const char *pfix,\n\t\t\t\t size_t pfix_len,\n\t\t\t\t const char *domain)\n{\n\tchar *q;\n\n#if LIBIDN\n\tint err;\n\tchar *p;\n\n\terr=idna_to_ascii_8z(domain, &p, 0);\n\n\tif (err != IDNA_SUCCESS)\n\t{\n\t\terrno=EINVAL;\n\t\treturn NULL;\n\t}\n#else\n\tchar *p;\n\n\tp=strdup(domain);\n\n\tif (!p)\n\t\treturn NULL;\n#endif\n\n\tq=malloc(strlen(p)+pfix_len+1);\n\n\tif (!q)\n\t{\n\t\tfree(p);\n\t\treturn NULL;\n\t}\n\n\tif (pfix_len)\n\t\tmemcpy(q, pfix, pfix_len);\n\n\tstrcpy(q + pfix_len, p);\n\tfree(p);\n\treturn q;\n}", "label": 0, "cwe": null, "length": 163 }, { "index": 567971, "code": "da9150_charger_battery_health(struct da9150_charger *charger,\n\t\t\t\t\t union power_supply_propval *val)\n{\n\tu8 reg;\n\n\treg = da9150_reg_read(charger->da9150, DA9150_STATUS_J);\n\n\t/* Check if temperature limit reached */\n\tswitch (reg & DA9150_CHG_TEMP_MASK) {\n\tcase DA9150_CHG_TEMP_UNDER:\n\t\tval->intval = POWER_SUPPLY_HEALTH_COLD;\n\t\treturn 0;\n\tcase DA9150_CHG_TEMP_OVER:\n\t\tval->intval = POWER_SUPPLY_HEALTH_OVERHEAT;\n\t\treturn 0;\n\tdefault:\n\t\tbreak;\n\t}\n\n\t/* Check for other health states */\n\tswitch (reg & DA9150_CHG_STAT_MASK) {\n\tcase DA9150_CHG_STAT_ACT:\n\tcase DA9150_CHG_STAT_PRE:\n\t\tval->intval = POWER_SUPPLY_HEALTH_DEAD;\n\t\tbreak;\n\tcase DA9150_CHG_STAT_TIME:\n\t\tval->intval = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;\n\t\tbreak;\n\tdefault:\n\t\tval->intval = POWER_SUPPLY_HEALTH_GOOD;\n\t\tbreak;\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 228 }, { "index": 120755, "code": "DocAll(std::ostream &s){\n tConfItemMap & confmap = ConfItemMap();\n for(tConfItemMap::iterator iter = confmap.begin(); iter != confmap.end() ; ++iter)\n {\n tConfItemBase * ci = (*iter).second;\n\n tString help ( ci->help );\n if ( help != \"UNDOCUMENTED\" )\n {\n tString line;\n line << ci->title;\n line.SetPos( 30, false );\n line << help;\n s << line << '\\n';\n }\n }\n}", "label": 0, "cwe": null, "length": 123 }, { "index": 930389, "code": "ReplaceGlobalVariable(\n void *theEnv,\n struct expr *ePtr)\n {\n struct defglobal *theGlobal;\n int count;\n\n /*=================================*/\n /* Search for the global variable. */\n /*=================================*/\n\n theGlobal = (struct defglobal *)\n FindImportedConstruct(theEnv,\"defglobal\",NULL,ValueToString(ePtr->value),\n &count,TRUE,NULL);\n\n /*=============================================*/\n /* If it wasn't found, print an error message. */\n /*=============================================*/\n\n if (theGlobal == NULL)\n {\n GlobalReferenceErrorMessage(theEnv,ValueToString(ePtr->value));\n return(FALSE);\n }\n\n /*========================================================*/\n /* The current implementation of the defmodules shouldn't */\n /* allow a construct to be defined which would cause an */\n /* ambiguous reference, but we'll check for it anyway. */\n /*========================================================*/\n\n if (count > 1)\n {\n AmbiguousReferenceErrorMessage(theEnv,\"defglobal\",ValueToString(ePtr->value));\n return(FALSE);\n }\n\n /*==============================================*/\n /* Replace the symbolic reference of the global */\n /* variable with a direct pointer reference. */\n /*==============================================*/\n\n ePtr->type = DEFGLOBAL_PTR;\n ePtr->value = (void *) theGlobal;\n\n return(TRUE);\n }", "label": 0, "cwe": null, "length": 286 }, { "index": 554604, "code": "Write_amdba(ostream &f) const \n{\n assert(this && nbt);\n\n Int4 i,j;\n Int4 * reft = new Int4[nbt];\n Int4 nbInT = ConsRefTriangle(reft);\n f << nbv << \" \" << nbInT << endl;\n cout.precision(12);\n for (i=0;i=0)\n\tf << j++ << \" \" \n\t << Number(triangles[i][0]) +1 << \" \" \n\t << Number(triangles[i][1]) +1 << \" \" \n\t << Number(triangles[i][2]) +1 << \" \" \n\t << subdomains[reft[i]].ref << endl ;\n\tf << endl;\n delete [] reft;\n\n\n}", "label": 0, "cwe": null, "length": 231 }, { "index": 547015, "code": "addDefinition(const char *name, const void *def)\n{\n\tconst char *str;\n\tint\tr, pos;\n\tSymbol s;\n\tDictionaryEntry *de, *newde;\n\tListIterator iterator(*this);\n\tSymbolManager *sm = getSymbolManager();\n\n\t\t\n\tif (this->isSorted) {\n\t pos = 1;\n\t while ((de=(DictionaryEntry*)iterator.getNext())) {\n\t\t str = sm->getSymbolString(de->name);\n\t\t ASSERT(str);\n\t\t r = STRCMP(str, name);\n\t\t if (r == 0)\n\t\t\treturn FALSE;\n\t\t else if (r >= 0)\n\t\t\tbreak;\n\t\t pos++;\n\t }\n\t} else {\n\t pos = 0;\n\t}\n\ts = sm->registerSymbol(name);\n\tnewde = new DictionaryEntry(s,(void*)def);\n \tif (pos == 0)\n\t return this->appendElement(newde);\n\telse\n\t return this->insertElement(newde, pos);\n}", "label": 0, "cwe": null, "length": 197 }, { "index": 956389, "code": "result_to_string (xmmsv_t *val, column_def_t *coldef, gchar *buffer)\n{\n\tgint realsize;\n\tgint ival;\n\tconst gchar *sval;\n\tgchar *value;\n\n\tswitch (xmmsv_dict_entry_get_type (val, coldef->arg.string)) {\n\tcase XMMSV_TYPE_NONE:\n\t\t/* Yeah, lots of code duplication, lets fix that */\n\t\tvalue = NULL;\n\t\tif (!strcmp (coldef->arg.string, \"title\")) {\n\t\t\tif (xmmsv_dict_entry_get_string (val, \"url\", &sval)) {\n\t\t\t\tvalue = g_path_get_basename (sval);\n\t\t\t\trealsize = crop_string (buffer, value,\n\t\t\t\t coldef->size);\n\t\t\t\tg_free (value);\n\t\t\t}\n\t\t}\n\t\tif (!value) {\n\t\t\t*buffer = '\\0';\n\t\t\trealsize = 0;\n\t\t}\n\t\tbreak;\n\tcase XMMSV_TYPE_INT32:\n\t\txmmsv_dict_entry_get_int (val, coldef->arg.string, &ival);\n\t\trealsize = g_snprintf (buffer, coldef->size + 1, \"%d\", ival);\n\t\tbreak;\n\tcase XMMSV_TYPE_STRING:\n\t\txmmsv_dict_entry_get_string (val, coldef->arg.string, &sval);\n\n\t\t/* Use UTF-8 column width, not characters or bytes */\n\t\t/* Note: realsize means the number of columns used to\n\t\t * *display* this time, instead of \"the numbers of bytes that\n\t\t * would have been written if the buffer was large enough\". */\n\t\trealsize = crop_string (buffer, sval, coldef->size);\n\t\tbreak;\n\tdefault:\n\t\t/* No valid data, display empty value */\n\t\t*buffer = '\\0';\n\t\trealsize = 0;\n\t\tbreak;\n\t}\n\n\treturn realsize;\n}", "label": 0, "cwe": null, "length": 406 }, { "index": 433439, "code": "read_all (int fd, guchar *buf, int len)\n{\n\tint all = len;\n\tint res;\n\n\twhile (len > 0) {\n\n\t\tres = read (fd, buf, len);\n\n\t\tif (res < 0) {\n\t\t\tif (errno == EAGAIN || errno == EINTR)\n\t\t\t\tcontinue;\n\t\t\tg_warning (\"couldn't read %u bytes from client: %s\", all,\n\t\t\t g_strerror (errno));\n\t\t\treturn FALSE;\n\t\t} else if (res == 0) {\n\t\t\treturn FALSE;\n\t\t} else {\n\t\t\tlen -= res;\n\t\t\tbuf += res;\n\t\t}\n\t}\n\n\treturn TRUE;\n}", "label": 1, "cwe": [ "CWE-120", "CWE-other" ], "length": 138 }, { "index": 1009997, "code": "sizeMess(int argc, t_atom*argv)\n{ \n switch(argc){\n case 1:\n m_size[0]=m_size[1]=m_size[2]=atom_getfloat(argv);\n break;\n case 3:\n m_size[0]=atom_getfloat(argv++);\n m_size[1]=atom_getfloat(argv++);\n m_size[2]=atom_getfloat(argv++);\n default:;\n }\n}", "label": 0, "cwe": null, "length": 90 }, { "index": 879992, "code": "pk11_AttrFlagsToAttributes(PK11AttrFlags attrFlags, CK_ATTRIBUTE *attrs,\n\t\t\t\tCK_BBOOL *ckTrue, CK_BBOOL *ckFalse)\n{\n const static CK_ATTRIBUTE_TYPE attrTypes[5] = {\n\tCKA_TOKEN, CKA_PRIVATE, CKA_MODIFIABLE, CKA_SENSITIVE,\n\tCKA_EXTRACTABLE\n };\n\n const CK_ATTRIBUTE_TYPE *pType\t= attrTypes;\n CK_ATTRIBUTE *attr\t= attrs;\n PK11AttrFlags test\t= PK11_ATTR_TOKEN;\n\n PR_ASSERT(!pk11_BadAttrFlags(attrFlags));\n\n /* we test two related bitflags in each iteration */\n for (; attrFlags && test <= PK11_ATTR_EXTRACTABLE; test <<= 2, ++pType) {\n \tif (test & attrFlags) {\n\t attrFlags ^= test;\n\t PK11_SETATTRS(attr, *pType, ckTrue, sizeof *ckTrue); \n\t ++attr;\n\t} else if ((test << 1) & attrFlags) {\n\t attrFlags ^= (test << 1);\n\t PK11_SETATTRS(attr, *pType, ckFalse, sizeof *ckFalse); \n\t ++attr;\n\t}\n }\n return (attr - attrs);\n}", "label": 0, "cwe": null, "length": 269 }, { "index": 185264, "code": "set_prefetch_sub_info(Prefetch_sub_data *src)\n{\n Prefetch_sub_data *tmp;\n PrefetchSubInfo *ret = NULL;\n Boolean first_flag = TRUE;\n \n for (tmp = src; tmp != NULL; tmp = tmp->next_dim){\n PrefetchSubInfo *sub, *tmp_sub = NULL;\n \n sub = alloc_prefetch_sub_info();\n sub->kind = tmp->sub_kind;\n sub->sub_script = tmp->sub_script;\n switch (sub->kind) {\n case KIND_CONST:\n if (tmp->value_sub != NULL) {\n sub->value = sub_data_b(tmp->value_sub);\n } else {\n sub->value = tmp->value;\n }\n break;\n case KIND_VAR:\n sub->loop_info = tmp->loop_info;\n break;\n case KIND_TEMP:\n if (tmp->offset_sub != NULL) {\n sub->offset = sub_data_b(tmp->offset_sub);\n } else {\n sub->offset = tmp->offset;\n }\n sub->loop_info = tmp->loop_info;\n break;\n default:\n return 0;\n }\n if (first_flag) {\n ret = sub;\n tmp_sub = ret;\n first_flag = FALSE;\n } else {\n tmp_sub->next_dim = sub;\n tmp_sub = tmp_sub->next_dim;\n }\n }\n return ret;\n}", "label": 1, "cwe": [ "CWE-476", "CWE-other" ], "length": 302 }, { "index": 166356, "code": "GetItemCount(uint32 item, Item* eItem) const\n{\n uint32 count = 0;\n\n for (uint32 i = 0; i < GetBagSize(); ++i)\n if (m_bagslot[i])\n if (m_bagslot[i] != eItem && m_bagslot[i]->GetEntry() == item)\n { count += m_bagslot[i]->GetCount(); }\n\n return count;\n}", "label": 0, "cwe": null, "length": 95 }, { "index": 565110, "code": "p_get_filtername(const char *line)\n{\n if(*line == '\"')\n {\n gchar *filtername;\n gchar *ptr;\n\n filtername = g_strdup(&line[1]);\n ptr = filtername;\n while(ptr)\n {\n if((*ptr == '\\n') || (*ptr == '\\0') || (*ptr == '\"'))\n {\n *ptr = '\\0';\n break;\n }\n ptr++;\n }\n return(filtername);\n }\n return NULL;\n}", "label": 0, "cwe": null, "length": 106 }, { "index": 70911, "code": "lrc_create(CONNECTION *c, DBH *dbh, char **arglist)\n\n{\n int\trc;\n\n if (!arglist[0] || !arglist[1]) {\n rrpc_error(c, GLOBUS_RLS_BADARG, \"\");\n return;\n }\n if ((rc = db_lrc_create(dbh->lrc, arglist[0], arglist[1],\n\t\t\t c->errmsg)) != GLOBUS_RLS_SUCCESS) {\n rrpc_error(c, rc, \"%s\", c->errmsg);\n return;\n } else {\n if (bloomfilter.bfsize) {\n globus_mutex_lock(&bloomfilter.mtx);\n bf_addlfn(&bloomfilter, arglist[0]);\n globus_mutex_unlock(&bloomfilter.mtx);\n }\n }\n rrpc_success(c);\n\n if (rc == GLOBUS_RLS_SUCCESS) {\n if (update_immediate)\n doimmediate(rliop_add, lrc_rlilist, &lrc_rlilistlock, arglist[0], NULL);\n\n\tbfresize(dbh);\n }\n}", "label": 0, "cwe": null, "length": 240 }, { "index": 698963, "code": "circle_link_remove(struct circle_link *link, struct single_link_node *node)\n{\n\tstruct single_link_node *head, *prev;\n\n\tpthread_mutex_lock(&link->lock);\n\n\tfor (prev = head = &link->head_node; prev->next != head; prev = prev->next)\n\t{\n\t\tif (prev->next == node)\n\t\t{\n\t\t\tcircle_link_remove_base(prev, node);\n\t\t\tpthread_mutex_unlock(&link->lock);\n\t\t\treturn true;\n\t\t}\n\t}\n\n\tpthread_mutex_unlock(&link->lock);\n\n\treturn false;\n}", "label": 0, "cwe": null, "length": 114 }, { "index": 188378, "code": "perf_event_sysfs_show(struct device *dev, struct device_attribute *attr,\n\t\t\t char *page)\n{\n\tstruct perf_pmu_events_attr *pmu_attr =\n\t\tcontainer_of(attr, struct perf_pmu_events_attr, attr);\n\n\tif (pmu_attr->event_str)\n\t\treturn sprintf(page, \"%s\\n\", pmu_attr->event_str);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 78 }, { "index": 752441, "code": "instrumentPointerComparisonOrSubtraction(\n Instruction *I) {\n IRBuilder<> IRB(I);\n Function *F = isa(I) ? AsanPtrCmpFunction : AsanPtrSubFunction;\n Value *Param[2] = {I->getOperand(0), I->getOperand(1)};\n for (int i = 0; i < 2; i++) {\n if (Param[i]->getType()->isPointerTy())\n Param[i] = IRB.CreatePointerCast(Param[i], IntptrTy);\n }\n IRB.CreateCall(F, Param);\n}", "label": 0, "cwe": null, "length": 131 }, { "index": 673699, "code": "removeEventListener(KasumiWordEventListener *listener){\n vector::iterator i;\n KasumiWordEventListener *p;\n\n for(i=EventListeners.begin();i!=EventListeners.end();i++){\n\tp = *i;\n\tif(p == listener){\n\t EventListeners.erase(i);\n\t return;\n\t}\n }\n}", "label": 0, "cwe": null, "length": 70 }, { "index": 50794, "code": "fm_irq_handle_intmsk_cmd_resp(struct fmdev *fmdev)\n{\n\tstruct sk_buff *skb;\n\n\tif (check_cmdresp_status(fmdev, &skb))\n\t\treturn;\n\t/*\n\t * This is last function in interrupt table to be executed.\n\t * So, reset stage index to 0.\n\t */\n\tfmdev->irq_info.stage = FM_SEND_FLAG_GETCMD_IDX;\n\n\t/* Start processing any pending interrupt */\n\tif (test_and_clear_bit(FM_INTTASK_SCHEDULE_PENDING, &fmdev->flag))\n\t\tfmdev->irq_info.handlers[fmdev->irq_info.stage](fmdev);\n\telse\n\t\tclear_bit(FM_INTTASK_RUNNING, &fmdev->flag);\n}", "label": 0, "cwe": null, "length": 145 }, { "index": 424245, "code": "inlist(place, passno)\nint place;\nint passno;\n/* decide whether passno matches list/number for variant section */\n/* handles representation of [X in the abc */\n{\n int a, b;\n char* p;\n int found;\n char msg[100];\n\n /* printf(\"passno = %d\\n\", passno); */\n if (denom[place] != 0) {\n /* special case when this is variant ending for only one pass */\n if (passno == denom[place]) {\n return(1);\n } else {\n return(0);\n };\n } else {\n /* must scan list */\n p = atext[pitch[place]];\n found = 0;\n while ((found == 0) && (*p != '\\0')) {\n if (!isdigit(*p)) {\n sprintf(msg, \"Bad variant list : %s\", atext[pitch[place]]);\n event_error(msg);\n found = 1;\n };\n a = readnump(&p);\n if (passno == a) {\n found = 1;\n };\n if (*p == '-') {\n p = p + 1;\n b = readnump(&p);\n if ((passno >= a) && (passno <= b)) {\n found = 1;\n };\n };\n if (*p == ',') {\n p = p + 1;\n };\n };\n return(found);\n };\n}", "label": 0, "cwe": null, "length": 314 }, { "index": 570158, "code": "toggle_eventTrace(struct toggle *t _is_unused, enum toggle_type tt)\n{\n\t/* If turning on event debug, and no trace file, open one. */\n\tif (toggled(EVENT_TRACE) && tracef == NULL)\n\t\ttracefile_on(EVENT_TRACE, tt);\n\n\t/* If turning off event debug, and not tracing the data stream,\n\t close the trace file. */\n\telse if (!toggled(EVENT_TRACE) && !toggled(DS_TRACE))\n\t\ttracefile_off();\n}", "label": 0, "cwe": null, "length": 101 }, { "index": 669551, "code": "udbg_knownIssueURLFrom(const char *ticket, char *buf) {\n if( ticket==NULL ) {\n return NULL;\n }\n\n if( !strncmp(ticket, CLDR_TICKET_PREFIX, strlen(CLDR_TICKET_PREFIX)) ) {\n strcpy( buf, CLDR_TRAC_URL );\n strcat( buf, ticket+strlen(CLDR_TICKET_PREFIX) );\n } else {\n strcpy( buf, ICU_TRAC_URL );\n strcat( buf, ticket );\n }\n return buf;\n}", "label": 0, "cwe": null, "length": 107 }, { "index": 111775, "code": "sci_port_disable(struct sci_port *sci_port)\n{\n\tif (!sci_port->port.dev)\n\t\treturn;\n\n\t/* Cancel the break timer to ensure that the timer handler will not try\n\t * to access the hardware with clocks and power disabled. Reset the\n\t * break flag to make the break debouncing state machine ready for the\n\t * next break.\n\t */\n\tdel_timer_sync(&sci_port->break_timer);\n\tsci_port->break_flag = 0;\n\n\tclk_disable_unprepare(sci_port->fclk);\n\tclk_disable_unprepare(sci_port->iclk);\n\n\tpm_runtime_put_sync(sci_port->port.dev);\n}", "label": 0, "cwe": null, "length": 133 }, { "index": 110108, "code": "__blk_end_bidi_request(struct request *rq, int error,\n\t\t\t\t unsigned int nr_bytes, unsigned int bidi_bytes)\n{\n\tif (blk_update_bidi_request(rq, error, nr_bytes, bidi_bytes))\n\t\treturn true;\n\n\tblk_finish_request(rq, error);\n\n\treturn false;\n}", "label": 0, "cwe": null, "length": 62 }, { "index": 454859, "code": "write(hsStream* S, plResManager* mgr) {\n pfGUIDialogMod::write(S, mgr);\n\n S->writeShort(fMargin);\n S->writeInt(fMenuItems.getSize());\n for (size_t i=0; iwrite(256, buf);\n pfGUICtrlProcWriteableObject::Write(S, fMenuItems[i].fHandler);\n mgr->writeKey(S, fMenuItems[i].fSubMenu);\n }\n\n mgr->writeKey(S, fSkin);\n mgr->writeKey(S, fOriginAnchor);\n mgr->writeKey(S, fOriginContext);\n S->writeByte(fAlignment);\n}", "label": 0, "cwe": null, "length": 180 }, { "index": 615522, "code": "strcmpcasenosensitive_internal (fileName1,fileName2)\n const char* fileName1;\n const char* fileName2;\n{\n for (;;)\n {\n char c1=*(fileName1++);\n char c2=*(fileName2++);\n if ((c1>='a') && (c1<='z'))\n c1 -= 0x20;\n if ((c2>='a') && (c2<='z'))\n c2 -= 0x20;\n if (c1=='\\0')\n return ((c2=='\\0') ? 0 : -1);\n if (c2=='\\0')\n return 1;\n if (c1c2)\n return 1;\n }\n}", "label": 0, "cwe": null, "length": 172 }, { "index": 697279, "code": "rt2x00usb_interrupt_rxdone(struct urb *urb)\n{\n\tstruct queue_entry *entry = (struct queue_entry *)urb->context;\n\tstruct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;\n\n\tif (!test_and_clear_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags))\n\t\treturn;\n\n\t/*\n\t * Report the frame as DMA done\n\t */\n\trt2x00lib_dmadone(entry);\n\n\t/*\n\t * Check if the received data is simply too small\n\t * to be actually valid, or if the urb is signaling\n\t * a problem.\n\t */\n\tif (urb->actual_length < entry->queue->desc_size || urb->status)\n\t\tset_bit(ENTRY_DATA_IO_FAILED, &entry->flags);\n\n\t/*\n\t * Schedule the delayed work for reading the RX status\n\t * from the device.\n\t */\n\tqueue_work(rt2x00dev->workqueue, &rt2x00dev->rxdone_work);\n}", "label": 0, "cwe": null, "length": 210 }, { "index": 281424, "code": "d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, void *u)\n{\n\tBIO *bp;\n\tEVP_PKEY *ret;\n\tif(!(bp = BIO_new_fp(fp, BIO_NOCLOSE))) {\n\t\tPEMerr(PEM_F_D2I_PKCS8PRIVATEKEY_FP,ERR_R_BUF_LIB);\n return NULL;\n\t}\n\tret = d2i_PKCS8PrivateKey_bio(bp, x, cb, u);\n\tBIO_free(bp);\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 114 }, { "index": 117024, "code": "check_ping(char *buf, int len)\n{\n\tPing\tpi;\n\taConfItem\t*aconf;\n\tstruct\ttimeval\ttv;\n\tdouble\td;\n\taCPing\t*cp = NULL;\n\tu_long\trtt;\n\n\t(void)gettimeofday(&tv, NULL);\n\n\tif (len < sizeof(pi) + 8)\n\t\treturn -1;\n\n\tbcopy(buf, (char *)&pi, sizeof(pi));\t/* ensure nice byte align. */\n\n\tfor (aconf = conf; aconf; aconf = aconf->next)\n\t\tif (pi.pi_cp == aconf && (cp = aconf->ping))\n\t\t\tbreak;\n\tif (!aconf || match(aconf->name, buf + sizeof(pi)))\n\t\treturn -1;\n\n\tcp->recvd++;\n\tcp->lrecvd++;\n\trtt = ((tv.tv_sec - pi.pi_tv.tv_sec) * 1000 +\n\t\t(tv.tv_usec - pi.pi_tv.tv_usec) / 1000);\n\tcp->ping += rtt;\n\tcp->rtt += rtt;\n\tif (cp->rtt > 1000000)\n\t {\n\t\tcp->ping = (cp->rtt /= cp->lrecvd);\n\t\tcp->recvd = cp->lrecvd = 1;\n\t\tcp->seq = cp->lseq = 1;\n\t }\n\td = (double)cp->recvd / (double)cp->seq;\n\td = pow(d, (double)20.0);\n\td = (double)cp->ping / (double)cp->recvd / d;\n\tif (d > 10000.0)\n\t\td = 10000.0;\n\taconf->pref = (int) (d * 100.0);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 361 }, { "index": 418886, "code": "kcm_ccache_destroy_if_empty(krb5_context context,\n\t\t\t kcm_ccache ccache)\n{\n krb5_error_code ret;\n\n KCM_ASSERT_VALID(ccache);\n\n if (ccache->creds == NULL) {\n\tret = kcm_ccache_destroy(context, ccache->name);\n } else\n\tret = 0;\n\n return ret;\n}", "label": 0, "cwe": null, "length": 77 }, { "index": 978799, "code": "_ldapfull_connect_bind(moddata_t data)\n{\n if(data->ld != NULL && data->binded ) {\n return 0;\n }\n\n if( _ldapfull_connect(data) ) {\n return 1;\n }\n\n if(ldap_simple_bind_s(data->ld, data->binddn, data->bindpw))\n {\n log_write(data->ar->c2s->log, LOG_ERR, \"ldap: bind as '%s' failed: %s\", data->binddn, ldap_err2string(_ldapfull_get_lderrno(data->ld)));\n _ldapfull_unbind(data);\n return 1;\n }\n\n log_debug(ZONE, \"binded to ldap server\");\n data->binded = 1;\n return 0;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-469" ], "length": 165 }, { "index": 677893, "code": "process (GeglOperation *operation,\n GeglBuffer *input,\n GeglBuffer *output,\n const GeglRectangle *roi,\n gint level)\n{\n GeglRectangle src_rect;\n GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);\n GeglOperationAreaFilter *op_area;\n gfloat* buf;\n\n op_area = GEGL_OPERATION_AREA_FILTER (operation);\n src_rect = *roi;\n src_rect.x -= op_area->left;\n src_rect.y -= op_area->top;\n src_rect.width += op_area->left + op_area->right;\n src_rect.height += op_area->top + op_area->bottom;\n\n if (gegl_cl_is_accelerated ())\n if (cl_process (operation, input, output, roi))\n return TRUE;\n\n buf = g_new0 (gfloat, src_rect.width * src_rect.height * 4);\n\n gegl_buffer_get (input, &src_rect, 1.0, babl_format (\"RaGaBaA float\"), buf, GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);\n\n pixelize(buf, roi, o->size_x, o->size_y);\n\n gegl_buffer_set (output, roi, 0, babl_format (\"RaGaBaA float\"), buf, GEGL_AUTO_ROWSTRIDE);\n\n g_free (buf);\n\n return TRUE;\n}", "label": 0, "cwe": null, "length": 303 }, { "index": 367967, "code": "_dxl_XRemoveWorkProc(DXLConnection *c)\n{\n XEventHandlerData *xehd = (XEventHandlerData *)c->eventHandlerData;\n if (xehd && xehd->wpid != 0)\n {\n\tXtRemoveWorkProc(xehd->wpid);\n\txehd->wpid = 0;\n }\n}", "label": 0, "cwe": null, "length": 78 }, { "index": 799053, "code": "set_best_encoder(struct drm_atomic_state *state,\n\t\t struct drm_connector_state *conn_state,\n\t\t struct drm_encoder *encoder)\n{\n\tstruct drm_crtc_state *crtc_state;\n\tstruct drm_crtc *crtc;\n\n\tif (conn_state->best_encoder) {\n\t\t/* Unset the encoder_mask in the old crtc state. */\n\t\tcrtc = conn_state->connector->state->crtc;\n\n\t\t/* A NULL crtc is an error here because we should have\n\t\t * duplicated a NULL best_encoder when crtc was NULL.\n\t\t * As an exception restoring duplicated atomic state\n\t\t * during resume is allowed, so don't warn when\n\t\t * best_encoder is equal to encoder we intend to set.\n\t\t */\n\t\tWARN_ON(!crtc && encoder != conn_state->best_encoder);\n\t\tif (crtc) {\n\t\t\tcrtc_state = drm_atomic_get_existing_crtc_state(state, crtc);\n\n\t\t\tcrtc_state->encoder_mask &=\n\t\t\t\t~(1 << drm_encoder_index(conn_state->best_encoder));\n\t\t}\n\t}\n\n\tif (encoder) {\n\t\tcrtc = conn_state->crtc;\n\t\tWARN_ON(!crtc);\n\t\tif (crtc) {\n\t\t\tcrtc_state = drm_atomic_get_existing_crtc_state(state, crtc);\n\n\t\t\tcrtc_state->encoder_mask |=\n\t\t\t\t1 << drm_encoder_index(encoder);\n\t\t}\n\t}\n\n\tconn_state->best_encoder = encoder;\n}", "label": 0, "cwe": null, "length": 301 }, { "index": 875433, "code": "nssSlot_CreateSession\n(\n NSSSlot *slot,\n NSSArena *arenaOpt,\n PRBool readWrite\n)\n{\n nssSession *rvSession;\n\n if (!readWrite) {\n\t/* nss3hack version only returns rw swssions */\n\treturn NULL;\n }\n rvSession = nss_ZNEW(arenaOpt, nssSession);\n if (!rvSession) {\n\treturn (nssSession *)NULL;\n }\n\n rvSession->handle = PK11_GetRWSession(slot->pk11slot);\n if (rvSession->handle == CK_INVALID_HANDLE) {\n\t nss_ZFreeIf(rvSession);\n\t return NULL;\n }\n rvSession->isRW = PR_TRUE;\n rvSession->slot = slot;\n /*\n * The session doesn't need its own lock. Here's why.\n * 1. If we are reusing the default RW session of the slot,\n * the slot lock is already locked to protect the session.\n * 2. If the module is not thread safe, the slot (or rather\n * module) lock is already locked.\n * 3. If the module is thread safe and we are using a new\n * session, no higher-level lock has been locked and we\n * would need a lock for the new session. However, the\n * current usage of the session is that it is always\n * used and destroyed within the same function and never\n * shared with another thread.\n * So the session is either already protected by another\n * lock or only used by one thread.\n */\n rvSession->lock = NULL;\n rvSession->ownLock = PR_FALSE;\n return rvSession;\n}", "label": 0, "cwe": null, "length": 371 }, { "index": 625205, "code": "xmlFileOpenW (const char *filename) {\n const char *path = NULL;\n FILE *fd;\n\n if (!strcmp(filename, \"-\")) {\n fd = stdout;\n return((void *) fd);\n }\n\n if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST \"file://localhost/\", 17))\n#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)\n path = &filename[17];\n#else\n path = &filename[16];\n#endif\n else if (!xmlStrncasecmp(BAD_CAST filename, BAD_CAST \"file:///\", 8)) {\n#if defined (_WIN32) || defined (__DJGPP__) && !defined(__CYGWIN__)\n path = &filename[8];\n#else\n path = &filename[7];\n#endif\n } else\n path = filename;\n\n if (path == NULL)\n return(NULL);\n\n#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)\n fd = xmlWrapOpen(path, 1);\n#else\n fd = fopen(path, \"wb\");\n#endif /* WIN32 */\n\n if (fd == NULL) xmlIOErr(0, path);\n return((void *) fd);\n}", "label": 0, "cwe": null, "length": 268 }, { "index": 329943, "code": "printableStringValidate(\n\tSyntax *syntax,\n\tstruct berval *val )\n{\n\tber_len_t i;\n\n\tif( BER_BVISEMPTY( val ) ) return LDAP_INVALID_SYNTAX;\n\n\tfor(i=0; i < val->bv_len; i++) {\n\t\tif( !SLAP_PRINTABLE(val->bv_val[i]) ) {\n\t\t\treturn LDAP_INVALID_SYNTAX;\n\t\t}\n\t}\n\n\treturn LDAP_SUCCESS;\n}", "label": 0, "cwe": null, "length": 90 }, { "index": 600699, "code": "EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub_key)\n\t{\n\tif (key->pub_key != NULL)\n\t\tEC_POINT_free(key->pub_key);\n\tkey->pub_key = EC_POINT_dup(pub_key, key->group);\n\treturn (key->pub_key == NULL) ? 0 : 1;\n\t}", "label": 0, "cwe": null, "length": 72 }, { "index": 13252, "code": "SkipFrame()\n{\n AVM_WRITE(__MODULE__, 2, \"SkipFrame()\\n\");\n if (m_pPacket)\n\tm_pPacket->Release();\n m_pPacket = 0;\n Flush();\n return m_pPacket ? 0 : -1;\n}", "label": 0, "cwe": null, "length": 58 }, { "index": 97520, "code": "isl_mat_sub_alloc6(isl_ctx *ctx, isl_int **row,\n\tunsigned first_row, unsigned n_row, unsigned first_col, unsigned n_col)\n{\n\tint i;\n\tstruct isl_mat *mat;\n\n\tmat = isl_alloc_type(ctx, struct isl_mat);\n\tif (!mat)\n\t\treturn NULL;\n\tmat->row = isl_alloc_array(ctx, isl_int *, n_row);\n\tif (n_row && !mat->row)\n\t\tgoto error;\n\tfor (i = 0; i < n_row; ++i)\n\t\tmat->row[i] = row[first_row+i] + first_col;\n\tmat->ctx = ctx;\n\tisl_ctx_ref(ctx);\n\tmat->ref = 1;\n\tmat->n_row = n_row;\n\tmat->n_col = n_col;\n\tmat->block = isl_blk_empty();\n\tmat->flags = ISL_MAT_BORROWED;\n\treturn mat;\nerror:\n\tfree(mat);\n\treturn NULL;\n}", "label": 0, "cwe": null, "length": 189 }, { "index": 819574, "code": "kill_check_x_buffer()\n{\n if (!has_xsel())\n return;\n\n const env_var_t disp = env_get_string(L\"DISPLAY\");\n if (! disp.missing())\n {\n size_t i;\n wcstring cmd = L\"xsel -t 500 -b\";\n wcstring new_cut_buffer=L\"\";\n wcstring_list_t list;\n if (exec_subshell(cmd, list, false /* do not apply exit status */) != -1)\n {\n\n for (i=0; i 0) new_cut_buffer += L\"\\\\n\";\n new_cut_buffer += next_line;\n }\n\n if (new_cut_buffer.size() > 0)\n {\n /*\n The buffer is inserted with backslash escapes,\n since we don't really like tabs, newlines,\n etc. anyway.\n */\n\n if (cut_buffer == NULL || cut_buffer != new_cut_buffer)\n {\n free(cut_buffer);\n cut_buffer = wcsdup(new_cut_buffer.c_str());\n kill_list.push_front(new_cut_buffer);\n }\n }\n }\n }\n}", "label": 0, "cwe": null, "length": 256 }, { "index": 602367, "code": "getTargetPrinterAnnotationPosition(const char *targetID)\n{\n OFString value;\n copyValue(getConfigEntry(L2_COMMUNICATION, targetID, L0_ANNOTATION), 0, value);\n if (value.length())\n {\n Uint16 result = 0;\n if (1 == sscanf(value.c_str(), \"%hu\", &result)) return result;\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 86 }, { "index": 355672, "code": "cant_create(int *mtype, bool revival)\n{\n\n /* SHOPKEEPERS can be revived now */\n if (*mtype==PM_GUARD || (*mtype==PM_SHOPKEEPER && !revival)\n || *mtype==PM_ALIGNED_PRIEST || *mtype==PM_ANGEL)\n {\n *mtype = PM_HUMAN_ZOMBIE;\n return true;\n }\n else if (*mtype==PM_LONG_WORM_TAIL)\n {\t/* for create_particular() */\n *mtype = PM_LONG_WORM;\n return true;\n }\n return false;\n}", "label": 0, "cwe": null, "length": 132 }, { "index": 72902, "code": "r200_get_vtx_size_1(uint32_t vtx_fmt_1)\n{\n\tint vtx_size, i, tex_size;\n\tvtx_size = 0;\n\tfor (i = 0; i < 6; i++) {\n\t\ttex_size = (vtx_fmt_1 >> (i * 3)) & 0x7;\n\t\tif (tex_size > 4)\n\t\t\tcontinue;\n\t\tvtx_size += tex_size;\n\t}\n\treturn vtx_size;\n}", "label": 0, "cwe": null, "length": 100 }, { "index": 70501, "code": "chknumvec(sym,vptr)\ntruc sym;\ntruc *vptr;\n{\n struct vector *vec;\n truc *ptr;\n int len;\n int flg, flg0 = fFIXNUM;\n\n vec = (struct vector *)TAddress(vptr);\n len = vec->len;\n ptr = &(vec->ele0);\n\n while(--len >= 0) {\n flg = *FLAGPTR(ptr);\n if(flg < fFIXNUM)\n return(error(sym,err_num,*ptr));\n else if(flg > flg0)\n flg0 = flg;\n ptr++;\n }\n return(flg0);\n}", "label": 1, "cwe": "CWE-other", "length": 142 }, { "index": 876233, "code": "H5A_dense_post_copy_file_cb(const H5A_t *attr_dst, void *_udata)\n{\n H5A_dense_file_cp_ud_t *udata = (H5A_dense_file_cp_ud_t *)_udata;\n herr_t ret_value = H5_ITER_CONT; /* Return value */\n\n FUNC_ENTER_NOAPI_NOINIT(H5A_dense_post_copy_file_cb)\n\n /* check arguments */\n HDassert(attr_dst);\n HDassert(udata);\n HDassert(udata->ainfo);\n HDassert(udata->file);\n HDassert(udata->cpy_info);\n\n if ( H5A_attr_post_copy_file(udata->oloc_src, NULL,\n udata->oloc_dst, attr_dst, udata->dxpl_id, udata->cpy_info) < 0)\n HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, H5_ITER_ERROR, \"can't copy attribute\")\n\ndone:\n\n FUNC_LEAVE_NOAPI(ret_value)\n}", "label": 0, "cwe": null, "length": 216 }, { "index": 58467, "code": "afr_sh_data_post_nonblocking_inodelk_cbk (call_frame_t *frame, xlator_t *this)\n{\n afr_internal_lock_t *int_lock = NULL;\n afr_local_t *local = NULL;\n afr_self_heal_t *sh = NULL;\n\n local = frame->local;\n int_lock = &local->internal_lock;\n sh = &local->self_heal;\n\n if (int_lock->lock_op_ret < 0) {\n gf_log (this->name, GF_LOG_DEBUG, \"Non Blocking data inodelks \"\n \"failed for %s. by %s\",\n local->loc.path, lkowner_utoa (&frame->root->lk_owner));\n\n\t\tif (!sh->data_lock_block) {\n\t\t\tsh->data_lock_failure_handler(frame, this);\n\t\t} else {\n\t\t\tint_lock->lock_cbk =\n\t\t\t\tafr_sh_data_post_blocking_inodelk_cbk;\n\t\t\tafr_blocking_lock (frame, this);\n\t\t}\n } else {\n\n gf_log (this->name, GF_LOG_DEBUG, \"Non Blocking data inodelks \"\n \"done for %s by %s. Proceeding to self-heal\",\n local->loc.path, lkowner_utoa (&frame->root->lk_owner));\n sh->data_lock_success_handler (frame, this);\n }\n\n return 0;\n}", "label": 0, "cwe": null, "length": 295 }, { "index": 29987, "code": "cogorc_planar_chroma_422_420 (guint8 * ORC_RESTRICT d1, int d1_stride, const guint8 * ORC_RESTRICT s1, int s1_stride, const guint8 * ORC_RESTRICT s2, int s2_stride, int n, int m)\n{\n OrcExecutor _ex, *ex = &_ex;\n static volatile int p_inited = 0;\n static OrcProgram *p = 0;\n void (*func) (OrcExecutor *);\n\n if (!p_inited) {\n orc_once_mutex_lock ();\n if (!p_inited) {\n\n p = orc_program_new ();\n orc_program_set_2d (p);\n orc_program_set_name (p, \"cogorc_planar_chroma_422_420\");\n orc_program_set_backup_function (p, _backup_cogorc_planar_chroma_422_420);\n orc_program_add_destination (p, 1, \"d1\");\n orc_program_add_source (p, 1, \"s1\");\n orc_program_add_source (p, 1, \"s2\");\n\n orc_program_append_2 (p, \"avgub\", 0, ORC_VAR_D1, ORC_VAR_S1, ORC_VAR_S2, ORC_VAR_D1);\n\n orc_program_compile (p);\n }\n p_inited = TRUE;\n orc_once_mutex_unlock ();\n }\n ex->program = p;\n\n ex->n = n;\n ORC_EXECUTOR_M(ex) = m;\n ex->arrays[ORC_VAR_D1] = d1;\n ex->params[ORC_VAR_D1] = d1_stride;\n ex->arrays[ORC_VAR_S1] = (void *)s1;\n ex->params[ORC_VAR_S1] = s1_stride;\n ex->arrays[ORC_VAR_S2] = (void *)s2;\n ex->params[ORC_VAR_S2] = s2_stride;\n\n func = p->code_exec;\n func (ex);\n}", "label": 0, "cwe": null, "length": 441 }, { "index": 367956, "code": "ShowAchievementCriteriaListHelper(AchievementCriteriaEntry const* criEntry, AchievementEntry const* achEntry, LocaleConstant loc, Player* target /*= NULL*/)\n{\n std::ostringstream ss;\n if (m_session)\n {\n ss << criEntry->ID << \" - |cffffffff|Hachievement_criteria:\" << criEntry->ID << \"|h[\" << criEntry->name[loc] << \" \" << localeNames[loc] << \"]|h|r\";\n }\n else\n ss << criEntry->ID << \" - \" << criEntry->name[loc] << \" \" << localeNames[loc];\n\n if (target)\n ss << \" = \" << target->GetAchievementMgr().GetCriteriaProgressCounter(criEntry);\n\n if (achEntry->flags & ACHIEVEMENT_FLAG_COUNTER)\n ss << GetMangosString(LANG_COUNTER);\n else\n {\n ss << \" [\" << AchievementMgr::GetCriteriaProgressMaxCounter(criEntry, achEntry) << \"]\";\n\n if (target && target->GetAchievementMgr().IsCompletedCriteria(criEntry, achEntry))\n ss << GetMangosString(LANG_COMPLETE);\n }\n\n SendSysMessage(ss.str().c_str());\n}", "label": 0, "cwe": null, "length": 260 }, { "index": 956677, "code": "AutoSwitchIncam(){\n if (localPlayer)\n return localPlayer->autoSwitchIncam;\n else\n return false;\n}", "label": 0, "cwe": null, "length": 30 }, { "index": 832771, "code": "byte_lowpart_offset (enum machine_mode outer_mode,\n\t\t enum machine_mode inner_mode)\n{\n if (GET_MODE_SIZE (outer_mode) < GET_MODE_SIZE (inner_mode))\n return subreg_lowpart_offset (outer_mode, inner_mode);\n else\n return -subreg_lowpart_offset (inner_mode, outer_mode);\n}", "label": 0, "cwe": null, "length": 71 }, { "index": 318624, "code": "if_exists_else_spec_function (argc, argv)\n int argc;\n const char **argv;\n{\n /* Must have exactly two arguments. */\n if (argc != 2)\n return NULL;\n\n if (IS_ABSOLUTE_PATHNAME (argv[0]) && ! access (argv[0], R_OK))\n return argv[0];\n\n return argv[1];\n}", "label": 0, "cwe": null, "length": 81 }, { "index": 534071, "code": "free_lang_data_in_cgraph (void)\n{\n struct cgraph_node *n;\n struct varpool_node *v;\n struct free_lang_data_d fld;\n tree t;\n unsigned i;\n alias_pair *p;\n\n /* Initialize sets and arrays to store referenced decls and types. */\n fld.pset = pointer_set_create ();\n fld.worklist = NULL;\n fld.decls = VEC_alloc (tree, heap, 100);\n fld.types = VEC_alloc (tree, heap, 100);\n\n /* Find decls and types in the body of every function in the callgraph. */\n for (n = cgraph_nodes; n; n = n->next)\n find_decls_types_in_node (n, &fld);\n\n FOR_EACH_VEC_ELT (alias_pair, alias_pairs, i, p)\n find_decls_types (p->decl, &fld);\n\n /* Find decls and types in every varpool symbol. */\n for (v = varpool_nodes; v; v = v->next)\n find_decls_types_in_var (v, &fld);\n\n /* Set the assembler name on every decl found. We need to do this\n now because free_lang_data_in_decl will invalidate data needed\n for mangling. This breaks mangling on interdependent decls. */\n FOR_EACH_VEC_ELT (tree, fld.decls, i, t)\n assign_assembler_name_if_neeeded (t);\n\n /* Traverse every decl found freeing its language data. */\n FOR_EACH_VEC_ELT (tree, fld.decls, i, t)\n free_lang_data_in_decl (t);\n\n /* Traverse every type found freeing its language data. */\n FOR_EACH_VEC_ELT (tree, fld.types, i, t)\n free_lang_data_in_type (t);\n\n pointer_set_destroy (fld.pset);\n VEC_free (tree, heap, fld.worklist);\n VEC_free (tree, heap, fld.decls);\n VEC_free (tree, heap, fld.types);\n}", "label": 0, "cwe": null, "length": 444 }, { "index": 823016, "code": "create(){\n if(!xid){\n if(getApp()->isInitialized()){\n FXTRACE((100,\"%s::create %p\\n\",getClassName(),this));\n\n#ifndef WIN32\n\n // Initialize visual\n visual->create();\n\n // Make pixmap\n xid=XCreatePixmap(DISPLAY(getApp()),XDefaultRootWindow(DISPLAY(getApp())),FXMAX(width,1),FXMAX(height,1),1);\n\n#else\n\n // Initialize visual\n visual->create();\n\n // Create uninitialized shape bitmap\n xid=CreateBitmap(FXMAX(width,1),FXMAX(height,1),1,1,NULL);\n\n#endif\n\n // Were we successful?\n if(!xid){ throw FXImageException(\"unable to create bitmap\"); }\n\n // Render pixels\n render();\n\n // If we're not keeping the pixel buffer, release it\n if(!(options&BITMAP_KEEP)) release();\n }\n }\n }", "label": 0, "cwe": null, "length": 195 }, { "index": 318626, "code": "filename_hash (const void *s)\n{\n /* The cast is for -Wc++-compat. */\n const unsigned char *str = (const unsigned char *) s;\n hashval_t r = 0;\n unsigned char c;\n\n while ((c = *str++) != 0)\n {\n if (c == '\\\\')\n\tc = '/';\n c = TOLOWER (c);\n r = r * 67 + c - 113;\n }\n\n return r;\n}", "label": 0, "cwe": null, "length": 105 }, { "index": 200574, "code": "Median(void) const\r\n{\r\n // Return median\r\n if (grid_size == 0) return 0.0;\r\n int tmp_count = 0;\r\n RNScalar *tmp_values = new RNScalar [ grid_size ];\r\n for (int i = 0; i < grid_size; i++) {\r\n if (grid_values[i] != R2_GRID_UNKNOWN_VALUE) {\r\n tmp_values[tmp_count++] = grid_values[i];\r\n }\r\n }\r\n if (tmp_count == 0) return R2_GRID_UNKNOWN_VALUE;\r\n qsort(tmp_values, tmp_count, sizeof(RNScalar), RNCompareScalars);\r\n RNScalar median = tmp_values[tmp_count/2];\r\n delete [] tmp_values;\r\n return median;\r\n}", "label": 0, "cwe": null, "length": 156 }, { "index": 94013, "code": "smart_reconnect(struct vsp_node * node, int mode)\n{\n\n\tint old_fd;\n\n\tif(node->flags != O_RDONLY) {\n\t\treturn 1;\n\t}\n\n\t/* user uses data fd as file descriptor and we have to keep it unchanged */\n\told_fd = node->dataFd;\n\n\tif(data_hello_conversation(node) < 0) {\n\t\tdc_debug(DC_ERROR, \"[%d] Failed to make a new data connection.\", node->dataFd);\n\t\treturn 1;\n\t}\n\n\t/* try to get old fd in use */\n\tnode->dataFd = dup2(node->dataFd, old_fd);\n\tif( node->dataFd != old_fd) {\n\t\tnode->dataFd = old_fd;\n\t\tdc_debug(DC_ERROR, \"dup2 failed. Reconnection impossible.\");\n\t\treturn 1;\n\t}\n\n\tif(mode && !dc_set_pos(node, mode, -1)) {\n\t\tdc_debug(DC_ERROR, \"[%d] Failed to set correct position.\", node->dataFd);\n\t\treturn 1;\n\t}\n\n\tdc_debug(DC_INFO, \"[%d] Broken connection recovered.\", node->dataFd);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 236 }, { "index": 604590, "code": "IsSFrame(u_char *data, struct layer2 *l2)\n{\n\tregister u_char d = *data;\n\n\tif (!test_bit(FLG_MOD128, &l2->flag))\n\t\td &= 0xf;\n\treturn ((d & 0xf3) == 1) && ((d & 0x0c) != 0x0c);\n}", "label": 0, "cwe": null, "length": 79 }, { "index": 808749, "code": "plugin_load_image(G3DContext *context, const gchar *filename,\n\tG3DImage *image, gpointer user_data)\n{\n\tGdkPixbuf *pixbuf;\n\n\tif(!gdkpixbuf_init())\n\t\treturn FALSE;\n\n\tpixbuf = gdk_pixbuf_new_from_file(filename, NULL);\n\tif(pixbuf == NULL)\n\t{\n\t\tg_warning(\"failed to load '%s'\", filename);\n\t\treturn FALSE;\n\t}\n\n\treturn gdkpixbuf_postprocess(pixbuf, image, filename);\n}", "label": 0, "cwe": null, "length": 104 }, { "index": 13172, "code": "vtkMINCImageWriterConvertVTKTypeToMINCType(\n int dataType,\n int &mincsigned)\n{\n nc_type minctype = NC_BYTE;\n\n // Get the vtk type of the data.\n switch (dataType)\n {\n case VTK_CHAR:\n case VTK_SIGNED_CHAR:\n minctype = NC_BYTE;\n mincsigned = 1;\n break;\n case VTK_UNSIGNED_CHAR:\n minctype = NC_BYTE;\n mincsigned = 0;\n break;\n case VTK_SHORT:\n minctype = NC_SHORT;\n mincsigned = 1;\n break;\n case VTK_UNSIGNED_SHORT:\n minctype = NC_SHORT;\n mincsigned = 0;\n break;\n case VTK_INT:\n minctype = NC_INT;\n mincsigned = 1;\n break;\n case VTK_UNSIGNED_INT:\n minctype = NC_INT;\n mincsigned = 0;\n break;\n case VTK_FLOAT:\n minctype = NC_FLOAT;\n mincsigned = 1;\n break;\n case VTK_DOUBLE:\n minctype = NC_DOUBLE;\n mincsigned = 1;\n break;\n default:\n break;\n }\n\n return minctype;\n}", "label": 0, "cwe": null, "length": 270 }, { "index": 703763, "code": "xtkbd_interrupt(struct serio *serio,\n\tunsigned char data, unsigned int flags)\n{\n\tstruct xtkbd *xtkbd = serio_get_drvdata(serio);\n\n\tswitch (data) {\n\t\tcase XTKBD_EMUL0:\n\t\tcase XTKBD_EMUL1:\n\t\t\tbreak;\n\t\tdefault:\n\n\t\t\tif (xtkbd->keycode[data & XTKBD_KEY]) {\n\t\t\t\tinput_report_key(xtkbd->dev, xtkbd->keycode[data & XTKBD_KEY], !(data & XTKBD_RELEASE));\n\t\t\t\tinput_sync(xtkbd->dev);\n\t\t\t} else {\n\t\t\t\tprintk(KERN_WARNING \"xtkbd.c: Unknown key (scancode %#x) %s.\\n\",\n\t\t\t\t\tdata & XTKBD_KEY, data & XTKBD_RELEASE ? \"released\" : \"pressed\");\n\t\t\t}\n\t}\n\treturn IRQ_HANDLED;\n}", "label": 0, "cwe": null, "length": 181 }, { "index": 121346, "code": "gfs_client_get_load_result(int sock,\n\tstruct sockaddr *server_addr, socklen_t *server_addr_sizep,\n\tstruct gfs_client_load *result)\n{\n\tint rv;\n\tdouble loadavg[3];\n#ifndef WORDS_BIGENDIAN\n\tstruct { char c[8]; } nloadavg[3];\n#else\n#\tdefine nloadavg loadavg\n#endif\n\n\tif (server_addr == NULL || server_addr_sizep == NULL) {\n\t\t/* caller doesn't need server_addr */\n\t\trv = read(sock, nloadavg, sizeof(nloadavg));\n\t} else {\n\t\trv = recvfrom(sock, nloadavg, sizeof(nloadavg), 0,\n\t\t server_addr, server_addr_sizep);\n\t}\n\tif (rv == -1) {\n\t\tint save_errno = errno;\n\t\tgflog_debug(GFARM_MSG_1001248,\n\t\t\t\"read or receive operation from socket failed: %s\",\n\t\t\tstrerror(save_errno));\n\t\treturn (gfarm_errno_to_error(save_errno));\n\t}\n\n#ifndef WORDS_BIGENDIAN\n\tswab(&nloadavg[0], &loadavg[0], sizeof(loadavg[0]));\n\tswab(&nloadavg[1], &loadavg[1], sizeof(loadavg[1]));\n\tswab(&nloadavg[2], &loadavg[2], sizeof(loadavg[2]));\n#endif\n\tresult->loadavg_1min = loadavg[0];\n\tresult->loadavg_5min = loadavg[1];\n\tresult->loadavg_15min = loadavg[2];\n\treturn (GFARM_ERR_NO_ERROR);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-other" ], "length": 332 }, { "index": 133442, "code": "nextRound(const InputProvider *input)\n{\n if (m_fastFalling) {\n while (beginFall()) {\n finishRound();\n }\n }\n else {\n beginFall();\n }\n\n if (isFresh()) {\n if (m_controls->driving(input)) {\n m_lastAction = Cube::ACTION_MOVE;\n }\n else {\n MouseControl rat(m_controls, m_view, m_finder);\n if (rat.mouseDrive(input)) {\n m_lastAction = Cube::ACTION_MOVE;\n }\n }\n }\n finishRound();\n}", "label": 0, "cwe": null, "length": 119 }, { "index": 54816, "code": "rl_message (const char *format, ...)\n#else\nrl_message (va_alist)\n va_dcl\n#endif\n{\n va_list args;\n#if defined (PREFER_VARARGS)\n char *format;\n#endif\n\n#if defined (PREFER_STDARG)\n va_start (args, format);\n#else\n va_start (args);\n format = va_arg (args, char *);\n#endif\n\n#if defined (HAVE_VSNPRINTF)\n vsnprintf (msg_buf, sizeof (msg_buf) - 1, format, args);\n#else\n vsprintf (msg_buf, format, args);\n msg_buf[sizeof(msg_buf) - 1] = '\\0';\t/* overflow? */\n#endif\n va_end (args);\n\n if (saved_local_prompt == 0)\n {\n rl_save_prompt ();\n msg_saved_prompt = 1;\n }\n rl_display_prompt = msg_buf;\n local_prompt = expand_prompt (msg_buf, &prompt_visible_length,\n\t\t\t\t\t &prompt_last_invisible,\n\t\t\t\t\t &prompt_invis_chars_first_line,\n\t\t\t\t\t &prompt_physical_chars);\n local_prompt_prefix = (char *)NULL;\n (*rl_redisplay_function) ();\n\n return 0;\n}", "label": 0, "cwe": null, "length": 249 }, { "index": 95702, "code": "match(struct AuthBlock *ptr, struct AuthBlock *acptr)\n{\n if((ptr->class == acptr->class) &&\n (ptr->flags == acptr->flags))\n {\n\tconst char *p1, *p2;\n\t\n\t/* check the spoofs match.. */\n\tif(ptr->spoof)\n\t p1 = ptr->spoof;\n\telse\n\t p1 = \"\";\n\n\tif(acptr->spoof)\n\t p2 = acptr->spoof;\n\telse\n\t p2 = \"\";\n\n\tif(strcmp(p1, p2))\n\t return 0;\n\n\t/* now check the passwords match.. */\n\tif(ptr->passwd)\n\t p1 = ptr->passwd;\n\telse\n\t p1 = \"\";\n\n\tif(acptr->passwd)\n\t p2 = acptr->passwd;\n\telse\n\t p2 = \"\";\n\n\tif(strcmp(p1, p2))\n\t return 0;\n\n\treturn 1;\n }\n\n return 0;\n}", "label": 0, "cwe": null, "length": 197 }, { "index": 968361, "code": "setAssumpThm(const Theorem& thm, int scope) {\n if(d_assump==NULL) {\n // Make sure d_val==0 all the way to scope 0\n d_assump = new(true) CDO(d_vm->getCM()->getCurrentContext());\n IF_DEBUG(d_val->setName(\"CDO[VariableValue::d_val]\");)\n }\n d_assump->set(thm, scope);\n}", "label": 0, "cwe": null, "length": 98 }, { "index": 506290, "code": "axp288_adc_probe(struct platform_device *pdev)\n{\n\tint ret;\n\tstruct axp288_adc_info *info;\n\tstruct iio_dev *indio_dev;\n\tstruct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);\n\n\tindio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*info));\n\tif (!indio_dev)\n\t\treturn -ENOMEM;\n\n\tinfo = iio_priv(indio_dev);\n\tinfo->irq = platform_get_irq(pdev, 0);\n\tif (info->irq < 0) {\n\t\tdev_err(&pdev->dev, \"no irq resource?\\n\");\n\t\treturn info->irq;\n\t}\n\tplatform_set_drvdata(pdev, indio_dev);\n\tinfo->regmap = axp20x->regmap;\n\t/*\n\t * Set ADC to enabled state at all time, including system suspend.\n\t * otherwise internal fuel gauge functionality may be affected.\n\t */\n\tret = regmap_write(info->regmap, AXP20X_ADC_EN1, AXP288_ADC_EN_MASK);\n\tif (ret) {\n\t\tdev_err(&pdev->dev, \"unable to enable ADC device\\n\");\n\t\treturn ret;\n\t}\n\n\tindio_dev->dev.parent = &pdev->dev;\n\tindio_dev->name = pdev->name;\n\tindio_dev->channels = axp288_adc_channels;\n\tindio_dev->num_channels = ARRAY_SIZE(axp288_adc_channels);\n\tindio_dev->info = &axp288_adc_iio_info;\n\tindio_dev->modes = INDIO_DIRECT_MODE;\n\tret = iio_map_array_register(indio_dev, axp288_adc_default_maps);\n\tif (ret < 0)\n\t\treturn ret;\n\n\tret = iio_device_register(indio_dev);\n\tif (ret < 0) {\n\t\tdev_err(&pdev->dev, \"unable to register iio device\\n\");\n\t\tgoto err_array_unregister;\n\t}\n\treturn 0;\n\nerr_array_unregister:\n\tiio_map_array_unregister(indio_dev);\n\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 419 }, { "index": 981305, "code": "tenmado_hit(tenm_object *my, tenm_object *your)\n{\n int n;\n\n /* sanity check */\n if (my == NULL)\n {\n fprintf(stderr, \"tenmado_hit: my is NULL\\n\");\n return 0;\n }\n if (your == NULL)\n {\n fprintf(stderr, \"tenmado_hit: your is NULL\\n\");\n return 0;\n }\n\n if (!(your->attr & ATTR_PLAYER_SHOT))\n return 0;\n\n deal_damage(my, your, 0);\n if (tenmado_green(my))\n add_chain(my, your);\n my->count[1] = 41;\n\n if (my->hit_point <= 0)\n {\n if (tenmado_green(my))\n n = 8;\n else\n n = 7;\n tenm_table_add(explosion_new(my->x, my->y,\n my->count_d[0] / 2.0, my->count_d[1]/ 2.0,\n 1, 20, n, 3.0, 8));\n tenm_table_add(fragment_new(my->x, my->y,\n my->count_d[0] / 2.0, my->count_d[1] / 2.0,\n 20.0, 10, n, 3.0, 0.0, 8));\n add_score(11);\n if (my->count[2] <= 1)\n tenm_table_apply(my->count[7],\n (int (*)(tenm_object *, int)) (&tenmado_signal),\n 0);\n return 1;\n }\n\n return 0;\n}", "label": 0, "cwe": null, "length": 369 }, { "index": 695947, "code": "put_address(char *st, u_char *p, int len)\n{\n\tu_char retval = 0;\n\tu_char adr_typ = 0; /* network standard */\n\n\tif (len < 2) return (retval);\n\tif (*p == 0xA1) {\n\t\tretval = *(++p) + 2; /* total length */\n\t\tif (retval > len) return (0); /* too short */\n\t\tlen = retval - 2; /* remaining length */\n\t\tif (len < 3) return (0);\n\t\tif ((*(++p) != 0x0A) || (*(++p) != 1)) return (0);\n\t\tadr_typ = *(++p);\n\t\tlen -= 3;\n\t\tp++;\n\t\tif (len < 2) return (0);\n\t\tif (*p++ != 0x12) return (0);\n\t\tif (*p > len) return (0); /* check number length */\n\t\tlen = *p++;\n\t} else if (*p == 0x80) {\n\t\tretval = *(++p) + 2; /* total length */\n\t\tif (retval > len) return (0);\n\t\tlen = retval - 2;\n\t\tp++;\n\t} else\n\t\treturn (0); /* invalid address information */\n\n\tsprintf(st, \"%d \", adr_typ);\n\tst += strlen(st);\n\tif (!len)\n\t\t*st++ = '-';\n\telse\n\t\twhile (len--)\n\t\t\t*st++ = *p++;\n\t*st = '\\0';\n\treturn (retval);\n}", "label": 0, "cwe": null, "length": 321 }, { "index": 826861, "code": "CanMoveTo(ARegion *r1, ARegion *r2)\n{\n\tif (r1 == r2) return 1;\n\n\tint exit = 1;\n\tint i;\n\tint dir;\n\n\tfor (i=0; ineighbors[i] == r2) {\n\t\t\texit = 0;\n\t\t\tdir = i;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (exit) return 0;\n\texit = 1;\n\tfor (i=0; ineighbors[i] == r1) {\n\t\t\texit = 0;\n\t\t\tbreak;\n\t\t}\n\t}\n\tif (exit) return 0;\n\n\tint mt = MoveType();\n\tif (((TerrainDefs[r1->type].similar_type == R_OCEAN) ||\n\t\t\t\t(TerrainDefs[r2->type].similar_type == R_OCEAN)) &&\n\t\t\t(!CanSwim() || GetFlag(FLAG_NOCROSS_WATER)))\n\t\treturn 0;\n\tint mp = CalcMovePoints() - movepoints;\n\tif (mp < (r2->MoveCost(mt, r1, dir, 0))) return 0;\n\treturn 1;\n}", "label": 0, "cwe": null, "length": 257 }, { "index": 101666, "code": "gst_tcp_client_src_class_init (GstTCPClientSrcClass * klass)\n{\n GObjectClass *gobject_class;\n GstBaseSrcClass *gstbasesrc_class;\n GstPushSrcClass *gstpush_src_class;\n\n gobject_class = (GObjectClass *) klass;\n gstbasesrc_class = (GstBaseSrcClass *) klass;\n gstpush_src_class = (GstPushSrcClass *) klass;\n\n gobject_class->set_property = gst_tcp_client_src_set_property;\n gobject_class->get_property = gst_tcp_client_src_get_property;\n gobject_class->finalize = gst_tcp_client_src_finalize;\n\n g_object_class_install_property (gobject_class, PROP_HOST,\n g_param_spec_string (\"host\", \"Host\",\n \"The host IP address to receive packets from\", TCP_DEFAULT_HOST,\n G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));\n g_object_class_install_property (gobject_class, PROP_PORT,\n g_param_spec_int (\"port\", \"Port\", \"The port to receive packets from\", 0,\n TCP_HIGHEST_PORT, TCP_DEFAULT_PORT,\n G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));\n g_object_class_install_property (gobject_class, PROP_PROTOCOL,\n g_param_spec_enum (\"protocol\", \"Protocol\", \"The protocol to wrap data in\",\n GST_TYPE_TCP_PROTOCOL, GST_TCP_PROTOCOL_NONE,\n G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));\n\n gstbasesrc_class->get_caps = gst_tcp_client_src_getcaps;\n gstbasesrc_class->start = gst_tcp_client_src_start;\n gstbasesrc_class->stop = gst_tcp_client_src_stop;\n gstbasesrc_class->unlock = gst_tcp_client_src_unlock;\n gstbasesrc_class->unlock_stop = gst_tcp_client_src_unlock_stop;\n\n gstpush_src_class->create = gst_tcp_client_src_create;\n\n GST_DEBUG_CATEGORY_INIT (tcpclientsrc_debug, \"tcpclientsrc\", 0,\n \"TCP Client Source\");\n}", "label": 0, "cwe": null, "length": 414 }, { "index": 73944, "code": "wcs_to_normal(const CHAR_T *str) {\n\tif (!str) return NULL;\n\t{\n\t\tint len\t\t= wcstombs(NULL, str,0);\n\t\tchar *tmp\t= xmalloc(len+1);\n\t\tint ret;\n\n\t\tret = wcstombs(tmp, (wchar_t *) str, len);\n//\t\tif (ret != len) printf(\"[wcs_to_normal_n, err] len = %d wcstombs = %d\\n\", ret, len);\n\t\treturn tmp;\n\t}\n}", "label": 0, "cwe": null, "length": 107 }, { "index": 912021, "code": "group_gap(int len,int sclass,char *seq)\n{\n\tint i,j,k,xtra;\n\t\n\tfor(i=1;i<=nseqs;++i)\n\t\tif(group[i] == sclass) {\n\t\t\txtra = len - seqlen_array[i];\n\t\t\tif(xtra>0)\n\t\t\t\tfor(j=1;j<=xtra;++j)\n\t\t\t\t\tseq_array[i][seqlen_array[i]+j] = -1;\n\t\t\tfor(j=1;j<=len;++j)\n\t\t\t\tif(seq[j] == '-') {\n\t\t\t\t\tfor(k=len;k>=j+1;--k)\n\t\t\t\t\tseq_array[i][k] = seq_array[i][k-1];\n\t\t\t\t\tseq_array[i][j] = -1;\n\t\t\t\t}\n\t\t\tseqlen_array[i] = len;\n\t\t}\n}", "label": 0, "cwe": null, "length": 167 }, { "index": 506068, "code": "lj_ir_tonumber(jit_State *J, TRef tr)\n{\n if (!tref_isnumber(tr)) {\n if (tref_isstr(tr))\n tr = emitir(IRTG(IR_STRTO, IRT_NUM), tr, 0);\n else\n lj_trace_err(J, LJ_TRERR_BADTYPE);\n }\n return tr;\n}", "label": 0, "cwe": null, "length": 79 }, { "index": 34349, "code": "gl_configure_getline(GetLine *gl, const char *app_string,\n\t\t\t const char *app_file, const char *user_file)\n{\n sigset_t oldset; /* The signals that were blocked on entry to this function */\n int status; /* The return status of _gl_configure_getline() */\n/*\n * Check the arguments.\n */\n if(!gl) {\n errno = EINVAL;\n return 1;\n };\n/*\n * Block all signals.\n */\n if(gl_mask_signals(gl, &oldset))\n return 1;\n/*\n * Execute the private body of the function while signals are blocked.\n */\n status = _gl_configure_getline(gl, app_string, app_file, user_file);\n/*\n * Restore the process signal mask.\n */\n gl_unmask_signals(gl, &oldset);\n return status;\n}", "label": 0, "cwe": null, "length": 173 }, { "index": 634305, "code": "eel_canvas_item_accessible_add_focus_handler (AtkComponent *component,\n AtkFocusHandler handler)\n{\n \tGSignalMatchType match_type;\n\tguint signal_id;\n\n\tmatch_type = G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC;\n\tsignal_id = g_signal_lookup (\"focus-event\", ATK_TYPE_OBJECT);\n\n\tif (!g_signal_handler_find (component, match_type, signal_id, 0, NULL,\n (gpointer) handler, NULL)) {\n\t\treturn g_signal_connect_closure_by_id (component,\n signal_id, 0,\n g_cclosure_new (\n G_CALLBACK (handler), NULL,\n (GClosureNotify) NULL),\n FALSE);\n\t} \n\treturn 0;\n}", "label": 0, "cwe": null, "length": 145 }, { "index": 12851, "code": "xgmac_change_mtu(struct net_device *dev, int new_mtu)\n{\n\tstruct xgmac_priv *priv = netdev_priv(dev);\n\tint old_mtu;\n\n\tif ((new_mtu < 46) || (new_mtu > MAX_MTU)) {\n\t\tnetdev_err(priv->dev, \"invalid MTU, max MTU is: %d\\n\", MAX_MTU);\n\t\treturn -EINVAL;\n\t}\n\n\told_mtu = dev->mtu;\n\n\t/* return early if the buffer sizes will not change */\n\tif (old_mtu == new_mtu)\n\t\treturn 0;\n\n\t/* Stop everything, get ready to change the MTU */\n\tif (!netif_running(dev))\n\t\treturn 0;\n\n\t/* Bring interface down, change mtu and bring interface back up */\n\txgmac_stop(dev);\n\tdev->mtu = new_mtu;\n\treturn xgmac_open(dev);\n}", "label": 0, "cwe": null, "length": 189 }, { "index": 57595, "code": "ComputeScore() {\n int p;\n\n float Score = Penalty(nClustersAlive);\n for(p=0; palocf) {\n if (pgr->ivals != NULL) gree(pgr->ivals,\"f88\");\n if (pgr->jvals != NULL) gree(pgr->jvals,\"f89\");\n }\n if (pgr->idim>-1) {\n gree(pgr->grid,\"f90\");\n gree(pgr->umask,\"f91\");\n }\n gree(pgr,\"f92\");\n}", "label": 1, "cwe": "CWE-other", "length": 125 }, { "index": 26709, "code": "snd_usbmidi_emagic_input(struct snd_usb_midi_in_endpoint *ep,\n\t\t\t\t uint8_t *buffer, int buffer_length)\n{\n\tint i;\n\n\t/* FF indicates end of valid data */\n\tfor (i = 0; i < buffer_length; ++i)\n\t\tif (buffer[i] == 0xff) {\n\t\t\tbuffer_length = i;\n\t\t\tbreak;\n\t\t}\n\n\t/* handle F5 at end of last buffer */\n\tif (ep->seen_f5)\n\t\tgoto switch_port;\n\n\twhile (buffer_length > 0) {\n\t\t/* determine size of data until next F5 */\n\t\tfor (i = 0; i < buffer_length; ++i)\n\t\t\tif (buffer[i] == 0xf5)\n\t\t\t\tbreak;\n\t\tsnd_usbmidi_input_data(ep, ep->current_port, buffer, i);\n\t\tbuffer += i;\n\t\tbuffer_length -= i;\n\n\t\tif (buffer_length <= 0)\n\t\t\tbreak;\n\t\t/* assert(buffer[0] == 0xf5); */\n\t\tep->seen_f5 = 1;\n\t\t++buffer;\n\t\t--buffer_length;\n\n\tswitch_port:\n\t\tif (buffer_length <= 0)\n\t\t\tbreak;\n\t\tif (buffer[0] < 0x80) {\n\t\t\tep->current_port = (buffer[0] - 1) & 15;\n\t\t\t++buffer;\n\t\t\t--buffer_length;\n\t\t}\n\t\tep->seen_f5 = 0;\n\t}\n}", "label": 0, "cwe": null, "length": 310 }, { "index": 619849, "code": "F_mpz_poly_clear(F_mpz_poly_t poly)\n{\n for (ulong i = 0; i < poly->alloc; i++) // Clean up any mpz_t's\n\t\t_F_mpz_demote(poly->coeffs + i);\n\tif (poly->coeffs) flint_heap_free(poly->coeffs); // clean up ordinary coeffs\n}", "label": 0, "cwe": null, "length": 76 }, { "index": 454441, "code": "fileChangedOnDisk( const QString& filename )\n{\n LOG(logDEBUG) << \"FileWatcher::fileChangedOnDisk \" << filename.toStdString();\n\n if ( ( monitoringState_ == FileExists ) && ( filename == fileMonitored_ ) )\n {\n emit fileChanged( filename );\n\n // If the file has been removed...\n if ( !QFileInfo( filename ).exists() )\n monitoringState_ = FileRemoved;\n }\n else\n LOG(logWARNING) << \"FileWatcher::fileChangedOnDisk - call from Qt but no file monitored\";\n}", "label": 0, "cwe": null, "length": 120 }, { "index": 27176, "code": "avi_init_super_index(avi_t *AVI, unsigned char *idxtag, avisuperindex_chunk **si)\n{\n int k;\n\n avisuperindex_chunk *sil = NULL;\n\n if ((sil = (avisuperindex_chunk *) gf_malloc (sizeof (avisuperindex_chunk))) == NULL) {\n\tAVI_errno = AVI_ERR_NO_MEM;\n\treturn -1;\n }\n memcpy (sil->fcc, \"indx\", 4);\n sil->dwSize = 0; // size of this chunk\n sil->wLongsPerEntry = 4;\n sil->bIndexSubType = 0;\n sil->bIndexType = AVI_INDEX_OF_INDEXES;\n sil->nEntriesInUse = 0; // none are in use\n memcpy (sil->dwChunkId, idxtag, 4);\n memset (sil->dwReserved, 0, sizeof (sil->dwReserved));\n\n // NR_IXNN_CHUNKS == allow 32 indices which means 32 GB files -- arbitrary\n sil->aIndex = (avisuperindex_entry *) gf_malloc (sil->wLongsPerEntry * NR_IXNN_CHUNKS * sizeof (void*));\n if (!sil->aIndex) {\n\tAVI_errno = AVI_ERR_NO_MEM;\n\treturn -1;\n }\n memset (sil->aIndex, 0, sil->wLongsPerEntry * NR_IXNN_CHUNKS * sizeof (u32));\n\n sil->stdindex = (avistdindex_chunk **)gf_malloc (NR_IXNN_CHUNKS * sizeof (avistdindex_chunk *));\n if (!sil->stdindex) {\n\tAVI_errno = AVI_ERR_NO_MEM;\n\treturn -1;\n }\n for (k = 0; k < NR_IXNN_CHUNKS; k++) {\n\tsil->stdindex[k] = (avistdindex_chunk *) gf_malloc (sizeof (avistdindex_chunk));\n\t// gets rewritten later\n\tsil->stdindex[k]->qwBaseOffset = (u64)k * NEW_RIFF_THRES;\n\tsil->stdindex[k]->aIndex = NULL;\n }\n\n *si = sil;\n\n return 0;\n}", "label": 0, "cwe": null, "length": 471 }, { "index": 987891, "code": "WriteImageStride(unsigned char *img, int stride, int cx, int cy)\n{\n if (WritePNG(szFile, img, stride, cx, cy) == -1)\n outputf(\"Error creating file %s\\n\", szFile);\n imagesWritten++;\n ProgressValueAdd(1);\n}", "label": 0, "cwe": null, "length": 65 }, { "index": 524872, "code": "hfi1_filter_ib_service_level(void *ibhdr, void *packet_data,\n\t\t\t\t\tvoid *value)\n{\n\tstruct hfi1_ib_header *hdr;\n\tint ret;\n\n\tret = hfi1_filter_check(ibhdr, \"header\");\n\tif (ret)\n\t\treturn ret;\n\tret = hfi1_filter_check(value, \"user\");\n\tif (ret)\n\t\treturn ret;\n\n\thdr = (struct hfi1_ib_header *)ibhdr;\n\n\tif ((*((u8 *)value)) == ((be16_to_cpu(hdr->lrh[0]) >> 4) & 0xF))\n\t\treturn HFI1_FILTER_HIT;\n\n\treturn HFI1_FILTER_MISS;\n}", "label": 0, "cwe": null, "length": 137 }, { "index": 68917, "code": "fid_response(FidFilter *filt, double freq) {\n double top[2], bot[2];\n double theta= freq * 2 * M_PI;\n double zz[2];\n\n top[0]= 1;\n top[1]= 0;\n bot[0]= 1;\n bot[1]= 0;\n zz[0]= cos(theta);\n zz[1]= sin(theta);\n\n while (filt->len) {\n double resp[2];\n int cnt= filt->len;\n evaluate(resp, filt->val, cnt, zz);\n if (filt->typ == 'I')\n\t cmul(bot, resp);\n else if (filt->typ == 'F')\n\t cmul(top, resp);\n else\n\t error(\"Unknown filter type %d in fid_response()\", filt->typ);\n filt= FFNEXT(filt);\n }\n\n cdiv(top, bot);\n\n return hypot(top[1], top[0]);\n}", "label": 0, "cwe": null, "length": 207 }, { "index": 992705, "code": "max8997_muic_set_path(struct max8997_muic_info *info,\n\t\tu8 val, bool attached)\n{\n\tint ret = 0;\n\tu8 ctrl1, ctrl2 = 0;\n\n\tif (attached)\n\t\tctrl1 = val;\n\telse\n\t\tctrl1 = CONTROL1_SW_OPEN;\n\n\tret = max8997_update_reg(info->muic,\n\t\t\tMAX8997_MUIC_REG_CONTROL1, ctrl1, COMP_SW_MASK);\n\tif (ret < 0) {\n\t\tdev_err(info->dev, \"failed to update MUIC register\\n\");\n\t\treturn ret;\n\t}\n\n\tif (attached)\n\t\tctrl2 |= CONTROL2_CPEN_MASK;\t/* LowPwr=0, CPEn=1 */\n\telse\n\t\tctrl2 |= CONTROL2_LOWPWR_MASK;\t/* LowPwr=1, CPEn=0 */\n\n\tret = max8997_update_reg(info->muic,\n\t\t\tMAX8997_MUIC_REG_CONTROL2, ctrl2,\n\t\t\tCONTROL2_LOWPWR_MASK | CONTROL2_CPEN_MASK);\n\tif (ret < 0) {\n\t\tdev_err(info->dev, \"failed to update MUIC register\\n\");\n\t\treturn ret;\n\t}\n\n\tdev_info(info->dev,\n\t\t\"CONTROL1 : 0x%02x, CONTROL2 : 0x%02x, state : %s\\n\",\n\t\tctrl1, ctrl2, attached ? \"attached\" : \"detached\");\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 308 }, { "index": 21466, "code": "dummy_driver_run_cycle (dummy_driver_t *driver)\n{\n\tjack_engine_t *engine = driver->engine;\n\tint wait_status;\n\tfloat delayed_usecs;\n\n\tjack_nframes_t nframes = dummy_driver_wait (driver, -1, &wait_status,\n\t\t\t\t\t\t &delayed_usecs);\n\tif (nframes == 0) {\n\t\t/* we detected an xrun and restarted: notify\n\t\t * clients about the delay. */\n\t\tengine->delay (engine, delayed_usecs);\n\t\treturn 0;\n\t} \n\n\t// FakeVideoSync (driver);\n\n\tif (wait_status == 0)\n\t\treturn engine->run_cycle (engine, nframes, delayed_usecs);\n\n\tif (wait_status < 0)\n\t\treturn -1;\n\telse\n\t\treturn 0;\n}", "label": 0, "cwe": null, "length": 163 }, { "index": 588854, "code": "ath9k_cmn_init_crypto(struct ath_hw *ah)\n{\n\tstruct ath_common *common = ath9k_hw_common(ah);\n\tint i = 0;\n\n\t/* Get the hardware key cache size. */\n\tcommon->keymax = AR_KEYTABLE_SIZE;\n\n\t/*\n\t * Check whether the separate key cache entries\n\t * are required to handle both tx+rx MIC keys.\n\t * With split mic keys the number of stations is limited\n\t * to 27 otherwise 59.\n\t */\n\tif (ah->misc_mode & AR_PCU_MIC_NEW_LOC_ENA)\n\t\tcommon->crypt_caps |= ATH_CRYPT_CAP_MIC_COMBINED;\n\n\t/*\n\t * Reset the key cache since some parts do not\n\t * reset the contents on initial power up.\n\t */\n\tfor (i = 0; i < common->keymax; i++)\n\t\tath_hw_keyreset(common, (u16) i);\n}", "label": 0, "cwe": null, "length": 192 }, { "index": 40587, "code": "ca91cx42_VERR_irqhandler(struct vme_bridge *ca91cx42_bridge)\n{\n\tint val;\n\tstruct ca91cx42_driver *bridge;\n\n\tbridge = ca91cx42_bridge->driver_priv;\n\n\tval = ioread32(bridge->base + DGCS);\n\n\tif (!(val & 0x00000800)) {\n\t\tdev_err(ca91cx42_bridge->parent, \"ca91cx42_VERR_irqhandler DMA \"\n\t\t\t\"Read Error DGCS=%08X\\n\", val);\n\t}\n\n\treturn CA91CX42_LINT_VERR;\n}", "label": 0, "cwe": null, "length": 120 }, { "index": 138064, "code": "__repmgr_format_eid_loc(db_rep, conn, buffer)\n\tDB_REP *db_rep;\n\tREPMGR_CONNECTION *conn;\n\tchar *buffer;\n{\n\tint eid;\n\n\tif (conn->type == APP_CONNECTION)\n\t\tsnprintf(buffer,\n\t\t MAX_SITE_LOC_STRING, \"(application channel)\");\n\telse if (conn->type == REP_CONNECTION &&\n\t IS_VALID_EID(eid = conn->eid))\n\t\t(void)__repmgr_format_site_loc(SITE_FROM_EID(eid), buffer);\n\telse\n\t\tsnprintf(buffer, MAX_SITE_LOC_STRING, \"(unidentified site)\");\n\treturn (buffer);\n}", "label": 0, "cwe": null, "length": 124 }, { "index": 85572, "code": "LoadFunction(State state,\n Handle object,\n Handle key) {\n if (key->IsSymbol()) {\n return CallICBase::LoadFunction(state,\n Code::kNoExtraICState,\n object,\n Handle::cast(key));\n }\n\n if (object->IsUndefined() || object->IsNull()) {\n return TypeError(\"non_object_property_call\", object, key);\n }\n\n if (FLAG_use_ic && state != MEGAMORPHIC && object->IsHeapObject()) {\n int argc = target()->arguments_count();\n Heap* heap = Handle::cast(object)->GetHeap();\n Map* map = heap->non_strict_arguments_elements_map();\n if (object->IsJSObject() &&\n Handle::cast(object)->elements()->map() == map) {\n MaybeObject* maybe_code = isolate()->stub_cache()->ComputeCallArguments(\n argc, Code::KEYED_CALL_IC);\n Object* code;\n if (maybe_code->ToObject(&code)) {\n set_target(Code::cast(code));\n#ifdef DEBUG\n TraceIC(\"KeyedCallIC\", key, state, target());\n#endif\n }\n } else if (FLAG_use_ic && state != MEGAMORPHIC &&\n !object->IsAccessCheckNeeded()) {\n MaybeObject* maybe_code = isolate()->stub_cache()->ComputeCallMegamorphic(\n argc, Code::KEYED_CALL_IC, Code::kNoExtraICState);\n Object* code;\n if (maybe_code->ToObject(&code)) {\n set_target(Code::cast(code));\n#ifdef DEBUG\n TraceIC(\"KeyedCallIC\", key, state, target());\n#endif\n }\n }\n }\n\n HandleScope scope(isolate());\n Handle result = GetProperty(object, key);\n RETURN_IF_EMPTY_HANDLE(isolate(), result);\n\n // Make receiver an object if the callee requires it. Strict mode or builtin\n // functions do not wrap the receiver, non-strict functions and objects\n // called as functions do.\n ReceiverToObjectIfRequired(result, object);\n\n if (result->IsJSFunction()) return *result;\n result = Handle(TryCallAsFunction(*result));\n if (result->IsJSFunction()) return *result;\n\n return TypeError(\"property_not_function\", object, key);\n}", "label": 0, "cwe": null, "length": 491 }, { "index": 9129, "code": "fm10k_remove(struct pci_dev *pdev)\n{\n\tstruct fm10k_intfc *interface = pci_get_drvdata(pdev);\n\tstruct net_device *netdev = interface->netdev;\n\n\tdel_timer_sync(&interface->service_timer);\n\n\tset_bit(__FM10K_SERVICE_DISABLE, &interface->state);\n\tcancel_work_sync(&interface->service_task);\n\n\t/* free netdev, this may bounce the interrupts due to setup_tc */\n\tif (netdev->reg_state == NETREG_REGISTERED)\n\t\tunregister_netdev(netdev);\n\n\t/* cleanup timestamp handling */\n\tfm10k_ptp_unregister(interface);\n\n\t/* release VFs */\n\tfm10k_iov_disable(pdev);\n\n\t/* disable mailbox interrupt */\n\tfm10k_mbx_free_irq(interface);\n\n\t/* free interrupts */\n\tfm10k_clear_queueing_scheme(interface);\n\n\t/* remove any debugfs interfaces */\n\tfm10k_dbg_intfc_exit(interface);\n\n\tif (interface->sw_addr)\n\t\tiounmap(interface->sw_addr);\n\tiounmap(interface->uc_addr);\n\n\tfree_netdev(netdev);\n\n\tpci_release_selected_regions(pdev,\n\t\t\t\t pci_select_bars(pdev, IORESOURCE_MEM));\n\n\tpci_disable_pcie_error_reporting(pdev);\n\n\tpci_disable_device(pdev);\n}", "label": 0, "cwe": null, "length": 251 }, { "index": 21636, "code": "endElement(const XMLCh* const uri,\n const XMLCh* const localname,\n const XMLCh* const qname )\n\n{\n m_nEntityCounter = 0;\n\n if (GMLHandler::endElement() == OGRERR_NOT_ENOUGH_MEMORY)\n {\n throw SAXNotSupportedException(\"Out of memory\");\n }\n}", "label": 0, "cwe": null, "length": 77 }, { "index": 726170, "code": "midi_fm_volume(int voice, int volume)\n{\n int vol;\n\n if ((adlib_style&SIERRA_STYLE)==0) //sierra likes it loud!\n {\n vol=volume>>2;\n\n if ((adlib_style&LUCAS_STYLE)!=0)\n {\n if ((adlib_data[0xc0+voice]&1)==1)\n midi_write_adlib(0x40+adlib_opadd[voice], (unsigned char)((63-vol) |\n (adlib_data[0x40+adlib_opadd[voice]]&0xc0)));\n midi_write_adlib(0x43+adlib_opadd[voice], (unsigned char)((63-vol) |\n (adlib_data[0x43+adlib_opadd[voice]]&0xc0)));\n }\n else\n {\n if ((adlib_data[0xc0+voice]&1)==1)\n midi_write_adlib(0x40+adlib_opadd[voice], (unsigned char)((63-vol) |\n (adlib_data[0x40+adlib_opadd[voice]]&0xc0)));\n midi_write_adlib(0x43+adlib_opadd[voice], (unsigned char)((63-vol) |\n (adlib_data[0x43+adlib_opadd[voice]]&0xc0)));\n }\n }\n}", "label": 0, "cwe": null, "length": 300 }, { "index": 653404, "code": "updateGeometry() {\n if (m_window == 0)\n return;\n\n Window root;\n unsigned int border_width, depth;\n XGetGeometry(display(), m_window, &root, &m_x, &m_y,\n (unsigned int *)&m_width, (unsigned int *)&m_height,\n &border_width, &depth);\n m_depth = depth;\n}", "label": 0, "cwe": null, "length": 79 }, { "index": 974102, "code": "ms_sensors_ht_read_humidity(struct ms_ht_dev *dev_data,\n\t\t\t\tu32 *humidity)\n{\n\tint ret;\n\tu32 adc;\n\tu16 delay;\n\n\tmutex_lock(&dev_data->lock);\n\tdelay = ms_sensors_ht_h_conversion_time[dev_data->res_index];\n\tret = ms_sensors_convert_and_read(dev_data->client,\n\t\t\t\t\t MS_SENSORS_HT_H_CONVERSION_START,\n\t\t\t\t\t MS_SENSORS_NO_READ_CMD,\n\t\t\t\t\t delay, &adc);\n\tmutex_unlock(&dev_data->lock);\n\tif (ret)\n\t\treturn ret;\n\n\tif (!ms_sensors_crc_valid(adc)) {\n\t\tdev_err(&dev_data->client->dev,\n\t\t\t\"Humidity read crc check error\\n\");\n\t\treturn -ENODEV;\n\t}\n\n\t/* Humidity algorithm */\n\t*humidity = (((s32)(adc >> 8) * 12500) >> 16) * 10 - 6000;\n\tif (*humidity >= 100000)\n\t\t*humidity = 100000;\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 209 }, { "index": 479784, "code": "mtk_disp_pwm_enable(struct pwm_chip *chip, struct pwm_device *pwm)\n{\n\tstruct mtk_disp_pwm *mdp = to_mtk_disp_pwm(chip);\n\tint err;\n\n\terr = clk_enable(mdp->clk_main);\n\tif (err < 0)\n\t\treturn err;\n\n\terr = clk_enable(mdp->clk_mm);\n\tif (err < 0) {\n\t\tclk_disable(mdp->clk_main);\n\t\treturn err;\n\t}\n\n\tmtk_disp_pwm_update_bits(mdp, DISP_PWM_EN, PWM_ENABLE_MASK, 1);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 118 }, { "index": 105581, "code": "gnc_currency_edit_finalize (GObject *object)\n{\n GNCCurrencyEditPrivate *priv;\n GNCCurrencyEdit *period;\n\n g_return_if_fail (object != NULL);\n g_return_if_fail (GNC_IS_CURRENCY_EDIT (object));\n\n period = GNC_CURRENCY_EDIT(object);\n priv = GET_PRIVATE(period);\n\n g_free (priv->mnemonic);\n\n /* Do not free the private data structure itself. It is part of\n * a larger memory block allocated by the type system. */\n\n if (G_OBJECT_CLASS(parent_class)->finalize)\n (* G_OBJECT_CLASS(parent_class)->finalize) (object);\n}", "label": 0, "cwe": null, "length": 135 }, { "index": 552911, "code": "overlap(const FXExtentd& a,const FXExtentd& b){\n return a.upper.x>=b.lower.x && a.lower.x<=b.upper.x && a.upper.y>=b.lower.y && a.lower.y<=b.upper.y;\n }", "label": 0, "cwe": null, "length": 51 }, { "index": 731909, "code": "ipset_match_option(const char *arg, const char * const name[])\n{\n\tassert(arg);\n\tassert(name && name[0]);\n\n\t/* Skip two leading dashes */\n\tif (arg[0] == '-' && arg[1] == '-')\n\t\targ++, arg++;\n\n\treturn STREQ(arg, name[0]) ||\n\t (name[1] != NULL && STREQ(arg, name[1]));\n}", "label": 0, "cwe": null, "length": 82 }, { "index": 15028, "code": "pd4990a_process_command(void)\r\n{\r\n\tswitch(pd4990a_getcommand())\r\n\t{\r\n\t\tcase 0x1:\t//load output register\r\n\t\t\tbitno=0;\r\n\t\t\tif(reading)\r\n\t\t\t\tpd4990a_readbit();\t//prepare first bit\r\n\t\t\tshiftlo=0;\r\n\t\t\tshifthi=0;\r\n\t\t\tbreak;\r\n\t\tcase 0x2:\r\n\t\t\twritting=0;\t//store register to current date\r\n\t\t\tpd4990a_update_date();\r\n\t\t\tbreak;\r\n\t\tcase 0x3:\t//start reading\r\n\t\t\treading=1;\r\n\t\t\tbreak;\r\n\t\tcase 0x7:\t//switch testbit every frame\r\n\t\t\tmaxwaits=1;\r\n\t\t\tbreak;\r\n\t\tcase 0x8:\t//switch testbit every half-second\r\n\t\t\tmaxwaits=30;\r\n\t\t\tbreak;\r\n\t}\r\n}", "label": 0, "cwe": null, "length": 185 }, { "index": 758416, "code": "Ins_SDPVTL( INS_ARG )\n {\n Long A, B, C;\n Long p1, p2; /* was Int in pas type ERROR */\n\n p1 = args[1];\n p2 = args[0];\n\n if ( BOUNDS( p2, CUR.zp1.n_points ) ||\n BOUNDS( p1, CUR.zp2.n_points ) )\n {\n CUR.error = TT_Err_Invalid_Reference;\n return;\n }\n\n A = CUR.zp1.org_x[p2] - CUR.zp2.org_x[p1];\n B = CUR.zp1.org_y[p2] - CUR.zp2.org_y[p1];\n\n if ( (CUR.opcode & 1) != 0 )\n {\n C = B; /* CounterClockwise rotation */\n B = A;\n A = -C;\n }\n\n if ( NORMalize( A, B, &CUR.GS.dualVector ) == FAILURE )\n return;\n\n A = CUR.zp1.cur_x[p2] - CUR.zp2.cur_x[p1];\n B = CUR.zp1.cur_y[p2] - CUR.zp2.cur_y[p1];\n\n if ( (CUR.opcode & 1) != 0 )\n {\n C = B; /* CounterClockwise rotation */\n B = A;\n A = -C;\n }\n\n if ( NORMalize( A, B, &CUR.GS.projVector ) == FAILURE )\n return;\n\n COMPUTE_Funcs();\n }", "label": 0, "cwe": null, "length": 340 }, { "index": 483910, "code": "setseg(newseg)\nfastin_pt newseg;\n{\n if (newseg != curseg)\n {\n\tsegpos[curseg] = spos;\n\tspos = segpos[curseg = newseg];\n\tseekout(FILEHEADERLENGTH + (unsigned long) spos\n\t\t+ (unsigned long) segadj[curseg]);\n }\n}", "label": 0, "cwe": null, "length": 72 }, { "index": 124065, "code": "psendr(ppr, length, flags)\n\nchar\t\t\t*ppr;\nint4\t\t\tlength;\nint4\t\t\tflags;\n\n{\n\tstruct nmsg\tnhead;\t\t/* reply message */\n\n\tLAM_ZERO_ME(nhead);\n\tnhead.nh_node = pq.pq_src_node;\n\tnhead.nh_event = pq.pq_src_event;\n\tnhead.nh_type = 0;\n\tnhead.nh_flags = flags | NREEL;\n\tnhead.nh_length = length;\n\tnhead.nh_msg = ppr;\n\n\tif (nsend(&nhead)) lampanic(\"kenyad (nsend)\");\n}", "label": 0, "cwe": null, "length": 129 }, { "index": 964575, "code": "_evas_object_text_horiz_advance_get(const Evas_Object *obj,\n const Evas_Object_Text *o)\n{\n Evas_Object_Text_Item *it;\n Evas_Coord adv;\n (void) obj;\n\n adv = 0;\n EINA_INLIST_FOREACH(EINA_INLIST_GET(o->items), it)\n {\n adv += it->adv;\n }\n\n return adv;\n}", "label": 0, "cwe": null, "length": 86 }, { "index": 310716, "code": "gretl_matrix_add (const gretl_matrix *a, const gretl_matrix *b,\n\t\t gretl_matrix *c)\n{\n int rows = a->rows, cols = a->cols;\n int i, n;\n\n if (b->rows != rows || c->rows != rows ||\n\tb->cols != cols || c->cols != cols) {\n\tfprintf(stderr, \"gretl_matrix_add: non-conformable\\n\");\n\treturn E_NONCONF;\n }\n\n n = rows * cols;\n\n if (n < SIMD_MIN || is_block_matrix(a) || is_block_matrix(a) ||\n\tis_block_matrix(c)) {\n\t/* we can't assume suitable alignment of sub-matrices */\n\tfor (i=0; ival[i] = a->val[i] + b->val[i];\n\t}\n\treturn 0;\n }\n\n#if defined(USE_SIMD)\n gretl_matrix_simd_add(a, b, c);\n#else\n for (i=0; ival[i] = a->val[i] + b->val[i];\n }\n#endif\n\n return 0;\n}", "label": 0, "cwe": null, "length": 251 }, { "index": 169010, "code": "sleep_functions_on_battery_store(struct device *dev,\n\t\t\t\t\t\tstruct device_attribute *attr,\n\t\t\t\t\t\tconst char *buf, size_t count)\n{\n\tstruct toshiba_acpi_dev *toshiba = dev_get_drvdata(dev);\n\tu32 status;\n\tint value;\n\tint ret;\n\tint tmp;\n\n\tret = kstrtoint(buf, 0, &value);\n\tif (ret)\n\t\treturn ret;\n\n\t/*\n\t * Set the status of the function:\n\t * 0 - Disabled\n\t * 1-100 - Enabled\n\t */\n\tif (value < 0 || value > 100)\n\t\treturn -EINVAL;\n\n\tif (value == 0) {\n\t\ttmp = toshiba->usbsc_bat_level << HCI_MISC_SHIFT;\n\t\tstatus = tmp | SCI_USB_CHARGE_BAT_LVL_OFF;\n\t} else {\n\t\ttmp = value << HCI_MISC_SHIFT;\n\t\tstatus = tmp | SCI_USB_CHARGE_BAT_LVL_ON;\n\t}\n\tret = toshiba_sleep_functions_status_set(toshiba, status);\n\tif (ret < 0)\n\t\treturn ret;\n\n\ttoshiba->usbsc_bat_level = status >> HCI_MISC_SHIFT;\n\n\treturn count;\n}", "label": 0, "cwe": null, "length": 241 }, { "index": 367284, "code": "mono_class_inflate_generic_type_no_copy (MonoImage *image, MonoType *type, MonoGenericContext *context, MonoError *error)\n{\n\tMonoType *inflated = NULL; \n\n\tmono_error_init (error);\n\tif (context) {\n\t\tinflated = inflate_generic_type (image, type, context, error);\n\t\tif (!mono_error_ok (error))\n\t\t\treturn NULL;\n\t}\n\n\tif (!inflated)\n\t\treturn type;\n\n\tmono_stats.inflated_type_count++;\n\treturn inflated;\n}", "label": 0, "cwe": null, "length": 109 }, { "index": 31977, "code": "spawnPanel ( const ASCString& panelName )\n{\n if ( panelName == \"WindInfo\" ) {\n spawnPanel ( WindInfo );\n return true;\n }\n\n if ( panelName == \"UnitInfo\" ) {\n spawnPanel ( UnitInfo );\n return true;\n }\n \n if ( panelName == \"GuiIcons\" ) {\n spawnPanel ( ButtonPanel );\n return true;\n }\n\n if ( panelName == \"OverviewMap\" ) {\n spawnPanel ( OverviewMap );\n return true;\n }\n\n if ( panelName == \"MapInfo\" ) {\n spawnPanel ( MapControl );\n return true;\n }\n\n if ( panelName == \"ActionInfo\" ) {\n spawnPanel ( ActionInfo );\n return true;\n }\n \n return false;\n}", "label": 0, "cwe": null, "length": 169 }, { "index": 101371, "code": "isValid(FieldType type, int32_t width) {\n switch (type) {\n case HOUR:\n return (width == 1 || width == 2);\n case MINUTE:\n case SECOND:\n return (width == 2);\n default:\n U_ASSERT(FALSE);\n }\n return (width > 0);\n}", "label": 0, "cwe": null, "length": 71 }, { "index": 86386, "code": "draw_rectangle(struct cave *c, int y1, int x1, int y2, int x2, int feat)\n{\n\tint y, x;\n\n\tfor (y = y1; y <= y2; y++) {\n\t\tcave_set_feat(c, y, x1, feat);\n\t\tcave_set_feat(c, y, x2, feat);\n\t}\n\n\tfor (x = x1; x <= x2; x++) {\n\t\tcave_set_feat(c, y1, x, feat);\n\t\tcave_set_feat(c, y2, x, feat);\n\t}\n}", "label": 0, "cwe": null, "length": 124 }, { "index": 742619, "code": "f_float2nr(argvars, rettv)\n typval_T\t*argvars;\n typval_T\t*rettv;\n{\n float_T\tf;\n\n if (get_float_arg(argvars, &f) == OK)\n {\n\tif (f < -0x7fffffff)\n\t rettv->vval.v_number = -0x7fffffff;\n\telse if (f > 0x7fffffff)\n\t rettv->vval.v_number = 0x7fffffff;\n\telse\n\t rettv->vval.v_number = (varnumber_T)f;\n }\n else\n\trettv->vval.v_number = 0;\n}", "label": 0, "cwe": null, "length": 137 }, { "index": 260162, "code": "GC_debug_register_finalizer_unreachable\n (void * obj, GC_finalization_proc fn,\n void * cd, GC_finalization_proc *ofn,\n void * *ocd)\n{\n GC_finalization_proc my_old_fn = OFN_UNSET;\n void * my_old_cd;\n ptr_t base = GC_base(obj);\n if (0 == base) {\n /* We won't collect it, hence finalizer wouldn't be run. */\n if (ocd) *ocd = 0;\n if (ofn) *ofn = 0;\n return;\n }\n if ((ptr_t)obj - base != sizeof(oh)) {\n GC_err_printf(\n \"GC_debug_register_finalizer_unreachable called with \"\n \"non-base-pointer %p\\n\",\n obj);\n }\n if (0 == fn) {\n GC_register_finalizer_unreachable(base, 0, 0, &my_old_fn, &my_old_cd);\n } else {\n cd = GC_make_closure(fn, cd);\n if (cd == 0) return; /* out of memory */\n GC_register_finalizer_unreachable(base, GC_debug_invoke_finalizer,\n cd, &my_old_fn, &my_old_cd);\n }\n store_old(obj, my_old_fn, (struct closure *)my_old_cd, ofn, ocd);\n}", "label": 0, "cwe": null, "length": 289 }, { "index": 227867, "code": "vxge_search_mac_addr_in_list(\n\tstruct vxge_vpath *vpath, u64 del_mac)\n{\n\tstruct list_head *entry, *next;\n\tlist_for_each_safe(entry, next, &vpath->mac_addr_list) {\n\t\tif (((struct vxge_mac_addrs *)entry)->macaddr == del_mac)\n\t\t\treturn TRUE;\n\t}\n\treturn FALSE;\n}", "label": 0, "cwe": null, "length": 78 }, { "index": 498455, "code": "entryname(wstring_ty *s)\n{\n wchar_t *start;\n wchar_t *finish;\n wchar_t *cp;\n wchar_t prev;\n\n start = s->wstr_text;\n finish = s->wstr_text;\n prev = '/';\n cp = s->wstr_text;\n for (;;)\n {\n if (prev == '/')\n {\n if (*cp != '/' && *cp != 0)\n start = cp;\n }\n else\n {\n if (*cp == '/' || *cp == 0)\n finish = cp;\n }\n if (!*cp)\n break;\n prev = *cp++;\n }\n return wstr_n_from_wc(start, finish - start);\n}", "label": 1, "cwe": "CWE-other", "length": 158 }, { "index": 588435, "code": "bfa_ioc_sm_fail(struct bfa_ioc *ioc, enum ioc_event event)\n{\n\tswitch (event) {\n\tcase IOC_E_ENABLE:\n\t\tioc->cbfn->enable_cbfn(ioc->bfa, BFA_STATUS_IOC_FAILURE);\n\t\tbreak;\n\n\tcase IOC_E_DISABLE:\n\t\tbfa_fsm_set_state(ioc, bfa_ioc_sm_disabling);\n\t\tbreak;\n\n\tcase IOC_E_DETACH:\n\t\tbfa_fsm_set_state(ioc, bfa_ioc_sm_uninit);\n\t\tbfa_iocpf_stop(ioc);\n\t\tbreak;\n\n\tcase IOC_E_HWERROR:\n\t\t/* HB failure notification, ignore. */\n\t\tbreak;\n\n\tdefault:\n\t\tbfa_sm_fault(event);\n\t}\n}", "label": 0, "cwe": null, "length": 149 }, { "index": 101683, "code": "linkIds() const\n{\n if (d->m_PersonalLkId != -1) {\n return QList() << d->m_LkIds << d->m_PersonalLkId;\n }\n return QList() << d->m_LkIds;\n}", "label": 0, "cwe": null, "length": 63 }, { "index": 405244, "code": "e_book_backend_summary_search (EBookBackendSummary *summary,\n const gchar *query)\n{\n\tESExp *sexp;\n\tESExpResult *r;\n\tGPtrArray *retval;\n\tgint i;\n\tgint esexp_error;\n\n\tg_return_val_if_fail (summary != NULL, NULL);\n\n\tsexp = e_sexp_new ();\n\n\tfor (i = 0; i < G_N_ELEMENTS (symbols); i++) {\n\t\tif (symbols[i].type == 1) {\n\t\t\te_sexp_add_ifunction (sexp, 0, symbols[i].name,\n\t\t\t\t\t (ESExpIFunc *) symbols[i].func, summary);\n\t\t} else {\n\t\t\te_sexp_add_function (\n\t\t\t\tsexp, 0, symbols[i].name,\n\t\t\t\tsymbols[i].func, summary);\n\t\t}\n\t}\n\n\te_sexp_input_text (sexp, query, strlen (query));\n\tesexp_error = e_sexp_parse (sexp);\n\n\tif (esexp_error == -1) {\n\t\treturn NULL;\n\t}\n\n\tretval = g_ptr_array_new ();\n\tr = e_sexp_eval (sexp);\n\n\tif (r && r->type == ESEXP_RES_ARRAY_PTR && r->value.ptrarray) {\n\t\tGPtrArray *ptrarray = r->value.ptrarray;\n\t\tgint i;\n\n\t\tfor (i = 0; i < ptrarray->len; i++)\n\t\t\tg_ptr_array_add (retval, g_ptr_array_index (ptrarray, i));\n\t}\n\n\te_sexp_result_free (sexp, r);\n\n\te_sexp_unref (sexp);\n\n\treturn retval;\n}", "label": 0, "cwe": null, "length": 335 }, { "index": 855586, "code": "createVLIWDAGScheduler(SelectionDAGISel *IS, CodeGenOpt::Level) {\n return new ScheduleDAGVLIW(*IS->MF, IS->AA, new ResourcePriorityQueue(IS));\n}", "label": 0, "cwe": null, "length": 48 }, { "index": 710463, "code": "grammar_start_symbol_set (symbol *sym, location loc)\n{\n if (start_flag)\n complain (&loc, complaint, _(\"multiple %s declarations\"), \"%start\");\n else\n {\n start_flag = true;\n startsymbol = sym;\n startsymbol_location = loc;\n }\n}", "label": 0, "cwe": null, "length": 63 }, { "index": 69923, "code": "displaymessage(struct mame_bitmap *bitmap,const char *text)\r\n{\r\n\tstruct DisplayText dt[2];\r\n\tint avail;\r\n\r\n\r\n\tif (uirotwidth < uirotcharwidth * strlen(text))\r\n\t{\r\n\t\tui_displaymessagewindow(bitmap,text);\r\n\t\treturn;\r\n\t}\r\n\r\n\tavail = strlen(text)+2;\r\n\r\n\tui_drawbox(bitmap,(uirotwidth - uirotcharwidth * avail) / 2,\r\n\t\t\tuirotheight - 3*uirotcharheight,\r\n\t\t\tavail * uirotcharwidth,\r\n\t\t\t2*uirotcharheight);\r\n\r\n\tdt[0].text = text;\r\n\tdt[0].color = UI_COLOR_NORMAL;\r\n\tdt[0].x = (uirotwidth - uirotcharwidth * strlen(text)) / 2;\r\n\tdt[0].y = uirotheight - 5*uirotcharheight/2;\r\n\tdt[1].text = 0; /* terminate array */\r\n\tdisplaytext(bitmap,dt);\r\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 198 }, { "index": 981360, "code": "integer_to_byte()\n{\n fprintf(out, \" ; integer_to_byte() (sign extend)\\n\");\n\n if (stack > 0)\n {\n fprintf(out, \" mov ebx, [esp]\\n\");\n fprintf(out, \" movsx ebx, bl\\n\");\n fprintf(out, \" mov [esp], ebx\\n\");\n }\n else\n {\n fprintf(out, \" movsx %s, %s\\n\", REG_STACK(reg-1), REG_STACK8(reg-1));\n }\n\n return 0;\n}", "label": 0, "cwe": null, "length": 116 }, { "index": 182857, "code": "slotSaveFormatList()\n{\n if( !m_formatListModified )\n return;\n\n QStringList presets;\n int n = m_presetCombo->count();\n int current_idx = m_presetCombo->currentIndex();\n\n for( int i = 0; i < n; ++i )\n {\n QString item;\n if( i == current_idx )\n item = \"%1#DELIM#%2#DELIM#selected\";\n else\n item = \"%1#DELIM#%2\";\n\n QString scheme = m_presetCombo->itemData( i ).toString();\n QString label = m_presetCombo->itemText( i );\n item = item.arg( label, scheme );\n presets.append( item );\n }\n\n Amarok::config( m_configCategory ).writeEntry( QString::fromLatin1( \"Format Presets\" ), presets );\n}", "label": 0, "cwe": null, "length": 184 }, { "index": 24880, "code": "mi_mmap_pwrite(MI_INFO *info, const uchar *Buffer,\n size_t Count, my_off_t offset, myf MyFlags)\n{\n DBUG_PRINT(\"info\", (\"mi_write with mmap %d\\n\", info->dfile));\n if (info->s->concurrent_insert)\n mysql_rwlock_rdlock(&info->s->mmap_lock);\n\n /*\n The following test may fail in the following cases:\n - We failed to remap a memory area (fragmented memory?)\n - This thread has done some writes, but not yet extended the\n memory mapped area.\n */\n\n if (info->s->mmaped_length >= offset + Count)\n {\n memcpy(info->s->file_map + offset, Buffer, Count); \n if (info->s->concurrent_insert)\n mysql_rwlock_unlock(&info->s->mmap_lock);\n return 0;\n }\n else\n {\n info->s->nonmmaped_inserts++;\n if (info->s->concurrent_insert)\n mysql_rwlock_unlock(&info->s->mmap_lock);\n return mysql_file_pwrite(info->dfile, Buffer, Count, offset, MyFlags);\n }\n\n}", "label": 0, "cwe": null, "length": 258 }, { "index": 784681, "code": "test_bsaindexentry()\n{\n bsaindexentry bie(\"test\", 1, 2, true);\n\n bie.set_name(\"XYZZY\");\n std::cout << bie.to_string() << std::endl;\n}", "label": 0, "cwe": null, "length": 51 }, { "index": 894653, "code": "get_endobs (char *datestr, int startyr, int startfrac, \n\t\t int pd, int n)\n{\n int endyr, endfrac; \n\n endyr = startyr + n / pd;\n endfrac = startfrac - 1 + n % pd;\n\n if (endfrac >= pd) {\n\tendyr++;\n\tendfrac -= pd;\n }\n\n if (endfrac == 0) {\n\tendyr--;\n\tendfrac = pd;\n } \n \n if (pd == 1) {\n\tsprintf(datestr, \"%d\", endyr);\n } else if (pd == 4) {\n\tsprintf(datestr, \"%d.%d\", endyr, endfrac);\n } else if (pd == 12 || pd == 52) {\n\tsprintf(datestr, \"%d.%02d\", endyr, endfrac);\n }\n\n return 0;\n}", "label": 0, "cwe": null, "length": 187 }, { "index": 150089, "code": "file_is_opened(const char *o_path)\n{\n int i;\n\n\n for(i=0; ifilename, o_path))\n {\n return(1);\n }\n }\n\n return(0);\n}", "label": 0, "cwe": null, "length": 63 }, { "index": 974079, "code": "DrawDashedWedge (int x, int y, int tx, int ty, int active,int color)\n/* draws the dashed wedge for a bond behind the image plane */\n{\n int i, xlen, ylen;\n GdkGC *thegc;\n int len;\n float step,factor;\n \n if (xbmflag)\n thegc = drawing_area->style->black_gc;\n else if (active)\n thegc = hlgc;\n else \n thegc= mygc[color];\n \n xlen = tx - x;\n ylen = ty - y;\n\nlen=(int) rint(calc_vector(abs(xlen),abs(ylen))/8.);\nif (len<8) len=8;\n step = 1./len;\n factor=0.0125;\n if (len>20) factor= 0.00125;\n if (len==8) {\n factor =0.03;\n }\n for (i = 1; i < len; i++)\n gdk_draw_line (picture, thegc,\n\t\t (x + step * i * xlen - factor * ylen * i) * size_factor,\n\t\t (y + step * i * ylen + factor * xlen * i) * size_factor,\n\t\t (x + step * i * xlen + factor * ylen * i) * size_factor,\n\t\t (y + step * i * ylen - factor * xlen * i) * size_factor);\n}", "label": 0, "cwe": null, "length": 312 }, { "index": 919212, "code": "checkStyle(GLEFont* child) {\n\tif (m_Bold.get() == child) {\n\t\treturn GLEFontStyleBold;\n\t} else if (m_Italic.get() == child) {\n\t\treturn GLEFontStyleItalic;\n\t} else if (m_BoldItalic.get() == child) {\n\t\treturn GLEFontStyleBoldItalic;\n\t} else {\n\t\treturn GLEFontStyleRoman;\n\t}\n}", "label": 0, "cwe": null, "length": 90 }, { "index": 576746, "code": "Csec_server_get_client_vo(Csec_context_t *ctx) {\n SAVE_ERR;\n Csec_clear_errmsg();\n if (ctx == NULL) {\n serrno = EINVAL;\n return NULL;\n }\n RESTORE_ERR(0);\n return ctx->voname;\n}", "label": 0, "cwe": null, "length": 62 }, { "index": 30977, "code": "pkey_dh_init(EVP_PKEY_CTX *ctx)\n\t{\n\tDH_PKEY_CTX *dctx;\n\tdctx = OPENSSL_malloc(sizeof(DH_PKEY_CTX));\n\tif (!dctx)\n\t\treturn 0;\n\tdctx->prime_len = 1024;\n\tdctx->generator = 2;\n\tdctx->use_dsa = 0;\n\n\tctx->data = dctx;\n\tctx->keygen_info = dctx->gentmp;\n\tctx->keygen_info_count = 2;\n\t\n\treturn 1;\n\t}", "label": 0, "cwe": null, "length": 112 }, { "index": 88498, "code": "AlphaMultiplyARGB(WebPPicture* const pic, int inverse) {\n uint32_t* ptr = pic->argb;\n int y;\n for (y = 0; y < pic->height; ++y) {\n WebPMultARGBRow(ptr, pic->width, inverse);\n ptr += pic->argb_stride;\n }\n}", "label": 0, "cwe": null, "length": 77 }, { "index": 100582, "code": "unity_protocol_activation_reply_raw_copy (const UnityProtocolActivationReplyRaw* self, UnityProtocolActivationReplyRaw* dest) {\n\tconst gchar* _tmp0_ = NULL;\n\tgchar* _tmp1_ = NULL;\n\tguint _tmp2_ = 0U;\n\tGHashTable* _tmp3_ = NULL;\n\tGHashTable* _tmp4_ = NULL;\n\t_tmp0_ = (*self).uri;\n\t_tmp1_ = g_strdup (_tmp0_);\n\t_g_free0 ((*dest).uri);\n\t(*dest).uri = _tmp1_;\n\t_tmp2_ = (*self).handled;\n\t(*dest).handled = _tmp2_;\n\t_tmp3_ = (*self).hints;\n\t_tmp4_ = _g_hash_table_ref0 (_tmp3_);\n\t_g_hash_table_unref0 ((*dest).hints);\n\t(*dest).hints = _tmp4_;\n}", "label": 0, "cwe": null, "length": 184 }, { "index": 350449, "code": "process_dump(struct request *r)\n{\n\tFILE *f;\n\tint fd, fd2;\n\tchar name[32];\n\n\tif (r->method != M_GET && r->method != M_HEAD) {\n\t\tr->status = 405;\n\t\treturn 0;\n\t}\n\tif (r->path_args[0]) {\n\t\tr->error_file = r->c->error_404_file;\n\t\tr->status = 404;\n\t\treturn 1;\n\t}\n\tstrcpy(name, \"/tmp/mathop-dump.XXXXXXXX\");\n\tfd = mkstemp(name);\n\tif (fd == -1) {\n\t\tr->status = 500;\n\t\treturn 0;\n\t}\n\tfcntl(fd, F_SETFD, FD_CLOEXEC);\n\tif (remove(name) == -1) {\n\t\tlog_d(\"cannot remove temporary file %s\", name);\n\t\tlerror(\"remove\");\n\t\tclose(fd);\n\t\tr->status = 500;\n\t\treturn 0;\n\t}\n\tfd2 = dup(fd);\n\tif (fd2 == -1) {\n\t\tlerror(\"dup\");\n\t\tclose(fd);\n\t\tr->status = 500;\n\t\treturn 0;\n\t}\n\tfcntl(fd2, F_SETFD, FD_CLOEXEC);\n\tf = fdopen(fd2, \"a+\");\n\tif (f == 0) {\n\t\tlog_d(\"dump: failed to associate stream with descriptor %d\", fd2);\n\t\tclose(fd2);\n\t\tclose(fd);\n\t\tr->status = 500;\n\t\treturn 0;\n\t}\n\tfdump(f);\n\tif (fclose(f) == EOF) {\n\t\tlerror(\"fclose\");\n\t\tclose(fd2);\n\t\tclose(fd);\n\t\tr->status = 500;\n\t\treturn 0;\n\t}\n\tif (fstat(fd, &r->finfo) == -1) {\n\t\tlerror(\"fstat\");\n\t\tclose(fd);\n\t\tr->status = 500;\n\t\treturn 0;\n\t}\n\tr->content_length = r->finfo.st_size;\n\tr->last_modified = r->finfo.st_mtime;\n\tif (r->method == M_GET) {\n\t\tlseek(fd, 0, SEEK_SET);\n\t\tr->cn->file_offset = 0;\n\t\tr->cn->rfd = fd;\n\t} else\n\t\tclose(fd);\n\tr->content_type = \"text/plain\";\n\tr->num_content = 0;\n\tr->status = 200;\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 503 }, { "index": 113050, "code": "get_drive_parameters_without_extensions(struct driveinfo *drive_info)\n{\n com32sys_t getparm, parm;\n\n memset(&getparm, 0, sizeof getparm);\n memset(&parm, 0, sizeof parm);\n\n /* Ralf Brown recommends setting ES:DI to 0:0 */\n getparm.esi.w[0] = 0;\n getparm.ds = 0;\n getparm.edx.b[0] = drive_info->disk;\n getparm.eax.b[1] = 0x08;\n\n __intcall(0x13, &getparm, &parm);\n\n /* CF set on error */\n if (parm.eflags.l & EFLAGS_CF)\n\treturn parm.eax.b[1];\n\n /* DL contains the maximum drive number (it starts at 0) */\n drive_info->legacy_max_drive = parm.edx.b[0];\n\n // XXX broken\n /* Drive specified greater than the bumber of attached drives */\n //if (drive_info->disk > drive_info->drives)\n // return -1;\n\n drive_info->legacy_type = parm.ebx.b[0];\n\n /* DH contains the maximum head number (it starts at 0) */\n drive_info->legacy_max_head = parm.edx.b[1];\n\n /* Maximum sector number (bits 5-0) per track */\n drive_info->legacy_sectors_per_track = parm.ecx.b[0] & 0x3f;\n\n /*\n * Maximum cylinder number:\n * CH = low eight bits of maximum cylinder number\n * CL = high two bits of maximum cylinder number (bits 7-6)\n */\n drive_info->legacy_max_cylinder = parm.ecx.b[1] +\n\t((parm.ecx.b[0] & 0xc0) << 2);\n\n if (drive_info->legacy_sectors_per_track > 0)\n\tdrive_info->cbios = 1;\t/* Valid geometry */\n\n return 0;\n}", "label": 0, "cwe": null, "length": 427 }, { "index": 115951, "code": "channel_is_valid(RTPClient *rtp, RTPStream *ch)\n{\n\tu32 i=0;\n\tRTPStream *st;\n\twhile ((st = (RTPStream *)gf_list_enum(rtp->channels, &i))) {\n\t\tif (st == ch) return 1;\n\t}\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 68 }, { "index": 104969, "code": "esc_enc_len(const char *src, unsigned srclen)\n{\n\tconst char *end = src + srclen;\n\tint\t\t\tlen = 0;\n\n\twhile (src < end)\n\t{\n\t\tif (*src == '\\0')\n\t\t\tlen += 4;\n\t\telse if (*src == '\\\\')\n\t\t\tlen += 2;\n\t\telse\n\t\t\tlen++;\n\n\t\tsrc++;\n\t}\n\n\treturn len;\n}", "label": 0, "cwe": null, "length": 84 }, { "index": 96228, "code": "sigmaKin() {\n\n // Check if at least one RPV coupling non-zero\n if(!coupSUSYPtr->isUDD) {\n sigBW = 0.0;\n return;\n }\n\n mRes = particleDataPtr->m0(abs(idRes));\n GammaRes = particleDataPtr->mWidth(abs(idRes));\n m2Res = pow2(mRes);\n \n sigBW = sH * GammaRes/ ( pow2(sH - m2Res) + pow2(mRes * GammaRes) );\n sigBW *= 2.0/3.0/mRes;\n\n // Width out only includes open channels. \n widthOut = GammaRes * particleDataPtr->resOpenFrac(id3);\n}", "label": 0, "cwe": null, "length": 163 }, { "index": 622341, "code": "operator<< ( QDataStream & s, const KFileItem & a )\n{\n if (a.d) {\n // We don't need to save/restore anything that refresh() invalidates,\n // since that means we can re-determine those by ourselves.\n s << a.d->m_url;\n s << a.d->m_strName;\n s << a.d->m_strText;\n } else {\n s << KUrl();\n s << QString();\n s << QString();\n }\n\n return s;\n}", "label": 0, "cwe": null, "length": 111 }, { "index": 339345, "code": "xmms_collection_unreference (xmms_coll_dag_t *dag, const gchar *name, guint nsid)\n{\n\txmmsv_coll_t *existing, *active_pl;\n\tgboolean retval = FALSE;\n\n\texisting = g_hash_table_lookup (dag->collrefs[nsid], name);\n\tactive_pl = g_hash_table_lookup (dag->collrefs[XMMS_COLLECTION_NSID_PLAYLISTS],\n\t XMMS_ACTIVE_PLAYLIST);\n\n\t/* Unref if collection exists, and is not pointed at by _active playlist */\n\tif (existing != NULL && existing != active_pl) {\n\t\tconst gchar *matchkey;\n\t\tconst gchar *nsname = xmms_collection_get_namespace_string (nsid);\n\t\tcoll_rebind_infos_t infos = { name, nsname, existing, NULL };\n\n\t\t/* FIXME: if reference pointed to by a label, we should update\n\t\t * the label to point to the ref'd operator instead ! */\n\n\t\t/* Strip all references to the deleted coll, bind operator directly */\n\t\txmms_collection_apply_to_all_collections (dag, strip_references, &infos);\n\n\t\t/* Remove all pairs pointing to that collection */\n\t\twhile ((matchkey = xmms_collection_find_alias (dag, nsid,\n\t\t existing, NULL)) != NULL) {\n\n\t\t\tXMMS_COLLECTION_CHANGED_MSG (XMMS_COLLECTION_CHANGED_REMOVE,\n\t\t\t matchkey,\n\t\t\t nsname);\n\n\t\t\tg_hash_table_remove (dag->collrefs[nsid], matchkey);\n\t\t}\n\n\t\tretval = TRUE;\n\t}\n\n\treturn retval;\n}", "label": 0, "cwe": null, "length": 324 }, { "index": 817084, "code": "cpu_write_( hes_addr_t addr, int data )\n{\n\tif ( unsigned (addr - apu.start_addr) <= apu.end_addr - apu.start_addr )\n\t{\n\t\tGME_APU_HOOK( this, addr - apu.start_addr, data );\n\t\t// avoid going way past end when a long block xfer is writing to I/O space\n\t\thes_time_t t = min( time(), end_time() + 8 );\n\t\tapu.write_data( t, addr, data );\n\t\treturn;\n\t}\n\n\thes_time_t time = this->time();\n\tswitch ( addr )\n\t{\n\tcase 0x0000:\n\tcase 0x0002:\n\tcase 0x0003:\n\t\tcpu_write_vdp( addr, data );\n\t\treturn;\n\n\tcase 0x0C00: {\n\t\trun_until( time );\n\t\ttimer.raw_load = (data & 0x7F) + 1;\n\t\trecalc_timer_load();\n\t\ttimer.count = timer.load;\n\t\tbreak;\n\t}\n\n\tcase 0x0C01:\n\t\tdata &= 1;\n\t\tif ( timer.enabled == data )\n\t\t\treturn;\n\t\trun_until( time );\n\t\ttimer.enabled = data;\n\t\tif ( data )\n\t\t\ttimer.count = timer.load;\n\t\tbreak;\n\n\tcase 0x1402:\n\t\trun_until( time );\n\t\tirq.disables = data;\n\t\tif ( (data & 0xF8) && (data & 0xF8) != 0xF8 ) // flag questionable values\n\t\t\tdebug_printf( \"Int mask: $%02X\\n\", data );\n\t\tbreak;\n\n\tcase 0x1403:\n\t\trun_until( time );\n\t\tif ( timer.enabled )\n\t\t\ttimer.count = timer.load;\n\t\ttimer.fired = false;\n\t\tbreak;\n\n#ifndef NDEBUG\n\tcase 0x1000: // I/O port\n\tcase 0x0402: // palette\n\tcase 0x0403:\n\tcase 0x0404:\n\tcase 0x0405:\n\t\treturn;\n\n\tdefault:\n\t\tdebug_printf( \"unmapped write $%04X <- $%02X\\n\", addr, data );\n\t\treturn;\n#endif\n\t}\n\n\tirq_changed();\n}", "label": 0, "cwe": null, "length": 457 }, { "index": 656180, "code": "do_jump_by_parts_greater (tree treeop0, tree treeop1, int swap,\n\t\t\t rtx if_false_label, rtx if_true_label, int prob)\n{\n rtx op0 = expand_normal (swap ? treeop1 : treeop0);\n rtx op1 = expand_normal (swap ? treeop0 : treeop1);\n enum machine_mode mode = TYPE_MODE (TREE_TYPE (treeop0));\n int unsignedp = TYPE_UNSIGNED (TREE_TYPE (treeop0));\n\n do_jump_by_parts_greater_rtx (mode, unsignedp, op0, op1, if_false_label,\n\t\t\t\tif_true_label, prob);\n}", "label": 0, "cwe": null, "length": 138 }, { "index": 91056, "code": "cxxabs (double ar, double ai)\n{\tif (ar==0.0) return fabs(ai);\n\tif (ai==0.0) return fabs(ar);\n\treturn sqrt(ai*ai+ar*ar);\n}", "label": 0, "cwe": null, "length": 46 }, { "index": 837028, "code": "GetNextStyle()\n{\n const char *pszDash = NULL;\n const char *pszOutput = NULL;\n\n while( iNextStyle < CSLCount(m_papszStyleTable) )\n {\n\n if ( NULL == (pszOutput = CSLGetField(m_papszStyleTable,iNextStyle++)))\n continue;\n\n pszDash = strstr(pszOutput,\":\");\n\n int nColon;\n\n osLastRequestedStyleName = pszOutput;\n nColon = osLastRequestedStyleName.find( ':' );\n if( nColon != -1 )\n osLastRequestedStyleName = \n osLastRequestedStyleName.substr(0,nColon);\n\n if (pszDash)\n return pszDash + 1;\n }\n return NULL;\n}", "label": 0, "cwe": null, "length": 158 }, { "index": 98829, "code": "ion_system_heap_allocate(struct ion_heap *heap,\n\t\t\t\t struct ion_buffer *buffer,\n\t\t\t\t unsigned long size, unsigned long align,\n\t\t\t\t unsigned long flags)\n{\n\tstruct ion_system_heap *sys_heap = container_of(heap,\n\t\t\t\t\t\t\tstruct ion_system_heap,\n\t\t\t\t\t\t\theap);\n\tstruct sg_table *table;\n\tstruct scatterlist *sg;\n\tstruct list_head pages;\n\tstruct page *page, *tmp_page;\n\tint i = 0;\n\tunsigned long size_remaining = PAGE_ALIGN(size);\n\tunsigned int max_order = orders[0];\n\n\tif (align > PAGE_SIZE)\n\t\treturn -EINVAL;\n\n\tif (size / PAGE_SIZE > totalram_pages / 2)\n\t\treturn -ENOMEM;\n\n\tINIT_LIST_HEAD(&pages);\n\twhile (size_remaining > 0) {\n\t\tpage = alloc_largest_available(sys_heap, buffer, size_remaining,\n\t\t\t\t\t\tmax_order);\n\t\tif (!page)\n\t\t\tgoto free_pages;\n\t\tlist_add_tail(&page->lru, &pages);\n\t\tsize_remaining -= PAGE_SIZE << compound_order(page);\n\t\tmax_order = compound_order(page);\n\t\ti++;\n\t}\n\ttable = kmalloc(sizeof(struct sg_table), GFP_KERNEL);\n\tif (!table)\n\t\tgoto free_pages;\n\n\tif (sg_alloc_table(table, i, GFP_KERNEL))\n\t\tgoto free_table;\n\n\tsg = table->sgl;\n\tlist_for_each_entry_safe(page, tmp_page, &pages, lru) {\n\t\tsg_set_page(sg, page, PAGE_SIZE << compound_order(page), 0);\n\t\tsg = sg_next(sg);\n\t\tlist_del(&page->lru);\n\t}\n\n\tbuffer->priv_virt = table;\n\treturn 0;\n\nfree_table:\n\tkfree(table);\nfree_pages:\n\tlist_for_each_entry_safe(page, tmp_page, &pages, lru)\n\t\tfree_buffer_page(sys_heap, buffer, page);\n\treturn -ENOMEM;\n}", "label": 0, "cwe": null, "length": 374 }, { "index": 232850, "code": "_combobox_separator_func(GtkTreeModel *model,\n\t\tGtkTreeIter *iter, gpointer data)\n{\n\tgchar *txt = NULL;\n\n\tcm_return_val_if_fail(model != NULL, FALSE);\n\n\tgtk_tree_model_get(model, iter, COMBOBOX_TEXT, &txt, -1);\n\n\tif( txt == NULL )\n\t\treturn TRUE;\n\treturn FALSE;\n}", "label": 0, "cwe": null, "length": 73 }, { "index": 125676, "code": "SFgetDir (SFDir *dir) {\n SFEntry *result = NULL;\n int alloc = 0;\n int i;\n DIR *dirp;\n struct dirent *dp;\n char *str;\n int len;\n int maxChars;\n struct stat statBuf;\n\n maxChars = strlen (dir->dir) - 1;\n dir->entries = NULL;\n dir->nEntries = 0;\n dir->nChars = 0;\n result = NULL;\n i = 0;\n dirp = opendir (\".\");\n if (!dirp) {\n return 1;\n }\n stat (\".\", &statBuf);\n dir->mtime = statBuf.st_mtime;\n readdir (dirp); /* throw away \".\" */\n\n#ifndef S_IFLNK\n readdir (dirp); /* throw away \"..\" */\n#endif /* ndef S_IFLNK */\n\n while ((dp = readdir (dirp))) {\n if (i >= alloc) {\n alloc = 2 * (alloc + 1);\n result = (SFEntry *) XtRealloc (\n (char *) result, (unsigned) (alloc * sizeof (SFEntry))\n );\n }\n result[i].statDone = 0;\n str = dp->d_name;\n len = strlen (str);\n result[i].real = XtMalloc ((unsigned) (len + 2));\n strcat (strcpy (result[i].real, str), \" \");\n if (len > maxChars) {\n maxChars = len;\n }\n result[i].shown = result[i].real;\n i++;\n }\n\n#if defined (SVR4) || defined (SYSV) || defined (USG)\n qsort ((char *) result, (unsigned) i, sizeof (SFEntry), SFcompareEntries);\n#else /* defined (SVR4) || defined (SYSV) || defined (USG) */\n qsort ((char *) result, i, sizeof (SFEntry), SFcompareEntries);\n#endif /* defined (SVR4) || defined (SYSV) || defined (USG) */\n\n dir->entries = result;\n dir->nEntries = i;\n dir->nChars = maxChars + 1;\n closedir (dirp);\n return 0;\n}", "label": 0, "cwe": null, "length": 495 }, { "index": 810401, "code": "trigger_redraw(ViewHelper *priv,\n GeglRectangle *rect,\n GeglGtkView *view)\n{\n if (rect->width < 0 || rect->height < 0)\n gtk_widget_queue_draw(GTK_WIDGET(view));\n else\n gtk_widget_queue_draw_area(GTK_WIDGET(view),\n rect->x, rect->y, rect->width, rect->height);\n}", "label": 0, "cwe": null, "length": 82 }, { "index": 62081, "code": "backupcopy_skip_root(gchar *filename)\n{\n\t/* first skip the root (e.g. c:\\ on windows) */\n\tconst gchar *dir = g_path_skip_root(filename);\n\n\t/* if this has failed, use the filename again */\n\tif (dir == NULL)\n\t\tdir = filename;\n\t/* check again for leading / or \\ */\n\twhile (*dir == G_DIR_SEPARATOR)\n\t\tdir++;\n\n\treturn (gchar *) dir;\n}", "label": 0, "cwe": null, "length": 90 }, { "index": 87756, "code": "mark_clusters(graph_t * g)\n{\n int c;\n node_t *n, *nn, *vn;\n edge_t *orig, *e;\n graph_t *clust;\n\n /* remove sub-clusters below this level */\n for (n = agfstnode(g); n; n = agnxtnode(g, n)) {\n\tif (ND_ranktype(n) == CLUSTER)\n\t UF_singleton(n);\n\tND_clust(n) = NULL;\n }\n\n for (c = 1; c <= GD_n_cluster(g); c++) {\n\tclust = GD_clust(g)[c];\n\tfor (n = agfstnode(clust); n; n = nn) {\n\t\tnn = agnxtnode(clust,n);\n\t if (ND_ranktype(n) != NORMAL) {\n\t\tagerr(AGWARN,\n\t\t \"%s was already in a rankset, deleted from cluster %s\\n\",\n\t\t agnameof(n), agnameof(g));\n\t\tagdelete(clust,n);\n\t\tcontinue;\n\t }\n\t UF_setname(n, GD_leader(clust));\n\t ND_clust(n) = clust;\n\t ND_ranktype(n) = CLUSTER;\n\n\t /* here we mark the vnodes of edges in the cluster */\n\t for (orig = agfstout(clust, n); orig;\n\t\t orig = agnxtout(clust, orig)) {\n\t\tif ((e = ED_to_virt(orig))) {\n\t\t while (e && ND_node_type(vn =aghead(e)) == VIRTUAL) {\n\t\t\tND_clust(vn) = clust;\n\t\t\te = ND_out(aghead(e)).list[0];\n\t\t\t/* trouble if concentrators and clusters are mixed */\n\t\t }\n\t\t}\n\t }\n\t}\n }\n}", "label": 0, "cwe": null, "length": 371 }, { "index": 507832, "code": "transchar(c)\nint c;\n{\n\tif (c == '+') return('`');\n\tif (c == ',') return('\\'');\n\tif (c == '[') return('&');\n\tif (c == '.') return('$');\n\n\treturn('\\0');\n}", "label": 0, "cwe": null, "length": 51 }, { "index": 500762, "code": "SN_StartSequence(mobj_t * mobj, int sequence)\n{\n seqnode_t *node;\n\n SN_StopSequence(mobj); // Stop any previous sequence\n node = (seqnode_t *) Z_Malloc(sizeof(seqnode_t), PU_STATIC, NULL);\n node->sequencePtr = SequenceData[SequenceTranslate[sequence].scriptNum];\n node->sequence = sequence;\n node->mobj = mobj;\n node->delayTics = 0;\n node->stopSound = SequenceTranslate[sequence].stopSound;\n node->volume = 127; // Start at max volume\n\n if (!SequenceListHead)\n {\n SequenceListHead = node;\n node->next = node->prev = NULL;\n }\n else\n {\n SequenceListHead->prev = node;\n node->next = SequenceListHead;\n node->prev = NULL;\n SequenceListHead = node;\n }\n ActiveSequences++;\n return;\n}", "label": 0, "cwe": null, "length": 206 }, { "index": 93254, "code": "cmp_room_surface(const void *room1, const void *room2)\n{\n\tint r1 = *(int *)room1;\n\tint r2 = *(int *)room2;\n\n\tint s1 = rooms[r1].w * rooms[r1].h;\n\tint s2 = rooms[r2].w * rooms[r2].h;\n\n\tif (s1 == s2) { \n\t\treturn 0;\n\t} else if (s1 < s2) {\n\t\treturn 1;\n\t} else \n\t\treturn -1;\n}", "label": 0, "cwe": null, "length": 111 }, { "index": 661356, "code": "appendf(char* zBuf, int* nCurlen, int nBuflen, const char *zFormat, ...){\n va_list ap;\n struct sgMprintf sMprintf;\n\n if( nBuflen <= 0 ) return -1;\n\n sMprintf.nChar = nCurlen ? *nCurlen : strlen(zBuf);\n sMprintf.nAlloc = nBuflen;\n sMprintf.zText = zBuf;\n\n if( sMprintf.nCharinitialize();\n}", "label": 0, "cwe": null, "length": 66 }, { "index": 256270, "code": "gst_memory_is_span (GstMemory * mem1, GstMemory * mem2, gsize * offset)\n{\n g_return_val_if_fail (mem1 != NULL, FALSE);\n g_return_val_if_fail (mem2 != NULL, FALSE);\n\n /* need to have the same allocators */\n if (mem1->allocator != mem2->allocator)\n return FALSE;\n\n /* need to have the same parent */\n if (mem1->parent == NULL || mem1->parent != mem2->parent)\n return FALSE;\n\n /* and memory is contiguous */\n if (!mem1->allocator->mem_is_span (mem1, mem2, offset))\n return FALSE;\n\n return TRUE;\n}", "label": 0, "cwe": null, "length": 149 }, { "index": 549360, "code": "command_module_find_and_remove(COMMAND_REC *rec, SIGNAL_FUNC func)\n{\n\tGSList *tmp, *tmp2;\n\n\tg_return_val_if_fail(rec != NULL, NULL);\n\tg_return_val_if_fail(func != NULL, NULL);\n\n\tfor (tmp = rec->modules; tmp != NULL; tmp = tmp->next) {\n\t\tCOMMAND_MODULE_REC *rec = tmp->data;\n\n\t\tfor (tmp2 = rec->callbacks; tmp2 != NULL; tmp2 = tmp2->next) {\n\t\t\tCOMMAND_CALLBACK_REC *cb = tmp2->data;\n\n\t\t\tif (cb->func == func) {\n\t\t\t\trec->callbacks =\n\t\t\t\t\tg_slist_remove(rec->callbacks, cb);\n\t\t\t\tg_free(cb);\n\t\t\t\treturn rec;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn NULL;\n}", "label": 0, "cwe": null, "length": 166 }, { "index": 277372, "code": "try_remove_classifiers(RouterT *router, Vector &classifiers)\n{\n for (int i = 0; i < classifiers.size(); i++)\n\tif (!router->find_connections_to(PortT(classifiers[i], 0))) {\n\t classifiers[i]->kill();\n\t classifiers[i] = classifiers.back();\n\t classifiers.pop_back();\n\t i--;\n\t}\n router->remove_dead_elements();\n}", "label": 0, "cwe": null, "length": 86 }, { "index": 43585, "code": "gx_restrict01_paint_3(gs_client_color * pcc, const gs_color_space * pcs)\n{\n pcc->paint.values[2] = FORCE_UNIT(pcc->paint.values[2]);\n pcc->paint.values[1] = FORCE_UNIT(pcc->paint.values[1]);\n pcc->paint.values[0] = FORCE_UNIT(pcc->paint.values[0]);\n}", "label": 0, "cwe": null, "length": 83 }, { "index": 767339, "code": "getNumExplicitOperands() const {\n unsigned NumOperands = TID->getNumOperands();\n if (!TID->isVariadic())\n return NumOperands;\n\n for (unsigned i = NumOperands, e = getNumOperands(); i != e; ++i) {\n const MachineOperand &MO = getOperand(i);\n if (!MO.isReg() || !MO.isImplicit())\n NumOperands++;\n }\n return NumOperands;\n}", "label": 0, "cwe": null, "length": 100 }, { "index": 690744, "code": "makewindowed()\n{\n\tSDL_Surface * fullscreensave=SDL_CreateRGBSurface(SDL_SWSURFACE,WIDTH,HEIGHT,32,0,0,0,0);\n\tclean();\n\tSDL_BlitSurface(screen, NULL, fullscreensave, NULL);\n\t\n\tscreen = SDL_SetVideoMode(WIDTH, HEIGHT, 32, SDL_HWSURFACE);\n\tif (screen == NULL)\n\t{\n\t\tfprintf(stderr, \"Couldn't switch to windowed screen mode.\\n\"\n\t\t \"SDL error: \"\n\t\t \"%s\\n\\n\", SDL_GetError());\n\t\texit(1);\n\t}\t\n\t\n\tSDL_BlitSurface(fullscreensave, NULL, screen, NULL);\n\tSDL_UpdateRect(screen,0,0,0,0);\n\tSDL_FreeSurface(fullscreensave);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 163 }, { "index": 277723, "code": "stonith_fence(xmlNode * msg)\n{\n const char *device_id = NULL;\n stonith_device_t *device = NULL;\n async_command_t *cmd = create_async_command(msg);\n xmlNode *dev = get_xpath_object(\"//@\" F_STONITH_TARGET, msg, LOG_ERR);\n\n if (cmd == NULL) {\n return -EPROTO;\n }\n\n device_id = crm_element_value(dev, F_STONITH_DEVICE);\n if (device_id) {\n device = g_hash_table_lookup(device_list, device_id);\n if (device == NULL) {\n crm_err(\"Requested device '%s' is not available\", device_id);\n return -ENODEV;\n }\n schedule_stonith_command(cmd, device);\n\n } else {\n const char *host = crm_element_value(dev, F_STONITH_TARGET);\n\n if (cmd->options & st_opt_cs_nodeid) {\n int nodeid = crm_atoi(host, NULL);\n crm_node_t *node = crm_get_peer(nodeid, NULL);\n\n if (node) {\n host = node->uname;\n }\n }\n get_capable_devices(host, cmd->action, cmd->default_timeout, cmd,\n stonith_fence_get_devices_cb);\n }\n\n return -EINPROGRESS;\n}", "label": 0, "cwe": null, "length": 280 }, { "index": 130479, "code": "GuessFromModality(const char *modality, unsigned int dim)\n{\n // no default value is set, it is up to the user to decide initial value\n if( !modality || !dim ) return;\n //if( strlen(modality) != 2 ) return;\n int i = 0;\n while( MSModalityTypes[i].Modality &&\n (strcmp(modality, MSModalityTypes[i].Modality) != 0 || MSModalityTypes[i].Dimension < dim ))\n {\n ++i;\n }\n if( MSModalityTypes[i].Modality )\n {\n // Ok we found something...\n MSField = (MSType)i;\n }\n}", "label": 0, "cwe": null, "length": 151 }, { "index": 243322, "code": "brasero_data_project_reference_remove_children_cb (gpointer key,\n\t\t\t\t\t\t gpointer data,\n\t\t\t\t\t\t gpointer callback_data)\n{\n\tBraseroFileNode *node = data;\n\tBraseroFileNode *parent = callback_data;\n\n\tif (brasero_file_node_is_ancestor (parent, node))\n\t\treturn TRUE;\n\n\treturn FALSE;\n}", "label": 0, "cwe": null, "length": 69 }, { "index": 109776, "code": "anon_vma_compatible(struct vm_area_struct *a, struct vm_area_struct *b)\n{\n\treturn a->vm_end == b->vm_start &&\n\t\tmpol_equal(vma_policy(a), vma_policy(b)) &&\n\t\ta->vm_file == b->vm_file &&\n\t\t!((a->vm_flags ^ b->vm_flags) & ~(VM_READ|VM_WRITE|VM_EXEC|VM_SOFTDIRTY)) &&\n\t\tb->vm_pgoff == a->vm_pgoff + ((b->vm_start - a->vm_start) >> PAGE_SHIFT);\n}", "label": 0, "cwe": null, "length": 118 }, { "index": 536640, "code": "getRenderingContext_impl(RenderingContext& ctx) const\n{\n // if not dragging, do the default thing.\n if (!d_dragging)\n return (void)Window::getRenderingContext_impl(ctx);\n\n // otherwise, switch rendering onto root rendering surface\n const Window* root = getRootWindow();\n ctx.surface = &root->getTargetRenderingSurface();\n // ensure root window is only used as owner if it really is.\n ctx.owner = root->getRenderingSurface() == ctx.surface ? root : 0;\n // ensure use of correct offset for the surface we're targetting\n ctx.offset = ctx.owner ? ctx.owner->getOuterRectClipper().getPosition() :\n Vector2(0, 0);\n // draw to overlay queue\n ctx.queue = RQ_OVERLAY;\n}", "label": 0, "cwe": null, "length": 170 }, { "index": 780435, "code": "PostImportDocument(FCDocument* document)\r\n{\r\n\t// Create a map of the plugin profile names in order to process the extra trees faster.\r\n\tFCPExtraMap pluginMap;\r\n\tCreateExtraTechniquePluginMap(pluginMap);\r\n\tif (pluginMap.empty()) return;\r\n\r\n\tFCDExtraSet& extraTrees = document->GetExtraTrees();\r\n\tfor (FCDExtraSet::iterator itE = extraTrees.begin(); itE != extraTrees.end(); ++itE)\r\n\t{\r\n\t\tsize_t typeCount = itE->first->GetTypeCount();\r\n\t\tfor (size_t i = 0; i < typeCount; ++i)\r\n\t\t{\r\n\t\t\tFCDEType* type = itE->first->GetType(i);\r\n\t\t\tsize_t techniqueCount = type->GetTechniqueCount();\r\n\t\t\tfor (size_t j = 0; j < techniqueCount; ++j)\r\n\t\t\t{\r\n\t\t\t\tFCDETechnique* technique = type->GetTechnique(j);\r\n\t\t\t\tuint32 crc = FUCrc32::CRC32(technique->GetProfile());\r\n\t\t\t\tFCPExtraMap::iterator itP = pluginMap.find(crc);\r\n\t\t\t\tif (itP != pluginMap.end())\r\n\t\t\t\t{\r\n\t\t\t\t\t// Call the corresponding plug-in to process this information.\r\n\t\t\t\t\tFUTrackable* customized = itP->second->ReadFromArchive(technique, itE->first->GetParent());\r\n\t\t\t\t\tif (customized != NULL)\r\n\t\t\t\t\t{\r\n\t\t\t\t\t\ttechnique->SetPluginObject(customized);\r\n\t\t\t\t\t\twhile (technique->GetChildNodeCount() != 0) technique->GetChildNode(technique->GetChildNodeCount() - 1)->Release();\r\n\t\t\t\t\t}\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n}", "label": 0, "cwe": null, "length": 360 }, { "index": 530290, "code": "free_mdep_data(gpointer data)\n{\n\tstruct get_mdep_data *mdep_data = data;\n\n\tif (mdep_data->destroy)\n\t\tmdep_data->destroy(mdep_data->data);\n\thdp_application_unref(mdep_data->app);\n\n\tg_free(mdep_data);\n}", "label": 0, "cwe": null, "length": 59 }, { "index": 113406, "code": "cdio_get_track_lsn(const CdIo_t *p_cdio, track_t i_track)\n{\n if (p_cdio == NULL) return CDIO_INVALID_LSN;\n\n if (p_cdio->op.get_track_lba) {\n return cdio_lba_to_lsn(p_cdio->op.get_track_lba (p_cdio->env, i_track));\n } else {\n msf_t msf;\n if (cdio_get_track_msf(p_cdio, i_track, &msf))\n return cdio_msf_to_lsn(&msf);\n return CDIO_INVALID_LSN;\n }\n}", "label": 0, "cwe": null, "length": 135 }, { "index": 502164, "code": "test_program_load_unbalanced_brackets (void)\n{\n\tCattleProgram *program;\n\tCattleInstruction *instruction;\n\tCattleInstructionValue value;\n\tGError *error;\n\tgboolean success;\n\n\tprogram = cattle_program_new ();\n\n\terror = NULL;\n\tsuccess = cattle_program_load (program, \"[\", &error);\n\n\tg_assert (!success);\n\tg_assert (error != NULL);\n\tg_assert (error->domain == CATTLE_ERROR);\n\tg_assert (error->code == CATTLE_ERROR_UNBALANCED_BRACKETS);\n\n\tinstruction = cattle_program_get_instructions (program);\n\n\tg_assert (CATTLE_IS_INSTRUCTION (instruction));\n\tg_assert (cattle_instruction_get_next (instruction) == NULL);\n\tg_assert (cattle_instruction_get_loop (instruction) == NULL);\n\n\tvalue = cattle_instruction_get_value (instruction);\n\n\tg_assert (value == CATTLE_INSTRUCTION_NONE);\n\n\tg_object_unref (instruction);\n\tg_object_unref (program);\n}", "label": 0, "cwe": null, "length": 185 }, { "index": 997595, "code": "cmd_http_txreq(CMD_ARGS)\n{\n\tstruct http *hp;\n\tconst char *req = \"GET\";\n\tconst char *url = \"/\";\n\tconst char *proto = \"HTTP/1.1\";\n\tconst char *body = NULL;\n\n\t(void)cmd;\n\t(void)vl;\n\tCAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC);\n\tONLY_CLIENT(hp, av);\n\tassert(!strcmp(av[0], \"txreq\"));\n\tav++;\n\n\tVSB_clear(hp->vsb);\n\n\tfor(; *av != NULL; av++) {\n\t\tif (!strcmp(*av, \"-url\")) {\n\t\t\turl = av[1];\n\t\t\tav++;\n\t\t} else if (!strcmp(*av, \"-proto\")) {\n\t\t\tproto = av[1];\n\t\t\tav++;\n\t\t} else if (!strcmp(*av, \"-req\")) {\n\t\t\treq = av[1];\n\t\t\tav++;\n\t\t} else\n\t\t\tbreak;\n\t}\n\tVSB_printf(hp->vsb, \"%s %s %s%s\", req, url, proto, nl);\n\tfor(; *av != NULL; av++) {\n\t\tif (!strcmp(*av, \"-hdr\")) {\n\t\t\tVSB_printf(hp->vsb, \"%s%s\", av[1], nl);\n\t\t\tav++;\n\t\t} else\n\t\t\tbreak;\n\t}\n\tfor(; *av != NULL; av++) {\n\t\tif (!strcmp(*av, \"-body\")) {\n\t\t\tAZ(body);\n\t\t\tbody = av[1];\n\t\t\tav++;\n\t\t} else if (!strcmp(*av, \"-bodylen\")) {\n\t\t\tAZ(body);\n\t\t\tbody = synth_body(av[1], 0);\n\t\t\tav++;\n\t\t} else\n\t\t\tbreak;\n\t}\n\tif (*av != NULL)\n\t\tvtc_log(hp->vl, 0, \"Unknown http txreq spec: %s\\n\", *av);\n\tif (body != NULL)\n\t\tVSB_printf(hp->vsb, \"Content-Length: %ju%s\",\n\t\t (uintmax_t)strlen(body), nl);\n\tVSB_cat(hp->vsb, nl);\n\tif (body != NULL) {\n\t\tVSB_cat(hp->vsb, body);\n\t\tVSB_cat(hp->vsb, nl);\n\t}\n\thttp_write(hp, 4, \"txreq\");\n}", "label": 0, "cwe": null, "length": 482 }, { "index": 885525, "code": "wfreq_sorter(wcount **p1, wcount **p2)\n{//==============================================\n\tint x;\n\twcount *a, *b;\n\ta = *p1;\n\tb = *p2;\n\tif((x = b->count - a->count) != 0)\n\t\treturn(x);\n\treturn(strcmp(a->word,b->word));\n}", "label": 0, "cwe": null, "length": 73 }, { "index": 19611, "code": "of_NAND_narrow(vthread_t thr, vvp_code_t cp)\n{\n unsigned idx1 = cp->bit_idx[0];\n unsigned idx2 = cp->bit_idx[1];\n unsigned wid = cp->number;\n\n for (unsigned idx = 0 ; idx < wid ; idx += 1) {\n\t vvp_bit4_t lb = thr_get_bit(thr, idx1);\n\t vvp_bit4_t rb = thr_get_bit(thr, idx2);\n\t thr_put_bit(thr, idx1, ~(lb&rb));\n\t idx1 += 1;\n\t if (idx2 >= 4)\n\t\t idx2 += 1;\n }\n\n return true;\n}", "label": 0, "cwe": null, "length": 148 }, { "index": 372149, "code": "parse_vector_common (const sc_char *vector, sc_int count)\n{\n sc_int index_;\n\n /* Parse the vector property count times, pushing a key on each. */\n for (index_ = 0; index_ < count; index_++)\n {\n sc_vartype_t vt_key;\n\n vt_key.integer = index_;\n parse_push_key (vt_key, PROP_KEY_INTEGER);\n\n parse_element (vector + 1);\n\n parse_pop_key ();\n }\n}", "label": 0, "cwe": null, "length": 101 }, { "index": 40709, "code": "LoadParameter()\n{\n ASCString filename = selectFile( fileNamePattern, true );\n if ( !filename.empty() ) {\n tnfilestream s ( filename, tnstream::reading );\n \n TextFormatParser tfp ( &s );\n auto_ptr tpg ( tfp.run());\n \n PropertyReadingContainer pc ( blockName, tpg.get() );\n \n runTextIO( pc );\n propertyEditor->Reload();\n return true; \n } \n return false;\n}", "label": 0, "cwe": null, "length": 107 }, { "index": 260758, "code": "gst_jpegenc_term_destination (j_compress_ptr cinfo)\n{\n GstBuffer *outbuf;\n GstJpegEnc *jpegenc = (GstJpegEnc *) (cinfo->client_data);\n gsize memory_size = jpegenc->output_map.size - jpegenc->jdest.free_in_buffer;\n GstByteReader reader =\n GST_BYTE_READER_INIT (jpegenc->output_map.data, memory_size);\n guint16 marker;\n gint sof_marker = -1;\n\n GST_DEBUG_OBJECT (jpegenc, \"gst_jpegenc_chain: term_source\");\n\n /* Find the SOF marker */\n while (gst_byte_reader_get_uint16_be (&reader, &marker)) {\n /* SOF marker */\n if (marker >> 4 == 0x0ffc) {\n sof_marker = marker & 0x4;\n break;\n }\n }\n\n gst_memory_unmap (jpegenc->output_mem, &jpegenc->output_map);\n /* Trim the buffer size. we will push it in the chain function */\n gst_memory_resize (jpegenc->output_mem, 0, memory_size);\n jpegenc->output_map.data = NULL;\n jpegenc->output_map.size = 0;\n\n if (jpegenc->sof_marker != sof_marker) {\n GstVideoCodecState *output;\n output =\n gst_video_encoder_set_output_state (GST_VIDEO_ENCODER (jpegenc),\n gst_caps_new_simple (\"image/jpeg\", \"sof-marker\", G_TYPE_INT, sof_marker,\n NULL), jpegenc->input_state);\n gst_video_codec_state_unref (output);\n jpegenc->sof_marker = sof_marker;\n }\n\n outbuf = gst_buffer_new ();\n gst_buffer_copy_into (outbuf, jpegenc->current_frame->input_buffer,\n GST_BUFFER_COPY_METADATA, 0, -1);\n gst_buffer_append_memory (outbuf, jpegenc->output_mem);\n jpegenc->output_mem = NULL;\n\n jpegenc->current_frame->output_buffer = outbuf;\n\n gst_video_frame_unmap (&jpegenc->current_vframe);\n\n GST_VIDEO_CODEC_FRAME_SET_SYNC_POINT (jpegenc->current_frame);\n\n jpegenc->res = gst_video_encoder_finish_frame (GST_VIDEO_ENCODER (jpegenc),\n jpegenc->current_frame);\n jpegenc->current_frame = NULL;\n}", "label": 0, "cwe": null, "length": 492 }, { "index": 515597, "code": "sqlite_db_create_aggregate(pTHX_ SV *dbh, const char *name, int argc, SV *aggr_pkg)\n{\n D_imp_dbh(dbh);\n int rc;\n SV *aggr_pkg_copy;\n\n if (!DBIc_ACTIVE(imp_dbh)) {\n sqlite_error(dbh, -2, \"attempt to create aggregate on inactive database handle\");\n return FALSE;\n }\n\n /* Copy the aggregate reference */\n aggr_pkg_copy = newSVsv(aggr_pkg);\n av_push( imp_dbh->aggregates, aggr_pkg_copy );\n\n croak_if_db_is_null();\n\n rc = sqlite3_create_function( imp_dbh->db, name, argc, SQLITE_UTF8,\n aggr_pkg_copy,\n NULL,\n sqlite_db_aggr_step_dispatcher,\n sqlite_db_aggr_finalize_dispatcher\n );\n\n if ( rc != SQLITE_OK ) {\n sqlite_error(dbh, rc, form(\"sqlite_create_aggregate failed with error %s\", sqlite3_errmsg(imp_dbh->db)));\n return FALSE;\n }\n return TRUE;\n}", "label": 0, "cwe": null, "length": 232 }, { "index": 873759, "code": "append_resolver(int index, const char *domain,\n\t\t\t\tconst char *server, unsigned int lifetime,\n\t\t\t\t\t\t\tunsigned int flags)\n{\n\tstruct entry_data *entry;\n\tunsigned int interval;\n\n\tDBG(\"index %d domain %s server %s lifetime %d flags %d\",\n\t\t\t\tindex, domain, server, lifetime, flags);\n\n\tif (server == NULL && domain == NULL)\n\t\treturn -EINVAL;\n\n\tentry = g_try_new0(struct entry_data, 1);\n\tif (entry == NULL)\n\t\treturn -ENOMEM;\n\n\tentry->index = index;\n\tentry->domain = g_strdup(domain);\n\tentry->server = g_strdup(server);\n\tentry->flags = flags;\n\tentry->lifetime = lifetime;\n\n\tif (server != NULL)\n\t\tentry->family = connman_inet_check_ipaddress(server);\n\n\tif (lifetime) {\n\t\tinterval = lifetime * RESOLVER_LIFETIME_REFRESH_THRESHOLD;\n\n\t\tDBG(\"RDNSS start index %d domain %s \"\n\t\t\t\t\"server %s lifetime threshold %d\",\n\t\t\t\tindex, domain, server, interval);\n\n\t\tentry->timeout = g_timeout_add_seconds(interval,\n\t\t\t\tresolver_refresh_cb, entry);\n\n\t\t/*\n\t\t * We update the service only for those nameservers\n\t\t * that are automagically added via netlink (lifetime > 0)\n\t\t */\n\t\tif (server != NULL && entry->index >= 0) {\n\t\t\tstruct connman_service *service;\n\t\t\tservice = __connman_service_lookup_from_index(entry->index);\n\t\t\tif (service != NULL)\n\t\t\t\t__connman_service_nameserver_append(service,\n\t\t\t\t\t\t\t\tserver, TRUE);\n\t\t}\n\t}\n\tentry_list = g_slist_append(entry_list, entry);\n\n\tif (dnsproxy_enabled == TRUE)\n\t\t__connman_dnsproxy_append(entry->index, domain, server);\n\telse\n\t\t__connman_resolvfile_append(entry->index, domain, server);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 391 }, { "index": 891021, "code": "dfs_push_decls (tree binfo, void *data)\n{\n tree type = BINFO_TYPE (binfo);\n tree method_vec;\n tree fields;\n \n for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))\n if (DECL_NAME (fields) \n\t&& TREE_CODE (fields) != TYPE_DECL\n\t&& TREE_CODE (fields) != USING_DECL\n\t&& !DECL_ARTIFICIAL (fields))\n setup_class_bindings (DECL_NAME (fields), /*type_binding_p=*/0);\n else if (TREE_CODE (fields) == FIELD_DECL\n\t && ANON_AGGR_TYPE_P (TREE_TYPE (fields)))\n dfs_push_decls (TYPE_BINFO (TREE_TYPE (fields)), data);\n \n method_vec = (CLASS_TYPE_P (type) \n\t\t? CLASSTYPE_METHOD_VEC (type) : NULL_TREE);\n \n if (method_vec && TREE_VEC_LENGTH (method_vec) >= 3)\n {\n tree *methods;\n tree *end;\n \n /* Farm out constructors and destructors. */\n end = TREE_VEC_END (method_vec);\n \n for (methods = &TREE_VEC_ELT (method_vec, 2);\n\t methods < end && *methods;\n\t methods++)\n\tsetup_class_bindings (DECL_NAME (OVL_CURRENT (*methods)), \n\t\t\t /*type_binding_p=*/0);\n }\n\n BINFO_PUSHDECLS_MARKED (binfo) = 0;\n\n return NULL_TREE;\n}", "label": 0, "cwe": null, "length": 312 }, { "index": 846806, "code": "to_shortname_char(struct nls_table *nls,\n\t\t\t\t unsigned char *buf, int buf_size,\n\t\t\t\t wchar_t *src, struct shortname_info *info)\n{\n\tint len;\n\n\tif (vfat_skip_char(*src)) {\n\t\tinfo->valid = 0;\n\t\treturn 0;\n\t}\n\tif (vfat_replace_char(*src)) {\n\t\tinfo->valid = 0;\n\t\tbuf[0] = '_';\n\t\treturn 1;\n\t}\n\n\tlen = nls->uni2char(*src, buf, buf_size);\n\tif (len <= 0) {\n\t\tinfo->valid = 0;\n\t\tbuf[0] = '_';\n\t\tlen = 1;\n\t} else if (len == 1) {\n\t\tunsigned char prev = buf[0];\n\n\t\tif (buf[0] >= 0x7F) {\n\t\t\tinfo->lower = 0;\n\t\t\tinfo->upper = 0;\n\t\t}\n\n\t\tbuf[0] = nls_toupper(nls, buf[0]);\n\t\tif (isalpha(buf[0])) {\n\t\t\tif (buf[0] == prev)\n\t\t\t\tinfo->lower = 0;\n\t\t\telse\n\t\t\t\tinfo->upper = 0;\n\t\t}\n\t} else {\n\t\tinfo->lower = 0;\n\t\tinfo->upper = 0;\n\t}\n\n\treturn len;\n}", "label": 0, "cwe": null, "length": 283 }, { "index": 68294, "code": "removeUnitFromCargo( Vehicle* veh, bool recursive )\n{\n if ( !veh )\n return false;\n else {\n if ( removeUnitFromCargo( veh->networkid, recursive )) {\n cargoChanged();\n return true;\n } else\n return false;\n }\n}", "label": 0, "cwe": null, "length": 62 }, { "index": 98183, "code": "common_fd_init(int fd)\n{\n\tint n;\n\tFILE *fp;\n\n\tif (lseek(fd, 0L, SEEK_END) >= 0 &&\n\t lseek(fd, 0L, SEEK_SET) >= 0)\n\t{\n\t\tint fd2=dup(fd);\n\n\t\tif (fd2 < 0)\n\t\t\tthrow strerror(errno);\n\n\t\tif ((content_fp=fdopen(fd2, \"r\")) == NULL)\n\t\t{\n\t\t\tclose(fd2);\n\t\t\tthrow strerror(errno);\n\t\t}\n\t\treturn;\n\t}\n\n\tfp=tmpfile();\n\tif (!fp)\n\t{\n\t\tthrow strerror(errno);\n\t}\n\n\twhile ((n=read(fd, encode_info.output_buffer,\n\t\t // Convenient buffer\n\t\t sizeof(encode_info.output_buffer))) > 0)\n\t{\n\t\tif (fwrite(encode_info.output_buffer, n, 1, fp) != 1)\n\t\t{\n\t\t\tfclose(fp);\n\t\t\tthrow strerror(errno);\n\t\t}\n\t}\n\n\tif (fflush(fp) < 0 || ferror(fp))\n\t{\n\t\tfclose(fp);\n\t\tthrow strerror(errno);\n\t}\n\tcontent_fp=fp;\n}", "label": 0, "cwe": null, "length": 228 }, { "index": 569373, "code": "tda10023_writereg (struct tda10023_state* state, u8 reg, u8 data)\n{\n\tu8 buf[] = { reg, data };\n\tstruct i2c_msg msg = { .addr = state->config->demod_address, .flags = 0, .buf = buf, .len = 2 };\n\tint ret;\n\n\tret = i2c_transfer (state->i2c, &msg, 1);\n\tif (ret != 1) {\n\t\tint num = state->frontend.dvb ? state->frontend.dvb->num : -1;\n\t\tprintk(KERN_ERR \"DVB: TDA10023(%d): %s, writereg error \"\n\t\t\t\"(reg == 0x%02x, val == 0x%02x, ret == %i)\\n\",\n\t\t\tnum, __func__, reg, data, ret);\n\t}\n\treturn (ret != 1) ? -EREMOTEIO : 0;\n}", "label": 0, "cwe": null, "length": 206 }, { "index": 560984, "code": "getGlobalBaseReg() {\n // Return if it has already been initialized.\n if (GlobalBaseReg)\n return GlobalBaseReg;\n\n MipsSubtarget const &STI =\n static_cast(MF.getSubtarget());\n\n const TargetRegisterClass *RC =\n STI.inMips16Mode()\n ? &Mips::CPU16RegsRegClass\n : STI.inMicroMipsMode()\n ? &Mips::GPRMM16RegClass\n : static_cast(MF.getTarget())\n .getABI()\n .IsN64()\n ? &Mips::GPR64RegClass\n : &Mips::GPR32RegClass;\n return GlobalBaseReg = MF.getRegInfo().createVirtualRegister(RC);\n}", "label": 0, "cwe": null, "length": 174 }, { "index": 32422, "code": "opj_jp2_decode(opj_jp2_t *jp2,\n opj_stream_private_t *p_stream,\n opj_image_t* p_image,\n opj_event_mgr_t * p_manager)\n{\n\tif (!p_image)\n\t\treturn OPJ_FALSE;\n\n\t/* J2K decoding */\n\tif( ! opj_j2k_decode(jp2->j2k, p_stream, p_image, p_manager) ) {\n\t\topj_event_msg(p_manager, EVT_ERROR, \"Failed to decode the codestream in the JP2 file\\n\");\n\t\treturn OPJ_FALSE;\n\t}\n\n if (!jp2->ignore_pclr_cmap_cdef){\n\n\t /* Set Image Color Space */\n\t if (jp2->enumcs == 16)\n\t\t p_image->color_space = OPJ_CLRSPC_SRGB;\n\t else if (jp2->enumcs == 17)\n\t\t p_image->color_space = OPJ_CLRSPC_GRAY;\n\t else if (jp2->enumcs == 18)\n\t\t p_image->color_space = OPJ_CLRSPC_SYCC;\n\t else\n\t\t p_image->color_space = OPJ_CLRSPC_UNKNOWN;\n\n\t /* Apply the color space if needed */\n\t if(jp2->color.jp2_cdef) {\n\t\t opj_jp2_apply_cdef(p_image, &(jp2->color));\n\t }\n\n\t if(jp2->color.jp2_pclr) {\n\t\t /* Part 1, I.5.3.4: Either both or none : */\n\t\t if( !jp2->color.jp2_pclr->cmap)\n\t\t\t opj_jp2_free_pclr(&(jp2->color));\n\t\t else\n\t\t\t opj_jp2_apply_pclr(p_image, &(jp2->color));\n\t }\n\n\t if(jp2->color.icc_profile_buf) {\n\t\t p_image->icc_profile_buf = jp2->color.icc_profile_buf;\n\t\t p_image->icc_profile_len = jp2->color.icc_profile_len;\n\t\t jp2->color.icc_profile_buf = NULL;\n\t }\n }\n\n\treturn OPJ_TRUE;\n}", "label": 0, "cwe": null, "length": 445 }, { "index": 768341, "code": "get_date_format(int no_of_fields, char* fieldname, char* value)\n{\n char * result = get_field(DATE_FORMAT, no_of_fields, fieldname, value);\n int i;\n if (result==0) {\n return (char*)\"\";\n }\n else {\n for (i=0;ipar;\n\tunsigned gx_base;\n\tint fb_len;\n\tint ret;\n\n\tgx_base = gx1_gx_base();\n\tif (!gx_base)\n\t\treturn -ENODEV;\n\n\tret = pci_enable_device(dev);\n\tif (ret < 0)\n\t\treturn ret;\n\n\tret = pci_request_region(dev, 0, \"gx1fb (video)\");\n\tif (ret < 0)\n\t\treturn ret;\n\tpar->vid_regs = pci_ioremap_bar(dev, 0);\n\tif (!par->vid_regs)\n\t\treturn -ENOMEM;\n\n\tif (!request_mem_region(gx_base + 0x8300, 0x100, \"gx1fb (display controller)\"))\n\t\treturn -EBUSY;\n\tpar->dc_regs = ioremap(gx_base + 0x8300, 0x100);\n\tif (!par->dc_regs)\n\t\treturn -ENOMEM;\n\n\tif ((fb_len = gx1_frame_buffer_size()) < 0)\n\t\treturn -ENOMEM;\n\tinfo->fix.smem_start = gx_base + 0x800000;\n\tinfo->fix.smem_len = fb_len;\n\tinfo->screen_base = ioremap(info->fix.smem_start, info->fix.smem_len);\n\tif (!info->screen_base)\n\t\treturn -ENOMEM;\n\n\tdev_info(&dev->dev, \"%d Kibyte of video memory at 0x%lx\\n\",\n\t\t info->fix.smem_len / 1024, info->fix.smem_start);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 337 }, { "index": 121688, "code": "RemoveCPFunction(\n void *theEnv,\n char *name,\n struct cleanupFunction **head)\n {\n struct cleanupFunction *currentPtr, *lastPtr;\n\n lastPtr = NULL;\n currentPtr = *head;\n\n while (currentPtr != NULL)\n {\n if (strcmp(name,currentPtr->name) == 0)\n {\n if (lastPtr == NULL)\n { *head = currentPtr->next; }\n else\n { lastPtr->next = currentPtr->next; }\n rtn_struct(theEnv,cleanupFunction,currentPtr);\n return(TRUE);\n }\n lastPtr = currentPtr;\n currentPtr = currentPtr->next;\n }\n\n return(FALSE);\n }", "label": 0, "cwe": null, "length": 152 }, { "index": 305216, "code": "NoteOldRevision()\n{\n // Info for root repository\n this->Repositories.push_back( SVNInfo(\"\") );\n this->RootInfo = &(this->Repositories.back());\n // Info for the external repositories\n this->LoadExternals();\n\n // Get info for all the repositories\n std::list::iterator itbeg = this->Repositories.begin();\n std::list::iterator itend = this->Repositories.end();\n for( ; itbeg != itend ; itbeg++)\n {\n SVNInfo& svninfo = *itbeg;\n svninfo.OldRevision = this->LoadInfo(svninfo);\n this->Log << \"Revision for repository '\" << svninfo.LocalPath\n << \"' before update: \" << svninfo.OldRevision << \"\\n\";\n cmCTestLog(this->CTest, HANDLER_OUTPUT,\n \" Old revision of external repository '\"\n << svninfo.LocalPath << \"' is: \"\n << svninfo.OldRevision << \"\\n\");\n }\n\n // Set the global old revision to the one of the root\n this->OldRevision = this->RootInfo->OldRevision;\n this->PriorRev.Rev = this->OldRevision;\n}", "label": 0, "cwe": null, "length": 258 }, { "index": 559733, "code": "gib_list_move_down_by_one(gib_list * root, gib_list * l)\n{\n gib_list *temp;\n\n if (!l || !l->next)\n return (root);\n\n /* store item we link next to */\n temp = l->next;\n /* remove from list */\n root = gib_list_unlink(root, l);\n /* add back one before */\n l->next = temp->next;\n l->prev = temp;\n if (temp->next)\n temp->next->prev = l;\n temp->next = l;\n\n return (root);\n}", "label": 0, "cwe": null, "length": 126 }, { "index": 428255, "code": "s16g_mul(long x, long y, int clamp)\n{\n if (x == 0) return 0;\n if (y > 32767) return (x>0)?range_s16hi(0, clamp):range_s16lo(0, clamp);\n return clamp_s16(x*y, clamp);\n}", "label": 0, "cwe": null, "length": 71 }, { "index": 649877, "code": "WriteControllerInstance(FCDObject* object, xmlNode* parentNode)\r\n{\r\n\tFCDControllerInstance* controllerInstance = (FCDControllerInstance*)object;\r\n\r\n\t// Export the geometry instantiation information.\r\n\txmlNode* instanceNode = FArchiveXML::WriteGeometryInstance(controllerInstance, parentNode);\r\n\txmlNode* insertBeforeNode = (instanceNode != NULL) ? instanceNode->children : NULL;\r\n\r\n\t// Retrieve the parent joints and export the elements.\r\n\tFUUriList& skeletonRoots = controllerInstance->GetSkeletonRoots();\r\n\tfor (FUUriList::iterator itS = skeletonRoots.begin(); itS != skeletonRoots.end(); ++itS)\r\n\t{\r\n\t\t// TODO: External references (again)\r\n\t\tfm::string fragment = TO_STRING((*itS).GetFragment());\r\n\t\tFUSStringBuilder builder; builder.set('#'); builder.append(fragment);\r\n\t\txmlNode* skeletonNode = InsertChild(instanceNode, insertBeforeNode, DAE_SKELETON_ELEMENT);\r\n\t\tAddContent(skeletonNode, builder);\r\n\t}\r\n\r\n\tFArchiveXML::WriteEntityInstanceExtra(controllerInstance, instanceNode);\r\n\treturn instanceNode;\r\n}", "label": 0, "cwe": null, "length": 235 }, { "index": 284377, "code": "e1000_suspend(struct pci_dev *pdev, pm_message_t state)\n{\n\tint retval;\n\tbool wake;\n\n\tretval = __e1000_shutdown(pdev, &wake);\n\tif (retval)\n\t\treturn retval;\n\n\tif (wake) {\n\t\tpci_prepare_to_sleep(pdev);\n\t} else {\n\t\tpci_wake_from_d3(pdev, false);\n\t\tpci_set_power_state(pdev, PCI_D3hot);\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 92 }, { "index": 544334, "code": "parse_bbox_bounds(const char* string, Bounds* bounds) {\n\tconst char *end = string + strlen(string);\n\tconst char *comma1, *comma2, *comma3;\n\n\tif ((comma1 = strchr(string, ',')) == NULL)\n\t\treturn 0;\n\n\tif ((comma2 = strchr(comma1 + 1, ',')) == NULL)\n\t\treturn 0;\n\n\tif ((comma3 = strchr(comma2 + 1, ',')) == NULL)\n\t\treturn 0;\n\n\tdouble left, bottom, right, top;\n\n\tif (!parse_double(string, comma1, &left))\n\t\treturn 0;\n\tif (!parse_double(comma1 + 1, comma2, &bottom))\n\t\treturn 0;\n\tif (!parse_double(comma2 + 1, comma3, &right))\n\t\treturn 0;\n\tif (!parse_double(comma3 + 1, end, &top))\n\t\treturn 0;\n\n\tif (left > right) {\n\t\tdouble tmp = left;\n\t\tleft = right;\n\t\tright = tmp;\n\t}\n\n\tif (bottom > top) {\n\t\tdouble tmp = top;\n\t\ttop = bottom;\n\t\tbottom = tmp;\n\t}\n\n\tif (left < -180.0 || right > 180.0)\n\t\treturn 0;\n\tif (bottom < -90.0 || top > 90.0)\n\t\treturn 0;\n\n\tbounds->left = 0.5 + left / 360.0;\n\tbounds->right = 0.5 + right / 360.0;\n\tbounds->top = 0.5 - top / 180.0;\n\tbounds->bottom = 0.5 - bottom / 180.0;\n\n\treturn 1;\n}", "label": 0, "cwe": null, "length": 359 }, { "index": 205984, "code": "sge_mirror_process_mark4registration(sge_evc_class_t *evc, object_description *object_base,\n sge_object_type type,\n sge_event_action action,\n lListElem *event,\n void *clientdata)\n{\n DENTER(TOP_LAYER, \"sge_mirror_process_mark4registration\");\n\n DPRINTF((\"mark4registration - this happens for ACK TIMEOUT or QMASTER GOES DOWN event\\n\"));\n\n evc->ec_mark4registration(evc);\n\n DRETURN(SGE_EMA_OK);\n}", "label": 0, "cwe": null, "length": 111 }, { "index": 98627, "code": "set_pado_delay_exec(const char *cmd, char * const *f, int f_cnt, void *cli)\n{\n\tif (f_cnt != 4)\n\t\treturn CLI_CMD_SYNTAX;\n\n\tif (dpado_parse(f[3]))\n\t\treturn CLI_CMD_INVAL;\n\n\treturn CLI_CMD_OK;\n}", "label": 0, "cwe": null, "length": 63 }, { "index": 622735, "code": "read_user_guide(const gchar *filename)\n{\n gchar *buf = NULL;\n\n g_file_get_contents(filename, &buf, NULL, NULL);\n user_guide = g_hash_table_new(g_str_hash, g_str_equal);\n while (buf && *buf) {\n MapInfo *minfo;\n gchar *key = gwy_str_next_line(&buf);\n gchar *val = strchr(key, ' ');\n\n if (!val)\n continue;\n *val = '\\0';\n minfo = g_new0(MapInfo, 1);\n minfo->target = val+1;\n g_hash_table_insert(user_guide, key, minfo);\n };\n}", "label": 0, "cwe": null, "length": 140 }, { "index": 555361, "code": "ClrBlank(WINDOW *win)\n{\n NCURSES_CH_T blank = blankchar;\n if (back_color_erase)\n\tAddAttr(blank, (AttrOf(BCE_BKGD(win)) & BCE_ATTRS));\n return blank;\n}", "label": 0, "cwe": null, "length": 51 }, { "index": 107932, "code": "ResourceOwnerDelete(ResourceOwner owner)\n{\n\t/* We had better not be deleting CurrentResourceOwner ... */\n\tAssert(owner != CurrentResourceOwner);\n\n\t/* And it better not own any resources, either */\n\tAssert(owner->nbuffers == 0);\n\tAssert(owner->ncatrefs == 0);\n\tAssert(owner->ncatlistrefs == 0);\n\tAssert(owner->nrelrefs == 0);\n\tAssert(owner->ntupdescs == 0);\n\tAssert(owner->nfiles == 0);\n\n\t/*\n\t * Delete children. The recursive call will delink the child from me, so\n\t * just iterate as long as there is a child.\n\t */\n\twhile (owner->firstchild != NULL)\n\t\tResourceOwnerDelete(owner->firstchild);\n\n\t/*\n\t * We delink the owner from its parent before deleting it, so that if\n\t * there's an error we won't have deleted/busted owners still attached to\n\t * the owner tree.\tBetter a leak than a crash.\n\t */\n\tResourceOwnerNewParent(owner, NULL);\n\n\t/* And free the object. */\n\tif (owner->buffers)\n\t\tpfree(owner->buffers);\n\tif (owner->catrefs)\n\t\tpfree(owner->catrefs);\n\tif (owner->catlistrefs)\n\t\tpfree(owner->catlistrefs);\n\tif (owner->relrefs)\n\t\tpfree(owner->relrefs);\n\tif (owner->tupdescs)\n\t\tpfree(owner->tupdescs);\n\tif (owner->files)\n\t\tpfree(owner->files);\n\n\tpfree(owner);\n}", "label": 0, "cwe": null, "length": 321 }, { "index": 485523, "code": "get_prop_intrinsic(VMG_ vm_prop_id_t prop, vm_val_t *val,\r\n vm_obj_id_t self, vm_obj_id_t *source_obj,\r\n uint *argc)\r\n{\r\n uint func_idx;\r\n \r\n /* translate the property into a function vector index */\r\n func_idx = G_meta_table\r\n ->prop_to_vector_idx(metaclass_reg_->get_reg_idx(), prop);\r\n\r\n /* call the appropriate function in our function vector */\r\n if ((this->*func_table_[func_idx])(vmg_ self, val, argc))\r\n {\r\n *source_obj = metaclass_reg_->get_class_obj(vmg0_);\r\n return TRUE;\r\n }\r\n\r\n /* didn't find it */\r\n return FALSE;\r\n}", "label": 0, "cwe": null, "length": 152 }, { "index": 689666, "code": "pixacompWriteStream(FILE *fp,\n PIXAC *pixac)\n{\nl_int32 n, i;\nPIXC *pixc;\n\n PROCNAME(\"pixacompWriteStream\");\n\n if (!fp)\n return ERROR_INT(\"stream not defined\", procName, 1);\n if (!pixac)\n return ERROR_INT(\"pixac not defined\", procName, 1);\n\n n = pixacompGetCount(pixac);\n fprintf(fp, \"\\nPixacomp Version %d\\n\", PIXACOMP_VERSION_NUMBER);\n fprintf(fp, \"Number of pixcomp = %d\", n);\n boxaWriteStream(fp, pixac->boxa);\n for (i = 0; i < n; i++) {\n if ((pixc = pixacompGetPixcomp(pixac, i)) == NULL)\n return ERROR_INT(\"pixc not found\", procName, 1);\n fprintf(fp, \" Pixcomp[%d]: w = %d, h = %d, d = %d\\n\",\n i, pixc->w, pixc->h, pixc->d);\n fprintf(fp, \" comptype = %d, size = %d, cmapflag = %d\\n\",\n pixc->comptype, pixc->size, pixc->cmapflag);\n fprintf(fp, \" xres = %d, yres = %d\\n\", pixc->xres, pixc->yres);\n fwrite(pixc->data, 1, pixc->size, fp);\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 344 }, { "index": 95507, "code": "gvprintpointflist(GVJ_t * job, pointf *p, int n)\n{\n int i = 0;\n\n while (TRUE) {\n\tgvprintpointf(job, p[i]);\n if (++i >= n) break;\n gvwrite(job, \" \", 1);\n }\n}", "label": 0, "cwe": null, "length": 67 }, { "index": 105389, "code": "rb_bh_gc_event(void *unused)\n{\n\trb_dlink_node *ptr;\n\tRB_DLINK_FOREACH(ptr, heap_lists->head)\n\t{\n\t\trb_bh_gc(ptr->data);\n\t}\n}", "label": 0, "cwe": null, "length": 42 }, { "index": 217230, "code": "Check_Numeric_Character(int c, const void * argp)\n{\n argp=0; /* Silence unused parameter warning. */\n return (isdigit(c) || \n\t c == '+' || \n\t c == '-' || \n\t c == (\n#if HAVE_LOCALE_H\n\t\t(L && L->decimal_point) ? *(L->decimal_point) :\n#endif\n\t\t'.')\n\t ) ? TRUE : FALSE;\n}", "label": 0, "cwe": null, "length": 93 }, { "index": 706922, "code": "get_model_name(char *iProduct, char *iModel)\n{\n models_name_t *model = NULL;\n\n upsdebugx(2, \"get_model_name(%s, %s)\\n\", iProduct, iModel);\n\n /* Search for formatting rules */\n for ( model = models_names ; model->iProduct != NULL ; model++ )\n\t{\n\t upsdebugx(2, \"comparing with: %s\", model->finalname);\n\t if ( (!strncmp(iProduct, model->iProduct, strlen(model->iProduct)))\n\t\t && (!strncmp(iModel, model->iModel, strlen(model->iModel))) )\n\t\t{\n\t\t upsdebugx(2, \"Found %s\\n\", model->finalname);\n\t\t break;\n\t\t}\n\t}\n /* FIXME: if we end up with model->iProduct == NULL\n * then process name in a generic way (not yet supported models!)\n */\n return model->finalname;\n}", "label": 0, "cwe": null, "length": 204 }, { "index": 117151, "code": "Log__osBinChar(ostream& os, char const& c)\n{\n char const cOldFill = os.fill('0');\n os << (isprint(c) ? c : '.') <<\n \" [0x\" << hex << (int)c << dec << \"]\";\n os.fill(cOldFill);\n return os;\n}", "label": 0, "cwe": null, "length": 70 }, { "index": 37030, "code": "UpdateParameter\t(Param param, float value)\n{\n\tswitch (param)\n\t{\n\tcase kAmsynthParameter_MasterVolume:\t\tmMasterVol = value;\t\tbreak;\n\tcase kAmsynthParameter_ReverbRoomsize:\treverb->setroomsize (value);\tbreak;\n\tcase kAmsynthParameter_ReverbDamp:\t\treverb->setdamp (value);\tbreak;\n\tcase kAmsynthParameter_ReverbWet:\t\treverb->setwet (value); reverb->setdry(1.0f-value); break;\n\tcase kAmsynthParameter_ReverbWidth:\t\treverb->setwidth (value);\tbreak;\n\tcase kAmsynthParameter_AmpDistortion:\tdistortion->SetCrunch (value);\tbreak;\n\t\n\tdefault: for (unsigned i=0; i<_voices.size(); i++) _voices[i]->UpdateParameter (param, value); break;\n\t}\n}", "label": 0, "cwe": null, "length": 192 }, { "index": 116867, "code": "apply_local_search(lp_prob *p, double *solutionValue, double *colSolution,\n\t\t double *betterSolution, double *dual_gap, double t_lb)\n{\n\n int is_ip_feasible = FALSE; \n \n while(true){\n\n char new_sol_found = FALSE;\n \n if(*dual_gap > p->par.ls_min_gap && p->par.ls_enabled &&\n\t local_search(p, solutionValue, colSolution, betterSolution)){\n\t memcpy(colSolution, betterSolution, DSIZE*p->lp_data->n);\n\t if(*solutionValue > t_lb + 100*p->lp_data->lpetol){\n\t *dual_gap = d_gap(*solutionValue, t_lb, p->mip->obj_offset,\n\t\t\t p->mip->obj_sense);\n\t }else{\n\t *dual_gap = MIN(1e-4, 0.1*p->par.ls_min_gap);\n\t }\n\t new_sol_found = TRUE; \n\t is_ip_feasible = TRUE; \n }\n \n if(!new_sol_found) break; \n }\n \n return is_ip_feasible;\n}", "label": 0, "cwe": null, "length": 238 }, { "index": 435009, "code": "ToString( string& str, const gnSeqI len, const gnSeqI offset ) const\n{\n\tSTACK_TRACE_START\n\t\tgnSeqI real_offset = offset - 1;\n\t\tgnSeqI m_length = length();\n\t\tgnSeqI readSize = len > m_length - real_offset ? m_length - real_offset : len;\n\t\tArray array_buf( readSize+1 );\n\t\tchar *buf = array_buf.data;\n\t\tboolean success = spec->SeqRead( real_offset, buf, readSize, ALL_CONTIGS);\n\t\tbuf[readSize] = '\\0';\n\t\tstr = buf;\n\n\t\t//now filter the string\n\t\tlist::const_iterator iter = filter_list.begin();\n\t\tfor(; iter != filter_list.end(); iter++)\n\t\t\t(*iter)->Filter(str);\n\n\t\tif( success )\n\t\t\treturn true;\n\t\treturn false;\n\tSTACK_TRACE_END\n}", "label": 0, "cwe": null, "length": 193 }, { "index": 126181, "code": "handleTimer(YTimer *t) {\n if (t != fUpdateTimer)\n return false;\n if (toolTipVisible())\n updateToolTip();\n updateStatus();\n return true;\n}", "label": 0, "cwe": null, "length": 42 }, { "index": 982342, "code": "ap_method_list_remove(ap_method_list_t *l,\n const char *method)\n{\n int methnum;\n char **methods;\n\n /*\n * If it's a known methods, either builtin or registered\n * by a module, use the bitmask.\n */\n methnum = ap_method_number_of(method);\n l->method_mask |= ~(AP_METHOD_BIT << methnum);\n if (methnum != M_INVALID) {\n return;\n }\n /*\n * Otherwise, see if the method name is in the array of string names.\n */\n if (l->method_list->nelts != 0) {\n register int i, j, k;\n methods = (char **)l->method_list->elts;\n for (i = 0; i < l->method_list->nelts; ) {\n if (strcmp(method, methods[i]) == 0) {\n for (j = i, k = i + 1; k < l->method_list->nelts; ++j, ++k) {\n methods[j] = methods[k];\n }\n --l->method_list->nelts;\n }\n else {\n ++i;\n }\n }\n }\n}", "label": 0, "cwe": null, "length": 255 }, { "index": 889960, "code": "ssh_bind_poll_callback(ssh_poll_handle sshpoll,\n socket_t fd, int revents, void *user){\n ssh_bind sshbind=(ssh_bind)user;\n (void)sshpoll;\n (void)fd;\n\n if(revents & POLLIN){\n /* new incoming connection */\n if(ssh_callbacks_exists(sshbind->bind_callbacks,incoming_connection)){\n sshbind->bind_callbacks->incoming_connection(sshbind,\n sshbind->bind_callbacks_userdata);\n }\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 111 }, { "index": 26059, "code": "isLineBreakBeforeClosingHeader()\n{\n\tassert(foundClosingHeader && previousNonWSChar == '}');\n\tif (bracketFormatMode == BREAK_MODE\n\t || bracketFormatMode == RUN_IN_MODE\n\t || shouldAttachClosingBracket)\n\t{\n\t\tisInLineBreak = true;\n\t}\n\telse if (bracketFormatMode == NONE_MODE)\n\t{\n\t\tif (shouldBreakClosingHeaderBrackets\n\t\t || getBracketIndent() || getBlockIndent())\n\t\t{\n\t\t\tisInLineBreak = true;\n\t\t}\n\t\telse\n\t\t{\n\t\t\tappendSpacePad();\n\t\t\t// is closing bracket broken?\n\t\t\tsize_t i = currentLine.find_first_not_of(\" \\t\");\n\t\t\tif (i != string::npos && currentLine[i] == '}')\n\t\t\t\tisInLineBreak = false;\n\n\t\t\tif (shouldBreakBlocks)\n\t\t\t\tisAppendPostBlockEmptyLineRequested = false;\n\t\t}\n\t}\n\t// bracketFormatMode == ATTACH_MODE, LINUX_MODE, STROUSTRUP_MODE\n\telse\n\t{\n\t\tif (shouldBreakClosingHeaderBrackets\n\t\t || getBracketIndent() || getBlockIndent())\n\t\t{\n\t\t\tisInLineBreak = true;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// if a blank line does not preceed this\n\t\t\t// or last line is not a one line block, attach header\n\t\t\tbool previousLineIsEmpty = isEmptyLine(formattedLine);\n\t\t\tint previousLineIsOneLineBlock = 0;\n\t\t\tsize_t firstBracket = findNextChar(formattedLine, '{');\n\t\t\tif (firstBracket != string::npos)\n\t\t\t\tpreviousLineIsOneLineBlock = isOneLineBlockReached(formattedLine, firstBracket);\n\t\t\tif (!previousLineIsEmpty\n\t\t\t && previousLineIsOneLineBlock == 0)\n\t\t\t{\n\t\t\t\tisInLineBreak = false;\n\t\t\t\tappendSpacePad();\n\t\t\t\tspacePadNum = 0;\t// don't count as comment padding\n\t\t\t}\n\n\t\t\tif (shouldBreakBlocks)\n\t\t\t\tisAppendPostBlockEmptyLineRequested = false;\n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 433 }, { "index": 976299, "code": "ProcessBlock(BasicBlock &BB) {\n // Can't sink anything out of a block that has less than two successors.\n if (BB.getTerminator()->getNumSuccessors() <= 1) return false;\n\n // Don't bother sinking code out of unreachable blocks. In addition to being\n // unprofitable, it can also lead to infinite looping, because in an\n // unreachable loop there may be nowhere to stop.\n if (!DT->isReachableFromEntry(&BB)) return false;\n\n bool MadeChange = false;\n\n // Walk the basic block bottom-up. Remember if we saw a store.\n BasicBlock::iterator I = BB.end();\n --I;\n bool ProcessedBegin = false;\n SmallPtrSet Stores;\n do {\n Instruction *Inst = &*I; // The instruction to sink.\n\n // Predecrement I (if it's not begin) so that it isn't invalidated by\n // sinking.\n ProcessedBegin = I == BB.begin();\n if (!ProcessedBegin)\n --I;\n\n if (isa(Inst))\n continue;\n\n if (SinkInstruction(Inst, Stores))\n ++NumSunk, MadeChange = true;\n\n // If we just processed the first instruction in the block, we're done.\n } while (!ProcessedBegin);\n\n return MadeChange;\n}", "label": 0, "cwe": null, "length": 297 }, { "index": 118616, "code": "read(const byte* pData,\n uint32_t size,\n ByteOrder /*byteOrder*/)\n {\n if (!pData || size < sizeOfSignature()) return false;\n if (0 != memcmp(pData, signature_, sizeOfSignature())) return false;\n buf_.alloc(sizeOfSignature());\n std::memcpy(buf_.pData_, pData, buf_.size_);\n start_ = sizeOfSignature();\n return true;\n }", "label": 0, "cwe": null, "length": 92 }, { "index": 271479, "code": "firstTradeDateOfMonth(const MSDate& aDate_, const MSResourceCodeSet& rCodeSet_)\n{\n if(aDate_.isSet()==MSFalse) return MSDate::nullDate();\n MSDate tradeDate(aDate_);\n MSDate lastDayOfMonth(aDate_); \n tradeDate.setFirstDayOfMonth();\n lastDayOfMonth.setLastDayOfMonth();\n\n MSGUARD(holidaySetMutex);\n\n while (tradeDate<=lastDayOfMonth)\n {\n if (_isValidTradeDate(tradeDate,holidaySet(),rCodeSet_)==MSTrue)\n\t{\n\t return tradeDate;\n\t}\n\n tradeDate++;\n }\n\n return tradeDate;\n}", "label": 0, "cwe": null, "length": 142 }, { "index": 623545, "code": "got441()\n/*\n * ERROR: User is not on that channel\n *\n * from: \n * msg: :They aren't on that channel\n *\n * Probably results when we do an action, and the user PART's before the\n * action gets processed. Check if they're on that channel. If so, remove\n * them.\n */\n{\n\tchanrec\t*chan;\n\tmembrec\t*m;\n\tchar\tnick[NICKLEN];\n\n\tstr_element(Server->chname,Server->msg,3);\n\tstr_element(nick,Server->msg,2);\n\n\t/* Retrieve channel info */\n\tchan = Channel_channel(Server->chname);\n\tif(chan == NULL)\n\t\treturn;\n\n\t/* Retrieve member info */\n\tm = Channel_member(chan,nick);\n\tif(m == NULL)\n\t\treturn;\n\n\t/* uh oh. We still show this member as being on the channel */\n\tChannel_removemember(chan,m);\n}", "label": 0, "cwe": null, "length": 204 }, { "index": 109360, "code": "SetId (gchar const *Id)\n{\n\tif (!Id)\n\t\treturn;\n\tif (m_Id) {\n\t\tif (!strcmp (Id, m_Id))\n\t\t\treturn;\n\t\tif (m_Parent)\n\t\t\tm_Parent->m_Children.erase (m_Id);\n\t\tg_free(m_Id);\n\t}\n\tm_Id = g_strdup (Id);\n\tif (m_Parent) {\n\t\tObject *parent = m_Parent;\n\t\tm_Parent = NULL;\n\t\tparent->AddChild (this);\n\t}\n}", "label": 0, "cwe": null, "length": 107 }, { "index": 881976, "code": "IsContourValue(double val)\n{\n int i;\n\n // Check to see whether a vertex is an intersection point.\n for ( i=0; i < this->NumberOfClipValues; i++)\n {\n if ( val == this->ClipValues[i] )\n {\n return 1;\n }\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 74 }, { "index": 69272, "code": "saa7164_i2c_register(struct saa7164_i2c *bus)\n{\n\tstruct saa7164_dev *dev = bus->dev;\n\n\tdprintk(DBGLVL_I2C, \"%s(bus = %d)\\n\", __func__, bus->nr);\n\n\tbus->i2c_adap = saa7164_i2c_adap_template;\n\tbus->i2c_client = saa7164_i2c_client_template;\n\n\tbus->i2c_adap.dev.parent = &dev->pci->dev;\n\n\tstrlcpy(bus->i2c_adap.name, bus->dev->name,\n\t\tsizeof(bus->i2c_adap.name));\n\n\tbus->i2c_adap.algo_data = bus;\n\ti2c_set_adapdata(&bus->i2c_adap, bus);\n\ti2c_add_adapter(&bus->i2c_adap);\n\n\tbus->i2c_client.adapter = &bus->i2c_adap;\n\n\tif (0 != bus->i2c_rc)\n\t\tprintk(KERN_ERR \"%s: i2c bus %d register FAILED\\n\",\n\t\t\tdev->name, bus->nr);\n\n\treturn bus->i2c_rc;\n}", "label": 0, "cwe": null, "length": 250 }, { "index": 973218, "code": "_cache_lookup(cache_t cache, const char *name)\n{\n\tstruct list_head *pos;\n\tstruct list_head *list;\n\t__cache_t *c = cache;\n\t__cache_e_t *cc;\n\tif (!c || !name)\n\t\treturn NULL;\t\n\tlist = &c->hash[hash_string(name) % HASH_SIZE];\n\tlist_for_each(pos, list) {\n\t\tcc = (__cache_e_t*)((__hash_item_t*)pos)->data;\n\t\tif (!strcmp(cc->name, name))\n\t\t\treturn cc;\n\t}\n\treturn NULL;\n}", "label": 0, "cwe": null, "length": 113 }, { "index": 87474, "code": "DoWorkDecode( MvData& out_data)\n{\n int step,max; \n int split_depth; \n int xstart,ystart; \n\n for (m_sb_yp = 0,m_sb_tlb_y = 0; m_sb_yp < out_data.SBSplit().LengthY(); ++m_sb_yp,m_sb_tlb_y += 4)\n {\n for (m_sb_xp = 0,m_sb_tlb_x = 0; m_sb_xp < out_data.SBSplit().LengthX(); ++m_sb_xp,m_sb_tlb_x += 4)\n {\n //start with split mode\n split_depth = out_data.SBSplit()[m_sb_yp][m_sb_xp]; \n step = 4 >> (split_depth); \n max = (1 << split_depth); \n\n //now do all the block mvs in the mb\n for (int j = 0; j < max; ++j)\n { \n for (int i = 0; i < max; ++i)\n {\n xstart = m_b_xp = m_sb_tlb_x + i * step; \n ystart = m_b_yp = m_sb_tlb_y + j * step; \n \n if(out_data.Mode()[m_b_yp][m_b_xp] == INTRA)\n {\n DecodeVal( out_data ); \n }\n \n // propagate throughout SB \n for (m_b_yp = ystart; m_b_yp < ystart+step; m_b_yp++)\n {\n for (m_b_xp = xstart; m_b_xp < xstart+step; m_b_xp++)\n { \n out_data.DC( m_csort )[m_b_yp][m_b_xp] = out_data.DC( m_csort )[ystart][xstart]; \n }//m_b_xp\n }//m_b_yp\n }//i \n }//j\n\n }//m_sb_xp\n }//m_sb_yp\n\n}", "label": 0, "cwe": null, "length": 446 }, { "index": 628866, "code": "updateSplinePoint(float dt) {\n if(parent == 0) return;\n\n //update the spline point\n vec2 td = (parent->getPos() - pos) * 0.5f;\n\n vec2 mid = pos + td;// - td.perpendicular() * pos.normal();// * 10.0;\n\n vec2 delta = (mid - spos);\n\n //dont let spos get more than half the length of the distance behind\n if(glm::length2(delta) > glm::length2(td)) {\n spos += normalise(delta) * (glm::length(delta) - glm::length(td));\n }\n\n spos += delta * std::min(1.0f, dt * 2.0f);\n}", "label": 0, "cwe": null, "length": 157 }, { "index": 118258, "code": "sqliteSrcListAppend(SrcList *pList, Token *pTable, Token *pDatabase){\n if( pList==0 ){\n pList = sqliteMalloc( sizeof(SrcList) );\n if( pList==0 ) return 0;\n pList->nAlloc = 1;\n }\n if( pList->nSrc>=pList->nAlloc ){\n SrcList *pNew;\n pList->nAlloc *= 2;\n pNew = sqliteRealloc(pList,\n sizeof(*pList) + (pList->nAlloc-1)*sizeof(pList->a[0]) );\n if( pNew==0 ){\n sqliteSrcListDelete(pList);\n return 0;\n }\n pList = pNew;\n }\n memset(&pList->a[pList->nSrc], 0, sizeof(pList->a[0]));\n if( pDatabase && pDatabase->z==0 ){\n pDatabase = 0;\n }\n if( pDatabase && pTable ){\n Token *pTemp = pDatabase;\n pDatabase = pTable;\n pTable = pTemp;\n }\n if( pTable ){\n char **pz = &pList->a[pList->nSrc].zName;\n sqliteSetNString(pz, pTable->z, pTable->n, 0);\n if( *pz==0 ){\n sqliteSrcListDelete(pList);\n return 0;\n }else{\n sqliteDequote(*pz);\n }\n }\n if( pDatabase ){\n char **pz = &pList->a[pList->nSrc].zDatabase;\n sqliteSetNString(pz, pDatabase->z, pDatabase->n, 0);\n if( *pz==0 ){\n sqliteSrcListDelete(pList);\n return 0;\n }else{\n sqliteDequote(*pz);\n }\n }\n pList->a[pList->nSrc].iCursor = -1;\n pList->nSrc++;\n return pList;\n}", "label": 0, "cwe": null, "length": 440 }, { "index": 450902, "code": "rpc_clnt_unset_connected (rpc_clnt_connection_t *conn)\n{\n if (!conn) {\n goto out;\n }\n\n pthread_mutex_lock (&conn->lock);\n {\n conn->connected = 0;\n }\n pthread_mutex_unlock (&conn->lock);\n\nout:\n return;\n}", "label": 0, "cwe": null, "length": 64 }, { "index": 46184, "code": "HpmfwupgAbortUpgrade(struct ipmi_intf *intf, struct HpmfwupgAbortUpgradeCtx* pCtx) \n{\n int rc = HPMFWUPG_SUCCESS;\n struct ipmi_rs * rsp;\n struct ipmi_rq req;\n \n pCtx->req.picmgId = HPMFWUPG_PICMG_IDENTIFIER;\n \n memset(&req, 0, sizeof(req));\n req.msg.netfn = IPMI_NETFN_PICMG;\n\treq.msg.cmd = HPMFWUPG_ABORT_UPGRADE;\n\treq.msg.data = (unsigned char*)&pCtx->req;\n\treq.msg.data_len = sizeof(struct HpmfwupgAbortUpgradeReq);\n \n rsp = HpmfwupgSendCmd(intf, req, NULL); \n \n if ( rsp )\n {\n if ( rsp->ccode != 0x00 )\n {\n lprintf(LOG_NOTICE,\"Error aborting upgrade, compcode = %x\\n\", rsp->ccode);\n rc = HPMFWUPG_ERROR;\n }\n }\n else\n {\n lprintf(LOG_NOTICE,\"Error aborting upgrade\\n\");\n rc = HPMFWUPG_ERROR;\n }\n return rc;\n}", "label": 0, "cwe": null, "length": 264 }, { "index": 279710, "code": "immediate_arithmetic_op_16(byte subcode,\n Register dst,\n Immediate src) {\n EnsureSpace ensure_space(this);\n emit(0x66); // Operand size override prefix.\n emit_optional_rex_32(dst);\n if (is_int8(src.value_)) {\n emit(0x83);\n emit_modrm(subcode, dst);\n emit(src.value_);\n } else if (dst.is(rax)) {\n emit(0x05 | (subcode << 3));\n emitw(src.value_);\n } else {\n emit(0x81);\n emit_modrm(subcode, dst);\n emitw(src.value_);\n }\n}", "label": 0, "cwe": null, "length": 143 }, { "index": 179131, "code": "nfs4_proc_renew(struct nfs_client *clp, struct rpc_cred *cred)\n{\n\tstruct rpc_message msg = {\n\t\t.rpc_proc\t= &nfs4_procedures[NFSPROC4_CLNT_RENEW],\n\t\t.rpc_argp\t= clp,\n\t\t.rpc_cred\t= cred,\n\t};\n\tunsigned long now = jiffies;\n\tint status;\n\n\tstatus = rpc_call_sync(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT);\n\tif (status < 0)\n\t\treturn status;\n\tdo_renew_lease(clp, now);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 124 }, { "index": 502673, "code": "error_watch (GIOChannel *source,\n GIOCondition condition,\n CkJob *job)\n{\n gboolean finished = FALSE;\n\n if (condition & G_IO_IN) {\n GIOStatus status;\n GError *error = NULL;\n char *line;\n\n line = NULL;\n status = g_io_channel_read_line (source, &line, NULL, NULL, &error);\n\n switch (status) {\n case G_IO_STATUS_NORMAL:\n g_debug (\"command error output: %s\", line);\n g_string_append (job->priv->std_err, line);\n break;\n case G_IO_STATUS_EOF:\n finished = TRUE;\n break;\n case G_IO_STATUS_ERROR:\n finished = TRUE;\n g_debug (\"Error reading from child: %s\\n\", error->message);\n break;\n case G_IO_STATUS_AGAIN:\n default:\n break;\n }\n g_free (line);\n } else if (condition & G_IO_HUP) {\n finished = TRUE;\n }\n\n if (finished) {\n job->priv->err_watch_id = 0;\n maybe_complete_job (job);\n return FALSE;\n }\n\n return TRUE;\n}", "label": 0, "cwe": null, "length": 258 }, { "index": 650892, "code": "create_new_chain (unsigned this_regno, unsigned this_nregs, rtx *loc,\n\t\t rtx insn, enum reg_class cl)\n{\n struct du_head *head = XOBNEW (&rename_obstack, struct du_head);\n struct du_chain *this_du;\n int nregs;\n\n head->next_chain = open_chains;\n head->regno = this_regno;\n head->nregs = this_nregs;\n head->need_caller_save_reg = 0;\n head->cannot_rename = 0;\n\n VEC_safe_push (du_head_p, heap, id_to_chain, head);\n head->id = current_id++;\n\n bitmap_initialize (&head->conflicts, &bitmap_default_obstack);\n bitmap_copy (&head->conflicts, &open_chains_set);\n mark_conflict (open_chains, head->id);\n\n /* Since we're tracking this as a chain now, remove it from the\n list of conflicting live hard registers and track it in\n live_in_chains instead. */\n nregs = head->nregs;\n while (nregs-- > 0)\n {\n SET_HARD_REG_BIT (live_in_chains, head->regno + nregs);\n CLEAR_HARD_REG_BIT (live_hard_regs, head->regno + nregs);\n }\n\n COPY_HARD_REG_SET (head->hard_conflicts, live_hard_regs);\n bitmap_set_bit (&open_chains_set, head->id);\n\n open_chains = head;\n\n if (dump_file)\n {\n fprintf (dump_file, \"Creating chain %s (%d)\",\n\t reg_names[head->regno], head->id);\n if (insn != NULL_RTX)\n\tfprintf (dump_file, \" at insn %d\", INSN_UID (insn));\n fprintf (dump_file, \"\\n\");\n }\n\n if (insn == NULL_RTX)\n {\n head->first = head->last = NULL;\n return head;\n }\n\n this_du = XOBNEW (&rename_obstack, struct du_chain);\n head->first = head->last = this_du;\n\n this_du->next_use = 0;\n this_du->loc = loc;\n this_du->insn = insn;\n this_du->cl = cl;\n record_operand_use (head, this_du);\n return head;\n}", "label": 0, "cwe": null, "length": 503 }, { "index": 914556, "code": "gee_tree_map_entry_set_real_first (GeeAbstractSortedSet* base) {\n\tGeeTreeMapEntrySet * self;\n\tGeeMapEntry* result = NULL;\n\tGeeTreeMap* _tmp0_ = NULL;\n\tGeeTreeMapNode* _tmp1_ = NULL;\n\tGeeTreeMap* _tmp2_ = NULL;\n\tGeeTreeMapNode* _tmp3_ = NULL;\n\tGeeMapEntry* _tmp4_ = NULL;\n\tself = (GeeTreeMapEntrySet*) base;\n\t_tmp0_ = self->priv->_map;\n\t_tmp1_ = _tmp0_->priv->first;\n\t_vala_assert (_tmp1_ != NULL, \"_map.first != null\");\n\t_tmp2_ = self->priv->_map;\n\t_tmp3_ = _tmp2_->priv->first;\n\t_tmp4_ = gee_tree_map_entry_entry_for (self->priv->k_type, (GBoxedCopyFunc) self->priv->k_dup_func, self->priv->k_destroy_func, self->priv->v_type, (GBoxedCopyFunc) self->priv->v_dup_func, self->priv->v_destroy_func, _tmp3_);\n\tresult = _tmp4_;\n\treturn result;\n}", "label": 0, "cwe": null, "length": 261 }, { "index": 937313, "code": "get_host(char *const name, struct addrinfo *res, int ai_family)\n{\n struct addrinfo *chain, *ap;\n struct addrinfo hints;\n int ret_val;\n\n#ifdef HAVE_INET_NTOP\n memset (&hints, 0, sizeof(hints));\n hints.ai_family = ai_family;\n hints.ai_socktype = SOCK_STREAM;\n hints.ai_flags = AI_CANONNAME;\n if((ret_val = getaddrinfo(name, NULL, &hints, &chain)) == 0) {\n#ifdef _AIX\n ap = chain;\n#else\n for(ap = chain; ap != NULL; ap = ap->ai_next)\n if(ap->ai_socktype == SOCK_STREAM)\n break;\n#endif\n if(ap == NULL) {\n freeaddrinfo(chain);\n return EAI_NONAME;\n }\n *res = *ap;\n if((res->ai_addr = (struct sockaddr *)malloc(ap->ai_addrlen)) == NULL) {\n freeaddrinfo(chain);\n return EAI_MEMORY;\n }\n memcpy(res->ai_addr, ap->ai_addr, ap->ai_addrlen);\n freeaddrinfo(chain);\n }\n#else\n#error \"Pound requires getaddrinfo()\"\n#endif\n return ret_val;\n}", "label": 0, "cwe": null, "length": 268 }, { "index": 875891, "code": "simplify_stream (GSList * stream,\n\t\t\t\t gdouble maxcost)\n{\n GSList * i = stream;\n GSList * s = NULL;\n GtsPoint * p1 = NULL, * p2 = NULL;\n gdouble cost = 0.;\n\n while (i) {\n GtsPoint * p = i->data;\n\n if (p1 == NULL) { \n p1 = p;\n s = g_slist_prepend (s, p);\n }\n else if (p2 == NULL)\n p2 = p;\n else {\n cost += curve_cost (p1, p2, p);\n p1 = p2;\n p2 = p;\n if (cost > maxcost || !i->next) {\n\ts = g_slist_prepend (s, p);\n\tcost = 0.;\n }\n else\n\tGTS_OBJECT (p)->reserved = p;\n }\n i = i->next;\n }\n i = stream;\n while (i) {\n if (GTS_OBJECT (i->data)->reserved == i->data)\n gts_object_destroy (i->data);\n i = i->next;\n }\n g_slist_free (stream);\n return s;\n}", "label": 1, "cwe": "CWE-476", "length": 269 }, { "index": 528635, "code": "requested_work() {\n for (int i=0; i &gotoset, const FuncMap &funcmap, const map &intrinsics)\n{\n\tfor(vector::iterator i=gotoset.begin(); i!=gotoset.end(); ++i)\n\t{\n\t\tparse_ucs_pass2a((*i)().rbegin(), (*i)(), 0, funcmap, intrinsics);\n\t}\n}", "label": 0, "cwe": null, "length": 90 }, { "index": 67034, "code": "objectArrived(const Root& obj)\n{\n#ifdef ATLAS_LOG\n std::stringstream debugStream;\n Atlas::Codecs::Bach debugCodec(debugStream, *this /* dummy */);\n Atlas::Objects::ObjectsEncoder debugEncoder(debugCodec);\n debugEncoder.streamObjectsMessage(obj);\n debugStream << std::flush;\n\n std::cout << \"received:\" << debugStream.str() << std::endl;\n#endif\n RootOperation op = smart_dynamic_cast(obj);\n if (op.isValid()) {\n m_opDeque.push_back(op);\n } else\n error() << \"Con::objectArrived got non-op\";\n}", "label": 0, "cwe": null, "length": 137 }, { "index": 25518, "code": "fuse_writepages_send(struct fuse_fill_wb_data *data)\n{\n\tstruct fuse_req *req = data->req;\n\tstruct inode *inode = data->inode;\n\tstruct fuse_conn *fc = get_fuse_conn(inode);\n\tstruct fuse_inode *fi = get_fuse_inode(inode);\n\tint num_pages = req->num_pages;\n\tint i;\n\n\treq->ff = fuse_file_get(data->ff);\n\tspin_lock(&fc->lock);\n\tlist_add_tail(&req->list, &fi->queued_writes);\n\tfuse_flush_writepages(inode);\n\tspin_unlock(&fc->lock);\n\n\tfor (i = 0; i < num_pages; i++)\n\t\tend_page_writeback(data->orig_pages[i]);\n}", "label": 0, "cwe": null, "length": 143 }, { "index": 363924, "code": "camlidl_abstract0_ap_abstract0_add_dimensions(\n\tvalue _v_man,\n\tvalue _v_a,\n\tvalue _v_dimchange,\n\tvalue _v_project)\n{\n ap_manager_ptr man; /*in*/\n ap_abstract0_ptr a; /*in*/\n ap_dimchange_t dimchange; /*in*/\n int project; /*in*/\n ap_abstract0_ptr _res;\n value _vres;\n\n struct camlidl_ctx_struct _ctxs = { CAMLIDL_TRANSIENT, NULL };\n camlidl_ctx _ctx = &_ctxs;\n camlidl_ml2c_manager_ap_manager_ptr(_v_man, &man, _ctx);\n camlidl_ml2c_abstract0_ap_abstract0_ptr(_v_a, &a, _ctx);\n camlidl_ml2c_dim_ap_dimchange_t(_v_dimchange, &dimchange, _ctx);\n project = Int_val(_v_project);\n /* begin user-supplied calling sequence */\n_res = ap_abstract0_add_dimensions(man,false,a,&dimchange, project);ap_dimchange_clear(&dimchange);\n /* end user-supplied calling sequence */\n _vres = camlidl_c2ml_abstract0_ap_abstract0_ptr(&_res, _ctx);\n camlidl_free(_ctx);\n /* begin user-supplied deallocation sequence */\nif (man->result.exn!=AP_EXC_NONE) camlidl_apron_manager_check_exception(man,_ctx);\n /* end user-supplied deallocation sequence */\n return _vres;\n}", "label": 0, "cwe": null, "length": 319 }, { "index": 954348, "code": "charset_best_mask (unsigned int mask)\n{\n\tconst char *lang;\n\tguint i;\n\t\n\tfor (i = 0; i < G_N_ELEMENTS (charinfo); i++) {\n\t\tif (charinfo[i].bit & mask) {\n\t\t\tlang = g_mime_charset_language (charinfo[i].name);\n\t\t\t\n\t\t\tif (!lang || (locale_lang && !strncmp (locale_lang, lang, 2)))\n\t\t\t\treturn charinfo[i].name;\n\t\t}\n\t}\n\t\n\treturn \"UTF-8\";\n}", "label": 0, "cwe": null, "length": 108 }, { "index": 51628, "code": "katoob_info(const std::string& message) {\n Gtk::MessageDialog dlg(message, false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK, true);\n dlg.run();\n}", "label": 0, "cwe": null, "length": 41 }, { "index": 46498, "code": "setValue(int type, const QVariant &val, const QString &language)\n{\n// qWarning() << \"SPEC\" << type << val << language;\n if (type == Spec_Uuid) {\n d->m_Uuid = val.toString();\n return;\n }\n QString l = language;\n if (language.isEmpty())\n l = Trans::Constants::ALL_LANGUAGE;\n SpecsBook *values = d->createLanguage(l);\n values->m_Specs.insert(type,val);\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 500784, "code": "wasp_string_append(\n wasp_string string, const void* src, wasp_integer srclen \n){\n wasp_integer endpos = string->length + string->origin;\n\n if( srclen < ( string->capacity - endpos ) ){\n string->length += srclen;\n memmove( string->pool + endpos, src, srclen );\n }else{\n wasp_string_alter( string, string->length, 0, src, srclen );\n }\n}", "label": 0, "cwe": null, "length": 111 }, { "index": 122086, "code": "prog_err_file(const char *path)\n{\n\tMsg *mesg;\n\n\tif (!(mesg = msg_create_file_with_locker(g.locker, path)))\n\t\treturn -1;\n\n\tif (!prog_set_err(mesg))\n\t{\n\t\tmsg_release(mesg);\n\t\treturn -1;\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 68 }, { "index": 59963, "code": "main() // valid in C++, (void) in C\n{\n std::list > list;\n\n for (int i = 1; i < 6; ++i)\n {\n std::deque coll;\n for (int j = 1; j < 6; ++j)\n {\n coll.push_front(((float)i/j));\n }\n list.push_back(coll);\n\n }\n\n for (std::list >::const_iterator list_iter = list.begin();\n list_iter != list.end();\n ++list_iter)\n {\n for (std::deque::const_iterator deque_iter = list_iter->begin();\n deque_iter != list_iter->end();\n ++deque_iter)\n {\n float item = *deque_iter;\n std::cout << item << \", \";\n }\n std::cout << std::endl;\n }\n\n return 0;\n}", "label": 0, "cwe": null, "length": 197 }, { "index": 425066, "code": "start_template(template_symbol const* symbol)\n {\n // Quickbook 1.4-: When expanding the template continue to use the\n // current scope (the dynamic scope).\n // Quickbook 1.5+: Use the scope the template was defined in\n // (the static scope).\n if (symbol->content.get_file()->version() >= 105u)\n {\n parent_1_4 = scopes.front().parent_1_4;\n scopes.front().parent_scope = symbol->lexical_parent;\n }\n else\n {\n scopes.front().parent_scope = scopes.front().parent_1_4;\n }\n }\n}", "label": 0, "cwe": null, "length": 140 }, { "index": 118293, "code": "_isExtensionSingleton(const char* s, int32_t len) {\n /*\n * extension = singleton 1*(\"-\" (2*8alphanum))\n */\n if (len < 0) {\n len = (int32_t)uprv_strlen(s);\n }\n if (len == 1 && ISALPHA(*s) && (uprv_tolower(*s) != PRIVATEUSE)) {\n return TRUE;\n }\n return FALSE;\n}", "label": 0, "cwe": null, "length": 101 }, { "index": 433652, "code": "reserve_real_mode(void)\n{\n\tphys_addr_t mem;\n\tunsigned char *base;\n\tsize_t size = PAGE_ALIGN(real_mode_blob_end - real_mode_blob);\n\n\t/* Has to be under 1M so we can execute real-mode AP code. */\n\tmem = memblock_find_in_range(0, 1 << 20, size,\n\t\t\t\t KAISER_KERNEL_PGD_ALIGNMENT);\n\tif (!mem)\n\t\tpanic(\"Cannot allocate trampoline\\n\");\n\n\tbase = __va(mem);\n\tmemblock_reserve(mem, size);\n\treal_mode_header = (struct real_mode_header *) base;\n\tprintk(KERN_DEBUG \"Base memory trampoline at [%p] %llx size %zu\\n\",\n\t base, (unsigned long long)mem, size);\n}", "label": 0, "cwe": null, "length": 149 }, { "index": 197165, "code": "connman_device_disconnect_service(struct connman_device *device)\n{\n\tDBG(\"device %p\", device);\n\n\tdevice->reconnect = FALSE;\n\n\tif (device->network) {\n\t\tstruct connman_service *service =\n\t\t\tconnman_service_lookup_from_network(device->network);\n\n\t\tif (service != NULL)\n\t\t\t__connman_service_disconnect(service);\n\t\telse\n\t\t\tconnman_network_set_connected(device->network, FALSE);\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 93 }, { "index": 100286, "code": "worker_flush_chunk(worker_t *worker, char *chunked, int from, int to,\n apr_pool_t *ptmp) {\n apr_status_t status;\n int len;\n\n if (chunked) {\n worker_log_buf(worker, LOG_INFO, '>', chunked, strlen(chunked));\n }\n\n if (chunked) {\n len = strlen(chunked);\n if ((status = worker_socket_send(worker, chunked, len)) != APR_SUCCESS) {\n return status;\n }\n worker->sent += len;\n }\n\n return worker_flush_part(worker, from, to, ptmp);\n}", "label": 0, "cwe": null, "length": 130 }, { "index": 364948, "code": "jutil_header(char *xmlns, char *server)\n{\n\txmlnode result;\n\tif ((xmlns == NULL) || (server == NULL))\n\t\treturn NULL;\n\tresult = xmlnode_new_tag(\"stream:stream\");\n\txmlnode_put_attrib(result, \"xmlns:stream\",\n\t\t\"http://etherx.jabber.org/streams\");\n\txmlnode_put_attrib(result, \"xmlns\", xmlns);\n\txmlnode_put_attrib(result, \"to\", server);\n\n\treturn result;\n}", "label": 0, "cwe": null, "length": 94 }, { "index": 91477, "code": "archive_read_open2(struct archive *_a, void *client_data,\n archive_open_callback *client_opener,\n archive_read_callback *client_reader,\n archive_skip_callback *client_skipper,\n archive_close_callback *client_closer)\n{\n struct archive_read *a = (struct archive_read *)_a;\n struct archive_read_filter *filter;\n int e;\n\n __archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,\n \"archive_read_open\");\n archive_clear_error(&a->archive);\n\n if (client_reader == NULL)\n __archive_errx(1,\n \"No reader function provided to archive_read_open\");\n\n /* Open data source. */\n if (client_opener != NULL) {\n e =(client_opener)(&a->archive, client_data);\n if (e != 0) {\n /* If the open failed, call the closer to clean up. */\n if (client_closer)\n (client_closer)(&a->archive, client_data);\n return (e);\n }\n }\n\n /* Save the client functions and mock up the initial source. */\n a->client.reader = client_reader;\n a->client.skipper = client_skipper;\n a->client.closer = client_closer;\n\n filter = calloc(1, sizeof(*filter));\n if (filter == NULL)\n return (ARCHIVE_FATAL);\n filter->bidder = NULL;\n filter->upstream = NULL;\n filter->archive = a;\n filter->data = client_data;\n filter->read = client_read_proxy;\n filter->skip = client_skip_proxy;\n filter->close = client_close_proxy;\n filter->name = \"none\";\n filter->code = ARCHIVE_COMPRESSION_NONE;\n a->filter = filter;\n\n /* Build out the input pipeline. */\n e = build_stream(a);\n if (e == ARCHIVE_OK)\n a->archive.state = ARCHIVE_STATE_HEADER;\n\n return (e);\n}", "label": 0, "cwe": null, "length": 420 }, { "index": 361774, "code": "Destroy_frame(struct state *st)\n{\n int i;\n\n for (i=st->frame; imaxframe; i++) {\n st->exponents[st->frame] = st->exponents[st->frame+1];\n st->expind[st->frame] = st->expind[st->frame+1];\n st->a_minimums[st->frame] = st->a_minimums[st->frame+1];\n st->b_minimums[st->frame] = st->b_minimums[st->frame+1];\n st->a_maximums[st->frame] = st->a_maximums[st->frame+1];\n st->b_maximums[st->frame] = st->b_maximums[st->frame+1];\n }\n st->maxframe--;\n go_back(st);\n}", "label": 0, "cwe": null, "length": 186 }, { "index": 571152, "code": "time_to_string_text (gint64 msecs)\n{\n\tchar *secs, *mins, *hours, *string;\n\tint sec, min, hour, _time;\n\n\t_time = (int) (msecs / 1000);\n\tsec = _time % 60;\n\t_time = _time - sec;\n\tmin = (_time % (60*60)) / 60;\n\t_time = _time - (min * 60);\n\thour = _time / (60*60);\n\n\thours = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE, \"%d hour\", \"%d hours\", hour), hour);\n\n\tmins = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE, \"%d minute\",\n\t\t\t\t\t \"%d minutes\", min), min);\n\n\tsecs = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE, \"%d second\",\n\t\t\t\t\t \"%d seconds\", sec), sec);\n\n\tif (hour > 0)\n\t{\n\t\t/* 5 hours 2 minutes 12 seconds */\n\t\tstring = g_strdup_printf (C_(\"time\", \"%s %s %s\"), hours, mins, secs);\n\t} else if (min > 0) {\n\t\t/* 2 minutes 12 seconds */\n\t\tstring = g_strdup_printf (C_(\"time\", \"%s %s\"), mins, secs);\n\t} else if (sec > 0) {\n\t\t/* 10 seconds */\n\t\tstring = g_strdup (secs);\n\t} else {\n\t\t/* 0 seconds */\n\t\tstring = g_strdup (_(\"0 seconds\"));\n\t}\n\n\tg_free (hours);\n\tg_free (mins);\n\tg_free (secs);\n\n\treturn string;\n}", "label": 0, "cwe": null, "length": 342 }, { "index": 599211, "code": "iso7816_decipher (int slot, int extended_mode, \n const unsigned char *data, size_t datalen, int le,\n int padind, unsigned char **result, size_t *resultlen)\n{\n int sw;\n unsigned char *buf;\n\n if (!data || !datalen || !result || !resultlen)\n return gpg_error (GPG_ERR_INV_VALUE);\n *result = NULL;\n *resultlen = 0;\n\n if (!extended_mode)\n le = 256; /* Ignore provided Le and use what apdu_send uses. */\n else if (le >= 0 && le < 256)\n le = 256;\n\n if (padind >= 0)\n {\n /* We need to prepend the padding indicator. */\n buf = xtrymalloc (datalen + 1);\n if (!buf)\n return gpg_error (gpg_err_code_from_errno (errno));\n \n *buf = padind; /* Padding indicator. */\n memcpy (buf+1, data, datalen);\n sw = apdu_send_le (slot, extended_mode, \n 0x00, CMD_PSO, 0x80, 0x86,\n datalen+1, (char*)buf, le,\n result, resultlen);\n xfree (buf);\n }\n else\n {\n sw = apdu_send_le (slot, extended_mode,\n 0x00, CMD_PSO, 0x80, 0x86,\n datalen, (const char *)data, le,\n result, resultlen);\n }\n if (sw != SW_SUCCESS)\n {\n /* Make sure that pending buffers are released. */\n xfree (*result);\n *result = NULL;\n *resultlen = 0;\n return map_sw (sw);\n }\n\n return 0;\n}", "label": 1, "cwe": "CWE-120", "length": 400 }, { "index": 435949, "code": "qlist_clear(qlist_t *list) {\n qlist_lock(list);\n qlist_obj_t *obj;\n for (obj = list->first; obj;) {\n qlist_obj_t *next = obj->next;\n free(obj->data);\n free(obj);\n obj = next;\n }\n\n list->num = 0;\n list->datasum = 0;\n list->first = NULL;\n list->last = NULL;\n qlist_unlock(list);\n}", "label": 1, "cwe": "CWE-120", "length": 105 }, { "index": 949855, "code": "Exonerate_Server_get_seq(Dataset *dataset, gint num){\n register Dataset_Sequence *ds;\n register Sequence *seq;\n register gchar *str, *reply;\n if((num >= 0) && (num < dataset->seq_list->len)){\n ds = dataset->seq_list->pdata[num];\n seq = Dataset_get_sequence(dataset, num);\n str = Sequence_get_str(seq);\n Sequence_destroy(seq);\n reply = g_strdup_printf(\"seq: %s\\n\", str);\n g_free(str);\n } else {\n reply = g_strdup_printf(\"error: sequence num out of range [%d]\\n\", num);\n }\n return reply;\n }", "label": 0, "cwe": null, "length": 144 }, { "index": 863911, "code": "SetSection(const char *name,\n const char *docs[][3])\n{\n cmDocumentationSection *sec =\n new cmDocumentationSection(name,\n cmSystemTools::UpperCase(name).c_str());\n sec->Append(docs);\n this->SetSection(name,sec);\n}", "label": 0, "cwe": null, "length": 58 }, { "index": 81435, "code": "insertArr (vararr_t* arr, pointf p, double l)\n{\n if (arr->cnt >= arr->sz) {\n\tarr->sz *= 2;\n\tarr->pts = RALLOC(arr->sz,arr->pts,pathpoint);\n }\n\n arr->pts[arr->cnt].x = p.x; \n arr->pts[arr->cnt].y = p.y; \n arr->pts[arr->cnt++].lengthsofar = l; \n}", "label": 0, "cwe": null, "length": 98 }, { "index": 820482, "code": "nvme_ext_write_doorbell(u16 value, u32 __iomem* q_db,\n\t\t\t u32* db_addr, volatile u32* event_idx)\n{\n\tu16 old_value;\n\tif (!db_addr)\n\t\tgoto ring_doorbell;\n\n\told_value = *db_addr;\n\t*db_addr = value;\n\n\trmb();\n\tif (!nvme_ext_need_event(*event_idx, value, old_value))\n\t\tgoto no_doorbell;\n\nring_doorbell:\n\twritel(value, q_db);\nno_doorbell:\n\treturn;\n}", "label": 0, "cwe": null, "length": 107 }, { "index": 679348, "code": "writeDefaultValue(const TypePtr& p)\n{\n BuiltinPtr builtin = BuiltinPtr::dynamicCast(p);\n if(builtin)\n {\n switch(builtin->kind())\n {\n case Builtin::KindBool:\n {\n _out << \"False\";\n break;\n }\n case Builtin::KindByte:\n case Builtin::KindShort:\n case Builtin::KindInt:\n case Builtin::KindLong:\n {\n _out << \"0\";\n break;\n }\n case Builtin::KindFloat:\n case Builtin::KindDouble:\n {\n _out << \"0.0\";\n break;\n }\n case Builtin::KindString:\n {\n _out << \"''\";\n break;\n }\n case Builtin::KindObject:\n case Builtin::KindObjectProxy:\n case Builtin::KindLocalObject:\n {\n _out << \"None\";\n break;\n }\n }\n return;\n }\n\n EnumPtr en = EnumPtr::dynamicCast(p);\n if(en)\n {\n EnumeratorList enums = en->getEnumerators();\n _out << getSymbol(en) << \".\" << fixIdent(enums.front()->name());\n return;\n }\n\n StructPtr st = StructPtr::dynamicCast(p);\n if(st)\n {\n //\n // We cannot emit a call to the struct's constructor here because Python\n // only evaluates this expression once (see bug 3676). Instead, we emit\n // a marker that allows us to determine whether the application has\n // supplied a value.\n //\n _out << \"Ice._struct_marker\";\n return;\n }\n\n _out << \"None\";\n}", "label": 0, "cwe": null, "length": 362 }, { "index": 5166, "code": "parse_values(const TCHAR *ins, TCHAR *out)\n{\n\tint ident = 0;\n\tTCHAR tmp;\n\tTCHAR inbuf[IOBUFFERS];\n\tint op;\n\n\t_tcscpy (inbuf, ins);\n\tTCHAR *in = inbuf;\n\tTCHAR *p = out;\n\top = 0;\n\tif (in[0] == '-' || in[0] == '+') {\n\t\t*p++ = '0';\n\t}\n\twhile (*in) {\n\t\tTCHAR *instart = in;\n\t\tif (_istdigit (*in)) {\n\t\t\tif (ident >= MAX_VALUES)\n\t\t\t\treturn false;\n\t\t\tif (op > 1 && (in[-1] == '-' || in[-1] == '+')) {\n\t\t\t\tinstart--;\n\t\t\t\tp--;\n\t\t\t}\n\t\t\t*p++ = ident + 'a';\n\t\t\twhile (_istdigit (*in) || *in == '.')\n\t\t\t\tin++;\n\t\t\ttmp = *in;\n\t\t\t*in = 0;\n\t\t\tparsedvalues[ident++] = _tstof (instart);\n\t\t\t*in = tmp;\n\t\t\top = 0;\n\t\t} else {\n\t\t\tif (is_operator(*in))\n\t\t\t\top++;\n\t\t\t*p++ = *in++;\n\t\t}\n\t}\n\t*p = 0;\n\treturn true;\n}", "label": 0, "cwe": null, "length": 270 }, { "index": 735978, "code": "prepare_data(u8 cmd, struct sk_buff **skbp, size_t size)\n{\n\tstruct sk_buff *skb;\n\tvoid *data;\n\n\tskb = genlmsg_new(size, GFP_NOFS);\n\tif (!skb)\n\t\treturn -ENOMEM;\n\n\t/* add the message headers */\n\tdata = genlmsg_put(skb, 0, dlm_nl_seqnum++, &family, 0, cmd);\n\tif (!data) {\n\t\tnlmsg_free(skb);\n\t\treturn -EINVAL;\n\t}\n\n\t*skbp = skb;\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 114 }, { "index": 36930, "code": "convolution_filter_size_changed(GtkToggleButton *button,\n ConvolutionControls *controls)\n{\n guint newsize;\n\n if (controls->in_update)\n return;\n if (!gtk_toggle_button_get_active(button))\n return;\n\n newsize = gwy_radio_buttons_get_current(controls->sizes);\n gwy_convolution_filter_preset_data_resize(&controls->args->preset->data,\n newsize);\n convolution_filter_resize_matrix(controls);\n convolution_filter_update_matrix(controls);\n convolution_filter_update_symmetry(controls);\n controls->computed = FALSE;\n gwy_resource_data_changed(GWY_RESOURCE(controls->args->preset));\n}", "label": 0, "cwe": null, "length": 136 }, { "index": 29302, "code": "snd_pcm_route_hw_refine_sprepare(snd_pcm_t *pcm, snd_pcm_hw_params_t *sparams)\n{\n\tsnd_pcm_route_t *route = pcm->private_data;\n\tsnd_pcm_access_mask_t saccess_mask = { SND_PCM_ACCBIT_MMAP };\n\t_snd_pcm_hw_params_any(sparams);\n\t_snd_pcm_hw_param_set_mask(sparams, SND_PCM_HW_PARAM_ACCESS,\n\t\t\t\t &saccess_mask);\n\tif (route->sformat != SND_PCM_FORMAT_UNKNOWN) {\n\t\t_snd_pcm_hw_params_set_format(sparams, route->sformat);\n\t\t_snd_pcm_hw_params_set_subformat(sparams, SND_PCM_SUBFORMAT_STD);\n\t}\n\tif (route->schannels >= 0) {\n\t\t_snd_pcm_hw_param_set(sparams, SND_PCM_HW_PARAM_CHANNELS,\n\t\t\t\t (unsigned int) route->schannels, 0);\n\t}\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 184 }, { "index": 539098, "code": "_select_nodes_parts(struct job_record *job_ptr, bool test_only,\n\t\t\t bitstr_t **select_node_bitmap)\n{\n\tstruct part_record *part_ptr;\n\tListIterator iter;\n\tint rc = ESLURM_REQUESTED_PART_CONFIG_UNAVAILABLE;\n\n\tif (job_ptr->part_ptr_list) {\n\t\titer = list_iterator_create(job_ptr->part_ptr_list);\n\t\twhile ((part_ptr = list_next(iter))) {\n\t\t\tjob_ptr->part_ptr = part_ptr;\n\t\t\tdebug2(\"Try job %u on next partition %s\",\n\t\t\t job_ptr->job_id, part_ptr->name);\n\t\t\tif (job_limits_check(&job_ptr, false) != WAIT_NO_REASON)\n\t\t\t\tcontinue;\n\t\t\trc = select_nodes(job_ptr, test_only,\n\t\t\t\t\t select_node_bitmap);\n\t\t\tif ((rc != ESLURM_REQUESTED_NODE_CONFIG_UNAVAILABLE) &&\n\t\t\t (rc != ESLURM_REQUESTED_PART_CONFIG_UNAVAILABLE))\n\t\t\t\tbreak;\n\t\t}\n\t\tlist_iterator_destroy(iter);\n\t} else {\n\t\tif (job_limits_check(&job_ptr, false) != WAIT_NO_REASON)\n\t\t\ttest_only = true;\n\t\trc = select_nodes(job_ptr, test_only, select_node_bitmap);\n\t}\n\n\treturn rc;\n}", "label": 0, "cwe": null, "length": 245 }, { "index": 465277, "code": "cpor_tag_thread(void *args)\n{\n struct pdp_job_arg *arg = (struct pdp_job_arg *) args;\n pdp_ctx_t *ctx;\n pdp_cpor_ctx_t *p;\n pdp_cpor_tag_t *tag = NULL;\n int *ret = NULL;\n unsigned char *buf = NULL;\n size_t buf_len = 0;\n unsigned int i, block;\n\n if (!arg || !arg->ctx || !arg->key || !arg->file ||\n !arg->td || !arg->numblocks)\n goto cleanup;\n ctx = arg->ctx; \n p = ctx->cpor_param;\n\n // allocate memory for return value (will be freed by producer thread)\n if ((ret = malloc(sizeof(int))) == NULL)\n goto cleanup;\n *ret = -1;\n\n // allocate temp memory for reading a block and generating a tag / digest\n buf_len = sizeof(unsigned char) * p->block_size;\n if ((buf = malloc(buf_len)) == NULL) goto cleanup;\n\n // For N threads, read and tag every N-th block\n block = arg->index;\n for (i = 0; i < arg->numblocks; i++) {\n memset(buf, 0, buf_len);\n tag = NULL;\n\n // read file data\n fseek(arg->file, block * p->block_size, SEEK_SET);\n fread(buf, 1, buf_len, arg->file);\n if (ferror(arg->file)) goto cleanup;\n\n // tag the block\n if (cpor_tag_block(ctx, arg->key, arg->td, \n buf, buf_len, block, &tag) != 0)\n goto cleanup; \n\n // store the computed digest to correct location in tags output buffer\n arg->td->tags[block] = tag;\n\n block += ctx->num_threads;\n }\n *ret = 0;\n\ncleanup:\n if (!ret || (ret && *ret))\n PDP_ERR(\"some thread was unable to create a tag.\");\n sfree(buf, buf_len);\n#ifdef _THREAD_SUPPORT\n if (ctx->num_threads > 1)\n pthread_exit(ret);\n#endif\n return ret;\n}", "label": 1, "cwe": "CWE-other", "length": 476 }, { "index": 816340, "code": "smartmode(void)\n{\n\tint\tret, tries;\n\tchar\ttemp[256];\n\n\tfor (tries = 0; tries < 5; tries++) {\n\n\t\tret = ser_send_char(upsfd, APC_GOSMART);\n\n\t\tif (ret != 1) {\n\t\t\tupslog_with_errno(LOG_ERR, \"smartmode: ser_send_char failed\");\n\t\t\treturn 0;\n\t\t}\n\n\t\tret = ser_get_line(upsfd, temp, sizeof(temp), ENDCHAR, \n\t\t\tIGNCHARS, SER_WAIT_SEC, SER_WAIT_USEC);\n\n\t\tif (ret > 0)\n\t\t\tif (!strcmp(temp, \"SM\"))\n\t\t\t\treturn 1;\t/* success */\n\n\t\tsleep(1);\t/* wait before trying again */\n\n\t\t/* it failed, so try to bail out of menus on newer units */\n\n\t\tret = ser_send_char(upsfd, 27);\t/* ESC */\n\n\t\tif (ret != 1) {\n\t\t\tupslog_with_errno(LOG_ERR, \"smartmode: ser_send_char failed\");\n\t\t\treturn 0;\n\t\t}\n\n\t\t/* eat the response (might be NA, might be something else) */\n\t\tret = ser_get_line(upsfd, temp, sizeof(temp), ENDCHAR, \n\t\t\tIGNCHARS, SER_WAIT_SEC, SER_WAIT_USEC);\n\t}\n\n\treturn 0;\t/* failure */\n}", "label": 0, "cwe": null, "length": 285 }, { "index": 84352, "code": "NET_QueryPrintCallback(net_addr_t *addr,\n net_querydata_t *data,\n unsigned int ping_time,\n void *user_data)\n{\n // If this is the first server, print the header.\n\n if (!printed_header)\n {\n PrintHeader();\n printed_header = true;\n }\n\n formatted_printf(5, \"%4i\", ping_time);\n formatted_printf(18, \"%s: \", NET_AddrToString(addr));\n formatted_printf(8, \"%i/%i\", data->num_players, \n data->max_players);\n\n if (data->gamemode != indetermined)\n {\n printf(\"(%s) \", GameDescription(data->gamemode, \n data->gamemission));\n }\n\n if (data->server_state)\n {\n printf(\"(game running) \");\n }\n\n NET_SafePuts(data->description);\n}", "label": 0, "cwe": null, "length": 183 }, { "index": 307920, "code": "verify_result(GObject *object, const char *result, gboolean done, void *user_data)\n{\n\tgboolean *verify_completed = user_data;\n\tg_print(\"Verify result: %s (%s)\\n\", result, done ? \"done\" : \"not done\");\n\tif (done != FALSE)\n\t\t*verify_completed = TRUE;\n}", "label": 0, "cwe": null, "length": 71 }, { "index": 30969, "code": "integer_nonzerop (tree expr)\n{\n STRIP_NOPS (expr);\n\n return ((TREE_CODE (expr) == INTEGER_CST\n\t && ! TREE_CONSTANT_OVERFLOW (expr)\n\t && (TREE_INT_CST_LOW (expr) != 0\n\t || TREE_INT_CST_HIGH (expr) != 0))\n\t || (TREE_CODE (expr) == COMPLEX_CST\n\t && (integer_nonzerop (TREE_REALPART (expr))\n\t\t || integer_nonzerop (TREE_IMAGPART (expr)))));\n}", "label": 0, "cwe": null, "length": 112 }, { "index": 18943, "code": "BinaryOrderedWalsh( int k, double x )\n{\n // BINARY ORDERED WALSH FUNCTION\n // walsh\n //\n // Let K be a binary number, i.e.,\n // K = a(0)*2^0 + a(1)*2^1 + a(2)*2^2 + a(3)*2^3 + ... with a(i) = 0 or 1, i=0,1,2,...\n // then WALSH(K,X)= (RADMAC(0,X)^a(0)) * (RADMAC(1,X)^a(1)) * ...\n // Again, the WALSH functions form a complete set of orthogonal,\n // normalized rectangular periodic functions with period of one.\n // where K=non-negative integer, X is real\n // NB. WALSH can assume values of 1 or -1 only.\n //\n // REFERENCE: CACM ALGORITHMS # 389\n //\n int const j = k;\n int m = 1;\n int mw = 1;\n double result = 1.0;\n int i = -1;\n while( m <= j )\n {\n ++i;\n if( static_cast(k/(2.0*m)) != k/(2*m) )\n {\n mw *= static_cast(Rademacher(i,x));\n k -= m;\n }\n result = mw;\n m *= 2;\n }\n return result;\n}", "label": 0, "cwe": null, "length": 319 }, { "index": 691290, "code": "utl_GetHeaderString (str, separ)\n\nchar *str ;\nchar separ;\n\n {\n char *head = NULL;\n int found = 0 ;\n int i = 0 ;\n\n if (str != NULL)\n {\n while (str [i] != '\\0')\n {\n if (str [i] == separ)\n {\n found = 1;\n break;\n }\n i++;\n }\n\n if (found != 0)\n head = utl_SaveNString (str, i);\n else\n head = utl_SaveString (str );\n }\n\n return (head);\n }", "label": 0, "cwe": null, "length": 144 }, { "index": 862872, "code": "doDial(AuServer *aud, char *dialString, int volume, int pause, int spacing,\n int duration)\n{\n AuDeviceID outputDevice = AuNone;\n AuFlowID flow;\n int i;\n\n /* make sure the server supports wave form elements */\n for (i = 0; i < AuServerNumElementTypes(aud); i++)\n\tif (AuServerElementType(aud, i) == AuElementTypeImportWaveForm)\n\t break;\n\n if (i == AuServerNumElementTypes(aud))\n\tfatalError(\"audio server does not support the wave form element type\", NULL);\n\n /* make sure the server supports sine waves */\n for (i = 0; i < AuServerNumWaveForms(aud); i++)\n\tif (AuServerWaveForm(aud, i) == AuWaveFormSine)\n\t break;\n\n if (i == AuServerNumWaveForms(aud))\n\tfatalError(\"audio server does not support sine waves\", NULL);\n\n /* look for an appropriate output device */\n for (i = 0; i < AuServerNumDevices(aud); i++)\n\tif ((AuDeviceKind(AuServerDevice(aud, i)) ==\n\t AuComponentKindPhysicalOutput) &&\n\t AuDeviceNumTracks(AuServerDevice(aud, i)) == 1)\n\t{\n\t outputDevice = AuDeviceIdentifier(AuServerDevice(aud, i));\n\t break;\n\t}\n\n if (outputDevice == AuNone)\n\tfatalError(\"Couldn't find an appropriate output device\", NULL);\n\n flow = createDTMFflow(aud, outputDevice, volume, duration);\n\n dial(aud, flow, dialString, pause, spacing);\n}", "label": 0, "cwe": null, "length": 359 }, { "index": 138449, "code": "editPreferences()\n{\n PreferencesEditorDialog preferences;\n preferences.exec();\n m_Widget.m_pConnections->setFocus();\n}", "label": 0, "cwe": null, "length": 26 }, { "index": 610249, "code": "dblhashFind(dblhash_ *h, char *key, double *value)\n{\n double *valuePtr;\n\tReturnErrIf(dblhashFindPtr(h, key, &valuePtr));\n\tif(valuePtr != NULL) {\n\t\t*value = *valuePtr;\n\t} else {\n\t\t*value = HUGE_VAL;\n\t}\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 77 }, { "index": 810764, "code": "menuDestroy(MSPulldownMenu *menu_)\n{\n if (pulldownMenu()==menu_)\n {\n _pulldownMenu=0;\n _cascade=MSFalse;\n }\n}", "label": 0, "cwe": null, "length": 46 }, { "index": 38129, "code": "ScrollDown(int Lines) {\n int L = GetVPort()->TP.Row;\n if (SetNearPos(CP.Col, CP.Row - Lines, tmLeft) == 0) return 0;\n if (GetVPort()->SetTop(GetVPort()->TP.Col, L - Lines) == 0) return 0;\n return 1;\n}", "label": 0, "cwe": null, "length": 78 }, { "index": 124361, "code": "testOutputRemove()\n{\n\tstd::ostringstream output;\n\tOutputLineEndingConverter conv(output, \"\");\n\tconv << \"line1\\r\\nline2\\rline3\\n\" << std::flush;\n\tstd::string result = output.str();\n\tassert (result == \"line1line2line3\");\n}", "label": 0, "cwe": null, "length": 60 }, { "index": 854522, "code": "show(pkcs12_t *pkcs12)\n{\n\tenumerator_t *enumerator;\n\tcertificate_t *cert;\n\tprivate_key_t *key;\n\tint index = 1;\n\n\tprintf(\"Certificates:\\n\");\n\tenumerator = pkcs12->create_cert_enumerator(pkcs12);\n\twhile (enumerator->enumerate(enumerator, &cert))\n\t{\n\t\tx509_t *x509 = (x509_t*)cert;\n\n\t\tif (x509->get_flags(x509) & X509_CA)\n\t\t{\n\t\t\tprintf(\"[%2d] \\\"%Y\\\" (CA)\\n\", index++, cert->get_subject(cert));\n\t\t}\n\t\telse\n\t\t{\n\t\t\tprintf(\"[%2d] \\\"%Y\\\"\\n\", index++, cert->get_subject(cert));\n\t\t}\n\t}\n\tenumerator->destroy(enumerator);\n\n\tprintf(\"Private keys:\\n\");\n\tenumerator = pkcs12->create_key_enumerator(pkcs12);\n\twhile (enumerator->enumerate(enumerator, &key))\n\t{\n\t\tprintf(\"[%2d] %N %d bits\\n\", index++, key_type_names,\n\t\t\t key->get_type(key), key->get_keysize(key));\n\t}\n\tenumerator->destroy(enumerator);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 248 }, { "index": 666820, "code": "append_inst_tac(struct node_tac ** code_ref, struct tac * inst) {\n struct node_tac * novo_nodo = (struct node_tac *)malloc(sizeof(struct node_tac));\n\tnovo_nodo->inst = inst ;\n\n\tstruct node_tac * code = * code_ref ;\n\n\tif (code == NULL) {\n\t\tnovo_nodo->next = NULL ;\n\t\tnovo_nodo->prev = NULL ;\n\t\t*code_ref = novo_nodo ;\t\t\t\n\t}\n\telse {\n\t\twhile ( code->next != NULL ) {\n\t\t\tcode = code->next ;\n\t\t}\n\t\tcode->next = novo_nodo ;\n\t\tnovo_nodo->prev = code ;\n\t\tnovo_nodo->next = NULL ;\n\t}\n}", "label": 0, "cwe": null, "length": 150 }, { "index": 46343, "code": "post_force(int vflag)\n{\n energy = 0.0;\n\n for (int m = 0; m < nrestrain; m++)\n if (rstyle[m] == BOND) restrain_bond(m);\n else if (rstyle[m] == ANGLE) restrain_angle(m);\n else if (rstyle[m] == DIHEDRAL) restrain_dihedral(m);\n}", "label": 0, "cwe": null, "length": 86 }, { "index": 602584, "code": "server_setup_remove_config(SERVER_SETUP_REC *rec)\n{\n\tCONFIG_NODE *node;\n\tint index;\n\n\tnode = iconfig_node_traverse(\"servers\", FALSE);\n\tif (node != NULL) {\n\t\tindex = g_slist_index(setupservers, rec);\n\t\ticonfig_node_list_remove(node, index);\n\t}\n}", "label": 0, "cwe": null, "length": 67 }, { "index": 107930, "code": "zxid_fetch_ses(zxid_conf* cf, const char* sid)\n{\n zxid_ses* ses = zxid_alloc_ses(cf);\n if (sid && sid[0])\n if (!zxid_get_ses(cf, ses, sid)) {\n ZX_FREE(cf->ctx, ses);\n return 0;\n }\n zxid_ses_to_pool(cf, ses);\n return ses;\n}", "label": 0, "cwe": null, "length": 90 }, { "index": 526210, "code": "set_property (GObject *object,\n guint prop_id,\n\t\t\t const GValue *value,\n GParamSpec *pspec)\n{\n\tNMModemBroadband *self = NM_MODEM_BROADBAND (object);\n\n\tswitch (prop_id) {\n\tcase PROP_MODEM:\n\t\t/* construct-only */\n\t\tself->priv->modem_object = g_value_dup_object (value);\n\t\tself->priv->modem_iface = mm_object_get_modem (self->priv->modem_object);\n\t\tg_assert (self->priv->modem_iface != NULL);\n\t\tg_signal_connect (self->priv->modem_iface,\n \"state-changed\",\n G_CALLBACK (modem_state_changed),\n self);\n\n\t\tg_object_set (object,\n\t\t NM_MODEM_ENABLED, (mm_modem_get_state (self->priv->modem_iface) >= MM_MODEM_STATE_ENABLED),\n\t\t NM_MODEM_CONNECTED, (mm_modem_get_state (self->priv->modem_iface) >= MM_MODEM_STATE_CONNECTED),\n\t\t NULL);\n\n\t\t/* Note: don't grab the Simple iface here; the Modem interface is the\n\t\t * only one assumed to be always valid and available */\n\t\tbreak;\n\tdefault:\n\t\tG_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);\n\t\tbreak;\n\t}\n}", "label": 0, "cwe": null, "length": 278 }, { "index": 859329, "code": "print_shader_log(GLuint shader)\n{\n GLsizei len = 0;\n SYM(glGetShaderiv)(shader, GL_INFO_LOG_LENGTH, &len);\n if (!len)\n return;\n\n char *buffer = new char[len];\n SYM(glGetShaderInfoLog)(shader, len, &len, buffer);\n log_cb(RETRO_LOG_INFO, \":%s\\n\", buffer);\n delete[] buffer;\n}", "label": 0, "cwe": null, "length": 91 }, { "index": 105829, "code": "updateModelStatistics()\n{\n int index;\n\n // Bodies\n // ======\n modelStatistics->nofBodies = 0;\n modelStatistics->nofElementLoops = 0;\n modelStatistics->nofElements = 0;\n modelStatistics->nofInnerBoundaries = 0;\n modelStatistics->nofOuterBoundaries = 0;\n modelStatistics->nofVertices = 0;\n\n modelStatistics->maxLoopSize = 0;\n\n index = 0;\n while (true) {\n Body* body = getBody(index++);\n if (body==NULL) break;\n if ( body->isActive() ) {\n modelStatistics->nofBodies++;\n }\n }\n\n // Body element loops\n // ==================\n index = 0;\n while (true) {\n BodyElementLoop* bel = getBodyElementLoop(index++);\n if (bel==NULL) break;\n if ( bel->isActive() ) {\n modelStatistics->nofElementLoops++;\n\n int elem_c = bel->getNofElements();\n if ( elem_c > modelStatistics->maxLoopSize ) {\n modelStatistics->maxLoopSize = elem_c;\n }\n }\n }\n\n // Body elements\n // =============\n index = 0;\n while (true) {\n BodyElement* be = getBoundary(index++);\n if (be==NULL) break;\n if ( be->isActive() ) {\n modelStatistics->nofElements++;\n\n if ( NO_INDEX == be->getParentId(2) )\n modelStatistics->nofOuterBoundaries++;\n else\n modelStatistics->nofInnerBoundaries++;\n }\n }\n\n // Vertices\n // ========\n index = 0;\n while (true) {\n BodyElement* v = getVertex(index++);\n if (v==NULL) break;\n if ( v->isActive() ) {\n modelStatistics->nofVertices++;\n }\n }\n\n}", "label": 0, "cwe": null, "length": 408 }, { "index": 34104, "code": "ftdi_elan_init(void)\n{\n\tint result;\n\tpr_info(\"driver %s\\n\", ftdi_elan_driver.name);\n\tmutex_init(&ftdi_module_lock);\n\tINIT_LIST_HEAD(&ftdi_static_list);\n\tstatus_queue = create_singlethread_workqueue(\"ftdi-status-control\");\n\tif (!status_queue)\n\t\tgoto err_status_queue;\n\tcommand_queue = create_singlethread_workqueue(\"ftdi-command-engine\");\n\tif (!command_queue)\n\t\tgoto err_command_queue;\n\trespond_queue = create_singlethread_workqueue(\"ftdi-respond-engine\");\n\tif (!respond_queue)\n\t\tgoto err_respond_queue;\n\tresult = usb_register(&ftdi_elan_driver);\n\tif (result) {\n\t\tdestroy_workqueue(status_queue);\n\t\tdestroy_workqueue(command_queue);\n\t\tdestroy_workqueue(respond_queue);\n\t\tpr_err(\"usb_register failed. Error number %d\\n\", result);\n\t}\n\treturn result;\n\nerr_respond_queue:\n\tdestroy_workqueue(command_queue);\nerr_command_queue:\n\tdestroy_workqueue(status_queue);\nerr_status_queue:\n\tpr_err(\"%s couldn't create workqueue\\n\", ftdi_elan_driver.name);\n\treturn -ENOMEM;\n}", "label": 0, "cwe": null, "length": 237 }, { "index": 395102, "code": "seqWriteDasdna(AjPSeqout outseq)\n{\n ajuint i;\n ajuint ilen;\n ajuint iend;\n ajuint linelen = 50;\n AjPStr seq = NULL;\n\n ilen = ajStrGetLen(outseq->Seq);\n\n if(!outseq->Count)\n {\n outseq->Cleanup = seqCleanDasdna;\n ajFmtPrintF(outseq->File,\n \"\\n\");\n ajFmtPrintF(outseq->File,\n \"\\n\");\n ajFmtPrintF(outseq->File,\n \"\\n\");\n }\n \n\n ajFmtPrintF(outseq->File,\n \" \\n\",\n outseq->Name, 1+outseq->Offset,\n ilen+outseq->Offset,\n outseq->Sv);\n\n ajFmtPrintF(outseq->File,\n \" \\n\", ilen);\n\n for(i=0; i < ilen; i += linelen)\n {\n\tiend = AJMIN(ilen-1, i+linelen-1);\n\tajStrAssignSubS(&seq, outseq->Seq, i, iend);\n\tajFmtPrintF(outseq->File, \" %S\\n\", seq);\n }\n\n ajFmtPrintF(outseq->File,\n \" \\n\");\n ajFmtPrintF(outseq->File,\n \" \\n\");\n\n ajStrDel(&seq);\n\n return;\n}", "label": 0, "cwe": null, "length": 381 }, { "index": 838877, "code": "gth_seq_con_create(const GthSeqConClass *scc)\n{\n GthSeqCon *sc;\n gt_assert(scc && scc->size);\n sc = gt_calloc(1, scc->size);\n sc->c_class = scc;\n sc->pvt = NULL; /* XXX */\n return sc;\n}", "label": 0, "cwe": null, "length": 74 }, { "index": 73721, "code": "pod_startup1(struct usb_line6_pod *pod)\n{\n\tCHECK_STARTUP_PROGRESS(pod->startup_progress, POD_STARTUP_INIT);\n\n\t/* delay startup procedure: */\n\tline6_start_timer(&pod->startup_timer, POD_STARTUP_DELAY, pod_startup2,\n\t\t\t (unsigned long)pod);\n}", "label": 0, "cwe": null, "length": 62 }, { "index": 21695, "code": "gdl_dock_item_realize (GtkWidget *widget)\n{\n GdlDockItem *item;\n GtkAllocation allocation;\n GdkWindow *window;\n GdkWindowAttr attributes;\n gint attributes_mask;\n\n g_return_if_fail (widget != NULL);\n g_return_if_fail (GDL_IS_DOCK_ITEM (widget));\n\n item = GDL_DOCK_ITEM (widget);\n\n gtk_widget_set_realized (widget, TRUE);\n\n /* widget window */\n gtk_widget_get_allocation (widget, &allocation);\n attributes.x = allocation.x;\n attributes.y = allocation.y;\n attributes.width = allocation.width;\n attributes.height = allocation.height;\n attributes.window_type = GDK_WINDOW_CHILD;\n attributes.wclass = GDK_INPUT_OUTPUT;\n attributes.visual = gtk_widget_get_visual (widget);\n attributes.event_mask = (gtk_widget_get_events (widget) |\n GDK_EXPOSURE_MASK |\n GDK_BUTTON1_MOTION_MASK |\n GDK_BUTTON_PRESS_MASK |\n GDK_BUTTON_RELEASE_MASK);\n attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL;\n window = gdk_window_new (gtk_widget_get_parent_window (widget),\n &attributes, attributes_mask);\n gtk_widget_set_window (widget, window);\n gdk_window_set_user_data (window, widget);\n\n gtk_style_context_set_background (gtk_widget_get_style_context (widget),\n window);\n\n if (item->priv->child)\n gtk_widget_set_parent_window (item->priv->child, window);\n\n if (item->priv->grip)\n gtk_widget_set_parent_window (item->priv->grip, window);\n}", "label": 0, "cwe": null, "length": 342 }, { "index": 163067, "code": "pg_command(struct pg *dev, char *cmd, int dlen, unsigned long tmo)\n{\n\tint k;\n\n\tpi_connect(dev->pi);\n\n\twrite_reg(dev, 6, DRIVE(dev));\n\n\tif (pg_wait(dev, STAT_BUSY | STAT_DRQ, 0, tmo, \"before command\"))\n\t\tgoto fail;\n\n\twrite_reg(dev, 4, dlen % 256);\n\twrite_reg(dev, 5, dlen / 256);\n\twrite_reg(dev, 7, 0xa0);\t/* ATAPI packet command */\n\n\tif (pg_wait(dev, STAT_BUSY, STAT_DRQ, tmo, \"command DRQ\"))\n\t\tgoto fail;\n\n\tif (read_reg(dev, 2) != 1) {\n\t\tprintk(\"%s: command phase error\\n\", dev->name);\n\t\tgoto fail;\n\t}\n\n\tpi_write_block(dev->pi, cmd, 12);\n\n\tif (verbose > 1) {\n\t\tprintk(\"%s: Command sent, dlen=%d packet= \", dev->name, dlen);\n\t\tfor (k = 0; k < 12; k++)\n\t\t\tprintk(\"%02x \", cmd[k] & 0xff);\n\t\tprintk(\"\\n\");\n\t}\n\treturn 0;\nfail:\n\tpi_disconnect(dev->pi);\n\treturn -1;\n}", "label": 0, "cwe": null, "length": 270 }, { "index": 764005, "code": "WriteTextureParameter(FCDEffectStandard* effectStandard, xmlNode* parentNode, uint32 bucketIndex)\r\n{\r\n\txmlNode* textureNode = NULL;\r\n\tif (bucketIndex != FUDaeTextureChannel::UNKNOWN)\r\n\t{\r\n\t\tsize_t textureCount = effectStandard->GetTextureCount(bucketIndex);\r\n\t\tfor (size_t t = 0; t < textureCount; ++t)\r\n\t\t{\r\n\t\t\txmlNode* newTextureNode = FArchiveXML::LetWriteObject(effectStandard->GetTexture(bucketIndex, t), parentNode);\r\n\t\t\tif (newTextureNode != NULL && textureNode == NULL) textureNode = newTextureNode;\r\n\t\t}\r\n\t}\r\n\treturn textureNode;\r\n}", "label": 0, "cwe": null, "length": 141 }, { "index": 638215, "code": "cgroup_config_insert_cgroup(char *cg_name)\n{\n\tstruct cgroup *config_cgroup;\n\n\tif (cgroup_table_index >= MAX_CGROUPS - 1) {\n\t\tstruct cgroup *newblk;\n\t\tunsigned int oldlen;\n\n\t\tif (MAX_CGROUPS >= INT_MAX) {\n\t\t\tlast_errno = ENOMEM;\n\t\t\treturn 0;\n\t\t}\n\t\toldlen = MAX_CGROUPS;\n\t\tMAX_CGROUPS *= 2;\n\t\tnewblk = realloc(config_cgroup_table, (MAX_CGROUPS *\n\t\t\t\t\tsizeof(struct cgroup)));\n\t\tif (!newblk) {\n\t\t\tlast_errno = ENOMEM;\n\t\t\treturn 0;\n\t\t}\n\n\t\tmemset(newblk + oldlen, 0, (MAX_CGROUPS - oldlen) *\n\t\t\t\tsizeof(struct cgroup));\n\t\tinit_cgroup_table(newblk + oldlen, MAX_CGROUPS - oldlen);\n\t\tconfig_cgroup_table = newblk;\n\t\tcgroup_dbg(\"MAX_CGROUPS %d\\n\", MAX_CGROUPS);\n\t\tcgroup_dbg(\"reallocated config_cgroup_table to %p\\n\", config_cgroup_table);\n\t}\n\n\tconfig_cgroup = &config_cgroup_table[cgroup_table_index];\n\tstrncpy(config_cgroup->name, cg_name, FILENAME_MAX);\n\n\t/*\n\t * Since this will be the last part to be parsed.\n\t */\n\tcgroup_table_index++;\n\tfree(cg_name);\n\treturn 1;\n}", "label": 0, "cwe": null, "length": 297 }, { "index": 548830, "code": "cleanup(void)\n{\n // Make sure that the child process we spawn with fork doesnt also try to cleanup\n if (getpid() == myPid){\n char unloadSystemCall[1000];\n sprintf(unloadSystemCall, \"launchctl unload %s.%d \", \"/tmp/macWatch.plist\", myPid );\n system(unloadSystemCall);\n char removePlistSystemCall[1000];\n sprintf(removePlistSystemCall, \"rm %s.%d* \", \"/tmp/macWatch.plist\", myPid );\n system(removePlistSystemCall);\n char removePidFileSystemCall[1000];\n sprintf(removePidFileSystemCall, \"rm %s.%d\", \"/tmp/macWatch\", myPid);\n system(removePidFileSystemCall);\n exit(1);\n }\n}", "label": 0, "cwe": null, "length": 166 }, { "index": 977826, "code": "brasero_volume_get_gvolume (BraseroVolume *volume)\r\n{\r\n\tconst gchar *volume_path = NULL;\r\n\tGVolumeMonitor *monitor;\r\n\tGVolume *gvolume = NULL;\r\n\tBraseroDrive *drive;\r\n\tGList *volumes;\r\n\tGList *iter;\r\n\r\n\tg_return_val_if_fail (volume != NULL, NULL);\r\n\tg_return_val_if_fail (BRASERO_IS_VOLUME (volume), NULL);\r\n\r\n\tdrive = brasero_medium_get_drive (BRASERO_MEDIUM (volume));\r\n\r\n\t/* This returns the block device which is the\r\n\t * same as the device for all OSes except\r\n\t * Solaris where the device is the raw device. */\r\n\tvolume_path = brasero_drive_get_block_device (drive);\r\n\r\n\t/* NOTE: medium-monitor already holds a reference for GVolumeMonitor */\r\n\tmonitor = g_volume_monitor_get ();\r\n\tvolumes = g_volume_monitor_get_volumes (monitor);\r\n\tg_object_unref (monitor);\r\n\r\n\tfor (iter = volumes; iter; iter = iter->next) {\r\n\t\tgchar *device_path;\r\n\t\tGVolume *tmp;\r\n\r\n\t\ttmp = iter->data;\r\n\t\tdevice_path = g_volume_get_identifier (tmp, G_VOLUME_IDENTIFIER_KIND_UNIX_DEVICE);\r\n\t\tif (!device_path)\r\n\t\t\tcontinue;\r\n\r\n\t\tBRASERO_MEDIA_LOG (\"Found volume %s\", device_path);\r\n\t\tif (!strcmp (device_path, volume_path)) {\r\n\t\t\tgvolume = tmp;\r\n\t\t\tg_free (device_path);\r\n\t\t\tg_object_ref (gvolume);\r\n\t\t\tbreak;\r\n\t\t}\r\n\r\n\t\tg_free (device_path);\r\n\t}\r\n\tg_list_foreach (volumes, (GFunc) g_object_unref, NULL);\r\n\tg_list_free (volumes);\r\n\r\n\tif (!gvolume)\r\n\t\tBRASERO_MEDIA_LOG (\"No volume found for medium\");\r\n\r\n\treturn gvolume;\r\n}", "label": 0, "cwe": null, "length": 366 }, { "index": 827383, "code": "be_cmd_read_port_transceiver_data(struct be_adapter *adapter,\n\t\t\t\t u8 page_num, u8 *data)\n{\n\tstruct be_dma_mem cmd;\n\tstruct be_mcc_wrb *wrb;\n\tstruct be_cmd_req_port_type *req;\n\tint status;\n\n\tif (page_num > TR_PAGE_A2)\n\t\treturn -EINVAL;\n\n\tcmd.size = sizeof(struct be_cmd_resp_port_type);\n\tcmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma,\n\t\t\t\t GFP_ATOMIC);\n\tif (!cmd.va) {\n\t\tdev_err(&adapter->pdev->dev, \"Memory allocation failed\\n\");\n\t\treturn -ENOMEM;\n\t}\n\n\tspin_lock_bh(&adapter->mcc_lock);\n\n\twrb = wrb_from_mccq(adapter);\n\tif (!wrb) {\n\t\tstatus = -EBUSY;\n\t\tgoto err;\n\t}\n\treq = cmd.va;\n\n\tbe_wrb_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON,\n\t\t\t OPCODE_COMMON_READ_TRANSRECV_DATA,\n\t\t\t cmd.size, wrb, &cmd);\n\n\treq->port = cpu_to_le32(adapter->hba_port_num);\n\treq->page_num = cpu_to_le32(page_num);\n\tstatus = be_mcc_notify_wait(adapter);\n\tif (!status) {\n\t\tstruct be_cmd_resp_port_type *resp = cmd.va;\n\n\t\tmemcpy(data, resp->page_data, PAGE_DATA_LEN);\n\t}\nerr:\n\tspin_unlock_bh(&adapter->mcc_lock);\n\tdma_free_coherent(&adapter->pdev->dev, cmd.size, cmd.va, cmd.dma);\n\treturn status;\n}", "label": 0, "cwe": null, "length": 325 }, { "index": 415551, "code": "ApDelete(Appearance *ap)\n{\n if (ap == NULL || RefDecr((Ref *)ap) > 0)\n return;\n if (ap->magic != APMAGIC) {\n OOGLError(1, \"ApDelete(%x) of non-Appearance: magic %x != %x\",\n\t ap, ap->magic, APMAGIC);\n return;\n }\n if (ap->mat) MtDelete(ap->mat);\n if (ap->lighting) LmDelete(ap->lighting);\n if (ap->tex) TxDelete(ap->tex);\n\n OOGLFree(ap);\n}", "label": 0, "cwe": null, "length": 135 }, { "index": 77725, "code": "print_attr_strange(register u_char *data, u_int length, u_short attr_code)\n{\n u_short len_data;\n\n switch(attr_code)\n {\n case ARAP_PASS:\n if (length != 16)\n {\n printf(\"ERROR: length %u != 16\", length);\n return;\n }\n printf(\"User_challenge (\");\n TCHECK2(data[0],8);\n len_data = 8;\n PRINT_HEX(len_data, data);\n printf(\") User_resp(\");\n TCHECK2(data[0],8);\n len_data = 8;\n PRINT_HEX(len_data, data);\n printf(\")\");\n break;\n\n case ARAP_FEATURES:\n if (length != 14)\n {\n printf(\"ERROR: length %u != 14\", length);\n return;\n }\n TCHECK2(data[0],1);\n if (*data)\n printf(\"User can change password\");\n else\n printf(\"User cannot change password\");\n data++;\n TCHECK2(data[0],1);\n printf(\", Min password length: %d\",*data);\n data++;\n printf(\", created at: \");\n TCHECK2(data[0],4);\n len_data = 4;\n PRINT_HEX(len_data, data);\n printf(\", expires in: \");\n TCHECK2(data[0],4);\n len_data = 4;\n PRINT_HEX(len_data, data);\n printf(\", Current Time: \");\n TCHECK2(data[0],4);\n len_data = 4;\n PRINT_HEX(len_data, data);\n break;\n\n case ARAP_CHALLENGE_RESP:\n if (length < 8)\n {\n printf(\"ERROR: length %u != 8\", length);\n return;\n }\n TCHECK2(data[0],8);\n len_data = 8;\n PRINT_HEX(len_data, data);\n break;\n }\n return;\n\n trunc:\n printf(\" [|radius]\");\n}", "label": 0, "cwe": null, "length": 420 }, { "index": 901689, "code": "addmd5(md5p, s, len)\nmd5_t *md5p;\nCONST u_char *s;\nALLOC_T len;\n{\n\twhile (len--) {\n\t\tif (md5p -> cl <= (u_long)0xffffffff - (u_long)BITSPERBYTE)\n\t\t\tmd5p -> cl += (u_long)BITSPERBYTE;\n\t\telse {\n\t\t\tmd5p -> cl -=\n\t\t\t\t(u_long)0xffffffff - (u_long)BITSPERBYTE + 1;\n\t\t\t(md5p -> ch)++;\n\t\t\tmd5p -> ch &= (u_long)0xffffffff;\n\t\t}\n\n\t\tmd5p -> x[md5p -> n] |= ((u_long)(*(s++)) << (md5p -> b));\n\t\tif ((md5p -> b += BITSPERBYTE) >= BITSPERBYTE * 4) {\n\t\t\tmd5p -> b = 0;\n\t\t\tif (++(md5p -> n) >= MD5_BLOCKS) {\n\t\t\t\tmd5p -> n = 0;\n\t\t\t\tcalcmd5(md5p);\n\t\t\t\tmemset((char *)(md5p -> x),\n\t\t\t\t\t0, sizeof(md5p -> x));\n\t\t\t}\n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 262 }, { "index": 646760, "code": "connect(const String& display_name) {\n Display* d = Display::open(display_name);\n if (d != nil) {\n\trep_->connect(d);\n }\n return d;\n}", "label": 0, "cwe": null, "length": 40 }, { "index": 33790, "code": "file_split(char *dirbuf, size_t dirbuflen, char *orig_fname, int is_for_browse)\n{\n char *p, *fn;\n size_t dirlen;\n\n if(*orig_fname && (p = strrchr(orig_fname, C_FILESEP))){\n\tfn = p + 1;\n\tdirlen = p - orig_fname;\n\tif(p == orig_fname){\n\t strncpy(dirbuf, S_FILESEP, dirbuflen);\n\t dirbuf[dirbuflen-1] = '\\0';\n\t}\n#ifdef\tDOS\n\telse if(orig_fname[0] == C_FILESEP\n\t\t|| (isalpha((unsigned char)orig_fname[0])\n\t\t && orig_fname[1] == ':')){\n\t if(orig_fname[1] == ':' && p == orig_fname+2)\n\t dirlen = fn - orig_fname;\n\n\t dirlen = MIN(dirlen, dirbuflen-1);\n\t strncpy(dirbuf, orig_fname, dirlen);\n\t dirbuf[dirlen] = '\\0';\n\t}\n#else\n\telse if (orig_fname[0] == C_FILESEP || orig_fname[0] == '~'){\n\t dirlen = MIN(dirlen, dirbuflen-1);\n\t strncpy(dirbuf, orig_fname, dirlen);\n\t dirbuf[dirlen] = '\\0';\n\t}\n#endif\n\telse\n\t snprintf(dirbuf, dirbuflen, \"%s%c%.*s\", \n\t\t (gmode & MDCURDIR)\n\t\t ? ((is_for_browse && browse_dir[0]) ? browse_dir : \".\")\n\t\t : ((gmode & MDTREE) || opertree[0])\n\t\t ? opertree\n\t\t : ((is_for_browse && browse_dir[0])\n\t\t ? browse_dir : gethomedir(NULL)),\n\t\t C_FILESEP, p - orig_fname, orig_fname);\n }\n else{\n\tfn = orig_fname;\n\tstrncpy(dirbuf, (gmode & MDCURDIR)\n\t ? ((is_for_browse && browse_dir[0]) ? browse_dir : \".\")\n\t : ((gmode & MDTREE) || opertree[0])\n\t ? opertree\n\t : ((is_for_browse && browse_dir[0])\n\t\t ? browse_dir : gethomedir(NULL)), dirbuflen);\n\tdirbuf[dirbuflen-1] = '\\0';\n }\n\n return fn;\n}", "label": 1, "cwe": "CWE-120", "length": 504 }, { "index": 774326, "code": "omapi_set_value_str (omapi_object_t *h,\n\t\t\t\t omapi_object_t *id,\n\t\t\t\t const char *name,\n\t\t\t\t omapi_typed_data_t *value)\n{\n\tomapi_data_string_t *nds;\n\tisc_result_t status;\n\n\tnds = (omapi_data_string_t *)0;\n\tstatus = omapi_data_string_new (&nds, strlen (name), MDL);\n\tif (status != ISC_R_SUCCESS)\n\t\treturn status;\n\tmemcpy (nds -> value, name, strlen (name));\n\n\tstatus = omapi_set_value (h, id, nds, value);\n\tomapi_data_string_dereference (&nds, MDL);\n\treturn status;\n}", "label": 0, "cwe": null, "length": 141 }, { "index": 666684, "code": "dupe_match_print_group(DupeItem *di)\n{\n\tGList *work;\n\n\tlog_printf(\"+ %f %s\\n\", di->group_rank, di->fd->name);\n\n\twork = di->group;\n\twhile (work)\n\t\t{\n\t\tDupeMatch *dm = work->data;\n\t\twork = work->next;\n\n\t\tlog_printf(\" %f %s\\n\", dm->rank, dm->di->fd->name);\n\t\t}\n\n\tlog_printf(\"\\n\");\n}", "label": 0, "cwe": null, "length": 101 }, { "index": 908432, "code": "slapi_filter_get_attribute_type( Slapi_Filter *f, char **type )\n{ \n\n if ( f == NULL ) {\n\t\treturn -1;\n }\n\n switch ( f->f_choice ) {\n case LDAP_FILTER_GE:\n case LDAP_FILTER_LE:\n case LDAP_FILTER_APPROX:\n case LDAP_FILTER_EQUALITY:\n\t\t*type = f->f_ava.ava_type;\n\tbreak;\n case LDAP_FILTER_SUBSTRINGS:\n\t\t*type = f->f_sub_type;\t\n\tbreak;\n case LDAP_FILTER_PRESENT:\n \t\t*type = f->f_type;\n\tbreak;\n case LDAP_FILTER_EXTENDED:\n\t\t*type = f->f_mr_type;\n\tbreak;\n case LDAP_FILTER_AND:\n case LDAP_FILTER_OR:\n case LDAP_FILTER_NOT:\n\t\treturn(-1);\n default:\n\t\t/* Unknown filter choice */\n\t\treturn -1;\n }\n\n\t/* success */\n\treturn(0); \n}", "label": 0, "cwe": null, "length": 195 }, { "index": 994893, "code": "blk_cloned_rq_check_limits(struct request_queue *q,\n\t\t\t\t struct request *rq)\n{\n\tif (blk_rq_sectors(rq) > blk_queue_get_max_sectors(q, rq->cmd_flags)) {\n\t\tprintk(KERN_ERR \"%s: over max size limit.\\n\", __func__);\n\t\treturn -EIO;\n\t}\n\n\t/*\n\t * queue's settings related to segment counting like q->bounce_pfn\n\t * may differ from that of other stacking queues.\n\t * Recalculate it to check the request correctly on this queue's\n\t * limitation.\n\t */\n\tblk_recalc_rq_segments(rq);\n\tif (rq->nr_phys_segments > queue_max_segments(q)) {\n\t\tprintk(KERN_ERR \"%s: over max segments limit.\\n\", __func__);\n\t\treturn -EIO;\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 172 }, { "index": 524204, "code": "gst_adder_child_proxy_get_child_by_index (GstChildProxy * child_proxy,\n guint index)\n{\n GstAdder *adder = GST_ADDER (child_proxy);\n GObject *obj = NULL;\n\n GST_OBJECT_LOCK (adder);\n obj = g_list_nth_data (GST_ELEMENT_CAST (adder)->sinkpads, index);\n if (obj)\n gst_object_ref (obj);\n GST_OBJECT_UNLOCK (adder);\n return obj;\n}", "label": 0, "cwe": null, "length": 96 }, { "index": 414871, "code": "installRootColormap() {\n\n Display *disp = FbTk::App::instance()->display();\n XGrabServer(disp);\n\n bool install = true;\n int i = 0, ncmap = 0;\n Colormap *cmaps =\n XListInstalledColormaps(disp, m_root_window, &ncmap);\n\n if (cmaps) {\n for (i = 0; i < ncmap; i++) {\n if (*(cmaps + i) == m_colormap)\n install = false;\n }\n\n if (install)\n XInstallColormap(disp, m_colormap);\n\n XFree(cmaps);\n }\n\n XUngrabServer(disp);\n}", "label": 0, "cwe": null, "length": 150 }, { "index": 50792, "code": "firestring_strcasecmp(const char * restrict const s1, const char * restrict const s2) { /* case-insensitive string comparison, ignores tail of longer string */\n\tsize_t s;\n\tchar c1, c2;\n\tfor (s = 0; (s1[s] != '\\0') && (s2[s] != '\\0') && (tolower((unsigned char) s1[s]) == tolower((unsigned char) s2[s])); s++);\n\n\tc1 = tolower((unsigned char) s1[s]);\n\tc2 = tolower((unsigned char) s2[s]);\n\tif (c1 == c2)\n\t\treturn 0;\n\telse if (c1 < c2)\n\t\treturn -1;\n\telse\n\t\treturn 1;\n}", "label": 0, "cwe": null, "length": 158 }, { "index": 276291, "code": "listmem(long int row)\n{\n PerAddrBook *pab;\n AddrScrn_Disp *dl;\n\n dl = dlist(row);\n if(dl->type != ListEnt)\n return((char *)NULL);\n\n pab = &as.adrbks[adrbk_num_from_lineno(row)];\n\n return(listmem_from_dl(pab->address_book, dl));\n}", "label": 0, "cwe": null, "length": 81 }, { "index": 415646, "code": "gfs2_create_debugfs_file(struct gfs2_sbd *sdp)\n{\n\tstruct dentry *dent;\n\n\tdent = debugfs_create_dir(sdp->sd_table_name, gfs2_root);\n\tif (IS_ERR_OR_NULL(dent))\n\t\tgoto fail;\n\tsdp->debugfs_dir = dent;\n\n\tdent = debugfs_create_file(\"glocks\",\n\t\t\t\t S_IFREG | S_IRUGO,\n\t\t\t\t sdp->debugfs_dir, sdp,\n\t\t\t\t &gfs2_glocks_fops);\n\tif (IS_ERR_OR_NULL(dent))\n\t\tgoto fail;\n\tsdp->debugfs_dentry_glocks = dent;\n\n\tdent = debugfs_create_file(\"glstats\",\n\t\t\t\t S_IFREG | S_IRUGO,\n\t\t\t\t sdp->debugfs_dir, sdp,\n\t\t\t\t &gfs2_glstats_fops);\n\tif (IS_ERR_OR_NULL(dent))\n\t\tgoto fail;\n\tsdp->debugfs_dentry_glstats = dent;\n\n\tdent = debugfs_create_file(\"sbstats\",\n\t\t\t\t S_IFREG | S_IRUGO,\n\t\t\t\t sdp->debugfs_dir, sdp,\n\t\t\t\t &gfs2_sbstats_fops);\n\tif (IS_ERR_OR_NULL(dent))\n\t\tgoto fail;\n\tsdp->debugfs_dentry_sbstats = dent;\n\n\treturn 0;\nfail:\n\tgfs2_delete_debugfs_file(sdp);\n\treturn dent ? PTR_ERR(dent) : -ENOMEM;\n}", "label": 0, "cwe": null, "length": 296 }, { "index": 11006, "code": "tsubst_default_argument (tree fn, tree type, tree arg)\n{\n tree saved_class_ptr = NULL_TREE;\n tree saved_class_ref = NULL_TREE;\n\n /* This default argument came from a template. Instantiate the\n default argument here, not in tsubst. In the case of\n something like: \n \n template \n struct S {\n\t static T t();\n\t void f(T = t());\n };\n \n we must be careful to do name lookup in the scope of S,\n rather than in the current class. */\n push_access_scope (fn);\n /* The default argument expression should not be considered to be\n within the scope of FN. Since push_access_scope sets\n current_function_decl, we must explicitly clear it here. */\n current_function_decl = NULL_TREE;\n /* The \"this\" pointer is not valid in a default argument. */\n if (cfun)\n {\n saved_class_ptr = current_class_ptr;\n cp_function_chain->x_current_class_ptr = NULL_TREE;\n saved_class_ref = current_class_ref;\n cp_function_chain->x_current_class_ref = NULL_TREE;\n }\n\n push_deferring_access_checks(dk_no_deferred);\n arg = tsubst_expr (arg, DECL_TI_ARGS (fn),\n\t\t tf_error | tf_warning, NULL_TREE);\n pop_deferring_access_checks();\n\n /* Restore the \"this\" pointer. */\n if (cfun)\n {\n cp_function_chain->x_current_class_ptr = saved_class_ptr;\n cp_function_chain->x_current_class_ref = saved_class_ref;\n }\n\n pop_access_scope (fn);\n\n /* Make sure the default argument is reasonable. */\n arg = check_default_argument (type, arg);\n\n return arg;\n}", "label": 0, "cwe": null, "length": 377 }, { "index": 120814, "code": "append_options(int *argc, char **argv)\n{\n\n\tSTRBUF *sb = strbuf_open(0);\n\tconst char *p, *opt = check_strdup(htags_options);\n\tint count = 1;\n\tint quote = 0;\n\tconst char **newargv;\n\tint i = 0, j = 1;\n\n\tif (!opt)\n\t\tdie(\"Short of memory.\");\n\tfor (p = opt; *p && isspace(*p); p++)\n\t\t;\n\tfor (; *p; p++) {\n\t\tint c = *p;\n\n\t\tif (quote) {\n\t\t\tif (quote == c)\n\t\t\t\tquote = 0;\n\t\t\telse\n\t\t\t\tstrbuf_putc(sb, c);\n\t\t} else if (c == '\\\\') {\n\t\t\tstrbuf_putc(sb, c);\n\t\t} else if (c == '\\'' || c == '\"') {\n\t\t\tquote = c;\n\t\t} else if (isspace(c)) {\n\t\t\tstrbuf_putc(sb, '\\0');\n\t\t\tcount++;\n\t\t\twhile (*p && isspace(*p))\n\t\t\t\tp++;\n\t\t\tp--;\n\t\t} else {\n\t\t\tstrbuf_putc(sb, *p);\n\t\t}\n\t}\n\tnewargv = (const char **)check_malloc(sizeof(char *) * (*argc + count + 1));\n\tnewargv[i++] = argv[0];\n\tp = strbuf_value(sb);\n\twhile (count--) {\n\t\tnewargv[i++] = p;\n\t\tp += strlen(p) + 1;\n\t}\n\twhile (j < *argc)\n\t\tnewargv[i++] = argv[j++];\n\tnewargv[i] = NULL;\n\targv = (char **)newargv;\n\t*argc = i;\n#ifdef DEBUG\n\tfor (i = 0; i < *argc; i++)\n\t\tfprintf(stderr, \"argv[%d] = '%s'\\n\", i, argv[i]);\n#endif\n\t/* doesn't close string buffer. */\n\n\treturn argv;\n}", "label": 0, "cwe": null, "length": 396 }, { "index": 302410, "code": "_vala_clocks_alarm_main_panel_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {\n\tClocksAlarmMainPanel * self;\n\tself = G_TYPE_CHECK_INSTANCE_CAST (object, CLOCKS_ALARM_TYPE_MAIN_PANEL, ClocksAlarmMainPanel);\n\tswitch (property_id) {\n\t\tcase CLOCKS_ALARM_MAIN_PANEL_LABEL:\n\t\tclocks_clock_set_label ((ClocksClock*) self, g_value_get_string (value));\n\t\tbreak;\n\t\tcase CLOCKS_ALARM_MAIN_PANEL_HEADER_BAR:\n\t\tclocks_clock_set_header_bar ((ClocksClock*) self, g_value_get_object (value));\n\t\tbreak;\n\t\tcase CLOCKS_ALARM_MAIN_PANEL_PANEL_ID:\n\t\tclocks_clock_set_panel_id ((ClocksClock*) self, g_value_get_enum (value));\n\t\tbreak;\n\t\tdefault:\n\t\tG_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);\n\t\tbreak;\n\t}\n}", "label": 0, "cwe": null, "length": 196 }, { "index": 16926, "code": "boot_delay_msec(int level)\n{\n\tunsigned long long k;\n\tunsigned long timeout;\n\n\tif ((boot_delay == 0 || system_state != SYSTEM_BOOTING)\n\t\t|| (level >= console_loglevel && !ignore_loglevel)) {\n\t\treturn;\n\t}\n\n\tk = (unsigned long long)loops_per_msec * boot_delay;\n\n\ttimeout = jiffies + msecs_to_jiffies(boot_delay);\n\twhile (k) {\n\t\tk--;\n\t\tcpu_relax();\n\t\t/*\n\t\t * use (volatile) jiffies to prevent\n\t\t * compiler reduction; loop termination via jiffies\n\t\t * is secondary and may or may not happen.\n\t\t */\n\t\tif (time_after(jiffies, timeout))\n\t\t\tbreak;\n\t\ttouch_nmi_watchdog();\n\t}\n}", "label": 0, "cwe": null, "length": 158 }, { "index": 100690, "code": "changeThickness() \n{\n\tif (PaletteItem::changeThickness(m_holeSettings, sender())) {\n\t\tQLineEdit * edit = qobject_cast(sender());\n\t\tchangeHoleSize(m_holeSettings.holeDiameter + \",\" + edit->text() + m_holeSettings.currentUnits());\n\t}\t\n}", "label": 0, "cwe": null, "length": 67 }, { "index": 92182, "code": "resample_horiz (SDL_Surface *src, SDL_Surface *dst, FilterFunc filter, int support)\n{\n int x, y;\n int j;\n Uint8 *sp, *dp;\n int r, g, b, a;\n float factor = (float) src->w / dst->w;\n float dx = MAX(factor, 1.0);\n float *F = (float*) malloc(sizeof(float)*(2*support+1));\n \n for (x=0; xw; ++x) \n {\n float c = 0;\n float center = (x+0.5)*factor; /* kernel center in the source image */\n int start = (int) MAX(0, center-support + 0.5);\n int stop = (int) MIN(src->w, center+support+0.5);\n int n = stop-start;\n \n for (j=0; jpixels + x*4;\n for (y=0; yh; ++y) {\n sp = (Uint8*)src->pixels + y*src->pitch + start*4;\n r = g = b = a = 0;\n for (j=0; jpitch;\n }\n }\n free(F);\n}", "label": 0, "cwe": null, "length": 509 }, { "index": 931698, "code": "lock_set(const char *path, int type)\n{\n int res;\n\n if (type == LOCK_OPEN)\n {\n unsigned int *c;\n long hash = djb2(path, SIZE_MAX);\n\n pthread_mutex_lock(&m_lock_tree);\n\n if ((c = bst_get(lock_tree, hash)))\n {\n *c += 1;\n res = 0;\n }\n else\n {\n if ((c = malloc(sizeof *c)))\n {\n *c = 1;\n res = bst_insert(lock_tree, hash, c);\n }\n else\n res = -1;\n }\n\n pthread_mutex_unlock(&m_lock_tree);\n }\n else\n {\n pthread_mutex_lock(&m_lock_transfer);\n\n if (lock_transfer)\n res = -1;\n else\n {\n lock_transfer = strdup(path);\n res = (lock_transfer) ? 0 : -1;\n }\n\n pthread_mutex_unlock(&m_lock_transfer);\n }\n\n return res;\n}", "label": 0, "cwe": null, "length": 212 }, { "index": 866679, "code": "mark_all_loops_for_removal (void)\n{\n int i;\n loop_p loop;\n\n ira_assert (current_loops != NULL);\n FOR_EACH_VEC_SAFE_ELT (get_loops (), i, loop)\n if (ira_loop_nodes[i].regno_allocno_map != NULL)\n {\n\tif (ira_loop_nodes[i].parent == NULL)\n\t {\n\t /* Don't remove the root. */\n\t ira_loop_nodes[i].to_remove_p = false;\n\t continue;\n\t }\n\tira_loop_nodes[i].to_remove_p = true;\n\tif (internal_flag_ira_verbose > 1 && ira_dump_file != NULL)\n\t fprintf\n\t (ira_dump_file,\n\t \" Mark loop %d (header %d, freq %d, depth %d) for removal\\n\",\n\t ira_loop_nodes[i].loop_num,\n\t ira_loop_nodes[i].loop->header->index,\n\t ira_loop_nodes[i].loop->header->frequency,\n\t loop_depth (ira_loop_nodes[i].loop));\n }\n}", "label": 0, "cwe": null, "length": 222 }, { "index": 951932, "code": "mapkey(char* buf, unsigned int len) const {\n unsigned int n = 0;\n XEvent& xe = rep()->xevent_;\n if (xe.type == KeyPress) {\n\tn = XLookupString(&xe.xkey, buf, len, nil, nil);\n\t/*\n\t * R5 internationalization might make this superfluous.\n\t */\n\tif (meta_is_down()) {\n\t for (unsigned int i = 0; i < n; i++) {\n\t\tbuf[i] |= 0200;\n\t }\n\t}\n\n\t\n#if 0 /* determined this would be better done in Editor::keystroke */\n\tif (!n) {\n\t KeySym ks = XKeycodeToKeysym(rep()->display_->rep()->display_, xe.xkey.keycode, 0);\n\t if (ks) {\n\t strncpy(buf, (const char*)&ks, 2);\n\t n = 2;\n\t }\n\t}\n#endif\n\n }\n return n;\n}", "label": 0, "cwe": null, "length": 203 }, { "index": 45130, "code": "hasNext() {\n int32_t headIndex=bootIndex;\n PtnElem *curPtr=nodePtr;\n\n if (patternMap==NULL) {\n return FALSE;\n }\n while ( headIndex < MAX_PATTERN_ENTRIES ) {\n if ( curPtr != NULL ) {\n if ( curPtr->next != NULL ) {\n return TRUE;\n }\n else {\n headIndex++;\n curPtr=NULL;\n continue;\n }\n }\n else {\n if ( patternMap->boot[headIndex] != NULL ) {\n return TRUE;\n }\n else {\n headIndex++;\n continue;\n }\n }\n\n }\n return FALSE;\n}", "label": 0, "cwe": null, "length": 141 }, { "index": 67869, "code": "nilfs_segments_dirty_segments_show(struct nilfs_segments_attr *attr,\n\t\t\t\t struct the_nilfs *nilfs,\n\t\t\t\t char *buf)\n{\n\tstruct nilfs_sustat sustat;\n\tint err;\n\n\tdown_read(&nilfs->ns_segctor_sem);\n\terr = nilfs_sufile_get_stat(nilfs->ns_sufile, &sustat);\n\tup_read(&nilfs->ns_segctor_sem);\n\tif (err < 0) {\n\t\tprintk(KERN_ERR \"NILFS: unable to get segment stat: err=%d\\n\",\n\t\t\terr);\n\t\treturn err;\n\t}\n\n\treturn snprintf(buf, PAGE_SIZE, \"%llu\\n\", sustat.ss_ndirtysegs);\n}", "label": 0, "cwe": null, "length": 141 }, { "index": 393559, "code": "load(const char *modName,\n\t\t\t\t\t\t ArRobot *robot,\n\t\t\t\t\t\t void *modArgument,\n\t\t\t\t\t\t bool quiet)\n{\n std::string name;\n std::map::iterator iter;\n DllRef handle;\n bool (*func)(ArRobot*,void*);\n bool ret;\n\n name=modName;\n#ifdef WIN32\n if (strstr(modName, \".dll\") == 0)\n name+=\".dll\";\n#else\n if (strstr(modName, \".so\") == 0)\n name+=\".so\";\n#endif\n\n iter=ourModMap.find(name);\n if (iter != ourModMap.end())\n return(STATUS_ALREADY_LOADED);\n\n handle=dlopen(name.c_str(), RTLD_NOW | RTLD_GLOBAL);\n\n if (!handle || dlerror() != NULL)\n {\n if (!quiet)\n ArLog::log(ArLog::Terse, \"Failure to load module '%s': %s\",\n\t\t name.c_str(), dlerror());\n return(STATUS_FAILED_OPEN);\n }\n\n func=(bool(*)(ArRobot*,void*))dlsym(handle, \"ariaInitModule\");\n if (!func || dlerror() != NULL)\n {\n if (!quiet)\n ArLog::log(ArLog::Terse, \"No module initializer for %s.\", modName);\n ourModMap.insert(std::map::value_type(name,\n\t\t\t\t\t\t\t handle));\n return(STATUS_SUCCESS);\n //dlclose(handle);\n //return(STATUS_INVALID);\n }\n ret=(*func)(robot, modArgument);\n \n if (ret)\n {\n ourModMap.insert(std::map::value_type(name,\n\t\t\t\t\t\t\t handle));\n return(STATUS_SUCCESS);\n }\n else\n {\n if (!quiet)\n ArLog::log(ArLog::Terse, \"Module '%s' failed its init sequence\",\n\t\t name.c_str());\n dlclose(handle);\n return(STATUS_INIT_FAILED);\n }\n}", "label": 0, "cwe": null, "length": 429 }, { "index": 50640, "code": "makeLogBins(double xlow, double xup, unsigned int n) const {\n\n vector res;\n\n double c = log10(xup/xlow) / (n-1.);\n\n for ( unsigned int k = 0; k < n; ++k )\n res.push_back(xlow*pow(10.0,k*c));\n\n return res;\n\n}", "label": 0, "cwe": null, "length": 78 }, { "index": 1002973, "code": "stp_clear_parameter(stp_vars_t *v, const char *parameter, stp_parameter_type_t type)\n{\n switch (type)\n {\n case STP_PARAMETER_TYPE_STRING_LIST:\n stp_clear_string_parameter(v, parameter);\n break;\n case STP_PARAMETER_TYPE_FILE:\n stp_clear_file_parameter(v, parameter);\n break;\n case STP_PARAMETER_TYPE_DOUBLE:\n stp_clear_float_parameter(v, parameter);\n break;\n case STP_PARAMETER_TYPE_INT:\n stp_clear_int_parameter(v, parameter);\n break;\n case STP_PARAMETER_TYPE_DIMENSION:\n stp_clear_dimension_parameter(v, parameter);\n break;\n case STP_PARAMETER_TYPE_BOOLEAN:\n stp_clear_boolean_parameter(v, parameter);\n break;\n case STP_PARAMETER_TYPE_CURVE:\n stp_clear_curve_parameter(v, parameter);\n break;\n case STP_PARAMETER_TYPE_ARRAY:\n stp_clear_array_parameter(v, parameter);\n break;\n case STP_PARAMETER_TYPE_RAW:\n stp_clear_raw_parameter(v, parameter);\n break;\n default:\n stp_eprintf(v, \"Attempt to clear unknown type parameter!\\n\");\n }\n}", "label": 0, "cwe": null, "length": 246 }, { "index": 520120, "code": "last_not_in_array(apr_array_header_t *forwarded_for,\n apr_array_header_t *proxy_ips) {\n int i;\n for (i = (forwarded_for->nelts)-1; i > 0; i--) {\n\tif (!is_in_array(((char **)forwarded_for->elts)[i], proxy_ips))\n break;\n }\n return ((char **)forwarded_for->elts)[i];\n}", "label": 0, "cwe": null, "length": 90 }, { "index": 916867, "code": "dmap_addSN(CTX ctx, knh_dmap_t *dmap, ksfp_t *kvsfp)\n{\n\tsize_t loc = dmap->size;\n\tdmap_grow(ctx, dmap);\n\tKNH_INITv(dmap->dentry[loc].key, kvsfp[0].s);\n\tdmap->dentry[loc].nvalue = kvsfp[1].ndata;\n\tK_USE_FASTDMAP(dmap->dentry[loc].ukey = dmap->strkeyuint(S_tobytes(kvsfp[0].s)));\n\tdmap->size++;\n}", "label": 0, "cwe": null, "length": 124 }, { "index": 41082, "code": "init_ivecs(int client, int have_errsock)\n{\n size_t blocksize;\n\n krb5_crypto_getblocksize(context, crypto, &blocksize);\n\n ivec_in[0] = malloc(blocksize);\n memset(ivec_in[0], client, blocksize);\n\n if(have_errsock) {\n\tivec_in[1] = malloc(blocksize);\n\tmemset(ivec_in[1], 2 | client, blocksize);\n } else\n\tivec_in[1] = ivec_in[0];\n\n ivec_out[0] = malloc(blocksize);\n memset(ivec_out[0], !client, blocksize);\n\n if(have_errsock) {\n\tivec_out[1] = malloc(blocksize);\n\tmemset(ivec_out[1], 2 | !client, blocksize);\n } else\n\tivec_out[1] = ivec_out[0];\n}", "label": 0, "cwe": null, "length": 190 }, { "index": 916889, "code": "qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)\n{\n if (_c == QMetaObject::InvokeMetaMethod) {\n Q_ASSERT(staticMetaObject.cast(_o));\n SideBarModel *_t = static_cast(_o);\n switch (_id) {\n case 0: _t->removeLovedTracks(); break;\n case 1: _t->onResult((*reinterpret_cast< Request*(*)>(_a[1]))); break;\n case 2: _t->onAvatarDownloaded((*reinterpret_cast< QByteArray(*)>(_a[1]))); break;\n case 3: _t->onAppEvent((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< const QVariant(*)>(_a[2]))); break;\n case 4: _t->updateHistory(); break;\n default: ;\n }\n }\n}", "label": 0, "cwe": null, "length": 200 }, { "index": 93492, "code": "GLRenderInPath(SoGLRenderAction *action)\n\n////////////////////////////////////////////////////////////////////////\n{\n int numIndices;\n const int *indices;\n SoAction::PathCode pc = action->getPathCode(numIndices, indices);\n if (pc == SoAction::IN_PATH) { // still rendering in path:\n\tSoState *state = action->getState();\n\tstate->push();\n int whichChild = 0;\n for (int i = 0; i < numIndices && !action->hasTerminated(); i++) {\n\t while (whichChild < indices[i] && !action->hasTerminated()) {\n\t\tSoNode *kid = (SoNode *)children->get(whichChild);\n if (kid->affectsState()) {\n action->pushCurPath(whichChild);\n\t\t if (! action->abortNow())\n\t\t\tkid->GLRenderOffPath(action);\n\t\t else\n\t\t\tSoCacheElement::invalidate(action->getState());\n action->popCurPath(pc);\n }\n ++whichChild;\n\t }\n\t action->pushCurPath(whichChild);\n\t if (action->abortNow())\n\t\tSoCacheElement::invalidate(action->getState());\n\t else\n\t\t((SoNode *)children->get(whichChild))->GLRenderInPath(action);\n\t action->popCurPath(pc);\n\t ++whichChild;\n }\n\tstate->pop();\n } else if (pc == SoAction::BELOW_PATH) { // This must be tail node\n GLRenderBelowPath(action);\n } else { // This should NEVER happen:\n#ifdef DEBUG\n\tSoDebugError::post(\"SoSeparator::GLRenderInPath\",\n\t\t\t \"PathCode went to NO_PATH or OFF_PATH!\");\n#endif\n }\n}", "label": 0, "cwe": null, "length": 348 }, { "index": 978816, "code": "ipcp_process_devirtualization_opportunities (struct cgraph_node *node)\n{\n struct ipa_node_params *info = IPA_NODE_REF (node);\n struct cgraph_edge *ie, *next_ie;\n\n for (ie = node->indirect_calls; ie; ie = next_ie)\n {\n int param_index, types_count, j;\n HOST_WIDE_INT token;\n tree target, delta;\n\n next_ie = ie->next_callee;\n if (!ie->indirect_info->polymorphic)\n\tcontinue;\n param_index = ie->indirect_info->param_index;\n if (param_index == -1\n\t || ipa_param_cannot_devirtualize_p (info, param_index)\n\t || ipa_param_types_vec_empty (info, param_index))\n\tcontinue;\n\n token = ie->indirect_info->otr_token;\n target = NULL_TREE;\n types_count = VEC_length (tree, info->params[param_index].types);\n for (j = 0; j < types_count; j++)\n\t{\n\t tree binfo = VEC_index (tree, info->params[param_index].types, j);\n\t tree d;\n\t tree t = gimple_get_virt_method_for_binfo (token, binfo, &d, true);\n\n\t if (!t)\n\t {\n\t target = NULL_TREE;\n\t break;\n\t }\n\t else if (!target)\n\t {\n\t target = t;\n\t delta = d;\n\t }\n\t else if (target != t || !tree_int_cst_equal (delta, d))\n\t {\n\t target = NULL_TREE;\n\t break;\n\t }\n\t}\n\n if (target)\n\tipa_make_edge_direct_to_target (ie, target, delta);\n }\n}", "label": 0, "cwe": null, "length": 365 }, { "index": 536508, "code": "colorMess(float red, float green, float blue, float alpha)\n{\n GemMan::m_clear_color[0] = red;\n GemMan::m_clear_color[1] = green;\n GemMan::m_clear_color[2] = blue;\n GemMan::m_clear_color[3] = alpha;\n if ( GemMan::windowExists() ) {\n glClearColor(red, green, blue, alpha);\n }\n}", "label": 0, "cwe": null, "length": 94 }, { "index": 290969, "code": "_script_list_create (const char *pattern)\n{\n\tglob_t gl;\n\tsize_t i;\n\tList l = NULL;\n\n\tif (pattern == NULL)\n\t\treturn (NULL);\n\n\tint rc = glob (pattern, GLOB_ERR, _ef, &gl);\n\tswitch (rc) {\n\tcase 0:\n\t\tl = list_create ((ListDelF) _xfree_f);\n\t\tfor (i = 0; i < gl.gl_pathc; i++)\n\t\t\tlist_push (l, xstrdup (gl.gl_pathv[i]));\n\t\tbreak;\n\tcase GLOB_NOMATCH:\n\t\tbreak;\n\tcase GLOB_NOSPACE:\n\t\terror (\"run_script: glob(3): Out of memory\");\n\t\tbreak;\n\tcase GLOB_ABORTED:\n\t\terror (\"run_script: cannot read dir %s: %m\", pattern);\n\t\tbreak;\n\tdefault:\n\t\terror (\"Unknown glob(3) return code = %d\", rc);\n\t\tbreak;\n\t}\n\n\tglobfree (&gl);\n\n\treturn l;\n}", "label": 0, "cwe": null, "length": 206 }, { "index": 571060, "code": "phy_config_bb_with_pghdrfile(struct ieee80211_hw *hw,\n\t\t\t\t\t u8 configtype)\n{\n\tstruct rtl_priv *rtlpriv = rtl_priv(hw);\n\tint i;\n\tu32 *phy_regarray_table_pg;\n\tu16 phy_regarray_pg_len;\n\tu32 v1 = 0, v2 = 0, v3 = 0, v4 = 0, v5 = 0, v6 = 0;\n\n\tphy_regarray_pg_len = RTL8192EE_PHY_REG_ARRAY_PG_LEN;\n\tphy_regarray_table_pg = RTL8192EE_PHY_REG_ARRAY_PG;\n\n\tif (configtype == BASEBAND_CONFIG_PHY_REG) {\n\t\tfor (i = 0; i < phy_regarray_pg_len; i = i + 6) {\n\t\t\tv1 = phy_regarray_table_pg[i];\n\t\t\tv2 = phy_regarray_table_pg[i+1];\n\t\t\tv3 = phy_regarray_table_pg[i+2];\n\t\t\tv4 = phy_regarray_table_pg[i+3];\n\t\t\tv5 = phy_regarray_table_pg[i+4];\n\t\t\tv6 = phy_regarray_table_pg[i+5];\n\n\t\t\tif (v1 < 0xcdcdcdcd) {\n\t\t\t\t_rtl92ee_store_tx_power_by_rate(hw, v1, v2, v3,\n\t\t\t\t\t\t\t\tv4, v5, v6);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t} else {\n\t\tRT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,\n\t\t\t \"configtype != BaseBand_Config_PHY_REG\\n\");\n\t}\n\treturn true;\n}", "label": 0, "cwe": null, "length": 329 }, { "index": 306539, "code": "erts_pcre_get_stringnumber(const pcre *code, const char *stringname)\n{\nint rc;\nint entrysize;\nint top, bot;\nuschar *nametable;\n\nif ((rc = erts_pcre_fullinfo(code, NULL, PCRE_INFO_NAMECOUNT, &top)) != 0)\n return rc;\nif (top <= 0) return PCRE_ERROR_NOSUBSTRING;\n\nif ((rc = erts_pcre_fullinfo(code, NULL, PCRE_INFO_NAMEENTRYSIZE, &entrysize)) != 0)\n return rc;\nif ((rc = erts_pcre_fullinfo(code, NULL, PCRE_INFO_NAMETABLE, &nametable)) != 0)\n return rc;\n\nbot = 0;\nwhile (top > bot)\n {\n int mid = (top + bot) / 2;\n uschar *entry = nametable + entrysize*mid;\n int c = strcmp(stringname, (char *)(entry + 2));\n if (c == 0) return (entry[0] << 8) + entry[1];\n if (c > 0) bot = mid + 1; else top = mid;\n }\n\nreturn PCRE_ERROR_NOSUBSTRING;\n}", "label": 0, "cwe": null, "length": 265 }, { "index": 296185, "code": "init(void)\n{\n _title=label()->label();\n _highlightThickness=0;\n _shadowThickness=2;\n _titleAlignment=MSLeft|MSCenter;\n shadowStyle(MSEtchedIn);\n int offset=shadowThickness()+highlightThickness()+margin();\n label()->highlightThickness(0);\n label()->shadowThickness(0);\n label()->margin(4);\n label()->dynamic(MSTrue);\n label()->moveTo(offset,offset);\n if (label()->columns()>0) label()->map();\n}", "label": 0, "cwe": null, "length": 113 }, { "index": 6168, "code": "_hb_ot_shaper_shape_plan_data_create (hb_shape_plan_t *shape_plan,\n\t\t\t\t const hb_feature_t *user_features,\n\t\t\t\t unsigned int num_user_features)\n{\n hb_ot_shape_plan_t *plan = (hb_ot_shape_plan_t *) calloc (1, sizeof (hb_ot_shape_plan_t));\n if (unlikely (!plan))\n return NULL;\n\n hb_ot_shape_planner_t planner (shape_plan);\n\n planner.shaper = hb_ot_shape_complex_categorize (&planner);\n\n hb_ot_shape_collect_features (&planner, &shape_plan->props, user_features, num_user_features);\n\n planner.compile (*plan);\n\n if (plan->shaper->data_create) {\n plan->data = plan->shaper->data_create (plan);\n if (unlikely (!plan->data))\n return NULL;\n }\n\n return plan;\n}", "label": 0, "cwe": null, "length": 181 }, { "index": 945130, "code": "RemoveNode(Node *n)\n{\n for(int j=0; jduration==(u64) -1) ptr->version = 0;\n\telse ptr->version = (ptr->duration>0xFFFFFFFF) ? 1 : 0;\n\te = gf_isom_full_box_get_size(s);\n\tif (e) return e;\n\tptr->size += (ptr->version == 1) ? 28 : 16;\n\tptr->size += 80;\n\treturn GF_OK;\n}", "label": 0, "cwe": null, "length": 122 }, { "index": 943071, "code": "check(Canvas* c, const Allocation& a) {\n if (canvas_ == nil || canvas_ != c ||\n\ttransformer_ != c->transformer() || !allocation_.equals(a, 1e-4)\n ) {\n\tExtension ext;\n\tscrollbox_->allocate(c, a, ext);\n }\n}", "label": 0, "cwe": null, "length": 67 }, { "index": 1015925, "code": "r128_cce_dispatch_flip(struct drm_device *dev)\n{\n\tdrm_r128_private_t *dev_priv = dev->dev_private;\n\tRING_LOCALS;\n\tDRM_DEBUG(\"page=%d pfCurrentPage=%d\\n\",\n\t\t dev_priv->current_page, dev_priv->sarea_priv->pfCurrentPage);\n\n#if R128_PERFORMANCE_BOXES\n\t/* Do some trivial performance monitoring...\n\t */\n\tr128_cce_performance_boxes(dev_priv);\n#endif\n\n\tBEGIN_RING(4);\n\n\tR128_WAIT_UNTIL_PAGE_FLIPPED();\n\tOUT_RING(CCE_PACKET0(R128_CRTC_OFFSET, 0));\n\n\tif (dev_priv->current_page == 0)\n\t\tOUT_RING(dev_priv->back_offset);\n\telse\n\t\tOUT_RING(dev_priv->front_offset);\n\n\tADVANCE_RING();\n\n\t/* Increment the frame counter. The client-side 3D driver must\n\t * throttle the framerate by waiting for this value before\n\t * performing the swapbuffer ioctl.\n\t */\n\tdev_priv->sarea_priv->last_frame++;\n\tdev_priv->sarea_priv->pfCurrentPage = dev_priv->current_page =\n\t 1 - dev_priv->current_page;\n\n\tBEGIN_RING(2);\n\n\tOUT_RING(CCE_PACKET0(R128_LAST_FRAME_REG, 0));\n\tOUT_RING(dev_priv->sarea_priv->last_frame);\n\n\tADVANCE_RING();\n}", "label": 0, "cwe": null, "length": 284 }, { "index": 288473, "code": "sock_get(void)\n{\n int i;\n dns_sock_t *sock;\n\n for (i = 0; i < NELEMS(SockPool); i++) {\n sock = &SockPool[i];\n if (sock->sock_state == SOCK_FREE) {\n if (ATOMIC_CAS(&sock->sock_state, SOCK_FREE, SOCK_RESERVED)) {\n sock->sock_timer.st_lastevent = time(NULL);\n return sock;\n }\n }\n }\n\n return NULL;\n}", "label": 0, "cwe": null, "length": 104 }, { "index": 33676, "code": "get_private_data (GObject *gobject)\n{\n WnckPagerAccessiblePriv *private_data;\n\n private_data = g_object_get_qdata (gobject,\n quark_private_data);\n if (!private_data)\n {\n private_data = g_new0 (WnckPagerAccessiblePriv, 1);\n g_object_set_qdata (gobject,\n quark_private_data,\n private_data);\n }\n return private_data;\n}", "label": 0, "cwe": null, "length": 96 }, { "index": 770382, "code": "runOnModule(Module &M) {\n bool Changed = false;\n\n // Convert any aliases that alias with an available externally\n // value (which will be turned into declarations later on in this routine)\n // into declarations themselves. All aliases must be definitions, and\n // must alias with a definition. So this involves creating a declaration\n // equivalent to the alias's base object.\n for (Module::alias_iterator I = M.alias_begin(), E = M.alias_end(); I != E;) {\n // Increment the iterator first since we may delete the current alias.\n GlobalAlias &GA = *(I++);\n GlobalValue *GVal = GA.getBaseObject();\n if (!GVal->hasAvailableExternallyLinkage())\n continue;\n convertAliasToDeclaration(GA, M);\n Changed = true;\n }\n\n // Drop initializers of available externally global variables.\n for (GlobalVariable &GV : M.globals()) {\n if (!GV.hasAvailableExternallyLinkage())\n continue;\n if (GV.hasInitializer()) {\n Constant *Init = GV.getInitializer();\n GV.setInitializer(nullptr);\n if (isSafeToDestroyConstant(Init))\n Init->destroyConstant();\n }\n GV.removeDeadConstantUsers();\n GV.setLinkage(GlobalValue::ExternalLinkage);\n NumVariables++;\n Changed = true;\n }\n\n // Drop the bodies of available externally functions.\n for (Function &F : M) {\n if (!F.hasAvailableExternallyLinkage())\n continue;\n if (!F.isDeclaration())\n // This will set the linkage to external\n F.deleteBody();\n F.removeDeadConstantUsers();\n NumFunctions++;\n Changed = true;\n }\n\n return Changed;\n}", "label": 0, "cwe": null, "length": 363 }, { "index": 832580, "code": "action_self_start_volume_callback (GtkAction *action,\n\t\t\t\t gpointer data)\n{\n\tNemoFile *file;\n\tNemoView *view;\n\tGMountOperation *mount_op;\n\n\tview = NEMO_VIEW (data);\n\n\tfile = nemo_view_get_directory_as_file (view);\n\tif (file == NULL) {\n\t\treturn;\n\t}\n\n\tmount_op = gtk_mount_operation_new (nemo_view_get_containing_window (view));\n\tnemo_file_start (file, mount_op, NULL, file_start_callback, NULL);\n\tg_object_unref (mount_op);\n}", "label": 0, "cwe": null, "length": 115 }, { "index": 247185, "code": "make_member_array(struct dlm_ls *ls)\n{\n\tstruct dlm_member *memb;\n\tint i, w, x = 0, total = 0, all_zero = 0, *array;\n\n\tkfree(ls->ls_node_array);\n\tls->ls_node_array = NULL;\n\n\tlist_for_each_entry(memb, &ls->ls_nodes, list) {\n\t\tif (memb->weight)\n\t\t\ttotal += memb->weight;\n\t}\n\n\t/* all nodes revert to weight of 1 if all have weight 0 */\n\n\tif (!total) {\n\t\ttotal = ls->ls_num_nodes;\n\t\tall_zero = 1;\n\t}\n\n\tls->ls_total_weight = total;\n\n\tarray = kmalloc(sizeof(int) * total, GFP_NOFS);\n\tif (!array)\n\t\treturn;\n\n\tlist_for_each_entry(memb, &ls->ls_nodes, list) {\n\t\tif (!all_zero && !memb->weight)\n\t\t\tcontinue;\n\n\t\tif (all_zero)\n\t\t\tw = 1;\n\t\telse\n\t\t\tw = memb->weight;\n\n\t\tDLM_ASSERT(x < total, printk(\"total %d x %d\\n\", total, x););\n\n\t\tfor (i = 0; i < w; i++)\n\t\t\tarray[x++] = memb->nodeid;\n\t}\n\n\tls->ls_node_array = array;\n}", "label": 0, "cwe": null, "length": 275 }, { "index": 933178, "code": "XagDestroyApplicationGroup(Display* dpy, XAppGroup app_group)\n{\n XExtDisplayInfo *info = find_display (dpy);\n xXagDestroyReq *req;\n\n XagCheckExtension (dpy, info, False);\n\n LockDisplay(dpy);\n GetReq(XagDestroy, req);\n req->reqType = info->codes->major_opcode;\n req->xagReqType = X_XagDestroy;\n req->app_group = app_group;\n UnlockDisplay(dpy);\n SyncHandle();\n return True;\n}", "label": 0, "cwe": null, "length": 119 }, { "index": 921475, "code": "expand_string(const char *s)\n{\n struct expand_buf eb;\n char *res;\n eb.size = 256;\n eb.buf = malloc(eb.size);\n eb.cur = eb.buf;\n eb.len = 0;\n\n while (*s) {\n const char *subst = get_subst(s);\n if (subst) {\n int len = strlen(subst);\n ensure_buffer(&eb, len + 1);\n *eb.cur = 0;\n strcat(eb.buf, subst);\n eb.cur += len;\n eb.len += len;\n s = strchr(s, '}');\n s ++;\n } else {\n *eb.cur = *s;\n /**/\n eb.cur ++;\n s++;\n eb.len ++;\n }\n /**/\n ensure_buffer(&eb, 256);\n }\n *eb.cur = 0;\n /**/\n res = strdup(eb.buf);\n free(eb.buf);\n return res;\n}", "label": 0, "cwe": null, "length": 203 }, { "index": 862526, "code": "send_event(CSPLITTER *_object)\n{\n\tif (!WIDGET)\n\t\treturn;\n\tGB.Raise(THIS, EVENT_Resize, 0);\n\tTHIS->event = FALSE;\n}", "label": 0, "cwe": null, "length": 40 }, { "index": 27093, "code": "xappend(void)\n{\n LVAL list,last=NULL,next,val;\n\n /* protect some pointers */\n xlsave1(val);\n\n /* initialize */\n val = NIL;\n \n /* append each argument */\n if (moreargs()) {\n while (xlargc > 1) {\n\n /* append each element of this list to the result list */\n for (list = nextarg(); consp(list); list = cdr(list)) {\n next = consa(car(list));\n if (val) rplacd(last,next);\n else val = next;\n last = next;\n }\n }\n\n /* handle the last argument */\n if (val) rplacd(last,nextarg());\n else val = nextarg();\n }\n\n /* restore the stack */\n xlpop();\n\n /* return the list */\n return (val);\n}", "label": 1, "cwe": "CWE-476", "length": 175 }, { "index": 167850, "code": "parser_explode_string( const char *string, char c )\n{\n List *list = list_create( LIST_AUTO_DELETE, LIST_NO_CALLBACK );\n char *next_slash = 0;\n char small_buf[64];\n while ( *string != 0 && ( next_slash = strchr( string, c ) ) != 0 ) {\n if ( next_slash != string ) {\n\t const unsigned buflen = next_slash - string;\n\t /* don't bust the stack. call alloca only on long strings */\n\t char *buffer = buflen < sizeof small_buf ? small_buf : alloca(buflen + 1);\n memcpy( buffer, string, buflen );\n\t buffer[buflen] = 0;\n list_add( list, strdup( buffer ) );\n }\n string += next_slash - string + 1;\n }\n if ( string[0] != 0 )\n list_add( list, strdup( string ) );\n return list;\n}", "label": 0, "cwe": null, "length": 207 }, { "index": 240515, "code": "glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)\n{\n _GLFWwindow* window = (_GLFWwindow*) handle;\n assert(window != NULL);\n assert(numer != 0);\n assert(denom != 0);\n\n _GLFW_REQUIRE_INIT();\n\n if (numer != GLFW_DONT_CARE && denom != GLFW_DONT_CARE)\n {\n if (numer <= 0 || denom <= 0)\n {\n _glfwInputError(GLFW_INVALID_VALUE,\n \"Invalid window aspect ratio %i:%i\",\n numer, denom);\n return;\n }\n }\n\n window->numer = numer;\n window->denom = denom;\n\n if (window->monitor || !window->resizable)\n return;\n\n _glfwPlatformSetWindowAspectRatio(window, numer, denom);\n}", "label": 0, "cwe": null, "length": 175 }, { "index": 554521, "code": "SoftenFloatOp_SELECT_CC(SDNode *N) {\n SDValue NewLHS = N->getOperand(0), NewRHS = N->getOperand(1);\n ISD::CondCode CCCode = cast(N->getOperand(4))->get();\n\n EVT VT = NewLHS.getValueType();\n NewLHS = GetSoftenedFloat(NewLHS);\n NewRHS = GetSoftenedFloat(NewRHS);\n TLI.softenSetCCOperands(DAG, VT, NewLHS, NewRHS, CCCode, SDLoc(N));\n\n // If softenSetCCOperands returned a scalar, we need to compare the result\n // against zero to select between true and false values.\n if (!NewRHS.getNode()) {\n NewRHS = DAG.getConstant(0, SDLoc(N), NewLHS.getValueType());\n CCCode = ISD::SETNE;\n }\n\n // Update N to have the operands specified.\n return SDValue(DAG.UpdateNodeOperands(N, NewLHS, NewRHS,\n N->getOperand(2), N->getOperand(3),\n DAG.getCondCode(CCCode)),\n 0);\n}", "label": 0, "cwe": null, "length": 260 }, { "index": 83246, "code": "free_post_context(PostContext *context)\n{\n n_post_contexts--;\n if (context->file_name) {\n\tunlink(context->file_name);\n\tXtFree(context->file_name);\n\tcontext->file_name = NULL;\n }\n free((char *)context->art); /* :-( */\n context->art = NULL;\n XtFree(context->charset);\n context->charset = NULL;\n if (context->widgets) {\n\tdestroy_post_widgets(context->widgets);\n\tcontext->widgets = NULL;\n }\n if (context->attachments) {\n\tint\ti, n = context->n_attachments;\n\n\tfor (i = 0 ; i < n ; i++)\n\t free_attachment(context->attachments[i]);\n\tXtFree((char *)context->attachments);\n\tcontext->attachments = NULL;\n\tcontext->n_attachments = 0;\n }\n XtFree((char *)context);\n}", "label": 0, "cwe": null, "length": 182 }, { "index": 776174, "code": "nl_model_add_spec_info (MODEL *pmod, nlspec *spec)\n{\n const char *cmd = gretl_command_word(spec->ci);\n PRN *prn;\n char *buf;\n int i, err = 0;\n\n prn = gretl_print_new(GRETL_PRINT_BUFFER, &err);\n if (err) {\n\treturn err;\n }\n\n pputs(prn, cmd);\n\n if (pmod->depvar != NULL) {\n\tpprintf(prn, \" %s\\n\", pmod->depvar);\n } else {\n\tpputc(prn, '\\n');\n }\n\n for (i=0; inaux; i++) {\n\tpprintf(prn, \"%s\\n\", spec->aux[i]);\n }\n\n if (spec->ci == GMM) {\n\t/* orthog, weights */\n\tnlspec_print_gmm_info(spec, prn);\n }\n\n if (numeric_mode(spec)) {\n\tpprintf(prn, \"params\");\n\tfor (i=0; inparam; i++) {\n\t pprintf(prn, \" %s\", spec->params[i].name);\n\t}\n\tpputc(prn, '\\n');\n } else {\n\tfor (i=0; inparam; i++) {\n\t pprintf(prn, \"deriv %s = %s\\n\", spec->params[i].name,\n\t\t spec->params[i].deriv);\n\t}\n }\n\n if (spec->hesscall != NULL) {\n\tpprintf(prn, \"hessian %s\\n\", spec->hesscall);\n }\n\n pprintf(prn, \"end %s\\n\", cmd);\n\n buf = gretl_print_steal_buffer(prn);\n gretl_model_set_string_as_data(pmod, \"nlinfo\", buf);\n gretl_print_destroy(prn);\n\n return 0;\n}", "label": 0, "cwe": null, "length": 408 }, { "index": 884145, "code": "csv_import_trans_assistant_file_page_prepare (GtkAssistant *assistant,\n gpointer user_data)\n{\n CsvImportTrans *info = user_data;\n gint num = gtk_assistant_get_current_page (assistant);\n GtkWidget *page = gtk_assistant_get_nth_page (assistant, num);\n\n info->account_picker->auto_create = TRUE; /* Step over account page if we find matching online id */\n info->previewing_errors = FALSE; /* We're looking at all the data. */\n info->approved = FALSE; /* This is FALSE until the user clicks \"OK\". */\n\n /* Set the default directory */\n if (info->starting_dir)\n gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(info->file_chooser), info->starting_dir);\n\n /* Disable the Forward Assistant Button */\n gtk_assistant_set_page_complete (assistant, page, FALSE);\n}", "label": 0, "cwe": null, "length": 185 }, { "index": 151868, "code": "DropAt(SelectionPosition position, const char *value, bool moving, bool rectangular) {\n\t//Platform::DebugPrintf(\"DropAt %d %d\\n\", inDragDrop, position);\n\tif (inDragDrop == ddDragging)\n\t\tdropWentOutside = false;\n\n\tbool positionWasInSelection = PositionInSelection(position.Position());\n\n\tbool positionOnEdgeOfSelection =\n\t (position == SelectionStart()) || (position == SelectionEnd());\n\n\tif ((inDragDrop != ddDragging) || !(positionWasInSelection) ||\n\t (positionOnEdgeOfSelection && !moving)) {\n\n\t\tSelectionPosition selStart = SelectionStart();\n\t\tSelectionPosition selEnd = SelectionEnd();\n\n\t\tUndoGroup ug(pdoc);\n\n\t\tSelectionPosition positionAfterDeletion = position;\n\t\tif ((inDragDrop == ddDragging) && moving) {\n\t\t\t// Remove dragged out text\n\t\t\tif (rectangular || sel.selType == Selection::selLines) {\n\t\t\t\tfor (size_t r=0; r= sel.Range(r).Start()) {\n\t\t\t\t\t\tif (position > sel.Range(r).End()) {\n\t\t\t\t\t\t\tpositionAfterDeletion.Add(-sel.Range(r).Length());\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tpositionAfterDeletion.Add(-SelectionRange(position, sel.Range(r).Start()).Length());\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (position > selStart) {\n\t\t\t\t\tpositionAfterDeletion.Add(-SelectionRange(selEnd, selStart).Length());\n\t\t\t\t}\n\t\t\t}\n\t\t\tClearSelection();\n\t\t}\n\t\tposition = positionAfterDeletion;\n\n\t\tif (rectangular) {\n\t\t\tPasteRectangular(position, value, istrlen(value));\n\t\t\t// Should try to select new rectangle but it may not be a rectangle now so just select the drop position\n\t\t\tSetEmptySelection(position);\n\t\t} else {\n\t\t\tposition = MovePositionOutsideChar(position, sel.MainCaret() - position.Position());\n\t\t\tposition = SelectionPosition(InsertSpace(position.Position(), position.VirtualSpace()));\n\t\t\tif (pdoc->InsertCString(position.Position(), value)) {\n\t\t\t\tSelectionPosition posAfterInsertion = position;\n\t\t\t\tposAfterInsertion.Add(istrlen(value));\n\t\t\t\tSetSelection(posAfterInsertion, position);\n\t\t\t}\n\t\t}\n\t} else if (inDragDrop == ddDragging) {\n\t\tSetEmptySelection(position);\n\t}\n}", "label": 0, "cwe": null, "length": 500 }, { "index": 612294, "code": "frame2flat(\n flames_frame *myframe, \n allflats *myflats, \n int32_t iframe)\n{\n int32_t ifibre=0;\n int32_t i=0;\n frame_data *fdvecbuf1=0;\n\n /* copy pointers from myframe to myflats */\n myflats->flatdata[iframe].data = myframe->frame_array;\n myflats->flatdata[iframe].sigma = myframe->frame_sigma;\n myflats->flatdata[iframe].badpixel = myframe->badpixel;\n myflats->flatdata[iframe].framename = myframe->framename;\n myflats->flatdata[iframe].sigmaname = myframe->sigmaname;\n myflats->flatdata[iframe].badname = myframe->badname;\n /* generate numfibres and fibres */\n myflats->flatdata[iframe].numfibres = 0;\n for (ifibre = 0; ifibre <= myframe->maxfibres-1; ifibre++){\n if (myframe->fibremask[ifibre] == TRUE) {\n myflats->flatdata[iframe].fibres[myflats->flatdata[iframe].numfibres] =\n ifibre;\n myflats->fibremask[ifibre] = TRUE;\n myflats->fibre2frame[ifibre] = (int) iframe;\n myflats->flatdata[iframe].numfibres++;\n }\n }\n /* update global numfibres */\n myflats->numfibres += myflats->flatdata[iframe].numfibres;\n\n /* check to find pixmax */\n fdvecbuf1 = myflats->flatdata[iframe].data[0];\n for (i=0; i<=((myflats->subrows*myflats->subcols)-1); i++) {\n if (fdvecbuf1[i] > myflats->pixmax) {\n myflats->pixmax = fdvecbuf1[i];\n }\n }\n\n return(NOERR);\n\n}", "label": 0, "cwe": null, "length": 463 }, { "index": 180451, "code": "readRideData(RideFile *rideFile, const QByteArray& block, const int nrOfRecords, const qint16 version) {\n const int dataRecordSize = (version == 100) ? TACX_RIDE_DATA_BLOCK_SIZE : TACX_RIDE_DATA_BLOCK_SIZE + 8;\n\n double seconds = rideFile->recIntSecs();\n\n struct RideFilePoint firstDataPoint = readSinglePoint(block, seconds, rideFile->recIntSecs());\n float startDistance = firstDataPoint.km * 1000.0;\n float lastDistance = 0.0f;\n for(int i = 0; i < nrOfRecords; i++, seconds += rideFile->recIntSecs()) {\n const QByteArray& record = block.mid(i * dataRecordSize);\n struct RideFilePoint nextDataPoint = readSinglePoint(record, seconds, rideFile->recIntSecs(), startDistance, lastDistance);\n lastDistance = nextDataPoint.km * 1000.0;\n\n rideFile->appendPoint(nextDataPoint.secs, nextDataPoint.cad,\n nextDataPoint.hr, nextDataPoint.km,\n nextDataPoint.kph, nextDataPoint.nm,\n nextDataPoint.watts, nextDataPoint.alt,\n nextDataPoint.lon, nextDataPoint.lat,\n nextDataPoint.headwind, 0.0, RideFile::noTemp, 0.0, nextDataPoint.interval);\n }\n return true;\n}", "label": 0, "cwe": null, "length": 316 }, { "index": 617502, "code": "dom_property_exists(zval *object, zval *member, int check_empty, const zend_literal *key TSRMLS_DC)\n{\n\tdom_object *obj;\n\tzval tmp_member;\n\tdom_prop_handler *hnd;\n\tzend_object_handlers *std_hnd;\n\tint ret, retval=0;\n\n \tif (member->type != IS_STRING) {\n\t\ttmp_member = *member;\n\t\tzval_copy_ctor(&tmp_member);\n\t\tconvert_to_string(&tmp_member);\n\t\tmember = &tmp_member;\n\t}\n\n\tret = FAILURE;\n\tobj = (dom_object *)zend_objects_get_address(object TSRMLS_CC);\n\n\tif (obj->prop_handler != NULL) {\n\t\tret = zend_hash_find((HashTable *)obj->prop_handler, Z_STRVAL_P(member), Z_STRLEN_P(member)+1, (void **) &hnd);\n\t}\n\tif (ret == SUCCESS) {\n\t\tzval *tmp;\n\n\t\tif (check_empty == 2) {\n\t\t\tretval = 1;\n\t\t} else if (hnd->read_func(obj, &tmp TSRMLS_CC) == SUCCESS) {\n\t\t\tZ_SET_REFCOUNT_P(tmp, 1);\n\t\t\tZ_UNSET_ISREF_P(tmp);\n\t\t\tif (check_empty == 1) {\n\t\t\t\tretval = zend_is_true(tmp);\n\t\t\t} else if (check_empty == 0) {\n\t\t\t\tretval = (Z_TYPE_P(tmp) != IS_NULL);\n\t\t\t}\n\t\t\tzval_ptr_dtor(&tmp);\n\t\t}\n\t} else {\n\t\tstd_hnd = zend_get_std_object_handlers();\n\t\tretval = std_hnd->has_property(object, member, check_empty, key TSRMLS_CC);\n\t}\n\n\tif (member == &tmp_member) {\n\t\tzval_dtor(member);\n\t}\n\treturn retval;\n}", "label": 0, "cwe": null, "length": 363 }, { "index": 351017, "code": "maxtype(int t1, int t2)\n#endif\n{\n\tint t;\n\n\tt = t1 >= t2 ? t1 : t2;\n\tif(t==TYCOMPLEX && (t1==TYDREAL || t2==TYDREAL) )\n\t\tt = TYDCOMPLEX;\n\treturn(t);\n}", "label": 0, "cwe": null, "length": 66 }, { "index": 33758, "code": "collate_startup (struct linereader *ldfile, struct localedef_t *locale,\n\t\t struct localedef_t *copy_locale, int ignore_content)\n{\n if (!ignore_content && locale->categories[LC_COLLATE].collate == NULL)\n {\n struct locale_collate_t *collate;\n\n if (copy_locale == NULL)\n\t{\n\t collate = locale->categories[LC_COLLATE].collate =\n\t (struct locale_collate_t *)\n\t xcalloc (1, sizeof (struct locale_collate_t));\n\n\t /* Init the various data structures. */\n\t init_hash (&collate->elem_table, 100);\n\t init_hash (&collate->sym_table, 100);\n\t init_hash (&collate->seq_table, 500);\n\t obstack_init (&collate->mempool);\n\n\t collate->col_weight_max = -1;\n\t}\n else\n\t/* Reuse the copy_locale's data structures. */\n\tcollate = locale->categories[LC_COLLATE].collate =\n\t copy_locale->categories[LC_COLLATE].collate;\n }\n\n ldfile->translate_strings = 0;\n ldfile->return_widestr = 0;\n}", "label": 0, "cwe": null, "length": 255 }, { "index": 484940, "code": "valint(const Value *val)\n{\n if (!(val = valnum(val)))\n\treturn 0;\n\n if (val->type & (TYPE_INT | TYPE_POS | TYPE_ENUM))\n return val->u.ival;\n if (val->type & (TYPE_DECIMAL|TYPE_DTIME|TYPE_ATIME))\n return (long)val->u.tval.tv_sec;\n#if !NO_FLOAT\n else if (val->type & TYPE_FLOAT) {\n double fival = val->u.fval < 0 ? ceil(val->u.fval) : floor(val->u.fval);\n if (fival != (long)val->u.fval) {\n\t eprintf(\"real value too large to convert to integer\");\n\t}\n return (long)val->u.fval;\n }\n#endif\n return 0;\n}", "label": 0, "cwe": null, "length": 178 }, { "index": 71957, "code": "list_get_value (void * user, int row, int column, GValue * value)\n{\n g_return_if_fail (search_matches);\n g_return_if_fail (column >= 0 && column < 2);\n g_return_if_fail (row >= 0 && row < search_matches->len);\n\n int playlist = aud_playlist_get_active ();\n int entry = g_array_index (search_matches, int, row);\n\n switch (column)\n {\n case 0:\n g_value_set_int (value, 1 + entry);\n break;\n case 1:;\n char * title = aud_playlist_entry_get_title (playlist, entry, TRUE);\n g_return_if_fail (title);\n g_value_set_string (value, title);\n str_unref (title);\n break;\n }\n}", "label": 0, "cwe": null, "length": 168 }, { "index": 8823, "code": "insert_unichar (ClutterText *text, gunichar unichar, int position)\n{\n if (position > DONT_MOVE_CURSOR)\n {\n clutter_text_set_cursor_position (text, position);\n g_assert_cmpint (clutter_text_get_cursor_position (text), ==, position);\n }\n\n clutter_text_insert_unichar (text, unichar);\n}", "label": 0, "cwe": null, "length": 82 }, { "index": 263683, "code": "vmw_cmd_dx_so_define(struct vmw_private *dev_priv,\n\t\t\t\tstruct vmw_sw_context *sw_context,\n\t\t\t\tSVGA3dCmdHeader *header)\n{\n\tstruct vmw_resource_val_node *ctx_node = sw_context->dx_ctx_node;\n\tstruct vmw_resource *res;\n\t/*\n\t * This is based on the fact that all affected define commands have\n\t * the same initial command body layout.\n\t */\n\tstruct {\n\t\tSVGA3dCmdHeader header;\n\t\tuint32 defined_id;\n\t} *cmd;\n\tenum vmw_so_type so_type;\n\tint ret;\n\n\tif (unlikely(ctx_node == NULL)) {\n\t\tDRM_ERROR(\"DX Context not set.\\n\");\n\t\treturn -EINVAL;\n\t}\n\n\tso_type = vmw_so_cmd_to_type(header->id);\n\tres = vmw_context_cotable(ctx_node->res, vmw_so_cotables[so_type]);\n\tcmd = container_of(header, typeof(*cmd), header);\n\tret = vmw_cotable_notify(res, cmd->defined_id);\n\tvmw_resource_unreference(&res);\n\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 228 }, { "index": 25488, "code": "waitForEvents (TimeVal* tv_)\n{\n trace_with_mask(\"Reactor::waitForEvents\",REACTTRACE);\n\n TimerCountdown traceTime (tv_);\n DL((REACT,\"======================================\\n\"));\n\n /*--- Expire all stale Timers ---*/\n m_tqueue.expire (TimeVal::gettimeofday ());\n\n\t/* Test to see if Reactor has been deactivated as a result\n\t * of processing done by any TimerHandlers.\n\t */\n\tif (!m_active) {\n\t\treturn;\n\t}\n\n int nReady;\n TimeVal delay;\n TimeVal* dlp = &delay;\n\n /*---\n In case if not all data have been processed by the EventHandler,\n and EventHandler stated so in its callback's return value\n to dispatcher (), it will be called again. This way\n underlying file/socket stream can efficiently utilize its\n buffering mechaninsm.\n ---*/\n if ((nReady = isAnyReady ())) {\n\t\tDL((REACT,\"isAnyReady returned: %d\\n\",nReady));\n\t\tdispatch (nReady);\n\t\treturn;\n }\n\n DL((REACT,\"=== m_waitSet ===\\n\"));\n m_waitSet.dump ();\n\n do {\n\t\tm_readySet.reset ();\n\t\tDL ((REACT,\"m_readySet after reset():\\n\"));\n\t\tm_readySet.dump ();\n\n\t\tm_readySet = m_waitSet;\n\t\tDL ((REACT,\"m_readySet after assign:\\n\"));\n\t\tm_readySet.dump ();\n\n\t\tcalculateTimeout (dlp, tv_);\n\n\t\tnReady = ::select (m_maxfd_plus1,\n\t\t\t\t\t\t &m_readySet.m_rset,\n\t\t\t\t\t\t &m_readySet.m_wset,\n\t\t\t\t\t\t &m_readySet.m_eset,\n\t\t\t\t\t\t dlp);\n\t\tDL((REACT,\"::select() returned: %d\\n\",nReady));\n\n\t\tm_readySet.sync ();\n\t\tDL ((REACT,\"m_readySet after select:\\n\"));\n\t\tm_readySet.dump ();\n\n }\n\twhile (nReady < 0 && handleError ());\n\n dispatch (nReady);\n}", "label": 0, "cwe": null, "length": 432 }, { "index": 101909, "code": "remove_autosave_timeout (GtrTab * tab)\n{\n g_return_if_fail (tab->priv->autosave_timeout > 0);\n\n g_source_remove (tab->priv->autosave_timeout);\n tab->priv->autosave_timeout = 0;\n}", "label": 0, "cwe": null, "length": 57 }, { "index": 33441, "code": "gyrus_admin_acl_set_entry (GyrusAdmin *admin, const gchar *mailbox,\n\t\t\t const gchar* user, const gchar* permissions,\n\t\t\t gchar **error)\n{\n\tGyrusImapStatus status;\n\tgchar *msg;\n\n\tif (!gyrus_common_str_is_ascii (user)) {\n\t\tif (error != NULL)\n\t\t\t*error = g_strdup(_(\"Invalid identifier.\"));\n\t\treturn FALSE;\n\t}\n\n\tif (strlen (user) == 0) {\n\t\tif (error != NULL)\n\t\t\t*error = g_strdup(_(\"Empty entry name.\"));\n\t\treturn FALSE;\n\t}\n\telse if (strlen (mailbox) == 0) {\n\t\tif (error != NULL)\n\t\t\t*error = g_strdup(_(\"Empty mailbox name.\"));\n\t\treturn FALSE;\n\t}\n\t\n\tmsg = g_strdup_printf (\". setacl \\\"%s\\\" \\\"%s\\\" %s\\n\",\n\t\t\t mailbox, user, permissions);\n\tgyrus_admin_write_channel (admin, msg);\n\tg_free (msg);\n\n\tstatus = gyrus_admin_listen_channel (admin, &msg, NULL);\n\tg_free (msg);\n\n\tif (error != NULL)\n\t\tswitch (status) {\n\t\tcase GYRUS_IMAP_STATUS_NO:\n\t\t\t*error = g_strdup_printf\n\t\t\t\t(_(\"Mailbox '%s' does not exist.\"), mailbox);\n\t\t\tbreak;\n\t\tcase GYRUS_IMAP_STATUS_BAD:\n\t\t\t*error = g_strdup\n\t\t\t\t(_(\"Missing required argument to Setacl\"));\n\t\tcase GYRUS_IMAP_STATUS_BYE:\n\t\tcase GYRUS_IMAP_STATUS_LIST:\n\t\tcase GYRUS_IMAP_STATUS_OK:\n\t\t\tbreak;\n\t\t}\n\t\n\treturn (status == GYRUS_IMAP_STATUS_OK);\n}", "label": 0, "cwe": null, "length": 356 }, { "index": 210118, "code": "queue_message_thread (gpointer data)\n{\n\tSoupMessageQueueItem *item = data;\n\n\tsoup_session_process_queue_item (item->session, item, NULL, TRUE);\n\tif (item->callback) {\n\t\tsoup_add_completion (soup_session_get_async_context (item->session),\n\t\t\t\t queue_message_callback, item);\n\t} else\n\t\tsoup_message_queue_item_unref (item);\n\n\treturn NULL;\n}", "label": 0, "cwe": null, "length": 85 }, { "index": 273468, "code": "regcomp_start(expr, re_flags)\n char_u\t*expr;\n int\t\tre_flags;\t /* see vim_regcomp() */\n{\n initchr(expr);\n if (re_flags & RE_MAGIC)\n\treg_magic = MAGIC_ON;\n else\n\treg_magic = MAGIC_OFF;\n reg_string = (re_flags & RE_STRING);\n reg_strict = (re_flags & RE_STRICT);\n\n num_complex_braces = 0;\n regnpar = 1;\n vim_memset(had_endbrace, 0, sizeof(had_endbrace));\n#ifdef FEAT_SYN_HL\n regnzpar = 1;\n re_has_z = 0;\n#endif\n regsize = 0L;\n regflags = 0;\n#if defined(FEAT_SYN_HL) || defined(PROTO)\n had_eol = FALSE;\n#endif\n}", "label": 0, "cwe": null, "length": 184 }, { "index": 120841, "code": "sigtermhandler(int num){\n g_sigterm = TRUE;\n if(num == 1 && g_bgmode) g_sigrestart = TRUE;\n}", "label": 0, "cwe": null, "length": 32 }, { "index": 650669, "code": "crypto_ccm_encrypt_done(struct crypto_async_request *areq, int err)\n{\n\tstruct aead_request *req = areq->data;\n\tstruct crypto_aead *aead = crypto_aead_reqtfm(req);\n\tstruct crypto_ccm_req_priv_ctx *pctx = crypto_ccm_reqctx(req);\n\tu8 *odata = pctx->odata;\n\n\tif (!err)\n\t\tscatterwalk_map_and_copy(odata, req->dst,\n\t\t\t\t\t req->assoclen + req->cryptlen,\n\t\t\t\t\t crypto_aead_authsize(aead), 1);\n\taead_request_complete(req, err);\n}", "label": 0, "cwe": null, "length": 124 }, { "index": 526097, "code": "multi_common_scroll_text_down()\n{\n\tMulti_common_top_text_line++;\n\tif ( (Multi_common_num_text_lines - Multi_common_top_text_line) < Multi_common_text_max_display[gr_screen.res] ) {\n\t\tMulti_common_top_text_line--;\n\t\tif ( !mouse_down(MOUSE_LEFT_BUTTON) ){\n\t\t\tgamesnd_play_iface(SND_GENERAL_FAIL);\n\t\t}\n\t} else {\n\t\tgamesnd_play_iface(SND_SCROLL);\n\t}\n}", "label": 0, "cwe": null, "length": 94 }, { "index": 100472, "code": "main(int argc, char *argv[])\n{\n\tchar *file = g_strdup_printf(\"/tmp/test-%d.rhash\", getpid());\n\tfs_rhash *rh = fs_rhash_open_filename(file, O_RDWR | O_CREAT | O_TRUNC);\n\tfs_resource res;\n\tchar *strings[] = { \"foo\", \"bar\", \"qwertyuiopasdf\",\n\t\t\t \"http://example.org/foo/bar\",\n\t\t\t \"http://example.org/foo#bar\" };\n\tfs_resource r1 = { 23, \"foo\", 0 };\n\tfs_resource r2 = { 23+262144, \"bar\", 0 };\n\tfs_rhash_put(rh, &r1);\n\tfs_rhash_put(rh, &r2);\n\tres.rid = 23;\n\tfs_rhash_get(rh, &res);\n\tprintf(\"GOT %llx -> %s\\n\", res.rid, res.lex);\n\tdouble then = fs_time();\n\tfor (int i=0; ix_align;\n}", "label": 0, "cwe": null, "length": 57 }, { "index": 500543, "code": "hitum(struct monst *mon, int tmp, struct attack *uattk)\t\n{\n /* returns true if monster still lives */\n bool malive;\n int mhit = (tmp > (dieroll = rnd(20)) || u.uswallow);\n\n if(tmp > dieroll) exercise(A_DEX, true);\n malive = known_hitum(mon, &mhit, uattk);\n passive(mon, mhit, malive, AT_WEAP);\n return(malive);\n}", "label": 0, "cwe": null, "length": 110 }, { "index": 34506, "code": "valid_commercial_p(VALUE y, int w, int d, double sg,\n\t\t VALUE *nth, int *ry,\n\t\t int *rw, int *rd, int *rjd,\n\t\t int *ns)\n{\n double style = guess_style(y, sg);\n int r;\n\n if (style == 0) {\n\tint jd;\n\n\tr = c_valid_commercial_p(FIX2INT(y), w, d, sg, rw, rd, &jd, ns);\n\tif (!r)\n\t return 0;\n\tdecode_jd(INT2FIX(jd), nth, rjd);\n\tif (f_zero_p(*nth))\n\t *ry = FIX2INT(y);\n\telse {\n\t VALUE nth2;\n\t decode_year(y, *ns ? -1 : +1, &nth2, ry);\n\t}\n }\n else {\n\tdecode_year(y, style, nth, ry);\n\tr = c_valid_commercial_p(*ry, w, d, style, rw, rd, rjd, ns);\n }\n return r;\n}", "label": 0, "cwe": null, "length": 218 }, { "index": 580572, "code": "crcValid() const\n{\n\tif (!_ptrBuf) return true; // directory entry\n\treturn _crc32.checksum() == _expectedCrc32;\n}", "label": 0, "cwe": null, "length": 34 }, { "index": 6549, "code": "PWhiteSpace2(EOFControl)\n\nint EOFControl;\n{\n int Returned = PSUCCEEDED;\n while((PChar = getc(PCIFFileDesc)) != '-' And PChar != '('\n And PChar != ')' And (PChar < 'A' Or PChar > 'Z')\n And (PChar < '0' Or PChar > '9') And PChar != ';') {\n if (PChar == EOF) {\n if (EOFControl != PDONTFAILONEOF) {\n PErrorEOF();\n Returned = PFAILED;\n }\n break;\n }\n }\n ungetc((char)PChar,PCIFFileDesc);\n return (Returned);\n}", "label": 0, "cwe": null, "length": 147 }, { "index": 388415, "code": "frame_print (const struct frame *frame,\n\t int level,\n\t const char *prefix)\n{\n struct gc_arena gc = gc_new ();\n struct buffer out = alloc_buf_gc (256, &gc);\n if (prefix)\n buf_printf (&out, \"%s \", prefix);\n buf_printf (&out, \"[\");\n buf_printf (&out, \" L:%d\", frame->link_mtu);\n buf_printf (&out, \" D:%d\", frame->link_mtu_dynamic);\n buf_printf (&out, \" EF:%d\", frame->extra_frame);\n buf_printf (&out, \" EB:%d\", frame->extra_buffer);\n buf_printf (&out, \" ET:%d\", frame->extra_tun);\n buf_printf (&out, \" EL:%d\", frame->extra_link);\n if (frame->align_flags && frame->align_adjust)\n buf_printf (&out, \" AF:%u/%d\", frame->align_flags, frame->align_adjust);\n buf_printf (&out, \" ]\");\n\n msg (level, \"%s\", out.data);\n gc_free (&gc);\n}", "label": 0, "cwe": null, "length": 232 }, { "index": 767988, "code": "getIpAddr(VarBind *varbind, Variable *var)\n{\n if (!local_ip) {\n local_ip = get_local_ip();\n if (!local_ip) {\n\tstruct hostent* h;\n\tchar hostname[128];\n\n\tif (!gethostname(hostname, sizeof(hostname)-1)) {\n\t h = (struct hostent*) gethostbyname(hostname);\n\t if (!h) local_ip = 0; /* give up :-( */\n\t else memcpy(&local_ip,h->h_addr_list[0],4);\n\t}\n }\n }\n if (!((IpAddress*) var->value)->octs) {\n unsigned char *p;\n\n ((IpAddress *) var->value)->octs = p = alloc(4);\n memcpy(((IpAddress *) var->value)->octs,&local_ip,4);\n diag(COMPONENT,DIAG_DEBUG,\"Local IP address is %d.%d.%d.%d\",p[0],p[1],\n\tp[2],p[3]);\n }\n varbind->value = Asn1Alloc(sizeof(ObjectSyntax));\n varbind->value->choiceId = OBJECTSYNTAX_APPLICATION_WIDE;\n varbind->value->a.application_wide = Asn1Alloc(sizeof(ApplicationSyntax));\n varbind->value->a.application_wide->choiceId = APPLICATIONSYNTAX_ADDRESS;\n varbind->value->a.application_wide->a.address = Asn1Alloc(sizeof(NetworkAddress));\n varbind->value->a.application_wide->a.address->choiceId = NETWORKADDRESS_INTERNET;\n varbind->value->a.application_wide->a.address->a.internet = (IpAddress*) var->value;\n return NOERROR;\n}", "label": 0, "cwe": null, "length": 350 }, { "index": 996229, "code": "sq_getsize(HSQUIRRELVM v, SQInteger idx)\n{\n\tSQObjectPtr &o = stack_get(v, idx);\n\tSQObjectType type = type(o);\n\tswitch(type) {\n\tcase OT_STRING:\t\treturn _string(o)->_len;\n\tcase OT_TABLE:\t\treturn _table(o)->CountUsed();\n\tcase OT_ARRAY:\t\treturn _array(o)->Size();\n\tcase OT_USERDATA:\treturn _userdata(o)->_size;\n\tcase OT_INSTANCE:\treturn _instance(o)->_class->_udsize;\n\tcase OT_CLASS:\t\treturn _class(o)->_udsize;\n\tdefault:\n\t\treturn sq_aux_invalidtype(v, type);\n\t}\n}", "label": 0, "cwe": null, "length": 136 }, { "index": 96428, "code": "slurm_ckpt_comp (struct step_record * step_ptr, time_t event_time,\n\t\tuint32_t error_code, char *error_msg)\n{\n/* FIXME: How do we tell when checkpoint completes?\n * Add another RPC from srun to slurmctld?\n * Where is this called from? */\n\tstruct check_job_info *check_ptr;\n\ttime_t now;\n\tlong delay;\n\n\txassert(step_ptr);\n\tcheck_ptr = (struct check_job_info *) step_ptr->check_job;\n\txassert(check_ptr);\n\n\t/* We ignore event_time here, just key off reply_cnt */\n\tif (check_ptr->reply_cnt)\n\t\treturn ESLURM_ALREADY_DONE;\n\n\tif (error_code > check_ptr->error_code) {\n\t\tinfo(\"slurm_ckpt_comp for step %u.%u error %u: %s\",\n\t\t\tstep_ptr->job_ptr->job_id, step_ptr->step_id,\n\t\t\terror_code, error_msg);\n\t\tcheck_ptr->error_code = error_code;\n\t\txfree(check_ptr->error_msg);\n\t\tcheck_ptr->error_msg = xstrdup(error_msg);\n\t\treturn SLURM_SUCCESS;\n\t}\n\n\tnow = time(NULL);\n\tdelay = difftime(now, check_ptr->time_stamp);\n\tinfo(\"slurm_ckpt_comp for step %u.%u in %ld secs: %s\",\n\t\tstep_ptr->job_ptr->job_id, step_ptr->step_id,\n\t\tdelay, error_msg);\n\tcheck_ptr->error_code = error_code;\n\txfree(check_ptr->error_msg);\n\tcheck_ptr->error_msg = xstrdup(error_msg);\n\tcheck_ptr->reply_cnt++;\n\tcheck_ptr->time_stamp = now;\n\n\treturn SLURM_SUCCESS;\n}", "label": 0, "cwe": null, "length": 343 }, { "index": 106215, "code": "OnSendDestructionFromQuery(unsigned int queryToDestructIdx, ReplicaManager3 *replicaManager)\r\n{\r\n\tConstructionMode constructionMode = QueryConstructionMode();\r\n\tRakAssert(constructionMode==QUERY_REPLICA_FOR_CONSTRUCTION || constructionMode==QUERY_REPLICA_FOR_CONSTRUCTION_AND_DESTRUCTION);\r\n\t(void) constructionMode;\r\n\r\n\tValidateLists(replicaManager);\r\n\tLastSerializationResult* lsr = queryToDestructReplicaList[queryToDestructIdx];\r\n\tqueryToDestructReplicaList.RemoveAtIndex(queryToDestructIdx);\r\n\tunsigned int j;\r\n\tfor (j=0; j < queryToSerializeReplicaList.Size(); j++)\r\n\t{\r\n\t\tif (queryToSerializeReplicaList[j]->replica==lsr->replica )\r\n\t\t{\r\n\t\t\tqueryToSerializeReplicaList.RemoveAtIndex(j);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\tfor (j=0; j < constructedReplicaList.Size(); j++)\r\n\t{\r\n\t\tif (constructedReplicaList[j]->replica==lsr->replica )\r\n\t\t{\r\n\t\t\tconstructedReplicaList.RemoveAtIndex(j);\r\n\t\t\tbreak;\r\n\t\t}\r\n\t}\r\n\t//assert(queryToConstructReplicaList.GetIndexOf(lsr->replica)==(unsigned int)-1);\r\n\tqueryToConstructReplicaList.Push(lsr,_FILE_AND_LINE_);\r\n\tValidateLists(replicaManager);\r\n}", "label": 0, "cwe": null, "length": 281 }, { "index": 499286, "code": "gst_edgetv_start (GstBaseTransform * trans)\n{\n GstEdgeTV *edgetv = GST_EDGETV (trans);\n\n if (edgetv->map)\n memset (edgetv->map, 0,\n edgetv->map_width * edgetv->map_height * sizeof (guint32) * 2);\n return TRUE;\n}", "label": 0, "cwe": null, "length": 82 }, { "index": 750533, "code": "chkplusargs(sym,argptr)\ntruc sym;\ntruc *argptr;\n{\n int flg, flg1;\n\n flg = *FLAGPTR(argptr);\n flg1 = *FLAGPTR(argptr+1);\n if(flg >= fFIXNUM) {\n if(flg1 >= fFIXNUM)\n return (flg1 >= flg ? flg1 : flg);\n else\n return error(sym,err_num,argptr[1]);\n }\n else if((flg == flg1) && (flg == fVECTOR || flg == fGF2NINT))\n return flg;\n else\n return error(sym,err_num,*argptr);\n}", "label": 0, "cwe": null, "length": 151 }, { "index": 739009, "code": "initializeRandomTable()\n{\n\t// From GIMP \"paint_funcs.c\" v1.2\n\tsrand(RANDOM_SEED);\n\n\tfor (int i = 0; i < RANDOM_TABLE_SIZE; i++)\n\t\trandom_table[i] = rand();\n\n\tfor (int i = 0; i < RANDOM_TABLE_SIZE; i++) {\n\t\tint tmp;\n\t\tint swap = i + rand() % (RANDOM_TABLE_SIZE - i);\n\t\ttmp = random_table[i];\n\t\trandom_table[i] = random_table[swap];\n\t\trandom_table[swap] = tmp;\n\t}\n}", "label": 0, "cwe": null, "length": 119 }, { "index": 236351, "code": "tapemapClicked()\n{\n\tif (mInternalChange) return;\n\tmInternalChange = true; // do not trigger signal when changing the bellow checkboxes\n\n\tif (ui.tapemapCheckBox->isChecked())\n\t{\n\t\tui.allCheckBox->setChecked(false);\n\t\tui.fileInfoCheckBox->setChecked(false);\n\t\tui.labelInfoCheckBox->setChecked(false);\n\t\tui.dataInfoCheckBox->setChecked(false);\n\t\tui.allCheckBox->setEnabled(false);\n\t\tui.fileInfoCheckBox->setEnabled(false);\n\t\tui.labelInfoCheckBox->setEnabled(false);\n\t\tui.dataInfoCheckBox->setEnabled(false);\n\t}\n\telse\n\t{\n\t\tui.allCheckBox->setEnabled(true);\n\t\tui.fileInfoCheckBox->setEnabled(true);\n\t\tui.labelInfoCheckBox->setEnabled(true);\n\t\tui.dataInfoCheckBox->setEnabled(true);\n\t\tui.allCheckBox->setChecked(true);\n\t}\n\n\tmInternalChange = false; // resume propagating signals\n}", "label": 0, "cwe": null, "length": 179 }, { "index": 43075, "code": "clear(JSContext *cx)\n{\n CHECK_ANCESTOR_LINE(this, true);\n LIVE_SCOPE_METER(cx, cx->runtime->liveScopeProps -= entryCount);\n\n if (table)\n js_free(table);\n clearMiddleDelete();\n js_LeaveTraceIfGlobalObject(cx, object);\n\n JSClass *clasp = object->getClass();\n JSObject *proto = object->getProto();\n JSEmptyScope *emptyScope;\n uint32 newShape;\n if (proto &&\n OBJ_IS_NATIVE(proto) &&\n (emptyScope = OBJ_SCOPE(proto)->emptyScope) &&\n emptyScope->clasp == clasp) {\n newShape = emptyScope->shape;\n } else {\n newShape = js_GenerateShape(cx, false);\n }\n initMinimal(cx, newShape);\n\n JS_ATOMIC_INCREMENT(&cx->runtime->propertyRemovals);\n}", "label": 0, "cwe": null, "length": 188 }, { "index": 393790, "code": "book_backend_get_contact_list_uids_thread (GSimpleAsyncResult *simple,\n GObject *source_object,\n GCancellable *cancellable)\n{\n\tEBookBackend *backend;\n\tEBookBackendClass *class;\n\tAsyncContext *async_context;\n\n\tbackend = E_BOOK_BACKEND (source_object);\n\n\tclass = E_BOOK_BACKEND_GET_CLASS (backend);\n\tg_return_if_fail (class->get_contact_list_uids_sync != NULL);\n\n\tasync_context = g_simple_async_result_get_op_res_gpointer (simple);\n\n\tif (!e_book_backend_is_opened (backend)) {\n\t\tg_simple_async_result_set_error (\n\t\t\tsimple, E_CLIENT_ERROR,\n\t\t\tE_CLIENT_ERROR_NOT_OPENED,\n\t\t\t\"%s\", e_client_error_to_string (\n\t\t\tE_CLIENT_ERROR_NOT_OPENED));\n\n\t} else {\n\t\tGError *error = NULL;\n\n\t\tclass->get_contact_list_uids_sync (\n\t\t\tbackend,\n\t\t\tasync_context->query,\n\t\t\tasync_context->string_queue,\n\t\t\tcancellable, &error);\n\n\t\tif (error != NULL)\n\t\t\tg_simple_async_result_take_error (simple, error);\n\t}\n\n\t/* XXX Once we get rid of the old-style API we can dispatch\n\t * methods using g_simple_async_result_run_in_thread(),\n\t * which completes the GSimpleAsyncResult for us. */\n\tg_simple_async_result_complete_in_idle (simple);\n}", "label": 0, "cwe": null, "length": 276 }, { "index": 270103, "code": "unescaped_fill(S d, S s, I n){I k=0,q;DO(n,d[k++]=unescape(s+i,&q);i+=q-1) R k;}", "label": 0, "cwe": null, "length": 40 }, { "index": 638284, "code": "slotSelectionChanged(const QItemSelection &selected, const QItemSelection &deselected)\n{\n Q_UNUSED(deselected)\n\n const QModelIndexList indexes = selected.indexes();\n if (indexes.count() == 1 && !d->appModel->isDirectory(indexes.at(0))) {\n QString exec = d->appModel->execFor(indexes.at(0));\n if (!exec.isEmpty()) {\n emit this->selected(d->appModel->entryPathFor(indexes.at(0)), exec);\n }\n }\n}", "label": 0, "cwe": null, "length": 113 }, { "index": 550321, "code": "format2_charset_proc(const cff_data_t *data, unsigned p, unsigned pe, unsigned int i)\n{\n int code;\n unsigned int cid = 0;\n\n while( p < pe - 4) {\n unsigned int first, count;\n\n if ((code = card16(&first, data, p, pe)) < 0)\n return code;\n if ((code = card16(&count, data, p + 2, pe)) < 0)\n return code;\n ++count;\n\n if (i < cid + count)\n return first + i - cid;\n p += 4;\n cid += count;\n }\n return_error(e_rangecheck);\n}", "label": 0, "cwe": null, "length": 147 }, { "index": 71317, "code": "terminated (writer_t *pipe_)\n{\n // Remove the pipe from the list; adjust number of active and/or\n // eligible pipes accordingly.\n if (pipes.index (pipe_) < active)\n active--;\n if (pipes.index (pipe_) < eligible)\n eligible--;\n pipes.erase (pipe_);\n\n if (unlikely (terminating))\n sink->unregister_term_ack ();\n}", "label": 0, "cwe": null, "length": 84 }, { "index": 26280, "code": "rspectprod(float *data1, float *data2, float *outdata, long N){\n// When multiplying a pair of spectra from rfft care must be taken to multiply the\n// two real values seperately from the complex ones. This routine does it correctly.\n// the result can be stored in-place over one of the inputs\n/* INPUTS */\n/* *data1 = input data array\tfirst spectra */\n/* *data2 = input data array\tsecond spectra */\n/* N = fft input size for both data1 and data2 */\n/* OUTPUTS */\n/* *outdata = output data array spectra */\nif(N>1){\n\toutdata[0] = data1[0] * data2[0];\t// multiply the zero freq values\n\toutdata[1] = data1[1] * data2[1];\t// multiply the nyquest freq values\n\tcvprod(data1 + 2, data2 + 2, outdata + 2, N/2-1);\t// multiply the other positive freq values\n}\nelse{\n\toutdata[0] = data1[0] * data2[0];\n}\n}", "label": 0, "cwe": null, "length": 239 }, { "index": 181945, "code": "HasSelection(int curve_index) const\n{\n if (curve_index == -1)\n {\n int n, count = m_curveSelections.GetCount();\n for ( n = 0; n < count; n++ )\n {\n if ((m_curveSelections[n].GetCount() > 0) ||\n (m_dataSelections[n].GetCount() > 0))\n return true;\n }\n return false;\n }\n\n wxCHECK_MSG(CurveIndexOk(curve_index), false, wxT(\"invalid curve index\"));\n return (m_curveSelections[curve_index].GetCount() > 0) ||\n (m_dataSelections[curve_index].GetCount() > 0);\n}", "label": 0, "cwe": null, "length": 152 }, { "index": 97361, "code": "_display_archive(struct cmd_context *cmd, struct archive_file *af)\n{\n\tstruct volume_group *vg = NULL;\n\tstruct format_instance *tf;\n\tstruct format_instance_ctx fic;\n\tstruct text_context tc = {.path_live = af->path,\n\t\t\t\t .path_edit = NULL,\n\t\t\t\t .desc = NULL};\n\ttime_t when;\n\tchar *desc;\n\n\tlog_print(\" \");\n\tlog_print(\"File:\\t\\t%s\", af->path);\n\n\tfic.type = FMT_INSTANCE_PRIVATE_MDAS;\n\tfic.context.private = &tc;\n\tif (!(tf = cmd->fmt_backup->ops->create_instance(cmd->fmt_backup, &fic))) {\n\t\tlog_error(\"Couldn't create text instance object.\");\n\t\treturn;\n\t}\n\n\t/*\n\t * Read the archive file to ensure that it is valid, and\n\t * retrieve the archive time and description.\n\t */\n\t/* FIXME Use variation on _vg_read */\n\tif (!(vg = text_vg_import_file(tf, af->path, &when, &desc))) {\n\t\tlog_error(\"Unable to read archive file.\");\n\t\ttf->fmt->ops->destroy_instance(tf);\n\t\treturn;\n\t}\n\n\tlog_print(\"VG name: \\t%s\", vg->name);\n\tlog_print(\"Description:\\t%s\", desc ? : \"\");\n\tlog_print(\"Backup Time:\\t%s\", ctime(&when));\n\n\trelease_vg(vg);\n}", "label": 0, "cwe": null, "length": 283 }, { "index": 729184, "code": "rtc_load_internal(FILE *f)\n{\n\tint rt = 0;\n\tfscanf(\n\t\tf, \"%d %d %d %02d %02d %02d %02d\\n%d\\n\",\n\t\t&rtc.carry, &rtc.stop, &rtc.d,\n\t\t&rtc.h, &rtc.m, &rtc.s, &rtc.t, &rt);\n\twhile (rtc.t >= 60) rtc.t -= 60;\n\twhile (rtc.s >= 60) rtc.s -= 60;\n\twhile (rtc.m >= 60) rtc.m -= 60;\n\twhile (rtc.h >= 24) rtc.h -= 24;\n\twhile (rtc.d >= 365) rtc.d -= 365;\n\trtc.stop &= 1;\n\trtc.carry &= 1;\n\tif (rt) rt = (time(0) - rt) * 60;\n\tif (syncrtc) while (rt-- > 0) rtc_tick();\n}", "label": 0, "cwe": null, "length": 199 }, { "index": 715342, "code": "gst_rtsp_connection_do_tunnel (GstRTSPConnection * conn,\n GstRTSPConnection * conn2)\n{\n g_return_val_if_fail (conn != NULL, GST_RTSP_EINVAL);\n\n if (conn2 != NULL) {\n g_return_val_if_fail (conn->tstate == TUNNEL_STATE_GET, GST_RTSP_EINVAL);\n g_return_val_if_fail (conn2->tstate == TUNNEL_STATE_POST, GST_RTSP_EINVAL);\n g_return_val_if_fail (!memcmp (conn2->tunnelid, conn->tunnelid,\n TUNNELID_LEN), GST_RTSP_EINVAL);\n\n /* both connections have socket0 as the read/write socket. start by taking the\n * socket from conn2 and set it as the socket in conn */\n conn->socket1 = conn2->socket0;\n conn->stream1 = conn2->stream0;\n conn->input_stream = conn2->input_stream;\n conn->control_stream = g_io_stream_get_input_stream (conn->stream0);\n\n /* clean up some of the state of conn2 */\n g_cancellable_cancel (conn2->cancellable);\n conn2->write_socket = conn2->read_socket = NULL;\n conn2->socket0 = NULL;\n conn2->stream0 = NULL;\n conn2->input_stream = NULL;\n conn2->output_stream = NULL;\n conn2->control_stream = NULL;\n g_cancellable_reset (conn2->cancellable);\n\n /* We make socket0 the write socket and socket1 the read socket. */\n conn->write_socket = conn->socket0;\n conn->read_socket = conn->socket1;\n\n conn->tstate = TUNNEL_STATE_COMPLETE;\n\n g_free (conn->initial_buffer);\n conn->initial_buffer = conn2->initial_buffer;\n conn2->initial_buffer = NULL;\n conn->initial_buffer_offset = conn2->initial_buffer_offset;\n }\n\n /* we need base64 decoding for the readfd */\n conn->ctx.state = 0;\n conn->ctx.save = 0;\n conn->ctx.cout = 0;\n conn->ctx.coutl = 0;\n conn->ctxp = &conn->ctx;\n\n return GST_RTSP_OK;\n}", "label": 0, "cwe": null, "length": 486 }, { "index": 561899, "code": "get (tstring * value, tstring const & key) const\n{\n assert (value);\n\n MappedDiagnosticContextMap * const dc = getPtr ();\n MappedDiagnosticContextMap::const_iterator it = dc->find (key);\n if (it != dc->end ())\n {\n *value = it->second;\n return true;\n }\n else\n return false;\n}", "label": 0, "cwe": null, "length": 85 }, { "index": 65398, "code": "__word_encodeDouble (W_ j, I_ e)\n{\n StgDouble r;\n \n r = (StgDouble)j;\n \n /* Now raise to the exponent */\n if ( r != 0.0 ) /* Lennart suggests this avoids a bug in MIPS's ldexp */\n r = ldexp(r, e);\n \n return r;\n}", "label": 0, "cwe": null, "length": 81 }, { "index": 8570, "code": "indentAfterNewLine(StringRef Str,\n std::string &NewStr,\n const std::string &IndentStr)\n{\n SmallVector StrVec;\n Str.split(StrVec, \"\\n\"); \n NewStr = \"\";\n for(SmallVector::iterator I = StrVec.begin(), \n E = StrVec.end(); I != E; ++I) {\n NewStr += ((*I).str() + \"\\n\" + IndentStr);\n }\n}", "label": 0, "cwe": null, "length": 109 }, { "index": 85866, "code": "displaycacheexpl(unsigned long reg, const char * const descr, unsigned char iseax)\n{\n\tunsigned char j;\n\tunsigned char vb; /* valid bytes in register */\n\tunsigned char l;\n\tunsigned char cc; /* cache code */\n\t\n\tif (reg & 0x80000000) {\n\t\toutputatlvl(2, \" * %s : can not be parsed\\n\", descr);\n\t} else {\n\t\tif (iseax) {\n\t\t\tvb = 3; /* eax only contains 3 data bytes */\n\t\t} else {\n\t\t\tvb = 4; /* the other registers contain 4. */\n\t\t}\n\t\tfor (j = 0; j < vb; j++) {\n\t\t\tcc = (unsigned char)((reg >> 24) & 0xFF);\n\t\t\treg <<= 8;\n\t\t\tif (cc == 0) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\toutputatlvl(2, \" * %s%d: (%02x) \", descr, j, cc);\n\t\t\tl = 0;\n\t\t\twhile (cachecodes[l].description[0] != 0) {\n\t\t\t\tif (cachecodes[l].code == cc) {\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tl++;\n\t\t\t}\n\t\t\tif (cachecodes[l].description[0] == 0) {\n\t\t\t\toutputatlvl(2, \"%s\", \"???\\n\");\n\t\t\t} else {\n\t\t\t\toutputatlvl(2, \"%s\\n\",\n\t\t\t\t\tcachecodes[l].description);\n\t\t\t}\n\t\t}\n\t}\n\treturn;\n}", "label": 0, "cwe": null, "length": 330 }, { "index": 56065, "code": "ping_begin (void)\n{\n\tslurm_mutex_lock(&lock_mutex);\n\tping_count++;\n\tslurm_mutex_unlock(&lock_mutex);\n}", "label": 0, "cwe": null, "length": 28 }, { "index": 574198, "code": "checkcond (LexState *LS, char *buff)\n{\n static char *opts[] = {\"nil\", \"1\", NULL};\n int i = luaL_findstring(buff, opts);\n if (i >= 0) return i;\n else if (isalpha((unsigned char)buff[0]) || buff[0] == '_')\n return luaS_globaldefined(buff);\n else {\n luaX_syntaxerror(LS, \"invalid $if condition\", buff);\n return 0; /* to avoid warnings */\n }\n}", "label": 0, "cwe": null, "length": 114 }, { "index": 738854, "code": "saa7127_g_sliced_fmt(struct v4l2_subdev *sd, struct v4l2_sliced_vbi_format *fmt)\n{\n\tstruct saa7127_state *state = to_state(sd);\n\n\tmemset(fmt->service_lines, 0, sizeof(fmt->service_lines));\n\tif (state->vps_enable)\n\t\tfmt->service_lines[0][16] = V4L2_SLICED_VPS;\n\tif (state->wss_enable)\n\t\tfmt->service_lines[0][23] = V4L2_SLICED_WSS_625;\n\tif (state->cc_enable) {\n\t\tfmt->service_lines[0][21] = V4L2_SLICED_CAPTION_525;\n\t\tfmt->service_lines[1][21] = V4L2_SLICED_CAPTION_525;\n\t}\n\tfmt->service_set =\n\t\t(state->vps_enable ? V4L2_SLICED_VPS : 0) |\n\t\t(state->wss_enable ? V4L2_SLICED_WSS_625 : 0) |\n\t\t(state->cc_enable ? V4L2_SLICED_CAPTION_525 : 0);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 255 }, { "index": 2570, "code": "H5O_fill_old_encode(H5F_t UNUSED *f, uint8_t *p, const void *_fill)\n{\n const H5O_fill_t *fill = (const H5O_fill_t *)_fill;\n\n FUNC_ENTER_NOAPI_NOINIT_NOERR\n\n HDassert(f);\n HDassert(p);\n HDassert(fill && NULL == fill->type);\n\n UINT32ENCODE(p, fill->size);\n if(fill->buf)\n HDmemcpy(p, fill->buf, (size_t)fill->size);\n\n FUNC_LEAVE_NOAPI(SUCCEED)\n}", "label": 0, "cwe": null, "length": 123 }, { "index": 657872, "code": "sentinelSetClientName(sentinelRedisInstance *ri, redisAsyncContext *c, char *type) {\n char name[64];\n\n snprintf(name,sizeof(name),\"sentinel-%.8s-%s\",server.runid,type);\n if (redisAsyncCommand(c, sentinelDiscardReplyCallback, NULL,\n \"CLIENT SETNAME %s\", name) == REDIS_OK)\n {\n ri->pending_commands++;\n }\n}", "label": 0, "cwe": null, "length": 92 }, { "index": 816392, "code": "next_upage(struct task_context *tc, ulong vaddr, ulong *nextvaddr)\n{\n\tulong vma, total_vm;\n\tchar *vma_buf;\n ulong vm_start, vm_end;\n\tulong vm_next;\n\n if (!tc->mm_struct)\n return FALSE;\n\n fill_mm_struct(tc->mm_struct);\n\tvma = ULONG(tt->mm_struct + OFFSET(mm_struct_mmap));\n\ttotal_vm = ULONG(tt->mm_struct + OFFSET(mm_struct_total_vm));\n\n\tif (!vma || (total_vm == 0))\n\t\treturn FALSE;\n\n\tvaddr = VIRTPAGEBASE(vaddr) + PAGESIZE(); /* first possible page */\n\n for ( ; vma; vma = vm_next) {\n vma_buf = fill_vma_cache(vma);\n\n vm_start = ULONG(vma_buf + OFFSET(vm_area_struct_vm_start));\n vm_end = ULONG(vma_buf + OFFSET(vm_area_struct_vm_end));\n vm_next = ULONG(vma_buf + OFFSET(vm_area_struct_vm_next));\n\n\t\tif (vaddr <= vm_start) {\n\t\t\t*nextvaddr = vm_start;\n\t\t\treturn TRUE;\n\t\t}\n\n\t\tif ((vaddr > vm_start) && (vaddr < vm_end)) {\n\t\t\t*nextvaddr = vaddr;\n\t\t\treturn TRUE;\n\t\t}\n\t}\n\n\treturn FALSE;\n}", "label": 0, "cwe": null, "length": 278 }, { "index": 720049, "code": "i40e_clear_lan_tx_queue_context(struct i40e_hw *hw,\n\t\t\t\t\t\t u16 queue)\n{\n\ti40e_status err;\n\tu8 *context_bytes;\n\n\terr = i40e_hmc_get_object_va(&hw->hmc, &context_bytes,\n\t\t\t\t I40E_HMC_LAN_TX, queue);\n\tif (err < 0)\n\t\treturn err;\n\n\treturn i40e_clear_hmc_context(hw, context_bytes, I40E_HMC_LAN_TX);\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 92635, "code": "header_declaration(TRANS_DECL *decl)\n{\n\tPATTERN *look = JOB->current;\n\tPATTERN *save;\n\tbool is_static = FALSE;\n\tbool is_public = FALSE;\n\tbool is_const = FALSE;\n\t//bool has_static = FALSE;\n\n\t/* static ! */\n\n\tif (JOB->is_module)\n\t{\n\t\tis_static = TRUE;\n\t}\n\telse if (PATTERN_is(*look, RS_STATIC))\n\t{\n\t\tis_static = TRUE;\n\t\t//has_static = TRUE;\n\t\tlook++;\n\t}\n\n\tcheck_public_private(&look, &is_public);\n\n\t/* const ? */\n\n\tis_const = FALSE;\n\n\tif (PATTERN_is(*look, RS_CONST))\n\t{\n\t\t//if (has_static)\n\t\t//\tTHROW(\"Unexpected &1\", \"STATIC\");\n\n\t\tis_const = TRUE;\n\t\tlook++;\n\t}\n\n\tif (!PATTERN_is_identifier(*look))\n\t\treturn FALSE;\n\n\tCLEAR(decl);\n\n\tdecl->index = PATTERN_index(*look);\n\tlook++;\n\n\tsave = JOB->current;\n\tJOB->current = look;\n\n\tif (!TRANS_type((!is_const ? TT_CAN_ARRAY | TT_CAN_EMBED : 0) | TT_CAN_NEW, decl))\n\t{\n\t\tJOB->current = save;\n\t\treturn FALSE;\n\t}\n\n\tif (is_static) TYPE_set_flag(&decl->type, TF_STATIC);\n\tif (is_public) TYPE_set_flag(&decl->type, TF_PUBLIC);\n\tif (is_const)\n\t\tTYPE_set_kind(&decl->type, TK_CONST);\n\telse\n\t\tTYPE_set_kind(&decl->type, TK_VARIABLE);\n\n\tif (is_const)\n\t{\n\t\tif (!decl->init)\n\t\t\tTHROW(E_SYNTAX_MISSING, \"'='\");\n\n\t\tJOB->current = decl->init;\n\t\tJOB->current = TRANS_get_constant_value(decl, JOB->current);\n\t}\n\n\t//JOB->current = look;\n\n\treturn TRUE;\n}", "label": 0, "cwe": null, "length": 394 }, { "index": 128715, "code": "check_sql_expr(const char *stmt, int location, int leaderlen)\n{\n\tsql_error_callback_arg cbarg;\n\tErrorContextCallback syntax_errcontext;\n\tMemoryContext oldCxt;\n\n\tif (!plpgsql_check_syntax)\n\t\treturn;\n\n\tcbarg.location = location;\n\tcbarg.leaderlen = leaderlen;\n\n\tsyntax_errcontext.callback = plpgsql_sql_error_callback;\n\tsyntax_errcontext.arg = &cbarg;\n\tsyntax_errcontext.previous = error_context_stack;\n\terror_context_stack = &syntax_errcontext;\n\n\toldCxt = MemoryContextSwitchTo(compile_tmp_cxt);\n\t(void) raw_parser(stmt);\n\tMemoryContextSwitchTo(oldCxt);\n\n\t/* Restore former ereport callback */\n\terror_context_stack = syntax_errcontext.previous;\n}", "label": 0, "cwe": null, "length": 153 }, { "index": 912857, "code": "FindFile(const std::string& name,\n const std::vector& userPaths,\n bool no_system_path)\n{\n std::string tryPath = SystemTools::FindName(name, userPaths, no_system_path);\n if (!tryPath.empty() && !SystemTools::FileIsDirectory(tryPath)) {\n return SystemTools::CollapseFullPath(tryPath);\n }\n // Couldn't find the file.\n return \"\";\n}", "label": 0, "cwe": null, "length": 95 }, { "index": 59425, "code": "write(const bool* val, size_t count)\n {\n for (size_t i = 0; i < count; ++i, ++val)\n {\n char c = (*val)? 1 : 0;\n write(&c);\n }\n }", "label": 0, "cwe": null, "length": 57 }, { "index": 264084, "code": "Connect( const char* host, unsigned short remotePort, const char *passwordData, int passwordDataLength, PublicKey *publicKey, unsigned connectionSocketIndex, unsigned sendConnectionAttemptCount, unsigned timeBetweenSendConnectionAttemptsMS, RakNet::TimeMS timeoutTime )\r\n{\r\n\t// If endThreads is true here you didn't call Startup() first.\r\n\tif ( host == 0 || endThreads || connectionSocketIndex>=socketList.Size() )\r\n\t\treturn INVALID_PARAMETER;\r\n\r\n\tRakAssert(remotePort!=0);\r\n\r\n\tconnectionSocketIndex=GetRakNetSocketFromUserConnectionSocketIndex(connectionSocketIndex);\r\n\r\n\tif (passwordDataLength>255)\r\n\t\tpasswordDataLength=255;\r\n\r\n\tif (passwordData==0)\r\n\t\tpasswordDataLength=0;\r\n\r\n\t// Not threadsafe but it's not important enough to lock. Who is going to change the password a lot during runtime?\r\n\t// It won't overflow at least because outgoingPasswordLength is an unsigned char\r\n//\tif (passwordDataLength>0)\r\n//\t\tmemcpy(outgoingPassword, passwordData, passwordDataLength);\r\n//\toutgoingPasswordLength=(unsigned char) passwordDataLength;\r\n\r\n\t// 04/02/09 - Can't remember why I disabled connecting to self, but it seems to work\r\n\t// Connecting to ourselves in the same instance of the program?\r\n//\tif ( ( strcmp( host, \"127.0.0.1\" ) == 0 || strcmp( host, \"0.0.0.0\" ) == 0 ) && remotePort == mySystemAddress[0].port )\r\n//\t\treturn false;\r\n\r\n\treturn SendConnectionRequest( host, remotePort, passwordData, passwordDataLength, publicKey, connectionSocketIndex, 0, sendConnectionAttemptCount, timeBetweenSendConnectionAttemptsMS, timeoutTime);\r\n}", "label": 0, "cwe": null, "length": 369 }, { "index": 217487, "code": "get_fan(\n\t\tstruct device *dev,\n\t\tstruct device_attribute *devattr,\n\t\tchar *buf)\n{\n\tstruct amc6821_data *data = amc6821_update_device(dev);\n\tint ix = to_sensor_dev_attr(devattr)->index;\n\tif (0 == data->fan[ix])\n\t\treturn sprintf(buf, \"0\");\n\treturn sprintf(buf, \"%d\\n\", (int)(6000000 / data->fan[ix]));\n}", "label": 1, "cwe": "CWE-120", "length": 92 }, { "index": 316146, "code": "menuitem_rebuild_screen_ip(MenuItem *item, Screen *s)\n{\n\tWidget *w;\n\n\tdebug(RPT_DEBUG, \"%s(item=[%s], screen=[%s])\", __FUNCTION__,\n\t\t\t((item != NULL) ? item->id : \"(null)\"),\n\t\t\t((s != NULL) ? s->id : \"(null)\"));\n\n\tif ((item == NULL) || (s == NULL))\n\t\treturn;\n\n\tif (display_props->height >= 2) {\n\t\t/* Only add a title if enough space... */\n\t\tw = widget_create(\"text\", WID_STRING, s);\n\t\tscreen_add_widget(s, w);\n\t\tw->text = strdup(item->text);\n\t\tw->x = 1;\n\t\tw->y = 1;\n\t}\n\n\tw = widget_create(\"value\", WID_STRING, s);\n\tscreen_add_widget(s, w);\n\tw->text = malloc(item->data.ip.maxlength+1);\n\tw->x = 2;\n\tw->y = display_props->height / 2 + 1;\n\n\t/* Only display error string if enough space... */\n\tif (display_props->height > 2) {\n\t\tw = widget_create(\"error\", WID_STRING, s);\n\t\tscreen_add_widget(s, w);\n\t\tw->text = strdup(\"\");\n\t\tw->x = 1;\n\t\tw->y = display_props->height;\n\t}\n}", "label": 0, "cwe": null, "length": 290 }, { "index": 1011484, "code": "xkl_config_registry_find_option_group(XklConfigRegistry * config, XklConfigItem * pitem\t/* in/out */\n )\n{\n\txmlNodePtr node = NULL;\n\tgboolean rv = xkl_config_registry_find_object(config,\n\t\t\t\t\t\t XKBCR_GROUP_PATH\n\t\t\t\t\t\t \"[configItem/name = '%s%s']\",\n\t\t\t\t\t\t \"\", pitem, &node);\n\tif (rv) {\n\t\txmlChar *val = xmlGetProp(node, (unsigned char *)\n\t\t\t\t\t XCI_PROP_ALLOW_MULTIPLE_SELECTION);\n\t\tif (val != NULL) {\n\t\t\tgboolean allow_multisel =\n\t\t\t !g_ascii_strcasecmp(\"true\",\n\t\t\t\t\t\t(char *) val);\n\t\t\tg_object_set_data(G_OBJECT(pitem),\n\t\t\t\t\t XCI_PROP_ALLOW_MULTIPLE_SELECTION,\n\t\t\t\t\t GINT_TO_POINTER(allow_multisel));\n\t\t\txmlFree(val);\n\t\t}\n\t}\n\treturn rv;\n}", "label": 0, "cwe": null, "length": 180 }, { "index": 95511, "code": "printMinoltaSonyFlashExposureComp(std::ostream& os, const Value& value, const ExifData*)\n {\n if (value.count() != 1 || value.typeId() != signedRational) {\n return os << \"(\" << value << \")\";\n }\n return os << std::fixed << std::setprecision(2) << value.toFloat(0) << \" EV\";\n }", "label": 0, "cwe": null, "length": 85 }, { "index": 530135, "code": "readBucket(CompiledFlowInputPtr input)\n{\n ComponentPtr c = input->component;\n FlowElementPtr flowEl = input->flowEl;\n AuUint8 *s, *d;\n AuUint32 size, bytesOut, bytesIn, available;\n\n if (flowEl->parmsChanged) {\n flowEl->read = c->data + flowEl->raw->importbucket.offset *\n c->bytesPerSample;\n\n if (flowEl->countSamples)\n flowEl->numBytes = flowEl->raw->importbucket.num_samples *\n c->bytesPerSample;\n\n flowEl->parmsChanged = AuFalse;\n }\n\n s = flowEl->read;\n d = flowEl->minibuf;\n\n /* how much do we want */\n size = flowEl->minibufChunk;\n\n /* how much can we get from the bucket */\n available = c->dataEnd - s;\n\n if (flowEl->countSamples)\n available = aumin(available, flowEl->numBytes);\n\n /* do the rate conversion */\n bytesOut =\n (*input->rateConvert) (flowEl, s, d, size, available,\n &bytesIn);\n\n flowEl->read = s + bytesIn;\n flowEl->numBytes -= bytesIn;\n\n /* did we run out of data? */\n if (flowEl->read == c->dataEnd) {\n flowEl->minibufSamples = bytesOut / c->bytesPerSample;\n\n return AuChangeElementState(flowEl->flow, flowEl->elementNum,\n AuStateStop, AuFalse, AuReasonEOF);\n }\n\n return AuFalse;\n}", "label": 0, "cwe": null, "length": 353 }, { "index": 409833, "code": "itemLabel(int row_)\n{\n A outStr=aplus_nl;\n V v=(model()==0)?0:((AplusModel*)model())->aplusVar();\n int n=(model()==0)?0:((AplusModel*)model())->numElmts();\n if (v!=0&&n==2)\n {\n AOutFunction *titleFunc=AplusModel::getTitleFunc(v);\n if (titleFunc!=0)\n {\n\tP p; p.i=((AplusModel*)model())->data();\n\tA as=p.a[0];\n\tA av=p.a[1];\n if (row_>=0&&row_<(int)av->n)\n\t {\n\t A attr=(A)as->p[row_]; // used as the pick\n\t A val =(A)av->p[row_];\n\t outStr=(A) titleFunc->invoke(v,(A)val,(A)attr); \n outStr =(outStr->t==Ct)?outStr:aplus_nl;\n\t }\n }\n }\n return outStr;\n}", "label": 1, "cwe": "CWE-other", "length": 226 }, { "index": 666351, "code": "draw_label(gpointer p) {\n draw_label_args_t *args = (draw_label_args_t *) p;\n\n if (args != NULL) {\n if (args->label != NULL && args->text != NULL) {\n gtk_label_set_text(GTK_LABEL(args->label), args->text);\n }\n if (args->text != NULL)\n g_free(args->text);\n g_free(args);\n }\n return FALSE;\n}", "label": 0, "cwe": null, "length": 93 }, { "index": 143406, "code": "draw_lissie (ModeInfo * mi)\n{\n\tregister unsigned char ball;\n\tlissstruct *lp;\n\n\tif (lisses == NULL)\n\t\treturn;\n\tlp = &lisses[MI_SCREEN(mi)];\n\tif (lp->lissie == NULL)\n\t\treturn;\n\n\tMI_IS_DRAWN(mi) = True;\n\n\tif (++lp->loopcount > MI_CYCLES(mi)) {\n\t\tinit_lissie(mi);\n\t} else {\n\t\tlp->painted = True;\n\t\tfor (ball = 0; ball < (unsigned char) lp->nlissies; ball++)\n\t\t\tdrawlissie(mi, &lp->lissie[ball]);\n\t}\n}", "label": 0, "cwe": null, "length": 140 }, { "index": 671298, "code": "unicode_wbscan_callback(int flag, void *arg)\n{\n\tunicode_wbscan_info_t i=(unicode_wbscan_info_t)arg;\n\n\tif (flag && i->cnt > 0)\n\t\ti->found=1;\n\n\tif (!i->found)\n\t\t++i->cnt;\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 67 }, { "index": 729110, "code": "isKnownType(const Variable* var, const Token* varTypeTok)\n{\n return(varTypeTok->isStandardType() || varTypeTok->next()->isStandardType() || isComplexType(var, varTypeTok));\n}", "label": 0, "cwe": null, "length": 49 }, { "index": 31869, "code": "smsc_ircc_interrupt_sir(struct net_device *dev)\n{\n\tstruct smsc_ircc_cb *self = netdev_priv(dev);\n\tint boguscount = 0;\n\tint iobase;\n\tint iir, lsr;\n\n\t/* Already locked coming here in smsc_ircc_interrupt() */\n\t/*spin_lock(&self->lock);*/\n\n\tiobase = self->io.sir_base;\n\n\tiir = inb(iobase + UART_IIR) & UART_IIR_ID;\n\tif (iir == 0)\n\t\treturn IRQ_NONE;\n\twhile (iir) {\n\t\t/* Clear interrupt */\n\t\tlsr = inb(iobase + UART_LSR);\n\n\t\tpr_debug(\"%s(), iir=%02x, lsr=%02x, iobase=%#x\\n\",\n\t\t\t __func__, iir, lsr, iobase);\n\n\t\tswitch (iir) {\n\t\tcase UART_IIR_RLSI:\n\t\t\tpr_debug(\"%s(), RLSI\\n\", __func__);\n\t\t\tbreak;\n\t\tcase UART_IIR_RDI:\n\t\t\t/* Receive interrupt */\n\t\t\tsmsc_ircc_sir_receive(self);\n\t\t\tbreak;\n\t\tcase UART_IIR_THRI:\n\t\t\tif (lsr & UART_LSR_THRE)\n\t\t\t\t/* Transmitter ready for data */\n\t\t\t\tsmsc_ircc_sir_write_wakeup(self);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tpr_debug(\"%s(), unhandled IIR=%#x\\n\",\n\t\t\t\t __func__, iir);\n\t\t\tbreak;\n\t\t}\n\n\t\t/* Make sure we don't stay here to long */\n\t\tif (boguscount++ > 100)\n\t\t\tbreak;\n\n\t iir = inb(iobase + UART_IIR) & UART_IIR_ID;\n\t}\n\t/*spin_unlock(&self->lock);*/\n\treturn IRQ_HANDLED;\n}", "label": 0, "cwe": null, "length": 384 }, { "index": 443774, "code": "readFile(string fileName)\n{\n\tifstream fileText;\n\tstring text, res=\"\";\n\n\tfileText.open(fileName.c_str());\n\n while(getline(fileText, text))\n res.append(text);\n\n \tfileText.close();\n\n\treturn res;\n}", "label": 0, "cwe": null, "length": 48 }, { "index": 811781, "code": "x509_set_extension( asn1_named_data **head, const char *oid, size_t oid_len,\n int critical, const unsigned char *val, size_t val_len )\n{\n asn1_named_data *cur;\n\n if( ( cur = asn1_store_named_data( head, oid, oid_len,\n NULL, val_len + 1 ) ) == NULL )\n {\n return( POLARSSL_ERR_X509_MALLOC_FAILED );\n }\n\n cur->val.p[0] = critical;\n memcpy( cur->val.p + 1, val, val_len );\n\n return( 0 );\n}", "label": 0, "cwe": null, "length": 129 }, { "index": 579101, "code": "call_insn_operand (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)\n{\n return (\n#line 550 \"../../src/gcc/config/i386/predicates.md\"\n(constant_call_address_operand\n\t\t (op, mode == VOIDmode ? mode : Pmode))) || ((call_register_no_elim_operand (op, mode)) || ((!(\n#line 553 \"../../src/gcc/config/i386/predicates.md\"\n(ix86_indirect_branch_register))) && ((!(\n#line 554 \"../../src/gcc/config/i386/predicates.md\"\n(TARGET_X32))) && (memory_operand (op, mode)))));\n}", "label": 0, "cwe": null, "length": 122 }, { "index": 808475, "code": "parse_version(FILE* f, char* new_version, int len) {\n char buf2[256];\n bool same_platform = false, newer_version_exists = false;\n\n MIOFILE mf;\n XML_PARSER xp(&mf);\n mf.init_file(f);\n\n while (!xp.get_tag()) {\n if (xp.match_tag(\"/version\")) {\n return (same_platform && newer_version_exists);\n }\n if (xp.parse_str(\"dbplatform\", buf2, sizeof(buf2))) {\n same_platform = (strcmp(buf2, gstate.get_primary_platform())==0);\n }\n if (xp.parse_str(\"version_num\", buf2, sizeof(buf2))) {\n newer_version_exists = is_version_newer(buf2);\n strlcpy(new_version, buf2, len);\n }\n }\n return false;\n}", "label": 0, "cwe": null, "length": 174 }, { "index": 28330, "code": "cpl_plugin_get_version_string(const cpl_plugin *self)\n{\n\n\n unsigned long version;\n unsigned major;\n unsigned minor;\n unsigned micro;\n\n if (self == NULL) {\n cpl_error_set_(CPL_ERROR_NULL_INPUT);\n return NULL;\n }\n\n version = self->version;\n\n micro = version % 100;\n version = version / 100;\n minor = version % 100;\n version = version / 100;\n major = version;\n\n return cpl_sprintf(\"%-u.%-u.%-u\", major, minor, micro);\n\n}", "label": 0, "cwe": null, "length": 128 }, { "index": 658912, "code": "tps80031_reg_disable(struct regulator_dev *rdev)\n{\n\tstruct tps80031_regulator *ri = rdev_get_drvdata(rdev);\n\tstruct device *parent = to_tps80031_dev(rdev);\n\tint ret;\n\n\tif (ri->ext_ctrl_flag & TPS80031_EXT_PWR_REQ)\n\t\treturn 0;\n\n\tret = tps80031_update(parent, TPS80031_SLAVE_ID1, ri->rinfo->state_reg,\n\t\t\tTPS80031_STATE_OFF, TPS80031_STATE_MASK);\n\tif (ret < 0)\n\t\tdev_err(&rdev->dev, \"Reg 0x%02x update failed, err = %d\\n\",\n\t\t\tri->rinfo->state_reg, ret);\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 159 }, { "index": 335267, "code": "disconnect_from_server (int s, int echo)\n{\n#if 0\n char buffer[REPLYSIZ+1];\n#else\n char buffer[GSERV_BUFSZ+1];\n#endif\n int add_newline = 1;\n int length;\n\n send_string(s,EOT_STR);\t\t/* make sure server gets string */\n\n#if !defined (linux) && !defined (_SCO_DS) \n /*\n * shutdown is completely hozed under linux. If s is a unix domain socket,\n * you'll get EOPNOTSUPP back from it. If s is an internet socket, you get\n * a broken pipe when you try to read a bit later. The latter\n * problem is fixed for linux versions >= 1.1.46, but the problem\n * with unix sockets persists. Sigh.\n */\n\n if (shutdown(s,1) == -1) {\n perror(progname);\n fprintf(stderr, \"%s: unable to shutdown socket\\n\",progname);\n exit(1);\n }; /* if */\n#endif\n\n#if 0\n while((length = recv(s,buffer,REPLYSIZ,0)) > 0) {\n buffer[length] = '\\0';\n if (echo) fputs(buffer,stdout);\n add_newline = (buffer[length-1] != '\\n');\n }; /* while */\n#else\n while ((length = read(s,buffer,GSERV_BUFSZ)) > 0 ||\n (length == -1 && errno == EINTR)) {\n if (length > 0) {\n buffer[length] = '\\0';\n if (echo) {\n\tfputs(buffer,stdout);\n\tadd_newline = (buffer[length-1] != '\\n');\n }; /* if */\n }; /* if */\n }; /* while */\n#endif\n \n if (echo && add_newline) putchar('\\n');\n\n if(length < 0) {\n perror(progname);\n fprintf(stderr,\"%s: unable to read the reply from the server\\n\",progname);\n exit(1);\n }; /* if */\n\n}", "label": 0, "cwe": null, "length": 443 }, { "index": 665573, "code": "RotateLeft(Dlist * l, size_t n)\n{\n DlistElement *rvp, *oldStart;\n if (l == NULL)\n return iError.NullPtrError(\"iDlist.RotateLeft\");\n if (l->Flags & CONTAINER_READONLY) {\n l->RaiseError(\"iDlist.RotateLeft\",CONTAINER_ERROR_READONLY,l);\n return CONTAINER_ERROR_READONLY;\n }\n if (l->count < 2 || n == 0)\n return 0;\n n %= l->count;\n if (n == 0)\n return 0;\n rvp = l->First;\n oldStart = rvp;\n while (n > 0) {\n rvp = rvp->Next;\n n--;\n }\n l->First = rvp;\n l->Last->Next = oldStart;\n oldStart->Previous = l->Last;\n l->Last = rvp->Previous;\n l->Last->Next = NULL;\n rvp->Previous = NULL;\n return 1;\n}", "label": 0, "cwe": null, "length": 225 }, { "index": 846281, "code": "main (int argc, char *argv[]) {\n GOptionContext* context = g_option_context_new(\"- Graphical Disk Map\");\n GError* error = NULL;\n\n\tbindtextdomain(GETTEXT_PACKAGE, GDMAP_LOCALE_DIR);\n\tbind_textdomain_codeset(GETTEXT_PACKAGE, \"UTF-8\");\n\ttextdomain(GETTEXT_PACKAGE);\n\n g_option_context_set_ignore_unknown_options(context, FALSE);\n g_option_context_set_help_enabled(context, TRUE);\n g_option_context_add_main_entries(context, Options, NULL);\n if (!g_option_context_parse(context, &argc, &argv, &error)) {\n g_warning(\"%s\", error->message);\n g_option_context_free(context);\n return 0;\n }\n g_option_context_free(context);\n \n gtk_init(&argc, &argv);\n \n gtk_rc_parse_string(GtkResource);\n \n gui_create_main_win();\n\n colors_init();\n pref_init();\n\n g_idle_add((GSourceFunc)on_load, NULL);\n \n gtk_main();\n\n return 0;\n}", "label": 0, "cwe": null, "length": 217 }, { "index": 899779, "code": "merge_sort (List_Node *a_head)\n{\n if (!a_head || !a_head->next)\n return a_head;\n else\n {\n List_Node *middle = a_head;\n List_Node *temp = a_head->next->next;\n\n while (temp)\n {\n temp = temp->next;\n middle = middle->next;\n if (temp)\n temp = temp->next;\n }\n\n temp = middle->next;\n middle->next = 0;\n return merge (merge_sort (a_head), merge_sort (temp));\n }\n}", "label": 0, "cwe": null, "length": 123 }, { "index": 159573, "code": "p_image_sizechange(gint32 image_id,\n GapRangeOpsAsiz asiz_mode,\n long size_x, long size_y,\n long offs_x, long offs_y\n)\n{\n gboolean l_rc;\n\n if(gap_debug)\n {\n printf(\"p_image_sizechange: image_id: %d\\n\", (int)image_id);\n\n printf(\"size_x:%d size_y: %d\\n\", (int)size_x , (int)size_y );\n printf(\"size_x:%d size_y: %d\\n\", (int)size_x , (int)size_y );\n\n if(asiz_mode != GAP_ASIZ_SCALE)\n {\n printf(\"offs_x: %d\\n\", (int)offs_x);\n printf(\"offs_y: %d\\n\", (int)offs_y);\n }\n }\n\n switch(asiz_mode)\n {\n case GAP_ASIZ_CROP:\n l_rc = gimp_image_crop(image_id, size_x, size_y, offs_x, offs_y);\n break;\n case GAP_ASIZ_RESIZE:\n l_rc = gimp_image_resize(image_id, size_x, size_y, offs_x, offs_y);\n break;\n default:\n l_rc = gimp_image_scale(image_id, size_x, size_y);\n break;\n }\n\n if(l_rc) return 0;\n return -1;\n}", "label": 0, "cwe": null, "length": 291 }, { "index": 108381, "code": "do_init(char *host, int port)\n{\n int debug, protocol;\n LDAP *ld;\n\n if ((ld = ldap_init(host, port)) == NULL) {\n\tlog_msg((LOG_ERROR_LEVEL, \"ldap_init to %s:%d failed\", host, port));\n\treturn(NULL);\n }\n\n if (ldap_set_option(ld, LDAP_OPT_REFERRALS, LDAP_OPT_OFF)\n\t != LDAP_OPT_SUCCESS) {\n\tlog_msg((LOG_ERROR_LEVEL, \"Could not set LDAP_OPT_REFERRALS off\"));\n\treturn(NULL);\n }\n\n /* LDAPv3 only */\n protocol = LDAP_VERSION3;\n if (ldap_set_option(ld, LDAP_OPT_PROTOCOL_VERSION, &protocol)\n\t != LDAP_OPT_SUCCESS) {\n\tlog_msg((LOG_ERROR_LEVEL, \"Could not set LDAP_OPT_PROTOCOL_VERSION %d\",\n\t\t\t protocol));\n\treturn(NULL);\n }\n\n debug = (trace_level > 1);\n if (ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, &debug) != LDAP_OPT_SUCCESS)\n\tlog_msg((LOG_DEBUG_LEVEL, \"Could not set LDAP_OPT_DEBUG_LEVEL %d\", debug));\n\n return(ld);\n}", "label": 0, "cwe": null, "length": 230 }, { "index": 75221, "code": "find_next_number(uint16_t requestno, request * k,\n\t\t\t\t\t\t\t\t uint16_t * curmax)\n{\n\tif (*curmax != requestno)\n\t{\n\t\t// We can use this number\n\t\treturn TRUE;\n\t}\n\telse\n\t{\n\t\t*curmax = (requestno) + 1;\t// Try next\n\t\treturn FALSE;\n\t}\n}", "label": 0, "cwe": null, "length": 78 }, { "index": 462970, "code": "clear_tag_tab ()\n{\n int i;\n\n if (! tagtab || tagtab->scope_level < scope_level)\n return;\n \n for (i = 0; i < SIZE_HAS_LOC; i++)\n {\n if (NULL != tagtab->hastab_loc[i].name)\n\t{\n#if 0\n\t free (tagtab->hastab_loc[i].name);\n#endif\n\t tagtab->hastab_loc[i].name = NULL;\n\t clear_internal_type ((tagtab->table +\n\t\t\t\ttagtab->hastab_loc[i].def)->type);\n\t tagtab->hastab_loc[i].def = 0;\n\t tagtab->hastab_loc[i].count = 0;\n\t tagtab->hastab_loc[i].use_line_number = 0;\n\t tagtab->hastab_loc[i].l_value_flag = 0;\n\t if (NULL != tagtab->hastab_loc[i].next)\n\t clear_hash_tab_next (tagtab, tagtab->hastab_loc[i].next);\n\t}\n }\n tagtab->pi_loc = 0;\n tagtab = tagtab->previous_level;\n \n return;\n}", "label": 0, "cwe": null, "length": 253 }, { "index": 883314, "code": "CombineCVTAToLocal(MachineInstr &Root) {\n auto &MBB = *Root.getParent();\n auto &MF = *MBB.getParent();\n const auto &MRI = MF.getRegInfo();\n const TargetInstrInfo *TII = MF.getSubtarget().getInstrInfo();\n auto &Prev = *MRI.getUniqueVRegDef(Root.getOperand(1).getReg());\n\n MachineInstrBuilder MIB =\n BuildMI(MF, Root.getDebugLoc(), TII->get(Prev.getOpcode()),\n Root.getOperand(0).getReg())\n .addReg(NVPTX::VRFrameLocal)\n .addOperand(Prev.getOperand(2));\n\n MBB.insert((MachineBasicBlock::iterator)&Root, MIB);\n\n // Check if MRI has only one non dbg use, which is Root\n if (MRI.hasOneNonDBGUse(Prev.getOperand(0).getReg())) {\n Prev.eraseFromParentAndMarkDBGValuesForRemoval();\n }\n Root.eraseFromParentAndMarkDBGValuesForRemoval();\n}", "label": 0, "cwe": null, "length": 227 }, { "index": 235837, "code": "LSL_isMA86available() {\n#ifndef COINHSL_HAS_MA86\n\treturn func_ma86_default_control!=NULL && func_ma86_analyse!=NULL && func_ma86_factor!=NULL && func_ma86_factor_solve!=NULL && func_ma86_solve!=NULL && func_ma86_finalise!=NULL;\n#else\n\treturn 1;\n#endif\n}", "label": 0, "cwe": null, "length": 75 }, { "index": 17244, "code": "walk_alter_subreg (rtx *xp, bool *changed)\n{\n rtx x = *xp;\n switch (GET_CODE (x))\n {\n case PLUS:\n case MULT:\n case AND:\n XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0), changed);\n XEXP (x, 1) = walk_alter_subreg (&XEXP (x, 1), changed);\n break;\n\n case MEM:\n case ZERO_EXTEND:\n XEXP (x, 0) = walk_alter_subreg (&XEXP (x, 0), changed);\n break;\n\n case SUBREG:\n *changed = true;\n return alter_subreg (xp, true);\n\n default:\n break;\n }\n\n return *xp;\n}", "label": 0, "cwe": null, "length": 176 }, { "index": 155562, "code": "lister_has_next(Lister *lister)\n{\n\tif (!lister)\n\t\treturn set_errno(EINVAL);\n\n\treturn lister->index + 1 < lister->list->length;\n}", "label": 0, "cwe": null, "length": 41 }, { "index": 361736, "code": "is_mode_has_row (MOID_T * m)\n{\n if (IS (m, STRUCT_SYMBOL) || IS (m, UNION_SYMBOL)) {\n BOOL_T k = A68_FALSE;\n PACK_T *p = PACK (m);\n for (; p != NO_PACK && k == A68_FALSE; FORWARD (p)) {\n HAS_ROWS (MOID (p)) = is_mode_has_row (MOID (p));\n k |= (HAS_ROWS (MOID (p)));\n }\n return (k);\n } else {\n return ((BOOL_T) (HAS_ROWS (m) || IS (m, ROW_SYMBOL) || IS (m, FLEX_SYMBOL)));\n }\n}", "label": 0, "cwe": null, "length": 145 }, { "index": 180776, "code": "ExecUnbComObjName (\n Stat stat )\n{\n Obj record; /* record, left operand */\n UInt rnam; /* name, left operand */\n\n /* evaluate the record (checking is done by 'UNB_REC') */\n SET_BRK_CURR_STAT( stat );\n record = EVAL_EXPR( ADDR_STAT(stat)[0] );\n\n /* get the name (stored immediately in the statement) */\n rnam = (UInt)(ADDR_STAT(stat)[1]);\n\n /* unbind the element of the record */\n if ( TNUM_OBJ(record) == T_COMOBJ ) {\n UnbPRec( record, rnam );\n }\n else {\n UNB_REC( record, rnam );\n }\n\n /* return 0 (to indicate that no leave-statement was executed) */\n return 0;\n}", "label": 0, "cwe": null, "length": 185 }, { "index": 364354, "code": "gnc_simple_combo_make (GtkComboBox *cbox, QofBook *book,\n gboolean none_ok, QofIdType type_name,\n GList * (*get_list)(QofBook*),\n GenericLookup_t get_name,\n GenericEqual_t is_equal,\n gpointer initial_choice)\n{\n ListStoreData *lsd;\n\n lsd = g_object_get_data (G_OBJECT (cbox), \"liststore-data\");\n\n /* If this is the first time we've been called, then build the\n * Option Menu Data object, register with the component manager, and\n * watch for changed items. Then register for deletion, so we can\n * unregister and free the data when this menu is destroyed.\n */\n if (!lsd)\n {\n\n lsd = g_new0 (ListStoreData, 1);\n lsd->cbox = cbox;\n lsd->book = book;\n lsd->none_ok = none_ok;\n lsd->get_name = get_name;\n lsd->get_list = get_list;\n lsd->is_equal = is_equal;\n g_object_set_data (G_OBJECT (cbox), \"liststore-data\", lsd);\n\n lsd->component_id =\n gnc_register_gui_component (\"gnc-simple-combo-refresh-hook\",\n gnc_simple_combo_refresh_handler,\n NULL, lsd);\n\n if (type_name)\n gnc_gui_component_watch_entity_type (lsd->component_id,\n type_name,\n QOF_EVENT_MODIFY | QOF_EVENT_DESTROY);\n\n g_signal_connect (G_OBJECT (cbox), \"destroy\",\n G_CALLBACK (gnc_simple_combo_destroy_cb), lsd);\n }\n\n gnc_simple_combo_generate_liststore (lsd);\n gnc_simple_combo_set_value (cbox, initial_choice);\n}", "label": 0, "cwe": null, "length": 387 }, { "index": 39901, "code": "ptrace(int request, pid_t pid, void *addr, void *data) {\n errno=0;\n switch (request) {\n case PTRACE_TRACEME: case PTRACE_KILL: case PTRACE_ATTACH:\n case PTRACE_DETACH:\n return (__diet_ptrace (request, pid, NULL, NULL));\n case PTRACE_PEEKDATA: case PTRACE_PEEKUSER: case PTRACE_PEEKTEXT:\n {\n\tlong result;\n\tif (__diet_ptrace (request, pid, addr, &result) == -1)\n\t\treturn (-1);\n\treturn (result);\n }\n default:\n return (__diet_ptrace (request, pid, addr, data));\n }\n}", "label": 0, "cwe": null, "length": 150 }, { "index": 64896, "code": "on_mount_added(GVolumeMonitor* vm, GMount* mount, gpointer user_data)\n{\n /* If a filesystem is mounted over an existing folder,\n * we need to refresh the content of the folder to reflect\n * the changes. Besides, we need to create a new GFileMonitor\n * for the newly-mounted filesystem as the inode already changed.\n * GFileMonitor cannot detect this kind of changes caused by mounting.\n * So let's do it ourselves. */\n\n GFile* gfile = g_mount_get_root(mount);\n /* g_debug(\"FmFolder::mount_added\"); */\n if(gfile)\n {\n GHashTableIter it;\n FmPath* path;\n FmFolder* folder;\n FmPath* mounted_path = fm_path_new_for_gfile(gfile);\n g_object_unref(gfile);\n\n G_LOCK(hash);\n g_hash_table_iter_init(&it, hash);\n while(g_hash_table_iter_next(&it, (gpointer*)&path, (gpointer*)&folder))\n {\n if(path == mounted_path)\n queue_reload(folder);\n else if(fm_path_has_prefix(path, mounted_path))\n {\n /* see if currently cached folders are below the mounted path.\n * Folders below the mounted folder are removed.\n * FIXME: should we emit \"removed\" signal for them, or \n * keep the folders and only reload them? */\n /* g_signal_emit(folder, signals[REMOVED], 0); */\n queue_reload(folder);\n }\n }\n G_UNLOCK(hash);\n fm_path_unref(mounted_path);\n }\n}", "label": 0, "cwe": null, "length": 338 }, { "index": 19805, "code": "afs_flush(struct file *file, fl_owner_t id)\n{\n\t_enter(\"\");\n\n\tif ((file->f_mode & FMODE_WRITE) == 0)\n\t\treturn 0;\n\n\treturn vfs_fsync(file, 0);\n}", "label": 0, "cwe": null, "length": 47 }, { "index": 228030, "code": "mono_regname_full (int reg, int bank)\n{\n\tif (G_UNLIKELY (bank)) {\n#if MONO_ARCH_NEED_SIMD_BANK\n\t\tif (bank == MONO_REG_SIMD)\n\t\t\treturn mono_arch_xregname (reg);\n#endif\n\t\tif (bank == MONO_REG_INT_REF || bank == MONO_REG_INT_MP)\n\t\t\treturn mono_arch_regname (reg);\n\t\tg_assert (bank == MONO_REG_DOUBLE);\n\t\treturn mono_arch_fregname (reg);\n\t} else {\n\t\treturn mono_arch_regname (reg);\n\t}\n}", "label": 0, "cwe": null, "length": 119 }, { "index": 932862, "code": "neon_disambiguate_copy (rtx *operands, rtx *dest, rtx *src, unsigned int count)\n{\n unsigned int i;\n\n if (!reg_overlap_mentioned_p (operands[0], operands[1])\n || REGNO (operands[0]) < REGNO (operands[1]))\n {\n for (i = 0; i < count; i++)\n\t{\n\t operands[2 * i] = dest[i];\n\t operands[2 * i + 1] = src[i];\n\t}\n }\n else\n {\n for (i = 0; i < count; i++)\n\t{\n\t operands[2 * i] = dest[count - i - 1];\n\t operands[2 * i + 1] = src[count - i - 1];\n\t}\n }\n}", "label": 0, "cwe": null, "length": 176 }, { "index": 869753, "code": "cp2112_gpio_set(struct gpio_chip *chip, unsigned offset, int value)\n{\n\tstruct cp2112_device *dev = container_of(chip, struct cp2112_device,\n\t\t\t\t\t\t gc);\n\tstruct hid_device *hdev = dev->hdev;\n\tu8 buf[3];\n\tint ret;\n\n\tbuf[0] = CP2112_GPIO_SET;\n\tbuf[1] = value ? 0xff : 0;\n\tbuf[2] = 1 << offset;\n\n\tret = hid_hw_raw_request(hdev, CP2112_GPIO_SET, buf, sizeof(buf),\n\t\t\t\t HID_FEATURE_REPORT, HID_REQ_SET_REPORT);\n\tif (ret < 0)\n\t\thid_err(hdev, \"error setting GPIO values: %d\\n\", ret);\n}", "label": 0, "cwe": null, "length": 153 }, { "index": 71182, "code": "drawLayout(PangoLayout *ly, bool markup, int x, int y, int w, int h, int align)\n{\n\tint offx = 0, offy = 0;\n\tfloat foffx, foffy;\n\tint tw, th;\n\tfloat ftw, fth;\n\n\tgt_add_layout_from_font(ly, font());\n\t\n\tgt_layout_alignment(ly, (float)w, (float)h, &ftw, &fth, align, &foffx, &foffy);\n\ttw = (int)ftw;\n\tth = (int)fth;\n\toffx = (int)foffx;\n\toffy = (int)foffy;\n\n\tif (markup)\n\t\toffx = 0;\n\n\tif (!_transparent)\n\t{\n\t\tgColor buf = foreground();\n\t\tsetForeground(background());\n\t\tgdk_draw_rectangle (dr, gc, true, x + offx, y + offy, tw, th);\t\n\t\tif (drm) gdk_draw_rectangle (drm, gcm, true, x + offx, y + offy, tw, th);\t\n\t\tsetForeground(buf);\n\t}\n\t\n\tgdk_draw_layout(dr, gc, x + offx, y + offy, ly);\n\t\n\tif (drm && _transparent)\n\t{\n\t\tGdkBitmap *mask;\n\t\t\n\t\tmask = gt_make_text_mask(dr, tw, th, ly, 0, 0);\n\t\t\n\t\tgdk_gc_set_function(gcm, GDK_OR);\n\t\tgdk_draw_drawable(drm, gcm, mask, 0, 0, x + offx, y + offy, tw, th);\n\t\tgdk_gc_set_function(gcm, GDK_COPY);\n\t\t\n\t\tg_object_unref(mask);\n\t}\n\t\n\tg_object_unref(G_OBJECT(ly));\n}", "label": 0, "cwe": null, "length": 382 }, { "index": 91640, "code": "gui_link(struct gui_object *obj1, struct gui_object *obj2)\n{\n\tstruct gui_link *cur;\n\t/* See if the link is there already */\n\tcur = links;\n\twhile(cur) {\n\t\tif (((cur->obj1 == obj1) && (cur->obj2 == obj2)) ||\n\t\t ((cur->obj1 == obj2) && (cur->obj2 == obj1)))\n\t\t\t\tbreak;\n\t\tcur = cur->next;\n\t}\n\tif (!cur) {\n\t\tcur = g_new0(struct gui_link, 1);\n\t\tcur->widget = gtk_link_new();\n\t\tcur->obj1 = obj1;\n\t\tcur->obj2 = obj2;\n\t\tgtk_widget_show(cur->widget);\n\t\tgtk_layout_put(GTK_LAYOUT(canvas), cur->widget, 0, 0);\n\t\tcur->next = links;\n\t\tlinks = cur;\n\t}\n\tgtk_link_set_coords(GTK_LINK(cur->widget), \n\t\tobj1->widget->allocation.x + obj1->widget->allocation.width/2,\n\t\tobj1->widget->allocation.y + obj1->widget->allocation.height/2,\n\t\tobj2->widget->allocation.x + obj2->widget->allocation.width/2,\n\t\tobj2->widget->allocation.y + obj2->widget->allocation.height/2);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 274 }, { "index": 448325, "code": "ajSysCommandRemovedirC(const char* name)\n{\n AjPStr cmdstr = NULL;\n AjBool ret;\n\n ret = ajTrue;\n \n cmdstr = ajStrNewC(name);\n if(!ajFilenameExistsDir(cmdstr))\n {\n if(!ajFilenameExists(cmdstr))\n ajErr(\"Unable to remove directory '%S' not found\", cmdstr);\n else\n ajErr(\"Unable to remove directory '%S' not a directory\", cmdstr);\n\n return ajFalse;\n }\n \n ret = ajSysFileRmrfC(name);\n\n ajStrDel(&cmdstr);\n\n return ret;\n}", "label": 0, "cwe": null, "length": 136 }, { "index": 389216, "code": "execute()\n{\n unsigned int new_value;\n\n if (access)\n source = cpu_pic->register_bank[register_address];\n else if (cpu16->extended_instruction() && register_address < 0x60)\n source = cpu_pic->registers[register_address + cpu16->ind2.fsr_value];\n else\n source = cpu_pic->registers[register_address];\n\n new_value = source->get() ^ 0xff;\n\n // Store the result\n\n if(destination)\n source->put(new_value); // Result goes to source\n else\n cpu16->Wput(new_value);\n\n cpu16->status->put_N_Z(new_value);\n\n cpu16->pc->increment();\n\n}", "label": 0, "cwe": null, "length": 150 }, { "index": 228455, "code": "test_spin_button (void)\n{\n const gchar buffer[] =\n \"\"\n \"\"\n \"0\"\n \"10\"\n \"2\"\n \"3\"\n \"5\"\n \"1\"\n \"\"\n \"\"\n \"True\"\n \"adjustment1\"\n \"\"\n \"\";\n GObject *object;\n GtkAdjustment *adjustment;\n gdouble value;\n \n builder = builder_new_from_string (buffer, -1, NULL);\n object = gtk_builder_get_object (builder, \"spinbutton1\");\n cut_assert (GTK_IS_SPIN_BUTTON (object));\n adjustment = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (object));\n cut_assert (GTK_IS_ADJUSTMENT (adjustment));\n g_object_get (adjustment, \"value\", &value, NULL);\n cut_assert_equal_int (1, value);\n g_object_get (adjustment, \"lower\", &value, NULL);\n cut_assert_equal_int (0, value);\n g_object_get (adjustment, \"upper\", &value, NULL);\n cut_assert_equal_int (10, value);\n g_object_get (adjustment, \"step-increment\", &value, NULL);\n cut_assert_equal_int (2, value);\n g_object_get (adjustment, \"page-increment\", &value, NULL);\n cut_assert_equal_int (3, value);\n g_object_get (adjustment, \"page-size\", &value, NULL);\n cut_assert_equal_int (5, value);\n \n g_object_unref (builder);\n builder = NULL;\n}", "label": 0, "cwe": null, "length": 424 }, { "index": 955512, "code": "mthca_MAP_ICM_page(struct mthca_dev *dev, u64 dma_addr, u64 virt)\n{\n\tstruct mthca_mailbox *mailbox;\n\t__be64 *inbox;\n\tint err;\n\n\tmailbox = mthca_alloc_mailbox(dev, GFP_KERNEL);\n\tif (IS_ERR(mailbox))\n\t\treturn PTR_ERR(mailbox);\n\tinbox = mailbox->buf;\n\n\tinbox[0] = cpu_to_be64(virt);\n\tinbox[1] = cpu_to_be64(dma_addr);\n\n\terr = mthca_cmd(dev, mailbox->dma, 1, 0, CMD_MAP_ICM,\n\t\t\tCMD_TIME_CLASS_B);\n\n\tmthca_free_mailbox(dev, mailbox);\n\n\tif (!err)\n\t\tmthca_dbg(dev, \"Mapped page at %llx to %llx for ICM.\\n\",\n\t\t\t (unsigned long long) dma_addr, (unsigned long long) virt);\n\n\treturn err;\n}", "label": 0, "cwe": null, "length": 194 }, { "index": 827565, "code": "val_str(String *str)\n{\n /*\n As far as Item_in_subselect called only from Item_in_optimizer this\n method should not be used\n */\n DBUG_ASSERT(0);\n DBUG_ASSERT(fixed == 1);\n null_value= was_null= FALSE;\n if (exec())\n {\n reset();\n return 0;\n }\n if (was_null && !value)\n {\n null_value= TRUE;\n return 0;\n }\n str->set((ulonglong)value, &my_charset_bin);\n return str;\n}", "label": 0, "cwe": null, "length": 121 }, { "index": 854420, "code": "box_assign_texpr_array(ap_manager_t* man,\n\t\t\t bool destructive,\n\t\t\t box_t* a,\n\t\t\t ap_dim_t* tdim, \n\t\t\t ap_texpr0_t** texpr,\n\t\t\t size_t size,\n\t\t\t box_t* dest)\n{\n size_t i;\n box_t* res;\n box_internal_t* intern = man->internal;\n \n if (a->p==NULL || (dest && dest->p==NULL)){\n man->result.flag_best = true;\n man->result.flag_exact = true;\n return destructive ? a : box_copy(man,a);\n }\n if (size==1){\n res = destructive ? a : box_copy(man,a);\n itv_eval_ap_texpr0(intern->itv,res->p[tdim[0]],texpr[0],a->p);\n }\n else {\n res = box_copy(man,a);\n for (i=0;iitv,res->p[tdim[i]],texpr[i],a->p);\n }\n if (destructive) box_free(man,a);\n }\n if (dest)\n res = box_meet(man,true,res,dest);\n man->result.flag_best = false;\n man->result.flag_exact = false;\n return res;\n}", "label": 0, "cwe": null, "length": 282 }, { "index": 799657, "code": "gvlook(char *name)\n{\n\tint h = hash(name, NVAR);\n\tvar *v;\n\tfor(v = gvar[h];v;v = v->next) if(strcmp(v->name, name)==0) return v;\n\treturn gvar[h] = newvar(strdup(name), gvar[h]);\n}", "label": 0, "cwe": null, "length": 66 }, { "index": 232858, "code": "nemo_get_cached_x_content_types_for_mount (GMount *mount)\n{\n\tchar **cached;\n\n\tif (mount == NULL) {\n\t\treturn NULL;\n\t}\n\n\tcached = g_object_get_data (G_OBJECT (mount), \"nemo-content-type-cache\");\n\tif (cached != NULL) {\n\t\treturn g_strdupv (cached);\n\t}\n\n\treturn NULL;\n}", "label": 0, "cwe": null, "length": 75 }, { "index": 99672, "code": "cache_alloc_mm(unsigned int bytes) {\n\tint\t\tfile_fd;\n\tint\t\trc;\n\tint\t\tchunk_count;\n\tchar\t\tnull_buff[1024];\n\tsize_t mm_file_len;\n\t\n\tmm.bytes = bytes;\n\n\tmm_file_len = strlen(run_path) + sizeof(CACHE_MMAP_FILE) + 1;\n\tif (!(mm.file =\n\t (char *)malloc(mm_file_len))) {\n\t\tlogger(L_ERR, L_FUNC, \"could not allocate memory\");\n\t\treturn NULL;\n\t}\n\n\tstrlcpy(mm.file, run_path, mm_file_len);\n\tstrlcat(mm.file, CACHE_MMAP_FILE, mm_file_len);\n\t\n\tif ((file_fd =\n\t open(mm.file, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR)) < 0) {\n\t\trc = errno;\n\t\tlogger(L_ERR, L_FUNC, \"could not open mmap file: %s\", mm.file);\n\t\tlogger(L_ERR, L_FUNC, \"open: %s\", strerror(rc));\n\t\treturn NULL;\n\t}\n\n\tmemset(null_buff, 0, sizeof(null_buff));\n\n\tchunk_count = (bytes / sizeof(null_buff)) + 1;\n\n\twhile (chunk_count > 0) {\n\t if (tx_rec(file_fd, null_buff, sizeof(null_buff))\n\t\t!= (ssize_t)sizeof(null_buff)) {\n\t\trc = errno;\n\t\tlogger(L_ERR, L_FUNC,\n\t\t \"failed while writing to mmap file: %s\",\n\t\t mm.file);\n\t\tclose(file_fd);\n\t\treturn NULL;\n\t }\n\t \n\t chunk_count--;\n\t}\t\n\t\n\tif ((mm.base = mmap(NULL, bytes, PROT_READ|PROT_WRITE,\n\t\t\t MAP_SHARED, file_fd, 0))== (void *)-1) {\n\t\trc = errno;\n\t\tlogger(L_ERR, L_FUNC, \"could not mmap shared memory segment\");\n\t\tlogger(L_ERR, L_FUNC, \"mmap: %s\", strerror(rc));\n\t\tclose(file_fd);\n\t\treturn NULL;\n\t}\n\n\tclose(file_fd);\n\n\tif (flags & VERBOSE) {\n\t\tlogger(L_DEBUG, L_FUNC,\n\t\t \"mmaped shared memory segment on file: %s\", mm.file);\n\t}\n\n\treturn mm.base;\n}", "label": 0, "cwe": null, "length": 449 }, { "index": 242135, "code": "str_squeeze_unlocked(String *str)\n{\n\tchar *s, *r;\n\tint started = 0;\n\tint was_space = 0;\n\n\tif (!str)\n\t\treturn set_errnull(EINVAL);\n\n\tfor (r = s = str->str; s - str->str < str->length - 1; ++s)\n\t{\n\t\tif (!is_space(*s))\n\t\t{\n\t\t\tif (was_space && started)\n\t\t\t\t*r++ = ' ';\n\t\t\t*r++ = *s;\n\t\t\tstarted = 1;\n\t\t}\n\n\t\twas_space = is_space(*s);\n\t}\n\n\tif (r - str->str < str->length)\n\t\tif (!str_remove_range_unlocked(str, r - str->str, str->length - 1 - (r - str->str)))\n\t\t\treturn NULL;\n\n\treturn str;\n}", "label": 0, "cwe": null, "length": 177 }, { "index": 466393, "code": "checkObsoleteOrientation(QDomElement & instance)\n{\n\tQString flippedSMD = instance.attribute(\"flippedSMD\", \"\");\n\tif (flippedSMD != \"true\") return false;\n\n\tQDomElement views = instance.firstChildElement(\"views\");\n\tQDomElement pcbView = views.firstChildElement(\"pcbView\");\n return (pcbView.attribute(\"layer\", \"\") == \"copper0\");\n}", "label": 0, "cwe": null, "length": 79 }, { "index": 75383, "code": "disp_label_edit(char *str)\n{\n#if WIN32\n if (test_mode)\n return;\n#endif\n if (!label_edit)\n return;\n\n show_hide_label_edit();\n#if GTK_CHECK_VERSION(2,91,6)\n // bug in gtk3\n set_label_font_size(label_edit, gcin_font_size);\n#endif\n\n gtk_label_set_markup(GTK_LABEL(label_edit), str);\n}", "label": 0, "cwe": null, "length": 85 }, { "index": 659591, "code": "loghistory(const char *cmd, size_t len) {\n\tconst char *s, *end;\n\tif (history == NULL || disablehistory)\n\t\treturn;\n\tif (historyfd == -1) {\n\t\thistoryfd = eopen(history, oAppend);\n\t\tif (historyfd == -1) {\n\t\t\teprint(\"history(%s): %s\\n\", history, esstrerror(errno));\n\t\t\tvardef(\"history\", NULL, NULL);\n\t\t\treturn;\n\t\t}\n\t}\n\t/* skip empty lines and comments in history */\n\tfor (s = cmd, end = s + len; s < end; s++)\n\t\tswitch (*s) {\n\t\tcase '#': case '\\n':\treturn;\n\t\tcase ' ': case '\\t':\tbreak;\n\t\tdefault:\t\tgoto writeit;\n\t\t}\n\twriteit:\n\t\t;\n\t/*\n\t * Small unix hack: since read() reads only up to a newline\n\t * from a terminal, then presumably this write() will write at\n\t * most only one input line at a time.\n\t */\n\tewrite(historyfd, cmd, len);\n}", "label": 0, "cwe": null, "length": 229 }, { "index": 909086, "code": "dotExp(Scope *sc, Expression *e, Identifier *ident, int flag)\n{\n#if LOGDOTEXP\n printf(\"TypeSArray::dotExp(e = '%s', ident = '%s')\\n\", e->toChars(), ident->toChars());\n#endif\n if (ident == Id::length)\n {\n Loc oldLoc = e->loc;\n e = dim->copy();\n e->loc = oldLoc;\n }\n else if (ident == Id::ptr)\n {\n if (size(e->loc) == 0)\n e = new NullExp(e->loc, next->pointerTo());\n else\n {\n e = new IndexExp(e->loc, e, new IntegerExp(0));\n e = new AddrExp(e->loc, e);\n }\n }\n else\n {\n e = TypeArray::dotExp(sc, e, ident, flag);\n }\n if (!flag || e)\n e = e->semantic(sc);\n return e;\n}", "label": 0, "cwe": null, "length": 217 }, { "index": 470422, "code": "propertyFree(CssProperty *p){\n if (p && p->eType == CSS_TYPE_LIST) {\n int ii;\n CssProperty **apProp = (CssProperty **)p->v.p;\n for (ii = 0; apProp[ii]; ii++) {\n propertyFree(apProp[ii]);\n }\n }\n HtmlFree(p);\n}", "label": 0, "cwe": null, "length": 76 }, { "index": 40231, "code": "CPUShot(player_t *g)\n{\n uint32_t state;\n\n switch(GetTable()>>1)\n {\n case 1:\n state=JPF_JOY_UP;\n break;\n case 2:\n state=JPF_JOY_DOWN;\n break;\n default:\n state=0L;\n }\n\n SetShotSpeed(g,IndirizzaTiro(g,state));\n\n g->dir=(pl->dir+8)>>5;\n\n if(g->dir>7)\n g->dir-=8;\n\n// Gestione della quota\n\n switch(GetTable())\n {\n case 5:\n pl->TipoTiro=TIRO_PALLONETTO;\n break;\n case 4:\n case 3:\n pl->TipoTiro=TIRO_RASOTERRA;\n break;\n default:\n pl->TipoTiro=TIRO_ALTO;\n }\n\n Tira(g);\n}", "label": 0, "cwe": null, "length": 199 }, { "index": 536100, "code": "cal_obj_yearly_find_next_position (CalObjTime *cotime,\n CalObjTime *event_end,\n RecurData *recur_data,\n CalObjTime *interval_end)\n{\n\t/* NOTE: The day may now be invalid, e.g. 29th Feb. */\n\tcotime->year += recur_data->recur->interval;\n\n\tif ((event_end && cotime->year > event_end->year)\n\t || (interval_end && cotime->year > interval_end->year))\n\t\treturn TRUE;\n\n\treturn FALSE;\n}", "label": 0, "cwe": null, "length": 112 }, { "index": 33926, "code": "gth_stat_add_to_refseqcovdistri(GthStat *stat, unsigned long data)\n{\n gt_assert(stat);\n if (stat->refseqcovdistri)\n gt_disc_distri_add(stat->refseqcoveragedistribution, data);\n}", "label": 0, "cwe": null, "length": 54 }, { "index": 53868, "code": "_blend_nodes_build(Elm_Transit *transit, Elm_Transit_Effect_Blend *blend)\n{\n Elm_Transit_Effect_Blend_Node *blend_node;\n Eina_List *data_list = NULL;\n int i, count;\n\n count = eina_list_count(transit->objs);\n for (i = 0; i < (count - 1); i += 2)\n {\n blend_node = ELM_NEW(Elm_Transit_Effect_Blend_Node);\n if (!blend_node)\n {\n eina_list_free(data_list);\n return NULL;\n }\n\n blend_node->before = eina_list_nth(transit->objs, i);\n blend_node->after = eina_list_nth(transit->objs, i + 1);\n evas_object_show(blend_node->before);\n evas_object_show(blend_node->after);\n\n evas_object_color_get(blend_node->before, &blend_node->from.r,\n &blend_node->from.g, &blend_node->from.b,\n &blend_node->from.a);\n evas_object_color_get(blend_node->after, &blend_node->to.r,\n &blend_node->to.g, &blend_node->to.b,\n &blend_node->to.a);\n\n data_list = eina_list_append(data_list, blend_node);\n\n evas_object_event_callback_add(blend_node->before,\n EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);\n evas_object_event_callback_add(blend_node->after,\n EVAS_CALLBACK_DEL, _blend_object_del_cb, blend);\n }\n return data_list;\n}", "label": 0, "cwe": null, "length": 347 }, { "index": 570905, "code": "gnome_online_accounts_config_oauth2 (EGnomeOnlineAccounts *extension,\n ESource *source,\n GoaObject *goa_object)\n{\n\tESourceExtension *source_extension;\n\tconst gchar *extension_name;\n\n\tif (goa_object_peek_oauth2_based (goa_object) == NULL)\n\t\treturn;\n\n\textension_name = E_SOURCE_EXTENSION_AUTHENTICATION;\n\tsource_extension = e_source_get_extension (source, extension_name);\n\n\te_source_authentication_set_method (\n\t\tE_SOURCE_AUTHENTICATION (source_extension),\n\t\tCAMEL_OAUTH2_MECHANISM_NAME);\n}", "label": 0, "cwe": null, "length": 117 }, { "index": 70076, "code": "val_str(String *str)\n{\n DBUG_ASSERT(fixed == 1);\n double nr= val_real();\n if (null_value)\n return 0;\t\t\t\t\t/* purecov: inspected */\n str->set_real(nr,decimals,&my_charset_bin);\n return str;\n}", "label": 0, "cwe": null, "length": 63 }, { "index": 614338, "code": "setData( const QModelIndex &index, const QVariant &value, int role )\n{\n if( !index.isValid() )\n return false;\n if( index.row() < 0 || index.row() >= m_providerData.count() )\n return false;\n if( index.column() != 0 )\n return false;\n if( role != Qt::CheckStateRole )\n return false;\n\n Qt::CheckState state = Qt::CheckState( value.toInt() );\n m_providerData[ index.row() ].enabled = ( state == Qt::Checked ) ? true : false;\n m_hasChanged = true;\n emit dataChanged( index, index );\n return true;\n}", "label": 0, "cwe": null, "length": 142 }, { "index": 238790, "code": "model_instance_free_all()\n{\n\tsize_t i;\n\n\t// free any outstanding model instances\n\tfor ( i = 0; i < Polygon_model_instances.size(); ++i ) {\n\t\tif ( Polygon_model_instances[i] ) {\n\t\t\tmodel_delete_instance(i);\n\t\t}\n\t}\n\n\tPolygon_model_instances.clear();\n}", "label": 0, "cwe": null, "length": 65 }, { "index": 94345, "code": "changeinkcode(VOID_A)\n{\n\tptylist[win].incode = (u_char)ptyinkcode;\n\tif (!emupid) return;\n\n\tsendword(emufd, TE_CHANGEINKCODE);\n\tsendword(emufd, win);\n\tsendword(emufd, ptyinkcode);\n}", "label": 0, "cwe": null, "length": 64 }, { "index": 938982, "code": "gst_y4m_dec_frames_to_timestamp (GstY4mDec * y4mdec, gint64 frame_index)\n{\n if (frame_index == -1)\n return -1;\n\n return gst_util_uint64_scale (frame_index, GST_SECOND * y4mdec->info.fps_d,\n y4mdec->info.fps_n);\n}", "label": 0, "cwe": null, "length": 78 }, { "index": 273534, "code": "reset_vars(void)\n{\n\tscript_var_t *it;\n\tfor(it=script_vars; it; it=it->next)\n\t{\n\t\tif(it->v.flags&VAR_VAL_STR)\n\t\t{\n\t\t\tpkg_free(it->v.value.s.s);\n\t\t\tit->v.flags &= ~VAR_VAL_STR;\n\t\t}\n\t\tmemset(&it->v.value, 0, sizeof(int_str));\n\t}\n}", "label": 0, "cwe": null, "length": 85 }, { "index": 5957, "code": "test_ctors()\n{\n const char *p;\n const char *buf_start, *buf_end;\n\n // const string c'tor copies the memory\n {\n\tconst char x[] = \"/one/two/three/four\";\n\ttok_t t(x, \"/\");\n\tbuf_start = (const char *)x;\n\tbuf_end = (const char *)(x+sizeof(x));\n\n\tp = t.next();\n\tcheck(p != 0);\n\tcheck(!strcmp(p, \"one\"));\n\tcheck(!(p >= buf_start && p <= buf_end));\t// buf was copied\n\tcheck(is_heap(p));\n\n\tp = t.next();\n\tcheck(p != 0);\n\tcheck(!strcmp(p, \"two\"));\n\tcheck(!(p >= buf_start && p <= buf_end));\t// buf was copied\n\tcheck(is_heap(p));\n\n\tp = t.next();\n\tcheck(p != 0);\n\tcheck(!strcmp(p, \"three\"));\n\tcheck(!(p >= buf_start && p <= buf_end));\t// buf was copied\n\tcheck(is_heap(p));\n\n\tp = t.next();\n\tcheck(p != 0);\n\tcheck(!strcmp(p, \"four\"));\n\tcheck(!(p >= buf_start && p <= buf_end));\t// buf was copied\n\tcheck(is_heap(p));\n\n\tp = t.next();\n\tcheck(p == 0);\n }\n\n // non-const string c'tor takes the memory over\n {\n\tchar *x = strdup(\"five/six/seven\");\n\ttok_t t(x, \"/\");\n\tbuf_start = (const char *)x;\n\tbuf_end = (const char *)(x+strlen(x)+1);\n\n\tp = t.next();\n\tcheck(p != 0);\n\tcheck(!strcmp(p, \"five\"));\n\tcheck((p >= buf_start && p <= buf_end));\t// buf was not copied\n\tcheck(is_heap(p));\n\n\tp = t.next();\n\tcheck(p != 0);\n\tcheck(!strcmp(p, \"six\"));\n\tcheck((p >= buf_start && p <= buf_end));\t// buf was not copied\n\tcheck(is_heap(p));\n\n\tp = t.next();\n\tcheck(p != 0);\n\tcheck(!strcmp(p, \"seven\"));\n\tcheck((p >= buf_start && p <= buf_end));\t// buf was not copied\n\tcheck(is_heap(p));\n\n\tp = t.next();\n\tcheck(p == 0);\n }\n}", "label": 0, "cwe": null, "length": 460 }, { "index": 224236, "code": "heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest)\n{\n\tif (!HeapTupleIsValid(src) || src->t_data == NULL)\n\t{\n\t\tdest->t_data = NULL;\n\t\treturn;\n\t}\n\n\tdest->t_len = src->t_len;\n\tdest->t_self = src->t_self;\n\tdest->t_tableOid = src->t_tableOid;\n\tdest->t_data = (HeapTupleHeader) palloc(src->t_len);\n\tmemcpy((char *) dest->t_data, (char *) src->t_data, src->t_len);\n}", "label": 0, "cwe": null, "length": 120 }, { "index": 55814, "code": "wm8991_mute(struct snd_soc_dai *dai, int mute)\n{\n\tstruct snd_soc_codec *codec = dai->codec;\n\tu16 val;\n\n\tval = snd_soc_read(codec, WM8991_DAC_CTRL) & ~WM8991_DAC_MUTE;\n\tif (mute)\n\t\tsnd_soc_write(codec, WM8991_DAC_CTRL, val | WM8991_DAC_MUTE);\n\telse\n\t\tsnd_soc_write(codec, WM8991_DAC_CTRL, val);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 105 }, { "index": 329519, "code": "OnSessionCreate(Session* session, bool received) {\n LOG(LS_INFO) << \"TunnelSessionClientBase::OnSessionCreate: received=\" \n << received;\n ASSERT(session_manager_->signaling_thread()->IsCurrent());\n if (received)\n sessions_.push_back(\n MakeTunnelSession(session, talk_base::Thread::Current(), RESPONDER));\n}", "label": 0, "cwe": null, "length": 79 }, { "index": 1014853, "code": "isfat (uae_u8 *p)\n{\n\tint i, b;\n\n\tif ((p[0x15] & 0xf0) != 0xf0)\n\t\treturn 0;\n\tif (p[0x0b] != 0x00 || p[0x0c] != 0x02)\n\t\treturn 0;\n\tb = 0;\n\tfor (i = 0; i < 8; i++) {\n\t\tif (p[0x0d] & (1 << i))\n\t\t\tb++;\n\t}\n\tif (b != 1)\n\t\treturn 0;\n\tif (p[0x0f] != 0)\n\t\treturn 0;\n\tif (p[0x0e] > 8 || p[0x0e] == 0)\n\t\treturn 0;\n\tif (p[0x10] == 0 || p[0x10] > 8)\n\t\treturn 0;\n\tb = (p[0x12] << 8) | p[0x11];\n\tif (b > 8192 || b <= 0)\n\t\treturn 0;\n\tb = p[0x16] | (p[0x17] << 8);\n\tif (b == 0 || b > 8192)\n\t\treturn 0;\n\treturn 1;\n}", "label": 0, "cwe": null, "length": 282 }, { "index": 39848, "code": "set_summary_type_from_sql(const Glib::ustring& summary_type)\n{\n if(summary_type == \"SUM\")\n m_summary_type = TYPE_SUM;\n else if(summary_type == \"AVG\")\n m_summary_type = TYPE_AVERAGE;\n else if(summary_type == \"COUNT\")\n m_summary_type = TYPE_COUNT;\n else\n m_summary_type = TYPE_INVALID;\n}", "label": 0, "cwe": null, "length": 81 }, { "index": 507428, "code": "radeon_gem_get_tiling_ioctl(struct drm_device *dev, void *data,\n\t\t\t\tstruct drm_file *filp)\n{\n\tstruct drm_radeon_gem_get_tiling *args = data;\n\tstruct drm_gem_object *gobj;\n\tstruct radeon_bo *rbo;\n\tint r = 0;\n\n\tDRM_DEBUG(\"\\n\");\n\tgobj = drm_gem_object_lookup(dev, filp, args->handle);\n\tif (gobj == NULL)\n\t\treturn -ENOENT;\n\trbo = gem_to_radeon_bo(gobj);\n\tr = radeon_bo_reserve(rbo, false);\n\tif (unlikely(r != 0))\n\t\tgoto out;\n\tradeon_bo_get_tiling_flags(rbo, &args->tiling_flags, &args->pitch);\n\tradeon_bo_unreserve(rbo);\nout:\n\tdrm_gem_object_unreference_unlocked(gobj);\n\treturn r;\n}", "label": 0, "cwe": null, "length": 179 }, { "index": 748994, "code": "L33__WINDOW_POSITIVE_Y__dwtrans()\n{register object *base=vs_base;\n\tregister object *sup=base+VM33; VC33\n\tvs_check;\n\t{object V86;\n\tobject V87;\n\tV86=(base[0]);\n\tV87=(base[1]);\n\tvs_top=sup;\n\tgoto TTL;\nTTL:;\n\tbase[2]= immnum_minus(CMPcadddr((V86)),(V87));\n\tvs_top=(vs_base=base+2)+1;\n\treturn;\n\t}\n}", "label": 0, "cwe": null, "length": 112 }, { "index": 371076, "code": "jumpwp_cb (GtkWidget * widget, guint datum)\n{\n\tgint i;\n\tgchar *p;\n\n\ti = deleteline;\n\tif (gui_status.posmode) {\n\t\tgtk_clist_get_text (GTK_CLIST (mylist), i, 3, &p);\n\t\tcoordinate_string2gdouble(p, &coords.posmode_lat);\n\t\tgtk_clist_get_text (GTK_CLIST (mylist), i, 4, &p);\n\t\tcoordinate_string2gdouble(p, &coords.posmode_lon);\n\t}\n\n\tif ((!gui_status.posmode) && (!current.simmode))\n\t\tgtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (posbt),\n\t\t\t\t\t TRUE);\n\tgetsqldata ();\n\treinsertwp_cb (NULL, 0);\n\tsel_targetweg_cb (NULL, 0);\n\treturn TRUE;\n}", "label": 0, "cwe": null, "length": 170 }, { "index": 929290, "code": "open_temp (const char *file_name, int flags, mode_t mode)\n{\n int fd;\n int saved_errno;\n\n block_fatal_signals ();\n /* Note: 'open' here is actually open() or open_safer(). */\n#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__\n /* Use _O_TEMPORARY when possible, to increase the chances that the\n temporary file is removed when the process crashes. */\n if (supports_delete_on_close ())\n fd = open (file_name, flags | _O_TEMPORARY, mode);\n else\n#endif\n fd = open (file_name, flags, mode);\n saved_errno = errno;\n if (fd >= 0)\n register_fd (fd);\n unblock_fatal_signals ();\n errno = saved_errno;\n return fd;\n}", "label": 0, "cwe": null, "length": 181 }, { "index": 823197, "code": "gnm_so_filled_write_xml_sax (SheetObject const *so, GsfXMLOut *output,\n\t\t\t GnmConventions const *convs)\n{\n\tGnmSOFilled const *sof = GNM_SO_FILLED (so);\n\tgsf_xml_out_add_int\t(output, \"Type\", sof->is_oval ? 102 : 101);\n\n\t/* Old 1.0 and 1.2 */\n\tgsf_xml_out_add_float (output, \"Width\", sof->style->line.width, 2);\n\tgnm_xml_out_add_gocolor (output, \"OutlineColor\", sof->style->line.color);\n\tgnm_xml_out_add_gocolor (output, \"FillColor\",\t sof->style->fill.pattern.back);\n\tif (sof->text != NULL && *(sof->text) != '\\0') {\n\t\tgsf_xml_out_add_cstr (output, \"Label\", sof->text);\n\t\tif (sof->markup != NULL) {\n\t\t\tGOFormat *fmt = go_format_new_markup\t(sof->markup, TRUE);\n\t\t\tgsf_xml_out_add_cstr (output, \"LabelFormat\",\n\t\t\t\t\t go_format_as_XL (fmt));\n\t\t\tgo_format_unref (fmt);\n\t\t}\n\t}\n\n\tgsf_xml_out_start_element (output, \"Style\");\n\tgo_persist_sax_save (GO_PERSIST (sof->style), output);\n\tgsf_xml_out_end_element (output); /* */\n}", "label": 0, "cwe": null, "length": 307 }, { "index": 375187, "code": "get( const QString& path, bool useCache )\n{\n applyProxy();\n m_buffer.clear();\n QString url = m_hostname + path;\n\n if ( useCache && haveCachedCopy( url ) )\n {\n // Using a singleshot so that we can return an ID and have\n // the operation proceed asynchronously.\n m_cacheStack.push( CachedRequestData( ++m_nextId, url ) );\n QTimer::singleShot( 0, this, SLOT( getFromCache() ) );\n return m_nextId;\n }\n\n QHttpRequestHeader header( \"GET\", path );\n header.setValue( \"Host\", m_hostname );\n applyUserAgent( header );\n\n m_dataID = request( header );\n if ( useCache )\n m_requestStack.insert( m_dataID, CachedRequestData( ++m_nextId, url ) );\n\n m_inProgress = true;\n\n return m_dataID;\n}", "label": 0, "cwe": null, "length": 193 }, { "index": 462339, "code": "peerAddress()\n{\n\tif (_sockfd == POCO_INVALID_SOCKET) throw InvalidSocketException();\n\t\n\tchar buffer[SocketAddress::MAX_ADDRESS_LENGTH];\n\tstruct sockaddr* pSA = reinterpret_cast(buffer);\n\tpoco_socklen_t saLen = sizeof(buffer);\n\tint rc = ::getpeername(_sockfd, pSA, &saLen);\n\tif (rc == 0)\n\t\treturn SocketAddress(pSA, saLen);\n\telse \n\t\terror();\n\treturn SocketAddress();\n}", "label": 0, "cwe": null, "length": 101 }, { "index": 41015, "code": "forwardIdx()\n{\n\tLASSERT(idx_ < nargs(), /**/);\n\n\t++idx_;\n\tpit_ = 0;\n\tpos_ = 0;\n}", "label": 0, "cwe": null, "length": 33 }, { "index": 24123, "code": "dsvec_lines(Dsvec *dsv, char *buf)\n{\n char *e, *p;\n Dsvec *av;\n\n if (dsv == NULL)\n av = dsvec_init(NULL, sizeof(char *));\n else\n av = dsv;\n\n p = buf;\n while ((e = strchr(p, (int) '\\n')) != NULL) {\n\t*e++ = '\\0';\n\tdsvec_add_ptr(av, p);\n\tp = e;\n }\n\n if (*p != '\\0')\n\tdsvec_add_ptr(av, p);\n\n return(av);\n}", "label": 0, "cwe": null, "length": 124 }, { "index": 7796, "code": "is_primary_selection(ED4_terminal *object )\n{\n ED4_list_elem *tmp_elem;\n ED4_selection_entry *tmp_entry;\n\n tmp_elem = ( ED4_list_elem *) selected_objects.last();\n if (!tmp_elem) return 0;\n\n tmp_entry = ( ED4_selection_entry *) tmp_elem->elem();\n return (tmp_entry != NULL) && (tmp_entry->object == object);\n}", "label": 0, "cwe": null, "length": 89 }, { "index": 85538, "code": "gl_bits_glPushAttrib(int value) {\n tack_t bits = {0};\n if (bit(value, 0x000FFFFF)) {\n return strdup(\"GL_ALL_ATTRIB_BITS\");\n }\n bit_push(0x00000001, \"GL_CURRENT_BIT\");\n bit_push(0x00000002, \"GL_POINT_BIT\");\n bit_push(0x00000004, \"GL_LINE_BIT\");\n bit_push(0x00000008, \"GL_POLYGON_BIT\");\n bit_push(0x00000010, \"GL_POLYGON_STIPPLE_BIT\");\n bit_push(0x00000020, \"GL_PIXEL_MODE_BIT\");\n bit_push(0x00000040, \"GL_LIGHTING_BIT\");\n bit_push(0x00000080, \"GL_FOG_BIT\");\n bit_push(0x00000100, \"GL_DEPTH_BUFFER_BIT\");\n bit_push(0x00000200, \"GL_ACCUM_BUFFER_BIT\");\n bit_push(0x00000400, \"GL_STENCIL_BUFFER_BIT\");\n bit_push(0x00000800, \"GL_VIEWPORT_BIT\");\n bit_push(0x00001000, \"GL_TRANSFORM_BIT\");\n bit_push(0x00002000, \"GL_ENABLE_BIT\");\n bit_push(0x00004000, \"GL_COLOR_BUFFER_BIT\");\n bit_push(0x00008000, \"GL_HINT_BIT\");\n bit_push(0x00010000, \"GL_EVAL_BIT\");\n bit_push(0x00020000, \"GL_LIST_BIT\");\n bit_push(0x00040000, \"GL_TEXTURE_BIT\");\n bit_push(0x00080000, \"GL_SCISSOR_BIT\");\n return finish(&bits);\n}", "label": 0, "cwe": null, "length": 367 }, { "index": 123532, "code": "iter_len(seqiterobject *it)\n{\n Py_ssize_t seqsize, len;\n\n if (it->it_seq) {\n seqsize = PySequence_Size(it->it_seq);\n if (seqsize == -1)\n return NULL;\n len = seqsize - it->it_index;\n if (len >= 0)\n return PyLong_FromSsize_t(len);\n }\n return PyLong_FromLong(0);\n}", "label": 0, "cwe": null, "length": 95 }, { "index": 415601, "code": "float32_to_float64(float32 a, float_status_t &status)\n{\n Bit32u aSig = extractFloat32Frac(a);\n Bit16s aExp = extractFloat32Exp(a);\n int aSign = extractFloat32Sign(a);\n\n if (aExp == 0xFF) {\n if (aSig) return commonNaNToFloat64(float32ToCommonNaN(a, status));\n return packFloat64(aSign, 0x7FF, 0);\n }\n if (aExp == 0) {\n if (aSig == 0) return packFloat64(aSign, 0, 0);\n float_raise(status, float_flag_denormal);\n normalizeFloat32Subnormal(aSig, &aExp, &aSig);\n --aExp;\n }\n return packFloat64(aSign, aExp + 0x380, ((Bit64u) aSig)<<29);\n}", "label": 0, "cwe": null, "length": 200 }, { "index": 7207, "code": "parse_rle_data_pseudocolor(TGAContext *ctx)\n{\n\tguint rle_num, raw_num;\n\tguchar *s, tag;\n\tguint n;\n\n\tg_return_val_if_fail(ctx->in->size > 0, 0);\n\ts = ctx->in->data;\n\n\tfor (n = 0; n < ctx->in->size; ) {\n\t\ttag = *s;\n\t\ts++, n++;\n\t\tif (tag & 0x80) {\n\t\t\tif (n == ctx->in->size) {\n\t\t\t\treturn --n;\n\t\t\t} else {\n\t\t\t\trle_num = (tag & 0x7f) + 1;\n\t\t\t\twrite_rle_data(ctx, &ctx->cmap->cols[*s], &rle_num);\n\t\t\t\ts++, n++;\n\t\t\t\tif (ctx->pbuf_bytes_done == ctx->pbuf_bytes) {\n\t\t\t\t\tctx->done = TRUE;\n\t\t\t\t\treturn n;\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\traw_num = tag + 1;\n\t\t\tif (n + raw_num >= ctx->in->size) {\n\t\t\t\treturn --n;\n\t\t\t} else {\n\t\t\t\tfor (; raw_num; raw_num--) {\n\t\t\t\t\t*ctx->pptr++ =\n\t\t\t\t\t\tctx->cmap->cols[*s].r;\n\t\t\t\t\t*ctx->pptr++ =\n\t\t\t\t\t\tctx->cmap->cols[*s].g;\n\t\t\t\t\t*ctx->pptr++ =\n\t\t\t\t\t\tctx->cmap->cols[*s].b;\n\t\t\t\t\tif (ctx->pbuf->n_channels == 4)\n\t\t\t\t\t\t*ctx->pptr++ = ctx->cmap->cols[*s].a;\n\t\t\t\t\ts++, n++;\n\t\t\t\t\tctx->pbuf_bytes_done += ctx->pbuf->n_channels;\n\t\t\t\t\tif (ctx->pbuf_bytes_done == ctx->pbuf_bytes) {\n\t\t\t\t\t\tctx->done = TRUE;\n\t\t\t\t\t\treturn n;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (ctx->pbuf_bytes_done == ctx->pbuf_bytes) \n\t\tctx->done = TRUE;\n\t\n\treturn n;\n}", "label": 0, "cwe": null, "length": 438 }, { "index": 430721, "code": "clicked_eject_button (NemoPlacesSidebar *sidebar,\n\t\t GtkTreePath **path)\n{\n\tGdkEvent *event = gtk_get_current_event ();\n\tGdkEventButton *button_event = (GdkEventButton *) event;\n\n\tif ((event->type == GDK_BUTTON_PRESS || event->type == GDK_BUTTON_RELEASE) &&\n\t over_eject_button (sidebar, button_event->x, button_event->y, path)) {\n\t\treturn TRUE;\n\t}\n\n\treturn FALSE;\n}", "label": 0, "cwe": null, "length": 98 }, { "index": 365319, "code": "command_toc (int unitnum, struct cd_toc_head *th)\n{\n\tstruct cdunit *cdu = unitisopen (unitnum);\n\tif (!cdu)\n\t\treturn 0;\n\n\tint i;\n\n\tmemset (&cdu->di.toc, 0, sizeof (struct cd_toc_head));\n\tif (!cdu->tracks)\n\t\treturn 0;\n\n\tmemset (th, 0, sizeof (struct cd_toc_head));\n\tstruct cd_toc *toc = &th->toc[0];\n\tth->first_track = 1;\n\tth->last_track = cdu->tracks;\n\tth->points = cdu->tracks + 3;\n\tth->tracks = cdu->tracks;\n\tth->firstaddress = 0;\n\tth->lastaddress = cdu->toc[cdu->tracks].address;\n\n\ttoc->adr = 1;\n\ttoc->point = 0xa0;\n\ttoc->track = th->first_track;\n\ttoc++;\n\n\tth->first_track_offset = 1;\n\tfor (i = 0; i < cdu->tracks; i++) {\n\t\ttoc->adr = cdu->toc[i].adr;\n\t\ttoc->control = cdu->toc[i].ctrl;\n\t\ttoc->track = i + 1;\n\t\ttoc->point = i + 1;\n\t\ttoc->paddress = cdu->toc[i].address;\n\t\ttoc++;\n\t}\n\n\tth->last_track_offset = cdu->tracks;\n\ttoc->adr = 1;\n\ttoc->point = 0xa1;\n\ttoc->track = th->last_track;\n\ttoc++;\n\n\ttoc->adr = 1;\n\ttoc->point = 0xa2;\n\ttoc->paddress = th->lastaddress;\n\ttoc++;\n\n\tmemcpy (&cdu->di.toc, th, sizeof (struct cd_toc_head));\n\treturn 1;\n}", "label": 0, "cwe": null, "length": 395 }, { "index": 201644, "code": "snd_trident_spdif_pointer(struct snd_pcm_substream *substream)\n{\n\tstruct snd_trident *trident = snd_pcm_substream_chip(substream);\n\tstruct snd_pcm_runtime *runtime = substream->runtime;\n\tstruct snd_trident_voice *voice = runtime->private_data;\n\tunsigned int result;\n\n\tif (!voice->running)\n\t\treturn 0;\n\n\tresult = inl(TRID_REG(trident, NX_SPCTRL_SPCSO)) & 0x00ffffff;\n\n\treturn result;\n}", "label": 0, "cwe": null, "length": 101 }, { "index": 172432, "code": "dbg_path_get_basename (const char *filename)\n{\n\tchar *r;\n\n\tif (!filename || strchr (filename, '/') || !strchr (filename, '\\\\'))\n\t\treturn g_path_get_basename (filename);\n\n\t/* From gpath.c */\n\n\t/* No separator -> filename */\n\tr = strrchr (filename, '\\\\');\n\tif (r == NULL)\n\t\treturn g_strdup (filename);\n\n\t/* Trailing slash, remove component */\n\tif (r [1] == 0){\n\t\tchar *copy = g_strdup (filename);\n\t\tcopy [r-filename] = 0;\n\t\tr = strrchr (copy, '\\\\');\n\n\t\tif (r == NULL){\n\t\t\tg_free (copy);\n\t\t\treturn g_strdup (\"/\");\n\t\t}\n\t\tr = g_strdup (&r[1]);\n\t\tg_free (copy);\n\t\treturn r;\n\t}\n\n\treturn g_strdup (&r[1]);\n}", "label": 0, "cwe": null, "length": 182 }, { "index": 795553, "code": "cardvcc_read(const struct lanai_vcc *lvcc,\n\tenum lanai_vcc_offset offset)\n{\n\tu32 val;\n\tAPRINTK(lvcc->vbase != NULL, \"cardvcc_read: unbound vcc!\\n\");\n\tval= readl(lvcc->vbase + offset);\n\tRWDEBUG(\"VR vci=%04d 0x%02X = 0x%08X\\n\",\n\t lvcc->vci, (int) offset, val);\n\treturn val;\n}", "label": 0, "cwe": null, "length": 111 }, { "index": 62626, "code": "cpufreq_monitor_set_property (GObject *object,\n guint prop_id,\n const GValue *value,\n GParamSpec *spec)\n{\n CPUFreqMonitor *monitor;\n\n monitor = CPUFREQ_MONITOR (object);\n\n switch (prop_id) {\n case PROP_CPU: {\n guint cpu = g_value_get_uint (value);\n\n if (cpu != monitor->priv->cpu) {\n monitor->priv->cpu = cpu;\n monitor->priv->changed = TRUE;\n }\n }\n break;\n case PROP_ONLINE:\n monitor->priv->online = g_value_get_boolean (value);\n\n break;\n case PROP_FREQUENCY: {\n gint freq = g_value_get_int (value);\n\n if (freq != monitor->priv->cur_freq) {\n monitor->priv->cur_freq = freq;\n monitor->priv->changed = TRUE;\n }\n }\n break;\n case PROP_MAX_FREQUENCY: {\n gint freq = g_value_get_int (value);\n\n if (freq != monitor->priv->max_freq) {\n monitor->priv->max_freq = freq;\n monitor->priv->changed = TRUE;\n }\n }\n break;\n case PROP_GOVERNOR: {\n const gchar *gov = g_value_get_string (value);\n\n if (monitor->priv->governor) {\n if (g_ascii_strcasecmp (gov, monitor->priv->governor) != 0) {\n g_free (monitor->priv->governor);\n monitor->priv->governor = gov ? g_strdup (gov) : NULL;\n monitor->priv->changed = TRUE;\n }\n } else {\n monitor->priv->governor = gov ? g_strdup (gov) : NULL;\n monitor->priv->changed = TRUE;\n }\n }\n break;\n default:\n G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, spec);\n break;\n }\n}", "label": 0, "cwe": null, "length": 410 }, { "index": 93942, "code": "PyvtkFunctionParser_GetVectorVariableValue_s1(PyObject *self, PyObject *args)\n{\n vtkPythonArgs ap(self, args, \"GetVectorVariableValue\");\n vtkObjectBase *vp = ap.GetSelfPointer(self, args);\n vtkFunctionParser *op = static_cast(vp);\n\n char *temp0 = NULL;\n int sizer = 3;\n PyObject *result = NULL;\n\n if (op && ap.CheckArgCount(1) &&\n ap.GetValue(temp0))\n {\n double *tempr = (ap.IsBound() ?\n op->GetVectorVariableValue(temp0) :\n op->vtkFunctionParser::GetVectorVariableValue(temp0));\n\n if (!ap.ErrorOccurred())\n {\n result = ap.BuildTuple(tempr, sizer);\n }\n }\n\n return result;\n}", "label": 0, "cwe": null, "length": 178 }, { "index": 260533, "code": "adis16136_show_product_id(void *arg, u64 *val)\n{\n\tstruct adis16136 *adis16136 = arg;\n\tu16 prod_id;\n\tint ret;\n\n\tret = adis_read_reg_16(&adis16136->adis, ADIS16136_REG_PROD_ID,\n\t\t&prod_id);\n\tif (ret < 0)\n\t\treturn ret;\n\n\t*val = prod_id;\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 93 }, { "index": 318763, "code": "xmlConnect2(CIMCEnv *env, const char *hn, const char *scheme, const char *port,\n\t\t\t const char *user, const char *pwd, \n\t\t\t int verifyMode, const char * trustStore,\n\t\t\t const char * certFile, const char * keyFile,\n\t\t\t CIMCStatus *rc)\n{ \n ClientEnc *cc = (ClientEnc*)calloc(1, sizeof(ClientEnc));\n\n cc->enc.hdl\t\t= &cc->data;\n cc->enc.ft\t\t= &clientFt;\n\n cc->data.hostName\t= hn ? strdup(hn) : strdup(\"localhost\");\n cc->data.user\t= user ? strdup(user) : NULL;\n cc->data.pwd\t\t= pwd ? strdup(pwd) : NULL;\n cc->data.scheme\t= scheme ? strdup(scheme) : strdup(\"http\");\n\n if (port != NULL)\n cc->data.port = strdup(port);\n else\n cc->data.port = strcmp(cc->data.scheme, \"https\") == 0 ? \n\tstrdup(\"5989\") : strdup(\"5988\");\n\n cc->certData.verifyMode = verifyMode;\n cc->certData.trustStore = trustStore ? strdup(trustStore) : NULL;\n cc->certData.certFile = certFile ? strdup(certFile) : NULL;\n cc->certData.keyFile = keyFile ? strdup(keyFile) : NULL;\n \n cc->connection=initConnection(&cc->data);\n\n /* set SSL options */\n if (cc->connection) {\n curl_easy_setopt(cc->connection->mHandle,CURLOPT_SSL_VERIFYPEER,\n\t\t verifyMode == CMCI_VERIFY_PEER ? 1 : 0);\n if (trustStore)\n curl_easy_setopt(cc->connection->mHandle,CURLOPT_CAINFO,trustStore);\n if (certFile)\n curl_easy_setopt(cc->connection->mHandle,CURLOPT_SSLCERT,certFile);\n if (keyFile)\n curl_easy_setopt(cc->connection->mHandle,CURLOPT_SSLKEY,keyFile); \n }\n \n CMSetStatus(rc, CIMC_RC_OK);\n return (CIMCClient*)cc;\n}", "label": 0, "cwe": null, "length": 460 }, { "index": 275278, "code": "size_too_large(krb5_storage *sp, size_t size)\n{\n if (sp->max_alloc && sp->max_alloc < size)\n\treturn HEIM_ERR_TOO_BIG;\n return 0;\n}", "label": 0, "cwe": null, "length": 45 }, { "index": 545632, "code": "ListToPacked(\n struct expr *original,\n struct expr *destination,\n long count)\n {\n long i;\n\n if (original == NULL) { return(count); }\n\n while (original != NULL)\n {\n i = count;\n count++;\n\n destination[i].type = original->type;\n destination[i].value = original->value;\n\n if (original->argList == NULL)\n { destination[i].argList = NULL; }\n else\n {\n destination[i].argList =\n (struct expr *) &destination[(long) count];\n count = ListToPacked(original->argList,destination,count);\n }\n\n if (original->nextArg == NULL)\n { destination[i].nextArg = NULL; }\n else\n {\n destination[i].nextArg =\n (struct expr *) &destination[(long) count];\n }\n\n original = original->nextArg;\n }\n\n return(count);\n }", "label": 0, "cwe": null, "length": 202 }, { "index": 35551, "code": "DrawLine (PCell B,int Line,int Col,ChColor color,int Width) {\n if (LineMsg)) {\n char str[1024];\n\t size_t len = UnTabStr(str,sizeof(str), Lines[Line]->Msg,\n\t\t\t\t strlen(Lines[Line]->Msg));\n if ((int)len > Col) MoveStr (B,0,Width,str+Col,color,Width);\n }\n}", "label": 0, "cwe": null, "length": 104 }, { "index": 972761, "code": "compress_savefile(const char *filename)\n{\n\tif (fork())\n\t\treturn;\n\t/*\n\t * Set to lowest priority so that this doesn't disturb the capture\n\t */\n#ifdef NZERO\n\tsetpriority(PRIO_PROCESS, 0, NZERO - 1);\n#else\n\tsetpriority(PRIO_PROCESS, 0, 19);\n#endif\n\tif (execlp(zflag, zflag, filename, (char *)NULL) == -1)\n\t\tfprintf(stderr,\n\t\t\t\"compress_savefile:execlp(%s, %s): %s\\n\",\n\t\t\tzflag,\n\t\t\tfilename,\n\t\t\tstrerror(errno));\n}", "label": 0, "cwe": null, "length": 130 }, { "index": 420605, "code": "gageKindTotalAnswerLength(const gageKind *kind) {\n static const char me[]=\"gageKindTotalAnswerLength\";\n char *err;\n unsigned int alen;\n int ii;\n\n if (gageKindCheck(kind)) {\n err = biffGetDone(GAGE);\n fprintf(stderr, \"%s: PANIC:\\n %s\", me, err);\n free(err); exit(1);\n }\n alen = 0;\n for (ii=1; ii<=kind->itemMax; ii++) {\n alen += (0 == kind->table[ii].parentItem\n ? kind->table[ii].answerLength\n : 0);\n }\n return alen;\n}", "label": 0, "cwe": null, "length": 151 }, { "index": 706319, "code": "realtime_sqlite3_update2(const char *database, const char *table, va_list ap)\n{\n\tstruct ast_str *sql;\n\tstruct ast_str *where_clause;\n\tconst char *key, *value;\n\tint first = 1, res;\n\n\tif (ast_strlen_zero(table)) {\n\t\tast_log(LOG_WARNING, \"Must have a table to query!\\n\");\n\t\treturn -1;\n\t}\n\n\tif (!(sql = ast_str_create(128))) {\n\t\treturn -1;\n\t}\n\n\tif (!(where_clause = ast_str_create(128))) {\n\t\tast_free(sql);\n\t\treturn -1;\n\t}\n\n\twhile ((key = va_arg(ap, const char *)) && (value = va_arg(ap, const char *))) {\n\t\tif (first) {\n\t\t\tast_str_set(&where_clause, 0, \" WHERE %s %s\", sqlite3_escape_column_op(key), sqlite3_escape_value(value));\n\t\t\tfirst = 0;\n\t\t} else {\n\t\t\tast_str_append(&where_clause, 0, \" AND %s %s\", sqlite3_escape_column_op(key), sqlite3_escape_value(value));\n\t\t}\n\t}\n\n\tfirst = 1;\n\twhile ((key = va_arg(ap, const char *)) && (value = va_arg(ap, const char *))) {\n\t\tif (first) {\n\t\t\tast_str_set(&sql, 0, \"UPDATE %s SET %s = %s\", sqlite3_escape_table(table), sqlite3_escape_column(key), sqlite3_escape_value(value));\n\t\t\tfirst = 0;\n\t\t} else {\n\t\t\tast_str_append(&sql, 0, \", %s = %s\", sqlite3_escape_column(key), sqlite3_escape_value(value));\n\t\t}\n\t}\n\n\tast_str_append(&sql, 0, \"%s\", ast_str_buffer(where_clause));\n\n\tres = realtime_sqlite3_execute(database, ast_str_buffer(sql), NULL, NULL, 1);\n\n\tast_free(sql);\n\tast_free(where_clause);\n\n\treturn res;\n}", "label": 0, "cwe": null, "length": 404 }, { "index": 531371, "code": "checkLastAllocator(size_t size) {\r\n#ifdef LOG_POOL_ALLOCATOR_MEMORY_USAGE\r\n\t\tlast_access++;\r\n#endif\r\n\t\tif(last_allocate_allocator && last_allocate_allocator->objectSize()==size) {\r\n#ifdef LOG_POOL_ALLOCATOR_MEMORY_USAGE\r\n\t\t\tlast_ok++;\r\n#endif\r\n\t\t\treturn last_allocate_allocator;\r\n\t\t}\r\n\t\telse if(last_free_allocator && last_free_allocator->objectSize()==size) {\r\n#ifdef LOG_POOL_ALLOCATOR_MEMORY_USAGE\r\n\t\t\tlast_ok++;\r\n#endif\r\n\t\t\treturn last_free_allocator;\r\n\t\t} else\r\n\t\t\treturn 0;\r\n\t}", "label": 0, "cwe": null, "length": 111 }, { "index": 583591, "code": "scif_p2p_setsg(phys_addr_t pa, int page_size, int page_cnt)\n{\n\tstruct scatterlist *sg;\n\tstruct page *page;\n\tint i;\n\n\tsg = kcalloc(page_cnt, sizeof(struct scatterlist), GFP_KERNEL);\n\tif (!sg)\n\t\treturn NULL;\n\tsg_init_table(sg, page_cnt);\n\tfor (i = 0; i < page_cnt; i++) {\n\t\tpage = pfn_to_page(pa >> PAGE_SHIFT);\n\t\tsg_set_page(&sg[i], page, page_size, 0);\n\t\tpa += page_size;\n\t}\n\treturn sg;\n}", "label": 0, "cwe": null, "length": 128 }, { "index": 34529, "code": "decide_line (int hpos)\n{\n\t/* Take care of the vertical DIW. */\n\tif (vpos == plffirstline) {\n\t\tdiwstate = DIW_waiting_stop;\n\t\tddf_change = vpos;\n\t}\n\tif (vpos == plflastline) {\n\t\tdiwstate = DIW_waiting_start;\n\t\tddf_change = vpos;\n\t}\n\n\tif (hpos <= last_decide_line_hpos)\n\t\treturn;\n\n\tif (fetch_state == fetch_not_started && (diwstate == DIW_waiting_stop || (currprefs.chipset_mask & CSMASK_ECS_AGNUS))) {\n\t\tint ok = 0;\n\t\tif (last_decide_line_hpos < plfstrt_start && hpos >= plfstrt_start) {\n\t\t\tif (plf_state == plf_idle)\n\t\t\t\tplf_state = plf_start;\n\t\t}\n\t\tif (last_decide_line_hpos < plfstrt && hpos >= plfstrt) {\n\t\t\tif (plf_state == plf_start)\n\t\t\t\tplf_state = plf_active;\n\t\t\tif (plf_state == plf_active)\n\t\t\t\tok = 1;\n\t\t\t/* hack warning.. Writing to DDFSTRT when DMA should start must be ignored\n\t\t\t* (correct fix would be emulate this delay for every custom register, but why bother..) */\n\t\t\tif (hpos - 2 == ddfstrt_old_hpos)\n\t\t\t\tok = 0;\n\t\t}\n\t\tif (ok && diwstate == DIW_waiting_stop) {\n\t\t\tif (dmaen (DMA_BITPLANE)) {\n\t\t\t\tstart_bpl_dma (hpos, plfstrt);\n\t\t\t\testimate_last_fetch_cycle (plfstrt);\n\t\t\t}\n\t\t\tlast_decide_line_hpos = hpos;\n#ifndef\tCUSTOM_SIMPLE\n\t\t\tdo_sprites (hpos);\n#endif\n\t\t\treturn;\n\t\t}\n\t}\n\n#ifndef\tCUSTOM_SIMPLE\n\tif (hpos > last_sprite_hpos && last_sprite_hpos < SPR0_HPOS + 4 * MAX_SPRITES)\n\t\tdo_sprites (hpos);\n#endif\n\n\tlast_decide_line_hpos = hpos;\n}", "label": 0, "cwe": null, "length": 455 }, { "index": 628974, "code": "_bdf_memmove(char *dest, char *src, unsigned long bytes)\n{\n long i, j;\n\n i = (long) bytes;\n j = i & 7;\n i = (i + 7) >> 3;\n\n /*\n * Do a memmove using Ye Olde Duff's Device for efficiency.\n */\n if (src < dest) {\n src += bytes;\n dest += bytes;\n\n switch (j) {\n case 0: do {\n *--dest = *--src;\n case 7: *--dest = *--src;\n case 6: *--dest = *--src;\n case 5: *--dest = *--src;\n case 4: *--dest = *--src;\n case 3: *--dest = *--src;\n case 2: *--dest = *--src;\n case 1: *--dest = *--src;\n } while (--i > 0);\n }\n } else if (src > dest) {\n switch (j) {\n case 0: do {\n *dest++ = *src++;\n case 7: *dest++ = *src++;\n case 6: *dest++ = *src++;\n case 5: *dest++ = *src++;\n case 4: *dest++ = *src++;\n case 3: *dest++ = *src++;\n case 2: *dest++ = *src++;\n case 1: *dest++ = *src++;\n } while (--i > 0);\n }\n }\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-other" ], "length": 345 }, { "index": 253957, "code": "show_image_transform()\n{\n\tif (_imageTransform_exists) {\n\t\tint i;\n\t\tprintf(\"_imageTransform[0-255] is:\\n\");\n\t\tfor (i = 0; i < 256; i++) {\n\t\t\tprintf(\"im_tr[%d] = %d\\n\", i, _imageTransform[i]);\n\t\t}\n\t} else {\n\t\tprintf(\"_imageTransform[] NOT DEFINED YET\\n\");\n\t}\n}", "label": 0, "cwe": null, "length": 91 }, { "index": 78767, "code": "fop_unlink_stub (call_frame_t *frame,\n fop_unlink_t fn,\n loc_t *loc, int xflag, dict_t *xdata)\n{\n call_stub_t *stub = NULL;\n\n GF_VALIDATE_OR_GOTO (\"call-stub\", frame, out);\n GF_VALIDATE_OR_GOTO (\"call-stub\", loc, out);\n\n stub = stub_new (frame, 1, GF_FOP_UNLINK);\n GF_VALIDATE_OR_GOTO (\"call-stub\", stub, out);\n\n stub->args.unlink.fn = fn;\n loc_copy (&stub->args.unlink.loc, loc);\n stub->args.unlink.xflag = xflag;\n if (xdata)\n stub->xdata = dict_ref (xdata);\n\nout:\n return stub;\n}", "label": 0, "cwe": null, "length": 166 }, { "index": 362780, "code": "hfs_setxattr(struct dentry *dentry, const char *name,\n\t\t const void *value, size_t size, int flags)\n{\n\tstruct inode *inode = d_inode(dentry);\n\tstruct hfs_find_data fd;\n\thfs_cat_rec rec;\n\tstruct hfs_cat_file *file;\n\tint res;\n\n\tif (!S_ISREG(inode->i_mode) || HFS_IS_RSRC(inode))\n\t\treturn -EOPNOTSUPP;\n\n\tres = hfs_find_init(HFS_SB(inode->i_sb)->cat_tree, &fd);\n\tif (res)\n\t\treturn res;\n\tfd.search_key->cat = HFS_I(inode)->cat_key;\n\tres = hfs_brec_find(&fd);\n\tif (res)\n\t\tgoto out;\n\thfs_bnode_read(fd.bnode, &rec, fd.entryoffset,\n\t\t\tsizeof(struct hfs_cat_file));\n\tfile = &rec.file;\n\n\tif (!strcmp(name, \"hfs.type\")) {\n\t\tif (size == 4)\n\t\t\tmemcpy(&file->UsrWds.fdType, value, 4);\n\t\telse\n\t\t\tres = -ERANGE;\n\t} else if (!strcmp(name, \"hfs.creator\")) {\n\t\tif (size == 4)\n\t\t\tmemcpy(&file->UsrWds.fdCreator, value, 4);\n\t\telse\n\t\t\tres = -ERANGE;\n\t} else\n\t\tres = -EOPNOTSUPP;\n\tif (!res)\n\t\thfs_bnode_write(fd.bnode, &rec, fd.entryoffset,\n\t\t\t\tsizeof(struct hfs_cat_file));\nout:\n\thfs_find_exit(&fd);\n\treturn res;\n}", "label": 0, "cwe": null, "length": 334 }, { "index": 606209, "code": "on_anim_curve_changed(GtkWidget *widget, gpointer user_data) {\n /* The user just changed the current keyframe's spline, update the model\n */\n Explorer *self = EXPLORER(user_data);\n GtkTreeIter iter;\n Spline *spline;\n\n if (!self->allow_transition_changes)\n\treturn;\n\n explorer_get_current_keyframe(self, &iter);\n\n spline = curve_editor_get_spline(CURVE_EDITOR(self->anim_curve));\n gtk_list_store_set(self->animation->model, &iter,\n\t\t ANIMATION_MODEL_SPLINE, spline,\n\t\t -1);\n spline_free(spline);\n}", "label": 0, "cwe": null, "length": 133 }, { "index": 36656, "code": "mono_image_ensure_section_idx (MonoImage *image, int section)\n{\n\tMonoCLIImageInfo *iinfo = (MonoCLIImageInfo *)image->image_info;\n\tMonoSectionTable *sect;\n\t\n\tg_return_val_if_fail (section < iinfo->cli_section_count, FALSE);\n\n\tif (iinfo->cli_sections [section] != NULL)\n\t\treturn TRUE;\n\n\tsect = &iinfo->cli_section_tables [section];\n\t\n\tif (sect->st_raw_data_ptr + sect->st_raw_data_size > image->raw_data_len)\n\t\treturn FALSE;\n#ifdef HOST_WIN32\n\tif (image->is_module_handle)\n\t\tiinfo->cli_sections [section] = image->raw_data + sect->st_virtual_address;\n\telse\n#endif\n\t/* FIXME: we ignore the writable flag since we don't patch the binary */\n\tiinfo->cli_sections [section] = image->raw_data + sect->st_raw_data_ptr;\n\treturn TRUE;\n}", "label": 0, "cwe": null, "length": 197 }, { "index": 973479, "code": "L11()\n{register object *base=vs_base;\n\tregister object *sup=base+VM11; VC11\n\tvs_check;\n\t{object V27;\n\tV27=(base[0]);\n\tvs_top=sup;\n\tgoto TTL;\nTTL:;\n\tbase[1]= CMPcar((V27));\n\tvs_top=(vs_base=base+1)+1;\n\t(void) (*Lnk64)();\n\tvs_top=sup;\n\tV28= vs_base[0];\n\tbase[1]= ((CMPcar(V28))==(((object)VV[19]))?Ct:Cnil);\n\tvs_top=(vs_base=base+1)+1;\n\treturn;\n\t}\n}", "label": 0, "cwe": null, "length": 141 }, { "index": 875586, "code": "export_database (AlmanahExportOperation *self, GFile *destination, AlmanahExportProgressCallback progress_callback, gpointer progress_user_data,\n GCancellable *cancellable, GError **error)\n{\n\tGFile *source;\n\tgboolean success;\n\tgchar *destination_path;\n\n\t/* We ignore the progress callbacks, since this is a fairly fast operation, and it exports all the entries at once. */\n\n\t/* Get the input file (current unencrypted database) */\n\tsource = g_file_new_for_path (almanah_storage_manager_get_filename (self->priv->storage_manager, TRUE));\n\n\t/* Copy the current database to that location */\n\tsuccess = g_file_copy (source, destination, G_FILE_COPY_OVERWRITE, cancellable, NULL, NULL, error);\n\n\t/* Ensure the backup is only readable to the current user. */\n\tdestination_path = g_file_get_path (destination);\n\tif (success == TRUE && g_chmod (destination_path, 0600) != 0) {\n\t\tg_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,\n\t\t _(\"Error changing exported file permissions: %s\"),\n\t\t g_strerror (errno));\n\t\tsuccess = FALSE;\n\t}\n\n\tg_free (destination_path);\n\tg_object_unref (source);\n\n\treturn success;\n}", "label": 0, "cwe": null, "length": 260 }, { "index": 695156, "code": "buffer_add(buffer_t *b)\n{\n\tbuffer_data_t *d;\n\n\td = (buffer_data_t *) MALLOC(offsetof(buffer_data_t, data[b->size]));\n\td->cp = d->sp = 0;\n\td->next = NULL;\n\n\tif (b->tail)\n\t\tb->tail->next = d;\n\telse\n\t\tb->head = d;\n\tb->tail = d;\n\n\treturn d;\n}", "label": 0, "cwe": null, "length": 86 }, { "index": 41435, "code": "cz_get_eclk_level(struct pp_hwmgr *hwmgr,\n\t\t\t\t\tuint32_t clock, uint32_t msg)\n{\n\tint i = 0;\n\tstruct phm_vce_clock_voltage_dependency_table *ptable =\n\t\thwmgr->dyn_state.vce_clock_voltage_dependency_table;\n\n\tswitch (msg) {\n\tcase PPSMC_MSG_SetEclkSoftMin:\n\tcase PPSMC_MSG_SetEclkHardMin:\n\t\tfor (i = 0; i < (int)ptable->count; i++) {\n\t\t\tif (clock <= ptable->entries[i].ecclk)\n\t\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\n\tcase PPSMC_MSG_SetEclkSoftMax:\n\tcase PPSMC_MSG_SetEclkHardMax:\n\t\tfor (i = ptable->count - 1; i >= 0; i--) {\n\t\t\tif (clock >= ptable->entries[i].ecclk)\n\t\t\t\tbreak;\n\t\t}\n\t\tbreak;\n\n\tdefault:\n\t\tbreak;\n\t}\n\n\treturn i;\n}", "label": 0, "cwe": null, "length": 209 }, { "index": 279574, "code": "IsLegacyChanged()\n{\n\n\tif ( ! this->changed ) return false;\n\tif ( this->legacyDeleted ) return true;\n\n\tInternalRsrcMap::iterator irPos = this->imgRsrcs.begin();\n\tInternalRsrcMap::iterator irEnd = this->imgRsrcs.end();\n\n\tfor ( ; irPos != irEnd; ++irPos ) {\n\t\tconst InternalRsrcInfo & rsrcInfo = irPos->second;\n\t\tif ( rsrcInfo.changed && (rsrcInfo.id != kPSIR_XMP) ) return true;\n\t}\n\n\treturn false;\t// Can get here if the XMP is the only thing changed.\n\n}", "label": 0, "cwe": null, "length": 137 }, { "index": 322414, "code": "KeyEquiv (Event& e) {\n boolean keyEquiv = false;\n\n if (e.eventType == KeyEvent && e.len > 0) {\n char c = e.keystring[0];\n\n if (c == '\\r' || c == '\\004' || c == '\\007' || c == '\\033') {\n state->SetValue(c);\n keyEquiv = true;\n }\n }\n return keyEquiv;\n}", "label": 0, "cwe": null, "length": 95 }, { "index": 522986, "code": "repaint(Priority p)\n{\n if (m_view && !m_staticMode) {\n if (p == RealtimePriority) {\n //m_view->resizeContents(docWidth(), docHeight());\n m_view->unscheduleRepaint();\n if (needsLayout()) {\n m_view->scheduleRelayout();\n return;\n }\n\t // ### same as in repaintRectangle\n m_view->updateContents(m_view->contentsX(), m_view->contentsY(),\n m_view->visibleWidth(), m_view->visibleHeight());\n }\n else if (p == HighPriority)\n m_view->scheduleRepaint(m_view->contentsX(), m_view->contentsY(),\n m_view->visibleWidth(), m_view->visibleHeight(), true /*asap*/);\n else\n m_view->scheduleRepaint(m_view->contentsX(), m_view->contentsY(),\n m_view->visibleWidth(), m_view->visibleHeight());\n }\n}", "label": 0, "cwe": null, "length": 199 }, { "index": 66921, "code": "cmpByKey(GBDATA *gbd1, GBDATA *gbd2, const char *field) {\n GBDATA *gb_field1 = GB_entry(gbd1, field);\n GBDATA *gb_field2 = GB_entry(gbd2, field);\n\n int cmp;\n if (gb_field1) {\n if (gb_field2) {\n switch (GB_read_type(gb_field1)) {\n case GB_STRING: {\n const char *s1 = GB_read_char_pntr(gb_field1);\n const char *s2 = GB_read_char_pntr(gb_field2);\n\n cmp = strcmp(s1, s2);\n break;\n }\n case GB_FLOAT: {\n double d1 = GB_read_float(gb_field1);\n double d2 = GB_read_float(gb_field2);\n\n cmp = d1d2 ? 1 : 0);\n break;\n }\n case GB_INT: {\n int i1 = GB_read_int(gb_field1);\n int i2 = GB_read_int(gb_field2);\n\n cmp = i1-i2;\n break;\n }\n default:\n cmp = 0; // other field type -> no idea how to compare\n break;\n }\n }\n else cmp = -1; // existing < missing!\n }\n else cmp = gb_field2 ? 1 : 0;\n\n return cmp;\n}", "label": 0, "cwe": null, "length": 314 }, { "index": 739435, "code": "setDragProperty(\n XDisplay* display, XEvent& xevent, XWindow destination,\n Atom messageType, int x, int y, const char* value = 0,\n int length = 0\n) {\n Atom property = None;\n if (length != 0) {\n\tchar buffer[256];\n\tstd::ostrstream name(buffer, 256);\n\tname << dragName << \"_\" << Host::name() << \"_\" << getpid() << \"_\" <<\n\t dropUid++ << '\\0';\n\tproperty = XInternAtom(display, name.str(), False);\n\n\tXChangeProperty(\n\t display, destination, property, XA_STRING, 8,\n\t PropModePrepend, \n\t (unsigned char*)value + (length<0 ? length : 0), \n\t Math::abs(length)\n\t);\n }\n\n xevent.xclient.type = ClientMessage;\n xevent.xclient.window = destination;\n xevent.xclient.display = display;\n xevent.xclient.message_type = messageType;\n xevent.xclient.format = 32;\n\n xevent.xclient.data.l[0] = x;\n xevent.xclient.data.l[1] = y;\n\n xevent.xclient.data.l[2] = destination;\n xevent.xclient.data.l[3] = property;\n xevent.xclient.data.l[4] = length;\n}", "label": 0, "cwe": null, "length": 286 }, { "index": 215317, "code": "kpagecgroup_read(struct file *file, char __user *buf,\n\t\t\t\tsize_t count, loff_t *ppos)\n{\n\tu64 __user *out = (u64 __user *)buf;\n\tstruct page *ppage;\n\tunsigned long src = *ppos;\n\tunsigned long pfn;\n\tssize_t ret = 0;\n\tu64 ino;\n\n\tpfn = src / KPMSIZE;\n\tcount = min_t(unsigned long, count, (max_pfn * KPMSIZE) - src);\n\tif (src & KPMMASK || count & KPMMASK)\n\t\treturn -EINVAL;\n\n\twhile (count > 0) {\n\t\tif (pfn_valid(pfn))\n\t\t\tppage = pfn_to_page(pfn);\n\t\telse\n\t\t\tppage = NULL;\n\n\t\tif (ppage)\n\t\t\tino = page_cgroup_ino(ppage);\n\t\telse\n\t\t\tino = 0;\n\n\t\tif (put_user(ino, out)) {\n\t\t\tret = -EFAULT;\n\t\t\tbreak;\n\t\t}\n\n\t\tpfn++;\n\t\tout++;\n\t\tcount -= KPMSIZE;\n\n\t\tcond_resched();\n\t}\n\n\t*ppos += (char __user *)out - buf;\n\tif (!ret)\n\t\tret = (char __user *)out - buf;\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 270 }, { "index": 367130, "code": "PSUBUSW_PqQq(bxInstruction_c *i)\n{\n#if BX_SUPPORT_MMX\n BX_CPU_THIS_PTR prepareMMX();\n\n BxPackedMmxRegister op1 = BX_READ_MMX_REG(i->nnn()), op2, result;\n\n /* op2 is a register or memory reference */\n if (i->modC0()) {\n op2 = BX_READ_MMX_REG(i->rm());\n }\n else {\n bx_address eaddr = BX_CPU_CALL_METHODR(i->ResolveModrm, (i));\n /* pointer, segment address pair */\n MMXUQ(op2) = read_virtual_qword(i->seg(), eaddr);\n }\n\n BX_CPU_THIS_PTR prepareFPU2MMX(); /* FPU2MMX transition */\n\n MMXUQ(result) = 0;\n\n if(MMXUW0(op1) > MMXUW0(op2)) MMXUW0(result) = MMXUW0(op1) - MMXUW0(op2);\n if(MMXUW1(op1) > MMXUW1(op2)) MMXUW1(result) = MMXUW1(op1) - MMXUW1(op2);\n if(MMXUW2(op1) > MMXUW2(op2)) MMXUW2(result) = MMXUW2(op1) - MMXUW2(op2);\n if(MMXUW3(op1) > MMXUW3(op2)) MMXUW3(result) = MMXUW3(op1) - MMXUW3(op2);\n\n /* now write result back to destination */\n BX_WRITE_MMX_REG(i->nnn(), result);\n#else\n BX_INFO((\"PSUBUSW_PqQq: required MMX, use --enable-mmx option\"));\n exception(BX_UD_EXCEPTION, 0, 0);\n#endif\n}", "label": 0, "cwe": null, "length": 418 }, { "index": 439731, "code": "get_conversion_factor( void )\n{\n double sc = 1.0;\n\n if ( fdopt.unit == FL_COORD_POINT )\n sc = 72.00 / fli_dpi;\n else if ( fdopt.unit == FL_COORD_MM )\n sc = 25.40 / fli_dpi;\n else if ( fdopt.unit == FL_COORD_centiPOINT )\n sc = 7200.00 / fli_dpi;\n else if ( fdopt.unit == FL_COORD_centiMM )\n sc = 2540.00 / fli_dpi;\n\n return sc;\n}", "label": 0, "cwe": null, "length": 127 }, { "index": 479180, "code": "draw_sprites(struct mame_bitmap *bitmap,const struct rectangle *cliprect)\r\n{\r\n\tint offs;\r\n\r\n\r\n\tfor (offs = 0; offs < spriteram_size; offs += 2)\r\n\t{\r\n\t\tint code, sx, sy, color, flipx, flipy;\r\n\r\n\r\n\t\tcode = ((spriteram_3[offs] & 0xfc) >> 2) + ((spriteram_2[offs] & 0x01) << 6)\r\n\t\t\t\t+ ((offs & 0x20) << 2);\r\n\r\n\t\tsx = spriteram_3[offs + 1];\r\n\t\tsy = spriteram[offs];\r\n\t\tcolor = spriteram[offs + 1] & 0x3f;\r\n\t\tflipx = spriteram_3[offs] & 0x02;\r\n\t\tflipy = spriteram_3[offs] & 0x01;\r\n\r\n\t\tif (flip_screen)\r\n\t\t{\r\n\t\t\tflipx = !flipx;\r\n\t\t\tflipy = !flipy;\r\n\t\t}\r\n\r\n\t\tif (spriteram_2[offs] & 0x08)\t/* double width */\r\n\t\t{\r\n\t\t\tif (!flip_screen)\r\n\t\t\t\tsy = 224 - sy;\r\n\r\n\t\t\tdrawgfx(bitmap,Machine->gfx[2],\r\n\t\t\t\t\tcode/2,\r\n\t\t\t\t\tcolor,\r\n\t\t\t\t\tflipx,flipy,\r\n\t\t\t\t\tsx,sy,\r\n\t\t\t\t\tcliprect,TRANSPARENCY_PEN,0);\r\n\t\t\t/* redraw with wraparound */\r\n\t\t\tdrawgfx(bitmap,Machine->gfx[2],\r\n\t\t\t\t\tcode/2,\r\n\t\t\t\t\tcolor,\r\n\t\t\t\t\tflipx,flipy,\r\n\t\t\t\t\tsx,sy+256,\r\n\t\t\t\t\tcliprect,TRANSPARENCY_PEN,0);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\tif (!flip_screen)\r\n\t\t\t\tsy = 240 - sy;\r\n\r\n\t\t\tdrawgfx(bitmap,Machine->gfx[1],\r\n\t\t\t\t\tcode,\r\n\t\t\t\t\tcolor,\r\n\t\t\t\t\tflipx,flipy,\r\n\t\t\t\t\tsx,sy,\r\n\t\t\t\t\tcliprect,TRANSPARENCY_PEN,0);\r\n\t\t}\r\n\t}\r\n}", "label": 0, "cwe": null, "length": 444 }, { "index": 549135, "code": "videotestsrc_blend_line (GstVideoTestSrc * v, guint8 * dest, guint8 * src,\n struct vts_color_struct *a, struct vts_color_struct *b, int n)\n{\n int i;\n if (v->fourcc->type == VTS_RGB || v->fourcc->type == VTS_BAYER) {\n for (i = 0; i < n; i++) {\n dest[i * 4 + 0] = BLEND (a->A, b->A, src[i]);\n dest[i * 4 + 1] = BLEND (a->R, b->R, src[i]);\n dest[i * 4 + 2] = BLEND (a->G, b->G, src[i]);\n dest[i * 4 + 3] = BLEND (a->B, b->B, src[i]);\n }\n } else {\n for (i = 0; i < n; i++) {\n dest[i * 4 + 0] = BLEND (a->A, b->A, src[i]);\n dest[i * 4 + 1] = BLEND (a->Y, b->Y, src[i]);\n dest[i * 4 + 2] = BLEND (a->U, b->U, src[i]);\n dest[i * 4 + 3] = BLEND (a->V, b->V, src[i]);\n }\n }\n#undef BLEND\n}", "label": 0, "cwe": null, "length": 323 }, { "index": 482716, "code": "eng_set_bg_bufout(gint32 frame_id, gint32 x1, gint32 y1, gint32 x2, gint32 y2) {\n\n\tguint8 *ptr_memout = frame[frame_id]->bufout + (y1 * frame[frame_id]->width + x1) * 3;\n\tgint32 i, j;\n\tgint32 height = y2 - y1 +1;\n\tgint32 width = (x2 - x1 +1) * 3;\n\tgint32 next = frame[frame_id]->width * 3;\n\n\tif(frame[frame_id]->gray_bgcolor)\n\t\tfor(i = 0 ; i < height ; i++, ptr_memout += next)\n\t\t\tmemset(ptr_memout, frame[frame_id]->bgcolor[0], width);\n\n\telse\n\t\tfor(i = 0 ; i < height ; i++, ptr_memout += next)\n\t\t\tfor(j = 0 ; j < width ; j+=3)\n\t\t\t\tmemcpy(ptr_memout + j, frame[frame_id]->bgcolor, 3);\n}", "label": 1, "cwe": "CWE-120", "length": 217 }, { "index": 98003, "code": "plugin_unpack_cai_from_ai(struct CategoryAppInfo *cai,\n unsigned char *ai_raw, int len)\n{\n struct ExpenseAppInfo ai;\n int r;\n \n jp_logf(JP_LOG_DEBUG, \"unpack_expense_cai_from_ai\\n\");\n\n memset(&ai, 0, sizeof(ai));\n r = unpack_ExpenseAppInfo(&ai, ai_raw, len);\n if (r <= 0) {\n jp_logf(JP_LOG_DEBUG, \"unpack_ExpenseAppInfo failed %s %d\\n\", __FILE__, __LINE__);\n return EXIT_FAILURE;\n }\n memcpy(cai, &(ai.category), sizeof(struct CategoryAppInfo));\n \n return EXIT_SUCCESS;\n}", "label": 1, "cwe": "CWE-120", "length": 149 }, { "index": 418395, "code": "getinformative(LINK)\nstruct LOC_readped *LINK;\n{\n long i, j, k, l, m, count, nchild;\n thisperson *child;\n long FORLIM1, FORLIM3;\n phenotype *WITH;\n locusvalues *WITH1;\n\n if (fitmodel || risk) {\n for (i = 0; i < nuped; i++)\n informative[i] = true;\n return;\n }\n for (i = 0; i < nuped; i++) {\n informative[i] = false;\n FORLIM1 = LINK->endped[i];\n for (j = LINK->startped[i]; j <= FORLIM1; j++) {\n if (person[j]->foff != NULL) {\n\tnchild = 0;\n\tchild = person[j]->foff;\n\tdo {\n\t nchild++;\n\t if (person[j]->male)\n\t child = child->nextpa;\n\t else\n\t child = child->nextma;\n\t} while (child != NULL);\n\tcount = 0;\n\tif (nchild > 1 || (nchild == 1 && person[j]->pa != NULL)) {\n\t for (k = 0; k < mlocus; k++) {\n\t WITH = person[j]->phen[k];\n\t WITH1 = thislocus[k];\n\t if (WITH1->which != binary_)\n\t count++;\n\t else {\n\t if (WITH->phenf == 0)\n\t\tcount++;\n\t else {\n\t\tl = 0;\n\t\tFORLIM3 = WITH1->nallele;\n if (binformat == WITH1->format) {\n\t\t for (m = 1; m <= FORLIM3; m++) {\n\t\t if ((unsigned long)m < 32 &&\n\t\t\t((1L << m) & WITH->phenf) != 0)\n\t\t l++;\n\t\t }\n }\n else\n if((WITH->allele1 > 0) && (WITH->allele2 > 0) &&\n (WITH->allele1 != WITH->allele2))\n l = 2;\n\t\tif (l > 1)\n\t\t count++;\n\t }\n\t }\n\t }\n\t}\n\tif (count > 1)\n\t informative[i] = true;\n }\n }\n }\n}", "label": 0, "cwe": null, "length": 485 }, { "index": 17197, "code": "PIT_RadiusAttack (mobj_t* thing)\n{\n fixed_t\tdx;\n fixed_t\tdy;\n fixed_t\tdist;\n\t\n if (!(thing->flags & MF_SHOOTABLE) )\n\treturn true;\n\n // Boss spider and cyborg\n // take no damage from concussion.\n if (thing->type == MT_CYBORG\n\t|| thing->type == MT_SPIDER)\n\treturn true;\t\n\t\t\n dx = abs(thing->x - bombspot->x);\n dy = abs(thing->y - bombspot->y);\n \n dist = dx>dy ? dx : dy;\n dist = (dist - thing->radius) >> FRACBITS;\n\n if (dist < 0)\n\tdist = 0;\n\n if (dist >= bombdamage)\n\treturn true;\t// out of range\n\n if ( P_CheckSight (thing, bombspot) )\n {\n\t// must be in direct path\n\tP_DamageMobj (thing, bombspot, bombsource, bombdamage - dist);\n }\n \n return true;\n}", "label": 0, "cwe": null, "length": 227 }, { "index": 405215, "code": "findClass(PyObject *self, PyObject *args)\n{\n char *className;\n\n if (!PyArg_ParseTuple(args, \"s\", &className))\n return NULL;\n\n try {\n jclass cls = env->findClass(className);\n\n if (cls)\n return t_Class::wrap_Object(Class(cls));\n } catch (int e) {\n switch (e) {\n case _EXC_PYTHON:\n return NULL;\n case _EXC_JAVA:\n return PyErr_SetJavaError();\n default:\n throw;\n }\n }\n\n Py_RETURN_NONE;\n}", "label": 0, "cwe": null, "length": 121 }, { "index": 436835, "code": "dupchain(chain_list* pthead)\n{\n chain_list *chain;\n chain_list *pred = NULL;\n chain_list *first = NULL;\n\n if ( !pthead ) return NULL;\n \n first = addchain( NULL, pthead->DATA );\n pred = first;\n\n for ( chain = pthead->NEXT; chain; chain = chain->NEXT )\n {\n ABL_CDR( pred ) = addchain( NULL, chain->DATA );\n pred = ABL_CDR( pred );\n }\n\n return first;\n}", "label": 0, "cwe": null, "length": 118 }, { "index": 78494, "code": "UTF8FromIconv(const Converter &conv, const char *s, int len) {\n\tif (conv) {\n\t\tstd::string utfForm(len*3+1, '\\0');\n\t\tchar *pin = const_cast(s);\n\t\tsize_t inLeft = len;\n\t\tchar *putf = &utfForm[0];\n\t\tchar *pout = putf;\n\t\tsize_t outLeft = len*3+1;\n\t\tsize_t conversions = conv.Convert(&pin, &inLeft, &pout, &outLeft);\n\t\tif (conversions != ((size_t)(-1))) {\n\t\t\t*pout = '\\0';\n\t\t\tutfForm.resize(pout - putf);\n\t\t\treturn utfForm;\n\t\t}\n\t}\n\treturn std::string();\n}", "label": 0, "cwe": null, "length": 163 }, { "index": 237121, "code": "gst_uvc_h264_mjpg_demux_set_property (GObject * object,\n guint prop_id, const GValue * value, GParamSpec * pspec)\n{\n GstUvcH264MjpgDemux *self = GST_UVC_H264_MJPG_DEMUX (object);\n\n switch (prop_id) {\n case PROP_DEVICE_FD:\n self->priv->device_fd = g_value_get_int (value);\n break;\n case PROP_NUM_CLOCK_SAMPLES:\n self->priv->num_clock_samples = g_value_get_int (value);\n if (self->priv->clock_samples) {\n if (self->priv->num_clock_samples) {\n self->priv->clock_samples = g_realloc_n (self->priv->clock_samples,\n self->priv->num_clock_samples, sizeof (GstUvcH264ClockSample));\n if (self->priv->num_samples > self->priv->num_clock_samples) {\n self->priv->num_samples = self->priv->num_clock_samples;\n if (self->priv->last_sample >= self->priv->num_samples)\n self->priv->last_sample = self->priv->num_samples - 1;\n }\n } else {\n g_free (self->priv->clock_samples);\n self->priv->clock_samples = NULL;\n self->priv->last_sample = -1;\n self->priv->num_samples = 0;\n }\n }\n if (self->priv->num_clock_samples > 0) {\n self->priv->clock_samples = g_malloc0_n (self->priv->num_clock_samples,\n sizeof (GstUvcH264ClockSample));\n self->priv->last_sample = -1;\n self->priv->num_samples = 0;\n }\n break;\n default:\n G_OBJECT_WARN_INVALID_PROPERTY_ID (self, prop_id, pspec);\n break;\n }\n}", "label": 0, "cwe": null, "length": 403 }, { "index": 393914, "code": "gst_bin_add (GstBin * bin, GstElement * element)\n{\n GstBinClass *bclass;\n gboolean result;\n\n g_return_val_if_fail (GST_IS_BIN (bin), FALSE);\n g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);\n\n bclass = GST_BIN_GET_CLASS (bin);\n\n if (G_UNLIKELY (bclass->add_element == NULL))\n goto no_function;\n\n GST_CAT_DEBUG (GST_CAT_PARENTAGE, \"adding element %s to bin %s\",\n GST_STR_NULL (GST_ELEMENT_NAME (element)),\n GST_STR_NULL (GST_ELEMENT_NAME (bin)));\n\n result = bclass->add_element (bin, element);\n\n return result;\n\n /* ERROR handling */\nno_function:\n {\n g_warning (\"adding elements to bin '%s' is not supported\",\n GST_ELEMENT_NAME (bin));\n return FALSE;\n }\n}", "label": 1, "cwe": "CWE-476", "length": 188 }, { "index": 29303, "code": "mousePressEvent(QMouseEvent* me)\n{\n if(me->button() != Qt::LeftButton)\n\treturn;\n emit click(m_number);\n}", "label": 0, "cwe": null, "length": 30 }, { "index": 737544, "code": "CdlComponentBody(std::string name_arg)\n : CdlNodeBody(name_arg),\n CdlContainerBody(),\n CdlUserVisibleBody(),\n CdlValuableBody(),\n CdlParentableBody(),\n CdlBuildableBody(),\n CdlDefinableBody()\n{\n CYG_REPORT_FUNCNAME(\"CdlComponentBody:: constructor\");\n CYG_REPORT_FUNCARG1XV(this);\n\n cdlcomponentbody_cookie = CdlComponentBody_Magic;\n CYGDBG_MEMLEAK_CONSTRUCTOR();\n\n CYG_POSTCONDITION_THISC();\n CYG_REPORT_RETURN();\n}\n\n//}}", "label": 0, "cwe": null, "length": 128 }, { "index": 408196, "code": "mpfr_cmp_z (mpfr_srcptr x, mpz_srcptr z)\n{\n mpfr_t t;\n int res;\n mpfr_prec_t p;\n unsigned int flags;\n\n if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (x)))\n return mpfr_cmp_si (x, mpz_sgn (z));\n\n if (mpz_size (z) <= 1)\n p = GMP_NUMB_BITS;\n else\n MPFR_MPZ_SIZEINBASE2 (p, z);\n mpfr_init2 (t, p);\n flags = __gmpfr_flags;\n if (mpfr_set_z (t, z, MPFR_RNDN))\n {\n /* overflow (t is an infinity) or underflow */\n mpfr_div_2ui (t, t, 2, MPFR_RNDZ); /* if underflow, set t to zero */\n __gmpfr_flags = flags; /* restore the flags */\n /* The real value of t (= z), which falls outside the exponent range,\n has been replaced by an equivalent value for the comparison: zero\n or an infinity. */\n }\n res = mpfr_cmp (x, t);\n mpfr_clear (t);\n return res;\n}", "label": 0, "cwe": null, "length": 264 }, { "index": 114251, "code": "idetape_init(void)\n{\n\tint error = 1;\n\tidetape_sysfs_class = class_create(THIS_MODULE, \"ide_tape\");\n\tif (IS_ERR(idetape_sysfs_class)) {\n\t\tidetape_sysfs_class = NULL;\n\t\tprintk(KERN_ERR \"Unable to create sysfs class for ide tapes\\n\");\n\t\terror = -EBUSY;\n\t\tgoto out;\n\t}\n\n\tif (register_chrdev(IDETAPE_MAJOR, \"ht\", &idetape_fops)) {\n\t\tprintk(KERN_ERR \"ide-tape: Failed to register chrdev\"\n\t\t\t\t\" interface\\n\");\n\t\terror = -EBUSY;\n\t\tgoto out_free_class;\n\t}\n\n\terror = driver_register(&idetape_driver.gen_driver);\n\tif (error)\n\t\tgoto out_free_driver;\n\n\treturn 0;\n\nout_free_driver:\n\tdriver_unregister(&idetape_driver.gen_driver);\nout_free_class:\n\tclass_destroy(idetape_sysfs_class);\nout:\n\treturn error;\n}", "label": 0, "cwe": null, "length": 201 }, { "index": 523207, "code": "i2c_mux_pinctrl_remove(struct platform_device *pdev)\n{\n\tstruct i2c_mux_pinctrl *mux = platform_get_drvdata(pdev);\n\tint i;\n\n\tfor (i = 0; i < mux->pdata->bus_count; i++)\n\t\ti2c_del_mux_adapter(mux->busses[i]);\n\n\ti2c_put_adapter(mux->parent);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 82 }, { "index": 451826, "code": "translateProp(char *fmt, int *type)\n{\n\tfor (int i=0; idata;\n\tstruct net_device *netdev;\n\tstruct ll_protocol *ll_protocol;\n\tuint8_t ll_dest_copy[ETH_ALEN];\n\tuint8_t ll_source_copy[ETH_ALEN];\n\tuint16_t tag;\n\tint rc;\n\n\t/* Sanity check */\n\tif ( iob_len ( iobuf ) < sizeof ( *vlanhdr ) ) {\n\t\tDBGC ( trunk, \"VLAN %s received underlength packet (%zd \"\n\t\t \"bytes)\\n\", trunk->name, iob_len ( iobuf ) );\n\t\trc = -EINVAL;\n\t\tgoto err_sanity;\n\t}\n\n\t/* Identify VLAN device */\n\ttag = VLAN_TAG ( ntohs ( vlanhdr->tci ) );\n\tnetdev = vlan_find ( trunk, tag );\n\tif ( ! netdev ) {\n\t\tDBGC2 ( trunk, \"VLAN %s received packet for unknown VLAN \"\n\t\t\t\"%d\\n\", trunk->name, tag );\n\t\trc = -EPIPE;\n\t\tgoto err_no_vlan;\n\t}\n\n\t/* Strip VLAN header and preserve original link-layer header fields */\n\tiob_pull ( iobuf, sizeof ( *vlanhdr ) );\n\tll_protocol = trunk->ll_protocol;\n\tmemcpy ( ll_dest_copy, ll_dest, ETH_ALEN );\n\tmemcpy ( ll_source_copy, ll_source, ETH_ALEN );\n\n\t/* Reconstruct link-layer header for VLAN device */\n\tll_protocol = netdev->ll_protocol;\n\tif ( ( rc = ll_protocol->push ( netdev, iobuf, ll_dest_copy,\n\t\t\t\t\tll_source_copy,\n\t\t\t\t\tvlanhdr->net_proto ) ) != 0 ) {\n\t\tDBGC ( netdev, \"VLAN %s could not reconstruct link-layer \"\n\t\t \"header: %s\\n\", netdev->name, strerror ( rc ) );\n\t\tgoto err_ll_push;\n\t}\n\n\t/* Enqueue packet on VLAN device */\n\tnetdev_rx ( netdev, iob_disown ( iobuf ) );\n\treturn 0;\n\n err_ll_push:\n err_no_vlan:\n err_sanity:\n\tfree_iob ( iobuf );\n\treturn rc;\n}", "label": 0, "cwe": null, "length": 466 }, { "index": 342, "code": "make_truncated_value_warning(THD *thd, MYSQL_ERROR::enum_warning_level level,\n const char *str_val,\n\t\t\t\t uint str_length, timestamp_type time_type,\n const char *field_name)\n{\n char warn_buff[MYSQL_ERRMSG_SIZE];\n const char *type_str;\n CHARSET_INFO *cs= &my_charset_latin1;\n char buff[128];\n String str(buff,(uint32) sizeof(buff), system_charset_info);\n str.copy(str_val, str_length, system_charset_info);\n str[str_length]= 0; // Ensure we have end 0 for snprintf\n\n switch (time_type) {\n case MYSQL_TIMESTAMP_DATE: \n type_str= \"date\";\n break;\n case MYSQL_TIMESTAMP_TIME:\n type_str= \"time\";\n break;\n case MYSQL_TIMESTAMP_DATETIME: // FALLTHROUGH\n default:\n type_str= \"datetime\";\n break;\n }\n if (field_name)\n cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),\n ER(ER_TRUNCATED_WRONG_VALUE_FOR_FIELD),\n type_str, str.c_ptr(), field_name,\n (ulong) thd->warning_info->current_row_for_warning());\n else\n {\n if (time_type > MYSQL_TIMESTAMP_ERROR)\n cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),\n ER(ER_TRUNCATED_WRONG_VALUE),\n type_str, str.c_ptr());\n else\n cs->cset->snprintf(cs, warn_buff, sizeof(warn_buff),\n ER(ER_WRONG_VALUE), type_str, str.c_ptr());\n }\n push_warning(thd, level,\n ER_TRUNCATED_WRONG_VALUE, warn_buff);\n}", "label": 0, "cwe": null, "length": 364 }, { "index": 25047, "code": "getText() const throw()\n {\n return gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(d_searchbar_ptr)->entry));\n }", "label": 0, "cwe": null, "length": 27 }, { "index": 511526, "code": "accept(vector id) {\n if(id.size()!=3){return false;}\n unsigned int npiplus(0),npi0(0),ngamma(0);\n for(unsigned int ix=0;ixnum_words += ifile_read_word_entry(line, idata);\n \n i++;\n }\n\n return idata->num_words;\n}", "label": 0, "cwe": null, "length": 126 }, { "index": 191415, "code": "HandleAutoEquipItemSlotOpcode(WorldPacket& recv_data)\n{\n ObjectGuid itemGuid;\n uint8 dstslot;\n recv_data >> itemGuid >> dstslot;\n\n // cheating attempt, client should never send opcode in that case\n if (!Player::IsEquipmentPos(INVENTORY_SLOT_BAG_0, dstslot))\n { return; }\n\n Item* item = _player->GetItemByGuid(itemGuid);\n uint16 dstpos = dstslot | (INVENTORY_SLOT_BAG_0 << 8);\n\n if (!item || item->GetPos() == dstpos)\n { return; }\n\n _player->SwapItem(item->GetPos(), dstpos);\n}", "label": 0, "cwe": null, "length": 144 }, { "index": 854825, "code": "M249PW(uint32 A, uint8 V)\n{\n if(EXPREGS[0]&0x2)\n {\n if(V<0x20)\n V=(V&1)|((V>>3)&2)|((V>>1)&4)|((V<<2)&8)|((V<<2)&0x10);\n else\n {\n V-=0x20;\n V=(V&3)|((V>>1)&4)|((V>>4)&8)|((V>>2)&0x10)|((V<<3)&0x20)|((V<<2)&0xC0);\n }\n }\n setprg8(A,V);\n}", "label": 0, "cwe": null, "length": 142 }, { "index": 707988, "code": "main(int argc, char *argv[]) {\n int i;\n\n Preprocessor_define(\"SWIGCLISP 1\", 0);\n SWIG_library_directory(\"clisp\");\n SWIG_config_file(\"clisp.swg\");\n generate_typedef_flag = 0;\n extern_all_flag = 0;\n\n for (i = 1; i < argc; i++) {\n if (!strcmp(argv[i], \"-help\")) {\n Printf(stdout, \"clisp Options (available with -clisp)\\n\");\n Printf(stdout,\n\t \" -extern-all\\n\"\n\t \"\\t If this option is given then clisp definitions for all the functions\\n\"\n\t \"and global variables will be created otherwise only definitions for \\n\"\n\t \"externed functions and variables are created.\\n\"\n\t \" -generate-typedef\\n\"\n\t \"\\t If this option is given then def-c-type will be used to generate shortcuts\\n\"\n\t \"according to the typedefs in the input.\\n\");\n } else if ((Strcmp(argv[i], \"-extern-all\") == 0)) {\n extern_all_flag = 1;\n Swig_mark_arg(i);\n } else if ((Strcmp(argv[i], \"-generate-typedef\") == 0)) {\n generate_typedef_flag = 1;\n Swig_mark_arg(i);\n }\n }\n}", "label": 0, "cwe": null, "length": 283 }, { "index": 405062, "code": "gtk_chk_uid(void)\n{\n\tchar\t*hd = getenv(\"HOME\");\n\tstruct\tstat\tsbuf;\n\n\tif (!hd || stat(hd, &sbuf) < 0 || (sbuf.st_mode & S_IFMT) != S_IFDIR || sbuf.st_uid != Realuid) {\n\t\tprint_error(8000);\t/* {Check file setup} */\n\t\texit(E_SETUP);\n\t}\n}", "label": 1, "cwe": "CWE-other", "length": 92 }, { "index": 26548, "code": "getStat(ModifierType stat) {\n CModifierGroup &modGroup = this->getModifierGroup();\n if (modGroup.getModifiers().size() == 0)\n return 0.0;\n const float rawMod = modGroup.getRawModifier(stat);\n const float currentValue = this->getBaseStat(stat);\n float newValue = currentValue + (currentValue * rawMod);\n return newValue;\n}", "label": 0, "cwe": null, "length": 86 }, { "index": 20336, "code": "gt_kmercodeiterator_filetab_new(\n const GtStrArray *filenametab,\n unsigned int numofchars,\n unsigned int kmersize,\n const GtUchar *symbolmap,\n bool plainformat,\n GtError *err)\n{\n GtKmercodeiterator *kmercodeiterator;\n GtUchar charcode;\n bool haserr = false;\n int retval;\n\n gt_error_check(err);\n kmercodeiterator = gt_malloc(sizeof (*kmercodeiterator));\n kmercodeiterator->esr = NULL;\n kmercodeiterator->hasprocessedfirst = false;\n kmercodeiterator->inputexhausted = false;\n kmercodeiterator->spwp = kmerstream_new(numofchars,kmersize);\n kmercodeiterator->totallength = 0;\n if (plainformat)\n {\n kmercodeiterator->fb = gt_sequence_buffer_plain_new(filenametab);\n } else\n {\n kmercodeiterator->fb = gt_sequence_buffer_new_guess_type(filenametab, err);\n }\n if (kmercodeiterator->fb == NULL)\n {\n haserr = true;\n }\n if (!haserr)\n {\n gt_sequence_buffer_set_symbolmap(kmercodeiterator->fb, symbolmap);\n for (kmercodeiterator->currentposition = 0;\n kmercodeiterator->currentposition < (unsigned long) kmersize;\n kmercodeiterator->currentposition++)\n {\n retval = gt_sequence_buffer_next(kmercodeiterator->fb,&charcode,err);\n if (retval < 0)\n {\n haserr = true;\n break;\n }\n if (retval == 0)\n {\n kmercodeiterator->inputexhausted = true;\n break;\n }\n kmercodeiterator->spwp->windowwidth++;\n updatespecialpositions(kmercodeiterator->spwp,charcode,false,0);\n kmercodeiterator->spwp->cyclicwindow[kmercodeiterator->\n spwp->windowwidth-1] = charcode;\n }\n }\n if (haserr)\n {\n gt_kmercodeiterator_delete(kmercodeiterator);\n return NULL;\n }\n return kmercodeiterator;\n}", "label": 0, "cwe": null, "length": 490 }, { "index": 449600, "code": "o_grips_end_picture(GSCHEM_TOPLEVEL *w_current, OBJECT *o_current,\n int whichone)\n{\n TOPLEVEL *toplevel = w_current->toplevel;\n\n /* don't allow zero width/height picturees\n * this ends the picture drawing behavior\n * we want this? hack */\n if ((GET_PICTURE_WIDTH(w_current) == 0) || (GET_PICTURE_HEIGHT(w_current) == 0)) {\n o_picture_invalidate_rubber (w_current);\n o_invalidate (w_current, o_current);\n return;\n }\n\n o_picture_modify(toplevel, o_current, \n\t\t w_current->second_wx, w_current->second_wy, whichone);\n\n g_object_unref (w_current->current_pixbuf);\n w_current->current_pixbuf = NULL;\n g_free (w_current->pixbuf_filename);\n w_current->pixbuf_filename = NULL;\n w_current->pixbuf_wh_ratio = 0;\n}", "label": 0, "cwe": null, "length": 207 }, { "index": 23397, "code": "LoadFile( FILE* fp )\r\n{\r\n Clear();\r\n\r\n fseek( fp, 0, SEEK_SET );\r\n if ( fgetc( fp ) == EOF && ferror( fp ) != 0 ) {\r\n SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );\r\n return _errorID;\r\n }\r\n\r\n fseek( fp, 0, SEEK_END );\r\n const long filelength = ftell( fp );\r\n fseek( fp, 0, SEEK_SET );\r\n if ( filelength == -1L ) {\r\n SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );\r\n return _errorID;\r\n }\r\n\r\n const size_t size = filelength;\r\n if ( size == 0 ) {\r\n SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );\r\n return _errorID;\r\n }\r\n\r\n _charBuffer = new char[size+1];\r\n size_t read = fread( _charBuffer, 1, size, fp );\r\n if ( read != size ) {\r\n SetError( XML_ERROR_FILE_READ_ERROR, 0, 0 );\r\n return _errorID;\r\n }\r\n\r\n _charBuffer[size] = 0;\r\n\r\n const char* p = _charBuffer;\r\n p = XMLUtil::SkipWhiteSpace( p );\r\n p = XMLUtil::ReadBOM( p, &_writeBOM );\r\n if ( !p || !*p ) {\r\n SetError( XML_ERROR_EMPTY_DOCUMENT, 0, 0 );\r\n return _errorID;\r\n }\r\n\r\n ParseDeep( _charBuffer + (p-_charBuffer), 0 );\r\n return _errorID;\r\n}", "label": 0, "cwe": null, "length": 344 }, { "index": 390358, "code": "Set(double number)\n{\n if (number > Maximum()) {\n Message(_(\"Value %.*f too large, truncated to %.*f.\"),\n AccuracyDigits(), number, AccuracyDigits(), Maximum());\n number = Maximum();\n } else if (number < Minimum()) {\n Message(_(\"Value %.*f too small, truncated to %.*f.\"),\n AccuracyDigits(), number, AccuracyDigits(), Minimum());\n number = Minimum();\n }\n if (!this->IsEqual(number)) {\n ufnumber->Number = number;\n ufnumber->CallValueChangedEvent(this);\n }\n // When numbers are equal up to Accuracy, we still want the new value\n ufnumber->Number = number;\n}", "label": 0, "cwe": null, "length": 145 }, { "index": 97635, "code": "globalRandomProvider()\n{\n\tQMutexLocker locker(global_random_mutex());\n\treturn global_random()->provider()->name();\n}", "label": 0, "cwe": null, "length": 23 }, { "index": 28190, "code": "findAndDeleteSequenceItem(const DcmTagKey &seqTagKey,\n const signed long itemNum)\n{\n DcmStack stack;\n /* find sequence */\n OFCondition status = search(seqTagKey, stack, ESM_fromHere, OFFalse /*searchIntoSub*/);\n if (status.good())\n {\n /* get element */\n DcmElement *delem = OFstatic_cast(DcmElement *, stack.top());\n if (delem != NULL)\n {\n /* check VR */\n if ((delem->ident() == EVR_SQ) || (delem->ident() == EVR_pixelSQ))\n {\n DcmSequenceOfItems *sequence = OFstatic_cast(DcmSequenceOfItems *, delem);\n const unsigned long count = sequence->card();\n /* last item? */\n if (itemNum == -1)\n delete sequence->remove(count - 1);\n /* valid item? */\n else if ((itemNum >= 0) && (OFstatic_cast(unsigned long, itemNum) < count))\n delete sequence->remove(OFstatic_cast(unsigned long, itemNum));\n else\n status = EC_IllegalParameter;\n } else\n status = EC_InvalidVR;\n } else\n status = EC_CorruptedData;\n }\n return status;\n}", "label": 0, "cwe": null, "length": 279 }, { "index": 33973, "code": "check_highscores( void )\n{\n\tint i;\n\t\n\tchart_clear_new_entries();\n\tfor ( i = 0; i < config.player_count; i++ )\n\t\tchart_add( \n\t\t\tchart_set_query(game_set->name), \n\t\t\tplayers[i].name, \n\t\t\tplayers[i].level_id + 1, \n\t\t\tplayers[i].stats.total_score );\n\tchart_save();\n}", "label": 0, "cwe": null, "length": 85 }, { "index": 435837, "code": "nlSparseMatrixAdd(NLSparseMatrix* M, NLuint i, NLuint j, NLdouble value) {\n nl_parano_range_assert(i, 0, M->m - 1) ;\n nl_parano_range_assert(j, 0, M->n - 1) ;\n if((M->storage & NL_MATRIX_STORE_SYMMETRIC) && (j > i)) {\n return ;\n }\n if(i == j) {\n M->diag[i] += value ;\n }\n if(M->storage & NL_MATRIX_STORE_ROWS) {\n nlRowColumnAdd(&(M->row[i]), j, value) ;\n }\n if(M->storage & NL_MATRIX_STORE_COLUMNS) {\n nlRowColumnAdd(&(M->column[j]), i, value) ;\n }\n}", "label": 0, "cwe": null, "length": 169 }, { "index": 945096, "code": "revision_info_get_property (GObject *object,\n\t\t\t guint param_id,\n\t\t\t GValue *value,\n\t\t\t GParamSpec *pspec)\n{\n\tGiggleRevisionInfoPriv *priv;\n\n\tpriv = GET_PRIV (object);\n\n\tswitch (param_id) {\n\tcase PROP_REVISION:\n\t\tg_value_set_object (value, priv->revision);\n\t\tbreak;\n\n\tcase PROP_LABEL:\n\t\tg_value_set_string (value, revision_info_get_label (priv));\n\t\tbreak;\n\n\tcase PROP_USE_MARKUP:\n\t\tg_value_set_boolean (value, priv->use_markup);\n\t\tbreak;\n\n\tdefault:\n\t\tG_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);\n\t\tbreak;\n\t}\n}", "label": 0, "cwe": null, "length": 144 }, { "index": 746590, "code": "_dxfCreateZoomInteractor (tdmInteractorWin W)\n{\n /*\n * Initialize and return a handle to a zoom interactor.\n */\n\n register tdmInteractor I ;\n\n ENTRY((\"_dxfCreateZoomInteractor(0x%x)\", W));\n \n if (W && (I = _dxfAllocateInteractor(W, sizeof(tdmZoomData))))\n {\n DEFDATA(I,tdmZoomData) ;\n\n /* instance interactor object methods */\n FUNC(I, StartStroke) = StartZoomStroke ;\n FUNC(I, StrokePoint) = StrokePoint ;\n FUNC(I, DoubleClick) = NullDoubleClick ;\n FUNC(I, EndStroke) = EndZoomStroke ;\n FUNC(I, ResumeEcho) = NullResumeEcho ;\n FUNC(I, Destroy) = _dxfDeallocateInteractor ;\n \n EXIT((\"I = 0x%x\",I));\n return I ;\n }\n else\n EXIT((\"ERROR\"));\n return 0 ;\n}", "label": 0, "cwe": null, "length": 210 }, { "index": 880518, "code": "gamgi_global_resources_text (gamgi_window *window)\n{\nchar *path;\n\n/*****************************************************\n * overwrite the text font default path, defined in *\n * GAMGI_IO_PATH_TRUETYPE, with the path set by *\n * the environment variable GAMGI_TEXT, if it exists *\n *****************************************************/\n\nif (gamgi_io_token_check_create (getenv (\"GAMGI_TEXT\"),\n&path, GAMGI_IO_PATHNAME) == FALSE)\n gamgi_gtk_dialog_message_create (\"Error\",\n \"Invalid local font path\", window);\n\nif (path != NULL)\n {\n gamgi_io_token_remove (&gamgi->text->path);\n gamgi_io_token_create (path, &gamgi->text->path);\n }\n}", "label": 1, "cwe": "CWE-other", "length": 155 }, { "index": 222061, "code": "totemip_sockaddr_to_totemip_convert(const struct sockaddr_storage *saddr,\n\t\t\t\t\tstruct totem_ip_address *ip_addr)\n{\n\tint ret = -1;\n\n\tip_addr->family = saddr->ss_family;\n\tip_addr->nodeid = 0;\n\n\tif (saddr->ss_family == AF_INET) {\n\t\tconst struct sockaddr_in *sin = (const struct sockaddr_in *)saddr;\n\n\t\tmemcpy(ip_addr->addr, &sin->sin_addr, sizeof(struct in_addr));\n\t\tret = 0;\n\t}\n\n\tif (saddr->ss_family == AF_INET6) {\n\t\tconst struct sockaddr_in6 *sin\n\t\t = (const struct sockaddr_in6 *)saddr;\n\n\t\tmemcpy(ip_addr->addr, &sin->sin6_addr, sizeof(struct in6_addr));\n\n\t\tret = 0;\n\t}\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 177 }, { "index": 771357, "code": "Unix_cf_pclose(FILE *pp)\n\n{ int fd;\n pid_t pid;\n\nDebug(\"Unix_cf_pclose(pp)\\n\");\n\nif (!ThreadLock(cft_count))\n {\n return -1;\n }\n\nif (CHILDREN == NULL) /* popen hasn't been called */\n {\n ThreadUnlock(cft_count);\n return -1;\n }\n\nThreadUnlock(cft_count);\n\nALARM_PID = -1;\nfd = fileno(pp);\n\nif (fd >= MAX_FD)\n {\n CfOut(cf_error,\"\",\"File descriptor %d of child higher than MAX_FD in Unix_cf_pclose, check for defunct children\", fd);\n pid = -1;\n }\nelse\n {\n if ((pid = CHILDREN[fd]) == 0)\n {\n return -1;\n }\n\n ThreadLock(cft_count);\n CHILDREN[fd] = 0;\n ThreadUnlock(cft_count);\n }\n\nif (fclose(pp) == EOF)\n {\n return -1;\n }\n\nreturn cf_pwait(pid);\n}", "label": 0, "cwe": null, "length": 221 }, { "index": 283810, "code": "ifec_get_rx_desc ( struct net_device *netdev, int cur, int cmd,\n\t\t\t int link )\n{\n\tstruct ifec_private *priv = netdev->priv;\n\tstruct ifec_rfd *rfd = priv->rfds[cur];\n\n\tDBGP ( \"ifec_get_rx_desc\\n\" );\n\n\tpriv->rx_iobs[cur] = alloc_iob ( sizeof ( *rfd ) );\n\tif ( ! priv->rx_iobs[cur] ) {\n\t\tDBG ( \"alloc_iob failed. desc. nr: %d\\n\", cur );\n\t\tpriv->rfds[cur] = NULL;\n\t\treturn -ENOMEM;\n\t}\n\n\t/* Initialize new tail. */\n\tpriv->rfds[cur] = priv->rx_iobs[cur]->data;\n\tifec_rfd_init ( priv->rfds[cur], cmd, link );\n\tiob_reserve ( priv->rx_iobs[cur], RFD_HEADER_LEN );\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 192 }, { "index": 124177, "code": "qo_title(const struct ltab *lt)\n{\n\tchar\t*str;\n\tstruct\tsctrl\twst_file;\n\n\twst_file.helpcode = lt->helpcode;\n\twst_file.helpfn = HELPLESS;\n\twst_file.size = lt->size;\n\twst_file.col = lt->col;\n\twst_file.magic_p = MAG_OK|MAG_R|MAG_CRS|MAG_NL;\n\twst_file.msg = (char *) 0;\n\n\tif ((str = wgets(stdscr, lt->row, &wst_file, JREQ.spq_file))) {\n\t\tstrncpy(JREQ.spq_file, str, MAXTITLE);\n\t\tcmsg();\n\t\treturn 404;\t/* {key eol} */\n\t}\n\treturn wst_file.retv;\n}", "label": 0, "cwe": null, "length": 163 }, { "index": 434502, "code": "evas_common_font_add(RGBA_Font *fn, const char *name, int size, Font_Rend_Flags wanted_rend)\n{\n RGBA_Font_Int *fi;\n\n if (!fn) return NULL;\n fi = evas_common_font_int_load(name, size, wanted_rend);\n if (fi)\n {\n\tfn->fonts = eina_list_append(fn->fonts, fi);\n\tfi->hinting = fn->hinting;\n if (fi->inuse) evas_common_font_int_promote(fi);\n else\n {\n fi->inuse = 1;\n fonts_use_lru = eina_inlist_prepend(fonts_use_lru, EINA_INLIST_GET(fi));\n }\n\treturn fn;\n }\n return NULL;\n}", "label": 0, "cwe": null, "length": 161 }, { "index": 691459, "code": "quiesce_open_cbk (call_frame_t *frame, void *cookie, xlator_t *this,\n int32_t op_ret, int32_t op_errno, fd_t *fd)\n{\n call_stub_t *stub = NULL;\n quiesce_local_t *local = NULL;\n\n local = frame->local;\n frame->local = NULL;\n if ((op_ret == -1) && (op_errno == ENOTCONN)) {\n /* Re-transmit (by putting in the queue) */\n stub = fop_open_stub (frame, default_open_resume,\n &local->loc, local->flag, local->fd,\n local->wbflags);\n if (!stub) {\n STACK_UNWIND_STRICT (open, frame, -1, ENOMEM,\n NULL);\n goto out;\n }\n\n gf_quiesce_enqueue (this, stub);\n goto out;\n }\n\n STACK_UNWIND_STRICT (open, frame, op_ret, op_errno, fd);\nout:\n gf_quiesce_local_wipe (this, local);\n\n return 0;\n}", "label": 1, "cwe": "CWE-other", "length": 235 }, { "index": 624494, "code": "untaggedMessage(mail::imap &imapAccount, string name)\n{\n\tif (isdigit((int)(unsigned char)*name.begin()))\n\t{\n\t\tif (imapAccount.handlers.count(mail::imapSELECT::name) > 0)\n\t\t\treturn false;\t// SELECT in progress\n\t\tsize_t c=0;\n\n\t\tistringstream(name.c_str()) >> c;\n\n\t\timapAccount.installBackgroundTask(new mail::imapFOLDER_COUNT(c));\n\t\treturn true;\n\t}\n\n\tif (name == \"FLAGS\")\n\t{\n\t\timapAccount\n\t\t\t.installBackgroundTask(new mail::imapSELECT_FLAGS());\n\t\treturn true;\n\t}\n\n\treturn false;\n}", "label": 0, "cwe": null, "length": 132 }, { "index": 287343, "code": "_stat_slurm_dirs(void)\n{\n\tstruct stat stat_buf;\n\tchar *problem_dir = NULL;\n\n\tif ((stat(slurmctld_conf.plugindir, &stat_buf) == 0) &&\n\t (stat_buf.st_mode & S_IWOTH)) {\n\t\tproblem_dir = \"PluginDir\";\n\t}\n\tif ((stat(slurmctld_conf.plugstack, &stat_buf) == 0) &&\n\t (stat_buf.st_mode & S_IWOTH)) {\n\t\tproblem_dir = \"PlugStack\";\n\t}\n\tif ((stat(slurmctld_conf.slurmd_spooldir, &stat_buf) == 0) &&\n\t (stat_buf.st_mode & S_IWOTH)) {\n\t\tproblem_dir = \"SlurmdSpoolDir\";\n\t}\n\tif ((stat(slurmctld_conf.state_save_location, &stat_buf) == 0) &&\n\t (stat_buf.st_mode & S_IWOTH)) {\n\t\tproblem_dir = \"StateSaveLocation\";\n\t}\n\n\tif (problem_dir) {\n\t\terror(\"################################################\");\n\t\terror(\"### SEVERE SECURITY VULERABILTY ###\");\n\t\terror(\"### %s DIRECTORY IS WORLD WRITABLE ###\", problem_dir);\n\t\terror(\"### CORRECT FILE PERMISSIONS ###\");\n\t\terror(\"################################################\");\n\t}\n}", "label": 0, "cwe": null, "length": 271 }, { "index": 381769, "code": "linda_out(hlinda *h, const char *s)\n{\n\tif (!h)\n\t\treturn 0;\n\n\tjson *j = json_open(s);\n\tjson *j1 = json_get_object(j);\n\tjson *joid = json_find(j1, LINDA_OID);\n\tuuid u;\n\n\tif (joid)\n\t{\n\t\tuuid_from_string(json_get_string(joid), &u);\n\t}\n\telse\n\t\tuuid_gen(&u);\n\n\tjson *jid = json_find(j1, LINDA_ID);\n\n\tif (jid)\n\t{\n\t\tif (json_is_integer(jid))\n\t\t{\n\t\t\tlong long k = json_get_integer(jid);\n\n\t\t\tif (h->l->sl && !h->l->is_int)\n\t\t\t{\n\t\t\t\tprintf(\"linda_out: expected integer id\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\tif (!h->l->sl)\n\t\t\t{\n\t\t\t\th->l->sl = sl_int_uuid_create2();\n\t\t\t\th->l->is_int = 1;\n\t\t\t}\n\n\t\t\tsl_int_uuid_add(h->l->sl, k, &u);\n\t\t}\n\t\telse if (json_is_string(jid))\n\t\t{\n\t\t\tconst char *k = json_get_string(jid);\n\n\t\t\tif (h->l->sl && !h->l->is_string)\n\t\t\t{\n\t\t\t\tprintf(\"linda_out: expected string id\\n\");\n\t\t\t\treturn 0;\n\t\t\t}\n\n\t\t\tif (!h->l->sl)\n\t\t\t{\n\t\t\t\th->l->sl = sl_string_uuid_create2();\n\t\t\t\th->l->is_string = 1;\n\t\t\t}\n\n\t\t\tsl_string_uuid_add(h->l->sl, k, &u);\n\t\t}\n\t}\n\n\tstore_hadd(h->hst, &u, s, strlen(s));\n\th->last_oid = u;\n\tjson_close(j);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 392 }, { "index": 298206, "code": "clutter_gst_video_texture_size_change (ClutterTexture *texture,\n gint width,\n gint height)\n{\n ClutterGstVideoTexture *video_texture = CLUTTER_GST_VIDEO_TEXTURE (texture);\n ClutterGstVideoTexturePrivate *priv = video_texture->priv;\n gboolean changed;\n\n /* we are being told the actual (as in number of pixels in the buffers)\n * frame size. Store the values to be used in preferred_width/height() */\n changed = (priv->buffer_width != width) || (priv->buffer_height != height);\n priv->buffer_width = width;\n priv->buffer_height = height;\n\n if (changed)\n {\n /* reset the computed texture dimensions if the underlying frames have\n * changed size */\n CLUTTER_GST_NOTE (ASPECT_RATIO, \"frame size has been updated to %dx%d\",\n width, height);\n\n priv->texture_width = priv->texture_height = 0;\n\n /* queue a relayout to ask containers/layout manager to ask for\n * the preferred size again */\n clutter_actor_queue_relayout (CLUTTER_ACTOR (texture));\n }\n}", "label": 0, "cwe": null, "length": 247 }, { "index": 758707, "code": "str_match_len(const struct value_pair *vp, const char *str)\n{\n\treturn max(strlen(vp->ival), opt_len(str));\n}", "label": 0, "cwe": null, "length": 29 }, { "index": 33015, "code": "unbind_all()\n {\n for(BindingMap::const_iterator iter = m_bindings.begin();\n iter != m_bindings.end(); ++iter) {\n tomboy_keybinder_unbind (iter->first.c_str(), &XKeybinder::keybinding_pressed);\n }\n m_bindings.clear();\n }", "label": 0, "cwe": null, "length": 65 }, { "index": 198522, "code": "_bfd_elf_rela_local_sym (bfd *abfd,\n\t\t\t Elf_Internal_Sym *sym,\n\t\t\t asection **psec,\n\t\t\t Elf_Internal_Rela *rel)\n{\n asection *sec = *psec;\n bfd_vma relocation;\n\n relocation = (sec->output_section->vma\n\t\t+ sec->output_offset\n\t\t+ sym->st_value);\n if ((sec->flags & SEC_MERGE)\n && ELF_ST_TYPE (sym->st_info) == STT_SECTION\n && sec->sec_info_type == SEC_INFO_TYPE_MERGE)\n {\n rel->r_addend =\n\t_bfd_merged_section_offset (abfd, psec,\n\t\t\t\t elf_section_data (sec)->sec_info,\n\t\t\t\t sym->st_value + rel->r_addend);\n if (sec != *psec)\n\t{\n\t /* If we have changed the section, and our original section is\n\t marked with SEC_EXCLUDE, it means that the original\n\t SEC_MERGE section has been completely subsumed in some\n\t other SEC_MERGE section. In this case, we need to leave\n\t some info around for --emit-relocs. */\n\t if ((sec->flags & SEC_EXCLUDE) != 0)\n\t sec->kept_section = *psec;\n\t sec = *psec;\n\t}\n rel->r_addend -= relocation;\n rel->r_addend += sec->output_section->vma + sec->output_offset;\n }\n return relocation;\n}", "label": 0, "cwe": null, "length": 320 }, { "index": 807837, "code": "glp_write_mip(glp_prob *mip, const char *fname)\n{ XFILE *fp;\n int i, j, ret = 0;\n xprintf(\"Writing MIP solution to `%s'...\\n\", fname);\n fp = xfopen(fname, \"w\");\n if (fp == NULL)\n { xprintf(\"Unable to create `%s' - %s\\n\", fname, xerrmsg());\n ret = 1;\n goto done;\n }\n /* number of rows, number of columns */\n xfprintf(fp, \"%d %d\\n\", mip->m, mip->n);\n /* solution status, objective value */\n xfprintf(fp, \"%d %.*g\\n\", mip->mip_stat, DBL_DIG, mip->mip_obj);\n /* rows (auxiliary variables) */\n for (i = 1; i <= mip->m; i++)\n xfprintf(fp, \"%.*g\\n\", DBL_DIG, mip->row[i]->mipx);\n /* columns (structural variables) */\n for (j = 1; j <= mip->n; j++)\n xfprintf(fp, \"%.*g\\n\", DBL_DIG, mip->col[j]->mipx);\n xfflush(fp);\n if (xferror(fp))\n { xprintf(\"Write error on `%s' - %s\\n\", fname, xerrmsg());\n ret = 1;\n goto done;\n }\n xprintf(\"%d lines were written\\n\", 2 + mip->m + mip->n);\ndone: if (fp != NULL) xfclose(fp);\n return ret;\n}", "label": 0, "cwe": null, "length": 349 }, { "index": 70328, "code": "mtdoops_write(struct mtdoops_context *cxt, int panic)\n{\n\tstruct mtd_info *mtd = cxt->mtd;\n\tsize_t retlen;\n\tu32 *hdr;\n\tint ret;\n\n\t/* Add mtdoops header to the buffer */\n\thdr = cxt->oops_buf;\n\thdr[0] = cxt->nextcount;\n\thdr[1] = MTDOOPS_KERNMSG_MAGIC;\n\n\tif (panic) {\n\t\tret = mtd_panic_write(mtd, cxt->nextpage * record_size,\n\t\t\t\t record_size, &retlen, cxt->oops_buf);\n\t\tif (ret == -EOPNOTSUPP) {\n\t\t\tprintk(KERN_ERR \"mtdoops: Cannot write from panic without panic_write\\n\");\n\t\t\treturn;\n\t\t}\n\t} else\n\t\tret = mtd_write(mtd, cxt->nextpage * record_size,\n\t\t\t\trecord_size, &retlen, cxt->oops_buf);\n\n\tif (retlen != record_size || ret < 0)\n\t\tprintk(KERN_ERR \"mtdoops: write failure at %ld (%td of %ld written), error %d\\n\",\n\t\t cxt->nextpage * record_size, retlen, record_size, ret);\n\tmark_page_used(cxt, cxt->nextpage);\n\tmemset(cxt->oops_buf, 0xff, record_size);\n\n\tmtdoops_inc_counter(cxt);\n}", "label": 0, "cwe": null, "length": 296 }, { "index": 385386, "code": "Init() {\n\n static ClassDocumentation documentation\n (\"The MEee2gZ2qqPowheg class implements the next-to-leading order \"\n \"matrix element for e+e- > q qbar in the POWHEG scheme\");\n\n static Switch interfaceContribution\n (\"Contribution\",\n \"Which contributions to the cross section to include\",\n &MEee2gZ2qqPowheg::contrib_, 1, false, false);\n static SwitchOption interfaceContributionLeadingOrder\n (interfaceContribution,\n \"LeadingOrder\",\n \"Just generate the leading order cross section\",\n 0);\n static SwitchOption interfaceContributionPositiveNLO\n (interfaceContribution,\n \"PositiveNLO\",\n \"Generate the positive contribution to the full NLO cross section\",\n 1);\n static SwitchOption interfaceContributionNegativeNLO\n (interfaceContribution,\n \"NegativeNLO\",\n \"Generate the negative contribution to the full NLO cross section\",\n 2);\n\n static Parameter interfacezPower\n (\"zPower\",\n \"The sampling power for z\",\n &MEee2gZ2qqPowheg::zPow_, 0.5, 0.0, 1.0,\n false, false, Interface::limited);\n\n static Parameter interfaceyPower\n (\"yPower\",\n \"The sampling power for y\",\n &MEee2gZ2qqPowheg::yPow_, 0.9, 0.0, 1.0,\n false, false, Interface::limited);\n\n}", "label": 0, "cwe": null, "length": 386 }, { "index": 599868, "code": "pk_client_cancel_all_dbus_methods (PkClient *client)\n{\n\tconst PkClientState *state;\n\tguint i;\n\tGPtrArray *array;\n\n\t/* just cancel the call */\n\tarray = client->priv->calls;\n\tfor (i=0; ilen; i++) {\n\t\tstate = g_ptr_array_index (array, i);\n\t\tif (state->proxy == NULL)\n\t\t\tcontinue;\n\t\tg_debug (\"cancel in flight call\");\n\t\tg_cancellable_cancel (state->cancellable);\n\t}\n\n\treturn TRUE;\n}", "label": 0, "cwe": null, "length": 113 }, { "index": 785962, "code": "_k_initDeviceList()\n{\n Solid::DeviceNotifier *notifier = Solid::DeviceNotifier::instance();\n\n connect(notifier, SIGNAL(deviceAdded(QString)),\n q, SLOT(_k_deviceAdded(QString)));\n connect(notifier, SIGNAL(deviceRemoved(QString)),\n q, SLOT(_k_deviceRemoved(QString)));\n\n const QList &deviceList = Solid::Device::listFromQuery(predicate);\n\n foreach(const Solid::Device &device, deviceList) {\n availableDevices << device.udi();\n }\n\n _k_reloadBookmarks();\n}", "label": 0, "cwe": null, "length": 115 }, { "index": 301942, "code": "ci_fan_ctrl_stop_smc_fan_control(struct radeon_device *rdev)\n{\n\tPPSMC_Result ret;\n\tstruct ci_power_info *pi = ci_get_pi(rdev);\n\n\tret = ci_send_msg_to_smc(rdev, PPSMC_StopFanControl);\n\tif (ret == PPSMC_Result_OK) {\n\t\tpi->fan_is_controlled_by_smc = false;\n\t\treturn 0;\n\t} else\n\t\treturn -EINVAL;\n}", "label": 0, "cwe": null, "length": 98 }, { "index": 674573, "code": "ParseSMARTSRecord( char *ptr )\n {\n register char *src;\n\n src = ptr;\n while( *src && !isspace(*src) )\n src++;\n\n if( isspace(*src) )\n {\n *src++ = '\\0';\n while( isspace(*src) )\n src++;\n }\n\n return ParseSMARTSString(ptr);\n }", "label": 0, "cwe": null, "length": 81 }, { "index": 646064, "code": "getRelocationTySize(unsigned RelTy) const {\n // FIXME: Most of these sizes are guesses based on the name\n switch (RelTy) {\n case ELF::R_MICROBLAZE_32:\n case ELF::R_MICROBLAZE_32_PCREL:\n case ELF::R_MICROBLAZE_32_PCREL_LO:\n case ELF::R_MICROBLAZE_32_LO:\n case ELF::R_MICROBLAZE_SRO32:\n case ELF::R_MICROBLAZE_SRW32:\n case ELF::R_MICROBLAZE_32_SYM_OP_SYM:\n case ELF::R_MICROBLAZE_GOTOFF_32:\n return 32;\n\n case ELF::R_MICROBLAZE_64_PCREL:\n case ELF::R_MICROBLAZE_64:\n case ELF::R_MICROBLAZE_GOTPC_64:\n case ELF::R_MICROBLAZE_GOT_64:\n case ELF::R_MICROBLAZE_PLT_64:\n case ELF::R_MICROBLAZE_GOTOFF_64:\n return 64;\n }\n\n return 0;\n}", "label": 0, "cwe": null, "length": 249 }, { "index": 126001, "code": "slot_tp_repr(PyObject *self)\n{\n PyObject *func, *res;\n static PyObject *repr_str;\n\n func = lookup_method(self, \"__repr__\", &repr_str);\n if (func != NULL) {\n res = PyEval_CallObject(func, NULL);\n Py_DECREF(func);\n return res;\n }\n PyErr_Clear();\n return PyString_FromFormat(\"<%s object at %p>\",\n Py_TYPE(self)->tp_name, self);\n}", "label": 0, "cwe": null, "length": 98 }, { "index": 450417, "code": "gwy_3d_window_set_material(GtkTreeSelection *selection,\n Gwy3DWindow *gwy3dwindow)\n{\n Gwy3DView *view;\n GwyResource *resource;\n GtkTreeModel *model;\n GtkTreeIter iter;\n const gchar *name;\n\n if (gtk_tree_selection_get_selected(selection, &model, &iter)) {\n gtk_tree_model_get(model, &iter, 0, &resource, -1);\n view = GWY_3D_VIEW(gwy3dwindow->gwy3dview);\n name = gwy_resource_get_name(resource);\n gwy_container_set_string_by_name(gwy_3d_view_get_data(view),\n gwy_3d_view_get_material_key(view),\n g_strdup(name));\n }\n}", "label": 0, "cwe": null, "length": 169 }, { "index": 15355, "code": "open_cb(Fl_Widget*, void*) {\n if (!check_save()) return;\n\n char *newfile = fl_file_chooser(\"Open File?\", \"*\", filename);\n if (newfile != NULL) load_file(newfile, -1);\n}", "label": 0, "cwe": null, "length": 51 }, { "index": 677608, "code": "part_list_stub (XDR *xdr_in)\n{\n guestfs_int_partition_list *r;\n struct guestfs_part_list_args args;\n CLEANUP_FREE char *device = NULL;\n\n if (optargs_bitmask != 0) {\n reply_with_error (\"header optargs_bitmask field must be passed as 0 for calls that don't take optional arguments\");\n goto done_no_free;\n }\n\n memset (&args, 0, sizeof args);\n\n if (!xdr_guestfs_part_list_args (xdr_in, &args)) {\n reply_with_error (\"daemon failed to decode procedure arguments\");\n goto done;\n }\n RESOLVE_DEVICE (args.device, device, , goto done);\n\n r = do_part_list (device);\n if (r == NULL)\n /* do_part_list has already called reply_with_error */\n goto done;\n\n struct guestfs_part_list_ret ret;\n ret.partitions = *r;\n free (r);\n reply ((xdrproc_t) xdr_guestfs_part_list_ret, (char *) &ret);\n xdr_free ((xdrproc_t) xdr_guestfs_part_list_ret, (char *) &ret);\ndone:\n xdr_free ((xdrproc_t) xdr_guestfs_part_list_args, (char *) &args);\ndone_no_free:\n return;\n}", "label": 0, "cwe": null, "length": 283 }, { "index": 850030, "code": "rc_service_extra_commands(const char *service)\n{\n\tchar *svc;\n\tchar *cmd = NULL;\n\tchar *buffer = NULL;\n\tsize_t len = 0;\n\tRC_STRINGLIST *commands = NULL;\n\tchar *token;\n\tchar *p;\n\tFILE *fp;\n\tsize_t l;\n\n\tif (!(svc = rc_service_resolve(service)))\n\t\treturn NULL;\n\n\tl = strlen(OPTSTR) + strlen(svc) + 1;\n\tcmd = xmalloc(sizeof(char) * l);\n\tsnprintf(cmd, l, OPTSTR, svc);\n\tfree(svc);\n\n\tif ((fp = popen(cmd, \"r\"))) {\n\t\trc_getline(&buffer, &len, fp);\n\t\tp = buffer;\n\t\tcommands = rc_stringlist_new();\n\n\t\twhile ((token = strsep(&p, \" \")))\n\t\t\tif (token[0] != '\\0')\n\t\t\t\trc_stringlist_add(commands, token);\n\n\t\tpclose(fp);\n\t\tfree(buffer);\n\t}\n\n\tfree(cmd);\n\treturn commands;\n}", "label": 0, "cwe": null, "length": 201 }, { "index": 732802, "code": "recvv_n_i (ACE_HANDLE handle,\n iovec *iov,\n int iovcnt,\n size_t *bt)\n{\n size_t temp;\n size_t &bytes_transferred = bt == 0 ? temp : *bt;\n bytes_transferred = 0;\n\n for (int s = 0; s < iovcnt; )\n {\n // Try to transfer as much of the remaining data as possible.\n ssize_t n = ACE_OS::recvv (handle, iov + s, iovcnt - s);\n // Check EOF.\n if (n == 0)\n return 0;\n\n // Check for other errors.\n if (n == -1)\n {\n // Check for possible blocking.\n if (errno == EWOULDBLOCK)\n {\n // Wait for the blocking to subside.\n int const result = ACE::handle_read_ready (handle, 0);\n\n // Did select() succeed?\n if (result != -1)\n {\n // Blocking subsided. Continue data transfer.\n n = 0;\n continue;\n }\n }\n\n // Other data transfer or select() failures.\n return -1;\n }\n\n for (bytes_transferred += n;\n s < iovcnt\n && n >= static_cast (iov[s].iov_len);\n s++)\n n -= iov[s].iov_len;\n\n if (n != 0)\n {\n char *base = static_cast (iov[s].iov_base);\n iov[s].iov_base = base + n;\n iov[s].iov_len = iov[s].iov_len - n;\n }\n }\n\n return ACE_Utils::truncate_cast (bytes_transferred);\n}", "label": 0, "cwe": null, "length": 369 }, { "index": 712847, "code": "processSecurityMatrix(char *line)\n{\n DMAN_SECURITYMATRIX security;\n char *tok;\n CONDITION cond;\n\n memset(&security, 0, sizeof(security));\n security.Type = DMAN_K_SECURITYMATRIX;\n\n tok = strtok(line, \"^\\n\");\n copy(security.RequestingTitle, tok);\n security.Flag |= DMAN_K_SECURITY_REQUESTING;\n\n tok = strtok(NULL, \"^\\n\");\n copy(security.RespondingTitle, tok);\n security.Flag |= DMAN_K_SECURITY_RESPONDING;\n\n cond = DMAN_Insert(&dmanHandle, (DMAN_GENERICRECORD *) & security);\n if (cond != DMAN_NORMAL) {\n\tCOND_DumpConditions();\n\texit(1);\n }\n}", "label": 0, "cwe": null, "length": 155 }, { "index": 121709, "code": "formatInt(long x, char *buf, int bufSize,\n\t\t\tGBool zeroFill, int width, int base,\n\t\t\tchar **p, int *len) {\n static char vals[17] = \"0123456789abcdef\";\n GBool neg;\n int start, i, j;\n\n i = bufSize;\n if ((neg = x < 0)) {\n x = -x;\n }\n start = neg ? 1 : 0;\n if (x == 0) {\n buf[--i] = '0';\n } else {\n while (i > start && x) {\n buf[--i] = vals[x % base];\n x /= base;\n }\n }\n if (zeroFill) {\n for (j = bufSize - i; i > start && j < width - start; ++j) {\n buf[--i] = '0';\n }\n }\n if (neg) {\n buf[--i] = '-';\n }\n *p = buf + i;\n *len = bufSize - i;\n}", "label": 0, "cwe": null, "length": 229 }, { "index": 580813, "code": "mlx4_GID_HASH(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox,\n\t\t\t u16 *hash, u8 op_mod)\n{\n\tu64 imm;\n\tint err;\n\n\terr = mlx4_cmd_imm(dev, mailbox->dma, &imm, 0, op_mod,\n\t\t\t MLX4_CMD_MGID_HASH, MLX4_CMD_TIME_CLASS_A,\n\t\t\t MLX4_CMD_NATIVE);\n\n\tif (!err)\n\t\t*hash = imm;\n\n\treturn err;\n}", "label": 0, "cwe": null, "length": 102 }, { "index": 550030, "code": "eprn_flag_mismatch(const struct s_eprn_Device *eprn,\n bool no_match)\n{\n if (eprn->fmr != NULL) (*eprn->fmr)(eprn, no_match);\n else {\n const char *epref = eprn->CUPS_messages? CUPS_ERRPREF: \"\";\n\n eprintf2(\"%s\" ERRPREF \"The %s does not support \",\n epref, eprn->cap->name);\n if (eprn->desired_flags == 0) eprintf(\"an empty set of media flags\");\n else {\n eprintf(\"the \\\"\");\n print_flags(eprn->desired_flags, eprn->flag_desc);\n eprintf(\"\\\" flag(s)\");\n }\n eprintf1(\"\\n%s (ignoring presence or absence of \\\"\", epref);\n {\n ms_MediaCode optional = MS_TRANSVERSE_FLAG;\n if (eprn->optional_flags != NULL) {\n const ms_MediaCode *of = eprn->optional_flags;\n while (*of != ms_none) optional |= *of++;\n }\n print_flags(optional, eprn->flag_desc);\n }\n eprintf(\"\\\") for \");\n if (no_match) eprintf(\"any\"); else eprintf(\"this\");\n eprintf(\" page size.\\n\");\n }\n\n return;\n}", "label": 0, "cwe": null, "length": 297 }, { "index": 7044, "code": "computeCglpObjective(double gamma, bool strengthen)\n{\n double rhs = row_k_.rhs + gamma * row_i_.rhs;\n double numerator = - rhs * (1 - rhs);\n double denominator = 1;\n\n double coeff = gamma;//newRowCoefficient(basics_[row_i_.num], gamma);\n if (strengthen && isInteger(basics_[row_i_.num]))\n coeff = modularizedCoef(coeff, rhs);\n denominator += normedCoef(fabs(coeff), basics_[row_i_.num]);\n numerator += (coeff > 0 ?\n coeff *(1- rhs):\n - coeff * rhs)*\n getColsolToCut(basics_[row_i_.num]);\n for (int j = 0 ; j < ncols_ ; j++)\n {\n if (col_in_subspace[nonBasics_[j]]==false) {\n continue;\n }\n coeff = newRowCoefficient(nonBasics_[j], gamma);\n if (strengthen && nonBasics_[j] < ncols_orig_ && isInteger(j))\n coeff = modularizedCoef(coeff, rhs);\n denominator += normedCoef(fabs(coeff), nonBasics_[j]);\n numerator += (coeff > 0 ?\n coeff *(1- rhs):\n - coeff * rhs)*\n getColsolToCut(nonBasics_[j]);\n }\n return numerator*rhs_weight_/denominator;\n}", "label": 0, "cwe": null, "length": 299 }, { "index": 314069, "code": "glusterd_check_restart_gsync_session (glusterd_volinfo_t *volinfo, char *slave,\n dict_t *resp_dict)\n{\n\n int ret = 0;\n uuid_t uuid = {0, };\n glusterd_conf_t *priv = NULL;\n char *status_msg = NULL;\n\n GF_ASSERT (volinfo);\n GF_ASSERT (slave);\n GF_ASSERT (THIS);\n GF_ASSERT (THIS->private);\n\n priv = THIS->private;\n\n if (glusterd_gsync_get_uuid (slave, volinfo, uuid))\n /* session does not exist, nothing to do */\n goto out;\n if (uuid_compare (priv->uuid, uuid) == 0) {\n ret = stop_gsync (volinfo->volname, slave, &status_msg);\n if (ret == 0 && status_msg)\n ret = dict_set_str (resp_dict, \"gsync-status\",\n status_msg);\n if (ret == 0)\n ret = glusterd_start_gsync (volinfo, slave,\n uuid_utoa(priv->uuid), NULL);\n }\n\n out:\n gf_log (\"\", GF_LOG_DEBUG, \"Returning %d\", ret);\n return ret;\n}", "label": 0, "cwe": null, "length": 263 }, { "index": 774144, "code": "is_unset() const\n {\n return m_color.is_unset() || (m_width < length(EPIX_EPSILON));\n }", "label": 0, "cwe": null, "length": 28 }, { "index": 99428, "code": "calculateNextPositions()\n{\n unsigned int i;\n int j;\n\n j=(int)(calcPositionNumber[Options::aiDifficulty(playerNumber)]/cfg->gamespeed);\n\n if(shipsNextPositions[0]->size() != j)\n for(i=0;i<2;i++)\n shipsNextPositions[i]->resize(j);\n\n for(i=0;i<2;i++)\n nextPositions(ship[i]->toAiSprite(),shipsNextPositions[i],\n calcFrameIncrement[Options::aiDifficulty(playerNumber)]);\n\n if(cfg->maxMines > aiMines[0]->size())\n for(i=0;i<2;i++)\n aiMines[i]->resize(cfg->maxMines);\n\n for(i=0;i<2;i++)\n {\n for (j=0; jsize(); j++)\n {\n (*(aiMines[i]))[j]=mines[i]->value(j)->toAiSprite();\n }\n mineNumber[i]=j;\n }\n}", "label": 0, "cwe": null, "length": 211 }, { "index": 541491, "code": "ib_dealloc_pd(struct ib_pd *pd)\n{\n\tint ret;\n\n\tif (pd->local_mr) {\n\t\tret = ib_dereg_mr(pd->local_mr);\n\t\tWARN_ON(ret);\n\t\tpd->local_mr = NULL;\n\t}\n\n\t/* uverbs manipulates usecnt with proper locking, while the kabi\n\t requires the caller to guarantee we can't race here. */\n\tWARN_ON(atomic_read(&pd->usecnt));\n\n\t/* Making delalloc_pd a void return is a WIP, no driver should return\n\t an error here. */\n\tret = pd->device->dealloc_pd(pd);\n\tWARN_ONCE(ret, \"Infiniband HW driver failed dealloc_pd\");\n}", "label": 0, "cwe": null, "length": 145 }, { "index": 496929, "code": "playback_play (int seek_time, bool_t pause)\n{\n if (current_filename)\n playback_cleanup ();\n\n current_filename = playback_entry_get_filename ();\n g_return_if_fail (current_filename);\n\n playback_start (seek_time, pause);\n\n hook_call (\"playback begin\", NULL);\n}", "label": 0, "cwe": null, "length": 62 }, { "index": 425861, "code": "net2272_done(struct net2272_ep *ep, struct net2272_request *req, int status)\n{\n\tstruct net2272 *dev;\n\tunsigned stopped = ep->stopped;\n\n\tif (ep->num == 0) {\n\t\tif (ep->dev->protocol_stall) {\n\t\t\tep->stopped = 1;\n\t\t\tset_halt(ep);\n\t\t}\n\t\tallow_status(ep);\n\t}\n\n\tlist_del_init(&req->queue);\n\n\tif (req->req.status == -EINPROGRESS)\n\t\treq->req.status = status;\n\telse\n\t\tstatus = req->req.status;\n\n\tdev = ep->dev;\n\tif (use_dma && ep->dma)\n\t\tusb_gadget_unmap_request(&dev->gadget, &req->req,\n\t\t\t\tep->is_in);\n\n\tif (status && status != -ESHUTDOWN)\n\t\tdev_vdbg(dev->dev, \"complete %s req %p stat %d len %u/%u buf %p\\n\",\n\t\t\tep->ep.name, &req->req, status,\n\t\t\treq->req.actual, req->req.length, req->req.buf);\n\n\t/* don't modify queue heads during completion callback */\n\tep->stopped = 1;\n\tspin_unlock(&dev->lock);\n\tusb_gadget_giveback_request(&ep->ep, &req->req);\n\tspin_lock(&dev->lock);\n\tep->stopped = stopped;\n}", "label": 0, "cwe": null, "length": 289 }, { "index": 559166, "code": "p_scann_start_time(char *buf, GapMPlayerParams *gpp)\n{\n gint ii;\n gint tab_idx;\n gint num;\n gint factor;\n gint tab[3];\n gboolean num_ready;\n\n\n tab[0] = 0;\n tab[1] = 0;\n tab[2] = 0;\n\n tab_idx = 0;\n num = 0;\n factor = 1;\n num_ready = FALSE;\n\n ii = strlen(buf);\n while(TRUE)\n {\n ii--;\n\n if((buf[ii] >= '0') && (buf[ii] <= '9'))\n {\n num += ((buf[ii] - (gint)'0') * factor);\n factor = factor * 10;\n if((factor > 10) /* 2 digits done ? */\n || (ii==0)) /* last character handled ? */\n {\n num_ready = TRUE;\n }\n }\n else\n {\n /* current char is no digit */\n if(factor > 1)\n {\n /* at least one digit was collected in num */\n num_ready = TRUE;\n }\n }\n\n if(num_ready)\n {\n if(tab_idx < 3)\n {\n tab[tab_idx] = num;\n tab_idx++;\n }\n num = 0;\n factor = 1;\n num_ready = FALSE;\n }\n\n if(ii <= 0)\n {\n break;\n }\n }\n\n gpp->start_hour = tab[2];\n gpp->start_minute = tab[1];\n gpp->start_second = tab[0];\n\n}", "label": 0, "cwe": null, "length": 348 }, { "index": 9636, "code": "op_mul_pixel_span_get(RGBA_Image *src, RGBA_Image *dst, int pixels __UNUSED__)\n{\n int s = SP_AN, m = SM_N, c = SC_N, d = DP_AN;\n\n if (src && src->cache_entry.flags.alpha)\n {\n\tdst->cache_entry.flags.alpha = 1;\n\ts = SP;\n }\n if (dst && dst->cache_entry.flags.alpha)\n\td = DP;\n return mul_gfx_span_func_cpu(s, m, c, d);\n}", "label": 0, "cwe": null, "length": 110 }, { "index": 408597, "code": "format(double number,\n const UnicodeString& ruleSetName,\n UnicodeString& toAppendTo,\n FieldPosition& /* pos */,\n UErrorCode& status) const\n{\n if (U_SUCCESS(status)) {\n if (ruleSetName.indexOf(gPercentPercent, 2, 0) == 0) {\n // throw new IllegalArgumentException(\"Can't use internal rule set\");\n status = U_ILLEGAL_ARGUMENT_ERROR;\n } else {\n NFRuleSet *rs = findRuleSet(ruleSetName, status);\n if (rs) {\n int32_t startPos = toAppendTo.length();\n rs->format(number, toAppendTo, toAppendTo.length());\n adjustForCapitalizationContext(startPos, toAppendTo);\n }\n }\n }\n return toAppendTo;\n}", "label": 0, "cwe": null, "length": 166 }, { "index": 1013905, "code": "transBinds(bs)\t/* Translate list of bindings: */\nList bs; {\t\t\t\t/* eliminating pattern matching on */\n List newBinds = NIL;\t\t/* lhs of bindings. */\n for (; nonNull(bs); bs=tl(bs)) {\n#if IPARAM\n\tCell v = fst(hd(bs));\n\twhile (isAp(v) && fun(v) == nameInd)\n\t v = arg(v);\n\tfst(hd(bs)) = v;\n\tif (isVar(v)) {\n#else\n\t if (isVar(fst(hd(bs)))) {\n#endif\n\t mapProc(transAlt,snd(hd(bs)));\n\t newBinds = cons(hd(bs),newBinds);\n\t}\n\telse\n\t newBinds = remPat(fst(snd(hd(bs))),\n\t\t\t snd(snd(hd(bs)))=transRhs(snd(snd(hd(bs)))),\n\t\t\t newBinds);\n }\n return newBinds;\n}", "label": 0, "cwe": null, "length": 201 }, { "index": 292556, "code": "prepare_next_cycle (AsyncExistenceJob *job)\n{\n gboolean res = FALSE;\n\n if (job->type != (NUM_TESTS - 1))\n {\n (job->type)++;\n job->iteration = 0;\n\n res = TRUE;\n }\n\n return res;\n}", "label": 0, "cwe": null, "length": 61 }, { "index": 533022, "code": "setRgb( int r, int g, int b)\n{\n/* if ( (uint)r > 255 || (uint)g > 255 || (uint)b > 255 ) {\n#if defined(QT_CHECK_RANGE)\n\tqWarning( \"QColor::setRgb: RGB parameter(s) out of range\" );\n#endif\n\treturn;\n }*/\n d.argb = qRgba( r, g, b, alpha() );\n if ( colormodel == d8 ) {\n\td.d8.invalid = FALSE;\n\td.d8.direct = FALSE;\n\td.d8.dirty = TRUE;\n } else {\n\td.d32.pix = Dirt;\n }\n}", "label": 0, "cwe": null, "length": 137 }, { "index": 290222, "code": "add_bus_environment (BusActivation *activation,\n DBusError *error)\n{\n const char *type;\n\n if (!bus_activation_set_environment_variable (activation,\n \"DBUS_STARTER_ADDRESS\",\n activation->server_address,\n error))\n return FALSE;\n\n type = bus_context_get_type (activation->context);\n if (type != NULL)\n {\n if (!bus_activation_set_environment_variable (activation,\n \"DBUS_STARTER_BUS_TYPE\", type,\n error))\n return FALSE;\n\n if (strcmp (type, \"session\") == 0)\n {\n if (!bus_activation_set_environment_variable (activation,\n \"DBUS_SESSION_BUS_ADDRESS\",\n activation->server_address,\n error))\n return FALSE;\n }\n else if (strcmp (type, \"system\") == 0)\n {\n if (!bus_activation_set_environment_variable (activation,\n \"DBUS_SYSTEM_BUS_ADDRESS\",\n activation->server_address,\n error))\n return FALSE;\n }\n }\n\n return TRUE;\n}", "label": 0, "cwe": null, "length": 215 }, { "index": 54913, "code": "lj_ctype_repr_int64(lua_State *L, uint64_t n, int isunsigned)\n{\n char buf[1+20+3];\n char *p = buf+sizeof(buf);\n int sign = 0;\n *--p = 'L'; *--p = 'L';\n if (isunsigned) {\n *--p = 'U';\n } else if ((int64_t)n < 0) {\n n = (uint64_t)-(int64_t)n;\n sign = 1;\n }\n do { *--p = (char)('0' + n % 10); } while (n /= 10);\n if (sign) *--p = '-';\n return lj_str_new(L, p, (size_t)(buf+sizeof(buf)-p));\n}", "label": 0, "cwe": null, "length": 172 }, { "index": 237765, "code": "rename_directory(direntry_t *entry, MainParam_t *mp)\n{\n\tint ret;\n\n\t/* moves a DOS dir */\n\tif(isSubdirOf(mp->targetDir, mp->File)) {\n\t\tfprintf(stderr, \"Cannot move directory \");\n\t\tfprintPwd(stderr, entry,0);\n\t\tfprintf(stderr, \" into one of its own subdirectories (\");\n\t\tfprintPwd(stderr, getDirentry(mp->targetDir),0);\n\t\tfprintf(stderr, \")\\n\");\n\t\treturn ERROR_ONE;\n\t}\n\n\tif(entry->entry == -3) {\n\t\tfprintf(stderr, \"Cannot move a root directory: \");\n\t\tfprintPwd(stderr, entry,0);\n\t\treturn ERROR_ONE;\n\t}\n\n\tret = rename_file(entry, mp);\n\tif(ret & ERROR_ONE)\n\t\treturn ret;\n\t\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 168 }, { "index": 72759, "code": "setForBox(const Box& box,\n\t\t\t int *nBlocks, int (*shlBlocks)[2]) const\n{\n real center[3];\n for(int i=0; i<3; i++)\n center[i] = 0.5*(box.lo[i]+box.hi[i]);\n real cellSize = box.size(box.getMaxDim());\n\n ggmi.getBlocks(center, cellSize, rShell2, nBlocks, shlBlocks);\n}", "label": 0, "cwe": null, "length": 96 }, { "index": 712175, "code": "cx8802_request_acquire(struct cx8802_driver *drv)\n{\n\tstruct cx88_core *core = drv->core;\n\tunsigned int\ti;\n\n\t/* Fail a request for hardware if the device is busy. */\n\tif (core->active_type_id != CX88_BOARD_NONE &&\n\t core->active_type_id != drv->type_id)\n\t\treturn -EBUSY;\n\n\tif (drv->type_id == CX88_MPEG_DVB) {\n\t\t/* When switching to DVB, always set the input to the tuner */\n\t\tcore->last_analog_input = core->input;\n\t\tcore->input = 0;\n\t\tfor (i = 0;\n\t\t i < (sizeof(core->board.input) / sizeof(struct cx88_input));\n\t\t i++) {\n\t\t\tif (core->board.input[i].type == CX88_VMUX_DVB) {\n\t\t\t\tcore->input = i;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (drv->advise_acquire)\n\t{\n\t\tcore->active_ref++;\n\t\tif (core->active_type_id == CX88_BOARD_NONE) {\n\t\t\tcore->active_type_id = drv->type_id;\n\t\t\tdrv->advise_acquire(drv);\n\t\t}\n\n\t\tmpeg_dbg(1,\"%s() Post acquire GPIO=%x\\n\", __func__, cx_read(MO_GP0_IO));\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 284 }, { "index": 17189, "code": "list_split(char *sep, char *str)\n{\n List new = list_create ((ListDelF) free);\n char *tok;\n\n if (sep == NULL)\n sep = \" \\t\";\n\n while ((tok = _next_tok (sep, &str)) != NULL) {\n if (strlen (tok) > 0)\n list_append (new, strdup(tok));\n }\n\n return new;\n}", "label": 0, "cwe": null, "length": 89 }, { "index": 121313, "code": "Pairpool_push_copy (List_T list, T this, Pair_T orig) {\n List_T listcell;\n Pair_T pair;\n List_T p;\n int n;\n\n if (this->pairctr >= this->npairs) {\n this->pairptr = add_new_pairchunk(this);\n } else if ((this->pairctr % CHUNKSIZE) == 0) {\n for (n = this->npairs - CHUNKSIZE, p = this->pairchunks;\n\t n > this->pairctr; p = p->rest, n -= CHUNKSIZE) ;\n this->pairptr = (struct Pair_T *) p->first;\n debug1(printf(\"Located pair %d at %p\\n\",this->pairctr,this->pairptr));\n } \n pair = this->pairptr++;\n this->pairctr++;\n\n memcpy(pair,orig,sizeof(struct Pair_T));\n\n debug(\n\tprintf(\"Copying %p: %d %d %c %c %c\\n\",\n\t pair,pair->querypos,pair->genomepos,pair->cdna,pair->comp,pair->genome);\n\t);\n\n\tif (this->listcellctr >= this->nlistcells) {\n this->listcellptr = add_new_listcellchunk(this);\n } else if ((this->listcellctr % CHUNKSIZE) == 0) {\n for (n = this->nlistcells - CHUNKSIZE, p = this->listcellchunks;\n\t n > this->listcellctr; p = p->rest, n -= CHUNKSIZE) ;\n this->listcellptr = (struct List_T *) p->first;\n debug1(printf(\"Located listcell %d at %p\\n\",this->listcellctr,this->listcellptr));\n }\n listcell = this->listcellptr++;\n this->listcellctr++;\n\n listcell->first = (void *) pair;\n listcell->rest = list;\n\n return listcell;\n}", "label": 0, "cwe": null, "length": 415 }, { "index": 885333, "code": "de_bb_hdy (init_data, detected, easter, year, hd_elems, fday, count)\n Bool *init_data;\n const Bool detected;\n int easter;\n const int year;\n int *hd_elems;\n const int fday;\n const int count;\n/*\n Manages all specific holidays celebrated in Germany/Brandenburg.\n*/\n{\n if (!use_other_cc)\n {\n ptr_cc_id = \"DE_BB\";\n use_other_cc = !use_other_cc;\n de_hdy (init_data, detected, easter, year, hd_elems, fday, count);\n use_other_cc = !use_other_cc;\n }\n else\n de_hdy (init_data, detected, easter, year, hd_elems, fday, count);\n if (year > 1516)\n holiday (*init_data, detected, _(hd_text[HD_REFORMATION_DAY].ht_text),\n\t ptr_cc_id, \"+\", dvec[10 - 1], 10, year, hd_elems, fday, count);\n if (year > 1989)\n holiday (*init_data, detected, _(hd_text[HD_GERMAN_UNITY_DAY].ht_text),\n\t ptr_cc_id, \"+\", 3, 10, year, hd_elems, fday, count);\n}", "label": 0, "cwe": null, "length": 280 }, { "index": 952930, "code": "get_prev_terminal()\n{\n ED4_terminal *terminal = 0;\n\n if (parent) {\n if (index) {\n terminal = parent->get_last_terminal(index-1);\n }\n if (!terminal) {\n terminal = parent->get_prev_terminal();\n }\n }\n\n return terminal;\n}", "label": 0, "cwe": null, "length": 66 }, { "index": 76417, "code": "get_ctrl_task_for_no_layer_block(Block_info *block_info,\n int pe, int pe_no,\n Ctrl_task **ctrl_tasks,\n List *module_info_list)\n{\n Block *block = block_info_get_block(block_info);\n int id = block_info_get_id(block_info);\n Ctrl_task *ctrl_task;\n\n if (block->kind == SB) {\n Module_table *mpt = search_module_for_sb(block);\n int entry = mpt->entry;\n module_kind kind = mpt->kind;\n Module_info *m = module_info_list_lookup(module_info_list,\n entry, kind);\n\n Ctrl_task *sc = module_info_get_ctrl_task(m, PROC_CPU, pe);\n fv_kind fv = ctrl_task_get_fv(sc); /* todo: SB should be ANY? */\n fv_kind fin_fv = ctrl_task_get_fin_fv(sc);\n Boolean is_whole = ctrl_task_is_whole(sc);\n\n ctrl_task = ctrl_task_new(block_info, id, SB_CTRL, fv, fin_fv,\n is_whole, FALSE, NULL, NULL);\n ctrl_task_set_pe_no_in_sb(ctrl_task, pe);\n\n } else {\n fv_kind fv = block_info_get_fv(block_info);\n\n ctrl_task = ctrl_task_new(block_info, id, BB_CTRL, fv, fv,\n TRUE, FALSE, NULL, NULL);\n }\n\n return ctrl_task;\n}", "label": 0, "cwe": null, "length": 293 }, { "index": 898163, "code": "eval_grd_uh_d(const REAL lambda[N_LAMBDA], \n\t\t\t const REAL_D Lambda[N_LAMBDA],\n\t\t\t const REAL_D *uh_loc, const BAS_FCTS *b,\n\t\t\t REAL_DD grd_uh)\n{\n static REAL_DD grd;\n const REAL *grd_b;\n int i, j, n, dim = b->dim;\n GRD_BAS_FCT **grd_phi = b->grd_phi;\n REAL_D *val;\n REAL grd1[DIM_OF_WORLD][N_LAMBDA] = {{0}};\n \n val = grd_uh ? grd_uh : grd;\n \n for (i = 0; i < b->n_bas_fcts; i++)\n {\n grd_b = grd_phi[i](lambda);\n for (j = 0; j < dim+1; j++)\n for (n = 0; n < DIM_OF_WORLD; n++)\n\tgrd1[n][j] += uh_loc[i][n]*grd_b[j];\n }\n\n for (i = 0; i < DIM_OF_WORLD; i++)\n {\n for (n = 0; n < DIM_OF_WORLD; n++)\n\tfor (val[n][i] = j = 0; j < dim+1; j++)\n\t val[n][i] += Lambda[j][i]*grd1[n][j];\n }\n \n return((const REAL_D *) val);\n}", "label": 0, "cwe": null, "length": 312 }, { "index": 133, "code": "usbvision_frames_free(struct usb_usbvision *usbvision)\n{\n\t/* Have to free all that memory */\n\tPDEBUG(DBG_FUNC, \"free %d frames\", usbvision->num_frames);\n\n\tif (usbvision->fbuf != NULL) {\n\t\tusbvision_rvfree(usbvision->fbuf, usbvision->fbuf_size);\n\t\tusbvision->fbuf = NULL;\n\n\t\tusbvision->num_frames = 0;\n\t}\n}", "label": 0, "cwe": null, "length": 96 }, { "index": 331303, "code": "gl_color_combo_new (const gchar *default_label,\n guint default_color,\n guint color)\n{\n glColorCombo *this;\n\n this = g_object_new (TYPE_GL_COLOR_COMBO, NULL);\n\n if (!default_label)\n {\n default_label = _(\"Default Color\");\n }\n\n this->priv->default_color = default_color;\n this->priv->color = color;\n\n gl_color_swatch_set_color (GL_COLOR_SWATCH (this->priv->swatch), color);\n\n this->priv->menu = gl_color_combo_menu_new (default_label,\n color);\n gtk_widget_show_all (this->priv->menu);\n\n g_signal_connect (this->priv->menu, \"color_changed\",\n G_CALLBACK (menu_color_changed_cb), this);\n g_signal_connect (this->priv->menu, \"selection_done\",\n G_CALLBACK (menu_selection_done_cb), this);\n\n return GTK_WIDGET (this);\n}", "label": 0, "cwe": null, "length": 196 }, { "index": 776203, "code": "GNUNET_DISK_mktemp (const char *t)\n{\n const char *tmpdir;\n int fd;\n char *tmpl;\n char *fn;\n\n if ((t[0] != '/') && (t[0] != '\\\\')\n#if WINDOWS\n && !(isalpha ((int) t[0]) && (t[0] != '\\0') && (t[1] == ':'))\n#endif\n )\n {\n /* FIXME: This uses system codepage on W32, not UTF-8 */\n tmpdir = getenv (\"TMPDIR\");\n tmpdir = tmpdir ? tmpdir : \"/tmp\";\n GNUNET_asprintf (&tmpl, \"%s/%s%s\", tmpdir, t, \"XXXXXX\");\n }\n else\n {\n GNUNET_asprintf (&tmpl, \"%s%s\", t, \"XXXXXX\");\n }\n#ifdef MINGW\n fn = (char *) GNUNET_malloc (MAX_PATH + 1);\n if (ERROR_SUCCESS != plibc_conv_to_win_path (tmpl, fn))\n {\n GNUNET_free (fn);\n GNUNET_free (tmpl);\n return NULL;\n }\n GNUNET_free (tmpl);\n#else\n fn = tmpl;\n#endif\n /* FIXME: why is this not MKSTEMP()? This function is implemented in plibc.\n * CG: really? If I put MKSTEMP here, I get a compilation error...\n * It will assume that fn is UTF-8-encoded, if compiled with UTF-8 support.\n */\n fd = mkstemp (fn);\n if (fd == -1)\n {\n LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, \"mkstemp\", fn);\n GNUNET_free (fn);\n return NULL;\n }\n if (0 != CLOSE (fd))\n LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, \"close\", fn);\n return fn;\n}", "label": 1, "cwe": "CWE-other", "length": 398 }, { "index": 630181, "code": "UnloadAll(){\n //wavs.Add(this,id);\n eWavData* wav = s_anchor;\n while ( wav )\n {\n wav->Unload();\n wav = wav->Next();\n }\n\n}", "label": 0, "cwe": null, "length": 45 }, { "index": 331237, "code": "ath9k_htc_calcrxfilter(struct ath9k_htc_priv *priv)\n{\n#define\tRX_FILTER_PRESERVE (ATH9K_RX_FILTER_PHYERR | ATH9K_RX_FILTER_PHYRADAR)\n\n\tstruct ath_hw *ah = priv->ah;\n\tu32 rfilt;\n\n\trfilt = (ath9k_hw_getrxfilter(ah) & RX_FILTER_PRESERVE)\n\t\t| ATH9K_RX_FILTER_UCAST | ATH9K_RX_FILTER_BCAST\n\t\t| ATH9K_RX_FILTER_MCAST;\n\n\tif (priv->rxfilter & FIF_PROBE_REQ)\n\t\trfilt |= ATH9K_RX_FILTER_PROBEREQ;\n\n\tif (ah->is_monitoring)\n\t\trfilt |= ATH9K_RX_FILTER_PROM;\n\n\tif (priv->rxfilter & FIF_CONTROL)\n\t\trfilt |= ATH9K_RX_FILTER_CONTROL;\n\n\tif ((ah->opmode == NL80211_IFTYPE_STATION) &&\n\t (priv->nvifs <= 1) &&\n\t !(priv->rxfilter & FIF_BCN_PRBRESP_PROMISC))\n\t\trfilt |= ATH9K_RX_FILTER_MYBEACON;\n\telse\n\t\trfilt |= ATH9K_RX_FILTER_BEACON;\n\n\tif (conf_is_ht(&priv->hw->conf)) {\n\t\trfilt |= ATH9K_RX_FILTER_COMP_BAR;\n\t\trfilt |= ATH9K_RX_FILTER_UNCOMP_BA_BAR;\n\t}\n\n\tif (priv->rxfilter & FIF_PSPOLL)\n\t\trfilt |= ATH9K_RX_FILTER_PSPOLL;\n\n\tif (priv->nvifs > 1 || priv->rxfilter & FIF_OTHER_BSS)\n\t\trfilt |= ATH9K_RX_FILTER_MCAST_BCAST_ALL;\n\n\treturn rfilt;\n\n#undef RX_FILTER_PRESERVE\n}", "label": 0, "cwe": null, "length": 368 }, { "index": 956057, "code": "filterattr(dp)\nCONST struct filestat_t *dp;\n{\n\tint i, f;\n\n\tfor (i = 0; dirattr[i]; i++) {\n\t\tf = 0;\n\t\tif (dirattr[i] == '-') {\n\t\t\ti++;\n\t\t\tf++;\n\t\t}\n\n\t\tswitch (dirattr[i]) {\n\t\t\tcase 'D':\n\t\t\t\tif (!(dir_isdir(dp))) f ^= 1;\n\t\t\t\tbreak;\n\t\t\tcase 'R':\n\t\t\t\tif (dp -> mod & S_IWUSR) f ^= 1;\n\t\t\t\tbreak;\n\t\t\tcase 'H':\n\t\t\t\tif (dp -> mod & S_IRUSR) f ^= 1;\n\t\t\t\tbreak;\n\t\t\tcase 'S':\n\t\t\t\tif ((dp -> mod & S_IFMT) != S_IFSOCK) f ^= 1;\n\t\t\t\tbreak;\n\t\t\tcase 'A':\n\t\t\t\tif (!(dp -> mod & S_ISVTX)) f ^= 1;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\n\t\tif (f) return(-1);\n\t}\n\n\treturn(0);\n}", "label": 0, "cwe": null, "length": 215 }, { "index": 979507, "code": "dev_show_unique_id(struct device *dev,\n\t\t\t\t struct device_attribute *attr,\n\t\t\t\t char *buf)\n{\n\tdrive_info_struct *drv = to_drv(dev);\n\tstruct ctlr_info *h = to_hba(drv->dev.parent);\n\t__u8 sn[16];\n\tunsigned long flags;\n\tint ret = 0;\n\n\tspin_lock_irqsave(&h->lock, flags);\n\tif (h->busy_configuring)\n\t\tret = -EBUSY;\n\telse\n\t\tmemcpy(sn, drv->serial_no, sizeof(sn));\n\tspin_unlock_irqrestore(&h->lock, flags);\n\n\tif (ret)\n\t\treturn ret;\n\telse\n\t\treturn snprintf(buf, 16 * 2 + 2,\n\t\t\t\t\"%02X%02X%02X%02X%02X%02X%02X%02X\"\n\t\t\t\t\"%02X%02X%02X%02X%02X%02X%02X%02X\\n\",\n\t\t\t\tsn[0], sn[1], sn[2], sn[3],\n\t\t\t\tsn[4], sn[5], sn[6], sn[7],\n\t\t\t\tsn[8], sn[9], sn[10], sn[11],\n\t\t\t\tsn[12], sn[13], sn[14], sn[15]);\n}", "label": 1, "cwe": "CWE-120", "length": 268 }, { "index": 813113, "code": "Ns_DStringVarAppend(Ns_DString *dsPtr, ...)\n{\n register char *s;\n va_list ap;\n\n va_start(ap, dsPtr);\n while ((s = va_arg(ap, char *)) != NULL) {\n\tNs_DStringAppend(dsPtr, s);\n }\n va_end(ap);\n return dsPtr->string;\n}", "label": 0, "cwe": null, "length": 77 }, { "index": 49684, "code": "run_server (SoupServer *server)\n{\n\tGThread *thread;\n\tgchar *port_string;\n\tGError *error = NULL;\n\n\tthread = g_thread_try_new (\"server-thread\", (GThreadFunc) run_server_thread, server, &error);\n\tg_assert_no_error (error);\n\tg_assert (thread != NULL);\n\n\t/* Set the port so that libgdata doesn't override it. */\n\tport_string = g_strdup_printf (\"%u\", soup_server_get_port (server));\n\tg_setenv (\"LIBGDATA_HTTPS_PORT\", port_string, TRUE);\n\tg_free (port_string);\n\n\treturn thread;\n}", "label": 0, "cwe": null, "length": 124 }, { "index": 914496, "code": "ql_exec_mb_cmd(struct ql_adapter *qdev, struct mbox_params *mbcp)\n{\n\tint i, status;\n\n\t/*\n\t * Make sure there's nothing pending.\n\t * This shouldn't happen.\n\t */\n\tif (ql_read32(qdev, CSR) & CSR_HRI)\n\t\treturn -EIO;\n\n\tstatus = ql_sem_spinlock(qdev, SEM_PROC_REG_MASK);\n\tif (status)\n\t\treturn status;\n\n\t/*\n\t * Fill the outbound mailboxes.\n\t */\n\tfor (i = 0; i < mbcp->in_count; i++) {\n\t\tstatus = ql_write_mpi_reg(qdev, qdev->mailbox_in + i,\n\t\t\t\t\t\tmbcp->mbox_in[i]);\n\t\tif (status)\n\t\t\tgoto end;\n\t}\n\t/*\n\t * Wake up the MPI firmware.\n\t */\n\tql_write32(qdev, CSR, CSR_CMD_SET_H2R_INT);\nend:\n\tql_sem_unlock(qdev, SEM_PROC_REG_MASK);\n\treturn status;\n}", "label": 0, "cwe": null, "length": 204 }, { "index": 176096, "code": "bufToByte4(void)\n{\n ArTypes::Byte4 ret=0;\n unsigned char c1, c2, c3, c4;\n\n if (isNextGood(4))\n {\n memcpy(&c1, myBuf+myReadLength, 1);\n memcpy(&c2, myBuf+myReadLength+1, 1);\n memcpy(&c3, myBuf+myReadLength+2, 1);\n memcpy(&c4, myBuf+myReadLength+3, 1);\n ret = (c1 & 0xff) | (c2 << 8) | (c3 << 16) | (c4 << 24);\n myReadLength+=4;\n }\n\n return ret;\n}", "label": 0, "cwe": null, "length": 163 }, { "index": 5552, "code": "kvm_setup_secondary_clock(void)\n{\n\t/*\n\t * Now that the first cpu already had this clocksource initialized,\n\t * we shouldn't fail.\n\t */\n\tWARN_ON(kvm_register_clock(\"secondary cpu clock\"));\n}", "label": 0, "cwe": null, "length": 47 }, { "index": 51395, "code": "visit(cf_node& n, bool enter) {\n\tif (enter) {\n\t\tif (n.bc.op == CF_OP_CF_END) {\n\t\t\tn.flags |= NF_DEAD;\n\t\t\treturn false;\n\t\t}\n\t\tn.live_after = live;\n\t\tupdate_interferences();\n\t\tprocess_op(n);\n\t} else {\n\t\tn.live_before = live;\n\t}\n\treturn true;\n}", "label": 0, "cwe": null, "length": 77 }, { "index": 87629, "code": "GetPointerFromElement(Tag const &tag) const\n{\n const DataSet &ds = F->GetDataSet();\n if( ds.FindDataElement( tag ) )\n {\n const DataElement &de = ds.GetDataElement( tag );\n return de.GetByteValue();\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 65 }, { "index": 219418, "code": "cl_endpoint_list_get_last_touch_time(cl_raw_list_t* list_p, cl_com_endpoint_t* endpoint, unsigned long* touch_time) {\n\n int back = CL_RETVAL_UNKNOWN_ENDPOINT;\n int ret_val = CL_RETVAL_OK;\n cl_endpoint_list_elem_t* elem = NULL;\n \n\n if (list_p == NULL || endpoint == NULL) {\n return CL_RETVAL_PARAMS;\n }\n\n /* set time to 0 if endpoint not found, otherwise return last communication time */\n /* otherwise return error */\n if (touch_time) {\n *touch_time = 0;\n }\n\n /* lock list */\n if ( (ret_val = cl_raw_list_lock(list_p)) != CL_RETVAL_OK) {\n return ret_val;\n }\n\n elem = cl_endpoint_list_get_elem_endpoint(list_p, endpoint);\n if (elem != NULL) { \n /* found matching endpoint */\n back = CL_RETVAL_OK;\n CL_LOG_STR(CL_LOG_INFO,\"found endpoint comp_host:\", elem->endpoint->comp_host);\n if (touch_time) {\n *touch_time = elem->last_used;\n }\n } \n\n /* unlock list */\n if ( (ret_val = cl_raw_list_unlock(list_p)) != CL_RETVAL_OK) {\n return ret_val;\n }\n return back;\n\n}", "label": 0, "cwe": null, "length": 277 }, { "index": 262702, "code": "scale_bit_width(const Dataset& ds, bool downsample,\n const TransferFunction1D& tf)\n{\n size_t max_value = (ds.GetBitWidth() != 8 && downsample)\n ? 65536 : tf.GetSize();\n uint32_t max_range = static_cast(1 << ds.GetBitWidth());\n\n return (ds.GetBitWidth() != 8 && downsample)\n ? 1.0f : static_cast(max_range) /\n static_cast(max_value);\n}", "label": 0, "cwe": null, "length": 111 }, { "index": 708797, "code": "xmldoc_has_inside(struct ast_xml_node *fixnode, const char *what)\n{\n\tstruct ast_xml_node *node = fixnode;\n\n\tfor (node = ast_xml_node_get_children(fixnode); node; node = ast_xml_node_get_next(node)) {\n\t\tif (!strcasecmp(ast_xml_node_get_name(node), what)) {\n\t\t\treturn 1;\n\t\t}\n\t}\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 84 }, { "index": 549825, "code": "get_ringtone_name(int id, gn_data *data, struct gn_statemachine *state)\n{\n\tint i;\n\n\tinit_ringtone_list(data, state);\n\n\tfor (i = 0; i < ringtone_list.count; i++) {\n\t\tif (ringtone_list.ringtone[i].location == id)\n\t\t\treturn ringtone_list.ringtone[i].name;\n\t}\n\n\treturn _(\"Unknown\");\n}", "label": 0, "cwe": null, "length": 83 }, { "index": 863064, "code": "acl_copy_entry(acl_entry_t dest_d, acl_entry_t src_d)\n{\n\tacl_entry_obj *dest_p = ext2int(acl_entry, dest_d),\n\t *src_p = ext2int(acl_entry, src_d);\n\tif (!dest_d || !src_p)\n\t\treturn -1;\n\n\tdest_p->etag = src_p->etag;\n\tdest_p->eid = src_p->eid;\n\tdest_p->eperm = src_p->eperm;\n\t__acl_reorder_entry_obj_p(dest_p);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 116 }, { "index": 880051, "code": "__written_first_block(struct f2fs_inode *ri)\n{\n\tblock_t addr = le32_to_cpu(ri->i_addr[0]);\n\n\tif (addr != NEW_ADDR && addr != NULL_ADDR)\n\t\treturn true;\n\treturn false;\n}", "label": 0, "cwe": null, "length": 50 }, { "index": 816438, "code": "alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,\n\t\t\tconst struct hda_fixup *fix, int action)\n{\n\tstruct alc_spec *spec = codec->spec;\n\tunsigned int val;\n\n\tif (action != HDA_FIXUP_ACT_INIT)\n\t\treturn;\n\tval = snd_hda_codec_get_pin_target(codec, 0x0f);\n\tif (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))\n\t\tval |= AC_PINCTL_IN_EN;\n\tval |= AC_PINCTL_VREF_50;\n\tsnd_hda_set_pin_ctl(codec, 0x0f, val);\n\tspec->gen.keep_vref_in_automute = 1;\n}", "label": 0, "cwe": null, "length": 147 }, { "index": 674183, "code": "server_child_watch (GPid pid,\n int status,\n GdmServer *server)\n{\n g_debug (\"GdmServer: child (pid:%d) done (%s:%d)\",\n (int) pid,\n WIFEXITED (status) ? \"status\"\n : WIFSIGNALED (status) ? \"signal\"\n : \"unknown\",\n WIFEXITED (status) ? WEXITSTATUS (status)\n : WIFSIGNALED (status) ? WTERMSIG (status)\n : -1);\n\n g_object_ref (server);\n\n if (WIFEXITED (status)) {\n int code = WEXITSTATUS (status);\n g_signal_emit (server, signals [EXITED], 0, code);\n } else if (WIFSIGNALED (status)) {\n int num = WTERMSIG (status);\n g_signal_emit (server, signals [DIED], 0, num);\n }\n\n g_spawn_close_pid (server->priv->pid);\n server->priv->pid = -1;\n\n g_object_unref (server);\n}", "label": 0, "cwe": null, "length": 237 }, { "index": 878186, "code": "wifi_utils_set_mesh_channel (WifiData *data, guint32 channel)\n{\n\tg_return_val_if_fail (data != NULL, FALSE);\n\tg_return_val_if_fail (channel >= 0, FALSE);\n\tg_return_val_if_fail (channel <= 13, FALSE);\n\tg_return_val_if_fail (data->set_mesh_channel != NULL, FALSE);\n\treturn data->set_mesh_channel (data, channel);\n}", "label": 0, "cwe": null, "length": 83 }, { "index": 39313, "code": "angles()\n{\n // communication buffer for all my Angle info\n\n int ncol = 4;\n int sendrow = static_cast (nangles_local);\n int maxrow;\n MPI_Allreduce(&sendrow,&maxrow,1,MPI_INT,MPI_MAX,world);\n\n int **buf;\n if (me == 0) memory->create(buf,MAX(1,maxrow),ncol,\"write_data:buf\");\n else memory->create(buf,MAX(1,sendrow),ncol,\"write_data:buf\");\n\n // pack my angle data into buf\n\n atom->avec->pack_angle(buf);\n\n // write one chunk of info per proc to file\n // proc 0 pings each proc, receives its chunk, writes to file\n // all other procs wait for ping, send their chunk to proc 0\n\n int tmp,recvrow;\n MPI_Status status;\n MPI_Request request;\n\n int index = 1;\n if (me == 0) {\n fprintf(fp,\"\\nAngles\\n\\n\");\n for (int iproc = 0; iproc < nprocs; iproc++) {\n if (iproc) {\n MPI_Irecv(&buf[0][0],maxrow*ncol,MPI_INT,iproc,0,world,&request);\n MPI_Send(&tmp,0,MPI_INT,iproc,0,world);\n MPI_Wait(&request,&status);\n MPI_Get_count(&status,MPI_INT,&recvrow);\n recvrow /= ncol;\n } else recvrow = sendrow;\n \n atom->avec->write_angle(fp,recvrow,buf,index);\n index += recvrow;\n }\n \n } else {\n MPI_Recv(&tmp,0,MPI_INT,0,0,world,&status);\n MPI_Rsend(&buf[0][0],sendrow*ncol,MPI_INT,0,0,world);\n }\n\n memory->destroy(buf);\n}", "label": 0, "cwe": null, "length": 419 }, { "index": 32948, "code": "ntru_gen_key_pair(struct NtruEncParams *params, NtruEncKeyPair *kp, int (*rng)(unsigned[], int)) {\n int N = params->N;\n int q = params->q;\n int df1 = params->df1;\n int df2 = params->df2;\n int df3 = params->df3;\n\n NtruProdPoly t;\n NtruIntPoly fq;\n\n /* choose a random f that is invertible mod q */\n NtruIntPoly f;\n for (;;) {\n /* choose random t, calculate f=3t+1 */\n ntru_rand_prod(N, df1, df2, df3, df3, &t, rng);\n ntru_prod_to_int(&t, &f);\n ntru_mult_fac(&f, 3);\n f.coeffs[0] += 1;\n\n if (ntru_invert(&f, q, &fq))\n break;\n }\n\n /* by the choice of t, f is always invertible mod 3 and fp=1 */\n NtruIntPoly fp = {N, {0}};\n fp.coeffs[0] = 1;\n\n /* choose a random g that is invertible mod q */\n NtruTernPoly g;\n NtruIntPoly gq;\n int dg = N / 3;\n for (;;) {\n if (!ntru_rand_tern(N, dg, dg-1, &g, rng))\n return 0;\n NtruIntPoly g_int;\n ntru_tern_to_int(&g, &g_int);\n if (ntru_invert(&g_int, q, &gq))\n break;\n }\n\n NtruIntPoly h;\n if (!ntru_mult_tern(&fq, &g, &h))\n return 0;\n ntru_mult_fac(&h, 3);\n ntru_mod(&h, q);\n\n ntru_clear_tern(&g);\n ntru_clear_int(&fq);\n\n NtruEncPrivKey priv = {q, t};\n kp->priv = priv;\n NtruEncPubKey pub = {q, h};\n kp->pub = pub;\n\n return 1;\n}", "label": 0, "cwe": null, "length": 476 }, { "index": 112897, "code": "check_overflow()\n{\n double sum = 0.0;\n int i;\n\n for (i = 0; i < ST_MAX_BASE; i++) {\n sum += b[i];\n }\n if (sum < .00001) { // what happend no data, extremely unlikely\n for (i = 0; i < ST_MAX_BASE; i++)\n b[i] = .25;\n ld_lik -= 5; // ???\n } else {\n while (sum < 0.25) {\n sum *= 4;\n ld_lik -= 2;\n for (i = 0; i < ST_MAX_BASE; i++) {\n b[i] *= 4;\n }\n }\n }\n if (ld_lik> 10000) {\n printf(\"overflow\\n\");\n }\n}", "label": 0, "cwe": null, "length": 180 }, { "index": 69843, "code": "toLineString(const CoordinateSequence& seq)\n{\n\tstringstream buf(ios_base::in|ios_base::out);\n buf << \"LINESTRING \";\n\tunsigned int npts = seq.getSize();\n\tif ( npts == 0 )\n\t{\n\t\tbuf << \"EMPTY\";\n\t}\n\telse\n\t{\n\t\tbuf << \"(\";\n\t\tfor (unsigned int i=0; icanReadLine())\n {\n QString line = QString::fromUtf8(socket->readLine());\n // assuming we get LF as newline\n line.truncate(line.length() - 1);\n QTime now = QTime::currentTime();\n\n if (chat_re.search(line) != -1)\n {\n info_text->append(QString(\"%1 %2 %3\")\n\t\t\t.arg(now.toString(\"hh:mm:ss\"))\n\t\t\t.arg(chat_re.cap(2))\n\t\t\t.arg(chat_re.cap(3)));\n emit chatReceived();\n }\n else if (monitor_re.search(line) != -1)\n {\n if (handle_message(retr_board, board_str, monitor_re.cap(3)))\n {\n\tNetworkBoard board(board_str);\n\n\tif (!monitoring)\n\t{\n\t gotBoard(board.getCsa());\n\t monitoring = true;\n\t}\n\telse\n\t{\n\t QString last_move = board.getValue(\"Last_Move\");\n\n\t if (last_move[0] == last_player[0])\n\t {\n\t monitoring = false;\n\t monitor->setChecked(false);\n\t last_player = \"*\";\n\t }\n\t else\n\t {\n\t last_player = last_move;\n\t gotLastMove(last_move);\n\t }\n\t}\n\t \n }\n }\n else if (command_re.search(line) != -1)\n {\n handle_command(command_re.cap(1),\n\t\t command_re.cap(2));\n }\n else\n {\n info_text->append(tr(\"SYSTEM:%1\").arg(line));\n }\n }\n}", "label": 0, "cwe": null, "length": 328 }, { "index": 126939, "code": "ISNSDisplay_Port ( SOIP_Ifcp *p_port )\n{\n int ii;\n SOIP_COS unreg_cos;\n\n __LOG_INFO (\"******************** PORT RECORD **************\\n\"); \n ISNSDisplay_Port_Name (&p_port->port_name, p_name);\n ISNSDisplay_Port_Name (&p_port->fabric_port_name, \"Fabric Port\");\n\n __LOG_INFO (\"Symbolic Port Name : %s \\n\", p_port->sym_name); \n\n ISNSDisplay_Node_Name (&p_port->node_name);\n\n ISNSDisplay_IPAddress (&p_port->ip_addr);\n\n ISNSDisplay_HardAddr (&p_port->hard_addr);\n\n ISNSDisplay_Port_Id (&p_port->id);\n\n if (p_port->type != SNS_UNREGISTERED)\n __LOG_INFO (\"Port Type : %d \\n\", p_port->type); \n\n for (ii = 0; ii < 32; ii++)\n if (p_port->fc4_types.bitmap[ii])\n __LOG_INFO (\"FC-4 Types : 0x%2x [%d] \\n\", \n p_port->fc4_types.bitmap[ii], ii);\n\n memset(&unreg_cos, SNS_UNREGISTERED, sizeof(SOIP_COS));\n if (memcmp(&p_port->cos, &unreg_cos, sizeof(SOIP_COS)) != 0)\n __LOG_INFO (\"Port COS : %08X \\n\", (unsigned int)p_port->cos);\n\n __LOG_INFO (\"Port priority : %d \\n\", p_port->priority); \n\n for (ii = 0; ii < ZONE_BITMAP_SIZE; ii++)\n if (p_port->zone_bitmap[ii])\n __LOG_INFO (\"Zone bitmap : 0x%2x [%d] \\n\", \n p_port->zone_bitmap[ii], ii);\n\n __LOG_INFO (\"Remote flag : %d \\n\", p_port->remote); \n __LOG_INFO (\"Device type : %0lx \\n\", *(long *)&p_port->dev_type); \n\n __LOG_INFO (\"\\n***********************************************\\n\"); \n}", "label": 0, "cwe": null, "length": 459 }, { "index": 584524, "code": "connection_mgmt(int lld_no, struct mgmt_task *mtask,\n\t\t\t struct tgtadm_req *req,\n\t\t\t struct tgtadm_rsp *rsp)\n{\n\tint err = TGTADM_INVALID_REQUEST;\n\n\tswitch (req->op) {\n\tcase OP_SHOW:\n\t\tif (tgt_drivers[lld_no]->show) {\n\t\t\terr = tgt_drivers[lld_no]->show(req->mode,\n\t\t\t\t\t\t\treq->tid, req->sid,\n\t\t\t\t\t\t\treq->cid, req->lun,\n\t\t\t\t\t\t\tmtask->buf,\n\t\t\t\t\t\t\tmtask->bsize);\n\t\t\tset_show_results(rsp, &err);\n\t\t\treturn err;\n\t\t}\n\t\tbreak;\n\tdefault:\n\t\tif (tgt_drivers[lld_no]->update)\n\t\t\terr = tgt_drivers[lld_no]->update(req->mode, req->op,\n\t\t\t\t\t\t\t req->tid,\n\t\t\t\t\t\t\t req->sid, req->lun,\n\t\t\t\t\t\t\t req->cid, mtask->buf);\n\t\trsp->err = err;\n\t\trsp->len = sizeof(*rsp);\n\t\tbreak;\n\t}\n\n\treturn err;\n}", "label": 0, "cwe": null, "length": 216 }, { "index": 127059, "code": "p54spi_spi_write_dma(struct p54s_priv *priv, __le32 base,\n\t\t\t\tconst void *buf, size_t len)\n{\n\tif (!p54spi_wait_bit(priv, SPI_ADRS_DMA_WRITE_CTRL, HOST_ALLOWED)) {\n\t\tdev_err(&priv->spi->dev, \"spi_write_dma not allowed \"\n\t\t\t\"to DMA write.\\n\");\n\t\treturn -EAGAIN;\n\t}\n\n\tp54spi_write16(priv, SPI_ADRS_DMA_WRITE_CTRL,\n\t\t cpu_to_le16(SPI_DMA_WRITE_CTRL_ENABLE));\n\n\tp54spi_write16(priv, SPI_ADRS_DMA_WRITE_LEN, cpu_to_le16(len));\n\tp54spi_write32(priv, SPI_ADRS_DMA_WRITE_BASE, base);\n\tp54spi_spi_write(priv, SPI_ADRS_DMA_DATA, buf, len);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 174 }, { "index": 654526, "code": "deltrav(node *p, boolean value)\n{\n /* register p and p's children as deleted or extant, depending on value */\n node *q;\n\n p->deleted = value;\n\n if (p->tip)\n return;\n\n q = p->next;\n do {\n deltrav(q->back, value);\n q = q->next;\n } while (p != q);\n}", "label": 0, "cwe": null, "length": 88 }, { "index": 746652, "code": "createFlippedImage(int horz,\n int vert) const\n{\n if ((Image != NULL) && (horz || vert))\n {\n if (getWidth() <= 1) // can't flip horizontally\n horz = 0;\n if (getHeight() <= 1) // can't flip vertically\n vert = 0;\n DiImage *image;\n if (horz || vert) // flip at least one axis\n image = Image->createFlip(horz, vert);\n else // copy image\n image = Image->createImage(0, getFrameCount());\n if (image != NULL)\n {\n DicomImage *dicom = new DicomImage(this, image);\n return dicom;\n }\n }\n return NULL;\n}", "label": 0, "cwe": null, "length": 171 }, { "index": 115915, "code": "zend_multibyte_detect_utf_encoding(const unsigned char *script, size_t script_size TSRMLS_DC)\n{\n\tconst unsigned char *p;\n\tint wchar_size = 2;\n\tint le = 0;\n\n\t/* utf-16 or utf-32? */\n\tp = script;\n\twhile ((p-script) < script_size) {\n\t\tp = memchr(p, 0, script_size-(p-script)-2);\n\t\tif (!p) {\n\t\t\tbreak;\n\t\t}\n\t\tif (*(p+1) == '\\0' && *(p+2) == '\\0') {\n\t\t\twchar_size = 4;\n\t\t\tbreak;\n\t\t}\n\n\t\t/* searching for UTF-32 specific byte orders, so this will do */\n\t\tp += 4;\n\t}\n\n\t/* BE or LE? */\n\tp = script;\n\twhile ((p-script) < script_size) {\n\t\tif (*p == '\\0' && *(p+wchar_size-1) != '\\0') {\n\t\t\t/* BE */\n\t\t\tle = 0;\n\t\t\tbreak;\n\t\t} else if (*p != '\\0' && *(p+wchar_size-1) == '\\0') {\n\t\t\t/* LE* */\n\t\t\tle = 1;\n\t\t\tbreak;\n\t\t}\n\t\tp += wchar_size;\n\t}\n\n\tif (wchar_size == 2) {\n\t\treturn le ? zend_multibyte_encoding_utf16le : zend_multibyte_encoding_utf16be;\n\t} else {\n\t\treturn le ? zend_multibyte_encoding_utf32le : zend_multibyte_encoding_utf32be;\n\t}\n\n\treturn NULL;\n}", "label": 0, "cwe": null, "length": 330 }, { "index": 589008, "code": "hwloc_read_unit32be(const char *p, const char *p1, uint32_t *buf, int root_fd)\n{\n size_t cb = 0;\n uint32_t *tmp = hwloc_read_raw(p, p1, &cb, root_fd);\n if (sizeof(*buf) != cb) {\n errno = EINVAL;\n free(tmp); /* tmp is either NULL or contains useless things */\n return -1;\n }\n *buf = htonl(*tmp);\n free(tmp);\n return sizeof(*buf);\n}", "label": 0, "cwe": null, "length": 115 }, { "index": 814078, "code": "load_thumbnailers()\n{\n const gchar * const *data_dirs = g_get_system_data_dirs();\n const gchar * const *data_dir;\n\n /* use a temporary hash table to collect thumbnailer basenames\n * key: basename of thumbnailer entry file\n * value: data dir the thumbnailer entry file is in */\n GHashTable* tmp_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);\n\n /* load system-wide thumbnailers */\n for(data_dir = data_dirs; *data_dir; ++data_dir)\n find_thumbnailers_in_data_dir(tmp_hash, *data_dir);\n\n /* load user-specific thumbnailers */\n find_thumbnailers_in_data_dir(tmp_hash, g_get_user_data_dir());\n\n /* load all found thumbnailers */\n g_hash_table_foreach(tmp_hash, (GHFunc)load_thumbnailers_from_data_dir, NULL);\n /* all_thumbnailers = g_list_reverse(all_thumbnailers); */\n g_hash_table_destroy(tmp_hash); /* we don't need the hash table anymore */\n\n /* record current time which will be used to compare with\n * mtime of thumbnailer dirs later */\n last_loaded_time = time(NULL);\n}", "label": 0, "cwe": null, "length": 252 }, { "index": 625874, "code": "onAudioControllerStateChanged( RadioState newState )\n{\n // Stop and resume stopwatch when buffering\n if ( newState == State_Buffering && m_state == State_Streaming )\n {\n m_stationWatch.stop();\n m_trackWatch.stop();\n }\n else if ( newState == State_Streaming && m_state == State_Buffering )\n {\n if ( m_trackWatch.getTime() != 0 )\n {\n LOGL( 3, \"Sending a rebuffer report\" );\n ReportRebufferingRequest* r = new ReportRebufferingRequest();\n QString host = QUrl( m_audioController.currentTrackUrl() ).host();\n r->setStreamerHost( host );\n r->setUserName( The::currentUsername() );\n r->start();\n }\n\n m_stationWatch.start();\n m_trackWatch.start();\n }\n\n if ( m_state == State_Uninitialised ||\n m_state == State_Handshaking || \n m_state == State_Handshaken || \n m_state == State_ChangingStation || \n m_state == State_FetchingPlaylist )\n {\n // Don't let audio controller override these states as we manage\n // them ourselves\n }\n else if ( newState == State_Stopped && m_state != State_Stopping )\n {\n // Just an in-between tracks stop, don't forward\n }\n else\n {\n // Forward all other states on\n setState( newState );\n } \n\n}", "label": 0, "cwe": null, "length": 308 }, { "index": 313045, "code": "abort_connection(struct iwch_ep *ep, struct sk_buff *skb, gfp_t gfp)\n{\n\tPDBG(\"%s ep %p\\n\", __FILE__, ep);\n\tstate_set(&ep->com, ABORTING);\n\tsend_abort(ep, skb, gfp);\n}", "label": 0, "cwe": null, "length": 58 }, { "index": 446243, "code": "newDocument(void)\n{\n\tstd::string template_list[6];\n\n\tbuildTemplateList(template_list, \"normal.awt\");\n\n\tbool success = false;\n\n\tfor (UT_uint32 i = 0; i < 6 && !success; i++) \n\t\tsuccess = (importFile (template_list[i].c_str(), IEFT_Unknown, true, false) == UT_OK);\n\n\tif (!success) {\n\t\t\tm_pPieceTable = new pt_PieceTable(this);\n\t\t\tif (!m_pPieceTable)\n\t\t\t\treturn UT_NOPIECETABLE;\n\n\t\t\tm_pPieceTable->setPieceTableState(PTS_Loading);\n\n\t\t\t// add just enough structure to empty document so we can edit\n\t\t\tappendStrux(PTX_Section,NULL);\n\t\t\tappendStrux(PTX_Block, NULL);\n\n\t\t\t// set standard document properties, such as dtd, lang,\n\t\t\t// dom-dir, etc. (some of the code that used to be here is\n\t\t\t// now in the setAttrProp() function, since it is shared\n\t\t\t// both by new documents and documents being loaded from disk\n\t\t\t// this also initializes m_indexAP\n\t\t\tm_indexAP = 0xffffffff;\n\t\t\tsetAttrProp(NULL);\n\n\t\t\tm_pPieceTable->setPieceTableState(PTS_Editing);\n\t}\n\t//\tm_pPieceTable->getFragments().verifyDoc();\n\n\tsetDocVersion(0);\n\tsetEditTime(0);\n\tsetLastOpenedTime(time(NULL));\n\n\t// set document metadata from context\n\tsetMetaDataProp(PD_META_KEY_CREATOR, m_sUserName);\n \n\t// mark the document as not-dirty\n\t_setClean();\n\tUT_ASSERT(isOrigUUID());\n\n\treturn UT_OK;\n}", "label": 0, "cwe": null, "length": 356 }, { "index": 328055, "code": "smp_fetch_ssl_x_serial(struct proxy *px, struct session *l4, void *l7, unsigned int opt,\n const struct arg *args, struct sample *smp, const char *kw)\n{\n\tint cert_peer = (kw[4] == 'c') ? 1 : 0;\n\tX509 *crt = NULL;\n\tint ret = 0;\n\tstruct chunk *smp_trash;\n\tstruct connection *conn;\n\n\tif (!l4)\n\t\treturn 0;\n\n\tconn = objt_conn(l4->si[0].end);\n\tif (!conn || conn->xprt != &ssl_sock)\n\t\treturn 0;\n\n\tif (!(conn->flags & CO_FL_CONNECTED)) {\n\t\tsmp->flags |= SMP_F_MAY_CHANGE;\n\t\treturn 0;\n\t}\n\n\tif (cert_peer)\n\t\tcrt = SSL_get_peer_certificate(conn->xprt_ctx);\n\telse\n\t\tcrt = SSL_get_certificate(conn->xprt_ctx);\n\n\tif (!crt)\n\t\tgoto out;\n\n\tsmp_trash = get_trash_chunk();\n\tif (ssl_sock_get_serial(crt, smp_trash) <= 0)\n\t\tgoto out;\n\n\tsmp->data.str = *smp_trash;\n\tsmp->type = SMP_T_BIN;\n\tret = 1;\nout:\n\t/* SSL_get_peer_certificate, it increase X509 * ref count */\n\tif (cert_peer && crt)\n\t\tX509_free(crt);\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 300 }, { "index": 67521, "code": "line_adj(float *x1, float *y1, float *x2, float *y2, int left){\n float xd = *x2-*x1;\n float yd = *y2-*y1;\n float M = hypot(xd,yd);\n\n if(left){\n *x1 += yd/M*ADJ;\n *x2 += yd/M*ADJ;\n *y1 += -xd/M*ADJ;\n *y2 += -xd/M*ADJ;\n }else{\n *x1 += -yd/M*ADJ;\n *x2 += -yd/M*ADJ;\n *y1 += xd/M*ADJ;\n *y2 += xd/M*ADJ;\n }\n\n // make sure there's an overlap!\n *x1-=xd/M*4.;\n *x2+=xd/M*4.;\n *y1-=yd/M*4.;\n *y2+=yd/M*4.;\n}", "label": 0, "cwe": null, "length": 218 }, { "index": 518954, "code": "DoProf6args (\n Obj self,\n Obj arg1,\n Obj arg2,\n Obj arg3,\n Obj arg4,\n Obj arg5,\n Obj arg6 )\n{\n Obj result; /* value of function call, result */\n Obj prof; /* profiling bag */\n UInt timeElse; /* time spent elsewhere */\n UInt timeCurr; /* time spent in current funcs. */\n UInt storElse; /* storage spent elsewhere */\n UInt storCurr; /* storage spent in current funcs. */ \n\n /* get the profiling bag */\n prof = PROF_FUNC( PROF_FUNC( self ) );\n\n /* time and storage spent so far while this function what not active */\n timeElse = SyTime() - TIME_WITH_PROF(prof);\n storElse = SizeAllBags - STOR_WITH_PROF(prof);\n\n /* time and storage spent so far by all currently suspended functions */\n timeCurr = SyTime() - TimeDone;\n storCurr = SizeAllBags - StorDone;\n\n /* call the real function */\n result = CALL_6ARGS_PROF( self, arg1, arg2, arg3, arg4, arg5, arg6 );\n\n /* number of invocation of this function */\n SET_COUNT_PROF( prof, COUNT_PROF(prof) + 1 );\n\n /* time and storage spent in this function and its children */\n SET_TIME_WITH_PROF( prof, SyTime() - timeElse );\n SET_STOR_WITH_PROF( prof, SizeAllBags - storElse );\n\n /* time and storage spent by this invocation of this function */\n timeCurr = SyTime() - TimeDone - timeCurr;\n SET_TIME_WOUT_PROF( prof, TIME_WOUT_PROF(prof) + timeCurr );\n TimeDone += timeCurr;\n storCurr = SizeAllBags - StorDone - storCurr;\n SET_STOR_WOUT_PROF( prof, STOR_WOUT_PROF(prof) + storCurr );\n StorDone += storCurr;\n\n /* return the result from the function */\n return result;\n}", "label": 0, "cwe": null, "length": 463 }, { "index": 41525, "code": "listSchemas(const char *pattern, bool verbose)\n{\n\tPQExpBufferData buf;\n\tPGresult *res;\n\tprintQueryOpt myopt = pset.popt;\n\n\tinitPQExpBuffer(&buf);\n\tprintfPQExpBuffer(&buf,\n\t\t\t\t\t \"SELECT n.nspname AS \\\"%s\\\",\\n\"\n\t\t\t\t\t \" pg_catalog.pg_get_userbyid(n.nspowner) AS \\\"%s\\\"\",\n\t\t\t\t\t gettext_noop(\"Name\"),\n\t\t\t\t\t gettext_noop(\"Owner\"));\n\n\tif (verbose)\n\t{\n\t\tappendPQExpBuffer(&buf, \",\\n \");\n\t\tprintACLColumn(&buf, \"n.nspacl\");\n\t\tappendPQExpBuffer(&buf,\n\t\t \",\\n pg_catalog.obj_description(n.oid, 'pg_namespace') AS \\\"%s\\\"\",\n\t\t\t\t\t\t gettext_noop(\"Description\"));\n\t}\n\n\tappendPQExpBuffer(&buf,\n\t\t\t\t\t \"\\nFROM pg_catalog.pg_namespace n\\n\"\n\t\t\t\t\t \"WHERE\t(n.nspname !~ '^pg_temp_' OR\\n\"\n\t\t \"\t\t n.nspname = (pg_catalog.current_schemas(true))[1])\\n\");\t\t/* temp schema is first */\n\n\tprocessSQLNamePattern(pset.db, &buf, pattern, true, false,\n\t\t\t\t\t\t NULL, \"n.nspname\", NULL,\n\t\t\t\t\t\t NULL);\n\n\tappendPQExpBuffer(&buf, \"ORDER BY 1;\");\n\n\tres = PSQLexec(buf.data, false);\n\ttermPQExpBuffer(&buf);\n\tif (!res)\n\t\treturn false;\n\n\tmyopt.nullPrint = NULL;\n\tmyopt.title = _(\"List of schemas\");\n\tmyopt.translate_header = true;\n\n\tprintQuery(res, &myopt, pset.queryFout, pset.logfile);\n\n\tPQclear(res);\n\treturn true;\n}", "label": 0, "cwe": null, "length": 360 }, { "index": 619896, "code": "error_get_my_stack ( void)\n{\n PRStatus st;\n error_stack *rv;\n PRUintn new_size;\n PRUint32 new_bytes;\n error_stack *new_stack;\n\n if( INVALID_TPD_INDEX == error_stack_index ) {\n st = PR_CallOnce(&error_call_once, error_once_function);\n if( PR_SUCCESS != st ) {\n return (error_stack *)NULL;\n }\n }\n\n rv = (error_stack *)PR_GetThreadPrivate(error_stack_index);\n if( (error_stack *)NULL == rv ) {\n /* Doesn't exist; create one */\n new_size = 16;\n } else if( rv->header.count == rv->header.space &&\n rv->header.count < NSS_MAX_ERROR_STACK_COUNT ) {\n /* Too small, expand it */\n new_size = PR_MIN( rv->header.space * 2, NSS_MAX_ERROR_STACK_COUNT);\n } else {\n /* Okay, return it */\n return rv;\n }\n\n new_bytes = (new_size * sizeof(PRInt32)) + sizeof(error_stack);\n /* Use NSPR's calloc/realloc, not NSS's, to avoid loops! */\n new_stack = PR_Calloc(1, new_bytes);\n \n if( (error_stack *)NULL != new_stack ) {\n if( (error_stack *)NULL != rv ) {\n\t(void)nsslibc_memcpy(new_stack,rv,rv->header.space);\n }\n new_stack->header.space = new_size;\n }\n\n /* Set the value, whether or not the allocation worked */\n PR_SetThreadPrivate(error_stack_index, new_stack);\n return new_stack;\n}", "label": 0, "cwe": null, "length": 346 }, { "index": 775364, "code": "apei_res_sub(struct list_head *res_list1,\n\t\t\tstruct list_head *res_list2)\n{\n\tstruct apei_res *res1, *resn1, *res2, *res;\n\tres1 = list_entry(res_list1->next, struct apei_res, list);\n\tresn1 = list_entry(res1->list.next, struct apei_res, list);\n\twhile (&res1->list != res_list1) {\n\t\tlist_for_each_entry(res2, res_list2, list) {\n\t\t\tif (res1->start >= res2->end ||\n\t\t\t res1->end <= res2->start)\n\t\t\t\tcontinue;\n\t\t\telse if (res1->end <= res2->end &&\n\t\t\t\t res1->start >= res2->start) {\n\t\t\t\tlist_del(&res1->list);\n\t\t\t\tkfree(res1);\n\t\t\t\tbreak;\n\t\t\t} else if (res1->end > res2->end &&\n\t\t\t\t res1->start < res2->start) {\n\t\t\t\tres = kmalloc(sizeof(*res), GFP_KERNEL);\n\t\t\t\tif (!res)\n\t\t\t\t\treturn -ENOMEM;\n\t\t\t\tres->start = res2->end;\n\t\t\t\tres->end = res1->end;\n\t\t\t\tres1->end = res2->start;\n\t\t\t\tlist_add(&res->list, &res1->list);\n\t\t\t\tresn1 = res;\n\t\t\t} else {\n\t\t\t\tif (res1->start < res2->start)\n\t\t\t\t\tres1->end = res2->start;\n\t\t\t\telse\n\t\t\t\t\tres1->start = res2->end;\n\t\t\t}\n\t\t}\n\t\tres1 = resn1;\n\t\tresn1 = list_entry(resn1->list.next, struct apei_res, list);\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 364 }, { "index": 640600, "code": "Read(void* buffer, size_t buffer_len,\n size_t* read, int* error) {\n if (SIZE_UNKNOWN != length_) {\n if (pos_ >= length_)\n return SR_EOS;\n buffer_len = _min(buffer_len, length_ - pos_);\n }\n size_t backup_read;\n if (!read) {\n read = &backup_read;\n }\n StreamResult result = StreamAdapterInterface::Read(buffer, buffer_len,\n read, error);\n if (SR_SUCCESS == result) {\n pos_ += *read;\n }\n return result;\n}", "label": 0, "cwe": null, "length": 125 }, { "index": 559985, "code": "_hb_ot_layout_collect_lookups_features (hb_face_t *face,\n\t\t\t\t\thb_tag_t table_tag,\n\t\t\t\t\tunsigned int script_index,\n\t\t\t\t\tunsigned int language_index,\n\t\t\t\t\tconst hb_tag_t *features,\n\t\t\t\t\thb_set_t *lookup_indexes /* OUT */)\n{\n if (!features)\n {\n unsigned int required_feature_index;\n if (hb_ot_layout_language_get_required_feature_index (face,\n\t\t\t\t\t\t\t table_tag,\n\t\t\t\t\t\t\t script_index,\n\t\t\t\t\t\t\t language_index,\n\t\t\t\t\t\t\t &required_feature_index))\n _hb_ot_layout_collect_lookups_lookups (face,\n\t\t\t\t\t table_tag,\n\t\t\t\t\t required_feature_index,\n\t\t\t\t\t lookup_indexes);\n\n /* All features */\n unsigned int feature_indices[32];\n unsigned int offset, len;\n\n offset = 0;\n do {\n len = ARRAY_LENGTH (feature_indices);\n hb_ot_layout_language_get_feature_indexes (face,\n\t\t\t\t\t\t table_tag,\n\t\t\t\t\t\t script_index,\n\t\t\t\t\t\t language_index,\n\t\t\t\t\t\t offset, &len,\n\t\t\t\t\t\t feature_indices);\n\n for (unsigned int i = 0; i < len; i++)\n\t_hb_ot_layout_collect_lookups_lookups (face,\n\t\t\t\t\t table_tag,\n\t\t\t\t\t feature_indices[i],\n\t\t\t\t\t lookup_indexes);\n\n offset += len;\n } while (len == ARRAY_LENGTH (feature_indices));\n }\n else\n {\n for (; *features; features++)\n {\n unsigned int feature_index;\n if (hb_ot_layout_language_find_feature (face,\n\t\t\t\t\t table_tag,\n\t\t\t\t\t script_index,\n\t\t\t\t\t language_index,\n\t\t\t\t\t *features,\n\t\t\t\t\t &feature_index))\n _hb_ot_layout_collect_lookups_lookups (face,\n\t\t\t\t\t table_tag,\n\t\t\t\t\t feature_index,\n\t\t\t\t\t lookup_indexes);\n }\n }\n}", "label": 0, "cwe": null, "length": 350 }, { "index": 1002147, "code": "fc_lport_enter_fdmi(struct fc_lport *lport)\n{\n\tstruct fc_rport_priv *rdata;\n\n\tFC_LPORT_DBG(lport, \"Entered FDMI state from %s state\\n\",\n\t\t fc_lport_state(lport));\n\n\tfc_lport_state_enter(lport, LPORT_ST_FDMI);\n\n\tmutex_lock(&lport->disc.disc_mutex);\n\trdata = lport->tt.rport_create(lport, FC_FID_MGMT_SERV);\n\tmutex_unlock(&lport->disc.disc_mutex);\n\tif (!rdata)\n\t\tgoto err;\n\n\trdata->ops = &fc_lport_rport_ops;\n\tlport->tt.rport_login(rdata);\n\treturn;\n\nerr:\n\tfc_lport_error(lport, NULL);\n}", "label": 0, "cwe": null, "length": 155 }, { "index": 342446, "code": "has_checkpointed() {\n bool changed = false;\n if (checkpoint_filename.size() == 0) return false;\n struct stat new_stat;\n int retval = stat(checkpoint_filename.c_str(), &new_stat);\n if (retval) return false;\n if (!stat_first && new_stat.st_mtime != last_stat.st_mtime) {\n changed = true;\n }\n stat_first = false;\n last_stat.st_mtime = new_stat.st_mtime;\n return changed;\n }", "label": 0, "cwe": null, "length": 102 }, { "index": 109704, "code": "__suspend_report_result(const char *function, void *fn, int ret)\n{\n\tif (ret)\n\t\tprintk(KERN_ERR \"%s(): %pF returns %d\\n\", function, fn, ret);\n}", "label": 0, "cwe": null, "length": 44 }, { "index": 730207, "code": "request_free (Request *r)\n{\n\tif (!g_cancellable_is_cancelled (r->cancellable))\n\t\tg_hash_table_remove (APPLET_AGENT_GET_PRIVATE (r->agent)->requests, GUINT_TO_POINTER (r->id));\n\n\t/* By the time the request is freed, all keyring calls should be completed */\n\tg_warn_if_fail (r->keyring_calls == 0);\n\n\tg_object_unref (r->connection);\n\tg_free (r->path);\n\tg_free (r->setting_name);\n\tg_strfreev (r->hints);\n\tg_object_unref (r->cancellable);\n\tmemset (r, 0, sizeof (*r));\n\tg_slice_free (Request, r);\n}", "label": 0, "cwe": null, "length": 143 }, { "index": 1295, "code": "enter_initial_dirs(MainInfo *min, const gchar *dirleft, const gchar *dirright)\n{\n\tconst gchar\t*dir;\n\tconst gchar\t*odir[2];\n\tconst gchar\t*cmd[] = { \"ActivateLeft\", \"ActivateRight\" };\n\tgint\t\ti;\n\tgboolean\tok = TRUE;\n\n\todir[0] = dirleft;\n\todir[1] = dirright;\n\tfor(i = sizeof cmd / sizeof *cmd - 1; i >= 0; i--)\n\t{\n\t\tif((dir = odir[i]) == NULL)\n\t\t{\n\t\t\tdir = min->cfg.dp_format[i].def_path;\n\t\t\tif(!dir[0])\n\t\t\t\tdir = dph_history_get_first(&min->gui->pane[i]);\n\t\t}\n\t\tif(dir == NULL)\n\t\t\tdir = usr_get_home();\n\t\tcsq_execute(min, cmd[i]);\n\t\tok &= csq_execute_format(min, \"DirEnter 'dir=%s'\", stu_escape(dir)) != 0;\n\t}\n\n\treturn ok;\n}", "label": 0, "cwe": null, "length": 214 }, { "index": 297131, "code": "make_matrix_xtab (double **X, int n, \n\t\t\t const gretl_matrix *vx,\n\t\t\t const gretl_matrix *vy,\n\t\t\t gretl_matrix *tab)\n{\n int xr, xc, rndx, cndx;\n int counter, i;\n\n qsort(X, n, sizeof *X, compare_xtab_rows);\n\n /* compute frequencies by going through sorted X */\n\n counter = rndx = cndx = 0;\n xr = (int) gretl_vector_get(vx, 0);\n xc = (int) gretl_vector_get(vy, 0);\n\n for (i=0; i xr) { \n\t /* skip row */\n\t gretl_matrix_set(tab, rndx, cndx, counter);\n\t counter = 0;\n\t xr = gretl_vector_get(vx, ++rndx);\n\t cndx = 0;\n\t xc = gretl_vector_get(vy, 0);\n\t}\n\twhile (X[i][1] > xc) { \n\t /* skip column */\n\t gretl_matrix_set(tab, rndx, cndx, counter);\n\t counter = 0;\n\t xc = gretl_vector_get(vy, ++cndx);\n\t}\n\tcounter++;\n }\n gretl_matrix_set(tab, rndx, cndx, counter);\n}", "label": 1, "cwe": "CWE-other", "length": 298 }, { "index": 449829, "code": "camp_get_result_list()\n{\n List *list = list_create( LIST_AUTO_DELETE, LIST_NO_CALLBACK );\n if (camp_cur_scen->nexts) {\n const char *str;\n list_reset( camp_cur_scen->nexts );\n while ( ( str = list_next( camp_cur_scen->nexts ) ) ) {\n List *tokens;\n if ( ( tokens = parser_split_string( str, \">\" ) ) ) {\n list_add( list, strdup(list_first( tokens )) );\n list_delete( tokens );\n }\n }\n }\n return list;\n}", "label": 0, "cwe": null, "length": 125 }, { "index": 830297, "code": "sort_order (const void *l, const void *r)\n{\n int i;\n const struct hrec *left = l;\n const struct hrec *right = r;\n\n if (user_sort)\t/* If Sort by username, compare users */\n {\n\tif ((i = strcmp (left->user, right->user)) != 0)\n\t return i;\n }\n if (module_sort)\t/* If sort by modules, compare module names */\n {\n\tif (left->mod && right->mod)\n\t if ((i = strcmp (left->mod, right->mod)) != 0)\n\t\treturn i;\n }\n if (repos_sort)\t/* If sort by repository, compare them. */\n {\n\tif ((i = strcmp (left->repos, right->repos)) != 0)\n\t return i;\n }\n if (file_sort)\t/* If sort by filename, compare files, NOT dirs. */\n {\n\tif ((i = strcmp (left->file, right->file)) != 0)\n\t return i;\n\n\tif (working)\n\t{\n\t if ((i = strcmp (left->dir, right->dir)) != 0)\n\t\treturn i;\n\n\t if ((i = strcmp (left->end, right->end)) != 0)\n\t\treturn i;\n\t}\n }\n\n /*\n * By default, sort by date, time\n * XXX: This fails after 2030 when date slides into sign bit\n */\n if ((i = ((long) (left->date) - (long) (right->date))) != 0)\n\treturn i;\n\n /* For matching dates, keep the sort stable by using record index */\n return left->idx - right->idx;\n}", "label": 1, "cwe": "CWE-120", "length": 365 }, { "index": 585953, "code": "glade_gtk_cell_renderer_read_widget (GladeWidgetAdaptor * adaptor,\n GladeWidget * widget, GladeXmlNode * node)\n{\n if (!(glade_xml_node_verify_silent (node, GLADE_XML_TAG_WIDGET) ||\n\tglade_xml_node_verify_silent (node, GLADE_XML_TAG_TEMPLATE)))\n return;\n\n /* First chain up and read in all the properties... */\n GWA_GET_CLASS (G_TYPE_OBJECT)->read_widget (adaptor, widget, node);\n\n g_signal_connect (glade_widget_get_project (widget), \"parse-finished\",\n G_CALLBACK (glade_gtk_cell_renderer_parse_finished),\n widget);\n}", "label": 0, "cwe": null, "length": 139 }, { "index": 836768, "code": "create_target_regex (const char *target, guint *version, GError **error)\n{\n GRegex *regex;\n char *pattern;\n char *version_str;\n\n *version = 0;\n /* Make sure we have enough room for version pattern */\n pattern = g_strndup (target,\n strlen (target) + strlen (VERSION_PATTERN));\n\n version_str = get_version_for_target (pattern);\n if (version_str != NULL) {\n *version = atoi (version_str);\n strcpy (version_str, VERSION_PATTERN);\n }\n\n regex = g_regex_new (pattern, 0, 0, error);\n\n g_free (pattern);\n\n return regex;\n}", "label": 0, "cwe": null, "length": 145 }, { "index": 123854, "code": "get_tp_parameters (GoaAccount *account)\n{\n GHashTable *params = g_hash_table_new_full (g_str_hash, g_str_equal,\n NULL, g_free);\n const char *type = goa_account_get_provider_type (account);\n\n#define PARAM(key, value) g_hash_table_insert (params, key, g_strdup (value));\n\n if (!tp_strdiff (type, \"google\"))\n {\n PARAM (\"manager\", \"gabble\");\n PARAM (\"protocol\", \"jabber\");\n PARAM (\"Icon\", \"im-google-talk\");\n PARAM (\"Service\", \"google-talk\");\n\n PARAM (\"param-account\", goa_account_get_identity (account));\n PARAM (\"param-server\", \"talk.google.com\");\n PARAM (\"param-fallback-servers\",\n \"talkx.l.google.com;\"\n \"talkx.l.google.com:443,oldssl;\"\n \"talkx.l.google.com:80\");\n PARAM (\"param-extra-certificate-identities\", \"talk.google.com\");\n PARAM (\"param-require-encryption\", \"true\");\n }\n else if (!tp_strdiff (type, \"facebook\"))\n {\n PARAM (\"manager\", \"gabble\");\n PARAM (\"protocol\", \"jabber\");\n PARAM (\"Icon\", \"im-facebook\");\n PARAM (\"Service\", \"facebook\");\n\n PARAM (\"param-account\", \"chat.facebook.com\");\n PARAM (\"param-server\", \"chat.facebook.com\");\n PARAM (\"param-require-encryption\", \"true\");\n PARAM (\"param-fallback-servers\",\n \"chat.facebook.com:443\");\n }\n else if (!tp_strdiff (type, \"windows_live\"))\n {\n PARAM (\"manager\", \"gabble\");\n PARAM (\"protocol\", \"jabber\");\n PARAM (\"Icon\", \"im-msn\");\n PARAM (\"Service\", \"windows-live\");\n\n PARAM (\"param-account\", \"messenger.live.com\");\n PARAM (\"param-require-encryption\", \"true\");\n PARAM (\"param-fallback-servers\", \"xmpp.messenger.live.com\");\n PARAM (\"param-extra-certificate-identities\",\n \"*.gateway.messenger.live.com\");\n }\n else\n {\n DEBUG (\"Unknown account type %s\", type);\n g_hash_table_unref (params);\n return NULL;\n }\n\n /* generic properties */\n PARAM (\"DisplayName\", goa_account_get_presentation_identity (account));\n\n#undef PARAM\n\n return params;\n}", "label": 0, "cwe": null, "length": 495 }, { "index": 657651, "code": "authenticateUserRequestUsername(auth_user_request_t * auth_user_request)\n{\n assert(auth_user_request != NULL);\n if (auth_user_request->auth_user)\n\treturn authenticateUserUsername(auth_user_request->auth_user);\n else\n\treturn NULL;\n}", "label": 1, "cwe": "CWE-476", "length": 51 }, { "index": 96235, "code": "bus_expirelist_expire (BusExpireList *list)\n{\n int next_interval;\n\n next_interval = -1;\n\n if (list->items != NULL)\n {\n long tv_sec, tv_usec;\n\n _dbus_get_monotonic_time (&tv_sec, &tv_usec);\n\n next_interval = do_expiration_with_monotonic_time (list, tv_sec, tv_usec);\n }\n\n bus_expire_timeout_set_interval (list->timeout, next_interval);\n}", "label": 0, "cwe": null, "length": 99 }, { "index": 113594, "code": "krb5_c_random_to_key(krb5_context context, krb5_enctype enctype,\n krb5_data *random_data, krb5_keyblock *random_key)\n{\n krb5_error_code ret;\n const struct krb5_keytypes *ktp;\n\n if (random_data == NULL || random_key == NULL ||\n random_key->contents == NULL)\n return EINVAL;\n\n ktp = find_enctype(enctype);\n if (ktp == NULL)\n return KRB5_BAD_ENCTYPE;\n\n if (random_key->length != ktp->enc->keylength)\n return KRB5_BAD_KEYSIZE;\n\n ret = ktp->rand2key(random_data, random_key);\n if (ret)\n zap(random_key->contents, random_key->length);\n\n return ret;\n}", "label": 0, "cwe": null, "length": 169 }, { "index": 69790, "code": "front(void)\n{\n pair* s = &invalid_rep;\n int ret = pthread_mutex_trylock(&lock_rep);\n\n if (ret != 0 && \n cmds_rep.size() >= bounded_execution_queue_size_limit()) {\n /* queue has grown beyond the rt-safe maximum size, \n * change to non-bounded mode to force synchronization\n * between the producer and consumer threads \n */\n KVU_NOTE_SD(\"queue-limit-when-size=\", cmds_rep.size());\n ret = pthread_mutex_lock(&lock_rep);\n }\n\n if (ret == 0) {\n /* now that we have the lock, we can safely process\n * any pending pop requests */\n DBC_CHECK(cmds_rep.size() >= pending_pops_rep);\n while(pending_pops_rep > 0 &&\n\t cmds_rep.size() > 0) {\n cmds_rep.pop_front();\n --pending_pops_rep;\n KVU_NOTE_SD(\"dec-pending-pop=\", pending_pops_rep);\n }\n KVU_NOTE_SD(\"front-when-size=\", cmds_rep.size());\n s = &cmds_rep.front();\n pthread_mutex_unlock(&lock_rep);\n }\n\n return s;\n}", "label": 0, "cwe": null, "length": 249 }, { "index": 136838, "code": "_safe_dlclose(dbi_driver_t *driver) {\n int may_close = 0;\n\n may_close = dbi_driver_cap_get((dbi_driver)driver, \"safe_dlclose\");\n if (may_close) {\n my_dlclose(driver->dlhandle);\n return 0;\n }\n return 1;\n}", "label": 0, "cwe": null, "length": 70 }, { "index": 928148, "code": "anthy_read_line(char ***tokens, int *nr)\n{\n get_line();\n *tokens = g_ps.tokens;\n *nr = g_ps.nr_token;\n if (!*nr) {\n return -1;\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 55 }, { "index": 470477, "code": "collision_wall_exact(double *xs, int iwall, double *vs,\n double *xscoll, double *xbcoll,\n double *norm)\n{\n int dim = wallwhich[iwall] / 2;\n\n double dt = (xs[dim] - xwall[iwall]) / (vs[dim] - vwall[iwall]);\n xscoll[0] = xs[0] - dt*vs[0];\n xscoll[1] = xs[1] - dt*vs[1];\n xscoll[2] = xs[2] - dt*vs[2];\n\n xbcoll[0] = xbcoll[1] = xbcoll[2] = 0.0;\n xbcoll[dim] = xwall[iwall] - dt*vwall[iwall];\n\n int side = wallwhich[iwall] % 2;\n norm[0] = norm[1] = norm[2] = 0.0;\n if (side == 0) norm[dim] = 1.0;\n else norm[dim] = -1.0;\n\n return dt;\n}", "label": 0, "cwe": null, "length": 242 }, { "index": 445883, "code": "sgen_pin_stats_register_address (char *addr, int pin_type)\n{\n\tPinStatAddress **node_ptr = &pin_stat_addresses;\n\tPinStatAddress *node;\n\tint pin_type_bit = 1 << pin_type;\n\n\twhile (*node_ptr) {\n\t\tnode = *node_ptr;\n\t\tif (addr == node->addr) {\n\t\t\tnode->pin_types |= pin_type_bit;\n\t\t\treturn;\n\t\t}\n\t\tif (addr < node->addr)\n\t\t\tnode_ptr = &node->left;\n\t\telse\n\t\t\tnode_ptr = &node->right;\n\t}\n\n\tnode = sgen_alloc_internal_dynamic (sizeof (PinStatAddress), INTERNAL_MEM_STATISTICS, TRUE);\n\tnode->addr = addr;\n\tnode->pin_types = pin_type_bit;\n\tnode->left = node->right = NULL;\n\n\t*node_ptr = node;\n}", "label": 0, "cwe": null, "length": 173 }, { "index": 797999, "code": "fold_ctor_reference (tree type, tree ctor, unsigned HOST_WIDE_INT offset,\n\t\t unsigned HOST_WIDE_INT size, tree from_decl)\n{\n tree ret;\n\n /* We found the field with exact match. */\n if (useless_type_conversion_p (type, TREE_TYPE (ctor))\n && !offset)\n return canonicalize_constructor_val (unshare_expr (ctor), from_decl);\n\n /* We are at the end of walk, see if we can view convert the\n result. */\n if (!AGGREGATE_TYPE_P (TREE_TYPE (ctor)) && !offset\n /* VIEW_CONVERT_EXPR is defined only for matching sizes. */\n && !compare_tree_int (TYPE_SIZE (type), size)\n && !compare_tree_int (TYPE_SIZE (TREE_TYPE (ctor)), size))\n {\n ret = canonicalize_constructor_val (unshare_expr (ctor), from_decl);\n ret = fold_unary (VIEW_CONVERT_EXPR, type, ret);\n if (ret)\n\tSTRIP_NOPS (ret);\n return ret;\n }\n if (TREE_CODE (ctor) == STRING_CST)\n return fold_string_cst_ctor_reference (type, ctor, offset, size);\n if (TREE_CODE (ctor) == CONSTRUCTOR)\n {\n\n if (TREE_CODE (TREE_TYPE (ctor)) == ARRAY_TYPE\n\t || TREE_CODE (TREE_TYPE (ctor)) == VECTOR_TYPE)\n\treturn fold_array_ctor_reference (type, ctor, offset, size,\n\t\t\t\t\t from_decl);\n else\n\treturn fold_nonarray_ctor_reference (type, ctor, offset, size,\n\t\t\t\t\t from_decl);\n }\n\n return NULL_TREE;\n}", "label": 0, "cwe": null, "length": 345 }, { "index": 264574, "code": "trace_symlink_cbk (call_frame_t *frame, void *cookie, xlator_t *this,\n int32_t op_ret, int32_t op_errno,\n inode_t *inode, struct iatt *buf,\n struct iatt *preparent, struct iatt *postparent)\n{\n char *statstr = NULL;\n char *preparentstr = NULL;\n char *postparentstr = NULL;\n\n if (trace_fop_names[GF_FOP_SYMLINK].enabled) {\n if (op_ret >= 0) {\n statstr = trace_stat_to_str (buf);\n preparentstr = trace_stat_to_str (preparent);\n postparentstr = trace_stat_to_str (postparent);\n\n gf_log (this->name, GF_LOG_INFO,\n \"%\"PRId64\": gfid=%s (op_ret=%d \"\n \"*stbuf = {%s}, *preparent = {%s}, \"\n \"*postparent = {%s})\",\n frame->root->unique, uuid_utoa (inode->gfid),\n op_ret, statstr, preparentstr, postparentstr);\n\n if (statstr)\n GF_FREE (statstr);\n\n if (preparentstr)\n GF_FREE (preparentstr);\n\n if (postparentstr)\n GF_FREE (postparentstr);\n\n } else {\n gf_log (this->name, GF_LOG_INFO,\n \"%\"PRId64\": op_ret=%d, op_errno=%d\",\n frame->root->unique, op_ret, op_errno);\n }\n }\n\n frame->local = NULL;\n STACK_UNWIND_STRICT (symlink, frame, op_ret, op_errno, inode, buf,\n preparent, postparent);\n return 0;\n}", "label": 0, "cwe": null, "length": 378 }, { "index": 29165, "code": "copy_zend_constant(zend_constant *c)\n{\n\tc->name = zend_strndup(c->name, c->name_len - 1);\n\tif (!(c->flags & CONST_PERSISTENT)) {\n\t\tzval_copy_ctor(&c->value);\n\t}\n}", "label": 0, "cwe": null, "length": 57 }, { "index": 57611, "code": "mlmatch_aux(list_t *data,list_t* pattern,char* str,char* exp, \n\tint min_len)\n{\nif (data==NULL)\n\treturn NULL;\nelse\n\t{\n\tint rc;\n\trc = mlmatch_find(data,pattern,str,exp,pattern,NULL,0);\n\n\t//FIX may be faster if not recalculated each time\n\tif(rc >= min_len) \n\t\t{\n\t\tlist_t* tmp;\n\t\ttmp = malloc(sizeof(list_t));\n\t\tMALLOC_CHECK(tmp);\n\t\t\n\t\ttmp->data=new_answer(data,rc,pattern);\n\t\tMALLOC_CHECK(tmp->data);\n\t\ttmp->next=(mlmatch_aux(data->next,pattern,str,exp,min_len));\n\n\t\treset_dustlen(pattern);\n\t\treturn tmp;\n\t\t}\n\telse\n\t\t{\n\t\treset_dustlen(pattern);\n\t\treturn mlmatch_aux(data->next,pattern,str,exp,min_len);\n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 189 }, { "index": 335523, "code": "cfg_doc_enum(cfg_printer_t *pctx, const cfg_type_t *type) {\n\tconst char * const *p;\n\tcfg_print_chars(pctx, \"( \", 2);\n\tfor (p = type->of; *p != NULL; p++) {\n\t\tcfg_print_cstr(pctx, *p);\n\t\tif (p[1] != NULL)\n\t\t\tcfg_print_chars(pctx, \" | \", 3);\n\t}\n\tcfg_print_chars(pctx, \" )\", 2);\n}", "label": 0, "cwe": null, "length": 102 }, { "index": 30058, "code": "cfg_find_section(struct CFG_SECTIONS *c, char *name)\n{\n struct CFG_ENTRIES* e;\n int i;\n\n for (i = 0; i < c->sec_count; i++)\n\tif (0 == strcasecmp(c->sec_names[i],name))\n\t return c->sec_entries[i];\n\n /* 404 not found => create a new one */\n if ((c->sec_count % ALLOC_SIZE) == (ALLOC_SIZE-2)) {\n\tc->sec_names = realloc(c->sec_names,(c->sec_count+2+ALLOC_SIZE)*sizeof(char*));\n\tc->sec_entries = realloc(c->sec_entries,(c->sec_count+2+ALLOC_SIZE)*sizeof(struct CFG_ENTRIES*));\n }\n e = cfg_init_entries();\n c->sec_names[c->sec_count] = strdup(name);\n c->sec_entries[c->sec_count] = e;\n c->sec_count++; \n c->sec_names[c->sec_count] = NULL;\n c->sec_entries[c->sec_count] = NULL;\n return e;\n}", "label": 0, "cwe": null, "length": 227 }, { "index": 192024, "code": "dwc2_release_channel_ddma(struct dwc2_hsotg *hsotg,\n\t\t\t\t struct dwc2_qh *qh)\n{\n\tstruct dwc2_host_chan *chan = qh->channel;\n\n\tif (dwc2_qh_is_non_per(qh)) {\n\t\tif (hsotg->core_params->uframe_sched > 0)\n\t\t\thsotg->available_host_channels++;\n\t\telse\n\t\t\thsotg->non_periodic_channels--;\n\t} else {\n\t\tdwc2_update_frame_list(hsotg, qh, 0);\n\t}\n\n\t/*\n\t * The condition is added to prevent double cleanup try in case of\n\t * device disconnect. See channel cleanup in dwc2_hcd_disconnect().\n\t */\n\tif (chan->qh) {\n\t\tif (!list_empty(&chan->hc_list_entry))\n\t\t\tlist_del(&chan->hc_list_entry);\n\t\tdwc2_hc_cleanup(hsotg, chan);\n\t\tlist_add_tail(&chan->hc_list_entry, &hsotg->free_hc_list);\n\t\tchan->qh = NULL;\n\t}\n\n\tqh->channel = NULL;\n\tqh->ntd = 0;\n\n\tif (qh->desc_list)\n\t\tmemset(qh->desc_list, 0, sizeof(struct dwc2_hcd_dma_desc) *\n\t\t dwc2_max_desc_num(qh));\n}", "label": 0, "cwe": null, "length": 287 }, { "index": 864483, "code": "cht_codec_init(struct snd_soc_pcm_runtime *runtime)\n{\n\tint ret;\n\tint jack_type;\n\tstruct cht_mc_private *ctx = snd_soc_card_get_drvdata(runtime->card);\n\tstruct snd_soc_jack *jack = &ctx->jack;\n\n\t/**\n\t* TI supports 4 butons headset detection\n\t* KEY_MEDIA\n\t* KEY_VOICECOMMAND\n\t* KEY_VOLUMEUP\n\t* KEY_VOLUMEDOWN\n\t*/\n\tif (ctx->ts3a227e_present)\n\t\tjack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE |\n\t\t\t\t\tSND_JACK_BTN_0 | SND_JACK_BTN_1 |\n\t\t\t\t\tSND_JACK_BTN_2 | SND_JACK_BTN_3;\n\telse\n\t\tjack_type = SND_JACK_HEADPHONE | SND_JACK_MICROPHONE;\n\n\tret = snd_soc_card_jack_new(runtime->card, \"Headset Jack\",\n\t\t\t\t\tjack_type, jack, NULL, 0);\n\n\tif (ret) {\n\t\tdev_err(runtime->dev, \"Headset Jack creation failed %d\\n\", ret);\n\t\treturn ret;\n\t}\n\n\tif (ctx->ts3a227e_present)\n\t\tsnd_soc_jack_notifier_register(jack, &cht_jack_nb);\n\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 262 }, { "index": 9455, "code": "rsvg_new_filter (void)\n{\n RsvgFilter *filter;\n\n filter = g_new (RsvgFilter, 1);\n _rsvg_node_init (&filter->super, RSVG_NODE_TYPE_FILTER);\n filter->filterunits = objectBoundingBox;\n filter->primitiveunits = userSpaceOnUse;\n filter->x = _rsvg_css_parse_length (\"-10%\");\n filter->y = _rsvg_css_parse_length (\"-10%\");\n filter->width = _rsvg_css_parse_length (\"120%\");\n filter->height = _rsvg_css_parse_length (\"120%\");\n filter->super.set_atts = rsvg_filter_set_args;\n return (RsvgNode *) filter;\n}", "label": 0, "cwe": null, "length": 145 }, { "index": 590125, "code": "extfs_init(struct vmodule *module)\n{\n char *extfs_dir, *extfs_conf;\n struct filebuf *fb;\n int fd;\n int res;\n char *line;\n char *c;\n\n extfs_dir = av_get_config(\"moduledir\");\n extfs_dir = av_stradd(extfs_dir, \"/extfs\", NULL);\n extfs_conf = av_stradd(NULL, extfs_dir, \"/extfs.ini\", NULL);\n\n fd = open(extfs_conf, O_RDONLY);\n if(fd == -1) {\n res = -errno;\n av_log(AVLOG_WARNING, \"Could not open extfs config file %s: %s\", \n extfs_conf, strerror(errno));\n av_free(extfs_conf);\n av_free(extfs_dir);\n return res;\n }\n av_free(extfs_conf);\n \n fb = av_filebuf_new(fd, 0);\n\n while(1) {\n res = av_filebuf_getline(fb, &line, -1);\n if(res < 0 || line == NULL)\n break;\n\n if (*line != '#') {\n c = line + strlen(line) - 1;\n if(*c == '\\n') *c-- = '\\0';\n\n if(*line) \n res = create_extfs_handler(module, extfs_dir, line);\n }\n av_free(line);\n if(res < 0) \n break;\n }\n av_unref_obj(fb);\n av_free(extfs_dir);\n \n if(res < 0)\n return res;\n\n return 0;\n}", "label": 0, "cwe": null, "length": 339 }, { "index": 51513, "code": "GetTCPChannel(GF_RTSPSession *sess, u8 rtpID, u8 rtcpID, Bool RemoveIt)\n{\n\tGF_TCPChan *ptr;\n\tu32 i, count = gf_list_count(sess->TCPChannels);\n\tfor (i=0; iTCPChannels, i);\n\t\tif (ptr->rtpID == rtpID) goto exit;;\n\t\tif (ptr->rtcpID == rtcpID) goto exit;\n\t}\n\treturn NULL;\nexit:\n\tif (RemoveIt) gf_list_rem(sess->TCPChannels, i);\n\treturn ptr;\n}", "label": 0, "cwe": null, "length": 138 }, { "index": 266158, "code": "jspEvaluateVar(JsVar *str, JsVar *scope, bool parseTwice) {\n JsLex lex;\n JsVar *v = 0;\n\n assert(jsvIsString(str));\n jslInit(&lex, str);\n\n JSP_SAVE_EXECUTE();\n JsExecInfo oldExecInfo = execInfo;\n execInfo.lex = &lex;\n execInfo.execute = EXEC_YES;\n bool scopeAdded = false;\n if (scope) {\n // if we're adding a scope, make sure it's the *only* scope\n execInfo.scopeCount = 0;\n scopeAdded = jspeiAddScope(scope);\n }\n\n if (parseTwice) {\n JsExecFlags oldFlags = execInfo.execute;\n execInfo.execute = EXEC_PARSE_FUNCTION_DECL;\n while (!JSP_SHOULDNT_PARSE && execInfo.lex->tk != LEX_EOF) {\n jsvUnLock(v);\n v = jspeBlockOrStatement();\n }\n jslReset(execInfo.lex); // back to beginning\n execInfo.execute = oldFlags; // old flags\n }\n\n while (!JSP_SHOULDNT_PARSE && execInfo.lex->tk != LEX_EOF) {\n jsvUnLock(v);\n v = jspeBlockOrStatement();\n }\n // clean up\n if (scopeAdded)\n jspeiRemoveScope();\n jslKill(&lex);\n\n // restore state and execInfo\n JSP_RESTORE_EXECUTE();\n oldExecInfo.execute = execInfo.execute; // JSP_RESTORE_EXECUTE has made this ok.\n execInfo = oldExecInfo;\n\n // It may have returned a reference, but we just want the value...\n if (v) {\n return jsvSkipNameAndUnLock(v);\n }\n // nothing returned\n return 0;\n}", "label": 0, "cwe": null, "length": 386 }, { "index": 540710, "code": "array_tounicode(arrayobject *self, PyObject *unused)\n{\n if (self->ob_descr->typecode != 'u') {\n PyErr_SetString(PyExc_ValueError,\n \"tounicode() may only be called on unicode type arrays\");\n return NULL;\n }\n return PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND,\n (Py_UCS4 *) self->ob_item,\n Py_SIZE(self));\n}", "label": 0, "cwe": null, "length": 93 }, { "index": 459708, "code": "set_intersection_multi(PySetObject *so, PyObject *args)\n{\n Py_ssize_t i;\n PyObject *result = (PyObject *)so;\n\n if (PyTuple_GET_SIZE(args) == 0)\n return set_copy(so);\n\n Py_INCREF(so);\n for (i=0 ; ires || domain == info->orig_domain)\n\t\treturn;\n\tinfo->res = mono_g_hash_table_lookup (domain->ldstr_table, info->ins);\n}", "label": 0, "cwe": null, "length": 61 }, { "index": 560832, "code": "format_add_lineend(const char *text, const char *linestart)\n{\n\tGString *str;\n\tchar *ret;\n\n\tif (linestart == NULL)\n\t\treturn g_strdup(text);\n\n\tif (strchr(text, '\\n') == NULL)\n\t\treturn g_strconcat(text, linestart, NULL);\n\n\tstr = g_string_new(NULL);\n\twhile (*text != '\\0') {\n\t\tif (*text == '\\n')\n\t\t\tg_string_append(str, linestart);\n\t\tg_string_append_c(str, *text);\n\t\ttext++;\n\t}\n\tg_string_append(str, linestart);\n\n\tret = str->str;\n\tg_string_free(str, FALSE);\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 140 }, { "index": 666583, "code": "request_data_reference(REQUEST *request,\n\t\t void *unique_ptr, int unique_int)\n{\n\trequest_data_t **last;\n\n\tfor (last = &(request->data); *last != NULL; last = &((*last)->next)) {\n\t\tif (((*last)->unique_ptr == unique_ptr) &&\n\t\t ((*last)->unique_int == unique_int)) {\n\t\t\trequest_data_t *this = *last;\n\t\t\tvoid *ptr = this->opaque;\n\n\t\t\treturn ptr;\n\t\t}\n\t}\n\n\treturn NULL;\t\t/* wasn't found, too bad... */\n}", "label": 0, "cwe": null, "length": 116 }, { "index": 926723, "code": "encode_bcd_number(const char *number, unsigned char *out)\n{\n\twhile (number[0] != '\\0' && number[1] != '\\0') {\n\t\t*out = to_semi_oct(*number++);\n\t\t*out++ |= to_semi_oct(*number++) << 4;\n\t}\n\n\tif (*number)\n\t\t*out = to_semi_oct(*number) | 0xf0;\n}", "label": 0, "cwe": null, "length": 87 }, { "index": 23527, "code": "pdf_authenticate_user_password(pdf_crypt *crypt, unsigned char *password, int pwlen)\n{\n\tunsigned char output[32];\n\tpdf_compute_user_password(crypt, password, pwlen, output);\n\tif (crypt->r == 2 || crypt->r == 5 || crypt->r == 6)\n\t\treturn memcmp(output, crypt->u, 32) == 0;\n\tif (crypt->r == 3 || crypt->r == 4)\n\t\treturn memcmp(output, crypt->u, 16) == 0;\n\treturn 0;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-other" ], "length": 119 }, { "index": 55057, "code": "main(int argc, const char* argv[])\n{\n Proto** P,*tf;\n int i=doargs(argc,argv);\n argc-=i; argv+=i;\n if (argc<=0) usage(\"no input files given\",NULL);\n L=lua_open(0);\n P=luaM_newvector(L,argc,Proto*);\n for (i=0; iinode, out);\n\n ret = mq_inode_ctx_get (loc->inode, this, &ctx);\n if (ret < 0)\n goto out;\n\n contribution = mq_add_new_contribution_node (this, ctx, loc);\n if (contribution == NULL) {\n ret = -1;\n goto out;\n }\n\n mq_initiate_quota_txn (this, loc);\nout:\n return ret;\n}", "label": 0, "cwe": null, "length": 178 }, { "index": 256187, "code": "list_directory_contents(wsh_command *cmd) {\r\n\r\n struct dirent *dir;\r\n DIR *ls_dir = (1 == cmd->nargs) ? opendir(\".\") : opendir(cmd->args2D[1]);\r\n\r\n if (NULL == ls_dir) {\r\n perror(\"wsh\");\r\n exit(EXIT_FAILURE);\r\n }\r\n\r\n while (NULL != (dir = readdir(ls_dir))) {\r\n printf(\"%s\\n\", dir->d_name);\r\n }\r\n\r\n closedir(ls_dir);\r\n return OK;\r\n\r\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 122088, "code": "match_rr_type(type_operator operator,\n char *value,\n\t char *mvalue)\n{\n\tldns_rr_type a,b;\n\t\n\ta = ldns_get_rr_type_by_name(value);\n\tb = ldns_get_rr_type_by_name(mvalue);\n\t\n\tswitch (operator) {\n\t\tcase OP_EQUAL:\n\t\t\treturn a == b;\n\t\t\tbreak;\n\t\tcase OP_NOTEQUAL:\n\t\t\treturn a != b;\n\t\t\tbreak;\n\t\tcase OP_GREATER:\n\t\t\treturn a > b;\n\t\t\tbreak;\n\t\tcase OP_LESSER:\n\t\t\treturn a < b;\n\t\t\tbreak;\n\t\tcase OP_GREATEREQUAL:\n\t\t\treturn a >= b;\n\t\t\tbreak;\n\t\tcase OP_LESSEREQUAL:\n\t\t\treturn a <= b;\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tfprintf(stderr, \"Unknown operator: %u\\n\", operator);\n\t\t\texit(2);\n\t}\n}", "label": 0, "cwe": null, "length": 174 }, { "index": 653634, "code": "exit_jfs_fs(void)\n{\n\tint i;\n\n\tjfs_info(\"exit_jfs_fs called\");\n\n\ttxExit();\n\tmetapage_exit();\n\n\tkthread_stop(jfsIOthread);\n\tfor (i = 0; i < commit_threads; i++)\n\t\tkthread_stop(jfsCommitThread[i]);\n\tkthread_stop(jfsSyncThread);\n#ifdef PROC_FS_JFS\n\tjfs_proc_clean();\n#endif\n\tunregister_filesystem(&jfs_fs_type);\n\n\t/*\n\t * Make sure all delayed rcu free inodes are flushed before we\n\t * destroy cache.\n\t */\n\trcu_barrier();\n\tkmem_cache_destroy(jfs_inode_cachep);\n}", "label": 0, "cwe": null, "length": 134 }, { "index": 576667, "code": "show_branch_access_expression(ivl_expr_t net, unsigned ind)\n{\n ivl_branch_t bra = ivl_expr_branch(net);\n ivl_nature_t nature = ivl_expr_nature(net);\n fprintf(out, \"%*s\\n\",\n\t ind, \"\", bra, ivl_nature_name(nature));\n\n if (ivl_expr_value(net) != IVL_VT_REAL) {\n\t fprintf(out, \"%*sERROR: Expecting type IVL_VT_REAL, got %s\\n\",\n\t\t ind, \"\", vt_type_string(net));\n\t stub_errors += 1;\n }\n\n ivl_nexus_t ta = ivl_branch_terminal(bra, 0);\n ivl_nexus_t tb = ivl_branch_terminal(bra, 1);\n\n ivl_discipline_t ta_disc = discipline_of_nexus(ta);\n if (ta_disc == 0) {\n\t fprintf(out, \"%*sERROR: Source terminal of branch has no discipline\\n\",\n\t\t ind, \"\");\n\t stub_errors += 1;\n\t return;\n }\n\n ivl_discipline_t tb_disc = discipline_of_nexus(tb);\n if (ta_disc == 0) {\n\t fprintf(out, \"%*sERROR: Reference terminal of branch has no discipline\\n\",\n\t\t ind, \"\");\n\t stub_errors += 1;\n\t return;\n }\n\n if (ta_disc != tb_disc) {\n\t fprintf(out, \"%*sERROR: Branch terminal disciplines mismatch: %s != %s\\n\",\n\t\t ind, \"\", ivl_discipline_name(ta_disc),\n\t\t ivl_discipline_name(tb_disc));\n\t stub_errors += 1;\n }\n}", "label": 0, "cwe": null, "length": 352 }, { "index": 812501, "code": "player_check_by_bishop (int start_pos, int mod, int *moves_array)\n{\n /* Pretend king is a bishop/queen and generate moves. If king can then \n * attack an enemy's rook/queen, king is in check. */\n init_moves_board (moves_array);\n gen_sliding_moves (start_pos, mod, MOVE_DU_RIGHT, moves_array);\n gen_sliding_moves (start_pos, mod, MOVE_DD_RIGHT, moves_array);\n gen_sliding_moves (start_pos, mod, MOVE_DD_LEFT, moves_array);\n gen_sliding_moves (start_pos, mod, MOVE_DU_LEFT, moves_array);\n\n int i;\n for (i = 0; i < BOARD_SIZE; i++) {\n if ((moves_array[i] == TRUE) \n && (board[i] == chp_wbishop * mod \n || board[i] == chp_wqueen * mod)) {\n return TRUE;\n }\n }\n return FALSE;\n}", "label": 0, "cwe": null, "length": 209 }, { "index": 230136, "code": "rip_out_paths( const Environments &envs, map &version_map, map &versionfile_map )\n{\n version_map.clear();\n\n Environments env2;\n\n static const char *suffs[] = { \".tar.bz2\", \".tar.gz\", \".tar\", \".tgz\" };\n\n string versfile;\n\n for ( Environments::const_iterator it = envs.begin(); it != envs.end(); ++it )\n {\n for ( int i = 0; i < 4; i++ )\n if ( endswith( it->second, suffs[i], versfile ) )\n {\n versionfile_map[it->first] = it->second;\n versfile = find_basename( versfile );\n version_map[it->first] = versfile;\n env2.push_back( make_pair( it->first, versfile ) );\n }\n }\n return env2;\n}", "label": 0, "cwe": null, "length": 198 }, { "index": 822870, "code": "uih_cycling_on(struct uih_context *c)\n{\n if (c->zengine->fractalc->palette != NULL &&\n\tc->zengine->fractalc->palette->cyclecolors != NULL) {\n\tc->cycling = 1;\n\ttl_update_time();\n\tc->cyclingtimer = tl_create_timer();\n\tuih_emulatetimers(c);\n\tuih_setcycling(c, c->cyclingspeed);\n\ttl_set_multihandler(c->cyclingtimer, uih_cyclinghandler, c);\n\ttl_add_timer(syncgroup, c->cyclingtimer);\n } else {\n\tuih_updatemenus(c, \"cycling\");\n\tuih_updatemenus(c, \"rcycling\");\n\treturn 0;\n }\n uih_updatemenus(c, \"cycling\");\n uih_updatemenus(c, \"rcycling\");\n return 1;\n}", "label": 0, "cwe": null, "length": 191 }, { "index": 472809, "code": "aarch64_symbol_binds_local_p (const_rtx x)\n{\n return (SYMBOL_REF_DECL (x)\n\t ? targetm.binds_local_p (SYMBOL_REF_DECL (x))\n\t : SYMBOL_REF_LOCAL_P (x));\n}", "label": 0, "cwe": null, "length": 52 }, { "index": 774076, "code": "bowed_freq_toss_fetch(susp, snd_list)\n register bowed_freq_susp_type susp;\n snd_list_type snd_list;\n{\n long final_count = susp->susp.toss_cnt;\n time_type final_time = susp->susp.t0;\n long n;\n\n /* fetch samples from bowpress_env up to final_time for this block of zeros */\n while ((round((final_time - susp->bowpress_env->t0) * susp->bowpress_env->sr)) >=\n\t susp->bowpress_env->current)\n\tsusp_get_samples(bowpress_env, bowpress_env_ptr, bowpress_env_cnt);\n /* fetch samples from freq_env up to final_time for this block of zeros */\n while ((round((final_time - susp->freq_env->t0) * susp->freq_env->sr)) >=\n\t susp->freq_env->current)\n\tsusp_get_samples(freq_env, freq_env_ptr, freq_env_cnt);\n /* convert to normal processing when we hit final_count */\n /* we want each signal positioned at final_time */\n n = round((final_time - susp->bowpress_env->t0) * susp->bowpress_env->sr -\n (susp->bowpress_env->current - susp->bowpress_env_cnt));\n susp->bowpress_env_ptr += n;\n susp_took(bowpress_env_cnt, n);\n n = round((final_time - susp->freq_env->t0) * susp->freq_env->sr -\n (susp->freq_env->current - susp->freq_env_cnt));\n susp->freq_env_ptr += n;\n susp_took(freq_env_cnt, n);\n susp->susp.fetch = susp->susp.keep_fetch;\n (*(susp->susp.fetch))(susp, snd_list);\n}", "label": 0, "cwe": null, "length": 378 }, { "index": 123695, "code": "zaxisDefVct(int zaxisID, int size, const double *vct)\n{\n zaxis_t *zaxisptr;\n\n if ( reshGetStatus ( zaxisID, &zaxisOps ) == CLOSED )\n {\n xwarning(\"%s\", \"Operation not executed.\");\n return;\n }\n\n zaxisptr = ( zaxis_t * ) reshGetVal ( zaxisID, &zaxisOps );\n\n zaxis_check_ptr(zaxisID, zaxisptr);\n\n if ( zaxisptr->vct == 0 )\n {\n zaxisptr->vctsize = size;\n zaxisptr->vct = (double *) malloc(size*sizeof(double));\n memcpy(zaxisptr->vct, vct, size*sizeof(double));\n }\n else\n if ( zaxisptr->vctsize != size )\n Warning(\"VCT was already defined\");\n}", "label": 1, "cwe": "CWE-120", "length": 190 }, { "index": 62857, "code": "atou(char **sp)\n#else\nstatic Vmulong_t atou(sp)\nchar **sp;\n#endif\n{\n char *s = *sp;\n Vmulong_t v = 0;\n\n if (s[0] == '0' && (s[1] == 'x' || s[1] == 'X')) {\n\tfor (s += 2; *s; ++s) {\n\t if (*s >= '0' && *s <= '9')\n\t\tv = (v << 4) + (*s - '0');\n\t else if (*s >= 'a' && *s <= 'f')\n\t\tv = (v << 4) + (*s - 'a') + 10;\n\t else if (*s >= 'A' && *s <= 'F')\n\t\tv = (v << 4) + (*s - 'A') + 10;\n\t else\n\t\tbreak;\n\t}\n } else {\n\tfor (; *s; ++s) {\n\t if (*s >= '0' && *s <= '9')\n\t\tv = v * 10 + (*s - '0');\n\t else\n\t\tbreak;\n\t}\n }\n\n *sp = s;\n return v;\n}", "label": 0, "cwe": null, "length": 262 }, { "index": 853287, "code": "swan_vk_release_all_key(int sockfd)\n{\n\tu16 code;\n\tssize_t wrlen;\n\tstruct input_event events[2] =\n\t{\n\t\t{\n\t\t\t.type = EV_KEY,\n\t\t\t.value = 0\n\t\t},\n\t\t{\n\t\t\t.type = EV_SYN,\n\t\t\t.code = SYN_REPORT,\n\t\t\t.value = 0\n\t\t}\n\t};\n\n\tfor (code = 0; code < KEY_MAX; code++)\n\t{\n\t\tevents[0].code = code;\n\t\twrlen = inet_send(sockfd, (char *) events, sizeof(events));\n\t\tif (wrlen < 0)\n\t\t{\n\t\t\treturn wrlen;\n\t\t}\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 148 }, { "index": 105344, "code": "gap_dvref_debug_print_GapDrawableVideoRef(GapDrawableVideoRef *dvref)\n{\n if(gap_debug)\n {\n if(dvref == NULL)\n {\n printf(\"GapDrawableVideoRef: dvref:(null)\\n\");\n return;\n }\n if(dvref->videofile == NULL)\n {\n printf(\"GapDrawableVideoRef: videofile:(null) frame:%d seltrack:%d (%s)\\n\"\n ,dvref->para.framenr\n ,dvref->para.seltrack\n ,&dvref->para.preferred_decoder[0]\n );\n return;\n }\n\n printf(\"GapDrawableVideoRef: videofile:%s frame:%d seltrack:%d (%s)\\n\"\n ,dvref->videofile\n ,dvref->para.framenr\n ,dvref->para.seltrack\n ,&dvref->para.preferred_decoder[0]\n );\n }\n}", "label": 0, "cwe": null, "length": 210 }, { "index": 582621, "code": "test_index_conflicts__remove(void)\n{\n\tconst git_index_entry *entry;\n\tsize_t i;\n\n\tcl_assert(git_index_entrycount(repo_index) == 8);\n\n\tcl_git_pass(git_index_conflict_remove(repo_index, \"conflicts-one.txt\"));\n\tcl_assert(git_index_entrycount(repo_index) == 5);\n\n\tfor (i = 0; i < git_index_entrycount(repo_index); i++) {\n\t\tcl_assert(entry = git_index_get_byindex(repo_index, i));\n\t\tcl_assert(strcmp(entry->path, \"conflicts-one.txt\") != 0);\n\t}\n\n\tcl_git_pass(git_index_conflict_remove(repo_index, \"conflicts-two.txt\"));\n\tcl_assert(git_index_entrycount(repo_index) == 2);\n\n\tfor (i = 0; i < git_index_entrycount(repo_index); i++) {\n\t\tcl_assert(entry = git_index_get_byindex(repo_index, i));\n\t\tcl_assert(strcmp(entry->path, \"conflicts-two.txt\") != 0);\n\t}\n}", "label": 1, "cwe": "CWE-476", "length": 208 }, { "index": 79727, "code": "operator*(vnl_real_npolynomial const& P) const\n{\n assert(nvar_ == P.nvar_); // both polynomials must have the same variables\n\n vnl_vector coef(nterms_*P.nterms_);\n unsigned int k = 0;\n for (unsigned int i=0; i poly(nterms_*P.nterms_,nvar_);\n k = 0;\n for (unsigned int i=0; iblock->no);\n\tprint_array_du_semnode(smil->sm->module, store_range);\n\tprintf(\"####store range end####\\n\");\n }\n\n for (aduts = store_range; aduts != NULL; aduts = aduts->next) {\n\t\n\tif (is_local_memory_in_sm(smil->sm, aduts->entry)) {\n\n\t dest_lower = make_semtree_scalar_var(smil->sm->module);\n\t dest_upper = make_semtree_scalar_var(smil->sm->module);\n\t \n\t range_stm = make_store_range_stm(smil, aduts, \n\t\t\t\t\t &dest_lower, \n\t\t\t\t\t &dest_upper);\n\t if (opt_lad_sm_cmp_debug) {\n\n\t\tprintf(\"lower var entry : %d\\n\", \n\t\t semtree_to_scalar(dest_lower)->entry);\n\t\tprintf(\"upper var entry : %d\\n\", \n\t\t semtree_to_scalar(dest_upper)->entry);\n\n\t }\n\t \n\t dtu_stm = make_store_dtu_param_and_kick_checkf(smil,\n\t\t\t\t\t\t\t aduts,\n\t\t\t\t\t\t\t source_lower, /* ?? */\n\t\t\t\t\t\t\t source_upper, /* ?? */\n\t\t\t\t\t\t\t dest_lower,\n\t\t\t\t\t\t\t dest_upper);\n\t \n\t append_statement(&range_stm, dtu_stm);\n\n\t if (opt_lad_sm_cmp_debug) {\n\t\trange_stm = insert_debug_statement(smil,\n\t\t\t\t\t\t smil->block->post_head,\n\t\t\t\t\t\t range_stm,\n\t\t\t\t\t\t 1);\n\t }\n\t insert_stm(smil->block->post_head, NULL, range_stm);\n\t}\n }\n}", "label": 0, "cwe": null, "length": 437 }, { "index": 765991, "code": "TCSP_DirRead_Internal(TCS_CONTEXT_HANDLE hContext,\t/* in */\n\t\t TCPA_DIRINDEX dirIndex,\t/* in */\n\t\t TCPA_DIRVALUE * dirValue)\t/* out */\n{\n\tUINT64 offset = 0;\n\tUINT32 paramSize;\n\tTSS_RESULT result;\n\tBYTE txBlob[TSS_TPM_TXBLOB_SIZE];\n\n\tLogDebug(\"Entering DirRead\");\n\tif ((result = ctx_verify_context(hContext)))\n\t\treturn result;\n\n\tif (dirValue == NULL)\n\t\treturn TCSERR(TSS_E_BAD_PARAMETER);\n\n\tif (dirIndex > tpm_metrics.num_dirs)\n\t\treturn TCSERR(TSS_E_BAD_PARAMETER);\n\n\tif ((result = tpm_rqu_build(TPM_ORD_DirRead, &offset, txBlob, dirIndex, NULL)))\n\t\treturn result;\n\n\tif ((result = req_mgr_submit_req(txBlob)))\n\t\treturn result;\n\n\tresult = UnloadBlob_Header(txBlob, ¶mSize);\n\tif (!result) {\n\t\tresult = tpm_rsp_parse(TPM_ORD_DirRead, txBlob, paramSize, NULL, dirValue->digest);\n\t}\n\tLogResult(\"DirRead\", result);\n\treturn result;\n}", "label": 0, "cwe": null, "length": 241 }, { "index": 865905, "code": "tileset_setup_city_tiles(struct tileset *t, int style)\n{\n if (style == game.control.styles_count - 1) {\n\n /* Free old sprites */\n free_city_sprite(t->sprites.city.tile);\n free_city_sprite(t->sprites.city.wall);\n free_city_sprite(t->sprites.city.occupied);\n\n t->sprites.city.tile = load_city_sprite(t, \"city\");\n t->sprites.city.wall = load_city_sprite(t, \"wall\");\n t->sprites.city.occupied = load_city_sprite(t, \"occupied\");\n\n for (style = 0; style < game.control.styles_count; style++) {\n if (t->sprites.city.tile->styles[style].land_num_thresholds == 0) {\n log_fatal(\"City style \\\"%s\\\": no city graphics.\",\n city_style_rule_name(style));\n exit(EXIT_FAILURE);\n }\n if (t->sprites.city.wall->styles[style].land_num_thresholds == 0) {\n log_fatal(\"City style \\\"%s\\\": no wall graphics.\",\n city_style_rule_name(style));\n exit(EXIT_FAILURE);\n }\n if (t->sprites.city.occupied->styles[style].land_num_thresholds == 0) {\n log_fatal(\"City style \\\"%s\\\": no occupied graphics.\",\n city_style_rule_name(style));\n exit(EXIT_FAILURE);\n }\n }\n }\n}", "label": 0, "cwe": null, "length": 284 }, { "index": 80014, "code": "ClientRealm_new()\n{\n ClientRealm* tmp = calloc(1, sizeof(ClientRealm));\n assert(tmp != NULL);\n if (tmp == NULL) {\n return NULL;\n }\n tmp->password[0] = 1;\n tmp->password[1] = 2;\n tmp->password[2] = 3;\n tmp->password[3] = 4;\n tmp->masterSslFd = SslFd_new();\n assert(tmp->masterSslFd != NULL);\n if (tmp->masterSslFd == NULL) {\n ClientRealm_free(&tmp);\n return NULL;\n }\n tmp->arOptions = ArOptions_new();\n assert(tmp->arOptions != NULL);\n if (tmp->arOptions == NULL) {\n ClientRealm_free(&tmp);\n return NULL;\n }\n tmp->httpProxyOptions = HttpProxyOptions_new();\n assert(tmp->httpProxyOptions != NULL);\n if (tmp->httpProxyOptions == NULL) {\n ClientRealm_free(&tmp);\n return NULL;\n }\n#ifdef HAVE_LIBDL\n tmp->userModule = Module_new();\n assert(tmp->userModule != NULL);\n if (tmp->userModule == NULL) {\n ClientRealm_free(&tmp);\n return NULL;\n }\n tmp->serviceModule = Module_new();\n assert(tmp->serviceModule != NULL);\n if (tmp->serviceModule == NULL) {\n ClientRealm_free(&tmp);\n return NULL;\n }\n#endif\n return tmp;\n}", "label": 0, "cwe": null, "length": 320 }, { "index": 476809, "code": "atapi_request_sense(\n\tuint16_t unit,\n\tuint16_t port,\n\tstruct atapi_request_sense *rs\n)\n{\n\tuint16_t *buf = (uint16_t *) rs;\n\tuint8_t command[12];\n\tuint8_t status;\n\tuint16_t count;\n\n\tfor (count = 0; count < sizeof(command) / sizeof(command[0]); count++) {\n\t\tcommand[count] = 0;\n\t}\n\tcommand[0] = ATAPI_REQUEST_SENSE;\n\tcommand[4] = sizeof(*rs);\n\n\t/*\n\t * Send ATAPI command.\n\t */\n\tif (send_atapi_pc(unit, port, (struct atapi_compacket *) command)) {\n\t\treturn 1;\n\t}\n\n\t/*\n\t * Wait for result.\n\t */\n\tdo {\n\t\tstatus = inb(port + 0x206);\n\t} while (status & IDE_BUSY_STAT);\n\tif (status & IDE_ERR_STAT) {\n\t\treturn 1;\n\t}\n\n\t/*\n\t * Get result.\n\t */\n\tfor (count = 0; count < sizeof(*rs) / 2; count++) {\n\t\tassert(status & IDE_DRQ_STAT);\n\t\t*buf++ = inw(port);\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 252 }, { "index": 859090, "code": "i91u_intr(int irqno, void *dev_id)\n{\n\tstruct Scsi_Host *dev = dev_id;\n\tunsigned long flags;\n\tint r;\n\t\n\tspin_lock_irqsave(dev->host_lock, flags);\n\tr = initio_isr((struct initio_host *)dev->hostdata);\n\tspin_unlock_irqrestore(dev->host_lock, flags);\n\tif (r)\n\t\treturn IRQ_HANDLED;\n\telse\n\t\treturn IRQ_NONE;\n}", "label": 0, "cwe": null, "length": 90 }, { "index": 717607, "code": "cpuid (int CPU_number, unsigned int idx,\n\tunsigned long *eax,\n\tunsigned long *ebx,\n\tunsigned long *ecx,\n\tunsigned long *edx)\n{\n\tstatic int nodriver=0;\n\tchar cpuname[20];\n\tunsigned char buffer[16];\n\tint fh;\n\n\tif (nodriver==1) {\n\t\tcpuid_UP(idx, eax, ebx, ecx, edx);\n\t\treturn;\n\t}\n\n\t/* Ok, use the /dev/CPU interface in preference to the _up code. */\n\t(void)snprintf(cpuname,18, \"/dev/cpu/%d/cpuid\", CPU_number);\n\tfh = open(cpuname, O_RDONLY);\n\tif (fh != -1) {\n#ifndef S_SPLINT_S\n\t\tlseek64(fh, (off64_t)idx, SEEK_CUR);\n#endif\n\t\tif (read(fh, &buffer[0], 16) == -1) {\n\t\t\tperror(cpuname);\n\t\t\texit(EXIT_FAILURE);\n\t\t}\n\t\tif (eax!=0)\t*eax = (*(unsigned *)(buffer ));\n\t\tif (ebx!=0)\t*ebx = (*(unsigned *)(buffer+ 4));\n\t\tif (ecx!=0)\t*ecx = (*(unsigned *)(buffer+ 8));\n\t\tif (edx!=0)\t*edx = (*(unsigned *)(buffer+12));\n\t\tif (close(fh) == -1) {\n\t\t\tperror(\"close\");\n\t\t\texit(EXIT_FAILURE);\n\t\t}\n\t} else {\n\t\t/* Something went wrong, just do UP and hope for the best. */\n\t\tnodriver = 1;\n\t\tif (!silent && nrCPUs != 1)\n\t\t\tperror(cpuname);\n\t\tused_UP = 1;\n\t\tcpuid_UP (idx, eax, ebx, ecx, edx);\n\t\treturn;\n\t}\n}", "label": 0, "cwe": null, "length": 371 }, { "index": 875552, "code": "getResultPatternCost(TreePatternNode *P,\n CodeGenDAGPatterns &CGP) {\n if (P->isLeaf()) return 0;\n\n unsigned Cost = 0;\n Record *Op = P->getOperator();\n if (Op->isSubClassOf(\"Instruction\")) {\n Cost++;\n CodeGenInstruction &II = CGP.getTargetInfo().getInstruction(Op);\n if (II.usesCustomInserter)\n Cost += 10;\n }\n for (unsigned i = 0, e = P->getNumChildren(); i != e; ++i)\n Cost += getResultPatternCost(P->getChild(i), CGP);\n return Cost;\n}", "label": 0, "cwe": null, "length": 142 }, { "index": 163334, "code": "fl_insert_browser_line( FL_OBJECT * ob,\n int linenumb,\n const char * newtext )\n{\n FLI_BROWSER_SPEC *sp = ob->spec;\n FLI_TBOX_SPEC *tbsp = sp->tb->spec;\n\n /* When inserting into an empty browser or appending at then end\n it's treated exactly the same way as for fl_add_browser_line()\n (including interpretation of newline characters). */\n\n if ( tbsp->num_lines == 0 || linenumb > tbsp->num_lines )\n fli_tbox_insert_lines( sp->tb, linenumb - 1, newtext );\n else\n fli_tbox_insert_line( sp->tb, linenumb - 1, newtext );\n\n redraw_scrollbar( ob );\n}", "label": 0, "cwe": null, "length": 164 }, { "index": 45907, "code": "GetAttributeAsDouble( const wxString& name, double defVal ) const\n{\n double retVal;\n wxVariant variant = m_attributes.FindValue(name);\n\n if ( wxPGVariantToDouble(variant, &retVal) )\n return retVal;\n\n return defVal;\n}", "label": 0, "cwe": null, "length": 59 }, { "index": 76715, "code": "gen_return (void)\n{\n rtx _val = 0;\n start_sequence ();\n {\n#line 11697 \"../../src/gcc/config/i386/i386.md\"\n{\n if (crtl->args.pops_args)\n {\n rtx popc = GEN_INT (crtl->args.pops_args);\n emit_jump_insn (gen_return_pop_internal (popc));\n DONE;\n }\n}\n }\n emit_jump_insn (gen_rtx_RETURN (VOIDmode));\n _val = get_insns ();\n end_sequence ();\n return _val;\n}", "label": 0, "cwe": null, "length": 119 }, { "index": 370862, "code": "nmn4_check_line(char* line)\n{\n char* c = line;\n int i = 0;\n while ((c = strchr(c, '|'))) {\n c++;\n i++;\n }\n is_fatal((i != 15),\n MYNAME \": Invalid or unknown structure!\");\n}", "label": 0, "cwe": null, "length": 63 }, { "index": 794305, "code": "termorderWeight(PolynomialSet const &g)\n{\n IntegerVector ret=relativeInteriorPoint(g.getRing().getNumberOfVariables(),fastNormals(wallInequalities(g)),0);\n\n // fprintf(stderr,\"WEIGHT\");\n //AsciiPrinter(Stderr).printVector(ret);\n //fprintf(stderr,\"\\n\");\n return ret;\n}", "label": 0, "cwe": null, "length": 72 }, { "index": 488243, "code": "TEMP_TO_REG(long val)\n{\n\treturn via_lut[val <= -50000 ? 0 : val >= 110000 ? 160 :\n\t\t (val < 0 ? val - 500 : val + 500) / 1000 + 50];\n}", "label": 0, "cwe": null, "length": 56 }, { "index": 17101, "code": "on_debug_tree_edit_watch (GtkAction *action, gpointer user_data)\n{\n\tExprWatch * ew = (ExprWatch *)user_data;\n\tGtkTreeIter iter;\n\t\n\tif (debug_tree_get_current (ew->debug_tree, &iter))\n\t{\n\t\tdebug_tree_change_watch_dialog (ew, &iter);\n\t}\n}", "label": 0, "cwe": null, "length": 68 }, { "index": 49288, "code": "LC21(base0)\nregister object *base0;\n{\tregister object *base=vs_base;\n\tregister object *sup=base+VM34; VC34\n\tvs_reserve(VM34);\n\tihs_check;\n\t{object V149;\n\tcheck_arg(1);\n\tV149=(base[0]);\n\tvs_top=sup;\n\tbase[1]=symbol_function(((object)VV[40]));\n\tbase[2]= (V149);\n\tbase[3]= small_fixnum(1);\n\tvs_top=(vs_base=base+2)+2;\n\tfuncall_with_catcher(((object)VV[40]),base[1]);\n\treturn;\n\t}\n}", "label": 0, "cwe": null, "length": 134 }, { "index": 992370, "code": "evas_key_grab_find(Evas_Object *obj, const char *keyname, Evas_Modifier_Mask modifiers, Evas_Modifier_Mask not_modifiers, Eina_Bool exclusive)\n{\n /* MEM OK */\n Eina_List *l;\n Evas_Key_Grab *g;\n\n EINA_LIST_FOREACH(obj->layer->evas->grabs, l, g)\n {\n if ((g->modifiers == modifiers) &&\n (g->not_modifiers == not_modifiers) &&\n (!strcmp(g->keyname, keyname)))\n {\n if ((exclusive) || (obj == g->object)) return g;\n }\n }\n return NULL;\n}", "label": 0, "cwe": null, "length": 146 }, { "index": 379565, "code": "display_type_handles_projection (displayd * display, ProjectionMode pmode)\n{\n gboolean handles = false;\n ProjectionMode v = pmode;\n\n if (GGOBI_IS_EXTENDED_DISPLAY (display)) {\n handles =\n GGOBI_EXTENDED_DISPLAY_GET_CLASS (display)->handles_projection (display,\n v);\n }\n\n return handles;\n}", "label": 1, "cwe": "CWE-476", "length": 73 }, { "index": 966323, "code": "get_framebits(lame_global_flags const *gfp, int frameBits[15])\n{\n lame_internal_flags *const gfc = gfp->internal_flags;\n int bitsPerFrame, i;\n\n /* always use at least this many bits per granule per channel\n * unless we detect analog silence, see below\n */\n gfc->bitrate_index = gfc->VBR_min_bitrate;\n bitsPerFrame = getframebits(gfp);\n\n /* bits for analog silence\n */\n gfc->bitrate_index = 1;\n bitsPerFrame = getframebits(gfp);\n\n for (i = 1; i <= gfc->VBR_max_bitrate; i++) {\n gfc->bitrate_index = i;\n frameBits[i] = ResvFrameBegin(gfp, &bitsPerFrame);\n }\n}", "label": 0, "cwe": null, "length": 187 }, { "index": 50591, "code": "log_debug(int cls, int level, const char *fmt, ...)\n{\n\tva_list ap;\n\n\t/*\n\t * If we are not debugging this class, or the level is too low, just\n\t * return.\n */\n\tif (cls >= 0 && (log_level[cls] == 0 || level > log_level[cls]))\n\t\treturn;\n\tva_start(ap, fmt);\n\t_log_print(0, LOG_INFO, fmt, ap, cls, level);\n\tva_end(ap);\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 70698, "code": "p_pw_propagate_mask_attribute_changes(GapStbPropWidget *pw)\n{\n if(pw->stb_elem_refptr)\n {\n if(pw->is_mask_definition)\n {\n gap_story_dlg_pw_update_mask_references(pw->tabw);\n }\n }\n}", "label": 0, "cwe": null, "length": 61 }, { "index": 52943, "code": "displayOctetList() {\n\tstd::vector octs = Octet::loadOctets(QFile(getEnvSafe(\"UCNA_OCTET_LIST\")));\n\tfor(unsigned int i=0; idualbound;\n DSDPFunctionReturn(0);\n}", "label": 0, "cwe": null, "length": 78 }, { "index": 25053, "code": "init( Chuck_Shell * caller )\n{\n Command * temp;\n \n Command::init( caller );\n \n temp = new Command_CodeSave();\n temp->init( caller );\n commands[\"save\"] = temp;\n allocated_commands.push_back( temp );\n \n temp = new Command_CodeList();\n temp->init( caller );\n commands[\"list\"] = temp;\n allocated_commands.push_back( temp );\n \n temp = new Command_CodePrint();\n temp->init( caller );\n commands[\"print\"] = temp;\n allocated_commands.push_back( temp );\n \n temp = new Command_CodeDelete();\n temp->init( caller );\n commands[\"delete\"] = temp;\n allocated_commands.push_back( temp );\n \n temp = new Command_CodeWrite();\n temp->init( caller );\n commands[\"write\"] = temp;\n allocated_commands.push_back( temp );\n \n temp = new Command_CodeRead();\n temp->init( caller );\n commands[\"read\"] = temp;\n allocated_commands.push_back( temp );\n \n temp = new Command_CodeAdd();\n temp->init( caller );\n commands[\"add\"] = temp;\n commands[\"+\"] = temp;\n allocated_commands.push_back( temp );\n \n return TRUE;\n}", "label": 0, "cwe": null, "length": 260 }, { "index": 330818, "code": "luaG_typeerror(lua_State*L,const TValue*o,const char*op){\nconst char*name=NULL;\nconst char*t=luaT_typenames[ttype(o)];\nconst char*kind=(isinstack(L->ci,o))?\nNULL:\nNULL;\nif(kind)\nluaG_runerror(L,\"attempt to %s %s \"LUA_QL(\"%s\")\" (a %s value)\",\nop,kind,name,t);\nelse\nluaG_runerror(L,\"attempt to %s a %s value\",op,t);\n}", "label": 0, "cwe": null, "length": 110 }, { "index": 664202, "code": "update_wm_state (WnckWindow *window)\n{\n int state;\n\n if (!window->priv->need_update_wm_state)\n return;\n\n window->priv->need_update_wm_state = FALSE;\n\n window->priv->wm_state_iconic = FALSE;\n\n state = _wnck_get_wm_state (WNCK_SCREEN_XSCREEN (window->priv->screen),\n window->priv->xwindow);\n\n if (state == IconicState)\n window->priv->wm_state_iconic = TRUE;\n}", "label": 0, "cwe": null, "length": 112 }, { "index": 101534, "code": "multi_pxo_ban_draw()\n{\t\n\t// if we have a valid bitmap\n\tif(Multi_pxo_banner.ban_bitmap >= 0){\n\t\t// if the mouse is over the banner button, highlight with a rectangle\n\t\tif(Multi_pxo_ban_button.is_mouse_on()){\n\t\t\tgr_set_color_fast(&Color_bright_blue);\n\t\t\tgr_rect(Pxo_ban_coords[gr_screen.res][0] - 1, Pxo_ban_coords[gr_screen.res][1] - 1, Pxo_ban_coords[gr_screen.res][2] + 2, Pxo_ban_coords[gr_screen.res][3] + 2);\n\t\t}\n\n\t\t// draw the bitmap itself\n\t\tgr_set_bitmap(Multi_pxo_banner.ban_bitmap);\n\t\tgr_bitmap(Pxo_ban_coords[gr_screen.res][0], Pxo_ban_coords[gr_screen.res][1]);\n\t}\n}", "label": 0, "cwe": null, "length": 194 }, { "index": 487546, "code": "DrawFeatures(ByteImage &imageArrayBytes,\n Matches::Features &features,\n bool is_draw_orientation) {\n while(features) {\n Byte color = 255;\n float scale = features.feature()->scale;\n float angle = features.feature()->orientation;\n DrawCircle(features.feature()->x(),\n features.feature()->y(),\n scale,\n color,\n &imageArrayBytes);\n if (is_draw_orientation) {\n DrawLine(features.feature()->x(),\n features.feature()->y(),\n features.feature()->x() + scale * cos(angle),\n features.feature()->y() + scale * sin(angle),\n color,\n &imageArrayBytes);\n }\n features.operator++();\n }\n}", "label": 0, "cwe": null, "length": 154 }, { "index": 62220, "code": "operator+(const TagLib::String &s1, const char *s2)\n{\n String s(s1);\n s.append(s2);\n return s;\n}", "label": 0, "cwe": null, "length": 36 }, { "index": 1001020, "code": "requeue(struct smq_policy *mq, struct entry *e)\n{\n\tstruct entry *sentinel;\n\n\tif (!test_and_set_bit(from_cblock(infer_cblock(mq, e)), mq->cache_hit_bits)) {\n\t\tif (e->dirty) {\n\t\t\tsentinel = writeback_sentinel(mq, e->level);\n\t\t\tq_requeue_before(&mq->dirty, sentinel, e, 1u);\n\t\t} else {\n\t\t\tsentinel = demote_sentinel(mq, e->level);\n\t\t\tq_requeue_before(&mq->clean, sentinel, e, 1u);\n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 134 }, { "index": 874719, "code": "memory_write16()\n{\n if (stack >= 2)\n {\n fprintf(out, \" mov.w 2(SP), r15\\n\");\n fprintf(out, \" mov.w @SP, 0(r15)\\n\");\n fprintf(out, \" add.w #4, SP\\n\");\n stack -= 2;\n }\n else\n if (stack == 1)\n {\n //fprintf(out, \" mov.w @SP, 0(r%d)\\n\\n\", REG_STACK(reg-1));\n fprintf(out, \" pop 0(r%d)\\n\", REG_STACK(reg-1));\n reg--;\n stack--;\n }\n else\n {\n fprintf(out, \" mov.w r%d, 0(r%d)\\n\", REG_STACK(reg-1), REG_STACK(reg-2));\n reg -= 2;\n }\n\n return 0;\n}", "label": 0, "cwe": null, "length": 188 }, { "index": 279521, "code": "ipvs_mt_parse(struct xt_option_call *cb)\n{\n\tstruct xt_ipvs_mtinfo *data = cb->data;\n\n\txtables_option_parse(cb);\n\tswitch (cb->entry->id) {\n\tcase O_VPROTO:\n\t\tdata->l4proto = cb->val.protocol;\n\t\tbreak;\n\tcase O_VADDR:\n\t\tmemcpy(&data->vaddr, &cb->val.haddr, sizeof(cb->val.haddr));\n\t\tmemcpy(&data->vmask, &cb->val.hmask, sizeof(cb->val.hmask));\n\t\tbreak;\n\tcase O_VDIR:\n\t\tif (strcasecmp(cb->arg, \"ORIGINAL\") == 0) {\n\t\t\tdata->bitmask |= XT_IPVS_DIR;\n\t\t\tdata->invert &= ~XT_IPVS_DIR;\n\t\t} else if (strcasecmp(cb->arg, \"REPLY\") == 0) {\n\t\t\tdata->bitmask |= XT_IPVS_DIR;\n\t\t\tdata->invert |= XT_IPVS_DIR;\n\t\t} else {\n\t\t\txtables_param_act(XTF_BAD_VALUE,\n\t\t\t\t\t \"ipvs\", \"--vdir\", cb->arg);\n\t\t}\n\t\tbreak;\n\tcase O_VMETHOD:\n\t\tif (strcasecmp(cb->arg, \"GATE\") == 0)\n\t\t\tdata->fwd_method = IP_VS_CONN_F_DROUTE;\n\t\telse if (strcasecmp(cb->arg, \"IPIP\") == 0)\n\t\t\tdata->fwd_method = IP_VS_CONN_F_TUNNEL;\n\t\telse if (strcasecmp(cb->arg, \"MASQ\") == 0)\n\t\t\tdata->fwd_method = IP_VS_CONN_F_MASQ;\n\t\telse\n\t\t\txtables_param_act(XTF_BAD_VALUE,\n\t\t\t\t\t \"ipvs\", \"--vmethod\", cb->arg);\n\t\tbreak;\n\t}\n\tdata->bitmask |= 1 << cb->entry->id;\n\tif (cb->invert)\n\t\tdata->invert |= 1 << cb->entry->id;\n}", "label": 1, "cwe": "CWE-120", "length": 400 }, { "index": 510219, "code": "mono_attach_parse_options (char *options)\n{\n\tif (!options)\n\t\treturn;\n\tif (!strcmp (options, \"disable\"))\n\t\tconfig.enabled = FALSE;\n}", "label": 0, "cwe": null, "length": 34 }, { "index": 70319, "code": "create_expression(CmpInst* C) {\n Expression e;\n\n e.varargs.push_back(lookup_or_add(C->getOperand(0)));\n e.varargs.push_back(lookup_or_add(C->getOperand(1)));\n e.function = 0;\n e.type = C->getType();\n e.opcode = getOpcode(C);\n\n return e;\n}", "label": 0, "cwe": null, "length": 77 }, { "index": 520475, "code": "assemble_start_function (decl, fnname)\n tree decl;\n const char *fnname;\n{\n int align;\n\n /* The following code does not need preprocessing in the assembler. */\n\n app_disable ();\n\n if (CONSTANT_POOL_BEFORE_FUNCTION)\n output_constant_pool (fnname, decl);\n\n resolve_unique_section (decl, 0, flag_function_sections);\n function_section (decl);\n\n /* Tell assembler to move to target machine's alignment for functions. */\n align = floor_log2 (FUNCTION_BOUNDARY / BITS_PER_UNIT);\n if (align < force_align_functions_log)\n align = force_align_functions_log;\n if (align > 0)\n {\n ASM_OUTPUT_ALIGN (asm_out_file, align);\n }\n\n /* Handle a user-specified function alignment.\n Note that we still need to align to FUNCTION_BOUNDARY, as above,\n because ASM_OUTPUT_MAX_SKIP_ALIGN might not do any alignment at all. */\n if (align_functions_log > align\n && cfun->function_frequency != FUNCTION_FREQUENCY_UNLIKELY_EXECUTED)\n {\n#ifdef ASM_OUTPUT_MAX_SKIP_ALIGN\n ASM_OUTPUT_MAX_SKIP_ALIGN (asm_out_file,\n\t\t\t\t align_functions_log, align_functions - 1);\n#else\n ASM_OUTPUT_ALIGN (asm_out_file, align_functions_log);\n#endif\n }\n\n#ifdef ASM_OUTPUT_FUNCTION_PREFIX\n ASM_OUTPUT_FUNCTION_PREFIX (asm_out_file, fnname);\n#endif\n\n (*debug_hooks->begin_function) (decl);\n\n /* Make function name accessible from other files, if appropriate. */\n\n if (TREE_PUBLIC (decl))\n {\n if (! first_global_object_name)\n\t{\n\t const char *p;\n\t char *name;\n\n\t p = (* targetm.strip_name_encoding) (fnname);\n\t name = xstrdup (p);\n\n\t if (! DECL_WEAK (decl) && ! DECL_ONE_ONLY (decl))\n\t first_global_object_name = name;\n\t else\n\t weak_global_object_name = name;\n\t}\n\n globalize_decl (decl);\n\n maybe_assemble_visibility (decl);\n }\n\n /* Do any machine/system dependent processing of the function name */\n#ifdef ASM_DECLARE_FUNCTION_NAME\n ASM_DECLARE_FUNCTION_NAME (asm_out_file, fnname, current_function_decl);\n#else\n /* Standard thing is just output label for the function. */\n ASM_OUTPUT_LABEL (asm_out_file, fnname);\n#endif /* ASM_DECLARE_FUNCTION_NAME */\n}", "label": 0, "cwe": null, "length": 502 }, { "index": 615631, "code": "h_accept(const int fd, const short which, Srv *s)\n{\n conn c;\n int cfd, flags, r;\n socklen_t addrlen;\n struct sockaddr_in6 addr;\n\n addrlen = sizeof addr;\n cfd = accept(fd, (struct sockaddr *)&addr, &addrlen);\n if (cfd == -1) {\n if (errno != EAGAIN && errno != EWOULDBLOCK) twarn(\"accept()\");\n update_conns();\n return;\n }\n\n flags = fcntl(cfd, F_GETFL, 0);\n if (flags < 0) {\n twarn(\"getting flags\");\n close(cfd);\n update_conns();\n return;\n }\n\n r = fcntl(cfd, F_SETFL, flags | O_NONBLOCK);\n if (r < 0) {\n twarn(\"setting O_NONBLOCK\");\n close(cfd);\n update_conns();\n return;\n }\n\n c = make_conn(cfd, STATE_WANTCOMMAND, default_tube, default_tube);\n if (!c) {\n twarnx(\"make_conn() failed\");\n close(cfd);\n update_conns();\n return;\n }\n c->srv = s;\n c->sock.x = c;\n c->sock.f = (Handle)prothandle;\n c->sock.fd = cfd;\n\n dbgprintf(\"accepted conn, fd=%d\\n\", cfd);\n r = sockwant(&c->sock, 'r');\n if (r == -1) {\n twarn(\"sockwant\");\n close(cfd);\n update_conns();\n return;\n }\n update_conns();\n}", "label": 0, "cwe": null, "length": 360 }, { "index": 968639, "code": "fnt_font_done( FNT_Font* font,\n FT_Stream stream )\n {\n if ( font->fnt_frame )\n RELEASE_Frame( font->fnt_frame );\n\n font->fnt_size = 0;\n font->fnt_frame = 0;\n }", "label": 0, "cwe": null, "length": 63 }, { "index": 91901, "code": "HandleMacroEntry(StringRef Name, SMLoc NameLoc,\n const Macro *M) {\n // Arbitrarily limit macro nesting depth, to match 'as'. We can eliminate\n // this, although we should protect against infinite loops.\n if (ActiveMacros.size() == 20)\n return TokError(\"macros cannot be nested more than 20 levels deep\");\n\n // Parse the macro instantiation arguments.\n std::vector > MacroArguments;\n MacroArguments.push_back(std::vector());\n unsigned ParenLevel = 0;\n for (;;) {\n if (Lexer.is(AsmToken::Eof))\n return TokError(\"unexpected token in macro instantiation\");\n if (Lexer.is(AsmToken::EndOfStatement))\n break;\n\n // If we aren't inside parentheses and this is a comma, start a new token\n // list.\n if (ParenLevel == 0 && Lexer.is(AsmToken::Comma)) {\n MacroArguments.push_back(std::vector());\n } else {\n // Adjust the current parentheses level.\n if (Lexer.is(AsmToken::LParen))\n ++ParenLevel;\n else if (Lexer.is(AsmToken::RParen) && ParenLevel)\n --ParenLevel;\n\n // Append the token to the current argument list.\n MacroArguments.back().push_back(getTok());\n }\n Lex();\n }\n\n // Macro instantiation is lexical, unfortunately. We construct a new buffer\n // to hold the macro body with substitutions.\n SmallString<256> Buf;\n StringRef Body = M->Body;\n\n if (expandMacro(Buf, Body, M->Parameters, MacroArguments, getTok().getLoc()))\n return true;\n\n MemoryBuffer *Instantiation =\n MemoryBuffer::getMemBufferCopy(Buf.str(), \"\");\n\n // Create the macro instantiation object and add to the current macro\n // instantiation stack.\n MacroInstantiation *MI = new MacroInstantiation(M, NameLoc,\n getTok().getLoc(),\n Instantiation);\n ActiveMacros.push_back(MI);\n\n // Jump to the macro instantiation and prime the lexer.\n CurBuffer = SrcMgr.AddNewSourceBuffer(MI->Instantiation, SMLoc());\n Lexer.setBuffer(SrcMgr.getMemoryBuffer(CurBuffer));\n Lex();\n\n return false;\n}", "label": 0, "cwe": null, "length": 508 }, { "index": 45435, "code": "gg_pubdir50_get(gg_pubdir50_t res, int num, const char *field)\n{\n\tchar *value = NULL;\n\tint i;\n\n\tgg_debug(GG_DEBUG_FUNCTION, \"** gg_pubdir50_get(%p, %d, \\\"%s\\\");\\n\", res, num, field);\n\n\tif (!res || num < 0 || !field) {\n\t\tgg_debug(GG_DEBUG_MISC, \"// gg_pubdir50_get() invalid arguments\\n\");\n\t\terrno = EINVAL;\n\t\treturn NULL;\n\t}\n\n\tfor (i = 0; i < res->entries_count; i++) {\n\t\tif (res->entries[i].num == num && !strcasecmp(res->entries[i].field, field)) {\n\t\t\tvalue = res->entries[i].value;\n\t\t\tbreak;\n\t\t}\n\t}\n\n\treturn value;\n}", "label": 0, "cwe": null, "length": 173 }, { "index": 790582, "code": "_print_current_dir(Evas_Object *obj)\n{\n Elm_Ctxpopup_Direction dir;\n dir = elm_ctxpopup_direction_get(obj);\n\n switch(dir)\n {\n case ELM_CTXPOPUP_DIRECTION_LEFT:\n printf(\"ctxpopup direction: left!\\n\");\n break;\n case ELM_CTXPOPUP_DIRECTION_RIGHT:\n printf(\"ctxpopup direction: right!\\n\");\n break;\n case ELM_CTXPOPUP_DIRECTION_UP:\n printf(\"ctxpopup direction: up!\\n\");\n break;\n case ELM_CTXPOPUP_DIRECTION_DOWN:\n printf(\"ctxpopup direction: down!\\n\");\n break;\n case ELM_CTXPOPUP_DIRECTION_UNKNOWN:\n printf(\"ctxpopup direction: unknow!\\n\");\n break;\n }\n}", "label": 0, "cwe": null, "length": 159 }, { "index": 980672, "code": "getAssumptionsRef() const\n{\n DebugAssert(!isNull(), \"CVC3::Theorem::getAssumptionsRef: we are Null\");\n if (!isRefl()) {\n return thm()->getAssumptionsRef();\n }\n else return Assumptions::emptyAssump();\n}", "label": 0, "cwe": null, "length": 67 }, { "index": 113239, "code": "find_gatt_server(const bdaddr_t *bdaddr)\n{\n\tGSList *l;\n\n\tl = g_slist_find_custom(servers, bdaddr, adapter_cmp_addr);\n\tif (l == NULL) {\n\t\tchar addr[18];\n\n\t\tba2str(bdaddr, addr);\n\t\terror(\"No GATT server found in %s\", addr);\n\t\treturn NULL;\n\t}\n\n\treturn l->data;\n}", "label": 0, "cwe": null, "length": 87 }, { "index": 365111, "code": "aug_setm(struct augeas *aug, const char *base,\n const char *sub, const char *value) {\n struct pathx *bx = NULL, *sx = NULL;\n struct tree *bt, *st;\n int result, r;\n\n api_entry(aug);\n\n bx = pathx_aug_parse(aug, aug->origin, tree_root_ctx(aug), base, true);\n ERR_BAIL(aug);\n\n if (sub != NULL && STREQ(sub, \".\"))\n sub = NULL;\n\n result = 0;\n for (bt = pathx_first(bx); bt != NULL; bt = pathx_next(bx)) {\n if (sub != NULL) {\n /* Handle subnodes of BT */\n sx = pathx_aug_parse(aug, bt, NULL, sub, true);\n ERR_BAIL(aug);\n if (pathx_first(sx) != NULL) {\n /* Change existing subnodes matching SUB */\n for (st = pathx_first(sx); st != NULL; st = pathx_next(sx)) {\n r = tree_set_value(st, value);\n ERR_NOMEM(r < 0, aug);\n result += 1;\n }\n } else {\n /* Create a new subnode matching SUB */\n r = pathx_expand_tree(sx, &st);\n if (r == -1)\n goto error;\n r = tree_set_value(st, value);\n ERR_NOMEM(r < 0, aug);\n result += 1;\n }\n free_pathx(sx);\n sx = NULL;\n } else {\n /* Set nodes matching BT directly */\n r = tree_set_value(bt, value);\n ERR_NOMEM(r < 0, aug);\n result += 1;\n }\n }\n\n done:\n api_exit(aug);\n return result;\n error:\n result = -1;\n goto done;\n}", "label": 0, "cwe": null, "length": 406 }, { "index": 894386, "code": "lookup(const char *s, const char *d)\n{\n\tconst char *p;\n\n\tif (strncmp(s, d, strlen(d)) != 0) {\n\t\treturn 0;\n\t}\n\tp = s + strlen(d);\n\twhile (*p == ' ') {\n\t\tp++;\n\t}\n\tif (*p != ':') {\n\t\treturn 0;\n\t}\n\tp++;\n\tif (*p != ' ') {\n\t\treturn 0;\n\t}\n\tp++;\n\treturn p - s;\n}", "label": 0, "cwe": null, "length": 97 }, { "index": 414607, "code": "start_next_source(void)\n{\n probe_source(sources + n_started_sources);\n#if 0\n printf(\"Trying to start source %s\\n\", UTI_IPToString(&sources[n_started_sources].ip_addr));\n#endif\n n_started_sources++;\n \n if (n_started_sources < n_sources) {\n source_start_timeout_id = SCH_AddTimeoutByDelay(INTER_SOURCE_START, start_source_timeout_handler, NULL);\n }\n}", "label": 0, "cwe": null, "length": 90 }, { "index": 8087, "code": "replace_shred( const vector< string > &vec,\n string & out )\n{\n if( vec.size() < 2 )\n {\n out += \"replace: error: insufficient arguments...\\n\";\n return FALSE;\n }\n \n t_CKINT i = 0;\n t_CKBOOL return_val;\n vector::size_type j, str_len, vec_len = vec.size() + 1;\n char ** argv = new char * [ vec_len ];\n \n /* prepare an argument vector to submit to otf_send_cmd */\n /* first, specify an add command */\n argv[0] = \"--replace\";\n \n /* copy ids/files into argv */\n for( j = 1; j < vec_len; j++ )\n {\n str_len = vec[j - 1].size() + 1;\n argv[j] = new char [str_len];\n strncpy( argv[j], vec[j - 1].c_str(), str_len );\n }\n \n /* send the command */\n if( otf_send_cmd( vec_len, argv, i, hostname.c_str(), port ) )\n return_val = TRUE;\n \n else\n {\n out += \"replace: error: command failed\\n\";\n return_val = FALSE;\n }\n \n if( vec.size() % 2 != 0 )\n {\n out += \"repalce: warning: ignoring excess arguments\\n\";\n return FALSE;\n }\n \n/* clean up heap data */\n for( j = 1; j < vec_len; j++ )\n delete[] argv[j];\n delete[] argv;\n \n return return_val;\n}", "label": 0, "cwe": null, "length": 348 }, { "index": 800788, "code": "up (uint8_t joystick, uint8_t button)\n{\n Action action = Nothing;\n\n if ( hasConfiguration () &&\n Options::JoystickControls == m_PlayerControls.controlsType &&\n m_PlayerControls.joystick.index == joystick )\n {\n if ( m_PlayerControls.joystick.rotateClockwise == button )\n {\n action = RotateCWReleased;\n }\n else if ( m_PlayerControls.joystick.rotateCounterClockwise == button )\n {\n action = RotateCCWReleased;\n }\n }\n\n return action;\n}", "label": 0, "cwe": null, "length": 112 }, { "index": 99672, "code": "test_object_raw_chars__find_invalid_chars_in_oid(void)\n{\n\tgit_oid out;\n\tunsigned char exp[] = {\n\t\t0x16, 0xa6, 0x77, 0x70, 0xb7,\n\t\t0xd8, 0xd7, 0x23, 0x17, 0xc4,\n\t\t0xb7, 0x75, 0x21, 0x3c, 0x23,\n\t\t0xa8, 0xbd, 0x74, 0xf5, 0xe0,\n\t};\n\tchar in[] = \"16a67770b7d8d72317c4b775213c23a8bd74f5e0\";\n\tunsigned int i;\n\n\tfor (i = 0; i < 256; i++) {\n\t\tin[38] = (char)i;\n\t\tif (git__fromhex(i) >= 0) {\n\t\t\texp[19] = (unsigned char)(git__fromhex(i) << 4);\n\t\t\tcl_git_pass(git_oid_fromstr(&out, in));\n\t\t\tcl_assert(memcmp(out.id, exp, sizeof(out.id)) == 0);\n\t\t} else {\n\t\t\tcl_git_fail(git_oid_fromstr(&out, in));\n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 282 }, { "index": 179757, "code": "verify_path(char *path) {\n int dir = 0, indotseq = 0;\n\n while(*path) {\n if(*path == '/' || *path == '\\\\') {\n if(indotseq)\n return 0;\n if(dir)\n return 0;\n dir = 1;\n path++;\n continue;\n }\n\n if(dir || indotseq) {\n if(*path == '.')\n indotseq = 1;\n else\n indotseq = 0;\n }\n \n dir = 0;\n path++;\n }\n\n return 1;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 130 }, { "index": 3830, "code": "ap_set_send_buffer_size(cmd_parms *cmd,\n void *dummy,\n const char *arg)\n{\n int s = atoi(arg);\n const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);\n\n if (err != NULL) {\n return err;\n }\n\n if (s < 512 && s != 0) {\n return \"SendBufferSize must be >= 512 bytes, or 0 for system default.\";\n }\n\n send_buffer_size = s;\n return NULL;\n}", "label": 0, "cwe": null, "length": 106 }, { "index": 88158, "code": "rtl92cu_card_disable(struct ieee80211_hw *hw)\n{\n\tstruct rtl_priv *rtlpriv = rtl_priv(hw);\n\tstruct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw));\n\tstruct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));\n\tstruct rtl_mac *mac = rtl_mac(rtl_priv(hw));\n\tenum nl80211_iftype opmode;\n\n\tmac->link_state = MAC80211_NOLINK;\n\topmode = NL80211_IFTYPE_UNSPECIFIED;\n\t_rtl92cu_set_media_status(hw, opmode);\n\trtlpriv->cfg->ops->led_control(hw, LED_CTL_POWER_OFF);\n\tRT_SET_PS_LEVEL(ppsc, RT_RF_OFF_LEVL_HALT_NIC);\n\tif (rtlusb->disableHWSM)\n\t\t_CardDisableHWSM(hw);\n\telse\n\t\t_CardDisableWithoutHWSM(hw);\n\n\t/* after power off we should do iqk again */\n\trtlpriv->phy.iqk_initialized = false;\n}", "label": 0, "cwe": null, "length": 210 }, { "index": 280704, "code": "next(Buffer const * buf) const\n{\n\tLASSERT(buf, /**/);\n\n\tif (bstore.empty())\n\t\treturn 0;\n\tBufferStorage::const_iterator it = find(bstore.begin(),\n\t\t\t\t\t\tbstore.end(), buf);\n\tLASSERT(it != bstore.end(), /**/);\n\t++it;\n\tBuffer * nextbuf = (it == bstore.end()) ? bstore.front() : *it;\n\treturn nextbuf;\n}", "label": 0, "cwe": null, "length": 88 }, { "index": 30657, "code": "_shift_base_by_arrow(Evas_Object *arrow, Elm_Ctxpopup_Direction dir,\n Evas_Coord_Rectangle *rect)\n{\n Evas_Coord arrow_w, arrow_h;\n\n evas_object_geometry_get(arrow, NULL, NULL, &arrow_w, &arrow_h);\n switch (dir)\n {\n case ELM_CTXPOPUP_DIRECTION_RIGHT:\n rect->x += arrow_w;\n break;\n case ELM_CTXPOPUP_DIRECTION_LEFT:\n rect->x -= arrow_w;\n break;\n case ELM_CTXPOPUP_DIRECTION_DOWN:\n rect->y += arrow_h;\n break;\n case ELM_CTXPOPUP_DIRECTION_UP:\n rect->y -= arrow_h;\n break;\n default:\n break;\n }\n}", "label": 0, "cwe": null, "length": 162 }, { "index": 568177, "code": "enable_mii_autopoll(struct mac_regs __iomem *regs)\n{\n\tint ii;\n\n\twriteb(0, &(regs->MIICR));\n\twriteb(MIIADR_SWMPL, ®s->MIIADR);\n\n\tfor (ii = 0; ii < W_MAX_TIMEOUT; ii++) {\n\t\tudelay(1);\n\t\tif (BYTE_REG_BITS_IS_ON(MIISR_MIDLE, ®s->MIISR))\n\t\t\tbreak;\n\t}\n\n\twriteb(MIICR_MAUTO, ®s->MIICR);\n\n\tfor (ii = 0; ii < W_MAX_TIMEOUT; ii++) {\n\t\tudelay(1);\n\t\tif (!BYTE_REG_BITS_IS_ON(MIISR_MIDLE, ®s->MIISR))\n\t\t\tbreak;\n\t}\n\n}", "label": 0, "cwe": null, "length": 163 }, { "index": 640114, "code": "parse_options(int argc, char **argv, struct options * options)\n{\n /* Defined by getopt */\n extern int optind;\n\n int c;\n\n int unknown = 0;\n\n while ((c = getopt(argc, argv, \"\")) != EOF)\n switch (c) {\n case '?':\n unknown = c;\n break;\n }\n\n if( unknown ) return 1;\n\n if (argv[optind] == NULL) {\n fprintf(stderr, \"%s: no SCL file given\\n\", progname);\n return 1;\n }\n options->sclfile = argv[optind];\n if (argv[optind+1] == NULL) {\n fprintf(stderr, \"%s: no TRD file given\\n\", progname);\n return 1;\n }\n options->trdfile = argv[optind+1];\n\n return 0;\n}", "label": 0, "cwe": null, "length": 185 }, { "index": 821893, "code": "OnMouse(wxMouseEvent &event)\n{\n int prevState = mState;\n\n // Handle hilighting the image if the mouse is over it\n\n if (event.Entering())\n mState = 1;\n else if (event.Leaving())\n mState = 0;\n else {\n wxSize clientSize = GetClientSize();\n\n if (event.m_x >= 0 && event.m_y >= 0 &&\n event.m_x < clientSize.x && event.m_y < clientSize.y)\n mState = 1;\n else\n mState = 0;\n }\n\n if (event.ButtonDown())\n mOwnerToolBar->StartMoving();\n\n if (mState != prevState)\n Refresh(false);\n}", "label": 0, "cwe": null, "length": 154 }, { "index": 213701, "code": "cirrusfb_init(void)\n{\n\tint error = 0;\n\n#ifndef MODULE\n\tchar *option = NULL;\n\n\tif (fb_get_options(\"cirrusfb\", &option))\n\t\treturn -ENODEV;\n\tcirrusfb_setup(option);\n#endif\n\n#ifdef CONFIG_ZORRO\n\terror |= zorro_register_driver(&cirrusfb_zorro_driver);\n#endif\n#ifdef CONFIG_PCI\n\terror |= pci_register_driver(&cirrusfb_pci_driver);\n#endif\n\treturn error;\n}", "label": 0, "cwe": null, "length": 95 }, { "index": 663556, "code": "ov772x_get_fmt(struct v4l2_subdev *sd,\n\t\tstruct v4l2_subdev_pad_config *cfg,\n\t\tstruct v4l2_subdev_format *format)\n{\n\tstruct v4l2_mbus_framefmt *mf = &format->format;\n\tstruct ov772x_priv *priv = to_ov772x(sd);\n\n\tif (format->pad)\n\t\treturn -EINVAL;\n\n\tmf->width\t= priv->win->rect.width;\n\tmf->height\t= priv->win->rect.height;\n\tmf->code\t= priv->cfmt->code;\n\tmf->colorspace\t= priv->cfmt->colorspace;\n\tmf->field\t= V4L2_FIELD_NONE;\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 156 }, { "index": 647301, "code": "ipAddressStatus_set(ipAddressTable_rowreq_ctx * rowreq_ctx,\n u_long ipAddressStatus_val)\n{\n\n DEBUGMSGTL((\"verbose:ipAddressTable:ipAddressStatus_set\", \"called\\n\"));\n\n /** should never get a NULL pointer */\n netsnmp_assert(NULL != rowreq_ctx);\n\n /*\n * TODO:461:M: |-> Set ipAddressStatus value.\n * set ipAddressStatus value in rowreq_ctx->data\n */\n rowreq_ctx->data->ia_status = ipAddressStatus_val;\n\n return MFD_SUCCESS;\n}", "label": 1, "cwe": "CWE-476", "length": 116 }, { "index": 64314, "code": "kttour_getmove \n\t(Pos *pos, int x, int y, GtkboardEventType type, Player to_play, byte **movp, int ** rmovep)\n{\n\tstatic byte move[7];\n\tbyte *mp = move;\n\tint val;\n\tint cur_x, cur_y;\n\tif (type != GTKBOARD_BUTTON_RELEASE)\n\t\treturn 0;\n\tval = pos->board[y * board_wid + x];\n\tif (val == KTTOUR_CUR)\n\t\treturn 0;\n\tif (val == KTTOUR_USED)\n\t\treturn -1;\n\tfind_xy (pos->board, &cur_x, &cur_y, KTTOUR_CUR);\n\tif (val == KTTOUR_START)\n\t{\n\t\t*mp++ = x;\n\t\t*mp++ = y;\n\t\t*mp++ = KTTOUR_CUR;\n\t\t*mp++ = cur_x;\n\t\t*mp++ = cur_y;\n\t\t*mp++ = KTTOUR_START;\n\t\tadd_hints (pos->board, x, y, &mp);\n\t\t*mp++ = -1;\n\t\t*movp = move;\n\t\treturn 1;\n\t}\n\tif (cur_x >= 0 && !are_nbrs (cur_x, cur_y, x, y))\n\t\treturn -1;\n\t*mp++ = x;\n\t*mp++ = y;\n\t*mp++ = KTTOUR_CUR;\n\tif (cur_x >= 0)\n\t{\n\t\t*mp++ = cur_x;\n\t\t*mp++ = cur_y;\n\t\t*mp++ = pos->num_moves == 1 ? KTTOUR_START : KTTOUR_USED;\n\t}\n\tadd_hints (pos->board, x, y, &mp);\n\t*mp++ = -1;\n\t*movp = move;\n\treturn 1;\n}", "label": 0, "cwe": null, "length": 384 }, { "index": 178730, "code": "free_buf(BUF_NODE ** OBUF){\n\tint i = 0 ;\n\tBUF_NODE * b1, * b2;\n\tfor ( i = 0 ; i < free_buf_num; i++){\n\t\tb1 = (*(OBUF+i)) ;\n\t\twhile(b1 != NULL){\n\t\t\tb2 = b1->next;\n\t\t\tfree(b1);\n\t\t\tb1 = b2;\n\t\t}\n\n\t}\n\tfree(OBUF);\n}", "label": 0, "cwe": null, "length": 90 }, { "index": 378091, "code": "resource_request_starting_cb(WebKitWebView\t\t*view,\n\t\t\t\t\t WebKitWebFrame\t\t*frame,\n\t\t\t\t\t WebKitWebResource\t*resource,\n\t\t\t\t\t WebKitNetworkRequest\t*request,\n\t\t\t\t\t WebKitNetworkResponse\t*response,\n\t\t\t\t\t FancyViewer\t\t*viewer)\n{\n\tconst gchar *uri = webkit_network_request_get_uri(request);\n\tgchar *filename;\n\tgchar *image;\n\tgint err;\n\tMimeInfo *partinfo = viewer->to_load;\n\t\n\tfilename = viewer->filename;\n\tif ((!g_ascii_strncasecmp(uri, \"cid:\", 4)) || (!g_ascii_strncasecmp(uri, \"mid:\", 4))) {\n\t\timage = g_strconcat(\"<\", uri + 4, \">\", NULL);\n\t\twhile ((partinfo = procmime_mimeinfo_next(partinfo)) != NULL) {\n\t\t\tif (!g_ascii_strcasecmp(image, partinfo->id)) {\n\t\t\t\tfilename = procmime_get_tmp_file_name(partinfo);\n\t\t\t\tif (!filename) {\n\t\t\t\t\tg_free(image);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif ((err = procmime_get_part(filename, partinfo)) < 0)\n\t\t\t\t\talertpanel_error(_(\"Couldn't save the part of multipart message: %s\"),\n\t\t\t\t\t\t\t\t\t\tstrerror(-err));\n\t\t\t\tgchar *file_uri = g_filename_to_uri(filename, NULL, NULL);\n\t\t\t\twebkit_network_request_set_uri(request, file_uri);\n\t\t\t\tg_free(file_uri);\n\t\t\t\tg_free(filename);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tg_free(image);\n\t}\n\t\n\t/* refresh URI that may have changed */\n\turi = webkit_network_request_get_uri(request);\n\tif (!viewer->override_prefs_remote_content\n\t && strncmp(uri, \"file://\", 7) && strncmp(uri, \"data:\", 5)) {\n\t\tdebug_print(\"Preventing load of %s\\n\", uri);\n\t\twebkit_network_request_set_uri(request, \"about:blank\");\n\t}\n\telse\n\t\tdebug_print(\"Starting request of %zu %s\\n\", strlen(uri), uri);\n}", "label": 0, "cwe": null, "length": 422 }, { "index": 77041, "code": "pc_clock_adjtime(clockid_t id, struct timex *tx)\n{\n\tstruct posix_clock_desc cd;\n\tint err;\n\n\terr = get_clock_desc(id, &cd);\n\tif (err)\n\t\treturn err;\n\n\tif ((cd.fp->f_mode & FMODE_WRITE) == 0) {\n\t\terr = -EACCES;\n\t\tgoto out;\n\t}\n\n\tif (cd.clk->ops.clock_adjtime)\n\t\terr = cd.clk->ops.clock_adjtime(cd.clk, tx);\n\telse\n\t\terr = -EOPNOTSUPP;\nout:\n\tput_clock_desc(&cd);\n\n\treturn err;\n}", "label": 0, "cwe": null, "length": 127 }, { "index": 10435, "code": "_wapi_handle_timedwait_signal_handle (gpointer handle,\n\t\t\t\t\t\t\t\t\t\t struct timespec *timeout, gboolean alertable, gboolean poll)\n{\n\tDEBUG (\"%s: waiting for %p (type %s)\", __func__, handle,\n\t\t _wapi_handle_typename[_wapi_handle_type (handle)]);\n\t\n\tif (_WAPI_SHARED_HANDLE (_wapi_handle_type (handle))) {\n\t\tif (WAPI_SHARED_HANDLE_DATA(handle).signalled == TRUE) {\n\t\t\treturn (0);\n\t\t}\n\t\tif (timeout != NULL) {\n\t\t\tstruct timespec fake_timeout;\n\t\t\t_wapi_calc_timeout (&fake_timeout, 100);\n\t\t\n\t\t\tif ((fake_timeout.tv_sec > timeout->tv_sec) ||\n\t\t\t\t(fake_timeout.tv_sec == timeout->tv_sec &&\n\t\t\t\t fake_timeout.tv_nsec > timeout->tv_nsec)) {\n\t\t\t\t/* FIXME: Real timeout is less than\n\t\t\t\t * 100ms time, but is it really worth\n\t\t\t\t * calculating to the exact ms?\n\t\t\t\t */\n\t\t\t\t_wapi_handle_spin (100);\n\n\t\t\t\tif (WAPI_SHARED_HANDLE_DATA(handle).signalled == TRUE) {\n\t\t\t\t\treturn (0);\n\t\t\t\t} else {\n\t\t\t\t\treturn (ETIMEDOUT);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\t_wapi_handle_spin (100);\n\t\treturn (0);\n\t\t\n\t} else {\n\t\tguint32 idx = GPOINTER_TO_UINT(handle);\n\t\tint res;\n\t\tpthread_cond_t *cond;\n\t\tmono_mutex_t *mutex;\n\n\t\tif (alertable && !wapi_thread_set_wait_handle (handle))\n\t\t\treturn 0;\n\n\t\tcond = &_WAPI_PRIVATE_HANDLES (idx).signal_cond;\n\t\tmutex = &_WAPI_PRIVATE_HANDLES (idx).signal_mutex;\n\n\t\tif (poll) {\n\t\t\t/* This is needed when waiting for process handles */\n\t\t\tres = timedwait_signal_poll_cond (cond, mutex, timeout, alertable);\n\t\t} else {\n\t\t\tif (timeout)\n\t\t\t\tres = mono_cond_timedwait (cond, mutex, timeout);\n\t\t\telse\n\t\t\t\tres = mono_cond_wait (cond, mutex);\n\t\t}\n\n\t\tif (alertable)\n\t\t\twapi_thread_clear_wait_handle (handle);\n\n\t\treturn res;\n\t}\n}", "label": 0, "cwe": null, "length": 457 }, { "index": 493140, "code": "mono_mempool_stats (MonoMemPool *pool)\n{\n#ifdef MALLOC_ALLOCATION\n\tg_assert_not_reached ();\n#else\n\tMonoMemPool *p;\n\tint count = 0;\n\tguint32 still_free = 0;\n\n\tp = pool;\n\twhile (p) {\n\t\tstill_free += p->end - p->pos;\n\t\tp = p->next;\n\t\tcount++;\n\t}\n\tif (pool) {\n\t\tg_print (\"Mempool %p stats:\\n\", pool);\n\t\tg_print (\"Total mem allocated: %d\\n\", pool->d.allocated);\n\t\tg_print (\"Num chunks: %d\\n\", count);\n\t\tg_print (\"Free memory: %d\\n\", still_free);\n\t}\n#endif\n}", "label": 0, "cwe": null, "length": 153 }, { "index": 80812, "code": "PyFFLayer_ReverseDirection(PyFF_Layer *self, PyObject *args) {\n int i;\n\n for ( i=0; icntr_cnt; ++i )\n\tPyFFContour_ReverseDirection(self->contours[i],NULL); \nPy_RETURN( self );\n}", "label": 0, "cwe": null, "length": 63 }, { "index": 851826, "code": "reverseSentense(std::string input) {\n std::string::size_type start = 0;\n for (std::string::size_type i = 0; i < input.size(); ++i) {\n if (input.at(i) != ' ') continue;\n if (start == i) {\n // wrong format,do nothing\n } else {\n reverseArray(input, start, i);\n }\n start = i + 1;\n }\n if (start <= input.size()) reverseArray(input, start, input.size());\n reverseArray(input, 0, input.size());\n return input;\n}", "label": 0, "cwe": null, "length": 131 }, { "index": 120702, "code": "gtk_source_view_set_tab_width (GtkSourceView *view,\n\t\t\t guint width)\n{\n\tguint save_width;\n\n\tg_return_if_fail (GTK_SOURCE_VIEW (view));\n\tg_return_if_fail (width > 0 && width <= MAX_TAB_WIDTH);\n\n\tif (view->priv->tab_width == width)\n\t\treturn;\n\n\tsave_width = view->priv->tab_width;\n\tview->priv->tab_width = width;\n\tif (set_tab_stops_internal (view))\n\t{\n\t\tg_object_notify (G_OBJECT (view), \"tab-width\");\n\t}\n\telse\n\t{\n\t\tg_warning (\"Impossible to set tab width.\");\n\t\tview->priv->tab_width = save_width;\n\t}\n}", "label": 0, "cwe": null, "length": 141 }, { "index": 194460, "code": "extiInit()\n{\n if (isInit)\n return;\n\n NVIC_InitTypeDef NVIC_InitStructure;\n\n NVIC_InitStructure.NVIC_IRQChannel = RADIO_IRQ_CHANNEL;\n NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = NVIC_RADIO_PRI;\n NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;\n NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;\n NVIC_Init(&NVIC_InitStructure);\n\n isInit = true;\n}", "label": 0, "cwe": null, "length": 88 }, { "index": 63282, "code": "lo_tell64(PGconn *conn, int fd)\n{\n\tpg_int64\tretval;\n\tPQArgBlock\targv[1];\n\tPGresult *res;\n\tint\t\t\tresult_len;\n\n\tif (conn == NULL || conn->lobjfuncs == NULL)\n\t{\n\t\tif (lo_initialize(conn) < 0)\n\t\t\treturn -1;\n\t}\n\n\tif (conn->lobjfuncs->fn_lo_tell64 == 0)\n\t{\n\t\tprintfPQExpBuffer(&conn->errorMessage,\n\t\t\t libpq_gettext(\"cannot determine OID of function lo_tell64\\n\"));\n\t\treturn -1;\n\t}\n\n\targv[0].isint = 1;\n\targv[0].len = 4;\n\targv[0].u.integer = fd;\n\n\tres = PQfn(conn, conn->lobjfuncs->fn_lo_tell64,\n\t\t\t (void *) &retval, &result_len, 0, argv, 1);\n\tif (PQresultStatus(res) == PGRES_COMMAND_OK && result_len == 8)\n\t{\n\t\tPQclear(res);\n\t\treturn lo_ntoh64(retval);\n\t}\n\telse\n\t{\n\t\tPQclear(res);\n\t\treturn -1;\n\t}\n}", "label": 1, "cwe": "CWE-476", "length": 254 }, { "index": 404908, "code": "lsr_read_fixed_16_8(GF_LASeRCodec *lsr, const char *name)\n{\n\tu32 val;\n\tGF_LSR_READ_INT(lsr, val, 24, name);\n\tif (val & (1<<23)) {\n\t\ts32 res = val - (1<<24);\n#ifdef GPAC_FIXED_POINT\n\t\treturn res*256;\n#else\n\t\treturn INT2FIX(res) / 256;\n#endif\n\t} else {\n#ifdef GPAC_FIXED_POINT\n\t\treturn val*256;\n#else\n\t\treturn INT2FIX(val) / 256;\n#endif\n\t}\n}", "label": 0, "cwe": null, "length": 128 }, { "index": 649180, "code": "mouseBoxClick(const Qt::MouseButton button, int boxPosition)\n{\n\tm_cursor->setBoxPosition(boxPosition);\n\tif (button==Qt::RightButton)\n\t\tswitchMarker();\n\telse\n\t\tswitchBall();\n\tm_cursor->hide();\n}", "label": 0, "cwe": null, "length": 49 }, { "index": 220410, "code": "H5G_dense_fh_name_cmp(const void *obj, size_t H5_ATTR_UNUSED obj_len, void *_udata)\n{\n H5G_fh_ud_cmp_t *udata = (H5G_fh_ud_cmp_t *)_udata; /* User data for 'op' callback */\n H5O_link_t *lnk; /* Pointer to link created from heap object */\n herr_t ret_value = SUCCEED; /* Return value */\n\n FUNC_ENTER_NOAPI_NOINIT\n\n /* Decode link information */\n if(NULL == (lnk = (H5O_link_t *)H5O_msg_decode(udata->f, udata->dxpl_id, NULL, H5O_LINK_ID, (const unsigned char *)obj)))\n HGOTO_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, \"can't decode link\")\n\n /* Compare the string values */\n udata->cmp = HDstrcmp(udata->name, lnk->name);\n\n /* Check for correct link & callback to make */\n if(udata->cmp == 0 && udata->found_op) {\n if((udata->found_op)(lnk, udata->found_op_data) < 0)\n HGOTO_ERROR(H5E_SYM, H5E_CANTOPERATE, FAIL, \"link found callback failed\")\n } /* end if */\n\n /* Release the space allocated for the link */\n H5O_msg_free(H5O_LINK_ID, lnk);\n\ndone:\n FUNC_LEAVE_NOAPI(ret_value)\n}", "label": 0, "cwe": null, "length": 330 }, { "index": 446110, "code": "xprogn(void)\n{\n LVAL val;\n\n /* evaluate each expression */\n for (val = NIL; moreargs(); )\n val = xleval(nextarg());\n\n /* return the last test expression value */\n return (val);\n}", "label": 0, "cwe": null, "length": 53 }, { "index": 219994, "code": "Map(const LdifAttribute &ldifname,\n\t\t const std::string &readField,\n\t\t const std::string &writeField)\n{\n\tconst NameToFunc *read = GetField(readField);\n\tconst NameToFunc *write = GetField(writeField);\n\tif( !read || !write )\n\t\treturn false;\n\tMap(ldifname, read->read, write->write);\n\treturn true;\n}", "label": 0, "cwe": null, "length": 83 }, { "index": 563116, "code": "createInstance(UErrorCode& errorCode) {\n Locale locale; // The default locale.\n return createInstance(locale, errorCode);\n}", "label": 0, "cwe": null, "length": 28 }, { "index": 1016414, "code": "glade_signal_editor_drag_begin (GtkWidget *widget,\n GdkDragContext *context,\n gpointer user_data)\n{\n cairo_surface_t *s = NULL;\n GtkTreeModel *model;\n GtkTreeIter iter;\n GtkTreeSelection *selection;\n\n selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (widget));\n\n if (gtk_tree_selection_get_selected (selection, &model, &iter))\n {\n gchar* handler;\n gchar* text;\n gtk_tree_model_get (model, &iter,\n\t\t\t GLADE_SIGNAL_COLUMN_HANDLER, &handler, -1);\n\n text = g_strdup_printf (\"%s ()\", handler);\n g_free (handler);\n \n s = create_rich_drag_surface (widget, text);\n g_free (text);\n }\n\t\n if (s)\n {\n gtk_drag_set_icon_surface (context, s);\n cairo_surface_destroy (s);\n }\n else\n {\n gtk_drag_set_icon_default (context);\n }\n}", "label": 0, "cwe": null, "length": 208 }, { "index": 726296, "code": "gst_soup_http_client_sink_set_proxy (GstSoupHttpClientSink * souphttpsink,\n const gchar * uri)\n{\n if (souphttpsink->proxy) {\n soup_uri_free (souphttpsink->proxy);\n souphttpsink->proxy = NULL;\n }\n if (g_str_has_prefix (uri, \"http://\")) {\n souphttpsink->proxy = soup_uri_new (uri);\n } else {\n gchar *new_uri = g_strconcat (\"http://\", uri, NULL);\n\n souphttpsink->proxy = soup_uri_new (new_uri);\n g_free (new_uri);\n }\n\n return TRUE;\n}", "label": 0, "cwe": null, "length": 135 }, { "index": 32399, "code": "caml_callback (value closure, value arg)\n{\n value res = caml_callback_exn(closure, arg);\n if (Is_exception_result(res)) caml_raise(Extract_exception(res));\n return res;\n}", "label": 0, "cwe": null, "length": 47 }, { "index": 852104, "code": "blame_grep(struct view *view, struct line *line)\n{\n\tstruct blame *blame = line->data;\n\tstruct blame_commit *commit = blame->commit;\n\tconst char *text[] = {\n\t\tblame->text,\n\t\tcommit ? commit->title : \"\",\n\t\tcommit ? commit->id : \"\",\n\t\tcommit && opt_author ? commit->author : \"\",\n\t\tcommit ? mkdate(&commit->time, opt_date) : \"\",\n\t\tNULL\n\t};\n\n\treturn grep_text(view, text);\n}", "label": 0, "cwe": null, "length": 108 }, { "index": 825555, "code": "ml_compute_number_unique_proxy_ranks(\n int subgroup_index, int rank_index,\n int *sub_groups_in_lineage,int *len_sub_groups_in_lineage,\n sub_group_params_t *array_of_all_subgroup_ranks)\n{\n /* local variables */\n int total=0, i_rank, sg_i, sub_grp, depth;\n bool found;\n\n /* Do I represent several subgroups ? */\n if( array_of_all_subgroup_ranks[subgroup_index].rank_data[rank_index].\n n_connected_subgroups ) {\n for( sg_i = 0 ; sg_i <\n array_of_all_subgroup_ranks[subgroup_index].\n rank_data[rank_index].n_connected_subgroups ; sg_i++ ) {\n sub_grp= array_of_all_subgroup_ranks[subgroup_index].\n rank_data[rank_index].list_connected_subgroups[sg_i];\n\n /* make sure we don't loop back on ourselves */\n found=false;\n for(depth=0 ; depth < *len_sub_groups_in_lineage\n ; depth++ ){\n if(sub_groups_in_lineage[depth]==sub_grp)\n {\n found=true;\n break;\n }\n }\n if(found) {\n continue;\n }\n\n sub_groups_in_lineage[(*len_sub_groups_in_lineage)]=sub_grp;\n (*len_sub_groups_in_lineage)++;\n for(i_rank = 0 ;\n i_rank < array_of_all_subgroup_ranks[sub_grp].n_ranks ;\n i_rank++) {\n total+=ml_compute_number_unique_proxy_ranks(\n sub_grp, i_rank, sub_groups_in_lineage,\n len_sub_groups_in_lineage, array_of_all_subgroup_ranks);\n }\n (*len_sub_groups_in_lineage)--;\n }\n }\n /* if I am a leaf, count me */\n if( array_of_all_subgroup_ranks[subgroup_index].rank_data[rank_index].\n leaf ) {\n total++;\n }\n\n /* return */\n return total;\n\n}", "label": 0, "cwe": null, "length": 421 }, { "index": 160448, "code": "mapsize_callback(int value, struct connection *caller,\n char *reject_msg, size_t reject_msg_len)\n{\n if (value == MAPSIZE_XYSIZE && MAP_IS_ISOMETRIC &&\n map.ysize % 2 != 0) {\n /* An isometric map needs a even ysize. Is is calculated automatically\n * for all settings but mapsize=XYSIZE. */\n settings_snprintf(reject_msg, reject_msg_len,\n _(\"For an isometric or hexagonal map the ysize must be \"\n \"even.\"));\n return FALSE;\n }\n\n return TRUE;\n}", "label": 0, "cwe": null, "length": 127 }, { "index": 286487, "code": "__lambda117_ (SymbolsView* self) {\n\tMostUsedSymbols* _tmp0_ = NULL;\n\tMostUsedSymbols* _tmp1_ = NULL;\n\t_tmp0_ = most_used_symbols_get_default ();\n\t_tmp1_ = _tmp0_;\n\tmost_used_symbols_clear (_tmp1_);\n\t_g_object_unref0 (_tmp1_);\n}", "label": 0, "cwe": null, "length": 75 }, { "index": 72832, "code": "FindClosestScale(int width, int height,\n int target_num_pixels) {\n if (!target_num_pixels) {\n return 0.f;\n }\n int best_distance = INT_MAX;\n int best_index = 0; // default to unscaled\n for (size_t i = 0u; i < ARRAY_SIZE(kScaleFactors); ++i) {\n int test_num_pixels = static_cast(width * kScaleFactors[i] *\n height * kScaleFactors[i]);\n int diff = test_num_pixels - target_num_pixels;\n if (diff < 0) {\n diff = -diff;\n }\n if (diff < best_distance) {\n best_distance = diff;\n best_index = i;\n if (!best_distance) { // Found exact match\n break;\n }\n }\n }\n return kScaleFactors[best_index];\n}", "label": 0, "cwe": null, "length": 187 }, { "index": 917882, "code": "getPeerAddr() const\n{\n union\n {\n struct sockaddr_storage storage;\n struct sockaddr sa;\n struct sockaddr_in sa_in;\n struct sockaddr_in6 sa_in6;\n struct in_addr addr;\n } addr;\n\n addr.storage = _peeraddr;\n\n std::string ret;\n formatIp(addr.sa_in, ret);\n return ret;\n}", "label": 0, "cwe": null, "length": 82 }, { "index": 226681, "code": "RGBToHWBTransform(void *mutable_data, /* User provided mutable data */\n const void *immutable_data, /* User provided immutable data */\n Image *image, /* Modify image */\n PixelPacket *pixels, /* Pixel row */\n IndexPacket *indexes, /* Pixel row indexes */\n const long npixels, /* Number of pixels in row */\n ExceptionInfo *exception) /* Exception report */\n{\n /*\n Transform pixels from RGB space to HWB space.\n */\n double\n h,\n w,\n b;\n\n register long\n i; \n\n ARG_NOT_USED(mutable_data);\n ARG_NOT_USED(immutable_data);\n ARG_NOT_USED(image);\n ARG_NOT_USED(indexes);\n ARG_NOT_USED(exception);\n\n for (i=0; i < npixels; i++)\n {\n TransformHWB(pixels[i].red,pixels[i].green,pixels[i].blue,&h,&w,&b);\n h *= MaxRGB;\n w *= MaxRGB;\n b *= MaxRGB;\n pixels[i].red=RoundDoubleToQuantum(h);\n pixels[i].green=RoundDoubleToQuantum(w);\n pixels[i].blue=RoundDoubleToQuantum(b);\n }\n\n return MagickPass;\n}", "label": 0, "cwe": null, "length": 268 }, { "index": 15568, "code": "calcReplacedWidth() const\n{\n switch (style()->width().type()) {\n case Fixed:\n return qMax(0, style()->width().value());\n case Percent:\n {\n const int cw = containingBlockWidth();\n return cw > 0 ? qMax(0, style()->width().minWidth(cw)) : 0;\n }\n default:\n return 0;\n }\n}", "label": 0, "cwe": null, "length": 89 }, { "index": 45880, "code": "IReadBlock( int nBlockXOff, int nBlockYOff,\n void * pImage )\n{\n CPLErr ret;\n RPFTOCProxyRasterDataSet* proxyDS = (RPFTOCProxyRasterDataSet*)poDS;\n GDALDataset* ds = proxyDS->RefUnderlyingDataset();\n if (ds)\n {\n if (proxyDS->SanityCheckOK(ds) == FALSE)\n {\n proxyDS->UnrefUnderlyingDataset(ds);\n return CE_Failure;\n }\n\n GDALRasterBand* srcBand = ds->GetRasterBand(1);\n ret = srcBand->ReadBlock(nBlockXOff, nBlockYOff, pImage);\n \n if (initDone == FALSE)\n {\n int approximateMatching;\n if (srcBand->GetIndexColorTranslationTo(this, remapLUT, &approximateMatching ))\n {\n samePalette = FALSE;\n if (approximateMatching)\n {\n CPLError( CE_Failure, CPLE_AppDefined,\n \"Palette for %s is different from reference palette. \"\n \"Coudln't remap exactly all colors. Trying to find closest matches.\\n\", GetDescription());\n }\n }\n else\n {\n samePalette = TRUE;\n }\n initDone = TRUE;\n }\n\n\n if (samePalette == FALSE)\n {\n unsigned char* data = (unsigned char*)pImage;\n int i;\n for(i=0;iUnrefUnderlyingDataset(ds);\n\n return ret;\n}", "label": 0, "cwe": null, "length": 364 }, { "index": 984748, "code": "inode_close_read(struct file_opening *fo, struct gfarm_timespec *atime)\n{\n\tstruct inode *inode = fo->inode;\n\tstruct inode_open_state *ios = inode->u.c.state;\n\n\tif ((fo->flag & GFARM_FILE_TRUNC_PENDING) != 0) {\n\t\tinode_file_update(fo, 0, atime, &inode->i_mtimespec,\n\t\t NULL, NULL);\n\t} else if (atime != NULL)\n\t\tinode_set_atime(inode, atime);\n\n\tfo->opening_prev->opening_next = fo->opening_next;\n\tfo->opening_next->opening_prev = fo->opening_prev;\n\tif (ios->openings.opening_next == &ios->openings) { /* all closed */\n\t\tif (ios->u.f.event_waiters != NULL)\n\t\t\tinode_new_generation_done(inode, NULL,\n\t\t\t GFARM_ERR_PROTOCOL);\n\t\tinode_open_state_free(inode->u.c.state);\n\t\tinode->u.c.state = NULL;\n\t} else if ((accmode_to_op(fo->flag) & GFS_W_OK) != 0)\n\t\t--ios->u.f.writers;\n\n\tif (inode->i_nlink == 0 && inode->u.c.state == NULL &&\n\t (!inode_is_file(inode) || inode->u.c.s.f.rstate == NULL)) {\n\t\tinode_remove(inode); /* clears `ios->u.f.cksum_owner' too. */\n\t}\n}", "label": 0, "cwe": null, "length": 305 }, { "index": 684189, "code": "allocate_itemsets()\n{\n register Yshort *itemp;\n register Yshort *item_end;\n register int symbol;\n register int i;\n register int count;\n register int max;\n register Yshort *symbol_count;\n\n count = 0;\n symbol_count = NEW2(nsyms, Yshort);\n\n item_end = ritem + nitems;\n for (itemp = ritem; itemp < item_end; itemp++)\n {\n\tsymbol = *itemp;\n\tif (symbol >= 0)\n\t{\n\t count++;\n\t symbol_count[symbol]++;\n\t}\n }\n\n kernel_base = NEW2(nsyms, Yshort *);\n kernel_items = NEW2(count, Yshort);\n\n count = 0;\n max = 0;\n for (i = 0; i < nsyms; i++)\n {\n\tkernel_base[i] = kernel_items + count;\n\tcount += symbol_count[i];\n\tif (max < symbol_count[i])\n\t max = symbol_count[i];\n }\n\n shift_symbol = symbol_count;\n kernel_end = NEW2(nsyms, Yshort *);\n}", "label": 0, "cwe": null, "length": 236 }, { "index": 1010357, "code": "ch_util_get_dark_offsets (ChUtilPrivate *priv, gchar **values, GError **error)\n{\n\tgboolean ret;\n\tCdColorRGB value;\n\n\t/* get from HW */\n\tch_device_queue_get_dark_offsets (priv->device_queue,\n\t\t\t\t\t priv->device,\n\t\t\t\t\t &value);\n\tret = ch_device_queue_process (priv->device_queue,\n\t\t\t\t CH_DEVICE_QUEUE_PROCESS_FLAGS_NONE,\n\t\t\t\t NULL,\n\t\t\t\t error);\n\tif (!ret)\n\t\tgoto out;\n\n\tg_print (\"R:%.5f G:%.5f B:%.5f\\n\", value.R, value.G, value.B);\nout:\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 129 }, { "index": 1006295, "code": "uv_bios_mq_watchlist_alloc(unsigned long addr, unsigned int mq_size,\n\t\t\t unsigned long *intr_mmr_offset)\n{\n\tu64 watchlist;\n\ts64 ret;\n\n\t/*\n\t * bios returns watchlist number or negative error number.\n\t */\n\tret = (int)uv_bios_call_irqsave(UV_BIOS_WATCHLIST_ALLOC, addr,\n\t\t\tmq_size, (u64)intr_mmr_offset,\n\t\t\t(u64)&watchlist, 0);\n\tif (ret < BIOS_STATUS_SUCCESS)\n\t\treturn ret;\n\n\treturn watchlist;\n}", "label": 0, "cwe": null, "length": 116 }, { "index": 786382, "code": "dump_isakmp_delete(packet_t * pkt)\n{\n isakmpgeneric_t hdr;\n\n /* get the generic header */\n if (get_packet_bytes((u_int8_t *) &hdr, pkt, sizeof(hdr)) == 0)\n return;\n\n /* conversions */\n hdr.length = ntohs(hdr.length);\n\n if (my_args->m)\n {\n /* nothing to do here... */\n }\n else\n {\n display_header_banner(\"ISAKMP/IKE delete\");\n display_strmap(\"Next payload\", hdr.next_payload, isakmp_payload_map);\n display(\"Reserved\", (u_int8_t *) &hdr.reserved, 1, DISP_DEC);\n display(\"Payload length\", (u_int8_t *) &hdr.length, 2, DISP_DEC);\n }\n\n}", "label": 0, "cwe": null, "length": 168 }, { "index": 588031, "code": "techAdapterAvail( const ASCString& ta ) const\n{\n if( find ( predefinedTechAdapter.begin(), predefinedTechAdapter.end(), ta ) != predefinedTechAdapter.end() )\n return true; \n\n return triggeredTechAdapter.find ( ta ) != triggeredTechAdapter.end();\n}", "label": 0, "cwe": null, "length": 60 }, { "index": 832761, "code": "fmt_pid (rp_window_elem *elem, struct sbuf *buf)\n{\n struct rp_child_info *info;\n\n info = get_child_info (elem->win->w);\n if (info)\n sbuf_printf_concat (buf, \"%d\", info->pid);\n else\n sbuf_concat (buf, \"?\");\n}", "label": 0, "cwe": null, "length": 71 }, { "index": 110037, "code": "fetch(struct db *db, \n\t\t const char *key, int keylen,\n\t\t const char **data, int *datalen,\n\t\t struct txn **tid)\n{\n char quota_path[MAX_QUOTA_PATH+1], *tmpkey = NULL;\n\n /* if we need to truncate the key, do so */\n if (key[keylen] != '\\0') {\n\ttmpkey = xmalloc(keylen + 1);\n\tmemcpy(tmpkey, key, keylen);\n\ttmpkey[keylen] = '\\0';\n\tkey = tmpkey;\n }\n\n hash_quota(quota_path, sizeof(quota_path), key, db->path);\n if (tmpkey) free(tmpkey);\n\n return myfetch(db, quota_path, data, datalen, tid);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 159 }, { "index": 81238, "code": "ompi_pubsub_base_select(void)\n{\n int ret;\n ompi_pubsub_base_component_t *best_component = NULL;\n ompi_pubsub_base_module_t *best_module = NULL;\n\n /*\n * Select the best component\n */\n if( OPAL_SUCCESS != (ret = mca_base_select(\"pubsub\", ompi_pubsub_base_framework.framework_output,\n &ompi_pubsub_base_framework.framework_components,\n (mca_base_module_t **) &best_module,\n (mca_base_component_t **) &best_component))) {\n /* it is okay not to find any executable components */\n if (OMPI_ERR_NOT_FOUND == ret) {\n ret = OPAL_SUCCESS;\n }\n goto cleanup;\n }\n\n /* Save the winner */\n ompi_pubsub = *best_module;\n \n /* init the selected module */\n if (NULL != ompi_pubsub.init) {\n ret = ompi_pubsub.init();\n }\n\n cleanup:\n return ret;\n}", "label": 0, "cwe": null, "length": 208 }, { "index": 69607, "code": "xsltproc(xsltStylesheetPtr style, TString html, TString& result)\n{\nhtmlDocPtr phtml = htmlReadMemory ( html.begin(), html.size(), NULL, NULL, HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING );\nxmlDocPtr presult = xsltApplyStylesheet( style, phtml, NULL );\nxmlChar *xmlbuff;\nint buffsize;\nxmlDocDumpMemory( presult, &xmlbuff, &buffsize );\nresult.clear();\nresult += rawdata( (char*)xmlbuff, buffsize );\nxmlFree( xmlbuff );\nxmlFreeDoc( phtml );\n}", "label": 0, "cwe": null, "length": 125 }, { "index": 488033, "code": "adis16260_probe(struct spi_device *spi)\n{\n\tconst struct spi_device_id *id;\n\tstruct adis16260 *adis16260;\n\tstruct iio_dev *indio_dev;\n\tint ret;\n\n\tid = spi_get_device_id(spi);\n\tif (!id)\n\t\treturn -ENODEV;\n\n\t/* setup the industrialio driver allocated elements */\n\tindio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*adis16260));\n\tif (!indio_dev)\n\t\treturn -ENOMEM;\n\tadis16260 = iio_priv(indio_dev);\n\t/* this is only used for removal purposes */\n\tspi_set_drvdata(spi, indio_dev);\n\n\tadis16260->info = &adis16260_chip_info_table[id->driver_data];\n\n\tindio_dev->name = id->name;\n\tindio_dev->dev.parent = &spi->dev;\n\tindio_dev->info = &adis16260_info;\n\tindio_dev->channels = adis16260->info->channels;\n\tindio_dev->num_channels = adis16260->info->num_channels;\n\tindio_dev->modes = INDIO_DIRECT_MODE;\n\n\tret = adis_init(&adis16260->adis, indio_dev, spi, &adis16260_data);\n\tif (ret)\n\t\treturn ret;\n\n\tret = adis_setup_buffer_and_trigger(&adis16260->adis, indio_dev, NULL);\n\tif (ret)\n\t\treturn ret;\n\n\t/* Get the device into a sane initial state */\n\tret = adis_initial_startup(&adis16260->adis);\n\tif (ret)\n\t\tgoto error_cleanup_buffer_trigger;\n\tret = iio_device_register(indio_dev);\n\tif (ret)\n\t\tgoto error_cleanup_buffer_trigger;\n\n\treturn 0;\n\nerror_cleanup_buffer_trigger:\n\tadis_cleanup_buffer_and_trigger(&adis16260->adis, indio_dev);\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 400 }, { "index": 67937, "code": "vb2_create_bufs(struct vb2_queue *q, struct v4l2_create_buffers *create)\n{\n\tint ret = vb2_verify_memory_type(q, create->memory,\n\t\t\tcreate->format.type);\n\n\tcreate->index = q->num_buffers;\n\tif (create->count == 0)\n\t\treturn ret != -EBUSY ? ret : 0;\n\treturn ret ? ret : vb2_core_create_bufs(q, create->memory,\n\t\t&create->count, &create->format);\n}", "label": 0, "cwe": null, "length": 106 }, { "index": 441434, "code": "dps_skip_inner_module_recursive(Module_table *mpt)\n{\n List *callee_list;\n List *li;\n\n callee_list = get_callee_module_list(mpt);\n for (li = callee_list; li != NULL; li = li->next) {\n if (list_find(dps_skip_module_list, li->data) == NULL) {\n dps_skip_module_list = list_append(dps_skip_module_list, li->data);\n dps_skip_inner_module_recursive(li->data);\n }\n }\n}", "label": 0, "cwe": null, "length": 108 }, { "index": 165869, "code": "is_seek(InStream *is, off_t pos)\n{\n if (pos >= is->buf.start && pos < (is->buf.start + is->buf.len)) {\n is->buf.pos = pos - is->buf.start; /* seek within buffer */\n }\n else {\n is->buf.start = pos;\n is->buf.pos = 0;\n is->buf.len = 0; /* trigger refill() on read() */\n is->m->seek_i(is, pos);\n }\n}", "label": 0, "cwe": null, "length": 110 }, { "index": 266566, "code": "safe_hash_change(SAFE_HASH *hash, uchar *old_data, uchar *new_data)\n{\n SAFE_HASH_ENTRY *entry, *next;\n DBUG_ENTER(\"safe_hash_set\");\n\n rw_wrlock(&hash->mutex);\n\n for (entry= hash->root ; entry ; entry= next)\n {\n next= entry->next;\n if (entry->data == old_data)\n {\n if (new_data == hash->default_value)\n {\n if ((*entry->prev= entry->next))\n entry->next->prev= entry->prev;\n\tmy_hash_delete(&hash->hash, (uchar*) entry);\n }\n else\n\tentry->data= new_data;\n }\n }\n\n rw_unlock(&hash->mutex);\n DBUG_VOID_RETURN;\n}", "label": 0, "cwe": null, "length": 164 }, { "index": 23180, "code": "my_strnxfrm_czech(CHARSET_INFO *cs __attribute__((unused)), \n uchar *dest, size_t len,\n const uchar *src, size_t srclen)\n{\n int value;\n const uchar *p, * store;\n int pass = 0;\n size_t totlen = 0;\n p = src;\tstore = src;\n\n do\n {\n NEXT_CMP_VALUE(src, p, store, pass, value, (int)srclen);\n ADD_TO_RESULT(dest, len, totlen, value);\n }\n while (value);\n if (len > totlen)\n bfill(dest + totlen, len - totlen, ' ');\n return len;\n}", "label": 0, "cwe": null, "length": 153 }, { "index": 786679, "code": "slave_drivers_parameter_set_value(void * obj, const union jackctl_parameter_value * value_ptr)\n{\n char * buffer;\n char * save;\n const char * token;\n struct list_head old_list;\n struct list_head new_list;\n union jackctl_parameter_value old_value;\n union jackctl_parameter_value new_value;\n bool old_set;\n\n if (controller_ptr->started)\n {\n jack_error(\"Cannot modify slave-drivers when server is started\");\n return false;\n }\n\n old_set = controller_ptr->slave_drivers_set;\n old_value = controller_ptr->slave_drivers_vparam_value;\n controller_ptr->slave_drivers_vparam_value.str[0] = 0;\n old_list = controller_ptr->slave_drivers;\n INIT_LIST_HEAD(&controller_ptr->slave_drivers);\n\n buffer = strdup(value_ptr->str);\n if (buffer == NULL)\n {\n jack_error(\"strdup() failed.\");\n return false;\n }\n\n token = strtok_r(buffer, \",\", &save);\n while (token)\n {\n //jack_info(\"slave driver '%s'\", token);\n if (!jack_controller_add_slave_driver(controller_ptr, token))\n {\n jack_controller_remove_slave_drivers(controller_ptr);\n controller_ptr->slave_drivers = old_list;\n controller_ptr->slave_drivers_vparam_value = old_value;\n controller_ptr->slave_drivers_set = old_set;\n\n free(buffer);\n\n return false;\n }\n\n token = strtok_r(NULL, \",\", &save);\n }\n\n new_value = controller_ptr->slave_drivers_vparam_value;\n new_list = controller_ptr->slave_drivers;\n controller_ptr->slave_drivers = old_list;\n jack_controller_remove_slave_drivers(controller_ptr);\n controller_ptr->slave_drivers_vparam_value = new_value;\n controller_ptr->slave_drivers = new_list;\n controller_ptr->slave_drivers_set = true;\n\n free(buffer);\n\n return true;\n}", "label": 0, "cwe": null, "length": 411 }, { "index": 51755, "code": "extract(const LinearLocation& start, const LinearLocation& end)\n{\n\tif (end.compareTo(start) < 0)\n\t{\n\t\tGeometry* backwards = computeLinear(end, start);\n\t\tGeometry* forwards = reverse(backwards);\n\t\tdelete backwards;\n\t\treturn forwards;\n\t}\n\treturn computeLinear(start, end);\n}", "label": 0, "cwe": null, "length": 67 }, { "index": 969742, "code": "gray_level(normal)\nfloat *normal;\n{ REAL cosine;\n REAL denom;\n denom = sqrt(dotf(normal,normal,3));\n if ( denom == 0.0 ) return 0.0;\n cosine = normal[1]/denom;\n if ( (REAL)normal[2] < 0.0 ) return brightness - 0.9*(1-brightness)*cosine;\n return brightness + 0.9*(1-brightness)*cosine;\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 123735, "code": "tp_list_connection_managers (TpDBusDaemon *bus_daemon,\n TpConnectionManagerListCb callback,\n gpointer user_data,\n GDestroyNotify destroy,\n GObject *weak_object)\n{\n _ListContext *list_context = g_slice_new0 (_ListContext);\n\n list_context->base_len = strlen (TP_CM_BUS_NAME_BASE);\n list_context->callback = callback;\n list_context->user_data = user_data;\n list_context->destroy = destroy;\n\n list_context->getting_names = FALSE;\n list_context->refcount = 1;\n list_context->table = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,\n g_object_unref);\n list_context->arr = NULL;\n list_context->cms_to_ready = 0;\n\n if (weak_object != NULL)\n {\n list_context->weak_object = weak_object;\n list_context->had_weak_object = TRUE;\n g_object_add_weak_pointer (weak_object, &list_context->weak_object);\n }\n\n tp_dbus_daemon_list_activatable_names (bus_daemon, 2000,\n tp_list_connection_managers_got_names, list_context,\n (GDestroyNotify) list_context_unref, weak_object);\n}", "label": 0, "cwe": null, "length": 260 }, { "index": 958945, "code": "IsDeadCheck(i::Isolate* isolate, const char* location) {\n return !isolate->IsInitialized()\n && i::V8::IsDead() ? ReportV8Dead(location) : false;\n}", "label": 0, "cwe": null, "length": 47 }, { "index": 196714, "code": "git_buf_text_is_binary(const git_buf *buf)\n{\n\tconst char *scan = buf->ptr, *end = buf->ptr + buf->size;\n\tint printable = 0, nonprintable = 0;\n\n\twhile (scan < end) {\n\t\tunsigned char c = *scan++;\n\n\t\tif (c > 0x1F && c < 0x7F)\n\t\t\tprintable++;\n\t\telse if (c == '\\0')\n\t\t\treturn true;\n\t\telse if (!git__isspace(c))\n\t\t\tnonprintable++;\n\t}\n\n\treturn ((printable >> 7) < nonprintable);\n}", "label": 0, "cwe": null, "length": 128 }, { "index": 117633, "code": "on_toolbutton_computeUB_clicked(void)\n{\n\tLOG;\n\n\tHklSample *sample = _samples->current;\n\tif(sample){\n\t\thkl_sample_compute_UB_busing_levy(sample, 0, 1);\n\t\tthis->updateUB();\n\t\tthis->updateUxUyUz();\n\t\tthis->updatePseudoAxes();\n\t\tthis->updatePseudoAxesFrames();\n\t}\n}", "label": 0, "cwe": null, "length": 83 }, { "index": 367797, "code": "declare_types(void)\n{\n register int c;\n register bucket *bp;\n char *tag;\n\n c = nextc();\n if (c == EOF) unexpected_EOF();\n if (c != '<') syntax_error(lineno, line, cptr);\n tag = get_tag();\n\n for (;;)\n {\n c = nextc();\n if (isalpha(c) || c == '_' || c == '.' || c == '$')\n bp = get_name();\n else if (c == '\\'' || c == '\"')\n bp = get_literal();\n else\n return;\n\n if (bp->tag && tag != bp->tag)\n retyped_warning(bp->name);\n bp->tag = tag;\n }\n}", "label": 0, "cwe": null, "length": 155 }, { "index": 885867, "code": "postOrder(dectree_node* ptr)\n{\n\tif(ptr != NULL)\n\t{\n\t\tpostOrder(ptr->f);\n\t\tpostOrder(ptr->t);\n\n\t\tif(!((ptr->type).compare(\"terminal\")))\n\t\t\tstd::cout << \"Terminal: \" << ptr->output_id << \" \";\n\t\telse\n\t\t\tstd::cout << \"Split: \" << ptr->attribute_id << \" \";\n\t}\n}", "label": 0, "cwe": null, "length": 84 }, { "index": 204765, "code": "writeback_inode(struct inode *inode)\n{\n\n\tint ret;\n\n\t/* if we used wait=1, sync_inode_metadata waits for the io for the\n\t* inode to finish. So wait=0 is sent down to sync_inode_metadata\n\t* and filemap_fdatawrite is used for the data blocks\n\t*/\n\tret = sync_inode_metadata(inode, 0);\n\tif (!ret)\n\t\tret = filemap_fdatawrite(inode->i_mapping);\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 99 }, { "index": 27286, "code": "test_long_as_size_t(PyObject *self)\n{\n size_t out_u;\n Py_ssize_t out_s;\n\n Py_INCREF(Py_None);\n\n out_u = PyLong_AsSize_t(Py_None);\n if (out_u != (size_t)-1 || !PyErr_Occurred())\n return raiseTestError(\"test_long_as_size_t\",\n \"PyLong_AsSize_t(None) didn't complain\");\n if (!PyErr_ExceptionMatches(PyExc_TypeError))\n return raiseTestError(\"test_long_as_size_t\",\n \"PyLong_AsSize_t(None) raised \"\n \"something other than TypeError\");\n PyErr_Clear();\n\n out_s = PyLong_AsSsize_t(Py_None);\n if (out_s != (Py_ssize_t)-1 || !PyErr_Occurred())\n return raiseTestError(\"test_long_as_size_t\",\n \"PyLong_AsSsize_t(None) didn't complain\");\n if (!PyErr_ExceptionMatches(PyExc_TypeError))\n return raiseTestError(\"test_long_as_size_t\",\n \"PyLong_AsSsize_t(None) raised \"\n \"something other than TypeError\");\n PyErr_Clear();\n\n /* Py_INCREF(Py_None) omitted - we already have a reference to it. */\n return Py_None;\n}", "label": 0, "cwe": null, "length": 264 }, { "index": 907449, "code": "ipmipower_poll (struct pollfd *ufds, unsigned int nfds, int timeout)\n{\n int n;\n struct timeval tv, tv_orig;\n struct timeval start, end, delta;\n\n /* prep for EINTR handling */\n if (timeout >= 0)\n {\n /* poll uses timeout in milliseconds */\n tv_orig.tv_sec = (long)timeout/1000;\n tv_orig.tv_usec = (timeout % 1000) * 1000;\n\n if (gettimeofday(&start, NULL) < 0)\n {\n IPMIPOWER_ERROR ((\"gettimeofday: %s\", strerror (errno)));\n exit (1);\n }\n }\n else\n {\n tv_orig.tv_sec = 0;\n tv_orig.tv_usec = 0;\n }\n\n /* repeat poll if interrupted */\n do\n {\n n = poll(ufds, nfds, timeout);\n\n /* unrecov error */\n if (n < 0 && errno != EINTR)\n {\n IPMIPOWER_ERROR ((\"poll: %s\", strerror (errno)));\n exit (1);\n }\n\n if (n < 0 && timeout >= 0) /* EINTR - adjust timeout */\n {\n if (gettimeofday(&end, NULL) < 0)\n {\n IPMIPOWER_ERROR ((\"gettimeofday: %s\", strerror (errno)));\n exit (1);\n }\n\n timersub(&end, &start, &delta); /* delta = end-start */\n timersub(&tv_orig, &delta, &tv); /* tv = tvsave-delta */\n timeout = (tv.tv_sec * 1000) + (tv.tv_usec/1000);\n }\n } while (n < 0);\n\n return n;\n}", "label": 0, "cwe": null, "length": 377 }, { "index": 179822, "code": "fgetdword(lp, fd)\nlong *lp;\nint fd;\n{\n\tu_char buf[4];\n\n\tif (sureread(fd, buf, sizeof(buf)) != sizeof(buf)) return(-1);\n\t*lp = getdword(buf, 0);\n\n\treturn(0);\n}", "label": 0, "cwe": null, "length": 60 }, { "index": 998490, "code": "H5AC_check_if_write_permitted(const H5F_t UNUSED * f,\n hid_t UNUSED dxpl_id,\n hbool_t * write_permitted_ptr)\n#endif /* H5_HAVE_PARALLEL */\n{\n hbool_t\t\twrite_permitted = TRUE;\n herr_t\t\tret_value = SUCCEED; /* Return value */\n#ifdef H5_HAVE_PARALLEL\n H5AC_aux_t *\taux_ptr = NULL;\n#endif /* H5_HAVE_PARALLEL */\n\n\n FUNC_ENTER_NOAPI(FAIL)\n\n#ifdef H5_HAVE_PARALLEL\n HDassert( f != NULL );\n HDassert( f->shared != NULL );\n HDassert( f->shared->cache != NULL );\n\n aux_ptr = (H5AC_aux_t *)(f->shared->cache->aux_ptr);\n\n if ( aux_ptr != NULL ) {\n\n HDassert( aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC );\n\n if ( ( aux_ptr->mpi_rank == 0 ) ||\n ( aux_ptr->metadata_write_strategy ==\n H5AC_METADATA_WRITE_STRATEGY__DISTRIBUTED ) ) {\n\n\t write_permitted = aux_ptr->write_permitted;\n\n } else {\n\n\t write_permitted = FALSE;\n\t}\n }\n#endif /* H5_HAVE_PARALLEL */\n\n *write_permitted_ptr = write_permitted;\n\ndone:\n\n FUNC_LEAVE_NOAPI(ret_value)\n\n}", "label": 0, "cwe": null, "length": 288 }, { "index": 967057, "code": "katoob_big_info(const std::string& message, bool enable_insert) {\n Gtk::Dialog dlg;\n Gtk::ScrolledWindow sw;\n sw.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);\n Gtk::TextView tv;\n tv.set_editable(false);\n tv.get_buffer()->set_text(message);\n sw.add(tv);\n dlg.get_vbox()->pack_start(sw, true, true);\n dlg.set_size_request(Gdk::Screen::get_default()->get_width()/2, Gdk::Screen::get_default()->get_height()/2);\n\n if (enable_insert) {\n dlg.add_button(_(\"Insert to document\"), Gtk::RESPONSE_YES);\n }\n\n dlg.add_button(Gtk::Stock::OK, Gtk::RESPONSE_OK);\n\n dlg.show_all();\n switch (dlg.run()) {\n case Gtk::RESPONSE_YES:\n return true;\n default:\n return false;\n }\n}", "label": 0, "cwe": null, "length": 195 }, { "index": 692463, "code": "generic_table(unsigned int *value, const unsigned int lng, const int algo,const unsigned int val_stop,const int mode_aff)\n{\n {\n unsigned int i;\n for(i=0;i 4) {\n ShowUsage();\n return 1;\n }\n\n string in1_name = strcmp(argv[1], \"-\") == 0 ? \"\" : argv[1];\n string in2_name = strcmp(argv[2], \"-\") == 0 ? \"\" : argv[2];\n string out_name = argc > 3 ? argv[3] : \"\";\n\n if (in1_name.empty() && in2_name.empty()) {\n LOG(ERROR) << argv[0] << \": Can't take both inputs from standard input.\";\n return 1;\n }\n\n FstClass *ifst1 = FstClass::Read(in1_name);\n if (!ifst1) return 1;\n FstClass *ifst2 = FstClass::Read(in2_name);\n if (!ifst2) return 1;\n\n VectorFstClass ofst(ifst1->ArcType());\n\n fst::ComposeFilter cf;\n\n if (FLAGS_compose_filter == \"auto\") {\n cf = fst::AUTO_FILTER;\n } else if (FLAGS_compose_filter == \"sequence\") {\n cf = fst::SEQUENCE_FILTER;\n } else if (FLAGS_compose_filter == \"alt_sequence\") {\n cf = fst::ALT_SEQUENCE_FILTER;\n } else if (FLAGS_compose_filter == \"match\") {\n cf = fst::MATCH_FILTER;\n } else {\n LOG(ERROR) << argv[0] << \": Bad filter type \\\"\"\n << FLAGS_compose_filter << \"\\\"\";\n return 1;\n }\n\n fst::DifferenceOptions opts(FLAGS_connect, cf);\n\n s::Difference(*ifst1, *ifst2, &ofst, opts);\n\n ofst.Write(out_name);\n\n return 0;\n}", "label": 0, "cwe": null, "length": 502 }, { "index": 1014707, "code": "irafgetc (\n\nchar\t*irafheader,\t/* IRAF image header */\nint\toffset,\t\t/* Number of bytes to skip before string */\nint\tnc)\t\t/* Maximum number of characters in string */\n\n{\n char *ctemp, *cheader;\n int i;\n\n cheader = irafheader;\n ctemp = (char *) calloc (nc+1, 1);\n if (ctemp == NULL) {\n\tffpmsg(\"IRAFGETC Cannot allocate memory for string variable\");\n\treturn (NULL);\n\t}\n for (i = 0; i < nc; i++) {\n\tctemp[i] = cheader[offset+i];\n\tif (ctemp[i] > 0 && ctemp[i] < 32)\n\t ctemp[i] = ' ';\n\t}\n\n return (ctemp);\n}", "label": 0, "cwe": null, "length": 176 }, { "index": 651112, "code": "memrec_rem_var(memrec_t *memrec, const spif_charptr_t var, const spif_charptr_t filename, unsigned long line, const void *ptr)\n{\n register ptr_t *p;\n\n ASSERT(memrec != NULL);\n USE_VAR(var);\n USE_VAR(filename);\n USE_VAR(line);\n\n if ((p = memrec_find_var(memrec, ptr)) == NULL) {\n D_MEM((\"ERROR: File %s, line %d attempted to free variable %s (%10p) which was not allocated with MALLOC/REALLOC\\n\",\n filename, line, var, ptr));\n return;\n }\n D_MEM((\"Removing variable %s (%10p) of size %lu\\n\", var, ptr, p->size));\n if ((--memrec->cnt) > 0) {\n memmove(p, p + 1, sizeof(ptr_t) * (memrec->cnt - (p - memrec->ptrs)));\n memrec->ptrs = (ptr_t *) realloc(memrec->ptrs, sizeof(ptr_t) * memrec->cnt);\n }\n}", "label": 0, "cwe": null, "length": 236 }, { "index": 452708, "code": "draw_history(int num, int size, unsigned int *history,\n\t\t\t unsigned char *buf)\n{\n int pixels_per_byte;\n int j, k;\n int *p;\n int d;\n\n pixels_per_byte = 100;\n p = history;\n\n for (j = 0; j < num; j++) {\n\tif (p[0] > pixels_per_byte)\n\t pixels_per_byte += 100;\n\tp++;\n }\n\n p = history;\n\n for (k = 0; k < num; k++) {\n\td = (1.0 * p[0] / pixels_per_byte) * size;\n\n\tfor (j = 0; j < size; j++) {\n\t if (j < d - 2)\n\t\tdraw_pixel(k, size - j - 1, buf, \"\\x00\\x7d\\x71\");\n\t else if (j < d)\n\t\tdraw_pixel(k, size - j - 1, buf, \"\\x20\\xb6\\xae\");\n\t}\n\tp++;\n }\n\n for (j = pixels_per_byte - 100; j > 0; j -= 100) {\n\tfor (k = 0; k < num; k++) {\n\t d = ((float) size / pixels_per_byte) * j;\n\t draw_pixel(k, size - d - 1, buf, \"\\x71\\xe3\\x71\");\n\t}\n }\n}", "label": 0, "cwe": null, "length": 294 }, { "index": 10364, "code": "dsmark_parse_class_opt(struct qdisc_util *qu, int argc, char **argv,\n struct nlmsghdr *n)\n{\n\tstruct rtattr *tail;\n\t__u8 tmp;\n\tchar *end;\n\n\ttail = NLMSG_TAIL(n);\n\taddattr_l(n,1024,TCA_OPTIONS,NULL,0);\n\twhile (argc > 0) {\n\t\tif (!strcmp(*argv,\"mask\")) {\n\t\t\tNEXT_ARG();\n\t\t\ttmp = strtoul(*argv,&end,0);\n\t\t\tif (*end) {\n\t\t\t\texplain_class();\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\taddattr_l(n,1024,TCA_DSMARK_MASK,&tmp,1);\n\t\t}\n\t\telse if (!strcmp(*argv,\"value\")) {\n\t\t\tNEXT_ARG();\n\t\t\ttmp = strtoul(*argv,&end,0);\n\t\t\tif (*end) {\n\t\t\t\texplain_class();\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\taddattr_l(n,1024,TCA_DSMARK_VALUE,&tmp,1);\n\t\t}\n\t\telse {\n\t\t\texplain_class();\n\t\t\treturn -1;\n\t\t}\n\t\targc--;\n\t\targv++;\n\t}\n\ttail->rta_len = (void *) NLMSG_TAIL(n) - (void *) tail;\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 268 }, { "index": 479374, "code": "write_db(const char *name, long count, long cache, int wflags, tm_t *done)\n{\n\tDBM *db = open_db(name, TRUE, cache, wflags);\n\tlong i;\n\tdatum key;\n\tchar buf[1024];\n\tlong cpage = 0 == cache ? 64 : cache;\n\n\tprintf(\"Starting %swrite test (%ld item%s), \"\n\t\t\"cache=%ld page%s, %s write...\\n\",\n\t\t(wflags & WR_VOLATILE) ? \"volatile \" : \"\",\n\t\tcount, 1 == count ? \"\" : \"s\", cpage, 1 == cpage ? \"\" : \"s\",\n\t\t(wflags & WR_DELAY) ? \"delayed\" : \"immediate\");\n\n\tkey.dsize = large_keys ? sizeof buf : NORMAL_KEY_LEN;\n\tkey.dptr = buf;\n\n\tfor (i = 0; i < count; i++) {\n\t\tdatum val;\n\t\tchar valbuf[1024];\n\n\t\tif (progress && 0 == i % 500)\n\t\t\tshow_progress(i, count);\n\n\t\tfill_key(buf, sizeof buf, i);\n\n\t\tval.dptr = key.dptr;\n\t\tif (large_values) {\n\t\t\tif (large_keys) {\n\t\t\t\tval.dsize = key.dsize;\n\t\t\t} else {\n\t\t\t\tmemset(valbuf, 0, sizeof valbuf);\n\t\t\t\tmemcpy(valbuf, key.dptr, NORMAL_KEY_LEN);\n\t\t\t\tval.dsize = sizeof valbuf;\n\t\t\t\tval.dptr = valbuf;\n\t\t\t}\n\t\t} else {\n\t\t\tval.dsize = NORMAL_KEY_LEN;\n\t\t}\n\n\t\tif (-1 == sdbm_store(db, key, val, DBM_REPLACE))\n\t\t\toops(\"write error at item #%ld\", i);\n\t}\n\n\tshow_done(done);\n\n\tsdbm_close(db);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 377 }, { "index": 941515, "code": "__ibv_create_ah(struct ibv_pd *pd, struct ibv_ah_attr *attr)\n{\n\tstruct ibv_ah *ah = pd->context->ops.create_ah(pd, attr);\n\n\tif (ah) {\n\t\tah->context = pd->context;\n\t\tah->pd = pd;\n\t}\n\n\treturn ah;\n}", "label": 0, "cwe": null, "length": 74 }, { "index": 115733, "code": "concat(const FXString& srcfile1,const FXString& srcfile2,const FXString& dstfile,bool overwrite){\n FXuchar buffer[4096]; FXival nwritten,nread;\n if(srcfile1!=dstfile && srcfile2!=dstfile){\n FXFile src1(srcfile1,FXIO::Reading);\n if(src1.isOpen()){\n FXFile src2(srcfile2,FXIO::Reading);\n if(src2.isOpen()){\n FXFile dst(dstfile,overwrite?FXIO::Writing:FXIO::Writing|FXIO::Exclusive);\n if(dst.isOpen()){\n while(1){\n nread=src1.readBlock(buffer,sizeof(buffer));\n if(nread<0) return false;\n if(nread==0) break;\n nwritten=dst.writeBlock(buffer,nread);\n if(nwritten<0) return false;\n }\n while(1){\n nread=src2.readBlock(buffer,sizeof(buffer));\n if(nread<0) return false;\n if(nread==0) break;\n nwritten=dst.writeBlock(buffer,nread);\n if(nwritten<0) return false;\n }\n return true;\n }\n }\n }\n }\n return false;\n }", "label": 0, "cwe": null, "length": 261 }, { "index": 733536, "code": "FreeImage_Unload(FIBITMAP *dib) {\r\n\tif (NULL != dib) {\t\r\n\t\tif (NULL != dib->data) {\r\n\t\t\t// delete possible icc profile ...\r\n\t\t\tif (FreeImage_GetICCProfile(dib)->data)\r\n\t\t\t\tfree(FreeImage_GetICCProfile(dib)->data);\r\n\r\n\t\t\t// delete metadata models\r\n\t\t\tMETADATAMAP *metadata = ((FREEIMAGEHEADER *)dib->data)->metadata;\r\n\r\n\t\t\tfor(METADATAMAP::iterator i = (*metadata).begin(); i != (*metadata).end(); i++) {\r\n\t\t\t\tTAGMAP *tagmap = (*i).second;\r\n\r\n\t\t\t\tif(tagmap) {\r\n\t\t\t\t\tfor(TAGMAP::iterator j = tagmap->begin(); j != tagmap->end(); j++) {\r\n\t\t\t\t\t\tFITAG *tag = (*j).second;\r\n\t\t\t\t\t\tFreeImage_DeleteTag(tag);\r\n\t\t\t\t\t}\r\n\r\n\t\t\t\t\tdelete tagmap;\r\n\t\t\t\t}\r\n\t\t\t}\r\n\r\n\t\t\tdelete metadata;\r\n\r\n\t\t\t// delete embedded thumbnail\r\n\t\t\tFreeImage_Unload(FreeImage_GetThumbnail(dib));\r\n\r\n\t\t\t// delete bitmap ...\r\n\t\t\tFreeImage_Aligned_Free(dib->data);\r\n\t\t}\r\n\t\tfree(dib);\t\t// ... and the wrapper\r\n\t}\r\n}", "label": 0, "cwe": null, "length": 261 }, { "index": 908135, "code": "perf_event_validate_size(struct perf_event *event)\n{\n\t/*\n\t * The values computed here will be over-written when we actually\n\t * attach the event.\n\t */\n\t__perf_event_read_size(event, event->group_leader->nr_siblings + 1);\n\t__perf_event_header_size(event, event->attr.sample_type & ~PERF_SAMPLE_READ);\n\tperf_event__id_header_size(event);\n\n\t/*\n\t * Sum the lot; should not exceed the 64k limit we have on records.\n\t * Conservative limit to allow for callchains and other variable fields.\n\t */\n\tif (event->read_size + event->header_size +\n\t event->id_header_size + sizeof(struct perf_event_header) >= 16*1024)\n\t\treturn false;\n\n\treturn true;\n}", "label": 0, "cwe": null, "length": 162 }, { "index": 510, "code": "pushutfchar (lua_State *L, int arg) {\n lua_Integer code = luaL_checkinteger(L, arg);\n luaL_argcheck(L, 0 <= code && code <= MAXUNICODE, arg, \"value out of range\");\n lua_pushfstring(L, \"%U\", (long)code);\n}", "label": 0, "cwe": null, "length": 67 }, { "index": 428598, "code": "__percpu_init_rwsem(struct percpu_rw_semaphore *brw,\n\t\t\tconst char *name, struct lock_class_key *rwsem_key)\n{\n\tbrw->fast_read_ctr = alloc_percpu(int);\n\tif (unlikely(!brw->fast_read_ctr))\n\t\treturn -ENOMEM;\n\n\t/* ->rw_sem represents the whole percpu_rw_semaphore for lockdep */\n\t__init_rwsem(&brw->rw_sem, name, rwsem_key);\n\trcu_sync_init(&brw->rss, RCU_SCHED_SYNC);\n\tatomic_set(&brw->slow_read_ctr, 0);\n\tinit_waitqueue_head(&brw->write_waitq);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 139 }, { "index": 218857, "code": "ad_churn_machine(struct port *port)\n{\n\tif (port->sm_vars & AD_PORT_CHURNED) {\n\t\tport->sm_vars &= ~AD_PORT_CHURNED;\n\t\tport->sm_churn_actor_state = AD_CHURN_MONITOR;\n\t\tport->sm_churn_partner_state = AD_CHURN_MONITOR;\n\t\tport->sm_churn_actor_timer_counter =\n\t\t\t__ad_timer_to_ticks(AD_ACTOR_CHURN_TIMER, 0);\n\t\t port->sm_churn_partner_timer_counter =\n\t\t\t __ad_timer_to_ticks(AD_PARTNER_CHURN_TIMER, 0);\n\t\treturn;\n\t}\n\tif (port->sm_churn_actor_timer_counter &&\n\t !(--port->sm_churn_actor_timer_counter) &&\n\t port->sm_churn_actor_state == AD_CHURN_MONITOR) {\n\t\tif (port->actor_oper_port_state & AD_STATE_SYNCHRONIZATION) {\n\t\t\tport->sm_churn_actor_state = AD_NO_CHURN;\n\t\t} else {\n\t\t\tport->churn_actor_count++;\n\t\t\tport->sm_churn_actor_state = AD_CHURN;\n\t\t}\n\t}\n\tif (port->sm_churn_partner_timer_counter &&\n\t !(--port->sm_churn_partner_timer_counter) &&\n\t port->sm_churn_partner_state == AD_CHURN_MONITOR) {\n\t\tif (port->partner_oper.port_state & AD_STATE_SYNCHRONIZATION) {\n\t\t\tport->sm_churn_partner_state = AD_NO_CHURN;\n\t\t} else {\n\t\t\tport->churn_partner_count++;\n\t\t\tport->sm_churn_partner_state = AD_CHURN;\n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 331 }, { "index": 173341, "code": "setReadOnly(bool state)\n{\n // TODO: manage a read-only property PER ROW and for the whole model\n d->_readOnly = state;\n // update all itemdata of the parent formmain readonly property\n if (d->_formMain->itemData())\n d->_formMain->itemData()->setReadOnly(state);\n foreach(Form::FormItem *item, d->_formMain->flattenedFormItemChildren()) {\n if (item->itemData())\n item->itemData()->setReadOnly(state);\n }\n}", "label": 0, "cwe": null, "length": 110 }, { "index": 227331, "code": "build_unescape_string (const gchar *escaped)\n{\n\tgchar *unesc;\n\tgchar *end;\n\n \tif (escaped == NULL)\n\t\treturn NULL;\n\n\tunesc = g_new (gchar, strlen (escaped) + 1);\n\tend = unesc;\n\n\tfor (; *escaped != '\\0'; escaped++)\n\t{\n\n\t\tif (*escaped == '%')\n\t\t{\n\t\t\t*end++ = (g_ascii_xdigit_value (escaped[1]) << 4) | g_ascii_xdigit_value (escaped[2]);\n\t\t\tescaped += 2;\n\t\t}\n\t\telse\n\t\t{\n\t\t\t*end++ = *escaped;\n\t\t}\n\t}\n\t*end = '\\0';\n\n\treturn unesc;\n}", "label": 0, "cwe": null, "length": 152 }, { "index": 950166, "code": "param_check_val(struct iscsi_key *keys, int idx, unsigned int *val)\n{\n\tif (keys[idx].ops->check_val)\n\t\treturn keys[idx].ops->check_val(&keys[idx], val);\n\telse\n\t\treturn 0;\n}", "label": 0, "cwe": null, "length": 53 }, { "index": 787056, "code": "decide_tag_by_context(const char *tag, const char *file, const char *lineno)\n{\n\tchar path[MAXPATHLEN+1], s_fid[32];\n\tchar rootdir[MAXPATHLEN+1];\n\tconst char *tagline, *p;\n\tDBOP *dbop;\n\tint db = GSYMS;\n\n /*\n * rootdir always ends with '/'.\n */\n if (!strcmp(root, \"/\"))\n strlimcpy(rootdir, root, sizeof(rootdir));\n else\n snprintf(rootdir, sizeof(rootdir), \"%s/\", root);\n\tif (normalize(file, rootdir, cwd, path, sizeof(path)) == NULL)\n\t\tdie(\"'%s' is out of source tree.\", file);\n\t/*\n\t * get file id\n\t */\n\tif (gpath_open(dbpath, 0) < 0)\n\t\tdie(\"GPATH not found.\");\n\tif ((p = gpath_path2fid(path, NULL)) == NULL)\n\t\tdie(\"path name in the context is not found.\");\n\tstrlimcpy(s_fid, p, sizeof(s_fid));\n\tgpath_close();\n\t/*\n\t * read btree records directly to avoid the overhead.\n\t */\n\tdbop = dbop_open(makepath(dbpath, dbname(GTAGS), NULL), 0, 0, 0);\n\ttagline = dbop_first(dbop, tag, NULL, 0);\n\tif (tagline)\n\t\tdb = GTAGS;\n\tfor (; tagline; tagline = dbop_next(dbop)) {\n\t\t/*\n\t\t * examine whether the definition record include the context.\n\t\t */\n\t\tp = locatestring(tagline, s_fid, MATCH_AT_FIRST);\n\t\tif (p != NULL && *p == ' ') {\n\t\t\tfor (p++; *p && *p != ' '; p++)\n\t\t\t\t;\n\t\t\tif (*p++ != ' ')\n\t\t\t\tdie(\"Impossible!\");\n\t\t\tif ((p = locatestring(p, lineno, MATCH_AT_FIRST)) != NULL && *p == ' ') {\n\t\t\t\tdb = GRTAGS;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n dbop_close(dbop);\n\treturn db;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-469" ], "length": 441 }, { "index": 520339, "code": "sparse_keymap_setkeycode(struct input_dev *dev,\n\t\t\t\t const struct input_keymap_entry *ke,\n\t\t\t\t unsigned int *old_keycode)\n{\n\tstruct key_entry *key;\n\n\tif (dev->keycode) {\n\t\tkey = sparse_keymap_locate(dev, ke);\n\t\tif (key && key->type == KE_KEY) {\n\t\t\t*old_keycode = key->keycode;\n\t\t\tkey->keycode = ke->keycode;\n\t\t\tset_bit(ke->keycode, dev->keybit);\n\t\t\tif (!sparse_keymap_entry_from_keycode(dev, *old_keycode))\n\t\t\t\tclear_bit(*old_keycode, dev->keybit);\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\treturn -EINVAL;\n}", "label": 0, "cwe": null, "length": 153 }, { "index": 82546, "code": "find_user_host(struct Client *source_p, const char *userhost, char *luser, char *lhost)\n{\n\tchar *hostp;\n\tconst char *ptr;\n\n\thostp = strchr(userhost, '@');\n\n\tif(hostp != NULL)\t/* I'm a little user@host */\n\t{\n\t\t*(hostp++) = '\\0';\t/* short and squat */\n\t\tif(*userhost)\n\t\t\trb_strlcpy(luser, userhost, USERLEN + 1);\t/* here is my user */\n\t\telse\n\t\t\tstrcpy(luser, \"*\");\n\t\tif(*hostp)\n\t\t{\n\t\t\tptr = mangle_wildcard_to_cidr(hostp);\n\t\t\tif(ptr == NULL)\n\t\t\t\tptr = hostp;\n\t\t\trb_strlcpy(lhost, ptr, HOSTLEN + 1);\t/* here is my host */\n\t\t}\n\t\telse\n\t\t\tstrcpy(lhost, \"*\");\n\t}\n\telse\n\t{\n\t\t/* no '@', no '.', so its not a user@host or host, therefore\n\t\t * its a nick, which support was removed for.\n\t\t */\n\t\tif(strchr(userhost, '.') == NULL && strchr(userhost, ':') == NULL)\n\t\t{\n\t\t\tsendto_one_notice(source_p, \":K-Line must be a user@host or host\");\n\t\t\treturn 0;\n\t\t}\n\n\t\tluser[0] = '*';\t/* no @ found, assume its *@somehost */\n\t\tluser[1] = '\\0';\n\t\tptr = mangle_wildcard_to_cidr(userhost);\n\n\t\tif(ptr == NULL)\n\t\t\tptr = userhost;\n\n\t\trb_strlcpy(lhost, ptr, HOSTLEN + 1);\n\t}\n\n\treturn 1;\n}", "label": 1, "cwe": "CWE-120", "length": 362 }, { "index": 657227, "code": "getNumSelectRow(gint numOrb)\n{\n\tgint numRow = -1;\n\tgint i;\n\tfor(i=0;i test_winsync_plugin_start -- begin\\n\");\n\n\tif( slapi_apib_register(WINSYNC_v3_0_GUID, test_winsync_api_v3) ) {\n slapi_log_error( SLAPI_LOG_FATAL, test_winsync_plugin_name,\n \"<-- test_winsync_plugin_start -- failed to register winsync api -- end\\n\");\n return -1;\n\t}\n\t\n slapi_log_error(SLAPI_LOG_PLUGIN, test_winsync_plugin_name,\n \"<-- test_winsync_plugin_start -- end\\n\");\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 155 }, { "index": 536475, "code": "IsPredefinedName(const char* szPageSizeName)\n{\n\tfor (int i = static_cast(_first_predefined_pagesize_);\n\t\t i < static_cast(_last_predefined_pagesize_dont_use_); ++i)\n\t{\n\t\tif (!strcmp(pagesizes[i].name, szPageSizeName))\n\t\t\treturn true;\n\t}\n\treturn false;\n}", "label": 0, "cwe": null, "length": 74 }, { "index": 971393, "code": "hitmsg(mtmp, mattk)\nregister struct monst *mtmp;\nregister struct attack *mattk;\n{\n\tint compat;\n\n\t/* Note: if opposite gender, \"seductively\" */\n\t/* If same gender, \"engagingly\" for nymph, normal msg for others */\n\tif((compat = could_seduce(mtmp, &youmonst, mattk))\n\t\t\t&& !mtmp->mcan && !mtmp->mspec_used) {\n\t\tpline(\"%s %s you %s.\", Monnam(mtmp),\n\t\t\tBlind ? \"talks to\" : \"smiles at\",\n\t\t\tcompat == 2 ? \"engagingly\" : \"seductively\");\n\t} else\n\t switch (mattk->aatyp) {\n\t\tcase AT_BITE:\n\t\t\tpline(\"%s bites!\", Monnam(mtmp));\n\t\t\tbreak;\n\t\tcase AT_KICK:\n\t\t\tpline(\"%s kicks%c\", Monnam(mtmp),\n\t\t\t\t thick_skinned(youmonst.data) ? '.' : '!');\n\t\t\tbreak;\n\t\tcase AT_STNG:\n\t\t\tpline(\"%s stings!\", Monnam(mtmp));\n\t\t\tbreak;\n\t\tcase AT_BUTT:\n\t\t\tpline(\"%s butts!\", Monnam(mtmp));\n\t\t\tbreak;\n\t\tcase AT_TUCH:\n\t\t\tpline(\"%s touches you!\", Monnam(mtmp));\n\t\t\tbreak;\n\t\tcase AT_TENT:\n\t\t\tpline(\"%s tentacles suck you!\",\n\t\t\t\t s_suffix(Monnam(mtmp)));\n\t\t\tbreak;\n\t\tcase AT_EXPL:\n\t\tcase AT_BOOM:\n\t\t\tpline(\"%s explodes!\", Monnam(mtmp));\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tpline(\"%s hits!\", Monnam(mtmp));\n\t }\n}", "label": 0, "cwe": null, "length": 363 }, { "index": 577206, "code": "sky2_nway_reset(struct net_device *dev)\n{\n\tstruct sky2_port *sky2 = netdev_priv(dev);\n\n\tif (!netif_running(dev) || !(sky2->flags & SKY2_FLAG_AUTO_SPEED))\n\t\treturn -EINVAL;\n\n\tsky2_phy_reinit(sky2);\n\tsky2_set_multicast(dev);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 75 }, { "index": 6121, "code": "resizeMM(double mmW, double mmH, const LayerHash & viewLayers) \n{\n\tQ_UNUSED(viewLayers);\n\n\tif (mmW == 0 || mmH == 0) {\n\t\treturn false;\n\t}\n\n\t// DebugDialog::debug(QString(\"resize mm %1 %2\").arg(mmW).arg(mmH));\n\n\tQRectF r = this->boundingRect();\n\tif (qAbs(GraphicsUtils::pixels2mm(r.width(), GraphicsUtils::SVGDPI) - mmW) < .001 &&\n\t\tqAbs(GraphicsUtils::pixels2mm(r.height(), GraphicsUtils::SVGDPI) - mmH) < .001) \n\t{\n\t\treturn false;\n\t}\n\n\tdouble inW = GraphicsUtils::mm2mils(mmW) / 1000;\n\tdouble inH = GraphicsUtils::mm2mils(mmH) / 1000;\n\n\t// TODO: deal with aspect ratio\n\n\tQString svg = prop(\"shape\");\n\tif (svg.isEmpty()) return false;\n\n\tQString errorStr;\n\tint errorLine;\n\tint errorColumn;\n\n\tQDomDocument domDocument;\n\tif (!domDocument.setContent(svg, &errorStr, &errorLine, &errorColumn)) {\n\t\treturn false;\n\t}\n\n\tQDomElement root = domDocument.documentElement();\n\tif (root.isNull()) {\n\t\treturn false;\n\t}\n\n\tif (root.tagName() != \"svg\") {\n\t\treturn false;\n\t}\n\n\troot.setAttribute(\"width\", QString::number(inW) + \"in\");\n\troot.setAttribute(\"height\", QString::number(inH) + \"in\");\n\n\tsvg = TextUtils::removeXMLEntities(domDocument.toString());\t\n QString shape = getShapeForRenderer(svg);\n\n\tbool result = resetRenderer(shape);\n\tif (result) {\n\t\tmodelPart()->setLocalProp(\"shape\", svg);\n\t\tmodelPart()->setLocalProp(\"width\", mmW);\n\t\tmodelPart()->setLocalProp(\"height\", mmH);\n\t}\n\n\tsetWidthAndHeight(qRound(mmW * 10) / 10.0, qRound(mmH * 10) / 10.0);\n return true;\n}", "label": 0, "cwe": null, "length": 431 }, { "index": 126709, "code": "xml_hasComplexContent(JSContext *cx, uintN argc, jsval *vp)\n{\n JSXML *kid;\n JSObject *kidobj;\n uint32 i, n;\n\n XML_METHOD_PROLOG;\nagain:\n switch (xml->xml_class) {\n case JSXML_CLASS_ATTRIBUTE:\n case JSXML_CLASS_COMMENT:\n case JSXML_CLASS_PROCESSING_INSTRUCTION:\n case JSXML_CLASS_TEXT:\n *vp = JSVAL_FALSE;\n break;\n case JSXML_CLASS_LIST:\n if (xml->xml_kids.length == 0) {\n *vp = JSVAL_TRUE;\n } else if (xml->xml_kids.length == 1) {\n kid = XMLARRAY_MEMBER(&xml->xml_kids, 0, JSXML);\n if (kid) {\n kidobj = js_GetXMLObject(cx, kid);\n if (!kidobj)\n return JS_FALSE;\n obj = kidobj;\n xml = (JSXML *) obj->getPrivate();\n goto again;\n }\n }\n /* FALL THROUGH */\n default:\n *vp = JSVAL_FALSE;\n for (i = 0, n = xml->xml_kids.length; i < n; i++) {\n kid = XMLARRAY_MEMBER(&xml->xml_kids, i, JSXML);\n if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) {\n *vp = JSVAL_TRUE;\n break;\n }\n }\n break;\n }\n return JS_TRUE;\n}", "label": 0, "cwe": null, "length": 318 }, { "index": 76527, "code": "q_edge_tension_value(e_info)\nstruct qinfo *e_info;\n{ REAL energy;\n if ( web.modeltype == QUADRATIC ) return edge_length_q_value(e_info);\n if ( web.modeltype == LAGRANGE ) \n return lagrange_edge_tension_value(e_info);\n energy = sqrt(SDIM_dot(e_info->sides[0][0],e_info->sides[0][0]));\n\n if ( METH_INSTANCE(e_info->method)->flags & DEFAULT_INSTANCE )\n { \n#ifdef SHARED_MEMORY\n if ( nprocs > 1 ) \n proc_total_area[GET_THREAD_ID] += energy;\n else\n#endif\n binary_tree_add(web.total_area_addends,energy);\n set_edge_length(e_info->id,energy);\n }\n \n if ( METH_INSTANCE(e_info->method)->flags & USE_DENSITY )\n energy *= get_edge_density(e_info->id);\n \n return energy; \n}", "label": 0, "cwe": null, "length": 199 }, { "index": 137892, "code": "fuse_loop_start_thread(struct fuse_mt *mt)\n{\n\tint res;\n\tstruct fuse_worker *w = malloc(sizeof(struct fuse_worker));\n\tif (!w) {\n\t\tfprintf(stderr, \"fuse: failed to allocate worker structure\\n\");\n\t\treturn -1;\n\t}\n\tmemset(w, 0, sizeof(struct fuse_worker));\n\tw->bufsize = fuse_chan_bufsize(mt->prevch);\n\tw->buf = malloc(w->bufsize);\n\tw->mt = mt;\n\tif (!w->buf) {\n\t\tfprintf(stderr, \"fuse: failed to allocate read buffer\\n\");\n\t\tfree(w);\n\t\treturn -1;\n\t}\n\n\tres = fuse_start_thread(&w->thread_id, fuse_do_work, w);\n\tif (res == -1) {\n\t\tfree(w->buf);\n\t\tfree(w);\n\t\treturn -1;\n\t}\n\tlist_add_worker(w, &mt->main);\n\tmt->numavail ++;\n\tmt->numworker ++;\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 196 }, { "index": 916452, "code": "getWorkspaceNames(void)\n{\n if (_mwmWindow!=0 && _workspaceCount>0)\n {\n MSStringVector names(_workspaceCount);\n for (unsigned i=0; i<_workspaceCount; ++i)\n {\n\t names.replaceAt(i,getWorkspaceName(_workspaceAtoms[i]));\n }\n return names;\n }\n else\n {\n return MSStringVector();\n }\n}", "label": 0, "cwe": null, "length": 86 }, { "index": 279132, "code": "make_field(Send_field *tmp_field)\n{\n tmp_field->table_name= tmp_field->org_table_name= table_name;\n tmp_field->db_name= db_name;\n tmp_field->col_name= tmp_field->org_col_name= field->field_name;\n tmp_field->charsetnr= field->charset()->number;\n tmp_field->length=field->field_length;\n tmp_field->type=field->type();\n tmp_field->flags= field->table->maybe_null ? \n (field->flags & ~NOT_NULL_FLAG) : field->flags;\n tmp_field->decimals= field->decimals();\n}", "label": 0, "cwe": null, "length": 134 }, { "index": 325727, "code": "gst_opengl_oop_to_int_array (GLint *dest, OOP sourceOOP, int n)\n{\n enum gst_indexed_kind kind;\n void *base;\n int i, size;\n\n size = vm_proxy->basicSize (sourceOOP);\n if (size < n)\n return NULL;\n\n kind = vm_proxy->OOPIndexedKind (sourceOOP);\n base = vm_proxy->OOPIndexedBase (sourceOOP);\n switch (kind)\n {\n\n#define LOOP(type)\t\t\t\t\t\t\\\n {\t\t\t\t\t\t\t\t\\\n type *p = base;\t\t\t\t\t\t\\\n for (i = 0; i < n; i++)\t\t\t\t\t\\\n dest[i] = p[i];\t\t\t\t\t\t\\\n }\t\t\t\t\t\t\t\t\\\n break;\n\n case GST_ISP_SCHAR:\n\tLOOP (signed char);\n case GST_ISP_UCHAR:\n\tLOOP (unsigned char);\n case GST_ISP_SHORT:\n\tLOOP (short);\n case GST_ISP_USHORT:\n\tLOOP (unsigned short);\n case GST_ISP_INT:\n case GST_ISP_UINT:\n\treturn base;\n case GST_ISP_FLOAT:\n\tLOOP (float);\n case GST_ISP_DOUBLE:\n\tLOOP (double);\n\n case GST_ISP_POINTER:\n\t{\n\t OOP *p = base;\n\t for (i = 0; i < n; i++)\n\t dest[i] = vm_proxy->OOPToC (p[i]);\n\t break;\n\t}\n\n default:\n\treturn NULL;\n }\n\n return dest;\n}", "label": 0, "cwe": null, "length": 323 }, { "index": 994856, "code": "update_key_stats()\n{\n for (uint i= 0; i < table->s->keys; i++)\n {\n KEY *key=table->key_info+i;\n if (!key->rec_per_key)\n continue;\n if (key->algorithm != HA_KEY_ALG_BTREE)\n {\n if (key->flags & HA_NOSAME)\n key->rec_per_key[key->key_parts-1]= 1;\n else\n {\n ha_rows hash_buckets= file->s->keydef[i].hash_buckets;\n uint no_records= hash_buckets ? (uint) (file->s->records/hash_buckets) : 2;\n if (no_records < 2)\n no_records= 2;\n key->rec_per_key[key->key_parts-1]= no_records;\n }\n }\n }\n records_changed= 0;\n /* At the end of update_key_stats() we can proudly claim they are OK. */\n key_stat_version= file->s->key_stat_version;\n}", "label": 0, "cwe": null, "length": 218 }, { "index": 346814, "code": "spell_let_to_idx(ilet)\nchar ilet;\n{\n int indx;\n\n indx = ilet - 'a';\n if (indx >= 0 && indx < 26) return indx;\n indx = ilet - 'A';\n if (indx >= 0 && indx < 26) return indx + 26;\n return -1;\n}", "label": 0, "cwe": null, "length": 74 }, { "index": 289819, "code": "target_design(ivl_design_t des)\n{\n ivl_scope_t*root_scopes;\n unsigned nroot = 0;\n unsigned idx;\n\n const char*path = ivl_design_flag(des, \"-o\");\n if (path == 0) {\n\t return -1;\n }\n\n out = fopen(path, \"w\");\n if (out == 0) {\n\t perror(path);\n\t return -2;\n }\n\n for (idx = 0 ; idx < ivl_design_disciplines(des) ; idx += 1) {\n\t ivl_discipline_t dis = ivl_design_discipline(des,idx);\n\t fprintf(out, \"discipline %s\\n\", ivl_discipline_name(dis));\n }\n\n ivl_design_roots(des, &root_scopes, &nroot);\n for (idx = 0 ; idx < nroot ; idx += 1) {\n\n\t fprintf(out, \"root module = %s;\\n\",\n\t\t ivl_scope_name(root_scopes[idx]));\n\t show_scope(root_scopes[idx], 0);\n }\n\n while (udp_define_list) {\n\t struct udp_define_cell*cur = udp_define_list;\n\t udp_define_list = cur->next;\n\t show_primitive(cur->udp, cur->ref);\n\t free(cur);\n }\n\n ivl_design_process(des, show_process, 0);\n fclose(out);\n\n return stub_errors;\n}", "label": 1, "cwe": "CWE-other", "length": 296 }, { "index": 623769, "code": "big_block_is_allocated(DBM *db, size_t bno)\n{\n\tDBMBIG *dbg = db->big;\n\tlong bmap;\n\tsize_t bit;\n\n\tbmap = bno / BIG_BITCOUNT;\t\t\t/* Bitmap handling this block */\n\tbit = bno & (BIG_BITCOUNT - 1);\t\t/* Index within bitmap */\n\n\tif (bmap >= dbg->bitmaps)\n\t\treturn FALSE;\t\t\t\t\t/* Bitmap not allocated yet */\n\n\tif (0 == bit)\n\t\treturn FALSE;\t\t\t\t\t/* Refers to the bitmap itself */\n\n\t/*\n\t * Fetch the bitmap where block lies.\n\t */\n\n\tif (!fetch_bitbuf(db, bmap))\n\t\treturn FALSE;\n\n\t/*\n\t * Check bit in the loaded bitmap.\n\t */\n\n\treturn bit_field_get(dbg->bitbuf, bit);\n}", "label": 0, "cwe": null, "length": 167 }, { "index": 349733, "code": "PyErr_ProgramText(const char *filename, int lineno)\n{\n FILE *fp;\n int i;\n char linebuf[1000];\n\n if (filename == NULL || *filename == '\\0' || lineno <= 0)\n return NULL;\n fp = fopen(filename, \"r\" PY_STDIOTEXTMODE);\n if (fp == NULL)\n return NULL;\n for (i = 0; i < lineno; i++) {\n char *pLastChar = &linebuf[sizeof(linebuf) - 2];\n do {\n *pLastChar = '\\0';\n if (Py_UniversalNewlineFgets(linebuf, sizeof linebuf,\n fp, NULL) == NULL)\n break;\n /* fgets read *something*; if it didn't get as\n far as pLastChar, it must have found a newline\n or hit the end of the file; if pLastChar is \\n,\n it obviously found a newline; else we haven't\n yet seen a newline, so must continue */\n } while (*pLastChar != '\\0' && *pLastChar != '\\n');\n }\n fclose(fp);\n if (i == lineno) {\n char *p = linebuf;\n PyObject *res;\n while (*p == ' ' || *p == '\\t' || *p == '\\014')\n p++;\n res = PyUnicode_FromString(p);\n if (res == NULL)\n PyErr_Clear();\n return res;\n }\n return NULL;\n}", "label": 0, "cwe": null, "length": 325 }, { "index": 312694, "code": "getCRC16(armcpu_t* cpu)\n{\n unsigned int i,j;\n \n u32 crc = cpu->R[0];\n u32 datap = cpu->R[1];\n u32 size = cpu->R[2];\n \n static u16 val[] = { 0xC0C1,0xC181,0xC301,0xC601,0xCC01,0xD801,0xF001,0xA001 };\n for(i = 0; i < size; i++)\n {\n crc = crc ^ MMU_read8( cpu->proc_ID, datap + i);\n\n for(j = 0; j < 8; j++) {\n int do_bit = 0;\n\n if ( crc & 0x1)\n do_bit = 1;\n\n crc = crc >> 1;\n\n if ( do_bit) {\n crc = crc ^ (val[j] << (7-j));\n }\n }\n }\n cpu->R[0] = crc;\n return 1;\n}", "label": 0, "cwe": null, "length": 221 }, { "index": 47948, "code": "count_residues(glam2_col *col, const glam2_aln *aln, const mfasta *m) {\n int i;\n ZERO(col->emission_counts, col->alph_size+1);\n\n for (i = 0; i < col->seq_num; ++i)\n if (ALIGNED(aln, i) && col->matches[i]) {\n const int *seq = aln->strands[i] == '+' ? m->f[i].seq : m->f[i].rcseq;\n ++col->emission_counts[seq[col->positions[i]]];\n }\n}", "label": 0, "cwe": null, "length": 129 }, { "index": 853934, "code": "samsung_sabi_diag(struct samsung_laptop *samsung)\n{\n\tint loca = find_signature(samsung->f0000_segment, \"SDiaG@\");\n\tint i;\n\n\tif (loca == 0xffff)\n\t\treturn ;\n\n\t/* Example:\n\t * Ident: @SDiaG@686XX-N90X3A/966-SEC-07HL-S90X3A\n\t *\n\t * Product name: 90X3A\n\t * BIOS Version: 07HL\n\t */\n\tloca += 1;\n\tfor (i = 0; loca < 0xffff && i < sizeof(samsung->sdiag) - 1; loca++) {\n\t\tchar temp = readb(samsung->f0000_segment + loca);\n\n\t\tif (isalnum(temp) || temp == '/' || temp == '-')\n\t\t\tsamsung->sdiag[i++] = temp;\n\t\telse\n\t\t\tbreak ;\n\t}\n\n\tif (debug && samsung->sdiag[0])\n\t\tpr_info(\"sdiag: %s\", samsung->sdiag);\n}", "label": 0, "cwe": null, "length": 223 }, { "index": 110824, "code": "sshv2_send_command (gftp_request * request, char type, char *command, \n size_t len)\n{\n char buf[34000];\n guint32 clen;\n int ret;\n\n if (len > 33995)\n {\n request->logging_function (gftp_logging_error, request,\n _(\"Error: Message size %d too big\\n\"), len);\n gftp_disconnect (request);\n return (GFTP_EFATAL);\n }\n\n clen = htonl (len + 1);\n memcpy (buf, &clen, 4);\n buf[4] = type;\n memcpy (&buf[5], command, len);\n buf[len + 5] = '\\0';\n\n#ifdef DEBUG\n printf (\"\\rSending to FD %d: \", request->datafd);\n for (clen=0; clendatafd)) < 0)\n return (ret);\n\n return (0);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 270 }, { "index": 1003308, "code": "gwy_plain_tool_selection_reconnect(GwyPlainTool *plain_tool)\n{\n const gchar *key;\n gchar *sigdetail;\n\n gwy_debug(\"%s\", plain_tool->selection_bname);\n\n if (!plain_tool->selection_bname)\n return;\n\n key = gwy_plain_tool_set_selection_key(plain_tool,\n plain_tool->selection_bname);\n sigdetail = g_strconcat(ITEM_CHANGED, key, NULL);\n\n plain_tool->selection_item_id\n = g_signal_connect(plain_tool->container, sigdetail,\n G_CALLBACK(gwy_plain_tool_selection_item_changed),\n plain_tool);\n if (gwy_container_gis_object_by_name(plain_tool->container, key,\n &plain_tool->selection)) {\n g_object_ref(plain_tool->selection);\n plain_tool->selection_cid\n = g_signal_connect(plain_tool->selection, \"changed\",\n G_CALLBACK(gwy_plain_tool_selection_changed),\n plain_tool);\n plain_tool->selection_fid\n = g_signal_connect(plain_tool->selection, \"finished\",\n G_CALLBACK(gwy_plain_tool_selection_finished),\n plain_tool);\n }\n\n g_free(sigdetail);\n\n gwy_plain_tool_selection_changed(plain_tool->selection, -1, plain_tool);\n}", "label": 0, "cwe": null, "length": 265 }, { "index": 339903, "code": "sfx_audbuf_init(sfx_audio_buf_t *buf, sfx_pcm_config_t pcm_conf)\n{\n\tint framesize = SFX_PCM_FRAME_SIZE(pcm_conf);\n\tbyte silence[16];\n\tint silencew = pcm_conf.format & ~SFX_PCM_FORMAT_LMASK;\n\n\t/* Determine the correct 'silence' for the channel and install it */\n\t/* Conservatively assume stereo */\n\tif (pcm_conf.format & SFX_PCM_FORMAT_16) {\n\t\tif (pcm_conf.format & SFX_PCM_FORMAT_LE) {\n\t\t\tsilence[0] = silencew & 0xff;\n\t\t\tsilence[1] = (silencew >> 8) & 0xff;\n\t\t} else {\n\t\t\tsilence[0] = (silencew >> 8) & 0xff;\n\t\t\tsilence[1] = silencew & 0xff;\n\t\t}\n\t\tmemcpy(silence + 2, silence, 2);\n\t} else {\n\t\tsilence[0] = silencew;\n\t\tsilence[1] = silencew;\n\t}\n\n\tbuf->last = buf->first = sfx_audbuf_alloc_chunk();\n\tbuf->unused = NULL;\n\tmemcpy(buf->last_frame, silence, framesize);\t /* Initialise, in case we\n\t\t\t\t\t\t\t ** underrun before the\n\t\t\t\t\t\t\t ** first write */\n\tbuf->read_offset = 0;\n\tbuf->framesize = framesize;\n\tbuf->read_timestamp.secs = -1; /* Mark as inactive */\n\tbuf->frames_nr = 0;\n}", "label": 1, "cwe": "CWE-120", "length": 326 }, { "index": 647754, "code": "click_in_cksum(const unsigned char *addr, int len)\n{\n int nleft = len;\n const uint16_t *w = (const uint16_t *)addr;\n uint32_t sum = 0;\n uint16_t answer = 0;\n\n /*\n * Our algorithm is simple, using a 32 bit accumulator (sum), we add\n * sequential 16 bit words to it, and at the end, fold back all the\n * carry bits from the top 16 bits into the lower 16 bits.\n */\n while (nleft > 1) {\n\tsum += *w++;\n\tnleft -= 2;\n }\n\n /* mop up an odd byte, if necessary */\n if (nleft == 1) {\n\t*(unsigned char *)(&answer) = *(const unsigned char *)w ;\n\tsum += answer;\n }\n\n /* add back carry outs from top 16 bits to low 16 bits */\n sum = (sum & 0xffff) + (sum >> 16);\n sum += (sum >> 16);\n /* guaranteed now that the lower 16 bits of sum are correct */\n\n answer = ~sum; /* truncate to 16 bits */\n return answer;\n}", "label": 0, "cwe": null, "length": 260 }, { "index": 403823, "code": "node_states_clear_node(int node, struct memory_notify *arg)\n{\n\tif (arg->status_change_nid_normal >= 0)\n\t\tnode_clear_state(node, N_NORMAL_MEMORY);\n\n\tif ((N_MEMORY != N_NORMAL_MEMORY) &&\n\t (arg->status_change_nid_high >= 0))\n\t\tnode_clear_state(node, N_HIGH_MEMORY);\n\n\tif ((N_MEMORY != N_HIGH_MEMORY) &&\n\t (arg->status_change_nid >= 0))\n\t\tnode_clear_state(node, N_MEMORY);\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 192670, "code": "dav_xml_escape_uri(apr_pool_t *p, const char *uri)\n{\n /* check the easy case... */\n if (ap_strchr_c(uri, '&') == NULL)\n return uri;\n\n /* there was a '&', so more work is needed... sigh. */\n\n /*\n * Note: this is a teeny bit of overkill since we know there are no\n * '<' or '>' characters, but who cares.\n */\n return apr_xml_quote_string(p, uri, 0);\n}", "label": 0, "cwe": null, "length": 111 }, { "index": 252186, "code": "do_main_class(void)\n{\n\tstruct vm_object *loader = NULL;\n\n\tif (use_system_classloader) {\n\t\tloader = get_system_class_loader();\n\t\tif (!loader)\n\t\t\treturn -1;\n\t}\n\n\tif (exception_occurred()) {\n\t\treturn -1;\n\t}\n\n\tstruct vm_class *vmc = classloader_load(loader, classname);\n\tif (!vmc) {\n\t\tfprintf(stderr, \"error: %s: could not load\\n\", classname);\n\t\treturn -1;\n\t}\n\n\tif (vm_class_ensure_init(vmc)) {\n\t\tfprintf(stderr, \"error: %s: couldn't initialize\\n\", classname);\n\t\treturn -1;\n\t}\n\n\tstruct vm_method *vmm = vm_class_get_method_recursive(vmc,\n\t\t\"main\", \"([Ljava/lang/String;)V\");\n\tif (!vmm) {\n\t\tfprintf(stderr, \"error: %s: no main method\\n\", classname);\n\t\treturn -1;\n\t}\n\n\tif (!vm_method_is_static(vmm)) {\n\t\tfprintf(stderr, \"error: %s: main method not static\\n\",\n\t\t\tclassname);\n\t\treturn -1;\n\t}\n\n\tstruct vm_object *args;\n\n\targs = vm_object_alloc_array(vm_array_of_java_lang_String, nr_java_args);\n\tif (!args)\n\t\tdie(\"out of memory\");\n\n\tfor (unsigned int i = 0; i < nr_java_args; i++) {\n\t\tstruct vm_object *arg;\n\n\t\targ = vm_object_alloc_string_from_c(java_args[i]);\n\n\t\tarray_set_field_object(args, i, arg);\n\t}\n\n\tif (opt_interp_only) {\n\t\tvm_interp_method(vmm, args);\n\t} else {\n\t\tvoid (*java_main)(void *);\n\n\t\tjava_main = vm_method_trampoline_ptr(vmm);\n\t\tjava_main(args);\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 368 }, { "index": 430502, "code": "gfs_variables_from_list (GSList * i,\n\t\t\t\t gchar * list,\n\t\t\t\t gchar ** error)\n{\n gchar * s;\n GSList * var = NULL;\n\n g_return_val_if_fail (i != NULL, NULL);\n g_return_val_if_fail (error != NULL, NULL);\n\n s = strtok (list, \",\");\n while (s) {\n GfsVariable * v = gfs_variable_from_name (i, s);\n\n if (v == NULL) {\n *error = s;\n g_slist_free (var);\n return NULL;\n }\n var = g_slist_append (var, v);\n s = strtok (NULL, \",\");\n }\n return var;\n}", "label": 0, "cwe": null, "length": 148 }, { "index": 434055, "code": "prep(LINK)\nstruct LOC_update *LINK;\n{\n int i, k;\n\n iswup = 1;\n wtil[0] = -gsave[0];\n ztil[0] = y[0];\n for (k = 2; k <= n; k++) {\n wtil[k - 1] = -gsave[k - 1];\n ztil[k - 1] = y[k - 1];\n for (i = 0; i <= k - 2; i++) {\n tl[i][k - 1] = tl[k - 1][i];\n wtil[k - 1] -= tl[k - 1][i] * wtil[i];\n ztil[k - 1] -= tl[k - 1][i] * ztil[i];\n }\n }\n sb = 0.0;\n sc = 0.0;\n sd = 0.0;\n for (i = 0; i < n; i++) {\n sb += t * ztil[i] * wtil[i] / d[i];\n sc += t * t * wtil[i] * wtil[i] / d[i];\n sd += ztil[i] * ztil[i] / d[i];\n }\n}", "label": 0, "cwe": null, "length": 277 }, { "index": 114443, "code": "make_div_range_from_peel_info(Peel_info *p)\n{\n \n if(p->is_lower)\n return make_div_range(p->block_no, LEFT_BLOCK, p->peel_range);\n \n return make_div_range(p->block_no, RIGHT_BLOCK, p->peel_range); \n}", "label": 0, "cwe": null, "length": 64 }, { "index": 12307, "code": "fpm_bin_to_hex(gchar* out, const byte* in, gint len)\n{\n gint i, high, low;\n byte data;\n\n for(i=0; ilpath, stoptime))\n\t\treturn 0;\n\n\tresult = chirp_reli_getfile_buffer(current_volume->host, info->lpath, &buffer, stoptime);\n\tif(result <= 0)\n\t\treturn 0;\n\n\tfields = sscanf(buffer, \"%s %s\", info->rhost, info->rpath);\n\n\tfree(buffer);\n\n\tdebug(D_MULTI, \"lookup: /multi/%s%s at /chirp/%s/%s\", volume, path, info->rhost, info->rpath);\n\n\tif(fields == 2) {\n\t\treturn 1;\n\t} else {\n\t\terrno = EIO;\n\t\treturn 0;\n\t}\n}", "label": 1, "cwe": [ "CWE-120", "CWE-other" ], "length": 191 }, { "index": 572557, "code": "HandleBufferTransfer( const char * buffer, int len )\n{\n\tint i;\n\tCByteArray zbuffer;\n\tint outlen;\n\tint inlen;\n\t\n\t// decompress buffer ...\n\tif ( m_nDataType == 1 )\n\t{\n\t\tzbuffer.SetSize(1024*100);\n\t\toutlen = 1024*100;\n\t\tinlen = len;\n\t\tm_nZlibStatus = m_ZLib.InflateZBlock( buffer, &inlen, (char*)zbuffer.Data(), &outlen );\n\t\tif ( m_nZlibStatus == -1 )\n\t\t{\n\t\t\tDPRINTF(\"HandleBufferTransfer: inflate failed!\\n\");\n\t\t\tCallBack_SendError(\"Zlib decompression failed\");\n\n\t\t\t// disconnect on error\n\t\t\tDisconnect();\n\t\t\t\n\t\t\treturn -1;\n\t\t}\n\t\t\n\t\tlen = outlen;\n\t\tbuffer = (const char*)zbuffer.Data();\n\t}\n\n\t// check endposition\n\tif ( (len+m_nTransfered) > m_nChunkSize )\n\t{\n\t\ti = m_nChunkSize-m_nTransfered;\n\t}\n\telse\n\t{\n\t\ti = len;\n\t}\n\n\tpByteArray->Append((const unsigned char*)buffer,i);\n\n\tAddTraffic(i);\n\n\tif ( m_nDataType == 1 )\n\t{\n\t\ti = inlen;\n\t}\n\n\treturn i;\n}", "label": 0, "cwe": null, "length": 276 }, { "index": 573506, "code": "fit_read_field(fit_field_t* f)\n{\n int i;\n\n switch (f->type) {\n case 1: // sint8\n case 2: // uint8\n is_fatal(f->size != 1,\n MYNAME \": Bad field size in data message\\n\");\n return fit_getuint8();\n case 0x83: // sint16\n case 0x84: // uint16\n is_fatal(f->size != 2,\n MYNAME \": Bad field size in data message\\n\");\n return fit_getuint16();\n case 0x85: // sint32\n case 0x86: // uint32\n is_fatal(f->size != 4,\n MYNAME \": Bad field size in data message\\n\");\n return fit_getuint32();\n default: // Ignore everything else for now.\n for (i = 0; i < f->size; i++) {\n fit_getuint8();\n }\n return -1;\n }\n}", "label": 0, "cwe": null, "length": 216 }, { "index": 538134, "code": "osi_strtod(char * ptr, char ** output) \n{\n char * save = ptr;\n double value=-1.0e100;\n if (!stringsAllowed_) {\n *output=save;\n } else {\n // take off leading white space\n while (*ptr==' '||*ptr=='\\t')\n ptr++;\n if (*ptr=='=') {\n strcpy(valueString_,ptr);\n#define STRING_VALUE -1.234567e-101\n value = STRING_VALUE;\n *output=ptr+strlen(ptr);\n } else {\n *output=save;\n }\n }\n return value;\n}", "label": 0, "cwe": null, "length": 134 }, { "index": 802474, "code": "gm_mcp_icecrew_playerdb_modify_prop_list(GmMcpIcecrewPlayerdb *package,\n\t\tGmPlayerdbPlayerInfo *ppi, GList *fields, gboolean add) {\n\tGmKeyValuePair *data;\n \n\tif (ppi) {\n\t\tfor (; fields; fields = fields->next) {\n\t\t\tdata = (GmKeyValuePair *)(fields->data);\n\t\t\tgm_mcp_icecrew_playerdb_set_prop(package, ppi, data->key, \n\t\t\t\t\tdata->value, add);\n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 115 }, { "index": 552452, "code": "bselect(c,cri,pn)\nINT c, cri;\ndouble pn;\n{ double h0, g0, ifact;\n INT i;\n pen = pn;\n if (cri==BIND) pen /= factorial((int)lf.mi[MDEG]+1);\n hmin = h0 = lf.dp[c];\n if (h0==0) ERROR((\"bselect: initial bandwidth is 0\"));\n if (lf_error) return;\n sig2 = 1.0;\n \n gmin = g0 = bcri(h0,c,cri);\n if (cri==BCP)\n { sig2 = lf.dp[DRV];\n g0 = gmin = bcri(h0,c,cri+64);\n }\n \n ifact = 0.3;\n bsel2(h0,g0,ifact,c,cri);\n \n for (i=0; i<5; i++)\n { ifact = ifact/2;\n bsel3(hmin,gmin,ifact,c,cri);\n }\n lf.dp[c] = hmin;\n startlf(&des,&lf,procv,0);\n ressumm(&lf,&des);\n}", "label": 0, "cwe": null, "length": 253 }, { "index": 471337, "code": "EmitTextAttribute(unsigned Attribute, StringRef String) {\n switch (Attribute) {\n case ARMBuildAttrs::CPU_name:\n Streamer.EmitRawText(StringRef(\"\\t.cpu \") + LowercaseString(String));\n break;\n /* GAS requires .fpu to be emitted regardless of EABI attribute */\n case ARMBuildAttrs::Advanced_SIMD_arch:\n case ARMBuildAttrs::VFP_arch:\n Streamer.EmitRawText(StringRef(\"\\t.fpu \") + LowercaseString(String));\n break;\n default: assert(0 && \"Unsupported Text attribute in ASM Mode\"); break;\n }\n }", "label": 0, "cwe": null, "length": 132 }, { "index": 944901, "code": "ensSliceMatch(const EnsPSlice slice1, const EnsPSlice slice2)\n{\n if (ajDebugTest(\"ensSliceMatch\"))\n {\n ajDebug(\"ensSliceMatch\\n\"\n \" slice1 %p\\n\"\n \" slice2 %p\\n\",\n slice1,\n slice2);\n\n ensSliceTrace(slice1, 1);\n ensSliceTrace(slice2, 1);\n }\n\n if (!slice1)\n return ajFalse;\n\n if (!slice2)\n return ajFalse;\n\n /* Try a direct pointer comparison first. */\n\n if (slice1 == slice2)\n return ajTrue;\n\n if (!ensSeqregionMatch(slice1->Seqregion, slice2->Seqregion))\n return ajFalse;\n\n if (slice1->Start != slice2->Start)\n return ajFalse;\n\n if (slice1->End != slice2->End)\n return ajFalse;\n\n if (slice1->Strand != slice2->Strand)\n return ajFalse;\n\n if ((slice1->Sequence || slice2->Sequence) &&\n (!ajStrMatchS(slice1->Sequence, slice2->Sequence)))\n return ajFalse;\n\n return ajTrue;\n}", "label": 0, "cwe": null, "length": 256 }, { "index": 937870, "code": "val_int()\n{\n DBUG_ASSERT(fixed == 1);\n String *res=args[0]->val_str(&value);\n if (!res)\n {\n null_value=1;\n return 0;\n }\n null_value=0;\n if (!res->length()) return 0;\n#ifdef USE_MB\n if (use_mb(res->charset()))\n {\n register const char *str=res->ptr();\n register uint32 n=0, l=my_ismbchar(res->charset(),str,str+res->length());\n if (!l)\n return (longlong)((uchar) *str);\n while (l--)\n n=(n<<8)|(uint32)((uchar) *str++);\n return (longlong) n;\n }\n#endif\n return (longlong) ((uchar) (*res)[0]);\n}", "label": 0, "cwe": null, "length": 178 }, { "index": 100643, "code": "ps_meta_bar (void *p, double c, double r, double c1, double r1, double hue, int color, int framed)\n{\n\tFILE *out = (FILE*)p;\n\tdouble x=col(c);\n\tdouble y=row(1024.0-r);\n\tdouble w=col(c1-c);\n\tdouble h=row(r1-r);\n\t\n\tif (lineop) lineend(out,lcolor,lstyle,lwidth);\n\n\tif (firstuse.sethuecolor) {\n\t\tfprintf(out,\"%s\\n\",sethuecolormacro);\n\t\tfirstuse.sethuecolor = 0;\n\t}\n\t\n\tswitch (framed)\n\t{\n\t\tcase 0:\n\t\t\tif (firstuse.bar)\n\t\t\t{\n\t\t\t\tfprintf(out,\"%s\\n\",barmacro);\n\t\t\t\tfirstuse.bar = 0;\n\t\t\t}\n\t\t\tfprintf(out,\"%g %g %g %g %d %g bar\\n\",x,y,w,h,color,hue);\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tif (firstuse.fbar)\n\t\t\t{\n\t\t\t\tfprintf(out,\"%s\\n\",fbarmacro);\n\t\t\t\tfirstuse.fbar = 0;\n\t\t\t}\n\t\t\tfprintf(out,\"%g %g %g %g %d %g fbar\\n\",x,y,w,h,color,hue);\n\t}\n}", "label": 0, "cwe": null, "length": 266 }, { "index": 94278, "code": "Coro_bytesLeftOnStack(Coro *self)\n{\n\tunsigned char dummy;\n\tptrdiff_t p1 = (ptrdiff_t)(&dummy);\n\tptrdiff_t p2 = (ptrdiff_t)Coro_CurrentStackPointer();\n\tint stackMovesUp = p2 > p1;\n\tptrdiff_t start = ((ptrdiff_t)self->stack);\n\tptrdiff_t end = start + self->requestedStackSize;\n\n\tif (stackMovesUp) // like x86\n\t{\n\t\treturn end - p1;\n\t}\n\telse // like OSX on PPC\n\t{\n\t\treturn p1 - start;\n\t}\n}", "label": 0, "cwe": null, "length": 124 }, { "index": 880459, "code": "libdicteqv_hash(ScmObj *SCM_FP, int SCM_ARGCNT, void *data_)\n{\n ScmObj obj_scm;\n ScmObj obj;\n ScmObj SCM_SUBRARGS[1];\n int SCM_i;\n SCM_ENTER_SUBR(\"eqv-hash\");\n for (SCM_i=0; SCM_i<1; SCM_i++) {\n SCM_SUBRARGS[SCM_i] = SCM_ARGREF(SCM_i);\n }\n obj_scm = SCM_SUBRARGS[0];\n obj = (obj_scm);\n {\n{\nu_long SCM_RESULT;\nSCM_RESULT=(Scm_EqvHash(obj));\nSCM_RETURN(Scm_MakeIntegerFromUI(SCM_RESULT));\n}\n }\n}", "label": 0, "cwe": null, "length": 161 }, { "index": 630663, "code": "core_scsi3_nodeacl_undepend_item(struct se_node_acl *nacl)\n{\n\tif (!nacl->dynamic_node_acl)\n\t\ttarget_undepend_item(&nacl->acl_group.cg_item);\n\tatomic_dec_mb(&nacl->acl_pr_ref_count);\n}", "label": 0, "cwe": null, "length": 57 }, { "index": 995285, "code": "count_bits4(uint32_t mask)\n{\n\tunsigned int bits = 0;\n\n\tfor (mask = ~ntohl(mask); mask != 0; mask >>= 1)\n\t\t++bits;\n\n\treturn 32 - bits;\n}", "label": 0, "cwe": null, "length": 48 }, { "index": 125965, "code": "HvpHiveHeaderChecksum(\n PHBASE_BLOCK HiveHeader)\n{\n PULONG Buffer = (PULONG)HiveHeader;\n ULONG Sum = 0;\n ULONG i;\n\n for (i = 0; i < 127; i++)\n Sum ^= Buffer[i];\n if (Sum == (ULONG)-1)\n Sum = (ULONG)-2;\n if (Sum == 0)\n Sum = 1;\n\n return Sum;\n}", "label": 0, "cwe": null, "length": 98 }, { "index": 12968, "code": "SelectExecRegexMatch(char *filename,char *crit,char *prog)\n\n{ char line[CF_BUFSIZE];\n FILE *pp;\n char buf[CF_MAXVARSIZE];\n \n// insert real value of $(this.promiser) in command\n\nReplaceStr(prog,buf,sizeof(buf),\"$(this.promiser)\",filename);\nReplaceStr(prog,buf,sizeof(buf),\"${this.promiser}\",filename);\n\nif ((pp = cf_popen(buf,\"r\")) == NULL)\n {\n CfOut(cf_error,\"cf_popen\",\"Couldn't open pipe to command %s\\n\",buf);\n return false;\n }\n\nwhile (!feof(pp))\n {\n line[0] = '\\0';\n CfReadLine(line,CF_BUFSIZE,pp); /* One buffer only */\n\n if (FullTextMatch(crit,line))\n {\n cf_pclose(pp); \n return true;\n }\n }\n\ncf_pclose(pp); \nreturn false; \n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 196 }, { "index": 622221, "code": "marker_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,\n int32_t op_ret, int32_t op_errno, inode_t *inode,\n struct iatt *buf, dict_t *dict, struct iatt *postparent)\n{\n marker_conf_t *priv = NULL;\n marker_local_t *local = NULL;\n\n if (op_ret == -1) {\n gf_log (this->name, GF_LOG_TRACE, \"lookup failed with %s\",\n strerror (op_errno));\n }\n\n local = (marker_local_t *) frame->local;\n\n frame->local = NULL;\n\n STACK_UNWIND_STRICT (lookup, frame, op_ret, op_errno, inode, buf,\n dict, postparent);\n\n if (op_ret == -1 || local == NULL)\n goto out;\n\n priv = this->private;\n\n if (priv->feature_enabled & GF_QUOTA) {\n mq_xattr_state (this, &local->loc, dict, *buf);\n }\n\nout:\n marker_local_unref (local);\n\n return 0;\n}", "label": 0, "cwe": null, "length": 237 }, { "index": 405513, "code": "AM_changeWindowLoc(void)\n{\n if (m_paninc.x || m_paninc.y)\n {\n\tfollowplayer = 0;\n\tf_oldloc.x = INT_MAX;\n }\n\n m_x += m_paninc.x;\n m_y += m_paninc.y;\n\n if (m_x + m_w/2 > max_x)\n\tm_x = max_x - m_w/2;\n else if (m_x + m_w/2 < min_x)\n\tm_x = min_x - m_w/2;\n \n if (m_y + m_h/2 > max_y)\n\tm_y = max_y - m_h/2;\n else if (m_y + m_h/2 < min_y)\n\tm_y = min_y - m_h/2;\n\n m_x2 = m_x + m_w;\n m_y2 = m_y + m_h;\n}", "label": 0, "cwe": null, "length": 184 }, { "index": 48910, "code": "usage(int argc, char ** argv)\n{\n if (argc != 2)\n {\n std::cout << argv[0] << \" ./filename.data\" << std::endl;\n return true;\n }\n return false;\n}", "label": 0, "cwe": null, "length": 51 }, { "index": 23363, "code": "semantic(Scope *sc)\n{\n#if LOGSEMANTIC\n printf(\"PtrExp::semantic('%s')\\n\", toChars());\n#endif\n if (!type)\n {\n Expression *e = op_overload(sc);\n if (e)\n return e;\n Type *tb = e1->type->toBasetype();\n switch (tb->ty)\n {\n case Tpointer:\n type = ((TypePointer *)tb)->next;\n break;\n\n case Tsarray:\n case Tarray:\n deprecation(\"using * on an array is deprecated; use *(%s).ptr instead\", e1->toChars());\n type = ((TypeArray *)tb)->next;\n e1 = e1->castTo(sc, type->pointerTo());\n break;\n\n default:\n error(\"can only * a pointer, not a '%s'\", e1->type->toChars());\n case Terror:\n return new ErrorExp();\n }\n if (!rvalue())\n return new ErrorExp();\n }\n return this;\n}", "label": 0, "cwe": null, "length": 223 }, { "index": 895231, "code": "_reload_format(Evas_Object *obj)\n{\n unsigned int idx, field_count;\n Datetime_Field *field;\n char buf[BUFFER_SIZE];\n char *dt_fmt;\n\n ELM_DATETIME_DATA_GET(obj, sd);\n\n // FIXME: provide nl_langinfo on Windows if possible\n // fetch the default format from Libc.\n if (!sd->user_format)\n#ifdef HAVE_LANGINFO_H\n strncpy(sd->format, nl_langinfo(D_T_FMT), ELM_DATETIME_MAX_FORMAT_LEN);\n#else\n strncpy(sd->format, \"\", ELM_DATETIME_MAX_FORMAT_LEN);\n#endif\n\n dt_fmt = (char *)malloc(ELM_DATETIME_MAX_FORMAT_LEN);\n if (!dt_fmt) return;\n\n strncpy(dt_fmt, sd->format, ELM_DATETIME_MAX_FORMAT_LEN);\n\n _expand_format(dt_fmt);\n\n // reset all the fields to disable state\n for (idx = 0; idx < ELM_DATETIME_TYPE_COUNT; idx++)\n {\n field = sd->field_list + idx;\n field->fmt_exist = EINA_FALSE;\n field->location = -1;\n }\n\n field_count = _parse_format(obj, dt_fmt);\n free(dt_fmt);\n\n // assign locations to disabled fields for uniform usage\n for (idx = 0; idx < ELM_DATETIME_TYPE_COUNT; idx++)\n {\n field = sd->field_list + idx;\n if (field->location == -1) field->location = field_count++;\n\n if (field->fmt_exist && field->visible)\n {\n snprintf(buf, sizeof(buf), EDC_PART_FIELD_ENABLE_SIG_STR,\n field->location);\n elm_layout_signal_emit(obj, buf, \"elm\");\n }\n else\n {\n snprintf(buf, sizeof(buf), EDC_PART_FIELD_DISABLE_SIG_STR,\n field->location);\n elm_layout_signal_emit(obj, buf, \"elm\");\n }\n snprintf\n (buf, sizeof(buf), EDC_PART_SEPARATOR_STR, (field->location + 1));\n elm_layout_text_set(obj, buf, field->separator);\n }\n\n edje_object_message_signal_process(ELM_WIDGET_DATA(sd)->resize_obj);\n _field_list_arrange(obj);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-other" ], "length": 463 }, { "index": 220110, "code": "gr_rle_expand_scanline( ubyte *dest, ubyte *src, int x1, int x2 )\n{\n\tint i = 0;\n\tubyte count;\n\tubyte color=0;\n\n\tif ( x2 < x1 ) return;\n\n\tcount = 0;\n\twhile ( i < x1 )\t{\n\t\tcolor = *src++;\n\t\tif ( color == RLE_CODE ) return;\n\t\tif ( IS_RLE_CODE(color) )\t{\n\t\t\tcount = color & (~RLE_CODE);\n\t\t\tcolor = *src++;\n\t\t} else {\n\t\t\t// unique\n\t\t\tcount = 1;\n\t\t}\n\t\ti += count;\n\t}\n\tcount = i - x1;\n\ti = x1;\n\t// we know have '*count' pixels of 'color'.\n\t\n\tif ( x1+count > x2 )\t{\n\t\tcount = x2-x1+1;\n\t\trle_stosb( dest, count, color );\n\t\treturn;\n\t}\n\n\trle_stosb( dest, count, color );\n\tdest += count;\n\ti += count;\n\n\twhile( i <= x2 )\t\t{\n\t\tcolor = *src++;\n\t\tif ( color == RLE_CODE ) return;\n\t\tif ( IS_RLE_CODE(color) )\t{\n\t\t\tcount = color & (~RLE_CODE);\n\t\t\tcolor = *src++;\n\t\t} else {\n\t\t\t// unique\n\t\t\tcount = 1;\n\t\t}\n\t\t// we know have '*count' pixels of 'color'.\n\t\tif ( i+count <= x2 )\t{\n\t\t\trle_stosb( dest, count, color );\n\t\t\ti += count;\n\t\t\tdest += count;\n\t\t} else {\n\t\t\tcount = x2-i+1;\n\t\t\trle_stosb( dest, count, color );\n\t\t\ti += count;\n\t\t\tdest += count;\n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 391 }, { "index": 383171, "code": "intel_dsi_reset_clocks(struct intel_encoder *encoder, enum port port)\n{\n\tstruct drm_device *dev = encoder->base.dev;\n\n\tif (IS_BROXTON(dev))\n\t\tbxt_dsi_reset_clocks(encoder, port);\n\telse if (IS_VALLEYVIEW(dev) || IS_CHERRYVIEW(dev))\n\t\tvlv_dsi_reset_clocks(encoder, port);\n}", "label": 0, "cwe": null, "length": 79 }, { "index": 191861, "code": "init_wr32(struct nvbios_init *init, u32 reg, u32 val)\n{\n\tstruct nvkm_device *device = init->bios->subdev.device;\n\treg = init_nvreg(init, reg);\n\tif (reg != ~0 && init_exec(init))\n\t\tnvkm_wr32(device, reg, val);\n}", "label": 0, "cwe": null, "length": 68 }, { "index": 554752, "code": "ladish_check_app_level_validity(const char * level, size_t * len_ptr)\n{\n size_t len;\n len = strlen(level);\n if (len >= MAX_LEVEL_CHARCOUNT)\n {\n return false;\n }\n\n if (strcmp(level, LADISH_APP_LEVEL_0) != 0 &&\n strcmp(level, LADISH_APP_LEVEL_1) != 0 &&\n strcmp(level, LADISH_APP_LEVEL_LASH) != 0 &&\n strcmp(level, LADISH_APP_LEVEL_JACKSESSION) != 0)\n {\n return false;\n }\n\n if (len_ptr != NULL)\n {\n *len_ptr = len;\n }\n\n return true;\n}", "label": 0, "cwe": null, "length": 148 }, { "index": 579015, "code": "FormatBytesTimeRate(off_t bytes,double time_spent)\n{\n if(bytes<=0)\n return \"\";\n\n if(time_spent>=1)\n {\n xstring& msg=xstring::format(\n\t plural(\"%lld $#ll#byte|bytes$ transferred in %ld $#l#second|seconds$\",\n\t\t (long long)bytes,long(time_spent+.5)),\n\t\t (long long)bytes,long(time_spent+.5));\n double rate=bytes/time_spent;\n if(rate>=1)\n\t msg.appendf(\" (%s)\",Speedometer::GetStr(rate).get());\n return msg;\n }\n return xstring::format(plural(\"%lld $#ll#byte|bytes$ transferred\",\n\t\t (long long)bytes),(long long)bytes);\n}", "label": 0, "cwe": null, "length": 162 }, { "index": 336122, "code": "make_setop(SetOpCmd cmd, Plan *lefttree,\n\t\t List *distinctList, AttrNumber flagColIdx)\n{\n\tSetOp\t *node = makeNode(SetOp);\n\tPlan\t *plan = &node->plan;\n\tint\t\t\tnumCols = list_length(distinctList);\n\tint\t\t\tkeyno = 0;\n\tAttrNumber *dupColIdx;\n\tOid\t\t *dupOperators;\n\tListCell *slitem;\n\n\tcopy_plan_costsize(plan, lefttree);\n\n\t/*\n\t * Charge one cpu_operator_cost per comparison per input tuple. We assume\n\t * all columns get compared at most of the tuples.\n\t */\n\tplan->total_cost += cpu_operator_cost * plan->plan_rows * numCols;\n\n\t/*\n\t * We make the unsupported assumption that there will be 10% as many\n\t * tuples out as in. Any way to do better?\n\t */\n\tplan->plan_rows *= 0.1;\n\tif (plan->plan_rows < 1)\n\t\tplan->plan_rows = 1;\n\n\tplan->targetlist = lefttree->targetlist;\n\tplan->qual = NIL;\n\tplan->lefttree = lefttree;\n\tplan->righttree = NULL;\n\n\t/*\n\t * convert SortClause list into arrays of attr indexes and equality\n\t * operators, as wanted by executor\n\t */\n\tAssert(numCols > 0);\n\tdupColIdx = (AttrNumber *) palloc(sizeof(AttrNumber) * numCols);\n\tdupOperators = (Oid *) palloc(sizeof(Oid) * numCols);\n\n\tforeach(slitem, distinctList)\n\t{\n\t\tSortClause *sortcl = (SortClause *) lfirst(slitem);\n\t\tTargetEntry *tle = get_sortgroupclause_tle(sortcl, plan->targetlist);\n\n\t\tdupColIdx[keyno] = tle->resno;\n\t\tdupOperators[keyno] = get_equality_op_for_ordering_op(sortcl->sortop);\n\t\tif (!OidIsValid(dupOperators[keyno]))\t/* shouldn't happen */\n\t\t\telog(ERROR, \"could not find equality operator for ordering operator %u\",\n\t\t\t\t sortcl->sortop);\n\t\tkeyno++;\n\t}\n\n\tnode->cmd = cmd;\n\tnode->numCols = numCols;\n\tnode->dupColIdx = dupColIdx;\n\tnode->dupOperators = dupOperators;\n\tnode->flagColIdx = flagColIdx;\n\n\treturn node;\n}", "label": 0, "cwe": null, "length": 501 }, { "index": 42678, "code": "kxcjk1013_set_odr(struct kxcjk1013_data *data, int val, int val2)\n{\n\tint ret;\n\tint odr_bits;\n\tenum kxcjk1013_mode store_mode;\n\n\tret = kxcjk1013_get_mode(data, &store_mode);\n\tif (ret < 0)\n\t\treturn ret;\n\n\todr_bits = kxcjk1013_convert_freq_to_bit(val, val2);\n\tif (odr_bits < 0)\n\t\treturn odr_bits;\n\n\t/* To change ODR, the chip must be set to STANDBY as per spec */\n\tret = kxcjk1013_set_mode(data, STANDBY);\n\tif (ret < 0)\n\t\treturn ret;\n\n\tret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_DATA_CTRL,\n\t\t\t\t\todr_bits);\n\tif (ret < 0) {\n\t\tdev_err(&data->client->dev, \"Error writing data_ctrl\\n\");\n\t\treturn ret;\n\t}\n\n\tdata->odr_bits = odr_bits;\n\n\todr_bits = kxcjk1013_convert_wake_odr_to_bit(val, val2);\n\tif (odr_bits < 0)\n\t\treturn odr_bits;\n\n\tret = i2c_smbus_write_byte_data(data->client, KXCJK1013_REG_CTRL2,\n\t\t\t\t\todr_bits);\n\tif (ret < 0) {\n\t\tdev_err(&data->client->dev, \"Error writing reg_ctrl2\\n\");\n\t\treturn ret;\n\t}\n\n\tif (store_mode == OPERATION) {\n\t\tret = kxcjk1013_set_mode(data, OPERATION);\n\t\tif (ret < 0)\n\t\t\treturn ret;\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 364 }, { "index": 75794, "code": "NotifyTeamSwitchPending(RakNetGUID target, TeamId requestedTeam, NetworkID memberId)\r\n{\r\n\tBitStream bsOut;\r\n\tbsOut.Write((MessageID)ID_TEAM_BALANCER_REQUESTED_TEAM_FULL);\r\n\tbsOut.Write(requestedTeam);\r\n\tbsOut.Write(memberId);\r\n\trakPeerInterface->Send(&bsOut,HIGH_PRIORITY,RELIABLE_ORDERED,0,target,false);\r\n}", "label": 0, "cwe": null, "length": 81 }, { "index": 632436, "code": "vtkWrapPython_ArgCountToOverloadMap(\n FunctionInfo **wrappedFunctions, int numberOfWrappedFunctions,\n int fnum, int is_vtkobject, int *nmax, int *overlap)\n{\n static int overloadMap[512];\n int totalArgs, requiredArgs;\n int occ, occCounter;\n FunctionInfo *theOccurrence;\n FunctionInfo *theFunc;\n int mixed_static, any_static;\n int i;\n\n *nmax = 0;\n *overlap = 0;\n\n theFunc = wrappedFunctions[fnum];\n\n any_static = 0;\n mixed_static = 0;\n for (i = fnum; i < numberOfWrappedFunctions; i++)\n {\n if (wrappedFunctions[i]->Name &&\n strcmp(wrappedFunctions[i]->Name, theFunc->Name) == 0)\n {\n if (wrappedFunctions[i]->IsStatic)\n {\n any_static = 1;\n }\n else if (any_static)\n {\n mixed_static = 1;\n }\n }\n }\n\n for (i = 0; i < 100; i++)\n {\n overloadMap[i] = 0;\n }\n\n occCounter = 0;\n for (occ = fnum; occ < numberOfWrappedFunctions; occ++)\n {\n theOccurrence = wrappedFunctions[occ];\n\n if (theOccurrence->Name == 0 ||\n strcmp(theOccurrence->Name, theFunc->Name) != 0)\n {\n continue;\n }\n\n occCounter++;\n\n totalArgs = vtkWrap_CountWrappedArgs(theOccurrence);\n requiredArgs = vtkWrap_CountRequiredArgs(theOccurrence);\n\n /* vtkobject calls might have an extra \"self\" arg in front */\n if (mixed_static && is_vtkobject &&\n !theOccurrence->IsStatic)\n {\n totalArgs++;\n }\n\n if (totalArgs > *nmax)\n {\n *nmax = totalArgs;\n }\n\n for (i = requiredArgs; i <= totalArgs && i < 100; i++)\n {\n if (overloadMap[i] == 0)\n {\n overloadMap[i] = occCounter;\n }\n else\n {\n overloadMap[i] = -1;\n *overlap = 1;\n }\n }\n }\n\n return overloadMap;\n}", "label": 0, "cwe": null, "length": 497 }, { "index": 642870, "code": "increase_open_fds(unsigned int target)\n{\n\tstruct rlimit lim, orig;\n\t\n\tif (getrlimit(RLIMIT_NOFILE, &lim)<0){\n\t\tLM_CRIT(\"cannot get the maximum number of file descriptors: %s\\n\",\n\t\t\t\tstrerror(errno));\n\t\tgoto error;\n\t}\n\torig=lim;\n\tLM_DBG(\"current open file limits: %lu/%lu\\n\",\n\t\t\t(unsigned long)lim.rlim_cur, (unsigned long)lim.rlim_max);\n\tif ((lim.rlim_cur==RLIM_INFINITY) || (target<=lim.rlim_cur))\n\t\t/* nothing to do */\n\t\tgoto done;\n\telse if ((lim.rlim_max==RLIM_INFINITY) || (target<=lim.rlim_max)){\n\t\tlim.rlim_cur=target; /* increase soft limit to target */\n\t}else{\n\t\t/* more than the hard limit */\n\t\tLM_INFO(\"trying to increase the open file limit\"\n\t\t\t\t\" past the hard limit (%ld -> %d)\\n\", \n\t\t\t\t(unsigned long)lim.rlim_max, target);\n\t\tlim.rlim_max=target;\n\t\tlim.rlim_cur=target;\n\t}\n\tLM_DBG(\"increasing open file limits to: %lu/%lu\\n\",\n\t\t\t(unsigned long)lim.rlim_cur, (unsigned long)lim.rlim_max);\n\tif (setrlimit(RLIMIT_NOFILE, &lim)<0){\n\t\tLM_CRIT(\"cannot increase the open file limit to\"\n\t\t\t\t\" %lu/%lu: %s\\n\",\n\t\t\t\t(unsigned long)lim.rlim_cur, (unsigned long)lim.rlim_max,\n\t\t\t\tstrerror(errno));\n\t\tif (orig.rlim_max>orig.rlim_cur){\n\t\t\t/* try to increase to previous maximum, better than not increasing\n\t\t \t* at all */\n\t\t\tlim.rlim_max=orig.rlim_max;\n\t\t\tlim.rlim_cur=orig.rlim_max;\n\t\t\tif (setrlimit(RLIMIT_NOFILE, &lim)==0){\n\t\t\t\tLM_CRIT(\"maximum number of file descriptors increased to\"\n\t\t\t\t\t\" %u\\n\",(unsigned)orig.rlim_max);\n\t\t\t}\n\t\t}\n\t\tgoto error;\n\t}\ndone:\n\treturn 0;\nerror:\n\treturn -1;\n}", "label": 0, "cwe": null, "length": 467 }, { "index": 905041, "code": "remove_dir_recursive(const gchar *dir)\n{\n\tstruct stat s;\n\tGDir *dp;\n\tconst gchar *dir_name;\n\tgchar *prev_dir;\n\n\tif (g_stat(dir, &s) < 0) {\n\t\tFILE_OP_ERROR(dir, \"stat\");\n\t\tif (ENOENT == errno) return 0;\n\t\treturn -1;\n\t}\n\n\tif (!S_ISDIR(s.st_mode)) {\n\t\tif (claws_unlink(dir) < 0) {\n\t\t\tFILE_OP_ERROR(dir, \"unlink\");\n\t\t\treturn -1;\n\t\t}\n\n\t\treturn 0;\n\t}\n\n\tprev_dir = g_get_current_dir();\n\t/* g_print(\"prev_dir = %s\\n\", prev_dir); */\n\n\tif (!path_cmp(prev_dir, dir)) {\n\t\tg_free(prev_dir);\n\t\tif (g_chdir(\"..\") < 0) {\n\t\t\tFILE_OP_ERROR(dir, \"chdir\");\n\t\t\treturn -1;\n\t\t}\n\t\tprev_dir = g_get_current_dir();\n\t}\n\n\tif (g_chdir(dir) < 0) {\n\t\tFILE_OP_ERROR(dir, \"chdir\");\n\t\tg_free(prev_dir);\n\t\treturn -1;\n\t}\n\n\tif ((dp = g_dir_open(\".\", 0, NULL)) == NULL) {\n\t\tg_warning(\"failed to open directory: %s\\n\", dir);\n\t\tg_chdir(prev_dir);\n\t\tg_free(prev_dir);\n\t\treturn -1;\n\t}\n\n\t/* remove all files in the directory */\n\twhile ((dir_name = g_dir_read_name(dp)) != NULL) {\n\t\t/* g_print(\"removing %s\\n\", dir_name); */\n\n\t\tif (is_dir_exist(dir_name)) {\n\t\t\tif (remove_dir_recursive(dir_name) < 0) {\n\t\t\t\tg_warning(\"can't remove directory\\n\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t} else {\n\t\t\tif (claws_unlink(dir_name) < 0)\n\t\t\t\tFILE_OP_ERROR(dir_name, \"unlink\");\n\t\t}\n\t}\n\n\tg_dir_close(dp);\n\n\tif (g_chdir(prev_dir) < 0) {\n\t\tFILE_OP_ERROR(prev_dir, \"chdir\");\n\t\tg_free(prev_dir);\n\t\treturn -1;\n\t}\n\n\tg_free(prev_dir);\n\n\tif (g_rmdir(dir) < 0) {\n\t\tFILE_OP_ERROR(dir, \"rmdir\");\n\t\treturn -1;\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 487 }, { "index": 772686, "code": "g_proxy_drive_start (GDrive *drive,\n GDriveStartFlags flags,\n GMountOperation *mount_operation,\n GCancellable *cancellable,\n GAsyncReadyCallback callback,\n gpointer user_data)\n{\n GProxyDrive *proxy_drive = G_PROXY_DRIVE (drive);\n DBusStartOp *data;\n GVfsRemoteVolumeMonitor *proxy;\n\n G_LOCK (proxy_drive);\n\n if (g_cancellable_is_cancelled (cancellable))\n {\n GSimpleAsyncResult *simple;\n simple = g_simple_async_result_new_error (G_OBJECT (drive),\n callback,\n user_data,\n G_IO_ERROR,\n G_IO_ERROR_CANCELLED,\n _(\"Operation was cancelled\"));\n g_simple_async_result_complete_in_idle (simple);\n g_object_unref (simple);\n G_UNLOCK (proxy_drive);\n goto out;\n }\n\n data = g_new0 (DBusStartOp, 1);\n data->drive = g_object_ref (proxy_drive);\n data->callback = callback;\n data->user_data = user_data;\n if (cancellable != NULL)\n {\n data->cancellation_id = g_strdup_printf (\"%p\", cancellable);\n data->cancellable = g_object_ref (cancellable);\n data->cancelled_handler_id = g_signal_connect (data->cancellable,\n \"cancelled\",\n G_CALLBACK (start_cancelled),\n data);\n }\n else\n {\n data->cancellation_id = g_strdup (\"\");\n }\n\n data->mount_op_id = g_proxy_mount_operation_wrap (mount_operation, proxy_drive->volume_monitor);\n\n proxy = g_proxy_volume_monitor_get_dbus_proxy (proxy_drive->volume_monitor);\n g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (proxy), G_PROXY_VOLUME_MONITOR_DBUS_TIMEOUT); /* 30 minute timeout */\n\n gvfs_remote_volume_monitor_call_drive_start (proxy,\n proxy_drive->id,\n data->cancellation_id,\n flags,\n data->mount_op_id,\n NULL,\n (GAsyncReadyCallback) start_cb,\n data);\n\n g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (proxy), -1);\n g_object_unref (proxy);\n\n G_UNLOCK (proxy_drive);\n out:\n ;\n}", "label": 0, "cwe": null, "length": 475 }, { "index": 546333, "code": "acpi_ns_match_complex_repair(struct\n\t\t\t\t\t\t\t\t acpi_namespace_node\n\t\t\t\t\t\t\t\t *node)\n{\n\tconst struct acpi_repair_info *this_name;\n\n\t/* Search info table for a repairable predefined method/object name */\n\n\tthis_name = acpi_ns_repairable_names;\n\twhile (this_name->repair_function) {\n\t\tif (ACPI_COMPARE_NAME(node->name.ascii, this_name->name)) {\n\t\t\treturn (this_name);\n\t\t}\n\t\tthis_name++;\n\t}\n\n\treturn (NULL);\t\t/* Not found */\n}", "label": 0, "cwe": null, "length": 110 }, { "index": 117307, "code": "wc_file (char const *file, struct fstatus *fstatus)\n{\n if (! file || STREQ (file, \"-\"))\n {\n have_read_stdin = true;\n if (O_BINARY && ! isatty (STDIN_FILENO))\n xfreopen (NULL, \"rb\", stdin);\n return wc (STDIN_FILENO, file, fstatus);\n }\n else\n {\n int fd = open (file, O_RDONLY | O_BINARY);\n if (fd == -1)\n {\n error (0, errno, \"%s\", file);\n return false;\n }\n else\n {\n bool ok = wc (fd, file, fstatus);\n if (close (fd) != 0)\n {\n error (0, errno, \"%s\", file);\n return false;\n }\n return ok;\n }\n }\n}", "label": 1, "cwe": [ "CWE-469", "CWE-other" ], "length": 185 }, { "index": 749586, "code": "Alt(Info* a, Info* b) {\n Info *ab = new Info();\n\n if (a->is_exact_ && b->is_exact_) {\n CopyIn(a->exact_, &ab->exact_);\n CopyIn(b->exact_, &ab->exact_);\n ab->is_exact_ = true;\n } else {\n // Either a or b has is_exact_ = false. If the other\n // one has is_exact_ = true, we move it to match_ and\n // then create a OR of a,b. The resulting Info has\n // is_exact_ = false.\n ab->match_ = Prefilter::Or(a->TakeMatch(), b->TakeMatch());\n ab->is_exact_ = false;\n }\n\n delete a;\n delete b;\n return ab;\n}", "label": 0, "cwe": null, "length": 174 }, { "index": 422971, "code": "Java_ncsa_hdf_hdf5lib_H5__1H5Dcreate2\n (JNIEnv *env, jclass clss, jint loc_id, jstring name, jint type_id,\n jint space_id, jint link_plist_id, jint create_plist_id, jint access_plist_id)\n{\n hid_t status;\n char *file;\n jboolean isCopy;\n\n if (name == NULL) {\n h5nullArgument(env, \"H5Dcreate: name is NULL\");\n return -1;\n }\n file = (char *)ENVPTR->GetStringUTFChars(ENVPAR name, &isCopy);\n if (file == NULL) {\n h5JNIFatalError(env, \"H5Dcreate: file name not pinned\");\n return -1;\n }\n\n status = H5Dcreate2((hid_t)loc_id, (const char*)file, (hid_t)type_id, (hid_t)space_id, (hid_t)link_plist_id, (hid_t)create_plist_id, (hid_t)access_plist_id);\n\n ENVPTR->ReleaseStringUTFChars(ENVPAR name, file);\n if (status < 0) {\n h5libraryError(env);\n }\n return (jint)status;\n}", "label": 0, "cwe": null, "length": 283 }, { "index": 34110, "code": "imAnalyzeMeasureCentroid(const imImage* image, const int* data_area, int region_count, float* data_cx, float* data_cy)\n{\n imushort* img_data = (imushort*)image->data[0];\n int* local_data_area = 0;\n\n if (!data_area)\n {\n local_data_area = (int*)malloc(region_count*sizeof(int));\n imAnalyzeMeasureArea(image, local_data_area, region_count);\n data_area = (const int*)local_data_area;\n }\n\n if (data_cx) memset(data_cx, 0, region_count*sizeof(float));\n if (data_cy) memset(data_cy, 0, region_count*sizeof(float));\n\n#ifdef _OPENMP\n#pragma omp parallel for if (IM_OMP_MINHEIGHT(image->height))\n#endif\n for (int y = 0; y < image->height; y++) \n {\n int offset = y*image->width;\n\n for (int x = 0; x < image->width; x++)\n {\n int region_index = img_data[offset+x];\n if (region_index)\n {\n int ri = region_index-1;\n if (data_cx) \n {\n#ifdef _OPENMP\n#pragma omp atomic\n#endif\n data_cx[ri] += (float)x;\n }\n if (data_cy) \n {\n#ifdef _OPENMP\n#pragma omp atomic\n#endif\n data_cy[ri] += (float)y;\n }\n }\n }\n }\n\n for (int i = 0; i < region_count; i++) \n {\n if (data_cx) data_cx[i] /= (float)data_area[i];\n if (data_cy) data_cy[i] /= (float)data_area[i];\n }\n\n if (local_data_area)\n free(local_data_area);\n}", "label": 1, "cwe": "CWE-120", "length": 401 }, { "index": 1004725, "code": "appendData(const XMLString& arg)\n{\n\tXMLString oldData = _data;\n\t_data.append(arg);\n\tif (events()) dispatchCharacterDataModified(oldData, _data);\n}", "label": 0, "cwe": null, "length": 39 }, { "index": 957349, "code": "tack_push(tack_t *stack, void *data) {\n if (tack_grow(stack, 0)) {\n stack->data[stack->len++] = data;\n }\n}", "label": 0, "cwe": null, "length": 43 }, { "index": 809561, "code": "qt_graphicsItem_highlightSelected(QPainter *painter, const QStyleOptionGraphicsItem *option, const QRectF & boundingRect, const QPainterPath & path)\n{\t\n const QRectF murect = painter->transform().mapRect(QRectF(0, 0, 1, 1));\n if (qFuzzyCompare(qMax(murect.width(), murect.height()) + 1, 1))\n return;\n\n const QRectF mbrect = painter->transform().mapRect(boundingRect);\n if (qMin(mbrect.width(), mbrect.height()) < double(1.0))\n return;\n\n double itemPenWidth = 1.0;\n\tconst double pad = itemPenWidth / 2;\n const double penWidth = 0; // cosmetic pen\n\n const QColor fgcolor = option->palette.windowText().color();\n const QColor bgcolor( // ensure good contrast against fgcolor\n fgcolor.red() > 127 ? 0 : 255,\n fgcolor.green() > 127 ? 0 : 255,\n fgcolor.blue() > 127 ? 0 : 255);\n\n painter->setPen(QPen(bgcolor, penWidth, Qt::SolidLine));\n painter->setBrush(Qt::NoBrush);\n\tif (path.isEmpty()) {\n\t\tpainter->drawRect(boundingRect.adjusted(pad, pad, -pad, -pad));\n\t}\n\telse {\n\t\tpainter->drawPath(path);\n\t}\n\n\tpainter->setPen(QPen(option->palette.windowText(), 0, Qt::DashLine));\n painter->setBrush(Qt::NoBrush);\n\tif (path.isEmpty()) {\n\t\tpainter->drawRect(boundingRect.adjusted(pad, pad, -pad, -pad));\n\t}\n\telse {\n\t\tpainter->drawPath(path);\n\t} \n}", "label": 0, "cwe": null, "length": 386 }, { "index": 510442, "code": "need_load_eval(struct cpu_common_dbs_info *shared,\n\t\t\t unsigned int sampling_rate)\n{\n\tif (policy_is_shared(shared->policy)) {\n\t\tktime_t time_now = ktime_get();\n\t\ts64 delta_us = ktime_us_delta(time_now, shared->time_stamp);\n\n\t\t/* Do nothing if we recently have sampled */\n\t\tif (delta_us < (s64)(sampling_rate / 2))\n\t\t\treturn false;\n\t\telse\n\t\t\tshared->time_stamp = time_now;\n\t}\n\n\treturn true;\n}", "label": 0, "cwe": null, "length": 109 }, { "index": 859299, "code": "AddData(float *percentval, Field pie, Field edges, \n int numitemspie, int numitemsedges)\n{\n \n Array piedata=NULL, edgesdata=NULL;\n \n\n\n piedata = (Array)DXNewConstantArray(numitemspie, percentval, \n\t\t\t\t TYPE_FLOAT, \n\t\t\t\t CATEGORY_REAL, 0);\n if (!piedata)\n goto error;\n edgesdata = (Array)DXNewConstantArray(numitemsedges, percentval, \n\t\t\t\t\tTYPE_FLOAT, \n\t\t\t\t\tCATEGORY_REAL, 0);\n if (!edgesdata)\n goto error;\n \n if (!DXSetComponentValue(pie, \"data\", (Object)piedata))\n goto error;\n piedata=NULL;\n DXSetComponentAttribute(pie,\"data\", \"dep\", \n\t\t\t (Object)DXNewString(\"connections\"));\n \n if (!DXSetComponentValue(edges, \"data\", (Object)edgesdata))\n goto error;\n edgesdata=NULL;\n DXSetComponentAttribute(edges,\"data\", \"dep\", \n\t\t\t (Object)DXNewString(\"connections\"));\n \n \n return OK;\nerror:\n DXDelete((Object)piedata);\n DXDelete((Object)edgesdata);\n return ERROR;\n}", "label": 0, "cwe": null, "length": 260 }, { "index": 342208, "code": "check_connection_compatible (NMDevice *device,\n NMConnection *connection,\n GError **error)\n{\n\tNMDeviceInfinibandPrivate *priv = NM_DEVICE_INFINIBAND_GET_PRIVATE (device);\n\tNMSettingInfiniband *s_infiniband;\n\tconst GByteArray *mac;\n\n\tif (!nm_connection_is_type (connection, NM_SETTING_INFINIBAND_SETTING_NAME)) {\n\t\tg_set_error (error,\n\t\t NM_INFINIBAND_ERROR,\n\t\t\t\t\t NM_INFINIBAND_ERROR_CONNECTION_NOT_INFINIBAND,\n\t\t \"The connection was not an InfiniBand connection.\");\n\t\treturn FALSE;\n\t}\n\n\ts_infiniband = nm_connection_get_setting_infiniband (connection);\n\tif (!s_infiniband) {\n\t\tg_set_error (error,\n\t\t NM_INFINIBAND_ERROR, NM_INFINIBAND_ERROR_CONNECTION_INVALID,\n\t\t \"The connection was not a valid infiniband connection.\");\n\t\treturn FALSE;\n\t}\n\n\tif (s_infiniband) {\n\t\tmac = nm_setting_infiniband_get_mac_address (s_infiniband);\n\t\tif (mac && memcmp (mac->data, priv->hw_addr, INFINIBAND_ALEN)) {\n\t\t\tg_set_error (error,\n\t\t\t NM_INFINIBAND_ERROR,\n\t\t\t NM_INFINIBAND_ERROR_CONNECTION_INCOMPATIBLE,\n\t\t\t \"The connection's MAC address did not match this device.\");\n\t\t\treturn FALSE;\n\t\t}\n\t}\n\n\treturn TRUE;\n}", "label": 0, "cwe": null, "length": 303 }, { "index": 979584, "code": "hostap_ap_tx_cb_assoc(struct sk_buff *skb, int ok, void *data)\n{\n\tstruct ap_data *ap = data;\n\tstruct net_device *dev = ap->local->dev;\n\tstruct ieee80211_hdr *hdr;\n\tu16 status;\n\t__le16 *pos;\n\tstruct sta_info *sta = NULL;\n\tchar *txt = NULL;\n\n\tif (ap->local->hostapd) {\n\t\tdev_kfree_skb(skb);\n\t\treturn;\n\t}\n\n\thdr = (struct ieee80211_hdr *) skb->data;\n\tif ((!ieee80211_is_assoc_resp(hdr->frame_control) &&\n\t !ieee80211_is_reassoc_resp(hdr->frame_control)) ||\n\t skb->len < IEEE80211_MGMT_HDR_LEN + 4) {\n\t\tprintk(KERN_DEBUG \"%s: hostap_ap_tx_cb_assoc received invalid \"\n\t\t \"frame\\n\", dev->name);\n\t\tdev_kfree_skb(skb);\n\t\treturn;\n\t}\n\n\tif (!ok) {\n\t\ttxt = \"frame was not ACKed\";\n\t\tgoto done;\n\t}\n\n\tspin_lock(&ap->sta_table_lock);\n\tsta = ap_get_sta(ap, hdr->addr1);\n\tif (sta)\n\t\tatomic_inc(&sta->users);\n\tspin_unlock(&ap->sta_table_lock);\n\n\tif (!sta) {\n\t\ttxt = \"STA not found\";\n\t\tgoto done;\n\t}\n\n\tpos = (__le16 *) (skb->data + IEEE80211_MGMT_HDR_LEN);\n\tpos++;\n\tstatus = le16_to_cpu(*pos++);\n\tif (status == WLAN_STATUS_SUCCESS) {\n\t\tif (!(sta->flags & WLAN_STA_ASSOC))\n\t\t\thostap_event_new_sta(dev, sta);\n\t\ttxt = \"STA associated\";\n\t\tsta->flags |= WLAN_STA_ASSOC;\n\t\tsta->last_assoc = jiffies;\n\t} else\n\t\ttxt = \"association failed\";\n\n done:\n\tif (sta)\n\t\tatomic_dec(&sta->users);\n\tif (txt) {\n\t\tPDEBUG(DEBUG_AP, \"%s: %pM assoc_cb - %s\\n\",\n\t\t dev->name, hdr->addr1, txt);\n\t}\n\tdev_kfree_skb(skb);\n}", "label": 0, "cwe": null, "length": 434 }, { "index": 109262, "code": "wccpHereIam(void *voidnotused)\n{\n debug(80, 6) (\"wccpHereIam: Called\\n\");\n\n wccp_here_i_am.id = last_id;\n send(theWccpConnection,\n\t&wccp_here_i_am,\n\tsizeof(wccp_here_i_am),\n\t0);\n\n if (!eventFind(wccpHereIam, NULL))\n\teventAdd(\"wccpHereIam\", wccpHereIam, NULL, 10.0, 1);\n}", "label": 0, "cwe": null, "length": 114 }, { "index": 567939, "code": "s_cpinlist_add(CPINLIST * ptr)\n{\n CPINLIST *new_node;\n\n new_node = (CPINLIST *) g_malloc(sizeof(CPINLIST));\n\n /* setup node information */\n new_node->plid = 0;\n new_node->type = PIN_TYPE_NET;\n new_node->pin_number = NULL;\n new_node->pin_label = NULL;\n new_node->net_name = NULL;\n new_node->nets = NULL;\n\n /* Setup link list stuff */\n new_node->next = NULL;\n\n if (ptr == NULL) {\n\tnew_node->prev = NULL;\t/* setup previous link */\n\treturn (new_node);\n } else {\n\tnew_node->prev = ptr;\t/* setup previous link */\n\tptr->next = new_node;\n\treturn (ptr->next);\n }\n}", "label": 0, "cwe": null, "length": 172 }, { "index": 475862, "code": "Print(const char* file, bool print_current_value) {\n // Since flag registration is likely by file (= C++ file),\n // we don't need to sort by file and still get grouped output.\n const char* current = NULL;\n for (Flag* f = list_; f != NULL; f = f->next()) {\n if (file == NULL || file == f->file()) {\n if (current != f->file()) {\n printf(\"Flags from %s:\\n\", f->file());\n current = f->file();\n }\n f->Print(print_current_value);\n }\n }\n}", "label": 0, "cwe": null, "length": 131 }, { "index": 358067, "code": "finalize_legacy_starling_options(const prog_info& pinfo,\n starling_options& opt) {\n\n\n if (! opt.is_ref_set()) {\n pinfo.usage(\"a reference sequence must be specified\");\n }\n\n // canonicalize the reference sequence path:\n if (opt.is_samtools_ref_set) {\n if (! compat_realpath(opt.samtools_ref_seq_file)) {\n std::ostringstream oss;\n oss << \"can't resolve samtools reference path: \" << opt.samtools_ref_seq_file << \"\\n\";\n pinfo.usage(oss.str().c_str());\n }\n } else {\n assert(0);\n }\n\n if (! opt.is_user_genome_size) {\n // this requirement is not what we want, but it's the only way to make things reliable for now:\n pinfo.usage(\"must specify genome-size\");\n } else {\n if (opt.user_genome_size<1) {\n pinfo.usage(\"genome-size must be greater than 0\");\n }\n }\n\n\n if (! opt.is_call_indels()) {\n if (opt.is_simple_indel_error) {\n pinfo.usage(\"--indel-error-rate has no effect when not calling indels\");\n }\n }\n\n {\n const bool is_contigs(! opt.indel_contig_filename.empty());\n const bool is_reads(! opt.indel_contig_read_filename.empty());\n\n if (is_contigs ^ is_reads) { //should work when they're both bools...\n if (is_contigs) {\n pinfo.usage(\"Contigs specified without corresponding contig reads.\");\n } else {\n pinfo.usage(\"Contig reads specified without corresponding contigs.\");\n }\n }\n\n if (is_contigs || is_reads) {\n if (opt.is_ignore_read_names) {\n pinfo.usage(\"Cannot use 'ignore-conflicting-read-names' when indel contigs are specified.\");\n }\n }\n }\n\n if (opt.is_write_candidate_indels_only &&\n opt.candidate_indel_filename.empty()) {\n pinfo.usage(\"Cannot specify -write-candidate-indels-only without providing candidate indel filename.\");\n }\n}", "label": 0, "cwe": null, "length": 445 }, { "index": 92146, "code": "create_temp_filename(char *suffix)\n{\n char *abs, *app, *dir, *filename, *s;\n\n /* XXX no slashes? */\n app = get_dacs_app_name();\n\n if ((dir = conf_val(CONF_TEMP_DIRECTORY)) == NULL)\n\tdir = DEFAULT_TEMP_DIRECTORY;\n\n if (dir[0] != '/')\n\tabs = DACS_HOME;\n else\n\tabs = \"\";\n\n if (suffix == NULL)\n\ts = crypto_make_random_string(NULL, TEMP_FILENAME_RANDOM_LENGTH);\n else\n\ts = url_encode(suffix, 0);\n\n if (*s != '\\0')\n\tfilename = canon_pathname(ds_xprintf(\"%s/%s/%s%c%s\",\n\t\t\t\t\t\t\t\t\t\t abs, dir, app,\n\t\t\t\t\t\t\t\t\t\t TEMP_FILENAME_SEP_CHAR, s));\n else\n\tfilename = canon_pathname(ds_xprintf(\"%s/%s/%s\", abs, dir, app));\n\n return(filename);\n}", "label": 0, "cwe": null, "length": 187 }, { "index": 935315, "code": "loadToolbarData( const QDomElement &e )\n{\n\tQDomElement tb_prefs = e;\n\tToolbarPrefs tb;\n\n\treadEntry(tb_prefs, \"name\",\t\t&tb.name);\n\treadBoolEntry(tb_prefs, \"on\",\t\t&tb.on);\n\treadBoolEntry(tb_prefs, \"locked\",\t&tb.locked);\n\t// readBoolEntry(tb_prefs, \"stretchable\",\t&tb.stretchable);\n\txmlToStringList(tb_prefs, \"keys\",\t&tb.keys);\n\n\tbool found3 = false;\n\tQDomElement tb_position = findSubTag(tb_prefs, \"position\", &found3);\n\tif (found3)\n\t{\n\t\tQString dockStr;\n\t\tQt::Dock dock = Qt::DockTop;\n\t\treadEntry(tb_position, \"dock\", &dockStr);\n\t\tif (dockStr == \"DockTop\")\n\t\t\tdock = Qt::DockTop;\n\t\telse if (dockStr == \"DockBottom\")\n\t\t\tdock = Qt::DockBottom;\n\t\telse if (dockStr == \"DockLeft\")\n\t\t\tdock = Qt::DockLeft;\n\t\telse if (dockStr == \"DockRight\")\n\t\t\tdock = Qt::DockRight;\n\t\telse if (dockStr == \"DockMinimized\")\n\t\t\tdock = Qt::DockMinimized;\n\t\telse if (dockStr == \"DockTornOff\")\n\t\t\tdock = Qt::DockTornOff;\n\t\telse if (dockStr == \"DockUnmanaged\")\n\t\t\tdock = Qt::DockUnmanaged;\n\n\t\ttb.dock = dock;\n\n\t\t// readNumEntry(tb_position, \"index\",\t\t&tb.index);\n\t\treadBoolEntry(tb_position, \"nl\",\t\t&tb.nl);\n\t\t// readNumEntry(tb_position, \"extraOffset\",\t&tb.extraOffset);\n\t}\n\n\treturn tb;\n}", "label": 0, "cwe": null, "length": 377 }, { "index": 544121, "code": "parse_table_lookup_bitmask(const struct annotate_attrib *table,\n char** s, char* errmsg) \n{\n int result = 0;\n char *p, *p2;\n\n p = *s;\n do {\n\tp2 = p;\n\tfor (; *p && (isalnum(*p) || *p=='.' || *p=='-' || *p=='_' || *p=='/');\n\t p++);\n\tresult |= table_lookup(table, p2, p-p2, errmsg);\n\tfor (; *p && isspace(*p); p++);\n } while (*p && *p != ',');\n\n *s = p;\n return result;\n}", "label": 0, "cwe": null, "length": 137 }, { "index": 10682, "code": "fescape(FILE *f)\n{\n int n, k, c = fgetc(f);\n\n switch(c) {\n\tcase 'n': return '\\n';\n\tcase 'b': return '\\b';\n\tcase 't': return '\\t';\n\tcase 'r': return '\\r';\n }\n if(c < '0' || c > '7')\n\treturn c;\n \n n = c-'0'; k = 2;\n while((c = fgetc(f)) >= '0' && c <= '7') {\n\tn = (n*8) | (c-'0');\n\tif(--k <= 0)\n\t return n;\n }\n if(c != EOF) ungetc(c, f);\n return n;\n}", "label": 0, "cwe": null, "length": 152 }, { "index": 671719, "code": "endnetgrent_p(struct net_data *net_data) {\n\tstruct irs_ng *ng;\n\n\tif (!net_data)\n\t\treturn;\n\tif ((ng = net_data->ng) != NULL)\n\t\t(*ng->close)(ng);\n\tnet_data->ng = NULL;\n}", "label": 0, "cwe": null, "length": 58 }, { "index": 109938, "code": "if_convertible_loop_p (struct loop *loop)\n{\n edge e;\n edge_iterator ei;\n bool res = false;\n vec refs;\n vec ddrs;\n vec loop_nest;\n\n /* Handle only innermost loop. */\n if (!loop || loop->inner)\n {\n if (dump_file && (dump_flags & TDF_DETAILS))\n\tfprintf (dump_file, \"not innermost loop\\n\");\n return false;\n }\n\n /* If only one block, no need for if-conversion. */\n if (loop->num_nodes <= 2)\n {\n if (dump_file && (dump_flags & TDF_DETAILS))\n\tfprintf (dump_file, \"less than 2 basic blocks\\n\");\n return false;\n }\n\n /* More than one loop exit is too much to handle. */\n if (!single_exit (loop))\n {\n if (dump_file && (dump_flags & TDF_DETAILS))\n\tfprintf (dump_file, \"multiple exits\\n\");\n return false;\n }\n\n /* If one of the loop header's edge is an exit edge then do not\n apply if-conversion. */\n FOR_EACH_EDGE (e, ei, loop->header->succs)\n if (loop_exit_edge_p (loop, e))\n return false;\n\n refs.create (5);\n ddrs.create (25);\n loop_nest.create (3);\n res = if_convertible_loop_p_1 (loop, &loop_nest, &refs, &ddrs);\n\n if (flag_tree_loop_if_convert_stores)\n {\n data_reference_p dr;\n unsigned int i;\n\n for (i = 0; refs.iterate (i, &dr); i++)\n\tfree (dr->aux);\n }\n\n loop_nest.release ();\n free_data_refs (refs);\n free_dependence_relations (ddrs);\n return res;\n}", "label": 0, "cwe": null, "length": 409 }, { "index": 493820, "code": "idtol(char *id, int n)\n{\n\tlong\tl = 0;\n\n\tif (!id)\n\t{\n\t\t/* Whatever. */\n\t\treturn 0;\n\t}\n\n\twhile (n-- && *id)\n\t{\n\t\tl = l * CHIDNB + alphabet_id[(unsigned char )*id++];\n\t}\n\n\treturn l;\n}", "label": 0, "cwe": null, "length": 69 }, { "index": 125666, "code": "gnc_reset_warnings_add_one (RWDialog *rw_dialog, const gchar *prefs_group,\n const GncWarningSpec *warning, GtkWidget *box)\n{\n GtkWidget *checkbox;\n\n ENTER(\"rw_dialog %p, warning %p, box %p\", rw_dialog, warning, box);\n\n checkbox = gtk_check_button_new_with_label( _(warning->warn_desc ? warning->warn_desc : warning->warn_name));\n if (warning->warn_long_desc)\n gtk_widget_set_tooltip_text(checkbox, _(warning->warn_long_desc));\n\n gtk_widget_set_name(checkbox, warning->warn_name);\n g_object_set_data_full (G_OBJECT (checkbox), \"prefs-group\", g_strdup(prefs_group),\n (GDestroyNotify) g_free);\n g_signal_connect_swapped(G_OBJECT(checkbox), \"toggled\",\n (GCallback)gnc_reset_warnings_update_widgets, rw_dialog);\n gtk_box_pack_start(GTK_BOX(box), checkbox, TRUE, TRUE, 0);\n LEAVE(\" \");\n}", "label": 0, "cwe": null, "length": 211 }, { "index": 72690, "code": "drmaa_wtermsig(char *signal, size_t signal_len, int stat, char *error_diagnosis, size_t error_diag_len)\n{\n dstring sig, diag;\n dstring *diagp = NULL;\n int ret = DRMAA_ERRNO_SUCCESS;\n \n if (error_diagnosis != NULL) {\n sge_dstring_init(&diag, error_diagnosis, error_diag_len+1);\n diagp = &diag;\n }\n \n ret = japi_was_init_called(diagp);\n if (ret != DRMAA_ERRNO_SUCCESS) {\n /* diagp written by japi_was_init_called() */\n return ret;\n }\n\n if (signal != NULL) {\n sge_dstring_init(&sig, signal, signal_len+1);\n }\n \n return japi_wtermsig(signal?&sig:NULL, stat, error_diagnosis?&diag:NULL);\n}", "label": 0, "cwe": null, "length": 196 }, { "index": 73447, "code": "fsck_dtInsert(struct dinode *ip, struct component_name *name,\n\t\t uint32_t * fsn)\n{\n\tint rc = 0;\n\tstruct btpage *bp;\t/* page buffer */\n\tdtpage_t *p;\t\t/* base B+-tree index page */\n\tint64_t bn;\n\tint32_t index;\n\tstruct dtsplit split;\t/* split information */\n\tddata_t data;\n\tint32_t n;\n\tstruct btstack btstack;\n\tuint32_t ino;\n\n\t/*\n\t * search for the entry to insert:\n\t *\n\t * fsck_dtSearch() returns (leaf page pinned, index at which to insert).\n\t */\n\trc = fsck_dtSearch(ip, name, &ino, &btstack, JFS_CREATE);\n\tif (rc)\n\t\treturn rc;\n\n\t/*\n\t * retrieve search result\n\t *\n\t * fsck_dtSearch() returns (leaf page pinned, index at which to insert).\n\t * n.b. fsck_dtSearch() may return index of (maxindex + 1) of\n\t * the full page.\n\t */\n\tBT_GETSEARCH(ip, btstack.top, bn, bp, dtpage_t, p, index);\n\n\t/*\n\t * insert entry for new key\n\t */\n\tif (DO_INDEX())\n\t\tn = NDTLEAF(name->namlen);\n\telse\n\t\tn = NDTLEAF_LEGACY(name->namlen);\n\tdata.leaf.ino = *fsn;\n\n\t/*\n\t * leaf page does not have enough room for new entry:\n\t *\n\t * extend/split the leaf page;\n\t *\n\t * dtSplitUp() will insert the entry and unpin the leaf page.\n\t */\n\tif (n > p->header.freecnt) {\n\t\tsplit.bp = bp;\n\t\tsplit.index = index;\n\t\tsplit.nslot = n;\n\t\tsplit.key = name;\n\t\tsplit.data = &data;\n\t\trc = dtSplitUp(ip, &split, &btstack);\n\t\treturn rc;\n\t}\n\n\t/*\n\t * leaf page does have enough room for new entry:\n\t *\n\t * insert the new data entry into the leaf page;\n\t */\n\tdtInsertEntry(ip, p, index, name, &data);\n\n\t/* unpin the leaf page */\n\tFSCK_BT_PUTPAGE(bp);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 494 }, { "index": 379278, "code": "aoecmd_create ( struct aoe_device *aoedev,\n\t\t\t\t\t struct aoe_command_type *type ) {\n\tstruct aoe_command *aoecmd;\n\tint tag;\n\n\t/* Allocate command tag */\n\ttag = aoecmd_new_tag();\n\tif ( tag < 0 )\n\t\treturn NULL;\n\n\t/* Allocate and initialise structure */\n\taoecmd = zalloc ( sizeof ( *aoecmd ) );\n\tif ( ! aoecmd )\n\t\treturn NULL;\n\tref_init ( &aoecmd->refcnt, aoecmd_free );\n\tlist_add ( &aoecmd->list, &aoe_commands );\n\tintf_init ( &aoecmd->ata, &aoecmd_ata_desc, &aoecmd->refcnt );\n\ttimer_init ( &aoecmd->timer, aoecmd_expired, &aoecmd->refcnt );\n\taoecmd->aoedev = aoedev_get ( aoedev );\n\taoecmd->type = type;\n\taoecmd->tag = tag;\n\n\t/* Preserve timeout from last completed command */\n\taoecmd->timer.timeout = aoedev->timeout;\n\n\t/* Return already mortalised. (Reference is held by command list.) */\n\treturn aoecmd;\n}", "label": 0, "cwe": null, "length": 259 }, { "index": 680267, "code": "dpm_wait(struct device *dev, bool async)\n{\n\tif (!dev)\n\t\treturn;\n\n\tif (async || (pm_async_enabled && dev->power.async_suspend))\n\t\twait_for_completion(&dev->power.completion);\n}", "label": 0, "cwe": null, "length": 47 }, { "index": 998041, "code": "ftpCloseControlConnection()\n{\n m_extControl = 0;\n delete m_control;\n m_control = NULL;\n m_cDataMode = 0;\n m_bLoggedOn = false; // logon needs control connction\n m_bTextMode = false;\n m_bBusy = false;\n}", "label": 0, "cwe": null, "length": 68 }, { "index": 981606, "code": "adf_dev_in_use(struct adf_accel_dev *accel_dev)\n{\n\treturn atomic_read(&accel_dev->ref_count) != 0;\n}", "label": 0, "cwe": null, "length": 30 }, { "index": 544762, "code": "_NP_decrRefCount()\n{\n boa_lock.lock();\n int done = --pd_refCount > 0;\n boa_lock.unlock();\n if( done ) return;\n\n omniORB::logs(15, \"No more references to the BOA -- deleted.\");\n\n delete this;\n}", "label": 0, "cwe": null, "length": 63 }, { "index": 742747, "code": "groupEntries(EntriesOptions options)\n{\n Q_D(KServiceGroup);\n bool sort = options & SortEntries || options & AllowSeparators;\n QList list;\n List tmp = d->entries(this, sort, options & ExcludeNoDisplay, options & AllowSeparators, options & SortByGenericName);\n foreach(const SPtr &ptr, tmp) {\n if (ptr->isType(KST_KServiceGroup))\n list.append(Ptr::staticCast(ptr));\n else if (ptr->isType(KST_KServiceSeparator))\n list.append(KServiceGroup::Ptr(static_cast(new KSycocaEntry())));\n else if (sort && ptr->isType(KST_KService))\n break;\n }\n return list;\n}", "label": 0, "cwe": null, "length": 164 }, { "index": 1007745, "code": "des_test()\n{\n const byte vector[] = { /* \"now is the time for all \" w/o trailing 0 */\n 0x6e,0x6f,0x77,0x20,0x69,0x73,0x20,0x74,\n 0x68,0x65,0x20,0x74,0x69,0x6d,0x65,0x20,\n 0x66,0x6f,0x72,0x20,0x61,0x6c,0x6c,0x20\n };\n\n byte plain[24];\n byte cipher[24];\n\n Des enc;\n Des dec;\n\n const byte key[] = \n {\n 0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef\n };\n\n const byte iv[] = \n {\n 0x12,0x34,0x56,0x78,0x90,0xab,0xcd,0xef\n };\n\n const byte verify[] = \n {\n 0x8b,0x7c,0x52,0xb0,0x01,0x2b,0x6c,0xb8,\n 0x4f,0x0f,0xeb,0xf3,0xfb,0x5f,0x86,0x73,\n 0x15,0x85,0xb3,0x22,0x4b,0x86,0x2b,0x4b\n };\n\n\n Des_SetKey(&enc, key, iv, DES_ENCRYPTION);\n Des_CbcEncrypt(&enc, cipher, vector, sizeof(vector));\n Des_SetKey(&dec, key, iv, DES_DECRYPTION);\n Des_CbcDecrypt(&dec, plain, cipher, sizeof(cipher));\n\n if (memcmp(plain, vector, sizeof(plain)))\n return -31;\n\n if (memcmp(cipher, verify, sizeof(cipher)))\n return -32;\n\n return 0;\n}", "label": 0, "cwe": null, "length": 467 }, { "index": 409376, "code": "bSetCstrChar (bstring b, int pos, char c) {\r\n\tif (NULL == b || b->mlen <= 0 || b->slen < 0 || b->mlen < b->slen)\r\n\t\treturn BSTR_ERR;\r\n\tif (pos < 0 || pos > b->slen) return BSTR_ERR;\r\n\r\n\tif (pos == b->slen) {\r\n\t\tif ('\\0' != c) return bconchar (b, c);\r\n\t\treturn 0;\r\n\t}\r\n\r\n\tb->data[pos] = (unsigned char) c;\r\n\tif ('\\0' == c) b->slen = pos;\r\n\r\n\treturn 0;\r\n}", "label": 0, "cwe": null, "length": 140 }, { "index": 533277, "code": "indexOfFromStart(const Coordinate& inputPt,\n const LinearLocation* minIndex) const\n{\n\tdouble minDistance = numeric_limits::max();\n\tint minComponentIndex = 0;\n\tint minSegmentIndex = 0;\n\tdouble minFrac = -1.0;\n\n\tLineSegment seg;\n\tfor (LinearIterator it(linearGeom);\n\t\t\tit.hasNext(); it.next())\n\t{\n\t\tif (! it.isEndOfLine())\n\t\t{\n\t\t\tseg.p0 = it.getSegmentStart();\n\t\t\tseg.p1 = it.getSegmentEnd();\n\t\t\tdouble segDistance = seg.distance(inputPt);\n\t\t\tdouble segFrac = seg.segmentFraction(inputPt);\n\n\t\t\tint candidateComponentIndex = it.getComponentIndex();\n\t\t\tint candidateSegmentIndex = it.getVertexIndex();\n\t\t\tif (segDistance < minDistance)\n\t\t\t{\n\t\t\t\t// ensure after minLocation, if any\n\t\t\t\tif (!minIndex ||\n\t\t\t\t\t\tminIndex->compareLocationValues(candidateComponentIndex, candidateSegmentIndex, segFrac) < 0)\n\t\t\t\t{\n\t\t\t\t\t// otherwise, save this as new minimum\n\t\t\t\t\tminComponentIndex = candidateComponentIndex;\n\t\t\t\t\tminSegmentIndex = candidateSegmentIndex;\n\t\t\t\t\tminFrac = segFrac;\n\t\t\t\t\tminDistance = segDistance;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\tLinearLocation loc(minComponentIndex, minSegmentIndex, minFrac);\n\treturn loc;\n}", "label": 0, "cwe": null, "length": 288 }, { "index": 464907, "code": "gl_ui_property_bar_init (glUIPropertyBar *this)\n{\n\tgl_debug (DEBUG_PROPERTY_BAR, \"START\");\n\n\tthis->priv = g_new0 (glUIPropertyBarPrivate, 1);\n\n\tgl_debug (DEBUG_PROPERTY_BAR, \"END\");\n}", "label": 0, "cwe": null, "length": 53 }, { "index": 296264, "code": "posix_fchmodat(PyObject *self, PyObject *args)\n{\n int dirfd, mode, res;\n int flags = 0;\n PyObject *opath;\n char *path;\n\n if (!PyArg_ParseTuple(args, \"iO&i|i:fchmodat\",\n &dirfd, PyUnicode_FSConverter, &opath, &mode, &flags))\n return NULL;\n\n path = PyBytes_AsString(opath);\n\n Py_BEGIN_ALLOW_THREADS\n res = fchmodat(dirfd, path, mode, flags);\n Py_END_ALLOW_THREADS\n Py_DECREF(opath);\n if (res < 0)\n return posix_error();\n Py_RETURN_NONE;\n}", "label": 0, "cwe": null, "length": 144 }, { "index": 200766, "code": "updateGeometryWithoutNotifyNeighbours()\n {\n if (!mDirtyGeometryRect.isNull())\n {\n mQuadTree->updateVertexData(true, false, mDirtyGeometryRect, false);\n mDirtyGeometryRect.setNull();\n }\n }", "label": 0, "cwe": null, "length": 52 }, { "index": 723452, "code": "error_join(MUC_REC *channel, const char *code, const char *nick)\n{\n\tchar *altnick;\n\tint error;\n\n\tif (nick != NULL && strcmp(nick, channel->nick) != 0)\n\t\treturn;\n\terror = code != NULL ? atoi(code) : MUC_ERROR_UNKNOWN;\n\tsignal_emit(\"xmpp muc joinerror\", 2, channel, GINT_TO_POINTER(error));\n\tswitch(error) {\n\tcase MUC_ERROR_USE_RESERVED_ROOM_NICK:\n\tcase MUC_ERROR_NICK_IN_USE:\n\t\t/* rejoin with alternate nick */\n\t\taltnick = (char *)settings_get_str(\"alternate_nick\");\n\t\tif (altnick != NULL && *altnick != '\\0'\n\t\t && strcmp(channel->nick, altnick) != 0) {\n\t\t\tg_free(channel->nick);\n\t\t\tchannel->nick = g_strdup(altnick);\n\t\t} else {\n\t\t\taltnick = g_strdup_printf(\"%s_\", channel->nick);\n\t\t\tg_free(channel->nick);\n\t\t\tchannel->nick = altnick;\n\t\t}\n\t\tsend_join(channel);\n\t\treturn; /* don't destroy the channel */\n\t}\n\tchannel_destroy(CHANNEL(channel));\n}", "label": 1, "cwe": "CWE-other", "length": 246 }, { "index": 556640, "code": "check_new_and_strlen(struct state *st, const char *const p) {\n if(check_new(st, p))\n\tst->total_size += 1 + strlen(p);\n}", "label": 0, "cwe": null, "length": 37 }, { "index": 126667, "code": "compare_names(name1, name2)\nchar *name1, *name2;\n{\n int match, n2, i;\n char *ptr1, *ptr2, parts[10][12], ctemp1[120], ctemp2[120];\n\n match = 0;\n \n /* strtok modified the strings */\n strcpy(ctemp1, name1);\n strcpy(ctemp2, name2);\n\n /* strtok only tracks one string at a time, so pre-process name2 */\n /* max of 10 name parts, 12 chars in length each */\n n2 = 0;\n ptr2 = strtok(ctemp2, \"|\");\n while (ptr2 != NULL)\n {\n strcpy(parts[n2], ptr2);\n n2++;\n ptr2 = strtok(NULL, \"|\");\n }\n\n ptr1 = strtok(ctemp1, \"|\");\n while (ptr1 != NULL)\n { \n for (i=0; i strlen(name2))\n { strcpy(name2, name1); }\n \n return(match);\n\n}", "label": 0, "cwe": null, "length": 418 }, { "index": 679155, "code": "cms_RecipientInfo_ktri_encrypt(CMS_ContentInfo *cms,\n\t\t\t\t\tCMS_RecipientInfo *ri)\n\t{\n\tCMS_KeyTransRecipientInfo *ktri;\n\tCMS_EncryptedContentInfo *ec;\n\tEVP_PKEY_CTX *pctx = NULL;\n\tunsigned char *ek = NULL;\n\tsize_t eklen;\n\n\tint ret = 0;\n\n\tif (ri->type != CMS_RECIPINFO_TRANS)\n\t\t{\n\t\tCMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT,\n\t\t\tCMS_R_NOT_KEY_TRANSPORT);\n\t\treturn 0;\n\t\t}\n\tktri = ri->d.ktri;\n\tec = cms->d.envelopedData->encryptedContentInfo;\n\n\tpctx = EVP_PKEY_CTX_new(ktri->pkey, NULL);\n\tif (!pctx)\n\t\treturn 0;\n\n\tif (EVP_PKEY_encrypt_init(pctx) <= 0)\n\t\tgoto err;\n\n\tif (EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_ENCRYPT,\n\t\t\t\tEVP_PKEY_CTRL_CMS_ENCRYPT, 0, ri) <= 0)\n\t\t{\n\t\tCMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT, CMS_R_CTRL_ERROR);\n\t\tgoto err;\n\t\t}\n\n\tif (EVP_PKEY_encrypt(pctx, NULL, &eklen, ec->key, ec->keylen) <= 0)\n\t\tgoto err;\n\n\tek = OPENSSL_malloc(eklen);\n\n\tif (ek == NULL)\n\t\t{\n\t\tCMSerr(CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT,\n\t\t\t\t\t\t\tERR_R_MALLOC_FAILURE);\n\t\tgoto err;\n\t\t}\n\n\tif (EVP_PKEY_encrypt(pctx, ek, &eklen, ec->key, ec->keylen) <= 0)\n\t\tgoto err;\n\n\tASN1_STRING_set0(ktri->encryptedKey, ek, eklen);\n\tek = NULL;\n\n\tret = 1;\n\n\terr:\n\tif (pctx)\n\t\tEVP_PKEY_CTX_free(pctx);\n\tif (ek)\n\t\tOPENSSL_free(ek);\n\treturn ret;\n\n\t}", "label": 0, "cwe": null, "length": 450 }, { "index": 23997, "code": "gpk_application_set_text_buffer (GtkWidget *widget, const gchar *text)\n{\n\tGtkTextBuffer *buffer;\n\tbuffer = gtk_text_buffer_new (NULL);\n\t/* ITS4: ignore, not used for allocation */\n\tif (egg_strzero (text) == FALSE) {\n\t\tgtk_text_buffer_set_text (buffer, text, -1);\n\t} else {\n\t\t/* no information */\n\t\tgtk_text_buffer_set_text (buffer, \"\", -1);\n\t}\n\tgtk_text_view_set_buffer (GTK_TEXT_VIEW (widget), buffer);\n}", "label": 0, "cwe": null, "length": 111 }, { "index": 85121, "code": "krbhost_dealloc(void *ptr)\n{\n struct krb5_krbhst_data *handle = (struct krb5_krbhst_data *)ptr;\n krb5_krbhst_info *h, *next;\n\n for (h = handle->hosts; h != NULL; h = next) {\n\tnext = h->next;\n\t_krb5_free_krbhst_info(h);\n }\n if (handle->hostname)\n\tfree(handle->hostname);\n\n free(handle->realm);\n}", "label": 0, "cwe": null, "length": 106 }, { "index": 997954, "code": "gtk_plot_canvas_child_draw(GtkPlotCanvas *canvas,\n GtkPlotCanvasChild *child)\n{\n if(canvas->freeze_count > 0) return;\n\n gtk_plot_pc_gsave(canvas->pc);\n\n GTK_PLOT_CANVAS_CHILD_CLASS(GTK_OBJECT_GET_CLASS(GTK_OBJECT(child)))->draw(canvas, child);\n\n gtk_plot_pc_grestore(canvas->pc);\n}", "label": 0, "cwe": null, "length": 76 }, { "index": 995977, "code": "build_protocol_initializer (tree type, tree protocol_name, tree protocol_list,\n\t\t\t tree inst_methods, tree class_methods)\n{\n tree expr, ttyp;\n location_t loc;\n VEC(constructor_elt,gc) *inits = NULL;\n\n /* TODO: pass the loc in or find it from args. */\n loc = input_location;\n ttyp = build_pointer_type (xref_tag (RECORD_TYPE,\n\t\t\t\t get_identifier (UTAG_CLASS)));\n /* Filling the \"isa\" in with a version allows the runtime system to\n detect this ... */\n expr = build_int_cst (ttyp, PROTOCOL_VERSION);\n\n CONSTRUCTOR_APPEND_ELT (inits, NULL_TREE, expr);\n\n CONSTRUCTOR_APPEND_ELT (inits, NULL_TREE, protocol_name);\n CONSTRUCTOR_APPEND_ELT (inits, NULL_TREE, protocol_list);\n\n ttyp = objc_method_proto_list_ptr;\n if (inst_methods)\n expr = convert (ttyp, build_unary_op (loc, ADDR_EXPR, inst_methods, 0));\n else\n expr = convert (ttyp, null_pointer_node);\n CONSTRUCTOR_APPEND_ELT (inits, NULL_TREE, expr);\n\n if (class_methods)\n expr = convert (ttyp, build_unary_op (loc, ADDR_EXPR, class_methods, 0));\n else\n expr = convert (ttyp, null_pointer_node);\n CONSTRUCTOR_APPEND_ELT (inits, NULL_TREE, expr);\n\n return objc_build_constructor (type, inits);\n}", "label": 0, "cwe": null, "length": 327 }, { "index": 403869, "code": "gpc_unpc(Pixel *out, const Pixel *in, const Background *back)\n{\n (void)back;\n\n if (in->a <= 128)\n {\n out->r = out->g = out->b = 255;\n out->a = 0;\n }\n\n else\n {\n out->r = sRGB((double)in->r / in->a);\n out->g = sRGB((double)in->g / in->a);\n out->b = sRGB((double)in->b / in->a);\n out->a = u8d(in->a / 257.);\n }\n}", "label": 0, "cwe": null, "length": 142 }, { "index": 794751, "code": "defhbfile_get(GtkWidget *widget, gpointer user_data)\n{\nstruct defhbfile_data *data;\ngchar\t*owner;\nguint32\tvehicle;\ngint\tsmode, weekday, nbdays;\n\n\tDB( g_print(\"(ui-hbfile) get\\n\") );\n\n\tdata = g_object_get_data(G_OBJECT(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW)), \"inst_data\");\n\n\t// get values\n\towner = (gchar *)gtk_entry_get_text(GTK_ENTRY(data->ST_owner));\n\tvehicle = ui_cat_comboboxentry_get_key(GTK_COMBO_BOX(data->PO_grp));\n\tif( gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(data->radio[0])) )\n\t\tsmode = 0;\n\telse\n\t\tsmode = 1;\n\tweekday = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NU_weekday));\n\tnbdays = gtk_spin_button_get_value(GTK_SPIN_BUTTON(data->NU_nbdays));\n\n\t// check for changes\n\tif(strcasecmp(owner, GLOBALS->owner))\n\t\tdata->change++;\n\tif(vehicle != GLOBALS->vehicle_category)\n\t\tdata->change++;\n\tif(smode != GLOBALS->auto_smode)\n\t\tdata->change++;\n\tif(weekday != GLOBALS->auto_weekday)\n\t\tdata->change++;\n\tif(nbdays != GLOBALS->auto_nbdays)\n\t\tdata->change++;\n\n\t// update\n\tif (owner && *owner)\n\t\thbfile_change_owner(g_strdup(owner));\n\n\tGLOBALS->vehicle_category = vehicle;\n\tGLOBALS->auto_smode = smode;\n\tGLOBALS->auto_weekday = weekday;\n\tGLOBALS->auto_nbdays = nbdays;\n\n\tDB( g_print(\" -> owner %s\\n\", GLOBALS->owner) );\n\tDB( g_print(\" -> ccgrp %d\\n\", GLOBALS->vehicle_category) );\n\tDB( g_print(\" -> smode %d\\n\", GLOBALS->auto_smode) );\n\tDB( g_print(\" -> weekday %d\\n\", GLOBALS->auto_weekday) );\n\tDB( g_print(\" -> nbdays %d\\n\", GLOBALS->auto_nbdays) );\n\n}", "label": 0, "cwe": null, "length": 447 }, { "index": 517138, "code": "PrintSelf(ostream& os, vtkIndent indent)\n{\n this->Superclass::PrintSelf(os,indent);\n\n os << indent << \"Input DataSets:\\n\";\n this->InputList->PrintSelf(os,indent.GetNextIndent());\n \n if ( this->ExecuteMethod )\n {\n os << indent << \"An ExecuteMethod has been defined\\n\";\n }\n else\n {\n os << indent << \"An ExecuteMethod has NOT been defined\\n\";\n }\n}", "label": 0, "cwe": null, "length": 102 }, { "index": 22724, "code": "lvlval_obstacles_cmp_data(void *opaque_data1, void *opaque_data2)\n{\n#\tdefine DIST_EPSILON 0.01f\n\n\tstruct obstacle_excpt_data *data1 = opaque_data1;\n\tstruct obstacle_excpt_data *data2 = opaque_data2;\n\n\tif (data1->subtest != data2->subtest)\n\t\treturn FALSE;\n\n\tif (data1->obs_pos.z != data2->obs_pos.z)\n\t\treturn FALSE;\n\n\tif (data1->type != data2->type)\n\t\treturn FALSE;\n\n\tfloat dist = calc_distance(data1->obs_pos.x, data1->obs_pos.y, data2->obs_pos.x, data2->obs_pos.y);\n\tif (dist > DIST_EPSILON)\n\t\treturn FALSE;\n\n\tif (fabs(data1->border - data2->border) > DIST_EPSILON)\n\t\treturn FALSE;\n\n\treturn TRUE;\n\n#\tundef DIST_EPSILON\n}", "label": 0, "cwe": null, "length": 189 }, { "index": 45753, "code": "getInstance(InstantiatorFn *instantiator, const void *context,\n void *&duplicate,\n UErrorCode &errorCode) {\n duplicate=NULL;\n if(U_FAILURE(errorCode)) {\n return NULL;\n }\n int8_t haveInstance;\n UMTX_CHECK(NULL, fHaveInstance, haveInstance);\n if(haveInstance>0) {\n return fInstance; // instance was created\n } else if(haveInstance<0) {\n errorCode=fErrorCode; // instance creation failed\n return NULL;\n } else /* haveInstance==0 */ {\n void *instance=instantiator(context, errorCode);\n Mutex mutex;\n if(fHaveInstance==0) {\n if(U_SUCCESS(errorCode)) {\n fInstance=instance;\n instance=NULL;\n fHaveInstance=1;\n } else {\n fErrorCode=errorCode;\n fHaveInstance=-1;\n }\n } else {\n errorCode=fErrorCode;\n }\n duplicate=instance;\n return fInstance;\n }\n}", "label": 0, "cwe": null, "length": 214 }, { "index": 76040, "code": "ensureCapacity(int32_t newLen, UErrorCode& ec) {\n if (newLen <= capacity)\n return;\n UChar32* temp = (UChar32*) uprv_realloc(list, sizeof(UChar32) * (newLen + GROW_EXTRA));\n if (temp == NULL) {\n ec = U_MEMORY_ALLOCATION_ERROR;\n setToBogus();\n return;\n }\n list = temp;\n capacity = newLen + GROW_EXTRA;\n // else we keep the original contents on the memory failure.\n}", "label": 0, "cwe": null, "length": 116 }, { "index": 176426, "code": "gst_chop_my_data_process (GstChopMyData * chopmydata, gboolean flush)\n{\n GstFlowReturn ret = GST_FLOW_OK;\n GstBuffer *buffer;\n\n if (chopmydata->next_size == 0) {\n get_next_size (chopmydata);\n }\n\n while (gst_adapter_available (chopmydata->adapter) >= chopmydata->next_size) {\n buffer =\n gst_adapter_take_buffer (chopmydata->adapter, chopmydata->next_size);\n\n chopmydata->next_size = 0;\n\n ret = gst_pad_push (chopmydata->srcpad, buffer);\n if (ret != GST_FLOW_OK) {\n return ret;\n }\n\n get_next_size (chopmydata);\n }\n\n if (flush) {\n guint min_size = chopmydata->min_size;\n\n while (gst_adapter_available (chopmydata->adapter) >= min_size) {\n buffer = gst_adapter_take_buffer (chopmydata->adapter, min_size);\n ret = gst_pad_push (chopmydata->srcpad, buffer);\n if (ret != GST_FLOW_OK)\n break;\n }\n gst_adapter_clear (chopmydata->adapter);\n }\n\n return ret;\n}", "label": 0, "cwe": null, "length": 263 }, { "index": 105718, "code": "emit_tputd_trmsg(struct tedputp_t *tedp, struct tfarg_t *tfap)\n{ \n word32 *ap, *bp;\n struct tfrec_t *tfrp;\n struct expr_t *lhsxp;\n char s1[RECLEN], s2[IDLEN];\n\n lhsxp = tfap->arg.axp;\n if (tfap->anp->ntyp >= NONWIRE_ST) strcpy(s1, \"procedural\");\n else\n {\n if (lhsxp->x_multfi) strcpy(s1, \"continuous fi>1\");\n else strcpy(s1, \"continuous fi=1\");\n }\n tfrp = tedp->tedtfrp;\n if (lhsxp->x_stren)\n __st_regab_tostr(s2, (byte *) tedp->tedwp, lhsxp->szu.xclen);\n else\n { \n ap = tedp->tedwp;\n bp = &(ap[wlen_(lhsxp->szu.xclen)]);\n __regab_tostr(s2, ap, bp, lhsxp->szu.xclen, BHEX, FALSE);\n }\n __evtr_resume_msg();\n __tr_msg(\"tf_ arg %d at %s in %s strdelputp %s assign value %s\\n\",\n tedp->tedpnum, __bld_lineloc(__wrks1, tfrp->tffnam_ind, tfrp->tflin_cnt),\n __msg2_blditree(__wrks2, __inst_ptr), s1, s2);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 339 }, { "index": 400193, "code": "paint_toptext() // new v.11.07\n{\n int ii, px, py;\n\n for (ii = 0; ii < Ntoptext; ii++) {\n px = toptext[ii].px;\n py = toptext[ii].py;\n px = Mscale * (px - Iorgx) + Dorgx; // image to window space\n py = Mscale * (py - Iorgy) + Dorgy;\n paint_text(px,py,toptext[ii].text,toptext[ii].font);\n }\n\n return;\n}", "label": 0, "cwe": null, "length": 133 }, { "index": 39332, "code": "f_ftell(VALUE *vp)\n{\n\tVALUE result;\n\tZVALUE pos;\t\t/* current file position */\n\tint i;\n\n\t/* initialize VALUE */\n\tresult.v_subtype = V_NOSUBTYPE;\n\n\terrno = 0;\n\tif (vp->v_type != V_FILE)\n\t\treturn error_value(E_FTELL1);\n\ti = ftellid(vp->v_file, &pos);\n\tif (i < 0)\n\t\treturn error_value(E_FTELL2);\n\n\tresult.v_type = V_NUM;\n\tresult.v_num = qalloc();\n\tresult.v_num->num = pos;\n\treturn result;\n}", "label": 0, "cwe": null, "length": 124 }, { "index": 820558, "code": "setData(const gchar * pszFont,float fAlign,float fIndent)\n{\n\t//\n\t// we draw at 16 points in this preview\n\t//\n\tif(!pszFont || strcmp(pszFont,\"NULL\")== 0)\n\t{\n\t\tm_pFont = m_gc->findFont(\"Times New Roman\",\n\t\t\t\t\t\t\t\t \"normal\", \"\", \"normal\",\n\t\t\t\t\t\t\t\t \"\", \"16pt\", NULL);\n\t}\n\telse\n\t{\n\t\tm_pFont = m_gc->findFont((char *)pszFont, \"normal\", \"\", \"normal\",\n\t\t\t\t\t\t\t\t \"\", \"16pt\", NULL);\n\t}\t\n\tUT_ASSERT_HARMLESS(m_pFont);\n\t\n\tm_fAlign = fAlign;\n\tm_fIndent = fIndent;\n}", "label": 0, "cwe": null, "length": 145 }, { "index": 923346, "code": "config_append_ipv4(DBusMessageIter *iter,\n\t\tvoid *user_data)\n{\n\tstruct config_append *append = user_data;\n\tchar **opts = append->opts;\n\tint i = 0;\n\n\tif (opts == NULL)\n\t\treturn;\n\n\twhile (opts[i] != NULL && ipv4[i] != NULL) {\n\t\t__connmanctl_dbus_append_dict_entry(iter, ipv4[i],\n\t\t\t\tDBUS_TYPE_STRING, &opts[i]);\n\t\ti++;\n\t}\n\n\tappend->values = i;\n}", "label": 0, "cwe": null, "length": 106 }, { "index": 89199, "code": "s48_inet_ntop(s48_call_t call, s48_ref_t sch_af, s48_ref_t sch_src)\n{\n sa_family_t af = s48_extract_af(call, sch_af);\n\n switch (af)\n {\n case AF_INET:\n {\n\tchar dest[INET_ADDRSTRLEN+1]; /* be safe */\n\tstruct in_addr addr;\n\textract_in_addr(call, sch_src, &addr);\n#ifdef _WIN32\n\t{\n\t DWORD destlen;\n\t if (WSAAddressToString((struct sockaddr *)&addr, sizeof(struct in_addr),\n\t\t\t\t NULL, dest, &destlen) != 0)\n\t s48_os_error_2(call, \"s48_inet_ntop\", WSAGetLastError(), 2, sch_af, sch_src);\n\t}\n\t \n#else\n\tif (inet_ntop(AF_INET, &addr, dest, sizeof(dest)) == NULL)\n\t s48_os_error_2(call, \"s48_inet_ntop\", errno, 2, sch_af, sch_src);\n#endif\n\treturn s48_enter_string_latin_1_2(call, dest);\n }\n case AF_INET6:\n {\n\tchar dest[INET6_ADDRSTRLEN+1]; /* be safe */\n\tstruct in6_addr addr;\n\ts48_extract_in6_addr(call, sch_src, &addr);\n#ifdef _WIN32\n\t{\n\t DWORD destlen;\n\t if (WSAAddressToString((struct sockaddr *)&addr, sizeof(struct in6_addr),\n\t\t\t\t NULL, dest, &destlen) != 0)\n\t s48_os_error_2(call, \"s48_inet_ntop\", WSAGetLastError(), 2, sch_af, sch_src);\n\t}\n#else\n\tif (inet_ntop(AF_INET6, &addr, dest, sizeof(dest)) == NULL)\n\t s48_os_error_2(call, \"s48_inet_ntop\", errno, 2, sch_af, sch_src);\n#endif\n\treturn s48_enter_string_latin_1_2(call, dest);\n }\n default:\n s48_assertion_violation_2(call, \"s48_inet_ntop\", \"invalid adddress family\", 1, sch_af);\n }\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 460 }, { "index": 36082, "code": "match_futex(union futex_key *key1, union futex_key *key2)\n{\n\treturn (key1 && key2\n\t\t&& key1->both.word == key2->both.word\n\t\t&& key1->both.ptr == key2->both.ptr\n\t\t&& key1->both.offset == key2->both.offset);\n}", "label": 0, "cwe": null, "length": 76 }, { "index": 784897, "code": "proxy_map_location(request_rec *r)\n{\n int access_status;\n\n if (!r->proxyreq || !r->filename || strncmp(r->filename, \"proxy:\", 6) != 0)\n return DECLINED;\n\n /* Don't let the core or mod_http map_to_storage hooks handle this,\n * We don't need directory/file_walk, and we want to TRACE on our own.\n */\n if ((access_status = proxy_walk(r))) {\n ap_die(access_status, r);\n return access_status;\n }\n\n return OK;\n}", "label": 0, "cwe": null, "length": 117 }, { "index": 764678, "code": "Fetch()\n{\n if(!m_Collection)\n {\n std::cerr << \"Collection::Fetch() : Collection not set\" << std::endl;\n return false;\n }\n\n if(m_Collection->IsFetched())\n {\n return true;\n }\n \n if(!m_Collection->GetId())\n {\n std::cerr << \"Collection::Fetch() : Collection id not set\" << std::endl;\n return false;\n }\n \n CollectionXMLParser parser;\n parser.SetCollection(m_Collection);\n m_Collection->Clear();\n parser.AddTag(\"/rsp/name\",m_Collection->GetName());\n parser.AddTag(\"/rsp/description\",m_Collection->GetDescription());\n parser.AddTag(\"/rsp/uuid\",m_Collection->GetUuid());\n parser.AddTag(\"/rsp/parent\",m_Collection->GetParent());\n \n m_WebAPI->GetRestAPI()->SetXMLParser(&parser);\n \n std::stringstream url;\n url << \"midas.collection.get?id=\" << m_Collection->GetId();\n if(!m_WebAPI->Execute(url.str().c_str()))\n {\n std::cout << m_WebAPI->GetErrorMessage() << std::endl;\n return false;\n }\n m_Collection->SetFetched(true);\n return true;\n}", "label": 0, "cwe": null, "length": 279 }, { "index": 539575, "code": "RemoveUploadingClient(CUpDownClient* client)\n{\n\tif (m_ClientUploadList.erase(CCLIENTREF(client, wxEmptyString))) {\n\t\tNotify_SharedCtrlRemoveClient(client->ECID(), this);\n\t\tUpdateAutoUpPriority();\n\t}\n}", "label": 0, "cwe": null, "length": 53 }, { "index": 570610, "code": "axio_flush(ax25io *p)\n{\n\tint flushed = 0;\n\tint ret;\n\n#ifdef HAVE_ZLIB_H\n\tif (p->zptr) {\n\t\tstruct compr_s *z = (struct compr_s *) p->zptr;\n\t\tint ret;\n\n\t\t/*\n\t\t * Fail immediately if there has been an error in\n\t\t * compression or decompression.\n\t\t */\n\t\tif (z->z_error) {\n\t\t\terrno = z->z_error;\n\t\t\treturn -1;\n\t\t}\n\t\t/*\n\t\t * No new input, just flush the compression block.\n\t\t */\n\t\tz->zout.next_in = NULL;\n\t\tz->zout.avail_in = 0;\n\t\tdo {\n\t\t\t/* Adjust the output pointers */\n\t\t\tz->zout.next_out = p->obuf + p->optr;\n\t\t\tz->zout.avail_out = p->paclen - p->optr;\n\n\t\t\tret = deflate(&z->zout, Z_PARTIAL_FLUSH);\n\t\t\tp->optr = p->paclen - z->zout.avail_out;\n\n\t\t\tswitch (ret) {\n\t\t\tcase Z_OK:\n\t\t\t\t/* All OK */\n\t\t\t\tbreak;\n\t\t\tcase Z_BUF_ERROR:\n\t\t\t\t/*\n\t\t\t\t * Progress not possible, it's been\n\t\t\t\t * flushed already (I hope).\n\t\t\t\t */\n\t\t\t\tbreak;\n\t\t\tcase Z_STREAM_END:\n\t\t\t\t/* What ??? */\n\t\t\t\terrno = z->z_error = ZERR_STREAM_END;\n\t\t\t\treturn -1;\n\t\t\tcase Z_STREAM_ERROR:\n\t\t\t\t/* Something strange */\n\t\t\t\terrno = z->z_error = ZERR_STREAM_ERROR;\n\t\t\t\treturn -1;\n\t\t\tdefault:\n\t\t\t\terrno = z->z_error = ZERR_UNKNOWN;\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\t/*\n\t\t\t * If output buffer is full, flush it to make room\n\t\t\t * for more compressed data.\n\t\t\t */\n\t\t\tif (z->zout.avail_out == 0 && flush_obuf(p) < 0)\n\t\t\t\treturn -1;\n\n\t\t} while (z->zout.avail_out == 0);\n\t}\n#endif\n\n\twhile (p->optr) {\n\t\t/* Return on error or if zero bytes written */\n\t\tif ((ret = flush_obuf(p)) <= 0)\n\t\t\treturn -1;\n\t\tflushed += ret;\n\t}\n\n\treturn flushed;\n}", "label": 0, "cwe": null, "length": 491 }, { "index": 961318, "code": "sh_tmu_clock_event_start(struct sh_tmu_channel *ch, int periodic)\n{\n\tstruct clock_event_device *ced = &ch->ced;\n\n\tsh_tmu_enable(ch);\n\n\tclockevents_config(ced, ch->rate);\n\n\tif (periodic) {\n\t\tch->periodic = (ch->rate + HZ/2) / HZ;\n\t\tsh_tmu_set_next(ch, ch->periodic, 1);\n\t}\n}", "label": 0, "cwe": null, "length": 92 }, { "index": 708361, "code": "own_item(struct module *m, struct Item *i, struct Item *c)\n{\n if(i->owner)\n return NULL;\n i->owner = m;\n i->mod_chain = c;\n i->flags &= ~DISABLED;\n redraw_item(i, i->win);\n return i;\n}", "label": 0, "cwe": null, "length": 67 }, { "index": 27408, "code": "s6e8aa0_power_on(struct s6e8aa0 *ctx)\n{\n\tint ret;\n\n\tret = regulator_bulk_enable(ARRAY_SIZE(ctx->supplies), ctx->supplies);\n\tif (ret < 0)\n\t\treturn ret;\n\n\tmsleep(ctx->power_on_delay);\n\n\tgpiod_set_value(ctx->reset_gpio, 0);\n\tusleep_range(10000, 11000);\n\tgpiod_set_value(ctx->reset_gpio, 1);\n\n\tmsleep(ctx->reset_delay);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 109 }, { "index": 698126, "code": "gfm_server_bequeath_fd(struct peer *peer, int from_client, int skip)\n{\n\tgfarm_int32_t e;\n\tstruct host *spool_host;\n\tstruct process *process;\n\tgfarm_int32_t fd;\n\tstatic const char diag[] = \"GFM_PROTO_BEQUEATH_FD\";\n\n\tif (skip)\n\t\treturn (GFARM_ERR_NO_ERROR);\n\tgiant_lock();\n\n\tif (!from_client && (spool_host = peer_get_host(peer)) == NULL) {\n\t\tgflog_debug(GFARM_MSG_1001675,\n\t\t\t\"operation is not permitted \");\n\t\te = GFARM_ERR_OPERATION_NOT_PERMITTED;\n\t} else if ((process = peer_get_process(peer)) == NULL) {\n\t\tgflog_debug(GFARM_MSG_1001676,\n\t\t\t\"peer_get_process() failed\");\n\t\te = GFARM_ERR_OPERATION_NOT_PERMITTED;\n\t} else if ((e = peer_fdpair_get_current(peer, &fd)) !=\n\t GFARM_ERR_NO_ERROR) {\n\t\tgflog_debug(GFARM_MSG_1001677,\n\t\t\t\"peer_fdpair_get_current() failed\");\n\t} else\n\t\te = process_bequeath_fd(process, fd);\n\n\tgiant_unlock();\n\treturn (gfm_server_put_reply(peer, diag, e, \"\"));\n}", "label": 0, "cwe": null, "length": 269 }, { "index": 663075, "code": "maybe_remove_unreachable_handlers (void)\n{\n eh_landing_pad lp;\n unsigned i;\n\n if (cfun->eh == NULL)\n return;\n \n FOR_EACH_VEC_SAFE_ELT (cfun->eh->lp_array, i, lp)\n if (lp && lp->post_landing_pad)\n {\n\tif (label_to_block (lp->post_landing_pad) == NULL)\n\t {\n\t remove_unreachable_handlers ();\n\t return;\n\t }\n }\n}", "label": 0, "cwe": null, "length": 102 }, { "index": 438321, "code": "dl_avail_chunk_new(filesize_t from, filesize_t to, size_t sources)\n{\n\tstruct dl_avail_chunk *ac;\n\n\tg_assert(from < to);\n\tg_assert(size_is_positive(sources));\n\n\tac = dl_avail_chunk_alloc();\n\tac->from = from;\n\tac->to = to;\n\tac->sources = sources;\n\treturn ac;\n}", "label": 0, "cwe": null, "length": 69 }, { "index": 911085, "code": "ocfs2_lock_xattr_remove_allocators(struct inode *inode,\n\t\t\t\t\tstruct ocfs2_xattr_value_root *xv,\n\t\t\t\t\tstruct ocfs2_caching_info *ref_ci,\n\t\t\t\t\tstruct buffer_head *ref_root_bh,\n\t\t\t\t\tstruct ocfs2_alloc_context **meta_ac,\n\t\t\t\t\tint *ref_credits)\n{\n\tint ret, meta_add = 0;\n\tu32 p_cluster, num_clusters;\n\tunsigned int ext_flags;\n\n\t*ref_credits = 0;\n\tret = ocfs2_xattr_get_clusters(inode, 0, &p_cluster,\n\t\t\t\t &num_clusters,\n\t\t\t\t &xv->xr_list,\n\t\t\t\t &ext_flags);\n\tif (ret) {\n\t\tmlog_errno(ret);\n\t\tgoto out;\n\t}\n\n\tif (!(ext_flags & OCFS2_EXT_REFCOUNTED))\n\t\tgoto out;\n\n\tret = ocfs2_refcounted_xattr_delete_need(inode, ref_ci,\n\t\t\t\t\t\t ref_root_bh, xv,\n\t\t\t\t\t\t &meta_add, ref_credits);\n\tif (ret) {\n\t\tmlog_errno(ret);\n\t\tgoto out;\n\t}\n\n\tret = ocfs2_reserve_new_metadata_blocks(OCFS2_SB(inode->i_sb),\n\t\t\t\t\t\tmeta_add, meta_ac);\n\tif (ret)\n\t\tmlog_errno(ret);\n\nout:\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 262 }, { "index": 86053, "code": "objc_common_type (tree type1, tree type2)\n{\n tree inner1 = TREE_TYPE (type1), inner2 = TREE_TYPE (type2);\n\n while (POINTER_TYPE_P (inner1))\n {\n inner1 = TREE_TYPE (inner1);\n inner2 = TREE_TYPE (inner2);\n }\n\n /* If one type is derived from another, return the base type. */\n if (DERIVED_FROM_P (inner1, inner2))\n return type1;\n else if (DERIVED_FROM_P (inner2, inner1))\n return type2;\n\n /* If both types are 'Class', return 'Class'. */\n if (objc_is_class_id (inner1) && objc_is_class_id (inner2))\n return objc_class_type;\n\n /* Otherwise, return 'id'. */\n return objc_object_type;\n}", "label": 0, "cwe": null, "length": 183 }, { "index": 371132, "code": "ReadReg(avmcard *card, u32 reg)\n{\n\tu8 cmd = 0x01;\n\tif (b1dma_tolink(card, &cmd, 1) == 0\n\t && b1dma_tolink(card, ®, 4) == 0) {\n\t\tu32 tmp;\n\t\tif (b1dma_fromlink(card, &tmp, 4) == 0)\n\t\t\treturn (u8)tmp;\n\t}\n\treturn 0xff;\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 733387, "code": "x11ImageAttach( x11Image *image,\n void **ret_addr )\n{\n void *addr;\n\n D_MAGIC_ASSERT( image, x11Image );\n D_ASSERT( ret_addr != NULL );\n\n /* FIXME: We also need to DETACH! */\n\n addr = shmat( image->seginfo.shmid, NULL, 0 );\n if (!addr) {\n int erno = errno;\n\n D_PERROR( \"X11/Image: shmat( %d ) failed!\\n\", image->seginfo.shmid );\n\n return errno2result( erno );\n }\n\n *ret_addr = addr;\n\n return DFB_OK;\n}", "label": 0, "cwe": null, "length": 141 }, { "index": 729954, "code": "smem_open(char *filename, int rwmode, int *driverhandle)\n { int h, nitems, r;\n DAL_SHM_SEGHEAD *sp;\n\n\n if (NULL == filename) return(SHARED_NULPTR);\n if (NULL == driverhandle) return(SHARED_NULPTR);\n nitems = sscanf(filename, \"h%d\", &h);\n if (1 != nitems) return(SHARED_BADARG);\n\n if (SHARED_OK != (r = shared_attach(h))) return(r);\n\n if (NULL == (sp = (DAL_SHM_SEGHEAD *)shared_lock(h,\n ((READWRITE == rwmode) ? SHARED_RDWRITE : SHARED_RDONLY))))\n { shared_free(h);\n return(SHARED_BADARG);\n }\n\n if ((h != sp->h) || (DAL_SHM_SEGHEAD_ID != sp->ID))\n { shared_unlock(h);\n shared_free(h);\n\n return(SHARED_BADARG);\n }\n\n *driverhandle = h;\n return(0);\n }", "label": 0, "cwe": null, "length": 222 }, { "index": 93059, "code": "a_pp_deref(pTHX) {\n dA_MAP_THX;\n const a_op_info *oi;\n UV flags;\n dSP;\n\n oi = a_map_fetch(PL_op);\n\n flags = oi->flags;\n if (flags & A_HINT_DEREF) {\n OP *o;\n\n o = oi->old_pp(aTHX);\n\n if (flags & (A_HINT_NOTIFY|A_HINT_STORE)) {\n SPAGAIN;\n if (a_undef(TOPs)) {\n if (flags & A_HINT_STRICT)\n croak(\"Reference vivification forbidden\");\n else if (flags & A_HINT_WARN)\n warn(\"Reference was vivified\");\n else /* A_HINT_STORE */\n croak(\"Can't vivify reference\");\n }\n }\n\n return o;\n }\n\n return oi->old_pp(aTHX);\n}", "label": 0, "cwe": null, "length": 173 }, { "index": 575598, "code": "abook_select_tool(struct pine *ps, int cmd, CONF_S **cl, unsigned int flags)\n{\n int retval;\n\n switch(cmd){\n case MC_CHOICE :\n\t*((*cl)->d.b.selected) = cpystr((*cl)->d.b.abookname);\n\tretval = simple_exit_cmd(flags);\n\tbreak;\n\n case MC_EXIT :\n retval = simple_exit_cmd(flags);\n\tbreak;\n\n default:\n\tretval = -1;\n\tbreak;\n }\n\n if(retval > 0)\n ps->mangled_body = 1;\n\n return(retval);\n}", "label": 0, "cwe": null, "length": 117 }, { "index": 34677, "code": "com90xx_copy_from_card(struct net_device *dev, int bufnum,\n\t\t\t\t int offset, void *buf, int count)\n{\n\tstruct arcnet_local *lp = netdev_priv(dev);\n\tvoid __iomem *memaddr = lp->mem_start + bufnum * 512 + offset;\n\n\tTIME(dev, \"memcpy_fromio\", count, memcpy_fromio(buf, memaddr, count));\n}", "label": 0, "cwe": null, "length": 84 }, { "index": 55574, "code": "show_window(int img, char *label, double fraction)\n{\n char *m_label;\n char *u_label;\n\n GtkWidget *window = mbp_w.window;\n\n if (img >= IMG_NIMG)\n return;\n\n /* Cancel timer */\n if (mbp_w.timer > 0)\n g_source_remove(mbp_w.timer);\n\n if (!GTK_WIDGET_VISIBLE(window))\n draw_window_bg();\n\n /* Put the appropriate image in there */\n if (mbp_w.image != theme.images[img])\n {\n if (mbp_w.image != NULL)\n\tgtk_container_remove(GTK_CONTAINER(mbp_w.img_align), mbp_w.image);\n\n gtk_container_add(GTK_CONTAINER(mbp_w.img_align), theme.images[img]);\n }\n\n mbp_w.image = theme.images[img];\n\n /* Set the text label */\n u_label = g_locale_to_utf8(label, -1, NULL, NULL, NULL);\n\n if (u_label == NULL)\n m_label = \"\";\n else /* accepts only UTF-8 input ... segfaults otherwise */\n m_label = g_markup_printf_escaped(\"%s\", u_label);\n\n gtk_label_set_markup(GTK_LABEL(mbp_w.label), m_label);\n\n if (u_label != NULL)\n {\n g_free(u_label);\n g_free(m_label);\n }\n\n /* Set the progress bar */\n if (fraction >= 0.0)\n {\n gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(mbp_w.pbar), fraction);\n\n if (!mbp_w.pbar_state)\n\t{\n\t gtk_container_add(GTK_CONTAINER(mbp_w.pbar_align), mbp_w.pbar);\n\t mbp_w.pbar_state = 1;\n\t}\n }\n else if (mbp_w.pbar_state)\n {\n gtk_container_remove(GTK_CONTAINER(mbp_w.pbar_align), mbp_w.pbar);\n mbp_w.pbar_state = 0;\n }\n\n gtk_widget_show_all(window);\n\n mbp_w.timer = g_timeout_add(mbp_w.timeout, hide_window, NULL);\n}", "label": 0, "cwe": null, "length": 441 }, { "index": 443279, "code": "format(MSString& aString_,const MSFormat& aFormat_) const\n{\n return (aFormat_.formatType()==MSFormat::Int)?\n formatUnsigned(aString_,aFormat_.intFormat(),aFormat_.formatModifier(),_unsigned):format(aString_,MSInt::WithoutCommas);\n}", "label": 0, "cwe": null, "length": 66 }, { "index": 534474, "code": "krb5_dbe_free_strings(krb5_context context, krb5_string_attr *strings,\n int count)\n{\n int i;\n\n if (strings == NULL)\n return;\n for (i = 0; i < count; i++) {\n free(strings[i].key);\n free(strings[i].value);\n }\n free(strings);\n}", "label": 0, "cwe": null, "length": 76 }, { "index": 898045, "code": "client3_3_opendir (call_frame_t *frame, xlator_t *this,\n void *data)\n{\n clnt_local_t *local = NULL;\n clnt_conf_t *conf = NULL;\n clnt_args_t *args = NULL;\n gfs3_opendir_req req = {{0,},};\n int ret = 0;\n int op_errno = ESTALE;\n\n if (!frame || !this || !data)\n goto unwind;\n\n args = data;\n\n local = mem_get0 (this->local_pool);\n if (!local) {\n op_errno = ENOMEM;\n goto unwind;\n }\n if (!(args->loc && args->loc->inode))\n goto unwind;\n\n local->fd = fd_ref (args->fd);\n loc_copy (&local->loc, args->loc);\n frame->local = local;\n\n if (!uuid_is_null (args->loc->inode->gfid))\n memcpy (req.gfid, args->loc->inode->gfid, 16);\n else\n memcpy (req.gfid, args->loc->gfid, 16);\n\n GF_ASSERT_AND_GOTO_WITH_ERROR (this->name,\n !uuid_is_null (*((uuid_t*)req.gfid)),\n unwind, op_errno, EINVAL);\n\n conf = this->private;\n\n GF_PROTOCOL_DICT_SERIALIZE (this, args->xdata, (&req.xdata.xdata_val),\n req.xdata.xdata_len, op_errno, unwind);\n\n ret = client_submit_request (this, &req, frame, conf->fops,\n GFS3_OP_OPENDIR, client3_3_opendir_cbk,\n NULL, NULL, 0, NULL, 0, NULL,\n (xdrproc_t)xdr_gfs3_opendir_req);\n if (ret) {\n gf_log (this->name, GF_LOG_WARNING, \"failed to send the fop\");\n }\n\n GF_FREE (req.xdata.xdata_val);\n\n return 0;\n\nunwind:\n CLIENT_STACK_UNWIND (opendir, frame, -1, op_errno, NULL, NULL);\n\n GF_FREE (req.xdata.xdata_val);\n\n return 0;\n}", "label": 1, "cwe": [ "CWE-120", "CWE-476" ], "length": 480 }, { "index": 100674, "code": "xmlSecGnuTLSConvertParamsToMpis(gnutls_datum_t * params, xmlSecSize paramsNum,\n gcry_mpi_t * mpis, xmlSecSize mpisNum) {\n\n xmlSecSize ii;\n int rc;\n\n xmlSecAssert2(params != NULL, -1);\n xmlSecAssert2(mpis != NULL, -1);\n xmlSecAssert2(paramsNum == mpisNum, -1);\n\n for(ii = 0; ii < paramsNum; ++ii) {\n rc = gcry_mpi_scan(&(mpis[ii]), GCRYMPI_FMT_USG, params[ii].data, params[ii].size, NULL);\n if((rc != GPG_ERR_NO_ERROR) || (mpis[ii] == NULL)) {\n xmlSecError(XMLSEC_ERRORS_HERE,\n NULL,\n \"gcry_mpi_scan\",\n XMLSEC_ERRORS_R_CRYPTO_FAILED,\n XMLSEC_GNUTLS_GCRYPT_REPORT_ERROR(rc));\n xmlSecGnuTLSDestroyMpis(mpis, ii); /* destroy up to now */\n return(-1);\n }\n }\n\n /* done */\n return(0);\n}", "label": 0, "cwe": null, "length": 241 }, { "index": 1299, "code": "setEdgeType (graph_t* g, int dflt)\n{\n char* s = agget(g, \"splines\");\n int et;\n\n if (!s) {\n\tet = dflt;\n }\n else if (*s == '\\0') {\n\tet = ET_NONE;\n }\n else et = edgeType (s, dflt);\n GD_flags(g) |= et;\n}", "label": 0, "cwe": null, "length": 85 }, { "index": 102632, "code": "inline_conditional (NODE_T * p, FILE_T out, int phase)\n{\n NODE_T * if_part = NO_NODE, * then_part = NO_NODE, * else_part = NO_NODE;\n p = SUB (p);\n if (IS (p, IF_PART) || IS (p, OPEN_PART)) {\n if_part = p;\n } else {\n ABEND (A68_TRUE, \"if-part expected\", NO_TEXT);\n }\n FORWARD (p);\n if (IS (p, THEN_PART) || IS (p, CHOICE)) {\n then_part = p;\n } else {\n ABEND (A68_TRUE, \"then-part expected\", NO_TEXT);\n }\n FORWARD (p);\n if (IS (p, ELSE_PART) || IS (p, CHOICE)) {\n else_part = p;\n } else {\n else_part = NO_NODE;\n }\n if (phase == L_DECLARE) {\n inline_unit (SUB (NEXT_SUB (if_part)), out, L_DECLARE);\n inline_unit (SUB (NEXT_SUB (then_part)), out, L_DECLARE);\n inline_unit (SUB (NEXT_SUB (else_part)), out, L_DECLARE);\n } else if (phase == L_EXECUTE) {\n inline_unit (SUB (NEXT_SUB (if_part)), out, L_EXECUTE);\n inline_unit (SUB (NEXT_SUB (then_part)), out, L_EXECUTE);\n inline_unit (SUB (NEXT_SUB (else_part)), out, L_EXECUTE);\n } else if (phase == L_YIELD) {\n undent (out, \"(\");\n inline_unit (SUB (NEXT_SUB (if_part)), out, L_YIELD);\n undent (out, \" ? \");\n inline_unit (SUB (NEXT_SUB (then_part)), out, L_YIELD);\n undent (out, \" : \");\n if (else_part != NO_NODE) {\n inline_unit (SUB (NEXT_SUB (else_part)), out, L_YIELD);\n } else {\n/*\nThis is not an ideal solution although RR permits it;\nan omitted else-part means SKIP: yield some value of the\nmode required.\n*/\n inline_unit (SUB (NEXT_SUB (then_part)), out, L_YIELD);\n }\n undent (out, \")\");\n }\n}", "label": 0, "cwe": null, "length": 478 }, { "index": 176456, "code": "jl_get_specialization(jl_function_t *f, jl_tuple_t *types)\n{\n assert(jl_is_gf(f));\n if (!jl_is_leaf_type((jl_value_t*)types))\n return NULL;\n jl_methtable_t *mt = jl_gf_mtable(f);\n jl_function_t *sf = jl_method_lookup_by_type(mt, types, 1);\n if (sf == NULL) {\n return NULL;\n }\n if (sf->linfo == NULL || sf->linfo->ast == NULL) {\n return NULL;\n }\n if (sf->linfo->inInference) return NULL;\n if (sf->linfo->functionObject == NULL) {\n if (sf->fptr != &jl_trampoline)\n return NULL;\n jl_compile(sf);\n }\n return sf;\n}", "label": 0, "cwe": null, "length": 177 }, { "index": 35914, "code": "queryDeriver(const Path & path)\n{\n return queryPathInfo(path).deriver;\n}", "label": 0, "cwe": null, "length": 21 }, { "index": 637747, "code": "do_ncp_rpc_call(struct ncp_server *server, int size,\n\t\tunsigned char* reply_buf, int max_reply_size)\n{\n\tint result;\n\tstruct ncp_request_reply *req;\n\n\treq = ncp_alloc_req();\n\tif (!req)\n\t\treturn -ENOMEM;\n\n\treq->reply_buf = reply_buf;\n\treq->datalen = max_reply_size;\n\treq->tx_iov[1].iov_base = server->packet;\n\treq->tx_iov[1].iov_len = size;\n\treq->tx_iovlen = 1;\n\treq->tx_totallen = size;\n\treq->tx_type = *(u_int16_t*)server->packet;\n\n\tresult = ncp_add_request(server, req);\n\tif (result < 0)\n\t\tgoto out;\n\n\tif (wait_event_interruptible(req->wq, req->status == RQ_DONE)) {\n\t\tncp_abort_request(server, req, -EINTR);\n\t\tresult = -EINTR;\n\t\tgoto out;\n\t}\n\n\tresult = req->result;\n\nout:\n\tncp_req_put(req);\n\n\treturn result;\n}", "label": 0, "cwe": null, "length": 221 }, { "index": 172367, "code": "add_numbered_child(unsigned mod_no, const char *name, int num,\n\t\tvoid *pdata, unsigned pdata_len,\n\t\tbool can_wakeup, int irq0, int irq1)\n{\n\tstruct platform_device\t*pdev;\n\tstruct twl_client\t*twl;\n\tint\t\t\tstatus, sid;\n\n\tif (unlikely(mod_no >= twl_get_last_module())) {\n\t\tpr_err(\"%s: invalid module number %d\\n\", DRIVER_NAME, mod_no);\n\t\treturn ERR_PTR(-EPERM);\n\t}\n\tsid = twl_priv->twl_map[mod_no].sid;\n\ttwl = &twl_priv->twl_modules[sid];\n\n\tpdev = platform_device_alloc(name, num);\n\tif (!pdev) {\n\t\tdev_dbg(&twl->client->dev, \"can't alloc dev\\n\");\n\t\tstatus = -ENOMEM;\n\t\tgoto err;\n\t}\n\n\tpdev->dev.parent = &twl->client->dev;\n\n\tif (pdata) {\n\t\tstatus = platform_device_add_data(pdev, pdata, pdata_len);\n\t\tif (status < 0) {\n\t\t\tdev_dbg(&pdev->dev, \"can't add platform_data\\n\");\n\t\t\tgoto err;\n\t\t}\n\t}\n\n\tif (irq0) {\n\t\tstruct resource r[2] = {\n\t\t\t{ .start = irq0, .flags = IORESOURCE_IRQ, },\n\t\t\t{ .start = irq1, .flags = IORESOURCE_IRQ, },\n\t\t};\n\n\t\tstatus = platform_device_add_resources(pdev, r, irq1 ? 2 : 1);\n\t\tif (status < 0) {\n\t\t\tdev_dbg(&pdev->dev, \"can't add irqs\\n\");\n\t\t\tgoto err;\n\t\t}\n\t}\n\n\tstatus = platform_device_add(pdev);\n\tif (status == 0)\n\t\tdevice_init_wakeup(&pdev->dev, can_wakeup);\n\nerr:\n\tif (status < 0) {\n\t\tplatform_device_put(pdev);\n\t\tdev_err(&twl->client->dev, \"can't add %s dev\\n\", name);\n\t\treturn ERR_PTR(status);\n\t}\n\treturn &pdev->dev;\n}", "label": 0, "cwe": null, "length": 436 }, { "index": 120749, "code": "ipa_get_indirect_edge_target (struct cgraph_edge *ie,\n\t\t\t VEC (tree, heap) *known_vals,\n\t\t\t VEC (tree, heap) *known_binfos)\n{\n int param_index = ie->indirect_info->param_index;\n HOST_WIDE_INT token, anc_offset;\n tree otr_type;\n tree t;\n\n if (param_index == -1)\n return NULL_TREE;\n\n if (!ie->indirect_info->polymorphic)\n {\n tree t = (VEC_length (tree, known_vals) > (unsigned int) param_index\n\t ? VEC_index (tree, known_vals, param_index) : NULL);\n if (t &&\n\t TREE_CODE (t) == ADDR_EXPR\n\t && TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL)\n\treturn TREE_OPERAND (t, 0);\n else\n\treturn NULL_TREE;\n }\n\n token = ie->indirect_info->otr_token;\n anc_offset = ie->indirect_info->anc_offset;\n otr_type = ie->indirect_info->otr_type;\n\n t = VEC_index (tree, known_vals, param_index);\n if (!t && known_binfos\n && VEC_length (tree, known_binfos) > (unsigned int) param_index)\n t = VEC_index (tree, known_binfos, param_index);\n if (!t)\n return NULL_TREE;\n\n if (TREE_CODE (t) != TREE_BINFO)\n {\n tree binfo;\n binfo = gimple_extract_devirt_binfo_from_cst (t);\n if (!binfo)\n\treturn NULL_TREE;\n binfo = get_binfo_at_offset (binfo, anc_offset, otr_type);\n if (!binfo)\n\treturn NULL_TREE;\n return gimple_get_virt_method_for_binfo (token, binfo);\n }\n else\n {\n tree binfo;\n\n binfo = get_binfo_at_offset (t, anc_offset, otr_type);\n if (!binfo)\n\treturn NULL_TREE;\n return gimple_get_virt_method_for_binfo (token, binfo);\n }\n}", "label": 0, "cwe": null, "length": 458 }, { "index": 281276, "code": "qtdemux_tree_get_sibling_by_type_full (GNode * node, guint32 fourcc,\n GstByteReader * parser)\n{\n GNode *child;\n guint8 *buffer;\n guint32 child_fourcc, child_len;\n\n for (child = g_node_next_sibling (node); child;\n child = g_node_next_sibling (child)) {\n buffer = (guint8 *) child->data;\n\n child_fourcc = QT_FOURCC (buffer + 4);\n\n if (child_fourcc == fourcc) {\n if (parser) {\n child_len = QT_UINT32 (buffer);\n if (G_UNLIKELY (child_len < (4 + 4)))\n return NULL;\n /* FIXME: must verify if atom length < parent atom length */\n gst_byte_reader_init (parser, buffer + (4 + 4), child_len - (4 + 4));\n }\n return child;\n }\n }\n return NULL;\n}", "label": 0, "cwe": null, "length": 205 }, { "index": 300786, "code": "sbp_run_transaction(struct fw_card *card, int tcode, int destination_id,\n\t\tint generation, int speed, unsigned long long offset,\n\t\tvoid *payload, size_t length)\n{\n\tint attempt, ret, delay;\n\n\tfor (attempt = 1; attempt <= 5; attempt++) {\n\t\tret = fw_run_transaction(card, tcode, destination_id,\n\t\t\t\tgeneration, speed, offset, payload, length);\n\n\t\tswitch (ret) {\n\t\tcase RCODE_COMPLETE:\n\t\tcase RCODE_TYPE_ERROR:\n\t\tcase RCODE_ADDRESS_ERROR:\n\t\tcase RCODE_GENERATION:\n\t\t\treturn ret;\n\n\t\tdefault:\n\t\t\tdelay = 5 * attempt * attempt;\n\t\t\tusleep_range(delay, delay * 2);\n\t\t}\n\t}\n\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 159 }, { "index": 93893, "code": "parse_options(int argc, const char *argv[])\n{\n\tenum request request = REQ_VIEW_MAIN;\n\tconst char *subcommand;\n\tbool seen_dashdash = FALSE;\n\tconst char **filter_argv = NULL;\n\tint i;\n\n\tif (!isatty(STDIN_FILENO))\n\t\treturn REQ_VIEW_PAGER;\n\n\tif (argc <= 1)\n\t\treturn REQ_VIEW_MAIN;\n\n\tsubcommand = argv[1];\n\tif (!strcmp(subcommand, \"status\")) {\n\t\tif (argc > 2)\n\t\t\twarn(\"ignoring arguments after `%s'\", subcommand);\n\t\treturn REQ_VIEW_STATUS;\n\n\t} else if (!strcmp(subcommand, \"blame\")) {\n\t\tif (argc <= 2 || argc > 4)\n\t\t\tdie(\"invalid number of options to blame\\n\\n%s\", usage);\n\n\t\ti = 2;\n\t\tif (argc == 4) {\n\t\t\tstring_ncopy(opt_ref, argv[i], strlen(argv[i]));\n\t\t\ti++;\n\t\t}\n\n\t\tstring_ncopy(opt_file, argv[i], strlen(argv[i]));\n\t\treturn REQ_VIEW_BLAME;\n\n\t} else if (!strcmp(subcommand, \"show\")) {\n\t\trequest = REQ_VIEW_DIFF;\n\n\t} else {\n\t\tsubcommand = NULL;\n\t}\n\n\tfor (i = 1 + !!subcommand; i < argc; i++) {\n\t\tconst char *opt = argv[i];\n\n\t\tif (seen_dashdash) {\n\t\t\targv_append(&opt_file_argv, opt);\n\t\t\tcontinue;\n\n\t\t} else if (!strcmp(opt, \"--\")) {\n\t\t\tseen_dashdash = TRUE;\n\t\t\tcontinue;\n\n\t\t} else if (!strcmp(opt, \"-v\") || !strcmp(opt, \"--version\")) {\n\t\t\tprintf(\"tig version %s\\n\", TIG_VERSION);\n\t\t\tquit(0);\n\n\t\t} else if (!strcmp(opt, \"-h\") || !strcmp(opt, \"--help\")) {\n\t\t\tprintf(\"%s\\n\", usage);\n\t\t\tquit(0);\n\n\t\t} else if (!strcmp(opt, \"--all\")) {\n\t\t\targv_append(&opt_rev_argv, opt);\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!argv_append(&filter_argv, opt))\n\t\t\tdie(\"command too long\");\n\t}\n\n\tif (filter_argv)\n\t\tfilter_options(filter_argv);\n\n\treturn request;\n}", "label": 0, "cwe": null, "length": 460 }, { "index": 60641, "code": "scsi_trace_rw10(struct trace_seq *p, unsigned char *cdb, int len)\n{\n\tconst char *ret = trace_seq_buffer_ptr(p);\n\tsector_t lba = 0, txlen = 0;\n\n\tlba |= (cdb[2] << 24);\n\tlba |= (cdb[3] << 16);\n\tlba |= (cdb[4] << 8);\n\tlba |= cdb[5];\n\ttxlen |= (cdb[7] << 8);\n\ttxlen |= cdb[8];\n\n\ttrace_seq_printf(p, \"lba=%llu txlen=%llu protect=%u\",\n\t\t\t (unsigned long long)lba, (unsigned long long)txlen,\n\t\t\t cdb[1] >> 5);\n\n\tif (cdb[0] == WRITE_SAME)\n\t\ttrace_seq_printf(p, \" unmap=%u\", cdb[1] >> 3 & 1);\n\n\ttrace_seq_putc(p, 0);\n\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 206 }, { "index": 491511, "code": "LoadBackgroundImage( IDirectFB *dfb,\n CoreWindowStack *stack,\n DFBConfigLayer *conf )\n{\n DFBResult ret;\n DFBSurfaceDescription desc;\n IDirectFBImageProvider *provider;\n IDirectFBSurface *image;\n IDirectFBSurface_data *image_data;\n\n ret = dfb->CreateImageProvider( dfb, conf->background.filename, &provider );\n if (ret) {\n D_DERROR( ret, \"Failed loading background image '%s'!\\n\", conf->background.filename );\n return;\n }\n\n if (conf->background.mode == DLBM_IMAGE) {\n desc.flags = DSDESC_WIDTH | DSDESC_HEIGHT;\n desc.width = conf->config.width;\n desc.height = conf->config.height;\n }\n else {\n provider->GetSurfaceDescription( provider, &desc );\n }\n\n desc.flags |= DSDESC_CAPS | DSDESC_PIXELFORMAT;\n desc.caps = DSCAPS_SHARED;\n desc.pixelformat = conf->config.pixelformat;\n\n ret = dfb->CreateSurface( dfb, &desc, &image );\n if (ret) {\n DirectFBError( \"Failed creating surface for background image\", ret );\n provider->Release( provider );\n return;\n }\n\n ret = provider->RenderTo( provider, image, NULL );\n if (ret) {\n DirectFBError( \"Failed loading background image\", ret );\n image->Release( image );\n provider->Release( provider );\n return;\n }\n\n provider->Release( provider );\n\n image_data = (IDirectFBSurface_data*) image->priv;\n\n dfb_windowstack_set_background_image( stack, image_data->surface );\n\n image->Release( image );\n}", "label": 0, "cwe": null, "length": 380 }, { "index": 37540, "code": "dyn_spank_set_job_env (const char *n, const char *v, int overwrite)\n{\n\tvoid *h = dlopen (NULL, 0);\n\tint (*fn)(const char *n, const char *v, int overwrite);\n\n\tfn = dlsym (h, \"spank_set_job_env\");\n\tif (fn == NULL)\n\t\treturn (-1);\n\n\treturn ((*fn) (n, v, overwrite));\n}", "label": 0, "cwe": null, "length": 89 }, { "index": 264044, "code": "fixUpDown() {\n if(!upsidedown)return; /* everything's fine! */\n\n int linewidth = xsize*csize;\n unsigned char*line = new unsigned char[linewidth];\n unsigned char*line0, *line1;\n\n\n int y0=0, y1=ysize-1;\n for(y0=0; y0getBufferStart();\n return false;\n}", "label": 0, "cwe": null, "length": 207 }, { "index": 565720, "code": "PrepareRowForImg24(rfbClientPtr cl,\n uint8_t *dst,\n int x,\n int y,\n int count)\n{\n uint32_t *fbptr;\n uint32_t pix;\n\n fbptr = (uint32_t *)\n &cl->scaledScreen->frameBuffer[y * cl->scaledScreen->paddedWidthInBytes + x * 4];\n\n while (count--) {\n pix = *fbptr++;\n *dst++ = (uint8_t)(pix >> cl->screen->serverFormat.redShift);\n *dst++ = (uint8_t)(pix >> cl->screen->serverFormat.greenShift);\n *dst++ = (uint8_t)(pix >> cl->screen->serverFormat.blueShift);\n }\n}", "label": 0, "cwe": null, "length": 161 }, { "index": 437751, "code": "sig_server_reconnect_removed(RECONNECT_REC *reconnect)\n{\n\tg_return_if_fail(reconnect != NULL);\n\n\tprintformat(NULL, NULL, MSGLEVEL_CLIENTNOTICE,\n\t\t TXT_RECONNECT_REMOVED, reconnect->conn->address, reconnect->conn->port,\n\t\t reconnect->conn->chatnet == NULL ? \"\" : reconnect->conn->chatnet);\n}", "label": 0, "cwe": null, "length": 74 }, { "index": 211866, "code": "sinfo_parse_cpl_input_stack(cpl_parameterlist* cpl_cfg, \n cpl_frameset* sof, \n cpl_frameset** raw,\n fake* fk)\n{\n stack_config_n * cfg =sinfo_stack_cfg_create_n();\n int status=0;\n \n\n\n /*\n * Perform sanity checks, fill up the structure with what was\n * found in the ini file\n */\n\n parse_section_cleanmean (cfg, cpl_cfg);\n parse_section_flatfield (cfg, cpl_cfg);\n parse_section_badpixel (cfg, cpl_cfg); \n parse_section_interleaving (cfg); \n parse_section_gaussconvolution (cfg, cpl_cfg); \n parse_section_shiftframes (cfg); \n parse_section_warpfix (cfg, cpl_cfg);\n parse_section_qclog (cfg, cpl_cfg);\n parse_section_frames (cfg, sof, raw, &status, fk);\n if (status > 0) {\n sinfo_msg_error(\"parsing cpl input\");\n sinfo_stack_cfg_destroy_n(cfg);\n cfg = NULL ;\n return NULL ;\n }\n return cfg ;\n}", "label": 0, "cwe": null, "length": 258 }, { "index": 203668, "code": "json_lexer_check_first(JSONLexer *lexer)\n{\n /* Have we read the first token yet? If not, we need to. */\n\n if (!lexer->read_first) {\n lexer->next_token\n = internal_read_token(&lexer->reader,\n &lexer->string_buffers[0]);\n lexer->read_first = 1;\n }\n}", "label": 0, "cwe": null, "length": 77 }, { "index": 111941, "code": "nvme_nvm_submit_io(struct nvm_dev *dev, struct nvm_rq *rqd)\n{\n\tstruct request_queue *q = dev->q;\n\tstruct nvme_ns *ns = q->queuedata;\n\tstruct request *rq;\n\tstruct bio *bio = rqd->bio;\n\tstruct nvme_nvm_command *cmd;\n\n\trq = blk_mq_alloc_request(q, bio_rw(bio), 0);\n\tif (IS_ERR(rq))\n\t\treturn -ENOMEM;\n\n\tcmd = kzalloc(sizeof(struct nvme_nvm_command), GFP_KERNEL);\n\tif (!cmd) {\n\t\tblk_mq_free_request(rq);\n\t\treturn -ENOMEM;\n\t}\n\n\trq->cmd_type = REQ_TYPE_DRV_PRIV;\n\trq->ioprio = bio_prio(bio);\n\n\tif (bio_has_data(bio))\n\t\trq->nr_phys_segments = bio_phys_segments(q, bio);\n\n\trq->__data_len = bio->bi_iter.bi_size;\n\trq->bio = rq->biotail = bio;\n\n\tnvme_nvm_rqtocmd(rq, rqd, ns, cmd);\n\n\trq->cmd = (unsigned char *)cmd;\n\trq->cmd_len = sizeof(struct nvme_nvm_command);\n\trq->special = (void *)0;\n\n\trq->end_io_data = rqd;\n\n\tblk_execute_rq_nowait(q, NULL, rq, 0, nvme_nvm_end_io);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 300 }, { "index": 469509, "code": "IoBigNum_kronecker(IoBigNum * self, IoObject * locals, IoMessage * m)\n{\n\tIoObject *other = IoMessage_locals_valueArgAt_(m, locals, 0);\n\tif (ISNUMBER(other))\n\t\treturn IONUMBER(mpz_kronecker_si(DATA(self)->integer, IoNumber_asLong(other)));\n\telse if (ISBIGNUM(other))\n\t\treturn IONUMBER(mpz_kronecker(DATA(self)->integer, DATA(other)->integer));\n\telse\n\t\tIoState_error_(IOSTATE, m, \"argument 0 to method '%s' must be a Number or a BigNum, not a '%s'\\n\", CSTRING(IoMessage_name(m)), IoObject_name(other));\n\treturn IONIL(self);\n}", "label": 0, "cwe": null, "length": 162 }, { "index": 109029, "code": "_load_events(uint16_t rpc_version, Buf buffer, char *cluster_name,\n\t uint32_t rec_cnt)\n{\n\tchar *insert = NULL, *format = NULL;\n\tlocal_event_t object;\n\tint i = 0;\n\n\txstrfmtcat(insert, \"insert into \\\"%s_%s\\\" (%s\",\n\t\t cluster_name, event_table, event_req_inx[0]);\n\txstrcat(format, \"('%s'\");\n\tfor(i=1; iisExpired() && !existing->isPreloaded())\n {\n Cache::removeCacheEntry(existing);\n m_reloadedURLs.append(fullURL);\n reload = true;\n }\n }\n }\n else if ((m_cachePolicy == KIO::CC_Reload) || (m_cachePolicy == KIO::CC_Refresh))\n {\n if (!m_reloadedURLs.contains(fullURL))\n {\n if (existing && !existing->isPreloaded())\n {\n Cache::removeCacheEntry(existing);\n }\n if (!existing || !existing->isPreloaded()) {\n m_reloadedURLs.append(fullURL);\n reload = true;\n }\n }\n }\n return reload;\n}", "label": 0, "cwe": null, "length": 209 }, { "index": 307371, "code": "gnac_properties_window_show(void)\n{\n if (!gnac_properties_builder) {\n gnac_properties_window_new();\n }\n\n properties_displayed = TRUE;\n\n if (gnac_file_list_get_current_row(¤t_ref)) {\n gnac_properties_update_arrows();\n gnac_properties_update_display(current_ref);\n }\n\n GtkWidget *window = gnac_properties_get_widget(\"properties_window\");\n gtk_widget_show_all(window);\n\n gnac_properties_reset_spin_if_empty(\"track-number\");\n gnac_properties_reset_spin_if_empty(\"track-count\");\n gnac_properties_reset_spin_if_empty(\"album-disc-number\");\n gnac_properties_reset_spin_if_empty(\"album-disc-count\");\n gnac_properties_reset_spin_if_empty(\"date\");\n\n GtkWidget *notebook = gnac_properties_get_widget(\"notebook1\");\n gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);\n gtk_window_present(GTK_WINDOW(window));\n}", "label": 0, "cwe": null, "length": 191 }, { "index": 230611, "code": "gtkaspell_checkers_strerror(void)\n{\n\tcm_return_val_if_fail(gtkaspellcheckers, \"\");\n\treturn gtkaspellcheckers->error_message;\n}", "label": 0, "cwe": null, "length": 34 }, { "index": 183717, "code": "checkpoint_signal_tasks (void *job, char *image_dir)\n{\n int retval = SLURM_SUCCESS;\n\n slurm_mutex_lock( &context_lock );\n if ( g_context )\n retval = (*(ops.ckpt_signal_tasks))(job, image_dir);\n else {\n error (\"slurm_checkpoint plugin context not initialized\");\n retval = ENOENT;\n }\n slurm_mutex_unlock( &context_lock );\n return retval;\n}", "label": 0, "cwe": null, "length": 93 }, { "index": 92870, "code": "XS__getobjectnumber(pTHX_ CV *perlcv)\n{\n /* Not to be called by user.\n Arguments: name to match\n object type (0: trigger, 1: alias, 2: macro, 3: timer, 4:hook)\n search type (0: by name, 1: by owner plugin)\n [optional] hook event name, if we are dealing with a hook\n */\n GSList *tofind = NULL;\n GSList *found;\n GSList *iter;\n int i;\n int searchtype;\n FETCHWORLDVARS;\n dXSARGS;\n\n searchtype = SvIV(ST(3));\n\n FETCHWORLD;\n\n switch (SvIV(ST(2))) {\n case 0:\n tofind = world->triggers;\n break;\n\n case 1:\n tofind = world->aliases;\n break;\n\n case 2:\n tofind = world->macros;\n break;\n\n case 3:\n tofind = world->timers;\n break;\n\n case 4:\n tofind = get_hook_list_for_reading(world, SvPV_nolen(ST(4)), NULL);\n if (!tofind) {\n XSRETURN(0);\n }\n break;\n }\n\n found = get_object_numbers(tofind, SvPV_nolen(ST(1)), searchtype);\n\n i = 0;\n iter = found;\n while (iter) {\n XST_mIV(i++, GPOINTER_TO_INT(iter->data));\n\n iter = iter->next;\n }\n\n g_slist_free(found);\n\n XSRETURN(i);\n}", "label": 0, "cwe": null, "length": 351 }, { "index": 414627, "code": "redirect_immediate_dominators (enum cdi_direction dir, basic_block bb,\n\t\t\t basic_block to)\n{\n unsigned int dir_index = dom_convert_dir_to_idx (dir);\n struct et_node *bb_node, *to_node, *son;\n\n bb_node = bb->dom[dir_index];\n to_node = to->dom[dir_index];\n\n gcc_checking_assert (dom_computed[dir_index]);\n\n if (!bb_node->son)\n return;\n\n while (bb_node->son)\n {\n son = bb_node->son;\n\n et_split (son);\n et_set_father (son, to_node);\n }\n\n if (dom_computed[dir_index] == DOM_OK)\n dom_computed[dir_index] = DOM_NO_FAST_QUERY;\n}", "label": 0, "cwe": null, "length": 160 }, { "index": 866314, "code": "SetAttributeFilter( const char *pszQuery )\n\n{\n GetLayerDefn();\n\n if( pszQuery == NULL )\n osQuery = \"\";\n else\n osQuery = pszQuery;\n\n BuildWhere();\n\n ResetReading();\n\n return OGRERR_NONE;\n}", "label": 0, "cwe": null, "length": 57 }, { "index": 533551, "code": "cancel_delayed_work(struct delayed_work *dwork)\n{\n\tunsigned long flags;\n\tint ret;\n\n\tdo {\n\t\tret = try_to_grab_pending(&dwork->work, true, &flags);\n\t} while (unlikely(ret == -EAGAIN));\n\n\tif (unlikely(ret < 0))\n\t\treturn false;\n\n\tset_work_pool_and_clear_pending(&dwork->work,\n\t\t\t\t\tget_work_pool_id(&dwork->work));\n\tlocal_irq_restore(flags);\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 96 }, { "index": 366196, "code": "getUTF(JNIEnv *env, jstring str, char* localBuf, int bufSize)\n{\n char* utfStr = NULL;\n\n int len = (*env)->GetStringUTFLength(env, str);\n int unicode_len = (*env)->GetStringLength(env, str);\n if (len >= bufSize) {\n utfStr = malloc(len + 1);\n if (utfStr == NULL) {\n JNU_ThrowOutOfMemoryError(env, NULL);\n return NULL;\n }\n } else {\n utfStr = localBuf;\n }\n (*env)->GetStringUTFRegion(env, str, 0, unicode_len, utfStr);\n\n return utfStr;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 142 }, { "index": 394484, "code": "findArg( char* shortName, char* longName, int argc, char* argv[] )\n{\n int i = 1;\n while( i < argc )\n { if( argv[i] && (!strcmp(argv[i],shortName) || !strcmp(argv[i],longName )) ) return i; i++; }\n return 0; //search failed\n}", "label": 0, "cwe": null, "length": 79 }, { "index": 30622, "code": "convertValue(UnOpInit *BO) {\n if (BO->getOpcode() == UnOpInit::CAST) {\n Init *L = BO->getOperand()->convertInitializerTo(this);\n if (L == 0) return 0;\n if (L != BO->getOperand())\n return UnOpInit::get(UnOpInit::CAST, L, new StringRecTy);\n return BO;\n }\n\n return convertValue((TypedInit*)BO);\n}", "label": 0, "cwe": null, "length": 100 }, { "index": 940946, "code": "gst_tool_load_common_ui (GstTool *tool)\n{\n\tGtkBuilder *builder;\n\n\tg_return_val_if_fail (tool != NULL, NULL);\n\tg_return_val_if_fail (GST_IS_TOOL (tool), NULL);\n\tg_return_val_if_fail (tool->common_ui_path != NULL, NULL);\n\n\tbuilder = gtk_builder_new ();\n\n\tif (!gtk_builder_add_from_file (builder, tool->common_ui_path, NULL)) {\n\t\tg_error (\"Could not load %s\\n\", tool->common_ui_path);\n\t}\n\n\treturn builder;\n}", "label": 0, "cwe": null, "length": 109 }, { "index": 789247, "code": "dae_cb_geometry(DaeGlobalData *global, DaeLocalData *local)\n{\n\tG3DObject *object;\n\tG3DMaterial *material;\n\n\tobject = (G3DObject *)local->user_data;\n\tg_return_val_if_fail(object != NULL, FALSE);\n\n\tmaterial = g3d_material_new();\n\tmaterial->name = g_strdup(\"(default material)\");\n\tobject->materials = g_slist_append(object->materials, material);\n\n\tif(local->instance) {\n\t\t/* parse original node */\n\t\tdae_xml_parse(global, local->instance,\n\t\t\tdae_chunks_geometry, local->level, object);\n\t}\n\n\t/* parse instanced stuff */\n\treturn dae_xml_parse(global, local->node, dae_chunks_geometry,\n\t\tlocal->level, object);\n}", "label": 0, "cwe": null, "length": 160 }, { "index": 82086, "code": "gamgi_gtk_object_name_number (GtkWidget *host,\nchar *tag, gamgi_enum class, gamgi_window *window)\n{\ngamgi_object *object;\nchar name[GAMGI_ENGINE_TOKEN];\n\n/**************\n * get object *\n **************/\n\nobject = static_object (host, tag, class, window, name);\nif (object == NULL) return NULL;\n\n/****************\n * confirm name *\n ****************/\n\nif (strcmp (name, object->name) != 0) return NULL;\nreturn object;\n}", "label": 0, "cwe": null, "length": 104 }, { "index": 871868, "code": "lo_ioctl(struct block_device *bdev, fmode_t mode,\n\tunsigned int cmd, unsigned long arg)\n{\n\tstruct loop_device *lo = bdev->bd_disk->private_data;\n\tint err;\n\n\tmutex_lock_nested(&lo->lo_ctl_mutex, 1);\n\tswitch (cmd) {\n\tcase LOOP_SET_FD:\n\t\terr = loop_set_fd(lo, mode, bdev, arg);\n\t\tbreak;\n\tcase LOOP_CHANGE_FD:\n\t\terr = loop_change_fd(lo, bdev, arg);\n\t\tbreak;\n\tcase LOOP_CLR_FD:\n\t\t/* loop_clr_fd would have unlocked lo_ctl_mutex on success */\n\t\terr = loop_clr_fd(lo);\n\t\tif (!err)\n\t\t\tgoto out_unlocked;\n\t\tbreak;\n\tcase LOOP_SET_STATUS:\n\t\terr = -EPERM;\n\t\tif ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN))\n\t\t\terr = loop_set_status_old(lo,\n\t\t\t\t\t(struct loop_info __user *)arg);\n\t\tbreak;\n\tcase LOOP_GET_STATUS:\n\t\terr = loop_get_status_old(lo, (struct loop_info __user *) arg);\n\t\tbreak;\n\tcase LOOP_SET_STATUS64:\n\t\terr = -EPERM;\n\t\tif ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN))\n\t\t\terr = loop_set_status64(lo,\n\t\t\t\t\t(struct loop_info64 __user *) arg);\n\t\tbreak;\n\tcase LOOP_GET_STATUS64:\n\t\terr = loop_get_status64(lo, (struct loop_info64 __user *) arg);\n\t\tbreak;\n\tcase LOOP_SET_CAPACITY:\n\t\terr = -EPERM;\n\t\tif ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN))\n\t\t\terr = loop_set_capacity(lo, bdev);\n\t\tbreak;\n\tcase LOOP_SET_DIRECT_IO:\n\t\terr = -EPERM;\n\t\tif ((mode & FMODE_WRITE) || capable(CAP_SYS_ADMIN))\n\t\t\terr = loop_set_dio(lo, arg);\n\t\tbreak;\n\tdefault:\n\t\terr = lo->ioctl ? lo->ioctl(lo, cmd, arg) : -EINVAL;\n\t}\n\tmutex_unlock(&lo->lo_ctl_mutex);\n\nout_unlocked:\n\treturn err;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 428 }, { "index": 326251, "code": "dirty_check(void)\n{\n\tif (!dirty || dummy)\n\t\treturn;\n\n term_resize_dirty();\n\n\tif (full_redraw) {\n full_redraw = FALSE;\n\n\t\t/* first clear the screen so curses will be\n\t\t forced to redraw the screen */\n\t\tterm_clear();\n\t\tterm_refresh(NULL);\n\n\t\tmainwindows_redraw();\n\t\tstatusbar_redraw(NULL, TRUE);\n\t}\n\n\tmainwindows_redraw_dirty();\n statusbar_redraw_dirty();\n\tterm_refresh(NULL);\n\n dirty = FALSE;\n}", "label": 0, "cwe": null, "length": 105 }, { "index": 151821, "code": "vfPosition (aso, exp)\n Af_key *aso;\n Expr exp;\n{\n Af_set tset;\n Af_attrs tattrs;\n Af_key tkey;\n int hits, i;\n\n af_initattrs (&tattrs);\n strcpy (tattrs.af_host, af_retattr (aso, AF_ATTHOST));\n strcpy (tattrs.af_syspath, af_retattr (aso, AF_ATTSPATH));\n strcpy (tattrs.af_name, af_retattr (aso, AF_ATTNAME));\n strcpy (tattrs.af_type, af_retattr (aso, AF_ATTTYPE));\n\n if (stateFlag)\n tattrs.af_state = af_retnumattr (aso, AF_ATTSTATE);\n if (userFlag) {\n Af_user *asoOwner = af_retuserattr (aso, AF_ATTOWNER);\n strcpy (tattrs.af_owner.af_username, asoOwner->af_username);\n strcpy (tattrs.af_owner.af_userdomain, asoOwner->af_userdomain);\n }\n if (attrFlag) {\n Af_attrs attrs;\n af_allattrs (aso, &attrs);\n for (i = 0; i < AF_MAXUDAS; i++)\n tattrs.af_udattrs[i] = attrs.af_udattrs[i];\n af_freeattrbuf (&attrs);\n }\n\n if (af_find(&tattrs, &tset) == -1) {\n sprintf(stMessage, \"%s: af_find()\", stProgramName);\n af_perror(stMessage);\n return 0;\n }\n\n if ((hits = af_nrofkeys(&tset)) > 1) {\n af_sortset(&tset, AF_ATTBOUND);\n if (((int) exp->left) == VF_FIRST)\n af_setgkey(&tset, 0, &tkey);\n else\n af_setgkey(&tset, hits - 1, &tkey);\n hits = ((af_retnumattr (&tkey, AF_ATTGEN) == af_retnumattr (aso, AF_ATTGEN)) &&\n\t (af_retnumattr (&tkey, AF_ATTREV) == af_retnumattr (aso, AF_ATTREV))) ? 1 : 0;\n af_dropkey (&tkey);\n }\n af_dropset (&tset);\n return hits;\n}", "label": 0, "cwe": null, "length": 492 }, { "index": 166801, "code": "robustRigidTransformation(\n\tmrpt::utils::TMatchingPairList\t&in_correspondences,\n\tmrpt::poses::CPosePDFSOG\t\t\t\t&out_transformation,\n\tfloat\t\t\t\t\t\t\tnormalizationStd,\n\tunsigned int\t\t\t\t\transac_minSetSize,\n\tunsigned int\t\t\t\t\transac_maxSetSize,\n\tfloat\t\t\t\t\t\t\transac_mahalanobisDistanceThreshold,\n\tunsigned int\t\t\t\t\transac_nSimulations,\n\tmrpt::utils::TMatchingPairList\t\t*out_largestSubSet,\n\tbool\t\t\t\t\t\transac_fuseByCorrsMatch,\n\tfloat\t\t\t\t\t\transac_fuseMaxDiffXY,\n\tfloat\t\t\t\t\t\transac_fuseMaxDiffPhi,\n\tbool\t\t\t\t\t\transac_algorithmForLandmarks,\n\tdouble \t\t\t\t\t\tprobability_find_good_model,\n\tunsigned int\t\t\t\transac_min_nSimulations,\n\tconst bool verbose,\n\tdouble max_rmse_to_end\n\t)\n{\n\tmrpt::tfest::TSE2RobustParams params;\n\tparams.ransac_minSetSize = ransac_minSetSize;\n\tparams.ransac_maxSetSize = ransac_maxSetSize;\n\tparams.ransac_mahalanobisDistanceThreshold = ransac_mahalanobisDistanceThreshold;\n\tparams.ransac_nSimulations = ransac_nSimulations;\n\tparams.ransac_fuseByCorrsMatch = ransac_fuseByCorrsMatch;\n\tparams.ransac_fuseMaxDiffXY = ransac_fuseMaxDiffXY;\n\tparams.ransac_fuseMaxDiffPhi = ransac_fuseMaxDiffPhi;\n\tparams.ransac_algorithmForLandmarks = ransac_algorithmForLandmarks;\n\tparams.probability_find_good_model = probability_find_good_model;\n\tparams.ransac_min_nSimulations = ransac_min_nSimulations;\n\tparams.max_rmse_to_end = max_rmse_to_end;\n\tparams.verbose = verbose;\n\n\tmrpt::tfest::TSE2RobustResult results;\n\t//const bool ret = \n\tmrpt::tfest::se2_l2_robust(in_correspondences,normalizationStd,params,results);\n\n\tout_transformation = results.transformation;\n\tif (out_largestSubSet) *out_largestSubSet = results.largestSubSet;\n}", "label": 0, "cwe": null, "length": 474 }, { "index": 122386, "code": "includeItems(QHash& items1, const QHash& items2)\n{\n foreach (const KService::Ptr &p, items2) {\n items1.insert(p->menuId(), p);\n }\n}", "label": 0, "cwe": null, "length": 56 }, { "index": 814730, "code": "capi20_register( unsigned MaxB3Connection, unsigned MaxB3Blks, unsigned MaxSizeB3, unsigned *ApplID ) {\n\tunsigned int applid = 0;\n\tint fd = -1;\n\n\t*ApplID = 0;\n\n\tif (capi20_isinstalled() != CapiNoError)\n\t\treturn CapiRegNotInstalled;\n\n\tfd = psModule -> psOperations -> Register( MaxB3Connection, MaxB3Blks, MaxSizeB3, &applid );\n\tif ( fd < 0 ) {\n\t\treturn CapiRegOSResourceErr;\n\t}\n\n\tif (capi_remember_applid(applid, fd) < 0) {\n\t\tclose(fd);\n\t\treturn CapiRegOSResourceErr;\n\t}\n\tapplinfo[applid] = alloc_buffers(MaxB3Connection, MaxB3Blks, MaxSizeB3);\n\tif (applinfo[applid] == 0) {\n\t\tclose(fd);\n\t\treturn CapiRegOSResourceErr;\n\t}\n\t*ApplID = applid;\n\treturn CapiNoError;\n}", "label": 0, "cwe": null, "length": 231 }, { "index": 23982, "code": "initialize_texture_fields(struct gl_context *ctx,\n GLenum target,\n struct gl_texture_object *texObj,\n GLint levels,\n GLsizei width, GLsizei height, GLsizei depth,\n GLenum internalFormat, mesa_format texFormat)\n{\n const GLuint numFaces = _mesa_num_tex_faces(target);\n GLint level, levelWidth = width, levelHeight = height, levelDepth = depth;\n GLuint face;\n\n /* Pretend we are bound to initialize the gl_texture_image structs */\n texObj->Target = target;\n\n /* Set up all the texture object's gl_texture_images */\n for (level = 0; level < levels; level++) {\n for (face = 0; face < numFaces; face++) {\n struct gl_texture_image *texImage;\n GLenum faceTarget = target;\n\n if (target == GL_TEXTURE_CUBE_MAP)\n faceTarget = GL_TEXTURE_CUBE_MAP_POSITIVE_X + face;\n\n texImage = _mesa_get_tex_image(ctx, texObj, faceTarget, level);\n\n if (!texImage) {\n _mesa_error(ctx, GL_OUT_OF_MEMORY, \"glTexStorage\");\n return GL_FALSE;\n }\n\n _mesa_init_teximage_fields(ctx, texImage,\n levelWidth, levelHeight, levelDepth,\n 0, internalFormat, texFormat);\n }\n\n _mesa_next_mipmap_level_size(target, 0, levelWidth, levelHeight, levelDepth,\n &levelWidth, &levelHeight, &levelDepth);\n }\n\n /* \"unbind\" */\n texObj->Target = 0;\n\n return GL_TRUE;\n}", "label": 0, "cwe": null, "length": 337 }, { "index": 402315, "code": "append( const char *srcname )\n{\n\tchar name[PFS_PATH_MAX];\n\n\t/* Clean up the insane names that systems give us */\n\tstrcpy(name,srcname);\n\tstring_chomp(name);\n\n\t/* Create data list if it doesn't already exist */\n\tif(!data) data = list_create();\n\t\n\treturn list_push_tail(data, (void*)strdup(name));\n\n}", "label": 0, "cwe": null, "length": 76 }, { "index": 115523, "code": "unset_focus(GtkWidget *widget, gpointer data){\n\tGTK_WIDGET_UNSET_FLAGS(widget, GTK_CAN_FOCUS);\n\tif(GTK_IS_CONTAINER(widget))\n\t\tgtk_container_foreach(GTK_CONTAINER(widget), unset_focus, NULL);\n\n}", "label": 0, "cwe": null, "length": 44 }, { "index": 114362, "code": "parse(InputText *det)\n{\n parseCharacters(det);\n\n // TODO: Is this OK? The buffer could have ended in the middle of a word...\n addByte(0x20);\n\n double rawPercent = (double) hitCount / (double) ngramCount;\n\n // if (rawPercent <= 2.0) {\n // return 0;\n // }\n\n // TODO - This is a bit of a hack to take care of a case\n // were we were getting a confidence of 135...\n if (rawPercent > 0.33) {\n return 98;\n }\n\n return (int32_t) (rawPercent * 300.0);\n}", "label": 0, "cwe": null, "length": 150 }, { "index": 613762, "code": "endElement( const QString&, const QString&, const QString& qName )\n {\n if( qName == \"error\" ){\n error = cdata;\n return true;\n }\n return true;\n }", "label": 0, "cwe": null, "length": 46 }, { "index": 612110, "code": "jpeg_transfer_1(Image *ifile, Image *ofile)\n{\n int c;\n\n c = ReadBlobByte(ifile);\n if (c == EOF)\n return EOF;\n (void) WriteBlobByte(ofile,c);\n return c;\n}", "label": 0, "cwe": null, "length": 55 }, { "index": 196399, "code": "trx_undo_get_prev_rec_from_prev_page(\n/*=================================*/\n\ttrx_undo_rec_t*\trec,\t/*!< in: undo record */\n\tulint\t\tpage_no,/*!< in: undo log header page number */\n\tulint\t\toffset,\t/*!< in: undo log header offset on page */\n\tmtr_t*\t\tmtr)\t/*!< in: mtr */\n{\n\tulint\tspace;\n\tulint\tzip_size;\n\tulint\tprev_page_no;\n\tpage_t* prev_page;\n\tpage_t*\tundo_page;\n\n\tundo_page = page_align(rec);\n\n\tprev_page_no = flst_get_prev_addr(undo_page + TRX_UNDO_PAGE_HDR\n\t\t\t\t\t + TRX_UNDO_PAGE_NODE, mtr)\n\t\t.page;\n\n\tif (prev_page_no == FIL_NULL) {\n\n\t\treturn(NULL);\n\t}\n\n\tspace = page_get_space_id(undo_page);\n\tzip_size = fil_space_get_zip_size(space);\n\n\tprev_page = trx_undo_page_get_s_latched(space, zip_size,\n\t\t\t\t\t\tprev_page_no, mtr);\n\n\treturn(trx_undo_page_get_last_rec(prev_page, page_no, offset));\n}", "label": 0, "cwe": null, "length": 237 }, { "index": 16287, "code": "timblogiw_streamon(struct file *file, void *priv, enum v4l2_buf_type type)\n{\n\tstruct video_device *vdev = video_devdata(file);\n\tstruct timblogiw_fh *fh = priv;\n\n\tdev_dbg(&vdev->dev, \"%s: entry\\n\", __func__);\n\n\tif (type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {\n\t\tdev_dbg(&vdev->dev, \"%s - No capture device\\n\", __func__);\n\t\treturn -EINVAL;\n\t}\n\n\tfh->frame_count = 0;\n\treturn videobuf_streamon(&fh->vb_vidq);\n}", "label": 0, "cwe": null, "length": 129 }, { "index": 987677, "code": "mbm_cleanup(void)\n{\n\tif (!mbm_enabled)\n\t\treturn;\n\n\tkfree(mbm_local);\n\tkfree(mbm_total);\n\tmbm_enabled = false;\n}", "label": 0, "cwe": null, "length": 33 }, { "index": 462649, "code": "get_fg_tile_info(int tile_index)\r\n{\r\n\tunsigned char attr = mrdo_fgvideoram[tile_index];\r\n\tSET_TILE_INFO(\r\n\t\t\t0,\r\n\t\t\tmrdo_fgvideoram[tile_index+0x400] + ((attr & 0x80) << 1),\r\n\t\t\tattr & 0x3f,\r\n\t\t\t(attr & 0x40) ? TILE_IGNORE_TRANSPARENCY : 0)\r\n}", "label": 0, "cwe": null, "length": 89 }, { "index": 127235, "code": "notifyScript(std::string scriptName, std::string action, TNotifyScriptParams& params) {\n const char * argv[3];\n\n // get PATH\n char * path = getenv(\"PATH\");\n if (path) {\n params.addParam(\"PATH\", string(path));\n }\n\n // parameters: [0] - script name, [1] - action (add, modify, delete)\n argv[0] = scriptName.c_str();\n argv[1] = action.c_str();\n argv[2] = NULL;\n \n Log(Debug) << \"About to execute \" << scriptName << \" script, \"\n << params.envCnt << \" variables.\" << LogEnd;\n int returnCode = execute(scriptName.c_str(), argv, params.env);\n\n if (returnCode>=0) {\n Log(Debug) << \"Script execution complete, return code=\" << returnCode << LogEnd;\n } else {\n // negative return code, something went wrong\n Log(Warning) << \"Script execution failed, return code=\" << returnCode << LogEnd;\n }\n}", "label": 0, "cwe": null, "length": 229 }, { "index": 101537, "code": "safe_strncopy( char *ptr, const char *src, size_t n, struct berval *buf )\n{\n\twhile ( ptr + n >= buf->bv_val + buf->bv_len ) {\n\t\tchar *tmp = ch_realloc( buf->bv_val, 2*buf->bv_len );\n\t\tif ( tmp == NULL ) {\n\t\t\treturn NULL;\n\t\t}\n\t\tptr = tmp + (ptr - buf->bv_val);\n\t\tbuf->bv_val = tmp;\n\t\tbuf->bv_len *= 2;\n\t}\n\n\treturn lutil_strncopy( ptr, src, n );\n}", "label": 0, "cwe": null, "length": 126 }, { "index": 621149, "code": "AddFileToParser(cbProject* project, const wxString& filename, ParserBase* parser)\n{\n if (ParserCommon::FileType(filename) == ParserCommon::ftOther)\n return false;\n\n if (!parser)\n {\n parser = GetParserByProject(project);\n if (!parser)\n return false;\n }\n\n if (!parser->UpdateParsingProject(project))\n return false;\n\n TRACE(_T(\"NativeParser::AddFileToParser(): Calling Parser::AddFile()\"));\n\n return parser->AddFile(filename, project);\n}", "label": 0, "cwe": null, "length": 113 }, { "index": 145385, "code": "extra_redirect(MWA_REQ_CTXT *rc)\n{\n char *redirect_url;\n\n redirect_url = make_return_url(rc, 0);\n /* always strip extra-redirect URL */\n strip_end(redirect_url, WEBAUTHR_MAGIC);\n\n apr_table_setn(rc->r->err_headers_out, \"Location\", redirect_url);\n\n if (rc->sconf->debug)\n ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, rc->r->server,\n \"mod_webauth: extra_redirect: redirect(%s)\",\n redirect_url);\n\n set_pending_cookies(rc);\n return do_redirect(rc);\n}", "label": 0, "cwe": null, "length": 132 }, { "index": 120778, "code": "format_check (GdkPixbufModule *module, guchar *buffer, int size)\n{\n int i, j;\n gchar m;\n GdkPixbufModulePattern *pattern;\n gboolean anchored;\n guchar *prefix;\n gchar *mask;\n\n for (pattern = module->info->signature; pattern->prefix; pattern++) {\n if (pattern->mask && pattern->mask[0] == '*') {\n prefix = (guchar *)pattern->prefix + 1;\n mask = pattern->mask + 1;\n anchored = FALSE;\n }\n else {\n prefix = (guchar *)pattern->prefix;\n mask = pattern->mask;\n anchored = TRUE;\n }\n for (i = 0; i < size; i++) {\n for (j = 0; i + j < size && prefix[j] != 0; j++) {\n m = mask ? mask[j] : ' ';\n if (m == ' ') {\n if (buffer[i + j] != prefix[j])\n break;\n }\n else if (m == '!') {\n if (buffer[i + j] == prefix[j])\n break;\n }\n else if (m == 'z') {\n if (buffer[i + j] != 0)\n break;\n }\n else if (m == 'n') {\n if (buffer[i + j] == 0)\n break;\n }\n } \n\n if (prefix[j] == 0) \n return pattern->relevance;\n\n if (anchored)\n break;\n }\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 344 }, { "index": 479279, "code": "gs_image_cleanup(gs_image_enum * penum, gs_state *pgs)\n{\n int code = 0, code1;\n\n free_row_buffers(penum, penum->num_planes, \"gs_image_cleanup(row)\");\n if (penum->info != 0) {\n if (dev_proc(penum->info->dev, dev_spec_op)(penum->info->dev,\n gxdso_pattern_is_cpath_accum, NULL, 0)) {\n /* Performing a conversion of imagemask into a clipping path. */\n gx_device *cdev = penum->info->dev;\n\n code = gx_image_end(penum->info, !penum->error); /* Releases penum->info . */\n code1 = gx_image_fill_masked_end(cdev, penum->dev, gs_currentdevicecolor_inline(pgs));\n if (code == 0)\n code = code1;\n } else\n code = gx_image_end(penum->info, !penum->error);\n }\n /* Don't free the local enumerator -- the client does that. */\n\n return code;\n}", "label": 0, "cwe": null, "length": 234 }, { "index": 117484, "code": "read_block(struct inode *inode, void *addr, unsigned int block,\n\t\t struct ubifs_data_node *dn)\n{\n\tstruct ubifs_info *c = inode->i_sb->s_fs_info;\n\tint err, len, out_len;\n\tunion ubifs_key key;\n\tunsigned int dlen;\n\n\tdata_key_init(c, &key, inode->i_ino, block);\n\terr = ubifs_tnc_lookup(c, &key, dn);\n\tif (err) {\n\t\tif (err == -ENOENT)\n\t\t\t/* Not found, so it must be a hole */\n\t\t\tmemset(addr, 0, UBIFS_BLOCK_SIZE);\n\t\treturn err;\n\t}\n\n\tubifs_assert(le64_to_cpu(dn->ch.sqnum) >\n\t\t ubifs_inode(inode)->creat_sqnum);\n\tlen = le32_to_cpu(dn->size);\n\tif (len <= 0 || len > UBIFS_BLOCK_SIZE)\n\t\tgoto dump;\n\n\tdlen = le32_to_cpu(dn->ch.len) - UBIFS_DATA_NODE_SZ;\n\tout_len = UBIFS_BLOCK_SIZE;\n\terr = ubifs_decompress(c, &dn->data, dlen, addr, &out_len,\n\t\t\t le16_to_cpu(dn->compr_type));\n\tif (err || len != out_len)\n\t\tgoto dump;\n\n\t/*\n\t * Data length can be less than a full block, even for blocks that are\n\t * not the last in the file (e.g., as a result of making a hole and\n\t * appending data). Ensure that the remainder is zeroed out.\n\t */\n\tif (len < UBIFS_BLOCK_SIZE)\n\t\tmemset(addr + len, 0, UBIFS_BLOCK_SIZE - len);\n\n\treturn 0;\n\ndump:\n\tubifs_err(c, \"bad data node (block %u, inode %lu)\",\n\t\t block, inode->i_ino);\n\tubifs_dump_node(c, dn);\n\treturn -EINVAL;\n}", "label": 0, "cwe": null, "length": 397 }, { "index": 5804, "code": "test_array_insert_val ()\n{\n\tGArray *array = g_array_new (FALSE, FALSE, sizeof (gpointer));\n\tgpointer ptr0, ptr1, ptr2, ptr3;\n\n\tg_array_insert_val (array, 0, array);\n\n\tif (array != g_array_index (array, gpointer, 0))\n\t\treturn FAILED (\"1 The value in the array is incorrect\");\n\n\tg_array_insert_val (array, 1, array);\n\tif (array != g_array_index (array, gpointer, 1))\n\t\treturn FAILED (\"2 The value in the array is incorrect\");\n\n\tg_array_insert_val (array, 2, array);\n\tif (array != g_array_index (array, gpointer, 2))\n\t\treturn FAILED (\"3 The value in the array is incorrect\");\n\t\n\tg_array_free (array, TRUE);\n\tarray = g_array_new (FALSE, FALSE, sizeof (gpointer));\n\tptr0 = array;\n\tptr1 = array + 1;\n\tptr2 = array + 2;\n\tptr3 = array + 3;\n\n\tg_array_insert_val (array, 0, ptr0);\n\tg_array_insert_val (array, 1, ptr1);\n\tg_array_insert_val (array, 2, ptr2);\n\tg_array_insert_val (array, 1, ptr3);\n\tif (ptr0 != g_array_index (array, gpointer, 0))\n\t\treturn FAILED (\"4 The value in the array is incorrect\");\n\tif (ptr3 != g_array_index (array, gpointer, 1))\n\t\treturn FAILED (\"5 The value in the array is incorrect\");\n\tif (ptr1 != g_array_index (array, gpointer, 2))\n\t\treturn FAILED (\"6 The value in the array is incorrect\");\n\tif (ptr2 != g_array_index (array, gpointer, 3))\n\t\treturn FAILED (\"7 The value in the array is incorrect\");\n\n\tg_array_free (array, TRUE);\n\treturn NULL;\n}", "label": 0, "cwe": null, "length": 392 }, { "index": 56684, "code": "rtw_drv_entry(void)\n{\n\tRT_TRACE(_module_hci_intfs_c_, _drv_err_, \"+rtw_drv_entry\\n\");\n\treturn usb_register(usb_drv);\n}", "label": 0, "cwe": null, "length": 37 }, { "index": 480857, "code": "hns_nic_init_irq(struct hns_nic_priv *priv)\n{\n\tstruct hnae_handle *h = priv->ae_handle;\n\tstruct hns_nic_ring_data *rd;\n\tint i;\n\tint ret;\n\tint cpu;\n\tcpumask_t mask;\n\n\tfor (i = 0; i < h->q_num * 2; i++) {\n\t\trd = &priv->ring_data[i];\n\n\t\tif (rd->ring->irq_init_flag == RCB_IRQ_INITED)\n\t\t\tbreak;\n\n\t\tsnprintf(rd->ring->ring_name, RCB_RING_NAME_LEN,\n\t\t\t \"%s-%s%d\", priv->netdev->name,\n\t\t\t (i < h->q_num ? \"tx\" : \"rx\"), rd->queue_index);\n\n\t\trd->ring->ring_name[RCB_RING_NAME_LEN - 1] = '\\0';\n\n\t\tret = request_irq(rd->ring->irq,\n\t\t\t\t hns_irq_handle, 0, rd->ring->ring_name, rd);\n\t\tif (ret) {\n\t\t\tnetdev_err(priv->netdev, \"request irq(%d) fail\\n\",\n\t\t\t\t rd->ring->irq);\n\t\t\treturn ret;\n\t\t}\n\t\tdisable_irq(rd->ring->irq);\n\t\trd->ring->irq_init_flag = RCB_IRQ_INITED;\n\n\t\t/*set cpu affinity*/\n\t\tif (cpu_online(rd->queue_index)) {\n\t\t\tcpumask_clear(&mask);\n\t\t\tcpu = rd->queue_index;\n\t\t\tcpumask_set_cpu(cpu, &mask);\n\t\t\tirq_set_affinity_hint(rd->ring->irq, &mask);\n\t\t}\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 339 }, { "index": 639743, "code": "receive_cgreen_message(int messaging) {\n CgreenMessage *message = malloc(sizeof(CgreenMessage));\n if (message == NULL) {\n return -1;\n }\n fcntl(queues[messaging].readpipe, F_SETFL, O_NONBLOCK);\n ssize_t received = read(queues[messaging].readpipe, message, sizeof(CgreenMessage));\n int result = (received > 0 ? message->result : 0);\n free(message);\n return result;\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 1008110, "code": "rb_connect_tryconnect(rb_fde_t *F, void *notused)\n{\n\tint retval;\n\n\tif(F == NULL || F->connect == NULL || F->connect->callback == NULL)\n\t\treturn;\n\t/* Try the connect() */\n\tretval = connect(F->fd,\n\t\t\t (struct sockaddr *)&F->connect->hostaddr,\n\t\t\t GET_SS_LEN(&F->connect->hostaddr));\n\t/* Error? */\n\tif(retval < 0)\n\t{\n\t\t/*\n\t\t * If we get EISCONN, then we've already connect()ed the socket,\n\t\t * which is a good thing.\n\t\t * -- adrian\n\t\t */\n\t\trb_get_errno();\n\t\tif(errno == EISCONN)\n\t\t\trb_connect_callback(F, RB_OK);\n\t\telse if(rb_ignore_errno(errno))\n\t\t\t/* Ignore error? Reschedule */\n\t\t\trb_setselect(F, RB_SELECT_CONNECT, rb_connect_tryconnect, NULL);\n\t\telse\n\t\t\t/* Error? Fail with RB_ERR_CONNECT */\n\t\t\trb_connect_callback(F, RB_ERR_CONNECT);\n\t\treturn;\n\t}\n\t/* If we get here, we've suceeded, so call with RB_OK */\n\trb_connect_callback(F, RB_OK);\n}", "label": 0, "cwe": null, "length": 245 }, { "index": 7714, "code": "dbFindBits(u32 word, int l2nb)\n{\n\tint bitno, nb;\n\tu32 mask;\n\n\t/* get the number of bits.\n\t */\n\tnb = 1 << l2nb;\n\tassert(nb <= DBWORD);\n\n\t/* complement the word so we can use a mask (i.e. 0s represent\n\t * free bits) and compute the mask.\n\t */\n\tword = ~word;\n\tmask = ONES << (DBWORD - nb);\n\n\t/* scan the word for nb free bits at nb alignments.\n\t */\n\tfor (bitno = 0; mask != 0; bitno += nb, mask >>= nb) {\n\t\tif ((mask & word) == mask)\n\t\t\tbreak;\n\t}\n\n\tASSERT(bitno < 32);\n\n\t/* return the bit number.\n\t */\n\treturn (bitno);\n}", "label": 0, "cwe": null, "length": 173 }, { "index": 113837, "code": "snd_timer_instance_new(char *owner,\n\t\t\t\t\t\t\t struct snd_timer *timer)\n{\n\tstruct snd_timer_instance *timeri;\n\ttimeri = kzalloc(sizeof(*timeri), GFP_KERNEL);\n\tif (timeri == NULL)\n\t\treturn NULL;\n\ttimeri->owner = kstrdup(owner, GFP_KERNEL);\n\tif (! timeri->owner) {\n\t\tkfree(timeri);\n\t\treturn NULL;\n\t}\n\tINIT_LIST_HEAD(&timeri->open_list);\n\tINIT_LIST_HEAD(&timeri->active_list);\n\tINIT_LIST_HEAD(&timeri->ack_list);\n\tINIT_LIST_HEAD(&timeri->slave_list_head);\n\tINIT_LIST_HEAD(&timeri->slave_active_head);\n\n\ttimeri->timer = timer;\n\tif (timer && !try_module_get(timer->module)) {\n\t\tkfree(timeri->owner);\n\t\tkfree(timeri);\n\t\treturn NULL;\n\t}\n\n\treturn timeri;\n}", "label": 0, "cwe": null, "length": 181 }, { "index": 156768, "code": "sicmp(unsigned char a, unsigned char b)\n{\n\tif (a >= 'A' || a <= 'Z')\n\t\ta += 'a' - 'A';\n\tif (b >= 'A' || b <= 'Z')\n\t\tb += 'a' - 'A';\n\treturn scmp(a, b);\n}", "label": 0, "cwe": null, "length": 66 }, { "index": 195913, "code": "mmc_select_timing(struct mmc_card *card)\n{\n\tint err = 0;\n\n\tif (!mmc_can_ext_csd(card))\n\t\tgoto bus_speed;\n\n\tif (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS200)\n\t\terr = mmc_select_hs200(card);\n\telse if (card->mmc_avail_type & EXT_CSD_CARD_TYPE_HS)\n\t\terr = mmc_select_hs(card);\n\n\tif (err && err != -EBADMSG)\n\t\treturn err;\n\n\tif (err) {\n\t\tpr_warn(\"%s: switch to %s failed\\n\",\n\t\t\tmmc_card_hs(card) ? \"high-speed\" :\n\t\t\t(mmc_card_hs200(card) ? \"hs200\" : \"\"),\n\t\t\tmmc_hostname(card->host));\n\t\terr = 0;\n\t}\n\nbus_speed:\n\t/*\n\t * Set the bus speed to the selected bus timing.\n\t * If timing is not selected, backward compatible is the default.\n\t */\n\tmmc_set_bus_speed(card);\n\treturn err;\n}", "label": 0, "cwe": null, "length": 202 }, { "index": 60772, "code": "SV_DemoCompleted (void)\r\n{\r\n\tif (sv.demofile)\r\n\t{\r\n\t\tfclose (sv.demofile);\r\n\t\tsv.demofile = NULL;\r\n\t\tFS_FreeFile (sv.demobuf);\r\n\t\tsv.demosize = sv.demo_ofs = 0;\r\n\t}\r\n\tSV_Nextserver ();\r\n}", "label": 0, "cwe": null, "length": 70 }, { "index": 411356, "code": "md_process_queued_events()\n{\n struct md_queued_event *e;\n\n while((e=event_head)) {\n event_head=e->next;\n md_broker_func(&e->e.event, e->e.mask);\n free(e);\n }\n}", "label": 0, "cwe": null, "length": 55 }, { "index": 547638, "code": "parseGlobals(struct cli_bc *bc, unsigned char *buffer)\n{\n unsigned i, offset = 1, len = strlen((const char*)buffer), numglobals;\n unsigned maxglobal;\n char ok=1;\n\n if (buffer[0] != 'G') {\n\tcli_errmsg(\"bytecode: Invalid globals header: %c\\n\", buffer[0]);\n\treturn CL_EMALFDB;\n }\n maxglobal = readNumber(buffer, &offset, len, &ok);\n if (maxglobal > cli_apicall_maxglobal) {\n\tcli_dbgmsg(\"bytecode using global %u, but highest global known to libclamav is %u, skipping\\n\", maxglobal, cli_apicall_maxglobal);\n\treturn CL_BREAK;\n }\n numglobals = readNumber(buffer, &offset, len, &ok);\n bc->globals = cli_calloc(numglobals, sizeof(*bc->globals));\n if (!bc->globals) {\n\tcli_errmsg(\"bytecode: OOM allocating memory for %u globals\\n\", numglobals);\n\treturn CL_EMEM;\n }\n bc->globaltys = cli_calloc(numglobals, sizeof(*bc->globaltys));\n if (!bc->globaltys) {\n\tcli_errmsg(\"bytecode: OOM allocating memory for %u global types\\n\", numglobals);\n\treturn CL_EMEM;\n }\n bc->num_globals = numglobals;\n if (!ok)\n\treturn CL_EMALFDB;\n for (i=0;iglobaltys[i] = readTypeID(bc, buffer, &offset, len, &ok);\n\tcomp = type_components(bc, bc->globaltys[i], &ok);\n\tif (!ok)\n\t return CL_EMALFDB;\n\tbc->globals[i] = cli_malloc(sizeof(*bc->globals[0])*comp);\n\tif (!bc->globals[i])\n\t return CL_EMEM;\n\treadConstant(bc, i, comp, buffer, &offset, len, &ok);\n }\n if (!ok)\n\treturn CL_EMALFDB;\n if (offset != len) {\n\tcli_errmsg(\"Trailing garbage in globals: %d extra bytes\\n\",\n\t\t len-offset);\n\treturn CL_EMALFDB;\n }\n return CL_SUCCESS;\n}", "label": 0, "cwe": null, "length": 482 }, { "index": 870436, "code": "ext4_es_end(struct extent_status *es)\n{\n\tBUG_ON(es->es_lblk + es->es_len < es->es_lblk);\n\treturn es->es_lblk + es->es_len - 1;\n}", "label": 0, "cwe": null, "length": 48 }, { "index": 231075, "code": "load_cma_preset(struct section_file *file, int i)\n{\n struct cm_parameter parameter;\n const char *name =\n secfile_lookup_str_default(file, \"preset\",\n \"cma.preset%d.name\", i);\n\n output_type_iterate(o) {\n parameter.minimal_surplus[o] =\n secfile_lookup_int_default(file, 0, \"cma.preset%d.minsurp%d\", i, o);\n parameter.factor[o] =\n secfile_lookup_int_default(file, 0, \"cma.preset%d.factor%d\", i, o);\n } output_type_iterate_end;\n parameter.require_happy =\n secfile_lookup_bool_default(file, FALSE, \"cma.preset%d.reqhappy\", i);\n parameter.happy_factor =\n secfile_lookup_int_default(file, 0, \"cma.preset%d.happyfactor\", i);\n parameter.allow_disorder = FALSE;\n parameter.allow_specialists = TRUE;\n\n cmafec_preset_add(name, ¶meter);\n}", "label": 0, "cwe": null, "length": 217 }, { "index": 735563, "code": "do_syslog(void)\n{\n\tstruct log_msg_t *msg;\n\n\twhile (1) {\n\t\tspin_lock(&queue_lock);\n\t\tif (list_empty(&msg_queue)) {\n\t\t\tsleeping = 1;\n\t\t\tspin_unlock(&queue_lock);\n\t\t\tif (need_close)\n\t\t\t\ttriton_context_unregister(&syslog_ctx);\n\t\t\treturn;\n\t\t}\n\n\t\tmsg = list_entry(msg_queue.next, typeof(*msg), entry);\n\t\tlist_del(&msg->entry);\n\t\t--queue_size;\n\t\tspin_unlock(&queue_lock);\n\n\t\tunpack_msg(msg);\n\t\tsyslog(prio_map[msg->level], \"%s\", log_buf);\n\t\tlog_free_msg(msg);\n\t}\n}", "label": 0, "cwe": null, "length": 139 }, { "index": 72199, "code": "TemplateTriangulation()\n{\n TemplatesIterator titer = this->Templates->find(this->CellType);\n if ( titer != this->Templates->end() ) //something found\n {\n TemplateIDType index = this->ComputeTemplateIndex();\n TemplateList *tlist = (*titer).second;\n TemplateListIterator tlistIter=tlist->find(index);\n if ( tlistIter != tlist->end() ) //something found\n {\n int i, j;\n OTTemplate *tets = (*tlistIter).second;\n vtkIdType numTets = tets->NumberOfTetras;\n vtkIdType *clist = tets->Tetras;\n OTTetra *tetra;\n for (i=0; iHeap) OTTetra();\n this->Mesh->Tetras.push_front(tetra);\n tetra->Type = OTTetra::Inside;\n for (j=0; j<4; j++)\n {\n tetra->Points[j] = this->Mesh->Points.GetPointer(*clist++);\n }\n }//for all tetras in template\n return 1;\n }//if a template found\n }//if a template list for this cell type found\n\n return 0;\n}", "label": 0, "cwe": null, "length": 290 }, { "index": 64380, "code": "ProjectPointsToPlane()\n{\n if ( this->ProjectionNormal == VTK_PROJECTION_OBLIQUE )\n {\n if ( this->PlaneSource != NULL )\n {\n this->ProjectPointsToObliquePlane();\n }\n else\n {\n vtkGenericWarningMacro(<<\"Set the plane source for oblique projections...\");\n }\n }\n else\n {\n this->ProjectPointsToOrthoPlane();\n }\n}", "label": 0, "cwe": null, "length": 92 }, { "index": 252, "code": "mem_stat_reg_list(var,type,list)\nvoid **var;\nint type,list;\n{\n int n;\n\n if ( list < 0 || list >= MEM_CONNECT_MAX_LISTS )\n return -1;\n\n if (mem_stat_mark_curr == 0) return 0; /* not registered */\n if (var == NULL) return -1; /* error */\n\n if ( type < 0 || type >= mem_connect[list].ntypes || \n mem_connect[list].free_funcs[type] == NULL )\n {\n warning(WARN_WRONG_TYPE,\"mem_stat_reg_list\");\n return -1;\n }\n \n if ((n = mem_lookup(var)) >= 0) {\n mem_stat_var[n].var = var;\n mem_stat_var[n].mark = mem_stat_mark_curr;\n mem_stat_var[n].type = type;\n /* save n+1, not n */\n mem_hash_idx[mem_hash_idx_end++] = n+1;\n }\n\n return mem_stat_mark_curr;\n}", "label": 0, "cwe": null, "length": 212 }, { "index": 95968, "code": "bind_bytecoded_builtins(block b) {\n block builtins = gen_noop();\n {\n struct bytecoded_builtin builtin_defs[] = {\n {\"empty\", gen_op_simple(BACKTRACK)},\n {\"false\", gen_const(jv_false())},\n {\"true\", gen_const(jv_true())},\n {\"null\", gen_const(jv_null())},\n {\"not\", gen_condbranch(gen_const(jv_false()),\n gen_const(jv_true()))}\n };\n for (unsigned i=0; idev, res);\n\tif (IS_ERR(regs))\n\t\treturn PTR_ERR(regs);\n\n\t/*\n\t * Allocate our watchdog driver data, which has the\n\t * struct watchdog_device nested within it.\n\t */\n\twdt = devm_kzalloc(&pdev->dev, sizeof(*wdt), GFP_KERNEL);\n\tif (!wdt)\n\t\treturn -ENOMEM;\n\n\t/* Initialize struct tegra_wdt. */\n\twdt->wdt_regs = regs + WDT_BASE;\n\twdt->tmr_regs = regs + WDT_TIMER_BASE;\n\n\t/* Initialize struct watchdog_device. */\n\twdd = &wdt->wdd;\n\twdd->timeout = heartbeat;\n\twdd->info = &tegra_wdt_info;\n\twdd->ops = &tegra_wdt_ops;\n\twdd->min_timeout = MIN_WDT_TIMEOUT;\n\twdd->max_timeout = MAX_WDT_TIMEOUT;\n\twdd->parent = &pdev->dev;\n\n\twatchdog_set_drvdata(wdd, wdt);\n\n\twatchdog_set_nowayout(wdd, nowayout);\n\n\tret = watchdog_register_device(wdd);\n\tif (ret) {\n\t\tdev_err(&pdev->dev,\n\t\t\t\"failed to register watchdog device\\n\");\n\t\treturn ret;\n\t}\n\n\tplatform_set_drvdata(pdev, wdt);\n\n\tdev_info(&pdev->dev,\n\t\t \"initialized (heartbeat = %d sec, nowayout = %d)\\n\",\n\t\t heartbeat, nowayout);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 380 }, { "index": 680413, "code": "FindAliasInfo(SDNode *N,\n SDValue &Ptr, int64_t &Size,\n const Value *&SrcValue,\n int &SrcValueOffset,\n unsigned &SrcValueAlign,\n const MDNode *&TBAAInfo) const {\n if (LoadSDNode *LD = dyn_cast(N)) {\n Ptr = LD->getBasePtr();\n Size = LD->getMemoryVT().getSizeInBits() >> 3;\n SrcValue = LD->getSrcValue();\n SrcValueOffset = LD->getSrcValueOffset();\n SrcValueAlign = LD->getOriginalAlignment();\n TBAAInfo = LD->getTBAAInfo();\n return true;\n }\n if (StoreSDNode *ST = dyn_cast(N)) {\n Ptr = ST->getBasePtr();\n Size = ST->getMemoryVT().getSizeInBits() >> 3;\n SrcValue = ST->getSrcValue();\n SrcValueOffset = ST->getSrcValueOffset();\n SrcValueAlign = ST->getOriginalAlignment();\n TBAAInfo = ST->getTBAAInfo();\n return false;\n }\n llvm_unreachable(\"FindAliasInfo expected a memory operand\");\n}", "label": 0, "cwe": null, "length": 260 }, { "index": 525560, "code": "index(int row, int column, const QModelIndex& parent) const\n{\n if ( ! hasIndex( row, column, parent ) ) {\n return QModelIndex();\n }\n ActionCollection* par = parent.isValid() ? collection( parent ) : d->collection.data();\n if ( par == 0 ) {\n // safety: may happen if parent index is an action (ModelTest tests this)\n return QModelIndex();\n }\n return createIndex( row, column, par );\n}", "label": 0, "cwe": null, "length": 102 }, { "index": 281395, "code": "m62_start( void (*tile_get_info)( int memory_offset ), int rows, int cols, int x1, int y1, int x2, int y2 )\r\n{\r\n\tm62_background = tilemap_create( tile_get_info, tilemap_scan_rows, TILEMAP_TRANSPARENT, x1, y1, x2, y2 );\r\n\tif( !m62_background )\r\n\t{\r\n\t\treturn 1;\r\n\t}\r\n\r\n\tm62_background_hscroll = 0;\r\n\tm62_background_vscroll = 0;\r\n\r\n\tregister_savestate();\r\n\r\n\tif( rows != 0 )\r\n\t{\r\n\t\ttilemap_set_scroll_rows( m62_background, rows );\r\n\t}\r\n\tif( cols != 0 )\r\n\t{\r\n\t\ttilemap_set_scroll_cols( m62_background, cols );\r\n\t}\r\n\r\n\treturn 0;\r\n}", "label": 0, "cwe": null, "length": 164 }, { "index": 35206, "code": "InfpGetMultiSzField(PINFCONTEXT Context,\n ULONG FieldIndex,\n PWSTR ReturnBuffer,\n ULONG ReturnBufferSize,\n PULONG RequiredSize)\n{\n PINFCACHELINE CacheLine;\n PINFCACHEFIELD CacheField;\n PINFCACHEFIELD FieldPtr;\n ULONG Index;\n ULONG Size;\n PWCHAR Ptr;\n\n if (Context == NULL || Context->Line == NULL || FieldIndex == 0)\n {\n DPRINT(\"Invalid parameter\\n\");\n return INF_STATUS_INVALID_PARAMETER;\n }\n\n if (RequiredSize != NULL)\n *RequiredSize = 0;\n\n CacheLine = (PINFCACHELINE)Context->Line;\n\n if (FieldIndex > (ULONG)CacheLine->FieldCount)\n return INF_STATUS_INVALID_PARAMETER;\n\n CacheField = CacheLine->FirstField;\n for (Index = 1; Index < FieldIndex; Index++)\n CacheField = CacheField->Next;\n\n /* Calculate the required buffer size */\n FieldPtr = CacheField;\n Size = 0;\n while (FieldPtr != NULL)\n {\n Size += ((ULONG)strlenW(FieldPtr->Data) + 1);\n FieldPtr = FieldPtr->Next;\n }\n Size++;\n\n if (RequiredSize != NULL)\n *RequiredSize = Size;\n\n if (ReturnBuffer != NULL)\n {\n if (ReturnBufferSize < Size)\n return INF_STATUS_BUFFER_OVERFLOW;\n\n /* Copy multi-sz string */\n Ptr = ReturnBuffer;\n FieldPtr = CacheField;\n while (FieldPtr != NULL)\n {\n Size = (ULONG)strlenW(FieldPtr->Data) + 1;\n\n strcpyW(Ptr, FieldPtr->Data);\n\n Ptr = Ptr + Size;\n FieldPtr = FieldPtr->Next;\n }\n *Ptr = 0;\n }\n\n return INF_STATUS_SUCCESS;\n}", "label": 1, "cwe": "CWE-120", "length": 391 }, { "index": 560594, "code": "afs_alloc_inode(struct super_block *sb)\n{\n\tstruct afs_vnode *vnode;\n\n\tvnode = kmem_cache_alloc(afs_inode_cachep, GFP_KERNEL);\n\tif (!vnode)\n\t\treturn NULL;\n\n\tatomic_inc(&afs_count_active_inodes);\n\n\tmemset(&vnode->fid, 0, sizeof(vnode->fid));\n\tmemset(&vnode->status, 0, sizeof(vnode->status));\n\n\tvnode->volume\t\t= NULL;\n\tvnode->update_cnt\t= 0;\n\tvnode->flags\t\t= 1 << AFS_VNODE_UNSET;\n\tvnode->cb_promised\t= false;\n\n\t_leave(\" = %p\", &vnode->vfs_inode);\n\treturn &vnode->vfs_inode;\n}", "label": 0, "cwe": null, "length": 155 }, { "index": 754341, "code": "f1x_swap_interleaved_region(struct amd64_pvt *pvt, u64 sys_addr)\n{\n\tu32 swap_reg, swap_base, swap_limit, rgn_size, tmp_addr;\n\n\tif (pvt->fam == 0x10) {\n\t\t/* only revC3 and revE have that feature */\n\t\tif (pvt->model < 4 || (pvt->model < 0xa && pvt->stepping < 3))\n\t\t\treturn sys_addr;\n\t}\n\n\tamd64_read_pci_cfg(pvt->F2, SWAP_INTLV_REG, &swap_reg);\n\n\tif (!(swap_reg & 0x1))\n\t\treturn sys_addr;\n\n\tswap_base\t= (swap_reg >> 3) & 0x7f;\n\tswap_limit\t= (swap_reg >> 11) & 0x7f;\n\trgn_size\t= (swap_reg >> 20) & 0x7f;\n\ttmp_addr\t= sys_addr >> 27;\n\n\tif (!(sys_addr >> 34) &&\n\t (((tmp_addr >= swap_base) &&\n\t (tmp_addr <= swap_limit)) ||\n\t (tmp_addr < rgn_size)))\n\t\treturn sys_addr ^ (u64)swap_base << 27;\n\n\treturn sys_addr;\n}", "label": 0, "cwe": null, "length": 266 }, { "index": 1810, "code": "writeToStream(mrpt::utils::CStream &out, int *version) const\n{\n\tif (version)\n\t\t*version = 0;\n\telse\n\t{\n\t\t// Acquire all critical sections before!\n\t\t// -------------------------------------------\n\t\t//std::map< THypothesisID, CLocalMetricHypothesis >::const_iterator it;\n\n\t\t//CCriticalSectionLocker LMHs( & m_LMHs_cs );\n\t\t//for (it=m_LMHs.begin();it!=m_LMHs.end();it++) it->second.m_lock.enter();\n\n\t\tCCriticalSectionLocker lock_map( &m_map_cs );\n\n\t\t// Data:\n\t\tout << m_nextAreaLabel\n\t\t\t<< m_nextPoseID\n\t\t\t<< m_nextHypID;\n\n\t\t// The HMT-MAP:\n\t\tout << m_map;\n\n\t\t// The LMHs:\n\t\tout << m_LMHs;\n\n\t\t// Save options??? Better allow changing them...\n\n\t\t// Release all critical sections:\n\t\t//for (it=m_LMHs.begin();it!=m_LMHs.end();it++) it->second.m_lock.enter();\n\n\n\t}\n}", "label": 0, "cwe": null, "length": 248 }, { "index": 539892, "code": "SpawnerSummon(Creature* pSummoner)\n {\n if (m_uiRitualPhase > 7)\n {\n pSummoner->SummonCreature(NPC_PLAGUEMAW_THE_ROTTING, pSummoner->GetPositionX(), pSummoner->GetPositionY(), pSummoner->GetPositionZ(), pSummoner->GetOrientation(), TEMPSUMMON_TIMED_OOC_DESPAWN, 60000);\n return;\n }\n\n for (int i = 0; i < 4; ++i)\n {\n uint32 uiEntry = 0;\n\n // ref TARGET_RANDOM_CIRCUMFERENCE_POINT\n float angle = 2.0f * M_PI_F * rand_norm_f();\n float fX, fZ, fY;\n pSummoner->GetClosePoint(fX, fZ, fY, 0.0f, 2.0f, angle);\n\n switch (i)\n {\n case 0:\n case 1:\n uiEntry = NPC_WITHERED_BATTLE_BOAR;\n break;\n case 2:\n uiEntry = NPC_WITHERED_QUILGUARD;\n break;\n case 3:\n uiEntry = NPC_DEATHS_HEAD_GEOMANCER;\n break;\n }\n\n pSummoner->SummonCreature(uiEntry, fX, fZ, fY, 0.0f, TEMPSUMMON_TIMED_OOC_DESPAWN, 60000);\n }\n }", "label": 0, "cwe": null, "length": 319 }, { "index": 122491, "code": "flite_voice_list_print(void)\n{\n cst_voice *voice;\n const cst_val *v;\n\n printf(\"Voices available: \");\n for (v=flite_voice_list; v; v=val_cdr(v))\n {\n voice = val_voice(val_car(v));\n printf(\"%s \",voice->name);\n }\n printf(\"\\n\");\n\n return;\n}", "label": 0, "cwe": null, "length": 79 }, { "index": 67069, "code": "rl_vi_change_case (count, ignore)\n int count, ignore;\n{\n int c, p;\n\n /* Don't try this on an empty line. */\n if (rl_point >= rl_end)\n return (0);\n\n c = 0;\n#if defined (HANDLE_MULTIBYTE)\n if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)\n return (_rl_vi_change_mbchar_case (count));\n#endif\n\n while (count-- && rl_point < rl_end)\n {\n if (_rl_uppercase_p (rl_line_buffer[rl_point]))\n\tc = _rl_to_lower (rl_line_buffer[rl_point]);\n else if (_rl_lowercase_p (rl_line_buffer[rl_point]))\n\tc = _rl_to_upper (rl_line_buffer[rl_point]);\n else\n\t{\n\t /* Just skip over characters neither upper nor lower case. */\n\t rl_forward_char (1, c);\n\t continue;\n\t}\n\n /* Vi is kind of strange here. */\n if (c)\n\t{\n\t p = rl_point;\n\t rl_begin_undo_group ();\n\t rl_vi_delete (1, c);\n\t if (rl_point < p)\t/* Did we retreat at EOL? */\n\t rl_point++;\n\t _rl_insert_char (1, c);\n\t rl_end_undo_group ();\n\t rl_vi_check ();\n\t}\n else\n\trl_forward_char (1, c);\n }\n return (0);\n}", "label": 0, "cwe": null, "length": 302 }, { "index": 98879, "code": "c_ncdid (\n int ncid,\t\t/* netCDF ID */\n const char *dimname,/* dimension name */\n int *rcode\t\t/* returned error code */\n)\n{\n int dimid;\n\n if ((dimid = ncdimid (ncid, dimname)) == -1)\n\t*rcode = ncerr;\n else\n {\n\tdimid++;\n\t*rcode = 0;\n }\n\n return dimid;\n}", "label": 0, "cwe": null, "length": 96 }, { "index": 256414, "code": "mouse_clck_action(int mk_state, int x1, int y1)\n{\n if ( mk_state & MK_CONTROL )\n theControlCenter->getRenderer()->processSelection(MOUSE_CTRL_CLCK, mk_state, x1, y1);\n //else if ( mk_state & MK_SHIFT)\n // theControlCenter->getRenderer()->processSelection(MOUSE_SHFT_CLCK, mk_state, x1, y1);\n}", "label": 0, "cwe": null, "length": 92 }, { "index": 392678, "code": "QueryMemoryBySysconf()\n{\n#if defined(_SC_PHYS_PAGES) && defined(_SC_PAGESIZE)\n // Assume the mmap() granularity as returned by _SC_PAGESIZE is also\n // the system page size. The only known system where this isn't true\n // is Cygwin.\n long p = sysconf(_SC_PHYS_PAGES);\n long m = sysconf(_SC_PAGESIZE);\n\n if (p < 0 || m < 0)\n {\n return false;\n }\n\n // assume pagesize is a power of 2 and smaller 1 MiB\n size_t pagediv = (1024 * 1024 / m);\n\n this->TotalPhysicalMemory = p;\n this->TotalPhysicalMemory /= pagediv;\n\n#if defined(_SC_AVPHYS_PAGES)\n p = sysconf(_SC_AVPHYS_PAGES);\n if (p < 0)\n {\n return false;\n }\n\n this->AvailablePhysicalMemory = p;\n this->AvailablePhysicalMemory /= pagediv;\n#endif\n\n return true;\n#else\n return false;\n#endif\n}", "label": 0, "cwe": null, "length": 233 }, { "index": 608645, "code": "find_auth_cookie (FILE *f)\n{\n Xauth *ret = NULL;\n char local_hostname[MaxHostNameLen];\n char *display_str = getenv(\"DISPLAY\");\n char d[MaxHostNameLen + 4];\n char *colon;\n struct addrinfo *ai;\n struct addrinfo hints;\n int disp;\n int error;\n\n if(display_str == NULL)\n\tdisplay_str = \":0\";\n strlcpy(d, display_str, sizeof(d));\n display_str = d;\n colon = strchr (display_str, ':');\n if (colon == NULL)\n\tdisp = 0;\n else {\n\t*colon = '\\0';\n\tdisp = atoi (colon + 1);\n }\n if (strcmp (display_str, \"\") == 0\n\t|| strncmp (display_str, \"unix\", 4) == 0\n\t|| strncmp (display_str, \"localhost\", 9) == 0) {\n\tgethostname (local_hostname, sizeof(local_hostname));\n\tdisplay_str = local_hostname;\n }\n memset (&hints, 0, sizeof(hints));\n hints.ai_flags = AI_CANONNAME;\n hints.ai_socktype = SOCK_STREAM;\n hints.ai_protocol = IPPROTO_TCP;\n\n error = getaddrinfo (display_str, NULL, &hints, &ai);\n if (error)\n\tai = NULL;\n\n for (; (ret = XauReadAuth (f)) != NULL; XauDisposeAuth(ret)) {\n\tif (match_local_auth (ret, ai, display_str, disp) == 0) {\n\t if (ai != NULL)\n\t\tfreeaddrinfo (ai);\n\t return ret;\n\t}\n }\n if (ai != NULL)\n\tfreeaddrinfo (ai);\n return NULL;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-469", "CWE-other" ], "length": 367 }, { "index": 48583, "code": "TIFFReadRGBAImageOriented(TIFF* tif,\n\t\t\t uint32 rwidth, uint32 rheight, uint32* raster,\n\t\t\t int orientation, int stop)\n{\n char emsg[1024] = \"\";\n TIFFRGBAImage img;\n int ok;\n\n\tif (TIFFRGBAImageOK(tif, emsg) && TIFFRGBAImageBegin(&img, tif, stop, emsg)) {\n\t\timg.req_orientation = orientation;\n\t\t/* XXX verify rwidth and rheight against width and height */\n\t\tok = TIFFRGBAImageGet(&img, raster+(rheight-img.height)*rwidth,\n\t\t\trwidth, img.height);\n\t\tTIFFRGBAImageEnd(&img);\n\t} else {\n\t\tTIFFErrorExt(tif->tif_clientdata, TIFFFileName(tif), \"%s\", emsg);\n\t\tok = 0;\n }\n return (ok);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 188 }, { "index": 309285, "code": "qla24xx_update_fcport_fcp_prio(scsi_qla_host_t *vha, fc_port_t *fcport)\n{\n\tint ret;\n\tint priority;\n\tuint16_t mb[5];\n\n\tif (fcport->port_type != FCT_TARGET ||\n\t fcport->loop_id == FC_NO_LOOP_ID)\n\t\treturn QLA_FUNCTION_FAILED;\n\n\tpriority = qla24xx_get_fcp_prio(vha, fcport);\n\tif (priority < 0)\n\t\treturn QLA_FUNCTION_FAILED;\n\n\tif (IS_P3P_TYPE(vha->hw)) {\n\t\tfcport->fcp_prio = priority & 0xf;\n\t\treturn QLA_SUCCESS;\n\t}\n\n\tret = qla24xx_set_fcp_prio(vha, fcport->loop_id, priority, mb);\n\tif (ret == QLA_SUCCESS) {\n\t\tif (fcport->fcp_prio != priority)\n\t\t\tql_dbg(ql_dbg_user, vha, 0x709e,\n\t\t\t \"Updated FCP_CMND priority - value=%d loop_id=%d \"\n\t\t\t \"port_id=%02x%02x%02x.\\n\", priority,\n\t\t\t fcport->loop_id, fcport->d_id.b.domain,\n\t\t\t fcport->d_id.b.area, fcport->d_id.b.al_pa);\n\t\tfcport->fcp_prio = priority & 0xf;\n\t} else\n\t\tql_dbg(ql_dbg_user, vha, 0x704f,\n\t\t \"Unable to update FCP_CMND priority - ret=0x%x for \"\n\t\t \"loop_id=%d port_id=%02x%02x%02x.\\n\", ret, fcport->loop_id,\n\t\t fcport->d_id.b.domain, fcport->d_id.b.area,\n\t\t fcport->d_id.b.al_pa);\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 392 }, { "index": 1993, "code": "block_BINARY_RECV(worker_t * worker, worker_t *parent, apr_pool_t *ptmp) {\n apr_pool_t *pool;\n apr_status_t status;\n apr_size_t recv_len;\n apr_size_t peeklen;\n sockreader_t *sockreader;\n char *buf;\n const char *val;\n\n int poll = 0;\n\n val = store_get(worker->params, \"1\");\n /* must be a number */\n recv_len = apr_atoi64(val);\n\n apr_pool_create(&pool, NULL);\n\n if (worker->socket->sockreader == NULL) {\n peeklen = worker->socket->peeklen;\n worker->socket->peeklen = 0;\n if ((status = sockreader_new(&worker->socket->sockreader, \n worker->socket->transport,\n\t\t\t\t worker->socket->peek, peeklen)) \n != APR_SUCCESS) {\n goto out_err;\n }\n }\n sockreader = worker->socket->sockreader;\n\n if ((status = content_length_reader(sockreader, &buf, &recv_len, \"\")) != APR_SUCCESS) {\n if (poll && APR_STATUS_IS_INCOMPLETE(status)) {\n status = APR_SUCCESS;\n }\n else {\n goto out_err;\n }\n }\n\n worker->flags |= FLAGS_PRINT_HEX;\n if ((status = worker_handle_buf(worker, pool, buf, recv_len)) \n != APR_SUCCESS) {\n goto out_err;\n }\n\nout_err:\n status = worker_assert(worker, status);\n apr_pool_destroy(pool);\n\n return status;\n}", "label": 0, "cwe": null, "length": 330 }, { "index": 65485, "code": "snippets_group_new (const gchar* snippets_group_name)\n{\n\tAnjutaSnippetsGroup* snippets_group = NULL;\n\tAnjutaSnippetsGroupPrivate *priv = NULL;\n\n\t/* Assertions */\n\tg_return_val_if_fail (snippets_group_name != NULL, NULL);\n\t\n\t/* Initialize the object */\n\tsnippets_group = ANJUTA_SNIPPETS_GROUP (g_object_new (snippets_group_get_type (), NULL));\n\tpriv = ANJUTA_SNIPPETS_GROUP_GET_PRIVATE (snippets_group);\n\n\t/* Copy the name, description and filename */\n\tpriv->name = g_strdup (snippets_group_name);\n\t\n\treturn snippets_group;\n}", "label": 0, "cwe": null, "length": 136 }, { "index": 10094, "code": "IsInside(const Self & region) const\n{\n IndexType beginCorner = region.GetIndex();\n\n if ( !this->IsInside(beginCorner) )\n {\n return false;\n }\n IndexType endCorner(region.m_ImageDimension);\n SizeType size = region.GetSize();\n for ( unsigned int i = 0; i < m_ImageDimension; i++ )\n {\n endCorner[i] = beginCorner[i] + size[i] - 1;\n }\n if ( !this->IsInside(endCorner) )\n {\n return false;\n }\n return true;\n}", "label": 0, "cwe": null, "length": 126 }, { "index": 567890, "code": "bfad_init(void)\n{\n\tint\t\terror = 0;\n\n\tprintk(KERN_INFO \"Brocade BFA FC/FCOE SCSI driver - version: %s\\n\",\n\t\t\tBFAD_DRIVER_VERSION);\n\n\tif (num_sgpgs > 0)\n\t\tnum_sgpgs_parm = num_sgpgs;\n\n\terror = bfad_im_module_init();\n\tif (error) {\n\t\terror = -ENOMEM;\n\t\tprintk(KERN_WARNING \"bfad_im_module_init failure\\n\");\n\t\tgoto ext;\n\t}\n\n\tif (strcmp(FCPI_NAME, \" fcpim\") == 0)\n\t\tsupported_fc4s |= BFA_LPORT_ROLE_FCP_IM;\n\n\tbfa_auto_recover = ioc_auto_recover;\n\tbfa_fcs_rport_set_del_timeout(rport_del_timeout);\n\tbfa_fcs_rport_set_max_logins(max_rport_logins);\n\n\terror = pci_register_driver(&bfad_pci_driver);\n\tif (error) {\n\t\tprintk(KERN_WARNING \"pci_register_driver failure\\n\");\n\t\tgoto ext;\n\t}\n\n\treturn 0;\n\next:\n\tbfad_im_module_exit();\n\treturn error;\n}", "label": 0, "cwe": null, "length": 226 }, { "index": 293046, "code": "setat(const int n, const char ch)\n{\n if((!n)&&(!ptr))\n {\n init(GStringRep::Native::create(&ch,0,1));\n }else\n {\n init((*this)->setat(CheckSubscript(n),ch));\n }\n}", "label": 0, "cwe": null, "length": 63 }, { "index": 994964, "code": "GenerateUserXorMessage()\n {\n QByteArray msg;\n uint size = static_cast(_slot_signing_keys.size());\n\n _server_alibi_data.StorePhaseRngByteIndex(_rngs_with_servers[0]->BytesGenerated());\n\n /* For each slot */\n for(uint idx = 0; idx < size; idx++) {\n uint length = _message_lengths[idx] + _header_lengths[idx];\n QByteArray slot_msg(length, 0);\n //qDebug() << \"=> STORE BYTES Phase\" << _phase << \" Slot\" << idx << \"Bytes=\" << _rngs_with_servers[0]->BytesGenerated();\n\n /* For each server, XOR that server's pad with the empty message */\n for(int server_idx = 0; server_idx < _rngs_with_servers.count(); server_idx++) {\n QByteArray server_pad = GeneratePadWithServer(server_idx, length);\n \n //qDebug() << \"user ciphertext for slot\" << idx;\n _user_alibi_data.StoreMessage(_phase, idx, server_idx, server_pad);\n Xor(slot_msg, slot_msg, server_pad);\n }\n qDebug() << \"slot\" << idx;\n\n /* This is my slot */\n if(idx == _my_idx) {\n QByteArray my_msg = GenerateMyCleartextMessage();\n Xor(slot_msg, slot_msg, my_msg);\n }\n\n msg.append(slot_msg);\n //qDebug() << \"XOR length\" << msg.count();\n }\n\n return msg;\n }", "label": 0, "cwe": null, "length": 317 }, { "index": 534290, "code": "rlgets(char *s, size_t n, const char *prompt)\n{\n static char *line = (char *) NULL;\n static int leftover = -1;\t/* index of 1st char leftover from last call */\n\n if (leftover == -1) {\n\t/* If we already have a line, first free it */\n\tif (line != (char *) NULL) {\n\t free(line);\n\t line = NULL;\n\t /* so that ^C or int_error during readline() does\n\t * not result in line being free-ed twice */\n\t}\n\tline = readline_ipc((interactive) ? prompt : \"\");\n\tleftover = 0;\n\t/* If it's not an EOF */\n\tif (line && *line) {\n# if defined(HAVE_LIBREADLINE)\n\t int found;\n\t /* Initialize readline history functions */\n\t using_history();\n\n\t /* search in the history for entries containing line.\n\t * They may have other tokens before and after line, hence\n\t * the check on strcmp below. */\n\t found = history_search(line, -1);\n\t if (found != -1 && !strcmp(current_history()->line,line)) {\n\t\t/* this line is already in the history, remove the earlier entry */\n\t\tHIST_ENTRY *removed = remove_history(where_history());\n\t\t/* according to history docs we are supposed to free the stuff */\n\t\tif (removed) {\n\t\t free(removed->line);\n\t\t free(removed->data);\n\t\t free(removed);\n\t\t}\n\t }\n\t add_history(line);\n# elif defined(HAVE_LIBEDITLINE)\n\t /* deleting history entries does not work, so suppress adjacent \n\t duplicates only */\n \n\t int found;\n\t using_history();\n\n\t found = history_search(line, -1);\n\t if (found <= 0) {\n add_history(line);\n }\n# else /* builtin readline */\n\t add_history(line);\n# endif\n\t}\n }\n if (line) {\n\t/* s will be NUL-terminated here */\n\tsafe_strncpy(s, line + leftover, n);\n\tleftover += strlen(s);\n\tif (line[leftover] == NUL)\n\t leftover = -1;\n\treturn s;\n }\n return NULL;\n}", "label": 0, "cwe": null, "length": 459 }, { "index": 299361, "code": "cbf_count_typed_children (unsigned int *children, const cbf_node *node, CBF_NODETYPE type)\n{\n\n int i;\n\n /* Follow any links */\n\n node = cbf_get_link (node);\n\n\n /* Check the arguments */\n\n if (!children || !node || node->type == CBF_COLUMN)\n\n return CBF_ARGUMENT;\n\n /* Run through the children */\n\n *children = 0;\n\n for (i=0; i < node->children; i++) {\n\n if ( (node->child[i])->type == type ) (*children)++;\n\n }\n\n /* Success */\n\n return 0;\n}", "label": 0, "cwe": null, "length": 134 }, { "index": 255055, "code": "needs_quote(int ch)\n{\n\tif (((ch >= 'A') && (ch <= 'Z'))\n\t\t\t|| ((ch >= 'a') && (ch <= 'z'))\n\t\t\t|| ((ch >= '0') && (ch <= '9'))\n\t\t\t|| (ch == '/')\n\t\t\t|| (ch == '-')\n\t\t\t|| (ch == '.'))\n\t\treturn 0;\n\treturn 1;\n}", "label": 0, "cwe": null, "length": 85 }, { "index": 694769, "code": "applyActionProperties( const QDomElement &actionPropElement,\n ShortcutOption shortcutOption )\n{\n for (QDomElement e = actionPropElement.firstChildElement();\n !e.isNull(); e = e.nextSiblingElement()) {\n if ( !equals(e.tagName(), \"action\") )\n continue;\n\n QAction *action = guiClient->action( e );\n if ( !action )\n continue;\n\n configureAction( action, e.attributes(), shortcutOption );\n }\n}", "label": 0, "cwe": null, "length": 97 }, { "index": 761544, "code": "initMt() //compute the transposed entries (by rows)\n{\n int i, j;\n\n mt.clear();\n mt.resize(m.size());\n\n for(i = 0; i < (int)m.size(); ++i) {\n for(j = 0; j < (int)m[i].size(); ++j) {\n mt[m[i][j].first].push_back(make_pair(i, m[i][j].second));\n }\n }\n}", "label": 0, "cwe": null, "length": 97 }, { "index": 803870, "code": "getportnum(char *portnum)\n{\n\tchar\t\t\t*digits = portnum;\n\tstruct servent\t*serv;\n\tshort\t\t\tport;\n\n\tfor (port = 0; isdigit(*digits); ++digits)\n\t\t{\n\t\t\tport = (port * 10) + (*digits - '0');\n\t\t}\n\n\tif ((*digits != '\\0') || (port <= 0))\n\t\t{\n\t\t\tif ((serv = getservbyname(portnum, \"tcp\")) != NULL)\n\t\t\t\t{\n\t\t\t\t\tport = ntohs(serv->s_port);\n\t\t\t\t}\n\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tport = -1;\n\t\t\t\t}\n\t\t\tendservent();\n\t\t}\n\n#if DEBUG\n\tfprintf(stderr, \"Port lookup %s -> %hd\\n\", portnum, port);\n#endif\n\n\treturn (port);\n}", "label": 0, "cwe": null, "length": 168 }, { "index": 128535, "code": "update_button (CEPolkitButton *self, gboolean actionable)\n{\n\tCEPolkitButtonPrivate *priv = CE_POLKIT_BUTTON_GET_PRIVATE (self);\n\n\tgtk_widget_set_sensitive (GTK_WIDGET (self), actionable);\n\n\tif (priv->authorized) {\n\t\tgtk_button_set_label (GTK_BUTTON (self), priv->auth_label);\n\t\tgtk_widget_set_tooltip_text (GTK_WIDGET (self), priv->auth_tooltip);\n\t\tgtk_button_set_image (GTK_BUTTON (self), priv->auth);\n\t} else {\n\t\tgtk_button_set_label (GTK_BUTTON (self), priv->label);\n\t\tgtk_widget_set_tooltip_text (GTK_WIDGET (self), priv->tooltip);\n\t\tgtk_button_set_image (GTK_BUTTON (self), priv->stock);\n\t}\n}", "label": 0, "cwe": null, "length": 153 }, { "index": 155290, "code": "replica_updatedn_list_ismember(ReplicaUpdateDNList list, const Slapi_DN *dn)\n{\n\tPLHashTable *hash = list;\n\tPRBool ret = PR_FALSE;\n\n\tconst char *ndn = slapi_sdn_get_ndn(dn);\n\n\t/* Bug 605169 - null ndn would cause core dump */\n\tif ( ndn ) {\n\t\tret = (PRBool)((uintptr_t)PL_HashTableLookupConst(hash, ndn));\n\t}\n\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 106 }, { "index": 741691, "code": "SecondDerivative(Spline *s,bigreal t) {\n /* That is d2y/dx2, not d2y/dt2 */\n\n /* dy/dx = (dy/dt) / (dx/dt) */\n /* d2 y/dx2 = d(dy/dx)/dt / (dx/dt) */\n /* d2 y/dx2 = ((d2y/dt2)*(dx/dt) - (dy/dt)*(d2x/dt2))/ (dx/dt)^2 */\n\n /* dy/dt = 3 ay *t^2 + 2 by * t + cy */\n /* dx/dt = 3 ax *t^2 + 2 bx * t + cx */\n /* d2y/dt2 = 6 ay *t + 2 by */\n /* d2x/dt2 = 6 ax *t + 2 bx */\n bigreal dydt = (3*s->splines[1].a*t + 2*s->splines[1].b)*t + s->splines[1].c;\n bigreal dxdt = (3*s->splines[0].a*t + 2*s->splines[0].b)*t + s->splines[0].c;\n bigreal d2ydt2 = 6*s->splines[1].a*t + 2*s->splines[1].b;\n bigreal d2xdt2 = 6*s->splines[0].a*t + 2*s->splines[0].b;\n bigreal top = (d2ydt2*dxdt - dydt*d2xdt2);\n\n if ( dxdt==0 ) {\n\tif ( top==0 )\nreturn( 0 );\n\tif ( top>0 )\nreturn( 1e10 );\nreturn( -1e10 );\n }\n\nreturn( top/(dxdt*dxdt) );\n}", "label": 0, "cwe": null, "length": 415 }, { "index": 350535, "code": "usr_cache_compare_certs(const void *v1, const void *v2)\n{\n const SECItem *c1 = (const SECItem *)v1;\n const SECItem *c2 = (const SECItem *)v2;\n\n return (c1->len == c2 ->len && !memcmp(c1->data, c2->data, c1->len));\n}", "label": 0, "cwe": null, "length": 82 }, { "index": 341872, "code": "test_session_create_many_notify(struct test_session *session)\n{\n\tunsigned int nr;\n\n\tLOG(\"session %p\", session);\n\n\tnr = GPOINTER_TO_UINT(session->fix->user_data);\n\tnr--;\n\tsession->fix->user_data = GUINT_TO_POINTER(nr);\n\n\tif (nr > 0)\n\t\treturn;\n\n\tutil_idle_call(session->fix, util_quit_loop, util_session_destroy);\n}", "label": 0, "cwe": null, "length": 82 }, { "index": 49418, "code": "hash(const char* cp)\n{\n char name[80];\n char* xp = name;\n\n HASH_DECLARE(nh);\n\n while (*cp) {\n\tchar c = *cp++;\n\tif (c == '!')\n\t *xp++ = '_';\n\telse\n\t *xp++ = toupper(c);\n\tHASH_ITERATE(nh, c);\n }\n *xp = '\\0';\n HASH_FINISH(nh);\n\n printf(\"#define\tH_%s\t%uU\\n\", name, nh);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 105 }, { "index": 759052, "code": "initCounterOfCurrentUID()\n{\n /* Code taken from oftime.cc */\n#ifdef HAVE_WINDOWS_H\n /* Windows: no microseconds available, use milliseconds instead */\n SYSTEMTIME timebuf;\n GetSystemTime(&timebuf);\n counterOfCurrentUID = timebuf.wMilliseconds; /* This is in the range 0 - 999 */\n#else /* Unix */\n struct timeval tv;\n if (gettimeofday(&tv, NULL) == 0)\n counterOfCurrentUID = tv.tv_usec; /* This is in the range 0 - 999999 */\n#endif\n /* Do not ever use \"0\" for the counter */\n counterOfCurrentUID++;\n}", "label": 0, "cwe": null, "length": 139 }, { "index": 451391, "code": "strip_whitespace(char * str) {\n\t\n\tint i, j;\n\tfor (i = 0; str[i] != '\\0' && (str[i] == ' ' || str[i] == '\\t'); i++);\n\tif (str[i] == '\\0') {\n\t\tstr[0] = '\\0';\n\t\treturn str;\n\t}\n\tfor (j = strlen(str)-1; str[j] == ' ' || str[j] == '\\t'; j--);\n\tmemmove(str, str+i, j-i+1);\n\tstr[j-i+1] = '\\0';\n\treturn str;\n}", "label": 0, "cwe": null, "length": 123 }, { "index": 261073, "code": "setEncoderTransform(ArPose transformPos)\n{\n myEncoderTransform.setTransform(transformPos);\n myGlobalPose = myEncoderTransform.doTransform(myEncoderPose);\n mySetEncoderTransformCBList.invoke();\n}", "label": 0, "cwe": null, "length": 44 }, { "index": 248298, "code": "usblp_show_ieee1284_id(struct device *dev, struct device_attribute *attr, char *buf)\n{\n\tstruct usb_interface *intf = to_usb_interface(dev);\n\tstruct usblp *usblp = usb_get_intfdata(intf);\n\n\tif (usblp->device_id_string[0] == 0 &&\n\t usblp->device_id_string[1] == 0)\n\t\treturn 0;\n\n\treturn sprintf(buf, \"%s\", usblp->device_id_string+2);\n}", "label": 0, "cwe": null, "length": 108 }, { "index": 289555, "code": "_ibar_focus_prev(IBar *b)\n{\n IBar_Icon *ic, *ic1 = NULL, *ic2 = NULL;\n Eina_List *l;\n \n if (!b->focused) return;\n if (!b->icons) return;\n EINA_LIST_FOREACH(b->icons, l, ic)\n {\n if (ic->focused)\n {\n ic1 = ic;\n break;\n }\n ic2 = ic;\n }\n // wrap to end\n if ((ic1) && (!ic2)) ic2 = eina_list_last_data_get(b->icons);\n if ((ic1) && (ic2) && (ic1 != ic2))\n _ibar_icon_unfocus_focus(ic1, ic2);\n}", "label": 0, "cwe": null, "length": 162 }, { "index": 689219, "code": "phase28_deemp_put(struct snd_kcontrol *kcontrol,\n\t\t\t\tstruct snd_ctl_elem_value *ucontrol)\n{\n\tstruct snd_ice1712 *ice = snd_kcontrol_chip(kcontrol);\n\tint temp, temp2;\n\ttemp = wm_get(ice, WM_DAC_CTRL2);\n\ttemp2 = temp;\n\tif (ucontrol->value.integer.value[0])\n\t\ttemp |= 0xf;\n\telse\n\t\ttemp &= ~0xf;\n\tif (temp != temp2) {\n\t\twm_put(ice, WM_DAC_CTRL2, temp);\n\t\treturn 1;\n\t}\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 125 }, { "index": 72328, "code": "UnBan(Player* player, const char* targetName)\n{\n ObjectGuid guid = player->GetObjectGuid();\n\n if (!IsOn(guid))\n {\n WorldPacket data;\n MakeNotMember(&data);\n SendToOne(&data, guid);\n return;\n }\n\n if (!m_players[guid].IsModerator() && player->GetSession()->GetSecurity() < SEC_GAMEMASTER)\n {\n WorldPacket data;\n MakeNotModerator(&data);\n SendToOne(&data, guid);\n return;\n }\n\n Player* target = sObjectMgr.GetPlayer(targetName);\n if (!target)\n {\n WorldPacket data;\n MakePlayerNotFound(&data, targetName);\n SendToOne(&data, guid);\n return;\n }\n\n ObjectGuid targetGuid = target->GetObjectGuid();\n if (!IsBanned(targetGuid))\n {\n WorldPacket data;\n MakePlayerNotBanned(&data, targetName);\n SendToOne(&data, guid);\n return;\n }\n\n // unban player\n m_banned.erase(targetGuid);\n\n WorldPacket data;\n MakePlayerUnbanned(&data, targetGuid, guid);\n SendToAll(&data);\n}", "label": 0, "cwe": null, "length": 255 }, { "index": 677514, "code": "strv_contains (const gchar * const *strv,\n const gchar *str)\n{\n const gchar * const *p = strv;\n for (p = strv; *p; p++)\n if (g_strcmp0 (*p, str) == 0)\n return TRUE;\n\n return FALSE;\n}", "label": 0, "cwe": null, "length": 69 }, { "index": 102952, "code": "ceph_ioctl_get_layout(struct file *file, void __user *arg)\n{\n\tstruct ceph_inode_info *ci = ceph_inode(file_inode(file));\n\tstruct ceph_ioctl_layout l;\n\tint err;\n\n\terr = ceph_do_getattr(file_inode(file), CEPH_STAT_CAP_LAYOUT, false);\n\tif (!err) {\n\t\tl.stripe_unit = ceph_file_layout_su(ci->i_layout);\n\t\tl.stripe_count = ceph_file_layout_stripe_count(ci->i_layout);\n\t\tl.object_size = ceph_file_layout_object_size(ci->i_layout);\n\t\tl.data_pool = le32_to_cpu(ci->i_layout.fl_pg_pool);\n\t\tl.preferred_osd = (s32)-1;\n\t\tif (copy_to_user(arg, &l, sizeof(l)))\n\t\t\treturn -EFAULT;\n\t}\n\n\treturn err;\n}", "label": 0, "cwe": null, "length": 172 }, { "index": 30882, "code": "ResetDefglobalAction(\n void *theEnv,\n struct constructHeader *theConstruct,\n void *buffer)\n {\n#if MAC_MCW || IBM_MCW || MAC_XCD\n#pragma unused(buffer)\n#endif\n struct defglobal *theDefglobal = (struct defglobal *) theConstruct;\n DATA_OBJECT assignValue;\n\n if (EvaluateExpression(theEnv,theDefglobal->initial,&assignValue))\n {\n assignValue.type = SYMBOL;\n assignValue.value = EnvFalseSymbol(theEnv);\n }\n\n QSetDefglobalValue(theEnv,theDefglobal,&assignValue,FALSE);\n }", "label": 0, "cwe": null, "length": 126 }, { "index": 547830, "code": "VIstart(void)\n{\n intn ret_value = SUCCEED;\n CONSTR(FUNC, \"VIstart\"); /* for HERROR */\n\n /* Don't call this routine again... */\n library_terminate = TRUE;\n\n /* Install atexit() library cleanup routine */\n if (HPregister_term_func(&VPshutdown) != 0)\n HGOTO_ERROR(DFE_CANTINIT, FAIL);\n\n /* Install atexit() library cleanup routine */\n if (HPregister_term_func(&VSPshutdown) != 0)\n HGOTO_ERROR(DFE_CANTINIT, FAIL);\n\ndone:\n if(ret_value == FAIL) \n { /* Error condition cleanup */\n\n } /* end if */\n\n /* Normal function cleanup */\n\n return(ret_value);\n}", "label": 0, "cwe": null, "length": 162 }, { "index": 507381, "code": "Definition (ostream& out) {\n TextGraphic* g = (TextGraphic*) GetGraphicComp()->GetGraphic();\n const char* text = g->GetOriginal();\n int count = strlen(text);\n\n out << \"Begin \" << MARK << \" Text\\n\";\n\n float sep = g->GetLineHeight() - 1; // correct for vert shift\n Transformer corrected, *t = g->GetTransformer();\n corrected.Translate(0., sep);\n\n if (t == nil) {\n g->SetTransformer(&corrected);\n TextGS(out);\n g->SetTransformer(t);\n\n } else {\n t->Reference();\n corrected.Postmultiply(t);\n g->SetTransformer(&corrected);\n TextGS(out);\n g->SetTransformer(t);\n Unref(t);\n }\n\n out << MARK << \"\\n\";\n out << \"[\\n\";\n\n int beg, end, lineSize, nextBeg, ypos = 0;\n\n for (beg = 0; beg < count; beg = nextBeg) {\n GetLine(text, count, beg, end, lineSize, nextBeg);\n const char* string = Filter(&text[beg], end - beg + 1);\n out << \"(\" << string << \")\\n\";\n }\n\n out << \"] Text\\n\";\n out << \"End\\n\\n\";\n\n return out.good();\n}", "label": 0, "cwe": null, "length": 292 }, { "index": 67574, "code": "chunk (LexState *ls) {\n /* chunk -> { stat [';'] } */\n int islast = 0;\n while (!islast && !block_follow(ls->t.token)) {\n islast = stat(ls);\n optional(ls, ';');\n LUA_ASSERT(ls->fs->stacklevel == ls->fs->nactloc,\n \"stack size != # local vars\");\n }\n}", "label": 0, "cwe": null, "length": 86 }, { "index": 29708, "code": "containsControlCharacter(const char *str) {\n while (*str) {\n if (isControlCharacter(*(str++)))\n return true;\n }\n return false;\n}", "label": 0, "cwe": null, "length": 37 }, { "index": 462838, "code": "construct(Geometry_buffer *buffer,\n const char *data, uint32 data_len)\n{\n uint32 geom_type;\n Geometry *result;\n\n if (data_len < SRID_SIZE + WKB_HEADER_SIZE) // < 4 + (1 + 4)\n return NULL;\n /* + 1 to skip the byte order (stored in position SRID_SIZE). */\n geom_type= uint4korr(data + SRID_SIZE + 1);\n if (!(result= create_by_typeid(buffer, (int) geom_type)))\n return NULL;\n result->m_data= data+ SRID_SIZE + WKB_HEADER_SIZE;\n result->m_data_end= data + data_len;\n return result;\n}", "label": 0, "cwe": null, "length": 154 }, { "index": 204713, "code": "Java_org_eso_cpl_jni_JNIRecipe_nativeExecute(JNIEnv *env, jobject this,\n jstring jCurrentDir,\n jstring jExecDir)\n{\n\n const char *currentDir;\n const char *execDir;\n\n int status = 0;\n int ok = 1;\n int errnum = 0;\n int dirChanged = 0;\n\n\n /*\n * Try to change directory to execution directory if one is defined.\n */\n\n if (jExecDir) {\n execDir = (*env)->GetStringUTFChars(env, jExecDir, NULL);\n dirChanged = !chdir(execDir);\n ok = ok && dirChanged;\n if (!ok) {\n errnum = errno;\n }\n (*env)->ReleaseStringUTFChars(env, jExecDir, execDir);\n }\n\n\n /*\n * Execute the recipe.\n */\n\n if (ok) {\n status = doExec(env, this);\n }\n\n /*\n * Try to change back to the orginal directory if we changed before.\n */\n\n if (dirChanged) {\n currentDir = (*env)->GetStringUTFChars(env, jCurrentDir, NULL);\n dirChanged = !chdir(currentDir);\n ok = ok && dirChanged;\n if (!dirChanged) {\n errnum = errno;\n }\n (*env)->ReleaseStringUTFChars(env, jCurrentDir, currentDir);\n }\n\n if (errnum) {\n (*env)->ThrowNew(env, CPLExceptionClass, strerror(errnum));\n }\n\n return status;\n\n}", "label": 0, "cwe": null, "length": 329 }, { "index": 210202, "code": "init_drivers(struct jack_params * params_ptr)\n{\n const JSList * list;\n struct jack_parameter_container * container_ptr;\n\n container_ptr = create_container(¶ms_ptr->root.children, PTNODE_DRIVERS);\n if (container_ptr == NULL)\n {\n return false;\n }\n\n params_ptr->drivers_ptr = &container_ptr->children;\n params_ptr->drivers_count = 0;\n\n list = jackctl_server_get_drivers_list(params_ptr->server);\n while (list)\n {\n if (!init_leaf(&container_ptr->children, jackctl_driver_get_name(list->data), jackctl_driver_get_parameters(list->data), list->data))\n {\n return false;\n }\n\n params_ptr->drivers_count++;\n\n list = jack_slist_next(list);\n }\n\n return true;\n}", "label": 0, "cwe": null, "length": 171 }, { "index": 578467, "code": "refresh_context_classes (GtkSourceContextEngine *ce,\n const GtkTextIter *start,\n const GtkTextIter *end)\n{\n#ifdef ENABLE_PROFILE\n\tGTimer *timer;\n#endif\n\tGtkTextIter realend = *end;\n\n\tif (gtk_text_iter_starts_line (&realend))\n\t{\n\t\tgtk_text_iter_backward_char (&realend);\n\t}\n\n\tif (gtk_text_iter_compare (start, &realend) >= 0)\n\t{\n\t\treturn;\n\t}\n\n#ifdef ENABLE_PROFILE\n\ttimer = g_timer_new ();\n#endif\n\n\t/* First we need to delete tags in the regions. */\n\tremove_region_context_classes (ce, start, &realend);\n\n\tadd_region_context_classes (ce,\n\t ce->priv->root_segment,\n\t gtk_text_iter_get_offset (start),\n\t gtk_text_iter_get_offset (&realend));\n\n#ifdef ENABLE_PROFILE\n\tg_print (\"applied context classes (from %d to %d), %g ms elapsed\\n\",\n\t\t gtk_text_iter_get_offset (start),\n\t\t gtk_text_iter_get_offset (&realend),\n\t\t g_timer_elapsed (timer, NULL) * 1000);\n\tg_timer_destroy (timer);\n#endif\n}", "label": 0, "cwe": null, "length": 239 }, { "index": 64024, "code": "alGetListener3f(ALenum eParam, ALfloat *pflValue1, ALfloat *pflValue2, ALfloat *pflValue3)\n{\n ALCcontext *Context;\n\n Context = GetContextRef();\n if(!Context) return;\n\n if(pflValue1 && pflValue2 && pflValue3)\n {\n switch(eParam)\n {\n case AL_POSITION:\n LockContext(Context);\n *pflValue1 = Context->Listener.Position[0];\n *pflValue2 = Context->Listener.Position[1];\n *pflValue3 = Context->Listener.Position[2];\n UnlockContext(Context);\n break;\n\n case AL_VELOCITY:\n LockContext(Context);\n *pflValue1 = Context->Listener.Velocity[0];\n *pflValue2 = Context->Listener.Velocity[1];\n *pflValue3 = Context->Listener.Velocity[2];\n UnlockContext(Context);\n break;\n\n default:\n alSetError(Context, AL_INVALID_ENUM);\n break;\n }\n }\n else\n alSetError(Context, AL_INVALID_VALUE);\n\n ALCcontext_DecRef(Context);\n}", "label": 0, "cwe": null, "length": 249 }, { "index": 897620, "code": "deserialize_qkdata(bstr_t *bs, void *valptr, size_t len)\n{\n\tstruct qkdata *qk = valptr;\n\tuint8 version;\n\n\tg_assert(sizeof *qk == len);\n\n\tbstr_read_u8(bs, &version);\n\tbstr_read_time(bs, &qk->first_seen);\n\tbstr_read_time(bs, &qk->last_seen);\n\tbstr_read_time(bs, &qk->last_update);\n\tbstr_read_be32(bs, &qk->flags);\n\tbstr_read_u8(bs, &qk->length);\n\n\tif (qk->length != 0) {\n\t\tqk->query_key = walloc(qk->length);\n\t\tbstr_read(bs, qk->query_key, qk->length);\n\t} else {\n\t\tqk->query_key = NULL;\n\t}\n\n\tif (version >= 1) {\n\t\t/* Fields introduced at version 1 */\n\t\tbstr_read_time(bs, &qk->last_timeout);\n\t\tbstr_read_u8(bs, &qk->timeouts);\n\t} else {\n\t\tqk->last_timeout = 0;\n\t\tqk->timeouts = 0;\n\t}\n}", "label": 0, "cwe": null, "length": 251 }, { "index": 299481, "code": "rbtree_create(int (*Compare)(const void *, const void *),\n\t\t\tvoid (*freeNode)(void *),\n\t\t\tint replace_flag)\n{\n\trbtree_t\t*tree;\n\n\tif (!Compare) return NULL;\n\n\ttree = malloc(sizeof(*tree));\n\tif (!tree) return NULL;\n\n\tmemset(tree, 0, sizeof(*tree));\n#ifndef NDEBUG\n\ttree->magic = RBTREE_MAGIC;\n#endif\n\ttree->Root = NIL;\n\ttree->Compare = Compare;\n\ttree->replace_flag = replace_flag;\n\ttree->freeNode = freeNode;\n\n\treturn tree;\n}", "label": 0, "cwe": null, "length": 114 }, { "index": 505694, "code": "GetInputStyles (Xi18n i18n_core, XIMStyles **p_style)\n{\n Xi18nAddressRec *address = (Xi18nAddressRec *) &i18n_core->address;\n XIMStyles *p;\n int\ti;\n\n p = &address->input_styles;\n if ((*p_style = (XIMStyles *) malloc (sizeof (XIMStyles)\n + p->count_styles*sizeof (XIMStyle)))\n == NULL)\n {\n return False;\n }\n /*endif*/\n (*p_style)->count_styles = p->count_styles;\n (*p_style)->supported_styles = (XIMStyle *) ((XPointer) *p_style + sizeof (XIMStyles));\n for (i = 0; i < (int) p->count_styles; i++)\n (*p_style)->supported_styles[i] = p->supported_styles[i];\n /*endfor*/\n return True;\n}", "label": 0, "cwe": null, "length": 200 }, { "index": 70320, "code": "new_textvec(int n)\t\t/* Allocates space for array of n char ptrs */\n#else /* K&R style */\nnew_textvec(n)\t\t/* Allocates space for array of n char ptrs */\n int n;\n#endif /* HAVE_STDC */\n{\n int orig_top = ptrspace_top;\n ptrspace_top += n;\n\n if( ptrspace_top > PTRSPACESZ) {\n if(curr_ptrspace->next == (PtrSpace *)NULL) {\n PtrSpace *new_ptrspace;\n if( (new_ptrspace = (PtrSpace *)malloc(sizeof(PtrSpace)))\n\t == (PtrSpace *)NULL) {\n\toops_message(OOPS_FATAL,line_num,NO_COL_NUM,\n\t\t \"Cannot alloc space for pointers to text\");\n\treturn (char **)NULL; /*NOTREACHED*/\n }\n else {\n\tnew_ptrspace->next = (PtrSpace *)NULL;\n\tcurr_ptrspace->next = new_ptrspace;\n }\n }\n curr_ptrspace = curr_ptrspace->next;\n extra_ptrspace += orig_top;\n orig_top = 0;\n ptrspace_top = n;\n }\n return curr_ptrspace->ptrspace + orig_top;\n}", "label": 0, "cwe": null, "length": 249 }, { "index": 484774, "code": "pio( void *dest, const void *source, int count, UINT8 *pri, UINT32 pcode )\r\n{\r\n\tint i;\r\n\r\n\tif (pcode)\r\n\t\tfor( i=0; ilength;\n u16 *D = gfxs->Aop[0];\n u16 *S = gfxs->Bop[0];\n u32 Skey = gfxs->Skey;\n int Ostep = gfxs->Ostep;\n\n if (Ostep < 0) {\n D += gfxs->length - 1;\n S += gfxs->length - 1;\n }\n\n if ((long)D & 2) {\n u16 s = *S;\n#ifdef WORDS_BIGENDIAN\n if (s != (Skey >> 16))\n *D = s;\n#else\n if (s != (Skey & 0xffff))\n *D = s;\n#endif\n S += Ostep;\n D += Ostep;\n w--;\n }\n\n if (Ostep < 0) {\n S--;\n D--;\n }\n\n for (l = w>>1; l--;) {\n u32 s = *((u32*)S);\n\n if (s != Skey)\n *((u32*)D) = s;\n\n S += Ostep << 1;\n D += Ostep << 1;\n }\n\n if (w & 1) {\n u16 s = *S;\n#ifdef WORDS_BIGENDIAN\n if (s != (Skey & 0xffff))\n *D = s;\n#else\n if (s != (Skey >> 16))\n *D = s;\n#endif\n }\n}", "label": 0, "cwe": null, "length": 360 }, { "index": 378824, "code": "BM_destroy_sparse(struct BM *map)\n{\n int i;\n struct BMlink *p, *tmp;\n\n for (i = 0; i < map->rows; i++) {\n\tp = ((struct BMlink **)(map->data))[i];\n\twhile (p != NULL) {\n\t tmp = p->next;\n\t link_dispose(map->token, (VOID_T *) p);\n\t p = tmp;\n\t}\n }\n\n if (--depth == 0)\n\tlink_cleanup(map->token);\n\n free(map->data);\n free(map);\n\n return 0;\n}", "label": 0, "cwe": null, "length": 122 }, { "index": 43165, "code": "write_fd_chunk(struct output_file *out, unsigned int len,\n\t\tint fd, int64_t offset)\n{\n\tint ret;\n\tint64_t aligned_offset;\n\tint aligned_diff;\n\tint buffer_size;\n\tchar *ptr;\n\n\taligned_offset = offset & ~(4096 - 1);\n\taligned_diff = offset - aligned_offset;\n\tbuffer_size = len + aligned_diff;\n\n#ifndef USE_MINGW\n\tchar *data = mmap64(NULL, buffer_size, PROT_READ, MAP_SHARED, fd,\n\t\t\taligned_offset);\n\tif (data == MAP_FAILED) {\n\t\treturn -errno;\n\t}\n\tptr = data + aligned_diff;\n#else\n\toff64_t pos;\n\tchar *data = malloc(len);\n\tif (!data) {\n\t\treturn -errno;\n\t}\n\tpos = lseek64(fd, offset, SEEK_SET);\n\tif (pos < 0) {\n\t\treturn -errno;\n\t}\n\tret = read_all(fd, data, len);\n\tif (ret < 0) {\n\t\treturn ret;\n\t}\n\tptr = data;\n#endif\n\n\tret = out->sparse_ops->write_data_chunk(out, len, ptr);\n\n#ifndef USE_MINGW\n\tmunmap(data, buffer_size);\n#else\n\tfree(data);\n#endif\n\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 252 }, { "index": 59141, "code": "GetExtent( OGREnvelope *psExtent, int bForce )\n{\n if( sStaticEnvelope.IsInit() )\n {\n memcpy(psExtent, &sStaticEnvelope, sizeof(OGREnvelope));\n return OGRERR_NONE;\n }\n\n int bInit = FALSE;\n for(int i = 0; i < nSrcLayers; i++)\n {\n AutoWarpLayerIfNecessary(i);\n if( !bInit )\n {\n if( papoSrcLayers[i]->GetExtent(psExtent, bForce) == OGRERR_NONE )\n bInit = TRUE;\n }\n else\n {\n OGREnvelope sExtent;\n if( papoSrcLayers[i]->GetExtent(&sExtent, bForce) == OGRERR_NONE )\n {\n psExtent->Merge(sExtent);\n }\n }\n }\n return (bInit) ? OGRERR_NONE : OGRERR_FAILURE;\n}", "label": 0, "cwe": null, "length": 201 }, { "index": 748292, "code": "dai_incident(enum incident_type type, struct player *violator,\n\t\t struct player *victim)\n{\n switch(type) {\n case INCIDENT_DIPLOMAT:\n ai_incident_diplomat(violator, victim);\n break;\n case INCIDENT_WAR:\n ai_incident_war(violator, victim);\n break;\n case INCIDENT_PILLAGE:\n ai_incident_pillage(violator, victim);\n break;\n case INCIDENT_NUCLEAR:\n ai_incident_nuclear(violator, victim);\n break;\n case INCIDENT_NUCLEAR_NOT_TARGET:\n ai_incident_nuclear_not_target(violator, victim);\n break;\n case INCIDENT_NUCLEAR_SELF:\n ai_incident_nuclear_self(violator, victim);\n break;\n case INCIDENT_LAST:\n /* Assert that always fails, but with meaningfull message */\n fc_assert(type != INCIDENT_LAST);\n break;\n }\n}", "label": 0, "cwe": null, "length": 197 }, { "index": 32359, "code": "new_event_handler(GtkWidget *widget, GdkEventButton *event, gpointer user_data)\n{\n\tif (game_in_progress)\n\t{\n\t\tglog( \"You can't start a new game while you're still playing!\");\n\t\treturn(TRUE);\n\t}\n\telse\n\t{\n\t\t/* We'll return NEWGAME to the game. */ \n\t\tcmd_insert(CMD_NEWGAME);\n\t\tgtk_widget_set_sensitive(widget, FALSE);\n\t\treturn(FALSE);\n\t}\n}", "label": 0, "cwe": null, "length": 93 }, { "index": 754556, "code": "ipv6_icmp_rx(struct ipv6_context *context)\n{\n\tstruct ipv6_hdr *ipv6 =\n\t\t\t(struct ipv6_hdr *)context->ustack->network_layer;\n\tstruct icmpv6_hdr *icmp = (struct icmpv6_hdr *)((u8_t *)ipv6 +\n\t\t\t\t\t\tsizeof(struct ipv6_hdr));\n\n\tswitch (icmp->icmpv6_type) {\n\tcase ICMPV6_RTR_ADV:\n\t\tipv6_icmp_handle_router_adv(context);\n\t\tbreak;\n\n\tcase ICMPV6_NEIGH_SOL:\n\t\tipv6_icmp_handle_nd_sol(context);\n\t\tbreak;\n\n\tcase ICMPV6_NEIGH_ADV:\n\t\tipv6_icmp_handle_nd_adv(context);\n\t\tbreak;\n\n\tcase ICMPV6_ECHO_REQUEST:\n\t\t/* Response with ICMP reply */\n\t\tipv6_icmp_handle_echo_request(context);\n\t\tbreak;\n\n\tdefault:\n\t\tbreak;\n\t}\n}", "label": 0, "cwe": null, "length": 180 }, { "index": 46461, "code": "parse_saturating(const String &str, int32_t &result, const ArgContext &)\n{\n uint32_t x;\n if (!underparse(str, true, x))\n\treturn false;\n bool negative = str[0] == '-';\n if (status == status_ok\n\t&& x > uint32_t(integer_traits::const_max) + negative) {\n\tstatus = status_range;\n\tx = uint32_t(integer_traits::const_max) + negative;\n }\n result = negative ? -x : x;\n return true;\n}", "label": 0, "cwe": null, "length": 119 }, { "index": 613898, "code": "parse_templates (CtplEnviron *env,\n CtplOutputStream *output)\n{\n gboolean success = TRUE;\n \n if (OPT_input_files) {\n gsize i;\n \n for (i = 0; success && OPT_input_files[i] != NULL; i++) {\n GError *err = NULL;\n \n printv (\"Parsing template '%s'...\\n\", OPT_input_files[i]);\n if (! parse_template (OPT_input_files[i], output, env, &err)) {\n printerr (\"Failed to parse template '%s': %s\\n\",\n OPT_input_files[i], err->message);\n g_error_free (err);\n success = FALSE;\n }\n }\n }\n \n return success;\n}", "label": 0, "cwe": null, "length": 157 }, { "index": 623599, "code": "lremCommand(redisClient *c) {\n robj *subject, *obj;\n obj = c->argv[3] = tryObjectEncoding(c->argv[3]);\n long toremove;\n int removed = 0;\n listTypeEntry entry;\n\n if ((getLongFromObjectOrReply(c, c->argv[2], &toremove, NULL) != REDIS_OK))\n return;\n\n subject = lookupKeyWriteOrReply(c,c->argv[1],shared.czero);\n if (subject == NULL || checkType(c,subject,REDIS_LIST)) return;\n\n /* Make sure obj is raw when we're dealing with a ziplist */\n if (subject->encoding == REDIS_ENCODING_ZIPLIST)\n obj = getDecodedObject(obj);\n\n listTypeIterator *li;\n if (toremove < 0) {\n toremove = -toremove;\n li = listTypeInitIterator(subject,-1,REDIS_HEAD);\n } else {\n li = listTypeInitIterator(subject,0,REDIS_TAIL);\n }\n\n while (listTypeNext(li,&entry)) {\n if (listTypeEqual(&entry,obj)) {\n listTypeDelete(&entry);\n server.dirty++;\n removed++;\n if (toremove && removed == toremove) break;\n }\n }\n listTypeReleaseIterator(li);\n\n /* Clean up raw encoded object */\n if (subject->encoding == REDIS_ENCODING_ZIPLIST)\n decrRefCount(obj);\n\n if (listTypeLength(subject) == 0) dbDelete(c->db,c->argv[1]);\n addReplyLongLong(c,removed);\n if (removed) signalModifiedKey(c->db,c->argv[1]);\n}", "label": 0, "cwe": null, "length": 368 }, { "index": 693590, "code": "get_next_partition_id_list(PARTITION_ITERATOR *part_iter)\n{\n if (part_iter->part_nums.cur >= part_iter->part_nums.end)\n {\n if (part_iter->ret_null_part)\n {\n part_iter->ret_null_part= FALSE;\n return part_iter->part_info->has_null_part_id;\n }\n part_iter->part_nums.cur= part_iter->part_nums.start;\n part_iter->ret_null_part= part_iter->ret_null_part_orig;\n return NOT_A_PARTITION_ID;\n }\n else\n {\n partition_info *part_info= part_iter->part_info;\n uint32 num_part= part_iter->part_nums.cur++;\n if (part_info->column_list)\n {\n uint num_columns= part_info->part_field_list.elements;\n return part_info->list_col_array[num_part*num_columns].partition_id;\n }\n return part_info->list_array[num_part].partition_id;\n }\n}", "label": 0, "cwe": null, "length": 201 }, { "index": 914091, "code": "Process(float_buff *Input)\n{ int s1,s2;\n\n// TestOfs.Omega+=(-0.005*(2.0*M_PI/512)); // simulate frequency drift\n\n Output.Len=0;\n\n InpSplit.Process(Input);\n\n ProcLine.Process(&InpSplit.Output);\n// TestOfs.Process(&InpSplit.Output);\n// ProcLine.Process(&TestOfs.Output);\n\n // printf(\"New input, Len=%d/%d\\n\",Input->Len,ProcLine.InpLen);\n while((SyncProcPtr+WindowLen)\",\n //\t SyncSymbConf,SyncLocked,SyncProcPtr,SyncPtr,SymbPtr,SyncSymbShift,SyncFreqOfs);\n if(SyncPtr==SymbPtr)\n { s1=SyncProcPtr-ProcDelay+((int)SyncSymbShift-SymbPtr*SyncStep);\n s2=s1+SymbolSepar/2;\n// printf(\" Sample at %d,%d (SyncProcPtr-%d), time diff.=%d\\n\",s1,s2,SyncProcPtr-s1,s1-DataProcPtr);\n DataProcess(ProcLine.InpPtr+s1,ProcLine.InpPtr+s2,SyncFreqOfs,s1-DataProcPtr);\n DataProcPtr=s1;\n }\n // printf(\"\\n\");\n SyncProcPtr+=SyncStep;\n }\n SyncProcPtr-=ProcLine.InpLen; DataProcPtr-=ProcLine.InpLen;\n return 0;\n}", "label": 0, "cwe": null, "length": 400 }, { "index": 233847, "code": "amdgpu_sched_ib_submit_kernel_helper(struct amdgpu_device *adev,\n\t\t\t\t\t struct amdgpu_ring *ring,\n\t\t\t\t\t struct amdgpu_ib *ibs,\n\t\t\t\t\t unsigned num_ibs,\n\t\t\t\t\t int (*free_job)(struct amdgpu_job *),\n\t\t\t\t\t void *owner,\n\t\t\t\t\t struct fence **f)\n{\n\tint r = 0;\n\tif (amdgpu_enable_scheduler) {\n\t\tstruct amdgpu_job *job =\n\t\t\tkzalloc(sizeof(struct amdgpu_job), GFP_KERNEL);\n\t\tif (!job)\n\t\t\treturn -ENOMEM;\n\t\tjob->base.sched = &ring->sched;\n\t\tjob->base.s_entity = &adev->kernel_ctx.rings[ring->idx].entity;\n\t\tjob->base.s_fence = amd_sched_fence_create(job->base.s_entity, owner);\n\t\tif (!job->base.s_fence) {\n\t\t\tkfree(job);\n\t\t\treturn -ENOMEM;\n\t\t}\n\t\t*f = fence_get(&job->base.s_fence->base);\n\n\t\tjob->adev = adev;\n\t\tjob->ibs = ibs;\n\t\tjob->num_ibs = num_ibs;\n\t\tjob->owner = owner;\n\t\tjob->free_job = free_job;\n\t\tamd_sched_entity_push_job(&job->base);\n\t} else {\n\t\tr = amdgpu_ib_schedule(adev, num_ibs, ibs, owner);\n\t\tif (r)\n\t\t\treturn r;\n\t\t*f = fence_get(&ibs[num_ibs - 1].fence->base);\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 322 }, { "index": 532747, "code": "clone() const\n{\n\tif (isDestroyed())\n\t{\n\t\terrno=EIO;\n\t\treturn NULL;\n\t}\n\n\treturn new folder(myserver, path, hasMessagesFlag,\n\t\t\t hasSubFoldersFlag);\n}", "label": 0, "cwe": null, "length": 44 }, { "index": 403171, "code": "int8mul(PG_FUNCTION_ARGS)\n{\n\tint64\t\targ1 = PG_GETARG_INT64(0);\n\tint64\t\targ2 = PG_GETARG_INT64(1);\n\tint64\t\tresult;\n\n\tresult = arg1 * arg2;\n\n\t/*\n\t * Overflow check.\tWe basically check to see if result / arg2 gives arg1\n\t * again. There are two cases where this fails: arg2 = 0 (which cannot\n\t * overflow) and arg1 = INT64_MIN, arg2 = -1 (where the division itself\n\t * will overflow and thus incorrectly match).\n\t *\n\t * Since the division is likely much more expensive than the actual\n\t * multiplication, we'd like to skip it where possible. The best bang for\n\t * the buck seems to be to check whether both inputs are in the int32\n\t * range; if so, no overflow is possible. (But that only works if we\n\t * really have a 64-bit int64 datatype...)\n\t */\n#ifndef INT64_IS_BUSTED\n\tif (arg1 != (int64) ((int32) arg1) || arg2 != (int64) ((int32) arg2))\n#endif\n\t{\n\t\tif (arg2 != 0 &&\n\t\t\t(result / arg2 != arg1 || (arg2 == -1 && arg1 < 0 && result < 0)))\n\t\t\tereport(ERROR,\n\t\t\t\t\t(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),\n\t\t\t\t\t errmsg(\"bigint out of range\")));\n\t}\n\tPG_RETURN_INT64(result);\n}", "label": 0, "cwe": null, "length": 331 }, { "index": 302500, "code": "open_socket()\n{\n int size;\n int s;\n struct in_addr ip_address;\n struct hostent *hp;\n int i;\n int e;\n int r;\n char* lhost;\n char* lpstring;\n int lport;\n unsigned int p; /* port */\n char *machine = LINK_HOST; //static and global string;\n uid_t euid;\n gid_t egid;\n\n\n lhost = getenv(\"MINIVEND_HOST\");\n if(lhost == NULL) {\n \tlhost = machine;\n }\n\n lpstring = getenv(\"MINIVEND_PORT\");\n if(lpstring != 0) {\n \tlport = atoi(lpstring);\n }\n else {\n \tlport = LINK_PORT;\n }\n\n p = (unsigned int) htons((unsigned short) lport);\n\n ServAddr.sin_port = p;\n\n hp = get_the_host(lhost, &ip_address);\n\n \tif(hp == NULL) {\n\t if (ip_address.s_addr == INADDR_NONE) {\n die(\"Unknown host.\\n\");\n }\n ServAddr.sin_family = AF_INET;\n ServAddr.sin_addr.s_addr = ip_address.s_addr;\n }\n else {\n\t\tServAddr.sin_addr = *((struct in_addr *)hp->h_addr);\n ServAddr.sin_family = hp->h_addrtype;\n /* We'll fill in the rest of the structure below. */\n }\n\n\n for (i = 0; i < LINK_TIMEOUT; ++i) {\n sock = socket(ServAddr.sin_family, SOCK_STREAM, 0);\n e = errno;\n if (sock < 0)\n die(e, \"Could not open socket\");\n\n do {\n s = connect(sock, (struct sockaddr*) &ServAddr, (int) sizeof (ServAddr));\n e = errno;\n } while (s == -1 && e == EINTR);\n\n if (s == 0)\n break;\n close(sock);\n sleep(1);\n }\n if (s < 0) {\n server_not_running();\n exit(1);\n }\n}", "label": 0, "cwe": null, "length": 445 }, { "index": 880666, "code": "fqftrunc(fq)\n\nstruct freq\t\t*fq;\n\n{\n\tint4\t\tret;\t\t/* result of myftrunc() */\n\tstruct fdesc\t*f;\t\t/* target descriptor */\n\tint4\t\t*plen;\t\t/* ptr desired length */\n\n\tf = fdfind(fq->fq_tfd);\n\n\tif (f == FDNULL) {\n\t\tfsendr(fq->fq_src_node, fq->fq_src_event,\n\t\t\t\tEBADF, (int4) LAMERROR, INT4_NIL, INT4_NIL);\n\t} else {\n\t\tplen = (int4 *) fbuf;\n\t\tfdactivate(f);\n\t\tret = fmyftrunc(f->f_fd, (int4) ttol(*plen));\n\t\tfsendr(fq->fq_src_node, fq->fq_src_event, (ret == LAMERROR) ?\n\t\t\t\terrno : 0, ret, INT4_NIL, INT4_NIL);\n\t}\n}", "label": 0, "cwe": null, "length": 207 }, { "index": 793636, "code": "gt_ranges_are_equal(const GtArray *ranges_1, const GtArray *ranges_2)\n{\n unsigned long i;\n\n gt_assert(gt_ranges_are_sorted(ranges_1) && gt_ranges_are_sorted(ranges_2));\n\n if (gt_array_size(ranges_1) != gt_array_size(ranges_2))\n return false;\n\n for (i = 0; i < gt_array_size(ranges_1); i++) {\n if (gt_range_compare(gt_array_get(ranges_1, i), gt_array_get(ranges_2, i)))\n return false;\n }\n\n return true;\n}", "label": 0, "cwe": null, "length": 133 }, { "index": 18003, "code": "limnPolyDataAlloc(limnPolyData *pld,\n unsigned int infoBitFlag,\n unsigned int vertNum,\n unsigned int indxNum,\n unsigned int primNum) {\n static const char me[]=\"limnPolyDataAlloc\";\n\n if (!pld) {\n biffAddf(LIMN, \"%s: got NULL pointer\", me);\n return 1;\n }\n if (vertNum != pld->xyzwNum) {\n pld->xyzw = (float *)airFree(pld->xyzw);\n if (vertNum) {\n pld->xyzw = AIR_CALLOC(vertNum*4, float);\n if (!pld->xyzw) {\n biffAddf(LIMN, \"%s: couldn't allocate %u xyzw\", me, vertNum);\n return 1;\n }\n }\n pld->xyzwNum = vertNum;\n }\n if (_limnPolyDataInfoAlloc(pld, infoBitFlag, vertNum)) {\n biffAddf(LIMN, \"%s: couldn't allocate info\", me);\n return 1;\n }\n if (indxNum != pld->indxNum) {\n pld->indx = (unsigned int *)airFree(pld->indx);\n if (indxNum) {\n pld->indx = AIR_CALLOC(indxNum, unsigned int);\n if (!pld->indx) {\n biffAddf(LIMN, \"%s: couldn't allocate %u indices\", me, indxNum);\n return 1;\n }\n }\n pld->indxNum = indxNum;\n }\n if (primNum != pld->primNum) {\n pld->type = (unsigned char *)airFree(pld->type);\n pld->icnt = (unsigned int *)airFree(pld->icnt);\n if (primNum) {\n pld->type = AIR_CALLOC(primNum, unsigned char);\n pld->icnt = AIR_CALLOC(primNum, unsigned int);\n if (!(pld->type && pld->icnt)) {\n biffAddf(LIMN, \"%s: couldn't allocate %u primitives\", me, primNum);\n return 1;\n }\n }\n pld->primNum = primNum;\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 508 }, { "index": 199095, "code": "test_intra_proc_locking(void)\n{\n GThread *thd;\n int outpipe[2], inpipe[2];\n int thd_fds[2];\n int rv;\n\n unlink(TEST_FILENAME);\n\n g_assert(pipe(outpipe) == 0);\n g_assert(pipe(inpipe) == 0);\n\n thd_fds[0] = outpipe[0];\n thd_fds[1] = inpipe[1];\n thd = g_thread_create((GThreadFunc)test_intra_proc_locking_thd, (gpointer)thd_fds, TRUE, NULL);\n\n rv = locking_master(inpipe[0], outpipe[1]);\n\n /* close the write end of the outgoing pipe, which should trigger an EOF on\n * the slave if it's still running */\n close(outpipe[1]);\n g_thread_join(thd);\n unlink(TEST_FILENAME);\n\n /* caller will kill the remaining files */\n\n return rv;\n}", "label": 0, "cwe": null, "length": 202 }, { "index": 320787, "code": "parse_sysimgguid(int fd, char *line)\n{\n\tchar *s;\n\n\tif (!(s = strchr(line, '='))) {\n\t\tIBWARN(\"bad assignment: missing '=' sign\");\n\t\treturn -1;\n\t}\n\n\tnetsysimgguid = strtoull(s + 1, 0, 0);\n\n\treturn 1;\n}", "label": 0, "cwe": null, "length": 71 }, { "index": 958632, "code": "add(const Identifier& ident)\n{\n if (!m_set.add(ident.ustring().rep()).second)\n return;\n\n m_vector.append(ident);\n}\n\n}", "label": 0, "cwe": null, "length": 33 }, { "index": 11340, "code": "AcpiExSystemDoStall (\n UINT32 HowLong)\n{\n ACPI_STATUS Status = AE_OK;\n\n\n ACPI_FUNCTION_ENTRY ();\n\n\n if (HowLong > 255) /* 255 microseconds */\n {\n /*\n * Longer than 255 usec, this is an error\n *\n * (ACPI specifies 100 usec as max, but this gives some slack in\n * order to support existing BIOSs)\n */\n ACPI_ERROR ((AE_INFO, \"Time parameter is too large (%u)\",\n HowLong));\n Status = AE_AML_OPERAND_VALUE;\n }\n else\n {\n AcpiOsStall (HowLong);\n }\n\n return (Status);\n}", "label": 0, "cwe": null, "length": 152 }, { "index": 609965, "code": "_dxf_ExWriteSock(int fd, Pointer buffer, int size)\n{\n int sts;\n sts = write(fd, (char *)buffer, size);\n if(sts != size)\n DXUIMessage(\"ERROR\", \"error writing to socket\");\n return(sts);\n}", "label": 0, "cwe": null, "length": 60 }, { "index": 103094, "code": "setPixmapProvider( KPixmapProvider *prov )\n{\n if ( d->myPixProvider == prov )\n return;\n\n delete d->myPixProvider;\n d->myPixProvider = prov;\n\n // re-insert all the items with/without pixmap\n // I would prefer to use changeItem(), but that doesn't honor the pixmap\n // when using an editable combobox (what we do)\n if ( count() > 0 ) {\n QStringList items( historyItems() );\n clear();\n insertItems( items );\n }\n}", "label": 0, "cwe": null, "length": 116 }, { "index": 791350, "code": "Program_print (Program *p) {\n int i, j;\n OpCode c;\n\n for (i = 0; i < p->size; i++) {\n c = p->code[i];\n for (j = 0; j < N_OPCODES; j++)\n if (OpCodes[j].opCode == c) break;\n if (c == _NIL) break;\n\n if (OpCodes[j].hasOperand) {\n printf(\"%4d %s % 3d\\n\", i, OpCodes[j].mnemonic, p->code[i+1]);\n i++;\n } else {\n printf(\"%4d %s\\n\", i, OpCodes[j].mnemonic);\n }\n }\n}", "label": 0, "cwe": null, "length": 156 }, { "index": 157523, "code": "gtop_fsusage (PyObject *self, PyObject *args)\n{\n\n glibtop_fsusage buf;\n const char *mount_dir;\n PyObject *d;\n\n if (!PyArg_ParseTuple (args, \"s\", &mount_dir))\n return NULL;\n\n glibtop_get_fsusage (&buf, mount_dir);\n\n d = PyDict_New ();\n\n /* (x * block_size) may overflow ?\n * mult should be done with PyLong\n * but who has a PB harddrive ?\n */\n\n my_dict_add_and_decref (d, \"total\", PyL_ULL (buf.blocks * buf.block_size));\n my_dict_add_and_decref (d, \"free\", PyL_ULL (buf.bfree * buf.block_size));\n my_dict_add_and_decref (d, \"avail\", PyL_ULL (buf.bavail * buf.block_size));\n\n my_dict_add_and_decref (d, \"files\", PyL_ULL (buf.files));\n my_dict_add_and_decref (d, \"ffree\", PyL_ULL (buf.ffree));\n\n my_dict_add_and_decref (d, \"block_size\", PyL_ULL (buf.block_size));\n\n my_dict_add_and_decref (d, \"read\", PyL_ULL (buf.read));\n my_dict_add_and_decref (d, \"write\", PyL_ULL (buf.write));\n\n return _struct_new (d);\n}", "label": 0, "cwe": null, "length": 316 }, { "index": 17061, "code": "OpGetState()\n{\n dac_getstate_it in ;\n dac_getstate_ot out ;\n process_t *p_p ;\n\t\t\t\t/* obtain process name */\n if (!readn(newsock, (char *)&in, sizeof(dac_getstate_it)))\n return ;\n\n out.status = htons(FAILURE) ;\t/* assume error */\n out.error = htons(DAC_ER_NOPROCESS) ;\n\t\t\t\t/* locate process and return state */\n for (p_p = process_list ; p_p != NULL ; p_p = p_p->next)\n if (!strcmp(in.name, p_p->name))\n {\n\t out.status = htons(SUCCESS) ;\n\t out.error = htons(DAC_ER_NOERROR) ;\n\t if ((p_p->state == STARTED) && (!pingProcess(p_p)))\n\t out.state = htons(EXITTED) ;\n\t else\n\t out.state = htons(p_p->state) ;\n\t break ;\n }\n writen(newsock, (char *)&out, sizeof(dac_getstate_ot)) ;\n}", "label": 0, "cwe": null, "length": 216 }, { "index": 664687, "code": "ablkcipher_next_slow(struct ablkcipher_request *req,\n\t\t\t\t struct ablkcipher_walk *walk,\n\t\t\t\t unsigned int bsize,\n\t\t\t\t unsigned int alignmask,\n\t\t\t\t void **src_p, void **dst_p)\n{\n\tunsigned aligned_bsize = ALIGN(bsize, alignmask + 1);\n\tstruct ablkcipher_buffer *p;\n\tvoid *src, *dst, *base;\n\tunsigned int n;\n\n\tn = ALIGN(sizeof(struct ablkcipher_buffer), alignmask + 1);\n\tn += (aligned_bsize * 3 - (alignmask + 1) +\n\t (alignmask & ~(crypto_tfm_ctx_alignment() - 1)));\n\n\tp = kmalloc(n, GFP_ATOMIC);\n\tif (!p)\n\t\treturn ablkcipher_walk_done(req, walk, -ENOMEM);\n\n\tbase = p + 1;\n\n\tdst = (u8 *)ALIGN((unsigned long)base, alignmask + 1);\n\tsrc = dst = ablkcipher_get_spot(dst, bsize);\n\n\tp->len = bsize;\n\tp->data = dst;\n\n\tscatterwalk_copychunks(src, &walk->in, bsize, 0);\n\n\tablkcipher_queue_write(walk, p);\n\n\twalk->nbytes = bsize;\n\twalk->flags |= ABLKCIPHER_WALK_SLOW;\n\n\t*src_p = src;\n\t*dst_p = dst;\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 285 }, { "index": 410741, "code": "cleanupTemplate(DcmDataset *targetDset)\n{\n if (!targetDset)\n return;\n // Remove any existing image pixel module attribute\n targetDset->findAndDeleteElement(DCM_PixelDataProviderURL);\n targetDset->findAndDeleteElement(DCM_PhotometricInterpretation);\n targetDset->findAndDeleteElement(DCM_SamplesPerPixel);\n targetDset->findAndDeleteElement(DCM_Rows);\n targetDset->findAndDeleteElement(DCM_Columns);\n targetDset->findAndDeleteElement(DCM_BitsAllocated);\n targetDset->findAndDeleteElement(DCM_BitsStored);\n targetDset->findAndDeleteElement(DCM_HighBit);\n targetDset->findAndDeleteElement(DCM_PixelRepresentation);\n targetDset->findAndDeleteElement(DCM_PixelData);\n targetDset->findAndDeleteElement(DCM_PlanarConfiguration);\n targetDset->findAndDeleteElement(DCM_PixelAspectRatio);\n targetDset->findAndDeleteElement(DCM_SmallestImagePixelValue);\n targetDset->findAndDeleteElement(DCM_LargestImagePixelValue);\n targetDset->findAndDeleteElement(DCM_RedPaletteColorLookupTableDescriptor);\n targetDset->findAndDeleteElement(DCM_GreenPaletteColorLookupTableDescriptor);\n targetDset->findAndDeleteElement(DCM_BluePaletteColorLookupTableDescriptor);\n targetDset->findAndDeleteElement(DCM_RedPaletteColorLookupTableData);\n targetDset->findAndDeleteElement(DCM_GreenPaletteColorLookupTableData);\n targetDset->findAndDeleteElement(DCM_BluePaletteColorLookupTableData);\n targetDset->findAndDeleteElement(DCM_ICCProfile);\n // Remove SOP Class / Instance information\n targetDset->findAndDeleteElement(DCM_SOPClassUID);\n targetDset->findAndDeleteElement(DCM_SOPInstanceUID);\n\n}", "label": 0, "cwe": null, "length": 418 }, { "index": 259739, "code": "mangle(char *buf, const char *real)\n{\n\tchar c;\n\n\twhile ((c = *real++) != '\\0') {\n\t\tswitch (c) {\n\t\tcase '0' ... '9':\n\t\tcase 'A' ... 'Z':\n\t\tcase 'a' ... 'z':\n\t\tcase '_':\n\t\t\t*buf++ = c;\n\t\t\tbreak;\n\t\tcase '.':\n\t\t\t*buf++ = '_';\n\t\t\tbreak;\n\t\tcase '#':\n\t\t\t*buf++ = 'X';\n\t\t\t*buf++ = 'h';\n\t\t\t*buf++ = 'a';\n\t\t\t*buf++ = 's';\n\t\t\t*buf++ = 'h';\n\t\t\t*buf++ = 'X';\n\t\t\tbreak;\n\t\tcase '+':\n\t\t\t*buf++ = 'X';\n\t\t\t*buf++ = 'p';\n\t\t\t*buf++ = 'l';\n\t\t\t*buf++ = 'u';\n\t\t\t*buf++ = 's';\n\t\t\t*buf++ = 'X';\n\t\t\tbreak;\n\t\tcase '-':\n\t\t\t*buf++ = 'X';\n\t\t\t*buf++ = 'm';\n\t\t\t*buf++ = 'i';\n\t\t\t*buf++ = 'n';\n\t\t\t*buf++ = 'u';\n\t\t\t*buf++ = 's';\n\t\t\t*buf++ = 'X';\n\t\t\tbreak;\n\t\tdefault:\n\t\t\tfprintf(stderr, \"ERROR: %s: Bad character '%c' in signal name.\\n\",\n\t\t\t\t\tprogname, c);\n\t\t\tbreak;\n\t\t}\n\t}\n\t*buf = '\\0';\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 330 }, { "index": 25632, "code": "syn_cterm_attr2entry(attr)\n int\t\t attr;\n{\n attr -= ATTR_OFF;\n if (attr >= cterm_attr_table.ga_len)\t/* did \":syntax clear\" */\n\treturn NULL;\n return &(CTERM_ATTR_ENTRY(attr));\n}", "label": 0, "cwe": null, "length": 54 }, { "index": 17021, "code": "loc_less (const SourceLoc &r) const {\n return _loc.file_id () < r.file_id () ? true :\n (_loc.line () < r.line () ? true : (_loc.len () < r.len ()));\n }", "label": 0, "cwe": null, "length": 50 }, { "index": 565497, "code": "logsqlite_prepare_db(session_t * session, time_t sent, int mode)\n{\n\tchar * path;\n\tsqlite_t * db;\n\n\tif (!(path = logsqlite_prepare_path(session, sent)))\n\t\treturn 0;\n\tif (!logsqlite_current_db_path || !logsqlite_current_db) {\n\t\tif (! (db = logsqlite_open_db(session, sent, path)))\n\t\t\treturn 0;\n\t\txfree(logsqlite_current_db_path);\n\t\tlogsqlite_current_db_path = xstrdup(path);\n\t\tlogsqlite_current_db = db;\n\n\t\tif (mode)\n\t\t\tsqlite_n_exec(db, \"BEGIN TRANSACTION\", NULL, NULL, NULL);\n\t\tlogsqlite_in_transaction = mode;\n\t} else if (!xstrcmp(path, logsqlite_current_db_path) && logsqlite_current_db) {\n\t\tdb = logsqlite_current_db;\n\t\tdebug(\"[logsqlite] keeping old db\\n\");\n\n\t\tif (mode && !logsqlite_in_transaction)\n\t\t\tsqlite_n_exec(db, \"BEGIN TRANSACTION\", NULL, NULL, NULL);\n\t\telse if (!mode && logsqlite_in_transaction)\n\t\t\tsqlite_n_exec(db, \"COMMIT\", NULL, NULL, NULL);\n\t\tlogsqlite_in_transaction = mode;\n\t} else {\n\t\tlogsqlite_close_db(logsqlite_current_db);\n\t\tdb = logsqlite_open_db(session, sent, path);\n\t\tlogsqlite_current_db = db;\n\t\txfree(logsqlite_current_db_path);\n\t\tlogsqlite_current_db_path = xstrdup(path);\n\n\t\tif (mode)\n\t\t\tsqlite_n_exec(db, \"BEGIN TRANSACTION\", NULL, NULL, NULL);\n\t\tlogsqlite_in_transaction = mode;\n\t}\n\txfree(path);\n\treturn db;\n}", "label": 0, "cwe": null, "length": 344 }, { "index": 991880, "code": "CreateControl(wxWindow* parent)\n{\n panel = new wxPanel(parent);\n\n TextCtrlLogger::CreateControl(panel);\n control->SetId(ID_LOG_DOXYBLOCKS);\n\n sizer = new wxBoxSizer(wxVERTICAL);\n sizer->Add(control, 1, wxEXPAND, 0);\n panel->SetSizer(sizer);\n\n return panel;\n}", "label": 0, "cwe": null, "length": 80 }, { "index": 237572, "code": "__lsn_diff(low, high, current, max, is_forward)\n\tDB_LSN *low, *high, *current;\n\tu_int32_t max;\n\tint is_forward;\n{\n\tdouble nf;\n\n\t/*\n\t * There are three cases in each direction. If you are in the\n\t * same file, then all you need worry about is the difference in\n\t * offsets. If you are in different files, then either your offsets\n\t * put you either more or less than the integral difference in the\n\t * number of files -- we need to handle both of these.\n\t */\n\tif (is_forward) {\n\t\tif (current->file == low->file)\n\t\t\tnf = (double)(current->offset - low->offset) / max;\n\t\telse if (current->offset < low->offset)\n\t\t\tnf = (double)((current->file - low->file) - 1) +\n\t\t\t (double)((max - low->offset) + current->offset) /\n\t\t\t max;\n\t\telse\n\t\t\tnf = (double)(current->file - low->file) +\n\t\t\t (double)(current->offset - low->offset) / max;\n\t} else {\n\t\tif (current->file == high->file)\n\t\t\tnf = (double)(high->offset - current->offset) / max;\n\t\telse if (current->offset > high->offset)\n\t\t\tnf = (double)((high->file - current->file) - 1) +\n\t\t\t (double)\n\t\t\t ((max - current->offset) + high->offset) / max;\n\t\telse\n\t\t\tnf = (double)(high->file - current->file) +\n\t\t\t (double)(high->offset - current->offset) / max;\n\t}\n\treturn (nf);\n}", "label": 0, "cwe": null, "length": 371 }, { "index": 206729, "code": "xdr_bytes(XDR *xdrs, char **cpp, u_int *sizep, const u_int maxsize)\n{\n\tchar *sp = *cpp; /* sp is the actual string pointer */\n\tu_int nodesize;\n\n\t/*\n\t * first deal with the length since xdr bytes are counted\n\t * We decided not to use MACRO XDR_U_INT here, because the\n\t * advantages here will be miniscule compared to xdr_bytes.\n\t * This saved us 100 bytes in the library size.\n\t */\n\tif (!xdr_u_int(xdrs, sizep))\n\t\treturn (FALSE);\n\tnodesize = *sizep;\n\tif ((nodesize > maxsize) && (xdrs->x_op != XDR_FREE))\n\t\treturn (FALSE);\n\n\t/*\n\t * now deal with the actual bytes\n\t */\n\tswitch (xdrs->x_op) {\n\tcase XDR_DECODE:\n\t\tif (nodesize == 0)\n\t\t\treturn (TRUE);\n\t\tif (sp == NULL)\n\t\t\t*cpp = sp = malloc(nodesize);\n\t\tif (sp == NULL) {\n#if HAVE_SYSLOG_H\n\t\t\t(void) syslog(LOG_ERR, xdr_err);\n#else\n\t\t\t(void) fprintf(stderr, \"%s\\n\", xdr_err);\n#endif\n\t\t\treturn (FALSE);\n\t\t}\n\t\t/*FALLTHROUGH*/\n\tcase XDR_ENCODE:\n\t\treturn (xdr_opaque(xdrs, sp, nodesize));\n\tcase XDR_FREE:\n\t\tif (sp != NULL) {\n\t\t\tfree(sp);\n\t\t\t*cpp = NULL;\n\t\t}\n\t\treturn (TRUE);\n\t}\n\treturn (FALSE);\n}", "label": 0, "cwe": null, "length": 341 }, { "index": 630139, "code": "detectEncoding(const char* data, size_t dataSize) const\n{\n\tFileEncoding encoding = ENCODING_8BIT;\n\n\tif (dataSize >= 4 && memcmp(data, \"\\x00\\x00\\xFE\\xFF\", 4) == 0)\n\t\tencoding = UTF_32BE;\n\telse if (dataSize >= 4 && memcmp(data, \"\\xFF\\xFE\\x00\\x00\", 4) == 0)\n\t\tencoding = UTF_32LE;\n\telse if (dataSize >= 2 && memcmp(data, \"\\xFE\\xFF\", 2) == 0)\n\t\tencoding = UTF_16BE;\n\telse if (dataSize >= 2 && memcmp(data, \"\\xFF\\xFE\", 2) == 0)\n\t\tencoding = UTF_16LE;\n\n\treturn encoding;\n}", "label": 0, "cwe": null, "length": 170 }, { "index": 366528, "code": "entry_line(int entry, int lastchar)\n{\n register int p_line = COMPOSER_TOP_LINE;\n int i;\n register struct hdr_line *line;\n\n for(line = ods.top_l, i = ods.top_e;\n\theadents && headents[i].name && i <= entry;\n\tp_line++){\n\tif(p_line >= BOTTOM())\n\t break;\n\tif(i == entry){\n\t if(lastchar){\n\t\tif(line->next == NULL)\n\t\t return(p_line);\n\t }\n\t else if(line->prev == NULL)\n\t return(p_line);\n\t else\n\t return(-1);\n\t}\n\tline = next_hline(&i, line);\n }\n return(-1);\n}", "label": 0, "cwe": null, "length": 146 }, { "index": 39776, "code": "translucent_connection_destroy(BackendDB *be, Connection *conn) {\n\tslap_overinst *on = (slap_overinst *) be->bd_info;\n\ttranslucent_info *ov = on->on_bi.bi_private;\n\tint rc = 0;\n\n\tDebug(LDAP_DEBUG_TRACE, \"translucent_connection_destroy\\n\", 0, 0, 0);\n\n\trc = ov->db.bd_info->bi_connection_destroy(&ov->db, conn);\n\n\treturn(rc);\n}", "label": 0, "cwe": null, "length": 98 }, { "index": 187872, "code": "GetSkipCountDelta(void)\n{\n\tint\tcount;\n\n\tcount = GetUsefulRows() - overlapLines;\n\n\tif (count <= 0)\n\t\tcount = 1;\n\n\treturn count;\n}", "label": 0, "cwe": null, "length": 39 }, { "index": 35687, "code": "cddb_disc_destroy(cddb_disc_t *disc)\n{\n cddb_track_t *track, *next;\n\n if (disc) {\n FREE_NOT_NULL(disc->genre);\n FREE_NOT_NULL(disc->title);\n FREE_NOT_NULL(disc->artist);\n FREE_NOT_NULL(disc->ext_data);\n track = disc->tracks;\n while (track) {\n next = track->next;\n cddb_track_destroy(track);\n track = next;\n }\n free(disc);\n }\n}", "label": 0, "cwe": null, "length": 109 }, { "index": 509721, "code": "RecordDelayedPosixLocalorGlobalPre (char *name)\n{\n if (AL_Test(\"MPI2_function\"))\n /* for now, we just ignore these... */\n return 0;\n\n if ((strcmp (name, \"MPI_Wtick\") == 0) ||\n (strcmp (name, \"MPI_Wtime\") == 0))\n /* catching these would probably be a bad idea */\n /* especially since the standard says that the */\n /* implementation can omit them from the profiling interface... */\n return 0;\n\n /* these are handled in umpi_mpi_extra... */\n /* MPI_Errhandler_set is only handled there w/UMPI_MPI_PANIC... */\n if ((strcmp (name, \"MPI_Abort\") == 0) ||\n (strcmp (name, \"MPI_Errhandler_set\") == 0) ||\n (strcmp (name, \"MPI_Finalize\") == 0) ||\n (strcmp (name, \"MPI_Init\") == 0))\n return 0;\n\n /* initially, do it unless overridden by wrapper spec... */\n if ((AL_Test (\"nopre\")) || (AL_Test (\"noasynchpre\")))\n return 0;\n\n return 1;\n}", "label": 0, "cwe": null, "length": 256 }, { "index": 543590, "code": "do_cmd_disarm(cmd_code code, cmd_arg args[])\n{\n\tint y, x, dir;\n\n\ts16b o_idx;\n\n\tbool more = FALSE;\n\n\tdir = args[0].direction;\n\n\t/* Get location */\n\ty = p_ptr->py + ddy[dir];\n\tx = p_ptr->px + ddx[dir];\n\n\t/* Check for chests */\n\to_idx = chest_check(y, x);\n\n\n\t/* Verify legality */\n\tif (!o_idx && !do_cmd_disarm_test(y, x))\n\t{\n\t\t/* Cancel repeat */\n\t\tdisturb(p_ptr, 0, 0);\n\t\treturn;\n\t}\n\n\t/* Take a turn */\n\tp_ptr->energy_use = 100;\n\n\t/* Apply confusion */\n\tif (player_confuse_dir(p_ptr, &dir, FALSE))\n\t{\n\t\t/* Get location */\n\t\ty = p_ptr->py + ddy[dir];\n\t\tx = p_ptr->px + ddx[dir];\n\n\t\t/* Check for chests */\n\t\to_idx = chest_check(y, x);\n\t}\n\n\n\t/* Monster */\n\tif (cave->m_idx[y][x] > 0) {\n\t\tmsg(\"There is a monster in the way!\");\n\t\tpy_attack(y, x);\n\t}\n\n\t/* Chest */\n\telse if (o_idx)\n\t\tmore = do_cmd_disarm_chest(y, x, o_idx);\n\n\t/* Door to lock */\n\telse if (cave->feat[y][x] == FEAT_DOOR_HEAD)\n\t\tmore = do_cmd_lock_door(y, x);\n\n\t/* Disarm trap */\n\telse\n\t\tmore = do_cmd_disarm_aux(y, x);\n\n\t/* Cancel repeat unless told not to */\n\tif (!more) disturb(p_ptr, 0, 0);\n}", "label": 0, "cwe": null, "length": 361 }, { "index": 247177, "code": "sg_save_map_tiles_resources(struct savedata *saving)\n{\n /* Check status and return if not OK (sg_success != TRUE). */\n sg_check_ret();\n\n SAVE_MAP_CHAR(ptile, resource2char(ptile->resource), saving->file,\n \"map.res%04d\");\n}", "label": 0, "cwe": null, "length": 62 }, { "index": 729629, "code": "reorder_by_random(graph_t *g, boolean weighted) {\n\tstruct tms t;\n\tint i,r;\n\tint *new;\n\tboolean *used;\n\n\tsrand(times(&t)+time(NULL));\n\n\tnew=calloc(g->n, sizeof(int));\n\tused=calloc(g->n, sizeof(boolean));\n\tfor (i=0; i < g->n; i++) {\n\t\tdo {\n\t\t\tr=rand() % g->n;\n\t\t} while (used[r]);\n\t\tnew[i]=r;\n\t\tused[r]=TRUE;\n\t}\n\tfree(used);\n\treturn new;\n}", "label": 0, "cwe": null, "length": 119 }, { "index": 838882, "code": "fsdbm_invert(VALUE obj)\n{\n datum key, val;\n struct dbmdata *dbmp;\n DBM *dbm;\n VALUE keystr, valstr;\n VALUE hash = rb_hash_new();\n\n GetDBM2(obj, dbmp, dbm);\n for (key = sdbm_firstkey(dbm); key.dptr; key = sdbm_nextkey(dbm)) {\n\tval = sdbm_fetch(dbm, key);\n\tkeystr = rb_external_str_new(key.dptr, key.dsize);\n\tvalstr = rb_external_str_new(val.dptr, val.dsize);\n\trb_hash_aset(hash, valstr, keystr);\n }\n return hash;\n}", "label": 0, "cwe": null, "length": 149 }, { "index": 28029, "code": "_getIndex(int c){\n#define ERRCHR (font->u8FirstChar+1)\n /* Does this font provide this character? */\n if(cu8FirstChar)\n c=ERRCHR;\n if(c>font->u8LastChar && efont.type!=FONT_EXTERNAL && font->charExtra == NULL)\n c=ERRCHR;\n\n if(c>font->u8LastChar && (efont.type==FONT_EXTERNAL || font->charExtra != NULL)){\n if(efont.type==FONT_EXTERNAL){\n _getFontData(SEEK_EXTRAS,0);\n int cc=0;\n int cache;\n while( (cache=_getFontData(GET_EXTRAS,0)) < c)\n cc++;\n if( cache > c)\n c=ERRCHR;\n else\n c=font->u8LastChar+cc+1;\n }else{\n int cc=0;\n while( font->charExtra[cc] < c)\n cc++;\n if(font->charExtra[cc] > c)\n c=ERRCHR;\n else\n c=font->u8LastChar+cc+1;\n };\n };\n c-=font->u8FirstChar;\n return c;\n}", "label": 0, "cwe": null, "length": 269 }, { "index": 939545, "code": "bcm5461_enable_fiber(struct mii_phy* phy, int autoneg)\n{\n\t/* select fiber mode, enable 1000 base-X registers */\n\tsungem_phy_write(phy, MII_NCONFIG, 0xfc0b);\n\n\tif (autoneg) {\n\t\t/* enable fiber with no autonegotiation */\n\t\tsungem_phy_write(phy, MII_ADVERTISE, 0x01e0);\n\t\tsungem_phy_write(phy, MII_BMCR, 0x1140);\n\t} else {\n\t\t/* enable fiber with autonegotiation */\n\t\tsungem_phy_write(phy, MII_BMCR, 0x0140);\n\t}\n\n\tphy->autoneg = autoneg;\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 168 }, { "index": 377218, "code": "FillValues_(Index n_entries, const CompoundSymMatrix& matrix, Number* values)\n {\n Index total_n_entries = 0;\n\n for (Index i=0; i blk_mat = matrix.GetComp(i, j);\n if (IsValid(blk_mat)) {\n Index blk_n_entries = GetNumberEntries(*blk_mat);\n total_n_entries += blk_n_entries;\n FillValues(blk_n_entries, *blk_mat, values);\n\n // now shift the iRow, jCol pointers for the next term\n values += blk_n_entries;\n }\n }\n }\n DBG_ASSERT(total_n_entries == n_entries);\n }", "label": 0, "cwe": null, "length": 177 }, { "index": 101751, "code": "read_vpag_chunk_callback(png_struct *ping, png_unknown_chunkp chunk)\n{\n Image\n *image;\n\n\n /* The unknown chunk structure contains the chunk data:\n png_byte name[5];\n png_byte *data;\n png_size_t size;\n\n Note that libpng has already taken care of the CRC handling.\n */\n\n\n if (chunk->name[0] != 118 || chunk->name[1] != 112 ||\n chunk->name[2] != 65 ||chunk-> name[3] != 103)\n return(0); /* Did not recognize */\n\n /* recognized vpAg */\n\n if (chunk->size != 9)\n return(-1); /* Error return */\n\n if (chunk->data[8] != 0)\n return(0); /* ImageMagick requires pixel units */\n\n image=(Image *) png_get_user_chunk_ptr(ping);\n\n image->page.width=(size_t) ((chunk->data[0] << 24) |\n (chunk->data[1] << 16) | (chunk->data[2] << 8) | chunk->data[3]);\n\n image->page.height=(size_t) ((chunk->data[4] << 24) |\n (chunk->data[5] << 16) | (chunk->data[6] << 8) | chunk->data[7]);\n\n /* Return one of the following: */\n /* return(-n); chunk had an error */\n /* return(0); did not recognize */\n /* return(n); success */\n\n return(1);\n\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 340 }, { "index": 111617, "code": "floppy_wait(struct remote *rem, void *data, avoff_t end)\n{\n int res;\n struct floppylocalfile *lf = (struct floppylocalfile *) data;\n\n /* FIXME: timeout? */\n do {\n struct stat stbuf;\n \n res = av_program_log_output(lf->pr);\n if(res <= 0)\n return res;\n\n res = stat(lf->tmpfile, &stbuf);\n if(res == 0)\n lf->currsize = stbuf.st_size;\n\n if(lf->currsize < end)\n av_sleep(250);\n\n } while(lf->currsize < end);\n\n return 1;\n}", "label": 1, "cwe": "CWE-other", "length": 144 }, { "index": 155931, "code": "Clip(GB_PAINT *d, int preserve)\n{\n\tif (preserve)\n\t\tcairo_clip_preserve(CONTEXT(d));\n\telse\n\t\tcairo_clip(CONTEXT(d));\n}", "label": 0, "cwe": null, "length": 38 }, { "index": 118262, "code": "vtkPNGWriteInit(png_structp png_ptr, png_bytep data,\n png_size_t sizeToWrite)\n {\n vtkPNGWriter *self =\n vtkPNGWriter::SafeDownCast(static_cast\n (png_get_io_ptr(png_ptr)));\n if (self)\n {\n vtkUnsignedCharArray *uc = self->GetResult();\n // write to the uc array\n unsigned char *ptr = uc->WritePointer(uc->GetMaxId()+1,sizeToWrite);\n memcpy(ptr, data, sizeToWrite);\n }\n }", "label": 0, "cwe": null, "length": 120 }, { "index": 747324, "code": "asn_realloc_rbuild_header(u_char ** pkt, size_t * pkt_len,\n size_t * offset, int r,\n u_char type, size_t length)\n{\n char ebuf[128];\n\n if (asn_realloc_rbuild_length(pkt, pkt_len, offset, r, length)) {\n if (((*pkt_len - *offset) < 1)\n && !(r && asn_realloc(pkt, pkt_len))) {\n snprintf(ebuf, sizeof(ebuf),\n \"bad header length < 1 :%ld, %lu\",\n (long)(*pkt_len - *offset), (unsigned long)length);\n ebuf[ sizeof(ebuf)-1 ] = 0;\n ERROR_MSG(ebuf);\n return 0;\n }\n *(*pkt + *pkt_len - (++*offset)) = type;\n return 1;\n }\n return 0;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 189 }, { "index": 471141, "code": "toRaw(PadDocument *doc)\n{\n // qWarning() << \"core start\";\n // debug(2);\n QTextCursor raw(doc->rawSourceDocument());\n int oldLength = _end - _start;\n\n // recompute raw positions\n setStart(doc->positionTranslator().outputToRaw(_outputStart));\n setEnd(doc->positionTranslator().outputToRaw(_outputEnd));\n int s = QString(Constants::TOKEN_CORE_DELIMITER).size();\n\n // replace token content to its name\n raw.setPosition(_start);\n raw.setPosition(_end, QTextCursor::KeepAnchor);\n raw.removeSelectedText();\n raw.insertText(_uid);\n int newLength = _uid.size();\n doc->positionTranslator().addRawTranslation(_start, newLength-oldLength);\n doc->positionTranslator().addRawTranslation(_start, s);\n\n // add delimiters\n raw.setPosition(_start);\n raw.insertText(Constants::TOKEN_CORE_DELIMITER);\n\n setEnd(doc->positionTranslator().outputToRaw(_outputEnd));\n doc->positionTranslator().addRawTranslation(_start, s);\n raw.setPosition(_end);\n raw.insertText(Constants::TOKEN_CORE_DELIMITER);\n setEnd(_end + s);\n // qWarning() << \"core end\";\n // debug(2);\n // doc->positionTranslator().debug();\n}", "label": 0, "cwe": null, "length": 281 }, { "index": 844310, "code": "mkdir_path(const char *path, mode_t mode)\n{\n\tchar buf[PATH_MAX];\n\tchar parent[PATH_MAX];\n\tconst char *cp = path, *lcp = path;\n\tchar *bp = buf, *pp = parent;\n\n\t*parent = '\\0';\n\n\tdo {\n\t\tif (cp != path && (*cp == '/' || *cp == '\\0')) {\n\t\t\tmemcpy(bp, lcp, cp - lcp);\n\t\t\tbp += cp - lcp;\n\t\t\t*bp = '\\0';\n\t\t\tif (!do_mkdir(parent, buf, mode)) {\n\t\t\t\tif (*cp != '\\0') {\n\t\t\t\t\tmemcpy(pp, lcp, cp - lcp);\n\t\t\t\t\tpp += cp - lcp;\n\t\t\t\t\t*pp = '\\0';\n\t\t\t\t\tlcp = cp;\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\tmemcpy(pp, lcp, cp - lcp);\n\t\t\tpp += cp - lcp;\n\t\t\t*pp = '\\0';\n\t\t\tlcp = cp;\n\t\t}\n\t} while (*cp++ != '\\0');\n\n\treturn 0;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 228 }, { "index": 838274, "code": "_PyImport_ReleaseLock(void)\n{\n long me = PyThread_get_thread_ident();\n if (me == -1 || import_lock == NULL)\n return 0; /* Too bad */\n if (import_lock_thread != me)\n return -1;\n import_lock_level--;\n if (import_lock_level == 0) {\n import_lock_thread = -1;\n PyThread_release_lock(import_lock);\n }\n return 1;\n}", "label": 0, "cwe": null, "length": 95 }, { "index": 122408, "code": "send_line (socket_descriptor_t sd,\n\t const char *buf)\n{\n const ssize_t size = send (sd, buf, strlen (buf), MSG_NOSIGNAL);\n if (size != (ssize_t) strlen (buf))\n {\n msg (D_LINK_ERRORS | M_ERRNO_SOCK, \"send_line: TCP port write failed on send()\");\n return false;\n }\n return true;\n}", "label": 0, "cwe": null, "length": 87 }, { "index": 683192, "code": "enable_single (int type, PluginHandle * p)\n{\n PluginHandle * old = table[type].u.s.get_current ();\n\n plugin_misc_cleanup (old);\n\n AUDDBG (\"Switching from %s to %s.\\n\", plugin_get_name (old),\n plugin_get_name (p));\n plugin_set_enabled (old, FALSE);\n plugin_set_enabled (p, TRUE);\n\n if (table[type].u.s.set_current (p))\n return TRUE;\n\n fprintf (stderr, \"%s failed to start; falling back to %s.\\n\",\n plugin_get_name (p), plugin_get_name (old));\n plugin_set_enabled (p, FALSE);\n plugin_set_enabled (old, TRUE);\n\n if (table[type].u.s.set_current (old))\n return FALSE;\n\n fprintf (stderr, \"FATAL: %s failed to start.\\n\", plugin_get_name (old));\n plugin_set_enabled (old, FALSE);\n exit (EXIT_FAILURE);\n}", "label": 0, "cwe": null, "length": 203 }, { "index": 395460, "code": "eina_quadtree_change(Eina_QuadTree_Item *object)\n{\n EINA_MAGIC_CHECK_QUADTREE_ITEM(object, EINA_FALSE);\n\n if (object->delete_me || !object->visible)\n return EINA_FALSE;\n\n if (object->quad->resize)\n return EINA_TRUE;\n\n /* Delaying change until needed */\n if (!object->change)\n object->quad->change = eina_inlist_append(object->quad->change,\n EINA_INLIST_GET(object));\n\n object->change = EINA_TRUE;\n\n _eina_quadtree_remove(object);\n\n return EINA_TRUE;\n}", "label": 0, "cwe": null, "length": 124 }, { "index": 460229, "code": "getutxent(void) {\n static struct utmpx getutent_tmp, *retval;\n ssize_t ret;\n sigset_t oldset, *savedset;\n\n if (fd<0) {\n setutxent();\n if (fd<0) return 0;\n }\n savedset = __utmp_block_signals (&oldset);\n\n retval = __utmp_io(fd, &getutent_tmp, sizeof(struct utmpx),\n\t &utmp_current, F_RDLCK);\n\n if (savedset)\n sigprocmask (SIG_SETMASK, savedset, 0);\n\n return retval;\n}", "label": 0, "cwe": null, "length": 137 }, { "index": 996870, "code": "mainEntry(const char *action, \n const void *handle, \n Property::Set *inArgs,\n Property::Set *outArgs)\n {\n if(_plugin){\n PluginHandle* pHandle = _plugin->getPluginHandle();\n if(pHandle){\n OfxPlugin* ofxPlugin = pHandle->getOfxPlugin();\n if(ofxPlugin){\n \n OfxPropertySetHandle inHandle = 0;\n if(inArgs) {\n setCustomInArgs(action, *inArgs);\n inHandle = inArgs->getHandle();\n }\n \n OfxPropertySetHandle outHandle = 0;\n if(outArgs) {\n setCustomOutArgs(action, *outArgs);\n outHandle = outArgs->getHandle();\n }\n \n OfxStatus stat;\n try {\n stat = ofxPlugin->mainEntry(action, handle, inHandle, outHandle);\n } CatchAllSetStatus(stat, gImageEffectHost, ofxPlugin, action);\n\n if(outArgs) \n examineOutArgs(action, stat, *outArgs);\n\n return stat;\n }\n return kOfxStatFailed;\n }\n return kOfxStatFailed;\n }\n return kOfxStatFailed;\n }", "label": 0, "cwe": null, "length": 267 }, { "index": 49306, "code": "OnSearchProject(cb_unused wxCommandEvent& event)\n{\n wxChoice *chProject = XRCCTRL(*this, \"chProject\", wxChoice);\n wxChoice *chTarget = XRCCTRL(*this, \"chTarget\", wxChoice);\n int i=chProject->GetSelection();\n if (i<0)\n return;\n cbProject *active_project=(*Manager::Get()->GetProjectManager()->GetProjects())[i];\n const bool targAll = (chTarget->GetSelection() == 0);\n chTarget->Clear();\n chTarget->AppendString(_(\"All project files\"));\n for(int j=0;jGetBuildTargetsCount();++j)\n chTarget->AppendString(active_project->GetBuildTarget(j)->GetTitle());\n const int targIdx = chTarget->FindString(active_project->GetActiveBuildTarget(), true);\n chTarget->SetSelection(targAll || targIdx < 0 ? 0 : targIdx);\n}", "label": 0, "cwe": null, "length": 206 }, { "index": 506788, "code": "paintCustomSlider( QPainter *p, bool paintMoodbar )\n{\n qreal percent = 0.0;\n if ( maximum() > minimum() )\n percent = ((qreal)value()) / ( maximum() - minimum() );\n QStyleOptionSlider opt;\n initStyleOption( &opt );\n if ( m_sliding ||\n ( underMouse() && sliderHandleRect( rect(), percent ).contains( mapFromGlobal(QCursor::pos()) ) ) )\n {\n opt.activeSubControls |= QStyle::SC_SliderHandle;\n }\n The::svgHandler()->paintCustomSlider( p, &opt, percent, paintMoodbar );\n}", "label": 0, "cwe": null, "length": 140 }, { "index": 417400, "code": "makeSVGCubes (const int width)\n{\n QImage img (width, width, QImage::Format_ARGB32_Premultiplied);\n QPainter q; // Paints whole faces of the dice.\n\n QImage pip (width/7, width/7, QImage::Format_ARGB32_Premultiplied);\n QPainter r; // Paints the pips on the faces of the dice.\n\n QRectF rect (0, 0, width, width);\n qreal pc = 20.0;\t\t// % radius on corners.\n elements.clear();\n for (int i = FirstElement; i <= LastElement; i++) {\n q.begin(&img);\n q.setPen (Qt::NoPen);\n if (i == Pip) {\n pip.fill (0);\n }\n else {\n img.fill (0);\n }\n\n // NOTE: \"neutral\", \"player_1\" and \"player_2\" from file \"default.svg\" cause\n // odd effects at the corners. You get a cleaner look if they are omitted.\n\n switch (i) {\n case Neutral:\n // svg.render (&q, \"neutral\");\n q.setBrush (color0);\n q.drawRoundedRect (rect, pc, pc, Qt::RelativeSize);\n svg.render (&q, \"lighting\");\n break;\n case Player1:\n // svg.render (&q, \"player_1\");\n q.setBrush (color1);\n q.drawRoundedRect (rect, pc, pc, Qt::RelativeSize);\n svg.render (&q, \"lighting\");\n break;\n case Player2:\n // svg.render (&q, \"player_2\");\n q.setBrush (color2);\n q.drawRoundedRect (rect, pc, pc, Qt::RelativeSize);\n svg.render (&q, \"lighting\");\n break;\n case Pip:\n r.begin(&pip);\n svg.render (&r, \"pip\");\n r.end();\n break;\n case BlinkLight:\n svg.render (&q, \"blink_light\");\n break;\n case BlinkDark:\n svg.render (&q, \"blink_dark\");\n break;\n default:\n break;\n }\n q.end();\n elements.append\n ((i == Pip) ? QPixmap::fromImage (pip) : QPixmap::fromImage (img));\n }\n}", "label": 0, "cwe": null, "length": 499 }, { "index": 745223, "code": "orte_ps_init(int argc, char *argv[]) {\n int ret;\n#if OPAL_ENABLE_FT_CR == 1\n char * tmp_env_var = NULL;\n#endif\n\n /*\n * Make sure to init util before parse_args\n * to ensure installdirs is setup properly\n * before calling mca_base_open();\n */\n if( ORTE_SUCCESS != (ret = opal_init_util(&argc, &argv)) ) {\n return ret;\n }\n\n /*\n * Parse Command Line Arguments\n */\n if (ORTE_SUCCESS != (ret = parse_args(argc, argv))) {\n return ret;\n }\n\n /*\n * Setup OPAL Output handle from the verbose argument\n */\n if( orte_ps_globals.verbose ) {\n orte_ps_globals.output = opal_output_open(NULL);\n opal_output_set_verbosity(orte_ps_globals.output, 10);\n } else {\n orte_ps_globals.output = 0; /* Default=STDERR */\n }\n\n#if OPAL_ENABLE_FT_CR == 1\n /* Disable the checkpoint notification routine for this\n * tool. As we will never need to checkpoint this tool.\n * Note: This must happen before opal_init().\n */\n opal_cr_set_enabled(false);\n\n /* Select the none component, since we don't actually use a checkpointer */\n (void) mca_base_var_env_name(\"crs\", &tmp_env_var);\n opal_setenv(tmp_env_var,\n \"none\",\n true, &environ);\n free(tmp_env_var);\n tmp_env_var = NULL;\n\n (void) mca_base_var_env_name(\"opal_cr_is_tool\", &tmp_env_var);\n opal_setenv(tmp_env_var,\n \"1\",\n true, &environ);\n free(tmp_env_var);\n#endif\n\n /***************************\n * We need all of OPAL and the TOOL portion of ORTE\n ***************************/\n ret = orte_init(&argc, &argv, ORTE_PROC_TOOL);\n\n return ret;\n}", "label": 0, "cwe": null, "length": 430 }, { "index": 97370, "code": "mca_base_component_close (const mca_base_component_t *component, int output_id)\n{\n /* Close */\n if (NULL != component->mca_close_component) {\n component->mca_close_component();\n opal_output_verbose(10, output_id, \n \"mca: base: close: component %s closed\",\n component->mca_component_name);\n }\n\n mca_base_component_unload (component, output_id);\n}", "label": 0, "cwe": null, "length": 96 }, { "index": 252248, "code": "clist_do_polyfill(gx_device *dev, gx_path *ppath,\n const gx_drawing_color *pdcolor,\n gs_logical_operation_t lop)\n{\n const subpath *psub = ppath->first_subpath;\n const segment *pseg1;\n const segment *pseg2;\n int code;\n\n if (psub && (pseg1 = psub->next) != 0 && (pseg2 = pseg1->next) != 0) {\n fixed px = psub->pt.x, py = psub->pt.y;\n fixed ax = pseg1->pt.x - px, ay = pseg1->pt.y - py;\n fixed bx, by;\n /*\n * We take advantage of the fact that the parameter lists for\n * fill_parallelogram and fill_triangle are identical.\n */\n dev_proc_fill_parallelogram((*fill));\n\n /* close_path of 3 point triangle adds 4th point, detected here.*/\n /* close_path on parallelogram adds 5th point also ignored. */\n if (pseg2->next && !(px == pseg2->next->pt.x && py == pseg2->next->pt.y)) {\n /* Parallelogram */\n fill = dev_proc(dev, fill_parallelogram);\n bx = pseg2->pt.x - pseg1->pt.x;\n by = pseg2->pt.y - pseg1->pt.y;\n } else {\n /* Triangle */\n fill = dev_proc(dev, fill_triangle);\n bx = pseg2->pt.x - px;\n by = pseg2->pt.y - py;\n }\n code = fill(dev, px, py, ax, ay, bx, by, pdcolor, lop);\n } else\n code = 0;\n gx_path_new(ppath);\n return code;\n}", "label": 1, "cwe": "CWE-476", "length": 409 }, { "index": 69264, "code": "clip(const Frustum& fr)\n {\n // clip the body with each plane\n for ( unsigned short i = 0; i < 6; ++i )\n {\n // clip, but keep positive space this time since frustum planes are \n // the opposite to other cases (facing inwards rather than outwards)\n clip(fr.getFrustumPlane(i), false);\n }\n }", "label": 0, "cwe": null, "length": 87 }, { "index": 641890, "code": "hddtemp_fetch(const char *host, int port, const char *device)\n{\n char buffer[4096];\n char *key;\n int i;\n\n /* fetch a buffer of all hddtemps */\n if (!hddtemp_connect(host, port, buffer, sizeof(buffer))) {\n\treturn \"err\";\n }\n\n i = 1;\n while (1) {\n\tkey = split(buffer, i);\n\tif (key == NULL)\n\t break;\n\tif (strcmp(device, key) == 0) {\n\t return split(buffer, i + 2);\n\t}\n\ti += 5;\n }\n\n return \"n/a\";\n}", "label": 0, "cwe": null, "length": 135 }, { "index": 932074, "code": "FCEUI_VSUniSetDIP(int w, int state)\n{\n if(((vsdip >> w) & 1) != state)\n FCEUI_VSUniToggleDIP(w);\n}", "label": 0, "cwe": null, "length": 45 }, { "index": 112803, "code": "get_pid(gint row)\n{\n\tgint num = get_num_colonne_pid();\n\tgchar*pid;\n if(num>=0)\n\t\tpid = g_strdup(List[row][num]);\n\telse\n\t\tpid = g_strdup(\" \");\n\n\treturn pid;\n\n}", "label": 0, "cwe": null, "length": 52 }, { "index": 65173, "code": "jsvIsChild(JsVar *parent, JsVar *child) {\n assert(jsvIsArray(parent) || jsvIsObject(parent));\n assert(jsvIsName(child));\n JsVarRef childref = jsvGetRef(child);\n JsVarRef indexref;\n indexref = jsvGetFirstChild(parent);\n while (indexref) {\n if (indexref == childref) return true;\n // get next\n JsVar *indexVar = jsvLock(indexref);\n indexref = jsvGetNextSibling(indexVar);\n jsvUnLock(indexVar);\n }\n return false; // not found undefined\n}", "label": 0, "cwe": null, "length": 139 }, { "index": 63702, "code": "safeToQuit()\n{\n // ask user for guidance for each document with unsaved changes, but skip\n // active document if user requested automatic file export at shutdown\n DigitDoc* doc;\n for (doc = docList->first(); doc; doc = docList->next())\n {\n if (m_exportFileAtShutdown.isEmpty() || (doc != activeDocument()))\n {\n ASSERT_ENGAUGE(doc != 0);\n if (doc->modified())\n {\n if (!queryExit()) // user is canceling quit\n return false;\n break;\n }\n }\n }\n\n if (!m_exportFileAtShutdown.isEmpty())\n {\n // user has requested automatic file export of active document at shutdown\n doc = activeDocument();\n ASSERT_ENGAUGE(doc != 0);\n doc->markFileAsExported(); // prevent save file dialog from appearing in slotFileExport\n doc->setExportPath(m_exportFileAtShutdown);\n slotFileExport(); // export active document to export path from previous step\n }\n\n // last chance to save settings before quitting\n DefaultSettings::instance().archiveSettings();\n\n return true;\n}", "label": 0, "cwe": null, "length": 244 }, { "index": 607941, "code": "LookupFileExtMapping ( const char * filePath )\n{\n\tstd::string fileExt;\n\tsize_t extPos = strlen (filePath);\n\tfor ( --extPos; extPos > 0; --extPos ) if ( filePath[extPos] == '.' ) break;\n\n\tif ( filePath[extPos] != '.' ) return kXMP_UnknownFile;\n\n\t++extPos;\n\tfileExt.assign ( &filePath[extPos] );\n\tfor ( size_t i = 0; i < fileExt.size(); ++i ) {\n\t\tif ( ('A' <= fileExt[i]) && (fileExt[i] <= 'Z') ) fileExt[i] += 0x20;\n\t}\n\n\tsize_t mapPos;\n\tfor ( mapPos = 0; kFileExtMap[mapPos].ext != 0; ++mapPos ) {\n\t\tif ( fileExt == kFileExtMap[mapPos].ext ) break;\n\t}\n\n\treturn kFileExtMap[mapPos].format;\n\n}", "label": 0, "cwe": null, "length": 205 }, { "index": 614322, "code": "plugin_init()\n{\n\tinput_list *il = g_new0(input_list, 1);\n\n\teb_debug(DBG_MOD, \"IRC\\n\");\n\tref_count = 0;\n\n\tplugin_info.prefs = il;\n\til->widget.checkbox.value = &do_irc_debug;\n\til->name = \"do_irc_debug\";\n\til->label = _(\"Enable debugging\");\n\til->type = EB_INPUT_CHECKBOX;\n\n\treturn (0);\n}", "label": 0, "cwe": null, "length": 87 }, { "index": 40365, "code": "GetErrorMsg() const\n{\n wxCHECK_MSG(m_refData, wxEmptyString, wxT(\"Invalid plotfunction\"));\n return M_PLOTFUNCDATA->m_parser.ErrorMsg();\n}", "label": 0, "cwe": null, "length": 40 }, { "index": 251093, "code": "lineget (stream, buf, bufsize)\n reg FILE *stream;\n reg char *buf;\n int bufsize;\n{\n reg int c;\n int size;\n char *bufstart;\n\n size=0;\n bufstart=buf;\n\n for (;;)\n {\n if ((c = getc (stream)) == EOF)\n\treturn (-1);\n if ((!flag0 && c == '\\n') || (flag0 && c == '\\0'))\n\tbreak;\n if(sizebufsize-1)\n warn(bufstart,\"Path name too long, truncated\");\n\n return (0);\n}", "label": 0, "cwe": null, "length": 154 }, { "index": 456081, "code": "on_cell_data_group_name(Gtk::CellRenderer* renderer, const Gtk::TreeModel::iterator& iter)\n{\n //Set the view's cell properties depending on the model's data:\n Gtk::CellRendererText* renderer_text = dynamic_cast(renderer);\n if(renderer_text)\n {\n if(iter)\n {\n Gtk::TreeModel::Row row = *iter;\n\n Glib::ustring name = row[m_model_columns_groups.m_col_name];\n\n renderer_text->property_text() = Privs::get_user_visible_group_name(name);\n }\n }\n}\n\n}", "label": 0, "cwe": null, "length": 125 }, { "index": 44024, "code": "dom_document_dump (DomDocument *self,\n\t\t gsize *len)\n{\n\tGString *xml;\n\tchar *body;\n\n\txml = g_string_sized_new (4096);\n\tg_string_append (xml, \"\");\n\tg_string_append (xml, XML_RC);\n\n\tbody = dom_element_dump (DOM_ELEMENT (self), -1);\n\tg_string_append (xml, body);\n\tg_free (body);\n\n\tif (dom_element_has_child_nodes (DOM_ELEMENT (self)))\n\t\tg_string_append (xml, XML_RC);\n\n\tif (len != NULL)\n\t\t*len = xml->len;\n\n\treturn g_string_free (xml, FALSE);\n}", "label": 0, "cwe": null, "length": 145 }, { "index": 218037, "code": "oc_enc_frag_sub_128_c(ogg_int16_t *_diff,\n const unsigned char *_src,int _ystride){\n int i;\n for(i=0;i<8;i++){\n int j;\n for(j=0;j<8;j++)_diff[i*8+j]=(ogg_int16_t)(_src[j]-128);\n _src+=_ystride;\n }\n}", "label": 0, "cwe": null, "length": 82 }, { "index": 59150, "code": "pdf_get_halftone_component_index(const gs_multiple_halftone *pmht,\n const gx_device_halftone *pdht,\n int dht_index)\n{\n int j;\n\n for (j = 0; j < pmht->num_comp; j++)\n if (pmht->components[j].comp_number == dht_index)\n break;\n if (j == pmht->num_comp) {\n /* Look for Default. */\n for (j = 0; j < pmht->num_comp; j++)\n if (pmht->components[j].comp_number == GX_DEVICE_COLOR_MAX_COMPONENTS)\n break;\n if (j == pmht->num_comp)\n return_error(gs_error_undefined);\n }\n return j;\n}", "label": 0, "cwe": null, "length": 162 }, { "index": 108697, "code": "assign_columns (char **columns, char *Buffer, int maxfields) {\n char *token;\n int nfields = 0;\n \n columns[nfields++] = token = strtok(Buffer,\"\\t\");\n while ((token = strtok(NULL,\"\\t\")) != NULL && nfields < maxfields) {\n columns[nfields++] = token;\n }\n return nfields;\n}", "label": 0, "cwe": null, "length": 80 }, { "index": 215209, "code": "_print_job_time_limit(job_info_t * job, int width, bool right,\n\t\t\t char* suffix)\n{\n\tif (job == NULL)\t/* Print the Header instead */\n\t\t_print_str(\"TIMELIMIT\", width, right, true);\n\telse if (job->time_limit == INFINITE)\n\t\t_print_str(\"UNLIMITED\", width, right, true);\n\telse if (job->time_limit == NO_VAL)\n\t\t_print_str(\"NOT_SET\", width, right, true);\n\telse\n\t\t_print_secs((job->time_limit*60), width, right, false);\n\tif (suffix)\n\t\tprintf(\"%s\", suffix);\n\treturn SLURM_SUCCESS;\n}", "label": 0, "cwe": null, "length": 140 }, { "index": 403491, "code": "BoundsDisplayCoordinateChanged(vtkViewport *viewport)\n{\n double transMinPt[3], transMaxPt[3];\n viewport->SetWorldPoint(this->Bounds[0], this->Bounds[2], this->Bounds[4], 1.0);\n viewport->WorldToDisplay();\n viewport->GetDisplayPoint(transMinPt);\n viewport->SetWorldPoint(this->Bounds[1], this->Bounds[3], this->Bounds[5], 1.0);\n viewport->WorldToDisplay();\n viewport->GetDisplayPoint(transMaxPt);\n\n if( this->LastMinDisplayCoordinate[0] != transMinPt[0] \n || this->LastMinDisplayCoordinate[1] != transMinPt[1]\n || this->LastMinDisplayCoordinate[2] != transMinPt[2]\n || this->LastMaxDisplayCoordinate[0] != transMaxPt[0]\n || this->LastMaxDisplayCoordinate[1] != transMaxPt[1]\n || this->LastMaxDisplayCoordinate[2] != transMaxPt[2] )\n {\n int i = 0;\n for( i=0 ; i<3 ; ++i )\n {\n this->LastMinDisplayCoordinate[i] = transMinPt[i];\n this->LastMaxDisplayCoordinate[i] = transMaxPt[i];\n }\n return true;\n }\n\n return false;\n}", "label": 0, "cwe": null, "length": 297 }, { "index": 725679, "code": "bcm2048_deinit(struct bcm2048_device *bdev)\n{\n\tint err;\n\n\terr = bcm2048_set_audio_route(bdev, 0);\n\tif (err < 0)\n\t\tgoto exit;\n\n\terr = bcm2048_set_dac_output(bdev, 0);\n\tif (err < 0)\n\t\tgoto exit;\n\n\terr = bcm2048_set_power_state(bdev, BCM2048_POWER_OFF);\n\tif (err < 0)\n\t\tgoto exit;\n\nexit:\n\treturn err;\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 87572, "code": "skipMultiLineComment(void)\n{\n\tint c;\n\tint nesting = 1;\n\tdo\n\t{\n\t\tc = fileGetc();\n\t\tif (c == '*')\n\t\t{\n\t\t\tc = fileGetc();\n\t\t\tif (c == '/')\n\t\t\t\t--nesting;\n\t\t\telse\n\t\t\t\tfileUngetc(c);\n\t\t}\n\t\telse if (c == '/')\n\t\t{\n\t\t\tc = fileGetc();\n\t\t\tif (c == '*')\n\t\t\t\t++nesting;\n\t\t\telse\n\t\t\t\tfileUngetc(c);\n\t\t}\n\t}\n\twhile (c != EOF && c != '\\0' && nesting > 0);\n}", "label": 0, "cwe": null, "length": 131 }, { "index": 368875, "code": "build_asm_stmt (tree cv_qualifier, tree args)\n{\n if (!ASM_VOLATILE_P (args) && cv_qualifier)\n ASM_VOLATILE_P (args) = 1;\n return add_stmt (args);\n}", "label": 0, "cwe": null, "length": 51 }, { "index": 429004, "code": "L33()\n{register object *base=vs_base;\n\tregister object *sup=base+VM33; VC33\n\tvs_check;vs_top=sup;\n\t{object V387=base[0]->c.c_cdr;\n\tbase[2]= (V387->c.c_car);\n\tV387=V387->c.c_cdr;\n\tbase[3]= (V387->c.c_car);\n\tV387=V387->c.c_cdr;\n\tbase[4]= V387;}\n\tV388= list(2,((object)VV[37]),base[2]);\n\tV389= list(2,((object)VV[37]),base[2]);\n\tV390= list(2,((object)VV[37]),base[3]);\n\tV391= list(4,((object)VV[107]),/* INLINE-ARGS */V388,list(2,((object)VV[108]),list(4,((object)VV[109]),/* INLINE-ARGS */V389,/* INLINE-ARGS */V390,list(2,((object)VV[37]),base[4]))),((object)VV[110]));\n\tbase[5]= list(3,((object)VV[73]),/* INLINE-ARGS */V391,list(2,((object)VV[37]),base[2]));\n\tvs_top=(vs_base=base+5)+1;\n\treturn;\n}", "label": 0, "cwe": null, "length": 291 }, { "index": 294010, "code": "scm_i_remove_weaks_from_weak_vectors ()\n{\n SCM w = weak_vectors;\n while (!scm_is_null (w))\n {\n scm_i_remove_weaks (w);\n w = SCM_I_WVECT_GC_CHAIN (w);\n }\n}", "label": 0, "cwe": null, "length": 56 }, { "index": 162087, "code": "button_cb(Fl_Widget *,void *) {\n int i = 0;\n if (leftb->value()) i |= FL_ALIGN_LEFT;\n if (rightb->value()) i |= FL_ALIGN_RIGHT;\n if (clipb->value()) i |= FL_ALIGN_CLIP;\n text->rt_align=(Fl_Align)i;\n window->redraw();\n}", "label": 0, "cwe": null, "length": 76 }, { "index": 684010, "code": "SetPropertyShortcutReference(HeapObject* parent_obj,\n HeapEntry* parent_entry,\n String* reference_name,\n Object* child_obj) {\n HeapEntry* child_entry = GetEntry(child_obj);\n if (child_entry != NULL) {\n filler_->SetNamedReference(HeapGraphEdge::kShortcut,\n parent_obj,\n parent_entry,\n collection_->names()->GetName(reference_name),\n child_obj,\n child_entry);\n }\n}", "label": 0, "cwe": null, "length": 95 }, { "index": 599696, "code": "remote_session_add(const char *uid, const char *plugin) {\n\tsession_t *s;\n\tplugin_t *pl;\n\n\tif (!(pl = plugin_find(plugin))) {\n\t\tdebug_error(\"remote_session_add() plugin == NULL\\n\");\n\t\treturn NULL;\n\t}\n\t\t\n\ts = xmalloc(sizeof(session_t));\n\ts->uid\t\t= xstrdup(uid);\n\ts->status\t= EKG_STATUS_NA;\n\ts->plugin\t= pl;\n\n\tsessions_add(s);\n\n\t/* XXX, session_var_default() */\n\n\tquery_emit_id(NULL, SESSION_ADDED, &(s->uid));\n\treturn s;\n}", "label": 0, "cwe": null, "length": 124 }, { "index": 94722, "code": "WriteCompressionBlock(unsigned char* data,\n OffsetType size)\n{\n // Compress the data.\n vtkUnsignedCharArray* outputArray = this->Compressor->Compress(data, size);\n\n // Find the compressed size.\n HeaderType outputSize = outputArray->GetNumberOfTuples();\n unsigned char* outputPointer = outputArray->GetPointer(0);\n\n // Write the compressed data.\n int result = this->DataStream->Write(outputPointer, outputSize);\n this->Stream->flush();\n if (this->Stream->fail())\n {\n this->SetErrorCode(vtkErrorCode::GetLastSystemError());\n }\n\n // Store the resulting compressed size in the compression header.\n this->CompressionHeader[3+this->CompressionBlockNumber++] = outputSize;\n\n outputArray->Delete();\n\n return result;\n}", "label": 0, "cwe": null, "length": 174 }, { "index": 994849, "code": "dMassCheck (const dMass *m)\n{\n int i;\n\n if (m->mass <= 0) {\n dDEBUGMSG (\"mass must be > 0\");\n return 0;\n }\n if (!dIsPositiveDefinite (m->I,3)) {\n dDEBUGMSG (\"inertia must be positive definite\");\n return 0;\n }\n\n // verify that the center of mass position is consistent with the mass\n // and inertia matrix. this is done by checking that the inertia around\n // the center of mass is also positive definite. from the comment in\n // dMassTranslate(), if the body is translated so that its center of mass\n // is at the point of reference, then the new inertia is:\n // I + mass*crossmat(c)^2\n // note that requiring this to be positive definite is exactly equivalent\n // to requiring that the spatial inertia matrix\n // [ mass*eye(3,3) M*crossmat(c)^T ]\n // [ M*crossmat(c) I ]\n // is positive definite, given that I is PD and mass>0. see the theorem\n // about partitioned PD matrices for proof.\n\n dMatrix3 I2,chat;\n dSetZero (chat,12);\n dCROSSMAT (chat,m->c,4,+,-);\n dMULTIPLY0_333 (I2,chat,chat);\n for (i=0; i<3; i++) I2[i] = m->I[i] + m->mass*I2[i];\n for (i=4; i<7; i++) I2[i] = m->I[i] + m->mass*I2[i];\n for (i=8; i<11; i++) I2[i] = m->I[i] + m->mass*I2[i];\n if (!dIsPositiveDefinite (I2,3)) {\n dDEBUGMSG (\"center of mass inconsistent with mass parameters\");\n return 0;\n }\n return 1;\n}", "label": 0, "cwe": null, "length": 446 }, { "index": 77558, "code": "intel_panel_destroy_backlight(struct drm_connector *connector)\n{\n\tstruct intel_connector *intel_connector = to_intel_connector(connector);\n\tstruct intel_panel *panel = &intel_connector->panel;\n\n\t/* dispose of the pwm */\n\tif (panel->backlight.pwm)\n\t\tpwm_put(panel->backlight.pwm);\n\n\tpanel->backlight.present = false;\n}", "label": 0, "cwe": null, "length": 75 }, { "index": 139034, "code": "_osd_req_encode_common(struct osd_request *or,\n\t__be16 act, const struct osd_obj_id *obj, u64 offset, u64 len)\n{\n\tif (osd_req_is_ver1(or))\n\t\t_osdv1_req_encode_common(or, act, obj, offset, len);\n\telse\n\t\t_osdv2_req_encode_common(or, act, obj, offset, len);\n}", "label": 0, "cwe": null, "length": 86 }, { "index": 754031, "code": "jgdi_kill(JNIEnv *env, jobject jgdi, lList* lp, int kill_target, jobject answers)\n{\n lList *alp = NULL;\n sge_gdi_ctx_class_t *ctx = NULL;\n const char *default_cell = NULL;\n jgdi_result_t ret = JGDI_SUCCESS;\n rmon_ctx_t rmon_ctx;\n \n DENTER(TOP_LAYER, \"jgdi_kill\");\n \n jgdi_init_rmon_ctx(env, JGDI_LOGGER, &rmon_ctx);\n rmon_set_thread_ctx(&rmon_ctx);\n \n /* get context */\n ret = getGDIContext(env, jgdi, &ctx, &alp);\n\n sge_gdi_set_thread_local_ctx(ctx);\n\n if (ret == JGDI_SUCCESS) {\n default_cell = ctx->get_default_cell(ctx);\n alp = ctx->kill(ctx, lp, default_cell, 0, kill_target);\n \n /* if error throw exception */\n if (answers != NULL) {\n generic_fill_list(env, answers, \"com/sun/grid/jgdi/configuration/JGDIAnswer\", alp, NULL);\n }\n if (answer_list_has_error(&alp)) {\n ret = JGDI_ERROR;\n }\n }\n \n if (ret != JGDI_SUCCESS) {\n throw_error_from_answer_list(env, ret, alp);\n }\n\n lFreeList(&alp);\n sge_gdi_set_thread_local_ctx(NULL);\n rmon_set_thread_ctx(NULL);\n jgdi_destroy_rmon_ctx(&rmon_ctx);\n\n DRETURN_VOID;\n}", "label": 0, "cwe": null, "length": 347 }, { "index": 271988, "code": "nrrdKernelSpecNew(void) {\n NrrdKernelSpec *ksp;\n int i;\n\n ksp = (NrrdKernelSpec *)calloc(1, sizeof(NrrdKernelSpec));\n if (ksp) {\n ksp->kernel = NULL;\n for (i=0; iparm[i] = airNaN(); /* valgrind complained about AIR_NAN at -O2 */\n }\n }\n return ksp;\n}", "label": 0, "cwe": null, "length": 116 }, { "index": 250057, "code": "encode_rfc(char *buffer, uint8_t *output, size_t outlen)\n{\n\tint attr;\n\tint length, sublen;\n\tchar *p;\n\n\tattr = decode_attr(buffer, &p);\n\tif (attr == 0) return 0;\n\n\tlength = 2;\n\toutput[0] = attr;\n\toutput[1] = 2;\n\n\tif (attr == 26) {\n\t\tsublen = encode_vsa(p, output + 2, outlen - 2);\n\n\t} else if ((attr < 241) || (attr > 246)) {\n\t\tsublen = encode_data(p, output + 2, outlen - 2);\n\n\t} else {\n\t\tif (*p != '.') {\n\t\t\tfprintf(stderr, \"Invalid data following \"\n\t\t\t\t\"attribute number\\n\");\n\t\t\treturn 0;\n\t\t}\n\n\t\tif (attr < 245) {\n\t\t\tsublen = encode_extended(p + 1,\n\t\t\t\t\t\t output + 2, outlen - 2);\n\t\t} else {\n\n\t\t\t/*\n\t\t\t *\tNot like the others!\n\t\t\t */\n\t\t\treturn encode_extended_flags(p + 1, output, outlen);\n\t\t}\n\t}\n\tif (sublen == 0) return 0;\n\tif (sublen > (255 -2)) {\n\t\tfprintf(stderr, \"RFC Data is too long\\n\");\n\t\treturn 0;\n\t}\n\n\toutput[1] += sublen;\n\treturn length + sublen;\n}", "label": 0, "cwe": null, "length": 300 }, { "index": 56931, "code": "_valid_job_part_qos(struct part_record *part_ptr, slurmdb_qos_rec_t *qos_ptr)\n{\n\tif (part_ptr->allow_qos_bitstr) {\n\t\tint match = 0;\n\t\tif ((qos_ptr->id < bit_size(part_ptr->allow_qos_bitstr)) &&\n\t\t bit_test(part_ptr->allow_qos_bitstr, qos_ptr->id))\n\t\t\tmatch = 1;\n\t\tif (match == 0) {\n\t\t\tinfo(\"_valid_job_par_qost: job's QOS not permitted to \"\n\t\t\t \"use this partition (%s allows %s not %s)\",\n\t\t\t part_ptr->name, part_ptr->allow_qos,\n\t\t\t qos_ptr->name);\n\t\t\treturn ESLURM_INVALID_QOS;\n\t\t}\n\t} else if (part_ptr->deny_qos_bitstr) {\n\t\tint match = 0;\n\t\tif ((qos_ptr->id < bit_size(part_ptr->deny_qos_bitstr)) &&\n\t\t bit_test(part_ptr->deny_qos_bitstr, qos_ptr->id))\n\t\t\tmatch = 1;\n\t\tif (match == 1) {\n\t\t\tinfo(\"_valid_job_part_qos: job's QOS not permitted to \"\n\t\t\t \"use this partition (%s denies %s including %s)\",\n\t\t\t part_ptr->name, part_ptr->allow_qos,\n\t\t\t qos_ptr->name);\n\t\t\treturn ESLURM_INVALID_QOS;\n\t\t}\n\t}\n\n\treturn SLURM_SUCCESS;\n}", "label": 0, "cwe": null, "length": 295 }, { "index": 609245, "code": "pestm_substitute_canonical_pointer(Pe_statement *pestm, \n\t\t\t\t const Operand *op, \n\t\t\t\t const Operand *ss)\n{\n Pe_statement *ps;\n\n for (ps = pestm; ps != NULL; ps = ps->next) {\n\tif (ps->stm_head != NULL) {\n\t stm_substitute_canonical_pointer(ps->stm_head, op, ss);\n\t}\n }\n}", "label": 0, "cwe": null, "length": 86 }, { "index": 16911, "code": "bdx_remove(struct pci_dev *pdev)\n{\n\tstruct pci_nic *nic = pci_get_drvdata(pdev);\n\tstruct net_device *ndev;\n\tint port;\n\n\tfor (port = 0; port < nic->port_num; port++) {\n\t\tndev = nic->priv[port]->ndev;\n\t\tunregister_netdev(ndev);\n\t\tfree_netdev(ndev);\n\t}\n\n\t/*bdx_hw_reset_direct(nic->regs); */\n#ifdef BDX_MSI\n\tif (nic->irq_type == IRQ_MSI)\n\t\tpci_disable_msi(pdev);\n#endif\n\n\tiounmap(nic->regs);\n\tpci_release_regions(pdev);\n\tpci_disable_device(pdev);\n\tvfree(nic);\n\n\tRET();\n}", "label": 0, "cwe": null, "length": 149 }, { "index": 383676, "code": "open_mergetool(const char *file)\n{\n\tchar cmd[SIZEOF_STR];\n\tchar file_sq[SIZEOF_STR];\n\n\tif (sq_quote(file_sq, 0, file) < sizeof(file_sq) &&\n\t string_format(cmd, \"git mergetool %s\", file_sq)) {\n\t\topen_external_viewer(cmd);\n\t}\n}", "label": 0, "cwe": null, "length": 71 }, { "index": 109436, "code": "peerMonitorFetchReply(void *data, mem_node_ref nr, ssize_t size)\n{\n PeerMonitor *pm = data;\n\n if (size <= 0 || !cbdataValid(pm->peer)) {\n\tpeerMonitorCompleted(pm);\n } else {\n\tpm->running.size += size;\n\tpm->running.offset += size;\n\tstoreClientRef(pm->running.sc, pm->running.e, pm->running.offset, pm->running.offset, SM_PAGE_SIZE, peerMonitorFetchReply, pm);\n }\n stmemNodeUnref(&nr);\n}", "label": 0, "cwe": null, "length": 114 }, { "index": 725149, "code": "jbg_enc_layers(struct jbg_enc_state *s, int d)\n{\n if (d < 0 || d > 31)\n return;\n s->d = d;\n s->dl = 0;\n s->dh = s->d;\n jbg_set_default_l0(s);\n return;\n}", "label": 0, "cwe": null, "length": 71 }, { "index": 674230, "code": "do_user_summary_output(slist *sptr)\n{\n\tconst snode *sn;\n\n\tif (sptr->cnt == 0) {\n\t\tprintf(\"\\n\\n\");\n\t\treturn;\n\t}\n\tslist_first(sptr);\n\tsn=slist_get_cur(sptr);\n\twhile (sn) {\n\t\tlong uid;\n\t\tchar name[64];\n\n\t\tif (sn->str[0] == '-' || isdigit(sn->str[0])) {\n\t\t\tuid = strtol(sn->str, NULL, 10);\n\t\t\tprintf(\"%u %s\\n\", sn->hits, \n\t\t\t\taulookup_uid(uid, name, sizeof(name)));\n\t\t} else \n\t\t\tprintf(\"%u %s\\n\", sn->hits, sn->str); \n\t\tsn=slist_next(sptr);\n\t}\n}", "label": 0, "cwe": null, "length": 172 }, { "index": 959490, "code": "gcr_key_renderer_set_property (GObject *obj, guint prop_id, const GValue *value,\n GParamSpec *pspec)\n{\n\tGcrKeyRenderer *self = GCR_KEY_RENDERER (obj);\n\n\tswitch (prop_id) {\n\tcase PROP_LABEL:\n\t\tg_free (self->pv->label);\n\t\tself->pv->label = g_value_dup_string (value);\n\t\tg_object_notify (obj, \"label\");\n\t\tgcr_renderer_emit_data_changed (GCR_RENDERER (self));\n\t\tbreak;\n\tcase PROP_ATTRIBUTES:\n\t\tgck_attributes_unref (self->pv->attributes);\n\t\tself->pv->attributes = g_value_dup_boxed (value);\n\t\tgcr_renderer_emit_data_changed (GCR_RENDERER (self));\n\t\tbreak;\n\tcase PROP_OBJECT:\n\t\tg_clear_object (&self->pv->object);\n\t\tself->pv->object = g_value_dup_object (value);\n\t\tif (self->pv->object) {\n\t\t\tgck_attributes_unref (self->pv->attributes);\n\t\t\tself->pv->attributes = NULL;\n\t\t}\n\t\tif (GCK_IS_OBJECT_CACHE (self->pv->object)) {\n\t\t\tself->pv->notify_sig = g_signal_connect (self->pv->object,\n\t\t\t \"notify::attributes\",\n\t\t\t G_CALLBACK (on_object_cache_attributes),\n\t\t\t self);\n\t\t\ton_object_cache_attributes (G_OBJECT (self->pv->object), NULL, self);\n\t\t}\n\t\tg_object_notify (obj, \"attributes\");\n\t\tg_object_notify (obj, \"object\");\n\t\tbreak;\n\tdefault:\n\t\tG_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);\n\t\tbreak;\n\t}\n}", "label": 0, "cwe": null, "length": 342 }, { "index": 900073, "code": "precede(Home home, const SetVarArgs& x, const IntArgs& c) {\n using namespace Set;\n if (c.size() < 2)\n return;\n for (int i=c.size(); i--; )\n Limits::check(c[i],\"Set::precede\");\n if (home.failed()) return;\n\n for (int i=c.size()-1; i--; ) {\n ViewArray y(home, x);\n GECODE_ES_FAIL(Precede::Single::post(home, y, c[i], c[i+1]));\n }\n }\n\n}", "label": 0, "cwe": null, "length": 129 }, { "index": 366435, "code": "main_on_bus_acquired (GDBusConnection* _conn) {\n\tGDBusConnection* _tmp0_ = NULL;\n\tDVBManager* _tmp1_ = NULL;\n\tGDBusConnection* _tmp2_ = NULL;\n\tGDBusConnection* _tmp3_ = NULL;\n\tg_return_if_fail (_conn != NULL);\n\t_tmp0_ = _conn;\n\t_tmp1_ = main_manager;\n\tdvb_utils_dbus_register_object (DVB_TYPE_ID_BUS_MANAGER, (GBoxedCopyFunc) g_object_ref, g_object_unref, _tmp0_, DVB_CONSTANTS_DBUS_MANAGER_PATH, (DVBIDBusManager*) _tmp1_);\n\t_tmp2_ = _conn;\n\t_tmp3_ = _g_object_ref0 (_tmp2_);\n\t_g_object_unref0 (main_conn);\n\tmain_conn = _tmp3_;\n\tmain_start_recordings_store ();\n\tmain_restore_device_groups ();\n}", "label": 0, "cwe": null, "length": 188 }, { "index": 23104, "code": "AbDisplayUsage (\n UINT8 OptionCount)\n{\n\n if (OptionCount)\n {\n printf (\"Option requires %u arguments\\n\\n\", OptionCount);\n }\n\n ACPI_USAGE_HEADER (\"acpibin [options]\");\n\n ACPI_OPTION (\"-c \", \"Compare two binary AML files\");\n ACPI_OPTION (\"-d \", \"Dump AML binary to text file\");\n ACPI_OPTION (\"-e \", \"Extract binary AML table from AcpiDump file\");\n ACPI_OPTION (\"-h \", \"Display table header for binary AML file\");\n ACPI_OPTION (\"-s \", \"Update checksum for binary AML file\");\n ACPI_OPTION (\"-t\", \"Terse mode\");\n ACPI_OPTION (\"-v\", \"Display version information\");\n}", "label": 0, "cwe": null, "length": 178 }, { "index": 806448, "code": "sorting_large_first( int dim, int *critical_count_times, int *critical_dim )\n{\n int i, j;\n int max, max_count_dim, place;\n \n for( i = 0; i < dim; i++ ){\n\tmax = -1;\n\tplace = i;\n\tfor( j = i; j < dim; j++ ){\n\t if( critical_count_times[j] > max ){\n\t\tmax = critical_count_times[j];\n\t\tplace = j;\n\t }\n\t}\n\tmax_count_dim = critical_dim[place];\n\tcritical_dim[place] = critical_dim[i];\n\tcritical_count_times[place] = critical_count_times[i];\n\tcritical_dim[i] = max_count_dim;\n\tcritical_count_times[i] = max;\n }\n}", "label": 0, "cwe": null, "length": 160 }, { "index": 214005, "code": "DeleteDeadInstruction(Instruction *I,\n MemoryDependenceAnalysis &MD,\n SmallPtrSet *ValueSet = 0) {\n SmallVector NowDeadInsts;\n\n NowDeadInsts.push_back(I);\n --NumFastOther;\n\n // Before we touch this instruction, remove it from memdep!\n do {\n Instruction *DeadInst = NowDeadInsts.pop_back_val();\n ++NumFastOther;\n\n // This instruction is dead, zap it, in stages. Start by removing it from\n // MemDep, which needs to know the operands and needs it to be in the\n // function.\n MD.removeInstruction(DeadInst);\n\n for (unsigned op = 0, e = DeadInst->getNumOperands(); op != e; ++op) {\n Value *Op = DeadInst->getOperand(op);\n DeadInst->setOperand(op, 0);\n\n // If this operand just became dead, add it to the NowDeadInsts list.\n if (!Op->use_empty()) continue;\n\n if (Instruction *OpI = dyn_cast(Op))\n if (isInstructionTriviallyDead(OpI))\n NowDeadInsts.push_back(OpI);\n }\n\n DeadInst->eraseFromParent();\n\n if (ValueSet) ValueSet->erase(DeadInst);\n } while (!NowDeadInsts.empty());\n}", "label": 0, "cwe": null, "length": 302 }, { "index": 934029, "code": "tilingPatternFill(GfxState *state, Gfx *gfxA, Catalog *cat, Object *str,\n\t\t\t\t double *pmat, int paintType, int tilingType, Dict *resDict,\n\t\t\t\t double *mat, double *bbox,\n\t\t\t\t int x0, int y0, int x1, int y1,\n\t\t\t\t double xStep, double yStep) {\n if (x1 - x0 == 1 && y1 - y0 == 1) {\n // Don't need to use patterns if only one instance of the pattern is used\n PDFRectangle box;\n Gfx *gfx;\n double x, y, tx, ty;\n\n x = x0 * xStep;\n y = y0 * yStep;\n tx = x * mat[0] + y * mat[2] + mat[4];\n ty = x * mat[1] + y * mat[3] + mat[5];\n box.x1 = bbox[0];\n box.y1 = bbox[1];\n box.x2 = bbox[2];\n box.y2 = bbox[3];\n gfx = new Gfx(doc, this, resDict, &box, NULL, NULL, NULL, gfxA->getXRef());\n writePSFmt(\"[{0:.6g} {1:.6g} {2:.6g} {3:.6g} {4:.6g} {5:.6g}] cm\\n\", mat[0], mat[1], mat[2], mat[3], tx, ty);\n inType3Char = gTrue;\n gfx->display(str);\n inType3Char = gFalse;\n delete gfx;\n return gTrue;\n }\n\n if (level == psLevel1 || level == psLevel1Sep) {\n return tilingPatternFillL1(state, cat, str, pmat, paintType, tilingType, resDict,\n\t\t\t mat, bbox, x0, y0, x1, y1, xStep, yStep);\n } else {\n return tilingPatternFillL2(state, cat, str, pmat, paintType, tilingType, resDict,\n\t\t\t mat, bbox, x0, y0, x1, y1, xStep, yStep);\n }\n}", "label": 0, "cwe": null, "length": 488 }, { "index": 348348, "code": "onClicked(FXObject*,FXSelector,void*){\n FXDragType types[3];\n if(target && target->tryHandle(this,FXSEL(SEL_CLICKED,message),(void*)(FXuval)rgba)) return 1;\n if(!hasSelection()){\n types[0]=stringType;\n types[1]=colorType;\n types[2]=textType;\n acquireSelection(types,3);\n }\n return 1;\n }", "label": 0, "cwe": null, "length": 94 }, { "index": 116522, "code": "add_to_swap(struct page *page, struct list_head *list)\n{\n\tswp_entry_t entry;\n\tint err;\n\n\tVM_BUG_ON_PAGE(!PageLocked(page), page);\n\tVM_BUG_ON_PAGE(!PageUptodate(page), page);\n\n\tentry = get_swap_page();\n\tif (!entry.val)\n\t\treturn 0;\n\n\tif (unlikely(PageTransHuge(page)))\n\t\tif (unlikely(split_huge_page_to_list(page, list))) {\n\t\t\tswapcache_free(entry);\n\t\t\treturn 0;\n\t\t}\n\n\t/*\n\t * Radix-tree node allocations from PF_MEMALLOC contexts could\n\t * completely exhaust the page allocator. __GFP_NOMEMALLOC\n\t * stops emergency reserves from being allocated.\n\t *\n\t * TODO: this could cause a theoretical memory reclaim\n\t * deadlock in the swap out path.\n\t */\n\t/*\n\t * Add it to the swap cache and mark it dirty\n\t */\n\terr = add_to_swap_cache(page, entry,\n\t\t\t__GFP_HIGH|__GFP_NOMEMALLOC|__GFP_NOWARN);\n\n\tif (!err) {\t/* Success */\n\t\tSetPageDirty(page);\n\t\treturn 1;\n\t} else {\t/* -ENOMEM radix-tree allocation failure */\n\t\t/*\n\t\t * add_to_swap_cache() doesn't return -EEXIST, so we can safely\n\t\t * clear SWAP_HAS_CACHE flag.\n\t\t */\n\t\tswapcache_free(entry);\n\t\treturn 0;\n\t}\n}", "label": 0, "cwe": null, "length": 299 }, { "index": 684286, "code": "rotation_to_excel_v8 (int rotation)\n{\n\tif (rotation < 0)\n\t\treturn 0xff;\n\trotation = rotation % 360;\n\tif (rotation > 90)\n\t\treturn 360 + 90 - rotation;\n\treturn rotation;\n}", "label": 0, "cwe": null, "length": 53 }, { "index": 595101, "code": "on_each_cpu_mask(const struct cpumask *mask, smp_call_func_t func,\n\t\t\tvoid *info, bool wait)\n{\n\tint cpu = get_cpu();\n\n\tsmp_call_function_many(mask, func, info, wait);\n\tif (cpumask_test_cpu(cpu, mask)) {\n\t\tunsigned long flags;\n\t\tlocal_irq_save(flags);\n\t\tfunc(info);\n\t\tlocal_irq_restore(flags);\n\t}\n\tput_cpu();\n}", "label": 0, "cwe": null, "length": 87 }, { "index": 986684, "code": "gconf_sources_clear_cache (GConfSources *sources)\n{\n GList* tmp;\n\n tmp = sources->sources;\n\n while (tmp != NULL)\n {\n GConfSource* source = tmp->data;\n\n if (source->backend->vtable.clear_cache)\n (*source->backend->vtable.clear_cache)(source);\n \n tmp = g_list_next(tmp);\n }\n}", "label": 0, "cwe": null, "length": 86 }, { "index": 327064, "code": "showStatusMessage(const QString & message)\n{\n if (sender() == m_statusBar) {\n return;\n }\n\n if (message == m_statusBar->currentMessage()) {\n return;\n }\n\n //DebugDialog::debug(\"show message \" + message);\n m_statusBar->blockSignals(true);\n m_statusBar->showMessage(message);\n m_statusBar->blockSignals(false);\n}", "label": 0, "cwe": null, "length": 85 }, { "index": 120319, "code": "IIT_get_typed_signed_with_divno (int *ntypematches, T this, int divno, unsigned int x, unsigned int y, \n\t\t\t\t int type, int sign, bool sortp) {\n int *sorted;\n int index;\n int *typematches = NULL, *matches, nmatches, i, j;\n Interval_T interval;\n\n if (divno < 0) {\n /* fprintf(stderr,\"No div %s found in iit file\\n\",divstring); */\n *ntypematches = 0;\n return (int *) NULL;\n }\n\n *ntypematches = 0;\n matches = IIT_get_with_divno(&nmatches,this,divno,x,y,/*sortp*/false);\n for (i = 0; i < nmatches; i++) {\n index = matches[i];\n interval = &(this->intervals[0][index-1]);\n if (Interval_type(interval) == type && Interval_sign(interval) == sign) {\n (*ntypematches)++;\n }\n }\n\n if (*ntypematches > 0) {\n typematches = (int *) CALLOC(*ntypematches,sizeof(int));\n j = 0;\n for (i = 0; i < nmatches; i++) {\n index = matches[i];\n interval = &(this->intervals[0][index-1]);\n if (Interval_type(interval) == type && Interval_sign(interval) == sign) {\n\ttypematches[j++] = index;\n }\n }\n }\n \n if (matches != NULL) {\n FREE(matches);\n }\n\n if (sortp == false) {\n return typematches;\n#if 0\n } else if (this->version <= 2) {\n sorted = sort_matches_by_type(this,typematches,*ntypematches,/*alphabetizep*/false);\n FREE(typematches);\n return sorted;\n#endif\n } else {\n sorted = sort_matches_by_position(this,typematches,*ntypematches);\n FREE(typematches);\n return sorted;\n }\n}", "label": 0, "cwe": null, "length": 453 }, { "index": 51534, "code": "exo_toolbars_view_drag_data_received (GtkWidget *toolbar,\n GdkDragContext *context,\n gint x,\n gint y,\n GtkSelectionData *selection_data,\n guint info,\n guint drag_time,\n ExoToolbarsView *view)\n{\n GdkAtom target;\n gchar *type;\n gchar *id;\n gint toolbar_position;\n gint item_position;\n\n target = gtk_drag_dest_find_target (toolbar, context, NULL);\n type = exo_toolbars_model_get_item_type (view->priv->model, target);\n id = exo_toolbars_model_get_item_id (view->priv->model, type, (const gchar *) selection_data->data);\n\n if (G_UNLIKELY (id == NULL))\n {\n view->priv->pending = FALSE;\n g_free (type);\n return;\n }\n\n if (view->priv->pending)\n {\n view->priv->pending = FALSE;\n view->priv->dragged_item = exo_toolbars_view_create_item_from_action (view, id, type,\n data_is_separator (id),\n NULL);\n g_object_ref (G_OBJECT (view->priv->dragged_item));\n gtk_object_sink (GTK_OBJECT (view->priv->dragged_item));\n }\n else\n {\n item_position = gtk_toolbar_get_drop_index (GTK_TOOLBAR (toolbar), x, y);\n toolbar_position = exo_toolbars_view_get_toolbar_position (view, toolbar);\n\n if (data_is_separator ((const gchar *) selection_data->data))\n exo_toolbars_model_add_separator (view->priv->model, toolbar_position, item_position);\n else\n exo_toolbars_model_add_item (view->priv->model, toolbar_position, item_position, id, type);\n\n gtk_drag_finish (context, TRUE, context->action == GDK_ACTION_MOVE, drag_time);\n }\n\n g_free (type);\n g_free (id);\n}", "label": 0, "cwe": null, "length": 419 }, { "index": 942354, "code": "vd_auto_scroll_notify_cb(GtkWidget *widget, gint x, gint y, gpointer data)\n{\n\tViewDir *vd = data;\n\n\tif (!vd->drop_fd || vd->drop_list) return FALSE;\n\n\tif (!vd->drop_scroll_id) vd->drop_scroll_id = g_idle_add(vd_auto_scroll_idle_cb, vd);\n\n\treturn TRUE;\n}", "label": 0, "cwe": null, "length": 73 }, { "index": 384564, "code": "m_check_expression(pIIR_ExpressionList el, RegionStack &rstack)\n{\n int error_count = 0;\n list rlist;\n\n for (pIIR_ExpressionList elp = el; elp; elp = elp->rest) {\n error_count += check_expression(elp->first, rstack);\n rlist.push_back(static_declarative_region(elp->first));\n }\n // Determine combined declarative region\n static_declarative_region(el) = get_combined_static_region(rlist, rstack);\n\n return error_count;\n}", "label": 0, "cwe": null, "length": 130 }, { "index": 103550, "code": "icmTextDescription_unallocate(\n\ticmTextDescription *p\n) {\n\ticc *icp = p->icp;\n\n\tif (p->desc != NULL)\n\t\ticp->al->free(icp->al, p->desc);\n\tif (p->ucDesc != NULL)\n\t\ticp->al->free(icp->al, p->ucDesc);\n}", "label": 0, "cwe": null, "length": 82 }, { "index": 432365, "code": "get_type_basis_in_gamess_file(gchar *fileName)\n{\n \tgchar *t;\n \tFILE *fd;\n \tguint taille=BSIZE;\n\tgint ktype = -1;\n\n \tt=g_malloc(taille);\n \tfd = FOpen(fileName, \"rb\");\n\n \tif(fd ==NULL)\n \t{\n\t\tgchar buffer[BSIZE];\n\t\tsprintf(buffer,_(\"Sorry, I can not open '%s' file\\n\"),fileName);\n \t\tMessage(buffer,_(\"Error\"),TRUE);\n\n \t\tg_free(t);\n \t\treturn ktype;\n \t}\n\tktype = 0;\n\twhile(!feof(fd))\n\t{\n \t\t{ char* e = fgets(t,taille,fd);}\n \tif(strstr( t, \"ISPHER=\"))\n\t\t{\n\t\t\tgchar t1[50];\n\t\t\tgchar t2[50];\n\t\t\tsscanf(t,\"%s %s\",t1,t2);\n\t\t\tif(strstr(t2,\"-\")) ktype = 1;\n\t\t\telse if(atoi(t2)==0) ktype = -1;\n\t\t\tbreak;\n\t\t}\n\t}\n \tfclose(fd);\n \tg_free(t);\n\treturn ktype;\n \n}", "label": 1, "cwe": [ "CWE-120", "CWE-other" ], "length": 243 }, { "index": 334370, "code": "mr_get_norms_into(IndexReader *ir, int field_num, uchar *buf)\n{\n uchar *bytes;\n\n mutex_lock(&ir->mutex);\n bytes = h_get_int(MR(ir)->norms_cache, field_num);\n if (NULL != bytes) {\n memcpy(buf, bytes, MR(ir)->max_doc);\n }\n else {\n int i;\n const int mr_reader_cnt = MR(ir)->r_cnt;\n for (i = 0; i < mr_reader_cnt; i++) {\n int fnum = mr_get_field_num(MR(ir), i, field_num);\n if (fnum >= 0) {\n IndexReader *reader = MR(ir)->sub_readers[i];\n reader->get_norms_into(reader, fnum, buf + MR(ir)->starts[i]);\n }\n }\n }\n mutex_unlock(&ir->mutex);\n return buf;\n}", "label": 0, "cwe": null, "length": 190 }, { "index": 43222, "code": "fl_set_input_return( FL_OBJECT * obj,\n unsigned int when )\n{\n FLI_INPUT_SPEC *sp = obj->spec;\n\n if ( when & FL_RETURN_END_CHANGED )\n when &= ~ ( FL_RETURN_END | FL_RETURN_CHANGED );\n\n obj->how_return = sp->input->how_return = when;\n fl_set_object_return( sp->vscroll, FL_RETURN_CHANGED );\n fl_set_object_return( sp->hscroll, FL_RETURN_CHANGED );\n}", "label": 0, "cwe": null, "length": 100 }, { "index": 225308, "code": "jt8ew9_limits(struct smiapp_sensor *sensor)\n{\n\tif (sensor->minfo.revision_number_major < 0x03)\n\t\tsensor->frame_skip = 1;\n\n\t/* Below 24 gain doesn't have effect at all, */\n\t/* but ~59 is needed for full dynamic range */\n\tsmiapp_replace_limit(sensor, SMIAPP_LIMIT_ANALOGUE_GAIN_CODE_MIN, 59);\n\tsmiapp_replace_limit(\n\t\tsensor, SMIAPP_LIMIT_ANALOGUE_GAIN_CODE_MAX, 6000);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 118 }, { "index": 789949, "code": "EmitVFPRegSave(uint32_t VFPRegSave) {\n // We only have 4 bits to save the offset in the opcode so look at the lower\n // and upper 16 bits separately.\n for (uint32_t Regs : {VFPRegSave & 0xffff0000u, VFPRegSave & 0x0000ffffu}) {\n while (Regs) {\n // Now look for a run of set bits. Remember the MSB and LSB of the run.\n auto RangeMSB = 32 - countLeadingZeros(Regs);\n auto RangeLen = countLeadingOnes(Regs << (32 - RangeMSB));\n auto RangeLSB = RangeMSB - RangeLen;\n\n int Opcode = RangeLSB >= 16\n ? ARM::EHABI::UNWIND_OPCODE_POP_VFP_REG_RANGE_FSTMFDD_D16\n : ARM::EHABI::UNWIND_OPCODE_POP_VFP_REG_RANGE_FSTMFDD;\n\n EmitInt16(Opcode | ((RangeLSB % 16) << 4) | (RangeLen - 1));\n\n // Zero out bits we're done with.\n Regs &= ~(-1u << RangeLSB);\n }\n }\n}", "label": 0, "cwe": null, "length": 267 }, { "index": 782677, "code": "L4()\n{register object *base=vs_base;\n\tregister object *sup=base+VM4; VC4\n\tvs_check;vs_top=sup;\n\t{object V36=base[0]->c.c_cdr;\n\tbase[2]= V36;}\n\tif(!(((long)length(base[2]))<=((long)1))){\n\tgoto T52;}\n\tbase[3]= make_cons(((object)VV[20]),base[2]);\n\tvs_top=(vs_base=base+3)+1;\n\treturn;\n\tgoto T52;\nT52:;\n\tbase[3]= list(2,((object)VV[20]),make_cons(((object)VV[21]),base[2]));\n\tvs_top=(vs_base=base+3)+1;\n\treturn;\n}", "label": 0, "cwe": null, "length": 160 }, { "index": 5688, "code": "slip_read(ifp, m)\nstruct interface *ifp;\nstruct message *m;\n{\n\tint n;\n\tstruct slippy *s;\n\n\tCK_IFNULL(ifp);\n\tCK_IFTYPE(ifp,IF_TYPE_SLIP);\n\tCK_IFOPEN(ifp);\n\tCK_MNULL(m);\n\n\ts = (struct slippy *)ifp->private;\n\tifp->status &= ~IF_STAT_CALL_AGAIN;\n\tm->length = 0;\n\n\tfor(;;){\n\t\tif(s->bnext >= s->bcount){\t/* we need more data! */\n\t\t\ts->bnext = 0;\n\t\t\ts->bcount = 0;\n\t\t\tn = read(ifp->fd, (char *)s->buffer, MAX_SIZE);\n\t\t\tif(n==0)return 0;\t/* got nothing */\n\t\t\tif(n<0){\n\t\t\t\tif(errno==EINTR)return 0;\t/* SIGHUP! */\n\t\t\t\tif(errno==EWOULDBLOCK)return 0; /* got nothing */\n\t\t\t\tPERR(\"read from tty device\");\n\t\t\t\treturn -1;\n\t\t\t}\n\t\t\ts->bcount = n;\n\t\t}\n\n\t\tn = assemble_slip(s, s->buffer[s->bnext]);\n\t\ts->bnext++;\n\n\t\tif(n > 0){\n\t\t\t(void)memcpy((char *)m->msg, (char *)s->ipacket, n);\n\t\t\tm->length = n;\n\t\t\tif(s->bnext < s->bcount)\n\t\t\t\tifp->status |= IF_STAT_CALL_AGAIN;\n\t\t\treturn n;\n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 328 }, { "index": 569741, "code": "unregister(URegistryKey rkey, UErrorCode& status) \n{\n ICUServiceFactory *factory = (ICUServiceFactory*)rkey;\n UBool result = FALSE;\n if (factory != NULL && factories != NULL) {\n Mutex mutex(&lock);\n\n if (factories->removeElement(factory)) {\n clearCaches();\n result = TRUE;\n } else {\n status = U_ILLEGAL_ARGUMENT_ERROR;\n delete factory;\n }\n }\n if (result) {\n notifyChanged();\n }\n return result;\n}", "label": 0, "cwe": null, "length": 116 }, { "index": 322264, "code": "view_display_edited(GtkTreeModel *model, gboolean condition, const gchar *path_str,\n\tconst char *format, gchar *new_text)\n{\n\tif (validate_column(new_text, TRUE))\n\t{\n\t\tif (condition)\n\t\t{\n\t\t\tGtkTreeIter iter;\n\t\t\tchar *name;\n\t\t\tgint hb_mode;\n\t\t\tchar *locale;\n\n\t\t\tgtk_tree_model_get_iter_from_string(model, &iter, path_str);\n\t\t\tgtk_tree_model_get(model, &iter, COLUMN_NAME, &name, COLUMN_HB_MODE,\n\t\t\t\t&hb_mode, -1);\n\t\t\tlocale = utils_get_locale_from_display(new_text, hb_mode);\n\t\t\tutils_strchrepl(locale, '\\n', ' ');\n\t\t\tdebug_send_format(F, format, name, locale);\n\t\t\tg_free(name);\n\t\t\tg_free(locale);\n\t\t}\n\t\telse\n\t\t\tplugin_blink();\n\t}\n}", "label": 0, "cwe": null, "length": 183 }, { "index": 666430, "code": "platforms_compatible( const string &target, const string &platform )\n{\n if ( target == platform )\n return true;\n // the below doesn't work as the unmapped platform is transfered back to the\n // client and that asks the daemon for a platform he can't install (see TODO)\n\n static multimap platform_map;\n\n if (platform_map.empty())\n {\n platform_map.insert( make_pair( string( \"i386\" ), string( \"i486\" ) ) );\n platform_map.insert( make_pair( string( \"i386\" ), string( \"i586\" ) ) );\n platform_map.insert( make_pair( string( \"i386\" ), string( \"i686\" ) ) );\n platform_map.insert( make_pair( string( \"i386\" ), string( \"x86_64\" ) ) );\n\n platform_map.insert( make_pair( string( \"i486\" ), string( \"i586\" ) ) );\n platform_map.insert( make_pair( string( \"i486\" ), string( \"i686\" ) ) );\n platform_map.insert( make_pair( string( \"i486\" ), string( \"x86_64\" ) ) );\n\n platform_map.insert( make_pair( string( \"i586\" ), string( \"i686\" ) ) );\n platform_map.insert( make_pair( string( \"i586\" ), string( \"x86_64\" ) ) );\n\n platform_map.insert( make_pair( string( \"i686\" ), string( \"x86_64\" ) ) );\n\n platform_map.insert( make_pair( string( \"ppc\" ), string( \"ppc64\" ) ) );\n platform_map.insert( make_pair( string( \"s390\" ), string( \"s390x\" ) ) );\n }\n\n multimap::const_iterator end = platform_map.upper_bound( target );\n for ( multimap::const_iterator it = platform_map.lower_bound( target );\n it != end;\n ++it )\n {\n if ( it->second == platform )\n return true;\n }\n\n return false;\n}", "label": 0, "cwe": null, "length": 455 }, { "index": 794173, "code": "listTypeDelete(listTypeEntry *entry) {\n listTypeIterator *li = entry->li;\n if (li->encoding == REDIS_ENCODING_ZIPLIST) {\n unsigned char *p = entry->zi;\n li->subject->ptr = ziplistDelete(li->subject->ptr,&p);\n\n /* Update position of the iterator depending on the direction */\n if (li->direction == REDIS_TAIL)\n li->zi = p;\n else\n li->zi = ziplistPrev(li->subject->ptr,p);\n } else if (entry->li->encoding == REDIS_ENCODING_LINKEDLIST) {\n listNode *next;\n if (li->direction == REDIS_TAIL)\n next = entry->ln->next;\n else\n next = entry->ln->prev;\n listDelNode(li->subject->ptr,entry->ln);\n li->ln = next;\n } else {\n redisPanic(\"Unknown list encoding\");\n }\n}", "label": 0, "cwe": null, "length": 212 }, { "index": 445224, "code": "CheckPower()\n{\n // item cast not used power\n if (m_CastItem)\n return SPELL_CAST_OK;\n\n // Do precise power regen on spell cast\n if (m_powerCost > 0 && m_caster->GetTypeId() == TYPEID_PLAYER)\n {\n Player* playerCaster = (Player*)m_caster;\n uint32 diff = REGEN_TIME_FULL - m_caster->GetRegenTimer();\n if (diff >= REGEN_TIME_PRECISE)\n playerCaster->RegenerateAll(diff);\n }\n\n // health as power used - need check health amount\n if (m_spellInfo->powerType == POWER_HEALTH)\n {\n if (m_caster->GetHealth() <= m_powerCost)\n return SPELL_FAILED_CASTER_AURASTATE;\n return SPELL_CAST_OK;\n }\n\n // Check valid power type\n if (m_spellInfo->powerType >= MAX_POWERS)\n {\n sLog.outError(\"Spell::CheckMana: Unknown power type '%d'\", m_spellInfo->powerType);\n return SPELL_FAILED_UNKNOWN;\n }\n\n // check rune cost only if a spell has PowerType == POWER_RUNE\n if (m_spellInfo->powerType == POWER_RUNE)\n {\n SpellCastResult failReason = CheckOrTakeRunePower(false);\n if (failReason != SPELL_CAST_OK)\n return failReason;\n }\n\n // Check power amount\n Powers powerType = Powers(m_spellInfo->powerType);\n if (m_caster->GetPower(powerType) < m_powerCost)\n return SPELL_FAILED_NO_POWER;\n\n return SPELL_CAST_OK;\n}", "label": 0, "cwe": null, "length": 351 }, { "index": 3049, "code": "command_read_sequence(unsigned char command, unsigned char *data) {\n\tint bytes_read = 0;\n\tint retry = 0;\n\n\twhile ((bytes_read < 1) && (retry < 5)) {\n\t\tsend_read_command(command);\n\t\tbytes_read = get_answer(data);\n\t\tif (retry > 2) ser_flush_in(upsfd, \"\", 0);\n\t\tretry += 1;\n\t}\n\tif ((data[0] != command) || (retry == 5)) {\n\t\tser_comm_fail(\"Error executing command %d\\n\", command);\n\t\tdstate_datastale();\n\t\treturn -1;\n\t}\n\tser_comm_good();\n\treturn bytes_read;\n}", "label": 0, "cwe": null, "length": 141 }, { "index": 590576, "code": "logDensity(double const *x, unsigned int length, PDFType type,\n\t\t\tvector const &par,\n\t\t\tvector const &lengths,\n\t\t\tdouble const *lower, double const *upper) const\n{\n unsigned int y = static_cast(*x);\n if (y < 1 || y > NCAT(lengths)) {\n\treturn JAGS_NEGINF;\n }\n \n if (type == PDF_PRIOR) {\n\t//No need to calculate the normalizing constant\n\treturn log(PROB(par)[y-1]);\n }\n else {\n\t//Need to normalize the log density\n\tdouble sump = 0.0;\n\tfor (unsigned int i = 0; i < NCAT(lengths); i++) {\n\t sump += PROB(par)[i];\n\t}\n\treturn log(PROB(par)[y-1]) - log(sump);\n }\n}", "label": 0, "cwe": null, "length": 191 }, { "index": 185574, "code": "unrealize (GtkWidget *widget)\n{\n\tNautilusDesktopWindow *window;\n\tNautilusDesktopWindowDetails *details;\n\n\twindow = NAUTILUS_DESKTOP_WINDOW (widget);\n\tdetails = window->details;\n\n\tif (details->size_changed_id != 0) {\n\t\tg_signal_handler_disconnect (gtk_window_get_screen (GTK_WINDOW (window)),\n\t\t\t\t\t details->size_changed_id);\n\t\tdetails->size_changed_id = 0;\n\t}\n\n\tGTK_WIDGET_CLASS (nautilus_desktop_window_parent_class)->unrealize (widget);\n}", "label": 0, "cwe": null, "length": 113 }, { "index": 1015311, "code": "Gvl_load_colors_data(void **color_data, const char *name)\n{\n const char *mapset;\n struct Colors *colors;\n\n if (NULL == (mapset = G_find_grid3(name, \"\"))) {\n\tG_warning(_(\"3D raster map <%s> not found\"), name);\n\treturn (-1);\n }\n\n if (NULL == (colors = (struct Colors *)G_malloc(sizeof(struct Colors))))\n\treturn (-1);\n\n if (0 > G3d_readColors(name, mapset, colors)) {\n\tG_free(colors);\n\treturn (-1);\n }\n\n *color_data = colors;\n\n return (1);\n}", "label": 0, "cwe": null, "length": 132 }, { "index": 1012909, "code": "eventFilter(QObject *object, QEvent *event)\n{\n switch (event->type())\n {\n case QEvent::MouseButtonPress:\n case QEvent::MouseButtonRelease:\n case QEvent::MouseButtonDblClick:\n case QEvent::MouseMove:\n case QEvent::KeyPress:\n case QEvent::KeyRelease:\n case QEvent::Destroy:\n case QEvent::Close:\n case QEvent::Quit:\n case QEvent::Shortcut:\n case QEvent::ShortcutOverride:\n {\n while (object->parent())\n object = object->parent();\n if (object == this)\n return QWidget::eventFilter(object, event);\n else\n {\n if (event->type() == QEvent::Close)\n event->setAccepted(false);\n return true;\n }\n }\n break;\n default:\n return QWidget::eventFilter(object, event);\n }\n\n}", "label": 0, "cwe": null, "length": 191 }, { "index": 357078, "code": "make_path(const char* dir_path, const char* filename)\n{\n\tchar* buf;\n\tsize_t len;\n\tassert(dir_path);\n\tassert(filename);\n\n\t/* remove leading path separators from filename */\n\twhile(IS_PATH_SEPARATOR(*filename)) filename++;\n\n\t/* copy directory path */\n\tlen = strlen(dir_path);\n\tbuf = (char*)rsh_malloc(len + strlen(filename) + 2);\n\tstrcpy(buf, dir_path);\n\n\t/* separate directory from filename */\n\tif(len > 0 && !IS_PATH_SEPARATOR(buf[len-1]))\n\t\tbuf[len++] = SYS_PATH_SEPARATOR;\n\n\t/* append filename */\n\tstrcpy(buf+len, filename);\n\treturn buf;\n}", "label": 0, "cwe": null, "length": 129 }, { "index": 579641, "code": "finger_det_reqs_cb(struct libusb_transfer *t)\n{\n\tstruct libusb_transfer *transfer;\n\tunsigned char *data;\n\tint r;\n\tstruct fp_img_dev *dev = t->user_data;\n\n\tif (t->status != LIBUSB_TRANSFER_COMPLETED) {\n\t\tfp_dbg(\"req transfer status %d\\n\", t->status);\n\t\tfpi_imgdev_session_error(dev, -EIO);\n\t\tgoto exit_free_transfer;\n\t} else if (t->length != t->actual_length) {\n\t\tfp_dbg(\"expected %d, got %d bytes\", t->length, t->actual_length);\n\t\tfpi_imgdev_session_error(dev, -EPROTO);\n\t\tgoto exit_free_transfer;\n\t}\n\n\ttransfer = libusb_alloc_transfer(0);\n\tif (!transfer) {\n\t\tfpi_imgdev_session_error(dev, -ENOMEM);\n\t\tgoto exit_free_transfer;\n\t}\n\n\t/* 2 bytes of result */\n\tdata = g_malloc(AES2550_EP_IN_BUF_SIZE);\n\tlibusb_fill_bulk_transfer(transfer, dev->udev, EP_IN, data, AES2550_EP_IN_BUF_SIZE,\n\t\tfinger_det_data_cb, dev, BULK_TIMEOUT);\n\n\tr = libusb_submit_transfer(transfer);\n\tif (r < 0) {\n\t\tg_free(data);\n\t\tlibusb_free_transfer(transfer);\n\t\tfpi_imgdev_session_error(dev, r);\n\t}\nexit_free_transfer:\n\tlibusb_free_transfer(t);\n}", "label": 0, "cwe": null, "length": 293 }, { "index": 994153, "code": "OnAttach()\n{\n#if defined(TRACE_ENVVARS)\n Manager::Get()->GetLogManager()->DebugLog(F(_T(\"OnAttach\")));\n#endif\n\n if (!Manager::LoadResource(_T(\"envvars.zip\")))\n NotifyMissingFile(_T(\"envvars.zip\"));\n\n // load and apply configuration (to application only)\n ConfigManager *cfg = Manager::Get()->GetConfigManager(_T(\"envvars\"));\n if (!cfg)\n return;\n\n // will apply the currently active envvar set\n nsEnvVars::EnvvarSetApply(wxEmptyString, true);\n\n // register event sink\n Manager::Get()->RegisterEventSink(cbEVT_PROJECT_ACTIVATE, new cbEventFunctor(this, &EnvVars::OnProjectActivated));\n Manager::Get()->RegisterEventSink(cbEVT_PROJECT_CLOSE, new cbEventFunctor(this, &EnvVars::OnProjectClosed));\n\n // Register scripting\n Manager::Get()->GetScriptingManager(); // make sure the VM is initialised\n if (SquirrelVM::GetVMPtr())\n {\n SqPlus::RegisterGlobal(&nsEnvVars::GetEnvvarSetNames, \"EnvvarGetEnvvarSetNames\" );\n SqPlus::RegisterGlobal(&nsEnvVars::GetEnvvarSetNames, \"EnvvarGetActiveSetName\" );\n SqPlus::RegisterGlobal(&nsEnvVars::GetEnvvarsBySetPath, \"EnvVarGetEnvvarsBySetPath\");\n SqPlus::RegisterGlobal(&nsEnvVars::EnvvarSetExists, \"EnvvarSetExists\" );\n SqPlus::RegisterGlobal(&nsEnvVars::EnvvarSetApply, \"EnvvarSetApply\" );\n SqPlus::RegisterGlobal(&nsEnvVars::EnvvarSetDiscard, \"EnvvarSetDiscard\" );\n SqPlus::RegisterGlobal(&nsEnvVars::EnvvarApply, \"EnvvarApply\" );\n SqPlus::RegisterGlobal(&nsEnvVars::EnvvarDiscard, \"EnvvarDiscard\" );\n }\n}", "label": 0, "cwe": null, "length": 452 }, { "index": 24223, "code": "cavan_vfat_read_dbr(struct cavan_block_device *bdev, struct fat_dbr *dbr)\n{\n\tssize_t rdlen;\n\n\trdlen = bdev->read_byte(bdev, 0, 0, dbr, sizeof(*dbr));\n\tif (rdlen < 0)\n\t{\n\t\tpr_red_info(\"bdev->read_byte\");\n\t\treturn rdlen;\n\t}\n\n\tif (dbr->boot_flags != 0xAA55)\n\t{\n\t\tpr_red_info(\"dbr->boot_flags = 0x%04x\", dbr->boot_flags);\n\t\treturn -EINVAL;\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 136 }, { "index": 718890, "code": "on_lookup_unlocked (GObject *source,\n GAsyncResult *result,\n gpointer user_data)\n{\n\tGSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);\n\tLookupClosure *closure = g_simple_async_result_get_op_res_gpointer (res);\n\tSecretService *self = SECRET_SERVICE (source);\n\tGError *error = NULL;\n\tgchar **unlocked = NULL;\n\n\tsecret_service_unlock_dbus_paths_finish (SECRET_SERVICE (source),\n\t result, &unlocked, &error);\n\tif (error != NULL) {\n\t\tg_simple_async_result_take_error (res, error);\n\t\tg_simple_async_result_complete (res);\n\n\t} else if (unlocked && unlocked[0]) {\n\t\tsecret_service_get_secret_for_dbus_path (self, unlocked[0],\n\t\t closure->cancellable,\n\t\t on_lookup_get_secret,\n\t\t g_object_ref (res));\n\n\t} else {\n\t\tg_simple_async_result_complete (res);\n\t}\n\n\tg_strfreev (unlocked);\n\tg_object_unref (res);\n}", "label": 0, "cwe": null, "length": 216 }, { "index": 669457, "code": "BuildMenu(wxMenuBar* menuBar)\n{\n int idx = menuBar->FindMenu(_(\"&View\"));\n if (idx != wxNOT_FOUND)\n {\n wxMenu* view = menuBar->GetMenu(idx);\n wxMenuItemList& items = view->GetMenuItems();\n // find the first separator and insert before it\n bool done = false;\n for (size_t i = 0; i < items.GetCount(); ++i)\n {\n if (items[i]->IsSeparator())\n {\n view->InsertCheckItem(i, idViewTodo, _(\"Todo list\"), _(\"Toggle displaying the To-Do list\"));\n done = true;\n break;\n }\n }\n // not found, just append\n if ( !done )\n view->AppendCheckItem(idViewTodo, _(\"Todo list\"), _(\"Toggle displaying the To-Do list\"));\n }\n\n idx = menuBar->FindMenu(_(\"&Edit\"));\n if (idx != wxNOT_FOUND)\n {\n wxMenu* edit = menuBar->GetMenu(idx);\n edit->AppendSeparator();\n edit->Append(idAddTodo, _(\"Add Todo item...\"), _(\"Add Todo item...\"));\n }\n\n}", "label": 0, "cwe": null, "length": 250 }, { "index": 35247, "code": "pack_diameter(int n)\n{\n double *radius = atom->radius;\n\n for (int i = 0; i < nchoose; i++) {\n buf[n] = 2.0*radius[clist[i]];\n n += size_one;\n }\n}", "label": 0, "cwe": null, "length": 58 }, { "index": 515984, "code": "svc_rqst_integrity_protected(struct svc_rqst *rqstp)\n{\n\tstruct svc_cred *cr = &rqstp->rq_cred;\n\tu32 service;\n\n\tif (!cr->cr_gss_mech)\n\t\treturn false;\n\tservice = gss_pseudoflavor_to_service(cr->cr_gss_mech, cr->cr_flavor);\n\treturn service == RPC_GSS_SVC_INTEGRITY ||\n\t service == RPC_GSS_SVC_PRIVACY;\n}", "label": 0, "cwe": null, "length": 97 }, { "index": 632769, "code": "round6(double x) {\n x *= 1e6;\n if (x < 0) x -= 1.0;\n return 1e-6*(int)(x+0.5);\n}", "label": 0, "cwe": null, "length": 47 }, { "index": 824088, "code": "contentsDragEnterEvent( QDragEnterEvent *ev )\n{\n if ( ! acceptDrag( ev ) )\n {\n ev->ignore();\n return;\n }\n ev->acceptProposedAction();\n m_currentBeforeDropItem = selectedItem();\n\n Q3ListViewItem *item = itemAt( contentsToViewport( ev->pos() ) );\n if( item )\n {\n m_dropItem = item;\n m_autoOpenTimer->start( (QApplication::startDragTime() * 3) / 2 );\n }\n else\n {\n m_dropItem = 0;\n}\n}", "label": 0, "cwe": null, "length": 129 }, { "index": 312755, "code": "iso_mktime(const char *timestamp)\n{\n\tbool utc, zone;\n\tstruct tm t;\n\tint zoneminutes;\n\tif( !iso_to_tm(timestamp, &t, utc, &zone, &zoneminutes) )\n\t\treturn (time_t)-1;\n\n\tTzWrapper tzw;\n\tif( utc ) {\n\t\ttzw.SetUTC();\n\t}\n\telse if( zone ) {\n\t\ttzw.SetOffset(zoneminutes);\n\t}\n\treturn tzw.mktime(&t);\n}", "label": 0, "cwe": null, "length": 101 }, { "index": 625360, "code": "modperl_response_handler_run(request_rec *r)\n{\n int retval;\n\n modperl_response_init(r);\n\n retval = modperl_callback_per_dir(MP_RESPONSE_HANDLER, r, MP_HOOK_RUN_FIRST);\n\n if ((retval == DECLINED) && r->content_type) {\n r->handler = r->content_type; /* let http_core or whatever try */\n }\n\n return retval;\n}", "label": 0, "cwe": null, "length": 83 }, { "index": 365816, "code": "vtkOpaqueAtVertices (int XSize, int YSize, double ScaleFactor, \n vtkUnsignedCharArray *newScalars)\n{\n int i, j;\n double opacity;\n double point[3];\n double XScale = XSize + 1.0;\n double YScale = YSize + 1.0;\n unsigned char AGrayValue[2];\n double dist, distToV2, distToV3;\n double v1[3] = {0.0, 0.0, 0.0};\n double v2[3] = {1.0, 0.0, 0.0};\n double v3[3] = {0.5, sqrt(3.0)/2.0, 0.0};\n\n point[2] = 0.0;\n AGrayValue[0] = AGrayValue[1] = 255;\n\n for (j = 0; j < YSize; j++) \n {\n for (i = 0; i < XSize; i++) \n {\n point[0] = i / XScale;\n point[1] = j / YScale;\n dist = vtkMath::Distance2BetweenPoints (point, v1);\n distToV2 = vtkMath::Distance2BetweenPoints (point, v2);\n if (distToV2 < dist)\n {\n dist = distToV2;\n }\n distToV3 = vtkMath::Distance2BetweenPoints (point, v3);\n if (distToV3 < dist)\n {\n dist = distToV3;\n }\n\n opacity = sqrt(dist) * ScaleFactor;\n if (opacity < .5)\n {\n opacity = 0.0;\n }\n if (opacity > .5)\n {\n opacity = 1.0;\n }\n opacity = 1.0 - opacity;\n AGrayValue[1] = static_cast(opacity * 255);\n newScalars->SetValue ((XSize*j + i)*2, AGrayValue[0]);\n newScalars->SetValue ((XSize*j + i)*2 + 1, AGrayValue[1]);\n } \n }\n}", "label": 0, "cwe": null, "length": 479 }, { "index": 764629, "code": "_dispose (GObject *object)\n{\n FrogrConfigPrivate *priv = FROGR_CONFIG_GET_PRIVATE (object);\n\n if (priv->accounts)\n {\n g_slist_foreach (priv->accounts, (GFunc)g_object_unref, NULL);\n g_slist_free (priv->accounts);\n priv->accounts = NULL;\n }\n\n /* Call superclass */\n G_OBJECT_CLASS (frogr_config_parent_class)->dispose (object);\n}", "label": 0, "cwe": null, "length": 98 }, { "index": 35011, "code": "kvm_test_age_rmapp(struct kvm *kvm, unsigned long *rmapp,\n\t\t\t struct kvm_memory_slot *slot, gfn_t gfn,\n\t\t\t int level, unsigned long data)\n{\n\tu64 *sptep;\n\tstruct rmap_iterator iter;\n\tint young = 0;\n\n\t/*\n\t * If there's no access bit in the secondary pte set by the\n\t * hardware it's up to gup-fast/gup to set the access bit in\n\t * the primary pte or in the page structure.\n\t */\n\tif (!shadow_accessed_mask)\n\t\tgoto out;\n\n\tfor_each_rmap_spte(rmapp, &iter, sptep)\n\t\tif (*sptep & shadow_accessed_mask) {\n\t\t\tyoung = 1;\n\t\t\tbreak;\n\t\t}\nout:\n\treturn young;\n}", "label": 0, "cwe": null, "length": 173 }, { "index": 366779, "code": "ShowRelationalClicked(GtkTreeView * UNUSED(treeview), GtkTreePath * UNUSED(path),\n GtkTreeViewColumn * UNUSED(col), gpointer UNUSED(userdata))\n{\n gchar *name = GetSelectedPlayer();\n if (!name)\n return;\n\n CommandRelationalShowDetails(name);\n g_free(name);\n}", "label": 0, "cwe": null, "length": 64 }, { "index": 11918, "code": "main(int argc, char **argv)\n{\n GVirConfigCapabilities *caps;\n GVirConfigCapabilitiesHost *host_caps;\n GList *guests_caps, *iter;\n char *xml;\n GError *error = NULL;\n\n gvir_config_init(&argc, &argv);\n if (argc != 2) {\n g_print(\"Usage: %s filename\\n\", argv[0]);\n g_print(\"Attempt to parse the libvirt XML definition from filename\\n\");\n return 1;\n }\n\n g_file_get_contents(argv[1], &xml, NULL, &error);\n if (error != NULL) {\n g_print(\"Couldn't read %s: %s\\n\", argv[1], error->message);\n return 2;\n }\n\n caps = gvir_config_capabilities_new_from_xml(xml, &error);\n g_free(xml);\n if (error != NULL) {\n g_print(\"Couldn't parse %s: %s\\n\", argv[1], error->message);\n return 3;\n }\n g_assert(caps != NULL);\n gvir_config_object_validate(GVIR_CONFIG_OBJECT(caps), &error);\n if (error != NULL) {\n g_print(\"%s format is invalid: %s\\n\", argv[1], error->message);\n g_clear_error(&error);\n }\n\n host_caps = gvir_config_capabilities_get_host(caps);\n verify_host_caps(host_caps);\n g_object_unref(G_OBJECT(host_caps));\n\n guests_caps = gvir_config_capabilities_get_guests(caps);\n for (iter = guests_caps; iter != NULL; iter = iter->next) {\n GVirConfigCapabilitiesGuest *guest_caps;\n\n guest_caps = GVIR_CONFIG_CAPABILITIES_GUEST(iter->data);\n verify_guest_caps(guest_caps);\n g_object_unref(G_OBJECT(guest_caps));\n }\n g_list_free(guests_caps);\n\n xml = gvir_config_object_to_xml(GVIR_CONFIG_OBJECT(caps));\n g_print(\"%s\\n\", xml);\n g_free(xml);\n g_object_unref(G_OBJECT(caps));\n\n return 0;\n}", "label": 0, "cwe": null, "length": 447 }, { "index": 670658, "code": "BindSoundVariables(void)\n{\n M_BindVariable(\"snd_sfxdevice\", &snd_sfxdevice);\n M_BindVariable(\"snd_musicdevice\", &snd_musicdevice);\n M_BindVariable(\"snd_channels\", &numChannels);\n M_BindVariable(\"sfx_volume\", &sfxVolume);\n M_BindVariable(\"music_volume\", &musicVolume);\n M_BindVariable(\"snd_samplerate\", &snd_samplerate);\n M_BindVariable(\"use_libsamplerate\", &use_libsamplerate);\n M_BindVariable(\"libsamplerate_scale\", &libsamplerate_scale);\n M_BindVariable(\"timidity_cfg_path\", &timidity_cfg_path);\n M_BindVariable(\"gus_patch_path\", &gus_patch_path);\n M_BindVariable(\"gus_ram_kb\", &gus_ram_kb);\n\n M_BindVariable(\"snd_sbport\", &snd_sbport);\n M_BindVariable(\"snd_sbirq\", &snd_sbirq);\n M_BindVariable(\"snd_sbdma\", &snd_sbdma);\n M_BindVariable(\"snd_mport\", &snd_mport);\n\n M_BindVariable(\"snd_cachesize\", &snd_cachesize);\n M_BindVariable(\"opl_io_port\", &opl_io_port);\n\n if (gamemission == strife)\n {\n M_BindVariable(\"voice_volume\", &voiceVolume);\n M_BindVariable(\"show_talk\", &show_talk);\n }\n\n timidity_cfg_path = strdup(\"\");\n gus_patch_path = strdup(\"\");\n\n // Before SDL_mixer version 1.2.11, MIDI music caused the game\n // to crash when it looped. If this is an old SDL_mixer version,\n // disable MIDI.\n\n#ifdef __MACOSX__\n {\n const SDL_version *v = Mix_Linked_Version();\n\n if (SDL_VERSIONNUM(v->major, v->minor, v->patch)\n < SDL_VERSIONNUM(1, 2, 11))\n {\n snd_musicdevice = SNDDEVICE_NONE;\n }\n }\n#endif\n}", "label": 0, "cwe": null, "length": 466 }, { "index": 859843, "code": "load_comp_py_rgb32(\n\tstruct comp_s *image, const uint8_t *image_in, const struct info_s *info\n) {\n\tconst long int l = info->height * info->original_width;\n\tconst load_comp_py_px_func_t load_comp_py_px = load_comp_py_px_func[is_littlee()];\n\tcomp_t *d = image->data;\n\n\tfor (long int i = 0; i < l; i++) {\n\t\t*d++ = load_comp_py_px(&image_in) | 0xFF000000;\n\t\timage_in++;\n\t}\n}", "label": 0, "cwe": null, "length": 120 }, { "index": 562585, "code": "fcexp_cost(symbol_type type)\n{ int cost;\n\n#ifdef OUTPUT_TBL_OP_NAME\n printf(\"mathfunc name: %s\\n\",math_func_tbl[C_EXP].math_func_name);\n#endif\n cost = put_complex_or_dcomplex_cost( type, math_func_tbl[C_EXP].cost[0],\n\t\t\t math_func_tbl[C_EXP].cost[1]);\n\n if ( cost <= -1 )\n {\n symbol_type temp_type;\n temp_type = (type == TYPE_COMPLEX)? TYPE_REAL : TYPE_DOUBLE;\n\n cost = fexp_cost(temp_type);\n cost += fcos_cost(temp_type);\n cost += ope_cost_tbl[MUL].costs[1];\n cost += fsin_cost(temp_type);\n cost += ope_cost_tbl[MUL].costs[1];\n }\n\n return cost;\n}", "label": 0, "cwe": null, "length": 174 }, { "index": 254494, "code": "expand_is_clean(const wchar_t *in)\n{\n\n const wchar_t * str = in;\n\n CHECK(in, 1);\n\n /*\n Test characters that have a special meaning in the first character position\n */\n if (wcschr(UNCLEAN_FIRST, *str))\n return 0;\n\n /*\n Test characters that have a special meaning in any character position\n */\n while (*str)\n {\n if (wcschr(UNCLEAN, *str))\n return 0;\n str++;\n }\n\n return 1;\n}", "label": 0, "cwe": null, "length": 115 }, { "index": 487288, "code": "ostream_open_fd(int fd)\n{\n\tostream_t *os;\n\n\tg_assert(is_valid_fd(fd));\n\n\tos = ostream_alloc(OSTREAM_T_FD);\n\tos->u.fd = fd;\n\n\treturn os;\n}", "label": 0, "cwe": null, "length": 42 }, { "index": 618955, "code": "jp2_read_colr(\n opj_jp2_t * jp2,\n unsigned char * p_colr_header_data,\n unsigned int p_colr_header_size,\n opj_event_mgr_t * p_manager\n )\n{\n // preconditions\n assert(jp2 != 00);\n assert(p_colr_header_data != 00);\n assert(p_manager != 00);\n\n if\n (p_colr_header_size < 3)\n {\n opj_event_msg(p_manager, EVT_ERROR, \"Bad BPCC header box (bad size)\\n\");\n return false;\n }\n\n opj_read_bytes(p_colr_header_data,&jp2->meth ,1); /* METH */\n ++p_colr_header_data;\n\n opj_read_bytes(p_colr_header_data,&jp2->precedence ,1); /* PRECEDENCE */\n ++p_colr_header_data;\n\n opj_read_bytes(p_colr_header_data,&jp2->approx ,1); /* APPROX */\n ++p_colr_header_data;\n\n\n if\n (jp2->meth == 1)\n {\n if\n (p_colr_header_size != 7)\n {\n opj_event_msg(p_manager, EVT_ERROR, \"Bad BPCC header box (bad size)\\n\");\n return false;\n }\n opj_read_bytes(p_colr_header_data,&jp2->enumcs ,4); /* EnumCS */\n }\n /*else\n {\n // do not care with profiles.\n }*/\n return true;\n}", "label": 0, "cwe": null, "length": 329 }, { "index": 28798, "code": "updateTeardownAction()\n{\n const int rowCount = m_placesModel->rowCount();\n if (m_placesMenu->actions().size()==rowCount+2) {\n // remove teardown action\n QAction *action = m_placesMenu->actions().at(rowCount+1);\n m_placesMenu->removeAction(action);\n delete action;\n\n // remove separator\n action = m_placesMenu->actions().at(rowCount);\n m_placesMenu->removeAction(action);\n delete action;\n }\n\n const QModelIndex index = m_placesModel->index(m_selectedItem, 0);\n QAction *teardown = m_placesModel->teardownActionForIndex(index);\n if (teardown!=0) {\n teardown->setParent(m_placesMenu);\n teardown->setData(\"teardownAction\");\n\n m_placesMenu->addSeparator();\n m_placesMenu->addAction(teardown);\n }\n}", "label": 0, "cwe": null, "length": 184 }, { "index": 383332, "code": "pruss_handler(int irq, struct uio_info *info)\n{\n\tstruct uio_pruss_dev *gdev = info->priv;\n\tint intr_bit = (irq - gdev->hostirq_start + 2);\n\tint val, intr_mask = (1 << intr_bit);\n\tvoid __iomem *base = gdev->prussio_vaddr + gdev->pintc_base;\n\tvoid __iomem *intren_reg = base + PINTC_HIER;\n\tvoid __iomem *intrdis_reg = base + PINTC_HIDISR;\n\tvoid __iomem *intrstat_reg = base + PINTC_HIPIR + (intr_bit << 2);\n\n\tval = ioread32(intren_reg);\n\t/* Is interrupt enabled and active ? */\n\tif (!(val & intr_mask) && (ioread32(intrstat_reg) & HIPIR_NOPEND))\n\t\treturn IRQ_NONE;\n\t/* Disable interrupt */\n\tiowrite32(intr_bit, intrdis_reg);\n\treturn IRQ_HANDLED;\n}", "label": 0, "cwe": null, "length": 213 }, { "index": 840750, "code": "gom_driver_c_c_len (int c)\n{\n\tif (gom_driver_c (c) > -1)\n\t\t/* OSS only supports max. 2 channels */\n\t\treturn 1+gom_driver_private_getbits(gom_driver_oss.c.stereomask, c, 1);\n\telse\n\t\treturn -1;\n}", "label": 0, "cwe": null, "length": 69 }, { "index": 186611, "code": "gncTaxTableMakeInvisible (GncTaxTable *table)\n{\n struct _book_info *bi;\n if (!table) return;\n gncTaxTableBeginEdit (table);\n table->invisible = TRUE;\n bi = qof_book_get_data (qof_instance_get_book(table), _GNC_MOD_NAME);\n bi->tables = g_list_remove (bi->tables, table);\n gncTaxTableCommitEdit (table);\n}", "label": 0, "cwe": null, "length": 97 }, { "index": 941448, "code": "operator<< (ostream& ostr, const state& x) { \n\tif(x.board[0][0] == 0) cout << \" \"; else cout << x.board[0][0];\n\tcout << \" \";\n\tif(x.board[0][1] == 0) cout << \" \"; else cout << x.board[0][1];\n\tcout << \" \";\n\tif(x.board[0][2] == 0) cout << \" \"; else cout << x.board[0][2];\n\tcout << \" \";\n\tcout << endl;\n\n\tif(x.board[1][0] == 0) cout << \" \"; else cout << x.board[1][0];\n\tcout << \" \";\n\tif(x.board[1][1] == 0) cout << \" \"; else cout << x.board[1][1];\n\tcout << \" \";\n\tif(x.board[1][2] == 0) cout << \" \"; else cout << x.board[1][2];\n\tcout << \" \";\n\tcout << endl;\n\n\tif(x.board[2][0] == 0) cout << \" \"; else cout << x.board[2][0];\n\tcout << \" \";\n\tif(x.board[2][1] == 0) cout << \" \"; else cout << x.board[2][1];\n\tcout << \" \";\n\tif(x.board[2][2] == 0) cout << \" \"; else cout << x.board[2][2];\n\tcout << \" \";\n\tcout << endl;\n\n\treturn ostr;\n}", "label": 0, "cwe": null, "length": 301 }, { "index": 485067, "code": "coeff(int narg, char **arg)\n{\n if (narg < 4 || narg > 6)\n error->all(FLERR,\"Incorrect args for pair coefficients\");\n if (!allocated) allocate();\n\n int ilo,ihi,jlo,jhi;\n force->bounds(arg[0],atom->ntypes,ilo,ihi);\n force->bounds(arg[1],atom->ntypes,jlo,jhi);\n\n double epsilon_one = force->numeric(FLERR,arg[2]);\n double sigma_one = force->numeric(FLERR,arg[3]);\n\n double cut_lj_one = cut_lj_global;\n double cut_coul_one = cut_coul_global;\n if (narg >= 5) cut_coul_one = cut_lj_one = force->numeric(FLERR,arg[4]);\n if (narg == 6) cut_coul_one = force->numeric(FLERR,arg[5]);\n\n int count = 0;\n for (int i = ilo; i <= ihi; i++) {\n for (int j = MAX(jlo,i); j <= jhi; j++) {\n epsilon[i][j] = epsilon_one;\n sigma[i][j] = sigma_one;\n cut_lj[i][j] = cut_lj_one;\n cut_coul[i][j] = cut_coul_one;\n setflag[i][j] = 1;\n count++;\n }\n }\n\n if (count == 0) error->all(FLERR,\"Incorrect args for pair coefficients\");\n}", "label": 0, "cwe": null, "length": 330 }, { "index": 453330, "code": "parseFloat(const UString &s)\n{\n // Check for 0x prefix here, because toDouble allows it, but we must treat it as 0.\n // Need to skip any whitespace and then one + or - sign.\n int length = s.size();\n int p = 0;\n while (p < length && CommonUnicode::isStrWhiteSpace(s[p].uc)) {\n ++p;\n }\n if (p < length && (s[p] == '+' || s[p] == '-')) {\n ++p;\n }\n if (length - p >= 2 && s[p] == '0' && (s[p + 1] == 'x' || s[p + 1] == 'X')) {\n return 0;\n }\n\n return s.toDouble( true /*tolerant*/, false /* NaN for empty string */ );\n}", "label": 0, "cwe": null, "length": 183 }, { "index": 944162, "code": "glusterd_auth_get_password (glusterd_volinfo_t *volinfo) {\n\n GF_ASSERT (volinfo);\n\n return volinfo->auth.password;\n}", "label": 0, "cwe": null, "length": 35 }, { "index": 109806, "code": "tGetFontIndex(drawfile_fontref tFontRef)\n{\n\tconst char\t*szFontname;\n\tsize_t\t\ttIndex;\n\n\t/* Get the font name */\n\tszFontname = szGetFontname(tFontRef);\n\tfail(szFontname == NULL);\n\tif (szFontname == NULL) {\n\t\treturn 0;\n\t}\n\n\t/* Find the name in the table */\n\tfor (tIndex = 0; tIndex < elementsof(atFontname); tIndex++) {\n\t\tif (STRCEQ(atFontname[tIndex].szPSname, szFontname)) {\n\t\t\treturn tIndex;\n\t\t}\n\t}\n\t/* Not found */\n\tDBG_DEC(tFontRef);\n\tDBG_MSG(szFontname);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 155 }, { "index": 112980, "code": "r100_reloc_pitch_offset(struct radeon_cs_parser *p,\n\t\t\t struct radeon_cs_packet *pkt,\n\t\t\t unsigned idx,\n\t\t\t unsigned reg)\n{\n\tint r;\n\tu32 tile_flags = 0;\n\tu32 tmp;\n\tstruct radeon_bo_list *reloc;\n\tu32 value;\n\n\tr = radeon_cs_packet_next_reloc(p, &reloc, 0);\n\tif (r) {\n\t\tDRM_ERROR(\"No reloc for ib[%d]=0x%04X\\n\",\n\t\t\t idx, reg);\n\t\tradeon_cs_dump_packet(p, pkt);\n\t\treturn r;\n\t}\n\n\tvalue = radeon_get_ib_value(p, idx);\n\ttmp = value & 0x003fffff;\n\ttmp += (((u32)reloc->gpu_offset) >> 10);\n\n\tif (!(p->cs_flags & RADEON_CS_KEEP_TILING_FLAGS)) {\n\t\tif (reloc->tiling_flags & RADEON_TILING_MACRO)\n\t\t\ttile_flags |= RADEON_DST_TILE_MACRO;\n\t\tif (reloc->tiling_flags & RADEON_TILING_MICRO) {\n\t\t\tif (reg == RADEON_SRC_PITCH_OFFSET) {\n\t\t\t\tDRM_ERROR(\"Cannot src blit from microtiled surface\\n\");\n\t\t\t\tradeon_cs_dump_packet(p, pkt);\n\t\t\t\treturn -EINVAL;\n\t\t\t}\n\t\t\ttile_flags |= RADEON_DST_TILE_MICRO;\n\t\t}\n\n\t\ttmp |= tile_flags;\n\t\tp->ib.ptr[idx] = (value & 0x3fc00000) | tmp;\n\t} else\n\t\tp->ib.ptr[idx] = (value & 0xffc00000) | tmp;\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 349 }, { "index": 13435, "code": "ChangeXHeight(FontViewBase *fv,CharViewBase *cv, struct xheightinfo *xi) {\n int cnt, enc, gid;\n SplineChar *sc;\n SplineFont *sf = fv!=NULL ? fv->sf : cv->sc->parent;\n int layer = fv!=NULL ? fv->active_layer : CVLayer(cv);\n extern int detect_diagonal_stems;\n int dds = detect_diagonal_stems;\n\n detect_diagonal_stems = true;\n\n if ( cv!=NULL )\n\tSCChangeXHeight(cv->sc,layer,xi);\n else {\n\tcnt=0;\n\n\tfor ( enc=0; encmap->enccount; ++enc ) {\n\t if ( (gid=fv->map->map[enc])!=-1 && fv->selected[enc] && (sc=sf->glyphs[gid])!=NULL ) {\n\t\t++cnt;\n\t\tsc->ticked = false;\n\t }\n\t}\n\tif ( cnt!=0 ) {\n\t ff_progress_start_indicator(10,_(\"Change X-Height\"),\n\t\t_(\"Change X-Height\"),NULL,cnt,1);\n\n\t for ( enc=0; encmap->enccount; ++enc ) {\n\t\tif ( (gid=fv->map->map[enc])!=-1 && fv->selected[enc] &&\n\t\t\t(sc=sf->glyphs[gid])!=NULL && !sc->ticked ) {\n\t\t if ( !FVChangeXHeight(fv,sc,layer,xi))\n\t break;\n\t\t}\n\t }\n\t ff_progress_end_indicator();\n\t}\n }\n detect_diagonal_stems = dds;\n}", "label": 0, "cwe": null, "length": 353 }, { "index": 48911, "code": "load(QString f) {\n\tQUrl url(f);\n\tif (url.isLocalFile() || url.isRelative()) {\n\t\t// found local file, do not download\n\t\treturn QDir::toNativeSeparators(url.toLocalFile());\n\t}\n\n\tQEventLoop loop;\n\tQObject::connect(manager, SIGNAL(finished(QNetworkReply *)), &loop, SLOT(quit()));\n\tQNetworkReply *reply = manager->get(QNetworkRequest(url));\n\tQObject::connect(reply, SIGNAL(downloadProgress(qint64, qint64)), this, SLOT(progress(qint64, qint64)));\n\tloop.exec();\n#ifdef DEBUG\n\tcerr << \"File downloaded\" << endl;\n#endif\n\n\t// find unique temporary filename\n\tQFileInfo fileInfo(url.path());\n\tQString fileName = fileInfo.fileName();\n\tdelete file;\n\tfile = new QTemporaryFile(QDir::tempPath() + QDir::separator() + fileName);\n\tfile->setAutoRemove(true);\n\tfile->open();\n\n\tif (reply->error() != QNetworkReply::NoError || !reply->isReadable()) {\n\t\tcerr << reply->errorString().toStdString() << endl;\n\t\treturn NULL;\n\t}\n\n\t// store data in tempfile\n\tQByteArray data = reply->readAll();\n\treply->deleteLater();\n\tfile->write(data);\n\tfile->close();\n#ifdef DEBUG\n\tcerr << \"filename: \" << file.toStdString() << endl;\n#endif\n\treturn file->fileName();\n}", "label": 0, "cwe": null, "length": 283 }, { "index": 533999, "code": "mark_reg_live_nc (regno, mode)\n int regno;\n enum machine_mode mode;\n{\n int last = regno + HARD_REGNO_NREGS (regno, mode);\n while (regno < last)\n {\n SET_HARD_REG_BIT (hard_regs_live, regno);\n regno++;\n }\n}", "label": 0, "cwe": null, "length": 72 }, { "index": 111364, "code": "console_conditional_schedule(void)\n{\n\tif (console_may_schedule)\n\t\tcond_resched();\n}", "label": 0, "cwe": null, "length": 22 }, { "index": 220999, "code": "nkbd_connect(struct serio *serio, struct serio_driver *drv)\n{\n\tstruct nkbd *nkbd;\n\tstruct input_dev *input_dev;\n\tint err = -ENOMEM;\n\tint i;\n\n\tnkbd = kzalloc(sizeof(struct nkbd), GFP_KERNEL);\n\tinput_dev = input_allocate_device();\n\tif (!nkbd || !input_dev)\n\t\tgoto fail1;\n\n\tnkbd->serio = serio;\n\tnkbd->dev = input_dev;\n\tsnprintf(nkbd->phys, sizeof(nkbd->phys), \"%s/input0\", serio->phys);\n\tmemcpy(nkbd->keycode, nkbd_keycode, sizeof(nkbd->keycode));\n\n\tinput_dev->name = \"Newton Keyboard\";\n\tinput_dev->phys = nkbd->phys;\n\tinput_dev->id.bustype = BUS_RS232;\n\tinput_dev->id.vendor = SERIO_NEWTON;\n\tinput_dev->id.product = 0x0001;\n\tinput_dev->id.version = 0x0100;\n\tinput_dev->dev.parent = &serio->dev;\n\n\tinput_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REP);\n\tinput_dev->keycode = nkbd->keycode;\n\tinput_dev->keycodesize = sizeof(unsigned char);\n\tinput_dev->keycodemax = ARRAY_SIZE(nkbd_keycode);\n\tfor (i = 0; i < 128; i++)\n\t\tset_bit(nkbd->keycode[i], input_dev->keybit);\n\tclear_bit(0, input_dev->keybit);\n\n\tserio_set_drvdata(serio, nkbd);\n\n\terr = serio_open(serio, drv);\n\tif (err)\n\t\tgoto fail2;\n\n\terr = input_register_device(nkbd->dev);\n\tif (err)\n\t\tgoto fail3;\n\n\treturn 0;\n\n fail3:\tserio_close(serio);\n fail2:\tserio_set_drvdata(serio, NULL);\n fail1:\tinput_free_device(input_dev);\n\tkfree(nkbd);\n\treturn err;\n}", "label": 1, "cwe": "CWE-120", "length": 410 }, { "index": 404271, "code": "_limnQN13octa_QNtoV_f(float *vec, unsigned int qn) {\n unsigned int ui, vi, zi;\n float u, v, x, y, z, n;\n\n _ODD_OCTA_QtoV(6, float, vec, qn);\n}", "label": 0, "cwe": null, "length": 66 }, { "index": 794267, "code": "imapdriver_status_folder(mailsession * session, const char * mb,\n uint32_t * result_messages, uint32_t * result_recent,\n uint32_t * result_unseen)\n{\n int res;\n int current_folder;\n char * current_mb;\n \n if (mb == NULL) {\n mb = get_data(session)->imap_mailbox;\n if (mb == NULL) {\n res = MAIL_ERROR_BAD_STATE;\n goto err;\n }\n }\n \n current_mb = get_data(session)->imap_mailbox;\n if (strcmp(mb, current_mb) == 0)\n current_folder = 1;\n else\n current_folder = 0;\n \n if (current_folder)\n return status_selected_folder(session, mb, result_messages,\n result_recent, result_unseen);\n else\n return status_unselected_folder(session, mb, result_messages,\n result_recent, result_unseen);\n \n err:\n return res;\n}", "label": 0, "cwe": null, "length": 201 }, { "index": 654838, "code": "VSIInstallStdoutHandler()\n\n{\n VSIFileManager::InstallHandler( \"/vsistdout/\", new VSIStdoutFilesystemHandler );\n VSIFileManager::InstallHandler( \"/vsistdout_redirect/\", new VSIStdoutRedirectFilesystemHandler );\n}", "label": 0, "cwe": null, "length": 58 }, { "index": 274864, "code": "OTF_basename(char* path) {\n\tchar *ret;\n#if defined(_WIN32)\n\tconst char* s = \"\\\\\";\n#else\n\tconst char* s = \"/\";\n#endif\n\t\n\tif( path == NULL || strlen( path ) == 0 ) {\n\t\tret = strdup( \".\" );\n\t} else if( path[strlen(path)-1] == *s ) {\n\t\tret = strdup( s );\n\t} else {\n\t\tchar* tmp;\n\t\tif( ( tmp = strrchr( path, *s ) ) != NULL )\n\t\t\tret = strdup( tmp+1 );\n\t\telse\n\t\t\tret = strdup( path );\n\t}\n\t\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 134 }, { "index": 34082, "code": "scMathToRadians(const CFunctionsScopePtr &c, void *userdata) {\r\n\tPARAMETER_TO_NUMBER(a,\"a\"); RETURN_NAN_IS_NAN(a); RETURN_INFINITY_IS_INFINITY(a); \r\n\tRETURN( (k_PI/180.0)*a );\r\n}", "label": 0, "cwe": null, "length": 55 }, { "index": 11643, "code": "e2fsck_get_alloc_block(ext2_filsys fs, blk64_t goal,\n\t\t\t\t\tblk64_t *ret)\n{\n\te2fsck_t ctx = (e2fsck_t) fs->priv_data;\n\terrcode_t\tretval;\n\tblk_t\t\tnew_block;\n\n\tif (ctx->block_found_map) {\n\t\tretval = ext2fs_new_block(fs, (blk_t) goal,\n\t\t\t\t\t ctx->block_found_map, &new_block);\n\t\tif (retval)\n\t\t\treturn retval;\n\t\tif (fs->block_map) {\n\t\t\text2fs_mark_block_bitmap(fs->block_map, new_block);\n\t\t\text2fs_mark_bb_dirty(fs);\n\t\t}\n\t} else {\n\t\tif (!fs->block_map) {\n\t\t\tretval = ext2fs_read_block_bitmap(fs);\n\t\t\tif (retval)\n\t\t\t\treturn retval;\n\t\t}\n\n\t\tretval = ext2fs_new_block(fs, (blk_t) goal, 0, &new_block);\n\t\tif (retval)\n\t\t\treturn retval;\n\t}\n\n\t*ret = new_block;\n\treturn (0);\n}", "label": 0, "cwe": null, "length": 222 }, { "index": 371771, "code": "explain_buffer_errno_dup2_explanation(explain_string_buffer_t *sb,\n int errnum, int oldfd, int newfd)\n{\n /*\n * http://www.opengroup.org/onlinepubs/009695399/functions/dup2.html\n */\n switch (errnum)\n {\n case EBADF:\n if (fcntl(oldfd, F_GETFL) < 0)\n {\n explain_buffer_ebadf(sb, oldfd, \"oldfd\");\n }\n else if (explain_buffer_check_fildes_range(sb, newfd, \"newfd\"))\n {\n explain_string_buffer_puts\n (\n sb,\n \"oldfd isn't an open file descriptor; or, newfd is \"\n \"outside the allowed range for file descriptors\"\n );\n }\n break;\n\n case EINVAL:\n /* not on Linux */\n explain_buffer_check_fildes_range(sb, newfd, \"newfd\");\n break;\n\n case EBUSY:\n explain_string_buffer_puts\n (\n sb,\n \"a race condition was detected between open(2) and dup(2)\"\n );\n break;\n\n case EINTR:\n explain_buffer_eintr(sb, \"dup2\");\n break;\n\n case EMFILE:\n if (explain_buffer_check_fildes_range(sb, newfd, \"newfd\"))\n explain_buffer_emfile(sb);\n break;\n\n default:\n explain_buffer_errno_generic(sb, errnum, \"dup2\");\n break;\n }\n if (fcntl(newfd, F_GETFL) >= 0)\n {\n explain_string_buffer_puts(sb->footnotes, \"; \");\n explain_buffer_gettext\n (\n sb->footnotes,\n /*\n * xgettext: This error message is used when dup2(2) system\n * call fails, the destination file descriptor may or may\n * not be closed.\n */\n i18n(\"note that any errors that would have been reported by \"\n \"close(newfd) are lost, a careful programmer will not use \"\n \"dup2() without closing newfd first\")\n );\n }\n}", "label": 0, "cwe": null, "length": 447 }, { "index": 499823, "code": "dsSet(redisDb *db, robj *key, robj *val, time_t expire) {\n char buf[1024], buf2[1024];\n FILE *fp;\n int retval, len;\n\n len = dsKeyToPath(db,buf,key);\n memcpy(buf2,buf,len);\n snprintf(buf2+len,sizeof(buf2)-len,\"-%ld-%ld\",(long)time(NULL),(long)val);\n while ((fp = fopen(buf2,\"w\")) == NULL) {\n if (errno == ENOSPC) {\n redisLog(REDIS_WARNING,\"Diskstore: No space left on device. Please make room and wait 30 seconds for Redis to continue.\");\n sleep(30);\n } else {\n redisLog(REDIS_WARNING,\"diskstore error opening %s: %s\",\n buf2, strerror(errno));\n redisPanic(\"Unrecoverable diskstore error. Exiting.\");\n }\n }\n if ((retval = rdbSaveKeyValuePair(fp,key,val,expire,time(NULL))) == -1)\n return REDIS_ERR;\n fclose(fp);\n if (retval == 0) {\n /* Expired key. Unlink failing not critical */\n unlink(buf);\n unlink(buf2);\n } else {\n /* Use rename for atomic updadte of value */\n if (rename(buf2,buf) == -1) {\n redisLog(REDIS_WARNING,\"rename(2) returned an error: %s\",\n strerror(errno));\n redisPanic(\"Unrecoverable diskstore error. Exiting.\");\n }\n }\n return REDIS_OK;\n}", "label": 1, "cwe": "CWE-other", "length": 332 }, { "index": 306548, "code": "getICmpCode(const ICmpInst *ICI) {\n switch (ICI->getPredicate()) {\n // False -> 0\n case ICmpInst::ICMP_UGT: return 1; // 001\n case ICmpInst::ICMP_SGT: return 1; // 001\n case ICmpInst::ICMP_EQ: return 2; // 010\n case ICmpInst::ICMP_UGE: return 3; // 011\n case ICmpInst::ICMP_SGE: return 3; // 011\n case ICmpInst::ICMP_ULT: return 4; // 100\n case ICmpInst::ICMP_SLT: return 4; // 100\n case ICmpInst::ICMP_NE: return 5; // 101\n case ICmpInst::ICMP_ULE: return 6; // 110\n case ICmpInst::ICMP_SLE: return 6; // 110\n // True -> 7\n default:\n llvm_unreachable(\"Invalid ICmp predicate!\");\n return 0;\n }\n}", "label": 0, "cwe": null, "length": 258 }, { "index": 5990, "code": "area(const Mpoint* const p) const{\n Vec v1,v2,vA;\n float Tarea;\n \n //calculate\n v1=*_vertice[1]-*_vertice[0];\n v2=*_vertice[2]-*_vertice[0];\n Tarea=0.5*((v1*v2).norm());\n //find appriopriate vector\n for (int i = 0; i<3; i++){\n if (p==_vertice[i]){\n vA=(this->centroid())-*_vertice[i];\n }\n }\n vA=vA/vA.norm()*Tarea;\n\n return vA; \n}", "label": 0, "cwe": null, "length": 149 }, { "index": 15945, "code": "value_removed_current_editor (AnjutaPlugin *plugin,\n\t\t\t\t\t\t\t const char *name, gpointer data)\n{\n\tBasicAutotoolsPlugin *ba_plugin = ANJUTA_PLUGIN_BASIC_AUTOTOOLS (plugin);\n#if 0\n\tif (ba_plugin->indicators_updated_editors &&\n\t\tg_hash_table_lookup (ba_plugin->indicators_updated_editors,\n\t\t\t\t\t\t\t ba_plugin->current_editor))\n\t{\n\t\tg_hash_table_remove (ba_plugin->indicators_updated_editors,\n\t\t\t\t\t\t\t ba_plugin->current_editor);\n\t}\n#endif\n\tif (ba_plugin->current_editor_file)\n\t\tg_object_unref (ba_plugin->current_editor_file);\n\tba_plugin->current_editor_file = NULL;\n\tba_plugin->current_editor = NULL;\n\n\tupdate_module_ui (ba_plugin);\n}", "label": 0, "cwe": null, "length": 158 }, { "index": 26966, "code": "run_test (CutTestCase *test_case, CutTest *test,\n CutTestContext *test_context, CutRunContext *run_context)\n{\n gboolean success = TRUE;\n\n if (CUT_IS_TEST_ITERATOR(test)) {\n g_signal_emit_by_name(test_case, \"start-test-iterator\",\n test, test_context);\n } else {\n g_signal_emit_by_name(test_case, \"start-test\", test, test_context);\n cut_test_case_run_setup(test_case, test_context);\n }\n\n if (cut_test_context_is_failed(test_context)) {\n success = FALSE;\n } else if (cut_test_context_need_test_run(test_context)) {\n success = cut_test_run(test, test_context, run_context);\n }\n\n if (CUT_IS_TEST_ITERATOR(test)) {\n g_signal_emit_by_name(test_case, \"complete-test-iterator\",\n test, test_context, success);\n } else {\n cut_test_case_run_teardown(test_case, test_context);\n g_signal_emit_by_name(test_case, \"complete-test\",\n test, test_context, success);\n }\n\n return success;\n}", "label": 0, "cwe": null, "length": 234 }, { "index": 86718, "code": "_adcli_strv_join (char **strv,\n const char *delim)\n{\n\tchar *result = NULL;\n\tint at = 0;\n\tint dlen;\n\tint slen;\n\tint i;\n\n\tdlen = strlen (delim);\n\tfor (i = 0; strv && strv[i] != NULL; i++) {\n\t\tslen = strlen (strv[i]);\n\t\tresult = realloc (result, at + dlen + slen + 1);\n\t\treturn_val_if_fail (result != NULL, NULL);\n\t\tif (at != 0) {\n\t\t\tmemcpy (result + at, delim, dlen);\n\t\t\tat += dlen;\n\t\t}\n\n\t\tmemcpy (result + at, strv[i], slen);\n\t\tat += slen;\n\t\tresult[at] = '\\0';\n\t}\n\n\treturn result;\n}", "label": 1, "cwe": "CWE-120", "length": 175 }, { "index": 88429, "code": "ramfs_parse_options(char *data, struct ramfs_mount_opts *opts)\n{\n\tsubstring_t args[MAX_OPT_ARGS];\n\tint option;\n\tint token;\n\tchar *p;\n\n\topts->mode = RAMFS_DEFAULT_MODE;\n\n\twhile ((p = strsep(&data, \",\")) != NULL) {\n\t\tif (!*p)\n\t\t\tcontinue;\n\n\t\ttoken = match_token(p, tokens, args);\n\t\tswitch (token) {\n\t\tcase Opt_mode:\n\t\t\tif (match_octal(&args[0], &option))\n\t\t\t\treturn -EINVAL;\n\t\t\topts->mode = option & S_IALLUGO;\n\t\t\tbreak;\n\t\t/*\n\t\t * We might like to report bad mount options here;\n\t\t * but traditionally ramfs has ignored all mount options,\n\t\t * and as it is used as a !CONFIG_SHMEM simple substitute\n\t\t * for tmpfs, better continue to ignore other mount options.\n\t\t */\n\t\t}\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 195 }, { "index": 72989, "code": "___f_gmpc_metaimage_dispose (GObject * obj G_GNUC_UNUSED)\n#line 788 \"gmpc-metaimage.c\"\n#define PARENT_HANDLER(___obj) \\\n\t{ if(G_OBJECT_CLASS(parent_class)->dispose) \\\n\t\t(* G_OBJECT_CLASS(parent_class)->dispose)(___obj); }\n{\n#define __GOB_FUNCTION__ \"Gmpc:MetaImage::dispose\"\n{\n#line 210 \"gmpc-metaimage.gob\"\n\t\n\t\t\tSelf *self = GMPC_METAIMAGE(obj); \n if(self->_priv->meta_id)\n\t\t\t{\n\t\t\t\tg_signal_handler_disconnect(G_OBJECT(gmw),self->_priv->meta_id);\n\t\t\t\tself->_priv->meta_id = 0;\n\t\t\t}\n if(self->_priv->metadata_force_reload)\n {\n g_signal_handler_disconnect(G_OBJECT(gmw),self->_priv->metadata_force_reload);\n self->_priv->metadata_force_reload = 0;\n }\n\t\t\tif(self->_priv->image_url) {\n\t\t\t\tq_free(self->_priv->image_url);\n\t\t\t}\n\t\t\tif(self->_priv->status_signal){\n\t\t\t\tg_signal_handler_disconnect(G_OBJECT(gmpcconn), self->_priv->status_signal);\n\t\t\t\tself->_priv->status_signal =0;\n\t\t\t}\n\t\t\tif(self->_priv->connect_signal){\n\t\t\t\tg_signal_handler_disconnect(G_OBJECT(gmpcconn), self->_priv->connect_signal);\n\t\t\t\tself->_priv->connect_signal=0;\n\t\t\t}\n\t\t\tPARENT_HANDLER(obj);\n\t\t}}", "label": 0, "cwe": null, "length": 315 }, { "index": 809995, "code": "graph_show_remainder(struct git_graph *graph)\n{\n\tstruct strbuf msgbuf;\n\tint shown = 0;\n\n\tif (!graph)\n\t\treturn 0;\n\n\tif (graph_is_commit_finished(graph))\n\t\treturn 0;\n\n\tstrbuf_init(&msgbuf, 0);\n\tfor (;;) {\n\t\tgraph_next_line(graph, &msgbuf);\n\t\tfwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);\n\t\tstrbuf_setlen(&msgbuf, 0);\n\t\tshown = 1;\n\n\t\tif (!graph_is_commit_finished(graph))\n\t\t\tputchar('\\n');\n\t\telse\n\t\t\tbreak;\n\t}\n\tstrbuf_release(&msgbuf);\n\n\treturn shown;\n}", "label": 0, "cwe": null, "length": 137 }, { "index": 833894, "code": "sci_remote_node_table_clear_node_index(\n\tstruct sci_remote_node_table *remote_node_table,\n\tu32 remote_node_index)\n{\n\tu32 dword_location;\n\tu32 dword_remainder;\n\tu32 slot_position;\n\tu32 slot_normalized;\n\n\tBUG_ON(\n\t\t(remote_node_table->available_nodes_array_size * SCIC_SDS_REMOTE_NODE_SETS_PER_DWORD)\n\t\t<= (remote_node_index / SCU_STP_REMOTE_NODE_COUNT)\n\t\t);\n\n\tdword_location = remote_node_index / SCIC_SDS_REMOTE_NODES_PER_DWORD;\n\tdword_remainder = remote_node_index % SCIC_SDS_REMOTE_NODES_PER_DWORD;\n\tslot_normalized = (dword_remainder / SCU_STP_REMOTE_NODE_COUNT) * sizeof(u32);\n\tslot_position = remote_node_index % SCU_STP_REMOTE_NODE_COUNT;\n\n\tremote_node_table->available_remote_nodes[dword_location] &=\n\t\t~(1 << (slot_normalized + slot_position));\n}", "label": 0, "cwe": null, "length": 197 }, { "index": 898136, "code": "uvwrite_perm_rw_array (e, pzarg, zcmd, pccol)\n FILE *e;\n const char **pzarg;\n const char *zcmd;\n size_t *pccol;\n{\n size_t c;\n const char **pz, **pzcopy, **pzset;\n\n if (pzarg == NULL)\n return;\n\n c = 0;\n for (pz = pzarg; *pz != NULL; pz++)\n c++;\n\n pzcopy = (const char **) malloc ((c + 1) * sizeof (char *));\n if (pzcopy == NULL)\n uvuuconf_error ((pointer) NULL, UUCONF_MALLOC_FAILED);\n\n pzset = pzcopy;\n for (pz = pzarg; *pz != NULL; pz++)\n if ((*pz)[0] != '!')\n *pzset++ = *pz;\n *pzset = NULL;\n\n if (pzset != pzcopy)\n uvwrite_perm_array (e, (const char **) pzcopy, zcmd, pccol);\n\n pzset = pzcopy;\n for (pz = pzarg; *pz != NULL; pz++)\n if ((*pz)[0] == '!')\n *pzset++ = *pz;\n *pzset = NULL;\n\n if (pzset != pzcopy)\n {\n char ab[20];\n\n sprintf (ab, \"NO%s\", zcmd);\n uvwrite_perm_array (e, (const char **) pzcopy, ab, pccol);\n }\n}", "label": 0, "cwe": null, "length": 326 }, { "index": 572394, "code": "krb5_gss_delete_name_attribute(OM_uint32 *minor_status,\n gss_name_t name,\n gss_buffer_t attr)\n{\n krb5_context context;\n krb5_error_code code;\n krb5_gss_name_t kname;\n krb5_data kattr;\n\n if (minor_status != NULL)\n *minor_status = 0;\n\n code = krb5_gss_init_context(&context);\n if (code != 0) {\n *minor_status = code;\n return GSS_S_FAILURE;\n }\n\n kname = (krb5_gss_name_t)name;\n k5_mutex_lock(&kname->lock);\n\n if (kname->ad_context == NULL) {\n code = krb5_authdata_context_init(context, &kname->ad_context);\n if (code != 0) {\n *minor_status = code;\n k5_mutex_unlock(&kname->lock);\n krb5_free_context(context);\n return GSS_S_UNAVAILABLE;\n }\n }\n\n kattr.data = (char *)attr->value;\n kattr.length = attr->length;\n\n code = krb5_authdata_delete_attribute(context,\n kname->ad_context,\n &kattr);\n\n k5_mutex_unlock(&kname->lock);\n krb5_free_context(context);\n\n return kg_map_name_error(minor_status, code);\n}", "label": 1, "cwe": "CWE-476", "length": 292 }, { "index": 489792, "code": "dib8000_set_acquisition_mode(struct dib8000_state *state)\n{\n\tu16 nud = dib8000_read_word(state, 298);\n\tnud |= (1 << 3) | (1 << 0);\n\tdprintk(\"acquisition mode activated\");\n\tdib8000_write_word(state, 298, nud);\n}", "label": 0, "cwe": null, "length": 71 }, { "index": 982532, "code": "release_ep_resources(struct c4iw_ep *ep)\n{\n\tset_bit(RELEASE_RESOURCES, &ep->com.flags);\n\tc4iw_put_ep(&ep->com);\n}", "label": 0, "cwe": null, "length": 36 }, { "index": 20860, "code": "reap_kids()\n{\n int pid, status;\n\n if (n_children == 0)\n\treturn 0;\n while ((pid = waitpid(-1, &status, WNOHANG)) != -1 && pid != 0) {\n forget_child(pid, status);\n }\n if (pid == -1) {\n\tif (errno == ECHILD)\n\t return -1;\n\tif (errno != EINTR)\n\t error(\"Error waiting for child process: %m\");\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 111 }, { "index": 124051, "code": "GetConfigurationPanel(wxWindow* parent)\n// ----------------------------------------------------------------------------\n{\n\t//create and display the configuration dialog for your plugin\n if(!IsAttached()) {\treturn 0;}\n // Create a configuration dialogue and hand it off to codeblocks\n\n //cbConfigurationPanel* pDlg = new cbDragScrollCfg(parent, this);\n cbDragScrollCfg* pDlg = new cbDragScrollCfg(parent, this);\n // set current mouse scrolling options\n pDlg->SetMouseDragScrollEnabled ( MouseDragScrollEnabled );\n pDlg->SetMouseEditorFocusEnabled ( MouseEditorFocusEnabled );\n pDlg->SetMouseFocusEnabled ( MouseFocusEnabled );\n pDlg->SetMouseDragDirection ( MouseDragDirection );\n pDlg->SetMouseDragKey ( MouseDragKey );\n pDlg->SetMouseDragSensitivity ( MouseDragSensitivity );\n pDlg->SetMouseToLineRatio ( MouseToLineRatio );\n pDlg->SetMouseContextDelay ( MouseContextDelay );\n pDlg->SetMouseWheelZoom ( MouseWheelZoom );\n pDlg->SetPropagateLogZoomSize ( PropagateLogZoomSize );\n\n // when the configuration panel is closed with OK, OnDialogDone() will be called\n return pDlg;\n}", "label": 0, "cwe": null, "length": 260 }, { "index": 290113, "code": "go7007_reset_encoder(struct go7007 *go)\n{\n\tif (go7007_load_encoder(go) < 0)\n\t\treturn -1;\n\treturn go7007_init_encoder(go);\n}", "label": 0, "cwe": null, "length": 41 }, { "index": 353450, "code": "install_bpf_program(pcap_t *p, struct bpf_program *fp)\n{\n\tsize_t prog_size;\n\n\t/*\n\t * Validate the program.\n\t */\n\tif (!bpf_validate(fp->bf_insns, fp->bf_len)) {\n\t\tsnprintf(p->errbuf, sizeof(p->errbuf),\n\t\t\t\"BPF program is not valid\");\n\t\treturn (-1);\n\t}\n\n\t/*\n\t * Free up any already installed program.\n\t */\n\tpcap_freecode(&p->fcode);\n\n\tprog_size = sizeof(*fp->bf_insns) * fp->bf_len;\n\tp->fcode.bf_len = fp->bf_len;\n\tp->fcode.bf_insns = (struct bpf_insn *)malloc(prog_size);\n\tif (p->fcode.bf_insns == NULL) {\n\t\tsnprintf(p->errbuf, sizeof(p->errbuf),\n\t\t\t \"malloc: %s\", pcap_strerror(errno));\n\t\treturn (-1);\n\t}\n\tmemcpy(p->fcode.bf_insns, fp->bf_insns, prog_size);\n\treturn (0);\n}", "label": 0, "cwe": null, "length": 223 }, { "index": 831337, "code": "gdata_picasaweb_service_insert_album (GDataPicasaWebService *self, GDataPicasaWebAlbum *album, GCancellable *cancellable, GError **error)\n{\n\tg_return_val_if_fail (GDATA_IS_PICASAWEB_SERVICE (self), NULL);\n\tg_return_val_if_fail (GDATA_IS_PICASAWEB_ALBUM (album), NULL);\n\tg_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);\n\tg_return_val_if_fail (error == NULL || *error == NULL, NULL);\n\n\tif (gdata_entry_is_inserted (GDATA_ENTRY (album)) == TRUE) {\n\t\tg_set_error_literal (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_ENTRY_ALREADY_INSERTED,\n\t\t _(\"The album has already been inserted.\"));\n\t\treturn NULL;\n\t}\n\n\tif (gdata_authorizer_is_authorized_for_domain (gdata_service_get_authorizer (GDATA_SERVICE (self)),\n\t get_picasaweb_authorization_domain ()) == FALSE) {\n\t\tg_set_error_literal (error, GDATA_SERVICE_ERROR, GDATA_SERVICE_ERROR_AUTHENTICATION_REQUIRED,\n\t\t _(\"You must be authenticated to insert an album.\"));\n\t\treturn NULL;\n\t}\n\n\treturn GDATA_PICASAWEB_ALBUM (gdata_service_insert_entry (GDATA_SERVICE (self), get_picasaweb_authorization_domain (),\n\t \"https://picasaweb.google.com/data/feed/api/user/default\",\n\t GDATA_ENTRY (album), cancellable, error));\n}", "label": 0, "cwe": null, "length": 322 }, { "index": 375849, "code": "rpcsvc_create_listener (rpcsvc_t *svc, dict_t *options, char *name)\n{\n rpc_transport_t *trans = NULL;\n rpcsvc_listener_t *listener = NULL;\n int32_t ret = -1;\n\n if (!svc || !options) {\n goto out;\n }\n\n trans = rpcsvc_transport_create (svc, options, name);\n if (!trans) {\n /* LOG TODO */\n goto out;\n }\n\n listener = rpcsvc_listener_alloc (svc, trans);\n if (listener == NULL) {\n goto out;\n }\n\n ret = 0;\nout:\n if (!listener && trans) {\n rpc_transport_disconnect (trans);\n }\n\n return ret;\n}", "label": 0, "cwe": null, "length": 156 }, { "index": 161915, "code": "mp960_reorder_pixels (uint8_t * linebuf, uint8_t * sptr, unsigned c,\n unsigned n, unsigned m, unsigned w,\n unsigned line_size)\n{\n unsigned i, i2;\n\n /* try and copy 2 px at once */\n for (i = 0; i < w; i++)\n { /* process complete line */\n i2 = i % 2;\n if (i < w / 2)\n {\n if (i2 == 0)\n memcpy (linebuf + c * (n * ((i) % m) + ((i) / m)), sptr + c * i, c);\n else\n memcpy (linebuf + c * (n * ((i - 1) % m) + 1 + ((i) / m)), sptr + c * i, c);\n }\n else\n {\n if (i2 == 0)\n memcpy (linebuf + c * (n * ((i) % m) + ((i) / m) + 1), sptr + c * i, c);\n else\n memcpy (linebuf + c * (n * ((i - 1) % m) + 1 + ((i) / m) + 1), sptr + c * i, c);\n }\n }\n\n memcpy (sptr, linebuf, line_size);\n}", "label": 1, "cwe": "CWE-120", "length": 300 }, { "index": 918304, "code": "r8712_recv_entry(union recv_frame *precvframe)\n{\n\tstruct _adapter *padapter;\n\tstruct recv_priv *precvpriv;\n\n\ts32 ret = _SUCCESS;\n\n\tpadapter = precvframe->u.hdr.adapter;\n\tprecvpriv = &(padapter->recvpriv);\n\n\tpadapter->ledpriv.LedControlHandler(padapter, LED_CTL_RX);\n\n\tret = recv_func(padapter, precvframe);\n\tif (ret == _FAIL)\n\t\tgoto _recv_entry_drop;\n\tprecvpriv->rx_pkts++;\n\tprecvpriv->rx_bytes += (uint)(precvframe->u.hdr.rx_tail -\n\t\t\t\tprecvframe->u.hdr.rx_data);\n\treturn ret;\n_recv_entry_drop:\n\tprecvpriv->rx_drop++;\n\tpadapter->mppriv.rx_pktloss = precvpriv->rx_drop;\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 180 }, { "index": 805139, "code": "frame() const\n{\n if (!m_frozen || !m_rubberBand || !m_rubberBand->geometry().isValid())\n return QRect();\n return m_rubberBand->geometry();\n}", "label": 0, "cwe": null, "length": 43 }, { "index": 49270, "code": "cmd_stat(int argc, char *argv[])\n{\n\tstruct pstore_header *header;\n\tstruct stat st;\n\tint input;\n\n\tif (argc < 3)\n\t\tusage();\n\n\tparse_args(argc, argv);\n\n\tinput = open(input_file, O_RDONLY);\n\tif (input < 0)\n\t\tdie(\"open\");\n\n\tif (fstat(input, &st) < 0)\n\t\tdie(\"fstat\");\n\n\tif (posix_fadvise(input, 0, st.st_size, POSIX_FADV_SEQUENTIAL) != 0)\n\t\tdie(\"posix_fadvise\");\n\n\theader = pstore_header_read(input);\n\n\tpstore_header_stat(header, input);\n\n\tpstore_header_delete(header);\n\n\tif (close(input) < 0)\n\t\tdie(\"close\");\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 156 }, { "index": 851786, "code": "handle_non_critical_trips(struct thermal_zone_device *tz,\n\t\t\tint trip, enum thermal_trip_type trip_type)\n{\n\ttz->governor ? tz->governor->throttle(tz, trip) :\n\t\t def_governor->throttle(tz, trip);\n}", "label": 0, "cwe": null, "length": 60 }, { "index": 308026, "code": "mnt_lock_block_signals(struct libmnt_lock *ml, int enable)\n{\n\tif (!ml)\n\t\treturn -EINVAL;\n\tDBG(LOCKS, mnt_debug_h(ml, \"signals: %s\", enable ? \"BLOCKED\" : \"UNBLOCKED\"));\n\tml->sigblock = enable ? 1 : 0;\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 72 }, { "index": 50832, "code": "plugin_object_deallocate (NPObject *npobj)\n{\n PluginObject *obj = (PluginObject*)npobj;\n\n g_signal_handler_disconnect (obj->proxy, obj->signal_id);\n g_object_unref (obj->proxy);\n\n if (obj->listener)\n funcs.releaseobject (obj->listener);\n\n if (obj->watch_name_id)\n g_bus_unwatch_name (obj->watch_name_id);\n\n g_debug (\"plugin object destroyed\");\n\n g_slice_free (PluginObject, obj);\n}", "label": 0, "cwe": null, "length": 107 }, { "index": 512350, "code": "wb_create(dm_cblock_t cache_size,\n\t\t\t\t\t sector_t origin_size,\n\t\t\t\t\t sector_t cache_block_size)\n{\n\tint r;\n\tstruct policy *p = kzalloc(sizeof(*p), GFP_KERNEL);\n\n\tif (!p)\n\t\treturn NULL;\n\n\tinit_policy_functions(p);\n\tINIT_LIST_HEAD(&p->free);\n\tINIT_LIST_HEAD(&p->clean);\n\tINIT_LIST_HEAD(&p->clean_pending);\n\tINIT_LIST_HEAD(&p->dirty);\n\n\tp->cache_size = cache_size;\n\tspin_lock_init(&p->lock);\n\n\t/* Allocate cache entry structs and add them to free list. */\n\tr = alloc_cache_blocks_with_hash(p, cache_size);\n\tif (!r)\n\t\treturn &p->policy;\n\n\tkfree(p);\n\n\treturn NULL;\n}", "label": 0, "cwe": null, "length": 151 }, { "index": 236725, "code": "gt_bench_character_extractions(const GtEncseq *encseq,\n unsigned long ccext)\n{\n unsigned long idx, ccsum = 0,\n totallength = gt_encseq_total_length(encseq);\n GtTimer *timer = NULL;\n\n if (gt_showtime_enabled())\n {\n timer = gt_timer_new_with_progress_description(\"run character \"\n \"extractions\");\n gt_timer_start(timer);\n }\n for (idx = 0; idx < ccext; idx++)\n {\n GtUchar cc;\n unsigned long pos = gt_rand_max(totallength-1);\n\n cc = gt_encseq_get_encoded_char(encseq,pos,GT_READMODE_FORWARD);\n ccsum += (unsigned long) cc;\n }\n printf(\"ccsum=%lu\\n\",ccsum);\n if (timer != NULL)\n {\n gt_timer_show_progress_final(timer, stdout);\n gt_timer_delete(timer);\n }\n}", "label": 0, "cwe": null, "length": 202 }, { "index": 485436, "code": "OP_LDRBT_P_LSR_IMM_OFF_POSTIND(armcpu_t *cpu)\n{\n u32 oldmode;\n u32 i;\n u32 adr;\n u32 val;\n u32 shift_op;\n\n if(cpu->CPSR.bits.mode==USR)\n return 2;\n \n oldmode = armcpu_switchMode(cpu, SYS);\n //execute = FALSE;\n\t LOG(\"Untested opcode: OP_LDRBT_P_LSR_IMM_OFF_POSTIND\"); \n \n\n i = cpu->instruction;\n LSR_IMM; \n adr = cpu->R[REG_POS(i,16)];\n val = READ8(cpu->mem_if->data, adr);\n cpu->R[REG_POS(i,12)] = val;\n cpu->R[REG_POS(i,16)] = adr + shift_op;\n \n armcpu_switchMode(cpu, oldmode);\n \n return 3 + MMU.MMU_WAIT16[cpu->proc_ID][(adr>>24)&0xF];\n}", "label": 0, "cwe": null, "length": 213 }, { "index": 778114, "code": "cxgb4i_ofld_init(struct cxgbi_device *cdev)\n{\n\tint rc;\n\n\tif (cxgb4i_max_connect > CXGB4I_MAX_CONN)\n\t\tcxgb4i_max_connect = CXGB4I_MAX_CONN;\n\n\trc = cxgbi_device_portmap_create(cdev, cxgb4i_sport_base,\n\t\t\t\t\tcxgb4i_max_connect);\n\tif (rc < 0)\n\t\treturn rc;\n\n\tcdev->csk_release_offload_resources = release_offload_resources;\n\tcdev->csk_push_tx_frames = push_tx_frames;\n\tcdev->csk_send_abort_req = send_abort_req;\n\tcdev->csk_send_close_req = send_close_req;\n\tcdev->csk_send_rx_credits = send_rx_credits;\n\tcdev->csk_alloc_cpls = alloc_cpls;\n\tcdev->csk_init_act_open = init_act_open;\n\n\tpr_info(\"cdev 0x%p, offload up, added.\\n\", cdev);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 214 }, { "index": 686505, "code": "expat_comment_handler(XMLParserObject* self, const XML_Char* comment_in)\n{\n PyObject* comment;\n PyObject* res;\n\n if (PyErr_Occurred())\n return;\n\n if (self->handle_comment) {\n comment = PyUnicode_DecodeUTF8(comment_in, strlen(comment_in), \"strict\");\n if (comment) {\n res = PyObject_CallFunction(self->handle_comment, \"O\", comment);\n Py_XDECREF(res);\n Py_DECREF(comment);\n }\n }\n}", "label": 0, "cwe": null, "length": 106 }, { "index": 7135, "code": "eio_dir_copy(const char *source,\n const char *dest,\n Eio_Filter_Direct_Cb filter_cb,\n Eio_Progress_Cb progress_cb,\n Eio_Done_Cb done_cb,\n Eio_Error_Cb error_cb,\n const void *data)\n{\n Eio_Dir_Copy *copy;\n\n EINA_SAFETY_ON_NULL_RETURN_VAL(source, NULL);\n EINA_SAFETY_ON_NULL_RETURN_VAL(dest, NULL);\n EINA_SAFETY_ON_NULL_RETURN_VAL(done_cb, NULL);\n EINA_SAFETY_ON_NULL_RETURN_VAL(error_cb, NULL);\n\n copy = malloc(sizeof(Eio_Dir_Copy));\n EINA_SAFETY_ON_NULL_RETURN_VAL(copy, NULL);\n\n copy->progress.op = EIO_DIR_COPY;\n copy->progress.progress_cb = progress_cb;\n copy->progress.source = eina_stringshare_add(source);\n copy->progress.dest = eina_stringshare_add(dest);\n copy->filter_cb = filter_cb;\n copy->files = NULL;\n copy->dirs = NULL;\n copy->links = NULL;\n\n if (!eio_long_file_set(©->progress.common,\n done_cb,\n error_cb,\n data,\n _eio_dir_copy_heavy,\n _eio_dir_copy_notify,\n _eio_dir_copy_end,\n _eio_dir_copy_error))\n return NULL;\n\n return ©->progress.common;\n}", "label": 0, "cwe": null, "length": 298 }, { "index": 919909, "code": "delta(u64 x, u64 y)\n{\n\tif (use_ktime)\n\t\treturn y - x;\n\telse\n\t\treturn DELTA((unsigned int)x, (unsigned int)y);\n}", "label": 0, "cwe": null, "length": 40 }, { "index": 1018598, "code": "reg_w_val(struct gspca_dev *gspca_dev, __u16 index, __u8 value)\n{\n\tint ret;\n\tstruct usb_device *dev = gspca_dev->dev;\n\n\tret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),\n\t\t\t 0,\t\t/* request */\n\t\t\t USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,\n\t\t\t value, index, NULL, 0, 500);\n\tPDEBUG(D_USBO, \"reg write: 0x%02x:0x%02x\", index, value);\n\tif (ret < 0)\n\t\tpr_err(\"reg write: error %d\\n\", ret);\n}", "label": 0, "cwe": null, "length": 143 }, { "index": 34348, "code": "create_list_of_formats()\n{\n GtkTreeIter iter;\n GtkListStore *store;\n\tGtkTreeModel *model;\n\tGtkWidget *combobox;\n\tGtkCellRenderer *renderer;\n\tgint i;\n\tgint k;\n\tgchar* options[] = {\"BMP\",\"PPM\", \"JPEG\", \"PNG\", \"PNG transparent\", \"Povray\"};\n\tguint numberOfElements = G_N_ELEMENTS (options);\n\n\n\tk = 0;\n\tstore = gtk_list_store_new (1,G_TYPE_STRING);\n\tfor(i=0;i DEC_MAX_DIGITS) {\n // Don't report an error for requesting too much.\n // Arithemetic Results will be rounded to what can be supported.\n // At 999,999,999 max digits, exceeding the limit is not too likely!\n requestedCapacity = DEC_MAX_DIGITS;\n }\n if (requestedCapacity > fContext.digits) {\n decNumber *newBuffer = fStorage.resize(requestedCapacity, fStorage.getCapacity());\n if (newBuffer == NULL) {\n status = U_MEMORY_ALLOCATION_ERROR;\n return;\n }\n fContext.digits = requestedCapacity;\n fDecNumber = newBuffer;\n }\n}", "label": 0, "cwe": null, "length": 198 }, { "index": 481869, "code": "locale_determine_internal_code(const char *str) {\n unsigned len = strlen(str);\n char *buf = alloca(len + 1);\n char *pos;\n\n /* make a copy we can manipulate at will */\n strcpy(buf, str);\n\n /* format can be of ll_TT.ENCODING. Strip .ENCODING */\n pos = strchr(buf, '.');\n len = pos ? pos - buf : len;\n buf[len] = 0;\n\n do {\n /* In the first pass, try to match ll_TT.\n * If this fails, strip _TT and match again.\n */\n int i;\n for (i = 0; i < sizeof lang_data/sizeof lang_data[0]; i++) {\n if (strcmp(lang_data[i].lang, buf) == 0)\n return (LanguageCode)i;\n }\n\n /* strip _TT */\n pos = strchr(buf, '_');\n len = pos ? pos - buf : len;\n buf[len] = 0;\n } while(pos);\n\n return LC_C;\n}", "label": 0, "cwe": null, "length": 228 }, { "index": 41821, "code": "SavePDF( const QString& filePath, const QVariantMap& options ) const {\n if( paperTypeStringToQtG.size() == 0 ) {\n InitPaperTypeMap();\n InitUnitMap();\n }\n QPrinter p;\n p.setOutputFileName( filePath );\n p.setOutputFormat( QPrinter::PdfFormat );\n for( QVariantMap::const_iterator i = options.begin(); i != options.end(); ++i ) {\n const QString& op = i.key();\n if( op == \"orientation\" ) {\n if( i.value().toString() == \"portrait\" ) p.setOrientation( QPrinter::Portrait );\n else if( i.value().toString() == \"landscape\" ) p.setOrientation( QPrinter::Landscape );\n else return \"Error: unknown orientation - \" + i.value().toString();\n } else if( op == \"colormode\" ) {\n if( i.value().toString() == \"color\" ) p.setColorMode( QPrinter::Color );\n else if( i.value().toString() == \"grayscale\" || i.value() == \"greyscale\" ) p.setColorMode( QPrinter::GrayScale );\n else return \"Error: unknown colormode - \" + i.value().toString();\n } else if( op == \"paperType\" ) {\n if( !paperTypeStringToQtG.contains( i.value().toString() ) ) return \"Error: unknown paper type - \" + i.value().toString();\n p.setPaperSize( paperTypeStringToQtG[ i.value().toString() ] );\n } else if( op == \"paperSize\" ) {\n QVariantMap s = i.value().toMap();\n if( !s.isEmpty() ||\n !s.contains( \"w\" ) ||\n !s.contains( \"h\" ) ||\n !s.contains( \"unit\" ) ) return \"Error: invalid paperSize format\";\n if( !unitStringToQtG.contains( s[ \"unit\" ].toString() ) ) return \"Error: invalid unit - \" + s[ \"unit\" ].toString();\n p.setPaperSize( QSizeF( s[ \"w\" ].toReal(), s[ \"h\" ].toReal() ), unitStringToQtG[ s[ \"unit\" ].toString() ] );\n }\n }\n page()->mainFrame()->print( &p );\n return \"\";\n}", "label": 0, "cwe": null, "length": 499 }, { "index": 758523, "code": "matrix_inv_cov_float (float* invC,float* X,size_t n,size_t m)\n{\n float* R;\n size_t rang;\n \n if (n < m)\n return 0;\n\n R = (float*)malloc(m*m*sizeof(float));\n rang = matrix_qr_float(X,R,n,m);\n matrix_inv_r_float (X,R,m);\n memset(invC,0,m*m*sizeof(float));\n matrix_CpABt_float (invC,X,X,m,m,m);\n\n free(R);\n return rang;\n}", "label": 0, "cwe": null, "length": 114 }, { "index": 122464, "code": "_soxr_ordered_convolve_simd(int n, void * not_used, float * a, const float * b)\n{\n int i;\n float ab0, ab1;\n v4sf * /*RESTRICT*/ va = (v4sf *)a;\n v4sf const * RESTRICT vb = (v4sf const *)b;\n assert(VALIGNED(a) && VALIGNED(b));\n ab0 = a[0] * b[0], ab1 = a[1] * b[1];\n for (i = 0; i < n / 4; i += 2) {\n v4sf a1r = va[i+0], a1i = va[i+1];\n v4sf b1r = vb[i+0], b1i = vb[i+1];\n UNINTERLEAVE2(a1r, a1i, a1r, a1i);\n UNINTERLEAVE2(b1r, b1i, b1r, b1i);\n VCPLXMUL(a1r, a1i, b1r, b1i);\n INTERLEAVE2(a1r, a1i, a1r, a1i);\n va[i+0] = a1r, va[i+1] = a1i;\n }\n a[0] = ab0, a[1] = ab1;\n (void)not_used;\n}", "label": 0, "cwe": null, "length": 315 }, { "index": 840556, "code": "_del_StringGroup(StringGroup *sg)\n{\n if(sg) {\n StringSegment *node;\n/*\n * Delete the character arrays.\n */\n for(node=sg->head; node; node=node->next) {\n if(node->block)\n\tfree(node->block);\n node->block = NULL;\n };\n/*\n * Delete the list nodes that contained the string segments.\n */\n sg->node_mem = _del_FreeList(sg->node_mem, 1);\n sg->head = NULL; /* Already deleted by deleting sg->node_mem */\n/*\n * Delete the container.\n */\n free(sg);\n };\n return NULL;\n}", "label": 0, "cwe": null, "length": 134 }, { "index": 121464, "code": "keytab_key_proc(krb5_context context, krb5_enctype enctype,\n\t\tkrb5_const_pointer keyseed,\n\t\tkrb5_salt salt, krb5_data *s2kparms,\n\t\tkrb5_keyblock **key)\n{\n krb5_keytab_key_proc_args *args = rk_UNCONST(keyseed);\n krb5_keytab keytab = args->keytab;\n krb5_principal principal = args->principal;\n krb5_error_code ret;\n krb5_keytab real_keytab;\n krb5_keytab_entry entry;\n\n if(keytab == NULL)\n\tkrb5_kt_default(context, &real_keytab);\n else\n\treal_keytab = keytab;\n\n ret = krb5_kt_get_entry (context, real_keytab, principal,\n\t\t\t 0, enctype, &entry);\n\n if (keytab == NULL)\n\tkrb5_kt_close (context, real_keytab);\n\n if (ret)\n\treturn ret;\n\n ret = krb5_copy_keyblock (context, &entry.keyblock, key);\n krb5_kt_free_entry(context, &entry);\n return ret;\n}", "label": 0, "cwe": null, "length": 243 }, { "index": 71287, "code": "CallcNewChan(struct IsdnCardState *csta) {\n\tint i, err;\n\n\tchancount += 2;\n\terr = init_chan(0, csta);\n\tif (err)\n\t\treturn err;\n\terr = init_chan(1, csta);\n\tif (err)\n\t\treturn err;\n\tprintk(KERN_INFO \"HiSax: 2 channels added\\n\");\n\n\tfor (i = 0; i < MAX_WAITING_CALLS; i++) {\n\t\terr = init_chan(i + 2, csta);\n\t\tif (err)\n\t\t\treturn err;\n\t}\n\tprintk(KERN_INFO \"HiSax: MAX_WAITING_CALLS added\\n\");\n\tif (test_bit(FLG_PTP, &csta->channel->d_st->l2.flag)) {\n\t\tprintk(KERN_INFO \"LAYER2 WATCHING ESTABLISH\\n\");\n\t\tcsta->channel->d_st->lli.l4l3(csta->channel->d_st,\n\t\t\t\t\t DL_ESTABLISH | REQUEST, NULL);\n\t}\n\treturn (0);\n}", "label": 0, "cwe": null, "length": 213 }, { "index": 108789, "code": "mch_nodetype(name)\n char_u\t*name;\n{\n struct stat\tst;\n\n if (stat((char *)name, &st))\n\treturn NODE_NORMAL;\n if (S_ISREG(st.st_mode) || S_ISDIR(st.st_mode))\n\treturn NODE_NORMAL;\n#ifndef OS2\n if (S_ISBLK(st.st_mode))\t/* block device isn't writable */\n\treturn NODE_OTHER;\n#endif\n /* Everything else is writable? */\n return NODE_WRITABLE;\n}", "label": 0, "cwe": null, "length": 104 }, { "index": 365032, "code": "GatherProcessData()\n\n{ FILE *pp;\n char pscomm[CF_BUFSIZE];\n char user[CF_MAXVARSIZE];\n struct Item *list = NULL;\n \nsnprintf(pscomm,CF_BUFSIZE,\"%s %s\",VPSCOMM[VSYSTEMHARDCLASS],VPSOPTS[VSYSTEMHARDCLASS]);\n\nif ((pp = cfpopen(pscomm,\"r\")) == NULL)\n {\n return;\n }\n\nReadLine(VBUFF,CF_BUFSIZE,pp); \n\nwhile (!feof(pp))\n {\n ReadLine(VBUFF,CF_BUFSIZE,pp);\n sscanf(VBUFF,\"%s\",user);\n if (!IsItemIn(list,user))\n {\n PrependItem(&list,user,NULL);\n THIS[ob_users]++;\n }\n\n if (strcmp(user,\"root\") == 0)\n {\n THIS[ob_rootprocs]++;\n }\n else\n {\n THIS[ob_otherprocs]++;\n }\n }\n\ncfpclose(pp);\n\nsnprintf(VBUFF,CF_MAXVARSIZE,\"%s/state/cf_users\",CFWORKDIR);\nSaveItemList(list,VBUFF,\"none\");\n\nDeleteItemList(list);\nVerbose(\"(Users,root,other) = (%d,%d,%d)\\n\",THIS[ob_users],THIS[ob_rootprocs],THIS[ob_otherprocs]);\n}", "label": 0, "cwe": null, "length": 276 }, { "index": 444006, "code": "fillQT(QTN2QTState *state, QTNode *in)\n{\n\t/* since this function recurses, it could be driven to stack overflow. */\n\tcheck_stack_depth();\n\n\tif (in->valnode->type == QI_VAL)\n\t{\n\t\tmemcpy(state->curitem, in->valnode, sizeof(QueryOperand));\n\n\t\tmemcpy(state->curoperand, in->word, in->valnode->operand.length);\n\t\tstate->curitem->operand.distance = state->curoperand - state->operand;\n\t\tstate->curoperand[in->valnode->operand.length] = '\\0';\n\t\tstate->curoperand += in->valnode->operand.length + 1;\n\t\tstate->curitem++;\n\t}\n\telse\n\t{\n\t\tQueryItem *curitem = state->curitem;\n\n\t\tAssert(in->valnode->type == QI_OPR);\n\n\t\tmemcpy(state->curitem, in->valnode, sizeof(QueryOperator));\n\n\t\tAssert(in->nchild <= 2);\n\t\tstate->curitem++;\n\n\t\tfillQT(state, in->child[0]);\n\n\t\tif (in->nchild == 2)\n\t\t{\n\t\t\tcuritem->operator.left = state->curitem - curitem;\n\t\t\tfillQT(state, in->child[1]);\n\t\t}\n\t}\n}", "label": 1, "cwe": "CWE-120", "length": 276 }, { "index": 255053, "code": "string2uint64(char *s) {\nuint64_t\tu=0;\nchar \t\t*p = s;\n\n\twhile( *p ) {\n\t\tif ( *p < '0' || *p > '9' ) \n\t\t\t*p = '0';\n\t\tu = 10LL*u + (*p++ - 48);\n\t}\n\treturn u;\n\n}", "label": 0, "cwe": null, "length": 76 }, { "index": 133524, "code": "mangleunit (int unit)\n{\n\tif (unit <= 99)\n\t\treturn unit;\n\tif (unit == 100)\n\t\treturn 8;\n\tif (unit == 110)\n\t\treturn 9;\n\treturn -1;\n}", "label": 0, "cwe": null, "length": 49 }, { "index": 123893, "code": "resolve_first(struct ast_sockaddr *addr, const char *name, int flag,\n\t\t\t int family)\n{\n\tstruct ast_sockaddr *addrs;\n\tint addrs_cnt;\n\n\taddrs_cnt = ast_sockaddr_resolve(&addrs, name, flag, family);\n\tif (addrs_cnt > 0) {\n\t\tif (addrs_cnt > 1) {\n\t\t\tast_debug(1, \"Multiple addresses. Using the first only\\n\");\n\t\t}\n\t\tast_sockaddr_copy(addr, &addrs[0]);\n\t\tast_free(addrs);\n\t} else {\n\t\tast_log(LOG_WARNING, \"Unable to lookup '%s'\\n\", name);\n\t\treturn -1;\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 146 }, { "index": 134411, "code": "http_read (void *ptr, size_t size, void *d)\n{\n http_desc_t *desc = (http_desc_t*)d;\n pthread_mutex_t mut; /* temporary mutex. What is for? ;) */\n int tocopy;\t\t /* how much bytes we got? */\n\n /* Init temp mutex */\n pthread_mutex_init (&mut, NULL); \n\n /* check for reopen */\n if (desc->begin > desc->pos || desc->begin + desc->len + 3*HTTP_BLOCK_SIZE < desc->pos)\n\treconnect (desc, NULL);\n \n /* wait while the buffer will has entire block */\n while (1) {\n\tint readed;\n\t\n\t/* check for error */\n\tif (desc->error) {\n\t return 0;\n\t}\n\n\t/* We will work with buffer... we have to lock it! */\n\tpthread_mutex_lock (&desc->buffer_lock);\n\treaded = desc->begin + desc->len - desc->pos;\n\t\n\t/* done? */\n\tif (readed > 0 && readed >= size) {\n\t tocopy = size;\n\t break;\n\t}\n\n\t/* EOF reached and there is some data */\n\tif (!desc->going && readed > 0) {\n\t tocopy = readed;\n\t break;\n\t}\n\n\t/* EOF reached and there is no data readed*/\n\tif (!desc->going) {\n\t tocopy = 0;\n\t break;\n\t}\n\t\n\t/* break waiting */\n\tdesc->dont_wait = 1;\n\tpthread_cond_signal (&desc->dont_wait_signal);\n\t\n\t/* Allow buffer_thread to use buffer */\n pthread_mutex_unlock (&desc->buffer_lock);\n \n\t/* Wait for next portion of data */\n\tif (!desc->new_datablock) {\n\t pthread_mutex_lock (&mut);\n\t pthread_cond_wait (&desc->new_datablock_signal, &mut);\n\t pthread_mutex_unlock (&mut);\n\t} else {\n\t desc->new_datablock --;\n\t}\n }\n\n /* copy result If there are data to copy */\n if (tocopy) {\n\tmemcpy (ptr, desc->buffer + desc->pos - desc->begin, tocopy);\n\tdesc->pos += tocopy;\n\n\t/* let them know about new state, heh */\n\tstatus_notify (desc);\n }\n \n /* Allow buffer_thread to use buffer. */\n pthread_mutex_unlock (&desc->buffer_lock);\n\n return tocopy;\n}", "label": 0, "cwe": null, "length": 501 }, { "index": 419691, "code": "createNavigationModeButton()\n{\n QString icon;\n m_viewModeNav = new QToolButton(this);\n icon = theme()->iconFileName(CalendarTheme::NavigationViewMode);\n if (!icon.isEmpty())\n m_viewModeNav->setIcon(QIcon(icon));\n m_viewModeNav->setPopupMode(QToolButton::InstantPopup);\n aDayView = new QAction(tkTr(Trans::Constants::DAY), this);\n icon = theme()->iconFileName(CalendarTheme::NavigationDayViewMode);\n if (!icon.isEmpty())\n aDayView->setIcon(QIcon(icon));\n aWeekView = new QAction(tkTr(Trans::Constants::WEEK), this);\n icon = theme()->iconFileName(CalendarTheme::NavigationDayViewMode);\n if (!icon.isEmpty())\n aWeekView->setIcon(QIcon(icon));\n aMonthView = new QAction(tkTr(Trans::Constants::MONTH), this);\n icon = theme()->iconFileName(CalendarTheme::NavigationDayViewMode);\n if (!icon.isEmpty())\n aMonthView->setIcon(QIcon(icon));\n m_viewModeNav->addAction(aDayView);\n m_viewModeNav->addAction(aWeekView);\n m_viewModeNav->addAction(aMonthView);\n return m_viewModeNav;\n}", "label": 0, "cwe": null, "length": 254 }, { "index": 327863, "code": "lad_sm_make_max_access_search_pe_statement(StripMiningInnerLoop *smil, \n\t\t\t\t\t Pe_statement *pe_head, \n\t\t\t\t\t Array_table *ldm, \n\t\t\t\t\t SemTree **vss, \n\t\t\t\t\t SemTree **vss_prev, \n\t\t\t\t\t int dim,\n\t\t\t\t\t int work)\n{\n Pe_statement *pe_stm;\n\n if(pe_head == NULL) {\n\treturn;\n }\n\n for (pe_stm = pe_head; pe_stm != NULL; pe_stm = pe_stm->next) {\n\tlad_sm_make_max_access_search_statement(smil,\n\t\t\t\t\t\tpe_stm->stm_head,\n\t\t\t\t\t\tldm,\n\t\t\t\t\t\tvss,\n\t\t\t\t\t\tvss_prev,\n\t\t\t\t\t\tdim,\n\t\t\t\t\t\twork);\n }\n}", "label": 0, "cwe": null, "length": 152 }, { "index": 221022, "code": "_dxl_InvalidateSocket(DXLConnection *connection)\n{\n _DXLError(connection, \"Connection to DX broken\");\n\n if (connection->brokenConnectionCallback)\n (*connection->brokenConnectionCallback)\n (connection, connection->brokenConnectionCallbackData);\n\n if (connection->fd >= 0)\n {\n\tclose(connection->fd);\n\n\t/*\n\t * If there was a system-dependent event handler installed,\n\t * then clean it up.\n\t */\n\t_dxf_RemoveEventHandler(connection);\n\n\tconnection->fd = -1;\n }\n}", "label": 0, "cwe": null, "length": 110 }, { "index": 469936, "code": "RemoveNestAttribute(Function *F) {\n F->setAttributes(StripNest(F->getContext(), F->getAttributes()));\n for (User *U : F->users()) {\n if (isa(U))\n continue;\n CallSite CS(cast(U));\n CS.setAttributes(StripNest(F->getContext(), CS.getAttributes()));\n }\n}", "label": 0, "cwe": null, "length": 82 }, { "index": 34320, "code": "iscsi_target_destroy(int tid)\n{\n\tstruct iscsi_target* target;\n\n\ttarget = target_find_by_id(tid);\n\tif (!target) {\n\t\teprintf(\"can't find the target %d\\n\", tid);\n\t\treturn;\n\t}\n\n\tif (target->nr_sessions) {\n\t\teprintf(\"the target %d still has sessions\\n\", tid);\n\t\treturn;\n\t}\n\tif (!list_empty(&target->sessions_list)) {\n\t\teprintf(\"bug still have sessions %d\\n\", tid);\n\t\texit(-1);\n\t}\n\n\tlist_del(&target->tlist);\n\tif (target->redirect_info.callback)\n\t\tfree(target->redirect_info.callback);\n\tfree(target);\n\tisns_target_deregister(tgt_targetname(tid));\n\n\treturn;\n}", "label": 0, "cwe": null, "length": 151 }, { "index": 208146, "code": "GainMess(int argc, t_atom *argv)\n{\n t_float gain = 0.0;\n m_gain[chAlpha]=0.0;\n int i;\n\n switch (argc) {\n case 1:\n gain = atom_getfloat(argv);\n if (gain<=0) gain=1.0;\n m_gain[chRed]=m_gain[chGreen]=m_gain[chBlue]=gain;\n break;\n case 3:\n case 4:\n for (i=0; ipid == 0 || kill(io->pid, SIGKILL) != -1;\n}", "label": 0, "cwe": null, "length": 31 }, { "index": 97587, "code": "vacm_parse_setaccess(const char *token, char *param)\n{\n char *name, *context, *viewname, *viewval;\n int imodel, ilevel, iprefix;\n int viewnum;\n char *st;\n struct vacm_accessEntry *ap;\n \n if (_vacm_parse_access_common(token, param, &st, &name,\n &context, &imodel, &ilevel, &iprefix)\n == PARSE_FAIL) {\n return;\n }\n\n viewname = strtok_r(NULL, \" \\t\\n\", &st);\n if (!viewname) {\n config_perror(\"missing viewname parameter\");\n return;\n }\n viewval = strtok_r(NULL, \" \\t\\n\", &st);\n if (!viewval) {\n config_perror(\"missing viewval parameter\");\n return;\n }\n\n if (strlen(viewval) + 1 > sizeof(ap->views[VACM_VIEW_NOTIFY])) {\n config_perror(\"View value too long\");\n return;\n }\n\n viewnum = se_find_value_in_slist(VACM_VIEW_ENUM_NAME, viewname);\n if (viewnum < 0 || viewnum >= VACM_MAX_VIEWS) {\n config_perror(\"Illegal view name\");\n return;\n }\n \n ap = vacm_getAccessEntry(name, context, imodel, ilevel);\n if (!ap) {\n ap = vacm_createAccessEntry(name, context, imodel, ilevel);\n DEBUGMSGTL((\"vacm:conf:setaccess\",\n \"no existing access found; creating a new one\\n\"));\n } else {\n DEBUGMSGTL((\"vacm:conf:setaccess\",\n \"existing access found, using it\\n\"));\n }\n if (!ap) {\n config_perror(\"failed to create access entry\");\n return;\n }\n\n strcpy(ap->views[viewnum], viewval);\n ap->contextMatch = iprefix;\n ap->storageType = SNMP_STORAGE_PERMANENT;\n ap->status = SNMP_ROW_ACTIVE;\n free(ap->reserved);\n ap->reserved = NULL;\n}", "label": 1, "cwe": [ "CWE-120", "CWE-469" ], "length": 453 }, { "index": 20607, "code": "grab_file(const char *filename, unsigned long *size)\n{\n\tstruct stat st;\n\tvoid *map;\n\tint fd;\n\n\tfd = open(filename, O_RDONLY);\n\tif (fd < 0 || fstat(fd, &st) != 0)\n\t\treturn NULL;\n\n\t*size = st.st_size;\n\tmap = mmap(NULL, *size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0);\n\tclose(fd);\n\n\tif (map == MAP_FAILED)\n\t\treturn NULL;\n\treturn map;\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 934288, "code": "notes_area_do_set_project (NotesArea *na, GttProject *proj)\n{\n\tconst char * str;\n\tGttTask *tsk;\n\t\n\tif (!na) return;\n\tif (na->ignore_events) return;\n\n\t/* Calling gtk_entry_set_text makes 'changed' events happen,\n\t * which causes us to get the entry text, which exposes a gtk\n\t * bug. So we work around the bug and save cpu time by ignoring\n\t * change events during a mass update. */\n\tna->ignore_events = TRUE;\n\t\n\t/* Note Bene its OK to have the proj be null: this has the\n\t * effect of clearing all the fields out.\n\t */\n\tna->proj = proj;\n\t\n\t/* Fetch data from the data engine, stuff it into the GUI. */\n\tstr = gtt_project_get_title (proj);\n\tif (!str) str = \"\";\n\tgtk_entry_set_text (na->proj_title, str);\n\t\n\tstr = gtt_project_get_desc (proj);\n\tif (!str) str = \"\";\n\tgtk_entry_set_text (na->proj_desc, str);\n\n\tstr = gtt_project_get_notes (proj);\n\tif (!str) str = \"\";\n\txxxgtk_textview_set_text (na->proj_notes, str);\n\n\ttsk = gtt_project_get_first_task (proj);\n\tstr = gtt_task_get_memo (tsk);\n\tif (!str) str = \"\";\n\tgtk_entry_set_text (na->task_memo, str);\n\t\n\tstr = gtt_task_get_notes (tsk);\n\tif (!str) str = \"\";\n\txxxgtk_textview_set_text (na->task_notes, str);\n\n\tna->ignore_events = FALSE;\n}", "label": 0, "cwe": null, "length": 345 }, { "index": 837654, "code": "bgav_mxf_find_stream(mxf_file_t * f, bgav_demuxer_context_t * t, mxf_ul_t ul)\n {\n uint32_t stream_id;\n if(!UL_MATCH(ul, mxf_essence_element_key))\n return NULL;\n\n if(((mxf_preface_t*)(f->header.preface))->operational_pattern == MXF_OP_ATOM)\n {\n bgav_stream_t * ret = NULL;\n if(t->tt->cur->num_audio_streams)\n ret = t->tt->cur->audio_streams;\n if(t->tt->cur->num_video_streams)\n ret = t->tt->cur->video_streams;\n if(t->tt->cur->num_subtitle_streams)\n ret = t->tt->cur->subtitle_streams;\n if(ret && ret->action == BGAV_STREAM_MUTE)\n return NULL;\n return ret;\n }\n\n stream_id = ul[12] << 24 |\n ul[13] << 16 |\n ul[14] << 8 |\n ul[15];\n return bgav_track_find_stream(t, stream_id);\n }", "label": 0, "cwe": null, "length": 241 }, { "index": 22617, "code": "test_white_list_with_lib(const std::string &funcname, const Settings *settings)\n{\n return (std::binary_search(call_func_white_list,\n call_func_white_list+sizeof(call_func_white_list) / sizeof(call_func_white_list[0]),\n funcname) || (settings->library.leakignore.find(funcname) != settings->library.leakignore.end()));\n}", "label": 0, "cwe": null, "length": 79 }, { "index": 116317, "code": "ql_start_rss(struct ql_adapter *qdev)\n{\n\tstatic const u8 init_hash_seed[] = {\n\t\t0x6d, 0x5a, 0x56, 0xda, 0x25, 0x5b, 0x0e, 0xc2,\n\t\t0x41, 0x67, 0x25, 0x3d, 0x43, 0xa3, 0x8f, 0xb0,\n\t\t0xd0, 0xca, 0x2b, 0xcb, 0xae, 0x7b, 0x30, 0xb4,\n\t\t0x77, 0xcb, 0x2d, 0xa3, 0x80, 0x30, 0xf2, 0x0c,\n\t\t0x6a, 0x42, 0xb7, 0x3b, 0xbe, 0xac, 0x01, 0xfa\n\t};\n\tstruct ricb *ricb = &qdev->ricb;\n\tint status = 0;\n\tint i;\n\tu8 *hash_id = (u8 *) ricb->hash_cq_id;\n\n\tmemset((void *)ricb, 0, sizeof(*ricb));\n\n\tricb->base_cq = RSS_L4K;\n\tricb->flags =\n\t\t(RSS_L6K | RSS_LI | RSS_LB | RSS_LM | RSS_RT4 | RSS_RT6);\n\tricb->mask = cpu_to_le16((u16)(0x3ff));\n\n\t/*\n\t * Fill out the Indirection Table.\n\t */\n\tfor (i = 0; i < 1024; i++)\n\t\thash_id[i] = (i & (qdev->rss_ring_count - 1));\n\n\tmemcpy((void *)&ricb->ipv6_hash_key[0], init_hash_seed, 40);\n\tmemcpy((void *)&ricb->ipv4_hash_key[0], init_hash_seed, 16);\n\n\tstatus = ql_write_cfg(qdev, ricb, sizeof(*ricb), CFG_LR, 0);\n\tif (status) {\n\t\tnetif_err(qdev, ifup, qdev->ndev, \"Failed to load RICB.\\n\");\n\t\treturn status;\n\t}\n\treturn status;\n}", "label": 1, "cwe": "CWE-120", "length": 509 }, { "index": 66816, "code": "array_toLocaleString(JSContext *cx, uintN argc, jsval *vp)\n{\n JSObject *obj;\n\n obj = JS_THIS_OBJECT(cx, vp);\n if (!obj ||\n (OBJ_GET_CLASS(cx, obj) != &js_SlowArrayClass &&\n !JS_InstanceOf(cx, obj, &js_ArrayClass, vp + 2))) {\n return JS_FALSE;\n }\n\n /*\n * Passing comma here as the separator. Need a way to get a\n * locale-specific version.\n */\n return array_toString_sub(cx, obj, JS_TRUE, NULL, vp);\n}", "label": 0, "cwe": null, "length": 131 }, { "index": 49707, "code": "eeepc_acpi_notify(struct acpi_device *device, u32 event)\n{\n\tstruct eeepc_laptop *eeepc = acpi_driver_data(device);\n\tint old_brightness, new_brightness;\n\tu16 count;\n\n\tif (event > ACPI_MAX_SYS_NOTIFY)\n\t\treturn;\n\tcount = eeepc->event_count[event % 128]++;\n\tacpi_bus_generate_netlink_event(device->pnp.device_class,\n\t\t\t\t\tdev_name(&device->dev), event,\n\t\t\t\t\tcount);\n\n\t/* Brightness events are special */\n\tif (event < NOTIFY_BRN_MIN || event > NOTIFY_BRN_MAX) {\n\t\teeepc_input_notify(eeepc, event);\n\t\treturn;\n\t}\n\n\t/* Ignore them completely if the acpi video driver is used */\n\tif (!eeepc->backlight_device)\n\t\treturn;\n\n\t/* Update the backlight device. */\n\told_brightness = eeepc_backlight_notify(eeepc);\n\n\t/* Convert event to keypress (obsolescent hack) */\n\tnew_brightness = event - NOTIFY_BRN_MIN;\n\n\tif (new_brightness < old_brightness) {\n\t\tevent = NOTIFY_BRN_MIN; /* brightness down */\n\t} else if (new_brightness > old_brightness) {\n\t\tevent = NOTIFY_BRN_MAX; /* brightness up */\n\t} else {\n\t\t/*\n\t\t * no change in brightness - already at min/max,\n\t\t * event will be desired value (or else ignored)\n\t\t */\n\t}\n\teeepc_input_notify(eeepc, event);\n}", "label": 0, "cwe": null, "length": 310 }, { "index": 56121, "code": "ak4xxx_capture_source_put(struct snd_kcontrol *kcontrol,\n\t\t\t\t struct snd_ctl_elem_value *ucontrol)\n{\n\tstruct snd_akm4xxx *ak = snd_kcontrol_chip(kcontrol);\n\tint mixer_ch = AK_GET_SHIFT(kcontrol->private_value);\n\tint chip = AK_GET_CHIP(kcontrol->private_value);\n\tint addr = AK_GET_ADDR(kcontrol->private_value);\n\tint mask = AK_GET_MASK(kcontrol->private_value);\n\tunsigned char oval, val;\n\tint num_names = ak4xxx_capture_num_inputs(ak, mixer_ch);\n\n\tif (ucontrol->value.enumerated.item[0] >= num_names)\n\t\treturn -EINVAL;\n\n\toval = snd_akm4xxx_get(ak, chip, addr);\n\tval = oval & ~mask;\n\tval |= ucontrol->value.enumerated.item[0] & mask;\n\tif (val != oval) {\n\t\tsnd_akm4xxx_write(ak, chip, addr, val);\n\t\treturn 1;\n\t}\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 208 }, { "index": 69125, "code": "vfs_configInfoCache(\n HOST_CFG *pAnchor, /* IN-OUT: result */\n char *input, /* IN: path name */\n H_UINT *pArgs)\n{\n if (strlen(input)> 5) {\n char path[FILENAME_MAX];\n int idx;\n\n idx = atoi(input+5);\n (void)snprintf(path, 32, \"index%d\", idx);\n if (!strcmp(path, input)) {\n int plen, ctype, level, size;\n\n plen = snprintf(path, FILENAME_MAX, \"%s/devices/system/cpu/cpu%d/cache/index%d/level\",\n pAnchor->sysfs, pArgs[1], idx) - 5;\n level = vfs_configFile(pAnchor, path, vfs_configInt);\n strcpy(path+plen, \"type\");\n ctype = vfs_configFile(pAnchor, path, vfs_configType);\n strcpy(path+plen, \"size\");\n size = vfs_configFile(pAnchor, path, vfs_configInt);\n cfg_cacheAdd(pAnchor, SRC_VFS_INDEX, pArgs[1], level, ctype, size);\n }\n }\n return 0;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-other" ], "length": 252 }, { "index": 823625, "code": "mcxBDBhash\n( const void *key\n, u32 len\n)\n { const char* k = key\n ; u32 hash = 0\n\n ; while (len--)\n { hash = *k++ + (hash << 6) + (hash << 16) - hash\n ; }\n return hash\n; }", "label": 0, "cwe": null, "length": 89 }, { "index": 144505, "code": "script_find_selector(state_t *s, const char *selectorname)\n{\n int i;\n for (i = 0; i < s->selector_names_nr; i++)\n if (strcmp(selectorname, s->selector_names[i]) == 0)\n return i;\n\n sciprintf(\"Warning: Could not map '%s' to any selector!\\n\", selectorname);\n return -1;\n}", "label": 0, "cwe": null, "length": 88 }, { "index": 23640, "code": "refstrndup(const char *str, size_t len)\n{\n char *r;\n\n if (!str)\n\treturn NULL;\n\n len = strnlen(str, len);\n r = refstr_alloc(len);\n if (r)\n\tmemcpy(r, str, len);\n return r;\n}", "label": 0, "cwe": null, "length": 63 }, { "index": 44254, "code": "consumer5_set_mapping_tree_state_for_replica(const Replica *r, RUV *supplierRuv)\n{\n\tconst Slapi_DN *repl_root_sdn= replica_get_root(r);\n\tchar **ruv_referrals= NULL;\n\tchar **replica_referrals= NULL;\n RUV *ruv;\n\tint state_backend = -1;\n\tconst char *mtn_state = NULL;\n\t\n PR_Lock (r->repl_lock);\n\n\tif ( supplierRuv == NULL )\n\t{\n\t\truv = (RUV*)object_get_data (r->repl_ruv);\n\t\tPR_ASSERT (ruv);\n\n\t\truv_referrals= ruv_get_referrals(ruv); /* ruv_referrals has to be free'd */\n\t}\n\telse\n\t{\n\t\truv_referrals = ruv_get_referrals(supplierRuv);\n\t}\n\n\treplica_get_referrals_nolock (r, &replica_referrals); /* replica_referrals has to be free'd */\n\t\n /* JCMREPL - What if there's a Total update in progress? */\n\tif( (r->repl_type==REPLICA_TYPE_READONLY) || (r->legacy_consumer) )\n\t{\n\t\tstate_backend = 0;\n\t}\n\telse if (r->repl_type==REPLICA_TYPE_UPDATABLE)\n\t{\n\t\tstate_backend = 1;\n\t}\n\t/* Unlock to avoid changing MTN state under repl lock */\n PR_Unlock (r->repl_lock);\n\n\tif(state_backend == 0 )\n\t{\n\t\t/* Read-Only - The mapping tree should be refering all update operations. */\n\t\tmtn_state = STATE_UPDATE_REFERRAL;\n\t}\n\telse if (state_backend == 1)\n\t{\n\t\t/* Updatable - The mapping tree should be accepting all update operations. */\n\t\tmtn_state = STATE_BACKEND;\n\t}\n\n\t/* JCMREPL - Check the return code. */\n\trepl_set_mtn_state_and_referrals(repl_root_sdn, mtn_state, NULL,\n\t\t\t\t\t\t\t\t\t ruv_referrals, replica_referrals);\n\tcharray_free(ruv_referrals);\n\tcharray_free(replica_referrals);\n}", "label": 0, "cwe": null, "length": 454 }, { "index": 98026, "code": "io_bufread(char *ptr, long len, rb_io_t *fptr)\n{\n long offset = 0;\n long n = len;\n long c;\n\n if (READ_DATA_PENDING(fptr) == 0) {\n\twhile (n > 0) {\n again:\n\t c = rb_read_internal(fptr->fd, ptr+offset, n);\n\t if (c == 0) break;\n\t if (c < 0) {\n if (rb_io_wait_readable(fptr->fd))\n goto again;\n\t\treturn -1;\n\t }\n\t offset += c;\n\t if ((n -= c) <= 0) break;\n\t rb_thread_wait_fd(fptr->fd);\n\t}\n\treturn len - n;\n }\n\n while (n > 0) {\n\tc = read_buffered_data(ptr+offset, n, fptr);\n\tif (c > 0) {\n\t offset += c;\n\t if ((n -= c) <= 0) break;\n\t}\n\trb_thread_wait_fd(fptr->fd);\n\trb_io_check_closed(fptr);\n\tif (io_fillbuf(fptr) < 0) {\n\t break;\n\t}\n }\n return len - n;\n}", "label": 0, "cwe": null, "length": 250 }, { "index": 764932, "code": "flames_fileutils_create_fqfname (char * dir_name, char * file_name)\n\n{\n char *fqfn = NULL;\n\n int n;\n int ldn = 0, lfn = 0, lextra = 2;\n\n\n //FLAMES_TRACE(__func__)\n\n if (file_name == NULL) return NULL;\n\n if (dir_name != NULL)\n {\n ldn = (int) strlen (dir_name);\n if (dir_name[ldn] == '/') lextra = 1;\n }\n\n lfn = (int) strlen (file_name);\n n = sizeof (char) * (ldn + lfn + lextra);\n fqfn = (char *) cpl_malloc ((size_t) n);\n if (fqfn == NULL) return NULL;\n\n (void) strcpy (fqfn, dir_name);\n if (lextra == 2) (void) strcat (fqfn, \"/\");\n (void) strcat (fqfn, file_name);\n\n return fqfn;\n\n}", "label": 0, "cwe": null, "length": 218 }, { "index": 80512, "code": "get_dr23_drotx(ROT_MATRIX_TYPE type)\n{\n if(m_rot_matrix_type == Rotation_matrix::math)\n {\n return cos(m_angle_math_rotX) * cos(m_angle_math_rotY);\n }\n if(m_rot_matrix_type == Rotation_matrix::geodetic)\n {\n return -sin(m_angle_geod_rotX) * sin(m_angle_geod_rotY) * sin(m_angle_geod_rotZ) - cos(m_angle_geod_rotX) * cos(m_angle_geod_rotZ);\n }\nreturn 0.0;\n}", "label": 0, "cwe": null, "length": 119 }, { "index": 311779, "code": "max_thres_op_short(short* value, int count, int center)\n{\n short v = value[center], min, max;\n\n if (v < thresAux) \n return 0;\n\n imMinMax(value, count, min, max);\n\n if (v < max)\n return 0;\n\n return 1;\n}", "label": 0, "cwe": null, "length": 73 }, { "index": 7250, "code": "datablob_hmac_append(struct encrypted_key_payload *epayload,\n\t\t\t\tconst u8 *master_key, size_t master_keylen)\n{\n\tu8 derived_key[HASH_SIZE];\n\tu8 *digest;\n\tint ret;\n\n\tret = get_derived_key(derived_key, AUTH_KEY, master_key, master_keylen);\n\tif (ret < 0)\n\t\tgoto out;\n\n\tdigest = epayload->format + epayload->datablob_len;\n\tret = calc_hmac(digest, derived_key, sizeof derived_key,\n\t\t\tepayload->format, epayload->datablob_len);\n\tif (!ret)\n\t\tdump_hmac(NULL, digest, HASH_SIZE);\nout:\n\treturn ret;\n}", "label": 1, "cwe": "CWE-other", "length": 144 }, { "index": 40831, "code": "ChangeNodeName( nd, str )\n nptr nd;\n char *str;\n {\n int len;\n\n if( nd->nflags & POWER_RAIL )\n {\n\tif( str_eql( str, nd->nname ) == 0 )\n\t return;\n\telse if( nd == GND_node )\n\t chg_GND = TRUE;\n\telse\n\t chg_VDD = TRUE;\n }\n\n len = strlen( str ) + 1;\n\n n_delete( nd );\n\n nd->nname = Valloc( len, 1 );\n bcopy( str, nd->nname, len );\n\n CAP_CHANGE( nd, ch_nlist, 0 );\n\n if( str_eql( str, \"Vdd\" ) )\n\tnew_VDD = nd;\n else if( str_eql( str, \"Gnd\" ) )\n\tnew_GND = nd;\n }", "label": 0, "cwe": null, "length": 193 }, { "index": 262765, "code": "GetString() const\n{\n\twxString result;\n\tFormatList::const_iterator it = m_formats.begin();\n\tif (it == m_formats.end()) {\n\t\tresult = m_formatString;\n\t} else {\n\t\tunsigned lastEnd = 0;\n\t\tfor (; it != m_formats.end(); ++it) {\n\t\t\tresult += m_formatString.Mid(lastEnd, it->startPos - lastEnd);\n\t\t\tresult += it->result;\n\t\t\tlastEnd = it->endPos + 1;\n\t\t}\n\t\tresult += m_formatString.Mid(lastEnd);\n\t}\n\treturn result;\n}", "label": 0, "cwe": null, "length": 121 }, { "index": 987463, "code": "init_reg_sets ()\n{\n int i, j;\n\n /* First copy the register information from the initial int form into\n the regsets. */\n\n for (i = 0; i < N_REG_CLASSES; i++)\n {\n CLEAR_HARD_REG_SET (reg_class_contents[i]);\n\n /* Note that we hard-code 32 here, not HOST_BITS_PER_INT. */\n for (j = 0; j < FIRST_PSEUDO_REGISTER; j++)\n\tif (int_reg_class_contents[i][j / 32]\n\t & ((unsigned) 1 << (j % 32)))\n\t SET_HARD_REG_BIT (reg_class_contents[i], j);\n }\n\n memcpy (fixed_regs, initial_fixed_regs, sizeof fixed_regs);\n memcpy (call_used_regs, initial_call_used_regs, sizeof call_used_regs);\n memset (global_regs, 0, sizeof global_regs);\n\n /* Do any additional initialization regsets may need. */\n INIT_ONCE_REG_SET ();\n\n#ifdef REG_ALLOC_ORDER\n for (i = 0; i < FIRST_PSEUDO_REGISTER; i++)\n inv_reg_alloc_order[reg_alloc_order[i]] = i;\n#endif\n}", "label": 1, "cwe": "CWE-120", "length": 244 }, { "index": 665798, "code": "conf_set_general_stats_k_oper_only(confentry_t * entry, conf_t * conf, struct conf_items *item)\n{\n\tchar *val = entry->string;\n\n\tif(strcasecmp(val, \"yes\") == 0)\n\t\tConfigFileEntry.stats_k_oper_only = 2;\n\telse if(strcasecmp(val, \"masked\") == 0)\n\t\tConfigFileEntry.stats_k_oper_only = 1;\n\telse if(strcasecmp(val, \"no\") == 0)\n\t\tConfigFileEntry.stats_k_oper_only = 0;\n\telse\n\t\tconf_report_warning_nl(\"Invalid setting '%s' for general::stats_k_oper_only at %s:%d\", val, conf->filename, conf->line);\n}", "label": 0, "cwe": null, "length": 145 }, { "index": 641213, "code": "fill_ayuv (GstVideoBoxFill fill_type, guint b_alpha, GstVideoFormat format,\n guint8 * dest, gboolean sdtv, gint width, gint height)\n{\n guint32 empty_pixel;\n\n b_alpha = CLAMP (b_alpha, 0, 255);\n\n if (sdtv)\n empty_pixel = GUINT32_FROM_BE ((b_alpha << 24) |\n (yuv_sdtv_colors_Y[fill_type] << 16) |\n (yuv_sdtv_colors_U[fill_type] << 8) | yuv_sdtv_colors_V[fill_type]);\n else\n empty_pixel = GUINT32_FROM_BE ((b_alpha << 24) |\n (yuv_hdtv_colors_Y[fill_type] << 16) |\n (yuv_hdtv_colors_U[fill_type] << 8) | yuv_hdtv_colors_V[fill_type]);\n\n orc_splat_u32 ((guint32 *) dest, empty_pixel, width * height);\n}", "label": 0, "cwe": null, "length": 222 }, { "index": 465991, "code": "getOptionsObjectConst() const\n{\n FWOptions *iface_opt = FWOptions::cast(getFirstByType(InterfaceOptions::TYPENAME));\n if (iface_opt == NULL)\n cerr << \"Interface \"\n << getName()\n << \" (\"\n << getPath()\n << \") \"\n << \" has no options object; late initialization failure\"\n << endl;\n return iface_opt;\n}", "label": 0, "cwe": null, "length": 85 }, { "index": 336405, "code": "redraw_flies_background(int page)\n{\n\tint c2;\n\n\tfor (c2 = NUM_FLIES - 1; c2 >= 0; c2--) {\n\t\tif (flies[c2].back_defined[page] == 1)\n\t\t\tset_pixel(page, flies[c2].old_draw_x, flies[c2].old_draw_y, flies[c2].back[page]);\n\t\tflies[c2].old_draw_x = flies[c2].x;\n\t\tflies[c2].old_draw_y = flies[c2].y;\n\t}\n}", "label": 0, "cwe": null, "length": 116 }, { "index": 840903, "code": "pushDocInfo(const QString &fileName, const QString &baseDir)\n{\n m_docInfoStack.push(m_docInfo);\n if (!baseDir.isEmpty())\n {\n if (!QDir::isRelativePath(baseDir))\n m_docInfo.baseDir = KGlobal::dirs()->relativeLocation(\"xdgconf-menu\", baseDir);\n else\n m_docInfo.baseDir = baseDir;\n }\n\n QString baseName = fileName;\n if (!QDir::isRelativePath(baseName))\n registerFile(baseName);\n else\n baseName = m_docInfo.baseDir + baseName;\n\n m_docInfo.path = locateMenuFile(fileName);\n if (m_docInfo.path.isEmpty())\n {\n m_docInfo.baseDir.clear();\n m_docInfo.baseName.clear();\n kDebug(7021) << \"Menu\" << fileName << \"not found.\";\n return;\n }\n int i;\n i = baseName.lastIndexOf('/');\n if (i > 0)\n {\n m_docInfo.baseDir = baseName.left(i+1);\n m_docInfo.baseName = baseName.mid(i+1, baseName.length() - i - 6);\n }\n else\n {\n m_docInfo.baseDir.clear();\n m_docInfo.baseName = baseName.left( baseName.length() - 5 );\n }\n}", "label": 0, "cwe": null, "length": 283 }, { "index": 175818, "code": "__cbc_encrypt(struct blkcipher_desc *desc,\n\t\t\t\t struct blkcipher_walk *walk)\n{\n\tstruct bf_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);\n\tunsigned int bsize = BF_BLOCK_SIZE;\n\tunsigned int nbytes = walk->nbytes;\n\tu64 *src = (u64 *)walk->src.virt.addr;\n\tu64 *dst = (u64 *)walk->dst.virt.addr;\n\tu64 *iv = (u64 *)walk->iv;\n\n\tdo {\n\t\t*dst = *src ^ *iv;\n\t\tblowfish_enc_blk(ctx, (u8 *)dst, (u8 *)dst);\n\t\tiv = dst;\n\n\t\tsrc += 1;\n\t\tdst += 1;\n\t\tnbytes -= bsize;\n\t} while (nbytes >= bsize);\n\n\t*(u64 *)walk->iv = *iv;\n\treturn nbytes;\n}", "label": 0, "cwe": null, "length": 185 }, { "index": 882385, "code": "extractBase( SentenceAlignment &sentence )\n{\n ostringstream outextractFile;\n ostringstream outextractFileInv;\n\n int countF = sentence.source.size();\n for(int startF=0; startFinherited(inheritedC_, ec.specLevel, interp,\n\t\t\t\t *ec.actualDependencies);\n interp.makeReadOnly(obj);\n return obj;\n}", "label": 0, "cwe": null, "length": 102 }, { "index": 350199, "code": "device_isdup (uaecptr expbase, TCHAR *devname)\n{\n\tuaecptr bnode, dnode, name;\n\tint len, i;\n\tTCHAR dname[256];\n\n\tbnode = get_long (expbase + 74); /* expansion.library bootnode list */\n\twhile (get_long (bnode)) {\n\t\tdnode = get_long (bnode + 16); /* device node */\n\t\tname = get_long (dnode + 40) << 2; /* device name BSTR */\n\t\tlen = get_byte (name);\n\t\tfor (i = 0; i < len; i++)\n\t\t\tdname[i] = get_byte (name + 1 + i);\n\t\tdname[len] = 0;\n\t\tif (!_tcsicmp (devname, dname))\n\t\t\treturn 1;\n\t\tbnode = get_long (bnode);\n\t}\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 190 }, { "index": 723719, "code": "parse(const FXchar* expression,const FXchar* variables){\n FXExpressionError err=EXPRERR_EMPTY;\n FXint size=0;\n FXCompile cs;\n\n // Free old code, if any\n if(code!=initial) FXFREE(&code);\n code=(FXuchar*)initial;\n\n // If not empty, parse expression\n if(expression){\n\n // Fill in compile data\n cs.tail=expression;\n cs.vars=variables;\n cs.code=NULL;\n cs.pc=NULL;\n cs.token=TK_EOF;\n\n // Get first token\n cs.gettok();\n\n // Emit unknown size\n cs.operand(0);\n\n // Parse to check syntax and determine size\n err=cs.compile();\n\n // Was OK?\n if(err==EXPRERR_OK){\n\n // Allocate new code\n size=cs.pc-cs.code;\n if(!FXMALLOC(&code,FXuchar,size)){\n code=(FXuchar*)initial;\n return EXPRERR_MEMORY;\n }\n\n // Fill in compile data\n cs.tail=expression;\n cs.code=code;\n cs.pc=code;\n cs.token=TK_EOF;\n\n // Get first token\n cs.gettok();\n\n // Emit code size\n cs.operand(size);\n\n // Generate program\n err=cs.compile();\n\n // Dump for debugging\n#ifndef NDEBUG\n if(fxTraceLevel>100) dump(code);\n#endif\n }\n }\n return err;\n }", "label": 0, "cwe": null, "length": 309 }, { "index": 366076, "code": "git_tag_delete(git_repository *repo, const char *tag_name)\n{\n\tgit_reference *tag_ref;\n\tgit_buf ref_name = GIT_BUF_INIT;\n\tint error;\n\n\terror = retrieve_tag_reference(&tag_ref, &ref_name, repo, tag_name);\n\n\tgit_buf_free(&ref_name);\n\n\tif (error < 0)\n\t\treturn error;\n\n\terror = git_reference_delete(tag_ref);\n\n\tgit_reference_free(tag_ref);\n\n\treturn error;\n}", "label": 0, "cwe": null, "length": 89 }, { "index": 503255, "code": "selectNew()\n{\n\tsave();\n\t_idBase = DataTheme.bases.count();\n\tGenericBaseModel * base = new GenericBaseModel();\n\tDataTheme.bases.append( base );\n\tinit();\n}", "label": 0, "cwe": null, "length": 40 }, { "index": 916169, "code": "show_curr_unit(void)\n{\n\tstatic const char *tip = \"Display unit. Click to cycle.\";\n\n\tswitch (curr_unit) {\n\tcase curr_unit_mm:\n\t\tstatus_set_unit(tip, \"mm\");\n\t\tbreak;\n\tcase curr_unit_mil:\n\t\tstatus_set_unit(tip, \"mil\");\n\t\tbreak;\n\tcase curr_unit_auto:\n\t\tstatus_set_unit(tip, \"auto\");\n\t\tbreak;\n\tdefault:\n\t\tabort();\n\t}\n}", "label": 0, "cwe": null, "length": 91 }, { "index": 697318, "code": "servers_setup_deinit(void)\n{\n\tg_free_not_null(source_host_ip4);\n\tg_free_not_null(source_host_ip6);\n\tg_free_not_null(old_source_host);\n\n\twhile (setupservers != NULL)\n\t\tserver_setup_destroy(setupservers->data);\n\n\tsignal_remove(\"setup changed\", (SIGNAL_FUNC) read_settings);\n\tsignal_remove(\"setup reread\", (SIGNAL_FUNC) read_servers);\n signal_remove(\"irssi init read settings\", (SIGNAL_FUNC) read_servers);\n\n\tmodule_uniq_destroy(\"SERVER SETUP\");\n}", "label": 0, "cwe": null, "length": 108 }, { "index": 22611, "code": "FindSlotNameID(\n void *theEnv,\n SYMBOL_HN *slotName)\n {\n SLOT_NAME *snp;\n\n snp = DefclassData(theEnv)->SlotNameTable[HashSlotName(slotName)];\n while ((snp != NULL) ? (snp->name != slotName) : FALSE)\n snp = snp->nxt;\n return((snp != NULL) ? (short) snp->id : (short) -1);\n }", "label": 0, "cwe": null, "length": 105 }, { "index": 77860, "code": "completeParamSource(\n const String& paramName,\n const GpuConstantDefinitionMap* vertexConstantDefs, \n const GpuConstantDefinitionMap* geometryConstantDefs,\n const GpuConstantDefinitionMap* fragmentConstantDefs,\n GLUniformReference& refToUpdate)\n {\n if (vertexConstantDefs)\n {\n GpuConstantDefinitionMap::const_iterator parami = \n vertexConstantDefs->find(paramName);\n if (parami != vertexConstantDefs->end())\n {\n refToUpdate.mSourceProgType = GPT_VERTEX_PROGRAM;\n refToUpdate.mConstantDef = &(parami->second);\n return true;\n }\n\n }\n if (geometryConstantDefs)\n {\n GpuConstantDefinitionMap::const_iterator parami = \n geometryConstantDefs->find(paramName);\n if (parami != geometryConstantDefs->end())\n {\n refToUpdate.mSourceProgType = GPT_GEOMETRY_PROGRAM;\n refToUpdate.mConstantDef = &(parami->second);\n return true;\n }\n\n }\n if (fragmentConstantDefs)\n {\n GpuConstantDefinitionMap::const_iterator parami = \n fragmentConstantDefs->find(paramName);\n if (parami != fragmentConstantDefs->end())\n {\n refToUpdate.mSourceProgType = GPT_FRAGMENT_PROGRAM;\n refToUpdate.mConstantDef = &(parami->second);\n return true;\n }\n }\n return false;\n\n\n }", "label": 0, "cwe": null, "length": 302 }, { "index": 358137, "code": "drop(int x, int y, int b)\n{\n\tlast_n = n_droppable(x, y); /* also sets dest_stack */\n\n\tif (b > 1) {\n\t\tif (src_stack)\n\t\t\tstack_peek_card(src_stack, src_n, 0);\n\n\t\treturn;\n\t}\n\n\tstack_drop(dest_stack, last_n);\n\n\twhile (auto_move())\n\t\t;\n\n\tcheck_for_end_of_game();\n}", "label": 0, "cwe": null, "length": 85 }, { "index": 237895, "code": "display_disasm( void )\n{\n int y;\n char pbuf[40];\n libspectrum_word addr = debugger_memaddr;\n\n for( y = 0; y < 8; ++y ) {\n size_t length;\n char *spc;\n\n sprintf( pbuf, format_16_bit(), addr );\n widget_printstring_fixed( LC(1) / 8, LR(y) / 8, 7, pbuf );\n widget_printstring( LC(6), LR(y), 5, \":\" );\n\n debugger_disassemble( pbuf, sizeof( pbuf ), &length, addr );\n addr += length;\n spc = strchr( pbuf, ' ' );\n if( spc )\n *spc = 0;\n widget_printstring( LC(8), LR(y), 7, pbuf );\n if( spc ) {\n spc += 1 + strspn( spc + 1, \" \" );\n widget_printstring( LC(12) + 4, LR(y), 7, spc );\n }\n }\n}", "label": 0, "cwe": null, "length": 235 }, { "index": 615888, "code": "OTF_RBuffer_printRecord( OTF_RBuffer* rbuffer ) {\n\n\n\tchar *ret= NULL;\n\tuint32_t pos= 0;\n\tuint32_t size= REALLOCSIZE;\n\tuint32_t c= rbuffer->pos;\n\t\n\t\n\tret= (char*) malloc( size );\n\tif( NULL == ret ) {\n\t\t\n\t\tOTF_Error( \"ERROR in function %s, file: %s, line: %i:\\n \"\n\t\t\t\t\"no memory left.\\n\",\n\t\t\t\t__FUNCTION__, __FILE__, __LINE__ );\n\n\t\treturn NULL;\n\t}\n\twhile ( ( '\\n' != rbuffer->buffer[c] ) && ( c < rbuffer->end ) ) {\n\t\n\t\twhile( (pos+1) >= size ) {\n\t\t\t\n\t\t\tret= (char*) realloc( ret, size + REALLOCSIZE );\n\t\t\tif( NULL == ret ) {\n\t\t\t\t\n\t\t\t\tOTF_Error( \"ERROR in function %s, file: %s, line: %i:\\n \"\n\t\t\t\t\t\t\"no memory left.\\n\",\n\t\t\t\t\t\t__FUNCTION__, __FILE__, __LINE__ );\n\n\t\t\t\treturn NULL;\n\t\t\t}\n\t\t\tsize+= REALLOCSIZE;\n\t\t}\n\t\t\n\t\tret[pos]= rbuffer->buffer[c];\n\t\t++pos;\n\t\t++c;\n\t}\n\t\n\tret[pos]= '\\0';\n\n\t\t\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 285 }, { "index": 69875, "code": "rotateNibbles(uint64_t state) {\n\tint i;\n\tfor(i = 0; i < 16;i++) {\n\t\tstate = rotateLeft(state);\n\t}\n\treturn state;\n}", "label": 0, "cwe": null, "length": 39 }, { "index": 63327, "code": "rfc822_mkdate_buf(time_t t, char *buf)\n{\nstruct\ttm *p;\nint\toffset;\n\n#if\tUSE_TIME_ALTZONE\n\n\tp=localtime(&t);\n\toffset= -(int)timezone;\n\n\tif (p->tm_isdst > 0)\n\t\toffset= -(int)altzone;\n\n\tif (offset % 60)\n\t{\n\t\toffset=0;\n\t\tp=gmtime(&t);\n\t}\n\toffset /= 60;\n#else\n#if\tUSE_TIME_DAYLIGHT\n\n\tp=localtime(&t);\n\toffset= -(int)timezone;\n\n\tif (p->tm_isdst > 0)\n\t\toffset += 60*60;\n\tif (offset % 60)\n\t{\n\t\toffset=0;\n\t\tp=gmtime(&t);\n\t}\n\toffset /= 60;\n#else\n#if\tUSE_TIME_GMTOFF\n\tp=localtime(&t);\n\toffset= p->tm_gmtoff;\n\n\tif (offset % 60)\n\t{\n\t\toffset=0;\n\t\tp=gmtime(&t);\n\t}\n\toffset /= 60;\n#else\n\tp=gmtime(&t);\n\toffset=0;\n#endif\n#endif\n#endif\n\n\toffset = (offset % 60) + offset / 60 * 100;\n\n\tsprintf(buf, \"%s, %02d %s %04d %02d:%02d:%02d %+05d\",\n\t\twdays[p->tm_wday],\n\t\tp->tm_mday,\n\t\tmonths[p->tm_mon],\n\t\tp->tm_year+1900,\n\t\tp->tm_hour,\n\t\tp->tm_min,\n\t\tp->tm_sec,\n\t\toffset);\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 342 }, { "index": 988892, "code": "GetFrameworkFlags()\n{\n if(!this->Makefile->IsOn(\"APPLE\"))\n {\n return std::string();\n }\n\n std::set emitted;\n#ifdef __APPLE__ /* don't insert this when crosscompiling e.g. to iphone */\n emitted.insert(\"/System/Library/Frameworks\");\n#endif\n std::vector includes;\n\n const char *config = this->Makefile->GetDefinition(\"CMAKE_BUILD_TYPE\");\n this->LocalGenerator->GetIncludeDirectories(includes,\n this->GeneratorTarget,\n \"C\", config);\n // check all include directories for frameworks as this\n // will already have added a -F for the framework\n for(std::vector::iterator i = includes.begin();\n i != includes.end(); ++i)\n {\n if(this->Target->NameResolvesToFramework(i->c_str()))\n {\n std::string frameworkDir = *i;\n frameworkDir += \"/../\";\n frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());\n emitted.insert(frameworkDir);\n }\n }\n\n std::string flags;\n const char* cfg = this->LocalGenerator->ConfigurationName.c_str();\n if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg))\n {\n std::vector const& frameworks = cli->GetFrameworkPaths();\n for(std::vector::const_iterator i = frameworks.begin();\n i != frameworks.end(); ++i)\n {\n if(emitted.insert(*i).second)\n {\n flags += \"-F\";\n flags += this->Convert(i->c_str(),\n cmLocalGenerator::START_OUTPUT,\n cmLocalGenerator::SHELL, true);\n flags += \" \";\n }\n }\n }\n return flags;\n}", "label": 0, "cwe": null, "length": 383 }, { "index": 53614, "code": "sbrEncoder_Close (HANDLE_SBR_ENCODER *phSbrEncoder)\n{\n HANDLE_SBR_ENCODER hSbrEncoder = *phSbrEncoder;\n\n if (hSbrEncoder != NULL)\n {\n int el, ch;\n\n for (el=0; el<(6); el++)\n {\n if (hSbrEncoder->sbrElement[el]!=NULL) {\n sbrEncoder_ElementClose(&hSbrEncoder->sbrElement[el]);\n }\n }\n\n /* Close sbr Channels */\n for (ch=0; ch<(6); ch++)\n {\n if (hSbrEncoder->pSbrChannel[ch]) {\n sbrEncoder_ChannelClose(hSbrEncoder->pSbrChannel[ch]);\n FreeRam_SbrChannel(&hSbrEncoder->pSbrChannel[ch]);\n }\n\n if (hSbrEncoder->QmfAnalysis[ch].FilterStates)\n FreeRam_Sbr_QmfStatesAnalysis((FIXP_QAS**)&hSbrEncoder->QmfAnalysis[ch].FilterStates);\n\n\n }\n\n if (hSbrEncoder->hParametricStereo)\n PSEnc_Destroy(&hSbrEncoder->hParametricStereo);\n if (hSbrEncoder->qmfSynthesisPS.FilterStates)\n FreeRam_PsQmfStatesSynthesis((FIXP_DBL**)&hSbrEncoder->qmfSynthesisPS.FilterStates);\n\n /* Release Overlay */\n FreeRam_SbrDynamic_RAM((FIXP_DBL**)&hSbrEncoder->pSBRdynamic_RAM);\n\n\n FreeRam_SbrEncoder(phSbrEncoder);\n }\n\n}", "label": 0, "cwe": null, "length": 346 }, { "index": 271417, "code": "debuting_files_add_file_callback (NautilusView *view,\n\t\t\t\t NautilusFile *new_file,\n\t\t\t\t NautilusDirectory *directory,\n\t\t\t\t DebutingFilesData *data)\n{\n\tGFile *location;\n\n\tnautilus_profile_start (NULL);\n\n\tlocation = nautilus_file_get_location (new_file);\n\n\tif (g_hash_table_remove (data->debuting_files, location)) {\n\t\tnautilus_file_ref (new_file);\n\t\tdata->added_files = g_list_prepend (data->added_files, new_file);\n\n\t\tif (g_hash_table_size (data->debuting_files) == 0) {\n\t\t\tnautilus_view_call_set_selection (view, data->added_files);\n\t\t\tnautilus_view_reveal_selection (view);\n\t\t\tg_signal_handlers_disconnect_by_func (view,\n\t\t\t\t\t\t\t G_CALLBACK (debuting_files_add_file_callback),\n\t\t\t\t\t\t\t data);\n\t\t}\n\t}\n\n\tnautilus_profile_end (NULL);\n\n\tg_object_unref (location);\n}", "label": 0, "cwe": null, "length": 204 }, { "index": 672350, "code": "yy_get_previous_state (yyscan_t yyscanner)\n{\n\tregister yy_state_type yy_current_state;\n\tregister char *yy_cp;\n struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;\n\n\tyy_current_state = yy_start_state_list[yyg->yy_start];\n\n\tfor ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )\n\t\t{\n\t\tyy_current_state += yy_current_state[(*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1)].yy_nxt;\n\t\tif ( yy_current_state[-1].yy_nxt )\n\t\t\t{\n\t\t\tyyg->yy_last_accepting_state = yy_current_state;\n\t\t\tyyg->yy_last_accepting_cpos = yy_cp;\n\t\t\t}\n\t\t}\n\n\treturn yy_current_state;\n}", "label": 0, "cwe": null, "length": 190 }, { "index": 873924, "code": "remove_comments(char *string, const char *start_token, const char *end_token) {\n int in_string = 0, escaped = 0;\n size_t i;\n char *ptr = NULL, current_char;\n size_t start_token_len = strlen(start_token);\n size_t end_token_len = strlen(end_token);\n if (start_token_len == 0 || end_token_len == 0)\n \treturn;\n while ((current_char = *string) != '\\0') {\n if (current_char == '\\\\' && !escaped) {\n escaped = 1;\n string++;\n continue;\n } else if (current_char == '\\\"' && !escaped) {\n in_string = !in_string;\n } else if (!in_string && strncmp(string, start_token, start_token_len) == 0) {\n\t\t\tfor(i = 0; i < start_token_len; i++)\n string[i] = ' ';\n \tstring = string + start_token_len;\n ptr = strstr(string, end_token);\n if (!ptr)\n return;\n for (i = 0; i < (ptr - string) + end_token_len; i++)\n string[i] = ' ';\n \tstring = ptr + end_token_len - 1;\n }\n escaped = 0;\n string++;\n }\n}", "label": 0, "cwe": null, "length": 277 }, { "index": 1017800, "code": "vxge_hw_vpath_doorbell_rx(struct __vxge_hw_ring *ring)\n{\n\tu32 rxds_qw_per_block = VXGE_HW_MAX_RXDS_PER_BLOCK_1 *\n\t\tVXGE_HW_RING_RXD_QWORDS_MODE_1;\n\n\tring->doorbell_cnt += VXGE_HW_RING_RXD_QWORDS_MODE_1;\n\n\tring->total_db_cnt += VXGE_HW_RING_RXD_QWORDS_MODE_1;\n\n\tif (ring->total_db_cnt >= rxds_qw_per_block) {\n\t\t/* For each block add 4 more qwords */\n\t\tring->doorbell_cnt += VXGE_HW_RING_RXD_QWORDS_MODE_1;\n\n\t\t/* Reset total count */\n\t\tring->total_db_cnt -= rxds_qw_per_block;\n\t}\n\n\tif (ring->doorbell_cnt >= ring->rxd_qword_limit) {\n\t\twmb();\n\t\twriteq(VXGE_HW_PRC_RXD_DOORBELL_NEW_QW_CNT(\n\t\t\tring->doorbell_cnt),\n\t\t\t&ring->vp_reg->prc_rxd_doorbell);\n\t\tring->doorbell_cnt = 0;\n\t}\n}", "label": 0, "cwe": null, "length": 241 }, { "index": 943756, "code": "ext4_validate_inode_bitmap(struct super_block *sb,\n\t\t\t\t struct ext4_group_desc *desc,\n\t\t\t\t ext4_group_t block_group,\n\t\t\t\t struct buffer_head *bh)\n{\n\text4_fsblk_t\tblk;\n\tstruct ext4_group_info *grp = ext4_get_group_info(sb, block_group);\n\tstruct ext4_sb_info *sbi = EXT4_SB(sb);\n\n\tif (buffer_verified(bh))\n\t\treturn 0;\n\tif (EXT4_MB_GRP_IBITMAP_CORRUPT(grp))\n\t\treturn -EFSCORRUPTED;\n\n\text4_lock_group(sb, block_group);\n\tblk = ext4_inode_bitmap(sb, desc);\n\tif (!ext4_inode_bitmap_csum_verify(sb, block_group, desc, bh,\n\t\t\t\t\t EXT4_INODES_PER_GROUP(sb) / 8)) {\n\t\text4_unlock_group(sb, block_group);\n\t\text4_error(sb, \"Corrupt inode bitmap - block_group = %u, \"\n\t\t\t \"inode_bitmap = %llu\", block_group, blk);\n\t\tgrp = ext4_get_group_info(sb, block_group);\n\t\tif (!EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) {\n\t\t\tint count;\n\t\t\tcount = ext4_free_inodes_count(sb, desc);\n\t\t\tpercpu_counter_sub(&sbi->s_freeinodes_counter,\n\t\t\t\t\t count);\n\t\t}\n\t\tset_bit(EXT4_GROUP_INFO_IBITMAP_CORRUPT_BIT, &grp->bb_state);\n\t\treturn -EFSBADCRC;\n\t}\n\tset_buffer_verified(bh);\n\text4_unlock_group(sb, block_group);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 332 }, { "index": 579216, "code": "ptrsub(source, target)\nstruct symstruct *source;\nstruct symstruct *target;\n{\n label_no exitlab;\n uoffset_T factor;\n label_no usignlab;\n\n if (source->indcount == 0 && source->storage != CONSTANT)\n {\n\tloadpres(source, target);\n\tpush(source);\n }\n if (target->indcount == 0)\n {\n\tpres2(target, source);\n\tload(target, DREG);\n }\n factor = target->type->nexttype->typesize;\n source->type = target->type = itype;\n sub1(source, target);\n if (factor != 1)\n {\n\tpushlist(CCREG);\n\tsbranch(HS, usignlab = getlabel());\t/* HS == no carry */\n\tnegDreg();\n\toutnlabel(usignlab);\n\ttarget->type = uitype;\n\tsoftop(DIVOP, constsym((value_t) factor), target);\n\ttarget->type = itype;\n\tpoplist(CCREG);\n\tsbranch(HS, exitlab = getlabel());\n\tnegDreg();\n\toutnlabel(exitlab);\n }\n}", "label": 0, "cwe": null, "length": 239 }, { "index": 721688, "code": "stats_print_item(item_t * item) {\n\tstatistic_item_t * statistic_item = hash_table_entry(item, statistic_item_t, item);\n\n\tprintf(\"%s : %\"PRIu64\" (%0.2lfms)\\n\", statistic_item->operation, statistic_item->count, statistic_item->sumdur);\n}", "label": 1, "cwe": "CWE-476", "length": 64 }, { "index": 724042, "code": "minf_Size(GF_Box *s)\n{\n\tGF_Err e;\n\tGF_MediaInformationBox *ptr = (GF_MediaInformationBox *)s;\n\t\n\te = gf_isom_box_get_size(s);\n\tif (e) return e;\n\tif (ptr->InfoHeader) {\n\t\te = gf_isom_box_size((GF_Box *) ptr->InfoHeader);\n\t\tif (e) return e;\n\t\tptr->size += ptr->InfoHeader->size;\n\t}\t\n\tif (ptr->dataInformation) {\n\t\te = gf_isom_box_size((GF_Box *) ptr->dataInformation);\n\t\tif (e) return e;\n\t\tptr->size += ptr->dataInformation->size;\n\t}\t\n\tif (ptr->sampleTable) {\n\t\te = gf_isom_box_size((GF_Box *) ptr->sampleTable);\n\t\tif (e) return e;\n\t\tptr->size += ptr->sampleTable->size;\n\t}\t\n\treturn GF_OK;\n}", "label": 0, "cwe": null, "length": 201 }, { "index": 81624, "code": "saConcatenatePdf(SARRAY *sa,\n const char *fileout)\n{\nl_uint8 *data;\nl_int32 ret;\nsize_t nbytes;\n\n PROCNAME(\"saConcatenatePdf\");\n\n if (!sa)\n return ERROR_INT(\"sa not defined\", procName, 1);\n if (!fileout)\n return ERROR_INT(\"fileout not defined\", procName, 1);\n\n ret = saConcatenatePdfToData(sa, &data, &nbytes);\n if (ret)\n return ERROR_INT(\"pdf data not made\", procName, 1);\n ret = l_binaryWrite(fileout, \"w\", data, nbytes);\n FREE(data);\n return ret;\n}", "label": 0, "cwe": null, "length": 153 }, { "index": 945480, "code": "serverdata_new (DBusLoop *loop,\n DBusServer *server)\n{\n ServerData *sd;\n\n sd = dbus_new0 (ServerData, 1);\n if (sd == NULL)\n return NULL;\n\n sd->loop = loop;\n sd->server = server;\n\n dbus_server_ref (sd->server);\n _dbus_loop_ref (sd->loop);\n\n return sd;\n}", "label": 0, "cwe": null, "length": 88 }, { "index": 472310, "code": "tipo01(QList aristas, QList vertices){\n QList triangulos;\n //Pintar los triangulos\n for(int i=0; i in C95.\n * This routine is never called in POST_STD mode.\n */\n{\n typedef struct id_op {\n const char * name;\n int op_num;\n } ID_OP;\n\n ID_OP id_ops[] = {\n { \"and\", OP_ANA},\n { \"and_eq\", OP_2},\n { \"bitand\", OP_AND},\n { \"bitor\", OP_OR},\n { \"compl\", OP_COM},\n { \"not\", OP_NOT},\n { \"not_eq\", OP_NE},\n { \"or\", OP_ORO},\n { \"or_eq\", OP_2},\n { \"xor\", OP_XOR},\n { \"xor_eq\", OP_2},\n { NULL, 0},\n };\n\n ID_OP * id_p = id_ops;\n\n while (id_p->name != NULL) {\n if (str_eq( name, id_p->name))\n return id_p->op_num;\n id_p++;\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 282 }, { "index": 473963, "code": "mprEncode64(cchar *s)\n{\n uint shiftbuf;\n char *buffer, *bp;\n ssize len;\n int i, j, shift;\n\n len = slen(s) * 2;\n if ((buffer = mprAlloc(len + 1)) == 0) {\n return NULL;\n }\n bp = buffer;\n *bp = '\\0';\n while (*s) {\n shiftbuf = 0;\n for (j = 2; j >= 0 && *s; j--, s++) {\n shiftbuf |= ((*s & 0xff) << (j * 8));\n }\n shift = 18;\n for (i = ++j; i < 4 && bp < &buffer[len] ; i++) {\n *bp++ = encodeMap[(shiftbuf >> shift) & 0x3f];\n shift -= 6;\n }\n while (j-- > 0) {\n *bp++ = '=';\n }\n *bp = '\\0';\n }\n return buffer;\n}", "label": 0, "cwe": null, "length": 230 }, { "index": 101378, "code": "fcoe_ctlr_recv_work(struct work_struct *recv_work)\n{\n\tstruct fcoe_ctlr *fip;\n\tstruct sk_buff *skb;\n\n\tfip = container_of(recv_work, struct fcoe_ctlr, recv_work);\n\twhile ((skb = skb_dequeue(&fip->fip_recv_list)))\n\t\tfcoe_ctlr_recv_handler(fip, skb);\n}", "label": 0, "cwe": null, "length": 76 }, { "index": 118, "code": "md5_finish( struct md5_context *ctx, uint8 digest[16] )\n{\n uint32 last, padn;\n uint8 msglen[8];\n\n PUT_UINT32( ctx->total[0], msglen, 0 );\n PUT_UINT32( ctx->total[1], msglen, 4 );\n\n last = ( ctx->total[0] >> 3 ) & 0x3F;\n padn = ( last < 56 ) ? ( 56 - last ) : ( 120 - last );\n\n md5_update( ctx, md5_padding, padn );\n md5_update( ctx, msglen, 8 );\n\n PUT_UINT32( ctx->state[0], digest, 0 );\n PUT_UINT32( ctx->state[1], digest, 4 );\n PUT_UINT32( ctx->state[2], digest, 8 );\n PUT_UINT32( ctx->state[3], digest, 12 );\n}", "label": 0, "cwe": null, "length": 210 }, { "index": 8070, "code": "is_player_connected(Objid player)\n{\n shandle *h = find_shandle(player);\n return !h || h->disconnect_me ? 0 : 1;\n}", "label": 0, "cwe": null, "length": 38 }, { "index": 934450, "code": "cy_shutdown(struct cyclades_port *info, struct tty_struct *tty)\n{\n\tstruct cyclades_card *card;\n\tunsigned long flags;\n\n\tif (!(info->port.flags & ASYNC_INITIALIZED))\n\t\treturn;\n\n\tcard = info->card;\n\tif (!cy_is_Z(card)) {\n\t\tspin_lock_irqsave(&card->card_lock, flags);\n\n\t\t/* Clear delta_msr_wait queue to avoid mem leaks. */\n\t\twake_up_interruptible(&info->port.delta_msr_wait);\n\n\t\tif (info->port.xmit_buf) {\n\t\t\tunsigned char *temp;\n\t\t\ttemp = info->port.xmit_buf;\n\t\t\tinfo->port.xmit_buf = NULL;\n\t\t\tfree_page((unsigned long)temp);\n\t\t}\n\t\tif (tty->termios.c_cflag & HUPCL)\n\t\t\tcyy_change_rts_dtr(info, 0, TIOCM_RTS | TIOCM_DTR);\n\n\t\tcyy_issue_cmd(info, CyCHAN_CTL | CyDIS_RCVR);\n\t\t/* it may be appropriate to clear _XMIT at\n\t\t some later date (after testing)!!! */\n\n\t\tset_bit(TTY_IO_ERROR, &tty->flags);\n\t\tinfo->port.flags &= ~ASYNC_INITIALIZED;\n\t\tspin_unlock_irqrestore(&card->card_lock, flags);\n\t} else {\n#ifdef CY_DEBUG_OPEN\n\t\tint channel = info->line - card->first_line;\n\t\tprintk(KERN_DEBUG \"cyc shutdown Z card %d, channel %d, \"\n\t\t\t\"base_addr %p\\n\", card, channel, card->base_addr);\n#endif\n\n\t\tif (!cyz_is_loaded(card))\n\t\t\treturn;\n\n\t\tspin_lock_irqsave(&card->card_lock, flags);\n\n\t\tif (info->port.xmit_buf) {\n\t\t\tunsigned char *temp;\n\t\t\ttemp = info->port.xmit_buf;\n\t\t\tinfo->port.xmit_buf = NULL;\n\t\t\tfree_page((unsigned long)temp);\n\t\t}\n\n\t\tif (tty->termios.c_cflag & HUPCL)\n\t\t\ttty_port_lower_dtr_rts(&info->port);\n\n\t\tset_bit(TTY_IO_ERROR, &tty->flags);\n\t\tinfo->port.flags &= ~ASYNC_INITIALIZED;\n\n\t\tspin_unlock_irqrestore(&card->card_lock, flags);\n\t}\n\n#ifdef CY_DEBUG_OPEN\n\tprintk(KERN_DEBUG \"cyc shutdown done\\n\");\n#endif\n}", "label": 0, "cwe": null, "length": 488 }, { "index": 733072, "code": "_PoolPrint (\n IN VOID *Context,\n IN CHAR16 *Buffer\n )\n// Append string worker for PoolPrint and CatPrint\n{\n UINTN newlen;\n POOL_PRINT *spc;\n\n spc = Context;\n newlen = spc->len + StrLen(Buffer) + 1;\n\n //\n // Is the string is over the max, grow the buffer\n //\n\n if (newlen > spc->maxlen) {\n\n //\n // Grow the pool buffer\n //\n\n newlen += PRINT_STRING_LEN;\n spc->maxlen = newlen;\n spc->str = ReallocatePool (\n spc->str, \n spc->len * sizeof(CHAR16), \n spc->maxlen * sizeof(CHAR16)\n );\n\n if (!spc->str) {\n spc->len = 0;\n spc->maxlen = 0;\n }\n }\n\n //\n // Append the new text\n //\n\n return _SPrint (Context, Buffer);\n}", "label": 0, "cwe": null, "length": 230 }, { "index": 846193, "code": "decrypt_ticket_keyblock(krb5_context context, const krb5_keyblock *key,\n krb5_ticket *ticket)\n{\n krb5_error_code retval;\n krb5_data *realm;\n krb5_transited *trans;\n\n retval = krb5_decrypt_tkt_part(context, key, ticket);\n if (retval)\n goto done;\n\n trans = &ticket->enc_part2->transited;\n realm = &ticket->enc_part2->client->realm;\n if (trans->tr_contents.data && *trans->tr_contents.data) {\n retval = krb5_check_transited_list(context, &trans->tr_contents,\n realm, &ticket->server->realm);\n goto done;\n }\n\n if (ticket->enc_part2->flags & TKT_FLG_INVALID) { /* ie, KDC_OPT_POSTDATED */\n retval = KRB5KRB_AP_ERR_TKT_INVALID;\n goto done;\n }\n\ndone:\n return retval;\n}", "label": 0, "cwe": null, "length": 205 }, { "index": 89684, "code": "main (int argc, char **argv)\n{\n heap_params_t\t*heapParams;\n\n DebugF = stderr;\n\n /* process the command-line options */\n ParseOptions (argc, argv, &heapParams);\n\n#ifdef TARGET_BYTECODE\n if (BC_stdout == NULL)\n\tBC_stdout = fdopen(dup(1), \"w\");\n#endif\n\n InitTimers ();\n RecordGlobals ();\n InitCFunList ();\n\n#ifdef MP_SUPPORT\n MP_Init();\n#endif\n\n /* start ML */\n if (isBoot) {\n\tBootML (BootFrom, heapParams);\n }\n else { /* load an image */\n\tLoadML (LoadImage, heapParams);\n }\n\n Exit (0);\n}", "label": 0, "cwe": null, "length": 150 }, { "index": 22298, "code": "job_create_task(lListElem *job, lList **answer_list, u_long32 ja_task_id)\n{\n lListElem *ja_task = NULL; \n\n DENTER(TOP_LAYER, \"job_create_task\");\n\n if (job != NULL && job_is_ja_task_defined(job, ja_task_id)) {\n ja_task = job_enroll(job, answer_list, ja_task_id);\n }\n\n DRETURN(ja_task);\n}", "label": 0, "cwe": null, "length": 93 }, { "index": 242138, "code": "read_cr(struct spi_nor *nor)\n{\n\tint ret;\n\tu8 val;\n\n\tret = nor->read_reg(nor, SPINOR_OP_RDCR, &val, 1);\n\tif (ret < 0) {\n\t\tdev_err(nor->dev, \"error %d reading CR\\n\", ret);\n\t\treturn ret;\n\t}\n\n\treturn val;\n}", "label": 0, "cwe": null, "length": 77 }, { "index": 70405, "code": "deflateSetDictionary (strm, dictionary, dictLength)\n z_streamp strm;\n const Bytef *dictionary;\n uInt dictLength;\n{\n deflate_state *s;\n uInt length = dictLength;\n uInt n;\n IPos hash_head = 0;\n\n if (strm == Z_NULL || strm->state == Z_NULL || dictionary == Z_NULL ||\n strm->state->status != INIT_STATE) return Z_STREAM_ERROR;\n\n s = strm->state;\n strm->adler = adler32(strm->adler, dictionary, dictLength);\n\n if (length < MIN_MATCH) return Z_OK;\n if (length > MAX_DIST(s)) {\n\tlength = MAX_DIST(s);\n#ifndef USE_DICT_HEAD\n\tdictionary += dictLength - length; /* use the tail of the dictionary */\n#endif\n }\n zmemcpy(s->window, dictionary, length);\n s->strstart = length;\n s->block_start = (long)length;\n\n /* Insert all strings in the hash table (except for the last two bytes).\n * s->lookahead stays null, so s->ins_h will be recomputed at the next\n * call of fill_window.\n */\n s->ins_h = s->window[0];\n UPDATE_HASH(s, s->ins_h, s->window[1]);\n for (n = 0; n <= length - MIN_MATCH; n++) {\n\tINSERT_STRING(s, n, hash_head);\n }\n if (hash_head) hash_head = 0; /* to make compiler happy */\n return Z_OK;\n}", "label": 0, "cwe": null, "length": 341 }, { "index": 3626, "code": "mptspi_initTarget(MPT_SCSI_HOST *hd, VirtTarget *vtarget,\n\t\t struct scsi_device *sdev)\n{\n\n\t/* Is LUN supported? If so, upper 2 bits will be 0\n\t* in first byte of inquiry data.\n\t*/\n\tif (sdev->inq_periph_qual != 0)\n\t\treturn;\n\n\tif (vtarget == NULL)\n\t\treturn;\n\n\tvtarget->type = sdev->type;\n\n\tif ((sdev->type == TYPE_PROCESSOR) && (hd->ioc->spi_data.Saf_Te)) {\n\t\t/* Treat all Processors as SAF-TE if\n\t\t * command line option is set */\n\t\tvtarget->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED;\n\t\tmptspi_writeIOCPage4(hd, vtarget->channel, vtarget->id);\n\t}else if ((sdev->type == TYPE_PROCESSOR) &&\n\t\t!(vtarget->tflags & MPT_TARGET_FLAGS_SAF_TE_ISSUED )) {\n\t\tif (sdev->inquiry_len > 49 ) {\n\t\t\tif (sdev->inquiry[44] == 'S' &&\n\t\t\t sdev->inquiry[45] == 'A' &&\n\t\t\t sdev->inquiry[46] == 'F' &&\n\t\t\t sdev->inquiry[47] == '-' &&\n\t\t\t sdev->inquiry[48] == 'T' &&\n\t\t\t sdev->inquiry[49] == 'E' ) {\n\t\t\t\tvtarget->tflags |= MPT_TARGET_FLAGS_SAF_TE_ISSUED;\n\t\t\t\tmptspi_writeIOCPage4(hd, vtarget->channel, vtarget->id);\n\t\t\t}\n\t\t}\n\t}\n\tmptspi_setTargetNegoParms(hd, vtarget, sdev);\n}", "label": 0, "cwe": null, "length": 377 }, { "index": 88421, "code": "get_aliasf(int index, unsigned short ** fvec, FileMgr * af) {\n if ((index > 0) && (index <= numaliasf)) {\n *fvec = aliasf[index - 1];\n return aliasflen[index - 1];\n }\n HUNSPELL_WARNING(stderr, \"error: line %d: bad flag alias index: %d\\n\", af->getlinenum(), index);\n *fvec = NULL;\n return 0;\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 485800, "code": "historyNew( void ) {\n\tstruct sHistory *psRoot = NULL;\n\tstruct sHistory *psTemp;\n\tint nIndex;\n\n\tfor ( nIndex = 0; nIndex < 10; nIndex++ ) {\n\t\tpsTemp = psRoot;\n\t\tpsRoot = ( struct sHistory * ) malloc( sizeof( struct sHistory ) );\n\t\tpsRoot -> fValue = 0.0f;\n\t\tpsRoot -> psNext= psTemp;\n\t}\n\n\treturn psRoot;\n}", "label": 0, "cwe": null, "length": 98 }, { "index": 939395, "code": "CreateBackPointers() {\n DescriptorArray* descriptors = instance_descriptors();\n for (int i = 0; i < descriptors->number_of_descriptors(); i++) {\n if (descriptors->GetType(i) == MAP_TRANSITION ||\n descriptors->GetType(i) == ELEMENTS_TRANSITION ||\n descriptors->GetType(i) == CONSTANT_TRANSITION) {\n // Get target.\n Map* target = Map::cast(descriptors->GetValue(i));\n#ifdef DEBUG\n // Verify target.\n Object* source_prototype = prototype();\n Object* target_prototype = target->prototype();\n ASSERT(source_prototype->IsJSObject() ||\n source_prototype->IsMap() ||\n source_prototype->IsNull());\n ASSERT(target_prototype->IsJSObject() ||\n target_prototype->IsNull());\n ASSERT(source_prototype->IsMap() ||\n source_prototype == target_prototype);\n#endif\n // Point target back to source. set_prototype() will not let us set\n // the prototype to a map, as we do here.\n *RawField(target, kPrototypeOffset) = this;\n }\n }\n}", "label": 0, "cwe": null, "length": 239 }, { "index": 122496, "code": "bcm_sysport_suspend_to_wol(struct bcm_sysport_priv *priv)\n{\n\tstruct net_device *ndev = priv->netdev;\n\tunsigned int timeout = 1000;\n\tu32 reg;\n\n\t/* Password has already been programmed */\n\treg = umac_readl(priv, UMAC_MPD_CTRL);\n\treg |= MPD_EN;\n\treg &= ~PSW_EN;\n\tif (priv->wolopts & WAKE_MAGICSECURE)\n\t\treg |= PSW_EN;\n\tumac_writel(priv, reg, UMAC_MPD_CTRL);\n\n\t/* Make sure RBUF entered WoL mode as result */\n\tdo {\n\t\treg = rbuf_readl(priv, RBUF_STATUS);\n\t\tif (reg & RBUF_WOL_MODE)\n\t\t\tbreak;\n\n\t\tudelay(10);\n\t} while (timeout-- > 0);\n\n\t/* Do not leave the UniMAC RBUF matching only MPD packets */\n\tif (!timeout) {\n\t\treg = umac_readl(priv, UMAC_MPD_CTRL);\n\t\treg &= ~MPD_EN;\n\t\tumac_writel(priv, reg, UMAC_MPD_CTRL);\n\t\tnetif_err(priv, wol, ndev, \"failed to enter WOL mode\\n\");\n\t\treturn -ETIMEDOUT;\n\t}\n\n\t/* UniMAC receive needs to be turned on */\n\tumac_enable_set(priv, CMD_RX_EN, 1);\n\n\t/* Enable the interrupt wake-up source */\n\tintrl2_0_mask_clear(priv, INTRL2_0_MPD);\n\n\tnetif_dbg(priv, wol, ndev, \"entered WOL mode\\n\");\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 334 }, { "index": 976409, "code": "describe_pointer (GCObject *obj)\n{\n\tHashEntry *entry;\n\tint i;\n\n\tfor (i = 0; i < dyn_array_ptr_size (®istered_bridges); ++i) {\n\t\tif (obj == dyn_array_ptr_get (®istered_bridges, i)) {\n\t\t\tprintf (\"Pointer is a registered bridge object.\\n\");\n\t\t\tbreak;\n\t\t}\n\t}\n\n\tentry = (HashEntry *)sgen_hash_table_lookup (&hash_table, obj);\n\tif (!entry)\n\t\treturn;\n\n\tprintf (\"Bridge hash table entry %p:\\n\", entry);\n\tprintf (\" is bridge: %d\\n\", (int)entry->is_bridge);\n\tprintf (\" is visited: %d\\n\", (int)entry->v.dfs1.is_visited);\n}", "label": 0, "cwe": null, "length": 158 }, { "index": 233824, "code": "konami_set_context(void *src)\r\n{\r\n\tif( src )\r\n\t\tkonami = *(konami_Regs*)src;\r\n change_pc16(PC); /* TS 971002 */\r\n\r\n CHECK_IRQ_LINES;\r\n}", "label": 0, "cwe": null, "length": 46 }, { "index": 597745, "code": "init_seq_order(data *d) {\n const int seq_num = d->seqs.seqnum;\n int i;\n XMALLOC(d->seq_order, seq_num);\n for (i = 0; i < seq_num; ++i)\n d->seq_order[i] = i;\n}", "label": 0, "cwe": null, "length": 64 }, { "index": 360064, "code": "addPartTo(PartsBinPaletteWidget* bin, ModelPart* mp, bool setDirty) {\n\tif(mp) {\n\t\tbool alreadyIn = bin->contains(mp->moduleID());\n\t\tbin->addPart(mp);\n\t\tif(!alreadyIn && setDirty) {\n\t\t\tsetDirtyTab(bin,true);\n\t\t}\n\t}\n}", "label": 0, "cwe": null, "length": 70 }, { "index": 59556, "code": "export_png\n\t(\n\tconst char *fname,\t\t// File to write out.\n\tImage_buffer8& img,\t\t// Image.\n\tint xoff, int yoff\t\t// Offset (from bottom-right).\n\t)\n\t{\n\tunsigned char pal[3*256];\t// Set up palette.\n\tGet_rgb_palette(palette, pal);\n\tint w = img.get_width(), h = img.get_height();\n\tstruct stat fs;\t\t\t// Write out to the .png.\n\t\t\t\t\t// (Rotate transp. pixel to 0 for the\n\t\t\t\t\t// Gimp's sake.)\n\tif (!Export_png8(fname, transp, w, h, w, xoff, yoff, img.get_bits(),\n\t\t\t\t\t&pal[0], 256, true) ||\n\t stat(fname, &fs) != 0)\n\t\t{\n\t\tAlert(\"Error creating '%s'\", fname);\n\t\treturn 0;\n\t\t}\n\treturn fs.st_mtime;\n\t}", "label": 0, "cwe": null, "length": 202 }, { "index": 558989, "code": "movingOnChest( GenericLord * movingLord, GenericCell * destCell )\n{\n\tTRACE(\"Engine::movingOnChest\");\n\n\tGenericEvent * event = destCell->getEvent();\n\n\t_question->setLord( movingLord );\n\t_question->setType( C_QR_CHEST );\n\t_server->sendAskChest(_currentPlayer);\n\t_state = IN_QUESTION;\n\tdestCell->setEvent( 0 );\n\t_server->delEvent( _players, event );\n\tremoveEvent( event );\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 22012, "code": "ca_file_save_as (gchar *new_file_name)\n{\n\tgchar * initial_file = g_strdup(gnomint_current_opened_file);\n\tGMappedFile *map = NULL;\n\n\tca_file_close ();\n\n\tif (! (map = g_mapped_file_new (initial_file, FALSE, NULL))) {\n ca_file_open (gnomint_current_opened_file, FALSE);\n\t\treturn FALSE;\n }\n\n\tif (! g_file_set_contents (new_file_name, \n\t\t\t\t g_mapped_file_get_contents (map),\n\t\t\t\t g_mapped_file_get_length (map),\n\t\t\t\t NULL)) {\n\t\tg_mapped_file_free (map);\n ca_file_open (gnomint_current_opened_file, FALSE);\n\t\treturn FALSE;\n\t}\n\n\tg_mapped_file_free (map);\n\n\tg_free (initial_file);\n\n\treturn ca_file_open (new_file_name, FALSE);\n\n}", "label": 0, "cwe": null, "length": 170 }, { "index": 150390, "code": "reduced_hw_prim( struct gl_context *ctx, GLuint prim)\n{\n switch (prim) {\n case GL_POINTS:\n return ((!ctx->Point.SmoothFlag) ?\n\t R200_VF_PRIM_POINT_SPRITES : R200_VF_PRIM_POINTS);\n case GL_LINES:\n /* fallthrough */\n case GL_LINE_LOOP:\n /* fallthrough */\n case GL_LINE_STRIP:\n return R200_VF_PRIM_LINES;\n default:\n /* all others reduced to triangles */\n return R200_VF_PRIM_TRIANGLES;\n }\n}", "label": 0, "cwe": null, "length": 114 }, { "index": 346802, "code": "sfmap_cmp(void *a, void *b)\n{\n subfont_map_entry *sa = a, *sb = b;\n glyph ga = sa->subfont->vector[sa->position];\n glyph gb = sb->subfont->vector[sb->position];\n\n if (ga < gb) return -1;\n if (ga > gb) return 1;\n return 0;\n}", "label": 0, "cwe": null, "length": 86 }, { "index": 178009, "code": "fill_event_metadata(struct fsnotify_group *group,\n\t\t\t struct fanotify_event_metadata *metadata,\n\t\t\t struct fsnotify_event *fsn_event,\n\t\t\t struct file **file)\n{\n\tint ret = 0;\n\tstruct fanotify_event_info *event;\n\n\tpr_debug(\"%s: group=%p metadata=%p event=%p\\n\", __func__,\n\t\t group, metadata, fsn_event);\n\n\t*file = NULL;\n\tevent = container_of(fsn_event, struct fanotify_event_info, fse);\n\tmetadata->event_len = FAN_EVENT_METADATA_LEN;\n\tmetadata->metadata_len = FAN_EVENT_METADATA_LEN;\n\tmetadata->vers = FANOTIFY_METADATA_VERSION;\n\tmetadata->reserved = 0;\n\tmetadata->mask = fsn_event->mask & FAN_ALL_OUTGOING_EVENTS;\n\tmetadata->pid = pid_vnr(event->tgid);\n\tif (unlikely(fsn_event->mask & FAN_Q_OVERFLOW))\n\t\tmetadata->fd = FAN_NOFD;\n\telse {\n\t\tmetadata->fd = create_fd(group, event, file);\n\t\tif (metadata->fd < 0)\n\t\t\tret = metadata->fd;\n\t}\n\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 242 }, { "index": 386286, "code": "LoadFile( const std::string& filename )\r\n{\r\n\t// Delete the existing data:\r\n\tClear();\r\n\t\r\n\t// Load the new data:\r\n\tFILE* fp = fopen( filename.c_str(), \"r\" );\r\n\tif ( fp )\r\n\t{\r\n\t\tunsigned size;\r\n\t\tfseek( fp, 0, SEEK_END );\r\n\t\tsize = ftell( fp );\r\n\t\tfseek( fp, 0, SEEK_SET );\r\n\r\n\t\tchar* buf = new char[size+1];\r\n\t\tchar* p = buf;\r\n\t\twhile( fgets( p, size, fp ) )\r\n\t\t{\r\n\t\t\tp = strchr( p, 0 );\r\n\t\t}\r\n\t\tfclose( fp );\r\n\t\t\r\n\t\tParse( buf );\r\n\t\tdelete [] buf;\r\n\r\n\t\tif ( !Error() )\r\n\t\t\treturn true;\r\n\t}\r\n\telse\r\n\t{\r\n\t\tSetError( TIXML_ERROR_OPENING_FILE );\r\n\t}\r\n\treturn false;\r\n}", "label": 0, "cwe": null, "length": 184 }, { "index": 1019050, "code": "tag_make_default_color(TAGSTRING *buf, int maxlen)\n{\n\tif (maxlen <= (signed)sizeof (ht_tag_color)) return tag_error(buf, maxlen);\n\tht_tag_color tag;\n\ttag.escape = '\\e';\n\ttag.magic = HT_TAG_COLOR;\n\ttag.color = 0xffffffffU;\n\ttag.flush(buf);\n\treturn buf + sizeof(tag);\n}", "label": 0, "cwe": null, "length": 73 }, { "index": 53701, "code": "syck_add_sym( SyckParser *p, void *data )\n{\n SYMID id = 0;\n if ( p->syms == NULL )\n {\n p->syms = st_init_numtable();\n }\n id = p->syms->num_entries + 1;\n st_insert( p->syms, id, (st_data_t)data );\n return (int)id;\n}", "label": 0, "cwe": null, "length": 90 }, { "index": 158671, "code": "bpck_test_port ( PIA *pi ) \t/* check for 8-bit port */\n\n{\tint\ti, r, m;\n\n\tw2(0x2c); i = r0(); w0(255-i); r = r0(); w0(i);\n\tm = -1;\n\tif (r == i) m = 2;\n\tif (r == (255-i)) m = 0;\n\n\tw2(0xc); i = r0(); w0(255-i); r = r0(); w0(i);\n\tif (r != (255-i)) m = -1;\n\t\n\tif (m == 0) { w2(6); w2(0xc); r = r0(); w0(0xaa); w0(r); w0(0xaa); }\n\tif (m == 2) { w2(0x26); w2(0xc); }\n\n\tif (m == -1) return 0;\n\treturn 5;\n}", "label": 0, "cwe": null, "length": 205 }, { "index": 837604, "code": "in_cksum(const u_short *addr, register u_int len, int csum)\n{\n\tint nleft = len;\n\tconst u_short *w = addr;\n\tu_short answer;\n\tint sum = csum;\n\n\t/*\n\t * Our algorithm is simple, using a 32 bit accumulator (sum),\n\t * we add sequential 16 bit words to it, and at the end, fold\n\t * back all the carry bits from the top 16 bits into the lower\n\t * 16 bits.\n\t */\n\twhile (nleft > 1) {\n\t\tsum += *w++;\n\t\tnleft -= 2;\n\t}\n\tif (nleft == 1)\n\t\tsum += htons(*(u_char *)w<<8);\n\n\t/*\n\t * add back carry outs from top 16 bits to low 16 bits\n\t */\n\tsum = (sum >> 16) + (sum & 0xffff);\t/* add hi 16 to low 16 */\n\tsum += (sum >> 16);\t\t\t/* add carry */\n\tanswer = ~sum;\t\t\t\t/* truncate to 16 bits */\n\treturn (answer);\n}", "label": 0, "cwe": null, "length": 236 }, { "index": 690441, "code": "kcmss_close(krb5_context context,\n\t krb5_ccache id)\n{\n kcm_ccache c = KCMCACHE(id);\n\n KCM_ASSERT_VALID(c);\n\n id->data.data = NULL;\n id->data.length = 0;\n\n return 0;\n}", "label": 0, "cwe": null, "length": 61 }, { "index": 361855, "code": "Load(std::string fn)\n{\n std::fstream fh;\n fh.open(fn.c_str(),std::ios_base::in | std::ios_base::binary);\n if(!fh.is_open())\n return false;\n uint32 fs = GetFileSize(fn.c_str());\n ByteBuffer bb(fs);\n bb.resize(fs);\n fh.read((char*)bb.contents(),fs);\n fh.close();\n bb.rpos(0);\n return LoadMem(bb);\n}", "label": 0, "cwe": null, "length": 96 }, { "index": 510369, "code": "multipath_reschedule_retry (struct multipath_bh *mp_bh)\n{\n\tunsigned long flags;\n\tstruct mddev *mddev = mp_bh->mddev;\n\tstruct mpconf *conf = mddev->private;\n\n\tspin_lock_irqsave(&conf->device_lock, flags);\n\tlist_add(&mp_bh->retry_list, &conf->retry_list);\n\tspin_unlock_irqrestore(&conf->device_lock, flags);\n\tmd_wakeup_thread(mddev->thread);\n}", "label": 0, "cwe": null, "length": 93 }, { "index": 239988, "code": "func_clock_think (edict_t * self)\n{\n if (!self->enemy)\n {\n self->enemy = G_Find (NULL, FOFS (targetname), self->target);\n if (!self->enemy)\n\treturn;\n }\n\n if (self->spawnflags & 1)\n {\n func_clock_format_countdown (self);\n self->health++;\n }\n else if (self->spawnflags & 2)\n {\n func_clock_format_countdown (self);\n self->health--;\n }\n else\n {\n struct tm *ltime;\n time_t gmtime;\n\n time (&gmtime);\n ltime = localtime (&gmtime);\n Com_sprintf (self->message, CLOCK_MESSAGE_SIZE, \"%2i:%2i:%2i\",\n\t\t ltime->tm_hour, ltime->tm_min, ltime->tm_sec);\n if (self->message[3] == ' ')\n\tself->message[3] = '0';\n if (self->message[6] == ' ')\n\tself->message[6] = '0';\n }\n\n self->enemy->message = self->message;\n self->enemy->use (self->enemy, self, self);\n\n if (((self->spawnflags & 1) && (self->health > self->wait)) ||\n ((self->spawnflags & 2) && (self->health < self->wait)))\n {\n if (self->pathtarget)\n\t{\n\t char *savetarget;\n\t char *savemessage;\n\n\t savetarget = self->target;\n\t savemessage = self->message;\n\t self->target = self->pathtarget;\n\t self->message = NULL;\n\t G_UseTargets (self, self->activator);\n\t self->target = savetarget;\n\t self->message = savemessage;\n\t}\n\n if (!(self->spawnflags & 8))\n\treturn;\n\n func_clock_reset (self);\n\n if (self->spawnflags & 4)\n\treturn;\n }\n\n self->nextthink = level.time + 1;\n}", "label": 0, "cwe": null, "length": 445 }, { "index": 53777, "code": "getincdecexpr(void)\n{\n\tint type;\n\tint tok;\n\n\ttype = getterm();\n\ttok = gettoken();\n\tif (tok == T_PLUSPLUS || tok == T_MINUSMINUS) {\n\t\tif (isrvalue(type))\n\t\t\t\tscanerror(T_NULL, \"Bad ++ usage\");\n\t\twriteindexop();\n\t\tif (tok == T_PLUSPLUS)\n\t\t\taddop(OP_POSTINC);\n\t\telse\n\t\t\taddop(OP_POSTDEC);\n\t\tfor (;;) {\n\t\t\ttok = gettoken();\n\t\t\tswitch(tok) {\n\t\t\tcase T_PLUSPLUS:\n\t\t\t\taddop(OP_PREINC);\n\t\t\t\tcontinue;\n\t\t\tcase T_MINUSMINUS:\n\t\t\t\taddop(OP_PREDEC);\n\t\t\t\tcontinue;\n\t\t\tdefault:\n\t\t\t\taddop(OP_POP);\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tbreak;\n\t\t}\n\t\ttype = EXPR_RVALUE | EXPR_ASSIGN;\n\t}\n\tif (tok == T_NOT) {\n\t\taddopfunction(OP_CALL, getbuiltinfunc(\"fact\"), 1);\n\t\ttok = gettoken();\n\t\ttype = EXPR_RVALUE;\n\t}\n\trescantoken();\n\treturn type;\n}", "label": 0, "cwe": null, "length": 225 }, { "index": 124161, "code": "free_abbrevs (struct backtrace_state *state, struct abbrevs *abbrevs,\n\t backtrace_error_callback error_callback, void *data)\n{\n size_t i;\n\n for (i = 0; i < abbrevs->num_abbrevs; ++i)\n backtrace_free (state, abbrevs->abbrevs[i].attrs,\n\t\t abbrevs->abbrevs[i].num_attrs * sizeof (struct attr),\n\t\t error_callback, data);\n backtrace_free (state, abbrevs->abbrevs,\n\t\t abbrevs->num_abbrevs * sizeof (struct abbrev),\n\t\t error_callback, data);\n abbrevs->num_abbrevs = 0;\n abbrevs->abbrevs = NULL;\n}", "label": 0, "cwe": null, "length": 152 }, { "index": 190034, "code": "string_prop (const char *name, const char *value)\n{\n SmProp *prop;\n\n prop = g_new (SmProp, 1);\n prop->name = (char *)name;\n prop->type = SmARRAY8;\n\n prop->num_vals = 1;\n prop->vals = g_new (SmPropValue, 1);\n\n prop->vals[0].length = strlen (value);\n prop->vals[0].value = (char *)value;\n\n return prop;\n}", "label": 0, "cwe": null, "length": 108 }, { "index": 69399, "code": "rot_inverse(wrap)\n WRAPTYPE wrap; /* the element to invert */\n {\n rot_new_order();\n return stdwrap(-wrap);\n }", "label": 0, "cwe": null, "length": 32 }, { "index": 50608, "code": "measureStyle(QString name)\n{\n PointSet* pointSet = findMeasure(name);\n ASSERT_ENGAUGE(pointSet != 0);\n return pointSet->style();\n}", "label": 1, "cwe": "CWE-476", "length": 37 }, { "index": 733608, "code": "hx509_verify_attach_revoke(hx509_verify_ctx ctx, hx509_revoke_ctx revoke_ctx)\n{\n if (ctx->revoke_ctx)\n\thx509_revoke_free(&ctx->revoke_ctx);\n ctx->revoke_ctx = _hx509_revoke_ref(revoke_ctx);\n}", "label": 0, "cwe": null, "length": 63 }, { "index": 309816, "code": "getPrefsValueBool(const gchar * szKey, bool * pbValue, bool bAllowBuiltin) const\n{\n\t// a convenient routine to get a name/value pair from the current scheme\n\n\tUT_return_val_if_fail(m_currentScheme,false);\n\n\tif (m_currentScheme->getValueBool(szKey,pbValue))\n\t\treturn true;\n\tif (bAllowBuiltin && m_builtinScheme->getValueBool(szKey,pbValue))\n\t\treturn true;\n\t// It is legal for there to be arbitrary preference tags that start with \n\t// \"Debug\", and Abi apps won't choke. The idea is that developers can use\n\t// these to selectively trigger development-time behaviors.\n\tif (g_ascii_strncasecmp(szKey, DEBUG_PREFIX, sizeof(DEBUG_PREFIX) - 1) == 0)\n\t{\n\t\t*pbValue = false;\n\t\treturn true;\n\t}\n\n\treturn false;\n}", "label": 0, "cwe": null, "length": 187 }, { "index": 337246, "code": "first() const\n{\n return KBookmark( nextKnownTag( element.firstChildElement(), true ) );\n}", "label": 0, "cwe": null, "length": 23 }, { "index": 345385, "code": "_e_fm2_client_message_queue(int major, int minor, int ref, int ref_to, int response, const void *data, int size)\n{\n E_Fm2_Message *msg;\n\n msg = E_NEW(E_Fm2_Message, 1);\n if (!msg) return;\n msg->major = major;\n msg->minor = minor;\n msg->ref = ref;\n msg->ref_to = ref_to;\n msg->response = response;\n if (data)\n {\n msg->size = size;\n msg->data = malloc(size);\n if (msg->data)\n memcpy(msg->data, data, size);\n else\n {\n free(msg);\n return;\n }\n }\n _e_fm2_messages = eina_list_append(_e_fm2_messages, msg);\n}", "label": 1, "cwe": [ "CWE-120", "CWE-469", "CWE-other" ], "length": 174 }, { "index": 163897, "code": "popdown_find_dialog(void)\n{\n int i;\n \n for(i=0; i 0.0) ? true : false);\n\telse\n\t\treturn ((inc < 0.0) ? true : false);\n}", "label": 0, "cwe": null, "length": 52 }, { "index": 755144, "code": "clear()\r\n{\r\n\tItems.clear();\r\n\tItemsIconWidth = 0;\r\n\tSelected = -1;\r\n\r\n\tif (ScrollBar)\r\n\t\tScrollBar->setPos(0);\r\n\r\n\trecalculateItemHeight();\r\n}", "label": 0, "cwe": null, "length": 41 }, { "index": 1010326, "code": "closeTestMethod(const svUnitTest::svutTestCase& /*testCase*/, const svUnitTest::svutTestMethod& /*meth*/, const svUnitTest::svutStatusInfo& status)\n{\n\tstring statusLower = status.getStatusName();\n\tstd::transform(statusLower.begin(), statusLower.end(), statusLower.begin(), ::tolower);\n\t*out << \"\\t\\t\\t\" << endl;\n\tif (status.getStatus() != SVUT_STATUS_SUCCESS && status.getStatus() != SVUT_STATUS_SKIPED)\n\t\tthis->printAssertInfo(status);\n\t*out << \"\\t\\t\\t\" << setprecision(2) << (unsigned long)(status.getDuration() * 1000000.0) << \"\" << endl;\n\t*out << \"\\t\\t\" << endl;\n}", "label": 0, "cwe": null, "length": 168 }, { "index": 149618, "code": "fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int zero)\n{\n\tstruct sonet_stats tmp;\n \tint error = 0;\n\n\tatomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);\n\tsonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);\n\tif (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));\n\tif (zero && !error) {\n\t\t/* unused fields are reported as -1, but we must not \"adjust\"\n\t\t them */\n\t\ttmp.corr_hcs = tmp.tx_cells = tmp.rx_cells = 0;\n\t\tsonet_subtract_stats(&PRIV(dev)->sonet_stats,&tmp);\n\t}\n\treturn error ? -EFAULT : 0;\n}", "label": 0, "cwe": null, "length": 164 }, { "index": 203913, "code": "sge_basename(const char *name, int delim) \n{\n char *cp;\n\n DENTER(BASIS_LAYER, \"sge_basename\");\n\n if (!name) {\n DRETURN(NULL);\n }\n if (name[0] == '\\0') {\n DRETURN(NULL);\n }\n \n cp = strrchr(name, delim);\n if (!cp) {\n DRETURN(name); \n } else {\n cp++;\n if (*cp == '\\0') {\n DRETURN(NULL);\n }\n else {\n DRETURN(cp);\n }\n }\n}", "label": 0, "cwe": null, "length": 122 }, { "index": 875576, "code": "construct(PyObject* obj, \n python::converter::rvalue_from_python_stage1_data* data)\n {\n void* const storage = \n ((python::converter::rvalue_from_python_storage* ) data)->storage.bytes;\n\n // FIXME: there should be a more elegant way to program this...\n int typeID = -1;\n if(obj->ob_type == &PyArrayDescr_Type)\n typeID = (NPY_TYPES)((PyArray_Descr*)obj)->type_num;\n VIGRA_NUMPY_TYPECONVERTER(NPY_BOOL)\n VIGRA_NUMPY_TYPECONVERTER(NPY_INT8)\n VIGRA_NUMPY_TYPECONVERTER(NPY_UINT8)\n VIGRA_NUMPY_TYPECONVERTER(NPY_INT16)\n VIGRA_NUMPY_TYPECONVERTER(NPY_UINT16)\n VIGRA_NUMPY_TYPECONVERTER(NPY_INT32)\n VIGRA_NUMPY_TYPECONVERTER(NPY_UINT32)\n VIGRA_NUMPY_TYPECONVERTER(NPY_INT)\n VIGRA_NUMPY_TYPECONVERTER(NPY_UINT)\n VIGRA_NUMPY_TYPECONVERTER(NPY_INT64) \n VIGRA_NUMPY_TYPECONVERTER(NPY_UINT64)\n VIGRA_NUMPY_TYPECONVERTER(NPY_FLOAT32)\n VIGRA_NUMPY_TYPECONVERTER(NPY_FLOAT64)\n VIGRA_NUMPY_TYPECONVERTER(NPY_LONGDOUBLE)\n VIGRA_NUMPY_TYPECONVERTER(NPY_CFLOAT)\n VIGRA_NUMPY_TYPECONVERTER(NPY_CDOUBLE)\n VIGRA_NUMPY_TYPECONVERTER(NPY_CLONGDOUBLE)\n\n new (storage) NPY_TYPES((NPY_TYPES)typeID);\n\n data->convertible = storage;\n }", "label": 0, "cwe": null, "length": 389 }, { "index": 150358, "code": "dglHeapFree(dglHeap_s * pheap, dglHeapCancelItem_fn pfnCancelItem)\n{\n int iItem;\n\n if (pheap->pnode) {\n\tif (pfnCancelItem) {\n\t for (iItem = 0; iItem <= pheap->index; iItem++) {\n\t\tpfnCancelItem(pheap, &pheap->pnode[iItem]);\n\t }\n\t}\n\tfree(pheap->pnode);\n }\n pheap->pnode = NULL;\n}", "label": 0, "cwe": null, "length": 109 }, { "index": 754858, "code": "neural_apply_sanitize_args(NeuralApplyArgs *args)\n{\n if (!gwy_inventory_get_item(gwy_neural_networks(), args->name)) {\n g_free(args->name);\n args->name = g_strdup(GWY_NEURAL_NETWORK_UNTITLED);\n }\n args->scale_output = !!args->scale_output;\n}", "label": 0, "cwe": null, "length": 76 }, { "index": 859608, "code": "start_packet(struct r8a66597_ep *ep, struct r8a66597_request *req)\n{\n\tif (ep->ep.desc->bEndpointAddress & USB_DIR_IN)\n\t\tstart_packet_write(ep, req);\n\telse\n\t\tstart_packet_read(ep, req);\n}", "label": 0, "cwe": null, "length": 58 }, { "index": 187830, "code": "lis3lv02d_poweroff(struct lis3lv02d *lis3)\n{\n\tif (lis3->reg_ctrl)\n\t\tlis3_context_save(lis3);\n\t/* disable X,Y,Z axis and power down */\n\tlis3->write(lis3, CTRL_REG1, 0x00);\n\tif (lis3->reg_ctrl)\n\t\tlis3->reg_ctrl(lis3, LIS3_REG_OFF);\n}", "label": 0, "cwe": null, "length": 91 }, { "index": 88365, "code": "MatchPortName(const char* name, const char** ports, int alias, const std::string& type)\n{\n char alias1[REAL_JACK_PORT_NAME_SIZE];\n char alias2[REAL_JACK_PORT_NAME_SIZE];\n char* aliases[2];\n \n aliases[0] = alias1;\n aliases[1] = alias2;\n \n for (int i = 0; ports && ports[i]; ++i) {\n \n jack_port_id_t port_id2 = fGraphManager->GetPort(ports[i]);\n JackPort* port2 = (port_id2 != NO_PORT) ? fGraphManager->GetPort(port_id2) : NULL;\n \n if (port2) {\n int res = port2->GetAliases(aliases);\n string name_str;\n if (res >= alias) {\n name_str = string(aliases[alias-1]);\n } else {\n name_str = string(ports[i]);\n }\n string sub_name = RemoveLast(name);\n if ((name_str.find(sub_name) != string::npos) && (type == string(port2->GetType()))) {\n return name_str;\n }\n }\n }\n \n return \"\";\n}", "label": 0, "cwe": null, "length": 253 }, { "index": 290767, "code": "start_operation(void)\n{\n // ---\n DBC_REQUIRE(is_prepared() == true);\n DBC_REQUIRE(is_running() != true);\n // ---\n\n ECA_LOG_MSG(ECA_LOGGER::system_objects, \"starting engine operation!\");\n\n start_realtime_objects();\n running_rep = true;\n\n // ---\n DBC_ENSURE(is_running() == true);\n DBC_ENSURE(status() == ECA_ENGINE::engine_status_running);\n // ---\n}", "label": 0, "cwe": null, "length": 95 }, { "index": 256589, "code": "SQLITE3_qnext(CTX ctx, kqcur_t *qcur, struct kResultSet *rs)\n{\n\tsqlite3_stmt *stmt = (sqlite3_stmt*)qcur;\n\tint r = sqlite3_step(stmt);\n\tif(SQLITE_ROW == r) {\n\t\tsize_t i;\n\t\tknh_ResultSet_initData(ctx, rs);\n\t\tfor(i = 0; i < DP(rs)->column_size; i++) {\n\t\t\tint type = sqlite3_column_type(stmt, i);\n\t\t\tswitch(type) {\n\t\t\t\tcase SQLITE_INTEGER: {\n\t\t\t\t\tResultSet_setInt(ctx, rs, i, (kint_t)sqlite3_column_int64(stmt, i));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase SQLITE_FLOAT: {\n\t\t\t\t\tResultSet_setFloat(ctx, rs, i, (kfloat_t)sqlite3_column_double(stmt, i));\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase SQLITE_TEXT: {\n\t\t\t\t\tkbytes_t t = {{(const char*)sqlite3_column_text(stmt,i)}, sqlite3_column_bytes(stmt, i)};\n\t\t\t\t\tResultSet_setText(ctx, rs, i, t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase SQLITE_BLOB: {\n\t\t\t\t\tkbytes_t t = {{(const char*)sqlite3_column_blob(stmt,i)}, sqlite3_column_bytes(stmt, i)};\n\t\t\t\t\tResultSet_setBlob(ctx, rs, i, t);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tcase SQLITE_NULL:\n\t\t\t\tdefault: {\n\t\t\t\t\tResultSet_setNULL(ctx, rs, i);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn 1;\n\t}\n\telse if (r != SQLITE_DONE) {\n\t //\n\t}\n\treturn 0; /* NOMORE */\n}", "label": 0, "cwe": null, "length": 337 }, { "index": 878784, "code": "grow21_line(uint8_t *dst, const uint8_t *src,\n int width)\n{\n int w;\n const uint8_t *s1;\n uint8_t *d;\n\n s1 = src;\n d = dst;\n for(w = width;w >= 4; w-=4) {\n d[1] = d[0] = s1[0];\n d[3] = d[2] = s1[1];\n s1 += 2;\n d += 4;\n }\n for(;w >= 2; w -= 2) {\n d[1] = d[0] = s1[0];\n s1 ++;\n d += 2;\n }\n /* only needed if width is not a multiple of two */\n /* XXX: veryfy that */\n if (w) {\n d[0] = s1[0];\n }\n}", "label": 0, "cwe": null, "length": 199 }, { "index": 361677, "code": "nm_connection_editor_update_connection (NMConnectionEditor *editor)\n{\n\tNMSettingConnection *s_con;\n\tGHashTable *settings;\n\tgboolean everyone = FALSE;\n\tGError *error = NULL;\n\n\tg_return_val_if_fail (NM_IS_CONNECTION_EDITOR (editor), FALSE);\n\n\tif (!nm_connection_verify (editor->connection, &error)) {\n\t\t/* In theory, this cannot happen: the \"Save...\" button should only\n\t\t * be sensitive if the connection is valid.\n\t\t */\n\t\tnm_connection_editor_error (GTK_WINDOW (editor->window),\n\t\t _(\"Error saving connection\"),\n\t\t _(\"The property '%s' / '%s' is invalid: %d\"),\n\t\t g_type_name (nm_connection_lookup_setting_type_by_quark (error->domain)),\n\t\t error->message, error->code);\n\t\tg_error_free (error);\n\t\treturn FALSE;\n\t}\n\n\t/* Update secret flags at the end after all other settings have updated,\n\t * otherwise the secret flags we set here might be overwritten during\n\t * setting validation.\n\t */\n\ts_con = nm_connection_get_setting_connection (editor->connection);\n\teveryone = !nm_setting_connection_get_num_permissions (s_con);\n\tnm_connection_for_each_setting_value (editor->connection, update_secret_flags, GUINT_TO_POINTER (everyone));\n\n\t/* Copy the modified connection to the original connection */\n\tsettings = nm_connection_to_hash (editor->connection, NM_SETTING_HASH_FLAG_ALL);\n\tnm_connection_replace_settings (editor->orig_connection, settings, NULL);\n\tg_hash_table_destroy (settings);\n\n\treturn TRUE;\n}", "label": 0, "cwe": null, "length": 321 }, { "index": 816729, "code": "image_convert()\n{\n\n long source_length, i;\n char buf[2448];\n\n\n fseek (fsource, 0L, SEEK_END);\n source_length = (ftell (fsource) - img_offset) / img_size_sector;\n\n\n fseek (fsource, img_offset, SEEK_SET);\n\n {\n for (i = 0; i < source_length; i++)\n\n {\n main_percent(i*100/source_length);\n\n fseek (fsource, img_header, SEEK_CUR);\n if (fread (buf, sizeof (char), BLOCK_ISO_CD, fsource));\n\n else\n {\n fprintf (stderr, \"%s\\n\", strerror (errno));\n exit (EXIT_FAILURE);\n };\n if (fwrite (buf, sizeof (char), BLOCK_ISO_CD, fdest));\n\n else\n {\n fprintf (stderr, \"%s\\n\", strerror (errno));\n exit (EXIT_FAILURE);\n };\n fseek (fsource, img_ecc, SEEK_CUR);\n }\n }\n if (isatty(fileno(stderr)))\n fprintf (stderr, \"\\rDone \\n\");\n else\n fprintf (stderr, \" Done\\n\");\n return 0;\n}", "label": 1, "cwe": "CWE-other", "length": 252 }, { "index": 184043, "code": "nm_device_activate_ip4_state_in_wait (NMDevice *self)\n{\n\tg_return_val_if_fail (self != NULL, FALSE);\n\treturn NM_DEVICE_GET_PRIVATE (self)->ip4_state == IP_WAIT;\n}", "label": 0, "cwe": null, "length": 44 }, { "index": 698209, "code": "nodeListChunkRest(EvalContext &context, Interpreter &interp, bool &chunk)\n{\n for (;;) {\n NodePtr nd = nodeList_->nodeListFirst(context, interp);\n if (!nd)\n return interp.makeEmptyNodeList();\n if (nd->classDef().className == cls_)\n break;\n bool tem;\n nodeList_ = nodeList_->nodeListChunkRest(context, interp, tem);\n }\n NodeListObj *tem = nodeList_->nodeListChunkRest(context, interp, chunk);\n ELObjDynamicRoot protect(interp, tem);\n return new (interp) SelectByClassNodeListObj(tem, cls_);\n}", "label": 0, "cwe": null, "length": 135 }, { "index": 407161, "code": "already_tried (ghoststruct *g, int x, int y)\n{\n int i = 0;\n if (! ( 0 <= g->trace_idx && g->trace_idx < GHOST_TRACE ) ){\n fprintf(stderr, \"FOUND TRACE ERROR. DUMPING TRACE.\\n\");\n fprintf(stderr, \"%d\\n\", g->trace_idx );\n for ( i = 0; i < GHOST_TRACE; i++ ){\n fprintf(stderr, \"( %d, %d )\\n\", g->trace[i].vx, g->trace[i].vy );\n }\n assert ( False );\n }\n while (i < g->trace_idx){\n if ( x == g->trace[i].vx && y == g->trace[i].vy ){\n /* fprintf ( stderr, \"Match FOUND (%d, %d)\\n\", x, y); */\n return 1;\n }\n i++;\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 200 }, { "index": 791108, "code": "Result_free (T *old) {\n int i;\n Stage3end_T stage3;\n Stage3pair_T stage3pair;\n\n switch ((*old)->resulttype) {\n case SINGLEEND_NOMAPPING: case PAIREDEND_NOMAPPING: break;\n\n case SINGLEEND_UNIQ: case SINGLEEND_TRANSLOC: case SINGLEEND_MULT:\n for (i = 0; i < (*old)->npaths; i++) {\n stage3 = (*old)->array[i];\n Stage3end_free(&stage3);\n }\n FREE_OUT((*old)->array);\n break;\n\n case PAIRED_UNIQ: case PAIRED_MULT: case CONCORDANT_UNIQ: case CONCORDANT_TRANSLOC: case CONCORDANT_MULT:\n for (i = 0; i < (*old)->npaths; i++) {\n stage3pair = (*old)->array[i];\n Stage3pair_free(&stage3pair);\n }\n FREE_OUT((*old)->array);\n break;\n\n default:\n for (i = 0; i < (*old)->npaths2; i++) {\n stage3 = (*old)->array2[i];\n Stage3end_free(&stage3);\n }\n FREE_OUT((*old)->array2);\n\n for (i = 0; i < (*old)->npaths; i++) {\n stage3 = (*old)->array[i];\n Stage3end_free(&stage3);\n }\n FREE_OUT((*old)->array);\n }\n\n FREE_OUT(*old);\n\n return;\n}", "label": 0, "cwe": null, "length": 328 }, { "index": 122351, "code": "insert(node* node, int datum)\n{\n\tnode = top(node);\n\twhile (node != NULL)\n\t{\n\t\tif (datum < node->data)\n\t\t\tif (node->left == NULL)\n\t\t\t{\n\t\t\t\tif ( node->parent!=NULL && node->right==NULL && node->parent->right==NULL)\n\t\t\t\t{\n\t\t\t\t\tnode->parent->right=newNode(node->parent->data);\n\t\t\t\t\tnode->parent->data = node->data;\n\t\t\t\t\tnode->data = datum;\n\t\t\t\t\treturn node;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tnode->left = newNode(datum);\n\t\t\t\t\tnode->left->parent=node;\n\t\t\t\t\treturn node->left;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t\tnode = node->left;\n\n\t\telse if (datum > node->data)\n\t\t\tif (node->right == NULL)\n\t\t\t{\n\t\t\t\tif (node->parent!=NULL && node->left==NULL && node->parent->left==NULL)\n\t\t\t\t{\n\t\t\t\t\tnode->parent->left=newNode(node->parent->data);\n\t\t\t\t\tnode->parent->data = node->data;\n\t\t\t\t\tnode->data = datum;\n\t\t\t\t\treturn node;\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tnode->right = newNode(datum);\n\t\t\t\t\tnode->right->parent = node;\n\t\t\t\t\treturn node->right;\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t\tnode = node->right;\n\n\t\telse\n\t\t\treturn node;\n\t}\n}", "label": 0, "cwe": null, "length": 297 }, { "index": 310258, "code": "find_pending(pid_t pid) {\n LINK * l = pending_list.next;\n while (l != &pending_list) {\n Context * c = ctxl2ctxp(l);\n if (EXT(c)->pid == pid) {\n list_remove(&c->ctxl);\n return c;\n }\n l = l->next;\n }\n return NULL;\n}", "label": 0, "cwe": null, "length": 79 }, { "index": 89244, "code": "LocateAuthorities(const DNSMessage *const msg, const mDNSu8 *const end)\n\t{\n\tint i;\n\tconst mDNSu8 *ptr = LocateAnswers(msg, end);\n\tfor (i = 0; i < msg->h.numAnswers && ptr; i++) ptr = skipResourceRecord(msg, ptr, end);\n\treturn(ptr);\n\t}", "label": 0, "cwe": null, "length": 74 }, { "index": 71097, "code": "hwt_read(struct s_smc *smc)\n{\n\tu_short\ttr ;\n\tu_long\tis ;\n\n\tif (smc->hw.timer_activ) {\n\t\thwt_stop(smc) ;\n\t\ttr = (u_short)((inpd(ADDR(B2_TI_VAL))/200) & 0xffff) ;\n\n\t\tis = GET_ISR() ;\n\t\t/* Check if timer expired (or wraparound). */\n\t\tif ((tr > smc->hw.t_start) || (is & IS_TIMINT)) {\n\t\t\thwt_restart(smc) ;\n\t\t\tsmc->hw.t_stop = smc->hw.t_start ;\n\t\t}\n\t\telse\n\t\t\tsmc->hw.t_stop = smc->hw.t_start - tr ;\n\t}\n\treturn smc->hw.t_stop;\n}", "label": 0, "cwe": null, "length": 161 }, { "index": 46778, "code": "destructorImpl()\n{\n helpers::getLogLog().debug( DCMTK_LOG4CPLUS_TEXT(\"Destroying appender named [\")\n + name\n + DCMTK_LOG4CPLUS_TEXT(\"].\"));\n\n // An appender might be closed then destroyed. There is no\n // point in closing twice.\n if(closed)\n return;\n\n close();\n closed = true;\n}", "label": 0, "cwe": null, "length": 88 }, { "index": 89919, "code": "xmmsc_ipc_connect (xmmsc_ipc_t *ipc, char *path)\n{\n\tx_return_val_if_fail (ipc, false);\n\tx_return_val_if_fail (path, false);\n\n\tipc->transport = xmms_ipc_client_init (path);\n\tif (!ipc->transport) {\n\t\tipc->error = strdup (\"Could not init client!\");\n\t\treturn false;\n\t}\n\treturn true;\n}", "label": 0, "cwe": null, "length": 83 }, { "index": 354628, "code": "find_object_info(U8_T ID) {\n ObjectInfo * Info = find_object(sCache, ID);\n if (Info == NULL) {\n U4_T Hash = (U4_T)ID % OBJ_HASH_SIZE;\n if (ID < sDebugSection->addr + dio_gEntryPos) str_exception(ERR_INV_DWARF, \"Invalid entry reference\");\n Info = (ObjectInfo *)loc_alloc_zero(sizeof(ObjectInfo));\n Info->mHashNext = sCache->mObjectHash[Hash];\n sCache->mObjectHash[Hash] = Info;\n if (sObjectList == NULL) sObjectList = Info;\n else sObjectListTail->mListNext = Info;\n sObjectListTail = Info;\n Info->mID = ID;\n }\n return Info;\n}", "label": 0, "cwe": null, "length": 171 }, { "index": 668653, "code": "virtnet_set_channels(struct net_device *dev,\n\t\t\t\tstruct ethtool_channels *channels)\n{\n\tstruct virtnet_info *vi = netdev_priv(dev);\n\tu16 queue_pairs = channels->combined_count;\n\tint err;\n\n\t/* We don't support separate rx/tx channels.\n\t * We don't allow setting 'other' channels.\n\t */\n\tif (channels->rx_count || channels->tx_count || channels->other_count)\n\t\treturn -EINVAL;\n\n\tif (queue_pairs > vi->max_queue_pairs || queue_pairs == 0)\n\t\treturn -EINVAL;\n\n\tget_online_cpus();\n\terr = virtnet_set_queues(vi, queue_pairs);\n\tif (!err) {\n\t\tnetif_set_real_num_tx_queues(dev, queue_pairs);\n\t\tnetif_set_real_num_rx_queues(dev, queue_pairs);\n\n\t\tvirtnet_set_affinity(vi);\n\t}\n\tput_online_cpus();\n\n\treturn err;\n}", "label": 0, "cwe": null, "length": 187 }, { "index": 239296, "code": "GetALGOType(const char * type)\n{\n if(!type) return ALGOType_END;\n\n // Delete possible space as last character\n String<> str( type );\n str.Trim();\n\n const char * strClear = str.Trim().c_str();\n\n for(unsigned int i = 0; ALGOTypeStrings[i] != 0; ++i)\n {\n if( strcmp(strClear, ALGOTypeStrings[i]) == 0 )\n {\n return (ALGOType)i;\n }\n }\n // Ouch ! We did not find anything, that's pretty bad, let's hope that\n // the toolkit which wrote the image is buggy and tolerate space padded binary\n // string\n CodeString codestring = strClear;\n std::string cs = codestring.GetAsString();\n for(unsigned int i = 0; ALGOTypeStrings[i] != 0; ++i)\n {\n if( strcmp(cs.c_str(), ALGOTypeStrings[i]) == 0 )\n {\n return (ALGOType)i;\n }\n }\n\n return ALGOType_END;\n}", "label": 1, "cwe": "CWE-other", "length": 236 }, { "index": 67330, "code": "_gnutls_handshake_buffer_clear (gnutls_session_t session)\n{\n\n _gnutls_buffers_log (\"BUF[HSK]: Cleared Data from buffer\\n\");\n _gnutls_buffer_clear (&session->internals.handshake_hash_buffer);\n\n return 0;\n}", "label": 0, "cwe": null, "length": 60 }, { "index": 744301, "code": "length() const\n{\n\tunsigned long n = 0;\n\tNode* pCur = _pParent->firstChild();\n\twhile (pCur)\n\t{\n\t\t++n;\n\t\tpCur = pCur->nextSibling();\n\t}\n\treturn n;\n}", "label": 0, "cwe": null, "length": 53 }, { "index": 886303, "code": "explain_buffer_errno_getpgrp_explanation(explain_string_buffer_t *sb,\n int errnum, const char *syscall_name, pid_t pid)\n{\n /*\n * http://www.opengroup.org/onlinepubs/009695399/functions/getpgrp.html\n */\n switch (errnum)\n {\n case EINVAL:\n too_small:\n explain_buffer_einval_too_small(sb, \"pid\", pid);\n break;\n\n case ESRCH:\n if (pid < 0)\n goto too_small;\n explain_buffer_esrch(sb, \"pid\", pid);\n break;\n\n default:\n explain_buffer_errno_generic(sb, errnum, syscall_name);\n break;\n }\n}", "label": 0, "cwe": null, "length": 150 }, { "index": 59923, "code": "AddType( HFAType *poType )\n\n{\n if( nTypes == nTypesMax )\n {\n nTypesMax = nTypes * 2 + 10;\n papoTypes = (HFAType **) CPLRealloc( papoTypes,\n sizeof(void*) * nTypesMax );\n }\n\n papoTypes[nTypes++] = poType;\n}", "label": 0, "cwe": null, "length": 79 }, { "index": 77285, "code": "Integer_static_parseInt_0(JNIEnv *env , const char* p0 , jint p1 , jint* result, lList **alpp) {\n\n jgdi_result_t ret = JGDI_SUCCESS;\n static jmethodID mid = NULL; \n static jclass clazz = NULL;\n jstring p0_obj = NULL;\n jint temp = 0;\n\n DENTER(BASIS_LAYER, \"Integer_static_parseInt_0\");\n \n if (result == NULL ) {\n answer_list_add(alpp, \"result is NULL\", STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);\n DRETURN(JGDI_ILLEGAL_STATE);\n }\n /* We set the result always to the default value */\n *result = 0;\n \n if (mid == NULL) {\n if (JGDI_SUCCESS != get_static_method_id_for_fullClassname(env, &clazz, &mid, \"java/lang/Integer\", \"parseInt\", \"(Ljava/lang/String;I)I\", alpp)) {\n DRETURN(JGDI_ILLEGAL_STATE);\n }\n } if (p0 != NULL) {\n p0_obj = (*env)->NewStringUTF(env, p0); \n } temp = \n (*env)->CallStaticIntMethod(env, clazz, mid , p0_obj , p1 ); \n if (test_jni_error(env, \"Integer_parseInt_0 failed\", alpp)) {\n ret = JGDI_ILLEGAL_STATE;\n temp = 0; \n \n } else {\n \n *result = temp;\n \n }\n\n DRETURN(ret);\n}", "label": 0, "cwe": null, "length": 338 }, { "index": 272819, "code": "rfbssl_do_read(rfbClientPtr cl, char *buf, int bufsize)\n{\n struct rfbssl_ctx *ctx = (struct rfbssl_ctx *)cl->sslctx;\n int ret;\n\n while ((ret = gnutls_record_recv(ctx->session, buf, bufsize)) < 0) {\n\tif (ret == GNUTLS_E_AGAIN) {\n\t /* continue */\n\t} else if (ret == GNUTLS_E_INTERRUPTED) {\n\t /* continue */\n\t} else {\n\t break;\n\t}\n }\n\n if (ret < 0) {\n\trfbssl_error(__func__, ret);\n\terrno = EIO;\n\tret = -1;\n }\n\n return ret < 0 ? -1 : ret;\n}", "label": 0, "cwe": null, "length": 158 }, { "index": 311390, "code": "_hssl_superseed(void)\n{\n int buf[256], i;\n\n srand(time(NULL));\n\n for (i = 0; i < 256; i++)\n {\n buf[i] = rand();\n }\n RAND_seed((unsigned char *) buf, sizeof(buf));\n\n return;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120", "CWE-other" ], "length": 63 }, { "index": 184814, "code": "__tlb_remove_page(struct mmu_gather *tlb, struct page *page)\n{\n\tstruct mmu_gather_batch *batch;\n\n\tVM_BUG_ON(!tlb->end);\n\n\tbatch = tlb->active;\n\tbatch->pages[batch->nr++] = page;\n\tif (batch->nr == batch->max) {\n\t\tif (!tlb_next_batch(tlb))\n\t\t\treturn 0;\n\t\tbatch = tlb->active;\n\t}\n\tVM_BUG_ON_PAGE(batch->nr > batch->max, page);\n\n\treturn batch->max - batch->nr;\n}", "label": 0, "cwe": null, "length": 124 }, { "index": 372119, "code": "device_want_to_wakeup(struct hci_uart *hu)\n{\n\tunsigned long flags;\n\tstruct qca_data *qca = hu->priv;\n\n\tBT_DBG(\"hu %p want to wake up\", hu);\n\n\tspin_lock_irqsave(&qca->hci_ibs_lock, flags);\n\n\tqca->ibs_recv_wakes++;\n\n\tswitch (qca->rx_ibs_state) {\n\tcase HCI_IBS_RX_ASLEEP:\n\t\t/* Make sure clock is on - we may have turned clock off since\n\t\t * receiving the wake up indicator awake rx clock.\n\t\t */\n\t\tqueue_work(qca->workqueue, &qca->ws_awake_rx);\n\t\tspin_unlock_irqrestore(&qca->hci_ibs_lock, flags);\n\t\treturn;\n\n\tcase HCI_IBS_RX_AWAKE:\n\t\t/* Always acknowledge device wake up,\n\t\t * sending IBS message doesn't count as TX ON.\n\t\t */\n\t\tif (send_hci_ibs_cmd(HCI_IBS_WAKE_ACK, hu) < 0) {\n\t\t\tBT_ERR(\"Failed to acknowledge device wake up\");\n\t\t\tbreak;\n\t\t}\n\t\tqca->ibs_sent_wacks++;\n\t\tbreak;\n\n\tdefault:\n\t\t/* Any other state is illegal */\n\t\tBT_ERR(\"Received HCI_IBS_WAKE_IND in rx state %d\",\n\t\t qca->rx_ibs_state);\n\t\tbreak;\n\t}\n\n\tspin_unlock_irqrestore(&qca->hci_ibs_lock, flags);\n\n\t/* Actually send the packets */\n\thci_uart_tx_wakeup(hu);\n}", "label": 0, "cwe": null, "length": 314 }, { "index": 531355, "code": "acpi_db_display_interfaces(char *action_arg, char *interface_name_arg)\n{\n\tstruct acpi_interface_info *next_interface;\n\tchar *sub_string;\n\tacpi_status status;\n\n\t/* If no arguments, just display current interface list */\n\n\tif (!action_arg) {\n\t\t(void)acpi_os_acquire_mutex(acpi_gbl_osi_mutex,\n\t\t\t\t\t ACPI_WAIT_FOREVER);\n\n\t\tnext_interface = acpi_gbl_supported_interfaces;\n\t\twhile (next_interface) {\n\t\t\tif (!(next_interface->flags & ACPI_OSI_INVALID)) {\n\t\t\t\tacpi_os_printf(\"%s\\n\", next_interface->name);\n\t\t\t}\n\n\t\t\tnext_interface = next_interface->next;\n\t\t}\n\n\t\tacpi_os_release_mutex(acpi_gbl_osi_mutex);\n\t\treturn;\n\t}\n\n\t/* If action_arg exists, so must interface_name_arg */\n\n\tif (!interface_name_arg) {\n\t\tacpi_os_printf(\"Missing Interface Name argument\\n\");\n\t\treturn;\n\t}\n\n\t/* Uppercase the action for match below */\n\n\tacpi_ut_strupr(action_arg);\n\n\t/* install - install an interface */\n\n\tsub_string = strstr(\"INSTALL\", action_arg);\n\tif (sub_string) {\n\t\tstatus = acpi_install_interface(interface_name_arg);\n\t\tif (ACPI_FAILURE(status)) {\n\t\t\tacpi_os_printf(\"%s, while installing \\\"%s\\\"\\n\",\n\t\t\t\t acpi_format_exception(status),\n\t\t\t\t interface_name_arg);\n\t\t}\n\t\treturn;\n\t}\n\n\t/* remove - remove an interface */\n\n\tsub_string = strstr(\"REMOVE\", action_arg);\n\tif (sub_string) {\n\t\tstatus = acpi_remove_interface(interface_name_arg);\n\t\tif (ACPI_FAILURE(status)) {\n\t\t\tacpi_os_printf(\"%s, while removing \\\"%s\\\"\\n\",\n\t\t\t\t acpi_format_exception(status),\n\t\t\t\t interface_name_arg);\n\t\t}\n\t\treturn;\n\t}\n\n\t/* Invalid action_arg */\n\n\tacpi_os_printf(\"Invalid action argument: %s\\n\", action_arg);\n\treturn;\n}", "label": 0, "cwe": null, "length": 399 }, { "index": 28487, "code": "bssSelected(QTreeWidgetItem *sel)\n{\n\tNetworkConfig *nc = new NetworkConfig();\n\tif (nc == NULL)\n\t\treturn;\n\tnc->setWpaGui(wpagui);\n\tnc->paramsFromScanResults(sel);\n\tnc->show();\n\tnc->exec();\n}", "label": 0, "cwe": null, "length": 60 }, { "index": 833647, "code": "add_json_tree(node *state,node *output,node *tree,BOOL add_to_array,long item_index)\r\n{\r\n node *base_class = get_base_class(state);\r\n node *child = create_class_instance(base_class);\r\n if(node_GetKey(tree)!=NULL)\r\n set_obj_string(child,\"name\",node_GetKey(tree));\r\n if(node_GetType(tree)==NODE_TYPE_STRING)\r\n set_obj_string(child,\"value\",node_GetString(tree));\r\n else if(node_GetType(tree)==NODE_TYPE_UINT32)\r\n set_obj_int(child,\"value\",(long)node_GetUint32(tree));\r\n else if(node_GetType(tree)==NODE_TYPE_INT)\r\n set_obj_int(child,\"value\",node_GetInt(tree));\r\n else if(node_GetType(tree)==NODE_TYPE_SINT32)\r\n set_obj_int(child,\"value\",node_GetSint32(tree));\r\n else if(node_GetType(tree)==NODE_TYPE_FLOAT)\r\n set_obj_float(child,\"value\",(double)node_GetFloat(tree));\r\n else if(node_GetType(tree)==NODE_TYPE_DOUBLE)\r\n set_obj_float(child,\"value\",node_GetDouble(tree));\r\n else if(node_GetType(tree)==NODE_TYPE_ARRAY)\r\n {\r\n node *items = create_obj(\"items\");\r\n add_obj_kv(child,items);\r\n node_array_IterationReset(tree);\r\n long i = 0;\r\n while(node_array_IterationUnfinished(tree))\r\n {\r\n node *array_token = node_array_Iterate(tree);\r\n add_json_tree(state,items,array_token,1,i);\r\n i++;\r\n }\r\n }\r\n if(add_to_array)\r\n {\r\n node_AddItem(output,child);\r\n node_SetParent(child,output);\r\n set_obj_int(child,\"item_index\",item_index);\r\n }\r\n else\r\n add_member(output,child);\r\n inc_obj_refcount(child);\r\n node_ItemIterationReset(tree);\r\n while(node_ItemIterationUnfinished(tree))\r\n {\r\n node *sub = node_ItemIterate(tree);\r\n add_json_tree(state,child,sub,0,-1);\r\n }\r\n}", "label": 0, "cwe": null, "length": 420 }, { "index": 608281, "code": "prepare_pango_layout_width (NemoIconCanvasItem *item,\n\t\t\t PangoLayout *layout)\n{\n\tif (nemo_icon_canvas_item_get_max_text_width (item) < 0) {\n\t\tpango_layout_set_width (layout, -1);\n\t} else {\n\t\tpango_layout_set_width (layout, floor (nemo_icon_canvas_item_get_max_text_width (item)) * PANGO_SCALE);\n\t\tpango_layout_set_ellipsize (layout, PANGO_ELLIPSIZE_END);\n\t}\n}", "label": 0, "cwe": null, "length": 109 }, { "index": 423478, "code": "floor_ceil(K a, F(*g)(F))\n{\n I at=a->t, an=a->n;\n F(*h)(F)=g==ceil?floor:ceil;\n P(2 0&&!FC(f,1))||(f<0&&!FC(f,0))?h(e):g(e))\n else if(!at) DO(an, kK(z)[i]=floor_ceil(kK(a)[i],g))\n R z;\n}", "label": 1, "cwe": "CWE-other", "length": 189 }, { "index": 810521, "code": "RedrawDisplay()\n{\n\tint\tline;\n\tLinePtr\tnewtop = prev_line((curwind->w_line = curline),\n\t\t\t\targ_or_default(WSIZE(curwind)/2));\n\n\tif ((line = in_window(curwind, curwind->w_line)) != -1)\n\t\tPhysScreen[line].s_offset = -1;\n\tif (newtop == curwind->w_top)\n\t\tClAndRedraw();\n\telse\n\t\tSetTop(curwind, newtop);\n}", "label": 0, "cwe": null, "length": 100 }, { "index": 541747, "code": "CanReadFile(const char *file)\n{\n // First check the filename\n std::string filename = file;\n\n if ( filename == \"\" )\n {\n itkDebugMacro(<< \"No filename specified.\");\n return false;\n }\n\n // Now check the file header\n PNGFileWrapper pngfp(file, \"rb\");\n if ( pngfp.m_FilePointer == ITK_NULLPTR )\n {\n return false;\n }\n unsigned char header[8];\n size_t temp = fread(header, 1, 8, pngfp.m_FilePointer);\n if( temp != 8 )\n {\n itkExceptionMacro( \"PNGImageIO failed to read header for file: \"\n << this->GetFileName() << std::endl\n << \"Reason: fread read only \" << temp\n << \" instead of 8\" );\n }\n bool is_png = !png_sig_cmp(header, 0, 8);\n if ( !is_png )\n {\n return false;\n }\n png_structp png_ptr = png_create_read_struct\n (PNG_LIBPNG_VER_STRING, (png_voidp)ITK_NULLPTR,\n ITK_NULLPTR, ITK_NULLPTR);\n if ( !png_ptr )\n {\n return false;\n }\n\n png_infop info_ptr = png_create_info_struct(png_ptr);\n if ( !info_ptr )\n {\n png_destroy_read_struct(&png_ptr,\n (png_infopp)ITK_NULLPTR, (png_infopp)ITK_NULLPTR);\n return false;\n }\n\n png_infop end_info = png_create_info_struct(png_ptr);\n if ( !end_info )\n {\n png_destroy_read_struct(&png_ptr, &info_ptr,\n (png_infopp)ITK_NULLPTR);\n return false;\n }\n png_destroy_read_struct(&png_ptr, &info_ptr,\n &end_info);\n\n return true;\n}", "label": 1, "cwe": "CWE-other", "length": 404 }, { "index": 659478, "code": "wm831x_gpio_direction_out(struct gpio_chip *chip,\n\t\t\t\t unsigned offset, int value)\n{\n\tstruct wm831x_gpio *wm831x_gpio = to_wm831x_gpio(chip);\n\tstruct wm831x *wm831x = wm831x_gpio->wm831x;\n\tint val = 0;\n\tint ret;\n\n\tif (wm831x->has_gpio_ena)\n\t\tval |= WM831X_GPN_TRI;\n\n\tret = wm831x_set_bits(wm831x, WM831X_GPIO1_CONTROL + offset,\n\t\t\t WM831X_GPN_DIR | WM831X_GPN_TRI |\n\t\t\t WM831X_GPN_FN_MASK, val);\n\tif (ret < 0)\n\t\treturn ret;\n\n\t/* Can only set GPIO state once it's in output mode */\n\twm831x_gpio_set(chip, offset, value);\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 177 }, { "index": 487457, "code": "request_push(long last, PPGPushMachine *pm)\n{\n WAPEvent *ota_event;\n List *push_headers;\n\n gw_assert(last == 0 || last == 1);\n push_machine_assert(pm);\n \n push_headers = http_header_duplicate(pm->push_headers);\n\n ota_event = wap_event_create(Po_Push_Req);\n ota_event->u.Po_Push_Req.push_headers = push_headers;\n ota_event->u.Po_Push_Req.authenticated = pm->authenticated;\n ota_event->u.Po_Push_Req.trusted = pm->trusted;\n ota_event->u.Po_Push_Req.last = last;\n\n if (pm->push_data != NULL)\n ota_event->u.Po_Push_Req.push_body = \n octstr_duplicate(pm->push_data);\n else\n ota_event->u.Po_Push_Req.push_body = NULL; \n\n ota_event->u.Po_Push_Req.session_handle = pm->session_id;\n debug(\"wap.push.ppg\", 0, \"PPG: OTA request for push\");\n \n dispatch_to_ota(ota_event);\n}", "label": 0, "cwe": null, "length": 255 }, { "index": 602860, "code": "audio_device_request_authorization(struct audio_device *dev,\n\t\t\t\t\tconst char *uuid, service_auth_cb cb,\n\t\t\t\t\tvoid *user_data)\n{\n\tstruct dev_priv *priv = dev->priv;\n\tstruct service_auth *auth;\n\tint err;\n\n\tauth = g_try_new0(struct service_auth, 1);\n\tif (!auth)\n\t\treturn -ENOMEM;\n\n\tauth->cb = cb;\n\tauth->user_data = user_data;\n\n\tpriv->auths = g_slist_append(priv->auths, auth);\n\tif (g_slist_length(priv->auths) > 1)\n\t\treturn 0;\n\n\tif (priv->authorized || audio_device_is_connected(dev)) {\n\t\tpriv->auth_idle_id = g_idle_add(auth_idle_cb, dev);\n\t\treturn 0;\n\t}\n\n\terr = btd_request_authorization(&dev->src, &dev->dst, uuid, auth_cb,\n\t\t\t\t\tdev);\n\tif (err < 0) {\n\t\tpriv->auths = g_slist_remove(priv->auths, auth);\n\t\tg_free(auth);\n\t}\n\n\treturn err;\n}", "label": 0, "cwe": null, "length": 218 }, { "index": 69741, "code": "dilate_charimage_2(unsigned char *inp, unsigned char *out,\n const int iw, const int ih)\n{\n int row, col;\n unsigned char *itr = inp, *otr = out;\n \n memcpy(out, inp, iw*ih);\n \n /* for all pixels. set pixel if there is at least one true neighbor */\n for ( row = 0 ; row < ih ; row++ )\n for ( col = 0 ; col < iw ; col++ )\n { \n if (!*itr) /* pixel is already true, neighbors irrelevant */\n {\n /* more efficient with C's left to right evaluation of */\n /* conjuctions. E N S functions not executed if W is false */\n if (get_west8_2 ((char *)itr, col , 0) ||\n get_east8_2 ((char *)itr, col, iw , 0) ||\n get_north8_2((char *)itr, row, iw , 0) ||\n get_south8_2((char *)itr, row, iw, ih, 0))\n *otr = 1;\n }\n itr++ ; otr++;\n } \n}", "label": 1, "cwe": "CWE-120", "length": 260 }, { "index": 110345, "code": "spl_array_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) /* {{{ */\n{\n\tspl_array_object *intern = (spl_array_object*)zend_object_store_get_object(obj TSRMLS_CC);\n\tzval *tmp, *storage;\n\tint name_len;\n\tchar *zname;\n\tzend_class_entry *base;\n\n\t*is_temp = 0;\n\n\tif (!intern->std.properties) {\n\t\trebuild_object_properties(&intern->std);\n\t}\n\n\tif (HASH_OF(intern->array) == intern->std.properties) {\n\t\treturn intern->std.properties;\n\t} else {\n\t\tif (intern->debug_info == NULL) {\n\t\t\tALLOC_HASHTABLE(intern->debug_info);\n\t\t\tZEND_INIT_SYMTABLE_EX(intern->debug_info, zend_hash_num_elements(intern->std.properties) + 1, 0);\n\t\t}\n\n\t\tif (intern->debug_info->nApplyCount == 0) {\n\t\t\tzend_hash_clean(intern->debug_info);\n\t\t\tzend_hash_copy(intern->debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));\n\n\t\t\tstorage = intern->array;\n\t\t\tzval_add_ref(&storage);\n\n\t\t\tbase = (Z_OBJ_HT_P(obj) == &spl_handler_ArrayIterator) ? spl_ce_ArrayIterator : spl_ce_ArrayObject;\n\t\t\tzname = spl_gen_private_prop_name(base, \"storage\", sizeof(\"storage\")-1, &name_len TSRMLS_CC);\n\t\t\tzend_symtable_update(intern->debug_info, zname, name_len+1, &storage, sizeof(zval *), NULL);\n\t\t\tefree(zname);\n\t\t}\n\n\t\treturn intern->debug_info;\n\t}\n}", "label": 0, "cwe": null, "length": 365 }, { "index": 313654, "code": "is_known(struct conn_data *host)\n{\n struct known_hosts *this_host;\n\n this_host = first_host;\n while (this_host != NULL) {\n if (this_host->shost.s_addr != (host->shost.s_addr & this_host->netmask.s_addr)) {\n goto no_match;\n }\n if (this_host->time == 0)\n return this_host;\n if ((opt.dst_ip) && (this_host->dhost.s_addr != host->dhost.s_addr)) {\n goto no_match;\n }\n if ((opt.dst_port) && (this_host->dport != host->dport)) {\n goto no_match;\n }\n if ((opt.src_port) && (this_host->sport != host->sport)) {\n goto no_match;\n }\n if ((opt.proto) && (this_host->protocol != host->protocol)) {\n goto no_match;\n }\n break;\n no_match:\n this_host = this_host->next;\n }\n return this_host;\n}", "label": 0, "cwe": null, "length": 220 }, { "index": 809732, "code": "tp_asv_take_string (GHashTable *asv,\n const gchar *key,\n gchar *value)\n{\n g_return_if_fail (asv != NULL);\n g_return_if_fail (key != NULL);\n\n g_hash_table_insert (asv, (char *) key,\n tp_g_value_slice_new_take_string (value));\n}", "label": 0, "cwe": null, "length": 72 }, { "index": 1018141, "code": "lcd2usb_HD44780_scankeypad(PrivateData *p)\n{\n\tunsigned char buffer[2];\n\tint nBytes;\n\n\t/* send control request and accept return value */\n\tnBytes = usb_control_msg(p->usbHandle,\n\t\t USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_IN,\n\t LCD2USB_GET_KEYS, 0, 0, (char *) buffer, sizeof(buffer), 1000);\n\n\tif (nBytes != -1) {\n\t\treturn buffer[0];\n\t}\n\n\treturn '\\0';\n}", "label": 0, "cwe": null, "length": 110 }, { "index": 948764, "code": "copy_urb_data_to_user(u8 __user *userbuffer, struct urb *urb)\n{\n\tunsigned i, len, size;\n\n\tif (urb->number_of_packets > 0)\t\t/* Isochronous */\n\t\tlen = urb->transfer_buffer_length;\n\telse\t\t\t\t\t/* Non-Isoc */\n\t\tlen = urb->actual_length;\n\n\tif (urb->num_sgs == 0) {\n\t\tif (copy_to_user(userbuffer, urb->transfer_buffer, len))\n\t\t\treturn -EFAULT;\n\t\treturn 0;\n\t}\n\n\tfor (i = 0; i < urb->num_sgs && len; i++) {\n\t\tsize = (len > USB_SG_SIZE) ? USB_SG_SIZE : len;\n\t\tif (copy_to_user(userbuffer, sg_virt(&urb->sg[i]), size))\n\t\t\treturn -EFAULT;\n\t\tuserbuffer += size;\n\t\tlen -= size;\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 194 }, { "index": 851712, "code": "print_table(char **t, size_t max_y, size_t max_x)\n{\n\tint\ti, j;\n\n\tfor (i = 0; i < max_y; i++) {\n\t\tfor (j = 0; j < max_x; j++)\n\t\t\tfprintf(stdout, \"%c\", t[i][j]);\n\t\tfprintf(stdout, \"\\n\");\n\t}\n}", "label": 0, "cwe": null, "length": 75 }, { "index": 779752, "code": "gth_chain_copy(GthChain *dest, const GthChain *src)\n{\n gt_assert(dest&& src);\n chain_copy_core(dest, src);\n gt_array_add_array(dest->forwardranges, src->forwardranges);\n gt_array_add_array(dest->reverseranges, src->reverseranges);\n}", "label": 0, "cwe": null, "length": 68 }, { "index": 88077, "code": "operator=( const OsiOldLink & rhs)\n{\n if (this != &rhs) {\n OsiSOS::operator=(rhs);\n delete [] members_;\n numberLinks_ = rhs.numberLinks_;\n if (numberMembers_) {\n members_ = CoinCopyOfArray(rhs.members_, numberMembers_ * numberLinks_);\n } else {\n members_ = NULL;\n }\n }\n return *this;\n}", "label": 0, "cwe": null, "length": 90 }, { "index": 319508, "code": "start_auth(struct Client *client)\n{\n\tstruct AuthRequest *auth = 0;\n\ts_assert(0 != client);\n\tif(client == NULL)\n\t\treturn;\n\n\t/* to aid bopm which needs something unique to match against */\n\tsendto_one(client, \"NOTICE AUTH :*** Processing connection to %s\", me.name);\n\n\tauth = make_auth_request(client);\n\n\tsendheader(client, REPORT_DO_DNS);\n\n\trb_dlinkAdd(auth, &auth->node, &auth_poll_list);\n\n\t/* Note that the order of things here are done for a good reason\n\t * if you try to do start_auth_query before lookup_ip there is a \n\t * good chance that you'll end up with a double free on the auth\n\t * and that is bad. But you still must keep the SetDNSPending \n\t * before the call to start_auth_query, otherwise you'll have\n\t * the same thing. So think before you hack \n\t */\n\tSetDNS(auth);\t\t/* set both at the same time to eliminate possible race conditions */\n\tSetAuth(auth);\n\tif(ConfigFileEntry.disable_auth == 0)\n\t{\n\t\tstart_auth_query(auth);\n\t}\n\telse {\n\t\trb_free(client->localClient->lip);\n\t\tclient->localClient->lip = NULL;\n\t\tClearAuth(auth);\n\t}\n\tauth->dns_query =\n\t\tlookup_ip(client->sockhost, GET_SS_FAMILY(&client->localClient->ip),\n\t\t\t auth_dns_callback, auth);\n}", "label": 0, "cwe": null, "length": 304 }, { "index": 64170, "code": "dropEvent(QDropEvent *event)\n{\n event->accept();\n d_ptr->m_dragging = false;\n if (d_ptr->m_dragColor == color())\n return;\n setColor(d_ptr->m_dragColor);\n emit colorChanged(color());\n}", "label": 0, "cwe": null, "length": 56 }, { "index": 889019, "code": "getBody(PRFileDesc *fd, char **buf, int *actualBytesRead)\n{\n\tint totalBytesRead = 0;\n\tint size = 4 * HTTP_DEFAULT_BUFFER_SIZE;\n\tint bytesRead = size;\n\tchar *data = (char *) PR_Calloc(1, size);\n\twhile (bytesRead == size) {\n\t\tbytesRead = http_read(fd, (data+totalBytesRead), size);\n\t\tif (bytesRead <= 0) {\n\t\t\t/* Read error */\n\t\t\treturn PR_FAILURE;\n\t\t}\n\t\tif (bytesRead == size) {\n\t\t\t/* more data to be read so increase the buffer */\n\t\t\tsize = size * 2 ;\n\t\t\tdata = (char *) PR_Realloc(data, size);\n\t\t}\n\t\ttotalBytesRead += bytesRead;\n\t}\n\t*buf = data;\n\t*actualBytesRead = totalBytesRead;\n\n\treturn PR_SUCCESS;\n}", "label": 0, "cwe": null, "length": 183 }, { "index": 62435, "code": "fin_log(void)\n{\n\tif (_log_direct) {\n\t\t(void) dev_close(&_log_dev);\n\t\t_log_direct = 0;\n\t}\n\n\tif (_log_to_file) {\n\t\tif (dm_fclose(_log_file)) {\n\t\t\tif (errno)\n\t\t\t fprintf(stderr, \"failed to write log file: %s\\n\",\n\t\t\t\t strerror(errno));\n\t\t\telse\n\t\t\t fprintf(stderr, \"failed to write log file\\n\");\n\n\t\t}\n\t\t_log_to_file = 0;\n\t}\n}", "label": 0, "cwe": null, "length": 104 }, { "index": 786951, "code": "jswrap_graphics_setFontSizeX(JsVar *parent, int size, bool checkValid) {\n JsGraphics gfx; if (!graphicsGetFromVar(&gfx, parent)) return;\n\n if (checkValid) {\n if (size<1) size=1;\n if (size>1023) size=1023;\n }\n if (gfx.data.fontSize == JSGRAPHICS_FONTSIZE_CUSTOM) {\n jsvObjectSetChild(parent, JSGRAPHICS_CUSTOMFONT_BMP, 0);\n jsvObjectSetChild(parent, JSGRAPHICS_CUSTOMFONT_WIDTH, 0);\n jsvObjectSetChild(parent, JSGRAPHICS_CUSTOMFONT_HEIGHT, 0);\n jsvObjectSetChild(parent, JSGRAPHICS_CUSTOMFONT_FIRSTCHAR, 0);\n }\n gfx.data.fontSize = (short)size;\n graphicsSetVar(&gfx);\n}", "label": 0, "cwe": null, "length": 193 }, { "index": 790667, "code": "_e_fm2_sys_suspend_hibernate(void *d __UNUSED__, int type __UNUSED__, void *ev __UNUSED__)\n{\n Eina_List *l, *ll, *lll;\n E_Volume *v;\n E_Fm2_Mount *m;\n\n EINA_LIST_FOREACH(e_fm2_device_volume_list_get(), l, v)\n {\n EINA_LIST_FOREACH_SAFE(v->mounts, ll, lll, m)\n e_fm2_device_unmount(m);\n }\n return ECORE_CALLBACK_RENEW;\n}", "label": 0, "cwe": null, "length": 112 }, { "index": 319973, "code": "HIstrncpy(char *dest, const char *source, intn len)\n{\n char *destp;\n\n destp = dest;\n if (len == 0)\n return (destp);\n for (; (len > 1) && (*source != '\\0'); len--)\n *dest++ = *source++;\n *dest = '\\0'; /* Force the last byte be '\\0' */\n return (destp);\n}", "label": 0, "cwe": null, "length": 97 }, { "index": 85913, "code": "cond_write_bool(void *vkey, void *datum, void *ptr)\n{\n\tchar *key = vkey;\n\tstruct cond_bool_datum *booldatum = datum;\n\tstruct policy_data *pd = ptr;\n\tvoid *fp = pd->fp;\n\t__le32 buf[3];\n\tu32 len;\n\tint rc;\n\n\tlen = strlen(key);\n\tbuf[0] = cpu_to_le32(booldatum->value);\n\tbuf[1] = cpu_to_le32(booldatum->state);\n\tbuf[2] = cpu_to_le32(len);\n\trc = put_entry(buf, sizeof(u32), 3, fp);\n\tif (rc)\n\t\treturn rc;\n\trc = put_entry(key, 1, len, fp);\n\tif (rc)\n\t\treturn rc;\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 165 }, { "index": 895935, "code": "ibus_engine_get_surrounding_text (IBusEngine *engine,\n IBusText **text,\n guint *cursor_pos,\n guint *anchor_pos)\n{\n IBusEnginePrivate *priv;\n\n g_return_if_fail (IBUS_IS_ENGINE (engine));\n const gboolean signal_only = (text == NULL);\n\n g_return_if_fail (( signal_only && (cursor_pos == NULL)) ||\n (!signal_only && (cursor_pos != NULL)));\n\n g_return_if_fail (( signal_only && (anchor_pos == NULL)) ||\n (!signal_only && (anchor_pos != NULL)));\n\n priv = IBUS_ENGINE_GET_PRIVATE (engine);\n\n if (!signal_only) {\n *text = g_object_ref (priv->surrounding_text);\n *cursor_pos = priv->surrounding_cursor_pos;\n *anchor_pos = priv->selection_anchor_pos;\n }\n\n /* tell the client that this engine will utilize surrounding-text\n * feature, which causes periodical update. Note that the client\n * should request the initial surrounding-text when the engine is\n * enabled (see ibus_im_context_focus_in() and\n * _ibus_context_enabled_cb() in client/gtk2/ibusimcontext.c). */\n ibus_engine_emit_signal (engine,\n \"RequireSurroundingText\",\n NULL);\n\n // g_debug (\"get-surrounding-text ('%s', %d, %d)\", (*text)->text, *cursor_pos, *anchor_pos);\n}", "label": 0, "cwe": null, "length": 314 }, { "index": 879803, "code": "rhash_md5_final(md5_ctx *ctx, unsigned char* result)\n{\n\tunsigned index = ((unsigned)ctx->length & 63) >> 2;\n\tunsigned shift = ((unsigned)ctx->length & 3) * 8;\n\n\t/* pad message and run for last block */\n\n\t/* append the byte 0x80 to the message */\n\tctx->message[index] &= ~(0xFFFFFFFF << shift);\n\tctx->message[index++] ^= 0x80 << shift;\n\n\t/* if no room left in the message to store 64-bit message length */\n\tif (index > 14) {\n\t\t/* then fill the rest with zeros and process it */\n\t\twhile (index < 16) {\n\t\t\tctx->message[index++] = 0;\n\t\t}\n\t\trhash_md5_process_block(ctx->hash, ctx->message);\n\t\tindex = 0;\n\t}\n\twhile (index < 14) {\n\t\tctx->message[index++] = 0;\n\t}\n\tctx->message[14] = (unsigned)(ctx->length << 3);\n\tctx->message[15] = (unsigned)(ctx->length >> 29);\n\trhash_md5_process_block(ctx->hash, ctx->message);\n\n\tif (result) le32_copy(result, 0, &ctx->hash, 16);\n}", "label": 0, "cwe": null, "length": 273 }, { "index": 393909, "code": "fso_factory_function (FsoFrameworkSubsystem* system, GError** error) {\n\tgchar* result = NULL;\n\tFsoFrameworkSubsystem* _tmp0_ = NULL;\n\tFsoFrameworkSmartKeyFile* config = NULL;\n\tFsoFrameworkSmartKeyFile* _tmp1_ = NULL;\n\tFsoFrameworkSmartKeyFile* _tmp2_ = NULL;\n\tgchar* _tmp3_ = NULL;\n\tKernel26FirmwareLoader* _tmp4_ = NULL;\n\tgchar* _tmp5_ = NULL;\n\tg_return_val_if_fail (system != NULL, NULL);\n\t_tmp0_ = system;\n\tsubsystem = _tmp0_;\n\t_tmp1_ = fso_framework_theConfig;\n\t_tmp2_ = _g_object_ref0 (_tmp1_);\n\tconfig = _tmp2_;\n\t_tmp3_ = fso_framework_smart_key_file_stringValue (config, \"cornucopia\", \"sysfs_root\", \"/sys\");\n\t_g_free0 (sysfs_root);\n\tsysfs_root = _tmp3_;\n\t_tmp4_ = kernel26_firmware_loader_new ();\n\t_g_object_unref0 (instance);\n\tinstance = _tmp4_;\n\t_tmp5_ = g_strdup (\"fsodevice.kernel26_firmwareloader\");\n\tresult = _tmp5_;\n\t_g_object_unref0 (config);\n\treturn result;\n}", "label": 1, "cwe": "CWE-other", "length": 275 }, { "index": 544448, "code": "contains_empty_class_p (tree type)\n{\n if (is_empty_class (type))\n return true;\n if (CLASS_TYPE_P (type))\n {\n tree field;\n int i;\n\n for (i = 0; i < CLASSTYPE_N_BASECLASSES (type); ++i)\n\tif (contains_empty_class_p (TYPE_BINFO_BASETYPE (type, i)))\n\t return true;\n for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))\n\tif (TREE_CODE (field) == FIELD_DECL\n\t && !DECL_ARTIFICIAL (field)\n\t && is_empty_class (TREE_TYPE (field)))\n\t return true;\n }\n else if (TREE_CODE (type) == ARRAY_TYPE)\n return contains_empty_class_p (TREE_TYPE (type));\n return false;\n}", "label": 0, "cwe": null, "length": 173 }, { "index": 551431, "code": "ExecSupportsMarkRestore(Path *pathnode)\n{\n\t/*\n\t * For consistency with the routines above, we do not examine the nodeTag\n\t * but rather the pathtype, which is the Plan node type the Path would\n\t * produce.\n\t */\n\tswitch (pathnode->pathtype)\n\t{\n\t\tcase T_IndexScan:\n\t\tcase T_IndexOnlyScan:\n\t\tcase T_Material:\n\t\tcase T_Sort:\n\t\t\treturn true;\n\n\t\tcase T_CustomScan:\n\t\t\tAssert(IsA(pathnode, CustomPath));\n\t\t\tif (((CustomPath *) pathnode)->flags & CUSTOMPATH_SUPPORT_MARK_RESTORE)\n\t\t\t\treturn true;\n\t\t\treturn false;\n\n\t\tcase T_Result:\n\n\t\t\t/*\n\t\t\t * Although Result supports mark/restore if it has a child plan\n\t\t\t * that does, we presently come here only for ResultPath nodes,\n\t\t\t * which represent Result plans without a child plan. So there is\n\t\t\t * nothing to recurse to and we can just say \"false\". (This means\n\t\t\t * that Result's support for mark/restore is in fact dead code. We\n\t\t\t * keep it since it's not much code, and someday the planner might\n\t\t\t * be smart enough to use it. That would require making this\n\t\t\t * function smarter too, of course.)\n\t\t\t */\n\t\t\tAssert(IsA(pathnode, ResultPath));\n\t\t\treturn false;\n\n\t\tdefault:\n\t\t\tbreak;\n\t}\n\n\treturn false;\n}", "label": 0, "cwe": null, "length": 299 }, { "index": 69932, "code": "krb5_get_nonexp_tkts(context, cc, creds_array)\n krb5_context context;\n krb5_ccache cc;\n krb5_creds ***creds_array;\n{\n\n krb5_creds creds, temp_tktq, temp_tkt;\n krb5_creds **temp_creds;\n krb5_error_code retval=0;\n krb5_cc_cursor cur;\n int count = 0;\n int chunk_count = 1;\n\n if ( ! ( temp_creds = (krb5_creds **) malloc( CHUNK * sizeof(krb5_creds *)))){\n return ENOMEM;\n }\n\n\n memset(&temp_tktq, 0, sizeof(temp_tktq));\n memset(&temp_tkt, 0, sizeof(temp_tkt));\n memset(&creds, 0, sizeof(creds));\n\n /* initialize the cursor */\n if ((retval = krb5_cc_start_seq_get(context, cc, &cur))) {\n return retval;\n }\n\n while (!(retval = krb5_cc_next_cred(context, cc, &cur, &creds))){\n\n if ((retval = krb5_check_exp(context, creds.times))){\n if (retval != KRB5KRB_AP_ERR_TKT_EXPIRED){\n return retval;\n }\n if (auth_debug){\n fprintf(stderr,\"krb5_ccache_copy: CREDS EXPIRED:\\n\");\n fputs(\" Valid starting Expires Service principal\\n\",stdout);\n show_credential(context, &creds, cc);\n fprintf(stderr,\"\\n\");\n }\n }\n else { /* these credentials didn't expire */\n\n if ((retval = krb5_copy_creds(context, &creds,\n &temp_creds[count]))){\n return retval;\n }\n count ++;\n\n if (count == (chunk_count * CHUNK -1)){\n chunk_count ++;\n if (!(temp_creds = (krb5_creds **) realloc(temp_creds,\n chunk_count * CHUNK * sizeof(krb5_creds *)))){\n return ENOMEM;\n }\n }\n }\n\n }\n\n temp_creds[count] = NULL;\n *creds_array = temp_creds;\n\n if (retval == KRB5_CC_END) {\n retval = krb5_cc_end_seq_get(context, cc, &cur);\n }\n\n return retval;\n\n}", "label": 0, "cwe": null, "length": 487 }, { "index": 743483, "code": "url_escape_mask(const char *url, uint8 mask)\n{\n\tconst char *p;\n\tchar *q;\n\tint need_escape = 0;\n\tuchar c;\n\tchar *new;\n\n\tfor (p = url, c = *p++; c; c = *p++)\n\t\tif (!is_transparent_char(c, mask))\n\t\t\tneed_escape++;\n\n\tif (need_escape == 0)\n\t\treturn deconstify_gchar(url);\n\n\tnew = halloc(p - url + (need_escape << 1));\n\n\tfor (p = url, q = new, c = *p++; c; c = *p++) {\n\t\tif (is_transparent_char(c, mask))\n\t\t\t*q++ = c;\n\t\telse {\n\t\t\t*q++ = ESCAPE_CHAR;\n\t\t\t*q++ = hex_alphabet[c >> 4];\n\t\t\t*q++ = hex_alphabet[c & 0xf];\n\t\t}\n\t}\n\t*q = '\\0';\n\n\treturn new;\n}", "label": 0, "cwe": null, "length": 199 }, { "index": 572951, "code": "e2_utf8_from_locale (const gchar *d)\n{\n\tif (g_utf8_validate (d, -1, NULL))\n\t\treturn g_strdup (d);\n\tgchar *ret = g_locale_to_utf8 (d, -1, NULL, NULL, NULL);\n\tif (ret != NULL)\n\t\treturn ret;\n\tprintd (WARN, \"initial conversion of localised string %s to UTF8 failed\", d);\n\treturn e2_utf8_from_locale_fallback (d);\n}", "label": 0, "cwe": null, "length": 101 }, { "index": 254227, "code": "normalize_histograms()\n{\n for( int r=0; rlen);\n\tif (!msg) {\n\t\tr = -ENOMEM;\n\t\tgoto free_skb;\n\t}\n\n\tif (nla_put(msg, NFC_ATTR_VENDOR_DATA, skb->len, skb->data)) {\n\t\tkfree_skb(msg);\n\t\tr = -ENOBUFS;\n\t\tgoto free_skb;\n\t}\n\n\tr = nfc_vendor_cmd_reply(msg);\n\nfree_skb:\n\tkfree_skb(skb);\nexit:\n\treturn r;\n}", "label": 0, "cwe": null, "length": 216 }, { "index": 745700, "code": "cgroup_list_all_controllers(const char *tname,\n\tcont_name_t cont_name[CG_CONTROLLER_MAX], int c_number, int flags)\n{\n\tint ret = 0;\n\tvoid *handle;\n\tstruct controller_data info;\n\n\tint h_list[CG_CONTROLLER_MAX];\t/* list of hierarchies */\n\tint counter = 0;\n\tint j;\n\tint is_on_list = 0;\n\n\tret = cgroup_get_all_controller_begin(&handle, &info);\n\twhile (ret == 0) {\n\t\tif (info.hierarchy == 0) {\n\t\t\t/* the controller is not attached to any hierrachy */\n\t\t\tif (flags & FL_ALL)\n\t\t\t\t/* display only if -a flag is set */\n\t\t\t\tprintf(\"%s\\n\", info.name);\n\t\t}\n\t\tis_on_list = 0;\n\t\tj = 0;\n\t\twhile ((is_on_list == 0) && (j < c_number)) {\n\t\t\tif (strcmp(info.name, cont_name[j]) == 0) {\n\t\t\t\tis_on_list = 1;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tj++;\n\t\t}\n\n\t\tif ((info.hierarchy != 0) &&\n\t\t\t((flags & FL_ALL) ||\n\t\t\t(!(flags & FL_LIST) || (is_on_list == 1)))) {\n\t\t\t/* the controller is attached to some hierarchy\n\t\t\t and either should be output all controllers,\n\t\t\t or the controller is on the output list */\n\n\t\t\th_list[counter] = info.hierarchy;\n\t\t\tcounter++;\n\t\t\tfor (j = 0; j < counter-1; j++) {\n\t\t\t\t/*\n\t\t\t\t * the hierarchy already was on the list\n\t\t\t\t * so remove the new record\n\t\t\t\t */\n\t\t\t\tif (h_list[j] == info.hierarchy) {\n\t\t\t\t\tcounter--;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tret = cgroup_get_all_controller_next(&handle, &info);\n\t}\n\tcgroup_get_all_controller_end(&handle);\n\tif (ret == ECGEOF)\n\t\tret = 0;\n\tif (ret) {\n\t\tfprintf(stderr,\n\t\t\t\"cgroup_get_controller_begin/next failed (%s)\\n\",\n\t\t\tcgroup_strerror(ret));\n\t\treturn ret;\n\t}\n\n\n\tfor (j = 0; j < counter; j++)\n\t\tret = print_all_controllers_in_hierarchy(tname,\n\t\t\th_list[j], flags);\n\n\treturn ret;\n\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 488 }, { "index": 156187, "code": "L4()\n{register object *base=vs_base;\n\tregister object *sup=base+VM4; VC4\n\tvs_check;\n\tvs_top=sup;\n\tgoto TTL;\nTTL:;\n\t(((object)VV[2])->s.s_dbind)= Cnil;\n\t(((object)VV[3])->s.s_dbind)= Cnil;\n\t(((object)VV[4])->s.s_dbind)= Cnil;\n\t(((object)VV[5])->s.s_dbind)= small_fixnum(32);\n\t(((object)VV[6])->s.s_dbind)= Cnil;\n\tbase[0]= Cnil;\n\tvs_top=(vs_base=base+0)+1;\n\treturn;\n}", "label": 0, "cwe": null, "length": 148 }, { "index": 240707, "code": "breaktest(obj)\nstruct obj *obj;\n{\n\tif (obj_resists(obj, 1, 99)) return 0;\n\tif (objects[obj->otyp].oc_material == GLASS && !obj->oartifact &&\n\t\tobj->oclass != GEM_CLASS)\n\t return 1;\n\tswitch (obj->oclass == POTION_CLASS ? POT_WATER : obj->otyp) {\n#ifdef TOURIST\n\t\tcase EXPENSIVE_CAMERA:\n#endif\n\t\tcase POT_WATER:\t\t/* really, all potions */\n\t\tcase EGG:\n\t\tcase CREAM_PIE:\n\t\tcase MELON:\n\t\tcase ACID_VENOM:\n\t\tcase BLINDING_VENOM:\n\t\t\treturn 1;\n\t\tdefault:\n\t\t\treturn 0;\n\t}\n}", "label": 0, "cwe": null, "length": 158 }, { "index": 106583, "code": "e_illume_keyboard_safe_app_region_get(E_Zone *zone, int *x, int *y, int *w, int *h) \n{\n if (x) *x = 0;\n if (y) *y = 0;\n if (w) *w = 0;\n if (h) *h = 0;\n\n /* make sure we have a zone */\n if (!zone) return;\n\n /* set default values */\n if (x) *x = zone->x;\n if (y) *y = zone->y;\n if (w) *w = zone->w;\n if (h) *h = zone->h;\n\n /* if the keyboard is disabled, get out */\n if ((!_e_illume_kbd->visible) || (_e_illume_kbd->disabled)) return;\n\n /* if we don't have a border, get out */\n /* NB: This basically means that we have the vkbd structure, but no \n * app or module present to act as the vkbd */\n if (!_e_illume_kbd->border) return;\n\n /* if the keyboard border is not on this zone, get out */\n if (_e_illume_kbd->border->zone != zone) return;\n\n if (!_e_illume_kbd->animator) \n {\n if (h) \n {\n *h -= _e_illume_kbd->border->h;\n if (*h < 0) *h = 0;\n }\n }\n}", "label": 0, "cwe": null, "length": 335 }, { "index": 940947, "code": "on_cancel_clicked(GtkWidget *w, gpointer id) {\n ConfData *cd;\n\n cd = g_hash_table_lookup(id_hash, id);\n if (cd) {\n gtk_widget_set_sensitive(cd->window, FALSE);\n if (cd->cancel_handler)\n cd->cancel_handler(cd->user_data1, cd->user_data2);\n cleanup(id);\n }\n}", "label": 0, "cwe": null, "length": 80 }, { "index": 31379, "code": "remove_minutia(const int index, MINUTIAE *minutiae)\n{\n int fr, to;\n\n /* Make sure the requested index is within range. */\n if((index < 0) && (index >= minutiae->num)){\n fprintf(stderr, \"ERROR : remove_minutia : index out of range\\n\");\n return(-380);\n }\n\n /* Deallocate the minutia structure to be removed. */\n free_minutia(minutiae->list[index]);\n\n /* Slide the remaining list of minutiae up over top of the */\n /* position of the minutia being removed. */\n for(to = index, fr = index+1; fr < minutiae->num; to++, fr++)\n minutiae->list[to] = minutiae->list[fr];\n\n /* Decrement the number of minutiae remaining in the list. */\n minutiae->num--;\n\n /* Return normally. */\n return(0);\n}", "label": 0, "cwe": null, "length": 202 }, { "index": 24716, "code": "gt_sain_fast_assignSstarnames(unsigned long totallength,\n unsigned long countSstartype,\n unsigned long *suftab,\n unsigned long numberofnames,\n unsigned long nonspecialentries)\n{\n unsigned long *suftabptr, *secondhalf = suftab + countSstartype;\n\n if (numberofnames < countSstartype)\n {\n unsigned long currentname = numberofnames + 1;\n\n for (suftabptr = suftab + nonspecialentries - 1; suftabptr >= suftab;\n suftabptr--)\n {\n unsigned long position;\n\n if ((position = *suftabptr) >= totallength)\n {\n position -= totallength;\n gt_assert(currentname > 0);\n currentname--;\n }\n if (currentname <= numberofnames)\n {\n secondhalf[GT_DIV2(position)] = currentname;\n }\n }\n } else\n {\n for (suftabptr = suftab; suftabptr < suftab + nonspecialentries;\n suftabptr++)\n {\n if (*suftabptr >= totallength)\n {\n *suftabptr -= totallength;\n }\n }\n }\n}", "label": 0, "cwe": null, "length": 277 }, { "index": 677655, "code": "fd_destroy (fd_t *fd)\n{\n xlator_t *xl = NULL;\n int i = 0;\n xlator_t *old_THIS = NULL;\n\n if (fd == NULL){\n gf_log_callingfn (\"xlator\", GF_LOG_ERROR, \"invalid argument\");\n goto out;\n }\n\n if (fd->inode == NULL){\n gf_log_callingfn (\"xlator\", GF_LOG_ERROR, \"fd->inode is NULL\");\n goto out;\n }\n if (!fd->_ctx)\n goto out;\n\n if (IA_ISDIR (fd->inode->ia_type)) {\n for (i = 0; i < fd->xl_count; i++) {\n if (fd->_ctx[i].key) {\n xl = fd->_ctx[i].xl_key;\n old_THIS = THIS;\n THIS = xl;\n if (xl->cbks->releasedir)\n xl->cbks->releasedir (xl, fd);\n THIS = old_THIS;\n }\n }\n } else {\n for (i = 0; i < fd->xl_count; i++) {\n if (fd->_ctx[i].key) {\n xl = fd->_ctx[i].xl_key;\n old_THIS = THIS;\n THIS = xl;\n if (xl->cbks->release)\n xl->cbks->release (xl, fd);\n THIS = old_THIS;\n }\n }\n }\n\n LOCK_DESTROY (&fd->lock);\n\n GF_FREE (fd->_ctx);\n inode_unref (fd->inode);\n fd->inode = (inode_t *)0xaaaaaaaa;\n fd_lk_ctx_unref (fd->lk_ctx);\n mem_put (fd);\nout:\n return;\n}", "label": 0, "cwe": null, "length": 368 }, { "index": 327084, "code": "webcmd_reply()\n{\n\tchar\ttmp[BUFSIZ];\n\tint\tnum;\n\tnoterec\t*n;\n\tnbody\t*body;\n\n\t/* Display headers, statusline, and menu */\n\tsprintf(tmp,\"%s - Note %s\",Web->title,Web->tok1);\n\topenhtml(tmp);\n\twebsay_statusline();\n\tsprintf(tmp,\"Reply:%s\",Web->tok1);\n\twebsay_menuline(tmp);\n\twebsay(\"

\");\n\twebsay(\"\");\n\n\twebsay(\"
\",Web->cgi_url,Web->user->acctname,Web->user->pass);\n\n\t/* We do this just like Note below, but we show original. */\n\tnum = atoi(Web->tok1);\n\tn = Note_notebynumber(Web->user,num);\n\tif(n == NULL)\n\t{\n\t\twebsay(\"Note %d doesn't exist anymore!\",num);\n\t\tclosehtml();\n\t\treturn;\n\t}\n\n\t/* Draw Note */\n\twebsay(\"%s said:
\",Web->cgi_url,Web->user->acctname,Web->user->pass,n->nick,n->nick);\n\twebsay(\"
\");\n\tfor(body=n->body; body!=NULL; body=body->next)\n\t{\n\t\tif(body->text[0])\n\t\t{\n\t\t\tstrcpy(tmp, body->text);\n\t\t\tWeb_fixforhtml(tmp);\n\t\t\twebsay(\"%s\",tmp);\n\t\t}\n\t\telse\n\t\t\twebsay(\"

\");\n\t}\n\twebsay(\"

\");\n\twebsay(\"
\");\n\twebsay(\"\");\n\n\twebsay(\"\",n->nick);\n\twebsay(\"Your reply:\");\n\twebsay(\"
\");\n\twebsay(\"

\");\n\twebsay(\"
selection = \n\t\tg_list_remove (clipboard->selection, widget);\n\n\tif (g_list_length (clipboard->selection) == 0)\n\t\tglade_clipboard_set_has_selection (clipboard, FALSE);\n}", "label": 0, "cwe": null, "length": 95 }, { "index": 914351, "code": "object_from_reference(git_object **object, git_reference *reference)\n{\n\tgit_reference *resolved = NULL;\n\tint error;\n\n\tif (git_reference_resolve(&resolved, reference) < 0)\n\t\treturn -1;\n\n\terror = git_object_lookup(object, reference->owner, git_reference_oid(resolved), GIT_OBJ_ANY);\n\tgit_reference_free(resolved);\n\n\treturn error;\n}", "label": 0, "cwe": null, "length": 76 }, { "index": 896660, "code": "dhSearch2(char *v) {\n unsigned int i=hashU(v);\n unsigned char k=hashTwo(v);\n\n while(macros[i].name!=NULL)\n if(!strcmp(macros[i].name, v))\n return macros[i].data;\n else\n i=(i+k)%M;\n return '\\0';\n}", "label": 0, "cwe": null, "length": 73 }, { "index": 85174, "code": "find_conn_by_handle(struct dev_info *dev,\n\t\t\t\t\t\t\tuint16_t handle)\n{\n\tGSList *match;\n\n\tmatch = g_slist_find_custom(dev->connections, &handle,\n\t\t\t\t\t\t\tconn_handle_cmp);\n\tif (match)\n\t\treturn match->data;\n\n\treturn NULL;\n}", "label": 0, "cwe": null, "length": 57 }, { "index": 485337, "code": "cx88_xc5000_tuner_callback(struct cx88_core *core,\n\t\t\t\t int command, int arg)\n{\n\tswitch (core->boardnr) {\n\tcase CX88_BOARD_PINNACLE_PCTV_HD_800i:\n\t\tif (command == 0) { /* This is the reset command from xc5000 */\n\n\t\t\t/* djh - According to the engineer at PCTV Systems,\n\t\t\t the xc5000 reset pin is supposed to be on GPIO12.\n\t\t\t However, despite three nights of effort, pulling\n\t\t\t that GPIO low didn't reset the xc5000. While\n\t\t\t pulling MO_SRST_IO low does reset the xc5000, this\n\t\t\t also resets in the s5h1409 being reset as well.\n\t\t\t This causes tuning to always fail since the internal\n\t\t\t state of the s5h1409 does not match the driver's\n\t\t\t state. Given that the only two conditions in which\n\t\t\t the driver performs a reset is during firmware load\n\t\t\t and powering down the chip, I am taking out the\n\t\t\t reset. We know that the chip is being reset\n\t\t\t when the cx88 comes online, and not being able to\n\t\t\t do power management for this board is worse than\n\t\t\t not having any tuning at all. */\n\t\t\treturn 0;\n\t\t} else {\n\t\t\tdprintk(1, \"xc5000: unknown tuner callback command.\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tbreak;\n\tcase CX88_BOARD_DVICO_FUSIONHDTV_7_GOLD:\n\t\tif (command == 0) { /* This is the reset command from xc5000 */\n\t\t\tcx_clear(MO_GP0_IO, 0x00000010);\n\t\t\tmsleep(10);\n\t\t\tcx_set(MO_GP0_IO, 0x00000010);\n\t\t\treturn 0;\n\t\t} else {\n\t\t\tdprintk(1, \"xc5000: unknown tuner callback command.\\n\");\n\t\t\treturn -EINVAL;\n\t\t}\n\t\tbreak;\n\t}\n\treturn 0; /* Should never be here */\n}", "label": 0, "cwe": null, "length": 438 }, { "index": 829824, "code": "async_op_complete (AsyncOpData *op_data,\n const GError *error,\n gboolean in_idle)\n{\n\tGSimpleAsyncResult *simple;\n\n\tg_return_if_fail (op_data != NULL);\n\n\tg_atomic_int_inc (&op_data->ref_count);\n\tsimple = g_simple_async_result_new (G_OBJECT (op_data->proxy), op_data->async_callback, op_data->async_user_data, op_data->async_source_tag);\n\tg_simple_async_result_set_op_res_gpointer (simple, op_data, (GDestroyNotify) async_op_data_free);\n\tif (error)\n\t\tg_simple_async_result_set_from_error (simple, error);\n\n\tif (in_idle)\n\t\tg_simple_async_result_complete_in_idle (simple);\n\telse\n\t\tg_simple_async_result_complete (simple);\n\n\tg_object_unref (simple);\n}", "label": 0, "cwe": null, "length": 165 }, { "index": 977598, "code": "axmap_new(unsigned long nr_bits)\n{\n\tstruct axmap *axmap;\n\tunsigned int i, levels;\n\n\taxmap = malloc(sizeof(*axmap));\n\tif (!axmap)\n\t\treturn NULL;\n\n\tlevels = 1;\n\ti = (nr_bits + BLOCKS_PER_UNIT - 1) >> UNIT_SHIFT;\n\twhile (i > 1) {\n\t\ti = (i + BLOCKS_PER_UNIT - 1) >> UNIT_SHIFT;\n\t\tlevels++;\n\t}\n\n\taxmap->nr_levels = levels;\n\taxmap->levels = malloc(axmap->nr_levels * sizeof(struct axmap_level));\n\taxmap->nr_bits = nr_bits;\n\n\tfor (i = 0; i < axmap->nr_levels; i++) {\n\t\tstruct axmap_level *al = &axmap->levels[i];\n\n\t\tal->level = i;\n\t\tal->map_size = (nr_bits + BLOCKS_PER_UNIT - 1) >> UNIT_SHIFT;\n\t\tal->map = malloc(al->map_size * sizeof(unsigned long));\n\t\tif (!al->map)\n\t\t\tgoto err;\n\n\t\tnr_bits = (nr_bits + BLOCKS_PER_UNIT - 1) >> UNIT_SHIFT;\n\t}\n\n\taxmap_reset(axmap);\n\treturn axmap;\nerr:\n\tfor (i = 0; i < axmap->nr_levels; i++)\n\t\tif (axmap->levels[i].map)\n\t\t\tfree(axmap->levels[i].map);\n\n\tfree(axmap->levels);\n\tfree(axmap);\n\treturn NULL;\n}", "label": 1, "cwe": [ "CWE-120", "CWE-other" ], "length": 307 }, { "index": 331981, "code": "GetContig( const uint32 i ) const\n{\n\tif( i < m_contigList.size() ){\n\t\treturn m_contigList[i];\n\t}\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 39 }, { "index": 219453, "code": "InsideCellBounds(double x[3], vtkIdType cell_ID)\n{\n double cellBounds[6], delta[3] = {0.0, 0.0, 0.0};\n if (this->DataSet)\n {\n this->DataSet->GetCellBounds(cell_ID, cellBounds);\n return vtkMath::PointIsWithinBounds(x, cellBounds, delta)!=0;\n }\n return 0;\n}", "label": 0, "cwe": null, "length": 92 }, { "index": 719960, "code": "gt_freeEnumpatterniterator(Enumpatterniterator *epi)\n{\n if (!epi) return;\n gt_free(epi->patternspace);\n gt_free(epi->patternstat);\n gt_encseq_reader_delete(epi->esr);\n gt_free(epi);\n}", "label": 0, "cwe": null, "length": 62 }, { "index": 144403, "code": "do_command_dummy(char **argv, asciiMessage *result)\n{\n\tint i=0;\n\tsystem_write(2, \"Unknown reply from server: \\\"\", 27);\n\n\twhile(argv[i] != NULL ){\n\t\tsystem_write(2, argv[i], strlen(argv[i]) );\n\t\tsystem_write(2, \" \", 1);\n\t\ti++;\n\t}\n\n\tsystem_write(2, \"\\\"\\n\", 2);\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 89 }, { "index": 703722, "code": "currentLanguage() const\n{\n#ifdef LANGUAGEMANAGER_DEBUG\n qDebug() << \"LanguageManager::\" << __FUNCTION__;\n#endif\n if (!m_currentLanguage.isEmpty())\n return m_currentLanguage;\n\n const QString sysLanguage = QLocale::system().name();\n if (isLanguageAvailable(sysLanguage))\n return sysLanguage;\n return QString();\n}", "label": 0, "cwe": null, "length": 77 }, { "index": 489461, "code": "get_1284_register(struct parport *pp, unsigned char reg, unsigned char *val, gfp_t mem_flags)\n{\n\tstruct parport_uss720_private *priv;\n\tstruct uss720_async_request *rq;\n\tstatic const unsigned char regindex[9] = {\n\t\t4, 0, 1, 5, 5, 0, 2, 3, 6\n\t};\n\tint ret;\n\n\tif (!pp)\n\t\treturn -EIO;\n\tpriv = pp->private_data;\n\trq = submit_async_request(priv, 3, 0xc0, ((unsigned int)reg) << 8, 0, mem_flags);\n\tif (!rq) {\n\t\tdev_err(&priv->usbdev->dev, \"get_1284_register(%u) failed\",\n\t\t\t(unsigned int)reg);\n\t\treturn -EIO;\n\t}\n\tif (!val) {\n\t\tkref_put(&rq->ref_count, destroy_async);\n\t\treturn 0;\n\t}\n\tif (wait_for_completion_timeout(&rq->compl, HZ)) {\n\t\tret = rq->urb->status;\n\t\t*val = priv->reg[(reg >= 9) ? 0 : regindex[reg]];\n\t\tif (ret)\n\t\t\tprintk(KERN_WARNING \"get_1284_register: \"\n\t\t\t \"usb error %d\\n\", ret);\n\t\tkref_put(&rq->ref_count, destroy_async);\n\t\treturn ret;\n\t}\n\tprintk(KERN_WARNING \"get_1284_register timeout\\n\");\n\tkill_all_async_requests_priv(priv);\n\treturn -EIO;\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 327 }, { "index": 58901, "code": "read_unsigned(std::istream &is)\n{\n\tunsigned char b;\n\tunsigned ret = 0;\n\tunsigned shift = 0;\n\tdo {\n\t\tchar b2;\n\t\tis.get(b2);\n\t\tb = b2;\n\t\tret |= (b & 0x7f) << shift;\n\t\tshift += 7;\n\t} while (b & 0x80);\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 82 }, { "index": 726054, "code": "EncodeFromArray(const void* data, size_t len, string* result) {\n ASSERT(NULL != result);\n result->clear();\n result->reserve(((len + 2) / 3) * 4);\n const unsigned char* byte_data = static_cast(data);\n\n unsigned char c;\n size_t i = 0;\n while (i < len) {\n c = (byte_data[i] >> 2) & 0x3f;\n result->push_back(Base64Table[c]);\n\n c = (byte_data[i] << 4) & 0x3f;\n if (++i < len) {\n c |= (byte_data[i] >> 4) & 0x0f;\n }\n result->push_back(Base64Table[c]);\n\n if (i < len) {\n c = (byte_data[i] << 2) & 0x3f;\n if (++i < len) {\n c |= (byte_data[i] >> 6) & 0x03;\n }\n result->push_back(Base64Table[c]);\n } else {\n result->push_back(kPad);\n }\n\n if (i < len) {\n c = byte_data[i] & 0x3f;\n result->push_back(Base64Table[c]);\n ++i;\n } else {\n result->push_back(kPad);\n }\n }\n}", "label": 0, "cwe": null, "length": 302 }, { "index": 102500, "code": "test(char *URL)\n{\n CURLM* multi = NULL;\n int res = 0;\n char *address = libtest_arg2;\n char *port = libtest_arg3;\n char *path = URL;\n char dns_entry[256];\n int i;\n int count = 2;\n\n snprintf(dns_entry, sizeof(dns_entry), \"testserver.example.com:%s:%s\", port, address);\n\n start_test_timing();\n\n global_init(CURL_GLOBAL_ALL);\n multi_init(multi);\n\n for(i = 1; i <= count; i++) {\n char target_url[256];\n snprintf(target_url, sizeof(target_url), \"http://testserver.example.com:%s%s%04d\", port, path, i);\n\n /* second request must succeed like the first one */\n if((res = do_one_request(multi, target_url, dns_entry)))\n goto test_cleanup;\n\n if(i < count)\n sleep(DNS_TIMEOUT + 1);\n }\n\ntest_cleanup:\n\n curl_multi_cleanup(multi);\n\n return (int) res;\n}", "label": 0, "cwe": null, "length": 229 }, { "index": 428428, "code": "bwrite(int fd, void *loc, unsigned num)\n{\n bool failed;\n\n#ifdef UNIX\n if (buffering)\n {\n if(fd != bw_fd)\n panic(\"unbuffered write to fd %d (!= %d)\", fd, bw_fd);\n\n failed = (fwrite(loc, (int)num, 1, bw_FILE) != 1);\n }\n else\n#endif /* UNIX */\n {\n /* lint wants the 3rd arg of write to be an int; lint -p an unsigned */\n#if defined(BSD) || defined(ULTRIX)\n failed = (write(fd, loc, (int)num) != (int)num);\n#else /* e.g. SYSV, __TURBOC__ */\n failed = (write(fd, loc, num) != num);\n#endif\n }\n\n if (failed)\n {\n#if defined(UNIX) || defined(VMS) || defined(__EMX__)\n if (program_state.done_hup)\n terminate(EXIT_FAILURE);\n else\n#endif\n panic(\"cannot write %u bytes to file #%d\", num, fd);\n }\n}", "label": 0, "cwe": null, "length": 239 }, { "index": 114958, "code": "overlay_tree_on_cache(const char *tree_name, const char *prefix)\n{\n\tstruct tree *tree;\n\tunsigned char sha1[20];\n\tconst char **match;\n\tstruct cache_entry *last_stage0 = NULL;\n\tint i;\n\n\tif (get_sha1(tree_name, sha1))\n\t\tdie(\"tree-ish %s not found.\", tree_name);\n\ttree = parse_tree_indirect(sha1);\n\tif (!tree)\n\t\tdie(\"bad tree-ish %s\", tree_name);\n\n\t/* Hoist the unmerged entries up to stage #3 to make room */\n\tfor (i = 0; i < active_nr; i++) {\n\t\tstruct cache_entry *ce = active_cache[i];\n\t\tif (!ce_stage(ce))\n\t\t\tcontinue;\n\t\tce->ce_flags |= CE_STAGEMASK;\n\t}\n\n\tif (prefix) {\n\t\tstatic const char *(matchbuf[2]);\n\t\tmatchbuf[0] = prefix;\n\t\tmatchbuf[1] = NULL;\n\t\tmatch = matchbuf;\n\t} else\n\t\tmatch = NULL;\n\tif (read_tree(tree, 1, match))\n\t\tdie(\"unable to read tree entries %s\", tree_name);\n\n\tfor (i = 0; i < active_nr; i++) {\n\t\tstruct cache_entry *ce = active_cache[i];\n\t\tswitch (ce_stage(ce)) {\n\t\tcase 0:\n\t\t\tlast_stage0 = ce;\n\t\t\t/* fallthru */\n\t\tdefault:\n\t\t\tcontinue;\n\t\tcase 1:\n\t\t\t/*\n\t\t\t * If there is stage #0 entry for this, we do not\n\t\t\t * need to show it. We use CE_UPDATE bit to mark\n\t\t\t * such an entry.\n\t\t\t */\n\t\t\tif (last_stage0 &&\n\t\t\t !strcmp(last_stage0->name, ce->name))\n\t\t\t\tce->ce_flags |= CE_UPDATE;\n\t\t}\n\t}\n}", "label": 1, "cwe": [ "CWE-119", "CWE-120" ], "length": 383 }, { "index": 216100, "code": "getFalse(LLVMContext &Context) {\n LLVMContextImpl *pImpl = Context.pImpl;\n if (pImpl->TheFalseVal)\n return pImpl->TheFalseVal;\n else\n return (pImpl->TheFalseVal =\n ConstantInt::get(IntegerType::get(Context, 1), 0));\n}", "label": 0, "cwe": null, "length": 72 }, { "index": 179918, "code": "shm_mem_destroy(void)\n{\n#ifndef SHM_MMAP\n\tstruct shmid_ds shm_info;\n#endif\n\t\n\tLM_DBG(\"\\n\");\n\tif (mem_lock){\n\t\tLM_DBG(\"destroying the shared memory lock\\n\");\n\t\tlock_destroy(mem_lock); /* we don't need to dealloc it*/\n\t}\n\tif (shm_mempool && (shm_mempool!=(void*)-1)) {\n#ifdef SHM_MMAP\n\t\tmunmap(shm_mempool, /* SHM_MEM_SIZE */ shm_mem_size );\n#else\n\t\tshmdt(shm_mempool);\n#endif\n\t\tshm_mempool=(void*)-1;\n\t}\n#ifndef SHM_MMAP\n\tif (shm_shmid!=-1) {\n\t\tshmctl(shm_shmid, IPC_RMID, &shm_info);\n\t\tshm_shmid=-1;\n\t}\n#endif\n}", "label": 0, "cwe": null, "length": 181 }, { "index": 471819, "code": "mantis_dma_init(struct mantis_pci *mantis)\n{\n\tint err;\n\n\tdprintk(MANTIS_DEBUG, 1, \"Mantis DMA init\");\n\terr = mantis_alloc_buffers(mantis);\n\tif (err < 0) {\n\t\tdprintk(MANTIS_ERROR, 1, \"Error allocating DMA buffer\");\n\n\t\t/* Stop RISC Engine */\n\t\tmmwrite(0, MANTIS_DMA_CTL);\n\n\t\treturn err;\n\t}\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 101 }, { "index": 540305, "code": "yy_braces()\n{ int yypos0= yypos, yythunkpos0= yythunkpos;\n yyprintf((stderr, \"%s\\n\", \"braces\"));\n { int yypos14= yypos, yythunkpos14= yythunkpos; if (!yymatchChar('{')) goto l15;\n l16:;\t\n { int yypos17= yypos, yythunkpos17= yythunkpos;\n { int yypos18= yypos, yythunkpos18= yythunkpos; if (!yymatchChar('}')) goto l18; goto l17;\n l18:;\t yypos= yypos18; yythunkpos= yythunkpos18;\n } if (!yymatchDot()) goto l17; goto l16;\n l17:;\t yypos= yypos17; yythunkpos= yythunkpos17;\n } if (!yymatchChar('}')) goto l15; goto l14;\n l15:;\t yypos= yypos14; yythunkpos= yythunkpos14;\n { int yypos19= yypos, yythunkpos19= yythunkpos; if (!yymatchChar('}')) goto l19; goto l13;\n l19:;\t yypos= yypos19; yythunkpos= yythunkpos19;\n } if (!yymatchDot()) goto l13;\n }\n l14:;\t\n yyprintf((stderr, \" ok %s @ %s\\n\", \"braces\", yybuf+yypos));\n return 1;\n l13:;\t yypos= yypos0; yythunkpos= yythunkpos0;\n yyprintf((stderr, \" fail %s @ %s\\n\", \"braces\", yybuf+yypos));\n return 0;\n}", "label": 0, "cwe": null, "length": 431 }, { "index": 994302, "code": "firestream_init_one(struct pci_dev *pci_dev,\n\t\t\t const struct pci_device_id *ent)\n{\n\tstruct atm_dev *atm_dev;\n\tstruct fs_dev *fs_dev;\n\t\n\tif (pci_enable_device(pci_dev)) \n\t\tgoto err_out;\n\n\tfs_dev = kzalloc (sizeof (struct fs_dev), GFP_KERNEL);\n\tfs_dprintk (FS_DEBUG_ALLOC, \"Alloc fs-dev: %p(%Zd)\\n\",\n\t\t fs_dev, sizeof (struct fs_dev));\n\tif (!fs_dev)\n\t\tgoto err_out;\n\tatm_dev = atm_dev_register(\"fs\", &pci_dev->dev, &ops, -1, NULL);\n\tif (!atm_dev)\n\t\tgoto err_out_free_fs_dev;\n \n\tfs_dev->pci_dev = pci_dev;\n\tfs_dev->atm_dev = atm_dev;\n\tfs_dev->flags = ent->driver_data;\n\n\tif (fs_init(fs_dev))\n\t\tgoto err_out_free_atm_dev;\n\n\tfs_dev->next = fs_boards;\n\tfs_boards = fs_dev;\n\treturn 0;\n\n err_out_free_atm_dev:\n\tatm_dev_deregister(atm_dev);\n err_out_free_fs_dev:\n \tkfree(fs_dev);\n err_out:\n\treturn -ENODEV;\n}", "label": 0, "cwe": null, "length": 251 }, { "index": 584279, "code": "gnc_cellblock_changed (CellBlock *cursor, gboolean include_conditional)\n{\n int changed = 0;\n int r, c;\n\n if (!cursor)\n return FALSE;\n\n for (r = 0; r < cursor->num_rows; r++)\n for (c = 0; c < cursor->num_cols; c++)\n {\n BasicCell *cell;\n\n cell = gnc_cellblock_get_cell (cursor, r, c);\n if (cell == NULL)\n continue;\n\n if (gnc_basic_cell_get_changed (cell))\n {\n changed++;\n continue;\n }\n\n if (include_conditional &&\n gnc_basic_cell_get_conditionally_changed (cell))\n changed++;\n }\n\n return changed;\n}", "label": 0, "cwe": null, "length": 159 }, { "index": 462152, "code": "vme_master_free(struct vme_resource *resource)\n{\n\tstruct vme_master_resource *master_image;\n\n\tif (resource->type != VME_MASTER) {\n\t\tprintk(KERN_ERR \"Not a master resource\\n\");\n\t\treturn;\n\t}\n\n\tmaster_image = list_entry(resource->entry, struct vme_master_resource,\n\t\tlist);\n\tif (master_image == NULL) {\n\t\tprintk(KERN_ERR \"Can't find master resource\\n\");\n\t\treturn;\n\t}\n\n\t/* Unlock image */\n\tspin_lock(&master_image->lock);\n\tif (master_image->locked == 0)\n\t\tprintk(KERN_ERR \"Image is already free\\n\");\n\n\tmaster_image->locked = 0;\n\tspin_unlock(&master_image->lock);\n\n\t/* Free up resource memory */\n\tkfree(resource);\n}", "label": 0, "cwe": null, "length": 155 }, { "index": 571369, "code": "performmode_relative_id(const char *id, GEN_PERFORM_MODE pmode) {\n return GBS_global_string(\"%s_%s\", GEN_PERFORM_MODE_id[pmode], id);\n}", "label": 0, "cwe": null, "length": 41 }, { "index": 87395, "code": "mpfr_sum_sort (mpfr_srcptr *const tab, unsigned long n, mpfr_srcptr *perm)\n{\n mpfr_exp_t min, max;\n mpfr_uexp_t exp_num;\n unsigned long i;\n int sign_inf;\n\n sign_inf = 0;\n min = MPFR_EMIN_MAX;\n max = MPFR_EMAX_MIN;\n for (i = 0; i < n; i++)\n {\n if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (tab[i])))\n {\n if (MPFR_IS_NAN (tab[i]))\n return 2; /* Return NAN code */\n else if (MPFR_IS_INF (tab[i]))\n {\n if (sign_inf == 0) /* No previous INF */\n sign_inf = MPFR_SIGN (tab[i]);\n else if (sign_inf != MPFR_SIGN (tab[i]))\n return 2; /* Return NAN */\n }\n }\n else\n {\n MPFR_ASSERTD (MPFR_IS_PURE_FP (tab[i]));\n if (MPFR_GET_EXP (tab[i]) < min)\n min = MPFR_GET_EXP(tab[i]);\n if (MPFR_GET_EXP (tab[i]) > max)\n max = MPFR_GET_EXP(tab[i]);\n }\n }\n if (MPFR_UNLIKELY (sign_inf != 0))\n return sign_inf;\n\n exp_num = max - min + 1;\n /* FIXME : better test */\n if (exp_num > n * MPFR_INT_CEIL_LOG2 (n))\n heap_sort (tab, n, perm);\n else\n count_sort (tab, n, perm, min, exp_num);\n return 0;\n}", "label": 0, "cwe": null, "length": 362 }, { "index": 298381, "code": "camKeypointsMatching2(CamKeypoints *points1, CamKeypoints *points2, CamKeypointsMatches *matches)\r\n{\r\n int i, dist1, dist2;\r\n CamKeypoint *best;\r\n matches->nbMatches = 0;\r\n matches->nbOutliers = 0;\r\n\r\n for (i = 0; i < points1->nbPoints; i++) {\r\n\tbest = camFindKeypoint(points1->keypoint[i], points2, &dist1, &dist2);\r\n\tif (dist1 < 0.8 * dist2) {\r\n \t matches->pairs[matches->nbMatches].p1 = points1->keypoint[i];\r\n \t matches->pairs[matches->nbMatches].p2 = best;\r\n \t matches->pairs[matches->nbMatches].mark = dist1;\r\n\t matches->nbMatches++;\r\n\t if (matches->nbMatches == matches->allocated) break;\r\n\t}\r\n }\r\n return matches->nbMatches;\r\n}", "label": 0, "cwe": null, "length": 210 }, { "index": 27102, "code": "BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx)\n\t{\n\tint ret = 0;\n\tconst int max = BN_num_bits(p) + 1;\n\tint *arr=NULL;\n\tbn_check_top(a);\n\tbn_check_top(b);\n\tbn_check_top(p);\n\tif ((arr = (int *)OPENSSL_malloc(sizeof(int) * max)) == NULL) goto err;\n\tret = BN_GF2m_poly2arr(p, arr, max);\n\tif (!ret || ret > max)\n\t\t{\n\t\tBNerr(BN_F_BN_GF2M_MOD_MUL,BN_R_INVALID_LENGTH);\n\t\tgoto err;\n\t\t}\n\tret = BN_GF2m_mod_mul_arr(r, a, b, arr, ctx);\n\tbn_check_top(r);\nerr:\n\tif (arr) OPENSSL_free(arr);\n\treturn ret;\n\t}", "label": 0, "cwe": null, "length": 199 }, { "index": 980384, "code": "ipvideo_decode_0x2 (const GstMveDemuxStream * s, unsigned char *frame,\n const unsigned char **data, unsigned short *len)\n{\n unsigned char B;\n int x, y;\n int offset;\n\n /* copy block from 2 frames ago using a motion vector */\n CHECK_STREAM (len, 1);\n B = *(*data)++;\n\n if (B < 56) {\n x = 8 + (B % 7);\n y = B / 7;\n } else {\n x = -14 + ((B - 56) % 29);\n y = 8 + ((B - 56) / 29);\n }\n offset = y * s->width + x;\n\n return ipvideo_copy_block (s, frame, frame + offset, offset);\n}", "label": 0, "cwe": null, "length": 178 }, { "index": 318655, "code": "Open( const char * pszFilename, int bUpdate )\r\n\r\n{\r\n OGRMSSQLSpatialDataSource *poDS;\r\n\r\n if( !EQUALN(pszFilename,\"MSSQL:\",6) )\r\n return NULL;\r\n\r\n poDS = new OGRMSSQLSpatialDataSource();\r\n\r\n if( !poDS->Open( pszFilename, bUpdate, TRUE ) )\r\n {\r\n delete poDS;\r\n return NULL;\r\n }\r\n else\r\n return poDS;\r\n}", "label": 0, "cwe": null, "length": 101 }, { "index": 733022, "code": "emergency (void)\n{\n string name = \"emergency\";\n\n\n try {\n if (crbox) crbox->mbksave (name);\n }\n\n catch (...) {\n cerr << herr (\"\\n\");\n cerr << \" An exception have occurs in the emergency backup function itself !\\n\";\n cerr << \" Sorry, can't save the partially routed figure.\\n\\n\";\n cerr << \" This is a bug. Please e-mail to \\\"alliance-users@asim.lip6.fr\\\".\\n\\n\";\n }\n}", "label": 0, "cwe": null, "length": 115 }, { "index": 451335, "code": "_strip_escapes(char *line)\n{\n\tint i, j;\n\tint len = strlen(line);\n\n\tfor (i = 0, j = 0; i < len+1; i++, j++) {\n\t\tif (line[i] == '\\\\')\n\t\t\ti++;\n\t\tline[j] = line[i];\n\t}\n}", "label": 0, "cwe": null, "length": 66 }, { "index": 119846, "code": "process(LEGlyphStorage &glyphStorage) const\n{\n SubtableProcessor2 *processor = NULL;\n\n switch (SWAPL(coverage) & scfTypeMask2)\n {\n case mstIndicRearrangement:\n processor = new IndicRearrangementProcessor2(this);\n break;\n\n case mstContextualGlyphSubstitution:\n processor = new ContextualGlyphSubstitutionProcessor2(this);\n break;\n\n case mstLigatureSubstitution:\n processor = new LigatureSubstitutionProcessor2(this);\n break;\n\n case mstReservedUnused:\n break;\n\n case mstNonContextualGlyphSubstitution:\n processor = NonContextualGlyphSubstitutionProcessor2::createInstance(this);\n break;\n\n \n case mstContextualGlyphInsertion:\n processor = new ContextualGlyphInsertionProcessor2(this);\n break;\n\n default:\n break;\n }\n\n if (processor != NULL) {\n processor->process(glyphStorage);\n delete processor;\n }\n}", "label": 0, "cwe": null, "length": 218 }, { "index": 405022, "code": "bool_set(void *ptr, PyObject *value, Py_ssize_t size)\n{\n switch (PyObject_IsTrue(value)) {\n case -1:\n return NULL;\n case 0:\n *(BOOL_TYPE *)ptr = 0;\n _RET(value);\n default:\n *(BOOL_TYPE *)ptr = 1;\n _RET(value);\n }\n}", "label": 0, "cwe": null, "length": 77 }, { "index": 93642, "code": "Java_ncsa_hdf_hdf5lib_H5_H5Inmembers\n (JNIEnv *env, jclass clss, jint type)\n{\n herr_t retVal;\n hsize_t num_members;\n\n retVal = H5Inmembers((H5I_type_t)type, &num_members);\n\n if (retVal <0){\n h5libraryError(env);\n }\n\n return (jint)num_members;\n\n}", "label": 0, "cwe": null, "length": 90 }, { "index": 35884, "code": "wait_for_results(int wu_id) {\n DB_RESULT result;\n int count, retval;\n char buf[256];\n\n sprintf(buf, \"where workunitid=%d\", wu_id);\n while (1) {\n retval = result.count(count, buf);\n log_messages.printf(MSG_DEBUG, \"result.count for %d returned %d, error: %s\\n\",\n wu_id, count, boincerror(retval)\n );\n if (retval) {\n log_messages.printf(MSG_CRITICAL, \"result.count: %s\\n\", boincerror(retval));\n exit(1);\n }\n if (count > 0) return;\n daemon_sleep(10);\n check_stop_daemons();\n }\n}", "label": 0, "cwe": null, "length": 153 }, { "index": 477089, "code": "shiftHoles() {\n\t// vias and holes before version 0.7.3 did not have offset\n\n\tVersionThing versionThingOffset;\n\tversionThingOffset.majorVersion = 0;\n\tversionThingOffset.minorVersion = 7;\n\tversionThingOffset.minorSubVersion = 2;\n\tversionThingOffset.releaseModifier = \"b\";\n\tVersionThing versionThingFz;\n\tVersion::toVersionThing(m_sketchModel->fritzingVersion(), versionThingFz);\n\tbool doShift = !Version::greaterThan(versionThingOffset, versionThingFz);\n\tif (!doShift) return;\n\n\tforeach (QGraphicsItem * item, scene()->items()) {\n\t\tItemBase * itemBase = dynamic_cast(item);\n\t\tif (itemBase == NULL) continue;\n\n\t\tswitch (itemBase->itemType()) {\n\t\t\tcase ModelPart::Via:\n\t\t\tcase ModelPart::Hole:\n\t\t\t\titemBase->setPos(itemBase->pos().x() - (Hole::OffsetPixels / 2), itemBase->pos().y() - (Hole::OffsetPixels / 2));\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tcontinue;\n\t\t}\t\t\n\t}\n}", "label": 0, "cwe": null, "length": 242 }, { "index": 605304, "code": "message_view_store_get_path(GtkTreeModel * tree_model, GtkTreeIter * iter)\n{\n\tGtkTreePath *retval;\n\tmessage_view_store_t *store = (message_view_store_t *) tree_model;\n\tg_return_val_if_fail(SEAUDIT_IS_MESSAGE_VIEW_STORE(tree_model), NULL);\n\tg_return_val_if_fail(iter->stamp == store->stamp, NULL);\n\tretval = gtk_tree_path_new();\n\tgtk_tree_path_append_index(retval, GPOINTER_TO_INT(iter->user_data2));\n\treturn retval;\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 114450, "code": "dialog_data_unref (DialogData *data)\n{\n if (g_atomic_int_dec_and_test (&data->ref_count))\n {\n if (data->dialog != NULL)\n {\n gtk_widget_hide (data->dialog);\n gtk_widget_destroy (data->dialog);\n }\n if (data->object != NULL)\n g_object_unref (data->object);\n if (data->window != NULL)\n g_object_unref (data->window);\n if (data->builder != NULL)\n g_object_unref (data->builder);\n\n if (data->attributes_list != NULL)\n g_object_unref (data->attributes_list);\n\n g_free (data);\n }\n}", "label": 0, "cwe": null, "length": 142 }, { "index": 616348, "code": "Z_set(void *ptr, PyObject *value, Py_ssize_t size)\n{\n PyObject *keep;\n wchar_t *buffer;\n\n if (value == Py_None) {\n *(wchar_t **)ptr = NULL;\n Py_INCREF(value);\n return value;\n }\n if (PyLong_Check(value) || PyLong_Check(value)) {\n#if SIZEOF_VOID_P == SIZEOF_LONG_LONG\n *(wchar_t **)ptr = (wchar_t *)PyLong_AsUnsignedLongLongMask(value);\n#else\n *(wchar_t **)ptr = (wchar_t *)PyLong_AsUnsignedLongMask(value);\n#endif\n Py_INCREF(Py_None);\n return Py_None;\n }\n if (!PyUnicode_Check(value)) {\n PyErr_Format(PyExc_TypeError,\n \"unicode string or integer address expected instead of %s instance\",\n value->ob_type->tp_name);\n return NULL;\n }\n\n /* We must create a wchar_t* buffer from the unicode object,\n and keep it alive */\n buffer = PyUnicode_AsWideCharString(value, NULL);\n if (!buffer)\n return NULL;\n keep = PyCapsule_New(buffer, CTYPES_CFIELD_CAPSULE_NAME_PYMEM, pymem_destructor);\n if (!keep) {\n PyMem_Free(buffer);\n return NULL;\n }\n *(wchar_t **)ptr = buffer;\n return keep;\n}", "label": 0, "cwe": null, "length": 286 }, { "index": 45620, "code": "convertInitListSlice(const std::vector &Elements) const {\n ListRecTy *T = dynamic_cast(getType());\n if (T == 0) return 0; // Cannot subscript a non-list variable.\n\n if (Elements.size() == 1)\n return VarListElementInit::get(const_cast(this), Elements[0]);\n\n std::vector ListInits;\n ListInits.reserve(Elements.size());\n for (unsigned i = 0, e = Elements.size(); i != e; ++i)\n ListInits.push_back(VarListElementInit::get(const_cast(this),\n Elements[i]));\n return ListInit::get(ListInits, T);\n}", "label": 0, "cwe": null, "length": 161 }, { "index": 225864, "code": "DeleteCharacter (int count) {\n if (_dot != _mark) {\n DeleteSelection();\n } else {\n DeleteText(count);\n }\n}", "label": 0, "cwe": null, "length": 33 }, { "index": 388149, "code": "g2d_queue_setup(struct vb2_queue *vq, const void *parg,\n\t\t\t unsigned int *nbuffers, unsigned int *nplanes,\n\t\t\t unsigned int sizes[], void *alloc_ctxs[])\n{\n\tstruct g2d_ctx *ctx = vb2_get_drv_priv(vq);\n\tstruct g2d_frame *f = get_frame(ctx, vq->type);\n\n\tif (IS_ERR(f))\n\t\treturn PTR_ERR(f);\n\n\tsizes[0] = f->size;\n\t*nplanes = 1;\n\talloc_ctxs[0] = ctx->dev->alloc_ctx;\n\n\tif (*nbuffers == 0)\n\t\t*nbuffers = 1;\n\n\treturn 0;\n}", "label": 0, "cwe": null, "length": 144 }, { "index": 55091, "code": "unmarshalWChar(cdrStream& stream)\n{\n omniCodeSet::UniChar uc;\n _CORBA_Octet len = stream.unmarshalOctet();\n _CORBA_Octet o;\n\n switch (len) {\n case 0:\n uc = 0; // Evil but it might happen, I suppose\n break;\n case 1:\n o = stream.unmarshalOctet();\n uc = o;\n break;\n case 2:\n {\n _CORBA_Octet* p = (_CORBA_Octet*)&uc;\n if (stream.unmarshal_byte_swap()) {\n\to = stream.unmarshalOctet(); p[1] = o;\n\to = stream.unmarshalOctet(); p[0] = o;\n }\n else {\n\to = stream.unmarshalOctet(); p[0] = o;\n\to = stream.unmarshalOctet(); p[1] = o;\n }\n }\n break;\n case 4:\n {\n _CORBA_ULong tc;\n _CORBA_Octet* p = (_CORBA_Octet*)&tc;\n if (stream.unmarshal_byte_swap()) {\n\to = stream.unmarshalOctet(); p[3] = o;\n\to = stream.unmarshalOctet(); p[2] = o;\n\to = stream.unmarshalOctet(); p[1] = o;\n\to = stream.unmarshalOctet(); p[0] = o;\n }\n else {\n\to = stream.unmarshalOctet(); p[0] = o;\n\to = stream.unmarshalOctet(); p[1] = o;\n\to = stream.unmarshalOctet(); p[2] = o;\n\to = stream.unmarshalOctet(); p[3] = o;\n }\n if (tc > 0xffff)\n\tOMNIORB_THROW(DATA_CONVERSION, DATA_CONVERSION_CannotMapChar,\n\t\t (CORBA::CompletionStatus)stream.completion());\n uc = tc;\n }\n break;\n default:\n OMNIORB_THROW(MARSHAL, MARSHAL_InvalidWCharSize,\n\t\t (CORBA::CompletionStatus)stream.completion());\n }\n return uc;\n}", "label": 1, "cwe": "CWE-other", "length": 469 }, { "index": 956576, "code": "readwrite(wsym,strom)\ntruc wsym; /* writesym or writlnsym */\ntruc *strom;\n{\n truc *savptr;\n truc fun;\n truc obj;\n int tok, chk;\n int n = 0;\n\n savptr = argStkPtr;\n tok = nexttok(strom,1); /* ueberlese linke Klammer */\n while(tok != RPARENTOK) {\n obj = readexpr(strom,0);\n if(obj == parserrsym)\n goto cleanup;\n else {\n PARSpush(obj);\n n++;\n }\n tok = skipeoltok(strom);\n if(tok == COLONTOK) {\n obj = readformat(strom,&tok);\n if(obj == parserrsym)\n goto cleanup;\n PARSpush(obj);\n obj = mkbnode(formatsym);\n PARSpop();\n *argStkPtr = obj;\n }\n if(tok == COMMATOK)\n nexttok(strom,1);\n else if(tok != RPARENTOK) {\n rerror(parserrsym,err_0rparen,voidsym);\n obj = parserrsym;\n goto cleanup;\n }\n }\n nexttok(strom,0);\n\n fun = SYMbind(wsym); /* write_sym or writln_sym */\n chk = chknargs(fun,n);\n\n if(chk == NARGS_VAR)\n obj = mkfunode(fun,n);\n else {\n rerror(fun,err_args,voidsym);\n obj = parserrsym;\n }\n cleanup:\n argStkPtr = savptr;\n return(obj);\n}", "label": 0, "cwe": null, "length": 354 }, { "index": 450099, "code": "winsdelln(WINDOW *win, int n)\n{\n int code = ERR;\n\n T((T_CALLED(\"winsdelln(%p,%d)\"), win, n));\n\n if (win) {\n\tif (n != 0) {\n\t _nc_scroll_window(win, -n, win->_cury, win->_maxy,\n\t\t\t win->_nc_bkgd);\n\t _nc_synchook(win);\n\t}\n\tcode = OK;\n }\n returnCode(code);\n}", "label": 0, "cwe": null, "length": 104 }, { "index": 13169, "code": "putboxmask (int x, int y, int w, int h, void *b)\n{\n uchar *bp = b;\n uchar *vp;\n int i;\n ASSIGNVP8 (x, y, vp);\n for (i = 0; i < h; i++)\n {\n uchar *endoflinebp = bp + w;\n#ifdef __i386__\n while (bp < endoflinebp - 3)\n\t{\n\t unsigned int c4 = *(unsigned int *) bp;\n\t if ((c4 & 0xff) != notusedc)\n\t *vp = (uchar) c4;\n\t c4 >>= 8;\n\t if ((c4 & 0xff) != notusedc)\n\t *(vp + 1) = (uchar) c4;\n\t c4 >>= 8;\n\t if ((c4 & 0xff) != notusedc)\n\t *(vp + 2) = (uchar) c4;\n\t c4 >>= 8;\n\t if ((c4 & 0xff) != notusedc)\n\t *(vp + 3) = (uchar) c4;\n\t bp += 4;\n\t vp += 4;\n\t}\n#endif\n while (bp < endoflinebp)\n\t{\n\t uchar c = *bp;\n\t if (c != notusedc)\n\t *vp = c;\n\t bp++;\n\t vp++;\n\t}\n vp += MAPWIDTH - w;\n }\n}", "label": 0, "cwe": null, "length": 317 }, { "index": 126465, "code": "neb2_regen()\n{\n\tint idx;\n\tvec3d eye_pos;\n\tmatrix eye_orient;\n\n\tmprintf((\"Regenerating local nebula!\\n\"));\n\n\t// get eye position and orientation\n\tneb2_get_eye_pos(&eye_pos);\n\tneb2_get_eye_orient(&eye_orient);\n\n\t// determine the corner of the cube\n\tcube_cen = eye_pos;\n\n\t// generate slices of the cube\n\tfor (idx=0; idxwork, radeon_mn_destroy);\n\tschedule_work(&rmn->work);\n}", "label": 0, "cwe": null, "length": 68 }, { "index": 333988, "code": "analyzemove(int direction,int src) {\n int target = src+direction;\n if (!tb[target]) {\n if (!tb[target+direction]) is_protected[target] = 1;\n piece a = tb[src]; tb[src] = EMPTY;\n if (check(target,4) || check(target,5) ||\n\tcheck(target,-4) || check(target,-5) ||\n\t(tb[src+4]&ENEMY && check(src+4,4)) ||\n\t(tb[src+5]&ENEMY && check(src+5,5)) ||\n\t(tb[src-4]&ENEMY && check(src-4,-4)) ||\n\t(tb[src-5]&ENEMY && check(src-5,-5)))\n deniedmoves++;\n else undeniedmoves++;\n tb[src] = a;\n }\n}", "label": 0, "cwe": null, "length": 170 }, { "index": 61818, "code": "parse_uint(char const **arg, int comma, int defval)\n{\n\tunsigned long ul;\n\tint ret;\n\tchar *endp;\n\n\tul = strtoul(*arg, &endp, 10);\n\tif (*endp && *endp != comma)\n\t\treturn -1;\n\tif (ul > INT_MAX)\n\t\treturn -1;\n\tret = *arg == endp ? defval : (int)ul;\n\t*arg = *endp ? endp + 1 : endp;\n\treturn ret;\n}", "label": 0, "cwe": null, "length": 108 }, { "index": 268477, "code": "gui_set_widgets_status (gboolean mode, GUI *appGUI) {\n\n gtk_widget_set_sensitive (appGUI->romaji_entry, !mode);\n gtk_widget_set_sensitive (appGUI->frame_ro, !mode);\n\n if (mode) {\n gtk_widget_show (appGUI->start_button);\n gtk_widget_show (appGUI->quit_button);\n gtk_widget_hide (appGUI->stop_button);\n\n gtk_widget_show (appGUI->stat_button);\n gtk_widget_show (appGUI->about_button);\n gtk_widget_show (appGUI->prefs_button);\n gtk_widget_show (appGUI->chart_button);\n\n gtk_widget_hide (appGUI->timer_label);\n\n } else {\n gtk_widget_hide (appGUI->start_button);\n gtk_widget_hide (appGUI->quit_button);\n gtk_widget_show (appGUI->stop_button);\n\n gtk_widget_hide (appGUI->stat_button);\n gtk_widget_hide (appGUI->about_button);\n gtk_widget_hide (appGUI->prefs_button);\n gtk_widget_hide (appGUI->chart_button);\n\n gtk_widget_show (appGUI->timer_label);\n }\n\n gtk_widget_set_sensitive (appGUI->combobox_kana_mode, mode);\n gtk_widget_set_sensitive (appGUI->combobox_lesson, mode);\n gtk_widget_set_sensitive (appGUI->label_ka, mode);\n gtk_widget_set_sensitive (appGUI->label_le, mode);\n}", "label": 0, "cwe": null, "length": 297 }, { "index": 658398, "code": "InsertApplication(\n Interactor* i, IntCoord left, IntCoord bottom, Alignment a\n) {\n delete i->insert_window;\n ApplicationWindow* w = new ApplicationWindow(i);\n i->insert_window = w;\n i->managed_window = w;\n w->display(display_);\n w->pplace(left, bottom);\n AlignPosition(w, a);\n w->map();\n Handler* h = i->handler_;\n w->focus_event(h, h);\n}", "label": 0, "cwe": null, "length": 103 }, { "index": 486509, "code": "stv090x_read_signal_strength(struct dvb_frontend *fe, u16 *strength)\n{\n\tstruct stv090x_state *state = fe->demodulator_priv;\n\tu32 reg;\n\ts32 agc_0, agc_1, agc;\n\ts32 str;\n\n\treg = STV090x_READ_DEMOD(state, AGCIQIN1);\n\tagc_1 = STV090x_GETFIELD_Px(reg, AGCIQ_VALUE_FIELD);\n\treg = STV090x_READ_DEMOD(state, AGCIQIN0);\n\tagc_0 = STV090x_GETFIELD_Px(reg, AGCIQ_VALUE_FIELD);\n\tagc = MAKEWORD16(agc_1, agc_0);\n\n\tstr = stv090x_table_lookup(stv090x_rf_tab,\n\t\tARRAY_SIZE(stv090x_rf_tab) - 1, agc);\n\tif (agc > stv090x_rf_tab[0].read)\n\t\tstr = 0;\n\telse if (agc < stv090x_rf_tab[ARRAY_SIZE(stv090x_rf_tab) - 1].read)\n\t\tstr = -100;\n\t*strength = (str + 100) * 0xFFFF / 100;\n\n\treturn 0;\n}", "label": 1, "cwe": [ "CWE-120", "CWE-other" ], "length": 267 }, { "index": 22290, "code": "_e2_window_set_icon (void)\n{\n\tgchar *icons_dir = e2_utils_get_icons_path (FALSE);\n\tDIR *d = e2_fs_dir_open (icons_dir);\n\tif (d == NULL)\n\t{\n\t\tprintd (WARN, \"could not open window icon directory '%s' (%s)\",\n\t\t\ticons_dir, g_strerror (errno));\n\t\tg_free (icons_dir);\n\t\tgtk_window_set_default_icon_name (BINNAME);\n\t\treturn;\n\t}\n\tGList *list = NULL;\n\tconst gchar *name;\t//name is like \"emelfm2_24.png\"\n\tgchar *base = BINNAME\"_\";\t//this is the 'prefix' for window icon filenames\n\tguint len = strlen (base) + 6;\t//assuming ascii, +6 allows for xx.png, filters out the 'alternates'\n\tstruct dirent entry;\n\tstruct dirent *entryptr;\n\twhile (TRUE)\n\t{\n\t\tif (e2_fs_dir_read (d, &entry, &entryptr) || entryptr == NULL)\n\t\t\t\tbreak;\n\t\tname = entry.d_name;\n\t\tif (g_str_has_prefix (name, base) && g_str_has_suffix (name, \".png\") &&\n\t\t\tstrlen (name) == len)\n\t\t{\n\t\t\tgchar *file = g_build_filename (icons_dir, name, NULL);\n\t\t\tGError *error = NULL;\n\t\t\tGdkPixbuf *pixbuf = gdk_pixbuf_new_from_file (file, &error);\n\t\t\tif (error != NULL)\n\t\t\t{\n\t\t\t\tprintd (WARN, \"could not open image file '%s' (%s)\", file, error->message);\n\t\t\t\tg_free (file);\n\t\t\t\tg_error_free (error);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tg_free (file);\n\t\t\tlist = g_list_append (list, pixbuf);\n\t\t}\n\t}\n\tif (list != NULL)\n\t{\n\t\tgtk_window_set_default_icon_list (list);\n\t\t//gtk copies list and ref's its items, so cleanup here\n\t\tg_list_foreach (list, (GFunc) g_object_unref, NULL);\n\t\tg_list_free (list);\n\t}\n\tg_free (icons_dir);\n\te2_fs_dir_close (d);\n}", "label": 0, "cwe": null, "length": 462 }, { "index": 656616, "code": "dcc_chat_msg(CHAT_DCC_REC *dcc, const char *msg)\n{\n\tchar *event, *cmd, *ptr;\n\tint reply;\n\n\tg_return_if_fail(IS_DCC_CHAT(dcc));\n\tg_return_if_fail(msg != NULL);\n\n\treply = FALSE;\n\tif (g_ascii_strncasecmp(msg, \"CTCP_MESSAGE \", 13) == 0) {\n\t\t/* bitchx (and ircii?) sends this */\n\t\tmsg += 13;\n\t\tdcc->mirc_ctcp = FALSE;\n\t} else if (g_ascii_strncasecmp(msg, \"CTCP_REPLY \", 11) == 0) {\n\t\t/* bitchx (and ircii?) sends this */\n\t\tmsg += 11;\n\t\treply = TRUE;\n\t\tdcc->mirc_ctcp = FALSE;\n\t} else if (*msg == 1) {\n\t\t/* Use the mirc style CTCPs from now on.. */\n\t\tdcc->mirc_ctcp = TRUE;\n\t}\n\n\t/* Handle only DCC CTCPs */\n\tif (*msg != 1)\n\t\treturn;\n\n\t/* get ctcp command, remove \\001 chars */\n\tevent = g_strconcat(reply ? \"dcc reply \" : \"dcc ctcp \", msg+1, NULL);\n\tif (event[strlen(event)-1] == 1) event[strlen(event)-1] = '\\0';\n\n cmd = event + (reply ? 10 : 9);\n\tptr = strchr(cmd, ' ');\n\tif (ptr != NULL) *ptr++ = '\\0'; else ptr = \"\";\n\n\tcmd = g_ascii_strup(cmd, -1);\n\n\tg_strdown(event+9);\n\tif (!signal_emit(event, 2, dcc, ptr)) {\n\t\tsignal_emit(reply ? \"default dcc reply\" :\n\t\t\t \"default dcc ctcp\", 3, dcc, cmd, ptr);\n\t}\n\n g_free(cmd);\n\tg_free(event);\n\n\tsignal_stop();\n}", "label": 0, "cwe": null, "length": 397 }, { "index": 394234, "code": "vis(char *dst, int c, int flag, int nextc)\n{\n\tchar *extra = NULL;\n\tunsigned char uc = (unsigned char)c;\n\tvisfun_t f;\n\n\t_DIAGASSERT(dst != NULL);\n\n\tMAKEEXTRALIST(flag, extra, \"\");\n\tif (! extra) {\n\t\t*dst = '\\0';\t\t/* can't create extra, return \"\" */\n\t\treturn dst;\n\t}\n\tf = getvisfun(flag);\n\tdst = (*f)(dst, uc, flag, nextc, extra);\n\tfree(extra);\n\t*dst = '\\0';\n\treturn dst;\n}", "label": 0, "cwe": null, "length": 123 }, { "index": 754779, "code": "is_complete (ClutterTimeline *timeline)\n{\n ClutterTimelinePrivate *priv = timeline->priv;\n\n return (priv->direction == CLUTTER_TIMELINE_FORWARD\n ? priv->elapsed_time >= priv->duration\n : priv->elapsed_time <= 0);\n}", "label": 0, "cwe": null, "length": 60 }, { "index": 173550, "code": "set_var_mtrr_all(unsigned int address_bits)\n{\n\tunsigned long basek, sizek;\n\tunsigned char type;\n\tunsigned int reg;\n\n\tfor (reg = 0; reg < num_var_ranges; reg++) {\n\t\tbasek = range_state[reg].base_pfn << (PAGE_SHIFT - 10);\n\t\tsizek = range_state[reg].size_pfn << (PAGE_SHIFT - 10);\n\t\ttype = range_state[reg].type;\n\n\t\tset_var_mtrr(reg, basek, sizek, type, address_bits);\n\t}\n}", "label": 0, "cwe": null, "length": 117 } ]