idx
int64
func
string
target
int64
210,511
win_close(win_T *win, int free_buf) { win_T *wp; int other_buffer = FALSE; int close_curwin = FALSE; int dir; int help_window = FALSE; tabpage_T *prev_curtab = curtab; frame_T *win_frame = win->w_frame->fr_parent; #ifdef FEAT_DIFF int had_diffmode = win->w_p_diff; #endif #ifdef MESSAGE_QUEUE int did_decrement = FALSE; #endif #if defined(FEAT_TERMINAL) && defined(FEAT_PROP_POPUP) // Can close a popup window with a terminal if the job has finished. if (may_close_term_popup() == OK) return OK; #endif if (ERROR_IF_ANY_POPUP_WINDOW) return FAIL; if (last_window()) { emsg(_(e_cannot_close_last_window)); return FAIL; } if (win->w_closing || (win->w_buffer != NULL && win->w_buffer->b_locked > 0)) return FAIL; // window is already being closed if (win_unlisted(win)) { emsg(_(e_cannot_close_autocmd_or_popup_window)); return FAIL; } if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window()) { emsg(_(e_cannot_close_window_only_autocmd_window_would_remain)); return FAIL; } // When closing the last window in a tab page first go to another tab page // and then close the window and the tab page to avoid that curwin and // curtab are invalid while we are freeing memory. if (close_last_window_tabpage(win, free_buf, prev_curtab)) return FAIL; // When closing the help window, try restoring a snapshot after closing // the window. Otherwise clear the snapshot, it's now invalid. if (bt_help(win->w_buffer)) help_window = TRUE; else clear_snapshot(curtab, SNAP_HELP_IDX); if (win == curwin) { #ifdef FEAT_JOB_CHANNEL leaving_window(curwin); #endif /* * Guess which window is going to be the new current window. * This may change because of the autocommands (sigh). */ wp = frame2win(win_altframe(win, NULL)); /* * Be careful: If autocommands delete the window or cause this window * to be the last one left, return now. */ if (wp->w_buffer != curbuf) { other_buffer = TRUE; win->w_closing = TRUE; apply_autocmds(EVENT_BUFLEAVE, NULL, NULL, FALSE, curbuf); if (!win_valid(win)) return FAIL; win->w_closing = FALSE; if (last_window()) return FAIL; } win->w_closing = TRUE; apply_autocmds(EVENT_WINLEAVE, NULL, NULL, FALSE, curbuf); if (!win_valid(win)) return FAIL; win->w_closing = FALSE; if (last_window()) return FAIL; #ifdef FEAT_EVAL // autocmds may abort script processing if (aborting()) return FAIL; #endif } #ifdef FEAT_GUI // Avoid trouble with scrollbars that are going to be deleted in // win_free(). if (gui.in_use) out_flush(); #endif #ifdef FEAT_PROP_POPUP if (popup_win_closed(win) && !win_valid(win)) return FAIL; #endif // Trigger WinClosed just before starting to free window-related resources. trigger_winclosed(win); // autocmd may have freed the window already. if (!win_valid_any_tab(win)) return OK; win_close_buffer(win, free_buf ? DOBUF_UNLOAD : 0, TRUE); if (only_one_window() && win_valid(win) && win->w_buffer == NULL && (last_window() || curtab != prev_curtab || close_last_window_tabpage(win, free_buf, prev_curtab))) { // Autocommands have closed all windows, quit now. Restore // curwin->w_buffer, otherwise writing viminfo may fail. if (curwin->w_buffer == NULL) curwin->w_buffer = curbuf; getout(0); } // Autocommands may have moved to another tab page. if (curtab != prev_curtab && win_valid_any_tab(win) && win->w_buffer == NULL) { // Need to close the window anyway, since the buffer is NULL. win_close_othertab(win, FALSE, prev_curtab); return FAIL; } // Autocommands may have closed the window already or closed the only // other window. if (!win_valid(win) || last_window() || close_last_window_tabpage(win, free_buf, prev_curtab)) return FAIL; // Now we are really going to close the window. Disallow any autocommand // to split a window to avoid trouble. // Also bail out of parse_queued_messages() to avoid it tries to update the // screen. ++split_disallowed; #ifdef MESSAGE_QUEUE ++dont_parse_messages; #endif // Free the memory used for the window and get the window that received // the screen space. wp = win_free_mem(win, &dir, NULL); if (help_window) { // Closing the help window moves the cursor back to the current window // of the snapshot. win_T *prev_win = get_snapshot_curwin(SNAP_HELP_IDX); if (win_valid(prev_win)) wp = prev_win; } // Make sure curwin isn't invalid. It can cause severe trouble when // printing an error message. For win_equal() curbuf needs to be valid // too. if (win == curwin) { curwin = wp; #ifdef FEAT_QUICKFIX if (wp->w_p_pvw || bt_quickfix(wp->w_buffer)) { /* * If the cursor goes to the preview or the quickfix window, try * finding another window to go to. */ for (;;) { if (wp->w_next == NULL) wp = firstwin; else wp = wp->w_next; if (wp == curwin) break; if (!wp->w_p_pvw && !bt_quickfix(wp->w_buffer)) { curwin = wp; break; } } } #endif curbuf = curwin->w_buffer; close_curwin = TRUE; // The cursor position may be invalid if the buffer changed after last // using the window. check_cursor(); } if (p_ea && (*p_ead == 'b' || *p_ead == dir)) // If the frame of the closed window contains the new current window, // only resize that frame. Otherwise resize all windows. win_equal(curwin, curwin->w_frame->fr_parent == win_frame, dir); else win_comp_pos(); if (close_curwin) { // Pass WEE_ALLOW_PARSE_MESSAGES to decrement dont_parse_messages // before autocommands. #ifdef MESSAGE_QUEUE did_decrement = #else (void) #endif win_enter_ext(wp, WEE_CURWIN_INVALID | WEE_TRIGGER_ENTER_AUTOCMDS | WEE_TRIGGER_LEAVE_AUTOCMDS | WEE_ALLOW_PARSE_MESSAGES); if (other_buffer) // careful: after this wp and win may be invalid! apply_autocmds(EVENT_BUFENTER, NULL, NULL, FALSE, curbuf); } --split_disallowed; #ifdef MESSAGE_QUEUE if (!did_decrement) --dont_parse_messages; #endif /* * If last window has a status line now and we don't want one, * remove the status line. */ last_status(FALSE); // After closing the help window, try restoring the window layout from // before it was opened. if (help_window) restore_snapshot(SNAP_HELP_IDX, close_curwin); #ifdef FEAT_DIFF // If the window had 'diff' set and now there is only one window left in // the tab page with 'diff' set, and "closeoff" is in 'diffopt', then // execute ":diffoff!". if (diffopt_closeoff() && had_diffmode && curtab == prev_curtab) { int diffcount = 0; win_T *dwin; FOR_ALL_WINDOWS(dwin) if (dwin->w_p_diff) ++diffcount; if (diffcount == 1) do_cmdline_cmd((char_u *)"diffoff!"); } #endif #if defined(FEAT_GUI) // When 'guioptions' includes 'L' or 'R' may have to remove scrollbars. if (gui.in_use && !win_hasvertsplit()) gui_init_which_components(NULL); #endif redraw_all_later(NOT_VALID); return OK; }
1
238,595
static void sanitize_mark_insn_seen(struct bpf_verifier_env *env) { struct bpf_verifier_state *vstate = env->cur_state; /* If we simulate paths under speculation, we don't update the * insn as 'seen' such that when we verify unreachable paths in * the non-speculative domain, sanitize_dead_code() can still * rewrite/sanitize them. */ if (!vstate->speculative) env->insn_aux_data[env->insn_idx].seen = env->pass_cnt; }
0
337,813
static struct sctp_chunk *sctp_make_reconf(const struct sctp_association *asoc, int length) { struct sctp_reconf_chunk *reconf; struct sctp_chunk *retval; retval = sctp_make_control(asoc, SCTP_CID_RECONF, 0, length, GFP_ATOMIC); if (!retval) return NULL; reconf = (struct sctp_reconf_chunk *)retval->chunk_hdr; retval->param_hdr.v = reconf->params; return retval; }
0
386,482
int DL_Dxf::getLibVersion(const std::string& str) { int d[4]; int idx = 0; //char v[4][5]; std::string v[4]; int ret = 0; for (unsigned int i=0; i<str.length() && idx<3; ++i) { if (str[i]=='.') { d[idx] = i; idx++; } } if (idx>=2) { d[3] = str.length(); v[0] = str.substr(0, d[0]); v[1] = str.substr(d[0]+1, d[1]-d[0]-1); v[2] = str.substr(d[1]+1, d[2]-d[1]-1); if (idx>=3) { v[3] = str.substr(d[2]+1, d[3]-d[2]-1); } else { v[3] = "0"; } ret = (atoi(v[0].c_str())<<(3*8)) + (atoi(v[1].c_str())<<(2*8)) + (atoi(v[2].c_str())<<(1*8)) + (atoi(v[3].c_str())<<(0*8)); return ret; } else { std::cerr << "DL_Dxf::getLibVersion: invalid version number: " << str << "\n"; return 0; } }
0
307,838
ciField* ciEnv::get_field_by_index_impl(ciInstanceKlass* accessor, int index) { ciConstantPoolCache* cache = accessor->field_cache(); if (cache == NULL) { ciField* field = new (arena()) ciField(accessor, index); return field; } else { ciField* field = (ciField*)cache->get(index); if (field == NULL) { field = new (arena()) ciField(accessor, index); cache->insert(index, field); } return field; } }
0
387,733
Method* InstanceKlass::lookup_method_in_all_interfaces(Symbol* name, Symbol* signature, DefaultsLookupMode defaults_mode) const { Array<Klass*>* all_ifs = transitive_interfaces(); int num_ifs = all_ifs->length(); InstanceKlass *ik = NULL; for (int i = 0; i < num_ifs; i++) { ik = InstanceKlass::cast(all_ifs->at(i)); Method* m = ik->lookup_method(name, signature); if (m != NULL && m->is_public() && !m->is_static() && ((defaults_mode != skip_defaults) || !m->is_default_method())) { return m; } } return NULL; }
0
436,100
/* when returns >0, the caller should retry */ static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx, struct io_wait_queue *iowq, signed long *timeout) { int ret; /* make sure we run task_work before checking for signals */ ret = io_run_task_work_sig(); if (ret || io_should_wake(iowq)) return ret; /* let the caller flush overflows, retry */ if (test_bit(0, &ctx->check_cq_overflow)) return 1; *timeout = schedule_timeout(*timeout); return !*timeout ? -ETIME : 1;
0
238,809
searchc(cmdarg_T *cap, int t_cmd) { int c = cap->nchar; // char to search for int dir = cap->arg; // TRUE for searching forward long count = cap->count1; // repeat count int col; char_u *p; int len; int stop = TRUE; if (c != NUL) // normal search: remember args for repeat { if (!KeyStuffed) // don't remember when redoing { *lastc = c; set_csearch_direction(dir); set_csearch_until(t_cmd); lastc_bytelen = (*mb_char2bytes)(c, lastc_bytes); if (cap->ncharC1 != 0) { lastc_bytelen += (*mb_char2bytes)(cap->ncharC1, lastc_bytes + lastc_bytelen); if (cap->ncharC2 != 0) lastc_bytelen += (*mb_char2bytes)(cap->ncharC2, lastc_bytes + lastc_bytelen); } } } else // repeat previous search { if (*lastc == NUL && lastc_bytelen == 1) return FAIL; if (dir) // repeat in opposite direction dir = -lastcdir; else dir = lastcdir; t_cmd = last_t_cmd; c = *lastc; // For multi-byte re-use last lastc_bytes[] and lastc_bytelen. // Force a move of at least one char, so ";" and "," will move the // cursor, even if the cursor is right in front of char we are looking // at. if (vim_strchr(p_cpo, CPO_SCOLON) == NULL && count == 1 && t_cmd) stop = FALSE; } if (dir == BACKWARD) cap->oap->inclusive = FALSE; else cap->oap->inclusive = TRUE; p = ml_get_curline(); col = curwin->w_cursor.col; len = (int)STRLEN(p); while (count--) { if (has_mbyte) { for (;;) { if (dir > 0) { col += (*mb_ptr2len)(p + col); if (col >= len) return FAIL; } else { if (col == 0) return FAIL; col -= (*mb_head_off)(p, p + col - 1) + 1; } if (lastc_bytelen == 1) { if (p[col] == c && stop) break; } else if (STRNCMP(p + col, lastc_bytes, lastc_bytelen) == 0 && stop) break; stop = TRUE; } } else { for (;;) { if ((col += dir) < 0 || col >= len) return FAIL; if (p[col] == c && stop) break; stop = TRUE; } } } if (t_cmd) { // backup to before the character (possibly double-byte) col -= dir; if (has_mbyte) { if (dir < 0) // Landed on the search char which is lastc_bytelen long col += lastc_bytelen - 1; else // To previous char, which may be multi-byte. col -= (*mb_head_off)(p, p + col); } } curwin->w_cursor.col = col; return OK; }
0
412,131
dnsc_shared_secrets_sizefunc(void *k, void* ATTR_UNUSED(d)) { struct shared_secret_cache_key* ssk = (struct shared_secret_cache_key*)k; size_t key_size = sizeof(struct shared_secret_cache_key) + lock_get_mem(&ssk->entry.lock); size_t data_size = crypto_box_BEFORENMBYTES; (void)ssk; /* otherwise ssk is unused if no threading, or fixed locksize */ return key_size + data_size; }
0
372,861
static int irda_recvmsg_stream(struct kiocb *iocb, struct socket *sock, struct msghdr *msg, size_t size, int flags) { struct sock *sk = sock->sk; struct irda_sock *self = irda_sk(sk); int noblock = flags & MSG_DONTWAIT; size_t copied = 0; int target, err; long timeo; IRDA_DEBUG(3, "%s()\n", __func__); if ((err = sock_error(sk)) < 0) return err; if (sock->flags & __SO_ACCEPTCON) return -EINVAL; err =-EOPNOTSUPP; if (flags & MSG_OOB) return -EOPNOTSUPP; err = 0; target = sock_rcvlowat(sk, flags & MSG_WAITALL, size); timeo = sock_rcvtimeo(sk, noblock); msg->msg_namelen = 0; do { int chunk; struct sk_buff *skb = skb_dequeue(&sk->sk_receive_queue); if (skb == NULL) { DEFINE_WAIT(wait); err = 0; if (copied >= target) break; prepare_to_wait_exclusive(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); /* * POSIX 1003.1g mandates this order. */ err = sock_error(sk); if (err) ; else if (sk->sk_shutdown & RCV_SHUTDOWN) ; else if (noblock) err = -EAGAIN; else if (signal_pending(current)) err = sock_intr_errno(timeo); else if (sk->sk_state != TCP_ESTABLISHED) err = -ENOTCONN; else if (skb_peek(&sk->sk_receive_queue) == NULL) /* Wait process until data arrives */ schedule(); finish_wait(sk_sleep(sk), &wait); if (err) return err; if (sk->sk_shutdown & RCV_SHUTDOWN) break; continue; } chunk = min_t(unsigned int, skb->len, size); if (memcpy_toiovec(msg->msg_iov, skb->data, chunk)) { skb_queue_head(&sk->sk_receive_queue, skb); if (copied == 0) copied = -EFAULT; break; } copied += chunk; size -= chunk; /* Mark read part of skb as used */ if (!(flags & MSG_PEEK)) { skb_pull(skb, chunk); /* put the skb back if we didn't use it up.. */ if (skb->len) { IRDA_DEBUG(1, "%s(), back on q!\n", __func__); skb_queue_head(&sk->sk_receive_queue, skb); break; } kfree_skb(skb); } else { IRDA_DEBUG(0, "%s() questionable!?\n", __func__); /* put message back and return */ skb_queue_head(&sk->sk_receive_queue, skb); break; } } while (size); /* * Check if we have previously stopped IrTTP and we know * have more free space in our rx_queue. If so tell IrTTP * to start delivering frames again before our rx_queue gets * empty */ if (self->rx_flow == FLOW_STOP) { if ((atomic_read(&sk->sk_rmem_alloc) << 2) <= sk->sk_rcvbuf) { IRDA_DEBUG(2, "%s(), Starting IrTTP\n", __func__); self->rx_flow = FLOW_START; irttp_flow_request(self->tsap, FLOW_START); } } return copied; }
0
226,011
void urn_box_del(GF_Box *s) { GF_DataEntryURNBox *ptr = (GF_DataEntryURNBox *)s; if (ptr == NULL) return; if (ptr->location) gf_free(ptr->location); if (ptr->nameURN) gf_free(ptr->nameURN); gf_free(ptr); }
0
482,486
allocateDisplayTable(const FileInfo *file, DisplayTableHeader **table) { /* Allocate memory for the table and a guess on the number of rules */ const TranslationTableOffset startSize = 2 * sizeof(**table); if (*table) return 1; TranslationTableOffset bytesUsed = sizeof(**table) + OFFSETSIZE; /* So no offset is ever zero */ if (!(*table = malloc(startSize))) { compileError(file, "Not enough memory"); if (*table != NULL) free(*table); *table = NULL; _lou_outOfMemory(); } memset(*table, 0, startSize); (*table)->tableSize = startSize; (*table)->bytesUsed = bytesUsed; return 1; }
0
261,202
int MqttClient_WaitMessage(MqttClient *client, int timeout_ms) { if (client == NULL) return MQTT_CODE_ERROR_BAD_ARG; return MqttClient_WaitMessage_ex(client, &client->msg, timeout_ms); }
0
212,095
MOBI_RET mobi_reconstruct_infl(char *outstring, const MOBIIndx *infl, const MOBIIndexEntry *orth_entry) { const char *label = orth_entry->label; uint32_t *infl_groups = NULL; size_t infl_count = mobi_get_indxentry_tagarray(&infl_groups, orth_entry, INDX_TAGARR_ORTH_INFL); if (infl_count == 0 || !infl_groups) { return MOBI_SUCCESS; } const char *start_tag = "<idx:infl>"; const char *end_tag = "</idx:infl>"; const char *iform_tag = "<idx:iform%s value=\"%s\"/>"; char name_attr[INDX_INFLBUF_SIZEMAX + 1]; char infl_tag[INDX_INFLBUF_SIZEMAX + 1]; strcpy(outstring, start_tag); size_t initlen = strlen(start_tag) + strlen(end_tag); size_t outlen = initlen; size_t label_length = strlen(label); if (label_length > INDX_INFLBUF_SIZEMAX) { debug_print("Entry label too long (%s)\n", label); return MOBI_DATA_CORRUPT; } if (infl->cncx_record == NULL) { debug_print("%s\n", "Missing cncx record"); return MOBI_DATA_CORRUPT; } for (size_t i = 0; i < infl_count; i++) { size_t offset = infl_groups[i]; if (offset >= infl->entries_count) { debug_print("%s\n", "Invalid entry offset"); return MOBI_DATA_CORRUPT; } uint32_t *groups; size_t group_cnt = mobi_get_indxentry_tagarray(&groups, &infl->entries[offset], INDX_TAGARR_INFL_GROUPS); uint32_t *parts; size_t part_cnt = mobi_get_indxentry_tagarray(&parts, &infl->entries[offset], INDX_TAGARR_INFL_PARTS_V2); if (group_cnt != part_cnt) { return MOBI_DATA_CORRUPT; } for (size_t j = 0; j < part_cnt; j++) { name_attr[0] = '\0'; char *group_name = mobi_get_cncx_string(infl->cncx_record, groups[j]); if (group_name == NULL) { debug_print("%s\n", "Memory allocation failed"); return MOBI_MALLOC_FAILED; } if (strlen(group_name)) { snprintf(name_attr, INDX_INFLBUF_SIZEMAX, " name=\"%s\"", group_name); } free(group_name); unsigned char decoded[INDX_INFLBUF_SIZEMAX + 1]; memset(decoded, 0, INDX_INFLBUF_SIZEMAX + 1); unsigned char *rule = (unsigned char *) infl->entries[parts[j]].label; memcpy(decoded, label, label_length); int decoded_length = (int) label_length; MOBI_RET ret = mobi_decode_infl(decoded, &decoded_length, rule); if (ret != MOBI_SUCCESS) { return ret; } if (decoded_length == 0) { continue; } int n = snprintf(infl_tag, INDX_INFLBUF_SIZEMAX, iform_tag, name_attr, decoded); if (n > INDX_INFLBUF_SIZEMAX) { debug_print("Skipping truncated tag: %s\n", infl_tag); continue; } outlen += strlen(infl_tag); if (outlen > INDX_INFLTAG_SIZEMAX) { debug_print("Inflections text in %s too long (%zu)\n", label, outlen); return MOBI_ERROR; } strcat(outstring, infl_tag); } } if (outlen == initlen) { outstring[0] = '\0'; } else { strcat(outstring, end_tag); } return MOBI_SUCCESS; }
1
90,884
void ClientUsageTracker::AddCachedHost(const std::string& host) { cached_hosts_.insert(host); }
0
245,704
static int pull_client_data_chunked (struct conn_s *connptr) { char *buffer = 0; ssize_t len; long chunklen; while(1) { if (buffer) safefree(buffer); len = readline (connptr->client_fd, &buffer); if (len <= 0) goto ERROR_EXIT; if (!connptr->error_variables) { if (safe_write (connptr->server_fd, buffer, len) < 0) goto ERROR_EXIT; } chunklen = strtol (buffer, (char**)0, 16); if (pull_client_data (connptr, chunklen+2, 0) < 0) goto ERROR_EXIT; if(!chunklen) break; } safefree (buffer); return 0; ERROR_EXIT: safefree (buffer); return -1; }
0
318,977
f_test_null_list(typval_T *argvars UNUSED, typval_T *rettv) { rettv_list_set(rettv, NULL); }
0
462,556
void controller::write_item(std::shared_ptr<rss_item> item, const std::string& filename) { std::fstream f; f.open(filename.c_str(),std::fstream::out); if (!f.is_open()) throw exception(errno); write_item(item, f); }
0
512,435
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate) { return get_date_from_string(thd, ltime, fuzzydate); }
0
361,745
static int em28xx_usb_resume(struct usb_interface *intf) { struct em28xx *dev; dev = usb_get_intfdata(intf); if (!dev) return 0; em28xx_resume_extension(dev); return 0; }
0
454,757
static int ismt_int_init(struct ismt_priv *priv) { int err; /* Try using MSI interrupts */ err = pci_enable_msi(priv->pci_dev); if (err) goto intx; err = devm_request_irq(&priv->pci_dev->dev, priv->pci_dev->irq, ismt_do_msi_interrupt, 0, "ismt-msi", priv); if (err) { pci_disable_msi(priv->pci_dev); goto intx; } return 0; /* Try using legacy interrupts */ intx: dev_warn(&priv->pci_dev->dev, "Unable to use MSI interrupts, falling back to legacy\n"); err = devm_request_irq(&priv->pci_dev->dev, priv->pci_dev->irq, ismt_do_interrupt, IRQF_SHARED, "ismt-intx", priv); if (err) { dev_err(&priv->pci_dev->dev, "no usable interrupts\n"); return err; } return 0; }
0
219,996
int callback_glewlwyd_get_user_module (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_module; j_module = get_user_module(config, u_map_get(request->map_url, "name")); if (check_result_value(j_module, G_OK)) { ulfius_set_json_body_response(response, 200, json_object_get(j_module, "module")); } else if (check_result_value(j_module, G_ERROR_NOT_FOUND)) { response->status = 404; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_get_user_module - Error get_user_module"); response->status = 500; } json_decref(j_module); return U_CALLBACK_CONTINUE; }
0
221,132
GF_AV1Config *gf_odf_av1_cfg_read_bs(GF_BitStream *bs) { return gf_odf_av1_cfg_read_bs_size(bs, 0); }
0
338,138
void WasmBinaryBuilder::visitRefFunc(RefFunc* curr) { BYN_TRACE("zz node: RefFunc\n"); Index index = getU32LEB(); // We don't know function names yet, so record this use to be updated later. // Note that we do not need to check that 'index' is in bounds, as that will // be verified in the next line. (Also, note that functionRefs[index] may // write to an odd place in the functionRefs map if index is invalid, but that // is harmless.) functionRefs[index].push_back(curr); // To support typed function refs, we give the reference not just a general // funcref, but a specific subtype with the actual signature. curr->finalize(Type(getTypeByFunctionIndex(index), NonNullable)); }
0
221,178
GF_Err gf_odf_encode_ui_config(GF_UIConfig *cfg, GF_DefaultDescriptor **out_dsi) { u32 i, len; GF_BitStream *bs; GF_DefaultDescriptor *dsi; if (!out_dsi || (cfg->tag != GF_ODF_UI_CFG_TAG)) return GF_BAD_PARAM; *out_dsi = NULL; if (!cfg->deviceName) return GF_OK; bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE); len = (u32) strlen(cfg->deviceName); gf_bs_write_int(bs, len, 8); for (i=0; i<len; i++) gf_bs_write_int(bs, cfg->deviceName[i], 8); if (!stricmp(cfg->deviceName, "StringSensor")) { /*fixme - this should be UTF-8 chars*/ if (cfg->delChar || cfg->termChar) { gf_bs_write_int(bs, cfg->termChar, 8); gf_bs_write_int(bs, cfg->delChar, 8); } } if (cfg->ui_data) gf_bs_write_data(bs, cfg->ui_data, cfg->ui_data_length); dsi = (GF_DefaultDescriptor *) gf_odf_desc_new(GF_ODF_DSI_TAG); gf_bs_get_content(bs, &dsi->data, &dsi->dataLength); gf_bs_del(bs); *out_dsi = dsi; return GF_OK; }
0
247,734
setExpectedRequestedServerName(const std::string& expected_requested_server_name) { expected_requested_server_name_ = expected_requested_server_name; return *this; }
0
309,949
rewrite_sgr(char *s, char *attr) { if (s != 0) { if (PRESENT(attr)) { size_t len_s = strlen(s); size_t len_a = strlen(attr); if (len_s > len_a && !strncmp(attr, s, len_a)) { unsigned n; TR(TRACE_DATABASE, ("rewrite:\n\t%s", s)); for (n = 0; n < len_s - len_a; ++n) { s[n] = s[n + len_a]; } _nc_STRCPY(s + n, attr, strlen(s) + 1); TR(TRACE_DATABASE, ("to:\n\t%s", s)); } } return TRUE; } return FALSE; /* oops */ }
0
459,172
tc_cls_offload_cnt_reset(struct tcf_block *block, struct tcf_proto *tp, u32 *cnt, u32 *flags) { lockdep_assert_held(&block->cb_lock); spin_lock(&tp->lock); tcf_block_offload_dec(block, flags); *cnt = 0; spin_unlock(&tp->lock); }
0
338,081
void WasmBinaryBuilder::readHeader() { BYN_TRACE("== readHeader\n"); verifyInt32(BinaryConsts::Magic); verifyInt32(BinaryConsts::Version); }
0
244,125
GF_Err mhac_box_write(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_MHAConfigBox *ptr = (GF_MHAConfigBox *) s; e = gf_isom_box_write_header(s, bs); if (e) return e; gf_bs_write_u8(bs, ptr->configuration_version); gf_bs_write_u8(bs, ptr->mha_pl_indication); gf_bs_write_u8(bs, ptr->reference_channel_layout); gf_bs_write_u16(bs, ptr->mha_config ? ptr->mha_config_size : 0); if (ptr->mha_config && ptr->mha_config_size) gf_bs_write_data(bs, ptr->mha_config, ptr->mha_config_size); return GF_OK; }
0
253,545
smb2_make_node(unsigned int xid, struct inode *inode, struct dentry *dentry, struct cifs_tcon *tcon, const char *full_path, umode_t mode, dev_t dev) { struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); int rc = -EPERM; FILE_ALL_INFO *buf = NULL; struct cifs_io_parms io_parms = {0}; __u32 oplock = 0; struct cifs_fid fid; struct cifs_open_parms oparms; unsigned int bytes_written; struct win_dev *pdev; struct kvec iov[2]; /* * Check if mounted with mount parm 'sfu' mount parm. * SFU emulation should work with all servers, but only * supports block and char device (no socket & fifo), * and was used by default in earlier versions of Windows */ if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)) goto out; /* * TODO: Add ability to create instead via reparse point. Windows (e.g. * their current NFS server) uses this approach to expose special files * over SMB2/SMB3 and Samba will do this with SMB3.1.1 POSIX Extensions */ if (!S_ISCHR(mode) && !S_ISBLK(mode)) goto out; cifs_dbg(FYI, "sfu compat create special file\n"); buf = kmalloc(sizeof(FILE_ALL_INFO), GFP_KERNEL); if (buf == NULL) { rc = -ENOMEM; goto out; } oparms.tcon = tcon; oparms.cifs_sb = cifs_sb; oparms.desired_access = GENERIC_WRITE; oparms.create_options = cifs_create_options(cifs_sb, CREATE_NOT_DIR | CREATE_OPTION_SPECIAL); oparms.disposition = FILE_CREATE; oparms.path = full_path; oparms.fid = &fid; oparms.reconnect = false; if (tcon->ses->server->oplocks) oplock = REQ_OPLOCK; else oplock = 0; rc = tcon->ses->server->ops->open(xid, &oparms, &oplock, buf); if (rc) goto out; /* * BB Do not bother to decode buf since no local inode yet to put * timestamps in, but we can reuse it safely. */ pdev = (struct win_dev *)buf; io_parms.pid = current->tgid; io_parms.tcon = tcon; io_parms.offset = 0; io_parms.length = sizeof(struct win_dev); iov[1].iov_base = buf; iov[1].iov_len = sizeof(struct win_dev); if (S_ISCHR(mode)) { memcpy(pdev->type, "IntxCHR", 8); pdev->major = cpu_to_le64(MAJOR(dev)); pdev->minor = cpu_to_le64(MINOR(dev)); rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms, &bytes_written, iov, 1); } else if (S_ISBLK(mode)) { memcpy(pdev->type, "IntxBLK", 8); pdev->major = cpu_to_le64(MAJOR(dev)); pdev->minor = cpu_to_le64(MINOR(dev)); rc = tcon->ses->server->ops->sync_write(xid, &fid, &io_parms, &bytes_written, iov, 1); } tcon->ses->server->ops->close(xid, tcon, &fid); d_drop(dentry); /* FIXME: add code here to set EAs */ out: kfree(buf); return rc; }
0
259,081
void RestoreTensor(OpKernelContext* context, checkpoint::TensorSliceReader::OpenTableFunction open_func, int preferred_shard, bool restore_slice, int restore_index) { const Tensor& file_pattern_t = context->input(0); { const int64_t size = file_pattern_t.NumElements(); OP_REQUIRES( context, size == 1, errors::InvalidArgument( "Input 0 (file_pattern) must be a string scalar; got a tensor of ", size, " elements")); } const string& file_pattern = file_pattern_t.flat<tstring>()(0); const Tensor& tensor_name_t = context->input(1); { const int64_t size = tensor_name_t.NumElements(); OP_REQUIRES(context, size > restore_index, errors::InvalidArgument( "Input 1 (file_pattern) must be a have at least ", restore_index + 1, " elements")); } const string& tensor_name = tensor_name_t.flat<tstring>()(restore_index); // If we cannot find a cached reader we will allocate our own. std::unique_ptr<checkpoint::TensorSliceReader> allocated_reader; const checkpoint::TensorSliceReader* reader = nullptr; if (context->slice_reader_cache()) { reader = context->slice_reader_cache()->GetReader(file_pattern, open_func, preferred_shard); } if (!reader) { allocated_reader.reset(new checkpoint::TensorSliceReader( file_pattern, open_func, preferred_shard)); reader = allocated_reader.get(); } OP_REQUIRES_OK(context, CHECK_NOTNULL(reader)->status()); // Get the shape and type from the save file. DataType type; TensorShape saved_shape; OP_REQUIRES( context, reader->HasTensor(tensor_name, &saved_shape, &type), errors::NotFound("Tensor name \"", tensor_name, "\" not found in checkpoint files ", file_pattern)); OP_REQUIRES( context, type == context->expected_output_dtype(restore_index), errors::InvalidArgument("Expected to restore a tensor of type ", DataTypeString(context->expected_output_dtype(0)), ", got a tensor of type ", DataTypeString(type), " instead: tensor_name = ", tensor_name)); // Shape of the output and slice to load. TensorShape output_shape(saved_shape); TensorSlice slice_to_load(saved_shape.dims()); if (restore_slice) { const tstring& shape_spec = context->input(2).flat<tstring>()(restore_index); if (!shape_spec.empty()) { TensorShape parsed_shape; OP_REQUIRES_OK(context, checkpoint::ParseShapeAndSlice( shape_spec, &parsed_shape, &slice_to_load, &output_shape)); OP_REQUIRES( context, parsed_shape.IsSameSize(saved_shape), errors::InvalidArgument( "Shape in shape_and_slice spec does not match the shape in the " "save file: ", parsed_shape.DebugString(), ", save file shape: ", saved_shape.DebugString())); } } Tensor* t = nullptr; OP_REQUIRES_OK(context, context->allocate_output(restore_index, output_shape, &t)); if (output_shape.num_elements() == 0) return; #define READER_COPY(T) \ case DataTypeToEnum<T>::value: \ OP_REQUIRES(context, \ reader->CopySliceData(tensor_name, slice_to_load, \ t->flat<T>().data()), \ errors::InvalidArgument("Error copying slice data")); \ break; switch (type) { TF_CALL_SAVE_RESTORE_TYPES(READER_COPY) default: context->SetStatus(errors::Unimplemented( "Restoring data type ", DataTypeString(type), " not yet supported")); } #undef READER_COPY }
0
468,372
connection_attempt_new (void) { ConnectionAttempt *attempt = g_new0 (ConnectionAttempt, 1); g_ref_count_init (&attempt->ref); return attempt; }
0
278,254
set_indent( int size, // measured in spaces int flags) { char_u *p; char_u *newline; char_u *oldline; char_u *s; int todo; int ind_len; // measured in characters int line_len; int doit = FALSE; int ind_done = 0; // measured in spaces #ifdef FEAT_VARTABS int ind_col = 0; #endif int tab_pad; int retval = FALSE; int orig_char_len = -1; // number of initial whitespace chars when // 'et' and 'pi' are both set // First check if there is anything to do and compute the number of // characters needed for the indent. todo = size; ind_len = 0; p = oldline = ml_get_curline(); // Calculate the buffer size for the new indent, and check to see if it // isn't already set // if 'expandtab' isn't set: use TABs; if both 'expandtab' and // 'preserveindent' are set count the number of characters at the // beginning of the line to be copied if (!curbuf->b_p_et || (!(flags & SIN_INSERT) && curbuf->b_p_pi)) { // If 'preserveindent' is set then reuse as much as possible of // the existing indent structure for the new indent if (!(flags & SIN_INSERT) && curbuf->b_p_pi) { ind_done = 0; // count as many characters as we can use while (todo > 0 && VIM_ISWHITE(*p)) { if (*p == TAB) { #ifdef FEAT_VARTABS tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts, curbuf->b_p_vts_array); #else tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts); #endif // stop if this tab will overshoot the target if (todo < tab_pad) break; todo -= tab_pad; ++ind_len; ind_done += tab_pad; } else { --todo; ++ind_len; ++ind_done; } ++p; } #ifdef FEAT_VARTABS // These diverge from this point. ind_col = ind_done; #endif // Set initial number of whitespace chars to copy if we are // preserving indent but expandtab is set if (curbuf->b_p_et) orig_char_len = ind_len; // Fill to next tabstop with a tab, if possible #ifdef FEAT_VARTABS tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts, curbuf->b_p_vts_array); #else tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts); #endif if (todo >= tab_pad && orig_char_len == -1) { doit = TRUE; todo -= tab_pad; ++ind_len; // ind_done += tab_pad; #ifdef FEAT_VARTABS ind_col += tab_pad; #endif } } // count tabs required for indent #ifdef FEAT_VARTABS for (;;) { tab_pad = tabstop_padding(ind_col, curbuf->b_p_ts, curbuf->b_p_vts_array); if (todo < tab_pad) break; if (*p != TAB) doit = TRUE; else ++p; todo -= tab_pad; ++ind_len; ind_col += tab_pad; } #else while (todo >= (int)curbuf->b_p_ts) { if (*p != TAB) doit = TRUE; else ++p; todo -= (int)curbuf->b_p_ts; ++ind_len; // ind_done += (int)curbuf->b_p_ts; } #endif } // count spaces required for indent while (todo > 0) { if (*p != ' ') doit = TRUE; else ++p; --todo; ++ind_len; // ++ind_done; } // Return if the indent is OK already. if (!doit && !VIM_ISWHITE(*p) && !(flags & SIN_INSERT)) return FALSE; // Allocate memory for the new line. if (flags & SIN_INSERT) p = oldline; else p = skipwhite(p); line_len = (int)STRLEN(p) + 1; // If 'preserveindent' and 'expandtab' are both set keep the original // characters and allocate accordingly. We will fill the rest with spaces // after the if (!curbuf->b_p_et) below. if (orig_char_len != -1) { newline = alloc(orig_char_len + size - ind_done + line_len); if (newline == NULL) return FALSE; todo = size - ind_done; ind_len = orig_char_len + todo; // Set total length of indent in // characters, which may have been // undercounted until now p = oldline; s = newline; while (orig_char_len > 0) { *s++ = *p++; orig_char_len--; } // Skip over any additional white space (useful when newindent is less // than old) while (VIM_ISWHITE(*p)) ++p; } else { todo = size; newline = alloc(ind_len + line_len); if (newline == NULL) return FALSE; s = newline; } // Put the characters in the new line. // if 'expandtab' isn't set: use TABs if (!curbuf->b_p_et) { // If 'preserveindent' is set then reuse as much as possible of // the existing indent structure for the new indent if (!(flags & SIN_INSERT) && curbuf->b_p_pi) { p = oldline; ind_done = 0; while (todo > 0 && VIM_ISWHITE(*p)) { if (*p == TAB) { #ifdef FEAT_VARTABS tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts, curbuf->b_p_vts_array); #else tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts); #endif // stop if this tab will overshoot the target if (todo < tab_pad) break; todo -= tab_pad; ind_done += tab_pad; } else { --todo; ++ind_done; } *s++ = *p++; } // Fill to next tabstop with a tab, if possible #ifdef FEAT_VARTABS tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts, curbuf->b_p_vts_array); #else tab_pad = (int)curbuf->b_p_ts - (ind_done % (int)curbuf->b_p_ts); #endif if (todo >= tab_pad) { *s++ = TAB; todo -= tab_pad; #ifdef FEAT_VARTABS ind_done += tab_pad; #endif } p = skipwhite(p); } #ifdef FEAT_VARTABS for (;;) { tab_pad = tabstop_padding(ind_done, curbuf->b_p_ts, curbuf->b_p_vts_array); if (todo < tab_pad) break; *s++ = TAB; todo -= tab_pad; ind_done += tab_pad; } #else while (todo >= (int)curbuf->b_p_ts) { *s++ = TAB; todo -= (int)curbuf->b_p_ts; } #endif } while (todo > 0) { *s++ = ' '; --todo; } mch_memmove(s, p, (size_t)line_len); // Replace the line (unless undo fails). if (!(flags & SIN_UNDO) || u_savesub(curwin->w_cursor.lnum) == OK) { colnr_T old_offset = (colnr_T)(p - oldline); colnr_T new_offset = (colnr_T)(s - newline); // this may free "newline" ml_replace(curwin->w_cursor.lnum, newline, FALSE); if (flags & SIN_CHANGED) changed_bytes(curwin->w_cursor.lnum, 0); // Correct saved cursor position if it is in this line. if (saved_cursor.lnum == curwin->w_cursor.lnum) { if (saved_cursor.col >= old_offset) // cursor was after the indent, adjust for the number of // bytes added/removed saved_cursor.col += ind_len - old_offset; else if (saved_cursor.col >= new_offset) // cursor was in the indent, and is now after it, put it back // at the start of the indent (replacing spaces with TAB) saved_cursor.col = new_offset; } #ifdef FEAT_PROP_POPUP { int added = ind_len - old_offset; // When increasing indent this behaves like spaces were inserted at // the old indent, when decreasing indent it behaves like spaces // were deleted at the new indent. adjust_prop_columns(curwin->w_cursor.lnum, added > 0 ? old_offset : (colnr_T)ind_len, added, 0); } #endif retval = TRUE; } else vim_free(newline); curwin->w_cursor.col = ind_len; return retval; }
0
512,604
String *val_str(String *to) { DBUG_ASSERT(sane()); return null_value ? NULL : m_value.to_datetime(current_thd).to_string(to, decimals); }
0
222,918
DisjointSet() {}
0
492,691
vte_sequence_handler_ic (VteTerminal *terminal, GValueArray *params) { VteVisualPosition save; VteScreen *screen; screen = terminal->pvt->screen; save = screen->cursor_current; _vte_terminal_insert_char(terminal, ' ', TRUE, TRUE); screen->cursor_current = save; }
0
373,520
ipf_is_v6_frag(ovs_be16 ip6f_offlg) { if (ip6f_offlg & (IP6F_OFF_MASK | IP6F_MORE_FRAG)) { return true; } return false; }
0
238,494
static int insn_def_regno(const struct bpf_insn *insn) { switch (BPF_CLASS(insn->code)) { case BPF_JMP: case BPF_JMP32: case BPF_ST: return -1; case BPF_STX: if (BPF_MODE(insn->code) == BPF_ATOMIC && (insn->imm & BPF_FETCH)) { if (insn->imm == BPF_CMPXCHG) return BPF_REG_0; else return insn->src_reg; } else { return -1; } default: return insn->dst_reg; } }
0
401,568
static void do_init_timer(struct timer_list *timer, void (*func)(struct timer_list *), unsigned int flags, const char *name, struct lock_class_key *key) { timer->entry.pprev = NULL; timer->function = func; timer->flags = flags | raw_smp_processor_id(); lockdep_init_map(&timer->lockdep_map, name, key, 0); }
0
436,064
static void io_req_task_queue_fail(struct io_kiocb *req, int ret) { req->result = ret; req->io_task_work.func = io_req_task_cancel; io_req_task_work_add(req); }
0
247,640
TEST_P(SslSocketTest, FailedClientCertificateHashAndSpkiVerificationNoCAWrongClientCertificate) { envoy::config::listener::v3::Listener listener; envoy::config::listener::v3::FilterChain* filter_chain = listener.add_filter_chains(); envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context; envoy::extensions::transport_sockets::tls::v3::TlsCertificate* server_cert = tls_context.mutable_common_tls_context()->add_tls_certificates(); server_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_dns_cert.pem")); server_cert->mutable_private_key()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_dns_key.pem")); envoy::extensions::transport_sockets::tls::v3::CertificateValidationContext* server_validation_ctx = tls_context.mutable_common_tls_context()->mutable_validation_context(); server_validation_ctx->add_verify_certificate_hash( "0000000000000000000000000000000000000000000000000000000000000000"); server_validation_ctx->add_verify_certificate_spki(TEST_SAN_URI_CERT_SPKI); updateFilterChain(tls_context, *filter_chain); envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client; envoy::extensions::transport_sockets::tls::v3::TlsCertificate* client_cert = client.mutable_common_tls_context()->add_tls_certificates(); client_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/no_san_cert.pem")); client_cert->mutable_private_key()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/no_san_key.pem")); TestUtilOptionsV2 test_options(listener, client, false, GetParam()); testUtilV2(test_options.setExpectedServerStats("ssl.fail_verify_cert_hash") .setExpectedTransportFailureReasonContains("SSLV3_ALERT_CERTIFICATE_UNKNOWN")); // Fails even with client renegotiation. client.set_allow_renegotiation(true); testUtilV2(test_options); }
0
424,912
static u32 iwl_trans_pcie_read_prph(struct iwl_trans *trans, u32 reg) { u32 mask = iwl_trans_pcie_prph_msk(trans); iwl_trans_pcie_write32(trans, HBUS_TARG_PRPH_RADDR, ((reg & mask) | (3 << 24))); return iwl_trans_pcie_read32(trans, HBUS_TARG_PRPH_RDAT); }
0
450,434
static int zrle_send_framebuffer_update(VncState *vs, int x, int y, int w, int h) { bool be = vs->client_be; size_t bytes; int zywrle_level; if (vs->zrle->type == VNC_ENCODING_ZYWRLE) { if (!vs->vd->lossy || vs->tight->quality == (uint8_t)-1 || vs->tight->quality == 9) { zywrle_level = 0; vs->zrle->type = VNC_ENCODING_ZRLE; } else if (vs->tight->quality < 3) { zywrle_level = 3; } else if (vs->tight->quality < 6) { zywrle_level = 2; } else { zywrle_level = 1; } } else { zywrle_level = 0; } vnc_zrle_start(vs); switch (vs->client_pf.bytes_per_pixel) { case 1: zrle_encode_8ne(vs, x, y, w, h, zywrle_level); break; case 2: if (vs->client_pf.gmax > 0x1F) { if (be) { zrle_encode_16be(vs, x, y, w, h, zywrle_level); } else { zrle_encode_16le(vs, x, y, w, h, zywrle_level); } } else { if (be) { zrle_encode_15be(vs, x, y, w, h, zywrle_level); } else { zrle_encode_15le(vs, x, y, w, h, zywrle_level); } } break; case 4: { bool fits_in_ls3bytes; bool fits_in_ms3bytes; fits_in_ls3bytes = ((vs->client_pf.rmax << vs->client_pf.rshift) < (1 << 24) && (vs->client_pf.gmax << vs->client_pf.gshift) < (1 << 24) && (vs->client_pf.bmax << vs->client_pf.bshift) < (1 << 24)); fits_in_ms3bytes = (vs->client_pf.rshift > 7 && vs->client_pf.gshift > 7 && vs->client_pf.bshift > 7); if ((fits_in_ls3bytes && !be) || (fits_in_ms3bytes && be)) { if (be) { zrle_encode_24abe(vs, x, y, w, h, zywrle_level); } else { zrle_encode_24ale(vs, x, y, w, h, zywrle_level); } } else if ((fits_in_ls3bytes && be) || (fits_in_ms3bytes && !be)) { if (be) { zrle_encode_24bbe(vs, x, y, w, h, zywrle_level); } else { zrle_encode_24ble(vs, x, y, w, h, zywrle_level); } } else { if (be) { zrle_encode_32be(vs, x, y, w, h, zywrle_level); } else { zrle_encode_32le(vs, x, y, w, h, zywrle_level); } } } break; } vnc_zrle_stop(vs); bytes = zrle_compress_data(vs, Z_DEFAULT_COMPRESSION); vnc_framebuffer_update(vs, x, y, w, h, vs->zrle->type); vnc_write_u32(vs, bytes); vnc_write(vs, vs->zrle->zlib.buffer, vs->zrle->zlib.offset); return 1; }
0
216,973
create_worker_threads(uint n) { comp_thread_ctxt_t *threads; uint i; threads = (comp_thread_ctxt_t *) my_malloc(sizeof(comp_thread_ctxt_t) * n, MYF(MY_FAE)); for (i = 0; i < n; i++) { comp_thread_ctxt_t *thd = threads + i; thd->num = i + 1; thd->started = FALSE; thd->cancelled = FALSE; thd->data_avail = FALSE; thd->to = (char *) my_malloc(COMPRESS_CHUNK_SIZE + MY_QLZ_COMPRESS_OVERHEAD, MYF(MY_FAE)); /* Initialize the control mutex and condition var */ if (pthread_mutex_init(&thd->ctrl_mutex, NULL) || pthread_cond_init(&thd->ctrl_cond, NULL)) { goto err; } /* Initialize and data mutex and condition var */ if (pthread_mutex_init(&thd->data_mutex, NULL) || pthread_cond_init(&thd->data_cond, NULL)) { goto err; } pthread_mutex_lock(&thd->ctrl_mutex); if (pthread_create(&thd->id, NULL, compress_worker_thread_func, thd)) { msg("compress: pthread_create() failed: " "errno = %d", errno); goto err; } } /* Wait for the threads to start */ for (i = 0; i < n; i++) { comp_thread_ctxt_t *thd = threads + i; while (thd->started == FALSE) pthread_cond_wait(&thd->ctrl_cond, &thd->ctrl_mutex); pthread_mutex_unlock(&thd->ctrl_mutex); } return threads; err: my_free(threads); return NULL; }
1
502,693
long SSL_SESSION_set_time(SSL_SESSION *s, long t) { if (s == NULL) return (0); s->time = t; return (t); }
0
500,065
krb5_decrypt_tkt_part(krb5_context con, krb5_const krb5_keyblock *keys, krb5_ticket *ticket) { if (!krb5_loaded) load_krb5_dll(); if ( p_krb5_decrypt_tkt_part ) return(p_krb5_decrypt_tkt_part(con,keys,ticket)); else return KRB5KRB_ERR_GENERIC; }
0
238,807
get_spat(int idx) { return &spats[idx]; }
0
512,861
bool Item_func_between::fix_length_and_dec_numeric(THD *thd) { /* See the comment about the similar block in Item_bool_func2 */ if (args[0]->real_item()->type() == FIELD_ITEM && !thd->lex->is_ps_or_view_context_analysis()) { Item_field *field_item= (Item_field*) (args[0]->real_item()); if (field_item->field_type() == MYSQL_TYPE_LONGLONG || field_item->field_type() == MYSQL_TYPE_YEAR) { const bool cvt_arg1= convert_const_to_int(thd, field_item, &args[1]); const bool cvt_arg2= convert_const_to_int(thd, field_item, &args[2]); if (cvt_arg1 && cvt_arg2) { // Works for all types m_comparator.set_handler(&type_handler_longlong); } } } return FALSE; }
0
398,535
static void free_comp_unit(RzBinDwarfCompUnit *cu) { size_t i; if (!cu) { return; } for (i = 0; i < cu->count; i++) { if (cu->dies) { free_die(&cu->dies[i]); } } RZ_FREE(cu->dies); }
0
226,151
GF_Err gitn_box_size(GF_Box *s) { u32 i; GroupIdToNameBox *ptr = (GroupIdToNameBox *)s; ptr->size += 2; for (i=0; i<ptr->nb_entries; i++) { ptr->size += 5; if (ptr->entries[i].name) ptr->size += strlen(ptr->entries[i].name); } return GF_OK;
0
225,480
void MutableGraphView::UpdateMaxRegularOutputPortForRemovedFanin( const OutputPort& fanin, const absl::flat_hash_set<InputPort>& fanin_fanouts) { int max_port = max_regular_output_port()[fanin.node]; if (!fanin_fanouts.empty() || max_port != fanin.port_id) { return; } bool updated_max_port = false; for (int i = fanin.port_id - 1; i >= 0; --i) { OutputPort fanin_port(fanin.node, i); if (!fanouts()[fanin_port].empty()) { max_regular_output_port()[fanin.node] = i; updated_max_port = true; break; } } if (!updated_max_port) { max_regular_output_port().erase(fanin.node); } }
0
247,752
bool RWFunction::Validate(RandomNumberGenerator &rng, unsigned int level) const { bool pass = true; pass = pass && m_n > Integer::One() && m_n%8 == 5; return pass; }
0
256,414
PJ_DEF(void) pjmedia_rtcp_rx_rtp2(pjmedia_rtcp_session *sess, unsigned seq, unsigned rtp_ts, unsigned payload, pj_bool_t discarded) { pj_timestamp ts; pj_uint32_t arrival; pj_int32_t transit; pjmedia_rtp_status seq_st; #if !defined(PJMEDIA_HAS_RTCP_XR) || (PJMEDIA_HAS_RTCP_XR == 0) PJ_UNUSED_ARG(discarded); #endif if (sess->stat.rx.pkt == 0) { /* Init sequence for the first time. */ pjmedia_rtp_seq_init(&sess->seq_ctrl, (pj_uint16_t)seq); } sess->stat.rx.pkt++; sess->stat.rx.bytes += payload; /* Process the RTP packet. */ pjmedia_rtp_seq_update(&sess->seq_ctrl, (pj_uint16_t)seq, &seq_st); if (seq_st.status.flag.restart) { rtcp_init_seq(sess); } if (seq_st.status.flag.dup) { sess->stat.rx.dup++; TRACE_((sess->name, "Duplicate packet detected")); } if (seq_st.status.flag.outorder && !seq_st.status.flag.probation) { sess->stat.rx.reorder++; TRACE_((sess->name, "Out-of-order packet detected")); } if (seq_st.status.flag.bad) { sess->stat.rx.discard++; #if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0) pjmedia_rtcp_xr_rx_rtp(&sess->xr_session, seq, -1, /* lost */ (seq_st.status.flag.dup? 1:0), /* dup */ (!seq_st.status.flag.dup? 1:-1), /* discard */ -1, /* jitter */ -1, 0); /* toh */ #endif TRACE_((sess->name, "Bad packet discarded")); return; } /* Only mark "good" packets */ ++sess->received; /* Calculate loss periods. */ if (seq_st.diff > 1) { unsigned count = seq_st.diff - 1; unsigned period; period = count * sess->pkt_size * 1000 / sess->clock_rate; period *= 1000; /* Update packet lost. * The packet lost number will also be updated when we're sending * outbound RTCP RR. */ sess->stat.rx.loss += (seq_st.diff - 1); TRACE_((sess->name, "%d packet(s) lost", seq_st.diff - 1)); /* Update loss period stat */ pj_math_stat_update(&sess->stat.rx.loss_period, period); } /* * Calculate jitter only when sequence is good (see RFC 3550 section A.8), * AND only when the timestamp is different than the last packet * (see RTP FAQ). */ if (seq_st.diff == 1 && rtp_ts != sess->rtp_last_ts) { /* Get arrival time and convert timestamp to samples */ pj_get_timestamp(&ts); ts.u64 = ts.u64 * sess->clock_rate / sess->ts_freq.u64; arrival = ts.u32.lo; transit = arrival - rtp_ts; /* Ignore the first N packets as they normally have bad jitter * due to other threads working to establish the call */ if (sess->transit == 0 || sess->received < PJMEDIA_RTCP_IGNORE_FIRST_PACKETS) { sess->transit = transit; sess->stat.rx.jitter.min = (unsigned)-1; } else { pj_int32_t d; pj_uint32_t jitter; d = transit - sess->transit; if (d < 0) d = -d; sess->jitter += d - ((sess->jitter + 8) >> 4); /* Update jitter stat */ jitter = sess->jitter >> 4; /* Convert jitter unit from samples to usec */ if (jitter < 4294) jitter = jitter * 1000000 / sess->clock_rate; else { jitter = jitter * 1000 / sess->clock_rate; jitter *= 1000; } pj_math_stat_update(&sess->stat.rx.jitter, jitter); #if defined(PJMEDIA_RTCP_STAT_HAS_RAW_JITTER) && PJMEDIA_RTCP_STAT_HAS_RAW_JITTER!=0 { pj_uint32_t raw_jitter; /* Convert raw jitter unit from samples to usec */ if (d < 4294) raw_jitter = d * 1000000 / sess->clock_rate; else { raw_jitter = d * 1000 / sess->clock_rate; raw_jitter *= 1000; } /* Update jitter stat */ pj_math_stat_update(&sess->stat.rx_raw_jitter, raw_jitter); } #endif #if defined(PJMEDIA_RTCP_STAT_HAS_IPDV) && PJMEDIA_RTCP_STAT_HAS_IPDV!=0 { pj_int32_t ipdv; ipdv = transit - sess->transit; /* Convert IPDV unit from samples to usec */ if (ipdv > -2147 && ipdv < 2147) ipdv = ipdv * 1000000 / (int)sess->clock_rate; else { ipdv = ipdv * 1000 / (int)sess->clock_rate; ipdv *= 1000; } /* Update jitter stat */ pj_math_stat_update(&sess->stat.rx_ipdv, ipdv); } #endif #if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0) pjmedia_rtcp_xr_rx_rtp(&sess->xr_session, seq, 0, /* lost */ 0, /* dup */ discarded, /* discard */ (sess->jitter >> 4), /* jitter */ -1, 0); /* toh */ #endif /* Update session transit */ sess->transit = transit; } #if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0) } else if (seq_st.diff > 1) { int i; /* Report RTCP XR about packet losses */ for (i=seq_st.diff-1; i>0; --i) { pjmedia_rtcp_xr_rx_rtp(&sess->xr_session, seq - i, 1, /* lost */ 0, /* dup */ 0, /* discard */ -1, /* jitter */ -1, 0); /* toh */ } /* Report RTCP XR this packet */ pjmedia_rtcp_xr_rx_rtp(&sess->xr_session, seq, 0, /* lost */ 0, /* dup */ discarded, /* discard */ -1, /* jitter */ -1, 0); /* toh */ #endif } /* Update timestamp of last RX RTP packet */ sess->rtp_last_ts = rtp_ts; }
0
436,080
static int io_close(struct io_kiocb *req, unsigned int issue_flags) { struct files_struct *files = current->files; struct io_close *close = &req->close; struct fdtable *fdt; struct file *file = NULL; int ret = -EBADF; spin_lock(&files->file_lock); fdt = files_fdtable(files); if (close->fd >= fdt->max_fds) { spin_unlock(&files->file_lock); goto err; } file = fdt->fd[close->fd]; if (!file || file->f_op == &io_uring_fops) { spin_unlock(&files->file_lock); file = NULL; goto err; } /* if the file has a flush method, be safe and punt to async */ if (file->f_op->flush && (issue_flags & IO_URING_F_NONBLOCK)) { spin_unlock(&files->file_lock); return -EAGAIN; } ret = __close_fd_get_file(close->fd, &file); spin_unlock(&files->file_lock); if (ret < 0) { if (ret == -ENOENT) ret = -EBADF; goto err; } /* No ->flush() or already async, safely close from here */ ret = filp_close(file, current->files); err: if (ret < 0) req_set_fail(req); if (file) fput(file); __io_req_complete(req, issue_flags, ret, 0); return 0; }
0
264,301
static void send_ext_audio_ack(VncState *vs) { vnc_lock_output(vs); vnc_write_u8(vs, VNC_MSG_SERVER_FRAMEBUFFER_UPDATE); vnc_write_u8(vs, 0); vnc_write_u16(vs, 1); vnc_framebuffer_update(vs, 0, 0, surface_width(vs->vd->ds), surface_height(vs->vd->ds), VNC_ENCODING_AUDIO); vnc_unlock_output(vs); vnc_flush(vs); }
0
430,371
int seq_open(struct file *file, const struct seq_operations *op) { struct seq_file *p; WARN_ON(file->private_data); p = kmem_cache_zalloc(seq_file_cache, GFP_KERNEL); if (!p) return -ENOMEM; file->private_data = p; mutex_init(&p->lock); p->op = op; // No refcounting: the lifetime of 'p' is constrained // to the lifetime of the file. p->file = file; /* * seq_files support lseek() and pread(). They do not implement * write() at all, but we clear FMODE_PWRITE here for historical * reasons. * * If a client of seq_files a) implements file.write() and b) wishes to * support pwrite() then that client will need to implement its own * file.open() which calls seq_open() and then sets FMODE_PWRITE. */ file->f_mode &= ~FMODE_PWRITE; return 0; }
0
292,210
inbound_make_idtext (server *serv, char *idtext, int max, int id) { idtext[0] = 0; if (serv->have_idmsg || serv->have_accnotify) { if (id) { safe_strcpy (idtext, prefs.hex_irc_id_ytext, max); } else { safe_strcpy (idtext, prefs.hex_irc_id_ntext, max); } /* convert codes like %C,%U to the proper ones */ check_special_chars (idtext, TRUE); } }
0
231,031
static BaseType_t prvIsQueueFull( const Queue_t * pxQueue ) { BaseType_t xReturn; taskENTER_CRITICAL(); { if( pxQueue->uxMessagesWaiting == pxQueue->uxLength ) { xReturn = pdTRUE; } else { xReturn = pdFALSE; } } taskEXIT_CRITICAL(); return xReturn; }
0
383,333
gdImageColorAllocateAlpha (gdImagePtr im, int r, int g, int b, int a) { int i; int ct = (-1); if (im->trueColor) { return gdTrueColorAlpha (r, g, b, a); } for (i = 0; (i < (im->colorsTotal)); i++) { if (im->open[i]) { ct = i; break; } } if (ct == (-1)) { ct = im->colorsTotal; if (ct == gdMaxColors) { return -1; } im->colorsTotal++; } im->red[ct] = r; im->green[ct] = g; im->blue[ct] = b; im->alpha[ct] = a; im->open[ct] = 0; return ct; }
0
381,869
static int udf_extend_file(struct inode *inode, loff_t newsize) { struct extent_position epos; struct kernel_lb_addr eloc; uint32_t elen; int8_t etype; struct super_block *sb = inode->i_sb; sector_t first_block = newsize >> sb->s_blocksize_bits, offset; unsigned long partial_final_block; int adsize; struct udf_inode_info *iinfo = UDF_I(inode); struct kernel_long_ad extent; int err = 0; int within_final_block; if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_SHORT) adsize = sizeof(struct short_ad); else if (iinfo->i_alloc_type == ICBTAG_FLAG_AD_LONG) adsize = sizeof(struct long_ad); else BUG(); etype = inode_bmap(inode, first_block, &epos, &eloc, &elen, &offset); within_final_block = (etype != -1); if ((!epos.bh && epos.offset == udf_file_entry_alloc_offset(inode)) || (epos.bh && epos.offset == sizeof(struct allocExtDesc))) { /* File has no extents at all or has empty last * indirect extent! Create a fake extent... */ extent.extLocation.logicalBlockNum = 0; extent.extLocation.partitionReferenceNum = 0; extent.extLength = EXT_NOT_RECORDED_NOT_ALLOCATED; } else { epos.offset -= adsize; etype = udf_next_aext(inode, &epos, &extent.extLocation, &extent.extLength, 0); extent.extLength |= etype << 30; } partial_final_block = newsize & (sb->s_blocksize - 1); /* File has extent covering the new size (could happen when extending * inside a block)? */ if (within_final_block) { /* Extending file within the last file block */ udf_do_extend_final_block(inode, &epos, &extent, partial_final_block); } else { loff_t add = ((loff_t)offset << sb->s_blocksize_bits) | partial_final_block; err = udf_do_extend_file(inode, &epos, &extent, add); } if (err < 0) goto out; err = 0; iinfo->i_lenExtents = newsize; out: brelse(epos.bh); return err; }
0
274,699
callbacks_move_layer_down_menu_activate (GtkMenuItem *menuitem, gpointer user_data) { callbacks_move_layer_down_button_clicked(NULL, NULL); gtk_widget_grab_focus (screen.win.layerTree); }
0
437,696
static u32 filter_rx_s_min_width(struct cx23885_dev *dev, u32 min_width_ns) { u32 count = ns_to_lpf_count(min_width_ns); cx23888_ir_write4(dev, CX23888_IR_FILTR_REG, count); return lpf_count_to_ns(count); }
0
292,151
void LinkResolver::resolve_invoke(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, Bytecodes::Code byte, TRAPS) { switch (byte) { case Bytecodes::_invokestatic : resolve_invokestatic (result, pool, index, CHECK); break; case Bytecodes::_invokespecial : resolve_invokespecial (result, recv, pool, index, CHECK); break; case Bytecodes::_invokevirtual : resolve_invokevirtual (result, recv, pool, index, CHECK); break; case Bytecodes::_invokehandle : resolve_invokehandle (result, pool, index, CHECK); break; case Bytecodes::_invokedynamic : resolve_invokedynamic (result, pool, index, CHECK); break; case Bytecodes::_invokeinterface: resolve_invokeinterface(result, recv, pool, index, CHECK); break; default : break; } return; }
0
385,826
follow_link(struct path *link, struct nameidata *nd, void **p) { struct dentry *dentry = link->dentry; int error; char *s; BUG_ON(nd->flags & LOOKUP_RCU); if (link->mnt == nd->path.mnt) mntget(link->mnt); error = -ELOOP; if (unlikely(current->total_link_count >= 40)) goto out_put_nd_path; cond_resched(); current->total_link_count++; touch_atime(link); nd_set_link(nd, NULL); error = security_inode_follow_link(link->dentry, nd); if (error) goto out_put_nd_path; nd->last_type = LAST_BIND; *p = dentry->d_inode->i_op->follow_link(dentry, nd); error = PTR_ERR(*p); if (IS_ERR(*p)) goto out_put_nd_path; error = 0; s = nd_get_link(nd); if (s) { error = __vfs_follow_link(nd, s); if (unlikely(error)) put_link(nd, link, *p); } return error; out_put_nd_path: *p = NULL; path_put(&nd->path); path_put(link); return error; }
0
453,023
void nft_flow_rule_destroy(struct nft_flow_rule *flow) { struct flow_action_entry *entry; int i; flow_action_for_each(i, entry, &flow->rule->action) { switch (entry->id) { case FLOW_ACTION_REDIRECT: case FLOW_ACTION_MIRRED: dev_put(entry->dev); break; default: break; } } kfree(flow->rule); kfree(flow); }
0
254,872
bool operator()(const GroupsMap::value_type* lhs, const GroupsMap::value_type* rhs) const { return _valueComparator.evaluate(lhs->first < rhs->first); }
0
291,843
static void rtrs_clt_info_req_done(struct ib_cq *cq, struct ib_wc *wc) { struct rtrs_clt_con *con = to_clt_con(wc->qp->qp_context); struct rtrs_clt_path *clt_path = to_clt_path(con->c.path); struct rtrs_iu *iu; iu = container_of(wc->wr_cqe, struct rtrs_iu, cqe); rtrs_iu_free(iu, clt_path->s.dev->ib_dev, 1); if (wc->status != IB_WC_SUCCESS) { rtrs_err(clt_path->clt, "Path info request send failed: %s\n", ib_wc_status_msg(wc->status)); rtrs_clt_change_state_get_old(clt_path, RTRS_CLT_CONNECTING_ERR, NULL); return; } rtrs_clt_update_wc_stats(con); }
0
474,446
ObjectAllocateSlot( TPMI_DH_OBJECT *handle // OUT: handle of allocated object ) { OBJECT *object = FindEmptyObjectSlot(handle); if(object != NULL) { // if found, mark as occupied ObjectSetInUse(object); } return object; }
0
512,783
const MYSQL_TIME *const_ptr_mysql_time() const { return cached_time.get_mysql_time(); }
0
201,451
static Image *ReadCINImage(const ImageInfo *image_info,ExceptionInfo *exception) { #define MonoColorType 1 #define RGBColorType 3 char property[MaxTextExtent]; CINInfo cin; Image *image; MagickBooleanType status; MagickOffsetType offset; QuantumInfo *quantum_info; QuantumType quantum_type; ssize_t i; PixelPacket *q; size_t extent, length; ssize_t count, y; unsigned char magick[4], *pixels; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickCoreSignature); image=AcquireImage(image_info); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == MagickFalse) { image=DestroyImageList(image); return((Image *) NULL); } /* File information. */ offset=0; count=ReadBlob(image,4,magick); offset+=count; if ((count != 4) || ((LocaleNCompare((char *) magick,"\200\052\137\327",4) != 0))) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); memset(&cin,0,sizeof(cin)); image->endian=(magick[0] == 0x80) && (magick[1] == 0x2a) && (magick[2] == 0x5f) && (magick[3] == 0xd7) ? MSBEndian : LSBEndian; cin.file.image_offset=ReadBlobLong(image); offset+=4; cin.file.generic_length=ReadBlobLong(image); offset+=4; cin.file.industry_length=ReadBlobLong(image); offset+=4; cin.file.user_length=ReadBlobLong(image); offset+=4; cin.file.file_size=ReadBlobLong(image); offset+=4; offset+=ReadBlob(image,sizeof(cin.file.version),(unsigned char *) cin.file.version); (void) CopyMagickString(property,cin.file.version,sizeof(cin.file.version)); (void) SetImageProperty(image,"dpx:file.version",property); offset+=ReadBlob(image,sizeof(cin.file.filename),(unsigned char *) cin.file.filename); (void) CopyMagickString(property,cin.file.filename,sizeof(cin.file.filename)); (void) SetImageProperty(image,"dpx:file.filename",property); offset+=ReadBlob(image,sizeof(cin.file.create_date),(unsigned char *) cin.file.create_date); (void) CopyMagickString(property,cin.file.create_date, sizeof(cin.file.create_date)); (void) SetImageProperty(image,"dpx:file.create_date",property); offset+=ReadBlob(image,sizeof(cin.file.create_time),(unsigned char *) cin.file.create_time); (void) CopyMagickString(property,cin.file.create_time, sizeof(cin.file.create_time)); (void) SetImageProperty(image,"dpx:file.create_time",property); offset+=ReadBlob(image,sizeof(cin.file.reserve),(unsigned char *) cin.file.reserve); /* Image information. */ cin.image.orientation=(unsigned char) ReadBlobByte(image); offset++; if (cin.image.orientation != (unsigned char) (~0)) (void) FormatImageProperty(image,"dpx:image.orientation","%d", cin.image.orientation); switch (cin.image.orientation) { default: case 0: image->orientation=TopLeftOrientation; break; case 1: image->orientation=TopRightOrientation; break; case 2: image->orientation=BottomLeftOrientation; break; case 3: image->orientation=BottomRightOrientation; break; case 4: image->orientation=LeftTopOrientation; break; case 5: image->orientation=RightTopOrientation; break; case 6: image->orientation=LeftBottomOrientation; break; case 7: image->orientation=RightBottomOrientation; break; } cin.image.number_channels=(unsigned char) ReadBlobByte(image); offset++; offset+=ReadBlob(image,sizeof(cin.image.reserve1),(unsigned char *) cin.image.reserve1); for (i=0; i < 8; i++) { cin.image.channel[i].designator[0]=(unsigned char) ReadBlobByte(image); offset++; cin.image.channel[i].designator[1]=(unsigned char) ReadBlobByte(image); offset++; cin.image.channel[i].bits_per_pixel=(unsigned char) ReadBlobByte(image); offset++; cin.image.channel[i].reserve=(unsigned char) ReadBlobByte(image); offset++; cin.image.channel[i].pixels_per_line=ReadBlobLong(image); offset+=4; cin.image.channel[i].lines_per_image=ReadBlobLong(image); offset+=4; cin.image.channel[i].min_data=ReadBlobFloat(image); offset+=4; cin.image.channel[i].min_quantity=ReadBlobFloat(image); offset+=4; cin.image.channel[i].max_data=ReadBlobFloat(image); offset+=4; cin.image.channel[i].max_quantity=ReadBlobFloat(image); offset+=4; } cin.image.white_point[0]=ReadBlobFloat(image); offset+=4; if (IsFloatDefined(cin.image.white_point[0]) != MagickFalse) image->chromaticity.white_point.x=cin.image.white_point[0]; cin.image.white_point[1]=ReadBlobFloat(image); offset+=4; if (IsFloatDefined(cin.image.white_point[1]) != MagickFalse) image->chromaticity.white_point.y=cin.image.white_point[1]; cin.image.red_primary_chromaticity[0]=ReadBlobFloat(image); offset+=4; if (IsFloatDefined(cin.image.red_primary_chromaticity[0]) != MagickFalse) image->chromaticity.red_primary.x=cin.image.red_primary_chromaticity[0]; cin.image.red_primary_chromaticity[1]=ReadBlobFloat(image); offset+=4; if (IsFloatDefined(cin.image.red_primary_chromaticity[1]) != MagickFalse) image->chromaticity.red_primary.y=cin.image.red_primary_chromaticity[1]; cin.image.green_primary_chromaticity[0]=ReadBlobFloat(image); offset+=4; if (IsFloatDefined(cin.image.green_primary_chromaticity[0]) != MagickFalse) image->chromaticity.red_primary.x=cin.image.green_primary_chromaticity[0]; cin.image.green_primary_chromaticity[1]=ReadBlobFloat(image); offset+=4; if (IsFloatDefined(cin.image.green_primary_chromaticity[1]) != MagickFalse) image->chromaticity.green_primary.y=cin.image.green_primary_chromaticity[1]; cin.image.blue_primary_chromaticity[0]=ReadBlobFloat(image); offset+=4; if (IsFloatDefined(cin.image.blue_primary_chromaticity[0]) != MagickFalse) image->chromaticity.blue_primary.x=cin.image.blue_primary_chromaticity[0]; cin.image.blue_primary_chromaticity[1]=ReadBlobFloat(image); offset+=4; if (IsFloatDefined(cin.image.blue_primary_chromaticity[1]) != MagickFalse) image->chromaticity.blue_primary.y=cin.image.blue_primary_chromaticity[1]; offset+=ReadBlob(image,sizeof(cin.image.label),(unsigned char *) cin.image.label); (void) CopyMagickString(property,cin.image.label,sizeof(cin.image.label)); (void) SetImageProperty(image,"dpx:image.label",property); offset+=ReadBlob(image,sizeof(cin.image.reserve),(unsigned char *) cin.image.reserve); /* Image data format information. */ cin.data_format.interleave=(unsigned char) ReadBlobByte(image); offset++; cin.data_format.packing=(unsigned char) ReadBlobByte(image); offset++; cin.data_format.sign=(unsigned char) ReadBlobByte(image); offset++; cin.data_format.sense=(unsigned char) ReadBlobByte(image); offset++; cin.data_format.line_pad=ReadBlobLong(image); offset+=4; cin.data_format.channel_pad=ReadBlobLong(image); offset+=4; offset+=ReadBlob(image,sizeof(cin.data_format.reserve),(unsigned char *) cin.data_format.reserve); /* Image origination information. */ cin.origination.x_offset=ReadBlobSignedLong(image); offset+=4; if ((size_t) cin.origination.x_offset != ~0UL) (void) FormatImageProperty(image,"dpx:origination.x_offset","%.20g", (double) cin.origination.x_offset); cin.origination.y_offset=(ssize_t) ReadBlobLong(image); offset+=4; if ((size_t) cin.origination.y_offset != ~0UL) (void) FormatImageProperty(image,"dpx:origination.y_offset","%.20g", (double) cin.origination.y_offset); offset+=ReadBlob(image,sizeof(cin.origination.filename),(unsigned char *) cin.origination.filename); (void) CopyMagickString(property,cin.origination.filename, sizeof(cin.origination.filename)); (void) SetImageProperty(image,"dpx:origination.filename",property); offset+=ReadBlob(image,sizeof(cin.origination.create_date),(unsigned char *) cin.origination.create_date); (void) CopyMagickString(property,cin.origination.create_date, sizeof(cin.origination.create_date)); (void) SetImageProperty(image,"dpx:origination.create_date",property); offset+=ReadBlob(image,sizeof(cin.origination.create_time),(unsigned char *) cin.origination.create_time); (void) CopyMagickString(property,cin.origination.create_time, sizeof(cin.origination.create_time)); (void) SetImageProperty(image,"dpx:origination.create_time",property); offset+=ReadBlob(image,sizeof(cin.origination.device),(unsigned char *) cin.origination.device); (void) CopyMagickString(property,cin.origination.device, sizeof(cin.origination.device)); (void) SetImageProperty(image,"dpx:origination.device",property); offset+=ReadBlob(image,sizeof(cin.origination.model),(unsigned char *) cin.origination.model); (void) CopyMagickString(property,cin.origination.model, sizeof(cin.origination.model)); (void) SetImageProperty(image,"dpx:origination.model",property); (void) memset(cin.origination.serial,0, sizeof(cin.origination.serial)); offset+=ReadBlob(image,sizeof(cin.origination.serial),(unsigned char *) cin.origination.serial); (void) CopyMagickString(property,cin.origination.serial, sizeof(cin.origination.serial)); (void) SetImageProperty(image,"dpx:origination.serial",property); cin.origination.x_pitch=ReadBlobFloat(image); offset+=4; cin.origination.y_pitch=ReadBlobFloat(image); offset+=4; cin.origination.gamma=ReadBlobFloat(image); offset+=4; if (IsFloatDefined(cin.origination.gamma) != MagickFalse) image->gamma=cin.origination.gamma; offset+=ReadBlob(image,sizeof(cin.origination.reserve),(unsigned char *) cin.origination.reserve); if ((cin.file.image_offset > 2048) && (cin.file.user_length != 0)) { int c; /* Image film information. */ cin.film.id=ReadBlobByte(image); offset++; c=cin.film.id; if (c != ~0) (void) FormatImageProperty(image,"dpx:film.id","%d",cin.film.id); cin.film.type=ReadBlobByte(image); offset++; c=cin.film.type; if (c != ~0) (void) FormatImageProperty(image,"dpx:film.type","%d",cin.film.type); cin.film.offset=ReadBlobByte(image); offset++; c=cin.film.offset; if (c != ~0) (void) FormatImageProperty(image,"dpx:film.offset","%d", cin.film.offset); cin.film.reserve1=ReadBlobByte(image); offset++; cin.film.prefix=ReadBlobLong(image); offset+=4; if (cin.film.prefix != ~0UL) (void) FormatImageProperty(image,"dpx:film.prefix","%.20g",(double) cin.film.prefix); cin.film.count=ReadBlobLong(image); offset+=4; offset+=ReadBlob(image,sizeof(cin.film.format),(unsigned char *) cin.film.format); (void) CopyMagickString(property,cin.film.format, sizeof(cin.film.format)); (void) SetImageProperty(image,"dpx:film.format",property); cin.film.frame_position=ReadBlobLong(image); offset+=4; if (cin.film.frame_position != ~0UL) (void) FormatImageProperty(image,"dpx:film.frame_position","%.20g", (double) cin.film.frame_position); cin.film.frame_rate=ReadBlobFloat(image); offset+=4; if (IsFloatDefined(cin.film.frame_rate) != MagickFalse) (void) FormatImageProperty(image,"dpx:film.frame_rate","%g", cin.film.frame_rate); offset+=ReadBlob(image,sizeof(cin.film.frame_id),(unsigned char *) cin.film.frame_id); (void) CopyMagickString(property,cin.film.frame_id, sizeof(cin.film.frame_id)); (void) SetImageProperty(image,"dpx:film.frame_id",property); offset+=ReadBlob(image,sizeof(cin.film.slate_info),(unsigned char *) cin.film.slate_info); (void) CopyMagickString(property,cin.film.slate_info, sizeof(cin.film.slate_info)); (void) SetImageProperty(image,"dpx:film.slate_info",property); offset+=ReadBlob(image,sizeof(cin.film.reserve),(unsigned char *) cin.film.reserve); } if ((cin.file.image_offset > 2048) && (cin.file.user_length != 0)) { StringInfo *profile; /* User defined data. */ if (cin.file.user_length > GetBlobSize(image)) ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile"); profile=BlobToStringInfo((const void *) NULL,cin.file.user_length); if (profile == (StringInfo *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); offset+=ReadBlob(image,GetStringInfoLength(profile), GetStringInfoDatum(profile)); (void) SetImageProfile(image,"dpx:user.data",profile); profile=DestroyStringInfo(profile); } image->depth=cin.image.channel[0].bits_per_pixel; image->columns=cin.image.channel[0].pixels_per_line; image->rows=cin.image.channel[0].lines_per_image; if (image_info->ping != MagickFalse) { (void) CloseBlob(image); return(image); } if (((MagickSizeType) image->columns*image->rows/8) > GetBlobSize(image)) ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile"); for ( ; offset < (MagickOffsetType) cin.file.image_offset; offset++) { int c; c=ReadBlobByte(image); if (c == EOF) break; } if (offset < (MagickOffsetType) cin.file.image_offset) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); status=SetImageExtent(image,image->columns,image->rows); if (status == MagickFalse) { InheritException(exception,&image->exception); return(DestroyImageList(image)); } (void) SetImageBackgroundColor(image); /* Convert CIN raster image to pixel packets. */ quantum_info=AcquireQuantumInfo(image_info,image); if (quantum_info == (QuantumInfo *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); SetQuantumQuantum(quantum_info,32); SetQuantumPack(quantum_info,MagickFalse); quantum_type=RGBQuantum; extent=GetQuantumExtent(image,quantum_info,quantum_type); (void) extent; length=GetBytesPerRow(image->columns,3,image->depth,MagickTrue); if (cin.image.number_channels == 1) { quantum_type=GrayQuantum; length=GetBytesPerRow(image->columns,1,image->depth,MagickTrue); } status=SetQuantumPad(image,quantum_info,0); pixels=GetQuantumPixels(quantum_info); for (y=0; y < (ssize_t) image->rows; y++) { const void *stream; q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) break; stream=ReadBlobStream(image,length,pixels,&count); if (count != (ssize_t) length) break; (void) ImportQuantumPixels(image,(CacheView *) NULL,quantum_info, quantum_type,(unsigned char *) stream,exception); if (SyncAuthenticPixels(image,exception) == MagickFalse) break; if (image->previous == (Image *) NULL) { status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, image->rows); if (status == MagickFalse) break; } } SetQuantumImageType(image,quantum_type); quantum_info=DestroyQuantumInfo(quantum_info); if (EOFBlob(image) != MagickFalse) ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", image->filename); SetImageColorspace(image,LogColorspace); (void) CloseBlob(image); return(GetFirstImageInList(image)); }
1
269,488
static CustomStreamInfo *TIFFAcquireCustomStreamForWriting( PhotoshopProfile *profile,ExceptionInfo *exception) { CustomStreamInfo *custom_stream; custom_stream=AcquireCustomStreamInfo(exception); if (custom_stream == (CustomStreamInfo *) NULL) return(custom_stream); SetCustomStreamData(custom_stream,(void *) profile); SetCustomStreamWriter(custom_stream,TIFFWriteCustomStream); SetCustomStreamSeeker(custom_stream,TIFFSeekCustomStream); SetCustomStreamTeller(custom_stream,TIFFTellCustomStream); return(custom_stream); }
0
376,355
gpg_ctx_op_step (struct _GpgCtx *gpg, GCancellable *cancellable, GError **error) { #ifndef G_OS_WIN32 GPollFD polls[6]; gint status, i; gboolean read_data = FALSE, wrote_data = FALSE; for (i = 0; i < 6; i++) { polls[i].fd = -1; polls[i].events = 0; } if (!gpg->seen_eof1) { polls[0].fd = gpg->stdout_fd; polls[0].events = G_IO_IN; } if (!gpg->seen_eof2) { polls[1].fd = gpg->stderr_fd; polls[1].events = G_IO_IN; } if (!gpg->complete) { polls[2].fd = gpg->status_fd; polls[2].events = G_IO_IN; } polls[3].fd = gpg->stdin_fd; polls[3].events = G_IO_OUT; polls[4].fd = gpg->passwd_fd; polls[4].events = G_IO_OUT; polls[5].fd = g_cancellable_get_fd (cancellable); polls[5].events = G_IO_IN; do { for (i = 0; i < 6; i++) polls[i].revents = 0; status = g_poll (polls, 6, 30 * 1000); } while (status == -1 && errno == EINTR); if (status == 0) return 0; /* timed out */ else if (status == -1) goto exception; if ((polls[5].revents & G_IO_IN) && g_cancellable_set_error_if_cancelled (cancellable, error)) { gpg_ctx_op_cancel (gpg); return -1; } /* Test each and every file descriptor to see if it's 'ready', * and if so - do what we can with it and then drop through to * the next file descriptor and so on until we've done what we * can to all of them. If one fails along the way, return * -1. */ if (polls[2].revents & (G_IO_IN | G_IO_HUP)) { /* read the status message and decide what to do... */ gchar buffer[4096]; gssize nread; d (printf ("reading from gpg's status-fd...\n")); do { nread = read (gpg->status_fd, buffer, sizeof (buffer)); } while (nread == -1 && (errno == EINTR || errno == EAGAIN)); if (nread == -1) goto exception; if (nread > 0) { status_backup (gpg, buffer, nread); if (gpg_ctx_parse_status (gpg, error) == -1) return -1; } else { gpg->complete = TRUE; } } if ((polls[0].revents & (G_IO_IN | G_IO_HUP)) && gpg->ostream) { gchar buffer[4096]; gssize nread; d (printf ("reading gpg's stdout...\n")); do { nread = read (gpg->stdout_fd, buffer, sizeof (buffer)); } while (nread == -1 && (errno == EINTR || errno == EAGAIN)); if (nread == -1) goto exception; if (nread > 0) { gsize written = camel_stream_write ( gpg->ostream, buffer, (gsize) nread, cancellable, error); if (written != nread) return -1; } else { gpg->seen_eof1 = TRUE; } read_data = TRUE; } if (polls[1].revents & (G_IO_IN | G_IO_HUP)) { gchar buffer[4096]; gssize nread; d (printf ("reading gpg's stderr...\n")); do { nread = read (gpg->stderr_fd, buffer, sizeof (buffer)); } while (nread == -1 && (errno == EINTR || errno == EAGAIN)); if (nread == -1) goto exception; if (nread > 0) { camel_stream_write ( gpg->diagnostics, buffer, nread, cancellable, error); } else { gpg->seen_eof2 = TRUE; } } if ((polls[4].revents & (G_IO_OUT | G_IO_HUP)) && gpg->need_passwd && gpg->send_passwd) { gssize w, nwritten = 0; gsize n; d (printf ("sending gpg our passphrase...\n")); /* send the passphrase to gpg */ n = strlen (gpg->passwd); do { do { w = write (gpg->passwd_fd, gpg->passwd + nwritten, n - nwritten); } while (w == -1 && (errno == EINTR || errno == EAGAIN)); if (w > 0) nwritten += w; } while (nwritten < n && w != -1); /* zero and free our passwd buffer */ memset (gpg->passwd, 0, n); g_free (gpg->passwd); gpg->passwd = NULL; if (w == -1) goto exception; gpg->send_passwd = FALSE; } if ((polls[3].revents & (G_IO_OUT | G_IO_HUP)) && gpg->istream) { gchar buffer[4096]; gssize nread; d (printf ("writing to gpg's stdin...\n")); /* write our stream to gpg's stdin */ nread = camel_stream_read ( gpg->istream, buffer, sizeof (buffer), cancellable, NULL); if (nread > 0) { gssize w, nwritten = 0; do { do { w = write (gpg->stdin_fd, buffer + nwritten, nread - nwritten); } while (w == -1 && (errno == EINTR || errno == EAGAIN)); if (w > 0) nwritten += w; } while (nwritten < nread && w != -1); if (w == -1) goto exception; d (printf ("wrote %d (out of %d) bytes to gpg's stdin\n", nwritten, nread)); wrote_data = TRUE; } if (camel_stream_eos (gpg->istream)) { d (printf ("closing gpg's stdin\n")); close (gpg->stdin_fd); gpg->stdin_fd = -1; } } if (gpg->need_id && !gpg->processing && !read_data && !wrote_data) { /* do not ask more than hundred times per second when looking for a pass phrase, * in case user has the use-agent set, it'll not use the all CPU when * agent is asking for a pass phrase, instead of us */ g_usleep (G_USEC_PER_SEC / 100); } return 0; exception: /* always called on an i/o error */ g_set_error ( error, G_IO_ERROR, g_io_error_from_errno (errno), _("Failed to execute gpg: %s"), g_strerror (errno)); gpg_ctx_op_cancel (gpg); #endif return -1; }
0
512,868
Item_cond::fix_fields(THD *thd, Item **ref) { DBUG_ASSERT(fixed == 0); List_iterator<Item> li(list); Item *item; uchar buff[sizeof(char*)]; // Max local vars in function bool is_and_cond= functype() == Item_func::COND_AND_FUNC; not_null_tables_cache= 0; used_tables_and_const_cache_init(); /* and_table_cache is the value that Item_cond_or() returns for not_null_tables() */ and_tables_cache= ~(table_map) 0; if (check_stack_overrun(thd, STACK_MIN_SIZE, buff)) return TRUE; // Fatal error flag is set! /* The following optimization reduces the depth of an AND-OR tree. E.g. a WHERE clause like F1 AND (F2 AND (F2 AND F4)) is parsed into a tree with the same nested structure as defined by braces. This optimization will transform such tree into AND (F1, F2, F3, F4). Trees of OR items are flattened as well: ((F1 OR F2) OR (F3 OR F4)) => OR (F1, F2, F3, F4) Items for removed AND/OR levels will dangle until the death of the entire statement. The optimization is currently prepared statements and stored procedures friendly as it doesn't allocate any memory and its effects are durable (i.e. do not depend on PS/SP arguments). */ while ((item=li++)) { while (item->type() == Item::COND_ITEM && ((Item_cond*) item)->functype() == functype() && !((Item_cond*) item)->list.is_empty()) { // Identical function li.replace(((Item_cond*) item)->list); ((Item_cond*) item)->list.empty(); item= *li.ref(); // new current item } if (abort_on_null) item->top_level_item(); /* replace degraded condition: was: <field> become: <field> = 1 */ Item::Type type= item->type(); if (type == Item::FIELD_ITEM || type == Item::REF_ITEM) { Query_arena backup, *arena; Item *new_item; arena= thd->activate_stmt_arena_if_needed(&backup); if ((new_item= new (thd->mem_root) Item_func_ne(thd, item, new (thd->mem_root) Item_int(thd, 0, 1)))) li.replace(item= new_item); if (arena) thd->restore_active_arena(arena, &backup); } if (item->fix_fields_if_needed_for_bool(thd, li.ref())) return TRUE; /* purecov: inspected */ item= *li.ref(); // item can be substituted in fix_fields used_tables_cache|= item->used_tables(); if (item->const_item() && !item->with_param && !item->is_expensive() && !cond_has_datetime_is_null(item)) { if (item->eval_const_cond() == is_and_cond && top_level()) { /* a. This is "... AND true_cond AND ..." In this case, true_cond has no effect on cond_and->not_null_tables() b. This is "... OR false_cond/null cond OR ..." In this case, false_cond has no effect on cond_or->not_null_tables() */ } else { /* a. This is "... AND false_cond/null_cond AND ..." The whole condition is FALSE/UNKNOWN. b. This is "... OR const_cond OR ..." In this case, cond_or->not_null_tables()=0, because the condition const_cond might evaluate to true (regardless of whether some tables were NULL-complemented). */ not_null_tables_cache= (table_map) 0; and_tables_cache= (table_map) 0; } if (thd->is_error()) return TRUE; } else { table_map tmp_table_map= item->not_null_tables(); not_null_tables_cache|= tmp_table_map; and_tables_cache&= tmp_table_map; const_item_cache= FALSE; } join_with_sum_func(item); with_param|= item->with_param; with_field|= item->with_field; m_with_subquery|= item->with_subquery(); with_window_func|= item->with_window_func; maybe_null|= item->maybe_null; } if (fix_length_and_dec()) return TRUE; fixed= 1; return FALSE; }
0
409,406
limit_screen_size(void) { if (Columns < MIN_COLUMNS) Columns = MIN_COLUMNS; else if (Columns > 10000) Columns = 10000; if (Rows > 1000) Rows = 1000; }
0
391,672
static NTSTATUS fd_open_atomic(struct connection_struct *conn, files_struct *fsp, int flags, mode_t mode, bool *file_created) { NTSTATUS status = NT_STATUS_UNSUCCESSFUL; bool file_existed = VALID_STAT(fsp->fsp_name->st); *file_created = false; if (!(flags & O_CREAT)) { /* * We're not creating the file, just pass through. */ return fd_open(conn, fsp, flags, mode); } if (flags & O_EXCL) { /* * Fail if already exists, just pass through. */ status = fd_open(conn, fsp, flags, mode); /* * Here we've opened with O_CREAT|O_EXCL. If that went * NT_STATUS_OK, we *know* we created this file. */ *file_created = NT_STATUS_IS_OK(status); return status; } /* * Now it gets tricky. We have O_CREAT, but not O_EXCL. * To know absolutely if we created the file or not, * we can never call O_CREAT without O_EXCL. So if * we think the file existed, try without O_CREAT|O_EXCL. * If we think the file didn't exist, try with * O_CREAT|O_EXCL. Keep bouncing between these two * requests until either the file is created, or * opened. Either way, we keep going until we get * a returnable result (error, or open/create). */ while(1) { int curr_flags = flags; if (file_existed) { /* Just try open, do not create. */ curr_flags &= ~(O_CREAT); status = fd_open(conn, fsp, curr_flags, mode); if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { /* * Someone deleted it in the meantime. * Retry with O_EXCL. */ file_existed = false; DEBUG(10,("fd_open_atomic: file %s existed. " "Retry.\n", smb_fname_str_dbg(fsp->fsp_name))); continue; } } else { /* Try create exclusively, fail if it exists. */ curr_flags |= O_EXCL; status = fd_open(conn, fsp, curr_flags, mode); if (NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) { /* * Someone created it in the meantime. * Retry without O_CREAT. */ file_existed = true; DEBUG(10,("fd_open_atomic: file %s " "did not exist. Retry.\n", smb_fname_str_dbg(fsp->fsp_name))); continue; } if (NT_STATUS_IS_OK(status)) { /* * Here we've opened with O_CREAT|O_EXCL * and got success. We *know* we created * this file. */ *file_created = true; } } /* Create is done, or failed. */ break; } return status; }
0
313,782
del_from_showcmd(int len) { int old_len; if (!p_sc) return; old_len = (int)STRLEN(showcmd_buf); if (len > old_len) len = old_len; showcmd_buf[old_len - len] = NUL; if (!char_avail()) display_showcmd(); }
0
386,516
void DL_Dxf::writeBlock(DL_WriterA& dw, const DL_BlockData& data) { if (data.name.empty()) { std::cerr << "DL_Dxf::writeBlock: " << "Block name must not be empty\n"; return; } std::string n = data.name; std::transform(n.begin(), n.end(), n.begin(), ::toupper); if (n=="*PAPER_SPACE") { dw.sectionBlockEntry(0x1C); } else if (n=="*MODEL_SPACE") { dw.sectionBlockEntry(0x20); } else if (n=="*PAPER_SPACE0") { dw.sectionBlockEntry(0x24); } else { dw.sectionBlockEntry(); } dw.dxfString(2, data.name); dw.dxfInt(70, 0); dw.coord(10, data.bpx, data.bpy, data.bpz); dw.dxfString(3, data.name); dw.dxfString(1, ""); }
0
405,383
static void __xfrm_policy_inexact_prune_bin(struct xfrm_pol_inexact_bin *b, bool net_exit) { write_seqcount_begin(&b->count); xfrm_policy_inexact_gc_tree(&b->root_d, net_exit); xfrm_policy_inexact_gc_tree(&b->root_s, net_exit); write_seqcount_end(&b->count); if (!RB_EMPTY_ROOT(&b->root_d) || !RB_EMPTY_ROOT(&b->root_s) || !hlist_empty(&b->hhead)) { WARN_ON_ONCE(net_exit); return; } if (rhashtable_remove_fast(&xfrm_policy_inexact_table, &b->head, xfrm_pol_inexact_params) == 0) { list_del(&b->inexact_bins); kfree_rcu(b, rcu); } }
0
512,583
const Type_handler *type_handler() const { const Type_handler *handler= field->type_handler(); return handler->type_handler_for_item_field(); }
0
261,921
njs_string_alloc(njs_vm_t *vm, njs_value_t *value, uint64_t size, uint64_t length) { uint32_t total, map_offset, *map; njs_string_t *string; if (njs_slow_path(size > NJS_STRING_MAX_LENGTH)) { njs_range_error(vm, "invalid string length"); return NULL; } value->type = NJS_STRING; njs_string_truth(value, size); if (size <= NJS_STRING_SHORT) { value->short_string.size = size; value->short_string.length = length; return value->short_string.start; } /* * Setting UTF-8 length is not required here, it just allows * to store the constant in whole byte instead of bit twiddling. */ value->short_string.size = NJS_STRING_LONG; value->short_string.length = 0; value->long_string.external = 0; value->long_string.size = size; if (size != length && length > NJS_STRING_MAP_STRIDE) { map_offset = njs_string_map_offset(size); total = map_offset + njs_string_map_size(length); } else { map_offset = 0; total = size; } string = njs_mp_alloc(vm->mem_pool, sizeof(njs_string_t) + total); if (njs_fast_path(string != NULL)) { value->long_string.data = string; string->start = (u_char *) string + sizeof(njs_string_t); string->length = length; string->retain = 1; if (map_offset != 0) { map = (uint32_t *) (string->start + map_offset); map[0] = 0; } return string->start; } njs_memory_error(vm); return NULL; }
0
387,620
static int snd_ctl_elem_user_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { int change; struct user_element *ue = kcontrol->private_data; unsigned int size = ue->elem_data_size; char *dst = ue->elem_data + snd_ctl_get_ioff(kcontrol, &ucontrol->id) * size; change = memcmp(&ucontrol->value, dst, size) != 0; if (change) memcpy(dst, &ucontrol->value, size); return change; }
0
442,570
static void test_memslot_invalid_slot_id(void) { RedMemSlotInfo mem_info; init_meminfo(&mem_info); memslot_get_virt(&mem_info, 1 << mem_info.memslot_id_shift, 16, 0); }
0
255,757
create_node(authz_rule_segment_t *segment, apr_pool_t *result_pool) { node_t *result = apr_pcalloc(result_pool, sizeof(*result)); if (segment) result->segment = segment->pattern; else { result->segment.data = ""; result->segment.len = 0; } result->rights.access.sequence_number = NO_SEQUENCE_NUMBER; return result; }
0
325,820
copy_ciphersuites(gnutls_session_t session, gnutls_buffer_st * cdata, int add_scsv) { int ret; uint8_t cipher_suites[MAX_CIPHERSUITE_SIZE + RESERVED_CIPHERSUITES]; /* allow space for SCSV */ int cipher_suites_size; size_t init_length = cdata->length; ret = _gnutls_supported_ciphersuites(session, cipher_suites, sizeof(cipher_suites) - RESERVED_CIPHERSUITES); if (ret < 0) return gnutls_assert_val(ret); /* Here we remove any ciphersuite that does not conform * the certificate requested, or to the * authentication requested (eg SRP). */ ret = _gnutls_remove_unwanted_ciphersuites(session, cipher_suites, ret, NULL, 0); if (ret < 0) return gnutls_assert_val(ret); /* If no cipher suites were enabled. */ if (ret == 0) return gnutls_assert_val(GNUTLS_E_INSUFFICIENT_CREDENTIALS); cipher_suites_size = ret; if (add_scsv) { cipher_suites[cipher_suites_size] = 0x00; cipher_suites[cipher_suites_size + 1] = 0xff; cipher_suites_size += 2; ret = _gnutls_ext_sr_send_cs(session); if (ret < 0) return gnutls_assert_val(ret); } if (session->internals.priorities.fallback) { cipher_suites[cipher_suites_size] = GNUTLS_FALLBACK_SCSV_MAJOR; cipher_suites[cipher_suites_size + 1] = GNUTLS_FALLBACK_SCSV_MINOR; cipher_suites_size += 2; } ret = _gnutls_buffer_append_data_prefix(cdata, 16, cipher_suites, cipher_suites_size); if (ret < 0) return gnutls_assert_val(ret); ret = cdata->length - init_length; return ret; }
0
265,544
int mempool_releasebuffer(MemoryPoolHandle handle, void *buf, size_t released_buffer_size) { struct mempool *pool = (struct mempool *)handle; struct memory_pool_element *pool_item = (struct memory_pool_element *)buf; char *log_msg_fmt = "mempool(%p): mempool_releasebuffer called for invalid " "released_buffer_size(%zu), current pool manages only " "mempool_item_size(%zu)"; char log_msg[300]; if ((pool == NULL) || (pool_item == NULL)) { return S3_MEMPOOL_INVALID_ARG; } if (pool->mempool_item_size != released_buffer_size) { // This should never happen unless mempool is used wrongly. if (pool->log_callback_func) { snprintf(log_msg, sizeof(log_msg), log_msg_fmt, (void *)pool, released_buffer_size, pool->mempool_item_size); pool->log_callback_func(MEMPOOL_LOG_FATAL, log_msg); return S3_MEMPOOL_INVALID_ARG; } } if ((pool->flags & ENABLE_LOCKING) != 0) { pthread_mutex_lock(&pool->lock); } /* Clean up the buffer so that we get it 'clean' when we allocate it next * time*/ if ((pool->flags & ZEROED_BUFFER) != 0) { memset(pool_item, 0, pool->mempool_item_size); } // Add the buffer back to pool pool_item->next = pool->free_list; pool->free_list = pool_item; pool->free_bufs_in_pool++; pool_item = NULL; pool->number_of_bufs_shared--; if ((pool->flags & ENABLE_LOCKING) != 0) { pthread_mutex_unlock(&pool->lock); } return 0; }
0
262,033
ProtoMakeErrorReplyInt(ServiceConnection *conn, int reqSeqno, VGAuthError err, const char *errMsg) { gchar *packet; gchar *escapedErrMsg = g_markup_escape_text(errMsg, -1); /* * g_markup_printf_escaped() is broken when the printf format * contains the Windows FMT64 format string %I64 */ packet = g_strdup_printf(VGAUTH_ERROR_FORMAT, reqSeqno, err, escapedErrMsg); g_free(escapedErrMsg); Log("Returning error message '%s'\n", packet); return packet; }
0
282,862
static int rsi_send_beacon(struct rsi_common *common) { struct sk_buff *skb = NULL; u8 dword_align_bytes = 0; skb = dev_alloc_skb(MAX_MGMT_PKT_SIZE); if (!skb) return -ENOMEM; memset(skb->data, 0, MAX_MGMT_PKT_SIZE); dword_align_bytes = ((unsigned long)skb->data & 0x3f); if (dword_align_bytes) skb_pull(skb, (64 - dword_align_bytes)); if (rsi_prepare_beacon(common, skb)) { rsi_dbg(ERR_ZONE, "Failed to prepare beacon\n"); dev_kfree_skb(skb); return -EINVAL; } skb_queue_tail(&common->tx_queue[MGMT_BEACON_Q], skb); rsi_set_event(&common->tx_thread.event); rsi_dbg(DATA_TX_ZONE, "%s: Added to beacon queue\n", __func__); return 0; }
0
293,740
static bool check_buffer(RBinFile *bf, RBuffer *b) { if (r_buf_size (b) > 4) { ut8 buf[4]; r_buf_read_at (b, 0, buf, sizeof (buf)); if (!memcmp (buf, "\xcf\xfa\xed\xfe", 4)) { return is_kernelcache_buffer (b); } } return false; }
0
384,810
vim_backtick(char_u *p) { return (*p == '`' && *(p + 1) != NUL && *(p + STRLEN(p) - 1) == '`'); }
0
369,171
static void handle_prev_tw_list(struct io_wq_work_node *node, struct io_ring_ctx **ctx, bool *uring_locked) { if (*ctx && !*uring_locked) spin_lock(&(*ctx)->completion_lock); do { struct io_wq_work_node *next = node->next; struct io_kiocb *req = container_of(node, struct io_kiocb, io_task_work.node); prefetch(container_of(next, struct io_kiocb, io_task_work.node)); if (req->ctx != *ctx) { if (unlikely(!*uring_locked && *ctx)) ctx_commit_and_unlock(*ctx); ctx_flush_and_put(*ctx, uring_locked); *ctx = req->ctx; /* if not contended, grab and improve batching */ *uring_locked = mutex_trylock(&(*ctx)->uring_lock); percpu_ref_get(&(*ctx)->refs); if (unlikely(!*uring_locked)) spin_lock(&(*ctx)->completion_lock); } if (likely(*uring_locked)) req->io_task_work.func(req, uring_locked); else __io_req_complete_post(req, req->result, io_put_kbuf_comp(req)); node = next; } while (node); if (unlikely(!*uring_locked)) ctx_commit_and_unlock(*ctx); }
0
101,681
static uint64_t generatePageID() { static uint64_t uniquePageID = 1; return uniquePageID++; }
0
299,899
get_config_line(void) { int startoffset = 0; /* To first non-blank char in logical line */ int len = 0; /* Of logical line so far */ int newlen; uschar *s, *ss; macro_item *m; BOOL macro_found; /* Loop for handling continuation lines, skipping comments, and dealing with .include files. */ for (;;) { if (Ufgets(big_buffer+len, big_buffer_size-len, config_file) == NULL) { if (config_file_stack != NULL) /* EOF inside .include */ { (void)fclose(config_file); config_file = config_file_stack->file; config_filename = config_file_stack->filename; config_lineno = config_file_stack->lineno; config_file_stack = config_file_stack->next; continue; } /* EOF at top level */ if (cstate_stack_ptr >= 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "Unexpected end of configuration file: .endif missing"); if (len != 0) break; /* EOF after continuation */ next_section[0] = 0; /* EOF at start of logical line */ return NULL; } config_lineno++; newlen = len + Ustrlen(big_buffer + len); /* Handle pathologically long physical lines - yes, it did happen - by extending big_buffer at this point. The code also copes with very long logical lines. */ while (newlen == big_buffer_size - 1 && big_buffer[newlen - 1] != '\n') { uschar *newbuffer; big_buffer_size += BIG_BUFFER_SIZE; newbuffer = store_malloc(big_buffer_size); /* This use of strcpy is OK because we know that the string in the old buffer is shorter than the new buffer. */ Ustrcpy(newbuffer, big_buffer); store_free(big_buffer); big_buffer = newbuffer; if (Ufgets(big_buffer+newlen, big_buffer_size-newlen, config_file) == NULL) break; newlen += Ustrlen(big_buffer + newlen); } /* Find the true start of the physical line - leading spaces are always ignored. */ ss = big_buffer + len; while (isspace(*ss)) ss++; /* Process the physical line for macros. If this is the start of the logical line, skip over initial text at the start of the line if it starts with an upper case character followed by a sequence of name characters and an equals sign, because that is the definition of a new macro, and we don't do replacement therein. */ s = ss; if (len == 0 && isupper(*s)) { while (isalnum(*s) || *s == '_') s++; while (isspace(*s)) s++; if (*s != '=') s = ss; /* Not a macro definition */ } /* For each defined macro, scan the line (from after XXX= if present), replacing all occurrences of the macro. */ macro_found = FALSE; for (m = macros; m != NULL; m = m->next) { uschar *p, *pp; uschar *t = s; while ((p = Ustrstr(t, m->name)) != NULL) { int moveby; int namelen = Ustrlen(m->name); int replen = Ustrlen(m->replacement); /* Expand the buffer if necessary */ while (newlen - namelen + replen + 1 > big_buffer_size) { int newsize = big_buffer_size + BIG_BUFFER_SIZE; uschar *newbuffer = store_malloc(newsize); memcpy(newbuffer, big_buffer, newlen + 1); p = newbuffer + (p - big_buffer); s = newbuffer + (s - big_buffer); ss = newbuffer + (ss - big_buffer); t = newbuffer + (t - big_buffer); big_buffer_size = newsize; store_free(big_buffer); big_buffer = newbuffer; } /* Shuffle the remaining characters up or down in the buffer before copying in the replacement text. Don't rescan the replacement for this same macro. */ pp = p + namelen; moveby = replen - namelen; if (moveby != 0) { memmove(p + replen, pp, (big_buffer + newlen) - pp + 1); newlen += moveby; } Ustrncpy(p, m->replacement, replen); t = p + replen; macro_found = TRUE; } } /* An empty macro replacement at the start of a line could mean that ss no longer points to the first non-blank character. */ while (isspace(*ss)) ss++; /* Check for comment lines - these are physical lines. */ if (*ss == '#') continue; /* Handle conditionals, which are also applied to physical lines. Conditions are of the form ".ifdef ANYTEXT" and are treated as true if any macro expansion occured on the rest of the line. A preliminary test for the leading '.' saves effort on most lines. */ if (*ss == '.') { int i; /* Search the list of conditional directives */ for (i = 0; i < cond_list_size; i++) { int n; cond_item *c = cond_list+i; if (Ustrncmp(ss+1, c->name, c->namelen) != 0) continue; /* The following character must be white space or end of string */ n = ss[1 + c->namelen]; if (n != ' ' && n != 't' && n != '\n' && n != 0) break; /* .ifdef and .ifndef push the current state onto the stack, then set a new one from the table. Stack overflow is an error */ if (c->pushpop > 0) { if (cstate_stack_ptr >= CSTATE_STACK_SIZE - 1) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, ".%s nested too deeply", c->name); cstate_stack[++cstate_stack_ptr] = cstate; cstate = next_cstate[cstate][macro_found? c->action1 : c->action2]; } /* For any of the others, stack underflow is an error. The next state comes either from the stack (.endif) or from the table. */ else { if (cstate_stack_ptr < 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, ".%s without matching .ifdef", c->name); cstate = (c->pushpop < 0)? cstate_stack[cstate_stack_ptr--] : next_cstate[cstate][macro_found? c->action1 : c->action2]; } /* Having dealt with a directive, break the loop */ break; } /* If we have handled a conditional directive, continue with the next physical line. Otherwise, fall through. */ if (i < cond_list_size) continue; } /* If the conditional state is not 0 (actively using these lines), ignore this input line. */ if (cstate != 0) continue; /* Conditional skip */ /* Handle .include lines - these are also physical lines. */ if (Ustrncmp(ss, ".include", 8) == 0 && (isspace(ss[8]) || (Ustrncmp(ss+8, "_if_exists", 10) == 0 && isspace(ss[18])))) { uschar *t; int include_if_exists = isspace(ss[8])? 0 : 10; config_file_item *save; struct stat statbuf; ss += 9 + include_if_exists; while (isspace(*ss)) ss++; t = ss + Ustrlen(ss); while (t > ss && isspace(t[-1])) t--; if (*ss == '\"' && t[-1] == '\"') { ss++; t--; } *t = 0; if (*ss != '/') log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, ".include specifies a non-" "absolute path \"%s\"", ss); if (include_if_exists != 0 && (Ustat(ss, &statbuf) != 0)) continue; save = store_get(sizeof(config_file_item)); save->next = config_file_stack; config_file_stack = save; save->file = config_file; save->filename = config_filename; save->lineno = config_lineno; config_file = Ufopen(ss, "rb"); if (config_file == NULL) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "failed to open included " "configuration file %s", ss); config_filename = string_copy(ss); config_lineno = 0; continue; } /* If this is the start of the logical line, remember where the non-blank data starts. Otherwise shuffle down continuation lines to remove leading white space. */ if (len == 0) startoffset = ss - big_buffer; else { s = big_buffer + len; if (ss > s) { memmove(s, ss, (newlen - len) - (ss - s) + 1); newlen -= ss - s; } } /* Accept the new addition to the line. Remove trailing white space. */ len = newlen; while (len > 0 && isspace(big_buffer[len-1])) len--; big_buffer[len] = 0; /* We are done if the line does not end in backslash and contains some data. Empty logical lines are ignored. For continuations, remove the backslash and go round the loop to read the continuation line. */ if (len > 0) { if (big_buffer[len-1] != '\\') break; /* End of logical line */ big_buffer[--len] = 0; /* Remove backslash */ } } /* Loop for reading multiple physical lines */ /* We now have a logical line. Test for the end of a configuration section (or, more accurately, for the start of the next section). Place the name of the next section in next_section, and return NULL. If the name given is longer than next_section, truncate it. It will be unrecognized later, because all the known section names do fit. Leave space for pluralizing. */ s = big_buffer + startoffset; /* First non-space character */ if (strncmpic(s, US"begin ", 6) == 0) { s += 6; while (isspace(*s)) s++; if (big_buffer + len - s > sizeof(next_section) - 2) s[sizeof(next_section) - 2] = 0; Ustrcpy(next_section, s); return NULL; } /* Return the first non-blank character. */ return s; }
0
506,691
static int set_cn(X509 *crt, ...) { int ret = 0; X509_NAME *n = NULL; va_list ap; va_start(ap, crt); n = X509_NAME_new(); if (n == NULL) goto out; while (1) { int nid; const char *name; nid = va_arg(ap, int); if (nid == 0) break; name = va_arg(ap, const char *); if (!X509_NAME_add_entry_by_NID(n, nid, MBSTRING_ASC, (unsigned char *)name, -1, -1, 1)) goto out; } if (!X509_set_subject_name(crt, n)) goto out; ret = 1; out: X509_NAME_free(n); va_end(ap); return ret; }
0
318,095
static int rsi_usb_master_reg_read(struct rsi_hw *adapter, u32 reg, u32 *value, u16 len) { struct usb_device *usbdev = ((struct rsi_91x_usbdev *)adapter->rsi_dev)->usbdev; u16 temp; int ret; ret = rsi_usb_reg_read(usbdev, reg, &temp, len); if (ret < 0) return ret; *value = temp; return 0; }
0
231,018
static void prvInitialiseNewQueue( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t * pucQueueStorage, const uint8_t ucQueueType, Queue_t * pxNewQueue ) { /* Remove compiler warnings about unused parameters should * configUSE_TRACE_FACILITY not be set to 1. */ ( void ) ucQueueType; if( uxItemSize == ( UBaseType_t ) 0 ) { /* No RAM was allocated for the queue storage area, but PC head cannot * be set to NULL because NULL is used as a key to say the queue is used as * a mutex. Therefore just set pcHead to point to the queue as a benign * value that is known to be within the memory map. */ pxNewQueue->pcHead = ( int8_t * ) pxNewQueue; } else { /* Set the head to the start of the queue storage area. */ pxNewQueue->pcHead = ( int8_t * ) pucQueueStorage; } /* Initialise the queue members as described where the queue type is * defined. */ pxNewQueue->uxLength = uxQueueLength; pxNewQueue->uxItemSize = uxItemSize; ( void ) xQueueGenericReset( pxNewQueue, pdTRUE ); #if ( configUSE_TRACE_FACILITY == 1 ) { pxNewQueue->ucQueueType = ucQueueType; } #endif /* configUSE_TRACE_FACILITY */ #if ( configUSE_QUEUE_SETS == 1 ) { pxNewQueue->pxQueueSetContainer = NULL; } #endif /* configUSE_QUEUE_SETS */ traceQUEUE_CREATE( pxNewQueue ); }
0
509,473
int ha_maria::write_row(const uchar * buf) { /* If we have an auto_increment column and we are writing a changed row or a new row, then update the auto_increment value in the record. */ if (table->next_number_field && buf == table->record[0]) { int error; if ((error= update_auto_increment())) return error; } return maria_write(file, buf); }
0
234,865
static void bbio_error(struct btrfs_bio *bbio, struct bio *bio, u64 logical) { atomic_inc(&bbio->error); if (atomic_dec_and_test(&bbio->stripes_pending)) { /* Should be the original bio. */ WARN_ON(bio != bbio->orig_bio); btrfs_io_bio(bio)->mirror_num = bbio->mirror_num; bio->bi_iter.bi_sector = logical >> 9; if (atomic_read(&bbio->error) > bbio->max_errors) bio->bi_status = BLK_STS_IOERR; else bio->bi_status = BLK_STS_OK; btrfs_end_bbio(bbio, bio); } }
0
230,379
PJ_DEF(int) pj_xml_print(const pj_xml_node *node, char *buf, pj_size_t len, pj_bool_t include_prolog) { int prolog_len = 0; int printed; if (!node || !buf || !len) return 0; if (include_prolog) { pj_str_t prolog = {"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", 39}; if ((int)len < prolog.slen) return -1; pj_memcpy(buf, prolog.ptr, prolog.slen); prolog_len = (int)prolog.slen; } printed = xml_print_node(node, 0, buf+prolog_len, len-prolog_len) + prolog_len; if (printed > 0 && len-printed >= 1) { buf[printed++] = '\n'; } return printed; }
0
481,277
static int mlx5_fpga_conn_connect(struct mlx5_fpga_conn *conn) { struct mlx5_fpga_device *fdev = conn->fdev; int err; MLX5_SET(fpga_qpc, conn->fpga_qpc, state, MLX5_FPGA_QPC_STATE_ACTIVE); err = mlx5_fpga_modify_qp(conn->fdev->mdev, conn->fpga_qpn, MLX5_FPGA_QPC_STATE, &conn->fpga_qpc); if (err) { mlx5_fpga_err(fdev, "Failed to activate FPGA RC QP: %d\n", err); goto out; } err = mlx5_fpga_conn_reset_qp(conn); if (err) { mlx5_fpga_err(fdev, "Failed to change QP state to reset\n"); goto err_fpga_qp; } err = mlx5_fpga_conn_init_qp(conn); if (err) { mlx5_fpga_err(fdev, "Failed to modify QP from RESET to INIT\n"); goto err_fpga_qp; } conn->qp.active = true; while (!mlx5_fpga_conn_post_recv_buf(conn)) ; err = mlx5_fpga_conn_rtr_qp(conn); if (err) { mlx5_fpga_err(fdev, "Failed to change QP state from INIT to RTR\n"); goto err_recv_bufs; } err = mlx5_fpga_conn_rts_qp(conn); if (err) { mlx5_fpga_err(fdev, "Failed to change QP state from RTR to RTS\n"); goto err_recv_bufs; } goto out; err_recv_bufs: mlx5_fpga_conn_free_recv_bufs(conn); err_fpga_qp: MLX5_SET(fpga_qpc, conn->fpga_qpc, state, MLX5_FPGA_QPC_STATE_INIT); if (mlx5_fpga_modify_qp(conn->fdev->mdev, conn->fpga_qpn, MLX5_FPGA_QPC_STATE, &conn->fpga_qpc)) mlx5_fpga_err(fdev, "Failed to revert FPGA QP to INIT\n"); out: return err; }
0