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
sum_file(const char *file, unsigned type) { #define buf bb_common_bufsiz1 unsigned long long total_bytes = 0; int fd, r; /* The sum of all the input bytes, modulo (UINT_MAX + 1). */ unsigned s = 0; fd = open_or_warn_stdin(file); if (fd == -1) return 0; while (1) { size_t bytes_read = safe_read(fd, buf, BUFSIZ); if ((ssize_t)bytes_read <= 0) { r = (fd && close(fd) != 0); if (!bytes_read && !r) /* no error */ break; bb_simple_perror_msg(file); return 0; } total_bytes += bytes_read; if (type >= SUM_SYSV) { do s += buf[--bytes_read]; while (bytes_read); } else { r = 0; do { s = (s >> 1) + ((s & 1) << 15); s += buf[r++]; s &= 0xffff; /* Keep it within bounds. */ } while (--bytes_read); } } if (type < PRINT_NAME) file = ""; if (type >= SUM_SYSV) { r = (s & 0xffff) + ((s & 0xffffffff) >> 16); s = (r & 0xffff) + (r >> 16); printf("%d %llu %s\n", s, (total_bytes + 511) / 512, file); } else printf("%05d %5llu %s\n", s, (total_bytes + 1023) / 1024, file); return 1; #undef buf }
false
false
false
false
false
0
sheet_set_hide_zeros (Sheet *sheet, gboolean hide) { hide = !!hide; if (sheet->hide_zero == hide) return; sheet->hide_zero = hide; sheet_mark_dirty (sheet); sheet_cell_foreach (sheet, (GHFunc)cb_sheet_set_hide_zeros, NULL); }
false
false
false
false
false
0
operator()(const GLEFileLocation& s1, const GLEFileLocation& s2) const { if (s1.getExt() == s2.getExt()) { if (s1.getName() == s2.getName()) { return s1.getFullPath() < s2.getFullPath(); } else { return s1.getName() < s2.getName(); } } else { if (str_i_equals(s1.getExt(), "GLE")) return true; if (str_i_equals(s2.getExt(), "GLE")) return false; return s1.getExt() < s2.getExt(); } } }
false
false
false
false
false
0
advance_lfo(FM_OPN *OPN) { UINT8 pos; UINT8 prev_pos; if (OPN->lfo_inc) /* LFO enabled ? */ { prev_pos = OPN->lfo_cnt>>LFO_SH & 127; OPN->lfo_cnt += OPN->lfo_inc; pos = (OPN->lfo_cnt >> LFO_SH) & 127; /* update AM when LFO output changes */ /*if (prev_pos != pos)*/ /* actually I can't optimize is this way without rewritting chan_calc() to use chip->lfo_am instead of global lfo_am */ { /* triangle */ /* AM: 0 to 126 step +2, 126 to 0 step -2 */ if (pos<64) LFO_AM = (pos&63) * 2; else LFO_AM = 126 - ((pos&63) * 2); } /* PM works with 4 times slower clock */ prev_pos >>= 2; pos >>= 2; /* update PM when LFO output changes */ /*if (prev_pos != pos)*/ /* can't use global lfo_pm for this optimization, must be chip->lfo_pm instead*/ { LFO_PM = pos; } } else { LFO_AM = 0; LFO_PM = 0; } }
false
false
false
false
false
0
snippets_init (const gchar* filename) { GuSnippets* s = g_new0 (GuSnippets, 1); gchar* dirname = g_path_get_dirname (filename); g_mkdir_with_parents (dirname, DIR_PERMS); g_free (dirname); slog (L_INFO, "snippets : %s\n", filename); s->filename = g_strdup (filename); s->accel_group = gtk_accel_group_new (); s->stackframe = NULL; snippets_load (s); return s; }
false
false
false
false
false
0
read_mask(const RrInstance *inst, const gchar *path, RrTheme *theme, const gchar *maskname, RrPixmapMask **value) { gboolean ret = FALSE; gchar *s; gint hx, hy; /* ignored */ guint w, h; guchar *b; s = g_build_filename(path, maskname, NULL); if (XReadBitmapFileData(s, &w, &h, &b, &hx, &hy) == BitmapSuccess) { ret = TRUE; *value = RrPixmapMaskNew(inst, w, h, (gchar*)b); XFree(b); } g_free(s); return ret; }
false
false
false
false
false
0
set_system_clock(const bool hclock_valid, const time_t newtime, const bool testing) { int retcode; if (!hclock_valid) { warnx(_ ("The Hardware Clock does not contain a valid time, so " "we cannot set the System Time from it.")); retcode = 1; } else { struct timeval tv; struct tm *broken; int minuteswest; int rc; tv.tv_sec = newtime; tv.tv_usec = 0; broken = localtime(&newtime); #ifdef HAVE_TM_GMTOFF minuteswest = -broken->tm_gmtoff / 60; /* GNU extension */ #else minuteswest = timezone / 60; if (broken->tm_isdst) minuteswest -= 60; #endif if (debug) { printf(_("Calling settimeofday:\n")); printf(_("\ttv.tv_sec = %ld, tv.tv_usec = %ld\n"), (long)tv.tv_sec, (long)tv.tv_usec); printf(_("\ttz.tz_minuteswest = %d\n"), minuteswest); } if (testing) { printf(_ ("Not setting system clock because running in test mode.\n")); retcode = 0; } else { const struct timezone tz = { minuteswest, 0 }; rc = settimeofday(&tv, &tz); if (rc) { if (errno == EPERM) { warnx(_ ("Must be superuser to set system clock.")); retcode = EX_NOPERM; } else { warn(_("settimeofday() failed")); retcode = 1; } } else retcode = 0; } } return retcode; }
false
false
false
false
false
0
usb_serial_disconnect(struct usb_interface *interface) { int i; struct usb_serial *serial = usb_get_intfdata(interface); struct device *dev = &interface->dev; struct usb_serial_port *port; struct tty_struct *tty; usb_serial_console_disconnect(serial); mutex_lock(&serial->disc_mutex); /* must set a flag, to signal subdrivers */ serial->disconnected = 1; mutex_unlock(&serial->disc_mutex); for (i = 0; i < serial->num_ports; ++i) { port = serial->port[i]; tty = tty_port_tty_get(&port->port); if (tty) { tty_vhangup(tty); tty_kref_put(tty); } usb_serial_port_poison_urbs(port); wake_up_interruptible(&port->port.delta_msr_wait); cancel_work_sync(&port->work); if (device_is_registered(&port->dev)) device_del(&port->dev); } if (serial->type->disconnect) serial->type->disconnect(serial); /* let the last holder of this object cause it to be cleaned up */ usb_serial_put(serial); dev_info(dev, "device disconnected\n"); }
false
false
false
false
false
0
rsvg_css_parse_list (const char *in_str, guint * out_list_len) { char *ptr, *tok; char *str; guint n = 0; GSList *string_list = NULL; gchar **string_array = NULL; str = g_strdup (in_str); tok = strtok_r (str, ", \t", &ptr); if (tok != NULL) { if (strcmp (tok, " ") != 0) { string_list = g_slist_prepend (string_list, g_strdup (tok)); n++; } while ((tok = strtok_r (NULL, ", \t", &ptr)) != NULL) { if (strcmp (tok, " ") != 0) { string_list = g_slist_prepend (string_list, g_strdup (tok)); n++; } } } g_free (str); if (out_list_len) *out_list_len = n; if (string_list) { GSList *slist; string_array = g_new (gchar *, n + 1); string_array[n--] = NULL; for (slist = string_list; slist; slist = slist->next) string_array[n--] = (gchar *) slist->data; g_slist_free (string_list); } return string_array; }
false
false
false
false
false
0
give_tribute(const char* tributeStr) { //---------------------------------------------// // // Send: // <King>'s Kingdom offers you <$999> in aid/tribute. // You offer <King>'s Kingdom <$999> in aid/tribute. // // Reply: // <King>'s Kingdom accepts/rejects your aid/tribute of <$999>. // You accept/reject the <$999> in aid/tribute from <King>'s Kingdom. // //---------------------------------------------// if( reply_type == REPLY_WAITING || !should_disp_reply ) { if( viewing_nation_recno == from_nation_recno ) { str = "You offer "; str += to_nation_name(); str += " "; str += misc.format(talk_para1, 2); str += " in "; str += tributeStr; str += "."; } else { str = from_nation_name(); str += " offers you "; str += misc.format(talk_para1, 2); str += " in "; str += tributeStr; str += "."; } } else { if( viewing_nation_recno == from_nation_recno ) { str = to_nation_name(); if( reply_type == REPLY_ACCEPT ) str += " accepts your "; else str += " rejects your "; str += tributeStr; str += " of "; str += misc.format(talk_para1, 2); str += "."; } else { if( reply_type == REPLY_ACCEPT ) str = "You accept the "; else str = "You reject the "; str += misc.format(talk_para1, 2); str += " in "; str += tributeStr; str += " from "; str += from_nation_name(); str += "."; } } }
false
false
false
false
false
0
execute_variable_command (command, vname) char *command, *vname; { char *last_lastarg; sh_parser_state_t ps; save_parser_state (&ps); last_lastarg = get_string_value ("_"); if (last_lastarg) last_lastarg = savestring (last_lastarg); parse_and_execute (savestring (command), vname, SEVAL_NONINT|SEVAL_NOHIST); restore_parser_state (&ps); bind_variable ("_", last_lastarg, 0); FREE (last_lastarg); if (token_to_read == '\n') /* reset_parser was called */ token_to_read = 0; }
false
false
false
false
false
0
visu_ui_stipple_combobox_setSelection(VisuUiStippleCombobox* stippleComboBox, guint16 stipple) { GtkTreeIter iter; gboolean validIter; GObjectClass *klass; GtkListStore *model; guint tmpStipple; g_return_val_if_fail(stipple && VISU_UI_IS_STIPPLE_COMBOBOX(stippleComboBox), FALSE); DBG_fprintf(stderr, "Gtk VisuUiStippleCombobox: select a new stipple %d.\n", stipple); klass = G_OBJECT_GET_CLASS(stippleComboBox); model = GTK_LIST_STORE(VISU_UI_STIPPLE_COMBOBOX_CLASS(klass)->listStoredStipples); validIter = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter); while (validIter) { gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, COLUMN_STIPPLE_VALUE, &tmpStipple, -1); if ((guint16)(tmpStipple) == stipple) { gtk_combo_box_set_active_iter(GTK_COMBO_BOX(stippleComboBox), &iter); return TRUE; } validIter = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); } return FALSE; }
false
false
false
false
false
0
state_version_major_e(char ch) { if (ch == ' ' || ch == '\t') { state = &HeaderParser::state_version_major_e; return; } else if (ch == '.') { state = &HeaderParser::state_version_minor; return; } else { log_warn("invalid character " << chartoprint(ch) << " in http version field"); state = &HeaderParser::state_error; return; } }
false
false
false
false
false
0
mjacobi (header *hd) { header *st=hd,*result,*hd1; double *m,max,neumax,*mr; int r,c,i,j; hd=getvalue(hd); if (error) return; if (hd->type!=s_matrix) wrong_arg_in("jacobi"); getmatrix(hd,&r,&c,&m); if (r!=c) wrong_arg_in("jacobi"); if (r<2) { moveresult(st,hd); return; } hd1=new_matrix(r,r,""); if (error) return; m=matrixof(hd1); memmove(m,matrixof(hd),(long)r*r*sizeof(double)); while(1) { max=0.0; for (i=0; i<r-1; i++) for (j=i+1; j<r; j++) if ((neumax=rotate(m,i,j,r))>max) max=neumax; if (max<epsilon) break; } result=new_matrix(1,r,""); if (error) return; mr=matrixof(result); for (i=0; i<r; i++) *mr++=*mat(m,r,i,i); moveresult(st,result); }
false
false
false
false
false
0
IDirectFBFont_GetStringWidth( IDirectFBFont *thiz, const char *text, int bytes, int *ret_width ) { DFBResult ret; int width = 0; DIRECT_INTERFACE_GET_DATA(IDirectFBFont) D_DEBUG_AT( Font, "%s( %p )\n", __FUNCTION__, thiz ); if (!text || !ret_width) return DFB_INVARG; if (bytes < 0) bytes = strlen (text); if (bytes > 0) { int i, num, kx; unsigned int prev = 0; unsigned int indices[bytes]; CoreFont *font = data->font; dfb_font_lock( font ); /* Decode string to character indices. */ ret = dfb_font_decode_text( font, data->encoding, text, bytes, indices, &num ); if (ret) { dfb_font_unlock( font ); return ret; } /* Calculate string width. */ for (i=0; i<num; i++) { unsigned int current = indices[i]; CoreGlyphData *glyph; if (dfb_font_get_glyph_data( font, current, &glyph ) == DFB_OK) { width += glyph->advance; if (prev && font->GetKerning && font->GetKerning( font, prev, current, &kx, NULL ) == DFB_OK) width += kx; } prev = current; } dfb_font_unlock( font ); } *ret_width = width; return DFB_OK; }
false
false
false
false
false
0
extract_ke() { double *vcm; double ke = 0.0; for (int i = 0; i < nlocal_body; i++) { vcm = body[i].vcm; ke += body[i].mass * (vcm[0]*vcm[0] + vcm[1]*vcm[1] + vcm[2]*vcm[2]); } double keall; MPI_Allreduce(&ke,&keall,1,MPI_DOUBLE,MPI_SUM,world); return 0.5*keall; }
false
false
false
false
false
0
step1() { for (int row = 0; row < size; ++row) { double minimum = grid_.at(row).at(0); for (int column = 1; column < size; ++column) minimum = std::min(minimum, grid_.at(row).at(column)); for (int column = 0; column < size; ++column) grid_[row][column] -= minimum; } return 2; }
false
false
false
false
false
0
rtsx_pci_ms_drv_remove(struct platform_device *pdev) { struct realtek_pci_ms *host = platform_get_drvdata(pdev); struct rtsx_pcr *pcr; struct memstick_host *msh; int rc; if (!host) return 0; pcr = host->pcr; pcr->slots[RTSX_MS_CARD].p_dev = NULL; pcr->slots[RTSX_MS_CARD].card_event = NULL; msh = host->msh; host->eject = true; cancel_work_sync(&host->handle_req); mutex_lock(&host->host_mutex); if (host->req) { dev_dbg(&(pdev->dev), "%s: Controller removed during transfer\n", dev_name(&msh->dev)); rtsx_pci_complete_unfinished_transfer(pcr); host->req->error = -ENOMEDIUM; do { rc = memstick_next_req(msh, &host->req); if (!rc) host->req->error = -ENOMEDIUM; } while (!rc); } mutex_unlock(&host->host_mutex); memstick_remove_host(msh); memstick_free_host(msh); dev_dbg(&(pdev->dev), ": Realtek PCI-E Memstick controller has been removed\n"); return 0; }
false
false
false
false
false
0
do_languages_line(apr_pool_t *p, const char **lang_line) { apr_array_header_t *lang_recs = apr_array_make(p, 2, sizeof(char *)); if (!lang_line) { return lang_recs; } while (**lang_line) { char **new = (char **) apr_array_push(lang_recs); *new = ap_get_token(p, lang_line, 0); ap_str_tolower(*new); if (**lang_line == ',' || **lang_line == ';') { ++(*lang_line); } } return lang_recs; }
false
false
false
false
false
0
js_generic_native_method_dispatcher(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { jsval fsv; JSFunctionSpec *fs; JSObject *tmp; if (!JS_GetReservedSlot(cx, JSVAL_TO_OBJECT(argv[-2]), 0, &fsv)) return JS_FALSE; fs = (JSFunctionSpec *) JSVAL_TO_PRIVATE(fsv); JS_ASSERT((fs->flags & (JSFUN_FAST_NATIVE | JSFUN_GENERIC_NATIVE)) == JSFUN_GENERIC_NATIVE); /* * We know that argv[0] is valid because JS_DefineFunctions, which is our * only (indirect) referrer, defined us as requiring at least one argument * (notice how it passes fs->nargs + 1 as the next-to-last argument to * JS_DefineFunction). */ if (JSVAL_IS_PRIMITIVE(argv[0])) { /* * Make sure that this is an object or null, as required by the generic * functions. */ if (!js_ValueToObject(cx, argv[0], &tmp)) return JS_FALSE; argv[0] = OBJECT_TO_JSVAL(tmp); } /* * Copy all actual (argc) arguments down over our |this| parameter, * argv[-1], which is almost always the class constructor object, e.g. * Array. Then call the corresponding prototype native method with our * first argument passed as |this|. */ memmove(argv - 1, argv, argc * sizeof(jsval)); /* * Follow Function.prototype.apply and .call by using the global object as * the 'this' param if no args. */ if (!js_ComputeThis(cx, JS_TRUE, argv)) return JS_FALSE; js_GetTopStackFrame(cx)->thisp = JSVAL_TO_OBJECT(argv[-1]); JS_ASSERT(cx->fp->argv == argv); /* * Protect against argc underflowing. By calling js_ComputeThis, we made * it as if the static was called with one parameter, the explicit |this| * object. */ if (argc != 0) { /* Clear the last parameter in case too few arguments were passed. */ argv[--argc] = JSVAL_VOID; } return fs->call(cx, JSVAL_TO_OBJECT(argv[-1]), argc, argv, rval); }
false
false
false
false
false
0
mos7720_throttle(struct tty_struct *tty) { struct usb_serial_port *port = tty->driver_data; struct moschip_port *mos7720_port; int status; mos7720_port = usb_get_serial_port_data(port); if (mos7720_port == NULL) return; if (!mos7720_port->open) { dev_dbg(&port->dev, "%s - port not opened\n", __func__); return; } /* if we are implementing XON/XOFF, send the stop character */ if (I_IXOFF(tty)) { unsigned char stop_char = STOP_CHAR(tty); status = mos7720_write(tty, port, &stop_char, 1); if (status <= 0) return; } /* if we are implementing RTS/CTS, toggle that line */ if (tty->termios.c_cflag & CRTSCTS) { mos7720_port->shadowMCR &= ~UART_MCR_RTS; write_mos_reg(port->serial, port->port_number, MOS7720_MCR, mos7720_port->shadowMCR); } }
false
false
false
false
true
1
get_fetch_map(const struct ref *remote_refs, const struct refspec *refspec, struct ref ***tail, int missing_ok) { struct ref *ref_map, **rmp; if (refspec->pattern) { ref_map = get_expanded_map(remote_refs, refspec); } else { const char *name = refspec->src[0] ? refspec->src : "HEAD"; ref_map = get_remote_ref(remote_refs, name); if (!missing_ok && !ref_map) die("Couldn't find remote ref %s", name); if (ref_map) { ref_map->peer_ref = get_local_ref(refspec->dst); if (ref_map->peer_ref && refspec->force) ref_map->peer_ref->force = 1; } } for (rmp = &ref_map; *rmp; ) { if ((*rmp)->peer_ref) { int st = check_ref_format((*rmp)->peer_ref->name + 5); if (st && st != CHECK_REF_FORMAT_ONELEVEL) { struct ref *ignore = *rmp; error("* Ignoring funny ref '%s' locally", (*rmp)->peer_ref->name); *rmp = (*rmp)->next; free(ignore->peer_ref); free(ignore); continue; } } rmp = &((*rmp)->next); } if (ref_map) tail_link_ref(ref_map, tail); return 0; }
false
false
false
false
false
0
dht_discover_complete (xlator_t *this, call_frame_t *discover_frame) { dht_local_t *local = NULL; call_frame_t *main_frame = NULL; int op_errno = 0; int ret = -1; dht_layout_t *layout = NULL; local = discover_frame->local; layout = local->layout; LOCK(&discover_frame->lock); { main_frame = local->main_frame; local->main_frame = NULL; } UNLOCK(&discover_frame->lock); if (!main_frame) return 0; if (local->file_count && local->dir_count) { gf_log (this->name, GF_LOG_ERROR, "path %s exists as a file on one subvolume " "and directory on another. " "Please fix it manually", local->loc.path); op_errno = EIO; goto out; } if (local->cached_subvol) { ret = dht_layout_preset (this, local->cached_subvol, local->inode); if (ret < 0) { gf_log (this->name, GF_LOG_WARNING, "failed to set layout for subvolume %s", local->cached_subvol ? local->cached_subvol->name : "<nil>"); op_errno = EINVAL; goto out; } } else { ret = dht_layout_normalize (this, &local->loc, layout); if ((ret < 0) || ((ret > 0) && (local->op_ret != 0))) { /* either the layout is incorrect or the directory is * not found even in one subvolume. */ gf_log (this->name, GF_LOG_DEBUG, "normalizing failed on %s " "(overlaps/holes present: %s, " "ENOENT errors: %d)", local->loc.path, (ret < 0) ? "yes" : "no", (ret > 0) ? ret : 0); op_errno = EINVAL; goto out; } dht_layout_set (this, local->inode, layout); } DHT_STACK_UNWIND (lookup, main_frame, local->op_ret, local->op_errno, local->inode, &local->stbuf, local->xattr, &local->postparent); return 0; out: DHT_STACK_UNWIND (lookup, main_frame, -1, op_errno, NULL, NULL, NULL, NULL); return ret; }
false
false
false
false
false
0
SetTransparency(Uint8 t, bool bRecursive) { if(_mid->simplebackground || _mid->nocache) { PG_Widget::SetTransparency(t, bRecursive); return; } if(t == 255) { DeleteThemedSurface(_mid->cachesurface); _mid->cachesurface = NULL; } else if(GetTransparency() == 255) { CreateSurface(); } PG_Widget::SetTransparency(t, bRecursive); }
false
false
false
false
false
0
qlcnic_sriov_pf_reinit(struct qlcnic_adapter *adapter) { struct qlcnic_hardware_context *ahw = adapter->ahw; int err; if (!qlcnic_sriov_enable_check(adapter)) return 0; ahw->op_mode = QLCNIC_SRIOV_PF_FUNC; err = qlcnic_sriov_pf_init(adapter); if (err) return err; dev_info(&adapter->pdev->dev, "%s: op_mode %d\n", __func__, ahw->op_mode); return err; }
false
false
false
false
false
0
dumpmem (uaecptr addr, uaecptr *nxmem, int lines) { TCHAR line[MAX_LINEWIDTH + 1]; for (;lines--;) { addr = dumpmem2 (addr, line, sizeof(line)); debug_out (_T("%s"), line); if (!debug_out (_T("\n"))) break; } *nxmem = addr; }
false
false
false
false
false
0
operator==(const SerializableMock& other) { COMPARE(ValInt, other.ValInt); COMPARE(ValFloat, other.ValFloat); COMPARE(ValString, other.ValString); COMPARE(ValStringW, other.ValStringW); if ( memcmp( ValBinary, other.ValBinary, BINARY_BLOCK_SIZE) != 0 ) { logTestString("Not identical %s in %s:%d", "ValBinary", __FILE__, __LINE__ ); return false; } COMPARE(ValStringWArray, other.ValStringWArray); COMPARE(ValBool, other.ValBool); COMPARE(ValEnum, other.ValEnum); COMPARE(ValColor, other.ValColor); if ( ValColorf.r != other.ValColorf.r || ValColorf.g != other.ValColorf.g || ValColorf.b != other.ValColorf.b || ValColorf.a != other.ValColorf.a ) { logTestString("Not identical %s in %s:%d", "ValColorf", __FILE__, __LINE__ ); return false; } COMPARE(ValVector3df, other.ValVector3df); COMPARE(ValVector2df, other.ValVector2df); COMPARE(ValDimension2du, other.ValDimension2du); COMPARE(ValPosition2di, other.ValPosition2di); COMPARE(ValRect, other.ValRect); COMPARE(ValMatrix, other.ValMatrix); COMPARE(ValQuaternion, other.ValQuaternion); COMPARE(ValAabbox3df, other.ValAabbox3df); COMPARE(ValPlane3df, other.ValPlane3df); COMPARE(ValTriangle3df, other.ValTriangle3df); COMPARE(ValLine2df, other.ValLine2df); COMPARE(ValLine3df, other.ValLine3df); // ValTexture; // TODO if ( ComparePointers ) COMPARE(ValPointer, other.ValPointer); return true; }
false
false
false
false
false
0
mascii (header *hd) { header *st=hd,*result; hd=getvalue(hd); if (error) return; if (hd->type!=s_string) wrong_arg_in("ascii"); result=new_real(*stringof(hd),""); if (error) return; moveresult(st,result); }
false
false
false
false
false
0
pd4990a_process_command(void) { switch(pd4990a_getcommand()) { case 0x1: //load output register bitno=0; if(reading) pd4990a_readbit(); //prepare first bit shiftlo=0; shifthi=0; break; case 0x2: writting=0; //store register to current date pd4990a_update_date(); break; case 0x3: //start reading reading=1; break; case 0x7: //switch testbit every frame maxwaits=1; break; case 0x8: //switch testbit every half-second maxwaits=30; break; } }
false
false
false
false
false
0
handle_cli_stun_set_debug(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { switch (cmd) { case CLI_INIT: e->command = "stun set debug {on|off}"; e->usage = "Usage: stun set debug {on|off}\n" " Enable/Disable STUN (Simple Traversal of UDP through NATs)\n" " debugging\n"; return NULL; case CLI_GENERATE: return NULL; } if (a->argc != e->args) return CLI_SHOWUSAGE; if (!strncasecmp(a->argv[e->args-1], "on", 2)) stundebug = 1; else if (!strncasecmp(a->argv[e->args-1], "off", 3)) stundebug = 0; else return CLI_SHOWUSAGE; ast_cli(a->fd, "STUN Debugging %s\n", stundebug ? "Enabled" : "Disabled"); return CLI_SUCCESS; }
false
false
false
false
false
0
SEC_PKCS5GetCryptoAlgorithm(SECAlgorithmID *algid) { SECOidTag pbeAlg; SECOidTag cipherAlg; if(algid == NULL) return SEC_OID_UNKNOWN; pbeAlg = SECOID_GetAlgorithmTag(algid); cipherAlg = sec_pkcs5GetCryptoFromAlgTag(pbeAlg); if ((cipherAlg == SEC_OID_PKCS5_PBKDF2) && (pbeAlg != SEC_OID_PKCS5_PBKDF2)) { sec_pkcs5V2Parameter *pbeV2_param; cipherAlg = SEC_OID_UNKNOWN; pbeV2_param = sec_pkcs5_v2_get_v2_param(NULL, algid); if (pbeV2_param != NULL) { cipherAlg = SECOID_GetAlgorithmTag(&pbeV2_param->cipherAlgId); sec_pkcs5_v2_destroy_v2_param(pbeV2_param); } } return cipherAlg; }
false
false
false
false
false
0
mca_scoll_basic_barrier(struct oshmem_group_t *group, long *pSync, int alg) { int rc = OSHMEM_SUCCESS; /* Arguments validation */ if (!group) { SCOLL_ERROR("Active set (group) of PE is not defined"); rc = OSHMEM_ERR_BAD_PARAM; } if ((rc == OSHMEM_SUCCESS) && oshmem_proc_group_is_member(group)) { if (pSync) { alg = (alg == SCOLL_DEFAULT_ALG ? mca_scoll_basic_param_barrier_algorithm : alg); switch (alg) { case SCOLL_ALG_BARRIER_CENTRAL_COUNTER: { rc = _algorithm_central_counter(group, pSync); break; } case SCOLL_ALG_BARRIER_TOURNAMENT: { rc = _algorithm_tournament(group, pSync); break; } case SCOLL_ALG_BARRIER_RECURSIVE_DOUBLING: { rc = _algorithm_recursive_doubling(group, pSync); break; } case SCOLL_ALG_BARRIER_DISSEMINATION: { rc = _algorithm_dissemination(group, pSync); break; } case SCOLL_ALG_BARRIER_BASIC: { rc = _algorithm_basic(group, pSync); break; } case SCOLL_ALG_BARRIER_ADAPTIVE: { rc = _algorithm_adaptive(group, pSync); break; } default: { rc = _algorithm_recursive_doubling(group, pSync); } } } else { SCOLL_ERROR("Incorrect argument pSync"); rc = OSHMEM_ERR_BAD_PARAM; } } return rc; }
false
false
false
false
false
0
wl1271_acx_fm_coex(struct wl1271 *wl) { struct wl1271_acx_fm_coex *acx; int ret; wl1271_debug(DEBUG_ACX, "acx fm coex setting"); acx = kzalloc(sizeof(*acx), GFP_KERNEL); if (!acx) { ret = -ENOMEM; goto out; } acx->enable = wl->conf.fm_coex.enable; acx->swallow_period = wl->conf.fm_coex.swallow_period; acx->n_divider_fref_set_1 = wl->conf.fm_coex.n_divider_fref_set_1; acx->n_divider_fref_set_2 = wl->conf.fm_coex.n_divider_fref_set_2; acx->m_divider_fref_set_1 = cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_1); acx->m_divider_fref_set_2 = cpu_to_le16(wl->conf.fm_coex.m_divider_fref_set_2); acx->coex_pll_stabilization_time = cpu_to_le32(wl->conf.fm_coex.coex_pll_stabilization_time); acx->ldo_stabilization_time = cpu_to_le16(wl->conf.fm_coex.ldo_stabilization_time); acx->fm_disturbed_band_margin = wl->conf.fm_coex.fm_disturbed_band_margin; acx->swallow_clk_diff = wl->conf.fm_coex.swallow_clk_diff; ret = wl1271_cmd_configure(wl, ACX_FM_COEX_CFG, acx, sizeof(*acx)); if (ret < 0) { wl1271_warning("acx fm coex setting failed: %d", ret); goto out; } out: kfree(acx); return ret; }
false
false
false
false
false
0
shapeCheck(K a, K p, I d) { //Descend through list a marking shape p as -1 where it doesn't correspond I at=a->t, an=a->n; if(at>0 || an!=kI(p)[d]) kI(p)[d]=-1;//Mismatch or atom means p length too long else if(at && d < p->n-1) kI(p)[d+1]=-1;//Another case of p being too long else if(!at && an && kI(p)[d]!=-1 && d < p->n-1) DO(an, shapeCheck(kK(a)[i],p,d+1)) }
false
false
false
false
true
1
afr_sh_data_erase_pending (call_frame_t *frame, xlator_t *this) { afr_local_t *local = NULL; afr_self_heal_t *sh = NULL; afr_private_t *priv = NULL; int call_count = 0; int i = 0; dict_t **erase_xattr = NULL; local = frame->local; sh = &local->self_heal; priv = this->private; afr_sh_pending_to_delta (priv, sh->xattr, sh->delta_matrix, sh->success, priv->child_count, AFR_DATA_TRANSACTION); gf_log (this->name, GF_LOG_DEBUG, "Delta matrix for: %"PRIu64, frame->root->lk_owner); afr_sh_print_pending_matrix (sh->delta_matrix, this); erase_xattr = GF_CALLOC (sizeof (*erase_xattr), priv->child_count, gf_afr_mt_dict_t); for (i = 0; i < priv->child_count; i++) { if (sh->xattr[i]) { call_count++; erase_xattr[i] = get_new_dict(); dict_ref (erase_xattr[i]); } } afr_sh_delta_to_xattr (priv, sh->delta_matrix, erase_xattr, priv->child_count, AFR_DATA_TRANSACTION); GF_ASSERT (call_count); local->call_count = call_count; for (i = 0; i < priv->child_count; i++) { if (!erase_xattr[i]) continue; gf_log (this->name, GF_LOG_DEBUG, "erasing pending flags from %s on %s", local->loc.path, priv->children[i]->name); STACK_WIND_COOKIE (frame, afr_sh_data_erase_pending_cbk, (void *) (long) i, priv->children[i], priv->children[i]->fops->fxattrop, sh->healing_fd, GF_XATTROP_ADD_ARRAY, erase_xattr[i]); if (!--call_count) break; } for (i = 0; i < priv->child_count; i++) { if (erase_xattr[i]) { dict_unref (erase_xattr[i]); } } GF_FREE (erase_xattr); return 0; }
false
false
false
false
false
0
scm_c_vector_length (SCM v) { if (SCM_I_IS_VECTOR (v)) return SCM_I_VECTOR_LENGTH (v); else return scm_to_size_t (scm_vector_length (v)); }
false
false
false
false
false
0
GetPreprocessorType() { const unsigned int undoIndex = m_TokenIndex; const unsigned int undoLine = m_LineNumber; MoveToNextChar(); while (SkipWhiteSpace() || SkipComment()) ; const wxString token = DoGetToken(); switch (token.Len()) { case 2: if (token == TokenizerConsts::kw_if) return ptIf; break; case 4: if (token == TokenizerConsts::kw_else) return ptElse; else if (token == TokenizerConsts::kw_elif) return ptElif; break; case 5: if (token == TokenizerConsts::kw_ifdef) return ptIfdef; else if (token == TokenizerConsts::kw_endif) return ptEndif; break; case 6: if (token == TokenizerConsts::kw_ifndef) return ptIfndef; break; case 7: if (token == TokenizerConsts::kw_elifdef) return ptElifdef; break; case 8: if (token == TokenizerConsts::kw_elifndef) return ptElifndef; break; default: break; } m_TokenIndex = undoIndex; m_LineNumber = undoLine; return ptOthers; }
false
false
false
false
false
0
onQueryTip(FXObject*sender,FXSelector sel,void* ptr){ if(FXTopWindow::onQueryTip(sender,sel,ptr)) return 1; if((flags&FLAG_TIP) && !tip.empty() && !grabbed() ){ sender->handle(this,FXSEL(SEL_COMMAND,ID_SETSTRINGVALUE),(void*)&tip); return 1; } return 0; }
false
false
false
false
false
0
test_copy_attribute (void) { GckAttribute attr, copy; gck_attribute_init_ulong (&attr, ATTR_TYPE, 88); gck_attribute_init_copy (&copy, &attr); gck_attribute_clear (&attr); g_assert (gck_attribute_get_ulong (&copy) == 88); g_assert (copy.type == ATTR_TYPE); gck_attribute_clear (&copy); }
false
false
false
false
false
0
p_cgi_url_unescape (PyObject *self, PyObject *args) { char *s; PyObject *rv; char *r; if (!PyArg_ParseTuple(args, "s:urlUnescape(str)", &s)) return NULL; r = strdup(s); if (r == NULL) return PyErr_NoMemory(); cgi_url_unescape (r); rv = Py_BuildValue ("s", r); free (r); return rv; }
false
false
false
false
false
0
fixtitle(PyUnicodeObject *self) { register Py_UNICODE *p = PyUnicode_AS_UNICODE(self); register Py_UNICODE *e; int previous_is_cased; /* Shortcut for single character strings */ if (PyUnicode_GET_SIZE(self) == 1) { Py_UNICODE ch = Py_UNICODE_TOTITLE(*p); if (*p != ch) { *p = ch; return 1; } else return 0; } e = p + PyUnicode_GET_SIZE(self); previous_is_cased = 0; for (; p < e; p++) { register const Py_UNICODE ch = *p; if (previous_is_cased) *p = Py_UNICODE_TOLOWER(ch); else *p = Py_UNICODE_TOTITLE(ch); if (Py_UNICODE_ISLOWER(ch) || Py_UNICODE_ISUPPER(ch) || Py_UNICODE_ISTITLE(ch)) previous_is_cased = 1; else previous_is_cased = 0; } return 1; }
false
false
false
false
false
0
H5A_dense_btree2_name_compare(const void *_bt2_udata, const void *_bt2_rec, int *result) { const H5A_bt2_ud_common_t *bt2_udata = (const H5A_bt2_ud_common_t *)_bt2_udata; const H5A_dense_bt2_name_rec_t *bt2_rec = (const H5A_dense_bt2_name_rec_t *)_bt2_rec; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Sanity check */ HDassert(bt2_udata); HDassert(bt2_rec); /* Check hash value */ if(bt2_udata->name_hash < bt2_rec->hash) *result = (-1); else if(bt2_udata->name_hash > bt2_rec->hash) *result = 1; else { H5A_fh_ud_cmp_t fh_udata; /* User data for fractal heap 'op' callback */ H5HF_t *fheap; /* Fractal heap handle to use for finding object */ /* Sanity check */ HDassert(bt2_udata->name_hash == bt2_rec->hash); /* Prepare user data for callback */ /* down */ fh_udata.f = bt2_udata->f; fh_udata.dxpl_id = bt2_udata->dxpl_id; fh_udata.name = bt2_udata->name; fh_udata.record = bt2_rec; fh_udata.found_op = bt2_udata->found_op; fh_udata.found_op_data = bt2_udata->found_op_data; /* up */ fh_udata.cmp = 0; /* Check for attribute in shared storage */ if(bt2_rec->flags & H5O_MSG_FLAG_SHARED) fheap = bt2_udata->shared_fheap; else fheap = bt2_udata->fheap; HDassert(fheap); /* Check if the user's attribute and the B-tree's attribute have the same name */ if(H5HF_op(fheap, bt2_udata->dxpl_id, &bt2_rec->id, H5A_dense_fh_name_cmp, &fh_udata) < 0) HGOTO_ERROR(H5E_HEAP, H5E_CANTCOMPARE, FAIL, "can't compare btree2 records") /* Callback will set comparison value */ *result = fh_udata.cmp; } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) }
false
false
false
false
false
0
adapter_set_discovering(struct btd_adapter *adapter, gboolean discovering) { const char *path = adapter->path; adapter->discovering = discovering; emit_property_changed(connection, path, ADAPTER_INTERFACE, "Discovering", DBUS_TYPE_BOOLEAN, &discovering); if (discovering) return; g_slist_foreach(adapter->oor_devices, emit_device_disappeared, adapter); g_slist_free_full(adapter->oor_devices, dev_info_free); adapter->oor_devices = g_slist_copy(adapter->found_devices); if (!adapter_has_discov_sessions(adapter) || adapter->discov_suspended) return; DBG("hci%u restarting discovery, disc_sessions %u", adapter->dev_id, g_slist_length(adapter->disc_sessions)); adapter->discov_id = g_idle_add(discovery_cb, adapter); }
false
false
false
false
false
0
write_cache_file(char *file, time_t date, char *ipaddr) { FILE *fp = NULL; if((fp=fopen(file, "w")) == NULL) { return(-1); } fprintf(fp, "%ld,%s\n", date, ipaddr); fclose(fp); return 0; }
false
false
false
false
false
0
defs_to_undefined (insn) rtx insn; { struct df_link *currdef; for (currdef = DF_INSN_DEFS (df_analyzer, insn); currdef; currdef = currdef->next) { if (values[DF_REF_REGNO (currdef->ref)].lattice_val != UNDEFINED) SET_BIT (ssa_edges, DF_REF_REGNO (currdef->ref)); values[DF_REF_REGNO (currdef->ref)].lattice_val = UNDEFINED; } }
false
false
false
false
false
0
makeFilename(unsigned int &seed, const char *dir, const char *prefix, const char *postfix, OFString &filename) { OFBool done = OFFalse; OFBool result = OFTrue; struct stat stat_buf; int stat_result = 0; unsigned tries = 0; do { // create filename filename.clear(); if (dir) { filename = dir; filename += PATH_SEPARATOR; } if (prefix) filename += prefix; addLongToString(creation_time, filename); addLongToString(((OFStandard::rand_r(seed) << 16) | OFStandard::rand_r(seed)), filename); if (postfix) filename += postfix; // check if filename exists stat_result = stat(filename.c_str(), &stat_buf); if (stat_result == 0) { if (++tries == MAX_TRY) { done = OFTrue; result = OFFalse; } } else { // file does not exists, bail out done = OFTrue; if (errno != ENOENT) result=OFFalse; // something wrong with path } } while (!done); return result; }
false
false
false
false
false
0
OpenWorldCommunityGridProjectsPage() const { wxLogTrace(wxT("Function Start/End"), wxT("CWelcomePage::OpenWorldCommunityGridProjectsPage - Function Begin")); CWizardAttach* pWAP = ((CWizardAttach*)GetParent()); wxASSERT(pWAP); wxASSERT(wxDynamicCast(pWAP, CWizardAttach)); wxLaunchDefaultBrowser(wxT("http://www.worldcommunitygrid.org/ms/viewMyProjects.do")); pWAP->SimulateCancelButton(); wxLogTrace(wxT("Function Start/End"), wxT("CWelcomePage::OpenWorldCommunityGridProjectsPage - Function End")); }
false
false
false
false
false
0
cts_cbc_encrypt(struct crypto_cts_ctx *ctx, struct blkcipher_desc *desc, struct scatterlist *dst, struct scatterlist *src, unsigned int offset, unsigned int nbytes) { int bsize = crypto_blkcipher_blocksize(desc->tfm); u8 tmp[bsize], tmp2[bsize]; struct blkcipher_desc lcldesc; struct scatterlist sgsrc[1], sgdst[1]; int lastn = nbytes - bsize; u8 iv[bsize]; u8 s[bsize * 2], d[bsize * 2]; int err; if (lastn < 0) return -EINVAL; sg_init_table(sgsrc, 1); sg_init_table(sgdst, 1); memset(s, 0, sizeof(s)); scatterwalk_map_and_copy(s, src, offset, nbytes, 0); memcpy(iv, desc->info, bsize); lcldesc.tfm = ctx->child; lcldesc.info = iv; lcldesc.flags = desc->flags; sg_set_buf(&sgsrc[0], s, bsize); sg_set_buf(&sgdst[0], tmp, bsize); err = crypto_blkcipher_encrypt_iv(&lcldesc, sgdst, sgsrc, bsize); memcpy(d + bsize, tmp, lastn); lcldesc.info = tmp; sg_set_buf(&sgsrc[0], s + bsize, bsize); sg_set_buf(&sgdst[0], tmp2, bsize); err = crypto_blkcipher_encrypt_iv(&lcldesc, sgdst, sgsrc, bsize); memcpy(d, tmp2, bsize); scatterwalk_map_and_copy(d, dst, offset, nbytes, 1); memcpy(desc->info, tmp2, bsize); return err; }
false
false
false
false
false
0
PixelWrite (uae_u8 *mem, int bits, uae_u32 fgpen, int Bpp, uae_u32 mask) { switch (Bpp) { case 1: if (mask != 0xFF) fgpen = (fgpen & mask) | (mem[bits] & ~mask); mem[bits] = (uae_u8)fgpen; break; case 2: ((uae_u16 *)mem)[bits] = (uae_u16)fgpen; break; case 3: mem[bits * 3 + 0] = fgpen >> 0; mem[bits * 3 + 1] = fgpen >> 8; mem[bits * 3 + 2] = fgpen >> 16; break; case 4: ((uae_u32 *)mem)[bits] = fgpen; break; } }
false
false
false
false
false
0
updateLayout() { ChatEdit* newEdit = createTextEdit(); if (textEdit_) { // all syntaxhighlighters should be removed while we move // the documents around, and should be reattached afterwards textEdit_->setCheckSpelling(false); newEdit->setCheckSpelling(false); moveData(newEdit, textEdit_); newEdit->setCheckSpelling(ChatEdit::checkSpellingGloballyEnabled()); } delete textEdit_; textEdit_ = newEdit; layout_->addWidget(textEdit_); emit textEditCreated(textEdit_); }
false
false
false
false
false
0
FastFileLock(struct FF_Handle *i) { if (!i) return NULL; #if defined HAVE_MMAP || defined _WIN32 char *buffer = NULL; if(!g_MemMap) return NULL; #endif #if defined HAVE_MMAP || defined _WIN32 buffer = (char*)g_MemMap; buffer += i->off; return SDL_RWFromMem(buffer, i->len); #else fseek(g_File, i->off, SEEK_SET); return SDL_RWFromFP(g_File, /*autoclose=*/0); #endif }
false
false
false
false
false
0
fos_open (const char *path, struct fuse_file_info *fi) { int ret = 0; char *location; location = trim_fosname (path); if ((fi->flags & 3) != O_RDONLY) ret = -EACCES; else if (!fosfat_isopenexm (fosfat, location)) ret = -ENOENT; if (location) free (location); return ret; }
false
false
false
false
false
0
flmLFileIndexBuild( FDB * pDb, LFILE * pIxLFile, IXD * pIxd, FLMBOOL bDoInBackground, FLMBOOL bCreateSuspended, FLMBOOL * pbLogCompleteIndexSet) { RCODE rc = FERR_OK; if( pDb->uiFlags & FDB_REPLAYING_RFL) { // Don't index now. The RFL function INDEX_SET will // generate index keys. if( pDb->pFile->FileHdr.uiVersionNum >= FLM_FILE_FORMAT_VER_3_02 && pDb->pFile->FileHdr.uiVersionNum <= FLM_FILE_FORMAT_VER_4_51) { if( RC_BAD( rc = flmSetIxTrackerInfo( pDb, pIxd->uiIndexNum, 1, 0, TRANS_ID_OFFLINE, FALSE))) { goto Exit; } goto Exit; } } // Start the indexing thread if building in the background // and NOT a unique index. if( bDoInBackground && !(pIxd->uiFlags & IXD_UNIQUE)) { if( RC_BAD( rc = flmSetIxTrackerInfo( pDb, pIxd->uiIndexNum, 1, 0, TRANS_ID_OFFLINE, bCreateSuspended))) { goto Exit; } if( RC_BAD( rc = flmLFileWrite( pDb, pIxLFile))) { goto Exit; } pIxd->uiFlags |= IXD_OFFLINE; if( bCreateSuspended) { pIxd->uiFlags |= IXD_SUSPENDED; } else if( !(pDb->uiFlags & FDB_REPLAYING_RFL)) { // Don't add the index to the start list if we are replaying // the RFL. The indexing threads will be started once // recovery is complete. if( RC_BAD( rc = flmAddToStartList( pDb, pIxd->uiIndexNum))) { goto Exit; } } goto Exit; } // uiIndexToBeUpdated better be zero at this point since we // are not working in the background. if( RC_BAD( rc = flmIndexSetOfRecords( pDb, pIxd->uiIndexNum, 0, 1, DRN_LAST_MARKER, pDb->fnStatus, pDb->StatusData, pDb->fnIxCallback, pDb->IxCallbackData, NULL, NULL))) { goto Exit; } if( pbLogCompleteIndexSet) { *pbLogCompleteIndexSet = TRUE; } Exit: // Need to convert FERR_NOT_UNIQUE to FERR_IX_FAILURE so that we // can force the transaction to abort. Normally, FERR_NOT_UNIQUE is // an error that does not require the transaction to abort. However, // in this case, we are generating an index and it is not possible // to continue the transaction - because we may have modified disk // blocks. if( rc == FERR_NOT_UNIQUE) { rc = RC_SET( FERR_IX_FAILURE); } return( rc); }
false
false
false
false
false
0
dane_X509_any_subject_alt_name_matches_server_name( X509 *cert, ldns_rdf* server_name) { GENERAL_NAMES* names; GENERAL_NAME* name; unsigned char* subject_alt_name_str = NULL; int i, n; names = X509_get_ext_d2i(cert, NID_subject_alt_name, 0, 0 ); if (! names) { /* No subjectAltName extension */ return false; } n = sk_GENERAL_NAME_num(names); for (i = 0; i < n; i++) { name = sk_GENERAL_NAME_value(names, i); if (name->type == GEN_DNS) { (void) ASN1_STRING_to_UTF8(&subject_alt_name_str, name->d.dNSName); if (subject_alt_name_str) { if (dane_name_matches_server_name((char*) subject_alt_name_str, server_name)) { OPENSSL_free(subject_alt_name_str); return true; } OPENSSL_free(subject_alt_name_str); } } } /* sk_GENERAL_NAMES_pop_free(names, sk_GENERAL_NAME_free); */ return false; }
false
false
false
false
false
0
ReadFileToString(const std::string& filename, std::string* data) { FILE *f = fopen(filename.c_str(), "rb"); if (f == 0) { LOG(INFO) << "Can't open file: " << filename; return false; } fseek(f, 0, SEEK_END); int size = ftell(f); fseek(f, 0, SEEK_SET); // There should be a faster way to do this, can I read to string.data()? char* d = new char[size]; bool ret = false; if (fread(d, 1, size, f) == size) { ret = true; data->append(d, size); } else { LOG(INFO) << "File size mismatch"; } fclose(f); delete d; return ret; }
false
false
false
false
false
0
_postorder(struct avln * ap, void *(*func) (), void *result) { if (ap != (struct avln *) (0)) { result = _postorder(ap->l, func, result); result = _postorder(ap->r, func, result); result = (*func) (ap->d, result); } return result; }
false
false
false
false
false
0
main(int argc, char* argv[]) { try { process(argc, argv); } catch (error& e) { cerr << e << endl; exit(EXIT_FAILURE); } catch (std::bad_alloc) { cerr << "Low memory" << endl; exit(EXIT_FAILURE); } catch (...) { cerr << "Unknown error" << endl; exit(EXIT_FAILURE); } return EXIT_SUCCESS; }
false
false
false
false
false
0
gamgi_mesa_pick_orbital (gamgi_orbital *orbital, int class, gamgi_object **array) { gamgi_dlist *dlist; unsigned char color_old[3], color_new[3]; double rotate[16]; double *center; double scale; int *dots; if (class == GAMGI_ENGINE_ORBITAL) { *array++ = GAMGI_CAST_OBJECT orbital; gamgi_mesa_select_old (color_old); gamgi_mesa_select_new (color_new); glColor3ubv (color_new); } glPushMatrix (); center = orbital->center; scale = orbital->object.scale; glTranslatef (center[0], center[1], center[2]); glScalef (scale, scale, scale); glTranslatef (-center[0], -center[1], -center[2]); glPushMatrix (); glTranslatef (orbital->origin[0], orbital->origin[1], orbital->origin[2]); gamgi_math_quaternion_to_matrix4 (orbital->quaternion, rotate); glMultMatrixd (rotate); /*********************** * scan orbital object * ***********************/ dots = orbital->dots; if (orbital->style == GAMGI_MESA_WIRED) { glLineWidth (4.0); if (dots[1] > 0) gamgi_mesa_render_points (dots[1], orbital->points + 3 * dots[0]); if (dots[2] > 0) gamgi_mesa_render_points (dots[2], orbital->points + 3 * dots[0] + 3 * dots[1]); glLineWidth (1.0); } if (orbital->style == GAMGI_MESA_SOLID) { glDisable (GL_CULL_FACE); if (dots[1] > 0) gamgi_mesa_render_triangles (dots[1] / 3, orbital->points + 3 * dots[0]); if (dots[2] > 0) gamgi_mesa_render_triangles (dots[2] / 3, orbital->points + 3 * dots[0] + 3 * dots[1]); glEnable (GL_CULL_FACE); } if (orbital->frame == TRUE) gamgi_mesa_render_lines (orbital->lines, orbital->points); if (orbital->axes > 0.0) gamgi_mesa_axes_orbital (orbital, FALSE); glPopMatrix (); /********************** * scan orbital child * **********************/ dlist = orbital->text_start; while (dlist != NULL) { array = gamgi_mesa_pick_text (GAMGI_CAST_TEXT dlist->data, class, array); dlist = dlist->next; } if (class == GAMGI_ENGINE_ORBITAL) glColor3ubv (color_old); glPopMatrix (); return array; }
false
false
false
false
false
0
ecc_encrypt_raw (int algo, gcry_mpi_t *resarr, gcry_mpi_t k, gcry_mpi_t *pkey, int flags) { ECC_public_key pk; mpi_ec_t ctx; gcry_mpi_t result[2]; int err; (void)algo; (void)flags; if (!k || !pkey[0] || !pkey[1] || !pkey[2] || !pkey[3] || !pkey[4] || !pkey[5]) return GPG_ERR_BAD_MPI; pk.E.p = pkey[0]; pk.E.a = pkey[1]; pk.E.b = pkey[2]; point_init (&pk.E.G); err = os2ec (&pk.E.G, pkey[3]); if (err) { point_free (&pk.E.G); return err; } pk.E.n = pkey[4]; point_init (&pk.Q); err = os2ec (&pk.Q, pkey[5]); if (err) { point_free (&pk.E.G); point_free (&pk.Q); return err; } ctx = _gcry_mpi_ec_init (pk.E.p, pk.E.a); /* The following is false: assert( mpi_cmp_ui( R.x, 1 )==0 );, so */ { mpi_point_t R; /* Result that we return. */ gcry_mpi_t x, y; x = mpi_new (0); y = mpi_new (0); point_init (&R); /* R = kQ <=> R = kdG */ _gcry_mpi_ec_mul_point (&R, k, &pk.Q, ctx); if (_gcry_mpi_ec_get_affine (x, y, &R, ctx)) log_fatal ("ecdh: Failed to get affine coordinates for kdG\n"); result[0] = ec2os (x, y, pk.E.p); /* R = kG */ _gcry_mpi_ec_mul_point (&R, k, &pk.E.G, ctx); if (_gcry_mpi_ec_get_affine (x, y, &R, ctx)) log_fatal ("ecdh: Failed to get affine coordinates for kG\n"); result[1] = ec2os (x, y, pk.E.p); mpi_free (x); mpi_free (y); point_free (&R); } _gcry_mpi_ec_free (ctx); point_free (&pk.E.G); point_free (&pk.Q); if (!result[0] || !result[1]) { mpi_free (result[0]); mpi_free (result[1]); return GPG_ERR_ENOMEM; } /* Success. */ resarr[0] = result[0]; resarr[1] = result[1]; return 0; }
false
false
false
false
false
0
val2txt(double val, int mode) { static char buf[64]; double aval = fabs(val); double sval, asval; char suffix; int ddigits; switch(mode) { case 1: sprintf(buf, "% .4g", val); break; case 0: default: if (1e12 <= aval) { suffix = 'T'; sval = val / 1e12; } else if(1e9 <= aval && aval < 1e12) { suffix = 'G'; sval = val / 1e9; } else if(1e6 <= aval && aval < 1e9) { suffix = 'M'; sval = val / 1e6; } else if(1e3 <= aval && aval < 1e6) { suffix = 'K'; sval = val / 1000; } else if(1e-3 <= aval && aval < 1) { suffix = 'm'; sval = val * 1000; } else if(1e-6 <= aval && aval < 1e-3) { suffix = 'u'; sval = val * 1e6; } else if(1e-9 <= aval && aval < 1e-6) { suffix = 'n'; sval = val * 1e9; } else if(1e-12 <= aval && aval < 1e-9) { suffix = 'p'; sval = val * 1e12; } else if(1e-15 <= aval && aval < 1e-12) { suffix = 'f'; sval = val * 1e15; } else if(DBL_EPSILON < aval && aval < 1e-15) { suffix = 'a'; sval = val * 1e18; } else { suffix = ' '; sval = val; } asval = fabs(sval); if(1.0 <= asval && asval < 10.0) ddigits = 3; else if(10.0 <= asval && asval < 100.0) ddigits = 2; else ddigits = 1; sprintf(buf, "% .*f%c", ddigits, sval, suffix); break; } return buf; }
true
true
false
false
false
1
lbtf_setup_firmware(struct lbtf_private *priv) { int ret = -1; lbtf_deb_enter(LBTF_DEB_FW); /* * Read priv address from HW */ eth_broadcast_addr(priv->current_addr); ret = lbtf_update_hw_spec(priv); if (ret) { ret = -1; goto done; } lbtf_set_mac_control(priv); lbtf_set_radio_control(priv); ret = 0; done: lbtf_deb_leave_args(LBTF_DEB_FW, "ret: %d", ret); return ret; }
false
false
false
false
false
0
ms_ping(struct Client *client_p, struct Client *source_p, int parc, char *parv[]) { struct Client *target_p; const char *origin, *destination; if (parc < 2 || EmptyString(parv[1])) { sendto_one(source_p, form_str(ERR_NOORIGIN), me.name, parv[0]); return; } origin = source_p->name; destination = parv[2]; /* Will get NULL or pointer (parc >= 2!!) */ if (!EmptyString(destination) && irccmp(destination, me.name) != 0 && irccmp(destination, me.id) != 0) { if ((target_p = find_server(destination))) sendto_one(target_p,":%s PING %s :%s", parv[0], origin, destination); else { sendto_one(source_p, form_str(ERR_NOSUCHSERVER), ID_or_name(&me, client_p), parv[0], destination); return; } } else sendto_one(source_p,":%s PONG %s :%s", ID_or_name(&me, client_p), (destination) ? destination : me.name, origin); }
false
false
false
false
false
0
edge_length_q_hess(e_info) struct qinfo *e_info; { int m,j,jj,k,kk; REAL value = 0.0; REAL len,density,fudge; REAL sumgrad[2][MAXCOORD]; REAL sumhess[2][2][MAXCOORD][MAXCOORD]; REAL tang[MAXCOORD]; if ( METH_INSTANCE(e_info->method)->flags & USE_DENSITY ) density = get_edge_density(e_info->id); else density = 1.0; /* derivatives of gaussian sum part */ memset((char*)sumgrad,0,sizeof(sumgrad)); memset((char*)sumhess,0,sizeof(sumhess)); for ( m = 0 ; m < gauss1D_num ; m++ ) { for ( j = 0 ; j < SDIM ; j ++ ) { tang[j] = 0.0; for ( k = 0 ; k < edge_ctrl ; k++ ) tang[j] += gauss1polyd[k][m]*e_info->x[k][j]; } len = sqrt(SDIM_dot(tang,tang)); if ( len == 0.0 ) continue; value += gauss1Dwt[m]*len; fudge = density*gauss1Dwt[m]/len; for ( k = 0 ; k < edge_ctrl ; k++ ) for ( j = 0 ; j < SDIM ; j++ ) e_info->grad[k][j] += fudge*tang[j]*gauss1polyd[k][m]; for ( k = 0 ; k < edge_ctrl ; k++ ) for ( kk = 0 ; kk < edge_ctrl ; kk++ ) for ( j = 0 ; j < SDIM ; j++ ) for ( jj = 0 ; jj < SDIM ; jj++ ) e_info->hess[k][kk][j][jj] += fudge* ( - tang[j]*tang[jj]*gauss1polyd[k][m]*gauss1polyd[kk][m]/len/len + ((j==jj)? gauss1polyd[k][m]*gauss1polyd[kk][m] : 0.0)); } return density*value; }
false
false
false
false
false
0
mprInsertCharToBuf(MprBuf *bp, int c) { if (bp->start == bp->data) { return MPR_ERR_BAD_STATE; } *--bp->start = c; return 0; }
false
false
false
false
false
0
small_smb2_init(__le16 smb2_command, struct cifs_tcon *tcon, void **request_buf) { int rc; unsigned int total_len; struct smb2_pdu *pdu; rc = smb2_reconnect(smb2_command, tcon); if (rc) return rc; /* BB eventually switch this to SMB2 specific small buf size */ *request_buf = cifs_small_buf_get(); if (*request_buf == NULL) { /* BB should we add a retry in here if not a writepage? */ return -ENOMEM; } pdu = (struct smb2_pdu *)(*request_buf); fill_small_buf(smb2_command, tcon, get_sync_hdr(pdu), &total_len); /* Note this is only network field converted to big endian */ pdu->hdr.smb2_buf_length = cpu_to_be32(total_len); if (tcon != NULL) { #ifdef CONFIG_CIFS_STATS2 uint16_t com_code = le16_to_cpu(smb2_command); cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_sent[com_code]); #endif cifs_stats_inc(&tcon->num_smbs_sent); } return rc; }
false
false
false
false
false
0
runnerName(const QString &id) const { if (runner(id)) { return runner(id)->name(); } else { return d->advertiseSingleRunnerIds.value(id, QString()); } }
false
false
false
false
false
0
hermon_eth_close ( struct net_device *netdev ) { struct hermon_port *port = netdev->priv; struct ib_device *ibdev = port->ibdev; struct hermon *hermon = ib_get_drvdata ( ibdev ); int rc; /* Close port */ if ( ( rc = hermon_cmd_close_port ( hermon, ibdev->port ) ) != 0 ) { DBGC ( hermon, "Hermon %p port %d could not close port: %s\n", hermon, ibdev->port, strerror ( rc ) ); /* Nothing we can do about this */ } /* Tear down the queues */ ib_destroy_qp ( ibdev, port->eth_qp ); ib_destroy_cq ( ibdev, port->eth_cq ); /* Close hardware */ hermon_close ( hermon ); }
false
false
false
false
false
0
stream_get_duration_string (Stream *stream) { if (!stream) return NULL; gchar *duration, *position, *ret; if (stream->duration >= 0) { gint hour, min, sec; split_nanoseconds (stream->duration, &hour, &min, &sec); duration = g_strdup_printf ("%u:%02u:%02u", hour, min, sec); } else { duration = g_strdup_printf ("-:--:--"); } if (stream->position >= 0) { gint hour, min, sec; split_nanoseconds (stream->position, &hour, &min, &sec); position = g_strdup_printf ("%u:%02u:%02u", hour, min, sec); } else { position = g_strdup_printf ("-:--:--"); } ret = g_strdup_printf ("(%s/%s)", position, duration); g_free (duration); g_free (position); return ret; }
false
false
false
false
false
0
_regmap_raw_multi_reg_write(struct regmap *map, const struct reg_sequence *regs, size_t num_regs) { int ret; void *buf; int i; u8 *u8; size_t val_bytes = map->format.val_bytes; size_t reg_bytes = map->format.reg_bytes; size_t pad_bytes = map->format.pad_bytes; size_t pair_size = reg_bytes + pad_bytes + val_bytes; size_t len = pair_size * num_regs; if (!len) return -EINVAL; buf = kzalloc(len, GFP_KERNEL); if (!buf) return -ENOMEM; /* We have to linearise by hand. */ u8 = buf; for (i = 0; i < num_regs; i++) { unsigned int reg = regs[i].reg; unsigned int val = regs[i].def; trace_regmap_hw_write_start(map, reg, 1); map->format.format_reg(u8, reg, map->reg_shift); u8 += reg_bytes + pad_bytes; map->format.format_val(u8, val, 0); u8 += val_bytes; } u8 = buf; *u8 |= map->write_flag_mask; ret = map->bus->write(map->bus_context, buf, len); kfree(buf); for (i = 0; i < num_regs; i++) { int reg = regs[i].reg; trace_regmap_hw_write_done(map, reg, 1); } return ret; }
false
false
false
false
false
0
dialog_changed(buf, checkall) buf_T *buf; int checkall; /* may abandon all changed buffers */ { char_u buff[IOSIZE]; int ret; buf_T *buf2; dialog_msg(buff, _("Save changes to \"%s\"?"), (buf->b_fname != NULL) ? buf->b_fname : (char_u *)_("Untitled")); if (checkall) ret = vim_dialog_yesnoallcancel(VIM_QUESTION, NULL, buff, 1); else ret = vim_dialog_yesnocancel(VIM_QUESTION, NULL, buff, 1); if (ret == VIM_YES) { #ifdef FEAT_BROWSE /* May get file name, when there is none */ browse_save_fname(buf); #endif if (buf->b_fname != NULL) /* didn't hit Cancel */ (void)buf_write_all(buf, FALSE); } else if (ret == VIM_NO) { unchanged(buf, TRUE); } else if (ret == VIM_ALL) { /* * Write all modified files that can be written. * Skip readonly buffers, these need to be confirmed * individually. */ for (buf2 = firstbuf; buf2 != NULL; buf2 = buf2->b_next) { if (bufIsChanged(buf2) && (buf2->b_ffname != NULL #ifdef FEAT_BROWSE || cmdmod.browse #endif ) && !buf2->b_p_ro) { #ifdef FEAT_BROWSE /* May get file name, when there is none */ browse_save_fname(buf2); #endif if (buf2->b_fname != NULL) /* didn't hit Cancel */ (void)buf_write_all(buf2, FALSE); #ifdef FEAT_AUTOCMD /* an autocommand may have deleted the buffer */ if (!buf_valid(buf2)) buf2 = firstbuf; #endif } } } else if (ret == VIM_DISCARDALL) { /* * mark all buffers as unchanged */ for (buf2 = firstbuf; buf2 != NULL; buf2 = buf2->b_next) unchanged(buf2, TRUE); } }
false
false
false
false
false
0
rtl8723be_phy_bb_config(struct ieee80211_hw *hw) { bool rtstatus = true; struct rtl_priv *rtlpriv = rtl_priv(hw); u16 regval; u8 b_reg_hwparafile = 1; u32 tmp; u8 crystalcap = rtlpriv->efuse.crystalcap; rtl8723_phy_init_bb_rf_reg_def(hw); regval = rtl_read_word(rtlpriv, REG_SYS_FUNC_EN); rtl_write_word(rtlpriv, REG_SYS_FUNC_EN, regval | BIT(13) | BIT(0) | BIT(1)); rtl_write_byte(rtlpriv, REG_RF_CTRL, RF_EN | RF_RSTB | RF_SDMRSTB); rtl_write_byte(rtlpriv, REG_SYS_FUNC_EN, FEN_PPLL | FEN_PCIEA | FEN_DIO_PCIE | FEN_BB_GLB_RSTN | FEN_BBRSTB); tmp = rtl_read_dword(rtlpriv, 0x4c); rtl_write_dword(rtlpriv, 0x4c, tmp | BIT(23)); rtl_write_byte(rtlpriv, REG_AFE_XTAL_CTRL + 1, 0x80); if (b_reg_hwparafile == 1) rtstatus = _rtl8723be_phy_bb8723b_config_parafile(hw); crystalcap = crystalcap & 0x3F; rtl_set_bbreg(hw, REG_MAC_PHY_CTRL, 0xFFF000, (crystalcap | crystalcap << 6)); return rtstatus; }
false
false
false
false
false
0
copy_remote_gzip_file(struct remote_file *rfp, char *file, char *ttystr) { int done; char sendbuf[BUFSIZE]; char readbuf[READBUFSIZE]; char gziphdr[DATA_HDRSIZE]; char *bufptr, *p1; FILE *pipe; size_t gtot; struct stat sbuf; ulong pct, ret, req, tot, total; sprintf(readbuf, "/usr/bin/gunzip > %s", pc->namelist); if ((pipe = popen(readbuf, "w")) == NULL) error(FATAL, "cannot open pipe to create %s\n", pc->namelist); BZERO(sendbuf, BUFSIZE); sprintf(sendbuf, "READ_GZIP %ld %s", pc->rcvbufsize, rfp->filename); send(pc->sockfd, sendbuf, strlen(sendbuf), 0); bzero(readbuf, READBUFSIZE); done = total = 0; gtot = 0; while (!done) { req = pc->rcvbufsize; bufptr = readbuf; tot = 0; while (req) { ret = (ulong)recv(pc->sockfd, bufptr, req, 0); if (!tot) { if (STRNEQ(bufptr, FAILMSG)) { fprintf(fp, "copy_remote_gzip_file: %s\n", bufptr); tot = -1; break; } if (STRNEQ(bufptr, DONEMSG) || STRNEQ(bufptr, DATAMSG)) { strncpy(gziphdr, bufptr, DATA_HDRSIZE); if (CRASHDEBUG(1)) fprintf(fp, "copy_remote_gzip_file: [%s]\n", gziphdr); p1 = strtok(gziphdr, " "); /* DONE */ if (STREQ(p1, "DONE")) done = TRUE; p1 = strtok(NULL, " "); /* count */ gtot = atol(p1); total += gtot; } } req -= ret; tot += ret; bufptr += ret; } if (tot == -1) break; if (fwrite(&readbuf[DATA_HDRSIZE], sizeof(char), gtot, pipe) != gtot) error(FATAL, "fwrite to %s failed\n", pc->namelist); if (ttystr && (stat(pc->namelist, &sbuf) == 0)) { pct = (sbuf.st_size * 100)/rfp->size; fprintf(stderr, "\r%s%ld%%)%s", ttystr, pct, CRASHDEBUG(1) ? "\n" : ""); } } if (CRASHDEBUG(1)) fprintf(fp, "copy_remote_gzip_file: GZIP total: %ld\n", total); pclose(pipe); }
true
true
false
false
true
1
lol_free( LOL *lol ) { int i; for( i = 0; i < lol->count; i++ ) list_free( lol->list[i] ); lol->count = 0; }
false
false
false
false
false
0
git_repository_open_ext( git_repository **repo_ptr, const char *start_path, unsigned int flags, const char *ceiling_dirs) { int error; git_buf path = GIT_BUF_INIT, parent = GIT_BUF_INIT; git_repository *repo; if (repo_ptr) *repo_ptr = NULL; error = find_repo(&path, &parent, start_path, flags, ceiling_dirs); if (error < 0 || !repo_ptr) return error; repo = repository_alloc(); GITERR_CHECK_ALLOC(repo); repo->path_repository = git_buf_detach(&path); GITERR_CHECK_ALLOC(repo->path_repository); if ((flags & GIT_REPOSITORY_OPEN_BARE) != 0) repo->is_bare = 1; else { git_config *config = NULL; if ((error = git_repository_config_snapshot(&config, repo)) < 0 || (error = load_config_data(repo, config)) < 0 || (error = load_workdir(repo, config, &parent)) < 0) git_repository_free(repo); git_config_free(config); } if (!error) *repo_ptr = repo; git_buf_free(&parent); return error; }
false
false
false
false
false
0
LoadGeometry() { int nInvalid; #ifdef DEBUG_TIMING clock_t start, end; #endif if (m_bGeometry) return 0; nInvalid = 0; m_bGeometry = TRUE; #ifdef DEBUG_TIMING start = clock(); #endif if (m_nFeatureCount < 0) { m_poReader->ReadDataRecords(this); } if (EQUAL (m_pszName, "SOBR") || EQUAL (m_pszName, "SPOL") || EQUAL (m_pszName, "OP") || EQUAL (m_pszName, "OBPEJ") || EQUAL (m_pszName, "OB") || EQUAL (m_pszName, "OBBP")) { /* -> wkbPoint */ nInvalid = LoadGeometryPoint(); } else if (EQUAL (m_pszName, "SBP")) { /* -> wkbLineString */ nInvalid = LoadGeometryLineStringSBP(); } else if (EQUAL (m_pszName, "HP") || EQUAL (m_pszName, "DPM")) { /* -> wkbLineString */ nInvalid = LoadGeometryLineStringHP(); } else if (EQUAL (m_pszName, "PAR") || EQUAL (m_pszName, "BUD")) { /* -> wkbPolygon */ nInvalid = LoadGeometryPolygon(); } #ifdef DEBUG_TIMING end = clock(); #endif if (nInvalid > 0) { CPLError(CE_Warning, CPLE_AppDefined, "%s: %d invalid features found", m_pszName, nInvalid); } #ifdef DEBUG_TIMING CPLDebug("OGR_VFK", "VFKDataBlock::LoadGeometry(): name=%s time=%ld sec", m_pszName, (long)((end - start) / CLOCKS_PER_SEC)); #endif return nInvalid; }
false
false
false
false
false
0
zbuildfunction(i_ctx_t *i_ctx_p) { os_ptr op = osp; gs_function_t *pfn; int code = fn_build_function(i_ctx_p, op, &pfn, imemory, 0, 0); if (code < 0) return code; code = make_function_proc(i_ctx_p, op, pfn); if (code < 0) gs_function_free(pfn, true, imemory); return 0; }
false
false
false
false
true
1
IniPath(void) { cvar_t *p; if (!*_inipath) { p = gi.cvar("ininame", "action.ini", 0); if (p->string && *(p->string)) sprintf(_inipath, "%s/%s", GAMEVERSION, p->string); else sprintf(_inipath, "%s/%s", GAMEVERSION, "action.ini"); } return _inipath; }
false
false
false
false
false
0
regex_search_get_real_start (GtkSourceSearchContext *search, const GtkTextIter *start, GtkTextIter *real_start, gint *start_pos) { gint max_lookbehind = g_regex_get_max_lookbehind (search->priv->regex); *real_start = *start; for (*start_pos = 0; *start_pos < max_lookbehind; (*start_pos)++) { if (!gtk_text_iter_backward_char (real_start)) { break; } } }
false
false
false
false
false
0
structseq_contains(PyStructSequence *obj, PyObject *o) { PyObject *tup; int result; tup = make_tuple(obj); if (!tup) return -1; result = PySequence_Contains(tup, o); Py_DECREF(tup); return result; }
false
false
false
false
false
0
__ecereMethod_ProjectSettings_OnPostCreate(struct __ecereNameSpace__ecere__com__Instance * this) { struct ProjectSettings * __ecerePointer_ProjectSettings = (struct ProjectSettings *)(this ? (((char *)this) + __ecereClass_ProjectSettings->offset) : 0); __ecereMethod_ProjectSettings_UpdateDialogTitle(this); __ecereProp___ecereNameSpace__ecere__gui__controls__TabControl_Set_curTab(__ecerePointer_ProjectSettings->prjTabControl, __ecerePointer_ProjectSettings->buildTab); __ecereProp___ecereNameSpace__ecere__gui__controls__DirectoriesBox_Set_baseBrowsePath(((struct __ecereNameSpace__ecere__com__Instance *)((struct OptionBox *)(((char *)((struct CompilerTab *)(((char *)((struct BuildTab *)(((char *)__ecerePointer_ProjectSettings->buildTab + __ecereClass_BuildTab->offset)))->compilerTab + __ecereClass_CompilerTab->offset)))->includeDirs + __ecereClass_OptionBox->offset)))->editor), __ecereProp_ProjectSettings_Get_project(this)->topNode->path); __ecereProp___ecereNameSpace__ecere__gui__controls__DirectoriesBox_Set_baseBrowsePath(((struct __ecereNameSpace__ecere__com__Instance *)((struct OptionBox *)(((char *)((struct LinkerTab *)(((char *)((struct BuildTab *)(((char *)__ecerePointer_ProjectSettings->buildTab + __ecereClass_BuildTab->offset)))->linkerTab + __ecereClass_LinkerTab->offset)))->libraryDirs + __ecereClass_OptionBox->offset)))->editor), __ecereProp_ProjectSettings_Get_project(this)->topNode->path); return 0x1; }
false
false
false
false
false
0
us_midi_parser_parse( us_midi_parser_t *self, uint8_t b, us_midi_msg_t *msg ) { /* No matter what state we are currently in we must deal with bytes with the high bit set first. */ us_midi_msg_init( msg ); if ( b & 0x80 ) { /* check for system messages (>=0xf0) */ uint8_t status = ( uint8_t )( b & 0xf0 ); if ( status == 0xf0 ) { /* System messages get parsed by us_parser_system_byte() */ return us_midi_parser_system_byte( self, b, msg ); } else { /* Otherwise, this is a new status byte. */ us_midi_parser_status_byte( self, b, msg ); return false; } } else { /* Try to parse the data byte */ return us_midi_parser_data_byte( self, b, msg ); } }
false
false
false
false
false
0
Getmem(struct Global *global, int size) { /* * Get a block of free memory. */ char *result; if ((result = (char *)Malloc((unsigned) size)) == NULL) cfatal(global, FATAL_OUT_OF_MEMORY); return(result); }
false
false
false
false
false
0
addAssociatedWidget(QWidget *widget) { if(!_associatedWidgets.contains(widget)) { widget->addActions(actions()); _associatedWidgets.append(widget); connect(widget, SIGNAL(destroyed(QObject *)), SLOT(associatedWidgetDestroyed(QObject *))); } }
false
false
false
false
false
0
readSignificant() { Token t; do { t = read(); } while ((t.type() == Token::COMMENT) || (t.type() == Token::NEWLINE)); return t; }
false
false
false
false
false
0
moveto(File *f, Range r) { Posn p1 = r.p1, p2 = r.p2; f->dot.r.p1 = p1; f->dot.r.p2 = p2; if(f->rasp){ telldot(f); outTsl(Hmoveto, f->tag, f->dot.r.p1); } }
false
false
false
false
false
0
plainto_tsquery_byid(PG_FUNCTION_ARGS) { Oid cfgid = PG_GETARG_OID(0); text *in = PG_GETARG_TEXT_P(1); TSQuery query; QueryItem *res; int32 len; query = parse_tsquery(text_to_cstring(in), pushval_morph, ObjectIdGetDatum(cfgid), true); if (query->size == 0) PG_RETURN_TSQUERY(query); /* clean out any stopword placeholders from the tree */ res = clean_fakeval(GETQUERY(query), &len); if (!res) { SET_VARSIZE(query, HDRSIZETQ); query->size = 0; PG_RETURN_POINTER(query); } memcpy((void *) GETQUERY(query), (void *) res, len * sizeof(QueryItem)); /* * Removing the stopword placeholders might've resulted in fewer * QueryItems. If so, move the operands up accordingly. */ if (len != query->size) { char *oldoperand = GETOPERAND(query); int32 lenoperand = VARSIZE(query) - (oldoperand - (char *) query); Assert(len < query->size); query->size = len; memmove((void *) GETOPERAND(query), oldoperand, lenoperand); SET_VARSIZE(query, COMPUTESIZE(len, lenoperand)); } pfree(res); PG_RETURN_POINTER(query); }
false
true
false
false
false
1
print_report ( char *method, int stats [COLAMD_STATS] ) { int i1, i2, i3 ; if (!stats) { PRINTF ("%s: No statistics available.\n", method) ; return ; } i1 = stats [COLAMD_INFO1] ; i2 = stats [COLAMD_INFO2] ; i3 = stats [COLAMD_INFO3] ; if (stats [COLAMD_STATUS] >= 0) { PRINTF ("%s: OK. ", method) ; } else { PRINTF ("%s: ERROR. ", method) ; } switch (stats [COLAMD_STATUS]) { case COLAMD_OK_BUT_JUMBLED: PRINTF ("Matrix has unsorted or duplicate row indices.\n") ; PRINTF ("%s: number of duplicate or out-of-order row indices: %d\n", method, i3) ; PRINTF ("%s: last seen duplicate or out-of-order row index: %d\n", method, INDEX (i2)) ; PRINTF ("%s: last seen in column: %d", method, INDEX (i1)) ; /* no break - fall through to next case instead */ case COLAMD_OK: PRINTF ("\n") ; PRINTF ("%s: number of dense or empty rows ignored: %d\n", method, stats [COLAMD_DENSE_ROW]) ; PRINTF ("%s: number of dense or empty columns ignored: %d\n", method, stats [COLAMD_DENSE_COL]) ; PRINTF ("%s: number of garbage collections performed: %d\n", method, stats [COLAMD_DEFRAG_COUNT]) ; break ; case COLAMD_ERROR_A_not_present: PRINTF ("Array A (row indices of matrix) not present.\n") ; break ; case COLAMD_ERROR_p_not_present: PRINTF ("Array p (column pointers for matrix) not present.\n") ; break ; case COLAMD_ERROR_nrow_negative: PRINTF ("Invalid number of rows (%d).\n", i1) ; break ; case COLAMD_ERROR_ncol_negative: PRINTF ("Invalid number of columns (%d).\n", i1) ; break ; case COLAMD_ERROR_nnz_negative: PRINTF ("Invalid number of nonzero entries (%d).\n", i1) ; break ; case COLAMD_ERROR_p0_nonzero: PRINTF ("Invalid column pointer, p [0] = %d, must be zero.\n", i1) ; break ; case COLAMD_ERROR_A_too_small: PRINTF ("Array A too small.\n") ; PRINTF (" Need Alen >= %d, but given only Alen = %d.\n", i1, i2) ; break ; case COLAMD_ERROR_col_length_negative: PRINTF ("Column %d has a negative number of nonzero entries (%d).\n", INDEX (i1), i2) ; break ; case COLAMD_ERROR_row_index_out_of_bounds: PRINTF ("Row index (row %d) out of bounds (%d to %d) in column %d.\n", INDEX (i2), INDEX (0), INDEX (i3-1), INDEX (i1)) ; break ; case COLAMD_ERROR_out_of_memory: PRINTF ("Out of memory.\n") ; break ; case COLAMD_ERROR_internal_error: /* if this happens, there is a bug in the code */ PRINTF ("Internal error! Please contact authors (davis@cise.ufl.edu).\n") ; break ; } }
false
false
false
false
false
0
doprg() { if(master&0x80) { ROM_BANK16(0x8000,master&0x1F); } else { ROM_BANK8(0x8000,mapbyte2[4]); ROM_BANK8(0xa000,mapbyte2[5]); } }
false
false
false
false
false
0
libdef_func(BuildCtx *ctx, char *p, int arg) { if (arg != LIBINIT_CF) ffasmfunc++; if (ctx->mode == BUILD_libdef) { if (modstate == 0) { fprintf(stderr, "Error: no module for function definition %s\n", p); exit(1); } if (regfunc == REGFUNC_NOREG) { if (optr+1 > obuf+sizeof(obuf)) { fprintf(stderr, "Error: output buffer overflow\n"); exit(1); } *optr++ = LIBINIT_FFID; } else { if (arg != LIBINIT_ASM_) { if (modstate != 1) fprintf(ctx->fp, ",\n"); modstate = 2; fprintf(ctx->fp, " %s%s", arg ? LABEL_PREFIX_FFH : LABEL_PREFIX_CF, p); } if (regfunc != REGFUNC_NOREGUV) obuf[2]++; /* Bump hash table size. */ libdef_name(regfunc == REGFUNC_NOREGUV ? "" : p, arg); } } else if (ctx->mode == BUILD_ffdef) { fprintf(ctx->fp, "FFDEF(%s)\n", p); } else if (ctx->mode == BUILD_recdef) { if (strlen(p) > sizeof(funcname)-1) { fprintf(stderr, "Error: function name too long: '%s'\n", p); exit(1); } strcpy(funcname, p); } else if (ctx->mode == BUILD_vmdef) { int i; for (i = 1; p[i] && modname[i-1]; i++) if (p[i] == '_') p[i] = '.'; fprintf(ctx->fp, "\"%s\",\n", p); } else if (ctx->mode == BUILD_bcdef) { if (arg != LIBINIT_CF) fprintf(ctx->fp, ",\n%d", find_ffofs(ctx, p)); } ffid++; regfunc = REGFUNC_OK; }
false
true
false
false
false
1
da9062_set_suspend_voltage(struct regulator_dev *rdev, int uv) { struct da9062_regulator *regl = rdev_get_drvdata(rdev); const struct da9062_regulator_info *rinfo = regl->info; int ret, sel; sel = regulator_map_voltage_linear(rdev, uv, uv); if (sel < 0) return sel; sel <<= ffs(rdev->desc->vsel_mask) - 1; ret = regmap_update_bits(regl->hw->regmap, rinfo->suspend_vsel_reg, rdev->desc->vsel_mask, sel); return ret; }
false
false
false
false
false
0
unites_to (MOID_T * m, MOID_T * u) { /* Uniting U (m) */ MOID_T *v = NO_MOID; PACK_T *p; if (u == MODE (SIMPLIN) || u == MODE (SIMPLOUT)) { return (m); } for (p = PACK (u); p != NO_PACK; FORWARD (p)) { /* Prefer []->[] over []->FLEX [] */ if (m == MOID (p)) { v = MOID (p); } else if (v == NO_MOID && DEFLEX (m) == DEFLEX (MOID (p))) { v = MOID (p); } } return (v); }
false
false
false
false
false
0
__parport_register_driver(struct parport_driver *drv, struct module *owner, const char *mod_name) { if (list_empty(&portlist)) get_lowlevel_driver (); if (drv->devmodel) { /* using device model */ int ret; /* initialize common driver fields */ drv->driver.name = drv->name; drv->driver.bus = &parport_bus_type; drv->driver.owner = owner; drv->driver.mod_name = mod_name; ret = driver_register(&drv->driver); if (ret) return ret; mutex_lock(&registration_lock); if (drv->match_port) bus_for_each_dev(&parport_bus_type, NULL, drv, port_check); mutex_unlock(&registration_lock); } else { struct parport *port; drv->devmodel = false; mutex_lock(&registration_lock); list_for_each_entry(port, &portlist, list) drv->attach(port); list_add(&drv->list, &drivers); mutex_unlock(&registration_lock); } return 0; }
false
false
false
false
false
0
theora_dec_src_convert (GstPad * pad, GstFormat src_format, gint64 src_value, GstFormat * dest_format, gint64 * dest_value) { gboolean res = TRUE; GstTheoraDec *dec; guint64 scale = 1; if (src_format == *dest_format) { *dest_value = src_value; return TRUE; } dec = GST_THEORA_DEC (gst_pad_get_parent (pad)); /* we need the info part before we can done something */ if (!dec->have_header) goto no_header; switch (src_format) { case GST_FORMAT_BYTES: switch (*dest_format) { case GST_FORMAT_DEFAULT: *dest_value = gst_util_uint64_scale_int (src_value, 8, dec->info.pic_height * dec->info.pic_width * dec->output_bpp); break; case GST_FORMAT_TIME: /* seems like a rather silly conversion, implement me if you like */ default: res = FALSE; } break; case GST_FORMAT_TIME: switch (*dest_format) { case GST_FORMAT_BYTES: scale = dec->output_bpp * (dec->info.pic_width * dec->info.pic_height) / 8; case GST_FORMAT_DEFAULT: *dest_value = scale * gst_util_uint64_scale (src_value, dec->info.fps_numerator, dec->info.fps_denominator * GST_SECOND); break; default: res = FALSE; } break; case GST_FORMAT_DEFAULT: switch (*dest_format) { case GST_FORMAT_TIME: *dest_value = gst_util_uint64_scale (src_value, GST_SECOND * dec->info.fps_denominator, dec->info.fps_numerator); break; case GST_FORMAT_BYTES: *dest_value = gst_util_uint64_scale_int (src_value, dec->output_bpp * dec->info.pic_width * dec->info.pic_height, 8); break; default: res = FALSE; } break; default: res = FALSE; } done: gst_object_unref (dec); return res; /* ERRORS */ no_header: { GST_DEBUG_OBJECT (dec, "no header yet, cannot convert"); res = FALSE; goto done; } }
false
false
false
false
false
0
process (GeglOperation *operation, GeglBuffer *input, GeglBuffer *output, const GeglRectangle *result, gint level) { GeglChantO *o = GEGL_CHANT_PROPERTIES (operation); gint x = result->x; /* initial x */ gint y = result->y; /* and y coordinates */ gfloat *dst_buf = g_slice_alloc (result->width * result->height * 4 * sizeof(gfloat)); gfloat *out_pixel = dst_buf; GeglSampler *sampler = gegl_buffer_sampler_new (input, babl_format ("RGBA float"), o->sampler_type); gint n_pixels = result->width * result->height; while (n_pixels--) { gdouble shift; gdouble coordsx; gdouble coordsy; gdouble lambda; gdouble angle_rad = o->angle / 180.0 * G_PI; gdouble nx = x * cos (angle_rad) + y * sin (angle_rad); switch (o->wave_type) { case GEGl_RIPPLE_WAVE_TYPE_SAWTOOTH: lambda = div (nx,o->period).rem - o->phi * o->period; if (lambda < 0) lambda += o->period; shift = o->amplitude * (fabs (((lambda / o->period) * 4) - 2) - 1); break; case GEGl_RIPPLE_WAVE_TYPE_SINE: default: shift = o->amplitude * sin (2.0 * G_PI * nx / o->period + 2.0 * G_PI * o->phi); break; } coordsx = x + shift * sin (angle_rad); coordsy = y + shift * cos (angle_rad); gegl_sampler_get (sampler, coordsx, coordsy, NULL, out_pixel); out_pixel += 4; /* update x and y coordinates */ x++; if (x>=result->x + result->width) { x=result->x; y++; } } gegl_buffer_set (output, result, 0, babl_format ("RGBA float"), dst_buf, GEGL_AUTO_ROWSTRIDE); g_slice_free1 (result->width * result->height * 4 * sizeof(gfloat), dst_buf); g_object_unref (sampler); return TRUE; }
false
false
false
false
false
0
stringset_three(string_list_ty *result) { while (stringset_token == STRINGSET_WORD) { string_list_append_unique(result, stringset_token_value); stringset_lex(); } }
false
false
false
false
false
0
slgt_compat_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) { struct slgt_info *info = tty->driver_data; int rc = -ENOIOCTLCMD; if (sanity_check(info, tty->name, "compat_ioctl")) return -ENODEV; DBGINFO(("%s compat_ioctl() cmd=%08X\n", info->device_name, cmd)); switch (cmd) { case MGSL_IOCSPARAMS32: rc = set_params32(info, compat_ptr(arg)); break; case MGSL_IOCGPARAMS32: rc = get_params32(info, compat_ptr(arg)); break; case MGSL_IOCGPARAMS: case MGSL_IOCSPARAMS: case MGSL_IOCGTXIDLE: case MGSL_IOCGSTATS: case MGSL_IOCWAITEVENT: case MGSL_IOCGIF: case MGSL_IOCSGPIO: case MGSL_IOCGGPIO: case MGSL_IOCWAITGPIO: case MGSL_IOCGXSYNC: case MGSL_IOCGXCTRL: case MGSL_IOCSTXIDLE: case MGSL_IOCTXENABLE: case MGSL_IOCRXENABLE: case MGSL_IOCTXABORT: case TIOCMIWAIT: case MGSL_IOCSIF: case MGSL_IOCSXSYNC: case MGSL_IOCSXCTRL: rc = ioctl(tty, cmd, arg); break; } DBGINFO(("%s compat_ioctl() cmd=%08X rc=%d\n", info->device_name, cmd, rc)); return rc; }
false
false
false
false
false
0
init_from_mem_pool(int data_size) { master_pos = uint8korr(mem_pool + SL_MASTER_POS_OFFSET); master_port = uint2korr(mem_pool + SL_MASTER_PORT_OFFSET); master_host = mem_pool + SL_MASTER_HOST_OFFSET; master_host_len = (uint) strlen(master_host); // safety master_log = master_host + master_host_len + 1; if (master_log > mem_pool + data_size) { master_host = 0; return; } master_log_len = (uint) strlen(master_log); }
false
false
false
false
false
0
rwm_op_bind( Operation *op, SlapReply *rs ) { slap_overinst *on = (slap_overinst *) op->o_bd->bd_info; int rc; rwm_op_cb *roc = rwm_callback_get( op ); rc = rwm_op_dn_massage( op, rs, "bindDN", &roc->ros ); if ( rc != LDAP_SUCCESS ) { op->o_bd->bd_info = (BackendInfo *)on->on_info; send_ldap_error( op, rs, rc, "bindDN massage error" ); return -1; } overlay_callback_after_backover( op, &roc->cb, 1 ); return SLAP_CB_CONTINUE; }
false
false
false
false
false
0
value_is_empty(const Gnome::Gda::Value& value) { if(value.is_null()) return true; switch(value.get_value_type()) { case(0): return true; //Empty and invalid. It has not been initalized with a type. case(G_TYPE_STRING): return value.get_string().empty(); default: return false; //None of the other types can be empty. (An empty numeric, date, or time type shows up as a GDA_TYPE_NULL). } }
false
false
false
false
false
0
cib_process_default(const char *op, int options, const char *section, xmlNode * req, xmlNode * input, xmlNode * existing_cib, xmlNode ** result_cib, xmlNode ** answer) { int result = pcmk_ok; crm_trace("Processing \"%s\" event", op); *answer = NULL; if (op == NULL) { result = -EINVAL; crm_err("No operation specified"); } else if (strcasecmp(CRM_OP_NOOP, op) == 0) { ; } else { result = -EPROTONOSUPPORT; crm_err("Action [%s] is not supported by the CIB", op); } return result; }
false
false
false
false
false
0