idx
int64
func
string
target
int64
395,066
redraw_asap(int type) { int rows; int cols = screen_Columns; int r; int ret = 0; schar_T *screenline; // copy from ScreenLines[] sattr_T *screenattr; // copy from ScreenAttrs[] int i; u8char_T *screenlineUC = NULL; // copy from ScreenLinesUC[] u8char_T *screenlineC[MAX_MCO]; // copy from ScreenLinesC[][] schar_T *screenline2 = NULL; // copy from ScreenLines2[] redraw_later(type); if (msg_scrolled || (State != NORMAL && State != NORMAL_BUSY) || exiting) return ret; // Allocate space to save the text displayed in the command line area. rows = screen_Rows - cmdline_row; screenline = LALLOC_MULT(schar_T, rows * cols); screenattr = LALLOC_MULT(sattr_T, rows * cols); if (screenline == NULL || screenattr == NULL) ret = 2; if (enc_utf8) { screenlineUC = LALLOC_MULT(u8char_T, rows * cols); if (screenlineUC == NULL) ret = 2; for (i = 0; i < p_mco; ++i) { screenlineC[i] = LALLOC_MULT(u8char_T, rows * cols); if (screenlineC[i] == NULL) ret = 2; } } if (enc_dbcs == DBCS_JPNU) { screenline2 = LALLOC_MULT(schar_T, rows * cols); if (screenline2 == NULL) ret = 2; } if (ret != 2) { // Save the text displayed in the command line area. for (r = 0; r < rows; ++r) { mch_memmove(screenline + r * cols, ScreenLines + LineOffset[cmdline_row + r], (size_t)cols * sizeof(schar_T)); mch_memmove(screenattr + r * cols, ScreenAttrs + LineOffset[cmdline_row + r], (size_t)cols * sizeof(sattr_T)); if (enc_utf8) { mch_memmove(screenlineUC + r * cols, ScreenLinesUC + LineOffset[cmdline_row + r], (size_t)cols * sizeof(u8char_T)); for (i = 0; i < p_mco; ++i) mch_memmove(screenlineC[i] + r * cols, ScreenLinesC[i] + LineOffset[cmdline_row + r], (size_t)cols * sizeof(u8char_T)); } if (enc_dbcs == DBCS_JPNU) mch_memmove(screenline2 + r * cols, ScreenLines2 + LineOffset[cmdline_row + r], (size_t)cols * sizeof(schar_T)); } update_screen(0); ret = 3; if (must_redraw == 0) { int off = (int)(current_ScreenLine - ScreenLines); // Restore the text displayed in the command line area. for (r = 0; r < rows; ++r) { mch_memmove(current_ScreenLine, screenline + r * cols, (size_t)cols * sizeof(schar_T)); mch_memmove(ScreenAttrs + off, screenattr + r * cols, (size_t)cols * sizeof(sattr_T)); if (enc_utf8) { mch_memmove(ScreenLinesUC + off, screenlineUC + r * cols, (size_t)cols * sizeof(u8char_T)); for (i = 0; i < p_mco; ++i) mch_memmove(ScreenLinesC[i] + off, screenlineC[i] + r * cols, (size_t)cols * sizeof(u8char_T)); } if (enc_dbcs == DBCS_JPNU) mch_memmove(ScreenLines2 + off, screenline2 + r * cols, (size_t)cols * sizeof(schar_T)); screen_line(cmdline_row + r, 0, cols, cols, 0); } ret = 4; } } vim_free(screenline); vim_free(screenattr); if (enc_utf8) { vim_free(screenlineUC); for (i = 0; i < p_mco; ++i) vim_free(screenlineC[i]); } if (enc_dbcs == DBCS_JPNU) vim_free(screenline2); // Show the intro message when appropriate. maybe_intro_message(); setcursor(); return ret; }
0
508,361
bool setup_tables_and_check_access(THD *thd, Name_resolution_context *context, List<TABLE_LIST> *from_clause, TABLE_LIST *tables, List<TABLE_LIST> &leaves, bool select_insert, ulong want_access_first, ulong want_access, bool full_table_list) { DBUG_ENTER("setup_tables_and_check_access"); if (setup_tables(thd, context, from_clause, tables, leaves, select_insert, full_table_list)) DBUG_RETURN(TRUE); List_iterator<TABLE_LIST> ti(leaves); TABLE_LIST *table_list; ulong access= want_access_first; while ((table_list= ti++)) { if (table_list->belong_to_view && !table_list->view && check_single_table_access(thd, access, table_list, FALSE)) { tables->hide_view_error(thd); DBUG_RETURN(TRUE); } access= want_access; } DBUG_RETURN(FALSE); }
0
384,800
gettail(char_u *fname) { char_u *p1, *p2; if (fname == NULL) return (char_u *)""; for (p1 = p2 = get_past_head(fname); *p2; ) // find last part of path { if (vim_ispathsep_nocolon(*p2)) p1 = p2 + 1; MB_PTR_ADV(p2); } return p1; }
0
417,119
mp_int64 PlayerGeneric::getSyncCount() const { if (player) return player->getSyncCount(); return 0; }
0
376,329
gpg_ctx_free (struct _GpgCtx *gpg) { gint i; if (gpg == NULL) return; if (gpg->session) g_object_unref (gpg->session); g_hash_table_foreach (gpg->userid_hint, userid_hint_free, NULL); g_hash_table_destroy (gpg->userid_hint); g_slist_free_full (gpg->userids, g_free); g_free (gpg->sigfile); if (gpg->recipients) { for (i = 0; i < gpg->recipients->len; i++) g_free (gpg->recipients->pdata[i]); g_ptr_array_free (gpg->recipients, TRUE); } if (gpg->stdin_fd != -1) close (gpg->stdin_fd); if (gpg->stdout_fd != -1) close (gpg->stdout_fd); if (gpg->stderr_fd != -1) close (gpg->stderr_fd); if (gpg->status_fd != -1) close (gpg->status_fd); if (gpg->passwd_fd != -1) close (gpg->passwd_fd); g_free (gpg->statusbuf); g_free (gpg->need_id); if (gpg->passwd) { memset (gpg->passwd, 0, strlen (gpg->passwd)); g_free (gpg->passwd); } if (gpg->istream) g_object_unref (gpg->istream); if (gpg->ostream) g_object_unref (gpg->ostream); g_object_unref (gpg->diagnostics); if (gpg->signers) g_string_free (gpg->signers, TRUE); g_free (gpg); }
0
282,877
int rsi_set_antenna(struct rsi_common *common, u8 antenna) { struct rsi_ant_sel_frame *ant_sel_frame; struct sk_buff *skb; skb = dev_alloc_skb(FRAME_DESC_SZ); if (!skb) { rsi_dbg(ERR_ZONE, "%s: Failed in allocation of skb\n", __func__); return -ENOMEM; } memset(skb->data, 0, FRAME_DESC_SZ); ant_sel_frame = (struct rsi_ant_sel_frame *)skb->data; ant_sel_frame->desc_dword0.frame_type = ANT_SEL_FRAME; ant_sel_frame->sub_frame_type = ANTENNA_SEL_TYPE; ant_sel_frame->ant_value = cpu_to_le16(antenna & ANTENNA_MASK_VALUE); rsi_set_len_qno(&ant_sel_frame->desc_dword0.len_qno, 0, RSI_WIFI_MGMT_Q); skb_put(skb, FRAME_DESC_SZ); return rsi_send_internal_mgmt_frame(common, skb); }
0
224,479
static GF_Err gf_text_ttml_setup(GF_Filter *filter, GF_TXTIn *ctx) { GF_Err e; u32 i, nb_children, ID; u64 file_size; s32 sub_fps_num, sub_fps_den; GF_XMLAttribute *att; GF_XMLNode *root, *node, *body_node; const char *lang = ctx->lang; ctx->is_setup = GF_TRUE; ctx->parser = gf_xml_dom_new(); e = gf_xml_dom_parse(ctx->parser, ctx->file_name, ttxt_dom_progress, ctx); if (e) { GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[TXTIn] Error parsing TTML file: Line %d - %s. Abort.\n", gf_xml_dom_get_line(ctx->parser), gf_xml_dom_get_error(ctx->parser) )); ctx->is_setup = GF_TRUE; ctx->non_compliant_ttml = GF_TRUE; return e; } root = gf_xml_dom_get_root(ctx->parser); if (!root) { GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[TXTIn] Error parsing TTML file: no root XML element found. Abort.\n")); ctx->non_compliant_ttml = GF_TRUE; return GF_NON_COMPLIANT_BITSTREAM; } /*look for TTML*/ if (gf_xml_get_element_check_namespace(root, "tt", NULL) != GF_OK) { if (root->ns) { GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("TTML file not recognized: root element is \"%s:%s\" (check your namespaces)\n", root->ns, root->name)); } else { GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("TTML file not recognized: root element is \"%s\"\n", root->name)); } ctx->non_compliant_ttml = GF_TRUE; return GF_NOT_SUPPORTED; } GF_LOG(GF_LOG_DEBUG, GF_LOG_PARSER, ("[TXTIn] TTML EBU-TTD detected\n")); root = gf_xml_dom_get_root(ctx->parser); /*** root (including language) ***/ sub_fps_num = 0; sub_fps_den = 0; i=0; while ( (att = (GF_XMLAttribute *)gf_list_enum(root->attributes, &i))) { const char *att_name; GF_LOG(GF_LOG_DEBUG, GF_LOG_PARSER, ("[TTML] Found root attribute name %s, value %s\n", att->name, att->value)); att_name = strchr(att->name, ':'); if (att_name) att_name++; else att_name = att->name; if (!strcmp(att->name, "xmlns")) { if (strcmp(att->value, TTML_NAMESPACE)) { GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[TTML] XML Namespace %s not recognized, expecting %s\n", att->name, att->value, TTML_NAMESPACE)); ctx->non_compliant_ttml = GF_TRUE; return GF_NON_COMPLIANT_BITSTREAM; } } else if (!strcmp(att->name, "xml:lang") && att->value && strlen(att->value)) { lang = att->value; } else if (!strcmp(att_name, "tickRate") && att->value) { ctx->tick_rate = atoi(att->value); } else if (!strcmp(att_name, "frameRate") && att->value) { ctx->ttml_fps_num = atoi(att->value); ctx->ttml_fps_den = 1; } else if (!strcmp(att_name, "frameRateMultiplier") && att->value) { char *sep = strchr(att->value, ' '); if (!sep) sep = strchr(att->value, '\t'); if (sep) { u8 c = sep[0]; sep[0] = 0; sub_fps_num = atoi(sep); sep[0] = c; while ((sep[0]==' ') || (sep[0]=='\t')) sep++; sub_fps_den = atoi(sep); } } else if (!strcmp(att_name, "subFrameRate") && att->value) { ctx->ttml_sfps = atoi(att->value); } } if (sub_fps_num && sub_fps_den && ctx->ttml_fps_num) { ctx->ttml_fps_num *= sub_fps_num; ctx->ttml_fps_den = sub_fps_den; } //locate body nb_children = gf_list_count(root->content); body_node = NULL; i=0; while ( (node = (GF_XMLNode*)gf_list_enum(root->content, &i))) { if (node->type) { nb_children--; continue; } e = gf_xml_get_element_check_namespace(node, "body", root->ns); if (e == GF_BAD_PARAM) { GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("[TTML EBU-TTD] ignored \"%s\" node, check your namespaces\n", node->name)); } else if (e == GF_OK) { if (body_node) { GF_LOG(GF_LOG_ERROR, GF_LOG_PARSER, ("[TTML EBU-TTD] duplicated \"body\" element. Abort.\n")); ctx->non_compliant_ttml = GF_TRUE; return GF_NON_COMPLIANT_BITSTREAM; } body_node = node; } } if (!body_node) { GF_LOG(GF_LOG_DEBUG, GF_LOG_PARSER, ("[TTML EBU-TTD] \"body\" element not found, assuming empty doc\n")); } if (!ctx->div_nodes_list) { ctx->div_nodes_list = gf_list_new(); if (!ctx->div_nodes_list) return GF_OUT_OF_MEM; } else { gf_list_reset(ctx->div_nodes_list); } if (body_node) { i=0; while ( (node = (GF_XMLNode*)gf_list_enum(body_node->content, &i))) { if (!node->type) { e = gf_xml_get_element_check_namespace(node, "div", root->ns); if (e == GF_BAD_PARAM) { GF_LOG(GF_LOG_WARNING, GF_LOG_PARSER, ("[TTML EBU-TTD] ignored \"%s\" node, check your namespaces\n", node->name)); } } gf_list_add(ctx->div_nodes_list, node); } } file_size = ctx->end; if (!ctx->timescale) ctx->timescale = 1000; if (!ctx->opid) ctx->opid = gf_filter_pid_new(filter); gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_STREAM_TYPE, &PROP_UINT(GF_STREAM_TEXT) ); gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_CODECID, &PROP_UINT(GF_CODECID_SUBS_XML) ); gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_TIMESCALE, &PROP_UINT(ctx->timescale) ); gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_DOWN_SIZE, &PROP_LONGUINT(file_size) ); ID = 1; gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_ID, &PROP_UINT(ID) ); if (ctx->width) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_WIDTH, &PROP_UINT(ctx->width) ); if (ctx->height) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_HEIGHT, &PROP_UINT(ctx->height) ); if (ctx->zorder) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_ZORDER, &PROP_SINT(ctx->zorder) ); if (lang) gf_filter_pid_set_property(ctx->opid, GF_PROP_PID_LANGUAGE, &PROP_STRING( lang) ); gf_filter_pid_set_property_str(ctx->opid, "meta:xmlns", &PROP_STRING(TTML_NAMESPACE) ); /*** body ***/ ctx->parser_working_copy = gf_xml_dom_new(); e = gf_xml_dom_parse(ctx->parser_working_copy, ctx->file_name, NULL, NULL); assert (e == GF_OK); ctx->root_working_copy = gf_xml_dom_get_root(ctx->parser_working_copy); assert(ctx->root_working_copy); if (body_node) { /*remove all the sample entries (instances in body) entries from the working copy, we will add each sample in this clone DOM to create full XML of each sample*/ ebu_ttd_remove_samples(ctx->root_working_copy, &ctx->body_node); if (!ctx->body_node) { return GF_NON_COMPLIANT_BITSTREAM; } } else { ctx->body_node = NULL; } ctx->current_tt_interval = 0; ctx->last_sample_duration = 0; ctx->end = 0; ctx->first_samp = GF_TRUE; txtin_probe_duration(ctx); e = ttml_setup_intervals(ctx); if (e) return e; if (ctx->has_images) { char *mime_cfg = "application/ttml+xml;codecs=im1i"; gf_filter_pid_set_property_str(ctx->opid, "meta:mime", &PROP_STRING(mime_cfg) ); } else { gf_filter_pid_set_property_str(ctx->opid, "meta:mime", NULL); } return GF_OK; }
0
509,540
int ha_maria::enable_indexes(uint mode) { int error; ha_rows start_rows= file->state->records; DBUG_PRINT("info", ("ha_maria::enable_indexes mode: %d", mode)); if (maria_is_all_keys_active(file->s->state.key_map, file->s->base.keys)) { /* All indexes are enabled already. */ return 0; } if (mode == HA_KEY_SWITCH_ALL) { error= maria_enable_indexes(file); /* Do not try to repair on error, as this could make the enabled state persistent, but mode==HA_KEY_SWITCH_ALL forbids it. */ } else if (mode == HA_KEY_SWITCH_NONUNIQ_SAVE) { THD *thd= table->in_use; HA_CHECK *param= (HA_CHECK*) thd->alloc(sizeof *param); if (!param) return HA_ADMIN_INTERNAL_ERROR; const char *save_proc_info= thd_proc_info(thd, "Creating index"); maria_chk_init(param); param->op_name= "recreating_index"; param->testflag= (T_SILENT | T_REP_BY_SORT | T_QUICK | T_CREATE_MISSING_KEYS | T_SAFE_REPAIR); /* Don't lock and unlock table if it's locked. Normally table should be locked. This test is mostly for safety. */ if (likely(file->lock_type != F_UNLCK)) param->testflag|= T_NO_LOCKS; if (file->create_unique_index_by_sort) param->testflag|= T_CREATE_UNIQUE_BY_SORT; if (bulk_insert_single_undo == BULK_INSERT_SINGLE_UNDO_AND_NO_REPAIR) { bulk_insert_single_undo= BULK_INSERT_SINGLE_UNDO_AND_REPAIR; /* Don't bump create_rename_lsn, because UNDO_BULK_INSERT should not be skipped in case of crash during repair. */ param->testflag|= T_NO_CREATE_RENAME_LSN; } param->myf_rw &= ~MY_WAIT_IF_FULL; param->orig_sort_buffer_length= THDVAR(thd,sort_buffer_size); param->stats_method= (enum_handler_stats_method)THDVAR(thd,stats_method); param->tmpdir= &mysql_tmpdir_list; if ((error= (repair(thd, param, 0) != HA_ADMIN_OK)) && param->retry_repair) { sql_print_warning("Warning: Enabling keys got errno %d on %s.%s, " "retrying", my_errno, param->db_name, param->table_name); /* This should never fail normally */ DBUG_ASSERT(thd->killed != 0); /* Repairing by sort failed. Now try standard repair method. */ param->testflag &= ~T_REP_BY_SORT; file->state->records= start_rows; error= (repair(thd, param, 0) != HA_ADMIN_OK); /* If the standard repair succeeded, clear all error messages which might have been set by the first repair. They can still be seen with SHOW WARNINGS then. */ if (!error) thd->clear_error(); } info(HA_STATUS_CONST); thd_proc_info(thd, save_proc_info); } else { /* mode not implemented */ error= HA_ERR_WRONG_COMMAND; } DBUG_EXECUTE_IF("maria_flush_whole_log", { DBUG_PRINT("maria_flush_whole_log", ("now")); translog_flush(translog_get_horizon()); }); DBUG_EXECUTE_IF("maria_crash_enable_index", { DBUG_PRINT("maria_crash_enable_index", ("now")); DBUG_SUICIDE(); }); return error; }
0
359,454
DEFUN (no_bgp_graceful_restart_stalepath_time, no_bgp_graceful_restart_stalepath_time_cmd, "no bgp graceful-restart stalepath-time", NO_STR "BGP specific commands\n" "Graceful restart capability parameters\n" "Set the max time to hold onto restarting peer's stale paths\n") { struct bgp *bgp; bgp = vty->index; if (! bgp) return CMD_WARNING; bgp->stalepath_time = BGP_DEFAULT_STALEPATH_TIME; return CMD_SUCCESS; }
0
225,689
void gnrm_box_del(GF_Box *s) { GF_GenericSampleEntryBox *ptr = (GF_GenericSampleEntryBox *)s; gf_isom_sample_entry_predestroy((GF_SampleEntryBox *)ptr); if (ptr->data) gf_free(ptr->data); gf_free(ptr); }
0
238,469
static void scrub_spilled_slot(u8 *stype) { if (*stype != STACK_INVALID) *stype = STACK_MISC; }
0
294,445
date_s__xmlschema(int argc, VALUE *argv, VALUE klass) { VALUE str, opt; rb_scan_args(argc, argv, "1:", &str, &opt); check_limit(str, opt); return date__xmlschema(str); }
0
310,071
NCURSES_SP_NAME(_nc_mvcur_resume) (NCURSES_SP_DCL0) /* what to do at initialization time and after each shellout */ { if (!SP_PARM || !IsTermInfo(SP_PARM)) return; /* initialize screen for cursor access */ if (enter_ca_mode) { NCURSES_PUTP2("enter_ca_mode", enter_ca_mode); } /* * Doing this here rather than in _nc_mvcur_wrap() ensures that * ncurses programs will see a reset scroll region even if a * program that messed with it died ungracefully. * * This also undoes the effects of terminal init strings that assume * they know the screen size. This is useful when you're running * a vt100 emulation through xterm. */ reset_scroll_region(NCURSES_SP_ARG); SP_PARM->_cursrow = SP_PARM->_curscol = -1; /* restore cursor shape */ if (SP_PARM->_cursor != -1) { int cursor = SP_PARM->_cursor; SP_PARM->_cursor = -1; NCURSES_SP_NAME(curs_set) (NCURSES_SP_ARGx cursor); } }
0
506,438
mech_rpa_build_token2(struct rpa_auth_request *request, size_t *size) { const struct auth_settings *set = request->auth_request.set; unsigned int realms_len, length; string_t *realms; buffer_t *buf; unsigned char timestamp[RPA_TIMESTAMP_LEN / 2]; const char *const *tmp; realms = t_str_new(64); for (tmp = set->realms_arr; *tmp != NULL; tmp++) { rpa_add_realm(realms, *tmp, request->auth_request.service); } if (str_len(realms) == 0) { rpa_add_realm(realms, *set->default_realm != '\0' ? set->default_realm : my_hostname, request->auth_request.service); } realms_len = str_len(realms) - 1; length = sizeof(rpa_oid) + 3 + RPA_SCHALLENGE_LEN + RPA_TIMESTAMP_LEN + 2 + realms_len; buf = buffer_create_dynamic(request->pool, length + 4); buffer_append_c(buf, ASN1_APPLICATION); buffer_append_asn1_length(buf, length); buffer_append(buf, rpa_oid, sizeof(rpa_oid)); /* Protocol version */ buffer_append_c(buf, 3); buffer_append_c(buf, 0); /* Service challenge */ request->service_challenge = p_malloc(request->pool, RPA_SCHALLENGE_LEN); random_fill(request->service_challenge, RPA_SCHALLENGE_LEN); buffer_append_c(buf, RPA_SCHALLENGE_LEN); buffer_append(buf, request->service_challenge, RPA_SCHALLENGE_LEN); /* Timestamp, looks like clients accept anything we send */ random_fill(timestamp, sizeof(timestamp)); request->service_timestamp = p_malloc(request->pool, RPA_TIMESTAMP_LEN); memcpy(request->service_timestamp, binary_to_hex(timestamp, sizeof(timestamp)), RPA_TIMESTAMP_LEN); buffer_append(buf, request->service_timestamp, RPA_TIMESTAMP_LEN); /* Realm list */ buffer_append_c(buf, realms_len >> 8); buffer_append_c(buf, realms_len & 0xff); buffer_append(buf, str_c(realms), realms_len); *size = buf->used; return buffer_free_without_data(&buf); }
0
267,971
R_IPI RBinFile *r_bin_file_xtr_load_buffer(RBin *bin, RBinXtrPlugin *xtr, const char *filename, RBuffer *buf, ut64 baseaddr, ut64 loadaddr, int idx, int fd, int rawstr) { r_return_val_if_fail (bin && xtr && buf, NULL); RBinFile *bf = r_bin_file_find_by_name (bin, filename); if (!bf) { bf = r_bin_file_new (bin, filename, r_buf_size (buf), rawstr, fd, xtr->name, bin->sdb, false); if (!bf) { return NULL; } r_list_append (bin->binfiles, bf); if (!bin->cur) { bin->cur = bf; } } r_list_free (bf->xtr_data); bf->xtr_data = NULL; if (xtr->extractall_from_buffer) { bf->xtr_data = xtr->extractall_from_buffer (bin, buf); } else if (xtr->extractall_from_bytes) { ut64 sz = 0; const ut8 *bytes = r_buf_data (buf, &sz); eprintf ("TODO: Implement extractall_from_buffer in '%s' xtr.bin plugin\n", xtr->name); bf->xtr_data = xtr->extractall_from_bytes (bin, bytes, sz); } if (bf->xtr_data) { RListIter *iter; RBinXtrData *x; //populate xtr_data with baddr and laddr that will be used later on //r_bin_file_object_new_from_xtr_data r_list_foreach (bf->xtr_data, iter, x) { x->baddr = baseaddr? baseaddr : UT64_MAX; x->laddr = loadaddr? loadaddr : UT64_MAX; } } bf->loadaddr = loadaddr; return bf; }
0
312,496
qf_list_empty(qf_list_T *qfl) { return qfl == NULL || qfl->qf_count <= 0; }
0
252,445
mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags) { mz_uint uncomp_crc32 = MZ_CRC32_INIT, level, num_alignment_padding_bytes; mz_uint16 method = 0, dos_time = 0, dos_date = 0, ext_attributes = 0; mz_uint64 local_dir_header_ofs = pZip->m_archive_size, cur_archive_file_ofs = pZip->m_archive_size, uncomp_size = 0, comp_size = 0; size_t archive_name_size; mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE]; MZ_FILE *pSrc_file = NULL; if ((int)level_and_flags < 0) level_and_flags = MZ_DEFAULT_LEVEL; level = level_and_flags & 0xF; if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || (!pArchive_name) || ((comment_size) && (!pComment)) || (level > MZ_UBER_COMPRESSION)) return MZ_FALSE; if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA) return MZ_FALSE; if (!mz_zip_writer_validate_archive_name(pArchive_name)) return MZ_FALSE; archive_name_size = strlen(pArchive_name); if (archive_name_size > 0xFFFF) return MZ_FALSE; num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip); // no zip64 support yet if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + comment_size + archive_name_size) > 0xFFFFFFFF)) return MZ_FALSE; if (!mz_zip_get_file_modified_time(pSrc_filename, &dos_time, &dos_date)) return MZ_FALSE; pSrc_file = MZ_FOPEN(pSrc_filename, "rb"); if (!pSrc_file) return MZ_FALSE; MZ_FSEEK64(pSrc_file, 0, SEEK_END); uncomp_size = MZ_FTELL64(pSrc_file); MZ_FSEEK64(pSrc_file, 0, SEEK_SET); if (uncomp_size > 0xFFFFFFFF) { // No zip64 support yet MZ_FCLOSE(pSrc_file); return MZ_FALSE; } if (uncomp_size <= 3) level = 0; if (!mz_zip_writer_write_zeros( pZip, cur_archive_file_ofs, num_alignment_padding_bytes + sizeof(local_dir_header))) { MZ_FCLOSE(pSrc_file); return MZ_FALSE; } local_dir_header_ofs += num_alignment_padding_bytes; if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); } cur_archive_file_ofs += num_alignment_padding_bytes + sizeof(local_dir_header); MZ_CLEAR_OBJ(local_dir_header); if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size) { MZ_FCLOSE(pSrc_file); return MZ_FALSE; } cur_archive_file_ofs += archive_name_size; if (uncomp_size) { mz_uint64 uncomp_remaining = uncomp_size; void *pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, MZ_ZIP_MAX_IO_BUF_SIZE); if (!pRead_buf) { MZ_FCLOSE(pSrc_file); return MZ_FALSE; } if (!level) { while (uncomp_remaining) { mz_uint n = (mz_uint)MZ_MIN((mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE, uncomp_remaining); if ((MZ_FREAD(pRead_buf, 1, n, pSrc_file) != n) || (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf, n) != n)) { pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); MZ_FCLOSE(pSrc_file); return MZ_FALSE; } uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, n); uncomp_remaining -= n; cur_archive_file_ofs += n; } comp_size = uncomp_size; } else { mz_bool result = MZ_FALSE; mz_zip_writer_add_state state; tdefl_compressor *pComp = (tdefl_compressor *)pZip->m_pAlloc( pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor)); if (!pComp) { pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); MZ_FCLOSE(pSrc_file); return MZ_FALSE; } state.m_pZip = pZip; state.m_cur_archive_file_ofs = cur_archive_file_ofs; state.m_comp_size = 0; if (tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, tdefl_create_comp_flags_from_zip_params( level, -15, MZ_DEFAULT_STRATEGY)) != TDEFL_STATUS_OKAY) { pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); MZ_FCLOSE(pSrc_file); return MZ_FALSE; } for (;;) { size_t in_buf_size = (mz_uint32)MZ_MIN(uncomp_remaining, (mz_uint)MZ_ZIP_MAX_IO_BUF_SIZE); tdefl_status status; if (MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size) break; uncomp_crc32 = (mz_uint32)mz_crc32( uncomp_crc32, (const mz_uint8 *)pRead_buf, in_buf_size); uncomp_remaining -= in_buf_size; status = tdefl_compress_buffer( pComp, pRead_buf, in_buf_size, uncomp_remaining ? TDEFL_NO_FLUSH : TDEFL_FINISH); if (status == TDEFL_STATUS_DONE) { result = MZ_TRUE; break; } else if (status != TDEFL_STATUS_OKAY) break; } pZip->m_pFree(pZip->m_pAlloc_opaque, pComp); if (!result) { pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); MZ_FCLOSE(pSrc_file); return MZ_FALSE; } comp_size = state.m_comp_size; cur_archive_file_ofs = state.m_cur_archive_file_ofs; method = MZ_DEFLATED; } pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf); } MZ_FCLOSE(pSrc_file); pSrc_file = NULL; // no zip64 support yet if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF)) return MZ_FALSE; if (!mz_zip_writer_create_local_dir_header( pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date)) return MZ_FALSE; if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header)) return MZ_FALSE; if (!mz_zip_writer_add_to_central_dir( pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment, comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date, local_dir_header_ofs, ext_attributes)) return MZ_FALSE; pZip->m_total_files++; pZip->m_archive_size = cur_archive_file_ofs; return MZ_TRUE; }
0
198,552
static int pkey_GOST_ECcp_encrypt(EVP_PKEY_CTX *pctx, unsigned char *out, size_t *out_len, const unsigned char *key, size_t key_len) { GOST_KEY_TRANSPORT *gkt = NULL; EVP_PKEY *pubk = EVP_PKEY_CTX_get0_pkey(pctx); struct gost_pmeth_data *data = EVP_PKEY_CTX_get_data(pctx); int pkey_nid = EVP_PKEY_base_id(pubk); ASN1_OBJECT *crypt_params_obj = (pkey_nid == NID_id_GostR3410_2001 || pkey_nid == NID_id_GostR3410_2001DH) ? OBJ_nid2obj(NID_id_Gost28147_89_CryptoPro_A_ParamSet) : OBJ_nid2obj(NID_id_tc26_gost_28147_param_Z); const struct gost_cipher_info *param = get_encryption_params(crypt_params_obj); unsigned char ukm[8], shared_key[32], crypted_key[44]; int ret = 0; int key_is_ephemeral = 1; gost_ctx cctx; EVP_PKEY *sec_key = EVP_PKEY_CTX_get0_peerkey(pctx); if (data->shared_ukm_size) { memcpy(ukm, data->shared_ukm, 8); } else { if (RAND_bytes(ukm, 8) <= 0) { GOSTerr(GOST_F_PKEY_GOST_ECCP_ENCRYPT, GOST_R_RNG_ERROR); return 0; } } if (!param) goto err; /* Check for private key in the peer_key of context */ if (sec_key) { key_is_ephemeral = 0; if (!gost_get0_priv_key(sec_key)) { GOSTerr(GOST_F_PKEY_GOST_ECCP_ENCRYPT, GOST_R_NO_PRIVATE_PART_OF_NON_EPHEMERAL_KEYPAIR); goto err; } } else { key_is_ephemeral = 1; if (out) { sec_key = EVP_PKEY_new(); if (!EVP_PKEY_assign(sec_key, EVP_PKEY_base_id(pubk), EC_KEY_new()) || !EVP_PKEY_copy_parameters(sec_key, pubk) || !gost_ec_keygen(EVP_PKEY_get0(sec_key))) { GOSTerr(GOST_F_PKEY_GOST_ECCP_ENCRYPT, GOST_R_ERROR_COMPUTING_SHARED_KEY); goto err; } } } if (out) { int dgst_nid = NID_undef; EVP_PKEY_get_default_digest_nid(pubk, &dgst_nid); if (dgst_nid == NID_id_GostR3411_2012_512) dgst_nid = NID_id_GostR3411_2012_256; if (!VKO_compute_key(shared_key, EC_KEY_get0_public_key(EVP_PKEY_get0(pubk)), EVP_PKEY_get0(sec_key), ukm, 8, dgst_nid)) { GOSTerr(GOST_F_PKEY_GOST_ECCP_ENCRYPT, GOST_R_ERROR_COMPUTING_SHARED_KEY); goto err; } gost_init(&cctx, param->sblock); keyWrapCryptoPro(&cctx, shared_key, ukm, key, crypted_key); } gkt = GOST_KEY_TRANSPORT_new(); if (!gkt) { goto err; } if (!ASN1_OCTET_STRING_set(gkt->key_agreement_info->eph_iv, ukm, 8)) { goto err; } if (!ASN1_OCTET_STRING_set(gkt->key_info->imit, crypted_key + 40, 4)) { goto err; } if (!ASN1_OCTET_STRING_set (gkt->key_info->encrypted_key, crypted_key + 8, 32)) { goto err; } if (key_is_ephemeral) { if (!X509_PUBKEY_set (&gkt->key_agreement_info->ephem_key, out ? sec_key : pubk)) { GOSTerr(GOST_F_PKEY_GOST_ECCP_ENCRYPT, GOST_R_CANNOT_PACK_EPHEMERAL_KEY); goto err; } } ASN1_OBJECT_free(gkt->key_agreement_info->cipher); gkt->key_agreement_info->cipher = OBJ_nid2obj(param->nid); if (key_is_ephemeral) EVP_PKEY_free(sec_key); if (!key_is_ephemeral) { /* Set control "public key from client certificate used" */ if (EVP_PKEY_CTX_ctrl(pctx, -1, -1, EVP_PKEY_CTRL_PEER_KEY, 3, NULL) <= 0) { GOSTerr(GOST_F_PKEY_GOST_ECCP_ENCRYPT, GOST_R_CTRL_CALL_FAILED); goto err; } } if ((*out_len = i2d_GOST_KEY_TRANSPORT(gkt, out ? &out : NULL)) > 0) ret = 1; OPENSSL_cleanse(shared_key, sizeof(shared_key)); GOST_KEY_TRANSPORT_free(gkt); return ret; err: OPENSSL_cleanse(shared_key, sizeof(shared_key)); if (key_is_ephemeral) EVP_PKEY_free(sec_key); GOST_KEY_TRANSPORT_free(gkt); return -1; }
1
196,790
Status Examples::Initialize(OpKernelContext* const context, const ModelWeights& weights, const int num_sparse_features, const int num_sparse_features_with_values, const int num_dense_features) { num_features_ = num_sparse_features + num_dense_features; OpInputList sparse_example_indices_inputs; TF_RETURN_IF_ERROR(context->input_list("sparse_example_indices", &sparse_example_indices_inputs)); if (sparse_example_indices_inputs.size() != num_sparse_features) return errors::InvalidArgument( "Expected ", num_sparse_features, " tensors in sparse_example_indices but got ", sparse_example_indices_inputs.size()); OpInputList sparse_feature_indices_inputs; TF_RETURN_IF_ERROR(context->input_list("sparse_feature_indices", &sparse_feature_indices_inputs)); if (sparse_feature_indices_inputs.size() != num_sparse_features) return errors::InvalidArgument( "Expected ", num_sparse_features, " tensors in sparse_feature_indices but got ", sparse_feature_indices_inputs.size()); OpInputList sparse_feature_values_inputs; if (num_sparse_features_with_values > 0) { TF_RETURN_IF_ERROR(context->input_list("sparse_feature_values", &sparse_feature_values_inputs)); if (sparse_feature_values_inputs.size() != num_sparse_features_with_values) return errors::InvalidArgument( "Expected ", num_sparse_features_with_values, " tensors in sparse_feature_values but got ", sparse_feature_values_inputs.size()); } const Tensor* example_weights_t; TF_RETURN_IF_ERROR(context->input("example_weights", &example_weights_t)); auto example_weights = example_weights_t->flat<float>(); if (example_weights.size() >= std::numeric_limits<int>::max()) { return errors::InvalidArgument(strings::Printf( "Too many examples in a mini-batch: %zu > %d", example_weights.size(), std::numeric_limits<int>::max())); } // The static_cast here is safe since num_examples can be at max an int. const int num_examples = static_cast<int>(example_weights.size()); const Tensor* example_labels_t; TF_RETURN_IF_ERROR(context->input("example_labels", &example_labels_t)); auto example_labels = example_labels_t->flat<float>(); OpInputList dense_features_inputs; TF_RETURN_IF_ERROR( context->input_list("dense_features", &dense_features_inputs)); examples_.clear(); examples_.resize(num_examples); probabilities_.resize(num_examples); sampled_index_.resize(num_examples); sampled_count_.resize(num_examples); for (int example_id = 0; example_id < num_examples; ++example_id) { Example* const example = &examples_[example_id]; example->sparse_features_.resize(num_sparse_features); example->dense_vectors_.resize(num_dense_features); example->example_weight_ = example_weights(example_id); example->example_label_ = example_labels(example_id); } const DeviceBase::CpuWorkerThreads& worker_threads = *context->device()->tensorflow_cpu_worker_threads(); TF_RETURN_IF_ERROR(CreateSparseFeatureRepresentation( worker_threads, num_examples, num_sparse_features, weights, sparse_example_indices_inputs, sparse_feature_indices_inputs, sparse_feature_values_inputs, &examples_)); TF_RETURN_IF_ERROR(CreateDenseFeatureRepresentation( worker_threads, num_examples, num_dense_features, weights, dense_features_inputs, &examples_)); TF_RETURN_IF_ERROR(ComputeSquaredNormPerExample( worker_threads, num_examples, num_sparse_features, num_dense_features, &examples_)); return Status::OK(); }
1
238,498
static bool insn_has_def32(struct bpf_verifier_env *env, struct bpf_insn *insn) { int dst_reg = insn_def_regno(insn); if (dst_reg == -1) return false; return !is_reg64(env, insn, dst_reg, NULL, DST_OP); }
0
349,887
void hw_atl_utils_mpi_read_stats(struct aq_hw_s *self, struct hw_atl_utils_mbox *pmbox) { int err = 0; err = hw_atl_utils_fw_downld_dwords(self, self->mbox_addr, (u32 *)(void *)pmbox, sizeof(*pmbox) / sizeof(u32)); if (err < 0) goto err_exit; if (ATL_HW_IS_CHIP_FEATURE(self, REVISION_A0)) { unsigned int mtu = self->aq_nic_cfg ? self->aq_nic_cfg->mtu : 1514U; pmbox->stats.ubrc = pmbox->stats.uprc * mtu; pmbox->stats.ubtc = pmbox->stats.uptc * mtu; pmbox->stats.dpc = atomic_read(&self->dpc); } else { pmbox->stats.dpc = hw_atl_rpb_rx_dma_drop_pkt_cnt_get(self); } err_exit:; }
0
248,762
static struct Cookie *dup_cookie(struct Cookie *src) { struct Cookie *d = calloc(sizeof(struct Cookie), 1); if(d) { CLONE(expirestr); CLONE(domain); CLONE(path); CLONE(spath); CLONE(name); CLONE(value); CLONE(maxage); CLONE(version); d->expires = src->expires; d->tailmatch = src->tailmatch; d->secure = src->secure; d->livecookie = src->livecookie; d->httponly = src->httponly; d->creationtime = src->creationtime; } return d; fail: freecookie(d); return NULL; }
0
359,258
DEFUN (bgp_bestpath_med2, bgp_bestpath_med2_cmd, "bgp bestpath med confed missing-as-worst", "BGP specific commands\n" "Change the default bestpath selection\n" "MED attribute\n" "Compare MED among confederation paths\n" "Treat missing MED as the least preferred one\n") { struct bgp *bgp; bgp = vty->index; bgp_flag_set (bgp, BGP_FLAG_MED_CONFED); bgp_flag_set (bgp, BGP_FLAG_MED_MISSING_AS_WORST); return CMD_SUCCESS; }
0
308,203
static int fastrpc_init(void) { int ret; ret = platform_driver_register(&fastrpc_cb_driver); if (ret < 0) { pr_err("fastrpc: failed to register cb driver\n"); return ret; } ret = register_rpmsg_driver(&fastrpc_driver); if (ret < 0) { pr_err("fastrpc: failed to register rpmsg driver\n"); platform_driver_unregister(&fastrpc_cb_driver); return ret; } return 0; }
0
390,602
XkbSendIndicatorMap( ClientPtr client, XkbIndicatorPtr indicators, xkbGetIndicatorMapReply * rep) { int length; CARD8 * map; register int i; register unsigned bit; length = rep->length*4; if (length>0) { CARD8 *to; to= map= (CARD8 *)xalloc(length); if (map) { xkbIndicatorMapWireDesc *wire = (xkbIndicatorMapWireDesc *)to; for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) { if (rep->which&bit) { wire->flags= indicators->maps[i].flags; wire->whichGroups= indicators->maps[i].which_groups; wire->groups= indicators->maps[i].groups; wire->whichMods= indicators->maps[i].which_mods; wire->mods= indicators->maps[i].mods.mask; wire->realMods= indicators->maps[i].mods.real_mods; wire->virtualMods= indicators->maps[i].mods.vmods; wire->ctrls= indicators->maps[i].ctrls; if (client->swapped) { register int n; swaps(&wire->virtualMods,n); swapl(&wire->ctrls,n); } wire++; } } to = (CARD8 *)wire; if ((to-map)!=length) { client->errorValue = _XkbErrCode2(0xff,length); return BadLength; } } else return BadAlloc; } else map = NULL; if (client->swapped) { swaps(&rep->sequenceNumber,i); swapl(&rep->length,i); swapl(&rep->which,i); swapl(&rep->realIndicators,i); } WriteToClient(client, SIZEOF(xkbGetIndicatorMapReply), (char *)rep); if (map) { WriteToClient(client, length, (char *)map); xfree((char *)map); } return client->noClientException; }
0
466,155
static int em_popa(struct x86_emulate_ctxt *ctxt) { int rc = X86EMUL_CONTINUE; int reg = VCPU_REGS_RDI; while (reg >= VCPU_REGS_RAX) { if (reg == VCPU_REGS_RSP) { register_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RSP], ctxt->op_bytes); --reg; } rc = emulate_pop(ctxt, &ctxt->regs[reg], ctxt->op_bytes); if (rc != X86EMUL_CONTINUE) break; --reg; } return rc; }
0
242,625
bool WouldExceedMemoryLimit(std::size_t bytes) const { return bytes + current_bytes_ > memory_limit_; }
0
512,665
void Item_equal::update_used_tables() { not_null_tables_cache= used_tables_cache= 0; if ((const_item_cache= cond_false || cond_true)) return; Item_equal_fields_iterator it(*this); Item *item; const_item_cache= 1; while ((item= it++)) { item->update_used_tables(); used_tables_cache|= item->used_tables(); /* see commentary at Item_equal::update_const() */ const_item_cache&= item->const_item() && !item->is_outer_field(); } }
0
400,113
vector<PortForwardSourceRequest> parseRangesToRequests(const string& input) { vector<PortForwardSourceRequest> pfsrs; auto j = split(input, ','); for (auto& pair : j) { vector<string> sourceDestination = split(pair, ':'); try { if (sourceDestination[0].find_first_not_of("0123456789-") != string::npos && sourceDestination[1].find_first_not_of("0123456789-") != string::npos) { PortForwardSourceRequest pfsr; pfsr.set_environmentvariable(sourceDestination[0]); pfsr.mutable_destination()->set_name(sourceDestination[1]); pfsrs.push_back(pfsr); } else if (sourceDestination[0].find('-') != string::npos && sourceDestination[1].find('-') != string::npos) { vector<string> sourcePortRange = split(sourceDestination[0], '-'); int sourcePortStart = stoi(sourcePortRange[0]); int sourcePortEnd = stoi(sourcePortRange[1]); vector<string> destinationPortRange = split(sourceDestination[1], '-'); int destinationPortStart = stoi(destinationPortRange[0]); int destinationPortEnd = stoi(destinationPortRange[1]); if (sourcePortEnd - sourcePortStart != destinationPortEnd - destinationPortStart) { STFATAL << "source/destination port range mismatch"; exit(1); } else { int portRangeLength = sourcePortEnd - sourcePortStart + 1; for (int i = 0; i < portRangeLength; ++i) { PortForwardSourceRequest pfsr; pfsr.mutable_source()->set_port(sourcePortStart + i); pfsr.mutable_destination()->set_port(destinationPortStart + i); pfsrs.push_back(pfsr); } } } else if (sourceDestination[0].find('-') != string::npos || sourceDestination[1].find('-') != string::npos) { STFATAL << "Invalid port range syntax: if source is range, " "destination must be range"; } else { PortForwardSourceRequest pfsr; pfsr.mutable_source()->set_port(stoi(sourceDestination[0])); pfsr.mutable_destination()->set_port(stoi(sourceDestination[1])); pfsrs.push_back(pfsr); } } catch (const std::logic_error& lr) { STFATAL << "Logic error: " << lr.what(); exit(1); } } return pfsrs; }
0
275,506
njs_vm_prop_magic32(njs_object_prop_t *prop) { return prop->value.data.magic32; }
0
352,970
issuerAndThisUpdateValidate( Syntax *syntax, struct berval *in ) { int rc; struct berval i, tu; Debug( LDAP_DEBUG_TRACE, ">>> issuerAndThisUpdateValidate: <%s>\n", in->bv_val ); rc = issuerAndThisUpdateCheck( in, &i, &tu, NULL ); if ( rc ) { goto done; } /* validate DN -- doesn't handle double dquote */ rc = dnValidate( NULL, &i ); if ( rc ) { rc = LDAP_INVALID_SYNTAX; } else if ( checkTime( &tu, NULL ) ) { rc = LDAP_INVALID_SYNTAX; } if ( in->bv_val[0] == '{' && in->bv_val[in->bv_len-1] == '}' ) { slap_sl_free( i.bv_val, NULL ); } Debug( LDAP_DEBUG_TRACE, "<<< issuerAndThisUpdateValidate: <%s> err=%d\n", in->bv_val, rc ); done:; return rc; }
0
274,849
TEST(ComparisonsTest, GreaterEqualQuantized) { const float kMin = -1.f; const float kMax = 128.f; ComparisonOpModel model({TensorType_UINT8, {1, 2, 2, 1}, kMin, kMax}, {TensorType_UINT8, {1, 2, 2, 1}, kMin, kMax}, TensorType_UINT8, BuiltinOperator_GREATER_EQUAL); model.QuantizeAndPopulate<uint8_t>(model.input1(), {1, 9, 7, 3}); model.QuantizeAndPopulate<uint8_t>(model.input2(), {1, 2, 6, 5}); model.Invoke(); EXPECT_THAT(model.GetOutput(), ElementsAre(true, true, true, false)); }
0
484,755
static void rx_refill_timeout(struct timer_list *t) { struct netfront_queue *queue = from_timer(queue, t, rx_refill_timer); napi_schedule(&queue->napi); }
0
333,077
st_error(int *postfix UNUSED, int *end UNUSED, int *p UNUSED) { #ifdef NFA_REGEXP_ERROR_LOG FILE *df; int *p2; df = fopen(NFA_REGEXP_ERROR_LOG, "a"); if (df) { fprintf(df, "Error popping the stack!\n"); # ifdef DEBUG fprintf(df, "Current regexp is \"%s\"\n", nfa_regengine.expr); # endif fprintf(df, "Postfix form is: "); # ifdef DEBUG for (p2 = postfix; p2 < end; p2++) { nfa_set_code(*p2); fprintf(df, "%s, ", code); } nfa_set_code(*p); fprintf(df, "\nCurrent position is: "); for (p2 = postfix; p2 <= p; p2 ++) { nfa_set_code(*p2); fprintf(df, "%s, ", code); } # else for (p2 = postfix; p2 < end; p2++) fprintf(df, "%d, ", *p2); fprintf(df, "\nCurrent position is: "); for (p2 = postfix; p2 <= p; p2 ++) fprintf(df, "%d, ", *p2); # endif fprintf(df, "\n--------------------------\n"); fclose(df); } #endif emsg(_("E874: (NFA) Could not pop the stack!")); }
0
450,423
static void framebuffer_update_request(VncState *vs, int incremental, int x, int y, int w, int h) { if (incremental) { if (vs->update != VNC_STATE_UPDATE_FORCE) { vs->update = VNC_STATE_UPDATE_INCREMENTAL; } } else { vs->update = VNC_STATE_UPDATE_FORCE; vnc_set_area_dirty(vs->dirty, vs->vd, x, y, w, h); } }
0
238,543
static int check_sock_access(struct bpf_verifier_env *env, int insn_idx, u32 regno, int off, int size, enum bpf_access_type t) { struct bpf_reg_state *regs = cur_regs(env); struct bpf_reg_state *reg = &regs[regno]; struct bpf_insn_access_aux info = {}; bool valid; if (reg->smin_value < 0) { verbose(env, "R%d min value is negative, either use unsigned index or do a if (index >=0) check.\n", regno); return -EACCES; } switch (reg->type) { case PTR_TO_SOCK_COMMON: valid = bpf_sock_common_is_valid_access(off, size, t, &info); break; case PTR_TO_SOCKET: valid = bpf_sock_is_valid_access(off, size, t, &info); break; case PTR_TO_TCP_SOCK: valid = bpf_tcp_sock_is_valid_access(off, size, t, &info); break; case PTR_TO_XDP_SOCK: valid = bpf_xdp_sock_is_valid_access(off, size, t, &info); break; default: valid = false; } if (valid) { env->insn_aux_data[insn_idx].ctx_field_size = info.ctx_field_size; return 0; } verbose(env, "R%d invalid %s access off=%d size=%d\n", regno, reg_type_str(env, reg->type), off, size); return -EACCES; }
0
234,799
static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans, struct btrfs_device *device, u64 start, u64 *dev_extent_len) { struct btrfs_fs_info *fs_info = device->fs_info; struct btrfs_root *root = fs_info->dev_root; int ret; struct btrfs_path *path; struct btrfs_key key; struct btrfs_key found_key; struct extent_buffer *leaf = NULL; struct btrfs_dev_extent *extent = NULL; path = btrfs_alloc_path(); if (!path) return -ENOMEM; key.objectid = device->devid; key.offset = start; key.type = BTRFS_DEV_EXTENT_KEY; again: ret = btrfs_search_slot(trans, root, &key, path, -1, 1); if (ret > 0) { ret = btrfs_previous_item(root, path, key.objectid, BTRFS_DEV_EXTENT_KEY); if (ret) goto out; leaf = path->nodes[0]; btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); extent = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_dev_extent); BUG_ON(found_key.offset > start || found_key.offset + btrfs_dev_extent_length(leaf, extent) < start); key = found_key; btrfs_release_path(path); goto again; } else if (ret == 0) { leaf = path->nodes[0]; extent = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_dev_extent); } else { goto out; } *dev_extent_len = btrfs_dev_extent_length(leaf, extent); ret = btrfs_del_item(trans, root, path); if (ret == 0) set_bit(BTRFS_TRANS_HAVE_FREE_BGS, &trans->transaction->flags); out: btrfs_free_path(path); return ret; }
0
221,074
OpTypeConstructor UnaryTensorContainer(FullTypeId t, FullTypeId dtype) { return [t, dtype](OpDef* op_def) { FullTypeDef* tdef = op_def->mutable_output_arg(0)->mutable_experimental_full_type(); tdef->set_type_id(t); FullTypeDef* arg = tdef->add_args(); arg->set_type_id(TFT_TENSOR); FullTypeDef* targ = arg->add_args(); targ->set_type_id(dtype); return Status::OK(); }; }
0
508,350
uint get_table_def_key(const TABLE_LIST *table_list, const char **key) { /* This call relies on the fact that TABLE_LIST::mdl_request::key object is properly initialized, so table definition cache can be produced from key used by MDL subsystem. */ DBUG_ASSERT(!strcmp(table_list->get_db_name(), table_list->mdl_request.key.db_name()) && !strcmp(table_list->get_table_name(), table_list->mdl_request.key.name())); *key= (const char*)table_list->mdl_request.key.ptr() + 1; return table_list->mdl_request.key.length() - 1; }
0
218,996
void ConstantFolding::ReplaceOperationWithNoOp(NodeDef* node, GraphProperties* properties, GraphDef* graph) { if (HasRegularOutputs(*node, *node_map_)) return; node->set_op("NoOp"); EraseRegularNodeAttributes(node); EraseNodeOutputAttributes(node); // Erase attributes that describe output properties. properties->ClearOutputProperties(node->name()); // Change all inputs to control dependencies. for (int i = 0; i < node->input_size(); ++i) { if (IsControlInput(node->input(i))) { break; } const string ctrl_dep = AddControlDependency(node->input(i), graph, node_map_.get()); node_map_->UpdateInput(node->name(), node->input(i), ctrl_dep); node->set_input(i, ctrl_dep); } DedupControlInputs(node); graph_modified_ = true; }
0
247,638
TEST_P(SslSocketTest, TicketSessionResumption) { const std::string server_ctx_yaml = R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_key.pem" session_ticket_keys: keys: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/ticket_key_a" )EOF"; const std::string client_ctx_yaml = R"EOF( common_tls_context: )EOF"; testTicketSessionResumption(server_ctx_yaml, {}, server_ctx_yaml, {}, client_ctx_yaml, true, GetParam()); }
0
512,546
void in_string::set(uint pos,Item *item) { String *str=((String*) base)+pos; String *res=item->val_str(str); if (res && res != str) { if (res->uses_buffer_owned_by(str)) res->copy(); if (item->type() == Item::FUNC_ITEM) str->copy(*res); else *str= *res; } if (!str->charset()) { CHARSET_INFO *cs; if (!(cs= item->collation.collation)) cs= &my_charset_bin; // Should never happen for STR items str->set_charset(cs); } }
0
512,563
const Type_handler *real_type_handler() const { return (*ref)->real_type_handler(); }
0
338,137
void WasmBinaryBuilder::visitNop(Nop* curr) { BYN_TRACE("zz node: Nop\n"); }
0
488,413
void migration_entry_wait(struct mm_struct *mm, pmd_t *pmd, unsigned long address) { pte_t *ptep, pte; spinlock_t *ptl; swp_entry_t entry; struct page *page; ptep = pte_offset_map_lock(mm, pmd, address, &ptl); pte = *ptep; if (!is_swap_pte(pte)) goto out; entry = pte_to_swp_entry(pte); if (!is_migration_entry(entry)) goto out; page = migration_entry_to_page(entry); get_page(page); pte_unmap_unlock(ptep, ptl); wait_on_page_locked(page); put_page(page); return; out: pte_unmap_unlock(ptep, ptl); }
0
224,462
static GF_Err swf_svg_add_iso_sample(void *user, const u8 *data, u32 length, u64 timestamp, Bool isRap) { GF_FilterPacket *pck; u8 *pck_data; GF_TXTIn *ctx = (GF_TXTIn *)user; if (ctx->seek_state==2) { Double ts = (Double) timestamp; ts/=1000; if (ts<ctx->start_range) return GF_OK; ctx->seek_state = 0; } pck = gf_filter_pck_new_alloc(ctx->opid, length, &pck_data); if (pck) { memcpy(pck_data, data, length); gf_filter_pck_set_cts(pck, (u64) (ctx->timescale*timestamp/1000) ); gf_filter_pck_set_sap(pck, isRap ? GF_FILTER_SAP_1 : GF_FILTER_SAP_NONE); gf_filter_pck_set_framing(pck, GF_TRUE, GF_FALSE); gf_filter_pck_send(pck); } if (gf_filter_pid_would_block(ctx->opid)) ctx->do_suspend = GF_TRUE; return GF_OK; }
0
232,939
new_unencoding_writer(struct Curl_easy *data, const struct content_encoding *handler, struct contenc_writer *downstream) { size_t sz = offsetof(struct contenc_writer, params) + handler->paramsize; struct contenc_writer *writer = (struct contenc_writer *)calloc(1, sz); if(writer) { writer->handler = handler; writer->downstream = downstream; if(handler->init_writer(data, writer)) { free(writer); writer = NULL; } } return writer; }
0
439,174
static MagickBooleanType WriteAVSImage(const ImageInfo *image_info,Image *image) { MagickBooleanType status; MagickOffsetType scene; MemoryInfo *pixel_info; register const PixelPacket *magick_restrict p; register ssize_t x; register unsigned char *magick_restrict q; size_t imageListLength; ssize_t count, y; unsigned char *pixels; /* Open output image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); assert(image != (Image *) NULL); assert(image->signature == MagickCoreSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); if (status == MagickFalse) return(status); scene=0; imageListLength=GetImageListLength(image); do { /* Write AVS header. */ (void) TransformImageColorspace(image,sRGBColorspace); (void) WriteBlobMSBLong(image,(unsigned int) image->columns); (void) WriteBlobMSBLong(image,(unsigned int) image->rows); /* Allocate memory for pixels. */ pixel_info=AcquireVirtualMemory(image->columns,4*sizeof(*pixels)); if (pixel_info == (MemoryInfo *) NULL) ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info); /* Convert MIFF to AVS raster pixels. */ for (y=0; y < (ssize_t) image->rows; y++) { p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception); if (p == (PixelPacket *) NULL) break; q=pixels; for (x=0; x < (ssize_t) image->columns; x++) { *q++=ScaleQuantumToChar((Quantum) (QuantumRange-(image->matte != MagickFalse ? GetPixelOpacity(p) : OpaqueOpacity))); *q++=ScaleQuantumToChar(GetPixelRed(p)); *q++=ScaleQuantumToChar(GetPixelGreen(p)); *q++=ScaleQuantumToChar(GetPixelBlue(p)); p++; } count=WriteBlob(image,(size_t) (q-pixels),pixels); if (count != (ssize_t) (q-pixels)) break; if (image->previous == (Image *) NULL) { status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, image->rows); if (status == MagickFalse) break; } } pixel_info=RelinquishVirtualMemory(pixel_info); if (GetNextImageInList(image) == (Image *) NULL) break; image=SyncNextImageInList(image); status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength); if (status == MagickFalse) break; } while (image_info->adjoin != MagickFalse); (void) CloseBlob(image); return(MagickTrue); }
0
384,828
rem_backslash(char_u *str) { #ifdef BACKSLASH_IN_FILENAME return (str[0] == '\\' && str[1] < 0x80 && (str[1] == ' ' || (str[1] != NUL && str[1] != '*' && str[1] != '?' && !vim_isfilec(str[1])))); #else return (str[0] == '\\' && str[1] != NUL); #endif }
0
310,026
_nc_retrace_void_ptr(void *code) { T((T_RETURN("%p"), code)); return code; }
0
273,398
explicit LSTMBlockCellOp(OpKernelConstruction* ctx) : OpKernel(ctx) { OP_REQUIRES_OK(ctx, ctx->GetAttr("forget_bias", &forget_bias_)); OP_REQUIRES_OK(ctx, ctx->GetAttr("cell_clip", &cell_clip_)); OP_REQUIRES_OK(ctx, ctx->GetAttr("use_peephole", &use_peephole_)); }
0
226,178
GF_Err moov_box_read(GF_Box *s, GF_BitStream *bs) { return gf_isom_box_array_read(s, bs); }
0
312,440
qf_win_pos_update( qf_info_T *qi, int old_qf_index) // previous qf_index or zero { win_T *win; int qf_index = qf_get_curlist(qi)->qf_index; // Put the cursor on the current error in the quickfix window, so that // it's viewable. win = qf_find_win(qi); if (win != NULL && qf_index <= win->w_buffer->b_ml.ml_line_count && old_qf_index != qf_index) { if (qf_index > old_qf_index) { win->w_redraw_top = old_qf_index; win->w_redraw_bot = qf_index; } else { win->w_redraw_top = qf_index; win->w_redraw_bot = old_qf_index; } qf_win_goto(win, qf_index); } return win != NULL; }
0
462,278
static pj_status_t decode_errcode_attr(pj_pool_t *pool, const pj_uint8_t *buf, const pj_stun_msg_hdr *msghdr, void **p_attr) { pj_stun_errcode_attr *attr; pj_str_t value; PJ_UNUSED_ARG(msghdr); /* Create the attribute */ attr = PJ_POOL_ZALLOC_T(pool, pj_stun_errcode_attr); GETATTRHDR(buf, &attr->hdr); attr->err_code = buf[6] * 100 + buf[7]; /* Get pointer to the string in the message */ value.ptr = ((char*)buf + ATTR_HDR_LEN + 4); value.slen = attr->hdr.length - 4; /* Make sure the length is never negative */ if (value.slen < 0) value.slen = 0; /* Copy the string to the attribute */ pj_strdup(pool, &attr->reason, &value); /* Done */ *p_attr = attr; return PJ_SUCCESS; }
0
90,223
virtual const WifiNetworkVector& remembered_wifi_networks() const { return wifi_networks_; }
0
307,840
ciInstance* ciEnv::unloaded_ciinstance() { GUARDED_VM_ENTRY(return _factory->get_unloaded_object_constant();) }
0
230,394
static pj_xml_node *xml_parse_node( pj_pool_t *pool, pj_scanner *scanner) { pj_xml_node *node; pj_str_t end_name; PJ_CHECK_STACK(); if (*scanner->curptr != '<') on_syntax_error(scanner); /* Handle Processing Instructino (PI) construct (i.e. "<?") */ if (*scanner->curptr == '<' && *(scanner->curptr+1) == '?') { pj_scan_advance_n(scanner, 2, PJ_FALSE); for (;;) { pj_str_t dummy; pj_scan_get_until_ch(scanner, '?', &dummy); if (*scanner->curptr=='?' && *(scanner->curptr+1)=='>') { pj_scan_advance_n(scanner, 2, PJ_TRUE); break; } else { pj_scan_advance_n(scanner, 1, PJ_FALSE); } } return xml_parse_node(pool, scanner); } /* Handle comments construct (i.e. "<!") */ if (pj_scan_strcmp(scanner, "<!", 2) == 0) { pj_scan_advance_n(scanner, 2, PJ_FALSE); for (;;) { pj_str_t dummy; pj_scan_get_until_ch(scanner, '>', &dummy); if (pj_scan_strcmp(scanner, ">", 1) == 0) { pj_scan_advance_n(scanner, 1, PJ_TRUE); break; } else { pj_scan_advance_n(scanner, 1, PJ_FALSE); } } return xml_parse_node(pool, scanner); } /* Alloc node. */ node = alloc_node(pool); /* Get '<' */ pj_scan_get_char(scanner); /* Get node name. */ pj_scan_get_until_chr( scanner, " />\t\r\n", &node->name); /* Get attributes. */ while (*scanner->curptr != '>' && *scanner->curptr != '/') { pj_xml_attr *attr = alloc_attr(pool); pj_scan_get_until_chr( scanner, "=> \t\r\n", &attr->name); if (*scanner->curptr == '=') { pj_scan_get_char( scanner ); pj_scan_get_quotes(scanner, "\"'", "\"'", 2, &attr->value); /* remove quote characters */ ++attr->value.ptr; attr->value.slen -= 2; } pj_list_push_back( &node->attr_head, attr ); } if (*scanner->curptr == '/') { pj_scan_get_char(scanner); if (pj_scan_get_char(scanner) != '>') on_syntax_error(scanner); return node; } /* Enclosing bracket. */ if (pj_scan_get_char(scanner) != '>') on_syntax_error(scanner); /* Sub nodes. */ while (*scanner->curptr == '<' && *(scanner->curptr+1) != '/' && *(scanner->curptr+1) != '!') { pj_xml_node *sub_node = xml_parse_node(pool, scanner); pj_list_push_back( &node->node_head, sub_node ); } /* Content. */ if (!pj_scan_is_eof(scanner) && *scanner->curptr != '<') { pj_scan_get_until_ch(scanner, '<', &node->content); } /* CDATA content. */ if (*scanner->curptr == '<' && *(scanner->curptr+1) == '!' && pj_scan_strcmp(scanner, "<![CDATA[", 9) == 0) { pj_scan_advance_n(scanner, 9, PJ_FALSE); pj_scan_get_until_ch(scanner, ']', &node->content); while (pj_scan_strcmp(scanner, "]]>", 3)) { pj_str_t dummy; pj_scan_advance_n(scanner, 1, PJ_FALSE); pj_scan_get_until_ch(scanner, ']', &dummy); } node->content.slen = scanner->curptr - node->content.ptr; pj_scan_advance_n(scanner, 3, PJ_TRUE); } /* Enclosing node. */ if (pj_scan_get_char(scanner) != '<' || pj_scan_get_char(scanner) != '/') on_syntax_error(scanner); pj_scan_get_until_chr(scanner, " \t>", &end_name); /* Compare name. */ if (pj_stricmp(&node->name, &end_name) != 0) on_syntax_error(scanner); /* Enclosing '>' */ if (pj_scan_get_char(scanner) != '>') on_syntax_error(scanner); return node; }
0
218,997
static Status PutValueIntoTensor(const int64_t value, const DataType& type, const int index, Tensor* tensor) { if (type == DT_INT32) { if (value >= INT_MAX) { return Status(error::INVALID_ARGUMENT, "int32 overflow"); } tensor->flat<int32>()(index) = static_cast<int32>(value); } else { tensor->flat<int64_t>()(index) = value; } return Status::OK(); }
0
384,848
lbr_chartabsize( char_u *line UNUSED, // start of the line unsigned char *s, colnr_T col) { #ifdef FEAT_LINEBREAK if (!curwin->w_p_lbr && *get_showbreak_value(curwin) == NUL && !curwin->w_p_bri) { #endif if (curwin->w_p_wrap) return win_nolbr_chartabsize(curwin, s, col, NULL); RET_WIN_BUF_CHARTABSIZE(curwin, curbuf, s, col) #ifdef FEAT_LINEBREAK } return win_lbr_chartabsize(curwin, line == NULL ? s : line, s, col, NULL); #endif }
0
238,474
static int __check_ptr_off_reg(struct bpf_verifier_env *env, const struct bpf_reg_state *reg, int regno, bool fixed_off_ok) { /* Access to this pointer-typed register or passing it to a helper * is only allowed in its original, unmodified form. */ if (!fixed_off_ok && reg->off) { verbose(env, "dereference of modified %s ptr R%d off=%d disallowed\n", reg_type_str(env, reg->type), regno, reg->off); return -EACCES; } if (!tnum_is_const(reg->var_off) || reg->var_off.value) { char tn_buf[48]; tnum_strn(tn_buf, sizeof(tn_buf), reg->var_off); verbose(env, "variable %s access var_off=%s disallowed\n", reg_type_str(env, reg->type), tn_buf); return -EACCES; } return 0; }
0
261,954
njs_string_prototype_to_utf8(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, njs_index_t unused) { njs_int_t ret; njs_slice_prop_t slice; njs_string_prop_t string; ret = njs_string_object_validate(vm, njs_argument(args, 0)); if (njs_slow_path(ret != NJS_OK)) { return ret; } (void) njs_string_prop(&string, njs_argument(args, 0)); string.length = 0; slice.string_length = string.size; ret = njs_string_slice_args(vm, &slice, args, nargs); if (njs_slow_path(ret != NJS_OK)) { return ret; } return njs_string_slice(vm, &vm->retval, &string, &slice); }
0
310,276
dirserv_generate_networkstatus_vote_obj(crypto_pk_env_t *private_key, authority_cert_t *cert) { or_options_t *options = get_options(); networkstatus_t *v3_out = NULL; uint32_t addr; char *hostname = NULL, *client_versions = NULL, *server_versions = NULL; const char *contact; smartlist_t *routers, *routerstatuses; char identity_digest[DIGEST_LEN]; char signing_key_digest[DIGEST_LEN]; int naming = options->NamingAuthoritativeDir; int listbadexits = options->AuthDirListBadExits; int listbaddirs = options->AuthDirListBadDirs; int vote_on_hsdirs = options->VoteOnHidServDirectoriesV2; routerlist_t *rl = router_get_routerlist(); time_t now = time(NULL); time_t cutoff = now - ROUTER_MAX_AGE_TO_PUBLISH; networkstatus_voter_info_t *voter = NULL; vote_timing_t timing; digestmap_t *omit_as_sybil = NULL; const int vote_on_reachability = running_long_enough_to_decide_unreachable(); smartlist_t *microdescriptors = NULL; tor_assert(private_key); tor_assert(cert); if (resolve_my_address(LOG_WARN, options, &addr, &hostname)<0) { log_warn(LD_NET, "Couldn't resolve my hostname"); return NULL; } if (!strchr(hostname, '.')) { tor_free(hostname); hostname = tor_dup_ip(addr); } if (crypto_pk_get_digest(private_key, signing_key_digest)<0) { log_err(LD_BUG, "Error computing signing key digest"); return NULL; } if (crypto_pk_get_digest(cert->identity_key, identity_digest)<0) { log_err(LD_BUG, "Error computing identity key digest"); return NULL; } if (options->VersioningAuthoritativeDir) { client_versions = format_versions_list(options->RecommendedClientVersions); server_versions = format_versions_list(options->RecommendedServerVersions); } contact = get_options()->ContactInfo; if (!contact) contact = "(none)"; /* precompute this part, since we need it to decide what "stable" * means. */ SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri, { dirserv_set_router_is_running(ri, now); }); dirserv_compute_performance_thresholds(rl); routers = smartlist_create(); smartlist_add_all(routers, rl->routers); routers_sort_by_identity(routers); omit_as_sybil = get_possible_sybil_list(routers); routerstatuses = smartlist_create(); microdescriptors = smartlist_create(); SMARTLIST_FOREACH_BEGIN(routers, routerinfo_t *, ri) { if (ri->cache_info.published_on >= cutoff) { routerstatus_t *rs; vote_routerstatus_t *vrs; microdesc_t *md; vrs = tor_malloc_zero(sizeof(vote_routerstatus_t)); rs = &vrs->status; set_routerstatus_from_routerinfo(rs, ri, now, naming, listbadexits, listbaddirs, vote_on_hsdirs); if (digestmap_get(omit_as_sybil, ri->cache_info.identity_digest)) clear_status_flags_on_sybil(rs); if (!vote_on_reachability) rs->is_running = 0; vrs->version = version_from_platform(ri->platform); md = dirvote_create_microdescriptor(ri); if (md) { char buf[128]; vote_microdesc_hash_t *h; dirvote_format_microdesc_vote_line(buf, sizeof(buf), md); h = tor_malloc(sizeof(vote_microdesc_hash_t)); h->microdesc_hash_line = tor_strdup(buf); h->next = NULL; vrs->microdesc = h; md->last_listed = now; smartlist_add(microdescriptors, md); } smartlist_add(routerstatuses, vrs); } } SMARTLIST_FOREACH_END(ri); { smartlist_t *added = microdescs_add_list_to_cache(get_microdesc_cache(), microdescriptors, SAVED_NOWHERE, 0); smartlist_free(added); smartlist_free(microdescriptors); } smartlist_free(routers); digestmap_free(omit_as_sybil, NULL); if (options->V3BandwidthsFile) { dirserv_read_measured_bandwidths(options->V3BandwidthsFile, routerstatuses); } v3_out = tor_malloc_zero(sizeof(networkstatus_t)); v3_out->type = NS_TYPE_VOTE; dirvote_get_preferred_voting_intervals(&timing); v3_out->published = now; { char tbuf[ISO_TIME_LEN+1]; networkstatus_t *current_consensus = networkstatus_get_live_consensus(now); long last_consensus_interval; /* only used to pick a valid_after */ if (current_consensus) last_consensus_interval = current_consensus->fresh_until - current_consensus->valid_after; else last_consensus_interval = options->TestingV3AuthInitialVotingInterval; v3_out->valid_after = dirvote_get_start_of_next_interval(now, (int)last_consensus_interval); format_iso_time(tbuf, v3_out->valid_after); log_notice(LD_DIR,"Choosing valid-after time in vote as %s: " "consensus_set=%d, last_interval=%d", tbuf, current_consensus?1:0, (int)last_consensus_interval); } v3_out->fresh_until = v3_out->valid_after + timing.vote_interval; v3_out->valid_until = v3_out->valid_after + (timing.vote_interval * timing.n_intervals_valid); v3_out->vote_seconds = timing.vote_delay; v3_out->dist_seconds = timing.dist_delay; tor_assert(v3_out->vote_seconds > 0); tor_assert(v3_out->dist_seconds > 0); tor_assert(timing.n_intervals_valid > 0); v3_out->client_versions = client_versions; v3_out->server_versions = server_versions; v3_out->known_flags = smartlist_create(); smartlist_split_string(v3_out->known_flags, "Authority Exit Fast Guard Stable V2Dir Valid", 0, SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0); if (vote_on_reachability) smartlist_add(v3_out->known_flags, tor_strdup("Running")); if (listbaddirs) smartlist_add(v3_out->known_flags, tor_strdup("BadDirectory")); if (listbadexits) smartlist_add(v3_out->known_flags, tor_strdup("BadExit")); if (naming) { smartlist_add(v3_out->known_flags, tor_strdup("Named")); smartlist_add(v3_out->known_flags, tor_strdup("Unnamed")); } if (vote_on_hsdirs) smartlist_add(v3_out->known_flags, tor_strdup("HSDir")); smartlist_sort_strings(v3_out->known_flags); if (options->ConsensusParams) { v3_out->net_params = smartlist_create(); smartlist_split_string(v3_out->net_params, options->ConsensusParams, NULL, 0, 0); smartlist_sort_strings(v3_out->net_params); } voter = tor_malloc_zero(sizeof(networkstatus_voter_info_t)); voter->nickname = tor_strdup(options->Nickname); memcpy(voter->identity_digest, identity_digest, DIGEST_LEN); voter->sigs = smartlist_create(); voter->address = hostname; voter->addr = addr; voter->dir_port = router_get_advertised_dir_port(options, 0); voter->or_port = router_get_advertised_or_port(options); voter->contact = tor_strdup(contact); if (options->V3AuthUseLegacyKey) { authority_cert_t *c = get_my_v3_legacy_cert(); if (c) { if (crypto_pk_get_digest(c->identity_key, voter->legacy_id_digest)) { log_warn(LD_BUG, "Unable to compute digest of legacy v3 identity key"); memset(voter->legacy_id_digest, 0, DIGEST_LEN); } } } v3_out->voters = smartlist_create(); smartlist_add(v3_out->voters, voter); v3_out->cert = authority_cert_dup(cert); v3_out->routerstatus_list = routerstatuses; /* Note: networkstatus_digest is unset; it won't get set until we actually * format the vote. */ return v3_out; }
0
300,766
static int tipc_connect(struct socket *sock, struct sockaddr *dest, int destlen, int flags) { struct sock *sk = sock->sk; struct tipc_sock *tsk = tipc_sk(sk); struct sockaddr_tipc *dst = (struct sockaddr_tipc *)dest; struct msghdr m = {NULL,}; long timeout = (flags & O_NONBLOCK) ? 0 : tsk->conn_timeout; int previous; int res = 0; if (destlen != sizeof(struct sockaddr_tipc)) return -EINVAL; lock_sock(sk); if (tsk->group) { res = -EINVAL; goto exit; } if (dst->family == AF_UNSPEC) { memset(&tsk->peer, 0, sizeof(struct sockaddr_tipc)); if (!tipc_sk_type_connectionless(sk)) res = -EINVAL; goto exit; } if (!tipc_sockaddr_is_sane(dst)) { res = -EINVAL; goto exit; } /* DGRAM/RDM connect(), just save the destaddr */ if (tipc_sk_type_connectionless(sk)) { memcpy(&tsk->peer, dest, destlen); goto exit; } else if (dst->addrtype == TIPC_SERVICE_RANGE) { res = -EINVAL; goto exit; } previous = sk->sk_state; switch (sk->sk_state) { case TIPC_OPEN: /* Send a 'SYN-' to destination */ m.msg_name = dest; m.msg_namelen = destlen; /* If connect is in non-blocking case, set MSG_DONTWAIT to * indicate send_msg() is never blocked. */ if (!timeout) m.msg_flags = MSG_DONTWAIT; res = __tipc_sendmsg(sock, &m, 0); if ((res < 0) && (res != -EWOULDBLOCK)) goto exit; /* Just entered TIPC_CONNECTING state; the only * difference is that return value in non-blocking * case is EINPROGRESS, rather than EALREADY. */ res = -EINPROGRESS; fallthrough; case TIPC_CONNECTING: if (!timeout) { if (previous == TIPC_CONNECTING) res = -EALREADY; goto exit; } timeout = msecs_to_jiffies(timeout); /* Wait until an 'ACK' or 'RST' arrives, or a timeout occurs */ res = tipc_wait_for_connect(sock, &timeout); break; case TIPC_ESTABLISHED: res = -EISCONN; break; default: res = -EINVAL; } exit: release_sock(sk); return res; }
0
220,432
mrb_ary_concat_m(mrb_state *mrb, mrb_value self) { mrb_value ary; mrb_get_args(mrb, "A", &ary); mrb_ary_concat(mrb, self, ary); return self; }
0
317,328
static int selinux_socket_bind(struct socket *sock, struct sockaddr *address, int addrlen) { struct sock *sk = sock->sk; struct sk_security_struct *sksec = sk->sk_security; u16 family; int err; err = sock_has_perm(sk, SOCKET__BIND); if (err) goto out; /* If PF_INET or PF_INET6, check name_bind permission for the port. */ family = sk->sk_family; if (family == PF_INET || family == PF_INET6) { char *addrp; struct common_audit_data ad; struct lsm_network_audit net = {0,}; struct sockaddr_in *addr4 = NULL; struct sockaddr_in6 *addr6 = NULL; u16 family_sa; unsigned short snum; u32 sid, node_perm; /* * sctp_bindx(3) calls via selinux_sctp_bind_connect() * that validates multiple binding addresses. Because of this * need to check address->sa_family as it is possible to have * sk->sk_family = PF_INET6 with addr->sa_family = AF_INET. */ if (addrlen < offsetofend(struct sockaddr, sa_family)) return -EINVAL; family_sa = address->sa_family; switch (family_sa) { case AF_UNSPEC: case AF_INET: if (addrlen < sizeof(struct sockaddr_in)) return -EINVAL; addr4 = (struct sockaddr_in *)address; if (family_sa == AF_UNSPEC) { /* see __inet_bind(), we only want to allow * AF_UNSPEC if the address is INADDR_ANY */ if (addr4->sin_addr.s_addr != htonl(INADDR_ANY)) goto err_af; family_sa = AF_INET; } snum = ntohs(addr4->sin_port); addrp = (char *)&addr4->sin_addr.s_addr; break; case AF_INET6: if (addrlen < SIN6_LEN_RFC2133) return -EINVAL; addr6 = (struct sockaddr_in6 *)address; snum = ntohs(addr6->sin6_port); addrp = (char *)&addr6->sin6_addr.s6_addr; break; default: goto err_af; } ad.type = LSM_AUDIT_DATA_NET; ad.u.net = &net; ad.u.net->sport = htons(snum); ad.u.net->family = family_sa; if (snum) { int low, high; inet_get_local_port_range(sock_net(sk), &low, &high); if (inet_port_requires_bind_service(sock_net(sk), snum) || snum < low || snum > high) { err = sel_netport_sid(sk->sk_protocol, snum, &sid); if (err) goto out; err = avc_has_perm(&selinux_state, sksec->sid, sid, sksec->sclass, SOCKET__NAME_BIND, &ad); if (err) goto out; } } switch (sksec->sclass) { case SECCLASS_TCP_SOCKET: node_perm = TCP_SOCKET__NODE_BIND; break; case SECCLASS_UDP_SOCKET: node_perm = UDP_SOCKET__NODE_BIND; break; case SECCLASS_DCCP_SOCKET: node_perm = DCCP_SOCKET__NODE_BIND; break; case SECCLASS_SCTP_SOCKET: node_perm = SCTP_SOCKET__NODE_BIND; break; default: node_perm = RAWIP_SOCKET__NODE_BIND; break; } err = sel_netnode_sid(addrp, family_sa, &sid); if (err) goto out; if (family_sa == AF_INET) ad.u.net->v4info.saddr = addr4->sin_addr.s_addr; else ad.u.net->v6info.saddr = addr6->sin6_addr; err = avc_has_perm(&selinux_state, sksec->sid, sid, sksec->sclass, node_perm, &ad); if (err) goto out; } out: return err; err_af: /* Note that SCTP services expect -EINVAL, others -EAFNOSUPPORT. */ if (sksec->sclass == SECCLASS_SCTP_SOCKET) return -EINVAL; return -EAFNOSUPPORT; }
0
448,538
int bgp_nlri_parse(struct peer *peer, struct attr *attr, struct bgp_nlri *packet, int mp_withdraw) { switch (packet->safi) { case SAFI_UNICAST: case SAFI_MULTICAST: return bgp_nlri_parse_ip(peer, mp_withdraw ? NULL : attr, packet); case SAFI_LABELED_UNICAST: return bgp_nlri_parse_label(peer, mp_withdraw ? NULL : attr, packet); case SAFI_MPLS_VPN: return bgp_nlri_parse_vpn(peer, mp_withdraw ? NULL : attr, packet); case SAFI_EVPN: return bgp_nlri_parse_evpn(peer, attr, packet, mp_withdraw); case SAFI_FLOWSPEC: return bgp_nlri_parse_flowspec(peer, attr, packet, mp_withdraw); } return BGP_NLRI_PARSE_ERROR; }
0
276,897
static int do_i2c_probe(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { int j; int addr = -1; int found = 0; #if defined(CONFIG_SYS_I2C_NOPROBES) int k, skip; unsigned int bus = GET_BUS_NUM; #endif /* NOPROBES */ int ret; #if CONFIG_IS_ENABLED(DM_I2C) struct udevice *bus, *dev; if (i2c_get_cur_bus(&bus)) return CMD_RET_FAILURE; #endif if (argc == 2) addr = simple_strtol(argv[1], 0, 16); puts ("Valid chip addresses:"); for (j = 0; j < 128; j++) { if ((0 <= addr) && (j != addr)) continue; #if defined(CONFIG_SYS_I2C_NOPROBES) skip = 0; for (k = 0; k < ARRAY_SIZE(i2c_no_probes); k++) { if (COMPARE_BUS(bus, k) && COMPARE_ADDR(j, k)) { skip = 1; break; } } if (skip) continue; #endif #if CONFIG_IS_ENABLED(DM_I2C) ret = dm_i2c_probe(bus, j, 0, &dev); #else ret = i2c_probe(j); #endif if (ret == 0) { printf(" %02X", j); found++; } } putc ('\n'); #if defined(CONFIG_SYS_I2C_NOPROBES) puts ("Excluded chip addresses:"); for (k = 0; k < ARRAY_SIZE(i2c_no_probes); k++) { if (COMPARE_BUS(bus,k)) printf(" %02X", NO_PROBE_ADDR(k)); } putc ('\n'); #endif return (0 == found); }
0
516,237
static bool virtio_net_can_receive(NetClientState *nc) { VirtIONet *n = qemu_get_nic_opaque(nc); VirtIODevice *vdev = VIRTIO_DEVICE(n); VirtIONetQueue *q = virtio_net_get_subqueue(nc); if (!vdev->vm_running) { return false; } if (nc->queue_index >= n->curr_queues) { return false; } if (!virtio_queue_ready(q->rx_vq) || !(vdev->status & VIRTIO_CONFIG_S_DRIVER_OK)) { return false; } return true; }
0
430,380
static struct nlattr *reserve_sfa_size(struct sw_flow_actions **sfa, int attr_len, bool log) { struct sw_flow_actions *acts; int new_acts_size; size_t req_size = NLA_ALIGN(attr_len); int next_offset = offsetof(struct sw_flow_actions, actions) + (*sfa)->actions_len; if (req_size <= (ksize(*sfa) - next_offset)) goto out; new_acts_size = max(next_offset + req_size, ksize(*sfa) * 2); if (new_acts_size > MAX_ACTIONS_BUFSIZE) { if ((next_offset + req_size) > MAX_ACTIONS_BUFSIZE) { OVS_NLERR(log, "Flow action size exceeds max %u", MAX_ACTIONS_BUFSIZE); return ERR_PTR(-EMSGSIZE); } new_acts_size = MAX_ACTIONS_BUFSIZE; } acts = nla_alloc_flow_actions(new_acts_size); if (IS_ERR(acts)) return (void *)acts; memcpy(acts->actions, (*sfa)->actions, (*sfa)->actions_len); acts->actions_len = (*sfa)->actions_len; acts->orig_len = (*sfa)->orig_len; kfree(*sfa); *sfa = acts; out: (*sfa)->actions_len += req_size; return (struct nlattr *) ((unsigned char *)(*sfa) + next_offset); }
0
307,870
ciInstanceKlass* ciEnv::get_instance_klass_for_declared_method_holder(ciKlass* method_holder) { // For the case of <array>.clone(), the method holder can be a ciArrayKlass // instead of a ciInstanceKlass. For that case simply pretend that the // declared holder is Object.clone since that's where the call will bottom out. // A more correct fix would trickle out through many interfaces in CI, // requiring ciInstanceKlass* to become ciKlass* and many more places would // require checks to make sure the expected type was found. Given that this // only occurs for clone() the more extensive fix seems like overkill so // instead we simply smear the array type into Object. guarantee(method_holder != NULL, "no method holder"); if (method_holder->is_instance_klass()) { return method_holder->as_instance_klass(); } else if (method_holder->is_array_klass()) { return current()->Object_klass(); } else { ShouldNotReachHere(); } return NULL; }
0
221,517
flatpak_run_parse_pulse_server (const char *value) { g_auto(GStrv) servers = g_strsplit (value, " ", 0); gsize i; for (i = 0; servers[i] != NULL; i++) { const char *server = servers[i]; if (g_str_has_prefix (server, "{")) { const char * closing = strstr (server, "}"); if (closing == NULL) continue; server = closing + 1; } if (g_str_has_prefix (server, "unix:")) return g_strdup (server + 5); } return NULL; }
0
383,306
gdAlphaOverlayColor( int src, int dst, int max ) { /* this function implements the algorithm * * for dst[rgb] < 0.5, * c[rgb] = 2.src[rgb].dst[rgb] * and for dst[rgb] > 0.5, * c[rgb] = -2.src[rgb].dst[rgb] + 2.dst[rgb] + 2.src[rgb] - 1 * */ dst = dst << 1; if( dst > max ) { /* in the "light" zone */ return dst + (src << 1) - (dst * src / max) - max; } else { /* in the "dark" zone */ return dst * src / max; } }
0
359,527
DEFUN (no_neighbor_shutdown, no_neighbor_shutdown_cmd, NO_NEIGHBOR_CMD2 "shutdown", NO_STR NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Administratively shut down this neighbor\n") { return peer_flag_unset_vty (vty, argv[0], PEER_FLAG_SHUTDOWN); }
0
312,527
copy_nonerror_line(char_u *linebuf, int linelen, qffields_T *fields) { char_u *p; if (linelen >= fields->errmsglen) { // linelen + null terminator if ((p = vim_realloc(fields->errmsg, linelen + 1)) == NULL) return QF_NOMEM; fields->errmsg = p; fields->errmsglen = linelen + 1; } // copy whole line to error message vim_strncpy(fields->errmsg, linebuf, linelen); return QF_OK; }
0
224,582
Status ValidateSparseTensor(InferenceContext* c, ShapeHandle indices_shape, ShapeHandle values_shape, ShapeHandle shape_shape) { // Validate ranks. ShapeHandle unused_shape; TF_RETURN_IF_ERROR(c->WithRank(indices_shape, 2, &unused_shape)); TF_RETURN_IF_ERROR(c->WithRank(values_shape, 1, &unused_shape)); TF_RETURN_IF_ERROR(c->WithRank(shape_shape, 1, &unused_shape)); // Number of elements in indices and values must match. DimensionHandle num_index_elements_dim = c->Dim(indices_shape, 0); if (c->ValueKnown(num_index_elements_dim)) { DimensionHandle num_values_elements_dim = c->Dim(values_shape, 0); if (c->ValueKnown(num_values_elements_dim)) { int64_t num_index_elements = c->Value(num_index_elements_dim); int64_t num_values_elements = c->Value(num_values_elements_dim); if (num_index_elements != num_values_elements) { return errors::InvalidArgument("Number of elements in index (", num_index_elements, ") and values (", num_values_elements, ") do not match."); } } } // Rank embedded in indices must match shape. DimensionHandle index_rank_dim = c->Dim(indices_shape, 1); if (c->ValueKnown(index_rank_dim)) { DimensionHandle shape_rank_dim = c->Dim(shape_shape, 0); if (c->ValueKnown(shape_rank_dim)) { int64_t index_rank = c->Value(index_rank_dim); int32_t shape_rank = c->Value(shape_rank_dim); if (index_rank != shape_rank) { return errors::InvalidArgument("Index rank (", index_rank, ") and shape rank (", shape_rank, ") do not match."); } } } return Status::OK(); }
0
252,345
static unsigned int readUInt(const char buf[4]) { const unsigned char *b = (const unsigned char *)buf; return (b[0] & 0x000000ff) | ((b[1] << 8) & 0x0000ff00) | ((b[2] << 16) & 0x00ff0000) | ((b[3] << 24) & 0xff000000); }
0
90,865
QuotaManagerTest() : callback_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), mock_time_counter_(0) { }
0
252,300
static void hufBuildEncTable( long long *frq, // io: input frequencies [HUF_ENCSIZE], output table int *im, // o: min frq index int *iM) // o: max frq index { // // This function assumes that when it is called, array frq // indicates the frequency of all possible symbols in the data // that are to be Huffman-encoded. (frq[i] contains the number // of occurrences of symbol i in the data.) // // The loop below does three things: // // 1) Finds the minimum and maximum indices that point // to non-zero entries in frq: // // frq[im] != 0, and frq[i] == 0 for all i < im // frq[iM] != 0, and frq[i] == 0 for all i > iM // // 2) Fills array fHeap with pointers to all non-zero // entries in frq. // // 3) Initializes array hlink such that hlink[i] == i // for all array entries. // std::vector<int> hlink(HUF_ENCSIZE); std::vector<long long *> fHeap(HUF_ENCSIZE); *im = 0; while (!frq[*im]) (*im)++; int nf = 0; for (int i = *im; i < HUF_ENCSIZE; i++) { hlink[i] = i; if (frq[i]) { fHeap[nf] = &frq[i]; nf++; *iM = i; } } // // Add a pseudo-symbol, with a frequency count of 1, to frq; // adjust the fHeap and hlink array accordingly. Function // hufEncode() uses the pseudo-symbol for run-length encoding. // (*iM)++; frq[*iM] = 1; fHeap[nf] = &frq[*iM]; nf++; // // Build an array, scode, such that scode[i] contains the number // of bits assigned to symbol i. Conceptually this is done by // constructing a tree whose leaves are the symbols with non-zero // frequency: // // Make a heap that contains all symbols with a non-zero frequency, // with the least frequent symbol on top. // // Repeat until only one symbol is left on the heap: // // Take the two least frequent symbols off the top of the heap. // Create a new node that has first two nodes as children, and // whose frequency is the sum of the frequencies of the first // two nodes. Put the new node back into the heap. // // The last node left on the heap is the root of the tree. For each // leaf node, the distance between the root and the leaf is the length // of the code for the corresponding symbol. // // The loop below doesn't actually build the tree; instead we compute // the distances of the leaves from the root on the fly. When a new // node is added to the heap, then that node's descendants are linked // into a single linear list that starts at the new node, and the code // lengths of the descendants (that is, their distance from the root // of the tree) are incremented by one. // std::make_heap(&fHeap[0], &fHeap[nf], FHeapCompare()); std::vector<long long> scode(HUF_ENCSIZE); memset(scode.data(), 0, sizeof(long long) * HUF_ENCSIZE); while (nf > 1) { // // Find the indices, mm and m, of the two smallest non-zero frq // values in fHeap, add the smallest frq to the second-smallest // frq, and remove the smallest frq value from fHeap. // int mm = fHeap[0] - frq; std::pop_heap(&fHeap[0], &fHeap[nf], FHeapCompare()); --nf; int m = fHeap[0] - frq; std::pop_heap(&fHeap[0], &fHeap[nf], FHeapCompare()); frq[m] += frq[mm]; std::push_heap(&fHeap[0], &fHeap[nf], FHeapCompare()); // // The entries in scode are linked into lists with the // entries in hlink serving as "next" pointers and with // the end of a list marked by hlink[j] == j. // // Traverse the lists that start at scode[m] and scode[mm]. // For each element visited, increment the length of the // corresponding code by one bit. (If we visit scode[j] // during the traversal, then the code for symbol j becomes // one bit longer.) // // Merge the lists that start at scode[m] and scode[mm] // into a single list that starts at scode[m]. // // // Add a bit to all codes in the first list. // for (int j = m;; j = hlink[j]) { scode[j]++; assert(scode[j] <= 58); if (hlink[j] == j) { // // Merge the two lists. // hlink[j] = mm; break; } } // // Add a bit to all codes in the second list // for (int j = mm;; j = hlink[j]) { scode[j]++; assert(scode[j] <= 58); if (hlink[j] == j) break; } } // // Build a canonical Huffman code table, replacing the code // lengths in scode with (code, code length) pairs. Copy the // code table from scode into frq. // hufCanonicalCodeTable(scode.data()); memcpy(frq, scode.data(), sizeof(long long) * HUF_ENCSIZE); }
0
309,969
_nc_mouse_init(SCREEN *sp) /* initialize the mouse */ { bool result = FALSE; if (sp != 0) { if (!sp->_mouse_initialized) { int i; sp->_mouse_initialized = TRUE; TR(MY_TRACE, ("_nc_mouse_init() called")); sp->_mouse_eventp = FirstEV(sp); for (i = 0; i < EV_MAX; i++) Invalidate(sp->_mouse_events + i); initialize_mousetype(sp); T(("_nc_mouse_init() set mousetype to %d", sp->_mouse_type)); } result = sp->_mouse_initialized; } return result; }
0
430,341
ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) { struct iovec iov = { .iov_base = buf, .iov_len = size}; struct kiocb kiocb; struct iov_iter iter; ssize_t ret; init_sync_kiocb(&kiocb, file); iov_iter_init(&iter, READ, &iov, 1, size); kiocb.ki_pos = *ppos; ret = seq_read_iter(&kiocb, &iter); *ppos = kiocb.ki_pos; return ret; }
0
487,615
void kernel_halt(void) { kernel_shutdown_prepare(SYSTEM_HALT); printk(KERN_EMERG "System halted.\n"); machine_halt(); }
0
225,400
static int vidioc_enum_fmt_cap(struct file *file, void *fh, struct v4l2_fmtdesc *f) { struct v4l2_loopback_device *dev; MARK(); dev = v4l2loopback_getdevice(file); if (f->index) return -EINVAL; if (dev->ready_for_capture) { const __u32 format = dev->pix_format.pixelformat; snprintf(f->description, sizeof(f->description), "[%c%c%c%c]", (format >> 0) & 0xFF, (format >> 8) & 0xFF, (format >> 16) & 0xFF, (format >> 24) & 0xFF); f->pixelformat = dev->pix_format.pixelformat; } else { return -EINVAL; } f->flags = 0; MARK(); return 0; }
0
234,188
display_debug_str_offsets (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED) { unsigned long idx; if (section->size == 0) { printf (_("\nThe %s section is empty.\n"), section->name); return 0; } unsigned char *start = section->start; unsigned char *end = start + section->size; unsigned char *curr = start; const char *suffix = strrchr (section->name, '.'); bool dwo = suffix && strcmp (suffix, ".dwo") == 0; if (dwo) load_debug_section_with_follow (str_dwo, file); else load_debug_section_with_follow (str, file); introduce (section, false); while (curr < end) { dwarf_vma length; dwarf_vma entry_length; SAFE_BYTE_GET_AND_INC (length, curr, 4, end); /* FIXME: We assume that this means 64-bit DWARF is being used. */ if (length == 0xffffffff) { SAFE_BYTE_GET_AND_INC (length, curr, 8, end); entry_length = 8; } else entry_length = 4; unsigned char *entries_end; if (length == 0) { /* This is probably an old style .debug_str_offset section which just contains offsets and no header (and the first offset is 0). */ length = section->size; curr = section->start; entries_end = end; printf (_(" Length: %#lx\n"), (unsigned long) length); printf (_(" Index Offset [String]\n")); } else { if (length <= (dwarf_vma) (end - curr)) entries_end = curr + length; else { warn (_("Section %s is too small %#lx\n"), section->name, (unsigned long) section->size); entries_end = end; } int version; SAFE_BYTE_GET_AND_INC (version, curr, 2, entries_end); if (version != 5) warn (_("Unexpected version number in str_offset header: %#x\n"), version); int padding; SAFE_BYTE_GET_AND_INC (padding, curr, 2, entries_end); if (padding != 0) warn (_("Unexpected value in str_offset header's padding field: %#x\n"), padding); printf (_(" Length: %#lx\n"), (unsigned long) length); printf (_(" Version: %#lx\n"), (unsigned long) version); printf (_(" Index Offset [String]\n")); } for (idx = 0; curr < entries_end; idx++) { dwarf_vma offset; const unsigned char * string; if ((dwarf_vma) (entries_end - curr) < entry_length) /* Not enough space to read one entry_length, give up. */ return 0; SAFE_BYTE_GET_AND_INC (offset, curr, entry_length, entries_end); if (dwo) string = (const unsigned char *) fetch_indexed_string (idx, NULL, entry_length, dwo, 0); else string = fetch_indirect_string (offset); printf (" %8lu %8s %s\n", idx, dwarf_vmatoa ("x", offset), string); } } return 1; }
0
389,733
check_for_string_or_dict_arg(typval_T *args, int idx) { if (args[idx].v_type != VAR_STRING && args[idx].v_type != VAR_DICT) { semsg(_(e_string_or_dict_required_for_argument_nr), idx + 1); return FAIL; } return OK; }
0
226,113
GF_Err sbgp_box_size(GF_Box *s) { GF_SampleGroupBox *p = (GF_SampleGroupBox*)s; p->size += 8; if (p->grouping_type_parameter) p->version=1; if (p->version==1) p->size += 4; p->size += 8*p->entry_count; return GF_OK;
0
372,349
void sdb_show_bp() { for(int i=0; i<7;i++) if (sdb_lines[i]!= -1) Print("Breakpoint %d: %s::%d\n",i+1,sdb_files[i],sdb_lines[i]); }
0
512,440
double Item_func_case::real_op() { DBUG_ASSERT(fixed == 1); Item *item= find_item(); double res; if (!item) { null_value=1; return 0; } res= item->val_real(); null_value=item->null_value; return res; }
0
512,720
void Item_func_if::fix_after_pullout(st_select_lex *new_parent, Item **ref, bool merge) { /* This will re-calculate attributes of the arguments */ Item_func::fix_after_pullout(new_parent, ref, merge); /* Then, re-calculate not_null_tables_cache according to our special rules */ eval_not_null_tables(NULL); }
0
243,001
static void ssl_build_record_nonce( unsigned char *dst_iv, size_t dst_iv_len, unsigned char const *fixed_iv, size_t fixed_iv_len, unsigned char const *dynamic_iv, size_t dynamic_iv_len ) { size_t i; /* Start with Fixed IV || 0 */ memset( dst_iv, 0, dst_iv_len ); memcpy( dst_iv, fixed_iv, fixed_iv_len ); dst_iv += dst_iv_len - dynamic_iv_len; for( i = 0; i < dynamic_iv_len; i++ ) dst_iv[i] ^= dynamic_iv[i]; }
0
522,322
static void RecWrd(GmfMshSct *msh, const void *wrd) { // [Bruno] added error control #ifdef WITH_GMF_AIO if(write(msh->FilDes, wrd, WrdSiz) != WrdSiz) #else if(fwrite(wrd, WrdSiz, 1, msh->hdl) != 1) #endif longjmp(msh->err,-28); }
0
379,667
static RAnalVar *get_stack_var(RAnalFunction *fcn, int delta) { void **it; r_pvector_foreach (&fcn->vars, it) { RAnalVar *var = *it; bool is_stack = var->kind == R_ANAL_VAR_KIND_SPV || var->kind == R_ANAL_VAR_KIND_BPV; if (is_stack && var->delta == delta) { return var; } } return NULL; }
0
401,483
int wait_for_random_bytes(void) { if (likely(crng_ready())) return 0; do { int ret; ret = wait_event_interruptible_timeout(crng_init_wait, crng_ready(), HZ); if (ret) return ret > 0 ? 0 : ret; try_to_generate_entropy(); } while (!crng_ready()); return 0; }
0
437,699
static int cx23888_ir_tx_shutdown(struct v4l2_subdev *sd) { struct cx23888_ir_state *state = to_state(sd); struct cx23885_dev *dev = state->dev; mutex_lock(&state->tx_params_lock); /* Disable or slow down all IR Tx circuits and counters */ irqenable_tx(dev, 0); control_tx_enable(dev, false); control_tx_modulation_enable(dev, false); cx23888_ir_write4(dev, CX23888_IR_TXCLK_REG, TXCLK_TCD); state->tx_params.shutdown = true; mutex_unlock(&state->tx_params_lock); return 0; }
0
223,402
static SLJIT_INLINE BOOL assert_needs_str_ptr_saving(PCRE2_SPTR cc) { while (TRUE) { switch (*cc) { case OP_CALLOUT_STR: cc += GET(cc, 1 + 2*LINK_SIZE); break; case OP_NOT_WORD_BOUNDARY: case OP_WORD_BOUNDARY: case OP_CIRC: case OP_CIRCM: case OP_DOLL: case OP_DOLLM: case OP_CALLOUT: case OP_ALT: cc += PRIV(OP_lengths)[*cc]; break; case OP_KET: return FALSE; default: return TRUE; } } }
0
512,288
Item_func_if::eval_not_null_tables(void *opt_arg) { if (Item_func::eval_not_null_tables(NULL)) return 1; not_null_tables_cache= (args[1]->not_null_tables() & args[2]->not_null_tables()); return 0; }
0
468,329
on_connected_cancelled (GObject *source_object, GAsyncResult *result, gpointer user_data) { GSocketConnection *conn; GError *error = NULL; conn = g_socket_client_connect_to_uri_finish (G_SOCKET_CLIENT (source_object), result, &error); g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED); g_assert_null (conn); g_error_free (error); g_main_loop_quit (user_data); }
0
387,720
Symbol* InstanceKlass::package_from_name(const Symbol* name, TRAPS) { if (name == NULL) { return NULL; } else { if (name->utf8_length() <= 0) { return NULL; } ResourceMark rm; const char* package_name = ClassLoader::package_from_name((const char*) name->as_C_string()); if (package_name == NULL) { return NULL; } Symbol* pkg_name = SymbolTable::new_symbol(package_name, THREAD); return pkg_name; } }
0
256,986
static void route4_queue_work(struct route4_filter *f) { tcf_queue_work(&f->rwork, route4_delete_filter_work); }
0
432,734
static void ipa_region_clip(wmfAPI *API, wmfPolyRectangle_t *poly_rect) { long i; wmf_magick_t *ddata = WMF_MAGICK_GetData (API); /* Reset any existing clip paths by popping wand */ if (ddata->clipping) (void) PopDrawingWand(WmfDrawingWand); ddata->clipping = MagickFalse; if (poly_rect->count > 0) { char clip_mask_id[MagickPathExtent]; /* Define clip path */ ddata->clip_mask_id++; DrawPushDefs(WmfDrawingWand); (void) FormatLocaleString(clip_mask_id,MagickPathExtent,"clip_%lu", ddata->clip_mask_id); DrawPushClipPath(WmfDrawingWand,clip_mask_id); (void) PushDrawingWand(WmfDrawingWand); for (i = 0; i < (long) poly_rect->count; i++) { DrawRectangle(WmfDrawingWand, XC(poly_rect->TL[i].x), YC(poly_rect->TL[i].y), XC(poly_rect->BR[i].x), YC(poly_rect->BR[i].y)); } (void) PopDrawingWand(WmfDrawingWand); DrawPopClipPath(WmfDrawingWand); DrawPopDefs(WmfDrawingWand); /* Push wand for new clip paths */ (void) PushDrawingWand(WmfDrawingWand); (void) DrawSetClipPath(WmfDrawingWand,clip_mask_id); ddata->clipping = MagickTrue; } }
0
412,101
respip_addr_lookup(const struct reply_info *rep, struct rbtree_type* iptree, size_t* rrset_id) { size_t i; struct resp_addr* ra; struct sockaddr_storage ss; socklen_t addrlen; for(i=0; i<rep->an_numrrsets; i++) { size_t j; const struct packed_rrset_data* rd; uint16_t rtype = ntohs(rep->rrsets[i]->rk.type); if(rtype != LDNS_RR_TYPE_A && rtype != LDNS_RR_TYPE_AAAA) continue; rd = rep->rrsets[i]->entry.data; for(j = 0; j < rd->count; j++) { if(!rdata2sockaddr(rd, rtype, j, &ss, &addrlen)) continue; ra = (struct resp_addr*)addr_tree_lookup(iptree, &ss, addrlen); if(ra) { *rrset_id = i; return ra; } } } return NULL; }
0