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
bh1780_store_power_state(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct platform_device *pdev = to_platform_device(dev); struct bh1780_data *ddata = platform_get_drvdata(pdev); unsigned long val; int error; error = kstrtoul(buf, 0, &val); if (error) return error; if (val < BH1780_POFF || val > BH1780_PON) return -EINVAL; mutex_lock(&ddata->lock); error = bh1780_write(ddata, BH1780_REG_CONTROL, val, "CONTROL"); if (error < 0) { mutex_unlock(&ddata->lock); return error; } msleep(BH1780_PON_DELAY); ddata->power_state = val; mutex_unlock(&ddata->lock); return count; }
false
false
false
false
false
0
esas2r_log_request_failure(struct esas2r_adapter *a, struct esas2r_request *rq) { u8 reqstatus = rq->req_stat; if (reqstatus == RS_SUCCESS) return; if (rq->vrq->scsi.function == VDA_FUNC_SCSI) { if (reqstatus == RS_SCSI_ERROR) { if (rq->func_rsp.scsi_rsp.sense_len >= 13) { esas2r_log(ESAS2R_LOG_WARN, "request failure - SCSI error %x ASC:%x ASCQ:%x CDB:%x", rq->sense_buf[2], rq->sense_buf[12], rq->sense_buf[13], rq->vrq->scsi.cdb[0]); } else { esas2r_log(ESAS2R_LOG_WARN, "request failure - SCSI error CDB:%x\n", rq->vrq->scsi.cdb[0]); } } else if ((rq->vrq->scsi.cdb[0] != INQUIRY && rq->vrq->scsi.cdb[0] != REPORT_LUNS) || (reqstatus != RS_SEL && reqstatus != RS_SEL2)) { if ((reqstatus == RS_UNDERRUN) && (rq->vrq->scsi.cdb[0] == INQUIRY)) { /* Don't log inquiry underruns */ } else { esas2r_log(ESAS2R_LOG_WARN, "request failure - cdb:%x reqstatus:%d target:%d", rq->vrq->scsi.cdb[0], reqstatus, rq->target_id); } } } }
false
false
false
false
false
0
openIn(const std::string& fileName, std::ifstream& ifs) { if (fileName == "-") return std::cin; ifs.open(fileName.c_str()); if (!ifs) err("can't open file: " + fileName); return ifs; }
false
false
false
false
false
0
isLast( const QModelIndex &index ) const { if(!hasParent(index)) return false; // what should be returned here? if(index.row() >= (index.model()->rowCount(index.parent())-1)) return true; else return false; }
false
false
false
false
false
0
output_func(const char *p, size_t n) { origSink << std::string(p, p+n); }
false
false
false
false
false
0
find_unlocked_1_reply (GkrOperation *op, DBusMessage *reply, gpointer data) { char **unlocked, **locked; int n_unlocked, n_locked; DBusMessage *req; /* At this point SearchItems has returned two lists of locked/unlocked items */ if (gkr_operation_handle_errors (op, reply)) return; if (!dbus_message_get_args (reply, NULL, DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH, &unlocked, &n_unlocked, DBUS_TYPE_ARRAY, DBUS_TYPE_OBJECT_PATH, &locked, &n_locked, DBUS_TYPE_INVALID)) { gkr_operation_complete (op, decode_invalid_response (reply)); return; } /* Do we have an unlocked item? */ if (n_unlocked) { gkr_callback_invoke_op_string (gkr_operation_pop (op), unlocked[0]); /* Do we have any to unlock? */ } else if (n_locked) { req = prepare_xlock ("Unlock", locked, n_locked); gkr_operation_push (op, find_unlocked_2_reply, GKR_CALLBACK_OP_MSG, NULL, NULL); gkr_operation_request (op, req); /* No passwords at all, complete */ } else { gkr_callback_invoke_op_string (gkr_operation_pop (op), NULL); } dbus_free_string_array (locked); dbus_free_string_array (unlocked); }
false
false
false
false
false
0
mxl111sf_i2c_stop(struct mxl111sf_state *state) { int ret; mxl_i2c("()"); ret = mxl111sf_write_reg(state, SW_I2C_ADDR, 0x10 | SW_I2C_EN); /* stop */ if (mxl_fail(ret)) goto fail; ret = mxl111sf_write_reg(state, SW_I2C_ADDR, 0x10 | SW_I2C_EN | SW_SCL_OUT); if (mxl_fail(ret)) goto fail; ret = mxl111sf_write_reg(state, SW_I2C_ADDR, 0x10 | SW_I2C_EN | SW_SCL_OUT | SW_SDA_OUT); if (mxl_fail(ret)) goto fail; ret = mxl111sf_write_reg(state, SW_I2C_ADDR, 0x10 | SW_SCL_OUT | SW_SDA_OUT); mxl_fail(ret); fail: return ret; }
false
false
false
false
false
0
ReadBytes() { uint8_t recv_bytes[1024]; int ret; // Don't read while we're in connect stage if (connect_complete == 0) return 0; if ((ret = read(cli_fd, recv_bytes, 1024)) < 0) { if (errno == EINTR || errno == EAGAIN) return 0; snprintf(errstr, 1024, "TCP client fd %d read() error: %s", cli_fd, strerror(errno)); globalreg->messagebus->InjectMessage(errstr, MSGFLAG_ERROR); KillConnection(); return -1; } if (ret <= 0) { snprintf(errstr, 1024, "TCP client fd %d socket closed.", cli_fd); globalreg->messagebus->InjectMessage(errstr, MSGFLAG_ERROR); KillConnection(); return -1; } if (read_buf->InsertData(recv_bytes, ret) == 0) { snprintf(errstr, 1024, "TCP client fd %d read error, ring buffer full", cli_fd); globalreg->messagebus->InjectMessage(errstr, MSGFLAG_ERROR); KillConnection(); return -1; } return ret; }
false
false
false
false
false
0
jpc_sop_putparms(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *out) { jpc_sop_t *sop = &ms->parms.sop; /* Eliminate compiler warning about unused variable. */ cstate = 0; if (jpc_putuint16(out, sop->seqno)) { return -1; } return 0; }
false
false
false
false
false
0
useContextMenu(bool state) { if (state) ui->widget->treeView()->setContextMenuPolicy(Qt::CustomContextMenu); else ui->widget->treeView()->setContextMenuPolicy(Qt::NoContextMenu); }
false
false
false
false
false
0
parseBody(struct toc** cur, bool empty, int endtype){ W("parseBody"); // zacatek tela -> spustit prikazy // ukladat je doleva za sebe do typu AST_CMDparseBody struct astNode* body = makeNewAST(); body->type = AST_CMD; *cur = getToc(); // prvni token tela!!! if((int)(*cur)->type == endtype){ D("Empty body"); if(empty) return body; else { E("Syntax error - empty body is not supported in this case"); exit(synt); } } struct astNode* cmd = parseCommand(cur); if((int)((*cur)->type) == endtype){ D("body: gets END"); // ukonceni bloku kodu if(cmd == NULL){ W("body: WARNING - statement without effect"); body->left = NULL; return body; } body->left = makeNewAST(); body->left->type = AST_CMD; body->left->left = NULL; body->left->right = cmd; return body; } else if((*cur)->type == T_SCOL){ D("body: gets SEMICOLON"); struct astNode* item = body; // ocekavat dalsi command while(cmd != NULL){ item->left = makeNewAST(); item->left->type = AST_CMD; item->left->left = NULL; item->left->right = cmd; D("Waiting for end or scol"); // pokud narazi na END tak ukoncit hledani dalsich if((int)((*cur)->type) == endtype){ D("Gets endtype"); break; } else if((*cur)->type == T_SCOL){ // nutno nacist dalsi token *cur = getToc(); // hledat dalsi cmd = parseCommand(cur); // posun na dalsi pole v seznamu prikazu item = item->left; } else { E("body: Syntax error - expected END or SEMICOLON"); exit(synt); } } } W("parseBody end"); return body; }
false
false
false
false
false
0
gda_xslt_getnodeset_function (xmlXPathParserContextPtr ctxt, int nargs) { GdaXsltIntCont *data; xsltTransformContextPtr tctxt; xmlXPathObjectPtr setname, nodeset; GdaXsltExCont *execc; if (nargs != 1) { xsltGenericError (xsltGenericErrorContext, "gda_xslt_getnodeset_function: invalid number of arguments\n"); return; } tctxt = xsltXPathGetTransformContext (ctxt); if (tctxt == NULL) { xsltGenericError (xsltGenericErrorContext, "sqlxslt: failed to get the transformation context\n"); return; } execc = (GdaXsltExCont *) tctxt->_private; data = (GdaXsltIntCont *) xsltGetExtData (tctxt, BAD_CAST GDA_XSLT_EXTENSION_URI); if (data == NULL) { xsltGenericError (xsltGenericErrorContext, "sqlxslt: failed to get module data\n"); return; } setname = valuePop (ctxt); if (setname == NULL) { xsltGenericError (xsltGenericErrorContext, "sqlxslt: internal error\n"); return; } if (setname->type != XPATH_STRING) { valuePush (ctxt, setname); xmlXPathStringFunction (ctxt, 1); setname = valuePop (ctxt); if (setname == NULL) { xsltGenericError (xsltGenericErrorContext, "sqlxslt: internal error\n"); return; } } nodeset = _gda_xslt_bk_fun_getnodeset (setname->stringval, execc, data); if (nodeset == NULL) { xsltGenericError (xsltGenericErrorContext, "exsltDynMapFunctoin: ret == NULL\n"); return; } valuePush (ctxt, nodeset); }
false
false
false
false
false
0
sign_undefine(sp, sp_prev) sign_T *sp; sign_T *sp_prev; { vim_free(sp->sn_name); vim_free(sp->sn_icon); #ifdef FEAT_SIGN_ICONS if (sp->sn_image != NULL) { out_flush(); gui_mch_destroy_sign(sp->sn_image); } #endif vim_free(sp->sn_text); if (sp_prev == NULL) first_sign = sp->sn_next; else sp_prev->sn_next = sp->sn_next; vim_free(sp); }
false
false
false
false
false
0
oppositeBorderPositionWithPoints(const int borderPosition, QList<int> &points) { // 1. Conversion "border position -> (Absolute) position" int position[DIM_MAX]; borderPositionToAbsolutePosition(borderPosition, position); // 2. Get start direction int direction[DIM_MAX]; if (borderPosition < m_columns) { direction[DIM_X] = 0; direction[DIM_Y] = 1; } else if ((borderPosition >= m_columns) && (borderPosition < m_columns + m_rows)) { direction[DIM_X] = -1; direction[DIM_Y] = 0; } else if ((borderPosition >= m_columns + m_rows) && (borderPosition < 2*m_columns + m_rows)) { direction[DIM_X] = 0; direction[DIM_Y] = -1; } else if (borderPosition >= 2*m_columns + m_rows) { direction[DIM_X] = 1; direction[DIM_Y] = 0; } // 3. Get the outgoing (absolute) position getOutgoingPosition(position, direction, points); // 4. Conversion "(absolute) position -> border position" return absolutePositionToBorderPosition(position); }
false
false
false
false
false
0
e_table_subset_variable_decrement (ETableSubsetVariable *etssv, gint position, gint amount) { gint i; ETableSubset *etss = E_TABLE_SUBSET (etssv); for (i = 0; i < etss->n_map; i++) { if (etss->map_table[i] >= position) etss->map_table[i] -= amount; } }
false
false
false
false
false
0
get_tablet_button_class_name (GsdWacomTabletButton *tablet_button, GtkDirectionType dir) { gchar *id; gchar c; id = tablet_button->id; switch (tablet_button->type) { case WACOM_TABLET_BUTTON_TYPE_RING: if (id[0] == 'l') /* left-ring */ return g_strdup_printf ("Ring%s", (dir == GTK_DIR_UP ? "CCW" : "CW")); if (id[0] == 'r') /* right-ring */ return g_strdup_printf ("Ring2%s", (dir == GTK_DIR_UP ? "CCW" : "CW")); g_warning ("Unknown ring type '%s'", id); return NULL; break; case WACOM_TABLET_BUTTON_TYPE_STRIP: if (id[0] == 'l') /* left-strip */ return g_strdup_printf ("Strip%s", (dir == GTK_DIR_UP ? "Up" : "Down")); if (id[0] == 'r') /* right-strip */ return g_strdup_printf ("Strip2%s", (dir == GTK_DIR_UP ? "Up" : "Down")); g_warning ("Unknown strip type '%s'", id); return NULL; break; case WACOM_TABLET_BUTTON_TYPE_NORMAL: case WACOM_TABLET_BUTTON_TYPE_HARDCODED: c = get_last_char (id); return g_strdup_printf ("%c", g_ascii_toupper (c)); break; default: g_warning ("Unknown button type '%s'", id); break; } return NULL; }
false
false
false
false
false
0
process_eprint( fields *bibin, fields *info, int level ) { int neprint, netype; char *eprint = NULL, *etype = NULL; neprint = fields_find( bibin, "eprint", -1 ); netype = fields_find( bibin, "eprinttype", -1 ); if ( neprint!=-1 ) eprint = bibin->data[neprint].data; if ( netype!=-1 ) etype = bibin->data[netype].data; fprintf(stderr,"process_eprint: neprint=%d netype=%d\n", neprint,netype ); if ( eprint && etype ) { if ( !strncasecmp( etype, "arxiv", 5 ) ) fields_add( info, "ARXIV", eprint, level ); else if ( !strncasecmp( etype, "jstor", 5 ) ) fields_add( info, "JSTOR", eprint, level ); else if ( !strncasecmp( etype, "pubmed", 6 ) ) fields_add( info, "PMID", eprint, level ); else if ( !strncasecmp( etype, "medline", 7 ) ) fields_add( info, "MEDLINE", eprint, level ); else { fields_add( info, "EPRINT", eprint, level ); fields_add( info, "EPRINTTYPE", etype, level ); } fields_setused( bibin, neprint ); fields_setused( bibin, netype ); } else if ( eprint ) { fields_add( info, "EPRINT", eprint, level ); fields_setused( bibin, neprint ); } else if ( etype ) { fields_add( info, "EPRINTTYPE", etype, level ); fields_setused( bibin, netype ); } }
false
false
false
false
false
0
bfa_timer_begin(struct bfa_timer_mod_s *mod, struct bfa_timer_s *timer, void (*timercb) (void *), void *arg, unsigned int timeout) { WARN_ON(timercb == NULL); WARN_ON(bfa_q_is_on_q(&mod->timer_q, timer)); timer->timeout = timeout; timer->timercb = timercb; timer->arg = arg; list_add_tail(&timer->qe, &mod->timer_q); }
false
false
false
false
false
0
gst_ring_buffer_delay (GstRingBuffer * buf) { GstRingBufferClass *rclass; guint res; g_return_val_if_fail (GST_IS_RING_BUFFER (buf), 0); /* buffer must be acquired */ if (G_UNLIKELY (!gst_ring_buffer_is_acquired (buf))) goto not_acquired; rclass = GST_RING_BUFFER_GET_CLASS (buf); if (G_LIKELY (rclass->delay)) res = rclass->delay (buf); else res = 0; return res; not_acquired: { GST_DEBUG_OBJECT (buf, "not acquired"); return 0; } }
false
false
false
true
false
1
ProcessPhpRequest(const char *filename, CSession *sess, long &size) { FILE *f = fopen(filename, "r"); if ( !f ) { return Get_404_Page(size); } CWriteStrBuffer buffer; CPhpFilter(this, sess, filename, &buffer); size = buffer.Length(); char *buf = new char [size+1]; buffer.CopyAll(buf); fclose(f); return buf; }
false
false
false
false
false
0
bUuDecodeEx (const_bstring src, int * badlines) { struct tagbstring t; struct bStream * s; struct bStream * d; bstring b; if (!src) return NULL; t = *src; /* Short lifetime alias to header of src */ s = bsFromBstrRef (&t); /* t is undefined after this */ if (!s) return NULL; d = bsUuDecode (s, badlines); b = bfromcstralloc (256, ""); if (NULL == b || 0 > bsread (b, d, INT_MAX)) { bdestroy (b); b = NULL; } bsclose(d); bsclose(s); return b; }
false
false
false
false
false
0
writeToStream(mrpt::utils::CStream &out,int *version) const { if (version) *version = 0; else { writeToStreamRender(out); out << m_radiusIn << m_radiusOut; out << m_nSlices << m_nLoops; } }
false
false
false
false
false
0
process_set_of_keys(int key, int count, int *list) { int i; for (i=0; i<count; i++) if (check_control(list[i], key)) button_info_set(&Player->bi, list[i]); }
false
false
false
false
false
0
fm_config_load_from_file(FmConfig* cfg, const char* name) { const gchar * const *dirs, * const *dir; char *path; GKeyFile* kf = g_key_file_new(); g_strfreev(cfg->modules_blacklist); g_strfreev(cfg->system_modules_blacklist); cfg->modules_blacklist = NULL; cfg->system_modules_blacklist = NULL; _cfg_monitor_free(cfg); if(G_LIKELY(!name)) name = "libfm/libfm.conf"; else { if(G_UNLIKELY(g_path_is_absolute(name))) { cfg->_cfg_name = g_strdup(name); if(g_key_file_load_from_file(kf, name, 0, NULL)) { fm_config_load_from_key_file(cfg, kf); _cfg_monitor_add(cfg, name); } goto _out; } } cfg->_cfg_name = g_strdup(name); dirs = g_get_system_config_dirs(); for(dir=dirs;*dir;++dir) { path = g_build_filename(*dir, name, NULL); if(g_key_file_load_from_file(kf, path, 0, NULL)) fm_config_load_from_key_file(cfg, kf); g_free(path); } path = g_build_filename(SYSCONF_DIR, name, NULL); if(g_key_file_load_from_file(kf, path, 0, NULL)) fm_config_load_from_key_file(cfg, kf); g_free(path); /* we got all system blacklists, save them and get user's one */ cfg->system_modules_blacklist = cfg->modules_blacklist; cfg->modules_blacklist = NULL; path = g_build_filename(g_get_user_config_dir(), name, NULL); if(g_key_file_load_from_file(kf, path, 0, NULL)) { fm_config_load_from_key_file(cfg, kf); _cfg_monitor_add(cfg, path); } g_free(path); _out: g_key_file_free(kf); g_signal_emit(cfg, signals[CHANGED], 0); /* FIXME: compare and send individual changes instead */ }
false
false
false
false
false
0
esc_encode(const char *src, unsigned srclen, char *dst) { const char *end = src + srclen; char *rp = dst; int len = 0; while (src < end) { unsigned char c = (unsigned char) *src; if (c == '\0' || IS_HIGHBIT_SET(c)) { rp[0] = '\\'; rp[1] = DIG(c >> 6); rp[2] = DIG((c >> 3) & 7); rp[3] = DIG(c & 7); rp += 4; len += 4; } else if (c == '\\') { rp[0] = '\\'; rp[1] = '\\'; rp += 2; len += 2; } else { *rp++ = c; len++; } src++; } return len; }
false
false
false
false
false
0
sftk_newPinCheck(CK_CHAR_PTR pPin, CK_ULONG ulPinLen) { unsigned int i; int nchar = 0; /* number of characters */ int ntrail = 0; /* number of trailing bytes to follow */ int ndigit = 0; /* number of decimal digits */ int nlower = 0; /* number of ASCII lowercase letters */ int nupper = 0; /* number of ASCII uppercase letters */ int nnonalnum = 0; /* number of ASCII non-alphanumeric characters */ int nnonascii = 0; /* number of non-ASCII characters */ int nclass; /* number of character classes */ for (i = 0; i < ulPinLen; i++) { unsigned int byte = pPin[i]; if (ntrail) { if ((byte & 0xc0) != 0x80) { /* illegal */ nchar = -1; break; } if (--ntrail == 0) { nchar++; nnonascii++; } continue; } if ((byte & 0x80) == 0x00) { /* single-byte (ASCII) character */ nchar++; if (isdigit(byte)) { if (i < ulPinLen - 1) { ndigit++; } } else if (islower(byte)) { nlower++; } else if (isupper(byte)) { if (i > 0) { nupper++; } } else { nnonalnum++; } } else if ((byte & 0xe0) == 0xc0) { /* leading byte of two-byte character */ ntrail = 1; } else if ((byte & 0xf0) == 0xe0) { /* leading byte of three-byte character */ ntrail = 2; } else if ((byte & 0xf8) == 0xf0) { /* leading byte of four-byte character */ ntrail = 3; } else { /* illegal */ nchar = -1; break; } } if (nchar == -1) { /* illegal UTF8 string */ return CKR_PIN_INVALID; } if (nchar < FIPS_MIN_PIN) { return CKR_PIN_LEN_RANGE; } nclass = (ndigit != 0) + (nlower != 0) + (nupper != 0) + (nnonalnum != 0) + (nnonascii != 0); if (nclass < 3) { return CKR_PIN_LEN_RANGE; } return CKR_OK; }
false
false
false
false
false
0
xeon_init_dev(struct intel_ntb_dev *ndev) { struct pci_dev *pdev; u8 ppd; int rc, mem; pdev = ndev_pdev(ndev); switch (pdev->device) { /* There is a Xeon hardware errata related to writes to SDOORBELL or * B2BDOORBELL in conjunction with inbound access to NTB MMIO Space, * which may hang the system. To workaround this use the second memory * window to access the interrupt and scratch pad registers on the * remote system. */ case PCI_DEVICE_ID_INTEL_NTB_SS_JSF: case PCI_DEVICE_ID_INTEL_NTB_PS_JSF: case PCI_DEVICE_ID_INTEL_NTB_B2B_JSF: case PCI_DEVICE_ID_INTEL_NTB_SS_SNB: case PCI_DEVICE_ID_INTEL_NTB_PS_SNB: case PCI_DEVICE_ID_INTEL_NTB_B2B_SNB: case PCI_DEVICE_ID_INTEL_NTB_SS_IVT: case PCI_DEVICE_ID_INTEL_NTB_PS_IVT: case PCI_DEVICE_ID_INTEL_NTB_B2B_IVT: case PCI_DEVICE_ID_INTEL_NTB_SS_HSX: case PCI_DEVICE_ID_INTEL_NTB_PS_HSX: case PCI_DEVICE_ID_INTEL_NTB_B2B_HSX: case PCI_DEVICE_ID_INTEL_NTB_SS_BDX: case PCI_DEVICE_ID_INTEL_NTB_PS_BDX: case PCI_DEVICE_ID_INTEL_NTB_B2B_BDX: ndev->hwerr_flags |= NTB_HWERR_SDOORBELL_LOCKUP; break; } switch (pdev->device) { /* There is a hardware errata related to accessing any register in * SB01BASE in the presence of bidirectional traffic crossing the NTB. */ case PCI_DEVICE_ID_INTEL_NTB_SS_IVT: case PCI_DEVICE_ID_INTEL_NTB_PS_IVT: case PCI_DEVICE_ID_INTEL_NTB_B2B_IVT: case PCI_DEVICE_ID_INTEL_NTB_SS_HSX: case PCI_DEVICE_ID_INTEL_NTB_PS_HSX: case PCI_DEVICE_ID_INTEL_NTB_B2B_HSX: case PCI_DEVICE_ID_INTEL_NTB_SS_BDX: case PCI_DEVICE_ID_INTEL_NTB_PS_BDX: case PCI_DEVICE_ID_INTEL_NTB_B2B_BDX: ndev->hwerr_flags |= NTB_HWERR_SB01BASE_LOCKUP; break; } switch (pdev->device) { /* HW Errata on bit 14 of b2bdoorbell register. Writes will not be * mirrored to the remote system. Shrink the number of bits by one, * since bit 14 is the last bit. */ case PCI_DEVICE_ID_INTEL_NTB_SS_JSF: case PCI_DEVICE_ID_INTEL_NTB_PS_JSF: case PCI_DEVICE_ID_INTEL_NTB_B2B_JSF: case PCI_DEVICE_ID_INTEL_NTB_SS_SNB: case PCI_DEVICE_ID_INTEL_NTB_PS_SNB: case PCI_DEVICE_ID_INTEL_NTB_B2B_SNB: case PCI_DEVICE_ID_INTEL_NTB_SS_IVT: case PCI_DEVICE_ID_INTEL_NTB_PS_IVT: case PCI_DEVICE_ID_INTEL_NTB_B2B_IVT: case PCI_DEVICE_ID_INTEL_NTB_SS_HSX: case PCI_DEVICE_ID_INTEL_NTB_PS_HSX: case PCI_DEVICE_ID_INTEL_NTB_B2B_HSX: case PCI_DEVICE_ID_INTEL_NTB_SS_BDX: case PCI_DEVICE_ID_INTEL_NTB_PS_BDX: case PCI_DEVICE_ID_INTEL_NTB_B2B_BDX: ndev->hwerr_flags |= NTB_HWERR_B2BDOORBELL_BIT14; break; } ndev->reg = &xeon_reg; rc = pci_read_config_byte(pdev, XEON_PPD_OFFSET, &ppd); if (rc) return -EIO; ndev->ntb.topo = xeon_ppd_topo(ndev, ppd); dev_dbg(ndev_dev(ndev), "ppd %#x topo %s\n", ppd, ntb_topo_string(ndev->ntb.topo)); if (ndev->ntb.topo == NTB_TOPO_NONE) return -EINVAL; if (ndev->ntb.topo != NTB_TOPO_SEC) { ndev->bar4_split = xeon_ppd_bar4_split(ndev, ppd); dev_dbg(ndev_dev(ndev), "ppd %#x bar4_split %d\n", ppd, ndev->bar4_split); } else { /* This is a way for transparent BAR to figure out if we are * doing split BAR or not. There is no way for the hw on the * transparent side to know and set the PPD. */ mem = pci_select_bars(pdev, IORESOURCE_MEM); ndev->bar4_split = hweight32(mem) == HSX_SPLIT_BAR_MW_COUNT + 1; dev_dbg(ndev_dev(ndev), "mem %#x bar4_split %d\n", mem, ndev->bar4_split); } rc = xeon_init_ntb(ndev); if (rc) return rc; return xeon_init_isr(ndev); }
false
false
false
false
false
0
fli_rgbmask_to_shifts( unsigned long mask, unsigned int * shift, unsigned int * bits ) { unsigned int val; if ( mask == 0 ) { *shift = *bits = 0; return; } *shift = 0; while ( ! ( ( 1 << *shift ) & mask ) ) ( *shift )++; val = mask >> *shift; *bits = 0; while ( ( 1 << *bits ) & val ) ( *bits )++; }
false
false
false
false
false
0
setnplayers (int n) { nrockets = n; maxnplayers = MAXROCKETS - nrockets; if (minim[0].number == &nplayers) { minim[0].max = maxnplayers; if (nplayers > maxnplayers) nplayers = maxnplayers; } nplayerchange (); }
false
false
false
false
false
0
glade_eprop_model_data_delete_selected (GladeEditorProperty *eprop) { GtkTreeIter iter; GladeEPropModelData *eprop_data = GLADE_EPROP_MODEL_DATA (eprop); GNode *data_tree = NULL, *row; gint rownum = -1; /* NOTE: This will trigger row-deleted below... */ if (!gtk_tree_selection_get_selected (eprop_data->selection, NULL, &iter)) return; gtk_tree_model_get (GTK_TREE_MODEL (eprop_data->store), &iter, COLUMN_ROW, &rownum, -1); g_assert (rownum >= 0); /* if theres a sected row, theres data... */ glade_property_get (eprop->property, &data_tree); g_assert (data_tree); data_tree = glade_model_data_tree_copy (data_tree); row = g_node_nth_child (data_tree, rownum); g_node_unlink (row); glade_model_data_tree_free (row); if (eprop_data->pending_data_tree) glade_model_data_tree_free (eprop_data->pending_data_tree); eprop_data->pending_data_tree = data_tree; g_idle_add ((GSourceFunc)update_data_tree_idle, eprop); }
false
false
false
false
false
0
unlink2 (PARAM_UNUSED void * dummy, const char * filename) { message (msg_tool | msg_file, (stderr, "Unlinking file `%s'\n", filename)); /* Don't complain if you can't unlink. Who cares of a tmp file? */ unlink (filename); }
false
false
false
false
false
0
twl_request(struct gpio_chip *chip, unsigned offset) { struct gpio_twl4030_priv *priv = to_gpio_twl4030(chip); int status = 0; mutex_lock(&priv->mutex); /* Support the two LED outputs as output-only GPIOs. */ if (offset >= TWL4030_GPIO_MAX) { u8 ledclr_mask = LEDEN_LEDAON | LEDEN_LEDAEXT | LEDEN_LEDAPWM | LEDEN_PWM_LENGTHA; u8 reg = TWL4030_PWMAON_REG; offset -= TWL4030_GPIO_MAX; if (offset) { ledclr_mask <<= 1; reg = TWL4030_PWMBON_REG; } /* initialize PWM to always-drive */ /* Configure PWM OFF register first */ status = twl_i2c_write_u8(TWL4030_MODULE_LED, 0x7f, reg + 1); if (status < 0) goto done; /* Followed by PWM ON register */ status = twl_i2c_write_u8(TWL4030_MODULE_LED, 0x7f, reg); if (status < 0) goto done; /* init LED to not-driven (high) */ status = twl_i2c_read_u8(TWL4030_MODULE_LED, &cached_leden, TWL4030_LED_LEDEN_REG); if (status < 0) goto done; cached_leden &= ~ledclr_mask; status = twl_i2c_write_u8(TWL4030_MODULE_LED, cached_leden, TWL4030_LED_LEDEN_REG); if (status < 0) goto done; status = 0; goto done; } /* on first use, turn GPIO module "on" */ if (!priv->usage_count) { struct twl4030_gpio_platform_data *pdata; u8 value = MASK_GPIO_CTRL_GPIO_ON; /* optionally have the first two GPIOs switch vMMC1 * and vMMC2 power supplies based on card presence. */ pdata = dev_get_platdata(chip->dev); if (pdata) value |= pdata->mmc_cd & 0x03; status = gpio_twl4030_write(REG_GPIO_CTRL, value); } done: if (!status) priv->usage_count |= BIT(offset); mutex_unlock(&priv->mutex); return status; }
false
false
false
false
false
0
SaveDefmethodsForDefgeneric( void *theEnv, struct constructHeader *theDefgeneric, void *userBuffer) { DEFGENERIC *gfunc = (DEFGENERIC *) theDefgeneric; char *logName = (char *) userBuffer; register unsigned i; for (i = 0 ; i < gfunc->mcnt ; i++) { if (gfunc->methods[i].ppForm != NULL) { PrintInChunks(theEnv,logName,gfunc->methods[i].ppForm); EnvPrintRouter(theEnv,logName,"\n"); } } }
false
false
false
false
false
0
parse_hints_parse(struct parse_hints *ph, const char **v_in_out) { const char *v = *v_in_out; char *nv; int base; int repeats = 0; int repeat_fixup = ph->result_len; if (ph->repeat) { if (!parse_hints_add_result_octet(ph, 0)) { return 0; } } do { base = 0; switch (ph->format) { case 'x': base += 6; /* fall through */ case 'd': base += 2; /* fall through */ case 'o': base += 8; /* fall through */ { int i; unsigned long number = strtol(v, &nv, base); if (nv == v) return 0; v = nv; for (i = 0; i < ph->length; i++) { int shift = 8 * (ph->length - 1 - i); if (!parse_hints_add_result_octet(ph, (u_char)(number >> shift) )) { return 0; /* failed */ } } } break; case 'a': { int i; for (i = 0; i < ph->length && *v; i++) { if (!parse_hints_add_result_octet(ph, *v++)) { return 0; /* failed */ } } } break; } repeats++; if (ph->separator && *v) { if (*v == ph->separator) { v++; } else { return 0; /* failed */ } } if (ph->terminator) { if (*v == ph->terminator) { v++; break; } } } while (ph->repeat && *v); if (ph->repeat) { ph->result[repeat_fixup] = repeats; } *v_in_out = v; return 1; }
false
false
false
false
false
0
record_init_root(record* r, btree* tree) { // Position to first leaf node ... UInt32 leaf_head = tree->head.leaf_head; node_buf* buf = btree_node_by_index(tree, leaf_head, NODE_CLEAN); if (!buf) return -1; return record_init(r, tree, buf, 0); }
false
false
false
false
false
0
nvkm_fifo_chan_ntfy(struct nvkm_object *object, u32 type, struct nvkm_event **pevent) { struct nvkm_fifo_chan *chan = nvkm_fifo_chan(object); if (chan->func->ntfy) return chan->func->ntfy(chan, type, pevent); return -ENODEV; }
false
false
false
false
false
0
diff_flush_stat(struct diff_filepair *p, struct diff_options *o, struct diffstat_t *diffstat) { if (diff_unmodified_pair(p)) return; if ((DIFF_FILE_VALID(p->one) && S_ISDIR(p->one->mode)) || (DIFF_FILE_VALID(p->two) && S_ISDIR(p->two->mode))) return; /* no tree diffs in patch format */ run_diffstat(p, o, diffstat); }
false
false
false
false
false
0
printing_is_pango_gdk_color_equal(PangoColor *p, GdkColor *g) { return ((p->red == g->red) && (p->green == g->green) && (p->blue == g->blue)); }
false
false
false
false
false
0
gnumeric_background_set (GnmStyle const *mstyle, cairo_t *cr, gboolean const is_selected, GtkStyleContext *ctxt) { int pattern; g_return_val_if_fail (!is_selected || ctxt != NULL, FALSE); /* * Draw the background if the PATTERN is non 0 * Draw a stipple too if the pattern is > 1 */ pattern = gnm_style_get_pattern (mstyle); if (pattern > 0 && pattern < GNUMERIC_SHEET_PATTERNS) { GOPattern gopat; cairo_pattern_t *crpat; gopat.pattern = patterns[pattern]; gopat.fore = gnm_style_get_pattern_color (mstyle)->go_color; gopat.back = gnm_style_get_back_color (mstyle)->go_color; if (is_selected) { GOColor light; GdkRGBA rgba; gtk_style_context_get_background_color (ctxt, GTK_STATE_FLAG_SELECTED, &rgba); light = GO_COLOR_FROM_GDK_RGBA (rgba); gopat.fore = GO_COLOR_INTERPOLATE (light, gopat.fore, .5); gopat.back = GO_COLOR_INTERPOLATE (light, gopat.back, .5); } crpat = go_pattern_create_cairo_pattern (&gopat, cr); if (crpat) cairo_set_source (cr, crpat); cairo_pattern_destroy (crpat); return TRUE; } else if (is_selected) { GdkRGBA rgba; GOColor color; gtk_style_context_get_background_color (ctxt, GTK_STATE_FLAG_SELECTED, &rgba); color = GO_COLOR_FROM_GDK_RGBA (rgba); /* Make a lighter version. */ color = GO_COLOR_INTERPOLATE (GO_COLOR_WHITE, color, .5); cairo_set_source_rgba (cr, GO_COLOR_TO_CAIRO (color)); } return FALSE; }
false
false
false
false
false
0
ath5k_hw_channel(struct ath5k_hw *ah, struct net80211_channel *channel) { int ret; /* * Check bounds supported by the PHY (we don't care about regultory * restrictions at this point). Note: hw_value already has the band * (CHANNEL_2GHZ, or CHANNEL_5GHZ) so we inform ath5k_channel_ok() * of the band by that */ if (!ath5k_channel_ok(ah, channel->center_freq, channel->hw_value)) { DBG("ath5k: channel frequency (%d MHz) out of supported " "range\n", channel->center_freq); return -EINVAL; } /* * Set the channel and wait */ switch (ah->ah_radio) { case AR5K_RF5110: ret = ath5k_hw_rf5110_channel(ah, channel); break; case AR5K_RF5111: ret = ath5k_hw_rf5111_channel(ah, channel); break; case AR5K_RF2425: ret = ath5k_hw_rf2425_channel(ah, channel); break; default: ret = ath5k_hw_rf5112_channel(ah, channel); break; } if (ret) { DBG("ath5k: setting channel failed: %s\n", strerror(ret)); return ret; } /* Set JAPAN setting for channel 14 */ if (channel->center_freq == 2484) { AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_CCKTXCTL, AR5K_PHY_CCKTXCTL_JAPAN); } else { AR5K_REG_ENABLE_BITS(ah, AR5K_PHY_CCKTXCTL, AR5K_PHY_CCKTXCTL_WORLD); } ah->ah_current_channel = channel; ah->ah_turbo = (channel->hw_value == CHANNEL_T ? 1 : 0); return 0; }
false
false
false
false
false
0
getRoadTypeByBinary( char binary ) { int index = -1; for( int i = 0; i < 16; i++ ) { if ( binary == binaryTable[ i ] ) { index = i; break; } } if( index == -1 ) { return -1; } return roadTypeTable[ index ]; }
false
false
false
false
false
0
__drbg_seed(struct drbg_state *drbg, struct list_head *seed, int reseed) { int ret = drbg->d_ops->update(drbg, seed, reseed); if (ret) return ret; drbg->seeded = true; /* 10.1.1.2 / 10.1.1.3 step 5 */ drbg->reseed_ctr = 1; return ret; }
false
false
false
false
false
0
worker_on_saved_session_name_read (GdmDBusWorker *worker, const char *session_name, GdmSessionConversation *conversation) { GdmSession *self = conversation->session; if (! get_session_command_for_name (session_name, NULL)) { /* ignore sessions that don't exist */ g_debug ("GdmSession: not using invalid .dmrc session: %s", session_name); g_free (self->priv->saved_session); self->priv->saved_session = NULL; return; } if (strcmp (session_name, get_default_session_name (self)) != 0) { g_free (self->priv->saved_session); self->priv->saved_session = g_strdup (session_name); if (self->priv->greeter_interface != NULL) { gdm_dbus_greeter_emit_default_session_name_changed (self->priv->greeter_interface, session_name); } } }
false
false
false
false
false
0
verify_pack_index(struct packed_git *p) { off_t index_size; const unsigned char *index_base; git_SHA_CTX ctx; unsigned char sha1[20]; int err = 0; if (open_pack_index(p)) return error("packfile %s index not opened", p->pack_name); index_size = p->index_size; index_base = p->index_data; /* Verify SHA1 sum of the index file */ git_SHA1_Init(&ctx); git_SHA1_Update(&ctx, index_base, (unsigned int)(index_size - 20)); git_SHA1_Final(sha1, &ctx); if (hashcmp(sha1, index_base + index_size - 20)) err = error("Packfile index for %s SHA1 mismatch", p->pack_name); return err; }
false
false
false
false
false
0
entry_register (struct web_entry *entry, struct ref *ref, char *used, char *use_addressof) { struct web_entry *root; rtx reg, newreg; /* Find the corresponding web and see if it has been visited. */ root = unionfind_root (entry); if (root->reg) return root->reg; /* We are seeing this web for the first time, do the assignment. */ reg = DF_REF_REAL_REG (ref); /* In case the original register is already assigned, generate new one. */ if (!used[REGNO (reg)]) newreg = reg, used[REGNO (reg)] = 1; else if (REG_USERVAR_P (reg) && 0/*&& !flag_messy_debugging*/) { newreg = reg; if (rtl_dump_file) fprintf (rtl_dump_file, "New web forced to keep reg=%i (user variable)\n", REGNO (reg)); } else if (use_addressof [REGNO (reg)]) { newreg = reg; if (rtl_dump_file) fprintf (rtl_dump_file, "New web forced to keep reg=%i (address taken)\n", REGNO (reg)); } else { newreg = gen_reg_rtx (GET_MODE (reg)); REG_USERVAR_P (newreg) = REG_USERVAR_P (reg); REG_POINTER (newreg) = REG_POINTER (reg); REG_LOOP_TEST_P (newreg) = REG_LOOP_TEST_P (reg); RTX_UNCHANGING_P (newreg) = RTX_UNCHANGING_P (reg); REG_ATTRS (newreg) = REG_ATTRS (reg); if (rtl_dump_file) fprintf (rtl_dump_file, "Web oldreg=%i newreg=%i\n", REGNO (reg), REGNO (newreg)); } root->reg = newreg; return newreg; }
false
false
false
false
false
0
appendMemTesterOutput(cmCTestTestResult& res, int test) { cmStdString ofile = testOutputFileName(test); if ( ofile.empty() ) { return; } std::ifstream ifs(ofile.c_str()); if ( !ifs ) { std::string log = "Cannot read memory tester output file: " + ofile; cmCTestLog(this->CTest, ERROR_MESSAGE, log.c_str() << std::endl); return; } std::string line; while ( cmSystemTools::GetLineFromStream(ifs, line) ) { res.Output += line; res.Output += "\n"; } }
false
false
false
false
false
0
Send_NR(char *reason) { char buffer[257]; int length; if ((length = strlen(reason)) > 255) length = 255; buffer[0] = NAK; buffer[1] = length; memcpy(buffer + 2, reason, length); write(fd, buffer, length + 2); }
false
false
false
false
false
0
load_dict (const gchar *file) { g_return_val_if_fail (file != NULL, GKAMUS_DIC_STATUS_NOT_FOUND); GIOChannel *read; gchar *temp; gboolean test; #ifdef PACKAGE_DATA_DIR temp = g_build_filename (PACKAGE_DATA_DIR, file, NULL); #else gchar *current_dir = get_get_current_dir (); temp = g_build_filename (current_dir, "share", "data", file, NULL); g_free (current_dir); #endif test = g_file_test (temp, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_EXISTS); if (!test) { g_free (temp); return GKAMUS_DIC_STATUS_NOT_FOUND; } read = g_io_channel_new_file (temp, "r", NULL); if (!read) { g_free (temp); return GKAMUS_DIC_STATUS_ERROR; } if (!check_dict (read)) /* format valid ? */ { g_free (temp); g_io_channel_shutdown (read, TRUE, NULL); g_io_channel_unref (read); return GKAMUS_DIC_STATUS_INVALID; } gchar **split; gchar *line, *word, *definition; guint i = 0; /* free list dan element */ if (dict != NULL) { g_list_foreach (dict, (GFunc) free_elements, NULL); g_list_free (dict); dict = NULL; } while (g_io_channel_read_line (read, &line, NULL, NULL, NULL) != G_IO_STATUS_EOF) { if (i > MAX_ENTRY) /* periksa entri maksimal */ { g_io_channel_shutdown (read, TRUE, NULL); g_io_channel_unref (read); g_free (line); g_free (temp); return GKAMUS_DIC_STATUS_MAX_ENTRY; } if ((split = divide_line (line, "\t"))) { Dictionary *dic = g_new (Dictionary, 1); word = g_ascii_strdown (g_strstrip (split[0]), -1); definition = g_strstrip (split[1]); dic->word = g_strdup (word); dic->definition = g_strdup (definition); g_free (word); /* g_list_insert() atau g_list_append() tentu akan lama untuk * data yang banyak, disini kita masukkan @dic pada head (awal) * list sort list sesuai abjad */ dict = g_list_prepend (dict, dic); i++; } g_free (line); g_strfreev (split); } /* reverse list dengan sort, kita tidak perlu g_list_reverse() */ dict = g_list_sort (dict, (GCompareFunc) list_compare); /* set @dict_file */ if (dict_file) g_free (dict_file); dict_file = g_strdup (temp); g_free (temp); g_io_channel_shutdown (read, TRUE, NULL); g_io_channel_unref (read); return GKAMUS_DIC_STATUS_OK; }
false
false
false
false
false
0
register_stat2( char *module, char *name, stat_var **pvar, unsigned short flags, void *ctx) { module_stats* mods; stat_var *stat; stat_var *it; str smodule; int hash; if (module==0 || name==0 || pvar==0) { LM_ERR("invalid parameters module=%p, name=%p, pvar=%p \n", module, name, pvar); goto error; } stat = (stat_var*)shm_malloc(sizeof(stat_var)); if (stat==0) { LM_ERR("no more shm memory\n"); goto error; } memset( stat, 0, sizeof(stat_var)); if ( (flags&STAT_IS_FUNC)==0 ) { stat->u.val = (stat_val*)shm_malloc(sizeof(stat_val)); if (stat->u.val==0) { LM_ERR("no more shm memory\n"); goto error1; } #ifdef NO_ATOMIC_OPS *(stat->u.val) = 0; #else atomic_set(stat->u.val,0); #endif *pvar = stat; } else { stat->u.f = (stat_function)(pvar); } /* is the module already recorded? */ smodule.s = module; smodule.len = strlen(module); mods = get_stat_module(&smodule); if (mods==0) { mods = add_stat_module(module); if (mods==0) { LM_ERR("failed to add new module\n"); goto error2; } } /* fill the stat record */ stat->mod_idx = collector->mod_no-1; stat->name.s = name; stat->name.len = strlen(name); stat->flags = flags; stat->context = ctx; /* compute the hash by name */ hash = stat_hash( &stat->name ); /* link it */ if (collector->hstats[hash]==0) { collector->hstats[hash] = stat; } else { it = collector->hstats[hash]; while(it->hnext) it = it->hnext; it->hnext = stat; } collector->stats_no++; /* add the statistic also to the module statistic list */ if (mods->tail) { mods->tail->lnext = stat; } else { mods->head = stat; } mods->tail = stat; mods->no++; return 0; error2: if ( (flags&STAT_IS_FUNC)==0 ) { shm_free(*pvar); *pvar = 0; } error1: shm_free(stat); error: *pvar = 0; return -1; }
false
false
false
true
false
1
add(ParmString w, ParmString s) { RET_ON_ERR(check_if_valid(*lang(),w)); SensitiveCompare c(lang()); WordEntry we; if (WritableDict::lookup(w,&c,we)) return no_err; byte * w2; w2 = (byte *)buffer.alloc(w.size() + 3); *w2++ = lang()->get_word_info(w); *w2++ = w.size(); memcpy(w2, w.str(), w.size() + 1); word_lookup->insert((char *)w2); if (use_soundslike) { byte * s2; s2 = (byte *)buffer.alloc(s.size() + 2); *s2++ = s.size(); memcpy(s2, s.str(), s.size() + 1); soundslike_lookup_[(char *)s2].push_back((char *)w2); } return no_err; }
false
false
false
false
false
0
create(KLocale::CalendarSystem calendarSystem, KSharedConfig::Ptr config, const KLocale *locale) { switch (calendarSystem) { case KLocale::QDateCalendar: return new KCalendarSystemQDate(config, locale); case KLocale::CopticCalendar: return new KCalendarSystemCoptic(config, locale); case KLocale::EthiopianCalendar: return new KCalendarSystemEthiopian(config, locale); case KLocale::GregorianCalendar: return new KCalendarSystemGregorian(config, locale); case KLocale::HebrewCalendar: return new KCalendarSystemHebrew(config, locale); case KLocale::IndianNationalCalendar: return new KCalendarSystemIndianNational(config, locale); case KLocale::IslamicCivilCalendar: return new KCalendarSystemIslamicCivil(config, locale); case KLocale::JalaliCalendar: return new KCalendarSystemJalali(config, locale); case KLocale::JapaneseCalendar: return new KCalendarSystemJapanese(config, locale); case KLocale::JulianCalendar: return new KCalendarSystemJulian(config, locale); case KLocale::MinguoCalendar: return new KCalendarSystemMinguo(config, locale); case KLocale::ThaiCalendar: return new KCalendarSystemThai(config, locale); default: return new KCalendarSystemQDate(config, locale); } }
false
false
false
false
false
0
ClassTagText(const AString &tag, const AString &cls, const AString &text) { AString temp = tag; temp += " class=\""; temp += cls; temp += "\""; Enclose(1, temp); PutStr(text); Enclose(0, tag); }
false
false
false
false
false
0
f_pumvisible(argvars, rettv) typval_T *argvars UNUSED; typval_T *rettv UNUSED; { #ifdef FEAT_INS_EXPAND if (pum_visible()) rettv->vval.v_number = 1; #endif }
false
false
false
false
false
0
xfs_bmbt_set_state( xfs_bmbt_rec_host_t *r, xfs_exntst_t v) { ASSERT(v == XFS_EXT_NORM || v == XFS_EXT_UNWRITTEN); if (v == XFS_EXT_NORM) r->l0 &= xfs_mask64lo(64 - BMBT_EXNTFLAG_BITLEN); else r->l0 |= xfs_mask64hi(BMBT_EXNTFLAG_BITLEN); }
false
false
false
false
false
0
get_ratio(GdkPixbuf *pixmap, gdouble size) { gdouble ratio = 1.0; gint pixmap_h, pixmap_w; pixmap_w = gdk_pixbuf_get_width(pixmap); pixmap_h = gdk_pixbuf_get_height(pixmap); if (pixmap_h <= pixmap_w){ if (pixmap_w > size) ratio = size / pixmap_w; } else { if (pixmap_h > size) ratio = size / pixmap_h; } return ratio; }
false
false
false
false
false
0
nxt_psp_get_buttons(nxt_t *nxt,int port,struct nxt_psp_buttons *buttons) { uint16_t buf; int ret = nxt_i2c_read(nxt,port,nxt_psp_i2c_addr,NXT_PSP_REG_BUTTONS,2,&buf); if (ret==2) { buf = ~buf; if (buttons!=NULL) { buttons->left = buf&NXT_PSP_BTN_LEFT; buttons->down = buf&NXT_PSP_BTN_DOWN; buttons->up = buf&NXT_PSP_BTN_UP; buttons->right = buf&NXT_PSP_BTN_RIGHT; buttons->r3 = buf&NXT_PSP_BTN_R3; buttons->l3 = buf&NXT_PSP_BTN_L3; buttons->square = buf&NXT_PSP_BTN_SQUARE; buttons->x = buf&NXT_PSP_BTN_X; buttons->o = buf&NXT_PSP_BTN_O; buttons->triangle = buf&NXT_PSP_BTN_TRIANGLE; buttons->r1 = buf&NXT_PSP_BTN_R1; buttons->l1 = buf&NXT_PSP_BTN_L1; buttons->r2 = buf&NXT_PSP_BTN_R2; buttons->l2 = buf&NXT_PSP_BTN_L2; } return 0; } else { return -1; } }
false
false
false
false
false
0
LC_ZkaCard__ParsePseudoOids(const uint8_t *p, uint32_t bs, GWEN_BUFFER *mbuf) { GWEN_BUFFER *xbuf; xbuf=GWEN_Buffer_new(0, 256, 0, 1); while(p && bs) { uint8_t x; x=*p; GWEN_Buffer_AppendByte(xbuf, (x>>4) & 0xf); GWEN_Buffer_AppendByte(xbuf, x & 0xf); p++; bs--; } p=(const uint8_t*)GWEN_Buffer_GetStart(xbuf); bs=GWEN_Buffer_GetUsedBytes(xbuf); while(p && bs) { uint32_t v=0; uint8_t x; x=*p; v<<=3; v|=x & 7; if ((x & 8)==0) { GWEN_Buffer_AppendByte(mbuf, (v>>24) & 0xff); GWEN_Buffer_AppendByte(mbuf, (v>>16) & 0xff); GWEN_Buffer_AppendByte(mbuf, (v>>8) & 0xff); GWEN_Buffer_AppendByte(mbuf, v & 0xff); } p++; bs--; } GWEN_Buffer_free(xbuf); return 0; }
false
false
false
false
false
0
OpenCurrentFile() { int result = 0; if ( this->CurrentGeometryFP == NULL) { int len = static_cast<int>(strlen(this->BaseName)); char *buf = new char [len+64]; sprintf(buf, "%s.coords", this->BaseName); this->CurrentGeometryFP = fopen(buf, "r"); if (this->CurrentGeometryFP == NULL) { vtkErrorMacro(<< "Problem opening " << buf); this->SetCurrentBaseName( NULL ); } else { sprintf(buf, "%s.graph", this->BaseName); this->CurrentGraphFP = fopen(buf, "r"); if (this->CurrentGraphFP == NULL) { vtkErrorMacro(<< "Problem opening " << buf); this->SetCurrentBaseName( NULL ); fclose(this->CurrentGeometryFP); this->CurrentGeometryFP = NULL; } else { this->SetCurrentBaseName( this->GetBaseName() ); result = 1; } } delete [] buf; } return result; }
false
false
false
false
true
1
NPP_URLNotify(NPP instance, const char* url, NPReason reason, void* notifyData) { if (!instance) return; QtNPInstance* This = (QtNPInstance*) instance->pdata; if (!This->bindable) return; QtNPBindable::Reason r; switch (reason) { case NPRES_DONE: r = QtNPBindable::ReasonDone; break; case NPRES_USER_BREAK: r = QtNPBindable::ReasonBreak; break; case NPRES_NETWORK_ERR: r = QtNPBindable::ReasonError; break; default: r = QtNPBindable::ReasonUnknown; break; } qint32 id = static_cast<qint32>(reinterpret_cast<size_t>(notifyData)); if (id < 0) // Sanity check id = 0; This->bindable->transferComplete(QString::fromLocal8Bit(url), id, r); }
false
false
false
false
false
0
get_tag(f_id) facet_id f_id; { if ( F_TAG_ATTR == 0 ) return 0; if ( EXTRAS(FACET)[F_TAG_ATTR].array_spec.datacount > 0 ) return (*FINT(f_id,F_TAG_ATTR)); else return 0; }
false
false
false
false
false
0
app_change_pin (app_t app, ctrl_t ctrl, const char *chvnostr, int reset_mode, gpg_error_t (*pincb)(void*, const char *, char **), void *pincb_arg) { gpg_error_t err; if (!app || !chvnostr || !*chvnostr || !pincb) return gpg_error (GPG_ERR_INV_VALUE); if (!app->ref_count) return gpg_error (GPG_ERR_CARD_NOT_INITIALIZED); if (!app->fnc.change_pin) return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION); err = lock_reader (app->slot, ctrl); if (err) return err; err = app->fnc.change_pin (app, ctrl, chvnostr, reset_mode, pincb, pincb_arg); unlock_reader (app->slot); if (opt.verbose) log_info ("operation change_pin result: %s\n", gpg_strerror (err)); return err; }
false
false
false
false
false
0
mgmt_remove_uuid(int index, uuid_t *uuid) { char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_remove_uuid)]; struct mgmt_hdr *hdr = (void *) buf; struct mgmt_cp_remove_uuid *cp = (void *) &buf[sizeof(*hdr)]; uuid_t uuid128; uint128_t uint128; DBG("index %d", index); uuid_to_uuid128(&uuid128, uuid); memset(buf, 0, sizeof(buf)); hdr->opcode = htobs(MGMT_OP_REMOVE_UUID); hdr->len = htobs(sizeof(*cp)); hdr->index = htobs(index); ntoh128((uint128_t *) uuid128.value.uuid128.data, &uint128); htob128(&uint128, (uint128_t *) cp->uuid); if (write(mgmt_sock, buf, sizeof(buf)) < 0) return -errno; return 0; }
false
false
false
false
false
0
set_new_fixed_colormap(const char *name) { int i; if (name && strcmp(name, "web") == 0) { Gif_Colormap *cm = Gif_NewFullColormap(216, 256); Gif_Color *col = cm->col; for (i = 0; i < 216; i++) { col[i].gfc_red = (i / 36) * 0x33; col[i].gfc_green = ((i / 6) % 6) * 0x33; col[i].gfc_blue = (i % 6) * 0x33; } def_output_data.colormap_fixed = cm; } else if (name && (strcmp(name, "gray") == 0 || strcmp(name, "grey") == 0)) { Gif_Colormap *cm = Gif_NewFullColormap(256, 256); Gif_Color *col = cm->col; for (i = 0; i < 256; i++) col[i].gfc_red = col[i].gfc_green = col[i].gfc_blue = i; def_output_data.colormap_fixed = cm; } else if (name && strcmp(name, "bw") == 0) { Gif_Colormap *cm = Gif_NewFullColormap(2, 256); cm->col[0].gfc_red = cm->col[0].gfc_green = cm->col[0].gfc_blue = 0; cm->col[1].gfc_red = cm->col[1].gfc_green = cm->col[1].gfc_blue = 255; def_output_data.colormap_fixed = cm; } else def_output_data.colormap_fixed = read_colormap_file(name, 0); }
false
false
false
false
false
0
SegmentsOverlap(real b1, real o1, real b2, real o2) { real t; if (b1 > o1) { t = o1; o1 = b1; b1 = t; } if (b2 > o2) { t = o2; o2 = b2; b2 = t; } return !((b2 > o1) || (o2 < b1)); }
false
false
false
false
false
0
classifyFoldPointMetapost(const char* s,WordList *keywordlists[]) { WordList& keywordsStart=*keywordlists[3]; WordList& keywordsStop1=*keywordlists[4]; if (keywordsStart.InList(s)) {return 1;} else if (keywordsStop1.InList(s)) {return -1;} return 0; }
false
false
false
false
false
0
pad_added_cb (GstElement * element, GstPad * pad, GstElement *convert) { /* Link remaining pad after decodebin2 does its magic. */ GstPad *conv_pad; conv_pad = gst_element_get_static_pad (convert, "sink"); g_assert (conv_pad != NULL); if (pads_compatible (pad, conv_pad)) { g_assert (!GST_PAD_IS_LINKED (gst_element_get_static_pad (convert, "sink"))); gst_pad_link (pad, conv_pad); } else { g_warning ("Could not link GStreamer pipeline."); } }
false
false
false
false
false
0
operator=(const std::string &Val) { // Create a regexp object to match pass names for emitOptimizationRemark. if (!Val.empty()) { Pattern = std::make_shared<Regex>(Val); std::string RegexError; if (!Pattern->isValid(RegexError)) report_fatal_error("Invalid regular expression '" + Val + "' in -pass-remarks: " + RegexError, false); } }
false
false
false
false
false
0
b43legacy_generate_probe_resp(struct b43legacy_wldev *dev, u16 *dest_size, struct ieee80211_rate *rate) { const u8 *src_data; u8 *dest_data; u16 src_size, elem_size, src_pos, dest_pos; __le16 dur; struct ieee80211_hdr *hdr; size_t ie_start; src_size = dev->wl->current_beacon->len; src_data = (const u8 *)dev->wl->current_beacon->data; /* Get the start offset of the variable IEs in the packet. */ ie_start = offsetof(struct ieee80211_mgmt, u.probe_resp.variable); B43legacy_WARN_ON(ie_start != offsetof(struct ieee80211_mgmt, u.beacon.variable)); if (B43legacy_WARN_ON(src_size < ie_start)) return NULL; dest_data = kmalloc(src_size, GFP_ATOMIC); if (unlikely(!dest_data)) return NULL; /* Copy the static data and all Information Elements, except the TIM. */ memcpy(dest_data, src_data, ie_start); src_pos = ie_start; dest_pos = ie_start; for ( ; src_pos < src_size - 2; src_pos += elem_size) { elem_size = src_data[src_pos + 1] + 2; if (src_data[src_pos] == 5) { /* This is the TIM. */ continue; } memcpy(dest_data + dest_pos, src_data + src_pos, elem_size); dest_pos += elem_size; } *dest_size = dest_pos; hdr = (struct ieee80211_hdr *)dest_data; /* Set the frame control. */ hdr->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | IEEE80211_STYPE_PROBE_RESP); dur = ieee80211_generic_frame_duration(dev->wl->hw, dev->wl->vif, IEEE80211_BAND_2GHZ, *dest_size, rate); hdr->duration_id = dur; return dest_data; }
false
false
false
false
false
0
items() const { QList<PopupDropperItem*> list; foreach( PopupDropperItem *item, d->pdiItems ) list.append( item ); return list; }
false
false
false
false
false
0
setInstanceUpdatesBlocked(bool blockUpdates) { if (blockUpdates) { if (!gElementsWithInstanceUpdatesBlocked) gElementsWithInstanceUpdatesBlocked = new HashSet<const SVGStyledElement*>; gElementsWithInstanceUpdatesBlocked->add(this); } else { ASSERT(gElementsWithInstanceUpdatesBlocked); ASSERT(gElementsWithInstanceUpdatesBlocked->contains(this)); gElementsWithInstanceUpdatesBlocked->remove(this); } }
false
false
false
false
false
0
cleartext() { text_start = 0; text_length = 0; for (GPosition i=children; i; ++i) children[i].cleartext(); }
false
false
false
false
false
0
utf8_cmp (const unsigned char *str, int length, const char *name) { const unsigned char *limit = str + length; int i; for (i = 0; name[i]; ++i) { int ch = UTF8_GET (str, limit); if (ch != name[i]) return ch - name[i]; } return str == limit ? 0 : 1; }
false
false
false
false
false
0
get_popstate_boxsize(struct popstate_t *p) { int size = 0, i = 0; if (p == NULL) ERROR_ABORT("popstate is NULL\n"); if( p->size > 0 ) return p->size; for(i = 0 ; i < p->num_msgs ; i++) size += get_mailmessage_size(get_popstate_mailmessage(p,i)); return size; }
false
false
false
false
false
0
keyspan_port_remove(struct usb_serial_port *port) { struct keyspan_port_private *p_priv; int i; p_priv = usb_get_serial_port_data(port); stop_urb(p_priv->inack_urb); stop_urb(p_priv->outcont_urb); for (i = 0; i < 2; i++) { stop_urb(p_priv->in_urbs[i]); stop_urb(p_priv->out_urbs[i]); } usb_free_urb(p_priv->inack_urb); usb_free_urb(p_priv->outcont_urb); for (i = 0; i < 2; i++) { usb_free_urb(p_priv->in_urbs[i]); usb_free_urb(p_priv->out_urbs[i]); } kfree(p_priv->outcont_buffer); kfree(p_priv->inack_buffer); for (i = 0; i < ARRAY_SIZE(p_priv->out_buffer); ++i) kfree(p_priv->out_buffer[i]); for (i = 0; i < ARRAY_SIZE(p_priv->in_buffer); ++i) kfree(p_priv->in_buffer[i]); kfree(p_priv); return 0; }
false
false
false
false
false
0
fgetsetversion(const char *name, unsigned long *get_version, unsigned long set_version) { #if HAVE_EXT2_IOCTLS int fd, r; IF_LONG_IS_WIDER(int ver;) fd = open(name, O_RDONLY | O_NONBLOCK); if (fd == -1) return -1; if (!get_version) { IF_LONG_IS_WIDER( ver = (int) set_version; r = ioctl(fd, EXT2_IOC_SETVERSION, &ver); ) IF_LONG_IS_SAME( r = ioctl(fd, EXT2_IOC_SETVERSION, (void*)&set_version); ) } else { IF_LONG_IS_WIDER( r = ioctl(fd, EXT2_IOC_GETVERSION, &ver); *get_version = ver; ) IF_LONG_IS_SAME( r = ioctl(fd, EXT2_IOC_GETVERSION, (void*)get_version); ) } close_silently(fd); return r; #else /* ! HAVE_EXT2_IOCTLS */ errno = EOPNOTSUPP; return -1; #endif /* ! HAVE_EXT2_IOCTLS */ }
false
false
false
false
true
1
tdb_unlock_record(struct tdb_context *tdb, tdb_off_t off) { struct tdb_traverse_lock *i; uint32_t count = 0; if (tdb->allrecord_lock.count) { return 0; } if (off == 0) return 0; for (i = &tdb->travlocks; i; i = i->next) if (i->off == off) count++; return (count == 1 ? tdb_brunlock(tdb, F_RDLCK, off, 1) : 0); }
false
false
false
false
false
0
addIsotopeToAtom(gchar* symbol, gint atomicNumber, gint iMass, gdouble rMass, gdouble abundance) { gint i = (gint)atomicNumber-1; gint j = 0; if(i>=NATOMS) return; if(i<0) return; if(strcmp(symbol,"Xx")==0) return; if(strcmp(symbol,"X")==0) return; if(i>=109) return; if(AtomsProp[i].nIsotopes>= MAXISOTOP) return; j = AtomsProp[i].nIsotopes; AtomsProp[i].nIsotopes++; AtomsProp[i].iMass[j] = iMass; AtomsProp[i].rMass[j] = rMass; AtomsProp[i].abundances[j] = abundance; if(j==0) AtomsProp[i].masse = rMass; }
false
false
false
false
false
0
set(const UnicodeString& pattern, FormatParser* fp, PtnSkeleton& skeletonResult) { int32_t i; for (i=0; i<UDATPG_FIELD_COUNT; ++i) { skeletonResult.type[i]=NONE; } fp->set(pattern); for (i=0; i < fp->itemNumber; i++) { UnicodeString field = fp->items[i]; if ( field.charAt(0) == LOW_A ) { continue; // skip 'a' } if ( fp->isQuoteLiteral(field) ) { UnicodeString quoteLiteral; fp->getQuoteLiteral(quoteLiteral, &i); continue; } int32_t canonicalIndex = fp->getCanonicalIndex(field); if (canonicalIndex < 0 ) { continue; } const dtTypeElem *row = &dtTypes[canonicalIndex]; int32_t typeValue = row->field; skeletonResult.original[typeValue]=field; UChar repeatChar = row->patternChar; int32_t repeatCount = row->minLen; // #7930 removes cap at 3 while (repeatCount-- > 0) { skeletonResult.baseOriginal[typeValue] += repeatChar; } int16_t subTypeValue = row->type; if ( row->type > 0) { subTypeValue += field.length(); } skeletonResult.type[typeValue] = subTypeValue; } copyFrom(skeletonResult); }
false
false
false
false
false
0
vpip_get_global(int property) { switch (property) { case vpiTimeUnit: case vpiTimePrecision: return vpip_get_time_precision(); default: fprintf(stderr, "vpi error: bad global property: %d\n", property); assert(0); return vpiUndefined; } }
false
false
false
false
false
0
isinxt (xfs_fileoff_t key, xfs_fileoff_t offset, xfs_filblks_t len) { return (key >= offset) ? (key < offset + len ? 1 : 0) : 0; }
false
false
false
false
false
0
buildPullDown(MSMenuBarItem *menuHead_, A data_, S *syms_, int numSyms_) { if (isSlotFiller(data_)==MSTrue) { MSPulldownMenu *pd = new MSPulldownMenu(menuHead_); pd->font(menuHead_->font()); buildCascades(pd, data_, syms_, numSyms_); } }
false
false
false
false
false
0
try_read_udp(conn *c) { int res; assert(c != NULL); c->request_addr_size = sizeof(c->request_addr); res = recvfrom(c->sfd, c->rbuf, c->rsize, 0, &c->request_addr, &c->request_addr_size); if (res > 8) { unsigned char *buf = (unsigned char *)c->rbuf; STATS_LOCK(); stats.bytes_read += res; STATS_UNLOCK(); /* Beginning of UDP packet is the request ID; save it. */ c->request_id = buf[0] * 256 + buf[1]; /* If this is a multi-packet request, drop it. */ if (buf[4] != 0 || buf[5] != 1) { out_string(c, "SERVER_ERROR multi-packet request not supported"); return 0; } /* Don't care about any of the rest of the header. */ res -= 8; memmove(c->rbuf, c->rbuf + 8, res); c->rbytes += res; c->rcurr = c->rbuf; return 1; } return 0; }
false
false
false
false
false
0
__remove_dirty_segment(struct f2fs_sb_info *sbi, unsigned int segno, enum dirty_type dirty_type) { struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); if (test_and_clear_bit(segno, dirty_i->dirty_segmap[dirty_type])) dirty_i->nr_dirty[dirty_type]--; if (dirty_type == DIRTY) { struct seg_entry *sentry = get_seg_entry(sbi, segno); enum dirty_type t = sentry->type; if (test_and_clear_bit(segno, dirty_i->dirty_segmap[t])) dirty_i->nr_dirty[t]--; if (get_valid_blocks(sbi, segno, sbi->segs_per_sec) == 0) clear_bit(GET_SECNO(sbi, segno), dirty_i->victim_secmap); } }
false
false
false
false
false
0
btrfs_alloc_from_cluster(struct btrfs_block_group_cache *block_group, struct btrfs_free_cluster *cluster, u64 bytes, u64 min_start, u64 *max_extent_size) { struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; struct btrfs_free_space *entry = NULL; struct rb_node *node; u64 ret = 0; spin_lock(&cluster->lock); if (bytes > cluster->max_size) goto out; if (cluster->block_group != block_group) goto out; node = rb_first(&cluster->root); if (!node) goto out; entry = rb_entry(node, struct btrfs_free_space, offset_index); while (1) { if (entry->bytes < bytes && entry->bytes > *max_extent_size) *max_extent_size = entry->bytes; if (entry->bytes < bytes || (!entry->bitmap && entry->offset < min_start)) { node = rb_next(&entry->offset_index); if (!node) break; entry = rb_entry(node, struct btrfs_free_space, offset_index); continue; } if (entry->bitmap) { ret = btrfs_alloc_from_bitmap(block_group, cluster, entry, bytes, cluster->window_start, max_extent_size); if (ret == 0) { node = rb_next(&entry->offset_index); if (!node) break; entry = rb_entry(node, struct btrfs_free_space, offset_index); continue; } cluster->window_start += bytes; } else { ret = entry->offset; entry->offset += bytes; entry->bytes -= bytes; } if (entry->bytes == 0) rb_erase(&entry->offset_index, &cluster->root); break; } out: spin_unlock(&cluster->lock); if (!ret) return 0; spin_lock(&ctl->tree_lock); ctl->free_space -= bytes; if (entry->bytes == 0) { ctl->free_extents--; if (entry->bitmap) { kfree(entry->bitmap); ctl->total_bitmaps--; ctl->op->recalc_thresholds(ctl); } kmem_cache_free(btrfs_free_space_cachep, entry); } spin_unlock(&ctl->tree_lock); return ret; }
false
false
false
false
false
0
ath_rx_edma_buf_link(struct ath_softc *sc, enum ath9k_rx_qtype qtype) { struct ath_hw *ah = sc->sc_ah; struct ath_rx_edma *rx_edma; struct sk_buff *skb; struct ath_rxbuf *bf; rx_edma = &sc->rx.rx_edma[qtype]; if (skb_queue_len(&rx_edma->rx_fifo) >= rx_edma->rx_fifo_hwsize) return false; bf = list_first_entry(&sc->rx.rxbuf, struct ath_rxbuf, list); list_del_init(&bf->list); skb = bf->bf_mpdu; memset(skb->data, 0, ah->caps.rx_status_len); dma_sync_single_for_device(sc->dev, bf->bf_buf_addr, ah->caps.rx_status_len, DMA_TO_DEVICE); SKB_CB_ATHBUF(skb) = bf; ath9k_hw_addrxbuf_edma(ah, bf->bf_buf_addr, qtype); __skb_queue_tail(&rx_edma->rx_fifo, skb); return true; }
false
false
false
false
false
0
GetOutputWidth(COLORTYPE color) // since we return 1-for-1, just return result first call { if (myplane == color) { return compressedsize; } else { return raster.rastersize[color]; } }
false
false
false
false
false
0
gfork_i_state_next( gfork_i_state_t current_state, gfork_i_events_t event) { gfork_i_state_t new_state; new_state = gfork_l_state_tansitions[current_state][event]; GlobusGForkDebugState( gfork_l_state_names[current_state], gfork_l_state_names[new_state], gfork_l_event_names[event]); return new_state; }
false
false
false
false
false
0
set_view() { int i; TBOOLEAN was_comma = TRUE; static const char errmsg1[] = "rot_%c must be in [0:%d] degrees range; view unchanged"; static const char errmsg2[] = "%sscale must be > 0; view unchanged"; double local_vals[4]; c_token++; if (equals(c_token,"map")) { splot_map = TRUE; c_token++; return; }; if (splot_map == TRUE) { splot_map_deactivate(); splot_map = FALSE; /* default is no map */ } if (almost_equals(c_token,"equal$_axes")) { c_token++; if (END_OF_COMMAND || equals(c_token,"xy")) { aspect_ratio_3D = 2; c_token++; } else if (equals(c_token,"xyz")) { aspect_ratio_3D = 3; c_token++; } return; } else if (almost_equals(c_token,"noequal$_axes")) { aspect_ratio_3D = 0; c_token++; return; } local_vals[0] = surface_rot_x; local_vals[1] = surface_rot_z; local_vals[2] = surface_scale; local_vals[3] = surface_zscale; for (i = 0; i < 4 && !(END_OF_COMMAND);) { if (equals(c_token,",")) { if (was_comma) i++; was_comma = TRUE; c_token++; } else { if (!was_comma) int_error(c_token, "',' expected"); local_vals[i] = real_expression(); i++; was_comma = FALSE; } } if (local_vals[0] < 0 || local_vals[0] > 360) int_error(c_token, errmsg1, 'x', 360); if (local_vals[1] < 0 || local_vals[1] > 360) int_error(c_token, errmsg1, 'z', 360); if (local_vals[2] < 1e-6) int_error(c_token, errmsg2, ""); if (local_vals[3] < 1e-6) int_error(c_token, errmsg2, "z"); surface_rot_x = local_vals[0]; surface_rot_z = local_vals[1]; surface_scale = local_vals[2]; surface_zscale = local_vals[3]; surface_lscale = log(surface_scale); }
false
false
false
false
false
0
dSScpy(String *dest, const conString *src, const char *file, int line) { if (dest->charattrs && !src->charattrs) { Sfree(dest, dest->charattrs); dest->charattrs = NULL; } dest->len = src->len; lcheck(dest, file, line); memcpy(dest->data, src->data ? src->data : "", src->len+1); if (src->charattrs) { check_charattrs(dest, 0, 0, file, line); memcpy(dest->charattrs, src->charattrs, sizeof(cattr_t) * (src->len+1)); } dest->attrs = src->attrs; return dest; }
false
false
false
false
false
0
extensionsInitialized() { if (Utils::Log::warnPluginsCreation()) qWarning() << "XmlIOPlugin::extensionsInitialized"; // no user -> end if (!user()) return; if (user()->uuid().isEmpty()) return; // initialize database Internal::XmlIOBase::instance()->initialize(); // add help menu action Core::Context globalcontext(Core::Constants::C_GLOBAL); Core::ActionContainer *hmenu = actionManager()->actionContainer(Core::Id(Core::Constants::M_HELP_DATABASES)); QAction *a = new QAction(this); a->setObjectName("aXmlFormIOPlugin.showDatabaseInformation"); a->setIcon(theme()->icon(Core::Constants::ICONHELP)); Core::Command *cmd = actionManager()->registerAction(a, Core::Id("aXmlFormIOPlugin.showDatabaseInformation"), globalcontext); cmd->setTranslations(Trans::Constants::XMLIO_DATABASE_INFORMATION); cmd->retranslate(); if (hmenu) { hmenu->addAction(cmd, Core::Id(Core::Constants::G_HELP_DATABASES)); } connect(a, SIGNAL(triggered()), this, SLOT(showDatabaseInformation())); addAutoReleasedObject(new Core::PluginAboutPage(pluginSpec(), this)); }
false
false
false
false
false
0
decode(const std::string& input, unsigned char *output, size_t& sz) { size_t i = 0; size_t l = input.size(); size_t j = 0; while (i < l) { while (i < l && (input[i] == 13 || input[i] == 10)) i++; if (i < l) { unsigned char b1 = (unsigned char)((rstr[(int)input[i]] << 2 & 0xfc) + (rstr[(int)input[i + 1]] >> 4 & 0x03)); if (output) { output[j] = b1; } j++; if (input[i + 2] != '=') { unsigned char b2 = (unsigned char)((rstr[(int)input[i + 1]] << 4 & 0xf0) + (rstr[(int)input[i + 2]] >> 2 & 0x0f)); if (output) { output[j] = b2; } j++; } if (input[i + 3] != '=') { unsigned char b3 = (unsigned char)((rstr[(int)input[i + 2]] << 6 & 0xc0) + rstr[(int)input[i + 3]]); if (output) { output[j] = b3; } j++; } i += 4; } } sz = j; }
false
false
false
false
false
0
parse(UTimeZoneFormatStyle style, const UnicodeString& text, ParsePosition& pos, UTimeZoneTimeType* timeType /*= NULL*/) const { UnicodeString tzID; parse(style, text, pos, tzID, timeType); if (pos.getErrorIndex() < 0) { return TimeZone::createTimeZone(tzID); } return NULL; }
false
false
false
false
false
0
OnContextMenuEntry(wxCommandEvent& event) { // we have a single event handler for all popup menu entries // This was ported from cbEditor and used for the basic operations: // Switch to, close, save, etc. const int id = event.GetId(); m_pData->m_CloseMe = false; if (id == idCloseMe) { if (m_pData->m_DisplayingPopupMenu) m_pData->m_CloseMe = true; // defer delete 'this' until after PopupMenu() call returns else GetEditorManager()->Close(this); } else if (id == idCloseAll) { if (m_pData->m_DisplayingPopupMenu) { GetEditorManager()->CloseAllExcept(this); m_pData->m_CloseMe = true; // defer delete 'this' until after PopupMenu() call returns } else GetEditorManager()->CloseAll(); } else if (id == idCloseAllOthers) { GetEditorManager()->CloseAllExcept(this); } else if (id == idSaveMe) { Save(); } else if (id == idSaveAll) { GetEditorManager()->SaveAll(); } else if (id >= idSwitchFile1 && id <= idSwitchFileMax) { // "Switch to..." item SEditorBase *const ed = (SEditorBase*)m_SwitchTo[id]; if (ed) { GetEditorManager()->SetActiveEditor(ed); } m_SwitchTo.clear(); } else if(wxMinimumVersion<2,6,1>::eval) { if (id == idGoogleCode) { wxLaunchDefaultBrowser(wxString(_T("http://www.google.com/codesearch?q=")) << URLEncode(lastWord)); } else if (id == idGoogle) { wxLaunchDefaultBrowser(wxString(_T("http://www.google.com/search?q=")) << URLEncode(lastWord)); } else if (id == idMsdn) { wxLaunchDefaultBrowser(wxString(_T("http://search.microsoft.com/search/results.aspx?qu=")) << URLEncode(lastWord) << _T("&View=msdn")); } } else { event.Skip(); } }
false
false
false
false
false
0
handleVectorSadIntrinsic(IntrinsicInst &I) { const unsigned SignificantBitsPerResultElement = 16; bool isX86_MMX = I.getOperand(0)->getType()->isX86_MMXTy(); Type *ResTy = isX86_MMX ? IntegerType::get(*MS.C, 64) : I.getType(); unsigned ZeroBitsPerResultElement = ResTy->getScalarSizeInBits() - SignificantBitsPerResultElement; IRBuilder<> IRB(&I); Value *S = IRB.CreateOr(getShadow(&I, 0), getShadow(&I, 1)); S = IRB.CreateBitCast(S, ResTy); S = IRB.CreateSExt(IRB.CreateICmpNE(S, Constant::getNullValue(ResTy)), ResTy); S = IRB.CreateLShr(S, ZeroBitsPerResultElement); S = IRB.CreateBitCast(S, getShadowTy(&I)); setShadow(&I, S); setOriginForNaryOp(I); }
false
false
false
false
false
0
trigger_processing(ViewHelper *self, GeglRectangle roi) { //GeglRectangle roi; // PERFORMANCE: determine the area that the view widget is interested in, // and calculate the intersection with the invalidated rect // and only pass this value as the ROI // Would then also have to follow changes in view transformation if (!self->node) return; // roi.x = self->x / self->scale; // roi.y = self->y / self->scale; // roi.width = ceil(self->widget_allocation.width / self->scale + 1); // roi.height = ceil(self->widget_allocation.height / self->scale + 1); if (self->monitor_id == 0) { self->monitor_id = g_idle_add_full(G_PRIORITY_LOW, (GSourceFunc) task_monitor, self, NULL); } // Add the invalidated region to the dirty GeglRectangle *rect = g_new(GeglRectangle, 1); rect->x = roi.x; rect->y = roi.y; rect->width = roi.width; rect->height = roi.height; g_queue_push_head(self->processing_queue, rect); }
false
false
false
false
false
0
collect_if(if_stat *s) { ullong data[4]; int i; if (rdval(get_file(&proc_net_dev), s->device_colon, data, 1, 3, 9, 11)) { put_question_marks(10); return; } for (i=0; i<4; i++) { ullong old = s->old[i]; if (data[i] < old) old = data[i]; //sanitize s->old[i] = data[i]; data[i] -= old; } put_c(data[1] ? '*' : ' '); scale(data[0]); put_c(data[3] ? '*' : ' '); scale(data[2]); }
false
false
false
false
false
0
empathy_account_selector_dialog_dispose (GObject *obj) { EmpathyAccountSelectorDialog *self = (EmpathyAccountSelectorDialog *) obj; g_list_free_full (self->priv->accounts, g_object_unref); self->priv->accounts = NULL; tp_clear_object (&self->priv->model); G_OBJECT_CLASS (empathy_account_selector_dialog_parent_class)->dispose (obj); }
false
false
false
false
false
0
g3d_stream_open_zip(const gchar *filename, const gchar *subfile) { GsfInput *input; GError *error = NULL; input = gsf_input_stdio_new(filename, &error); if(error != NULL) { g_warning("error opening container file '%s': %s", filename, error->message); g_error_free(error); return NULL; } return g3d_stream_open_zip_from_input(input, subfile); }
false
false
false
false
false
0
wrap_help (const char *help, const char *item, unsigned int item_width, unsigned int columns) { unsigned int col_width = LEFT_COLUMN; unsigned int remaining, room, len; remaining = strlen (help); do { room = columns - 3 - MAX (col_width, item_width); if (room > columns) room = 0; len = remaining; if (room < len) { unsigned int i; for (i = 0; help[i]; i++) { if (i >= room && len != remaining) break; if (help[i] == ' ') len = i; else if ((help[i] == '-' || help[i] == '/') && help[i + 1] != ' ' && i > 0 && ISALPHA (help[i - 1])) len = i + 1; } } printf( " %-*.*s %.*s\n", col_width, item_width, item, len, help); item_width = 0; while (help[len] == ' ') len++; help += len; remaining -= len; } while (remaining); }
false
false
false
false
false
0
seek_object(state * state) { int i; for (i = state->seen; i < state->len; i++) { if (state->counter++ >= state->block_size) break; switch(state->str[i]) { /* ignore spaces */ CASESPACE state->seen = i + 1; break; /* usually quotting */ case '"' : case '\'': state->marker = i; state->body = i + 1; state->mode = WAIT_OBJECT_TAIL; state->seen = i + 1; state->tsymbol = state->str[i]; state->need_eval = 0; return 1; case ']': case '}': state->mode = WAIT_DIVIDER; case '[': case '{': case '\\': state->seen = i + 1; state->marker_found = state->str[i]; return 1; case '+': case '-': state->marker = i; state->seen = i + 1; state->body = i; state->mode = WAIT_DIGIT_BODY; return 1; CASEDIGIT state->marker = i; state->seen = i + 1; state->body = i; state->mode = WAIT_DIGIT_TAIL; return 1; case '.': state->marker = i; state->seen = i + 1; state->body = i; state->mode = WAIT_ZFLOAT_TAIL; return 1; case 'u': state->seen = i + 1; state->marker = state->body = i; state->mode = WAIT_UNDEF; return 1; /* perl quotting */ case 'q': state->marker = i; state->body = i; state->mode = WAIT_OBJECT_BODY; state->seen = i + 1; state->need_eval = 0; return 1; /* unexpected symbol */ default: state->mode = ERROR_UNEXPECTED_SYMBOL; state->seen = i; return 0; } } return 0; }
false
false
false
false
false
0