functionSource
stringlengths
20
97.4k
CWE-119
bool
2 classes
CWE-120
bool
2 classes
CWE-469
bool
2 classes
CWE-476
bool
2 classes
CWE-other
bool
2 classes
combine
int64
0
1
find_volume (GVfsBackendAfpBrowse *afp_backend, char *filename) { char *end; guint len; guint i; while (*filename == '/') filename++; end = strchr (filename, '/'); if (end) { len = end - filename; while (*end == '/') end++; if (*end != 0) return NULL; } else len = strlen (filename); for (i = 0; i < afp_backend->volumes->len; i++) { GVfsAfpVolumeData *vol_data = g_ptr_array_index (afp_backend->volumes, i); if (strlen (vol_data->name) == len && strncmp (vol_data->name, filename, len) == 0) return vol_data; } return NULL; }
false
false
false
false
false
0
on_listitem3_button_press (GtkWidget * widget, GdkEvent * event, tListItem3 * parent) { if ((!parent->selected)&&(parent->can_select)) { playsound (SND_BUTTONDOWN); } return TRUE; }
false
false
false
false
false
0
save_acl(const char *identifier, const maildir_aclt *acl, void *cb_arg) { if (fprintf((FILE *)cb_arg, "%s %s\n", identifier, maildir_aclt_ascstr(acl)) < 0) return -1; return 0; }
false
false
false
false
false
0
add_line (struct backtrace_state *state, struct dwarf_data *ddata, uintptr_t pc, const char *filename, int lineno, backtrace_error_callback error_callback, void *data, struct line_vector *vec) { struct line *ln; /* If we are adding the same mapping, ignore it. This can happen when using discriminators. */ if (vec->count > 0) { ln = (struct line *) vec->vec.base + (vec->count - 1); if (pc == ln->pc && filename == ln->filename && lineno == ln->lineno) return 1; } ln = ((struct line *) backtrace_vector_grow (state, sizeof (struct line), error_callback, data, &vec->vec)); if (ln == NULL) return 0; /* Add in the base address here, so that we can look up the PC directly. */ ln->pc = pc + ddata->base_address; ln->filename = filename; ln->lineno = lineno; ++vec->count; return 1; }
false
false
false
false
false
0
cmd_selecttype(MainInfo *min, DirPane *src, DirPane *dst, const CmdArg *ca) { const gchar *tname; GList *types = NULL; GtkTreeModel *m = dp_get_tree_model(src); GtkTreeIter iter; if((tname = car_bareword_get(ca, 0U)) != NULL) types = typ_type_lookup_glob(min->cfg.type, tname); else { GdkEventButton *evt; GtkTreePath *path = NULL; if((evt = (GdkEventButton *) evt_event_get(GDK_BUTTON_PRESS)) != NULL) gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(src->view), evt->x, evt->y, &path, NULL, NULL, NULL); else gtk_tree_view_get_cursor(GTK_TREE_VIEW(src->view), &path, NULL); if(path != NULL) { GtkTreeIter ei; if(gtk_tree_model_get_iter(m, &ei, path)) types = g_list_append(NULL, dp_row_get_ftype(dp_get_tree_model(src), (DirRow2* ) &ei)); gtk_tree_path_free(path); } } if(types != NULL) { if(gtk_tree_model_get_iter_first(m, &iter)) { guint action; void (*afunc)(DirPane *dp, const DirRow2 *row); action = car_keyword_get_enum(ca, "action", 0, "select", "unselect", "toggle", NULL); afunc = (action == 0) ? dp_select : (action == 1) ? dp_unselect : dp_toggle; do { if(g_list_find(types, dp_row_get_ftype(m, &iter))) afunc(src, &iter); } while(gtk_tree_model_iter_next(m, &iter)); } g_list_free(types); } return 1; }
false
false
false
false
false
0
setAddrParams(int prefix, int bitfield) { AddrParams = new TSrvOptAddrParams(prefix, bitfield, 0 /* parent */); }
false
false
false
false
false
0
GetIndex(uint32_t RecordId, IndexType *pFoundIndex) const { StateMapType::const_iterator i = StateMap.begin(); for( ; i != StateMap.end(); ++i ) { if( i->second.RecordId == RecordId ) { if( pFoundIndex ) *pFoundIndex = i->first; return true; } } return false; }
false
false
false
false
false
0
nfs2_xdr_dec_readlinkres(struct rpc_rqst *req, struct xdr_stream *xdr, void *__unused) { enum nfs_stat status; int error; error = decode_stat(xdr, &status); if (unlikely(error)) goto out; if (status != NFS_OK) goto out_default; error = decode_path(xdr); out: return error; out_default: return nfs_stat_to_errno(status); }
false
false
false
false
false
0
qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 6) qt_static_metacall(this, _c, _id, _a); _id -= 6; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QString*>(_v) = street(); break; case 1: *reinterpret_cast< QString*>(_v) = city(); break; case 2: *reinterpret_cast< QString*>(_v) = zipCode(); break; case 3: *reinterpret_cast< QString*>(_v) = countryIso(); break; case 4: *reinterpret_cast< QString*>(_v) = stateProvince(); break; } _id -= 5; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setStreet(*reinterpret_cast< QString*>(_v)); break; case 1: setCity(*reinterpret_cast< QString*>(_v)); break; case 2: setZipCode(*reinterpret_cast< QString*>(_v)); break; case 3: setCountryIso(*reinterpret_cast< QString*>(_v)); break; case 4: setStateProvince(*reinterpret_cast< QString*>(_v)); break; } _id -= 5; } else if (_c == QMetaObject::ResetProperty) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 5; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 5; } #endif // QT_NO_PROPERTIES return _id; }
false
false
false
false
false
0
flakey_status(struct dm_target *ti, status_type_t type, unsigned status_flags, char *result, unsigned maxlen) { unsigned sz = 0; struct flakey_c *fc = ti->private; unsigned drop_writes; switch (type) { case STATUSTYPE_INFO: result[0] = '\0'; break; case STATUSTYPE_TABLE: DMEMIT("%s %llu %u %u ", fc->dev->name, (unsigned long long)fc->start, fc->up_interval, fc->down_interval); drop_writes = test_bit(DROP_WRITES, &fc->flags); DMEMIT("%u ", drop_writes + (fc->corrupt_bio_byte > 0) * 5); if (drop_writes) DMEMIT("drop_writes "); if (fc->corrupt_bio_byte) DMEMIT("corrupt_bio_byte %u %c %u %u ", fc->corrupt_bio_byte, (fc->corrupt_bio_rw == WRITE) ? 'w' : 'r', fc->corrupt_bio_value, fc->corrupt_bio_flags); break; } }
false
false
false
false
false
0
makeLegSvg(QPointF offset, double dpi, double printerScale, bool blackOnly) { if (!m_rubberBandLeg) return ""; QString data("M"); QPointF p = m_legPolygon.at(0); data += TextUtils::pointToSvgString(mapToScene(p), offset, dpi, printerScale); for (int i = 1; i < m_legPolygon.count(); i++) { QPointF p = m_legPolygon.at(i); Bezier * bezier = m_legCurves.at(i - 1); if (bezier == NULL || bezier->isEmpty()) { data += "L"; data += TextUtils::pointToSvgString(mapToScene(p), offset, dpi, printerScale); } else { data += "C"; data += TextUtils::pointToSvgString(mapToScene(bezier->cp0()), offset, dpi, printerScale); data += " "; data += TextUtils::pointToSvgString(mapToScene(bezier->cp1()), offset, dpi, printerScale); data += " "; data += TextUtils::pointToSvgString(mapToScene(p), offset, dpi, printerScale); } } QString path = QString("<path stroke='%1' stroke-width='%2' stroke-linecap='round' stroke-linejoin='round' fill='none' d='%3' />\n") .arg(blackOnly ? "black" : m_legColor.name()) .arg(m_legStrokeWidth * dpi / printerScale) .arg(data); return path; }
false
false
false
false
false
0
vectors_substractionf(int n, float *vector1, float *vector2, float *result) { int i; for (i = 0; i < n; i++) { result[i] = vector1[i] - vector2[i]; } }
false
false
false
false
false
0
CanEnter(Player* player) { if (player->GetMapRef().getTarget() == this) { sLog.outError("Map::CanEnter -%s already in map!", player->GetGuidStr().c_str()); MANGOS_ASSERT(false); return false; } return true; }
false
false
false
false
false
0
canFoldOffset(unsigned OffsetSize, unsigned AS, const AMDGPUSubtarget &STI) { switch (AS) { case AMDGPUAS::GLOBAL_ADDRESS: { // MUBUF instructions a 12-bit offset in bytes. return isUInt<12>(OffsetSize); } case AMDGPUAS::CONSTANT_ADDRESS: { // SMRD instructions have an 8-bit offset in dwords on SI and // a 20-bit offset in bytes on VI. if (STI.getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS) return isUInt<20>(OffsetSize); else return (OffsetSize % 4 == 0) && isUInt<8>(OffsetSize / 4); } case AMDGPUAS::LOCAL_ADDRESS: case AMDGPUAS::REGION_ADDRESS: { // The single offset versions have a 16-bit offset in bytes. return isUInt<16>(OffsetSize); } case AMDGPUAS::PRIVATE_ADDRESS: // Indirect register addressing does not use any offsets. default: return 0; } }
false
false
false
false
false
0
__cbc_decrypt(struct blkcipher_desc *desc, struct blkcipher_walk *walk) { struct bf_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); unsigned int bsize = BF_BLOCK_SIZE; unsigned int nbytes = walk->nbytes; u64 *src = (u64 *)walk->src.virt.addr; u64 *dst = (u64 *)walk->dst.virt.addr; u64 ivs[4 - 1]; u64 last_iv; /* Start of the last block. */ src += nbytes / bsize - 1; dst += nbytes / bsize - 1; last_iv = *src; /* Process four block batch */ if (nbytes >= bsize * 4) { do { nbytes -= bsize * 4 - bsize; src -= 4 - 1; dst -= 4 - 1; ivs[0] = src[0]; ivs[1] = src[1]; ivs[2] = src[2]; blowfish_dec_blk_4way(ctx, (u8 *)dst, (u8 *)src); dst[1] ^= ivs[0]; dst[2] ^= ivs[1]; dst[3] ^= ivs[2]; nbytes -= bsize; if (nbytes < bsize) goto done; *dst ^= *(src - 1); src -= 1; dst -= 1; } while (nbytes >= bsize * 4); } /* Handle leftovers */ for (;;) { blowfish_dec_blk(ctx, (u8 *)dst, (u8 *)src); nbytes -= bsize; if (nbytes < bsize) break; *dst ^= *(src - 1); src -= 1; dst -= 1; } done: *dst ^= *(u64 *)walk->iv; *(u64 *)walk->iv = last_iv; return nbytes; }
false
false
false
false
false
0
dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) { Q_UNUSED(column) if(action == Qt::IgnoreAction) return true; if(parent.isValid()) return false; if(data->hasFormat("application/actionaz.add.action")) { QByteArray encodedData = data->data("application/actionaz.add.action"); if(row == -1) row = rowCount(QModelIndex()); emit wantToAddAction(row, encodedData); return true; } else if(data->hasFormat("application/actionaz.action")) { QByteArray encodedData = data->data("application/actionaz.action"); QDataStream stream(&encodedData, QIODevice::ReadOnly); if(row == -1) row = rowCount(QModelIndex()); QList<int> previousRows; QList<ActionTools::ActionInstanceBuffer> actionInstanceBuffers; while(!stream.atEnd()) { int previousRow; ActionTools::ActionInstanceBuffer actionInstanceBuffer; stream >> previousRow; stream >> actionInstanceBuffer; previousRows << previousRow; actionInstanceBuffers << actionInstanceBuffer; } if(action == Qt::CopyAction) mUndoStack->push(new CopyActionCommand(row, actionInstanceBuffers, this)); else if(action == Qt::MoveAction) mUndoStack->push(new MoveActionCommand(row, previousRows, this)); emit scriptEdited(); return true; } else if(data->hasUrls()) { if(data->urls().count() != 1) return false; emit scriptFileDropped(data->urls().at(0).toLocalFile()); return true; } else if(data->hasText()) { emit scriptContentDropped(data->text()); return true; } return false; }
false
false
false
false
false
0
dupe_item_remove(DupeWindow *dw, DupeItem *di) { if (!di) return; /* handle things that may be in progress... */ if (dw->working && dw->working->data == di) { dw->working = dw->working->prev; } if (dw->thumb_loader && dw->thumb_item == di) { dupe_thumb_step(dw); } if (dw->setup_point && dw->setup_point->data == di) { dw->setup_point = dupe_setup_point_step(dw, dw->setup_point); if (dw->img_loader) { image_loader_free(dw->img_loader); dw->img_loader = NULL; dw->idle_id = g_idle_add(dupe_check_cb, dw); } } if (di->group && dw->dupes) { /* is a dupe, must remove from group/reset children if a parent */ DupeItem *parent; parent = dupe_match_find_parent(dw, di); if (di == parent) { if (g_list_length(parent->group) < 2) { DupeItem *child; child = dupe_match_highest_rank(parent); dupe_match_link_clear(child, TRUE); dupe_listview_remove(dw, child); dupe_match_link_clear(parent, TRUE); dupe_listview_remove(dw, parent); dw->dupes = g_list_remove(dw->dupes, parent); } else { DupeItem *new_parent; DupeMatch *dm; dm = parent->group->data; new_parent = dm->di; dupe_match_reparent(dw, parent, new_parent); dupe_listview_remove(dw, parent); } } else { if (g_list_length(parent->group) < 2) { dupe_match_link_clear(parent, TRUE); dupe_listview_remove(dw, parent); dw->dupes = g_list_remove(dw->dupes, parent); } dupe_match_link_clear(di, TRUE); dupe_listview_remove(dw, di); } } else { /* not a dupe, or not sorted yet, simply reset */ dupe_match_link_clear(di, TRUE); } if (dw->second_list && g_list_find(dw->second_list, di)) { dupe_second_remove(dw, di); } else { dw->list = g_list_remove(dw->list, di); } dupe_item_free(di); dupe_window_update_count(dw, FALSE); }
false
false
false
false
false
0
gftp_descramble_password (const char *password) { const char *passwordpos; char *newstr, *newpos; int error; if (*password != '$') return (g_strdup (password)); passwordpos = password + 1; newstr = g_malloc0 ((gulong) strlen (passwordpos) / 2 + 1); newpos = newstr; error = 0; while (*passwordpos != '\0' && *(passwordpos + 1) != '\0') { if ((*passwordpos & 0xc3) != 0x41 || (*(passwordpos + 1) & 0xc3) != 0x41) { error = 1; break; } *newpos++ = ((*passwordpos & 0x3c) << 2) | ((*(passwordpos + 1) & 0x3c) >> 2); passwordpos += 2; } if (error) { g_free (newstr); return (g_strdup (password)); } *newpos = '\0'; return (newstr); }
false
false
false
false
false
0
SubstituteAll(GtkWidget *W,gpointer Unused) { GtkTextIter Start,End; GtkTextMark *Mark; gint i; gchar StatusLine[MAX_STAT],*BufTxt; const gchar *FTxt; FTxt=gtk_entry_get_text(GTK_ENTRY(RFind)); if (!strlen(FTxt)) return; MaskBufChg=TRUE; SubsAll=TRUE; //Ensure BufferChanged wont act and Substitute wont wrap gtk_text_buffer_get_start_iter(Buf,&Start); gtk_text_buffer_get_end_iter(Buf,&End); BufTxt=gtk_text_buffer_get_text(Buf,&Start,&End,FALSE); if (strlen(BufTxt)<MAX_FSIZE-1) { strcpy(UBuf[UStat],BufTxt); UStat=1-UStat; } //Update UndoBuf gtk_text_buffer_select_range(Buf,&Start,&Start); //Move cursor to start for (i=0;i<1000;++i) { Substitute(W,NULL); if (!Located) break; } //Repeat substitutions. Limit to 1000 gtk_text_buffer_get_start_iter(Buf,&Start); gtk_text_buffer_select_range(Buf,&Start,&Start); //Move cursor to start Mark=gtk_text_buffer_create_mark(Buf,"Start",&Start,FALSE); //Mark at start gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(TextView),Mark); //Scroll to start gtk_statusbar_pop(GTK_STATUSBAR(StatBar),0); sprintf(StatusLine,"%d replacements made",i); gtk_statusbar_push(GTK_STATUSBAR(StatBar),StatID,StatusLine); //Display no. of substitutions MaskBufChg=FALSE; SubsAll=FALSE; //Restore these flags }
false
false
false
false
false
0
dlm_should_restart_join(struct dlm_ctxt *dlm, struct domain_join_ctxt *ctxt, enum dlm_query_join_response_code response) { int ret; if (response == JOIN_DISALLOW) { mlog(0, "Latest response of disallow -- should restart\n"); return 1; } spin_lock(&dlm->spinlock); /* For now, we restart the process if the node maps have * changed at all */ ret = memcmp(ctxt->live_map, dlm->live_nodes_map, sizeof(dlm->live_nodes_map)); spin_unlock(&dlm->spinlock); if (ret) mlog(0, "Node maps changed -- should restart\n"); return ret; }
false
false
false
false
false
0
dumpRoleMembership(PGconn *conn) { PGresult *res; int i; res = executeQuery(conn, "SELECT ur.rolname AS roleid, " "um.rolname AS member, " "a.admin_option, " "ug.rolname AS grantor " "FROM pg_auth_members a " "LEFT JOIN pg_authid ur on ur.oid = a.roleid " "LEFT JOIN pg_authid um on um.oid = a.member " "LEFT JOIN pg_authid ug on ug.oid = a.grantor " "ORDER BY 1,2,3"); if (PQntuples(res) > 0) fprintf(OPF, "--\n-- Role memberships\n--\n\n"); for (i = 0; i < PQntuples(res); i++) { char *roleid = PQgetvalue(res, i, 0); char *member = PQgetvalue(res, i, 1); char *option = PQgetvalue(res, i, 2); fprintf(OPF, "GRANT %s", fmtId(roleid)); fprintf(OPF, " TO %s", fmtId(member)); if (*option == 't') fprintf(OPF, " WITH ADMIN OPTION"); /* * We don't track the grantor very carefully in the backend, so cope * with the possibility that it has been dropped. */ if (!PQgetisnull(res, i, 3)) { char *grantor = PQgetvalue(res, i, 3); fprintf(OPF, " GRANTED BY %s", fmtId(grantor)); } fprintf(OPF, ";\n"); } PQclear(res); fprintf(OPF, "\n\n"); }
false
false
false
false
false
0
reverse(const std::string& seq) { return std::string(seq.rbegin(), seq.rend()); }
false
false
false
false
false
0
get_dot(Token *token) #else /* K&R style */ get_dot(token) Token *token; #endif /* HAVE_STDC */ { if(src_text_len < MAX_SRC_TEXT) src_text_buf[src_text_len++] = curr_char; closeup(); /* Advance till nonspace char in next_char */ if(isadigit(next_char)) get_number(token); /* Numeric const */ else if(isaletter(next_char)) get_dotted_keyword(token); /* .EQ. etc. */ else get_simple_punctuation(token); /* "." out of place */ }
false
false
false
false
false
0
cache_rrset_new(dns_msg_question_t *q, dns_tls_t *tls) { dns_cache_rrset_t *rrset; if ((rrset = (dns_cache_rrset_t *) dns_mpool_get(&CacheSetPool, tls->tls_id)) == NULL) { if ((rrset = cache_rrset_drain(tls)) == NULL) return NULL; } cache_rrset_reset(rrset, tls); if (cache_rrset_retain(rrset) < 0) plog(LOG_CRIT, "%s: new rrset retain failed. why?", __func__); return rrset; }
false
false
false
false
false
0
Free() { if (!m_data) return; uint32 offset = 0; for (uint32 x = 0; x < m_dstFieldCount; ++x) { switch (m_dst_format[x]) { case FT_LOGIC: offset += sizeof(bool); break; case FT_STRING: { for (uint32 recordItr = 0; recordItr < m_recordCount; ++recordItr) delete[] *(char**)((char*)(m_data + (recordItr * m_recordSize)) + offset); offset += sizeof(char*); break; } case FT_NA: case FT_INT: offset += sizeof(uint32); break; case FT_BYTE: case FT_NA_BYTE: offset += sizeof(char); break; case FT_FLOAT: case FT_NA_FLOAT: offset += sizeof(float); break; case FT_NA_POINTER: // TODO- possible (and small) memleak here possible offset += sizeof(char*); break; case FT_IND: case FT_SORT: assert(false && "SQL storage not have sort field types"); break; default: assert(false && "unknown format character"); break; } } delete[] m_data; m_data = NULL; m_recordCount = 0; }
false
false
false
false
false
0
Disconnect() { if (state_ != STATE_CLOSED) { EnterExit ee(this); if (state_ == STATE_OPEN) *output_ << "</stream:stream>"; state_ = STATE_CLOSED; } return XMPP_RETURN_OK; }
false
false
false
false
false
0
bdelta_done_alg(void *instance) { BDelta_Instance *b = (BDelta_Instance*)instance; while (!b->matches.empty()) { delete b->matches.first->obj; b->matches.erase(b->matches.first); } delete b; }
false
false
false
false
false
0
dc1394_usb_free_device_list (platform_device_list_t * d) { usb_device_list_t * list = (usb_device_list_t *) d; int i; for (i = 0; i < d->num_devices; i++) free (d->devices[i]); free (d->devices); libusb_free_device_list (list->libusb_list, 1); free (d); }
false
false
false
false
false
0
est_aidx_attr_out(VILLA *db, int id, const char *vbuf, int vsiz){ char *tbuf; int err, tsiz; assert(db && id >= 0 && vbuf && vsiz >= 0); err = FALSE; tsiz = vsiz + sizeof(int) + 1; CB_MALLOC(tbuf, tsiz); memcpy(tbuf, vbuf, vsiz + 1); memcpy(tbuf + vsiz + 1, &id, sizeof(int)); if(!vlout(db, tbuf, tsiz)) err = TRUE; free(tbuf); return err ? FALSE : TRUE; }
false
false
false
false
false
0
ctf_visitor_print_type_specifier_list(FILE *fd, int depth, struct ctf_node *node) { struct ctf_node *iter; int ret; print_tabs(fd, depth); fprintf(fd, "<type_specifier_list>\n"); bt_list_for_each_entry(iter, &node->u.type_specifier_list.head, siblings) { ret = ctf_visitor_print_xml(fd, depth + 1, iter); if (ret) return ret; } print_tabs(fd, depth); fprintf(fd, "</type_specifier_list>\n"); return 0; }
false
false
false
false
false
0
mouseReleaseEvent(QMouseEvent *e) { if (!isVisible()) return; emit clicked((int)e->button()); hide(); }
false
false
false
false
false
0
field_has_null_values(const sharedptr<const Field>& field) { //Note that "= Null" doesn't work, though it doesn't error either. //Note also that SELECT COUNT always returns 0 if all the values are NULL, so we can't use that to be more efficient. Glib::RefPtr<Gnome::Gda::SqlBuilder> builder = Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_SELECT); builder->select_add_field(field->get_name(), m_table_name); builder->select_add_target(m_table_name); builder->set_where( builder->add_cond(Gnome::Gda::SQL_OPERATOR_TYPE_ISNULL, builder->add_field_id(field->get_name(), m_table_name))); long null_count = 0; Glib::RefPtr<Gnome::Gda::DataModel> datamodel = DbUtils::query_execute_select(builder); if(datamodel) { if(datamodel->get_n_rows() && datamodel->get_n_columns()) { null_count = datamodel->get_n_rows(); //std::cout << "debug: null_count = " << null_count << std::endl; } } else { std::cerr << G_STRFUNC << ": query failed." << std::endl; } return null_count > 0; }
false
false
false
false
false
0
perf_iommu_stop(struct perf_event *event, int flags) { struct hw_perf_event *hwc = &event->hw; u64 config; pr_debug("perf: amd_iommu:perf_iommu_stop\n"); if (hwc->state & PERF_HES_UPTODATE) return; perf_iommu_disable_event(event); WARN_ON_ONCE(hwc->state & PERF_HES_STOPPED); hwc->state |= PERF_HES_STOPPED; if (hwc->state & PERF_HES_UPTODATE) return; config = hwc->config; perf_iommu_read(event); hwc->state |= PERF_HES_UPTODATE; }
false
false
false
false
false
0
log_initialize() { int i; if (_initialized) return; for (i = 0; i < LOG_MAXLOGS; i++) { loglist[i].in_use = 0; loglist[i].level = 2; loglist[i].size = 0; loglist[i].trigger_level = 0; loglist[i].filename = NULL; loglist[i].logfile = NULL; loglist[i].buffer = NULL; } /* initialize mutexes */ #ifndef _WIN32 pthread_mutex_init(&_logger_mutex, NULL); #else InitializeCriticalSection(&_logger_mutex); #endif _initialized = 1; }
false
false
false
false
false
0
jinit_huff_decoder (j_decompress_ptr cinfo) { huff_entropy_ptr entropy; int i; entropy = (huff_entropy_ptr) (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_IMAGE, SIZEOF(huff_entropy_decoder)); cinfo->entropy = (struct jpeg_entropy_decoder *) entropy; entropy->pub.start_pass = start_pass_huff_decoder; entropy->pub.decode_mcu = decode_mcu; /* Mark tables unallocated */ for (i = 0; i < NUM_HUFF_TBLS; i++) { entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL; } }
false
false
false
false
false
0
c_gc_show_freeable(state_t *s) { reg_t addr = cmd_params[0].reg; GET_SEG_INTERFACE(addr.segment); sciprintf("Freeable in segment %04x:\n", addr.segment); seg_interface->list_all_deallocatable(seg_interface, NULL, _print_address); seg_interface->deallocate_self(seg_interface); return 0; }
false
false
false
false
false
0
fso_gsm_base_unsolicited_response_handler_registerUrcPdu (FsoGsmBaseUnsolicitedResponseHandler* self, const gchar* prefix, UnsolicitedResponsePduHandlerFunc func, void* func_target) { GeeHashMap* _tmp0_ = NULL; const gchar* _tmp1_ = NULL; UnsolicitedResponsePduHandlerFunc _tmp2_ = NULL; void* _tmp2__target = NULL; UnsolicitedResponsePduHandlerFuncWrapper* _tmp3_ = NULL; UnsolicitedResponsePduHandlerFuncWrapper* _tmp4_ = NULL; g_return_if_fail (self != NULL); g_return_if_fail (prefix != NULL); _tmp0_ = self->priv->urcpdus; _tmp1_ = prefix; _tmp2_ = func; _tmp2__target = func_target; _tmp3_ = unsolicited_response_pdu_handler_func_wrapper_new (); (_tmp3_->func_target_destroy_notify == NULL) ? NULL : (_tmp3_->func_target_destroy_notify (_tmp3_->func_target), NULL); _tmp3_->func = NULL; _tmp3_->func_target = NULL; _tmp3_->func_target_destroy_notify = NULL; _tmp3_->func = _tmp2_; _tmp3_->func_target = _tmp2__target; _tmp3_->func_target_destroy_notify = NULL; _tmp4_ = _tmp3_; gee_abstract_map_set ((GeeAbstractMap*) _tmp0_, _tmp1_, _tmp4_); _unsolicited_response_pdu_handler_func_wrapper_unref0 (_tmp4_); }
false
false
false
false
false
0
uprv_getPOSIXID(void) { static const char* posixID = NULL; if (posixID == 0) { /* * On Solaris two different calls to setlocale can result in * different values. Only get this value once. * * We must check this first because an application can set this. * * LC_ALL can't be used because it's platform dependent. The LANG * environment variable seems to affect LC_CTYPE variable by default. * Here is what setlocale(LC_ALL, NULL) can return. * HPUX can return 'C C C C C C C' * Solaris can return /en_US/C/C/C/C/C on the second try. * Linux can return LC_CTYPE=C;LC_NUMERIC=C;... * * The default codepage detection also needs to use LC_CTYPE. * * Do not call setlocale(LC_*, "")! Using an empty string instead * of NULL, will modify the libc behavior. */ posixID = setlocale(LC_CTYPE, NULL); if ((posixID == 0) || (uprv_strcmp("C", posixID) == 0) || (uprv_strcmp("POSIX", posixID) == 0)) { /* Maybe we got some garbage. Try something more reasonable */ posixID = getenv("LC_ALL"); if (posixID == 0) { posixID = getenv("LC_CTYPE"); if (posixID == 0) { posixID = getenv("LANG"); } } } if ((posixID==0) || (uprv_strcmp("C", posixID) == 0) || (uprv_strcmp("POSIX", posixID) == 0)) { /* Nothing worked. Give it a nice POSIX default value. */ posixID = "en_US_POSIX"; } } return posixID; }
false
false
false
false
false
0
setContents( const QString &contents ) { Q_D( Annotation ); if (!d->pdfAnnot) { d->contents = contents; return; } GooString *s = QStringToUnicodeGooString(contents); d->pdfAnnot->setContents(s); delete s; }
false
false
false
false
false
0
event_terminate(void * x) { TerminateArgs * args = (TerminateArgs *)x; Context * ctx = args->ctx; ContextExtensionRC * ext = EXT(ctx); Channel * c = args->channel; LINK * l = ctx->children.next; while (l != &ctx->children) { Context * x = cldl2ctxp(l); ContextExtensionRC * y = EXT(x); if (!x->exited) { if (y->intercepted) send_event_context_resumed(x); x->pending_intercept = 0; x->pending_signals |= 1 << SIGKILL; } l = l->next; } if (ext->intercepted) send_event_context_resumed(ctx); ctx->pending_intercept = 0; ctx->pending_signals |= 1 << SIGKILL; context_unlock(ctx); channel_unlock(c); loc_free(args); }
false
false
false
false
false
0
copy_original_table_set (htab_t tab, unsigned obj, unsigned val) { struct htab_bb_copy_original_entry **slot; struct htab_bb_copy_original_entry key; if (!original_copy_bb_pool) return; key.index1 = obj; slot = (struct htab_bb_copy_original_entry **) htab_find_slot (tab, &key, INSERT); if (!*slot) { *slot = (struct htab_bb_copy_original_entry *) pool_alloc (original_copy_bb_pool); (*slot)->index1 = obj; } (*slot)->index2 = val; }
false
false
false
false
false
0
lookupFunction(const Function *F) { // Function not found, look it up... start by figuring out what the // composite function name should be. std::string ExtName = "lle_"; FunctionType *FT = F->getFunctionType(); for (unsigned i = 0, e = FT->getNumContainedTypes(); i != e; ++i) ExtName += getTypeID(FT->getContainedType(i)); ExtName += ("_" + F->getName()).str(); sys::ScopedLock Writer(*FunctionsLock); ExFunc FnPtr = (*FuncNames)[ExtName]; if (!FnPtr) FnPtr = (*FuncNames)[("lle_X_" + F->getName()).str()]; if (!FnPtr) // Try calling a generic function... if it exists... FnPtr = (ExFunc)(intptr_t)sys::DynamicLibrary::SearchForAddressOfSymbol( ("lle_X_" + F->getName()).str()); if (FnPtr) ExportedFunctions->insert(std::make_pair(F, FnPtr)); // Cache for later return FnPtr; }
false
false
false
false
false
0
kvp_frame_delete(KvpFrame * frame) { if (!frame) return; if (frame->hash) { /* free any allocated resource for frame or its children */ g_hash_table_foreach(frame->hash, & kvp_frame_delete_worker, (gpointer)frame); /* delete the hash table */ g_hash_table_destroy(frame->hash); frame->hash = NULL; } g_free(frame); }
false
false
false
false
false
0
drop_privileges(void) { #ifdef HAVE_SETGROUPS gid_t gr_list[1]; #endif /* set uid and gid */ if(global_options.gid) { if(setgid(global_options.gid)) { sockerror("setgid"); die(1); } #ifdef HAVE_SETGROUPS gr_list[0]=global_options.gid; if(setgroups(1, gr_list)) { sockerror("setgroups"); die(1); } #endif } if(global_options.uid) { if(setuid(global_options.uid)) { sockerror("setuid"); die(1); } } }
false
false
false
false
false
0
addArgumentOnTheFly(const string & name, int numValues, ...) { va_list args; va_start(args, numValues); if (numValues == 0) { _resArgs[name].push_back(""); } for (int i = 0; i < numValues; ++i) { char* v = va_arg(args, char *); _resArgs[name].push_back(v); } }
false
false
false
false
false
0
mainwindow_key_pressed (GtkWidget *widget, GdkEventKey *event, gpointer data) { MainWindow *mainwin = (MainWindow*) data; if (!mainwin || !event) return FALSE; if (quicksearch_has_focus(mainwin->summaryview->quicksearch)) { lastkey = event->keyval; return FALSE; } switch (event->keyval) { case GDK_KEY_Q: /* Quit */ BREAK_ON_MODIFIER_KEY(); if (gtk_window_is_active(GTK_WINDOW(mainwin->window))) { app_exit_cb(NULL, mainwin); } return FALSE; case GDK_KEY_space: BREAK_ON_MODIFIER_KEY(); if (gtk_window_is_active(GTK_WINDOW(mainwin->window))) { if (mainwin->folderview != NULL && mainwin->summaryview != NULL && ((!mainwin->summaryview->displayed && !mainwin->summaryview->selected) || (mainwin->summaryview->folder_item && mainwin->summaryview->folder_item->total_msgs == 0))) { g_signal_stop_emission_by_name(G_OBJECT(widget), "key_press_event"); folderview_select_next_unread(mainwin->folderview, TRUE); } } break; default: break; } return FALSE; }
false
false
false
false
false
0
JoinAnyTeam(TM_TeamMember *teamMember, int *resultCode) { TeamMemberLimit balancedLimit = GetBalancedTeamLimit(); unsigned int idx = GetAvailableTeamIndexWithFewestMembers(balancedLimit, ALLOW_JOIN_ANY_AVAILABLE_TEAM); if (idx == (unsigned int ) -1) { // If any team is joinable but full, return full. Otherwise return locked for (idx=0; idx < teams.Size(); idx++) { if ((teams[idx]->GetTeamMembersCount() >= balancedLimit || teams[idx]->GetTeamMembersCount() >= teams[idx]->GetMemberLimitSetting()) && teams[idx]->GetMemberLimitSetting() != 0 && (ALLOW_JOIN_ANY_AVAILABLE_TEAM & teams[idx]->GetJoinPermissions())!=0) { // Full *resultCode=-2; return teams[idx]; } } // Locked *resultCode=-1; return 0; } TM_Team* lowestMemberTeam = teams[idx]; teamMember->StoreLastTeams(); teamMember->UpdateTeamsRequestedToNone(); teamMember->AddToTeamList(lowestMemberTeam); teamManager->PushTeamAssigned(teamMember); *resultCode=1; return lowestMemberTeam; }
false
false
false
false
false
0
DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, fsec_t *fsec) { char *cp; *tmask = DTK_TIME_M; tm->tm_hour = strtol(str, &cp, 10); if (*cp != ':') return -1; str = cp + 1; tm->tm_min = strtol(str, &cp, 10); if (*cp == '\0') { tm->tm_sec = 0; *fsec = 0; } else if (*cp != ':') return -1; else { str = cp + 1; tm->tm_sec = strtol(str, &cp, 10); if (*cp == '\0') *fsec = 0; else if (*cp == '.') { #ifdef HAVE_INT64_TIMESTAMP char fstr[MAXDATELEN + 1]; /* * OK, we have at most six digits to work with. Let's construct a * string and then do the conversion to an integer. */ strncpy(fstr, (cp + 1), 7); strcpy(fstr + strlen(fstr), "000000"); *(fstr + 6) = '\0'; *fsec = strtol(fstr, &cp, 10); #else str = cp; *fsec = strtod(str, &cp); #endif if (*cp != '\0') return -1; } else return -1; } /* do a sanity check */ #ifdef HAVE_INT64_TIMESTAMP if (tm->tm_hour < 0 || tm->tm_min < 0 || tm->tm_min > 59 || tm->tm_sec < 0 || tm->tm_sec > 59 || *fsec >= USECS_PER_SEC) return -1; #else if (tm->tm_hour < 0 || tm->tm_min < 0 || tm->tm_min > 59 || tm->tm_sec < 0 || tm->tm_sec > 59 || *fsec >= 1) return -1; #endif return 0; }
false
false
false
false
false
0
ipa_tm_mayenterirr_function (struct cgraph_node *node) { struct tm_ipa_cg_data *d; tree decl; unsigned flags; d = get_cg_data (&node, true); decl = node->decl; flags = flags_from_decl_or_type (decl); /* Handle some TM builtins. Ordinarily these aren't actually generated at this point, but handling these functions when written in by the user makes it easier to build unit tests. */ if (flags & ECF_TM_BUILTIN) return false; /* Filter out all functions that are marked. */ if (flags & ECF_TM_PURE) return false; if (is_tm_safe (decl)) return false; if (is_tm_irrevocable (decl)) return true; if (is_tm_callable (decl)) return true; if (find_tm_replacement_function (decl)) return true; /* If we aren't seeing the final version of the function we don't know what it will contain at runtime. */ if (cgraph_function_body_availability (node) < AVAIL_AVAILABLE) return true; /* If the function must go irrevocable, then of course true. */ if (d->is_irrevocable) return true; /* If there are any blocks marked irrevocable, then the function as a whole may enter irrevocable. */ if (d->irrevocable_blocks_clone) return true; /* We may have previously marked this function as tm_may_enter_irr; see pass_diagnose_tm_blocks. */ if (node->local.tm_may_enter_irr) return true; /* Recurse on the main body for aliases. In general, this will result in one of the bits above being set so that we will not have to recurse next time. */ if (node->alias) return ipa_tm_mayenterirr_function (cgraph_get_node (node->thunk.alias)); /* What remains is unmarked local functions without items that force the function to go irrevocable. */ return false; }
false
false
false
false
false
0
Mono_Posix_FromEpollEvents (unsigned int x, unsigned int *r) { *r = 0; if ((x & Mono_Posix_EpollEvents_EPOLLERR) == Mono_Posix_EpollEvents_EPOLLERR) #ifdef EPOLLERR *r |= EPOLLERR; #else /* def EPOLLERR */ {errno = EINVAL; return -1;} #endif /* ndef EPOLLERR */ if ((x & Mono_Posix_EpollEvents_EPOLLET) == Mono_Posix_EpollEvents_EPOLLET) #ifdef EPOLLET *r |= EPOLLET; #else /* def EPOLLET */ {errno = EINVAL; return -1;} #endif /* ndef EPOLLET */ if ((x & Mono_Posix_EpollEvents_EPOLLHUP) == Mono_Posix_EpollEvents_EPOLLHUP) #ifdef EPOLLHUP *r |= EPOLLHUP; #else /* def EPOLLHUP */ {errno = EINVAL; return -1;} #endif /* ndef EPOLLHUP */ if ((x & Mono_Posix_EpollEvents_EPOLLIN) == Mono_Posix_EpollEvents_EPOLLIN) #ifdef EPOLLIN *r |= EPOLLIN; #else /* def EPOLLIN */ {errno = EINVAL; return -1;} #endif /* ndef EPOLLIN */ if ((x & Mono_Posix_EpollEvents_EPOLLMSG) == Mono_Posix_EpollEvents_EPOLLMSG) #ifdef EPOLLMSG *r |= EPOLLMSG; #else /* def EPOLLMSG */ {errno = EINVAL; return -1;} #endif /* ndef EPOLLMSG */ if ((x & Mono_Posix_EpollEvents_EPOLLONESHOT) == Mono_Posix_EpollEvents_EPOLLONESHOT) #ifdef EPOLLONESHOT *r |= EPOLLONESHOT; #else /* def EPOLLONESHOT */ {errno = EINVAL; return -1;} #endif /* ndef EPOLLONESHOT */ if ((x & Mono_Posix_EpollEvents_EPOLLOUT) == Mono_Posix_EpollEvents_EPOLLOUT) #ifdef EPOLLOUT *r |= EPOLLOUT; #else /* def EPOLLOUT */ {errno = EINVAL; return -1;} #endif /* ndef EPOLLOUT */ if ((x & Mono_Posix_EpollEvents_EPOLLPRI) == Mono_Posix_EpollEvents_EPOLLPRI) #ifdef EPOLLPRI *r |= EPOLLPRI; #else /* def EPOLLPRI */ {errno = EINVAL; return -1;} #endif /* ndef EPOLLPRI */ if ((x & Mono_Posix_EpollEvents_EPOLLRDBAND) == Mono_Posix_EpollEvents_EPOLLRDBAND) #ifdef EPOLLRDBAND *r |= EPOLLRDBAND; #else /* def EPOLLRDBAND */ {errno = EINVAL; return -1;} #endif /* ndef EPOLLRDBAND */ if ((x & Mono_Posix_EpollEvents_EPOLLRDHUP) == Mono_Posix_EpollEvents_EPOLLRDHUP) #ifdef EPOLLRDHUP *r |= EPOLLRDHUP; #else /* def EPOLLRDHUP */ {errno = EINVAL; return -1;} #endif /* ndef EPOLLRDHUP */ if ((x & Mono_Posix_EpollEvents_EPOLLRDNORM) == Mono_Posix_EpollEvents_EPOLLRDNORM) #ifdef EPOLLRDNORM *r |= EPOLLRDNORM; #else /* def EPOLLRDNORM */ {errno = EINVAL; return -1;} #endif /* ndef EPOLLRDNORM */ if ((x & Mono_Posix_EpollEvents_EPOLLWRBAND) == Mono_Posix_EpollEvents_EPOLLWRBAND) #ifdef EPOLLWRBAND *r |= EPOLLWRBAND; #else /* def EPOLLWRBAND */ {errno = EINVAL; return -1;} #endif /* ndef EPOLLWRBAND */ if ((x & Mono_Posix_EpollEvents_EPOLLWRNORM) == Mono_Posix_EpollEvents_EPOLLWRNORM) #ifdef EPOLLWRNORM *r |= EPOLLWRNORM; #else /* def EPOLLWRNORM */ {errno = EINVAL; return -1;} #endif /* ndef EPOLLWRNORM */ if (x == 0) return 0; return 0; }
false
false
false
false
false
0
getLevels(int rpt_index) { if (rpt_index < 0 || rpt_index > reports->number_of_rows() - 1) { return NULL; } else { return dynamic_cast<libdap::Sequence*>(reports->var_value(rpt_index, levels->name())); } }
false
false
false
false
false
0
max8997_led_brightness_set(struct led_classdev *led_cdev, enum led_brightness value) { struct max8997_led *led = container_of(led_cdev, struct max8997_led, cdev); if (value) { max8997_led_set_current(led, value); max8997_led_enable(led, true); } else { max8997_led_set_current(led, value); max8997_led_enable(led, false); } }
false
false
false
false
false
0
array_tobytes(arrayobject *self, PyObject *unused) { if (Py_SIZE(self) <= PY_SSIZE_T_MAX / self->ob_descr->itemsize) { return PyBytes_FromStringAndSize(self->ob_item, Py_SIZE(self) * self->ob_descr->itemsize); } else { return PyErr_NoMemory(); } }
false
false
false
false
false
0
proc_bufname(p) Process p; { Buffer *b = p->p_buffer; return (b != NULL) ? b->b_name : "<Deleted>"; }
false
false
false
false
false
0
get_const_signature (DBusHeader *header, const DBusString **type_str_p, int *type_pos_p) { if (_dbus_header_get_field_raw (header, DBUS_HEADER_FIELD_SIGNATURE, type_str_p, type_pos_p)) { *type_pos_p += 1; /* skip the signature length which is 1 byte */ } else { *type_str_p = &_dbus_empty_signature_str; *type_pos_p = 0; } }
false
false
false
false
false
0
_mixer_popup_cb_mixer(void *data, void *data2 __UNUSED__) { E_Mixer_Instance *inst = data; E_Mixer_Module_Context *ctxt; E_Container *con; _mixer_popup_del(inst); ctxt = mixer_mod->data; if (ctxt->mixer_dialog) { _mixer_app_select_current(ctxt->mixer_dialog, inst); e_dialog_show(ctxt->mixer_dialog); return; } con = e_container_current_get(e_manager_current_get()); ctxt->mixer_dialog = e_mixer_app_dialog_new(con, _mixer_app_cb_del, ctxt); _mixer_app_select_current(ctxt->mixer_dialog, inst); }
false
false
false
false
false
0
vid_cap_buf_prepare(struct vb2_buffer *vb) { struct vivid_dev *dev = vb2_get_drv_priv(vb->vb2_queue); unsigned long size; unsigned buffers = tpg_g_buffers(&dev->tpg); unsigned p; dprintk(dev, 1, "%s\n", __func__); if (WARN_ON(NULL == dev->fmt_cap)) return -EINVAL; if (dev->buf_prepare_error) { /* * Error injection: test what happens if buf_prepare() returns * an error. */ dev->buf_prepare_error = false; return -EINVAL; } for (p = 0; p < buffers; p++) { size = tpg_g_line_width(&dev->tpg, p) * dev->fmt_cap_rect.height + dev->fmt_cap->data_offset[p]; if (vb2_plane_size(vb, p) < size) { dprintk(dev, 1, "%s data will not fit into plane %u (%lu < %lu)\n", __func__, p, vb2_plane_size(vb, p), size); return -EINVAL; } vb2_set_plane_payload(vb, p, size); vb->planes[p].data_offset = dev->fmt_cap->data_offset[p]; } return 0; }
false
false
false
false
true
1
calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year) { uint days; ulong daynr=calc_daynr(l_time->year,l_time->month,l_time->day); ulong first_daynr=calc_daynr(l_time->year,1,1); bool monday_first= test(week_behaviour & WEEK_MONDAY_FIRST); bool week_year= test(week_behaviour & WEEK_YEAR); bool first_weekday= test(week_behaviour & WEEK_FIRST_WEEKDAY); uint weekday=calc_weekday(first_daynr, !monday_first); *year=l_time->year; if (l_time->month == 1 && l_time->day <= 7-weekday) { if (!week_year && ((first_weekday && weekday != 0) || (!first_weekday && weekday >= 4))) return 0; week_year= 1; (*year)--; first_daynr-= (days=calc_days_in_year(*year)); weekday= (weekday + 53*7- days) % 7; } if ((first_weekday && weekday != 0) || (!first_weekday && weekday >= 4)) days= daynr - (first_daynr+ (7-weekday)); else days= daynr - (first_daynr - weekday); if (week_year && days >= 52*7) { weekday= (weekday + calc_days_in_year(*year)) % 7; if ((!first_weekday && weekday < 4) || (first_weekday && weekday == 0)) { (*year)++; return 1; } } return days/7+1; }
false
false
false
false
false
0
GetStringSize(char *string, int level) { if (level > this->MaxFontLevel) { level = this->MaxFontLevel; } int size = 0, i; for(i = 0; string[i] != '\0'; i++) { if (string[i] < 32) { continue; } if (string[i] > 126) { continue; } size += this->FontWidths[level][string[i]-32]; } return size; }
false
false
false
false
false
0
__Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { PyObject *local_type, *local_value, *local_tb; PyObject *tmp_type, *tmp_value, *tmp_tb; PyThreadState *tstate = PyThreadState_GET(); local_type = tstate->curexc_type; local_value = tstate->curexc_value; local_tb = tstate->curexc_traceback; tstate->curexc_type = 0; tstate->curexc_value = 0; tstate->curexc_traceback = 0; PyErr_NormalizeException(&local_type, &local_value, &local_tb); if (unlikely(tstate->curexc_type)) goto bad; #if PY_MAJOR_VERSION >= 3 if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0)) goto bad; #endif *type = local_type; *value = local_value; *tb = local_tb; Py_INCREF(local_type); Py_INCREF(local_value); Py_INCREF(local_tb); tmp_type = tstate->exc_type; tmp_value = tstate->exc_value; tmp_tb = tstate->exc_traceback; tstate->exc_type = local_type; tstate->exc_value = local_value; tstate->exc_traceback = local_tb; /* Make sure tstate is in a consistent state when we XDECREF these objects (XDECREF may run arbitrary code). */ Py_XDECREF(tmp_type); Py_XDECREF(tmp_value); Py_XDECREF(tmp_tb); return 0; bad: *type = 0; *value = 0; *tb = 0; Py_XDECREF(local_type); Py_XDECREF(local_value); Py_XDECREF(local_tb); return -1; }
false
false
false
false
false
0
LoadTarballs() { for( int i = 0; i < 2; i++ ) { // load data into memory Restore builder(m_tarpaths[i]); StoreParser parser(m_tars[i]); Pipe pipe(builder); pipe.PumpFile(parser, m_ic.get()); // sort each database's record data by UniqueId for( DatabaseMap::iterator b = m_tars[i].begin(); b != m_tars[i].end(); ++b ) { if( m_sort_on_load ) sort(b->second.begin(), b->second.end(), DBDataCmp); } } }
false
false
false
false
false
0
gst_play_sink_set_subtitle_encoding (GstPlaySink * playsink, const gchar * encoding) { GstPlayTextChain *chain; GST_PLAY_SINK_LOCK (playsink); chain = (GstPlayTextChain *) playsink->textchain; g_free (playsink->subtitle_encoding); playsink->subtitle_encoding = g_strdup (encoding); if (chain && chain->overlay) { g_object_set (chain->overlay, "subtitle-encoding", encoding, NULL); } GST_PLAY_SINK_UNLOCK (playsink); }
false
false
false
false
false
0
snuff_light_source(x, y) int x, y; { light_source *ls; struct obj *obj; for (ls = light_base; ls; ls = ls->next) /* Is this position check valid??? Can I assume that the positions will always be correct because the objects would have been updated with the last vision update? [Is that recent enough???] */ if (ls->type == LS_OBJECT && ls->x == x && ls->y == y) { obj = (struct obj *) ls->id; if (obj_is_burning(obj)) { /* The only way to snuff Sunsword is to unwield it. Darkness * scrolls won't affect it. (If we got here because it was * dropped or thrown inside a monster, this won't matter anyway * because it will go out when dropped.) */ if (artifact_light(obj)) continue; end_burn(obj, obj->otyp != MAGIC_LAMP); /* * The current ls element has just been removed (and * ls->next is now invalid). Return assuming that there * is only one light source attached to each object. */ return; } } }
false
false
false
false
false
0
dw_sort_postings(HashTable *plists_ht) { int i, j; HashEntry *he; PostingList **plists = (PostingList **)plists_ht->table; const int num_entries = plists_ht->mask + 1; for (i = 0, j = 0; i < num_entries; i++) { he = &plists_ht->table[i]; if (he->value) { plists[j++] = (PostingList *)he->value; } } qsort(plists, plists_ht->size, sizeof(PostingList *), (int (*)(const void *, const void *))&pl_cmp); return plists; }
false
false
false
false
false
0
parse_noreturn() { if (noreturn.empty()) { noreturn.insert("exit"); noreturn.insert("_exit"); noreturn.insert("_Exit"); noreturn.insert("abort"); noreturn.insert("err"); noreturn.insert("verr"); noreturn.insert("errx"); noreturn.insert("verrx"); noreturn.insert("ExitProcess"); noreturn.insert("ExitThread"); noreturn.insert("pthread_exit"); } std::list<Scope>::const_iterator scope; for (scope = symbolDatabase->scopeList.begin(); scope != symbolDatabase->scopeList.end(); ++scope) { // only check functions if (scope->type != Scope::eFunction) continue; // parse this function to check if it contains an "exit" call.. bool isNoreturn = false; for (const Token *tok2 = scope->classStart->next(); tok2 != scope->classEnd; tok2 = tok2->next()) { if (Token::Match(tok2->previous(), "[;{}] exit (")) { isNoreturn = true; break; } } // This function is not a noreturn function if (isNoreturn) noreturn.insert(scope->className); else notnoreturn.insert(scope->className); } }
false
false
false
false
false
0
find_scope(const std::list<hname_t>&path) const { if (path.empty()) return 0; for (list<NetScope*>::const_iterator scope = root_scopes_.begin() ; scope != root_scopes_.end(); scope++) { NetScope*cur = *scope; if (path.front() != cur->fullname()) continue; std::list<hname_t> tmp = path; tmp.pop_front(); while (cur) { if (tmp.empty()) return cur; cur = cur->child( tmp.front() ); tmp.pop_front(); } } return 0; }
false
false
false
false
false
0
_e_order_save(E_Order *eo) { FILE *f; Eina_List *l; Efreet_Desktop *desktop; if (!eo->path) return; f = fopen(eo->path, "wb"); if (!f) return; EINA_LIST_FOREACH(eo->desktops, l, desktop) { const char *id; id = efreet_util_path_to_file_id(desktop->orig_path); if (id) fprintf(f, "%s\n", id); else fprintf(f, "%s\n", desktop->orig_path); } fclose(f); }
false
false
false
false
false
0
altera_ps2_open(struct serio *io) { struct ps2if *ps2if = io->port_data; /* clear fifo */ while (readl(ps2if->base) & 0xffff0000) /* empty */; writel(1, ps2if->base + 4); /* enable rx irq */ return 0; }
false
false
false
false
false
0
X509_NAME_to_string(std::string& str,const X509_NAME* name) { str.resize(0); if(name == NULL) return; char* s = X509_NAME_oneline((X509_NAME*)name,NULL,0); if(s) { str=s; OPENSSL_free(s); }; return; }
false
false
false
false
false
0
main(void) { deque_t *deque; int errcode,integer,integer_; size_t counter = 0; deque = deque_initialize(sizeof(int),NULL); if(!deque){ fputs("Error!\n",stderr); return -1; } while(counter != 64){ integer = counter; errcode = deque_push_front(deque,&integer); if(errcode){ deque_release(deque); fputs("Error!\n",stderr); return -1; } integer = counter+10; errcode = deque_push_back(deque,&integer); if(errcode){ deque_release(deque); fputs("Error!\n",stderr); return -1; } counter++; } counter = 0; while(counter != deque_size(deque)){ errcode = deque_refer_from_front(deque,counter,&integer); if(errcode){ deque_release(deque); fputs("Error!\n",stderr); return -1; } errcode = deque_refer_from_back(deque,counter,&integer_); if(errcode){ deque_release(deque); fputs("Error!\n",stderr); return -1; } fprintf(stdout,"%03d : %03d,%03d\n",counter,integer,integer_); counter++; } deque_release(deque); return 0; }
false
false
false
false
false
0
yylex(void) { extern YYSTYPE yylval; extern YYLTYPE yylloc; int result; int old_n; int is_elidable; int is_boiveho; if (!show_elisions) { /* Minimalist approach, no need for the fancy buffering */ TokenType tok; yylex1(&tok); yylval = tok.yylval; yylloc = tok.yylloc; return tok.value; } /* else ... */ /* Shift along the register to track whether we got a PA or a letter cmavo right before starting a block of elidables */ prev_token_was_pa_etc = cur_token_was_pa_etc; /* Otherwise, build up a buffer of arbitrarily many elidables with a single non-elidable at the end. Drain this buffer into the bison layer, performing shift-ability checks on the later tokens as each bison state is reached. */ if (tokbuf.rp < tokbuf.n) { yylval = tokbuf.buf[tokbuf.rp].yylval; yylloc = tokbuf.buf[tokbuf.rp].yylloc; result = tokbuf.buf[tokbuf.rp].value; tokbuf.sp = tokbuf.rp; /* Bison never has more than 1 lookahead token (!) */ ++tokbuf.rp; return result; } else { tokbuf.rp = tokbuf.n = 0; do { if (tokbuf.n == tokbuf.max) { grow_buffer(); } old_n = tokbuf.n; yylex1(&tokbuf.buf[tokbuf.n++]); tokbuf.flags[old_n].boiveho = 0; tokbuf.flags[old_n].subscript_before = 0; is_elidable = token_is_elidable(tokbuf.buf[old_n].yylval, &is_boiveho); tokbuf.flags[old_n].boiveho = is_boiveho; tokbuf.flags[old_n].tok_is_number_marker = token_is_number_marker(tokbuf.buf[old_n].yylval); } while (is_elidable); clear_conflicts(); #if 0 fprintf(stderr, "refill gave %d tokens\n", tokbuf.n); #endif yylval = tokbuf.buf[0].yylval; yylloc = tokbuf.buf[0].yylloc; result = tokbuf.buf[0].value; tokbuf.sp = tokbuf.rp; ++tokbuf.rp; if (tokbuf.rp == tokbuf.n) { /* Single token, or non-elidable at end of tokbuf */ switch (result) { case PA: case BU: case BY: case LAU: case TEI: case FOI: cur_token_was_pa_etc = 1; break; default: cur_token_was_pa_etc = 0; break; } } return result; } }
false
false
false
false
true
1
checkDBVersion() { // get a CRC for metadata.xml QString metadataXML = QString(home.absolutePath()) + "/metadata.xml"; int metadatacrcnow = computeFileCRC(metadataXML); // get a CRC for measures.xml //QString measuresXML = QString(home.absolutePath()) + "/measures.xml"; int measurescrcnow = 0; //computeFileCRC(measuresXML);// we don't allow user to edit // can we get a version number? QSqlQuery query("SELECT table_name, schema_version, creation_date, metadata_crc from version;", dbconn); bool rc = query.exec(); if (!rc) { // we couldn't read the version table properly // it must be out of date!! QSqlQuery dropM("DROP TABLE version", dbconn); dropM.exec(); // recreate version table and add one entry QSqlQuery version("CREATE TABLE version ( table_name varchar primary key, schema_version integer, creation_date date, metadata_crc integer );", dbconn); version.exec(); // wipe away whatever (if anything is there) dropMetricTable(); dropMeasuresTable(); // create afresh createMetricsTable(); createMeasuresTable(); return; } // ok we checked out ok, so lets adjust db schema to reflect // tne current version / crc bool dropMetric = false; bool dropMeasures = false; while (query.next()) { QString table_name = query.value(0).toString(); int currentversion = query.value(1).toInt(); //int creationdate = query.value(2).toInt(); // not relevant anymore, we use version/crc int crc = query.value(3).toInt(); if (table_name == "metrics" && (currentversion != DBSchemaVersion || crc != metadatacrcnow)) { dropMetric = true; } if (table_name == "measures" && crc != measurescrcnow) { dropMeasures = true; } } query.finish(); // "metrics" table, is it up-to-date? if (dropMetric) { dropMetricTable(); createMetricsTable(); } // "measures" table, is it up-to-date? - export - recreate - import .... // gets wiped away for now, will fix as part of v3.1 if (dropMeasures) { dropMeasuresTable(); createMeasuresTable(); } }
false
false
false
false
false
0
ibus_serializable_real_deserialize (IBusSerializable *object, GVariant *variant) { const gchar *key; GVariant *value; GVariantIter *iter = NULL; g_variant_get_child (variant, 1, "a{sv}", &iter); while (g_variant_iter_loop (iter, "{&sv}", &key, &value)) { GVariant *attachment = g_variant_get_variant (value); ibus_serializable_set_attachment (object, key, attachment); g_variant_unref (attachment); } g_variant_iter_free (iter); return 2; }
false
false
false
false
false
0
lmc_shm_create(const char* namespace, size_t size, lmc_error_t *e) { lmc_shm_t *mc = calloc(1, sizeof(lmc_shm_t)); if (!mc) { STD_OUT_OF_MEMORY_ERROR("lmc_shm_create"); return NULL; } snprintf((char *)&mc->namespace, 1023, "%s", namespace); mc->size = size; lmc_shm_ensure_namespace_file(mc->namespace); char fn[1024]; lmc_file_path_for_namespace((char *)&fn, mc->namespace); if (!lmc_handle_error((mc->fd = open(fn, O_RDWR, (mode_t)0777)) == -1, "open", "ShmError", e)) goto open_failed; if (!lmc_handle_error(lseek(mc->fd, mc->size - 1, SEEK_SET) == -1, "lseek", "ShmError", e)) goto failed; if (!lmc_handle_error(write(mc->fd, "", 1) != 1, "write", "ShmError", e)) goto failed; mc->base = mmap(0, mc->size, PROT_READ | PROT_WRITE, MAP_SHARED, mc->fd, (off_t)0); if (!lmc_handle_error(mc->base == MAP_FAILED, "mmap", "ShmError", e)) goto failed; return mc; failed: close(mc->fd); open_failed: free(mc); return NULL; }
false
false
false
false
false
0
Vertical_XOR_line_tall2(word x_pos,word y_pos,word height) { int i; byte *dest=Screen_pixels+x_pos*ZOOMX+y_pos*VIDEO_LINE_WIDTH*ZOOMY; for (i=height;i>0;i--) { *(dest+3*VIDEO_LINE_WIDTH+1)=*(dest+3*VIDEO_LINE_WIDTH)=*(dest+2*VIDEO_LINE_WIDTH+1)=*(dest+2*VIDEO_LINE_WIDTH)=*(dest+VIDEO_LINE_WIDTH+1)=*(dest+VIDEO_LINE_WIDTH)=*(dest+1)=*(dest)=~*(dest); dest+=VIDEO_LINE_WIDTH*ZOOMY; } }
false
false
false
false
false
0
DepthEvent(GtkWidget * UNUSED(widget), GdkEvent * event, rollswidget * prw) { switch (event->type) { case GDK_BUTTON_PRESS: fScrollComplete = FALSE; break; case GDK_BUTTON_RELEASE: fScrollComplete = TRUE; g_signal_emit_by_name(G_OBJECT(prw->pScale), "value-changed", prw); break; default: ; } return FALSE; }
false
false
false
false
false
0
button_release_event(GtkWidget *widget, GdkEventButton *event) { struct imgrect *ir; ir = find_image_rectangle(click.x, click.y); if (ir && ir == find_image_rectangle((int)event->x, (int)event->y)) { /* We draw a little frame around the image while we're saving it, to * give some visual feedback. */ struct timespec jiffy = { 0, 100000000 }; gdk_draw_rectangle(drawable, darea->style->white_gc, 0, ir->x - 2, ir->y - 2, ir->w + 3, ir->h + 3); gdk_flush(); /* force X to actually draw the damn thing. */ save_image(ir); nanosleep(&jiffy, NULL); gdk_draw_rectangle(drawable, darea->style->black_gc, 0, ir->x - 2, ir->y - 2, ir->w + 3, ir->h + 3); } }
false
false
false
false
false
0
v4lconvert_rotate90_rgbbgr24(const unsigned char *src, unsigned char *dst, int destwidth, int destheight) { int x, y; #define srcwidth destheight #define srcheight destwidth for (y = 0; y < destheight; y++) for (x = 0; x < destwidth; x++) { int offset = ((srcheight - x - 1) * srcwidth + y) * 3; *dst++ = src[offset++]; *dst++ = src[offset++]; *dst++ = src[offset]; } }
false
false
false
false
false
0
ossl_pkcs7_s_encrypt(int argc, VALUE *argv, VALUE klass) { VALUE certs, data, cipher, flags; STACK_OF(X509) *x509s; BIO *in; const EVP_CIPHER *ciph; int flg, status = 0; VALUE ret; PKCS7 *p7; rb_scan_args(argc, argv, "22", &certs, &data, &cipher, &flags); if(NIL_P(cipher)){ #if !defined(OPENSSL_NO_RC2) ciph = EVP_rc2_40_cbc(); #elif !defined(OPENSSL_NO_DES) ciph = EVP_des_ede3_cbc(); #elif !defined(OPENSSL_NO_RC2) ciph = EVP_rc2_40_cbc(); #elif !defined(OPENSSL_NO_AES) ciph = EVP_EVP_aes_128_cbc(); #else ossl_raise(ePKCS7Error, "Must specify cipher"); #endif } else ciph = GetCipherPtr(cipher); /* NO NEED TO DUP */ flg = NIL_P(flags) ? 0 : NUM2INT(flags); in = ossl_obj2bio(data); x509s = ossl_protect_x509_ary2sk(certs, &status); if(status){ BIO_free(in); rb_jump_tag(status); } if(!(p7 = PKCS7_encrypt(x509s, in, (EVP_CIPHER*)ciph, flg))){ BIO_free(in); sk_X509_pop_free(x509s, X509_free); ossl_raise(ePKCS7Error, NULL); } BIO_free(in); WrapPKCS7(cPKCS7, ret, p7); ossl_pkcs7_set_data(ret, data); sk_X509_pop_free(x509s, X509_free); return ret; }
false
false
false
false
true
1
insert(int type, int idno, int nindex, int*indexarray) { int i, j; int variableid; int found; if (Variable.getidnumber(idno)!=-1) { outerror(glno, "id exist."); return; } i=getidnumber(idno); if (i!=-1) { outerror(glno, "id exist."); return; } i=0; if (nvars<maxidnumber) { found=1; while(i<nindex&&found) { variableid=Variable.getidnumber(indexarray[i]); if(variableid==-1) found=0; else { arrayindex[nvars][i]=variableid; i++; } } if (!found) { outerror(glno, "index not defined."); printf("%s, \n",idname[indexarray[i]].c_str()); return; } /*add 0 to meet the ll needs*/ for (j=i; j<mx_array_dim; j++) arrayindex[nvars][j]=0; vararray[nvars]=idname[idno]; arraynindex[nvars]=nindex; arraytype[nvars]=type; nvars++; } else { outerror(glno, "More id than id container can hold, please contact writer.\n"); } }
false
false
false
false
false
0
dbmetaprint(kc::BasicDB* db, bool verbose) { if (verbose) { std::map<std::string, std::string> status; status["opaque"] = ""; if (db->status(&status)) { uint32_t type = kc::atoi(status["type"].c_str()); oprintf("type: %s (%s) (type=0x%02X)\n", kc::BasicDB::typecname(type), kc::BasicDB::typestring(type), type); uint32_t rtype = kc::atoi(status["realtype"].c_str()); if (rtype > 0 && rtype != type) oprintf("real type: %s (%s) (realtype=0x%02X)\n", kc::BasicDB::typecname(rtype), kc::BasicDB::typestring(rtype), rtype); oprintf("path: %s\n", status["path"].c_str()); if (status["opaque"].size() >= 16) { const char* opaque = status["opaque"].c_str(); oprintf("opaque:"); if (std::count(opaque, opaque + 16, 0) != 16) { for (int32_t i = 0; i < 16; i++) { oprintf(" %02X", ((unsigned char*)opaque)[i]); } } else { oprintf(" 0"); } oprintf("\n"); } int64_t count = kc::atoi(status["count"].c_str()); std::string cntstr = unitnumstr(count); oprintf("count: %lld (%s)\n", count, cntstr.c_str()); int64_t size = kc::atoi(status["size"].c_str()); std::string sizestr = unitnumstrbyte(size); oprintf("size: %lld (%s)\n", size, sizestr.c_str()); } } else { oprintf("count: %lld\n", (long long)db->count()); oprintf("size: %lld\n", (long long)db->size()); } int64_t musage = memusage(); if (musage > 0) oprintf("memory: %lld\n", (long long)(musage - g_memusage)); }
false
false
false
false
false
0
alarm_action_toggle_list_win (GtkAction *action, gpointer data) { AlarmApplet *applet = (AlarmApplet *)data; AlarmListWindow *list_window = applet->list_window; gboolean active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action)); g_debug ("AlarmAction: toggle list window"); /* if (!a || a->active == active) { // No alarms selected or no change return; } */ if (active) { alarm_list_window_show (list_window); } else { alarm_list_window_hide (list_window); } }
false
false
false
false
false
0
unmount_callback(DBusGProxy *proxy, GError *error, gpointer user_data) { AsyncData* data = (AsyncData*)user_data; GSimpleAsyncResult* res; if(error) { error = g_udisks_error_to_gio_error(error); res = g_simple_async_result_new_from_error(G_OBJECT(data->mnt), data->callback, data->user_data, error); g_error_free(error); } else { res = g_simple_async_result_new(G_OBJECT(data->mnt), data->callback, data->user_data, NULL); g_simple_async_result_set_op_res_gboolean(res, TRUE); } g_simple_async_result_complete(res); g_object_unref(res); g_object_unref(data->mnt); g_object_unref(data->proxy); g_slice_free(AsyncData, data); }
false
false
false
false
false
0
common_sh_start(const struct MachineSound *msound, const char *name) { int i, j; UINT32 shiftreg; poly18 = (UINT32 *)auto_malloc((1ul << (18-5)) * sizeof(UINT32)); if( !poly18 ) return 1; shiftreg = 0; for( i = 0; i < (1ul << (18-5)); i++ ) { UINT32 bits = 0; for( j = 0; j < 32; j++ ) { bits = (bits >> 1) | (shiftreg << 31); if( ((shiftreg >> 16) & 1) == ((shiftreg >> 17) & 1) ) shiftreg = (shiftreg << 1) | 1; else shiftreg <<= 1; } poly18[i] = bits; } channel = stream_init(name, 40, Machine->sample_rate, 0, pleiads_sound_update); if( channel == -1 ) return 1; return 0; }
false
false
false
false
false
0
hiface_pcm_prepare(struct snd_pcm_substream *alsa_sub) { struct pcm_runtime *rt = snd_pcm_substream_chip(alsa_sub); struct pcm_substream *sub = hiface_pcm_get_substream(alsa_sub); struct snd_pcm_runtime *alsa_rt = alsa_sub->runtime; int ret; if (rt->panic) return -EPIPE; if (!sub) return -ENODEV; mutex_lock(&rt->stream_mutex); hiface_pcm_stream_stop(rt); sub->dma_off = 0; sub->period_off = 0; if (rt->stream_state == STREAM_DISABLED) { ret = hiface_pcm_set_rate(rt, alsa_rt->rate); if (ret) { mutex_unlock(&rt->stream_mutex); return ret; } ret = hiface_pcm_stream_start(rt); if (ret) { mutex_unlock(&rt->stream_mutex); return ret; } } mutex_unlock(&rt->stream_mutex); return 0; }
false
false
false
false
false
0
on_action_public_default(struct recv_frame *precv_frame, u8 action) { unsigned int ret = _FAIL; u8 *pframe = precv_frame->rx_data; u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); u8 token; token = frame_body[2]; if (rtw_action_public_decache(precv_frame, token) == _FAIL) goto exit; ret = _SUCCESS; exit: return ret; }
false
false
false
false
false
0
setValue(const QVariant &value) { if (d->m_Type==ExtraDocument) { d->setDocumentHtml(value); d->setDirty(); } else if (d->m_Value != value) { d->m_Value = value; d->setDirty(); } }
false
false
false
false
false
0
iio_init(void) { int ret; /* Register sysfs bus */ ret = bus_register(&iio_bus_type); if (ret < 0) { pr_err("could not register bus type\n"); goto error_nothing; } ret = alloc_chrdev_region(&iio_devt, 0, IIO_DEV_MAX, "iio"); if (ret < 0) { pr_err("failed to allocate char dev region\n"); goto error_unregister_bus_type; } iio_debugfs_dentry = debugfs_create_dir("iio", NULL); return 0; error_unregister_bus_type: bus_unregister(&iio_bus_type); error_nothing: return ret; }
false
false
false
false
false
0
bf_actt_c1( FMField *out, FMField *bf, FMField *in ) { int32 iqp, ir, ic, nEP, nQP, dim; float64 *pout, *pbf, *pin; nEP = bf->nCol; nQP = bf->nLev; dim = in->nRow; #ifdef DEBUG_FMF if ((out->nRow != dim * nEP) || (out->nCol != 1) || (out->nLev != in->nLev) || (out->nLev != bf->nLev) || (in->nRow != dim) || (in->nCol != 1)) { errput( ErrHead "ERR_BadMatch: (%d %d %d), (%d %d %d), (%d %d %d)\n", out->nLev, out->nRow, out->nCol, bf->nLev, bf->nRow, bf->nCol, in->nLev, in->nRow, in->nCol ); } #endif for (iqp = 0; iqp < nQP; iqp++) { pbf = FMF_PtrLevel( bf, iqp ); pout = FMF_PtrLevel( out, iqp ); pin = FMF_PtrLevel( in, iqp ); for (ic = 0; ic < dim; ic++ ) { for (ir = 0; ir < nEP; ir++) { pout[nEP*ic+ir] = pbf[ir] * in->val[ic]; } } } return( RET_OK ); }
false
false
false
false
false
0
request( void ) throw ( NullPointerException ) { if( theState != NULLPTR ) { theState->handle(); } else { throw NullPointerException( LOCATION ); } }
false
false
false
false
false
0
print_save_msg(buf, nchars) nbbuf_T *buf; off_t nchars; { char_u c; char_u *p; if (nchars >= 0) { /* put fname in IObuff with quotes */ msg_add_fname(buf->bufp, buf->bufp->b_ffname); c = FALSE; msg_add_lines(c, buf->bufp->b_ml.ml_line_count, buf->bufp->b_orig_size); vim_free(keep_msg); keep_msg = NULL; msg_scrolled_ign = TRUE; p = msg_trunc_attr(IObuff, FALSE, 0); if ((msg_scrolled && !need_wait_return) || !buf->initDone) { /* Need to repeat the message after redrawing when: * - When reading from stdin (the screen will be cleared next). * - When restart_edit is set (otherwise there will be a delay * before redrawing). * - When the screen was scrolled but there is no wait-return * prompt. */ set_keep_msg(p, 0); } msg_scrolled_ign = FALSE; /* add_to_input_buf((char_u *)"\f", 1); */ } else { char_u msgbuf[IOSIZE]; vim_snprintf((char *)msgbuf, IOSIZE, _("E505: %s is read-only (add ! to override)"), IObuff); nbdebug((" %s\n", msgbuf)); emsg(msgbuf); } }
false
false
false
false
false
0
rt2x00lib_load_firmware(struct rt2x00_dev *rt2x00dev) { int retval; if (!rt2x00_has_cap_flag(rt2x00dev, REQUIRE_FIRMWARE)) return 0; if (!rt2x00dev->fw) { retval = rt2x00lib_request_firmware(rt2x00dev); if (retval) return retval; } /* * Send firmware to the device. */ retval = rt2x00dev->ops->lib->load_firmware(rt2x00dev, rt2x00dev->fw->data, rt2x00dev->fw->size); /* * When the firmware is uploaded to the hardware the LED * association status might have been triggered, for correct * LED handling it should now be reset. */ rt2x00leds_led_assoc(rt2x00dev, false); return retval; }
false
false
false
false
false
0
GetOrCreateTaskProfile(char* fileName, int lineNum) { for(int i=0;i<(int)mTasks.size();i++) { if(strcmp(fileName,mTasks[i]->mFileName)==0 && lineNum == mTasks[i]->mLine) return mTasks[i]; } TaskProfile* tp = new TaskProfile(); mTasks.push_back(tp); return tp; }
false
false
false
false
false
0
CountChar(char *string,char sep) { char *sp; int count = 0; if (string == NULL) { return 0; } if (string && strlen(string) == 0) { return 0; } for (sp = string; *sp != '\0'; sp++) { if (*sp == '\\' && *(sp+1) == sep) { ++sp; } else if (*sp == sep) { count++; } } return count; }
false
false
false
false
false
0
expandargv (int *argcp, char ***argvp) { /* The argument we are currently processing. */ int i = 0; /* Non-zero if ***argvp has been dynamically allocated. */ int argv_dynamic = 0; /* Limit the number of response files that we parse in order to prevent infinite recursion. */ unsigned int iteration_limit = 2000; /* Loop over the arguments, handling response files. We always skip ARGVP[0], as that is the name of the program being run. */ while (++i < *argcp) { /* The name of the response file. */ const char *filename; /* The response file. */ FILE *f; /* An upper bound on the number of characters in the response file. */ long pos; /* The number of characters in the response file, when actually read. */ size_t len; /* A dynamically allocated buffer used to hold options read from a response file. */ char *buffer; /* Dynamically allocated storage for the options read from the response file. */ char **file_argv; /* The number of options read from the response file, if any. */ size_t file_argc; /* We are only interested in options of the form "@file". */ filename = (*argvp)[i]; if (filename[0] != '@') continue; /* If we have iterated too many times then stop. */ if (-- iteration_limit == 0) { fprintf (stderr, "%s: error: too many @-files encountered\n", (*argvp)[0]); xexit (1); } /* Read the contents of the file. */ f = fopen (++filename, "r"); if (!f) continue; if (fseek (f, 0L, SEEK_END) == -1) goto error; pos = ftell (f); if (pos == -1) goto error; if (fseek (f, 0L, SEEK_SET) == -1) goto error; buffer = (char *) xmalloc (pos * sizeof (char) + 1); len = fread (buffer, sizeof (char), pos, f); if (len != (size_t) pos /* On Windows, fread may return a value smaller than POS, due to CR/LF->CR translation when reading text files. That does not in-and-of itself indicate failure. */ && ferror (f)) goto error; /* Add a NUL terminator. */ buffer[len] = '\0'; /* If the file is empty or contains only whitespace, buildargv would return a single empty argument. In this context we want no arguments, instead. */ if (only_whitespace (buffer)) { file_argv = (char **) xmalloc (sizeof (char *)); file_argv[0] = NULL; } else /* Parse the string. */ file_argv = buildargv (buffer); /* If *ARGVP is not already dynamically allocated, copy it. */ if (!argv_dynamic) *argvp = dupargv (*argvp); /* Count the number of arguments. */ file_argc = 0; while (file_argv[file_argc]) ++file_argc; /* Now, insert FILE_ARGV into ARGV. The "+1" below handles the NULL terminator at the end of ARGV. */ *argvp = ((char **) xrealloc (*argvp, (*argcp + file_argc + 1) * sizeof (char *))); memmove (*argvp + i + file_argc, *argvp + i + 1, (*argcp - i) * sizeof (char *)); memcpy (*argvp + i, file_argv, file_argc * sizeof (char *)); /* The original option has been replaced by all the new options. */ *argcp += file_argc - 1; /* Free up memory allocated to process the response file. We do not use freeargv because the individual options in FILE_ARGV are now in the main ARGV. */ free (file_argv); free (buffer); /* Rescan all of the arguments just read to support response files that include other response files. */ --i; error: /* We're all done with the file now. */ fclose (f); } }
false
true
false
false
true
1
latencyCommandGenSparkeline(char *event, struct latencyTimeSeries *ts) { int j; struct sequence *seq = createSparklineSequence(); sds graph = sdsempty(); uint32_t min = 0, max = 0; for (j = 0; j < LATENCY_TS_LEN; j++) { int i = (ts->idx + j) % LATENCY_TS_LEN; int elapsed; char buf[64]; if (ts->samples[i].time == 0) continue; /* Update min and max. */ if (seq->length == 0) { min = max = ts->samples[i].latency; } else { if (ts->samples[i].latency > max) max = ts->samples[i].latency; if (ts->samples[i].latency < min) min = ts->samples[i].latency; } /* Use as label the number of seconds / minutes / hours / days * ago the event happened. */ elapsed = time(NULL) - ts->samples[i].time; if (elapsed < 60) snprintf(buf,sizeof(buf),"%ds",elapsed); else if (elapsed < 3600) snprintf(buf,sizeof(buf),"%dm",elapsed/60); else if (elapsed < 3600*24) snprintf(buf,sizeof(buf),"%dh",elapsed/3600); else snprintf(buf,sizeof(buf),"%dd",elapsed/(3600*24)); sparklineSequenceAddSample(seq,ts->samples[i].latency,buf); } graph = sdscatprintf(graph, "%s - high %lu ms, low %lu ms (all time high %lu ms)\n", event, (unsigned long) max, (unsigned long) min, (unsigned long) ts->max); for (j = 0; j < LATENCY_GRAPH_COLS; j++) graph = sdscatlen(graph,"-",1); graph = sdscatlen(graph,"\n",1); graph = sparklineRender(graph,seq,LATENCY_GRAPH_COLS,4,SPARKLINE_FILL); freeSparklineSequence(seq); return graph; }
false
false
false
false
false
0
addlist (List **listp, char *key) { Node *p; if (*listp == NULL) *listp = getlist (); p = getnode (); p->type = FILES; p->key = xstrdup (key); if (addnode (*listp, p) != 0) freenode (p); }
false
false
false
false
false
0
prt_fnc(fnc) struct c_fnc *fnc; { struct code *sig; char *name; char *prefix; if (fnc->flag & CF_SigOnly) { /* * This function only returns a signal. A shared function is used in * its place. Make sure that function has been printed. */ sig = fnc->cd.next->SigRef->sig; if (sig->cd_id != C_Resume) { sig = ChkBound(sig); if (!(sig->LabFlg & FncPrtd)) { ChkSeqNum(sig); fprintf(inclfile, "static int sig_%d (void);\n", sig->SeqNum); fprintf(codefile, "\n"); fprintf(codefile, "static int sig_%d()\n", sig->SeqNum); fprintf(codefile, " {\n"); fprintf(codefile, " return %d; /* %s */\n", sig->SeqNum, sig->Desc); fprintf(codefile, " }\n"); sig->LabFlg |= FncPrtd; } } } else { ChkPrefix(fnc->prefix); prefix = fnc->prefix; name = cur_proc->name; fprintf(inclfile, "static int P%s_%s (void);\n", prefix, name); fprintf(codefile, "\n"); fprintf(codefile, "static int P%s_%s()\n", prefix, name); fprintf(codefile, " {\n"); if (fnc->flag & CF_Coexpr) fprintf(codefile, "#ifdef Coexpr\n"); prefix = fnc->frm_prfx; fprintf(codefile, " register int r_signal;\n"); fprintf(codefile, " register struct PF%s_%s *r_pfp;\n", prefix, name); fprintf(codefile, "\n"); fprintf(codefile, " r_pfp = (struct PF%s_%s *)pfp;\n", prefix, name); prtcode(&(fnc->cd), 0); if (fnc->flag & CF_Coexpr) { fprintf(codefile, "#else\t\t\t\t\t/* Coexpr */\n"); fprintf(codefile, " fatalerr(401, NULL);\n"); fprintf(codefile, "#endif\t\t\t\t\t/* Coexpr */\n"); } fprintf(codefile, " }\n"); } }
false
false
false
false
false
0
codec_copy_filtered (FsCodec *codec, FsParamType paramtypes) { FsCodec *copy = fs_codec_copy (codec); GList *item = NULL; const struct SdpNegoFunction *nf; nf = get_sdp_nego_function (codec->media_type, codec->encoding_name); if (nf) { for (item = copy->optional_params; item;) { FsCodecParameter *param = item->data; GList *next = g_list_next (item); if (codec_param_check_type (nf, param->name, paramtypes)) fs_codec_remove_optional_parameter (copy, param); item = next; } } return copy; }
false
false
false
false
false
0
iscsit_tmr_task_reassign( struct iscsi_cmd *cmd, unsigned char *buf) { struct iscsi_cmd *ref_cmd = NULL; struct iscsi_conn *conn = cmd->conn; struct iscsi_conn_recovery *cr = NULL; struct iscsi_tmr_req *tmr_req = cmd->tmr_req; struct se_tmr_req *se_tmr = cmd->se_cmd.se_tmr_req; struct iscsi_tm *hdr = (struct iscsi_tm *) buf; u64 ret, ref_lun; pr_debug("Got TASK_REASSIGN TMR ITT: 0x%08x," " RefTaskTag: 0x%08x, ExpDataSN: 0x%08x, CID: %hu\n", hdr->itt, hdr->rtt, hdr->exp_datasn, conn->cid); if (conn->sess->sess_ops->ErrorRecoveryLevel != 2) { pr_err("TMR TASK_REASSIGN not supported in ERL<2," " ignoring request.\n"); return ISCSI_TMF_RSP_NOT_SUPPORTED; } ret = iscsit_find_cmd_for_recovery(conn->sess, &ref_cmd, &cr, hdr->rtt); if (ret == -2) { pr_err("Command ITT: 0x%08x is still alligent to CID:" " %hu\n", ref_cmd->init_task_tag, cr->cid); return ISCSI_TMF_RSP_TASK_ALLEGIANT; } else if (ret == -1) { pr_err("Unable to locate RefTaskTag: 0x%08x in" " connection recovery command list.\n", hdr->rtt); return ISCSI_TMF_RSP_NO_TASK; } /* * Temporary check to prevent connection recovery for * connections with a differing Max*DataSegmentLength. */ if (cr->maxrecvdatasegmentlength != conn->conn_ops->MaxRecvDataSegmentLength) { pr_err("Unable to perform connection recovery for" " differing MaxRecvDataSegmentLength, rejecting" " TMR TASK_REASSIGN.\n"); return ISCSI_TMF_RSP_REJECTED; } if (cr->maxxmitdatasegmentlength != conn->conn_ops->MaxXmitDataSegmentLength) { pr_err("Unable to perform connection recovery for" " differing MaxXmitDataSegmentLength, rejecting" " TMR TASK_REASSIGN.\n"); return ISCSI_TMF_RSP_REJECTED; } ref_lun = scsilun_to_int(&hdr->lun); if (ref_lun != ref_cmd->se_cmd.orig_fe_lun) { pr_err("Unable to perform connection recovery for" " differing ref_lun: %llu ref_cmd orig_fe_lun: %llu\n", ref_lun, ref_cmd->se_cmd.orig_fe_lun); return ISCSI_TMF_RSP_REJECTED; } se_tmr->ref_task_tag = (__force u32)hdr->rtt; tmr_req->ref_cmd = ref_cmd; tmr_req->exp_data_sn = be32_to_cpu(hdr->exp_datasn); tmr_req->conn_recovery = cr; tmr_req->task_reassign = 1; /* * Command can now be reassigned to a new connection. * The task management response must be sent before the * reassignment actually happens. See iscsi_tmr_post_handler(). */ return ISCSI_TMF_RSP_COMPLETE; }
false
false
false
false
false
0