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
initialize(ErrorHandler *errh) { struct sockaddr_in sin; // open socket, set options, bind to address _fd = socket(PF_INET, SOCK_RAW, _protocol); if (_fd < 0) return initialize_socket_error(errh, "socket"); if (_port) { memset(&sin, 0, sizeof(sin)); sin.sin_family = PF_INET; sin.sin_port = htons(_port); sin.sin_addr = inet_makeaddr(0, 0); // bind to port #ifdef HAVE_PROPER int ret = -1; if (_proper) { ret = prop_bind_socket(_fd, (struct sockaddr *)&sin, sizeof(sin)); if (ret < 0) errh->warning("prop_bind_socket: %s", strerror(errno)); } if (ret < 0) #endif if (bind(_fd, (struct sockaddr *)&sin, sizeof(sin)) < 0) return initialize_socket_error(errh, "bind"); } // nonblocking I/O and close-on-exec for the socket fcntl(_fd, F_SETFL, O_NONBLOCK); fcntl(_fd, F_SETFD, FD_CLOEXEC); // include IP header int one = 1; if (setsockopt(_fd, 0, IP_HDRINCL, &one, sizeof(one)) < 0) return initialize_socket_error(errh, "IP_HDRINCL"); if (noutputs()) add_select(_fd, SELECT_READ); if (ninputs()) { ScheduleInfo::join_scheduler(this, &_task, errh); _signal = Notifier::upstream_empty_signal(this, 0, &_task); add_select(_fd, SELECT_WRITE); _timer.initialize(this); } return 0; }
false
false
false
false
false
0
w4_str(int fd, char *str) { char buf[40]; unsigned len = 0; int r; while (1) { r = read(fd, buf + len, sizeof(buf) - len - 1); if (r < 0) { if (errno == EINTR || errno == EAGAIN) continue; break; } if (!r) break; len += r; if (len < strlen(str)) continue; buf[len] = 0; if (strstr(buf, str)) return MS_SUCCESS; /* Detect PPP */ if (strchr(buf, '~')) return MS_PPP; } return MS_FAILED; }
true
true
false
false
true
1
usbpn_set_mtu(struct net_device *dev, int new_mtu) { if ((new_mtu < PHONET_MIN_MTU) || (new_mtu > PHONET_MAX_MTU)) return -EINVAL; dev->mtu = new_mtu; return 0; }
false
false
false
false
false
0
gl_view_object_create_mode (glView *view, glLabelObjectType type) { GdkWindow *window; GdkCursor *cursor = NULL; gl_debug (DEBUG_VIEW, "START"); g_return_if_fail (view && GL_IS_VIEW (view)); window = gtk_widget_get_window (view->canvas); switch (type) { case GL_LABEL_OBJECT_BOX: cursor = gl_view_box_get_create_cursor (); break; case GL_LABEL_OBJECT_ELLIPSE: cursor = gl_view_ellipse_get_create_cursor (); break; case GL_LABEL_OBJECT_LINE: cursor = gl_view_line_get_create_cursor (); break; case GL_LABEL_OBJECT_IMAGE: cursor = gl_view_image_get_create_cursor (); break; case GL_LABEL_OBJECT_TEXT: cursor = gl_view_text_get_create_cursor (); break; case GL_LABEL_OBJECT_BARCODE: cursor = gl_view_barcode_get_create_cursor (); break; default: g_message ("Invalid label object type.");/*Should not happen!*/ break; } gdk_window_set_cursor (window, cursor); gdk_cursor_unref (cursor); view->mode = GL_VIEW_MODE_OBJECT_CREATE; view->state = GL_VIEW_IDLE; view->create_type = type; gl_debug (DEBUG_VIEW, "END"); }
false
false
false
false
false
0
new_url_t(const char *url_str) { struct url_t *url = NULL; char *pre = NULL,*post = NULL; char *server_part = NULL; char *path_part = NULL; char *user_pass = NULL; char *host_port = NULL; if(!strstr(url_str,"://")) { return NULL; /* invalid url*/ } url = (struct url_t *)xmalloc(sizeof(struct url_t)); /* exmp://foo.bar.com/example/hoge.asf */ url->url = strdup(url_str); string_separate(url->url,"://",&pre,&post); if(pre) { url->protocol = strdup(pre); url->file = strdup(post); free(pre); free(post); string_separate(url->file,"/",&pre,&post); if(pre) { server_part = strdup(pre); path_part = strdup(post); free(pre); free(post); } else { server_part = strdup(url->file); } } /* interpret server_part */ if(server_part) { string_separate(server_part,"@",&pre,&post); if(pre) { /* user[:pass]'@'host[:port] */ user_pass = strdup(pre); host_port = strdup(post); free(pre); free(post); } else { /* host[:port] */ host_port = strdup(server_part); } /* interpret user_pass */ if(user_pass) { string_separate(user_pass,":",&pre,&post); if(pre) { url->username = strdup(pre); url->password = strdup(post); free(pre); free(post); } else { url->username = strdup(user_pass); } } /* interpret host_port */ if(host_port) { string_separate(host_port,":",&pre,&post); if(pre) { url->hostname = strdup(pre); url->port = atoi(post); free(pre); free(post); } else { url->hostname = strdup(host_port); url->port = 0; } } } /* interpret path_part */ if(path_part) { int len = strlen(path_part) + 2; url->filepath = xmalloc(len); strncpy(url->filepath,"/",len); strncat(url->filepath,path_part,len); } url->protocol_type = protocol_type_from_string(url->protocol); /* printf("url :%s\n" "prot:%s\n" "host:%s\n" "port:%d\n" "file:%s\n" "path:%s\n" "type:%d\n" "user:%s\n" "pass:%s\n" ,url->url,url->protocol,url->hostname,url->port,url->file,url->filepath,url->protocol_type, url->username,url->password); */ if(server_part) free(server_part); if(path_part) free(path_part); if(user_pass) free(user_pass); if(host_port) free(host_port); return url; }
false
false
false
false
false
0
ContinuePipe () { char RealCommand[2048]; size_t space; if (!OnFilesPos) { // At the end of all files, terminate ClosePipe (); return 0; } else if (Running) { // Already running, close the pipe and continue ReturnCode=gui->ClosePipe (PipeId); } else { // Not running -> set to Running mode Running=1; } // Make real command with some files from OnFiles, update OnFilesPos strcat (strcpy (RealCommand,Command)," "); space=sizeof (RealCommand)-strlen (RealCommand)-1; if (space>=strlen (OnFilesPos)) { strcat (RealCommand,OnFilesPos); OnFilesPos=NULL; } else { char c=OnFilesPos[space]; OnFilesPos[space]=0; char *s=strrchr (OnFilesPos,' '); OnFilesPos[space]=c; if (!s) { ClosePipe (); return 0; } *s=0; strcat (RealCommand,OnFilesPos); OnFilesPos=s+1; while (*OnFilesPos==' ') OnFilesPos++; if (!*OnFilesPos) OnFilesPos=NULL; } BufLen=BufPos=0; { char s[sizeof (RealCommand)+32]; sprintf (s,"[continuing: '%s']",RealCommand); AddLine (0,-1,s); } PipeId=gui->OpenPipe (RealCommand,this); return 0; }
false
false
false
false
false
0
uih_command(struct uih_context *uih, const char *command) { errstring = NULL; uih->playpos = 0; uih->playstring = command; uih_processcommand(uih, (uih->play ? MENUFLAG_NOMENU : 0)); uih->playstring = NULL; if (errstring != NULL) { uih_error(uih, errstring); } }
false
false
false
false
false
0
select_kernel(CHAR16 *buffer, INTN size) { #define CHAR_CTRL_C L'\003' /* Unicode CTRL-C */ #define CHAR_CTRL_D L'\004' /* Unicode CTRL-D */ #define CHAR_CTRL_U L'\025' /* Unicode CTRL-U */ //#define CHAR_TAB L'\t' SIMPLE_INPUT_INTERFACE *ip = systab->ConIn; EFI_INPUT_KEY key; EFI_STATUS status; INTN pos = 0, ret; INT8 first_time = 1; /* * let's give some help first */ print_help(0); print_infos(0); reprint: buffer[pos] = CHAR_NULL; Print(L"\nELILO boot: %s", buffer); /* * autoboot with default choice after timeout expires */ if (first_time && (ret=wait_timeout(elilo_opt.timeout)) != 1) { return ret == -1 ? -1: 0; } first_time = 0; for (;;) { while ((status = uefi_call_wrapper(ip->ReadKeyStroke, 2, ip, &key)) == EFI_NOT_READY); if (EFI_ERROR(status)) { ERR_PRT((L"select_kernel readkey: %r", status)); return -1; } switch (key.UnicodeChar) { case CHAR_TAB: Print(L"\n"); if (pos == 0) { print_label_list(); Print(L"(or a kernel file name: [[dev_name:/]path/]kernel_image cmdline options)\n"); } else { buffer[pos] = CHAR_NULL; display_label_info(buffer); } goto reprint; case L'%': if (pos>0) goto normal_char; Print(L"\n"); print_vars(); goto reprint; case L'?': if (pos>0) goto normal_char; Print(L"\n"); print_help(1); goto reprint; case L'&': if (pos>0) goto normal_char; Print(L"\n"); print_infos(1); goto reprint; case L'=': if (pos>0) goto normal_char; Print(L"\n"); print_devices(); goto reprint; case CHAR_BACKSPACE: if (pos == 0) break; pos--; Print(L"\b \b"); break; case CHAR_CTRL_U: /* clear line */ while (pos) { Print(L"\b \b"); pos--; } break; case CHAR_CTRL_C: /* kill line */ pos = 0; goto reprint; case CHAR_LINEFEED: case CHAR_CARRIAGE_RETURN: buffer[pos] = CHAR_NULL; Print(L"\n"); return 0; default: normal_char: if (key.UnicodeChar == CHAR_CTRL_D || key.ScanCode == 0x17 ) { Print(L"\nGiving up then...\n"); return -1; } if (key.UnicodeChar == CHAR_NULL) break; if (pos > size-1) break; buffer[pos++] = key.UnicodeChar; /* Write the character out */ Print(L"%c", key.UnicodeChar); } } return 0; }
false
false
false
false
false
0
get_text_align_max_fill_size (int align_pow, bfd_boolean use_nops, bfd_boolean use_no_density) { if (!use_nops) return (1 << align_pow); if (use_no_density) return 3 * (1 << align_pow); return 1 + (1 << align_pow); }
false
false
false
false
false
0
Sop_alut44_SKto_Dacc( GenefxState *gfxs ) { int w = gfxs->length; int i = gfxs->Xphase; int SperD = gfxs->SperD; GenefxAccumulator *D = gfxs->Dacc; u8 *S = gfxs->Sop[0]; u32 Skey = gfxs->Skey; DFBColor *entries = gfxs->Slut->entries; while (w--) { u8 s = S[i>>16]; if ((s & 0x0F) != Skey) { D->RGB.a = ((s & 0xF0) >> 4) | (s & 0xF0); s &= 0x0F; D->RGB.r = entries[s].r; D->RGB.g = entries[s].g; D->RGB.b = entries[s].b; } else D->RGB.a = 0xF000; i += SperD; D++; } }
false
false
false
false
false
0
pushutfchar (lua_State *L, int arg) { lua_Integer code = luaL_checkinteger(L, arg); luaL_argcheck(L, 0 <= code && code <= MAXUNICODE, arg, "value out of range"); lua_pushfstring(L, "%U", (long)code); }
false
false
false
false
false
0
matchPair(MachineBasicBlock::const_succ_iterator i, const MachineBasicBlock *a, const MachineBasicBlock *b) { if (*i == a) return *++i == b; if (*i == b) return *++i == a; return false; }
false
false
false
false
false
0
cyttsp_report_tchdata(struct cyttsp *ts) { struct cyttsp_xydata *xy_data = &ts->xy_data; struct input_dev *input = ts->input; int num_tch = GET_NUM_TOUCHES(xy_data->tt_stat); const struct cyttsp_tch *tch; int ids[CY_MAX_ID]; int i; DECLARE_BITMAP(used, CY_MAX_ID); if (IS_LARGE_AREA(xy_data->tt_stat) == 1) { /* terminate all active tracks */ num_tch = 0; dev_dbg(ts->dev, "%s: Large area detected\n", __func__); } else if (num_tch > CY_MAX_FINGER) { /* terminate all active tracks */ num_tch = 0; dev_dbg(ts->dev, "%s: Num touch error detected\n", __func__); } else if (IS_BAD_PKT(xy_data->tt_mode)) { /* terminate all active tracks */ num_tch = 0; dev_dbg(ts->dev, "%s: Invalid buffer detected\n", __func__); } cyttsp_extract_track_ids(xy_data, ids); bitmap_zero(used, CY_MAX_ID); for (i = 0; i < num_tch; i++) { tch = cyttsp_get_tch(xy_data, i); input_mt_slot(input, ids[i]); input_mt_report_slot_state(input, MT_TOOL_FINGER, true); input_report_abs(input, ABS_MT_POSITION_X, be16_to_cpu(tch->x)); input_report_abs(input, ABS_MT_POSITION_Y, be16_to_cpu(tch->y)); input_report_abs(input, ABS_MT_TOUCH_MAJOR, tch->z); __set_bit(ids[i], used); } for (i = 0; i < CY_MAX_ID; i++) { if (test_bit(i, used)) continue; input_mt_slot(input, i); input_mt_report_slot_state(input, MT_TOOL_FINGER, false); } input_sync(input); }
false
false
false
false
false
0
processevent(evdev_t *evdev, fd_set *permset) { struct input_event event; char message[1000]; int len; client_t *client, *prev, *next; if(read(evdev->fd, &event, sizeof event) != sizeof event) { syslog(LOG_ERR, "Error processing event from %s: %s\n", evdev->name, strerror(errno)); FD_CLR(evdev->fd, permset); close(evdev->fd); evdev->fd = -999; return; } if(event.type != EV_KEY) return; if(event.code > KEY_MAX || event.code < key_min) return; if(capture_modifiers) { if(event.code == KEY_LEFTCTRL || event.code == KEY_RIGHTCTRL) { ctrl = !!event.value; return; } if(event.code == KEY_LEFTSHIFT || event.code == KEY_RIGHTSHIFT) { shift = !!event.value; return; } if(event.code == KEY_LEFTALT || event.code == KEY_RIGHTALT) { alt = !!event.value; return; } if(event.code == KEY_LEFTMETA || event.code == KEY_RIGHTMETA) { meta = !!event.value; return; } } if(!event.value) return; struct timeval current; gettimeofday(&current, NULL); if(event.code == previous_event.code && time_elapsed(&previous_input, &current) < repeat_time) repeat++; else repeat = 0; if(KEY_NAME[event.code]) len = snprintf(message, sizeof message, "%x %x %s%s%s%s%s %s\n", event.code, repeat, ctrl ? "CTRL_" : "", shift ? "SHIFT_" : "", alt ? "ALT_" : "", meta ? "META_" : "", KEY_NAME[event.code], evdev->name); else len = snprintf(message, sizeof message, "%x %x KEY_CODE_%d %s\n", event.code, repeat, event.code, evdev->name); previous_input = current; previous_event = event; for(client = clients; client; client = client->next) { if(write(client->fd, message, len) != len) { close(client->fd); client->fd = -1; } } for(prev = NULL, client = clients; client; client = next) { next = client->next; if(client->fd < 0) { if(prev) prev->next = client->next; else clients = client->next; free(client); } else { prev = client; } } }
false
false
false
false
false
0
setTimeout(int t) { if (m_timeout != t) { log_debug("set timeout " << t << ", fd=" << getFd() << ", previous=" << m_timeout); if (getFd() >= 0 && ((t >= 0 && m_timeout < 0) || (t < 0 && m_timeout >= 0))) { long a = t >= 0 ? O_NONBLOCK : 0; log_debug("fcntl(" << getFd() << ", F_SETFL, " << a << ')'); int ret = fcntl(getFd(), F_SETFL, a); if (ret < 0) throw SystemError("fcntl"); } m_timeout = t; } }
false
false
false
false
false
0
xsh_verify_2dmap_poly_input(cpl_frame* order_tab_edges_frame, cpl_frame* spectralformat_frame, cpl_frame* theo_tab_frame) { cpl_table* tab_edges=NULL; cpl_table* tab_spectral_format=NULL; cpl_table* theo_tab=NULL; const char* name=NULL; int ord_min_ref=0; int ord_max_ref=0; int ord_min=0; int ord_max=0; check(name=cpl_frame_get_filename(order_tab_edges_frame)); check(tab_edges=cpl_table_load(name,1,0)); check(ord_min_ref=cpl_table_get_column_min(tab_edges,"ABSORDER")); check(ord_max_ref=cpl_table_get_column_max(tab_edges,"ABSORDER")); check(name=cpl_frame_get_filename(spectralformat_frame)); check(tab_spectral_format=cpl_table_load(name,1,0)); check(ord_min=cpl_table_get_column_min(tab_spectral_format,"ORDER")); check(ord_max=cpl_table_get_column_max(tab_spectral_format,"ORDER")); if(ord_min != ord_min_ref) { xsh_msg_error("Edge order table's ord_min != spectral format table's ord_min"); return CPL_ERROR_INCOMPATIBLE_INPUT; } if(ord_max != ord_max_ref) { xsh_msg_error("Edge order table's ord_max != spectral format table's ord_max"); return CPL_ERROR_INCOMPATIBLE_INPUT; } if(theo_tab_frame != NULL) { check(name=cpl_frame_get_filename(theo_tab_frame)); check(theo_tab=cpl_table_load(name,1,0)); check(ord_min=cpl_table_get_column_min(theo_tab,"Order")); check(ord_max=cpl_table_get_column_max(theo_tab,"Order")); if(ord_min != ord_min_ref) { xsh_msg_error("Theo table's ord_min != spectral format table's ord_min"); return CPL_ERROR_INCOMPATIBLE_INPUT; } if(ord_max != ord_max_ref) { xsh_msg_error("Theo table's ord_max != spectral format table's ord_max"); return CPL_ERROR_INCOMPATIBLE_INPUT; } } cleanup: xsh_free_table(&tab_edges); xsh_free_table(&tab_spectral_format); xsh_free_table(&theo_tab); return cpl_error_get_code(); }
false
false
false
false
false
0
crypto_init_spawn2(struct crypto_spawn *spawn, struct crypto_alg *alg, struct crypto_instance *inst, const struct crypto_type *frontend) { int err = -EINVAL; if ((alg->cra_flags ^ frontend->type) & frontend->maskset) goto out; spawn->frontend = frontend; err = crypto_init_spawn(spawn, alg, inst, frontend->maskset); out: return err; }
false
false
false
false
false
0
makeInvoke (const std::string &method, std::vector<std::string> args) { std::stringstream ss; std::vector<std::string>::iterator it; ss << "<invoke name=\"" << method << "\" returntype=\"xml\">"; ss << "<arguments>"; for (it=args.begin(); it != args.end(); ++it) { ss << *it; } ss << "</arguments>"; ss << "</invoke>"; // Add a CR on the end so the output is more readable on the other // end. XL should be ignoring the CR anyway. ss << std::endl; return ss.str(); }
false
false
false
false
false
0
SendAIEventAround(AIEventType eventType, Unit* pInvoker, uint32 uiDelay, float fRadius, uint32 miscValue /*=0*/) const { if (fRadius > 0) { std::list<Creature*> receiverList; // Allow sending custom AI events to all units in range if (eventType == AI_EVENT_CUSTOM_EVENTAI_A || eventType == AI_EVENT_CUSTOM_EVENTAI_B) { MaNGOS::AnyUnitInObjectRangeCheck u_check(m_creature, fRadius); MaNGOS::CreatureListSearcher<MaNGOS::AnyUnitInObjectRangeCheck> searcher(receiverList, u_check); Cell::VisitGridObjects(m_creature, searcher, fRadius); } else { // Use this check here to collect only assitable creatures in case of CALL_ASSISTANCE, else be less strict MaNGOS::AnyAssistCreatureInRangeCheck u_check(m_creature, eventType == AI_EVENT_CALL_ASSISTANCE ? pInvoker : NULL, fRadius); MaNGOS::CreatureListSearcher<MaNGOS::AnyAssistCreatureInRangeCheck> searcher(receiverList, u_check); Cell::VisitGridObjects(m_creature, searcher, fRadius); } if (!receiverList.empty()) { AiDelayEventAround* e = new AiDelayEventAround(eventType, pInvoker ? pInvoker->GetObjectGuid() : ObjectGuid(), *m_creature, receiverList, miscValue); m_creature->m_Events.AddEvent(e, m_creature->m_Events.CalculateTime(uiDelay)); } } }
false
false
false
false
false
0
DSA_sign(int type, const unsigned char *dgst, int dlen, unsigned char *sig, unsigned int *siglen, DSA *dsa) { DSA_SIG *s; RAND_seed(dgst, dlen); s=DSA_do_sign(dgst,dlen,dsa); if (s == NULL) { *siglen=0; return(0); } *siglen=i2d_DSA_SIG(s,&sig); DSA_SIG_free(s); return(1); }
false
false
false
false
false
0
rule_top (GtkWidget *widget, ERuleEditor *editor) { gint pos; update_selected_rule (editor); pos = e_rule_context_get_rank_rule ( editor->context, editor->current, editor->source); if (pos > 0) rule_move (editor, pos, 0); }
false
false
false
false
false
0
makeBranchSubNode(int32_t start, int32_t limit, int32_t unitIndex, int32_t length, UErrorCode &errorCode) { if(U_FAILURE(errorCode)) { return NULL; } UChar middleUnits[kMaxSplitBranchLevels]; Node *lessThan[kMaxSplitBranchLevels]; int32_t ltLength=0; while(length>getMaxBranchLinearSubNodeLength()) { // Branch on the middle unit. // First, find the middle unit. int32_t i=skipElementsBySomeUnits(start, unitIndex, length/2); // Create the less-than branch. middleUnits[ltLength]=getElementUnit(i, unitIndex); // middle unit lessThan[ltLength]=makeBranchSubNode(start, i, unitIndex, length/2, errorCode); ++ltLength; // Continue for the greater-or-equal branch. start=i; length=length-length/2; } if(U_FAILURE(errorCode)) { return NULL; } ListBranchNode *listNode=new ListBranchNode(); if(listNode==NULL) { errorCode=U_MEMORY_ALLOCATION_ERROR; return NULL; } // For each unit, find its elements array start and whether it has a final value. int32_t unitNumber=0; do { int32_t i=start; UChar unit=getElementUnit(i++, unitIndex); i=indexOfElementWithNextUnit(i, unitIndex, unit); if(start==i-1 && unitIndex+1==getElementStringLength(start)) { listNode->add(unit, getElementValue(start)); } else { listNode->add(unit, makeNode(start, i, unitIndex+1, errorCode)); } start=i; } while(++unitNumber<length-1); // unitNumber==length-1, and the maxUnit elements range is [start..limit[ UChar unit=getElementUnit(start, unitIndex); if(start==limit-1 && unitIndex+1==getElementStringLength(start)) { listNode->add(unit, getElementValue(start)); } else { listNode->add(unit, makeNode(start, limit, unitIndex+1, errorCode)); } Node *node=registerNode(listNode, errorCode); // Create the split-branch nodes. while(ltLength>0) { --ltLength; node=registerNode( new SplitBranchNode(middleUnits[ltLength], lessThan[ltLength], node), errorCode); } return node; }
false
false
false
false
false
0
doelectricity (void) { int leftelectrax; int rightelectrax; int temp; int n; if (levelinfo.electrasflag && levelinfo.electraoffset == 0) // When electra enemies ride over the main lightning... { for (n = 0; n < MAX_ENEMIES; n++) { if (enemy[n].exists && enemy[n].type == ELECTRA && enemy[enemy[n].intvar].exists) // If both electras exist... { leftelectrax = enemy[n].x; rightelectrax = enemy[enemy[n].intvar].x; if (rightelectrax < leftelectrax) { temp = leftelectrax; leftelectrax = rightelectrax; rightelectrax = temp; } drawelectricity(LIGHTNINGADJUST, lightningy, leftelectrax, NO); drawelectricity(rightelectrax, lightningy, WIDTH - LIGHTNINGADJUST, NO); return; } } } drawelectricity(LIGHTNINGADJUST, lightningy, WIDTH - LIGHTNINGADJUST, NO); return; }
false
false
false
false
false
0
ReadGifComment(GifComment, MemGif2) GIFCOMMENT *GifComment; /* Pointer to GIF Comment Extension structure */ BYTE **MemGif2; /* GIF image file input FILE stream */ { /* Read in the Plain Text data sub-blocks */ if (!(GifComment->CommentData = ReadDataSubBlocks(MemGif2 , &(GifComment->DataSize)))) return(1); GifComment->Terminator = 0; return(0); /* No FILE stream error occured */ }
false
false
false
false
false
0
select_earliest_finish_slot(Task *task, List *slotlist) { int pgno = task->TaskexePro[task->SelectTask]; int i; List *li; IntSet assigned; int bmax = get_max_block_no(task->block[1]); construct_IntSet(assigned, bmax + 1); for (i = 0; i < task->assigns[pgno]; i++) { add1_IntSet(assigned, task->assign[pgno][i]); for (li = slotlist; li != NULL; li = li->next) { Slot *slot = li->data; if (test_subtract_IntSet(slot->assigned_block, assigned) == 0) { return slot; } } } destruct_IntSet(assigned); fatal("Unexpected Situation\n"); return NULL; }
false
false
false
false
false
0
initCopyDict() // //////////////////////////////////////////////////////////////////////// { if (copyDictList == NULL) copyDictList = new SbPList; SbDict *copyDict = new SbDict; // Insert the new dictionary at the beginning. Since most copies // are non-recursive, having to make room in the list won't happen // too frequently. Accessing the list happens a lot, so using slot // 0 will speed that up some. copyDictList->insert(copyDict, 0); }
false
false
false
false
false
0
tvp7002_s_stream(struct v4l2_subdev *sd, int enable) { struct tvp7002 *device = to_tvp7002(sd); int error; if (device->streaming == enable) return 0; /* low impedance: on, high impedance: off */ error = tvp7002_write(sd, TVP7002_MISC_CTL_2, enable ? 0x00 : 0x03); if (error) { v4l2_dbg(1, debug, sd, "Fail to set streaming\n"); return error; } device->streaming = enable; return 0; }
false
false
false
false
false
0
typeToString(const int type) const { switch (type) { case Calendar::People::PeopleAttendee: return tkTr(Trans::Constants::ATTENDEE); case Calendar::People::PeopleOwner: return tkTr(Trans::Constants::OWNER); case Calendar::People::PeopleUser: return tkTr(Trans::Constants::USER); case Calendar::People::PeopleUserDelegate: return tkTr(Trans::Constants::USER_DELEGATES); } return QString(); }
false
false
false
false
false
0
_bdf_set_glyph_names(FILE *in, bdf_font_t *font, bdf_callback_t callback, int adobe) #else _bdf_set_glyph_names(in, font, callback, adobe) FILE *in; bdf_font_t *font; bdf_callback_t callback; int adobe; #endif { int changed; long i, size, len; bdf_glyph_t *gp; bdf_callback_struct_t cb; char name[MAX_GLYPH_NAME_LEN + 1]; if (callback != 0) { cb.reason = BDF_GLYPH_NAME_START; cb.current = 0; cb.total = font->glyphs_used; (*callback)(&cb, 0); } for (changed = 0, i = 0, gp = font->glyphs; i < font->glyphs_used; i++, gp++) { size = (adobe) ? _bdf_find_adobe_name(gp->encoding, name, in) : _bdf_find_name(gp->encoding, name, in); if (size < 0) continue; len = (gp->name) ? strlen(gp->name) : 0; if (len == 0) { gp->name = (char *) _bdf_strdup((unsigned char *) name, size + 1); changed = 1; } else if (size != len || strcmp(gp->name, name) != 0) { /* * Simply resize existing storage so lots of memory allocations * are not needed. */ if (size > len) gp->name = (char *) realloc(gp->name, size + 1); (void) strcpy(gp->name, name); changed = 1; } if (callback != 0) { cb.reason = BDF_GLYPH_NAME; cb.current = i; (*callback)(&cb, 0); } } if (callback != 0) { cb.reason = BDF_GLYPH_NAME; cb.current = cb.total; (*callback)(&cb, 0); } return changed; }
false
false
false
false
false
0
cont_scroll(Widget gw, XEvent *event, String *params, Cardinal *no_params) { ScrBarWidget w = (ScrBarWidget)gw; int x, y, dc, length; if (w->scrbar.mode != ScrBarModeContinuous) return; if (!get_event_xy(event, &x, &y)) { XBell(XtDisplay(w), 0); return; } length = w->scrbar.c4 - w->scrbar.c1; if (length <= 0) return; dc = (w->scrbar.vertical ? y : x ) - w->scrbar.init_ptr_pos; w->scrbar.slider_position = w->scrbar.init_slider_pos + dc * w->scrbar.canvas_length / length; fit_scrbar(w); calc_scrbar_coords(w); draw_thumb(w, NULL); send_scroll_report(w); }
false
false
false
false
false
0
__ecereMethod___ecereNameSpace__ecere__gui__controls__Button_OnLeftDoubleClick(struct __ecereNameSpace__ecere__com__Instance * this, int x, int y, unsigned int mods) { struct __ecereNameSpace__ecere__gui__controls__Button * __ecerePointer___ecereNameSpace__ecere__gui__controls__Button = (struct __ecereNameSpace__ecere__gui__controls__Button *)(this ? (((char *)this) + __ecereClass___ecereNameSpace__ecere__gui__controls__Button->offset) : 0); return ((unsigned int (*)(struct __ecereNameSpace__ecere__com__Instance *, struct __ecereNameSpace__ecere__com__Instance * button, int x, int y, unsigned int mods))__extension__ ({ struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = this; __internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__gui__controls__Button->_vTbl; })[__ecereVMethodID___ecereNameSpace__ecere__gui__controls__Button_NotifyDoubleClick])(__ecereProp___ecereNameSpace__ecere__gui__Window_Get_master(this), this, x, y, mods); }
false
false
false
false
false
0
GC_delete_thread(pthread_t id) { int hv = ((word)id) % THREAD_TABLE_SZ; register GC_thread p = GC_threads[hv]; register GC_thread prev = 0; while (!pthread_equal(p -> id, id)) { prev = p; p = p -> next; } if (prev == 0) { GC_threads[hv] = p -> next; } else { prev -> next = p -> next; } #ifdef GC_DARWIN_THREADS mach_port_deallocate(mach_task_self(), p->stop_info.mach_thread); #endif GC_INTERNAL_FREE(p); }
false
false
false
false
false
0
DataCompare(DATE left, DATE right) { if (left[YEAR] > right[YEAR]) return 0; else if (left[YEAR] < right[YEAR]) return 2; else if (left[YEAR] == right[YEAR]) { if (left[MONTH] > right[MONTH]) return 0; else if (left[MONTH] < right[MONTH]) return 2; else if (left[MONTH] == right[MONTH]) { if (left[DAY] > right[DAY]) return 0; else if (left[DAY] < right[DAY]) return 2; } } return 1; }
false
false
false
false
false
0
test_generate_key_pair (Test *test, gconstpointer unused) { GckMechanism mech = { CKM_MOCK_GENERATE, (guchar *)"generate", 9 }; GckBuilder builder = GCK_BUILDER_INIT; GckAttributes *pub_attrs, *prv_attrs; GError *error = NULL; GAsyncResult *result = NULL; GckObject *pub_key, *prv_key; gboolean ret; gck_builder_add_ulong (&builder, CKA_CLASS, CKO_PUBLIC_KEY); pub_attrs = gck_attributes_ref_sink (gck_builder_end (&builder)); gck_builder_add_ulong (&builder, CKA_CLASS, CKO_PRIVATE_KEY); prv_attrs = gck_attributes_ref_sink (gck_builder_end (&builder)); /* Full One*/ ret = gck_session_generate_key_pair_full (test->session, &mech, pub_attrs, prv_attrs, &pub_key, &prv_key, NULL, &error); g_assert_no_error (error); g_assert (ret); g_object_unref (pub_key); g_object_unref (prv_key); /* Failure one */ mech.type = 0; pub_key = prv_key = NULL; ret = gck_session_generate_key_pair_full (test->session, &mech, pub_attrs, prv_attrs, &pub_key, &prv_key, NULL, &error); g_assert (error != NULL); g_assert (!ret); g_clear_error (&error); g_assert (pub_key == NULL); g_assert (prv_key == NULL); /* Asynchronous one */ mech.type = CKM_MOCK_GENERATE; gck_session_generate_key_pair_async (test->session, &mech, pub_attrs, prv_attrs, NULL, fetch_async_result, &result); egg_test_wait_until (500); g_assert (result != NULL); ret = gck_session_generate_key_pair_finish (test->session, result, &pub_key, &prv_key, &error); g_assert_no_error (error); g_assert (ret); g_object_unref (result); g_object_unref (pub_key); g_object_unref (prv_key); /* Asynchronous failure */ result = NULL; mech.type = 0; pub_key = prv_key = NULL; gck_session_generate_key_pair_async (test->session, &mech, pub_attrs, prv_attrs, NULL, fetch_async_result, &result); egg_test_wait_until (500); g_assert (result != NULL); ret = gck_session_generate_key_pair_finish (test->session, result, &pub_key, &prv_key, &error); g_assert (error != NULL); g_assert (!ret); g_clear_error (&error); g_object_unref (result); g_assert (pub_key == NULL); g_assert (prv_key == NULL); gck_attributes_unref (pub_attrs); gck_attributes_unref (prv_attrs); }
false
false
false
false
false
0
gnumeric_isblank (GnmFuncEvalInfo *ei, GnmValue const * const *argv) { return value_new_bool (VALUE_IS_EMPTY (argv[0])); }
false
false
false
false
false
0
previousCodePoint(UErrorCode &errorCode) { UChar32 c; for(;;) { if(state == CHECK_BWD) { if(pos == 0) { return U_SENTINEL; } if((c = u8[pos - 1]) < 0x80) { --pos; return c; } U8_PREV_OR_FFFD(u8, 0, pos, c); if(CollationFCD::hasLccc(c <= 0xffff ? c : U16_LEAD(c)) && (CollationFCD::maybeTibetanCompositeVowel(c) || (pos != 0 && previousHasTccc()))) { // c is not FCD-inert, therefore it is not U+FFFD and it has a valid byte sequence // and we can use U8_LENGTH() rather than a previous-position variable. pos += U8_LENGTH(c); if(!previousSegment(errorCode)) { return U_SENTINEL; } continue; } return c; } else if(state == IN_FCD_SEGMENT && pos != start) { U8_PREV_OR_FFFD(u8, 0, pos, c); return c; } else if(state >= IN_NORMALIZED && pos != 0) { c = normalized.char32At(pos - 1); pos -= U16_LENGTH(c); return c; } else { switchToBackward(); } } }
false
false
false
false
false
0
gamgi_engine_link_object_plane (gamgi_object *object, gamgi_plane *plane) { /******************************* * bonds have no plane parents * *******************************/ switch (object->class) { case GAMGI_ENGINE_TEXT: gamgi_engine_link_text_plane (GAMGI_CAST_TEXT object, plane); break; case GAMGI_ENGINE_ORBITAL: gamgi_engine_link_orbital_plane (GAMGI_CAST_ORBITAL object, plane); break; case GAMGI_ENGINE_ATOM: gamgi_engine_link_atom_plane (GAMGI_CAST_ATOM object, plane); break; case GAMGI_ENGINE_DIRECTION: gamgi_engine_link_direction_plane (GAMGI_CAST_DIRECTION object, plane); break; default: break; } }
false
false
false
false
false
0
tcl_modules STDVAR { int i; char *p, s[24], s2[24]; EGG_CONST char *list[100], *list2[2]; dependancy *dep; module_entry *current; BADARGS(1, 1, ""); for (current = module_list; current; current = current->next) { list[0] = current->name; egg_snprintf(s, sizeof s, "%d.%d", current->major, current->minor); list[1] = s; i = 2; for (dep = dependancy_list; dep && (i < 100); dep = dep->next) { if (dep->needing == current) { list2[0] = dep->needed->name; egg_snprintf(s2, sizeof s2, "%d.%d", dep->major, dep->minor); list2[1] = s2; list[i] = Tcl_Merge(2, list2); i++; } } p = Tcl_Merge(i, list); Tcl_AppendElement(irp, p); Tcl_Free((char *) p); while (i > 2) { i--; Tcl_Free((char *) list[i]); } } return TCL_OK; }
false
false
false
false
false
0
getUnmatchedGlobalSuppressions(bool unusedFunctionChecking) const { std::list<SuppressionEntry> r; for (std::map<std::string, FileMatcher>::const_iterator i = _suppressions.begin(); i != _suppressions.end(); ++i) { if (!unusedFunctionChecking && i->first == "unusedFunction") continue; // global suppressions.. for (std::map<std::string, std::map<unsigned int, bool> >::const_iterator g = i->second._globs.begin(); g != i->second._globs.end(); ++g) { for (std::map<unsigned int, bool>::const_iterator l = g->second.begin(); l != g->second.end(); ++l) { if (!l->second) { r.push_back(SuppressionEntry(i->first, g->first, l->first)); } } } } return r; }
false
false
false
false
false
0
GetGlyphMetric(utf16 wGlyphID, GlyphMetric gmet, GdlObject * pgdlobj) { Assert(m_pFile); Assert(m_pLoca); Assert(m_pGlyf); Assert(m_pOs2); Assert(m_pHmtx); Assert(m_pHhea); switch(gmet) { case kgmetAscent: return TtfUtil::FontAscent(m_pOs2); case kgmetDescent: return TtfUtil::FontDescent(m_pOs2); case kgmetAdvHeight: // TODO AlanW (SharonC): eventually the vmtx table will be needed? return 0; default: break; // fall through } unsigned int nAdvWid; int nLsb; if (gmet == kgmetAdvWidth || gmet == kgmetLsb || gmet == kgmetRsb) { if (!TtfUtil::HorMetrics(wGlyphID, m_pHmtx, m_cHmtx, m_pHhea, nLsb, nAdvWid)) { g_errorList.AddError(120, pgdlobj, "Unable to get horizontal metrics for glyph ", GdlGlyphDefn::GlyphIDString(wGlyphID)); return INT_MIN; } switch(gmet) { case kgmetAdvWidth: return nAdvWid; case kgmetLsb: // Review: should we return xMin instead? return nLsb; default: break; // handle Rsb below } } if (TtfUtil::IsSpace(wGlyphID, m_pLoca, m_cLoca, m_pHead)) { if (gmet == kgmetRsb) return nAdvWid; // for space. RSB same as adv width to agree with compiler g_errorList.AddWarning(509, pgdlobj, "Requesting bounding box metric for white space glyph ", GdlGlyphDefn::GlyphIDString(wGlyphID), "; 0 will be used"); return 0; // for space, all BB metrics are zero } // Find bounding box metrics. /* Normally would use TtfUtil::GlyfBox but attachment points alter the metrics as follows. Normally the min and max values stored for each glyph also reflect the visual appearance of the glyph. When attachment points are added the min and max values may increase but the appearance of the glyph (the black part) will not change since attachment points aren't visible. We want the metrics returned here to match the appearance of the the glyph and not be the min and max values with attachment points. The GDL author will be familiar with former which is also more intuitive to use. The font could be adjusted so attachment points don't affect min and max values but that would add a step to the font production process and may produce unexpected side effects. The bounding box metrics returned from Windows (GetGlyphMetrics) disregard the min and max values for each glyph and match the visual appearance. Presumably this is related to the way the Windows rasterizer discards attachment points. This means the Graphite engine should obtain the same metrics as are returned here. Attachment points in this context are points that are alone on their own contour (or path), so they can easily be referenced by path number (GPath in GDL). */ std::vector<int> vnEndPt, vnX, vnY; std::vector<bool> vfOnCurve; int xMin = INT_MAX; int yMin = INT_MAX; int xMax = INT_MIN; int yMax = INT_MIN; if (GetGlyfPts(wGlyphID, &vnEndPt, &vnX, &vnY, &vfOnCurve)) { int nFirstPt = 0; int nSecondPt = -1; // so nFirstPt initialized to zero in loop below int cEndPoints = signed(vnEndPt.size()); int i, j; for (i = 0; i < cEndPoints; i++) { nFirstPt = nSecondPt + 1; nSecondPt = vnEndPt[i]; if (nSecondPt - nFirstPt) // throw out point on contour with single point { for (j = nFirstPt; j <= nSecondPt; j++) { xMin = Min(xMin, vnX[j]); yMin = Min(yMin, vnY[j]); xMax = Max(xMax, vnX[j]); yMax = Max(yMax, vnY[j]); } } } switch(gmet) { case kgmetBbTop: return yMax; case kgmetBbBottom: return yMin; case kgmetBbLeft: return xMin; case kgmetBbRight: return xMax; case kgmetBbWidth: return xMax - xMin; case kgmetBbHeight: return yMax - yMin; case kgmetRsb: return nAdvWid - nLsb - (xMax - xMin); default: break; } } g_errorList.AddError(121, pgdlobj, "Unable to get bounding box for glyph ", GdlGlyphDefn::GlyphIDString(wGlyphID)); return INT_MIN; }
false
false
false
false
false
0
do_info(const char *file, int FAST_FUNC (*proc)(char *)) { int lnr; FILE *procinfo; char *buffer; /* _stdin is just to save "r" param */ procinfo = fopen_or_warn_stdin(file); if (procinfo == NULL) { return; } lnr = 0; /* Why xmalloc_fgets_str? because it doesn't stop on NULs */ while ((buffer = xmalloc_fgets_str(procinfo, "\n")) != NULL) { /* line 0 is skipped */ if (lnr && proc(buffer)) bb_error_msg("%s: bogus data on line %d", file, lnr + 1); lnr++; free(buffer); } fclose(procinfo); }
false
false
false
false
false
0
_create_agent(void) { /* this needs to be set because the agent thread will do nothing if the connection was closed and then opened again */ agent_shutdown = 0; if (agent_list == NULL) { agent_list = list_create(slurmdbd_free_buffer); _load_dbd_state(); } if (agent_tid == 0) { pthread_attr_t agent_attr; slurm_attr_init(&agent_attr); if (pthread_create(&agent_tid, &agent_attr, _agent, NULL) || (agent_tid == 0)) fatal("pthread_create: %m"); slurm_attr_destroy(&agent_attr); } }
false
false
false
false
false
0
gridfs_store_file(gridfs *gfs, const char *filename, const char *remotename, const char *contenttype, int flags ) { char buffer[DEFAULT_CHUNK_SIZE]; FILE *fd; gridfs_offset chunkLen; gridfile gfile; gridfs_offset bytes_written = 0; /* Open the file and the correct stream */ if (strcmp(filename, "-") == 0) { fd = stdin; } else { fd = fopen(filename, "rb"); if (fd == NULL) { return MONGO_ERROR; } } /* Optional Remote Name */ if (remotename == NULL || *remotename == '\0') { remotename = filename; } if( gridfile_init( gfs, NULL, &gfile ) != MONGO_OK ) return MONGO_ERROR; if( gridfile_writer_init( &gfile, gfs, remotename, contenttype, flags ) != MONGO_OK ){ gridfile_destroy( &gfile ); return MONGO_ERROR; } chunkLen = fread(buffer, 1, DEFAULT_CHUNK_SIZE, fd); while( chunkLen != 0 ) { bytes_written = gridfile_write_buffer( &gfile, buffer, chunkLen ); if( bytes_written != chunkLen ) break; chunkLen = fread(buffer, 1, DEFAULT_CHUNK_SIZE, fd); } gridfile_writer_done( &gfile ); gridfile_destroy( &gfile ); /* Close the file stream */ if ( fd != stdin ) { fclose( fd ); } return ( chunkLen == 0) || ( bytes_written == chunkLen ) ? MONGO_OK : MONGO_ERROR; }
false
false
false
false
true
1
hash_find_entry (Hash_table *table, const void *entry, struct hash_entry **bucket_head, bool delete) { struct hash_entry *bucket = table->bucket + table->hasher (entry, table->n_buckets); struct hash_entry *cursor; assert (bucket < table->bucket_limit); *bucket_head = bucket; /* Test for empty bucket. */ if (bucket->data == NULL) return NULL; /* See if the entry is the first in the bucket. */ if ((*table->comparator) (entry, bucket->data)) { void *data = bucket->data; if (delete) { if (bucket->next) { struct hash_entry *next = bucket->next; /* Bump the first overflow entry into the bucket head, then save the previous first overflow entry for later recycling. */ *bucket = *next; free_entry (table, next); } else { bucket->data = NULL; } } return data; } /* Scan the bucket overflow. */ for (cursor = bucket; cursor->next; cursor = cursor->next) { if ((*table->comparator) (entry, cursor->next->data)) { void *data = cursor->next->data; if (delete) { struct hash_entry *next = cursor->next; /* Unlink the entry to delete, then save the freed entry for later recycling. */ cursor->next = next->next; free_entry (table, next); } return data; } } /* No entry found. */ return NULL; }
false
false
false
false
false
0
_dxfgetdictalias(struct dict *d, int alias, int *value) { struct dinfo *di; /* this is hashed on string value, so to look up an alias number * it has to be a linear search. */ if (!DXInitGetNextHashElement(d->dicttab)) return ERROR; while ((di = (struct dinfo *)DXGetNextHashElement(d->dicttab)) != NULL) { if (di->type != ALIAS) continue; if (di->value == alias) { *value = (int)((byte *)di - (byte *)d->dicttab); return OK; } } return ERROR; }
false
false
false
false
false
0
try_parse_special(const wcstring &special) { bzero(&data, sizeof data); const wchar_t *name = special.c_str(); if (! wcscasecmp(name, L"normal")) { this->type = type_normal; } else if (! wcscasecmp(name, L"reset")) { this->type = type_reset; } else if (! wcscasecmp(name, L"ignore")) { this->type = type_ignore; } else { this->type = type_none; } return this->type != type_none; }
false
false
false
false
false
0
thread_name (MonoProfiler *prof, uintptr_t tid, const char *name) { int len = strlen (name) + 1; uint64_t now; LogBuffer *logbuffer; logbuffer = ensure_logbuf ( EVENT_SIZE /* event */ + LEB128_SIZE /* time */ + EVENT_SIZE /* type */ + LEB128_SIZE /* tid */ + LEB128_SIZE /* flags */ + len /* name */ ); now = current_time (); ENTER_LOG (logbuffer, "tname"); emit_byte (logbuffer, TYPE_METADATA); emit_time (logbuffer, now); emit_byte (logbuffer, TYPE_THREAD); emit_ptr (logbuffer, (void*)tid); emit_value (logbuffer, 0); /* flags */ memcpy (logbuffer->data, name, len); logbuffer->data += len; EXIT_LOG (logbuffer); if (logbuffer->next) safe_send (prof, logbuffer); process_requests (prof); }
false
true
false
false
false
1
registerDragType(const FXString& name) const { if(initialized){ #ifndef WIN32 return (FXDragType)XInternAtom((Display*)display,name.text(),0); #else return RegisterClipboardFormatA(name.text()); #endif } return 0; }
false
false
false
false
false
0
XGIfb_set_par(struct fb_info *info) { int err; err = XGIfb_do_set_var(&info->var, 1, info); if (err) return err; XGIfb_get_fix(&info->fix, -1, info); return 0; }
false
false
false
false
false
0
handlePRERET(FlowInstruction *pre) { BasicBlock *bbE = pre->bb; BasicBlock *bbT = pre->target.bb; pre->subOp = NV50_IR_SUBOP_EMU_PRERET + 0; bbE->remove(pre); bbE->insertHead(pre); Instruction *skip = new_FlowInstruction(func, OP_PRERET, bbT); Instruction *call = new_FlowInstruction(func, OP_PRERET, bbE); bbT->insertHead(call); bbT->insertHead(skip); // NOTE: maybe split blocks to prevent the instructions from moving ? skip->subOp = NV50_IR_SUBOP_EMU_PRERET + 1; call->subOp = NV50_IR_SUBOP_EMU_PRERET + 2; }
false
false
false
true
false
1
chip_ti_1520_cwrite1( void *_cpssp, uint32_t addr, unsigned int bs, uint32_t val ) { struct cpssp *cpssp = (struct cpssp *) _cpssp; unsigned int bus; unsigned int dev; bus = (addr >> 16) & 0xff; if (bus == CB_BUS(cpssp, 0)) { dev = (addr >> 11) & 0x1f; addr &= 0x7fc; if (! cpssp->powered[0]) { return 1; } else { return sig_pci_bus_main_c0w(cpssp->port_cb0, cpssp, (1 << (11 + dev)) | addr, bs, val); } } else if (bus == CB_BUS(cpssp, 1)) { dev = (addr >> 11) & 0x1f; addr &= 0x7fc; if (! cpssp->powered[1]) { return 1; } else { return sig_pci_bus_main_c0w(cpssp->port_cb1, cpssp, (1 << (11 + dev)) | addr, bs, val); } } else if (bus <= SUB_BUS(cpssp, 0)) { if (! cpssp->powered[0]) { return 1; } else { return sig_pci_bus_c1w(cpssp->port_cb0, cpssp, addr, bs, val); } } else if (bus <= SUB_BUS(cpssp, 1)) { if (! cpssp->powered[1]) { return 1; } else { return sig_pci_bus_c1w(cpssp->port_cb1, cpssp, addr, bs, val); } } return -1; }
false
false
false
false
false
0
intel_runtime_pm_enable(struct drm_i915_private *dev_priv) { struct drm_device *dev = dev_priv->dev; struct device *device = &dev->pdev->dev; if (!HAS_RUNTIME_PM(dev)) return; /* * RPM depends on RC6 to save restore the GT HW context, so make RC6 a * requirement. */ if (!intel_enable_rc6(dev)) { DRM_INFO("RC6 disabled, disabling runtime PM support\n"); return; } pm_runtime_set_autosuspend_delay(device, 10000); /* 10s */ pm_runtime_mark_last_busy(device); pm_runtime_use_autosuspend(device); pm_runtime_put_autosuspend(device); }
false
false
false
false
false
0
numaNormalizeHistogram(NUMA *nas, l_float32 area) { l_int32 i, ns; l_float32 sum, factor, fval; NUMA *nad; PROCNAME("numaNormalizeHistogram"); if (!nas) return (NUMA *)ERROR_PTR("nas not defined", procName, NULL); if (area <= 0.0) return (NUMA *)ERROR_PTR("area must be > 0.0", procName, NULL); if ((ns = numaGetCount(nas)) == 0) return (NUMA *)ERROR_PTR("no bins in nas", procName, NULL); numaGetSum(nas, &sum); factor = area / sum; if ((nad = numaCreate(ns)) == NULL) return (NUMA *)ERROR_PTR("nad not made", procName, NULL); for (i = 0; i < ns; i++) { numaGetFValue(nas, i, &fval); fval *= factor; numaAddNumber(nad, fval); } return nad; }
false
false
false
false
false
0
test_create (void) { static double test[sizeof (double) * test_pixels * 4]; int i; static int done = 0; if (done) return test; srandom (20050728); for (i = 0; i < test_pixels * 4; i++) test [i] = (double) random () / RAND_MAX; done = 1; return test; }
false
false
false
false
false
0
collect_reloc(Elf32_Rel *rel, Elf32_Sym *sym) { /* Remember the address that needs to be adjusted. */ if (ELF32_R_TYPE(rel->r_info) == R_386_16) relocs16[reloc16_idx++] = rel->r_offset; else relocs[reloc_idx++] = rel->r_offset; }
false
false
false
false
false
0
cmor_convert_value(char *units,char *ctmp,double *tmp){ ut_unit *user_units=NULL, *cmor_units=NULL; cv_converter *ut_cmor_converter=NULL; double value; char msg[CMOR_MAX_STRING]; cmor_add_traceback("cmor_convert_value"); value = *tmp; if (units[0]!='\0') { cmor_prep_units(ctmp,units,&cmor_units,&user_units,&ut_cmor_converter); *tmp = cv_convert_double(ut_cmor_converter,value); if (ut_get_status() != UT_SUCCESS) { snprintf(msg,CMOR_MAX_STRING,"Udunits: Error converting units from %s to %s",units,ctmp); cmor_handle_error(msg,CMOR_CRITICAL); } cv_free(ut_cmor_converter); if (ut_get_status() != UT_SUCCESS) { snprintf(msg,CMOR_MAX_STRING,"Udunits: Error freeing converter"); cmor_handle_error(msg,CMOR_CRITICAL); } ut_free(cmor_units); if (ut_get_status() != UT_SUCCESS) { snprintf(msg,CMOR_MAX_STRING,"Udunits: Error freeing units"); cmor_handle_error(msg,CMOR_CRITICAL); } ut_free(user_units); if (ut_get_status() != UT_SUCCESS) { snprintf(msg,CMOR_MAX_STRING,"Udunits: Error freeing units"); cmor_handle_error(msg,CMOR_CRITICAL); } } else *tmp=value; cmor_pop_traceback(); return; }
false
false
false
false
false
0
EmitSignal (SignalId Signal) { Object *obj = NULL; Object *ancestor = this; while (ancestor && !ancestor->IsLocked () && ancestor->OnSignal (Signal, obj)) { obj = ancestor; ancestor = obj->m_Parent; } }
false
false
false
false
false
0
rs_allocmatDBL(double ***v, const int m, const int n) { int i; *v = reinterpret_cast<double **> (calloc (m, sizeof(double *))); if (*v == NULL) { printf("###ERROR: DOUBLE matrix allocation failed\n"); exit(1); } for(i=0; i<m; i++) { (*v)[i] = reinterpret_cast<double *> (calloc (n, sizeof(double))); if ((*v)[i] == NULL) { printf("###ERROR: DOUBLE matrix allocation failed\n"); exit(1); } } }
false
false
false
false
false
0
makeSubObject(DcmObject *&subObject, const DcmTag &newTag, const Uint32 newLength) { OFCondition l_error = EC_Normal; DcmItem *subItem = NULL; switch (newTag.getEVR()) { case EVR_na: if (newTag.getXTag() == DCM_Item) { if (getTag().getXTag() == DCM_DirectoryRecordSequence) subItem = new DcmDirectoryRecord(newTag, newLength); else subItem = new DcmItem(newTag, newLength); } else if (newTag.getXTag() == DCM_SequenceDelimitationItem) l_error = EC_SequEnd; else if (newTag.getXTag() == DCM_ItemDelimitationItem) l_error = EC_ItemEnd; else l_error = EC_InvalidTag; break; default: subItem = new DcmItem(newTag, newLength); l_error = EC_CorruptedData; break; } subObject = subItem; return l_error; }
false
false
false
false
false
0
hash_result(struct mdfour *md) { unsigned char sum[16]; char *ret; int i; ret = x_malloc(53); hash_result_as_bytes(md, sum); for (i=0;i<16;i++) { sprintf(&ret[i*2], "%02x", (unsigned)sum[i]); } sprintf(&ret[i*2], "-%u", (unsigned)md->totalN); return ret; }
false
false
false
false
false
0
get_icon_from_irda_hints( guint8 hints[2] ) { gchar *icon_name; if(hints[0] & HINT_PDA) icon_name = g_strdup("pda"); else if(hints[0] & HINT_COMPUTER) icon_name = g_strdup("computer"); else if(hints[0] & HINT_PRINTER) icon_name = g_strdup("printer"); else if(hints[1] & HINT_TELEPHONY) icon_name = g_strdup("phone"); else icon_name = g_strdup("ircp-tray"); return icon_name; }
false
false
false
false
false
0
param_is_printable(int i)const { if (has_common()) { return common()->param_is_printable(i); }else{ switch (COMPONENT::param_count() - 1 - i) { case 0: return value().has_hard_value(); case 1: return _mfactor.has_hard_value(); default: return CARD::param_is_printable(i); } } }
false
false
false
false
false
0
i7core_pci_lastbus(void) { int last_bus = 0, bus; struct pci_bus *b = NULL; while ((b = pci_find_next_bus(b)) != NULL) { bus = b->number; edac_dbg(0, "Found bus %d\n", bus); if (bus > last_bus) last_bus = bus; } edac_dbg(0, "Last bus %d\n", last_bus); return last_bus; }
false
false
false
false
false
0
xfs_mru_cache_create( struct xfs_mru_cache **mrup, unsigned int lifetime_ms, unsigned int grp_count, xfs_mru_cache_free_func_t free_func) { struct xfs_mru_cache *mru = NULL; int err = 0, grp; unsigned int grp_time; if (mrup) *mrup = NULL; if (!mrup || !grp_count || !lifetime_ms || !free_func) return -EINVAL; if (!(grp_time = msecs_to_jiffies(lifetime_ms) / grp_count)) return -EINVAL; if (!(mru = kmem_zalloc(sizeof(*mru), KM_SLEEP))) return -ENOMEM; /* An extra list is needed to avoid reaping up to a grp_time early. */ mru->grp_count = grp_count + 1; mru->lists = kmem_zalloc(mru->grp_count * sizeof(*mru->lists), KM_SLEEP); if (!mru->lists) { err = -ENOMEM; goto exit; } for (grp = 0; grp < mru->grp_count; grp++) INIT_LIST_HEAD(mru->lists + grp); /* * We use GFP_KERNEL radix tree preload and do inserts under a * spinlock so GFP_ATOMIC is appropriate for the radix tree itself. */ INIT_RADIX_TREE(&mru->store, GFP_ATOMIC); INIT_LIST_HEAD(&mru->reap_list); spin_lock_init(&mru->lock); INIT_DELAYED_WORK(&mru->work, _xfs_mru_cache_reap); mru->grp_time = grp_time; mru->free_func = free_func; *mrup = mru; exit: if (err && mru && mru->lists) kmem_free(mru->lists); if (err && mru) kmem_free(mru); return err; }
false
false
false
false
false
0
pixScaleToGray3(PIX *pixs) { l_uint8 *valtab; l_int32 ws, hs, wd, hd; l_int32 wpld, wpls; l_uint32 *sumtab; l_uint32 *datas, *datad; PIX *pixd; PROCNAME("pixScaleToGray3"); if (!pixs) return (PIX *)ERROR_PTR("pixs not defined", procName, NULL); if (pixGetDepth(pixs) != 1) return (PIX *)ERROR_PTR("pixs not 1 bpp", procName, NULL); pixGetDimensions(pixs, &ws, &hs, NULL); wd = (ws / 3) & 0xfffffff8; /* truncate to factor of 8 */ hd = hs / 3; if (wd == 0 || hd == 0) return (PIX *)ERROR_PTR("pixs too small", procName, NULL); if ((pixd = pixCreate(wd, hd, 8)) == NULL) return (PIX *)ERROR_PTR("pixd not made", procName, NULL); pixCopyResolution(pixd, pixs); pixScaleResolution(pixd, 0.33333, 0.33333); datas = pixGetData(pixs); datad = pixGetData(pixd); wpls = pixGetWpl(pixs); wpld = pixGetWpl(pixd); if ((sumtab = makeSumTabSG3()) == NULL) return (PIX *)ERROR_PTR("sumtab not made", procName, NULL); if ((valtab = makeValTabSG3()) == NULL) return (PIX *)ERROR_PTR("valtab not made", procName, NULL); scaleToGray3Low(datad, wd, hd, wpld, datas, wpls, sumtab, valtab); FREE(sumtab); FREE(valtab); return pixd; }
false
false
false
false
false
0
knh_PtrMap_rmS(CTX ctx, kPtrMap *pm, kString *s) { knh_hmap_t *hmap = (knh_hmap_t*)pm->mapptr; kbytes_t t = S_tobytes(s); khashcode_t hcode = knh_hash(0, t.text, t.len); knh_hentry_t *e = hmap_getentry(hmap, hcode); DBG_ASSERT(IS_bString(s)); while(e != NULL) { if(e->hcode == hcode && e->pvalue == (void*)s) { hmap_remove(hmap, e); hmap_unuse(hmap, e); return; } e = e->next; } DBG_P("not found removed %x '%s' %p", hcode, t.text, s); //KNH_ASSERT(ctx == NULL); }
false
false
false
false
false
0
termattrs(void) { chtype attrs = A_NORMAL; T((T_CALLED("termattrs()"))); if (enter_alt_charset_mode) attrs |= A_ALTCHARSET; if (enter_blink_mode) attrs |= A_BLINK; if (enter_bold_mode) attrs |= A_BOLD; if (enter_dim_mode) attrs |= A_DIM; if (enter_reverse_mode) attrs |= A_REVERSE; if (enter_standout_mode) attrs |= A_STANDOUT; if (enter_protected_mode) attrs |= A_PROTECT; if (enter_secure_mode) attrs |= A_INVIS; if (enter_underline_mode) attrs |= A_UNDERLINE; if (SP->_coloron) attrs |= A_COLOR; returnChar(attrs); }
false
false
false
false
false
0
normal_thumb(Glyph* g) { SliderImpl& s = *impl_; Resource::ref(g); Resource::unref(s.normal_thumb_); s.normal_thumb_ = g; Resource::unref(s.thumb_patch_); s.thumb_patch_ = new Patch(g); Resource::ref(s.thumb_patch_); }
false
false
false
false
false
0
save_pbm(const char* name, uchar* im, int height, int width ) { std::ofstream file(name, std::ios::out | std::ios::binary); file << "P4\n" << width << " " << height << "\n"; for (int i = 0; i < height; i++) write_packed(im+(width*i), width, file); }
false
false
false
false
false
0
check_modification_callback (GFile *source, GAsyncResult *res, AsyncData *async) { GeditDocumentSaver *saver; GError *error = NULL; GFileInfo *info; gedit_debug (DEBUG_SAVER); /* manually check cancelled state */ if (g_cancellable_is_cancelled (async->cancellable)) { async_data_free (async); return; } saver = async->saver; info = g_file_query_info_finish (source, res, &error); if (info == NULL) { if (error->code == G_IO_ERROR_NOT_MOUNTED && !async->tried_mount) { recover_not_mounted (async); g_error_free (error); return; } /* it's perfectly fine if the file doesn't exist yet */ if (error->code != G_IO_ERROR_NOT_FOUND) { gedit_debug_message (DEBUG_SAVER, "Error getting modification: %s", error->message); async_failed (async, error); return; } } /* check if the mtime is > what we know about it (if we have it) */ if (info != NULL && g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_MODIFIED)) { GTimeVal mtime; GTimeVal old_mtime; g_file_info_get_modification_time (info, &mtime); old_mtime = saver->priv->old_mtime; if ((old_mtime.tv_sec > 0 || old_mtime.tv_usec > 0) && (mtime.tv_sec != old_mtime.tv_sec || mtime.tv_usec != old_mtime.tv_usec) && (saver->priv->flags & GEDIT_DOCUMENT_SAVE_IGNORE_MTIME) == 0) { gedit_debug_message (DEBUG_SAVER, "File is externally modified"); g_set_error (&saver->priv->error, GEDIT_DOCUMENT_ERROR, GEDIT_DOCUMENT_ERROR_EXTERNALLY_MODIFIED, "Externally modified"); remote_save_completed_or_failed (saver, async); g_object_unref (info); return; } } if (info != NULL) g_object_unref (info); /* modification check passed, start write */ begin_write (async); }
false
false
false
false
false
0
gas_fire (edict_t * ent) { vec3_t offset; vec3_t forward, right; vec3_t start; int damage = GRENADE_DAMRAD; float timer; int speed; /* int held = false;*/ // Reset Grenade Damage to 1.52 when requested: if (use_classic->value) damage = 170; else damage = GRENADE_DAMRAD; if(is_quad) damage *= 1.5f; VectorSet (offset, 8, 8, ent->viewheight - 8); AngleVectors (ent->client->v_angle, forward, right, NULL); P_ProjectSource (ent->client, ent->s.origin, offset, forward, right, start); timer = 2.0; if (ent->client->resp.grenade_mode == 0) speed = 400; else if (ent->client->resp.grenade_mode == 1) speed = 720; else speed = 920; fire_grenade2 (ent, start, forward, damage, speed, timer, damage * 2, false); INV_AMMO(ent, GRENADE_NUM)--; if (INV_AMMO(ent, GRENADE_NUM) <= 0) { ent->client->newweapon = GET_ITEM(MK23_NUM); ChangeWeapon (ent); return; } else { ent->client->weaponstate = WEAPON_RELOADING; ent->client->ps.gunframe = 0; } // ent->client->grenade_time = level.time + 1.0; ent->client->ps.gunframe++; }
false
false
false
false
false
0
_wapi_handle_check_share (struct _WapiFileShare *share_info, int fd) { gboolean found = FALSE, proc_fds = FALSE; pid_t self = _wapi_getpid (); int pid; int thr_ret, i; /* Prevents entries from expiring under us if we remove this * one */ thr_ret = _wapi_handle_lock_shared_handles (); g_assert (thr_ret == 0); /* Prevent new entries racing with us */ thr_ret = _wapi_shm_sem_lock (_WAPI_SHARED_SEM_FILESHARE); g_assert (thr_ret == 0); /* If there is no /proc, there's nothing more we can do here */ if (access ("/proc", F_OK) == -1) { _wapi_handle_check_share_by_pid (share_info); goto done; } /* If there's another handle that thinks it owns this fd, then even * if the fd has been closed behind our back consider it still owned. * See bugs 75764 and 75891 */ for (i = 0; i < _wapi_fd_reserve; i++) { if (_wapi_private_handles [SLOT_INDEX (i)]) { struct _WapiHandleUnshared *handle = &_WAPI_PRIVATE_HANDLES(i); if (i != fd && handle->type == WAPI_HANDLE_FILE) { struct _WapiHandle_file *file_handle = &handle->u.file; if (file_handle->share_info == share_info) { DEBUG ("%s: handle 0x%x has this file open!", __func__, i); goto done; } } } } for (i = 0; i < _WAPI_HANDLE_INITIAL_COUNT; i++) { struct _WapiHandleShared *shared; struct _WapiHandle_process *process_handle; shared = &_wapi_shared_layout->handles[i]; if (shared->type == WAPI_HANDLE_PROCESS) { DIR *fd_dir; struct dirent *fd_entry; char subdir[_POSIX_PATH_MAX]; process_handle = &shared->u.process; pid = process_handle->id; /* Look in /proc/<pid>/fd/ but ignore * /proc/<our pid>/fd/<fd>, as we have the * file open too */ g_snprintf (subdir, _POSIX_PATH_MAX, "/proc/%d/fd", pid); fd_dir = opendir (subdir); if (fd_dir == NULL) { continue; } DEBUG ("%s: Looking in %s", __func__, subdir); proc_fds = TRUE; while ((fd_entry = readdir (fd_dir)) != NULL) { char path[_POSIX_PATH_MAX]; struct stat link_stat; if (!strcmp (fd_entry->d_name, ".") || !strcmp (fd_entry->d_name, "..") || (pid == self && fd == atoi (fd_entry->d_name))) { continue; } g_snprintf (path, _POSIX_PATH_MAX, "/proc/%d/fd/%s", pid, fd_entry->d_name); stat (path, &link_stat); if (link_stat.st_dev == share_info->device && link_stat.st_ino == share_info->inode) { DEBUG ("%s: Found it at %s", __func__, path); found = TRUE; } } closedir (fd_dir); } } if (proc_fds == FALSE) { _wapi_handle_check_share_by_pid (share_info); } else if (found == FALSE) { /* Blank out this entry, as it is stale */ DEBUG ("%s: Didn't find it, destroying entry", __func__); _wapi_free_share_info (share_info); } done: thr_ret = _wapi_shm_sem_unlock (_WAPI_SHARED_SEM_FILESHARE); _wapi_handle_unlock_shared_handles (); }
true
true
true
false
true
1
NumericValue(RefAST ast, bool * pfM) { Assert(ast->getType() == LIT_INT || ast->getType() == LIT_UHEX); std::string str = ast->getText(); int nRet = 0; unsigned int ich = 0; int nBase = 10; if (ast->getType() == LIT_UHEX) { if (str[0] == 'U' && str[1] == '+') ich = 2; nBase = 16; } else if (str[0] == '0' && str[1] == 'x') { ich = 2; nBase = 16; } else if (str[0] == 'x') { ich = 1; nBase = 16; } while (ich < str.length()) { if (str[ich] >= 0 && str[ich] <= '9') nRet = nRet * nBase + (str[ich] - '0'); else if (nBase == 16 && str[ich] >= 'A' && str[ich] <= 'F') nRet = nRet * nBase + (str[ich] - 'A' + 10); else if (nBase == 16 && str[ich] >= 'a' && str[ich] <= 'f') nRet = nRet * nBase + (str[ich] - 'a' + 10); else break; ich++; } *pfM = (str[ich] == 'm' || str[ich] == 'M'); Assert(!*pfM || ast->getType() != LIT_UHEX); return nRet; }
false
false
false
false
false
0
setIdColAcol() { // Flavours and colours are trivial. int idX1 = 10* (abs(idA) / 10) + 9900000; if (idA < 0) idX1 = -idX1; int idX2 = 10* (abs(idB) / 10) + 9900000; if (idB < 0) idX2 = -idX2; setId( idA, idB, idX1, idX2); setColAcol( 0, 0, 0, 0, 0, 0, 0, 0); }
false
false
false
false
false
0
gt_samfile_iterator_reset(GtSamfileIterator *s_iter, GtError *err) { gt_assert(s_iter != NULL); samclose(s_iter->samfile); s_iter->samfile = samopen(s_iter->filename, s_iter->mode, s_iter->aux); if (s_iter->samfile == NULL) { gt_error_set(err, "could not reopen sam/bam file: %s", s_iter->filename); return -1; } return 0; }
false
false
false
false
false
0
ao_hex_record_set_checksum(struct ao_hex_record *record) { uint8_t cksum = 0; int i; cksum += record->length; cksum += record->address >> 8; cksum += record->address; cksum += record->type; for (i = 0; i < record->length; i++) cksum += record->data[i]; record->checksum = -cksum; }
false
true
false
false
false
1
search_object_integer(struct alisp_instance *instance, long in) { struct list_head * pos; struct alisp_object * p; list_for_each(pos, &instance->used_objs_list[in & ALISP_OBJ_PAIR_HASH_MASK][ALISP_OBJ_INTEGER]) { p = list_entry(pos, struct alisp_object, list); if (p->value.i == in) { if (alisp_get_refs(p) > ALISP_MAX_REFS_LIMIT) continue; return incref_object(instance, p); } } return NULL; }
false
false
false
false
false
0
defragmentPage(Btree *pBt, MemPage *pPage){ int pc, i, n; FreeBlk *pFBlk; char newPage[SQLITE_USABLE_SIZE]; assert( sqlitepager_iswriteable(pPage) ); assert( pPage->isInit ); pc = sizeof(PageHdr); pPage->u.hdr.firstCell = SWAB16(pBt, pc); memcpy(newPage, pPage->u.aDisk, pc); for(i=0; i<pPage->nCell; i++){ Cell *pCell = pPage->apCell[i]; /* This routine should never be called on an overfull page. The ** following asserts verify that constraint. */ assert( Addr(pCell) > Addr(pPage) ); assert( Addr(pCell) < Addr(pPage) + SQLITE_USABLE_SIZE ); n = cellSize(pBt, pCell); pCell->h.iNext = SWAB16(pBt, pc + n); memcpy(&newPage[pc], pCell, n); pPage->apCell[i] = (Cell*)&pPage->u.aDisk[pc]; pc += n; } assert( pPage->nFree==SQLITE_USABLE_SIZE-pc ); memcpy(pPage->u.aDisk, newPage, pc); if( pPage->nCell>0 ){ pPage->apCell[pPage->nCell-1]->h.iNext = 0; } pFBlk = (FreeBlk*)&pPage->u.aDisk[pc]; pFBlk->iSize = SWAB16(pBt, SQLITE_USABLE_SIZE - pc); pFBlk->iNext = 0; pPage->u.hdr.firstFree = SWAB16(pBt, pc); memset(&pFBlk[1], 0, SQLITE_USABLE_SIZE - pc - sizeof(FreeBlk)); }
true
true
false
false
false
1
run_script(const char *name, const char *pattern, uint32_t job_id, int max_wait, char **env, uid_t uid) { int rc = 0; List l; ListIterator i; char *s; if (pattern == NULL || pattern[0] == '\0') return 0; l = _script_list_create (pattern); if (l == NULL) return error ("Unable to run %s [%s]", name, pattern); i = list_iterator_create (l); while ((s = list_next (i))) { rc = _run_one_script (name, s, job_id, max_wait, env, uid); if (rc) { error ("%s: exited with status 0x%04x\n", s, rc); break; } } list_iterator_destroy (i); list_destroy (l); return rc; }
false
false
false
false
false
0
DAC960_GEM_QueueCommand(DAC960_Command_T *Command) { DAC960_Controller_T *Controller = Command->Controller; void __iomem *ControllerBaseAddress = Controller->BaseAddress; DAC960_V2_CommandMailbox_T *CommandMailbox = &Command->V2.CommandMailbox; DAC960_V2_CommandMailbox_T *NextCommandMailbox = Controller->V2.NextCommandMailbox; CommandMailbox->Common.CommandIdentifier = Command->CommandIdentifier; DAC960_GEM_WriteCommandMailbox(NextCommandMailbox, CommandMailbox); if (Controller->V2.PreviousCommandMailbox1->Words[0] == 0 || Controller->V2.PreviousCommandMailbox2->Words[0] == 0) DAC960_GEM_MemoryMailboxNewCommand(ControllerBaseAddress); Controller->V2.PreviousCommandMailbox2 = Controller->V2.PreviousCommandMailbox1; Controller->V2.PreviousCommandMailbox1 = NextCommandMailbox; if (++NextCommandMailbox > Controller->V2.LastCommandMailbox) NextCommandMailbox = Controller->V2.FirstCommandMailbox; Controller->V2.NextCommandMailbox = NextCommandMailbox; }
false
false
false
false
false
0
gt_sortbench_option_parser_new(void *tool_arguments) { QSortBenchArguments *arguments = tool_arguments; GtOptionParser *op; GtOption *option; gt_assert(arguments); /* init */ op = gt_option_parser_new("[option ...]", "Benchmarks quicksort implementations."); option = gt_option_new_choice( "impl", "implementation\nchoose from " "thomas|system|inlinedptr|inlinedarr|direct|\n" "radixinplace|radixlsb", arguments->impl, gt_sort_implementation_names[0], gt_sort_implementation_names); gt_option_parser_add_option(op, option); option = gt_option_new_ulong("size", "number of integers to sort", &arguments->num_values, 1000000UL); gt_option_parser_add_option(op, option); /* default set to ULONG_MAX-1 to facilitate proper testing of the radixsort implementations (make sure that higher order bits are set) */ option = gt_option_new_ulong("maxval", "maximal integer to sort", &arguments->maxvalue, ULONG_MAX-1); gt_option_parser_add_option(op, option); option = gt_option_new_bool("aqsort", "prepare bad input array using the " "'aqsort' anti-quicksort algorithm", &arguments->use_aqsort, false); gt_option_parser_add_option(op, option); option = gt_option_new_bool("permute", "prepare bad input array by " "permutation of unique items", &arguments->use_permute, false); gt_option_parser_add_option(op, option); option = gt_option_new_verbose(&arguments->verbose); gt_option_parser_add_option(op, option); return op; }
false
false
false
false
false
0
crc32_le_80211(unsigned int *crc32_table, const unsigned char *buf, int len) { int i; unsigned int crc = 0xFFFFFFFF; for (i = 0; i < len; ++i) { crc = (crc >> 8) ^ crc32_table[(crc ^ buf[i]) & 0xFF]; } crc ^= 0xFFFFFFFF; return crc; }
false
false
false
false
false
0
bl_set_status(struct backlight_device *bd) { int bright = bd->props.brightness; if (bright >= ARRAY_SIZE(backlight_map) || bright < 0) return -EINVAL; /* Instance 0 is "set backlight" */ return msi_wmi_set_block(0, backlight_map[bright]); }
false
false
false
false
false
0
gt_twobitenc_editor_new(const GtEncseq *encseq, const char* indexname, GtError *err) { GtTwobitencEditor *twobitenc_editor; size_t t_offset; size_t c_offset; GtStr *encseqfilename; int had_err = 0; twobitenc_editor = gt_malloc(sizeof (GtTwobitencEditor)); had_err = gt_twobitenc_editor_check(encseq, err); if (had_err == 0) { t_offset = gt_encseq_twobitencoding_mapoffset(encseq); c_offset = gt_encseq_chardistri_mapoffset(encseq); encseqfilename = gt_str_new_cstr(indexname); gt_str_append_cstr(encseqfilename, GT_ENCSEQFILESUFFIX); twobitenc_editor->mapptr = (unsigned char*)gt_fa_mmap_write(gt_str_get( encseqfilename), NULL, err); twobitenc_editor->twobitencoding = (GtTwobitencoding*) (twobitenc_editor->mapptr + t_offset); twobitenc_editor->charcount = (unsigned long*) (twobitenc_editor->mapptr + c_offset); gt_str_delete(encseqfilename); } return (had_err == 0) ? twobitenc_editor : NULL; }
false
false
false
false
false
0
lvalue_error (location_t loc, enum lvalue_use use) { switch (use) { case lv_assign: error_at (loc, "lvalue required as left operand of assignment"); break; case lv_increment: error_at (loc, "lvalue required as increment operand"); break; case lv_decrement: error_at (loc, "lvalue required as decrement operand"); break; case lv_addressof: error_at (loc, "lvalue required as unary %<&%> operand"); break; case lv_asm: error_at (loc, "lvalue required in asm statement"); break; default: gcc_unreachable (); } }
false
false
false
false
false
0
fc_lport_recv_req(struct fc_lport *lport, struct fc_frame *fp) { struct fc_frame_header *fh = fc_frame_header_get(fp); struct fc_seq *sp = fr_seq(fp); struct fc4_prov *prov; /* * Use RCU read lock and module_lock to be sure module doesn't * deregister and get unloaded while we're calling it. * try_module_get() is inlined and accepts a NULL parameter. * Only ELSes and FCP target ops should come through here. * The locking is unfortunate, and a better scheme is being sought. */ rcu_read_lock(); if (fh->fh_type >= FC_FC4_PROV_SIZE) goto drop; prov = rcu_dereference(fc_passive_prov[fh->fh_type]); if (!prov || !try_module_get(prov->module)) goto drop; rcu_read_unlock(); prov->recv(lport, fp); module_put(prov->module); return; drop: rcu_read_unlock(); FC_LPORT_DBG(lport, "dropping unexpected frame type %x\n", fh->fh_type); fc_frame_free(fp); if (sp) lport->tt.exch_done(sp); }
false
false
false
false
false
0
git_repository_open_bare( git_repository **repo_ptr, const char *bare_path) { int error; git_buf path = GIT_BUF_INIT; git_repository *repo = NULL; if ((error = git_path_prettify_dir(&path, bare_path, NULL)) < 0) return error; if (!valid_repository_path(&path)) { git_buf_free(&path); giterr_set(GITERR_REPOSITORY, "Path is not a repository: %s", bare_path); return GIT_ENOTFOUND; } repo = repository_alloc(); GITERR_CHECK_ALLOC(repo); repo->path_repository = git_buf_detach(&path); GITERR_CHECK_ALLOC(repo->path_repository); /* of course we're bare! */ repo->is_bare = 1; repo->workdir = NULL; *repo_ptr = repo; return 0; }
false
false
false
false
false
0
_wrap_goo_canvas_item_model_find_child_property (PyObject *cls, PyObject *args, PyObject *kwargs) { static char *kwlist[] = { "property", NULL }; GObjectClass *klass; GType itype; const gchar *prop_name; GParamSpec *pspec; if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:item_model_class_find_child_property", kwlist, &prop_name)) return NULL; if ((itype = pyg_type_from_object(cls)) == 0) return NULL; klass = g_type_class_ref(itype); if (!klass) { PyErr_SetString(PyExc_RuntimeError, "could not get a reference to type class"); return NULL; } pspec = goo_canvas_item_model_class_find_child_property (klass, prop_name); if(!pspec){ PyErr_Format(PyExc_KeyError, "object %s does not support property %s", g_type_name(itype), prop_name); return NULL; } return pyg_param_spec_new(pspec); }
false
false
false
false
false
0
get_port(const char *service) { struct servent *serv = getservbyname(service, "udp"); if (serv == NULL) exit(1); return serv->s_port; }
false
false
false
false
false
0
record_start_time() { struct tm *tm_now; start_sec = time(NULL); tm_now = localtime(&start_sec); year = tm_now->tm_year + 1900; month = tm_now->tm_mon + 1; day_of_month = tm_now->tm_mday; day_now = day_num(year, month, day_of_month); if (day_now == -1) die("Invalid date (this is really embarrassing)"); if (!update_only && !testing_only) explain("Anacron " RELEASE " started on %04d-%02d-%02d", year, month, day_of_month); }
false
false
false
false
false
0
tvp7002_log_status(struct v4l2_subdev *sd) { struct tvp7002 *device = to_tvp7002(sd); const struct v4l2_bt_timings *bt; int detected; /* Find my current timings */ tvp7002_query_dv(sd, &detected); bt = &device->current_timings->timings.bt; v4l2_info(sd, "Selected DV Timings: %ux%u\n", bt->width, bt->height); if (detected == NUM_TIMINGS) { v4l2_info(sd, "Detected DV Timings: None\n"); } else { bt = &tvp7002_timings[detected].timings.bt; v4l2_info(sd, "Detected DV Timings: %ux%u\n", bt->width, bt->height); } v4l2_info(sd, "Streaming enabled: %s\n", device->streaming ? "yes" : "no"); /* Print the current value of the gain control */ v4l2_ctrl_handler_log_status(&device->hdl, sd->name); return 0; }
false
false
false
false
false
0
add_label(void) { int i; if (token[strlen(token)-1]==':') token[strlen(token)-1]=0; if (lindex>=MAX_LABELS) { printf("Too many labels.\n"); exit(0); } for (i=0;i<lindex;i++) { if (!strcasecmp(token,labels[i])) { printf("Warning: label '%s' already exists.\n",token); return; } } strcpy(labels[lindex],token); offsets[lindex++]=offset; }
false
false
false
false
false
0
clear_c(obj) CcWnnObject obj; { switch (obj->ccWnn.state) { case selection_s_state: case selection_l_state: endSelection(obj, False); cancel(obj); break; case symbol_state: clear_buffer(obj); break; default: if (jcIsConverted(JCBUF(obj), JCBUF(obj)->curClause)) cancel(obj); else clear_buffer(obj); break; } }
false
false
false
false
false
0
operator==(const QualifiedName& other) const { /*kDebug() << m_prefix.id() << other.prefixId().id() << ((m_prefix == other.prefixId())) << endl; kDebug() << (m_prefix == other.prefixId()) << (m_localName == other.localNameId()) << (m_namespace == other.namespaceNameId()) << endl;*/ return (m_prefix == other.prefixId() && m_localName == other.localNameId() && m_namespace == other.namespaceNameId()); }
false
false
false
false
false
0
ops_run_compute5(struct stripe_head *sh, struct raid5_percpu *percpu) { int disks = sh->disks; struct page **xor_srcs = to_addr_page(percpu, 0); int target = sh->ops.target; struct r5dev *tgt = &sh->dev[target]; struct page *xor_dest = tgt->page; int count = 0; struct dma_async_tx_descriptor *tx; struct async_submit_ctl submit; int i; BUG_ON(sh->batch_head); pr_debug("%s: stripe %llu block: %d\n", __func__, (unsigned long long)sh->sector, target); BUG_ON(!test_bit(R5_Wantcompute, &tgt->flags)); for (i = disks; i--; ) if (i != target) xor_srcs[count++] = sh->dev[i].page; atomic_inc(&sh->count); init_async_submit(&submit, ASYNC_TX_FENCE|ASYNC_TX_XOR_ZERO_DST, NULL, ops_complete_compute, sh, to_addr_conv(sh, percpu, 0)); if (unlikely(count == 1)) tx = async_memcpy(xor_dest, xor_srcs[0], 0, 0, STRIPE_SIZE, &submit); else tx = async_xor(xor_dest, xor_srcs, 0, count, STRIPE_SIZE, &submit); return tx; }
false
false
false
false
false
0
RFCNB_Recv(void *con_Handle, struct RFCNB_Pkt *Data, int Length) { struct RFCNB_Pkt *pkt; /* struct RFCNB_Hdr *hdr; */ int ret_len; if (con_Handle == NULL){ RFCNB_errno = RFCNBE_BadHandle; RFCNB_saved_errno = errno; return(RFCNBE_Bad); } /* Now get a packet from below. We allocate a header first */ /* Plug in the header and send the data */ pkt = RFCNB_Alloc_Pkt(RFCNB_Pkt_Hdr_Len); if (pkt == NULL) { RFCNB_errno = RFCNBE_NoSpace; RFCNB_saved_errno = errno; return(RFCNBE_Bad); } pkt -> next = Data; /* Plug in the data portion */ if ((ret_len = RFCNB_Get_Pkt(con_Handle, pkt, Length + RFCNB_Pkt_Hdr_Len)) < 0) { #ifdef RFCNB_DEBUG fprintf(stderr, "Bad packet return in RFCNB_Recv... \n"); #endif return(RFCNBE_Bad); } /* We should check that we go a message and not a keep alive */ pkt -> next = NULL; RFCNB_Free_Pkt(pkt); return(ret_len); }
false
false
false
false
false
0
_e_mod_menu_populate_filter(void *data __UNUSED__, Eio_File *handler __UNUSED__, const Eina_File_Direct_Info *info) { struct stat st; /* don't show .dotfiles */ if (fileman_config->view.menu_shows_files) return (info->path[info->name_start] != '.'); if (lstat(info->path, &st)) return EINA_FALSE; /* don't show links to prevent infinite submenus */ return (info->path[info->name_start] != '.') && (info->type == EINA_FILE_DIR) && (!S_ISLNK(st.st_mode)); }
false
false
false
false
false
0
utf8_idpb(char *utf8_text,uint32 ch) { /* Increment and deposit character */ if ( ch<0 || ch>=17*65536 ) return( utf8_text ); if ( ch<=127 ) *utf8_text++ = ch; else if ( ch<=0x7ff ) { *utf8_text++ = 0xc0 | (ch>>6); *utf8_text++ = 0x80 | (ch&0x3f); } else if ( ch<=0xffff ) { *utf8_text++ = 0xe0 | (ch>>12); *utf8_text++ = 0x80 | ((ch>>6)&0x3f); *utf8_text++ = 0x80 | (ch&0x3f); } else { uint32 val = ch-0x10000; int u = ((val&0xf0000)>>16)+1, z=(val&0x0f000)>>12, y=(val&0x00fc0)>>6, x=val&0x0003f; *utf8_text++ = 0xf0 | (u>>2); *utf8_text++ = 0x80 | ((u&3)<<4) | z; *utf8_text++ = 0x80 | y; *utf8_text++ = 0x80 | x; } return( utf8_text ); }
false
false
false
false
false
0
set_db_type(const char *name) { if (catalog_db != NULL) { free(catalog_db); } catalog_db = bstrdup(name); }
false
false
false
false
false
0
setBeforeClosingText(const QString & filename, QMessageBox & messageBox) { QString basename = QFileInfo(filename).fileName(); messageBox.setWindowTitle(tr("Save \"%1\"").arg(basename)); messageBox.setText(tr("Do you want to save the changes you made in the document \"%1\"?").arg(basename)); messageBox.setInformativeText(tr("Your changes will be lost if you don't save them.")); }
false
false
false
false
false
0