idx
int64
func
string
target
int64
294,716
m_yday(union DateData *x) { int jd, ry, rd; double sg; jd = m_local_jd(x); sg = m_virtual_sg(x); /* !=m_sg() */ if (m_proleptic_gregorian_p(x) || (jd - sg) > 366) return c_gregorian_to_yday(m_year(x), m_mon(x), m_mday(x)); if (m_proleptic_julian_p(x)) return c_julian_to_yday(m_year(x), m_mon(x), m_mday(x)); c_jd_to_ordinal(jd, sg, &ry, &rd); return rd; }
0
224,549
Status QuantizedConcatV2Shape(InferenceContext* c, int num_inputs_to_concat) { return ConcatShapeHelper(c, 0 /* start_value_index */, num_inputs_to_concat /* end_value_index */, num_inputs_to_concat /* dim_index */); }
0
313,766
nv_mark(cmdarg_T *cap) { if (!checkclearop(cap->oap)) { if (setmark(cap->nchar) == FAIL) clearopbeep(cap->oap); } }
0
492,693
vte_sequence_handler_set_scrolling_region_from_start (VteTerminal *terminal, GValueArray *params) { GValue value = {0}; g_value_init (&value, G_TYPE_LONG); g_value_set_long (&value, 0); /* Out of range means start/end */ g_value_array_insert (params, 0, &value); vte_sequence_handler_offset(terminal, params, -1, vte_sequence_handler_cs); }
0
343,238
void disablesignals(void) { sigset_t sigs; sigfillset(&sigs); if (sigprocmask(SIG_BLOCK, &sigs, &old_sigmask) < 0) { _EXIT(EXIT_FAILURE); } }
0
447,041
long SshIo::SshImpl::getFileLength() { long length = 0; if (protocol_ == pSftp) { // sftp sftp_attributes attributes = sftp_fstat(fileHandler_); length = (long)attributes->size; } else { // ssh std::string response; //std::string cmd = "stat -c %s " + hostInfo_.Path; std::string cmd = "declare -a x=($(ls -alt " + hostInfo_.Path + ")); echo ${x[4]}"; if (ssh_->runCommand(cmd, &response) != 0) { throw Error(1, "Unable to get file length."); } else { length = atol(response.c_str()); if (length == 0) { throw Error(1, "File is empty or not found."); } } } return length; }
0
387,639
void snd_ctl_disconnect_layer(struct snd_ctl_layer_ops *lops) { struct snd_ctl_layer_ops *lops2, *prev_lops2; down_write(&snd_ctl_layer_rwsem); for (lops2 = snd_ctl_layer, prev_lops2 = NULL; lops2; lops2 = lops2->next) { if (lops2 == lops) { if (!prev_lops2) snd_ctl_layer = lops->next; else prev_lops2->next = lops->next; break; } prev_lops2 = lops2; } up_write(&snd_ctl_layer_rwsem); }
0
247,128
void gf_fs_run_step(GF_FilterSession *fsess) { gf_fs_thread_proc(&fsess->main_th); }
0
248,294
DLLIMPORT int cfg_setnint(cfg_t *cfg, const char *name, long int value, unsigned int index) { cfg_opt_t *opt; opt = cfg_getopt(cfg, name); if (opt && opt->validcb2 && (*opt->validcb2)(cfg, opt, (void *)&value) != 0) return CFG_FAIL; return cfg_opt_setnint(opt, value, index); }
0
244,153
GF_Err pdin_box_read(GF_Box *s, GF_BitStream *bs) { u32 i; GF_ProgressiveDownloadBox *ptr = (GF_ProgressiveDownloadBox*)s; ptr->count = (u32) (ptr->size) / 8; ptr->rates = (u32*)gf_malloc(sizeof(u32)*ptr->count); if (!ptr->rates) return GF_OUT_OF_MEM; ptr->times = (u32*)gf_malloc(sizeof(u32)*ptr->count); if (!ptr->times) return GF_OUT_OF_MEM; for (i=0; i<ptr->count; i++) { ptr->rates[i] = gf_bs_read_u32(bs); ptr->times[i] = gf_bs_read_u32(bs); } return GF_OK; }
0
402,655
hide_stolen_goods_from_cms(cms_context *new, cms_context *old UNUSED) { new->tokenname = NULL; new->certname = NULL; }
0
476,132
static int composite_bind(struct usb_gadget *gadget, struct usb_gadget_driver *gdriver) { struct usb_composite_dev *cdev; struct usb_composite_driver *composite = to_cdriver(gdriver); int status = -ENOMEM; cdev = kzalloc(sizeof *cdev, GFP_KERNEL); if (!cdev) return status; spin_lock_init(&cdev->lock); cdev->gadget = gadget; set_gadget_data(gadget, cdev); INIT_LIST_HEAD(&cdev->configs); INIT_LIST_HEAD(&cdev->gstrings); status = composite_dev_prepare(composite, cdev); if (status) goto fail; /* composite gadget needs to assign strings for whole device (like * serial number), register function drivers, potentially update * power state and consumption, etc */ status = composite->bind(cdev); if (status < 0) goto fail; if (cdev->use_os_string) { status = composite_os_desc_req_prepare(cdev, gadget->ep0); if (status) goto fail; } update_unchanged_dev_desc(&cdev->desc, composite->dev); /* has userspace failed to provide a serial number? */ if (composite->needs_serial && !cdev->desc.iSerialNumber) WARNING(cdev, "userspace failed to provide iSerialNumber\n"); INFO(cdev, "%s ready\n", composite->name); return 0; fail: __composite_unbind(gadget, false); return status; }
0
498,100
void html_link_open(const char *url, const char *title, const char *class) { html("<a href='"); html_attr(url); if (title) { html("' title='"); html_attr(title); } if (class) { html("' class='"); html_attr(class); } html("'>"); }
0
336,020
static int sr_mdio_read(struct net_device *netdev, int phy_id, int loc) { struct usbnet *dev = netdev_priv(netdev); __le16 res; int rc = 0; if (phy_id) { netdev_dbg(netdev, "Only internal phy supported\n"); return 0; } /* Access NSR_LINKST bit for link status instead of MII_BMSR */ if (loc == MII_BMSR) { u8 value; sr_read_reg(dev, SR_NSR, &value); if (value & NSR_LINKST) rc = 1; } sr_share_read_word(dev, 1, loc, &res); if (rc == 1) res = le16_to_cpu(res) | BMSR_LSTATUS; else res = le16_to_cpu(res) & ~BMSR_LSTATUS; netdev_dbg(netdev, "sr_mdio_read() phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n", phy_id, loc, res); return res; }
0
379,324
do_exmode( int improved) // TRUE for "improved Ex" mode { int save_msg_scroll; int prev_msg_row; linenr_T prev_line; varnumber_T changedtick; if (improved) exmode_active = EXMODE_VIM; else exmode_active = EXMODE_NORMAL; State = MODE_NORMAL; may_trigger_modechanged(); // When using ":global /pat/ visual" and then "Q" we return to continue // the :global command. if (global_busy) return; save_msg_scroll = msg_scroll; ++RedrawingDisabled; // don't redisplay the window ++no_wait_return; // don't wait for return #ifdef FEAT_GUI // Ignore scrollbar and mouse events in Ex mode ++hold_gui_events; #endif msg(_("Entering Ex mode. Type \"visual\" to go to Normal mode.")); while (exmode_active) { // Check for a ":normal" command and no more characters left. if (ex_normal_busy > 0 && typebuf.tb_len == 0) { exmode_active = FALSE; break; } msg_scroll = TRUE; need_wait_return = FALSE; ex_pressedreturn = FALSE; ex_no_reprint = FALSE; changedtick = CHANGEDTICK(curbuf); prev_msg_row = msg_row; prev_line = curwin->w_cursor.lnum; if (improved) { cmdline_row = msg_row; do_cmdline(NULL, getexline, NULL, 0); } else do_cmdline(NULL, getexmodeline, NULL, DOCMD_NOWAIT); lines_left = Rows - 1; if ((prev_line != curwin->w_cursor.lnum || changedtick != CHANGEDTICK(curbuf)) && !ex_no_reprint) { if (curbuf->b_ml.ml_flags & ML_EMPTY) emsg(_(e_empty_buffer)); else { if (ex_pressedreturn) { // go up one line, to overwrite the ":<CR>" line, so the // output doesn't contain empty lines. msg_row = prev_msg_row; if (prev_msg_row == Rows - 1) msg_row--; } msg_col = 0; print_line_no_prefix(curwin->w_cursor.lnum, FALSE, FALSE); msg_clr_eos(); } } else if (ex_pressedreturn && !ex_no_reprint) // must be at EOF { if (curbuf->b_ml.ml_flags & ML_EMPTY) emsg(_(e_empty_buffer)); else emsg(_(e_at_end_of_file)); } } #ifdef FEAT_GUI --hold_gui_events; #endif --RedrawingDisabled; --no_wait_return; update_screen(CLEAR); need_wait_return = FALSE; msg_scroll = save_msg_scroll; }
0
259,268
static MOVFragmentStreamInfo *get_frag_stream_info_from_pkt(MOVFragmentIndex *frag_index, AVPacket *pkt, int id) { int current = frag_index->current; if (!frag_index->nb_items) return NULL; // Check frag_index->current is the right one for pkt. It can out of sync. if (current >= 0 && current < frag_index->nb_items) { if (frag_index->item[current].moof_offset < pkt->pos && (current + 1 == frag_index->nb_items || frag_index->item[current + 1].moof_offset > pkt->pos)) return get_frag_stream_info(frag_index, current, id); } for (int i = 0; i < frag_index->nb_items; i++) { if (frag_index->item[i].moof_offset > pkt->pos) break; current = i; } frag_index->current = current; return get_frag_stream_info(frag_index, current, id); }
0
197,223
njs_module_path(njs_vm_t *vm, const njs_str_t *dir, njs_module_info_t *info) { char *p; size_t length; njs_bool_t trail; char src[NJS_MAX_PATH + 1]; trail = 0; length = info->name.length; if (dir != NULL) { length = dir->length; if (length == 0) { return NJS_DECLINED; } trail = (dir->start[dir->length - 1] != '/'); if (trail) { length++; } } if (njs_slow_path(length > NJS_MAX_PATH)) { return NJS_ERROR; } p = &src[0]; if (dir != NULL) { p = (char *) njs_cpymem(p, dir->start, dir->length); if (trail) { *p++ = '/'; } } p = (char *) njs_cpymem(p, info->name.start, info->name.length); *p = '\0'; p = realpath(&src[0], &info->path[0]); if (p == NULL) { return NJS_DECLINED; } info->fd = open(&info->path[0], O_RDONLY); if (info->fd < 0) { return NJS_DECLINED; } info->file.start = (u_char *) &info->path[0]; info->file.length = njs_strlen(info->file.start); return NJS_OK; }
1
434,109
alist_name(aentry_T *aep) { buf_T *bp; // Use the name from the associated buffer if it exists. bp = buflist_findnr(aep->ae_fnum); if (bp == NULL || bp->b_fname == NULL) return aep->ae_fname; return bp->b_fname; }
0
261,200
int MqttClient_Publish_ex(MqttClient *client, MqttPublish *publish, MqttPublishCb pubCb) { int rc = MQTT_CODE_SUCCESS; MqttPacketType resp_type; /* Validate required arguments */ if (client == NULL || publish == NULL) { return MQTT_CODE_ERROR_BAD_ARG; } #ifdef WOLFMQTT_V5 /* Use specified protocol version if set */ publish->protocol_level = client->protocol_level; /* Validate publish request against server properties */ if ((publish->qos > client->max_qos) || ((publish->retain == 1) && (client->retain_avail == 0))) { return MQTT_CODE_ERROR_SERVER_PROP; } #endif switch (publish->stat) { case MQTT_MSG_BEGIN: { #ifdef WOLFMQTT_MULTITHREAD /* Lock send socket mutex */ rc = wm_SemLock(&client->lockSend); if (rc != 0) { return rc; } #endif /* Encode the publish packet */ rc = MqttEncode_Publish(client->tx_buf, client->tx_buf_len, publish, pubCb ? 1 : 0); #ifdef WOLFMQTT_DEBUG_CLIENT PRINTF("MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d," " QoS %d", rc, MqttPacket_TypeDesc(MQTT_PACKET_TYPE_PUBLISH), MQTT_PACKET_TYPE_PUBLISH, publish->packet_id, publish->qos); #endif if (rc <= 0) { #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif return rc; } client->write.len = rc; #ifdef WOLFMQTT_MULTITHREAD if (publish->qos > MQTT_QOS_0) { resp_type = (publish->qos == MQTT_QOS_1) ? MQTT_PACKET_TYPE_PUBLISH_ACK : MQTT_PACKET_TYPE_PUBLISH_COMP; rc = wm_SemLock(&client->lockClient); if (rc == 0) { /* inform other threads of expected response */ rc = MqttClient_RespList_Add(client, resp_type, publish->packet_id, &publish->pendResp, &publish->resp); wm_SemUnlock(&client->lockClient); } if (rc != 0) { wm_SemUnlock(&client->lockSend); return rc; /* Error locking client */ } } #endif publish->stat = MQTT_MSG_WRITE; } FALL_THROUGH; case MQTT_MSG_WRITE: { /* Send packet */ rc = MqttPacket_Write(client, client->tx_buf, client->write.len); #ifdef WOLFMQTT_NONBLOCK if (rc == MQTT_CODE_CONTINUE) return rc; #endif if (rc < 0) { #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif #ifdef WOLFMQTT_MULTITHREAD if (wm_SemLock(&client->lockClient) == 0) { MqttClient_RespList_Remove(client, &publish->pendResp); wm_SemUnlock(&client->lockClient); } #endif return rc; } /* advance state */ publish->stat = MQTT_MSG_WRITE_PAYLOAD; } FALL_THROUGH; case MQTT_MSG_WRITE_PAYLOAD: { rc = MqttClient_Publish_WritePayload(client, publish, pubCb); #ifdef WOLFMQTT_NONBLOCK if (rc == MQTT_CODE_CONTINUE) return rc; #endif #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif if (rc < 0) { #ifdef WOLFMQTT_MULTITHREAD if (wm_SemLock(&client->lockClient) == 0) { MqttClient_RespList_Remove(client, &publish->pendResp); wm_SemUnlock(&client->lockClient); } #endif break; } /* if not expecting a reply then we are done */ if (publish->qos == MQTT_QOS_0) { break; } publish->stat = MQTT_MSG_WAIT; } FALL_THROUGH; case MQTT_MSG_WAIT: { /* Handle QoS */ if (publish->qos > MQTT_QOS_0) { /* Determine packet type to wait for */ resp_type = (publish->qos == MQTT_QOS_1) ? MQTT_PACKET_TYPE_PUBLISH_ACK : MQTT_PACKET_TYPE_PUBLISH_COMP; /* Wait for publish response packet */ rc = MqttClient_WaitType(client, &publish->resp, resp_type, publish->packet_id, client->cmd_timeout_ms); #ifdef WOLFMQTT_NONBLOCK if (rc == MQTT_CODE_CONTINUE) break; #endif #ifdef WOLFMQTT_MULTITHREAD if (wm_SemLock(&client->lockClient) == 0) { MqttClient_RespList_Remove(client, &publish->pendResp); wm_SemUnlock(&client->lockClient); } #endif } break; } #ifdef WOLFMQTT_V5 case MQTT_MSG_AUTH: #endif case MQTT_MSG_READ: case MQTT_MSG_READ_PAYLOAD: #ifdef WOLFMQTT_DEBUG_CLIENT PRINTF("MqttClient_Publish: Invalid state %d!", publish->stat); #endif rc = MQTT_CODE_ERROR_STAT; break; } /* switch (publish->stat) */ /* reset state */ if ((rc != MQTT_CODE_PUB_CONTINUE) #ifdef WOLFMQTT_NONBLOCK && (rc != MQTT_CODE_CONTINUE) #endif ) { publish->stat = MQTT_MSG_BEGIN; } if (rc > 0) { rc = MQTT_CODE_SUCCESS; } return rc; }
0
500,046
krb5_error_code kssl_check_authent( /* IN */ KSSL_CTX *kssl_ctx, /* IN */ krb5_data *authentp, /* OUT */ krb5_timestamp *atimep, /* OUT */ KSSL_ERR *kssl_err ) { krb5_error_code krb5rc = 0; KRB5_ENCDATA *dec_authent = NULL; KRB5_AUTHENTBODY *auth = NULL; krb5_enctype enctype; EVP_CIPHER_CTX ciph_ctx; const EVP_CIPHER *enc = NULL; unsigned char iv[EVP_MAX_IV_LENGTH]; const unsigned char *p; unsigned char *unenc_authent; int outl, unencbufsize; struct tm tm_time, *tm_l, *tm_g; time_t now, tl, tg, tr, tz_offset; EVP_CIPHER_CTX_init(&ciph_ctx); *atimep = 0; kssl_err_set(kssl_err, 0, ""); #ifndef KRB5CHECKAUTH authentp = NULL; #else #if KRB5CHECKAUTH == 0 authentp = NULL; #endif #endif /* KRB5CHECKAUTH */ if (authentp == NULL || authentp->length == 0) return 0; #ifdef KSSL_DEBUG { unsigned int ui; printf("kssl_check_authent: authenticator[%d]:\n",authentp->length); p = authentp->data; for (ui=0; ui < authentp->length; ui++) printf("%02x ",p[ui]); printf("\n"); } #endif /* KSSL_DEBUG */ unencbufsize = 2 * authentp->length; if ((unenc_authent = calloc(1, unencbufsize)) == NULL) { kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT, "Unable to allocate authenticator buffer.\n"); krb5rc = KRB5KRB_ERR_GENERIC; goto err; } p = (unsigned char *)authentp->data; if ((dec_authent = d2i_KRB5_ENCDATA(NULL, &p, (long) authentp->length)) == NULL) { kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT, "Error decoding authenticator.\n"); krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY; goto err; } enctype = dec_authent->etype->data[0]; /* should = kssl_ctx->enctype */ #if !defined(KRB5_MIT_OLD11) switch ( enctype ) { case ENCTYPE_DES3_CBC_SHA1: /* EVP_des_ede3_cbc(); */ case ENCTYPE_DES3_CBC_SHA: case ENCTYPE_DES3_CBC_RAW: krb5rc = 0; /* Skip, can't handle derived keys */ goto err; } #endif enc = kssl_map_enc(enctype); memset(iv, 0, sizeof iv); /* per RFC 1510 */ if (enc == NULL) { /* Disable kssl_check_authent for ENCTYPE_DES3_CBC_SHA1. ** This enctype indicates the authenticator was encrypted ** using key-usage derived keys which openssl cannot decrypt. */ goto err; } if (!EVP_CipherInit(&ciph_ctx,enc,kssl_ctx->key,iv,0)) { kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT, "EVP_CipherInit error decrypting authenticator.\n"); krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY; goto err; } outl = dec_authent->cipher->length; if (!EVP_Cipher(&ciph_ctx,unenc_authent,dec_authent->cipher->data,outl)) { kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT, "EVP_Cipher error decrypting authenticator.\n"); krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY; goto err; } EVP_CIPHER_CTX_cleanup(&ciph_ctx); #ifdef KSSL_DEBUG printf("kssl_check_authent: decrypted authenticator[%d] =\n", outl); for (padl=0; padl < outl; padl++) printf("%02x ",unenc_authent[padl]); printf("\n"); #endif /* KSSL_DEBUG */ if ((p = kssl_skip_confound(enctype, unenc_authent)) == NULL) { kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT, "confounded by authenticator.\n"); krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY; goto err; } outl -= p - unenc_authent; if ((auth = (KRB5_AUTHENTBODY *) d2i_KRB5_AUTHENT(NULL, &p, (long) outl))==NULL) { kssl_err_set(kssl_err, SSL_R_KRB5_S_INIT, "Error decoding authenticator body.\n"); krb5rc = KRB5KRB_AP_ERR_BAD_INTEGRITY; goto err; } memset(&tm_time,0,sizeof(struct tm)); if (k_gmtime(auth->ctime, &tm_time) && ((tr = mktime(&tm_time)) != (time_t)(-1))) { now = time(&now); tm_l = localtime(&now); tl = mktime(tm_l); tm_g = gmtime(&now); tg = mktime(tm_g); tz_offset = tg - tl; *atimep = (krb5_timestamp)(tr - tz_offset); } #ifdef KSSL_DEBUG printf("kssl_check_authent: returns %d for client time ", *atimep); if (auth && auth->ctime && auth->ctime->length && auth->ctime->data) printf("%.*s\n", auth->ctime->length, auth->ctime->data); else printf("NULL\n"); #endif /* KSSL_DEBUG */ err: if (auth) KRB5_AUTHENT_free((KRB5_AUTHENT *) auth); if (dec_authent) KRB5_ENCDATA_free(dec_authent); if (unenc_authent) free(unenc_authent); EVP_CIPHER_CTX_cleanup(&ciph_ctx); return krb5rc; }
0
452,376
ex_retab(exarg_T *eap) { linenr_T lnum; int got_tab = FALSE; long num_spaces = 0; long num_tabs; long len; long col; long vcol; long start_col = 0; // For start of white-space string long start_vcol = 0; // For start of white-space string long old_len; long new_len; char_u *ptr; char_u *new_line = (char_u *)1; // init to non-NULL int did_undo; // called u_save for current line #ifdef FEAT_VARTABS int *new_vts_array = NULL; char_u *new_ts_str; // string value of tab argument #else int temp; int new_ts; #endif int save_list; linenr_T first_line = 0; // first changed line linenr_T last_line = 0; // last changed line save_list = curwin->w_p_list; curwin->w_p_list = 0; // don't want list mode here #ifdef FEAT_VARTABS new_ts_str = eap->arg; if (tabstop_set(eap->arg, &new_vts_array) == FAIL) return; while (vim_isdigit(*(eap->arg)) || *(eap->arg) == ',') ++(eap->arg); // This ensures that either new_vts_array and new_ts_str are freshly // allocated, or new_vts_array points to an existing array and new_ts_str // is null. if (new_vts_array == NULL) { new_vts_array = curbuf->b_p_vts_array; new_ts_str = NULL; } else new_ts_str = vim_strnsave(new_ts_str, eap->arg - new_ts_str); #else ptr = eap->arg; new_ts = getdigits(&ptr); if (new_ts < 0 && *eap->arg == '-') { emsg(_(e_argument_must_be_positive)); return; } if (new_ts < 0 || new_ts > TABSTOP_MAX) { semsg(_(e_invalid_argument_str), eap->arg); return; } if (new_ts == 0) new_ts = curbuf->b_p_ts; #endif for (lnum = eap->line1; !got_int && lnum <= eap->line2; ++lnum) { ptr = ml_get(lnum); col = 0; vcol = 0; did_undo = FALSE; for (;;) { if (VIM_ISWHITE(ptr[col])) { if (!got_tab && num_spaces == 0) { // First consecutive white-space start_vcol = vcol; start_col = col; } if (ptr[col] == ' ') num_spaces++; else got_tab = TRUE; } else { if (got_tab || (eap->forceit && num_spaces > 1)) { // Retabulate this string of white-space // len is virtual length of white string len = num_spaces = vcol - start_vcol; num_tabs = 0; if (!curbuf->b_p_et) { #ifdef FEAT_VARTABS int t, s; tabstop_fromto(start_vcol, vcol, curbuf->b_p_ts, new_vts_array, &t, &s); num_tabs = t; num_spaces = s; #else temp = new_ts - (start_vcol % new_ts); if (num_spaces >= temp) { num_spaces -= temp; num_tabs++; } num_tabs += num_spaces / new_ts; num_spaces -= (num_spaces / new_ts) * new_ts; #endif } if (curbuf->b_p_et || got_tab || (num_spaces + num_tabs < len)) { if (did_undo == FALSE) { did_undo = TRUE; if (u_save((linenr_T)(lnum - 1), (linenr_T)(lnum + 1)) == FAIL) { new_line = NULL; // flag out-of-memory break; } } // len is actual number of white characters used len = num_spaces + num_tabs; old_len = (long)STRLEN(ptr); new_len = old_len - col + start_col + len + 1; if (new_len <= 0 || new_len >= MAXCOL) { emsg(_(e_resulting_text_too_long)); break; } new_line = alloc(new_len); if (new_line == NULL) break; if (start_col > 0) mch_memmove(new_line, ptr, (size_t)start_col); mch_memmove(new_line + start_col + len, ptr + col, (size_t)(old_len - col + 1)); ptr = new_line + start_col; for (col = 0; col < len; col++) ptr[col] = (col < num_tabs) ? '\t' : ' '; if (ml_replace(lnum, new_line, FALSE) == OK) // "new_line" may have been copied new_line = curbuf->b_ml.ml_line_ptr; if (first_line == 0) first_line = lnum; last_line = lnum; ptr = new_line; col = start_col + len; } } got_tab = FALSE; num_spaces = 0; } if (ptr[col] == NUL) break; vcol += chartabsize(ptr + col, (colnr_T)vcol); if (vcol >= MAXCOL) { emsg(_(e_resulting_text_too_long)); break; } if (has_mbyte) col += (*mb_ptr2len)(ptr + col); else ++col; } if (new_line == NULL) // out of memory break; line_breakcheck(); } if (got_int) emsg(_(e_interrupted)); #ifdef FEAT_VARTABS // If a single value was given then it can be considered equal to // either the value of 'tabstop' or the value of 'vartabstop'. if (tabstop_count(curbuf->b_p_vts_array) == 0 && tabstop_count(new_vts_array) == 1 && curbuf->b_p_ts == tabstop_first(new_vts_array)) ; // not changed else if (tabstop_count(curbuf->b_p_vts_array) > 0 && tabstop_eq(curbuf->b_p_vts_array, new_vts_array)) ; // not changed else redraw_curbuf_later(NOT_VALID); #else if (curbuf->b_p_ts != new_ts) redraw_curbuf_later(NOT_VALID); #endif if (first_line != 0) changed_lines(first_line, 0, last_line + 1, 0L); curwin->w_p_list = save_list; // restore 'list' #ifdef FEAT_VARTABS if (new_ts_str != NULL) // set the new tabstop { // If 'vartabstop' is in use or if the value given to retab has more // than one tabstop then update 'vartabstop'. int *old_vts_ary = curbuf->b_p_vts_array; if (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_vts_array) > 1) { set_string_option_direct((char_u *)"vts", -1, new_ts_str, OPT_FREE|OPT_LOCAL, 0); curbuf->b_p_vts_array = new_vts_array; vim_free(old_vts_ary); } else { // 'vartabstop' wasn't in use and a single value was given to // retab then update 'tabstop'. curbuf->b_p_ts = tabstop_first(new_vts_array); vim_free(new_vts_array); } vim_free(new_ts_str); } #else curbuf->b_p_ts = new_ts; #endif coladvance(curwin->w_curswant); u_clearline(); }
0
244,139
void st3d_box_del(GF_Box *s) { gf_free(s); }
0
512,723
Item_default_value(THD *thd, Name_resolution_context *context_arg, Item *a, bool vcol_assignment_arg) :Item_field(thd, context_arg, (const char *)NULL, (const char *)NULL, &null_clex_str), vcol_assignment_ok(vcol_assignment_arg), arg(a), cached_field(NULL) {}
0
215,103
createRandomCursorExecutor(const CollectionPtr& coll, const boost::intrusive_ptr<ExpressionContext>& expCtx, long long sampleSize, long long numRecords, boost::optional<BucketUnpacker> bucketUnpacker) { OperationContext* opCtx = expCtx->opCtx; // Verify that we are already under a collection lock. We avoid taking locks ourselves in this // function because double-locking forces any PlanExecutor we create to adopt a NO_YIELD policy. invariant(opCtx->lockState()->isCollectionLockedForMode(coll->ns(), MODE_IS)); static const double kMaxSampleRatioForRandCursor = 0.05; if (!expCtx->ns.isTimeseriesBucketsCollection()) { if (sampleSize > numRecords * kMaxSampleRatioForRandCursor || numRecords <= 100) { return std::pair{nullptr, false}; } } else { // Suppose that a time-series bucket collection is observed to contain 200 buckets, and the // 'gTimeseriesBucketMaxCount' parameter is set to 1000. If all buckets are full, then the // maximum possible measurment count would be 200 * 1000 = 200,000. While the // 'SampleFromTimeseriesBucket' plan is more efficient when the sample size is small // relative to the total number of measurements in the time-series collection, for larger // sample sizes the top-k sort based sample is faster. Experiments have approximated that // the tipping point is roughly when the requested sample size is greater than 1% of the // maximum possible number of measurements in the collection (i.e. numBuckets * // maxMeasurementsPerBucket). static const double kCoefficient = 0.01; if (sampleSize > kCoefficient * numRecords * gTimeseriesBucketMaxCount) { return std::pair{nullptr, false}; } } // Attempt to get a random cursor from the RecordStore. auto rsRandCursor = coll->getRecordStore()->getRandomCursor(opCtx); if (!rsRandCursor) { // The storage engine has no random cursor support. return std::pair{nullptr, false}; } // Build a MultiIteratorStage and pass it the random-sampling RecordCursor. auto ws = std::make_unique<WorkingSet>(); std::unique_ptr<PlanStage> root = std::make_unique<MultiIteratorStage>(expCtx.get(), ws.get(), coll); static_cast<MultiIteratorStage*>(root.get())->addIterator(std::move(rsRandCursor)); // If the incoming operation is sharded, use the CSS to infer the filtering metadata for the // collection, otherwise treat it as unsharded auto collectionFilter = CollectionShardingState::get(opCtx, coll->ns()) ->getOwnershipFilter( opCtx, CollectionShardingState::OrphanCleanupPolicy::kDisallowOrphanCleanup); TrialStage* trialStage = nullptr; // Because 'numRecords' includes orphan documents, our initial decision to optimize the $sample // cursor may have been mistaken. For sharded collections, build a TRIAL plan that will switch // to a collection scan if the ratio of orphaned to owned documents encountered over the first // 100 works() is such that we would have chosen not to optimize. static const size_t kMaxPresampleSize = 100; if (collectionFilter.isSharded() && !expCtx->ns.isTimeseriesBucketsCollection()) { // The ratio of owned to orphaned documents must be at least equal to the ratio between the // requested sampleSize and the maximum permitted sampleSize for the original constraints to // be satisfied. For instance, if there are 200 documents and the sampleSize is 5, then at // least (5 / (200*0.05)) = (5/10) = 50% of those documents must be owned. If less than 5% // of the documents in the collection are owned, we default to the backup plan. const auto minAdvancedToWorkRatio = std::max( sampleSize / (numRecords * kMaxSampleRatioForRandCursor), kMaxSampleRatioForRandCursor); // The trial plan is SHARDING_FILTER-MULTI_ITERATOR. auto randomCursorPlan = std::make_unique<ShardFilterStage>( expCtx.get(), collectionFilter, ws.get(), std::move(root)); // The backup plan is SHARDING_FILTER-COLLSCAN. std::unique_ptr<PlanStage> collScanPlan = std::make_unique<CollectionScan>( expCtx.get(), coll, CollectionScanParams{}, ws.get(), nullptr); collScanPlan = std::make_unique<ShardFilterStage>( expCtx.get(), collectionFilter, ws.get(), std::move(collScanPlan)); // Place a TRIAL stage at the root of the plan tree, and pass it the trial and backup plans. root = std::make_unique<TrialStage>(expCtx.get(), ws.get(), std::move(randomCursorPlan), std::move(collScanPlan), kMaxPresampleSize, minAdvancedToWorkRatio); trialStage = static_cast<TrialStage*>(root.get()); } else if (expCtx->ns.isTimeseriesBucketsCollection()) { // Use a 'TrialStage' to run a trial between 'SampleFromTimeseriesBucket' and // 'UnpackTimeseriesBucket' with $sample left in the pipeline in-place. If the buckets are // not sufficiently full, or the 'SampleFromTimeseriesBucket' plan draws too many // duplicates, then we will fall back to the 'TrialStage' backup plan. This backup plan uses // the top-k sort sampling approach. // // Suppose the 'gTimeseriesBucketMaxCount' is 1000, but each bucket only contains 500 // documents on average. The observed trial advanced/work ratio approximates the average // bucket fullness, noted here as "abf". In this example, abf = 500 / 1000 = 0.5. // Experiments have shown that the optimized 'SampleFromTimeseriesBucket' algorithm performs // better than backup plan when // // sampleSize < 0.02 * abf * numRecords * gTimeseriesBucketMaxCount // // This inequality can be rewritten as // // abf > sampleSize / (0.02 * numRecords * gTimeseriesBucketMaxCount) // // Therefore, if the advanced/work ratio exceeds this threshold, we will use the // 'SampleFromTimeseriesBucket' plan. Note that as the sample size requested by the user // becomes larger with respect to the number of buckets, we require a higher advanced/work // ratio in order to justify using 'SampleFromTimeseriesBucket'. // // Additionally, we require the 'TrialStage' to approximate the abf as at least 0.25. When // buckets are mostly empty, the 'SampleFromTimeseriesBucket' will be inefficient due to a // lot of sampling "misses". static const auto kCoefficient = 0.02; static const auto kMinBucketFullness = 0.25; const auto minAdvancedToWorkRatio = std::max( std::min(sampleSize / (kCoefficient * numRecords * gTimeseriesBucketMaxCount), 1.0), kMinBucketFullness); auto arhashPlan = std::make_unique<SampleFromTimeseriesBucket>( expCtx.get(), ws.get(), std::move(root), *bucketUnpacker, // By using a quantity slightly higher than 'kMaxPresampleSize', we ensure that the // 'SampleFromTimeseriesBucket' stage won't fail due to too many consecutive sampling // attempts during the 'TrialStage's trial period. kMaxPresampleSize + 5, sampleSize, gTimeseriesBucketMaxCount); std::unique_ptr<PlanStage> collScanPlan = std::make_unique<CollectionScan>( expCtx.get(), coll, CollectionScanParams{}, ws.get(), nullptr); auto topkSortPlan = std::make_unique<UnpackTimeseriesBucket>( expCtx.get(), ws.get(), std::move(collScanPlan), *bucketUnpacker); root = std::make_unique<TrialStage>(expCtx.get(), ws.get(), std::move(arhashPlan), std::move(topkSortPlan), kMaxPresampleSize, minAdvancedToWorkRatio); trialStage = static_cast<TrialStage*>(root.get()); } auto execStatus = plan_executor_factory::make(expCtx, std::move(ws), std::move(root), &coll, opCtx->inMultiDocumentTransaction() ? PlanYieldPolicy::YieldPolicy::INTERRUPT_ONLY : PlanYieldPolicy::YieldPolicy::YIELD_AUTO, QueryPlannerParams::RETURN_OWNED_DATA); if (!execStatus.isOK()) { return execStatus.getStatus(); } // For sharded collections, the root of the plan tree is a TrialStage that may have chosen // either a random-sampling cursor trial plan or a COLLSCAN backup plan. We can only optimize // the $sample aggregation stage if the trial plan was chosen. return std::pair{std::move(execStatus.getValue()), !trialStage || !trialStage->pickedBackupPlan()}; }
1
413,819
Method* LinkResolver::resolve_interface_method(const LinkInfo& link_info, Bytecodes::Code code, TRAPS) { Klass* resolved_klass = link_info.resolved_klass(); // check if klass is interface if (!resolved_klass->is_interface()) { ResourceMark rm(THREAD); char buf[200]; jio_snprintf(buf, sizeof(buf), "Found class %s, but interface was expected", resolved_klass->external_name()); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf); } // check constant pool tag for called method - must be JVM_CONSTANT_InterfaceMethodref if (!link_info.tag().is_invalid() && !link_info.tag().is_interface_method()) { ResourceMark rm(THREAD); stringStream ss; ss.print("Method '"); Method::print_external_name(&ss, link_info.resolved_klass(), link_info.name(), link_info.signature()); ss.print("' must be InterfaceMethodref constant"); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string()); } // lookup method in this interface or its super, java.lang.Object // JDK8: also look for static methods methodHandle resolved_method(THREAD, lookup_method_in_klasses(link_info, false, true)); if (resolved_method.is_null() && !resolved_klass->is_array_klass()) { // lookup method in all the super-interfaces resolved_method = methodHandle(THREAD, lookup_method_in_interfaces(link_info)); } if (resolved_method.is_null()) { // no method found ResourceMark rm(THREAD); stringStream ss; ss.print("'"); Method::print_external_name(&ss, resolved_klass, link_info.name(), link_info.signature()); ss.print("'"); THROW_MSG_NULL(vmSymbols::java_lang_NoSuchMethodError(), ss.as_string()); } if (link_info.check_access()) { // JDK8 adds non-public interface methods, and accessability check requirement Klass* current_klass = link_info.current_klass(); assert(current_klass != NULL , "current_klass should not be null"); // check if method can be accessed by the referring class check_method_accessability(current_klass, resolved_klass, resolved_method->method_holder(), resolved_method, CHECK_NULL); } if (link_info.check_loader_constraints()) { check_method_loader_constraints(link_info, resolved_method, "interface method", CHECK_NULL); } if (code != Bytecodes::_invokestatic && resolved_method->is_static()) { ResourceMark rm(THREAD); stringStream ss; ss.print("Expected instance not static method '"); Method::print_external_name(&ss, resolved_klass, resolved_method->name(), resolved_method->signature()); ss.print("'"); THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string()); } if (log_develop_is_enabled(Trace, itables)) { char buf[200]; jio_snprintf(buf, sizeof(buf), "%s resolved interface method: caller-class:", Bytecodes::name(code)); trace_method_resolution(buf, link_info.current_klass(), resolved_klass, resolved_method(), true); } return resolved_method(); }
0
398,541
RzBinSection *getsection(RzBinFile *binfile, const char *sn) { rz_return_val_if_fail(binfile && sn, NULL); RzListIter *iter; RzBinSection *section = NULL; RzBinObject *o = binfile->o; if (!o || !o->sections) { return NULL; } rz_list_foreach (o->sections, iter, section) { if (!section->name) { continue; } if (strstr(section->name, sn)) { return section; } } return NULL; }
0
512,717
bool Regexp_processor_pcre::exec(String *str, int offset, uint n_result_offsets_to_convert) { if (!(str= convert_if_needed(str, &subject_converter))) return true; m_pcre_exec_rc= pcre_exec_with_warn(m_pcre, &m_pcre_extra, str->c_ptr_safe(), str->length(), offset, 0, m_SubStrVec, array_elements(m_SubStrVec)); if (m_pcre_exec_rc > 0) { uint i; for (i= 0; i < n_result_offsets_to_convert; i++) { /* Convert byte offset into character offset. */ m_SubStrVec[i]= (int) str->charset()->cset->numchars(str->charset(), str->ptr(), str->ptr() + m_SubStrVec[i]); } } return false; }
0
513,140
static bool plugin_load_list(MEM_ROOT *tmp_root, const char *list) { char buffer[FN_REFLEN]; LEX_STRING name= {buffer, 0}, dl= {NULL, 0}, *str= &name; char *p= buffer; DBUG_ENTER("plugin_load_list"); while (list) { if (p == buffer + sizeof(buffer) - 1) { sql_print_error("plugin-load parameter too long"); DBUG_RETURN(TRUE); } switch ((*(p++)= *(list++))) { case '\0': list= NULL; /* terminate the loop */ /* fall through */ case ';': #ifndef __WIN__ case ':': /* can't use this as delimiter as it may be drive letter */ #endif str->str[str->length]= '\0'; if (str == &name) // load all plugins in named module { if (!name.length) { p--; /* reset pointer */ continue; } dl= name; mysql_mutex_lock(&LOCK_plugin); free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE)); name.str= 0; // load everything if (plugin_add(tmp_root, &name, &dl, REPORT_TO_LOG)) goto error; } else { free_root(tmp_root, MYF(MY_MARK_BLOCKS_FREE)); mysql_mutex_lock(&LOCK_plugin); if (plugin_add(tmp_root, &name, &dl, REPORT_TO_LOG)) goto error; } mysql_mutex_unlock(&LOCK_plugin); name.length= dl.length= 0; dl.str= NULL; name.str= p= buffer; str= &name; continue; case '=': case '#': if (str == &name) { name.str[name.length]= '\0'; str= &dl; str->str= p; continue; } /* fall through */ default: str->length++; continue; } } DBUG_RETURN(FALSE); error: mysql_mutex_unlock(&LOCK_plugin); if (name.str) sql_print_error("Couldn't load plugin '%s' from '%s'.", name.str, dl.str); else sql_print_error("Couldn't load plugins from '%s'.", dl.str); DBUG_RETURN(TRUE); }
0
522,332
int my_aio_write ( struct aiocb *aiocbp){return(aio_write (aiocbp));}
0
359,843
WandPrivate void CLINoImageOperator(MagickCLI *cli_wand, const char *option,const char *arg1n,const char *arg2n) { const char /* percent escaped versions of the args */ *arg1, *arg2; #define _image_info (cli_wand->wand.image_info) #define _images (cli_wand->wand.images) #define _exception (cli_wand->wand.exception) #define _process_flags (cli_wand->process_flags) #define _option_type ((CommandOptionFlags) cli_wand->command->flags) #define IfNormalOp (*option=='-') #define IfPlusOp (*option!='-') assert(cli_wand != (MagickCLI *) NULL); assert(cli_wand->signature == MagickWandSignature); assert(cli_wand->wand.signature == MagickWandSignature); if (cli_wand->wand.debug != MagickFalse) (void) CLILogEvent(cli_wand,CommandEvent,GetMagickModule(), "- NoImage Operator: %s \"%s\" \"%s\"", option, arg1n != (char *) NULL ? arg1n : "", arg2n != (char *) NULL ? arg2n : ""); arg1 = arg1n; arg2 = arg2n; /* Interpret Percent Escapes in Arguments - using first image */ if ( (((_process_flags & ProcessInterpretProperities) != 0 ) || ((_option_type & AlwaysInterpretArgsFlag) != 0) ) && ((_option_type & NeverInterpretArgsFlag) == 0) ) { /* Interpret Percent escapes in argument 1 */ if (arg1n != (char *) NULL) { arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); if (arg1 == (char *) NULL) { CLIWandException(OptionWarning,"InterpretPropertyFailure",option); arg1=arg1n; /* use the given argument as is */ } } if (arg2n != (char *) NULL) { arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); if (arg2 == (char *) NULL) { CLIWandException(OptionWarning,"InterpretPropertyFailure",option); arg2=arg2n; /* use the given argument as is */ } } } #undef _process_flags #undef _option_type do { /* break to exit code */ /* No-op options (ignore these) */ if (LocaleCompare("noop",option+1) == 0) /* zero argument */ break; if (LocaleCompare("sans",option+1) == 0) /* one argument */ break; if (LocaleCompare("sans0",option+1) == 0) /* zero argument */ break; if (LocaleCompare("sans1",option+1) == 0) /* one argument */ break; if (LocaleCompare("sans2",option+1) == 0) /* two arguments */ break; /* Image Reading */ if ( ( LocaleCompare("read",option+1) == 0 ) || ( LocaleCompare("--",option) == 0 ) ) { /* Do Glob filename Expansion for 'arg1' then read all images. * * Expansion handles '@', '~', '*', and '?' meta-characters while ignoring * (but attaching to the filenames in the generated argument list) any * [...] read modifiers that may be present. * * For example: It will expand '*.gif[20x20]' into a list such as * 'abc.gif[20x20]', 'foobar.gif[20x20]', 'xyzzy.gif[20x20]' * * NOTE: In IMv6 this was done globally across all images. This * meant you could include IM options in '@filename' lists, but you * could not include comments. Doing it only for image read makes * it far more secure. * * Note: arguments do not have percent escapes expanded for security * reasons. */ int argc; char **argv; ssize_t i; argc = 1; argv = (char **) &arg1; /* Expand 'glob' expressions in the given filename. Expansion handles any 'coder:' prefix, or read modifiers attached to the filename, including them in the resulting expanded list. */ if (ExpandFilenames(&argc,&argv) == MagickFalse) CLIWandExceptArgBreak(ResourceLimitError,"MemoryAllocationFailed", option,GetExceptionMessage(errno)); /* loop over expanded filename list, and read then all in */ for (i=0; i < (ssize_t) argc; i++) { Image * new_images; if (_image_info->ping != MagickFalse) new_images=PingImages(_image_info,argv[i],_exception); else new_images=ReadImages(_image_info,argv[i],_exception); AppendImageToList(&_images, new_images); argv[i]=DestroyString(argv[i]); } argv=(char **) RelinquishMagickMemory(argv); break; } /* Image Writing Note: Writing a empty image list is valid in specific cases */ if (LocaleCompare("write",option+1) == 0) { /* Note: arguments do not have percent escapes expanded */ char key[MagickPathExtent]; Image *write_images; ImageInfo *write_info; /* Need images, unless a "null:" output coder is used */ if ( _images == (Image *) NULL ) { if ( LocaleCompare(arg1,"null:") == 0 ) break; CLIWandExceptArgBreak(OptionError,"NoImagesForWrite",option,arg1); } (void) FormatLocaleString(key,MagickPathExtent,"cache:%s",arg1); (void) DeleteImageRegistry(key); write_images=CloneImageList(_images,_exception); write_info=CloneImageInfo(_image_info); if (write_images != (Image *) NULL) (void) WriteImages(write_info,write_images,arg1,_exception); write_info=DestroyImageInfo(write_info); write_images=DestroyImageList(write_images); break; } /* Parenthesis and Brace operations */ if (LocaleCompare("(",option) == 0) { /* stack 'push' images */ Stack *node; size_t size; size=0; node=cli_wand->image_list_stack; for ( ; node != (Stack *) NULL; node=node->next) size++; if ( size >= MAX_STACK_DEPTH ) CLIWandExceptionBreak(OptionError,"ParenthesisNestedTooDeeply",option); node=(Stack *) AcquireMagickMemory(sizeof(*node)); if (node == (Stack *) NULL) CLIWandExceptionBreak(ResourceLimitFatalError, "MemoryAllocationFailed",option); node->data = (void *)cli_wand->wand.images; node->next = cli_wand->image_list_stack; cli_wand->image_list_stack = node; cli_wand->wand.images = NewImageList(); /* handle respect-parenthesis */ if (IsStringTrue(GetImageOption(cli_wand->wand.image_info, "respect-parenthesis")) != MagickFalse) option="{"; /* fall-thru so as to push image settings too */ else break; /* fall thru to operation */ } if (LocaleCompare("{",option) == 0) { /* stack 'push' of image_info settings */ Stack *node; size_t size; size=0; node=cli_wand->image_info_stack; for ( ; node != (Stack *) NULL; node=node->next) size++; if ( size >= MAX_STACK_DEPTH ) CLIWandExceptionBreak(OptionError,"CurlyBracesNestedTooDeeply",option); node=(Stack *) AcquireMagickMemory(sizeof(*node)); if (node == (Stack *) NULL) CLIWandExceptionBreak(ResourceLimitFatalError, "MemoryAllocationFailed",option); node->data = (void *)cli_wand->wand.image_info; node->next = cli_wand->image_info_stack; cli_wand->image_info_stack = node; cli_wand->wand.image_info = CloneImageInfo(cli_wand->wand.image_info); if (cli_wand->wand.image_info == (ImageInfo *) NULL) { CLIWandException(ResourceLimitFatalError,"MemoryAllocationFailed", option); cli_wand->wand.image_info = (ImageInfo *)node->data; node = (Stack *)RelinquishMagickMemory(node); break; } break; } if (LocaleCompare(")",option) == 0) { /* pop images from stack */ Stack *node; node = (Stack *)cli_wand->image_list_stack; if ( node == (Stack *) NULL) CLIWandExceptionBreak(OptionError,"UnbalancedParenthesis",option); cli_wand->image_list_stack = node->next; AppendImageToList((Image **)&node->data,cli_wand->wand.images); cli_wand->wand.images= (Image *)node->data; node = (Stack *)RelinquishMagickMemory(node); /* handle respect-parenthesis - of the previous 'pushed' settings */ node = cli_wand->image_info_stack; if ( node != (Stack *) NULL) { if (IsStringTrue(GetImageOption( cli_wand->wand.image_info,"respect-parenthesis")) != MagickFalse) option="}"; /* fall-thru so as to pop image settings too */ else break; } else break; /* fall thru to next if */ } if (LocaleCompare("}",option) == 0) { /* pop image_info settings from stack */ Stack *node; node = (Stack *)cli_wand->image_info_stack; if ( node == (Stack *) NULL) CLIWandExceptionBreak(OptionError,"UnbalancedCurlyBraces",option); cli_wand->image_info_stack = node->next; (void) DestroyImageInfo(cli_wand->wand.image_info); cli_wand->wand.image_info = (ImageInfo *)node->data; node = (Stack *)RelinquishMagickMemory(node); GetDrawInfo(cli_wand->wand.image_info, cli_wand->draw_info); cli_wand->quantize_info=DestroyQuantizeInfo(cli_wand->quantize_info); cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info); break; } if (LocaleCompare("print",option+1) == 0) { (void) FormatLocaleFile(stdout,"%s",arg1); break; } if (LocaleCompare("set",option+1) == 0) { /* Settings are applied to each image in memory in turn (if any). While a option: only need to be applied once globally. NOTE: rguments have not been automatically percent expaneded */ /* escape the 'key' once only, using first image. */ arg1=InterpretImageProperties(_image_info,_images,arg1n,_exception); if (arg1 == (char *) NULL) CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", option); if (LocaleNCompare(arg1,"registry:",9) == 0) { if (IfPlusOp) { (void) DeleteImageRegistry(arg1+9); arg1=DestroyString((char *)arg1); break; } arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); if (arg2 == (char *) NULL) { arg1=DestroyString((char *)arg1); CLIWandExceptionBreak(OptionWarning,"InterpretPropertyFailure", option); } (void) SetImageRegistry(StringRegistryType,arg1+9,arg2,_exception); arg1=DestroyString((char *)arg1); arg2=DestroyString((char *)arg2); break; } if (LocaleNCompare(arg1,"option:",7) == 0) { /* delete equivelent artifact from all images (if any) */ if (_images != (Image *) NULL) { MagickResetIterator(&cli_wand->wand); while (MagickNextImage(&cli_wand->wand) != MagickFalse) (void) DeleteImageArtifact(_images,arg1+7); MagickResetIterator(&cli_wand->wand); } /* now set/delete the global option as needed */ /* FUTURE: make escapes in a global 'option:' delayed */ arg2=(char *) NULL; if (IfNormalOp) { arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); if (arg2 == (char *) NULL) CLIWandExceptionBreak(OptionWarning, "InterpretPropertyFailure",option); } (void) SetImageOption(_image_info,arg1+7,arg2); arg1=DestroyString((char *)arg1); arg2=DestroyString((char *)arg2); break; } /* Set Artifacts/Properties/Attributes all images (required) */ if ( _images == (Image *) NULL ) CLIWandExceptArgBreak(OptionWarning,"NoImageForProperty",option,arg1); MagickResetIterator(&cli_wand->wand); while (MagickNextImage(&cli_wand->wand) != MagickFalse) { arg2=(char *) NULL; if (IfNormalOp) { arg2=InterpretImageProperties(_image_info,_images,arg2n,_exception); if (arg2 == (char *) NULL) CLIWandExceptionBreak(OptionWarning, "InterpretPropertyFailure",option); } if (LocaleNCompare(arg1,"artifact:",9) == 0) (void) SetImageArtifact(_images,arg1+9,arg2); else if (LocaleNCompare(arg1,"property:",9) == 0) (void) SetImageProperty(_images,arg1+9,arg2,_exception); else (void) SetImageProperty(_images,arg1,arg2,_exception); arg2=DestroyString((char *)arg2); } MagickResetIterator(&cli_wand->wand); arg1=DestroyString((char *)arg1); break; } if (LocaleCompare("clone",option+1) == 0) { Image *new_images; if (*option == '+') arg1=AcquireString("-1"); if (IsSceneGeometry(arg1,MagickFalse) == MagickFalse) CLIWandExceptionBreak(OptionError,"InvalidArgument",option); if ( cli_wand->image_list_stack == (Stack *) NULL) CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option); new_images = (Image *)cli_wand->image_list_stack->data; if (new_images == (Image *) NULL) CLIWandExceptionBreak(OptionError,"UnableToCloneImage",option); new_images=CloneImages(new_images,arg1,_exception); if (new_images == (Image *) NULL) CLIWandExceptionBreak(OptionError,"NoSuchImage",option); AppendImageToList(&_images,new_images); break; } /* Informational Operations. Note that these do not require either a cli-wand or images! Though currently a cli-wand much be provided regardless. */ if (LocaleCompare("version",option+1) == 0) { ListMagickVersion(stdout); break; } if (LocaleCompare("list",option+1) == 0) { /* FUTURE: This 'switch' should really be part of MagickCore */ ssize_t list; list=ParseCommandOption(MagickListOptions,MagickFalse,arg1); if ( list < 0 ) { CLIWandExceptionArg(OptionError,"UnrecognizedListType",option,arg1); break; } switch (list) { case MagickCoderOptions: { (void) ListCoderInfo((FILE *) NULL,_exception); break; } case MagickColorOptions: { (void) ListColorInfo((FILE *) NULL,_exception); break; } case MagickConfigureOptions: { (void) ListConfigureInfo((FILE *) NULL,_exception); break; } case MagickDelegateOptions: { (void) ListDelegateInfo((FILE *) NULL,_exception); break; } case MagickFontOptions: { (void) ListTypeInfo((FILE *) NULL,_exception); break; } case MagickFormatOptions: (void) ListMagickInfo((FILE *) NULL,_exception); break; case MagickLocaleOptions: (void) ListLocaleInfo((FILE *) NULL,_exception); break; case MagickLogOptions: (void) ListLogInfo((FILE *) NULL,_exception); break; case MagickMagicOptions: (void) ListMagicInfo((FILE *) NULL,_exception); break; case MagickMimeOptions: (void) ListMimeInfo((FILE *) NULL,_exception); break; case MagickModuleOptions: (void) ListModuleInfo((FILE *) NULL,_exception); break; case MagickPolicyOptions: (void) ListPolicyInfo((FILE *) NULL,_exception); break; case MagickResourceOptions: (void) ListMagickResourceInfo((FILE *) NULL,_exception); break; case MagickThresholdOptions: (void) ListThresholdMaps((FILE *) NULL,_exception); break; default: (void) ListCommandOptions((FILE *) NULL,(CommandOption) list, _exception); break; } break; } CLIWandException(OptionError,"UnrecognizedOption",option); DisableMSCWarning(4127) } while (0); /* break to exit code. */ RestoreMSCWarning /* clean up percent escape interpreted strings */ if (arg1 != arg1n ) arg1=DestroyString((char *)arg1); if (arg2 != arg2n ) arg2=DestroyString((char *)arg2); #undef _image_info #undef _images #undef _exception #undef IfNormalOp #undef IfPlusOp }
0
259,535
static CURLUcode hostname_check(struct Curl_URL *u, char *hostname) { size_t len; size_t hlen = strlen(hostname); if(hostname[0] == '[') { const char *l = "0123456789abcdefABCDEF:."; if(hlen < 4) /* '[::]' is the shortest possible valid string */ return CURLUE_BAD_IPV6; hostname++; hlen -= 2; if(hostname[hlen] != ']') return CURLUE_BAD_IPV6; /* only valid letters are ok */ len = strspn(hostname, l); if(hlen != len) { hlen = len; if(hostname[len] == '%') { /* this could now be '%[zone id]' */ char zoneid[16]; int i = 0; char *h = &hostname[len + 1]; /* pass '25' if present and is a url encoded percent sign */ if(!strncmp(h, "25", 2) && h[2] && (h[2] != ']')) h += 2; while(*h && (*h != ']') && (i < 15)) zoneid[i++] = *h++; if(!i || (']' != *h)) /* impossible to reach? */ return CURLUE_MALFORMED_INPUT; zoneid[i] = 0; u->zoneid = strdup(zoneid); if(!u->zoneid) return CURLUE_OUT_OF_MEMORY; hostname[len] = ']'; /* insert end bracket */ hostname[len + 1] = 0; /* terminate the hostname */ } else return CURLUE_BAD_IPV6; /* hostname is fine */ } #ifdef ENABLE_IPV6 { char dest[16]; /* fits a binary IPv6 address */ char norm[MAX_IPADR_LEN]; hostname[hlen] = 0; /* end the address there */ if(1 != Curl_inet_pton(AF_INET6, hostname, dest)) return CURLUE_BAD_IPV6; /* check if it can be done shorter */ if(Curl_inet_ntop(AF_INET6, dest, norm, sizeof(norm)) && (strlen(norm) < hlen)) { strcpy(hostname, norm); hlen = strlen(norm); hostname[hlen + 1] = 0; } hostname[hlen] = ']'; /* restore ending bracket */ } #endif } else { /* letters from the second string are not ok */ len = strcspn(hostname, " \r\n\t/:#?!@"); if(hlen != len) /* hostname with bad content */ return CURLUE_BAD_HOSTNAME; } if(!hostname[0]) return CURLUE_NO_HOST; return CURLUE_OK; }
0
313,833
nv_end(cmdarg_T *cap) { if (cap->arg || (mod_mask & MOD_MASK_CTRL)) // CTRL-END = goto last line { cap->arg = TRUE; nv_goto(cap); cap->count1 = 1; // to end of current line } nv_dollar(cap); }
0
462,252
static pj_status_t encode_binary_attr(const void *a, pj_uint8_t *buf, unsigned len, const pj_stun_msg_hdr *msghdr, unsigned *printed) { const pj_stun_binary_attr *ca = (const pj_stun_binary_attr*)a; PJ_CHECK_STACK(); PJ_UNUSED_ARG(msghdr); /* Calculated total attr_len (add padding if necessary) */ *printed = (ca->length + ATTR_HDR_LEN + 3) & (~3); if (len < *printed) return PJ_ETOOSMALL; PUTVAL16H(buf, 0, ca->hdr.type); PUTVAL16H(buf, 2, (pj_uint16_t) ca->length); /* Copy the data */ pj_memcpy(buf+ATTR_HDR_LEN, ca->data, ca->length); /* Done */ return PJ_SUCCESS; }
0
364,770
findtags_string_convert(findtags_state_T *st) { char_u *conv_line; int len; conv_line = string_convert(&st->vimconv, st->lbuf, NULL); if (conv_line == NULL) return; // Copy or swap lbuf and conv_line. len = (int)STRLEN(conv_line) + 1; if (len > st->lbuf_size) { vim_free(st->lbuf); st->lbuf = conv_line; st->lbuf_size = len; } else { STRCPY(st->lbuf, conv_line); vim_free(conv_line); } }
0
512,367
bool Item_func_between::fix_length_and_dec() { max_length= 1; /* As some compare functions are generated after sql_yacc, we have to check for out of memory conditions here */ if (!args[0] || !args[1] || !args[2]) return TRUE; if (m_comparator.aggregate_for_comparison(Item_func_between::func_name(), args, 3, false)) { DBUG_ASSERT(current_thd->is_error()); return TRUE; } return m_comparator.type_handler()-> Item_func_between_fix_length_and_dec(this); }
0
500,085
kssl_krb5_sname_to_principal(krb5_context CO, krb5_const char * pC1, krb5_const char * pC2, krb5_int32 I, krb5_principal * pPR) { if (!krb5_loaded) load_krb5_dll(); if ( p_krb5_sname_to_principal ) return(p_krb5_sname_to_principal(CO,pC1,pC2,I,pPR)); else return KRB5KRB_ERR_GENERIC; }
0
230,459
uip_nd6_init() { #if UIP_ND6_SEND_NA /* Only handle NSs if we are prepared to send out NAs */ uip_icmp6_register_input_handler(&ns_input_handler); #endif #if UIP_ND6_SEND_NS /* * Only handle NAs if we are prepared to send out NSs. */ uip_icmp6_register_input_handler(&na_input_handler); #endif #if UIP_CONF_ROUTER && UIP_ND6_SEND_RA /* Only accept RS if we are a router and happy to send out RAs */ uip_icmp6_register_input_handler(&rs_input_handler); #endif #if !UIP_CONF_ROUTER /* Only process RAs if we are not a router */ uip_icmp6_register_input_handler(&ra_input_handler); #endif }
0
401,541
int __init rand_initialize(void) { init_std_data(&input_pool); crng_initialize_primary(&primary_crng); crng_global_init_time = jiffies; if (ratelimit_disable) { urandom_warning.interval = 0; unseeded_warning.interval = 0; } return 0; }
0
338,747
static Image *ReadTGAImage(const ImageInfo *image_info, ExceptionInfo *exception) { Image *image; MagickBooleanType status; PixelInfo pixel; Quantum index; register Quantum *q; register ssize_t i, x; size_t base, flag, offset, real, skip; ssize_t count, y; TGAInfo tga_info; unsigned char j, k, pixels[4], runlength; unsigned int alpha_bits; /* 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,exception); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == MagickFalse) { image=DestroyImageList(image); return((Image *) NULL); } /* Read TGA header information. */ count=ReadBlob(image,1,&tga_info.id_length); tga_info.colormap_type=(unsigned char) ReadBlobByte(image); tga_info.image_type=(TGAImageType) ReadBlobByte(image); if ((count != 1) || ((tga_info.image_type != TGAColormap) && (tga_info.image_type != TGARGB) && (tga_info.image_type != TGAMonochrome) && (tga_info.image_type != TGARLEColormap) && (tga_info.image_type != TGARLERGB) && (tga_info.image_type != TGARLEMonochrome)) || (((tga_info.image_type == TGAColormap) || (tga_info.image_type == TGARLEColormap)) && (tga_info.colormap_type == 0))) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); tga_info.colormap_index=ReadBlobLSBShort(image); tga_info.colormap_length=ReadBlobLSBShort(image); tga_info.colormap_size=(unsigned char) ReadBlobByte(image); tga_info.x_origin=ReadBlobLSBShort(image); tga_info.y_origin=ReadBlobLSBShort(image); tga_info.width=(unsigned short) ReadBlobLSBShort(image); tga_info.height=(unsigned short) ReadBlobLSBShort(image); tga_info.bits_per_pixel=(unsigned char) ReadBlobByte(image); tga_info.attributes=(unsigned char) ReadBlobByte(image); if (EOFBlob(image) != MagickFalse) ThrowReaderException(CorruptImageError,"UnableToReadImageData"); if ((((tga_info.bits_per_pixel <= 1) || (tga_info.bits_per_pixel >= 17)) && (tga_info.bits_per_pixel != 24) && (tga_info.bits_per_pixel != 32))) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); /* Initialize image structure. */ image->columns=tga_info.width; image->rows=tga_info.height; alpha_bits=(tga_info.attributes & 0x0FU); image->alpha_trait=(alpha_bits > 0) || (tga_info.bits_per_pixel == 32) || (tga_info.colormap_size == 32) ? BlendPixelTrait : UndefinedPixelTrait; if ((tga_info.image_type != TGAColormap) && (tga_info.image_type != TGARLEColormap)) image->depth=(size_t) ((tga_info.bits_per_pixel <= 8) ? 8 : (tga_info.bits_per_pixel <= 16) ? 5 : 8); else image->depth=(size_t) ((tga_info.colormap_size <= 8) ? 8 : (tga_info.colormap_size <= 16) ? 5 : 8); if ((tga_info.image_type == TGAColormap) || (tga_info.image_type == TGAMonochrome) || (tga_info.image_type == TGARLEColormap) || (tga_info.image_type == TGARLEMonochrome)) image->storage_class=PseudoClass; image->compression=NoCompression; if ((tga_info.image_type == TGARLEColormap) || (tga_info.image_type == TGARLEMonochrome) || (tga_info.image_type == TGARLERGB)) image->compression=RLECompression; if (image->storage_class == PseudoClass) { if (tga_info.colormap_type != 0) image->colors=tga_info.colormap_index+tga_info.colormap_length; else { size_t one; one=1; image->colors=one << tga_info.bits_per_pixel; if (image->colors > ((~0UL)/sizeof(*image->colormap))) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); if (AcquireImageColormap(image,image->colors,exception) == MagickFalse) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); } } if (tga_info.id_length != 0) { char *comment; size_t length; /* TGA image comment. */ length=(size_t) tga_info.id_length; comment=(char *) NULL; if (~length >= (MagickPathExtent-1)) comment=(char *) AcquireQuantumMemory(length+MagickPathExtent, sizeof(*comment)); if (comment == (char *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); count=ReadBlob(image,tga_info.id_length,(unsigned char *) comment); comment[tga_info.id_length]='\0'; (void) SetImageProperty(image,"comment",comment,exception); comment=DestroyString(comment); } if (tga_info.attributes & (1UL << 4)) { if (tga_info.attributes & (1UL << 5)) SetImageArtifact(image,"tga:image-origin","TopRight"); else SetImageArtifact(image,"tga:image-origin","BottomRight"); } else { if (tga_info.attributes & (1UL << 5)) SetImageArtifact(image,"tga:image-origin","TopLeft"); else SetImageArtifact(image,"tga:image-origin","BottomLeft"); } if (image_info->ping != MagickFalse) { (void) CloseBlob(image); return(image); } status=SetImageExtent(image,image->columns,image->rows,exception); if (status == MagickFalse) return(DestroyImageList(image)); (void) ResetMagickMemory(&pixel,0,sizeof(pixel)); pixel.alpha=(MagickRealType) OpaqueAlpha; if (tga_info.colormap_type != 0) { /* Read TGA raster colormap. */ if (image->colors < tga_info.colormap_index) image->colors=tga_info.colormap_index; if (AcquireImageColormap(image,image->colors,exception) == MagickFalse) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); for (i=0; i < (ssize_t) tga_info.colormap_index; i++) image->colormap[i]=pixel; for ( ; i < (ssize_t) image->colors; i++) { switch (tga_info.colormap_size) { case 8: default: { /* Gray scale. */ pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char) ReadBlobByte(image)); pixel.green=pixel.red; pixel.blue=pixel.red; break; } case 15: case 16: { QuantumAny range; /* 5 bits each of red green and blue. */ j=(unsigned char) ReadBlobByte(image); k=(unsigned char) ReadBlobByte(image); range=GetQuantumRange(5UL); pixel.red=(MagickRealType) ScaleAnyToQuantum(1UL*(k & 0x7c) >> 2, range); pixel.green=(MagickRealType) ScaleAnyToQuantum((1UL*(k & 0x03) << 3)+(1UL*(j & 0xe0) >> 5),range); pixel.blue=(MagickRealType) ScaleAnyToQuantum(1UL*(j & 0x1f),range); break; } case 24: { /* 8 bits each of blue, green and red. */ pixel.blue=(MagickRealType) ScaleCharToQuantum((unsigned char) ReadBlobByte(image)); pixel.green=(MagickRealType) ScaleCharToQuantum((unsigned char) ReadBlobByte(image)); pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char) ReadBlobByte(image)); break; } case 32: { /* 8 bits each of blue, green, red, and alpha. */ pixel.blue=(MagickRealType) ScaleCharToQuantum((unsigned char) ReadBlobByte(image)); pixel.green=(MagickRealType) ScaleCharToQuantum((unsigned char) ReadBlobByte(image)); pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char) ReadBlobByte(image)); pixel.alpha=(MagickRealType) ScaleCharToQuantum((unsigned char) ReadBlobByte(image)); break; } } image->colormap[i]=pixel; } } /* Convert TGA pixels to pixel packets. */ base=0; flag=0; skip=MagickFalse; real=0; index=0; runlength=0; offset=0; for (y=0; y < (ssize_t) image->rows; y++) { real=offset; if (((unsigned char) (tga_info.attributes & 0x20) >> 5) == 0) real=image->rows-real-1; q=QueueAuthenticPixels(image,0,(ssize_t) real,image->columns,1,exception); if (q == (Quantum *) NULL) break; for (x=0; x < (ssize_t) image->columns; x++) { if ((tga_info.image_type == TGARLEColormap) || (tga_info.image_type == TGARLERGB) || (tga_info.image_type == TGARLEMonochrome)) { if (runlength != 0) { runlength--; skip=flag != 0; } else { count=ReadBlob(image,1,&runlength); if (count != 1) ThrowReaderException(CorruptImageError,"UnableToReadImageData"); flag=runlength & 0x80; if (flag != 0) runlength-=128; skip=MagickFalse; } } if (skip == MagickFalse) switch (tga_info.bits_per_pixel) { case 8: default: { /* Gray scale. */ index=(Quantum) ReadBlobByte(image); if (tga_info.colormap_type != 0) pixel=image->colormap[(ssize_t) ConstrainColormapIndex(image, (ssize_t) index,exception)]; else { pixel.red=(MagickRealType) ScaleCharToQuantum((unsigned char) index); pixel.green=(MagickRealType) ScaleCharToQuantum((unsigned char) index); pixel.blue=(MagickRealType) ScaleCharToQuantum((unsigned char) index); } break; } case 15: case 16: { QuantumAny range; /* 5 bits each of RGB. */ if (ReadBlob(image,2,pixels) != 2) ThrowReaderException(CorruptImageError,"UnableToReadImageData"); j=pixels[0]; k=pixels[1]; range=GetQuantumRange(5UL); pixel.red=(MagickRealType) ScaleAnyToQuantum(1UL*(k & 0x7c) >> 2, range); pixel.green=(MagickRealType) ScaleAnyToQuantum((1UL* (k & 0x03) << 3)+(1UL*(j & 0xe0) >> 5),range); pixel.blue=(MagickRealType) ScaleAnyToQuantum(1UL*(j & 0x1f),range); if (image->alpha_trait != UndefinedPixelTrait) pixel.alpha=(MagickRealType) ((k & 0x80) == 0 ? (Quantum) TransparentAlpha : (Quantum) OpaqueAlpha); if (image->storage_class == PseudoClass) index=(Quantum) ConstrainColormapIndex(image,((ssize_t) (k << 8))+ j,exception); break; } case 24: { /* BGR pixels. */ if (ReadBlob(image,3,pixels) != 3) ThrowReaderException(CorruptImageError,"UnableToReadImageData"); pixel.blue=(MagickRealType) ScaleCharToQuantum(pixels[0]); pixel.green=(MagickRealType) ScaleCharToQuantum(pixels[1]); pixel.red=(MagickRealType) ScaleCharToQuantum(pixels[2]); break; } case 32: { /* BGRA pixels. */ if (ReadBlob(image,4,pixels) != 4) ThrowReaderException(CorruptImageError,"UnableToReadImageData"); pixel.blue=(MagickRealType) ScaleCharToQuantum(pixels[0]); pixel.green=(MagickRealType) ScaleCharToQuantum(pixels[1]); pixel.red=(MagickRealType) ScaleCharToQuantum(pixels[2]); pixel.alpha=(MagickRealType) ScaleCharToQuantum(pixels[3]); break; } } if (status == MagickFalse) ThrowReaderException(CorruptImageError,"UnableToReadImageData"); if (image->storage_class == PseudoClass) SetPixelIndex(image,index,q); SetPixelRed(image,ClampToQuantum(pixel.red),q); SetPixelGreen(image,ClampToQuantum(pixel.green),q); SetPixelBlue(image,ClampToQuantum(pixel.blue),q); if (image->alpha_trait != UndefinedPixelTrait) SetPixelAlpha(image,ClampToQuantum(pixel.alpha),q); q+=GetPixelChannels(image); } /* if (((unsigned char) (tga_info.attributes & 0xc0) >> 6) == 4) offset+=4; else */ if (((unsigned char) (tga_info.attributes & 0xc0) >> 6) == 2) offset+=2; else offset++; if (offset >= image->rows) { base++; offset=base; } if (SyncAuthenticPixels(image,exception) == MagickFalse) break; if (image->previous == (Image *) NULL) { status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, image->rows); if (status == MagickFalse) break; } } if (EOFBlob(image) != MagickFalse) ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", image->filename); (void) CloseBlob(image); return(GetFirstImageInList(image)); }
0
353,196
static int getSat(int r, int g, int b) { int rgbMin, rgbMax; rgbMin = rgbMax = r; if (g < rgbMin) { rgbMin = g; } else if (g > rgbMax) { rgbMax = g; } if (b < rgbMin) { rgbMin = b; } else if (b > rgbMax) { rgbMax = b; } return rgbMax - rgbMin; }
0
353,142
void SplashOutputDev::updateOverprintMode(GfxState *state) { splash->setOverprintMode(state->getOverprintMode()); }
0
301,485
add_banned( suginfo_T *su, char_u *word) { char_u *s; hash_T hash; hashitem_T *hi; hash = hash_hash(word); hi = hash_lookup(&su->su_banned, word, hash); if (HASHITEM_EMPTY(hi)) { s = vim_strsave(word); if (s != NULL) hash_add_item(&su->su_banned, hi, s, hash); } }
0
359,512
DEFUN (neighbor_peer_group, neighbor_peer_group_cmd, "neighbor WORD peer-group", NEIGHBOR_STR "Neighbor tag\n" "Configure peer-group\n") { struct bgp *bgp; struct peer_group *group; bgp = vty->index; group = peer_group_get (bgp, argv[0]); if (! group) return CMD_WARNING; return CMD_SUCCESS; }
0
223,458
static void delayed_mem_copy_init(delayed_mem_copy_status *status, compiler_common *common) { int i; for (i = 0; i < RECURSE_TMP_REG_COUNT; i++) { SLJIT_ASSERT(status->tmp_regs[i] >= 0); SLJIT_ASSERT(sljit_get_register_index(status->saved_tmp_regs[i]) < 0 || status->tmp_regs[i] == status->saved_tmp_regs[i]); status->store_bases[i] = -1; } status->next_tmp_reg = 0; status->compiler = common->compiler; }
0
512,926
String *val_str(String *to) { return has_value() ? Datetime(this).to_string(to, decimals) : NULL; }
0
255,082
ompl::geometric::VFRRT::Motion *ompl::geometric::VFRRT::extendTree(Motion *m, base::State *rstate, const Eigen::VectorXd &v) { base::State *newState = si_->allocState(); si_->copyState(newState, m->state); double d = si_->distance(m->state, rstate); if (d > maxDistance_) d = maxDistance_; const base::StateSpacePtr &space = si_->getStateSpace(); for (unsigned int i = 0; i < vfdim_; i++) *space->getValueAddressAtIndex(newState, i) += d * v[i]; if (!v.hasNaN() && si_->checkMotion(m->state, newState)) { auto *motion = new Motion(); motion->state = newState; motion->parent = m; updateExplorationEfficiency(motion); nn_->add(motion); return motion; } else { si_->freeState(newState); inefficientCount_++; return nullptr; } }
0
401,598
u64 get_random_u64(void) { u64 ret; unsigned long flags; struct batched_entropy *batch; static void *previous; warn_unseeded_randomness(&previous); batch = raw_cpu_ptr(&batched_entropy_u64); spin_lock_irqsave(&batch->batch_lock, flags); if (batch->position % ARRAY_SIZE(batch->entropy_u64) == 0) { extract_crng((u8 *)batch->entropy_u64); batch->position = 0; } ret = batch->entropy_u64[batch->position++]; spin_unlock_irqrestore(&batch->batch_lock, flags); return ret; }
0
336,550
bool reds_handle_migrate_data(RedsState *reds, MainChannelClient *mcc, SpiceMigrateDataMain *mig_data, uint32_t size) { RedCharDeviceVDIPort *agent_dev = reds->agent_dev.get(); spice_debug("main-channel: got migrate data"); /* * Now that the client has switched to the target server, if main_channel * controls the mm-time, we update the client's mm-time. * (MSG_MAIN_INIT is not sent for a migrating connection) */ if (reds->mm_time_enabled) { reds_send_mm_time(reds); } if (mig_data->agent_base.connected) { if (agent_dev->priv->agent_attached) { // agent was attached before migration data has arrived if (!reds->vdagent) { spice_assert(agent_dev->priv->plug_generation > 0); reds->main_channel->push_agent_disconnected(); spice_debug("agent is no longer connected"); } else { if (agent_dev->priv->plug_generation > 1) { /* red_char_device_state_reset takes care of not making the device wait for migration data */ spice_debug("agent has been detached and reattached before receiving migration data"); reds->main_channel->push_agent_disconnected(); reds->main_channel->push_agent_connected(); } else { spice_debug("restoring state from mig_data"); return reds_agent_state_restore(reds, mig_data); } } } else { /* restore agent state when the agent gets attached */ spice_debug("saving mig_data"); spice_assert(agent_dev->priv->plug_generation == 0); agent_dev->priv->mig_data = (SpiceMigrateDataMain*) g_memdup(mig_data, size); } } else { spice_debug("agent was not attached on the source host"); if (reds->vdagent) { RedCharDeviceClientOpaque *client_opaque = (RedCharDeviceClientOpaque *) mcc->get_client(); /* red_char_device_client_remove disables waiting for migration data */ agent_dev->client_remove(client_opaque); reds->main_channel->push_agent_connected(); } } return TRUE; }
0
247,366
char * pgpArmorWrap(int atype, const unsigned char * s, size_t ns) { char *buf = NULL, *val = NULL; char *enc = rpmBase64Encode(s, ns, -1); char *crc = rpmBase64CRC(s, ns); const char *valstr = pgpValStr(pgpArmorTbl, atype); if (crc != NULL && enc != NULL) { rasprintf(&buf, "%s=%s", enc, crc); } free(crc); free(enc); rasprintf(&val, "-----BEGIN PGP %s-----\nVersion: rpm-" VERSION " (NSS-3)\n\n" "%s\n-----END PGP %s-----\n", valstr, buf != NULL ? buf : "", valstr); free(buf); return val; }
0
384,917
f_writefile(typval_T *argvars, typval_T *rettv) { int binary = FALSE; int append = FALSE; #ifdef HAVE_FSYNC int do_fsync = p_fs; #endif char_u *fname; FILE *fd; int ret = 0; listitem_T *li; list_T *list = NULL; blob_T *blob = NULL; rettv->vval.v_number = -1; if (check_secure()) return; if (in_vim9script() && (check_for_list_or_blob_arg(argvars, 0) == FAIL || check_for_string_arg(argvars, 1) == FAIL || check_for_opt_string_arg(argvars, 2) == FAIL)) return; if (argvars[0].v_type == VAR_LIST) { list = argvars[0].vval.v_list; if (list == NULL) return; CHECK_LIST_MATERIALIZE(list); FOR_ALL_LIST_ITEMS(list, li) if (tv_get_string_chk(&li->li_tv) == NULL) return; } else if (argvars[0].v_type == VAR_BLOB) { blob = argvars[0].vval.v_blob; if (blob == NULL) return; } else { semsg(_(e_invalid_argument_str), _("writefile() first argument must be a List or a Blob")); return; } if (argvars[2].v_type != VAR_UNKNOWN) { char_u *arg2 = tv_get_string_chk(&argvars[2]); if (arg2 == NULL) return; if (vim_strchr(arg2, 'b') != NULL) binary = TRUE; if (vim_strchr(arg2, 'a') != NULL) append = TRUE; #ifdef HAVE_FSYNC if (vim_strchr(arg2, 's') != NULL) do_fsync = TRUE; else if (vim_strchr(arg2, 'S') != NULL) do_fsync = FALSE; #endif } fname = tv_get_string_chk(&argvars[1]); if (fname == NULL) return; // Always open the file in binary mode, library functions have a mind of // their own about CR-LF conversion. if (*fname == NUL || (fd = mch_fopen((char *)fname, append ? APPENDBIN : WRITEBIN)) == NULL) { semsg(_(e_cant_create_file_str), *fname == NUL ? (char_u *)_("<empty>") : fname); ret = -1; } else if (blob) { if (write_blob(fd, blob) == FAIL) ret = -1; #ifdef HAVE_FSYNC else if (do_fsync) // Ignore the error, the user wouldn't know what to do about it. // May happen for a device. vim_ignored = vim_fsync(fileno(fd)); #endif fclose(fd); } else { if (write_list(fd, list, binary) == FAIL) ret = -1; #ifdef HAVE_FSYNC else if (do_fsync) // Ignore the error, the user wouldn't know what to do about it. // May happen for a device. vim_ignored = vim_fsync(fileno(fd)); #endif fclose(fd); } rettv->vval.v_number = ret; }
0
226,137
GF_Err sgpd_box_read(GF_Box *s, GF_BitStream *bs) { u32 entry_count; GF_SampleGroupDescriptionBox *p = (GF_SampleGroupDescriptionBox *)s; ISOM_DECREASE_SIZE(p, 8); p->grouping_type = gf_bs_read_u32(bs); if (p->version>=1) { ISOM_DECREASE_SIZE(p, 4); p->default_length = gf_bs_read_u32(bs); } if (p->version>=2) { ISOM_DECREASE_SIZE(p, 4); p->default_description_index = gf_bs_read_u32(bs); } entry_count = gf_bs_read_u32(bs); if (entry_count>p->size) return GF_ISOM_INVALID_FILE; while (entry_count) { void *ptr; u32 parsed_bytes=0; u32 size = p->default_length; if ((p->version>=1) && !size) { size = gf_bs_read_u32(bs); ISOM_DECREASE_SIZE(p, 4); } ptr = sgpd_parse_entry(p->grouping_type, bs, (s32) p->size, size, &parsed_bytes); //don't return an error, just stop parsing so that we skip over the sgpd box if (!ptr) return GF_OK; gf_list_add(p->group_descriptions, ptr); ISOM_DECREASE_SIZE(p, parsed_bytes); entry_count--; } return GF_OK;
0
230,272
njs_array_prototype_iterator(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, njs_index_t magic) { int64_t i, length; njs_int_t ret; njs_array_t *array; njs_value_t accumulator; njs_iterator_args_t iargs; njs_iterator_handler_t handler; iargs.value = njs_argument(args, 0); ret = njs_value_to_object(vm, iargs.value); if (njs_slow_path(ret != NJS_OK)) { return ret; } ret = njs_value_length(vm, iargs.value, &iargs.to); if (njs_slow_path(ret != NJS_OK)) { return ret; } iargs.from = 0; if (njs_array_arg1(magic) == NJS_ARRAY_FUNC) { if (njs_slow_path(!njs_is_function(njs_arg(args, nargs, 1)))) { njs_type_error(vm, "callback argument is not callable"); return NJS_ERROR; } iargs.function = njs_function(njs_argument(args, 1)); iargs.argument = njs_arg(args, nargs, 2); } else { iargs.argument = njs_arg(args, nargs, 1); } switch (njs_array_type(magic)) { case NJS_ARRAY_EVERY: handler = njs_array_handler_every; break; case NJS_ARRAY_SOME: handler = njs_array_handler_some; break; case NJS_ARRAY_INCLUDES: case NJS_ARRAY_INDEX_OF: switch (njs_array_type(magic)) { case NJS_ARRAY_INCLUDES: handler = njs_array_handler_includes; if (iargs.to == 0) { goto done; } break; default: handler = njs_array_handler_index_of; } ret = njs_value_to_integer(vm, njs_arg(args, nargs, 2), &iargs.from); if (njs_slow_path(ret != NJS_OK)) { return ret; } if (iargs.from < 0) { iargs.from += iargs.to; if (iargs.from < 0) { iargs.from = 0; } } break; case NJS_ARRAY_FOR_EACH: handler = njs_array_handler_for_each; break; case NJS_ARRAY_FIND: handler = njs_array_handler_find; break; case NJS_ARRAY_FIND_INDEX: handler = njs_array_handler_find_index; break; case NJS_ARRAY_REDUCE: handler = njs_array_handler_reduce; njs_set_invalid(&accumulator); if (nargs > 2) { accumulator = *iargs.argument; } iargs.argument = &accumulator; break; case NJS_ARRAY_FILTER: case NJS_ARRAY_MAP: default: if (njs_array_type(magic) == NJS_ARRAY_FILTER) { length = 0; handler = njs_array_handler_filter; } else { length = iargs.to; handler = njs_array_handler_map; } array = njs_array_alloc(vm, 0, length, NJS_ARRAY_SPARE); if (njs_slow_path(array == NULL)) { return NJS_ERROR; } if (array->object.fast_array) { for (i = 0; i < length; i++) { njs_set_invalid(&array->start[i]); } } iargs.data = array; break; } ret = njs_object_iterate(vm, &iargs, handler); if (njs_slow_path(ret == NJS_ERROR)) { return ret; } if (ret == NJS_DONE) { return NJS_OK; } done: /* Default values. */ switch (njs_array_type(magic)) { case NJS_ARRAY_EVERY: vm->retval = njs_value_true; break; case NJS_ARRAY_SOME: case NJS_ARRAY_INCLUDES: vm->retval = njs_value_false; break; case NJS_ARRAY_INDEX_OF: case NJS_ARRAY_FIND_INDEX: njs_set_number(&vm->retval, -1); break; case NJS_ARRAY_FOR_EACH: case NJS_ARRAY_FIND: njs_set_undefined(&vm->retval); break; case NJS_ARRAY_REDUCE: if (!njs_is_valid(&accumulator)) { njs_type_error(vm, "Reduce of empty object with no initial value"); return NJS_ERROR; } vm->retval = accumulator; break; case NJS_ARRAY_FILTER: case NJS_ARRAY_MAP: default: njs_set_array(&vm->retval, iargs.data); } return NJS_OK; }
0
409,502
term_delete_lines(int line_count) { OUT_STR(tgoto((char *)T_CDL, 0, line_count)); }
0
382,796
static void gdFreeDynamicCtx (struct gdIOCtx *ctx) { dynamicPtr *dp; dpIOCtx *dctx; dctx = (dpIOCtx *) ctx; dp = dctx->dp; gdFree(ctx); dp->realSize = 0; dp->logicalSize = 0; gdFree(dp); }
0
279,912
not_writing(void) { if (p_write) return FALSE; emsg(_(e_file_not_written_writing_is_disabled_by_write_option)); return TRUE; }
0
439,172
static inline double GetFITSPixel(Image *image,int bits_per_pixel) { switch (image->depth >> 3) { case 1: return((double) ReadBlobByte(image)); case 2: return((double) ((short) ReadBlobShort(image))); case 4: { if (bits_per_pixel > 0) return((double) ReadBlobSignedLong(image)); return((double) ReadBlobFloat(image)); } case 8: { if (bits_per_pixel > 0) return((double) ((MagickOffsetType) ReadBlobLongLong(image))); } default: break; } return(ReadBlobDouble(image)); }
0
223,094
static MagickBooleanType IsPCL(const unsigned char *magick,const size_t length) { if (length < 4) return(MagickFalse); if (memcmp(magick,"\033E\033&",4) == 0) return(MagickFalse); if (memcmp(magick,"\033E\033",3) == 0) return(MagickTrue); return(MagickFalse); }
0
220,171
void Compute(OpKernelContext* context) override { const Tensor& contents = context->input(0); OP_REQUIRES( context, TensorShapeUtils::IsScalar(contents.shape()), errors::InvalidArgument("`contents` must be scalar but got shape", contents.shape().DebugString())); const StringPiece input = contents.scalar<tstring>()(); OP_REQUIRES(context, !input.empty(), errors::InvalidArgument("Input is empty.")); OP_REQUIRES(context, input.size() <= std::numeric_limits<int>::max(), errors::InvalidArgument( "Input contents are too large for int: ", input.size())); // Parse magic bytes to determine file format. switch (ClassifyFileFormat(input)) { case kJpgFormat: DecodeJpegV2(context, input); break; case kPngFormat: DecodePngV2(context, input); break; case kGifFormat: DecodeGifV2(context, input); break; case kBmpFormat: DecodeBmpV2(context, input); break; case kUnknownFormat: OP_REQUIRES(context, false, errors::InvalidArgument("Unknown image file format. One of " "JPEG, PNG, GIF, BMP required.")); break; } }
0
508,384
lock_table_names(THD *thd, const DDL_options_st &options, TABLE_LIST *tables_start, TABLE_LIST *tables_end, ulong lock_wait_timeout, uint flags) { MDL_request_list mdl_requests; TABLE_LIST *table; MDL_request global_request; ulong org_lock_wait_timeout= lock_wait_timeout; /* Check if we are using CREATE TABLE ... IF NOT EXISTS */ bool create_table; Dummy_error_handler error_handler; DBUG_ENTER("lock_table_names"); DBUG_ASSERT(!thd->locked_tables_mode); for (table= tables_start; table && table != tables_end; table= table->next_global) { if (table->mdl_request.type < MDL_SHARED_UPGRADABLE || table->mdl_request.type == MDL_SHARED_READ_ONLY || table->open_type == OT_TEMPORARY_ONLY || (table->open_type == OT_TEMPORARY_OR_BASE && is_temporary_table(table))) { continue; } /* Write lock on normal tables is not allowed in a read only transaction. */ if (thd->tx_read_only) { my_error(ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION, MYF(0)); DBUG_RETURN(true); } /* Scoped locks: Take intention exclusive locks on all involved schemas. */ if (!(flags & MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK)) { MDL_request *schema_request= new (thd->mem_root) MDL_request; if (schema_request == NULL) DBUG_RETURN(TRUE); schema_request->init(MDL_key::SCHEMA, table->db, "", MDL_INTENTION_EXCLUSIVE, MDL_TRANSACTION); mdl_requests.push_front(schema_request); } mdl_requests.push_front(&table->mdl_request); } if (mdl_requests.is_empty()) DBUG_RETURN(FALSE); /* Check if CREATE TABLE without REPLACE was used */ create_table= thd->lex->sql_command == SQLCOM_CREATE_TABLE && !options.or_replace(); if (!(flags & MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK)) { /* Protect this statement against concurrent global read lock by acquiring global intention exclusive lock with statement duration. */ if (thd->global_read_lock.can_acquire_protection()) DBUG_RETURN(TRUE); global_request.init(MDL_key::GLOBAL, "", "", MDL_INTENTION_EXCLUSIVE, MDL_STATEMENT); mdl_requests.push_front(&global_request); if (create_table) #ifdef WITH_WSREP if (!(thd->lex->sql_command == SQLCOM_CREATE_TABLE && thd->wsrep_exec_mode == REPL_RECV)) #endif lock_wait_timeout= 0; // Don't wait for timeout } for (;;) { if (create_table) thd->push_internal_handler(&error_handler); // Avoid warnings & errors bool res= thd->mdl_context.acquire_locks(&mdl_requests, lock_wait_timeout); if (create_table) thd->pop_internal_handler(); if (!res) DBUG_RETURN(FALSE); // Got locks if (!create_table) DBUG_RETURN(TRUE); // Return original error /* We come here in the case of lock timeout when executing CREATE TABLE. Verify that table does exist (it usually does, as we got a lock conflict) */ if (ha_table_exists(thd, tables_start->db, tables_start->table_name)) { if (options.if_not_exists()) { push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, ER_TABLE_EXISTS_ERROR, ER_THD(thd, ER_TABLE_EXISTS_ERROR), tables_start->table_name); } else my_error(ER_TABLE_EXISTS_ERROR, MYF(0), tables_start->table_name); DBUG_RETURN(TRUE); } /* We got error from acquire_locks, but the table didn't exists. This could happen if another connection runs a statement involving this non-existent table, and this statement took the mdl, but didn't error out with ER_NO_SUCH_TABLE yet (yes, a race condition). We play safe and restart the original acquire_locks with the original timeout. */ create_table= 0; lock_wait_timeout= org_lock_wait_timeout; } }
0
409,450
handle_csi( char_u *tp, int len, char_u *argp, int offset, char_u *buf, int bufsize, int *buflen, char_u *key_name, int *slen) { int first = -1; // optional char right after {lead} int trail; // char that ends CSI sequence int arg[3] = {-1, -1, -1}; // argument numbers int argc; // number of arguments char_u *ap = argp; int csi_len; // Check for non-digit after CSI. if (!VIM_ISDIGIT(*ap)) first = *ap++; // Find up to three argument numbers. for (argc = 0; argc < 3; ) { if (ap >= tp + len) return -1; if (*ap == ';') arg[argc++] = -1; // omitted number else if (VIM_ISDIGIT(*ap)) { arg[argc] = 0; for (;;) { if (ap >= tp + len) return -1; if (!VIM_ISDIGIT(*ap)) break; arg[argc] = arg[argc] * 10 + (*ap - '0'); ++ap; } ++argc; } if (*ap == ';') ++ap; else break; } // mrxvt has been reported to have "+" in the version. Assume // the escape sequence ends with a letter or one of "{|}~". while (ap < tp + len && !(*ap >= '{' && *ap <= '~') && !ASCII_ISALPHA(*ap)) ++ap; if (ap >= tp + len) return -1; trail = *ap; csi_len = (int)(ap - tp) + 1; // Cursor position report: Eat it when there are 2 arguments // and it ends in 'R'. Also when u7_status is not "sent", it // may be from a previous Vim that just exited. But not for // <S-F3>, it sends something similar, check for row and column // to make sense. if (first == -1 && argc == 2 && trail == 'R') { handle_u7_response(arg, tp, csi_len); key_name[0] = (int)KS_EXTRA; key_name[1] = (int)KE_IGNORE; *slen = csi_len; } // Version string: Eat it when there is at least one digit and // it ends in 'c' else if (*T_CRV != NUL && ap > argp + 1 && trail == 'c') { handle_version_response(first, arg, argc, tp); *slen = csi_len; # ifdef FEAT_EVAL set_vim_var_string(VV_TERMRESPONSE, tp, *slen); # endif apply_autocmds(EVENT_TERMRESPONSE, NULL, NULL, FALSE, curbuf); key_name[0] = (int)KS_EXTRA; key_name[1] = (int)KE_IGNORE; } // Check blinking cursor from xterm: // {lead}?12;1$y set // {lead}?12;2$y not set // // {lead} can be <Esc>[ or CSI else if (rbm_status.tr_progress == STATUS_SENT && first == '?' && ap == argp + 6 && arg[0] == 12 && ap[-1] == '$' && trail == 'y') { initial_cursor_blink = (arg[1] == '1'); rbm_status.tr_progress = STATUS_GOT; LOG_TR(("Received cursor blinking mode response: %s", tp)); key_name[0] = (int)KS_EXTRA; key_name[1] = (int)KE_IGNORE; *slen = csi_len; # ifdef FEAT_EVAL set_vim_var_string(VV_TERMBLINKRESP, tp, *slen); # endif } // Check for a window position response from the terminal: // {lead}3;{x};{y}t else if (did_request_winpos && argc == 3 && arg[0] == 3 && trail == 't') { winpos_x = arg[1]; winpos_y = arg[2]; // got finished code: consume it key_name[0] = (int)KS_EXTRA; key_name[1] = (int)KE_IGNORE; *slen = csi_len; if (--did_request_winpos <= 0) winpos_status.tr_progress = STATUS_GOT; } // Key with modifier: // {lead}27;{modifier};{key}~ // {lead}{key};{modifier}u else if ((arg[0] == 27 && argc == 3 && trail == '~') || (argc == 2 && trail == 'u')) { return len + handle_key_with_modifier(arg, trail, csi_len, offset, buf, bufsize, buflen); } // else: Unknown CSI sequence. We could drop it, but then the // user can't create a map for it. return 0; }
0
346,423
ex_options( exarg_T *eap UNUSED) { char_u buf[500]; int multi_mods = 0; buf[0] = NUL; (void)add_win_cmd_modifers(buf, &cmdmod, &multi_mods); vim_setenv((char_u *)"OPTWIN_CMD", buf); cmd_source((char_u *)SYS_OPTWIN_FILE, NULL); }
0
512,319
longlong val_datetime_packed(THD *thd) { if (check_null_ref()) return 0; else return Item_direct_ref::val_datetime_packed(thd); }
0
335,420
apply_cmdmod(cmdmod_T *cmod) { #ifdef HAVE_SANDBOX if ((cmod->cmod_flags & CMOD_SANDBOX) && !cmod->cmod_did_sandbox) { ++sandbox; cmod->cmod_did_sandbox = TRUE; } #endif if (cmod->cmod_verbose != 0) { if (cmod->cmod_verbose_save == 0) cmod->cmod_verbose_save = p_verbose + 1; p_verbose = cmod->cmod_verbose < 0 ? 0 : cmod->cmod_verbose; } if ((cmod->cmod_flags & (CMOD_SILENT | CMOD_UNSILENT)) && cmod->cmod_save_msg_silent == 0) { cmod->cmod_save_msg_silent = msg_silent + 1; cmod->cmod_save_msg_scroll = msg_scroll; } if (cmod->cmod_flags & CMOD_SILENT) ++msg_silent; if (cmod->cmod_flags & CMOD_UNSILENT) msg_silent = 0; if (cmod->cmod_flags & CMOD_ERRSILENT) { ++emsg_silent; ++cmod->cmod_did_esilent; } if ((cmod->cmod_flags & CMOD_NOAUTOCMD) && cmod->cmod_save_ei == NULL) { // Set 'eventignore' to "all". // First save the existing option value for restoring it later. cmod->cmod_save_ei = vim_strsave(p_ei); set_string_option_direct((char_u *)"ei", -1, (char_u *)"all", OPT_FREE, SID_NONE); } }
0
411,917
_compare_tor_version_str_ptr(const void **_a, const void **_b) { const char *a = *_a, *b = *_b; int ca, cb; tor_version_t va, vb; ca = tor_version_parse(a, &va); cb = tor_version_parse(b, &vb); /* If they both parse, compare them. */ if (!ca && !cb) return tor_version_compare(&va,&vb); /* If one parses, it comes first. */ if (!ca && cb) return -1; if (ca && !cb) return 1; /* If neither parses, compare strings. Also, the directory server admin ** needs to be smacked upside the head. But Tor is tolerant and gentle. */ return strcmp(a,b); }
0
222,864
Status GraphProperties::UpdateMerge(SymbolicShapeRefiner* shape_refiner, const NodeDef* node, bool* new_shapes) const { InferenceContext* ic = shape_refiner->GetContext(node); if (!ic) { // Now we can run shape inference TF_RETURN_IF_ERROR(shape_refiner->AddNode(node)); ic = CHECK_NOTNULL(shape_refiner->GetContext(node)); *new_shapes = true; // Infer the shape of the second output once and for all since it never // changes. ShapeHandle out1 = ic->Scalar(); if (ic->num_outputs() >= 2) ic->set_output(1, out1); } ShapeHandle out; const std::vector<ShapeAndType>* out_handle = nullptr; bool out_initialized = false; for (const GraphView::Edge fanin : shape_refiner->graph().GetFaninEdges( *node, /*include_controlling_edges=*/false)) { InferenceContext* src_ic = shape_refiner->GetContext(fanin.src.node); if (!src_ic) { // Handling a loop for the first time, the back edge won't have any shape // info. continue; } ShapeHandle input = src_ic->output(fanin.src.port_id); ic->SetInput(fanin.dst.port_id, input); auto* input_handle = src_ic->output_handle_shapes_and_types(fanin.src.port_id); if (input_handle) ic->set_input_handle_shapes_and_types(fanin.dst.port_id, *input_handle); if (!out_initialized) { out_initialized = true; out = input; out_handle = input_handle; } else { // Note here only out, not out_handle, is modified. out = shape_refiner->OutputAsUnion(node, 0, input, out); } } if (*new_shapes || !shape_refiner->EquivalentShapes(out, ic->output(0))) { ic->set_output(0, out); if (out_handle) ic->set_output_handle_shapes_and_types(0, *out_handle); *new_shapes = true; } return Status::OK(); }
0
231,683
TEST_F( QuicServerTransportTest, MigrateToUnvalidatePeerCancelsOutstandingPathChallenge) { server->getNonConstConn().transportSettings.disableMigration = false; auto data = IOBuf::copyBuffer("bad data"); auto packetData = packetToBuf(createStreamPacket( *clientConnectionId, *server->getConn().serverConnectionId, clientNextAppDataPacketNum++, 2, *data, 0 /* cipherOverhead */, 0 /* largestAcked */)); auto peerAddress = server->getConn().peerAddress; auto congestionController = server->getConn().congestionController.get(); auto srtt = server->getConn().lossState.srtt; auto lrtt = server->getConn().lossState.lrtt; auto rttvar = server->getConn().lossState.rttvar; auto mrtt = server->getConn().lossState.mrtt; folly::SocketAddress newPeer("100.101.102.103", 23456); deliverData(std::move(packetData), true, &newPeer); EXPECT_EQ(server->getConn().peerAddress, newPeer); EXPECT_TRUE(server->getConn().outstandingPathValidation); EXPECT_TRUE(server->getConn().pendingEvents.schedulePathValidationTimeout); EXPECT_TRUE(server->pathValidationTimeout().isScheduled()); EXPECT_EQ(server->getConn().migrationState.previousPeerAddresses.size(), 1); EXPECT_EQ( server->getConn().migrationState.previousPeerAddresses.back(), peerAddress); EXPECT_EQ(server->getConn().lossState.srtt, 0us); EXPECT_EQ(server->getConn().lossState.lrtt, 0us); EXPECT_EQ(server->getConn().lossState.rttvar, 0us); EXPECT_EQ(server->getConn().lossState.mrtt, kDefaultMinRtt); EXPECT_NE(server->getConn().congestionController.get(), nullptr); EXPECT_NE(server->getConn().congestionController.get(), congestionController); EXPECT_EQ( server->getConn().migrationState.lastCongestionAndRtt->peerAddress, clientAddr); EXPECT_EQ( server->getConn() .migrationState.lastCongestionAndRtt->congestionController.get(), congestionController); EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->srtt, srtt); EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->lrtt, lrtt); EXPECT_EQ( server->getConn().migrationState.lastCongestionAndRtt->rttvar, rttvar); EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->mrtt, mrtt); auto packetData2 = packetToBuf(createStreamPacket( *clientConnectionId, *server->getConn().serverConnectionId, clientNextAppDataPacketNum++, 6, *data, 0 /* cipherOverhead */, 0 /* largestAcked */)); folly::SocketAddress newPeer2("200.101.102.103", 23456); deliverData(std::move(packetData2), false, &newPeer2); EXPECT_FALSE(server->getConn().outstandingPathValidation); EXPECT_FALSE(server->getConn().pendingEvents.schedulePathValidationTimeout); EXPECT_FALSE(server->pathValidationTimeout().isScheduled()); EXPECT_EQ(server->getConn().migrationState.previousPeerAddresses.size(), 1); EXPECT_EQ( server->getConn().migrationState.previousPeerAddresses.back(), peerAddress); EXPECT_EQ(server->getConn().lossState.srtt, 0us); EXPECT_EQ(server->getConn().lossState.lrtt, 0us); EXPECT_EQ(server->getConn().lossState.rttvar, 0us); EXPECT_EQ(server->getConn().lossState.mrtt, kDefaultMinRtt); EXPECT_NE(server->getConn().congestionController.get(), nullptr); EXPECT_NE(server->getConn().congestionController.get(), congestionController); EXPECT_EQ( server->getConn().migrationState.lastCongestionAndRtt->peerAddress, clientAddr); EXPECT_EQ( server->getConn() .migrationState.lastCongestionAndRtt->congestionController.get(), congestionController); EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->srtt, srtt); EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->lrtt, lrtt); EXPECT_EQ( server->getConn().migrationState.lastCongestionAndRtt->rttvar, rttvar); EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->mrtt, mrtt); }
0
267,919
void ogs_nas_5gs_nas_guti_to_mobility_identity_guti( ogs_nas_5gs_guti_t *nas_guti, ogs_nas_5gs_mobile_identity_guti_t *mobile_identity_guti) { ogs_assert(nas_guti); ogs_assert(mobile_identity_guti); memset(mobile_identity_guti, 0, sizeof(*mobile_identity_guti)); /* * TS24.501 * 9.11.3.4 5GS mobile identity * Figure 9.11.3.4.1 5GS mobile identity IE for type of identity "5G-GUTI" * * Octet 1 : 5GS mobile identity IEI * Octet 2-3 : Length of 5GS mobile identity contents * Octet 4 : 1 1 1 1 0 0 1 0 * * <Octet 4> * h.supi_format = 0xf (1 1 1 1) * h.odd_even = 0 (Spare 0) * h.type = x x x (Type of identity : 5G-GUTI) */ mobile_identity_guti->h.supi_format = 0xf; mobile_identity_guti->h.type = OGS_NAS_5GS_MOBILE_IDENTITY_GUTI; memcpy(&mobile_identity_guti->nas_plmn_id, &nas_guti->nas_plmn_id, OGS_PLMN_ID_LEN); memcpy(&mobile_identity_guti->amf_id, &nas_guti->amf_id, sizeof(ogs_amf_id_t)); mobile_identity_guti->m_tmsi = htobe32(nas_guti->m_tmsi); }
0
289,334
static int lock_params(struct snd_pcm_runtime *runtime) { if (mutex_lock_interruptible(&runtime->oss.params_lock)) return -ERESTARTSYS; if (atomic_read(&runtime->oss.rw_ref)) { mutex_unlock(&runtime->oss.params_lock); return -EBUSY; } return 0; }
0
505,646
bool smtp_command_parser_pending_data(struct smtp_command_parser *parser) { if (parser->data == NULL) return FALSE; return i_stream_have_bytes_left(parser->data); }
0
244,193
GF_Err trun_box_read(GF_Box *s, GF_BitStream *bs) { u32 i; GF_TrackFragmentRunBox *ptr = (GF_TrackFragmentRunBox *)s; #ifdef GF_ENABLE_CTRN if (ptr->type == GF_ISOM_BOX_TYPE_CTRN) { ptr->type = GF_ISOM_BOX_TYPE_TRUN; ptr->use_ctrn = GF_TRUE; return ctrn_box_read(s, bs); } #endif //check this is a good file if ((ptr->flags & GF_ISOM_TRUN_FIRST_FLAG) && (ptr->flags & GF_ISOM_TRUN_FLAGS)) return GF_ISOM_INVALID_FILE; ISOM_DECREASE_SIZE(ptr, 4); ptr->sample_count = gf_bs_read_u32(bs); //The rest depends on the flags if (ptr->flags & GF_ISOM_TRUN_DATA_OFFSET) { ISOM_DECREASE_SIZE(ptr, 4); ptr->data_offset = gf_bs_read_u32(bs); } if (ptr->flags & GF_ISOM_TRUN_FIRST_FLAG) { ISOM_DECREASE_SIZE(ptr, 4); ptr->first_sample_flags = gf_bs_read_u32(bs); } if (! (ptr->flags & (GF_ISOM_TRUN_DURATION | GF_ISOM_TRUN_SIZE | GF_ISOM_TRUN_FLAGS | GF_ISOM_TRUN_CTS_OFFSET) ) ) { ptr->samples = gf_malloc(sizeof(GF_TrunEntry)); if (!ptr->samples) return GF_OUT_OF_MEM; //memset to 0 !! memset(ptr->samples, 0, sizeof(GF_TrunEntry)); ptr->sample_alloc = ptr->nb_samples = 1; ptr->samples[0].nb_pack = ptr->sample_count; } else { //if we get here, at least one flag (so at least 4 bytes) is set, check size if (ptr->sample_count * 4 > ptr->size) { ISOM_DECREASE_SIZE(ptr, ptr->sample_count*4); } if ((u64)ptr->sample_count > (u64)SIZE_MAX/sizeof(GF_TrunEntry)) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Invalid number of samples %d in trun\n", ptr->sample_count)); return GF_ISOM_INVALID_FILE; } ptr->samples = gf_malloc(sizeof(GF_TrunEntry) * ptr->sample_count); if (!ptr->samples) return GF_OUT_OF_MEM; ptr->sample_alloc = ptr->nb_samples = ptr->sample_count; //memset to 0 upfront memset(ptr->samples, 0, ptr->sample_count * sizeof(GF_TrunEntry)); //read each entry (even though nothing may be written) for (i=0; i<ptr->sample_count; i++) { u32 trun_size = 0; GF_TrunEntry *p = &ptr->samples[i]; if (ptr->flags & GF_ISOM_TRUN_DURATION) { p->Duration = gf_bs_read_u32(bs); trun_size += 4; } if (ptr->flags & GF_ISOM_TRUN_SIZE) { p->size = gf_bs_read_u32(bs); trun_size += 4; } //SHOULDN'T BE USED IF GF_ISOM_TRUN_FIRST_FLAG IS DEFINED if (ptr->flags & GF_ISOM_TRUN_FLAGS) { p->flags = gf_bs_read_u32(bs); trun_size += 4; } if (ptr->flags & GF_ISOM_TRUN_CTS_OFFSET) { if (ptr->version==0) { p->CTS_Offset = (u32) gf_bs_read_u32(bs); } else { p->CTS_Offset = (s32) gf_bs_read_u32(bs); } trun_size += 4; } ISOM_DECREASE_SIZE(ptr, trun_size); } } /*todo parse sample reorder*/ if (ptr->size) { gf_bs_skip_bytes(bs, ptr->size); ptr->size = 0; } return GF_OK; }
0
289,313
snd_pcm_hw_param_value_max(const struct snd_pcm_hw_params *params, snd_pcm_hw_param_t var, int *dir) { if (hw_is_mask(var)) { if (dir) *dir = 0; return snd_mask_max(hw_param_mask_c(params, var)); } if (hw_is_interval(var)) { const struct snd_interval *i = hw_param_interval_c(params, var); if (dir) *dir = - (int) i->openmax; return snd_interval_max(i); } return -EINVAL; }
0
488,430
static int do_move_pages(struct mm_struct *mm, struct page_to_node *pm, int migrate_all) { int err; struct page_to_node *pp; LIST_HEAD(pagelist); down_read(&mm->mmap_sem); /* * Build a list of pages to migrate */ migrate_prep(); for (pp = pm; pp->node != MAX_NUMNODES; pp++) { struct vm_area_struct *vma; struct page *page; /* * A valid page pointer that will not match any of the * pages that will be moved. */ pp->page = ZERO_PAGE(0); err = -EFAULT; vma = find_vma(mm, pp->addr); if (!vma || !vma_migratable(vma)) goto set_status; page = follow_page(vma, pp->addr, FOLL_GET); err = PTR_ERR(page); if (IS_ERR(page)) goto set_status; err = -ENOENT; if (!page) goto set_status; if (PageReserved(page)) /* Check for zero page */ goto put_and_set; pp->page = page; err = page_to_nid(page); if (err == pp->node) /* * Node already in the right place */ goto put_and_set; err = -EACCES; if (page_mapcount(page) > 1 && !migrate_all) goto put_and_set; err = isolate_lru_page(page, &pagelist); put_and_set: /* * Either remove the duplicate refcount from * isolate_lru_page() or drop the page ref if it was * not isolated. */ put_page(page); set_status: pp->status = err; } if (!list_empty(&pagelist)) err = migrate_pages(&pagelist, new_page_node, (unsigned long)pm); else err = -ENOENT; up_read(&mm->mmap_sem); return err; }
0
379,685
static const char *get_regname(RAnal *anal, RAnalValue *value) { const char *name = NULL; if (value && value->reg && value->reg->name) { name = value->reg->name; RRegItem *ri = r_reg_get (anal->reg, value->reg->name, -1); if (ri && (ri->size == 32) && (anal->bits == 64)) { name = r_reg_32_to_64 (anal->reg, value->reg->name); } } return name; }
0
406,208
static void success_message(struct libmnt_context *cxt) { unsigned long mflags = 0; const char *tgt, *src; if (mnt_context_helper_executed(cxt) || mnt_context_get_status(cxt) != 1) return; mnt_context_get_mflags(cxt, &mflags); tgt = mnt_context_get_target(cxt); src = mnt_context_get_source(cxt); if (mflags & MS_MOVE) warnx(_("%s moved to %s"), src, tgt); else if (mflags & MS_BIND) warnx(_("%s binded on %s"), src, tgt); else if (mflags & MS_PROPAGATION) warnx(_("%s propagation flags changed"), tgt); else warnx(_("%s mounted on %s"), src, tgt); }
0
96,951
void encode(ArgumentEncoder* encoder, CFTypeRef typeRef) { CFType type = typeFromCFTypeRef(typeRef); encoder->encodeEnum(type); switch (type) { case CFArray: encode(encoder, static_cast<CFArrayRef>(typeRef)); return; case CFBoolean: encode(encoder, static_cast<CFBooleanRef>(typeRef)); return; case CFData: encode(encoder, static_cast<CFDataRef>(typeRef)); return; case CFDate: encode(encoder, static_cast<CFDateRef>(typeRef)); return; case CFDictionary: encode(encoder, static_cast<CFDictionaryRef>(typeRef)); return; case CFNull: return; case CFNumber: encode(encoder, static_cast<CFNumberRef>(typeRef)); return; case CFString: encode(encoder, static_cast<CFStringRef>(typeRef)); return; case CFURL: encode(encoder, static_cast<CFURLRef>(typeRef)); return; #if PLATFORM(MAC) case SecCertificate: encode(encoder, (SecCertificateRef)typeRef); return; case SecKeychainItem: encode(encoder, (SecKeychainItemRef)typeRef); return; #endif case Null: return; case Unknown: break; } ASSERT_NOT_REACHED(); }
0
261,248
int wm_SemFree(wm_Sem *s) { vSemaphoreDelete(*s); *s = NULL; return 0; }
0
234,864
static void reset_balance_state(struct btrfs_fs_info *fs_info) { struct btrfs_balance_control *bctl = fs_info->balance_ctl; int ret; BUG_ON(!fs_info->balance_ctl); spin_lock(&fs_info->balance_lock); fs_info->balance_ctl = NULL; spin_unlock(&fs_info->balance_lock); kfree(bctl); ret = del_balance_item(fs_info); if (ret) btrfs_handle_fs_error(fs_info, ret, NULL); }
0
473,846
onigenc_utf16_32_get_ctype_code_range(OnigCtype ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[], struct OnigEncodingTypeST* enc ARG_UNUSED) { *sb_out = 0x00; return onigenc_unicode_ctype_code_range(ctype, ranges); }
0
385,940
static int atomic_open(struct nameidata *nd, struct dentry *dentry, struct path *path, struct file *file, const struct open_flags *op, bool got_write, bool need_lookup, int *opened) { struct inode *dir = nd->path.dentry->d_inode; unsigned open_flag = open_to_namei_flags(op->open_flag); umode_t mode; int error; int acc_mode; int create_error = 0; struct dentry *const DENTRY_NOT_SET = (void *) -1UL; BUG_ON(dentry->d_inode); /* Don't create child dentry for a dead directory. */ if (unlikely(IS_DEADDIR(dir))) { error = -ENOENT; goto out; } mode = op->mode; if ((open_flag & O_CREAT) && !IS_POSIXACL(dir)) mode &= ~current_umask(); if ((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT)) { open_flag &= ~O_TRUNC; *opened |= FILE_CREATED; } /* * Checking write permission is tricky, bacuse we don't know if we are * going to actually need it: O_CREAT opens should work as long as the * file exists. But checking existence breaks atomicity. The trick is * to check access and if not granted clear O_CREAT from the flags. * * Another problem is returing the "right" error value (e.g. for an * O_EXCL open we want to return EEXIST not EROFS). */ if (((open_flag & (O_CREAT | O_TRUNC)) || (open_flag & O_ACCMODE) != O_RDONLY) && unlikely(!got_write)) { if (!(open_flag & O_CREAT)) { /* * No O_CREATE -> atomicity not a requirement -> fall * back to lookup + open */ goto no_open; } else if (open_flag & (O_EXCL | O_TRUNC)) { /* Fall back and fail with the right error */ create_error = -EROFS; goto no_open; } else { /* No side effects, safe to clear O_CREAT */ create_error = -EROFS; open_flag &= ~O_CREAT; } } if (open_flag & O_CREAT) { error = may_o_create(&nd->path, dentry, mode); if (error) { create_error = error; if (open_flag & O_EXCL) goto no_open; open_flag &= ~O_CREAT; } } if (nd->flags & LOOKUP_DIRECTORY) open_flag |= O_DIRECTORY; file->f_path.dentry = DENTRY_NOT_SET; file->f_path.mnt = nd->path.mnt; error = dir->i_op->atomic_open(dir, dentry, file, open_flag, mode, opened); if (error < 0) { if (create_error && error == -ENOENT) error = create_error; goto out; } acc_mode = op->acc_mode; if (*opened & FILE_CREATED) { fsnotify_create(dir, dentry); acc_mode = MAY_OPEN; } if (error) { /* returned 1, that is */ if (WARN_ON(file->f_path.dentry == DENTRY_NOT_SET)) { error = -EIO; goto out; } if (file->f_path.dentry) { dput(dentry); dentry = file->f_path.dentry; } if (create_error && dentry->d_inode == NULL) { error = create_error; goto out; } goto looked_up; } /* * We didn't have the inode before the open, so check open permission * here. */ error = may_open(&file->f_path, acc_mode, open_flag); if (error) fput(file); out: dput(dentry); return error; no_open: if (need_lookup) { dentry = lookup_real(dir, dentry, nd->flags); if (IS_ERR(dentry)) return PTR_ERR(dentry); if (create_error) { int open_flag = op->open_flag; error = create_error; if ((open_flag & O_EXCL)) { if (!dentry->d_inode) goto out; } else if (!dentry->d_inode) { goto out; } else if ((open_flag & O_TRUNC) && S_ISREG(dentry->d_inode->i_mode)) { goto out; } /* will fail later, go on to get the right error */ } } looked_up: path->dentry = dentry; path->mnt = nd->path.mnt; return 1; }
0
293,776
static bool on_rebase_pointer(ut64 offset, ut64 decorated_addr, RRebaseCtx *ctx) { if (offset < ctx->off) { return true; } if (offset >= ctx->eob) { return false; } ut64 in_buf = offset - ctx->off; if (in_buf >= ctx->count || (in_buf + 8) > ctx->count) { return false; } RParsedPointer ptr; r_parse_pointer (&ptr, decorated_addr, ctx->obj); r_write_le64 (&ctx->buf[in_buf], ptr.address); return true; }
0
226,204
void leva_box_del(GF_Box *s) { GF_LevelAssignmentBox *ptr = (GF_LevelAssignmentBox *)s; if (ptr == NULL) return; if (ptr->levels) gf_free(ptr->levels); gf_free(ptr);
0
384,837
transchar_buf(buf_T *buf, int c) { int i; i = 0; if (IS_SPECIAL(c)) // special key code, display as ~@ char { transchar_charbuf[0] = '~'; transchar_charbuf[1] = '@'; i = 2; c = K_SECOND(c); } if ((!chartab_initialized && ((c >= ' ' && c <= '~'))) || (c < 256 && vim_isprintc_strict(c))) { // printable character transchar_charbuf[i] = c; transchar_charbuf[i + 1] = NUL; } else transchar_nonprint(buf, transchar_charbuf + i, c); return transchar_charbuf; }
0
455,414
xfs_inode_ag_walk( struct xfs_mount *mp, struct xfs_perag *pag, int (*execute)(struct xfs_inode *ip, int flags, void *args), int flags, void *args, int tag, int iter_flags) { uint32_t first_index; int last_error = 0; int skipped; int done; int nr_found; restart: done = 0; skipped = 0; first_index = 0; nr_found = 0; do { struct xfs_inode *batch[XFS_LOOKUP_BATCH]; int error = 0; int i; rcu_read_lock(); if (tag == -1) nr_found = radix_tree_gang_lookup(&pag->pag_ici_root, (void **)batch, first_index, XFS_LOOKUP_BATCH); else nr_found = radix_tree_gang_lookup_tag( &pag->pag_ici_root, (void **) batch, first_index, XFS_LOOKUP_BATCH, tag); if (!nr_found) { rcu_read_unlock(); break; } /* * Grab the inodes before we drop the lock. if we found * nothing, nr == 0 and the loop will be skipped. */ for (i = 0; i < nr_found; i++) { struct xfs_inode *ip = batch[i]; if (done || xfs_inode_ag_walk_grab(ip, iter_flags)) batch[i] = NULL; /* * Update the index for the next lookup. Catch * overflows into the next AG range which can occur if * we have inodes in the last block of the AG and we * are currently pointing to the last inode. * * Because we may see inodes that are from the wrong AG * due to RCU freeing and reallocation, only update the * index if it lies in this AG. It was a race that lead * us to see this inode, so another lookup from the * same index will not find it again. */ if (XFS_INO_TO_AGNO(mp, ip->i_ino) != pag->pag_agno) continue; first_index = XFS_INO_TO_AGINO(mp, ip->i_ino + 1); if (first_index < XFS_INO_TO_AGINO(mp, ip->i_ino)) done = 1; } /* unlock now we've grabbed the inodes. */ rcu_read_unlock(); for (i = 0; i < nr_found; i++) { if (!batch[i]) continue; if ((iter_flags & XFS_AGITER_INEW_WAIT) && xfs_iflags_test(batch[i], XFS_INEW)) xfs_inew_wait(batch[i]); error = execute(batch[i], flags, args); IRELE(batch[i]); if (error == -EAGAIN) { skipped++; continue; } if (error && last_error != -EFSCORRUPTED) last_error = error; } /* bail out if the filesystem is corrupted. */ if (error == -EFSCORRUPTED) break; cond_resched(); } while (nr_found && !done); if (skipped) { delay(1); goto restart; } return last_error; }
0
224,736
GF_Err ipro_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem) { GF_ItemProtectionBox *ptr = (GF_ItemProtectionBox *)s; if (a->type == GF_ISOM_BOX_TYPE_SINF) { BOX_FIELD_LIST_ASSIGN(protection_information) return GF_OK; } return GF_OK; }
0
227,009
IRC_PROTOCOL_CALLBACK(438) { struct t_gui_buffer *ptr_buffer; IRC_PROTOCOL_MIN_ARGS(4); ptr_buffer = irc_msgbuffer_get_target_buffer (server, NULL, command, NULL, NULL); if (argc >= 5) { weechat_printf_date_tags ( ptr_buffer, date, irc_protocol_tags (command, "irc_numeric", NULL, NULL), "%s%s (%s => %s)", weechat_prefix ("network"), (argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4], argv[2], argv[3]); } else { weechat_printf_date_tags ( ptr_buffer, date, irc_protocol_tags (command, "irc_numeric", NULL, NULL), "%s%s %s", weechat_prefix ("network"), argv[2], argv[3]); } return WEECHAT_RC_OK; }
0
369,104
static void io_req_task_work_add(struct io_kiocb *req, bool priority) { struct task_struct *tsk = req->task; struct io_uring_task *tctx = tsk->io_uring; enum task_work_notify_mode notify; struct io_wq_work_node *node; unsigned long flags; bool running; WARN_ON_ONCE(!tctx); io_drop_inflight_file(req); spin_lock_irqsave(&tctx->task_lock, flags); if (priority) wq_list_add_tail(&req->io_task_work.node, &tctx->prior_task_list); else wq_list_add_tail(&req->io_task_work.node, &tctx->task_list); running = tctx->task_running; if (!running) tctx->task_running = true; spin_unlock_irqrestore(&tctx->task_lock, flags); /* task_work already pending, we're done */ if (running) return; /* * SQPOLL kernel thread doesn't need notification, just a wakeup. For * all other cases, use TWA_SIGNAL unconditionally to ensure we're * processing task_work. There's no reliable way to tell if TWA_RESUME * will do the job. */ notify = (req->ctx->flags & IORING_SETUP_SQPOLL) ? TWA_NONE : TWA_SIGNAL; if (likely(!task_work_add(tsk, &tctx->task_work, notify))) { if (notify == TWA_NONE) wake_up_process(tsk); return; } spin_lock_irqsave(&tctx->task_lock, flags); tctx->task_running = false; node = wq_list_merge(&tctx->prior_task_list, &tctx->task_list); spin_unlock_irqrestore(&tctx->task_lock, flags); while (node) { req = container_of(node, struct io_kiocb, io_task_work.node); node = node->next; if (llist_add(&req->io_task_work.fallback_node, &req->ctx->fallback_llist)) schedule_delayed_work(&req->ctx->fallback_work, 1); } }
0
343,231
static void sigterm_client(int sig) { (void) sig; disablesignals(); _EXIT(EXIT_SUCCESS); }
0
240,606
void Compute(OpKernelContext* c) override { core::RefCountPtr<Var> v; OP_REQUIRES_OK(c, LookupResource(c, HandleFromInput(c, 0), &v)); OP_REQUIRES_OK(c, EnsureSparseVariableAccess<Device, T>(c, v.get())); // NOTE: We hold the lock for the whole gather operation instead // of increasing the reference count of v->tensor() to avoid a // situation where a write to the same variable will see a // reference count greater than one and make a copy of the // (potentially very large) tensor buffer. tf_shared_lock ml(*v->mu()); const Tensor& params = *v->tensor(); const Tensor& indices = c->input(1); OP_REQUIRES( c, TensorShapeUtils::IsVectorOrHigher(params.shape()), errors::InvalidArgument("params must be at least 1 dimensional")); OP_REQUIRES( c, params.shape().dims() >= batch_dims_, errors::InvalidArgument("params must have at least ", batch_dims_, " (batch_dims) dimensions but it has shape ", params.shape().DebugString())); // Check that we have enough index space const int64_t N = indices.NumElements(); OP_REQUIRES( c, params.dim_size(0) <= std::numeric_limits<Index>::max(), errors::InvalidArgument("params.shape[0] too large for ", DataTypeString(DataTypeToEnum<Index>::v()), " indexing: ", params.dim_size(0), " > ", std::numeric_limits<Index>::max())); // The result shape is params.shape[:batch_dims] + // indices.shape[batch_dims:] + params.shape[batch_dims+1:]. TensorShape result_shape; for (int i = 0; i < batch_dims_; ++i) { result_shape.AddDim(params.dim_size(i)); } for (int i = batch_dims_; i < indices.dims(); ++i) { result_shape.AddDim(indices.dim_size(i)); } for (int i = batch_dims_ + 1; i < params.dims(); ++i) { result_shape.AddDim(params.dim_size(i)); } Tensor* out = nullptr; Tensor tmp; if (params.dtype() == DT_VARIANT) { tmp = Tensor(DT_VARIANT, result_shape); c->set_output(0, tmp); out = &tmp; } else { OP_REQUIRES_OK(c, c->allocate_output(0, result_shape, &out)); } if (N > 0) { Tensor tmp_indices; // Points to the original or updated (if batch_dims is set) indices. const Tensor* op_indices = &indices; if (batch_dims_ > 0) { OP_REQUIRES_OK(c, c->allocate_temp(indices.dtype(), indices.shape(), &tmp_indices)); functor::DenseUpdate<Device, Index, ASSIGN> copy_functor; copy_functor(c->eigen_device<Device>(), tmp_indices.flat<Index>(), indices.flat<Index>()); AddBatchOffsets(c, &tmp_indices, params); if (!c->status().ok()) return; op_indices = &tmp_indices; } int64_t gather_dim_size = 1; for (int idx = 0; idx <= batch_dims_; ++idx) { gather_dim_size *= params.dim_size(idx); } int64_t inner_size = 1; for (int i = batch_dims_ + 1; i < params.dims(); ++i) { inner_size *= params.dim_size(i); } auto params_flat = params.shaped<T, 3>({1, gather_dim_size, inner_size}); const auto indices_flat = op_indices->flat<Index>(); auto out_flat = out->shaped<T, 3>({1, N, out->NumElements() / N}); functor::GatherFunctor<Device, T, Index> functor; int64_t bad_i = functor(c, params_flat, indices_flat, out_flat); OP_REQUIRES( c, bad_i < 0, errors::InvalidArgument( "indices", SliceDebugString(indices.shape(), bad_i), " = ", indices_flat(bad_i), " is not in [0, ", params.dim_size(0), ")")); } }
0
385,796
static inline int should_follow_link(struct inode *inode, int follow) { if (unlikely(!(inode->i_opflags & IOP_NOFOLLOW))) { if (likely(inode->i_op->follow_link)) return follow; /* This gets set once for the inode lifetime */ spin_lock(&inode->i_lock); inode->i_opflags |= IOP_NOFOLLOW; spin_unlock(&inode->i_lock); } return 0; }
0
244,226
GF_Err metx_box_read(GF_Box *s, GF_BitStream *bs) { u32 size, i; GF_Err e; char *str; GF_MetaDataSampleEntryBox *ptr = (GF_MetaDataSampleEntryBox*)s; e = gf_isom_base_sample_entry_read((GF_SampleEntryBox *)ptr, bs); if (e) return e; ISOM_DECREASE_SIZE(ptr, 8); if (ptr->size > (u64)SIZE_MAX) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Invalid size "LLU" in metx\n", ptr->size)); return GF_ISOM_INVALID_FILE; } size = (u32) ptr->size; str = gf_malloc(sizeof(char)*size); if (!str) return GF_OUT_OF_MEM; i=0; while (size) { str[i] = gf_bs_read_u8(bs); size--; if (!str[i]) { i++; break; } i++; } if (!size && i>1 && str[i-1]) { GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] metx read invalid string\n")); gf_free(str); return GF_ISOM_INVALID_FILE; } if (i>1) { if (ptr->type==GF_ISOM_BOX_TYPE_STPP) { ptr->xml_namespace = gf_strdup(str); } else { ptr->content_encoding = gf_strdup(str); } } i=0; while (size) { str[i] = gf_bs_read_u8(bs); size--; if (!str[i]) { i++; break; } i++; } if (!size && i>1 && str[i-1]) { GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] metx read invalid string\n")); gf_free(str); return GF_ISOM_INVALID_FILE; } if ((ptr->type==GF_ISOM_BOX_TYPE_METX) || (ptr->type==GF_ISOM_BOX_TYPE_STPP)) { if (i>1) { if (ptr->type==GF_ISOM_BOX_TYPE_STPP) { ptr->xml_schema_loc = gf_strdup(str); } else { ptr->xml_namespace = gf_strdup(str); } } i=0; while (size) { str[i] = gf_bs_read_u8(bs); size--; if (!str[i]) { i++; break; } i++; } if (!size && i>1 && str[i-1]) { GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] metx read invalid string\n")); gf_free(str); return GF_ISOM_INVALID_FILE; } if (i>1) { if (ptr->type==GF_ISOM_BOX_TYPE_STPP) { ptr->mime_type = gf_strdup(str); } else { ptr->xml_schema_loc = gf_strdup(str); } } } //mett, sbtt, stxt, stpp else { if (i>1) ptr->mime_type = gf_strdup(str); } ptr->size = size; gf_free(str); return gf_isom_box_array_read(s, bs); }
0
247,618
TEST_P(SslSocketTest, RevokedIntermediateCertificate) { // This should succeed, since the crl chain is complete. // // Trust chain contains: // - Root authority certificate (i.e., ca_cert.pem) // - Intermediate authority certificate (i.e., intermediate_ca_cert.pem) // // Certificate revocation list contains: // - Root authority certificate revocation list (i.e., ca_cert.crl) // - Intermediate authority certificate revocation list (i.e., intermediate_ca_cert.crl) const std::string complete_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" validation_context: trusted_ca: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/intermediate_ca_cert_chain.pem" crl: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/intermediate_ca_cert_chain.crl" )EOF"; // This should fail, since the crl chain is incomplete. // // Trust chain contains: // - Root authority certificate (i.e., ca_cert.pem) // - Intermediate authority certificate (i.e., intermediate_ca_cert.pem) // // Certificate revocation list contains: // - Root authority certificate revocation list (i.e., ca_cert.crl) // // Certificate revocation list omits: // - Root authority certificate revocation list (i.e., ca_cert.crl) const std::string incomplete_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" validation_context: trusted_ca: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/intermediate_ca_cert_chain.pem" crl: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/intermediate_ca_cert.crl" )EOF"; // This should fail, since the certificate has been revoked. const std::string revoked_client_ctx_yaml = R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_dns3_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_dns3_key.pem" )EOF"; // This should succeed, since the certificate has not been revoked. const std::string unrevoked_client_ctx_yaml = R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_dns4_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_dns4_key.pem" )EOF"; // Ensure that incomplete crl chains fail with revoked certificates. TestUtilOptions incomplete_revoked_test_options(revoked_client_ctx_yaml, incomplete_server_ctx_yaml, false, GetParam()); testUtil(incomplete_revoked_test_options.setExpectedServerStats("ssl.fail_verify_error") .setExpectedVerifyErrorCode(X509_V_ERR_CERT_REVOKED)); // Ensure that incomplete crl chains fail with unrevoked certificates. TestUtilOptions incomplete_unrevoked_test_options(unrevoked_client_ctx_yaml, incomplete_server_ctx_yaml, false, GetParam()); testUtil(incomplete_unrevoked_test_options.setExpectedServerStats("ssl.fail_verify_error") .setExpectedVerifyErrorCode(X509_V_ERR_UNABLE_TO_GET_CRL)); // Ensure that complete crl chains fail with revoked certificates. TestUtilOptions complete_revoked_test_options(revoked_client_ctx_yaml, complete_server_ctx_yaml, false, GetParam()); testUtil(complete_revoked_test_options.setExpectedServerStats("ssl.fail_verify_error") .setExpectedVerifyErrorCode(X509_V_ERR_CERT_REVOKED)); // Ensure that complete crl chains succeed with unrevoked certificates. TestUtilOptions complete_unrevoked_test_options(unrevoked_client_ctx_yaml, complete_server_ctx_yaml, true, GetParam()); testUtil(complete_unrevoked_test_options.setExpectedSerialNumber(TEST_SAN_DNS4_CERT_SERIAL)); }
0
448,916
local int inflateStateCheck(strm) z_streamp strm; { struct inflate_state FAR *state; if (strm == Z_NULL || strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) return 1; state = (struct inflate_state FAR *)strm->state; if (state == Z_NULL || state->strm != strm || state->mode < HEAD || state->mode > SYNC) return 1; return 0; }
0
446,106
static int atusb_ed(struct ieee802154_hw *hw, u8 *level) { WARN_ON(!level); *level = 0xbe; return 0; }
0
300,757
static int __tipc_nl_add_sk_info(struct sk_buff *skb, struct tipc_sock *tsk) { struct net *net = sock_net(skb->sk); struct sock *sk = &tsk->sk; if (nla_put_u32(skb, TIPC_NLA_SOCK_REF, tsk->portid) || nla_put_u32(skb, TIPC_NLA_SOCK_ADDR, tipc_own_addr(net))) return -EMSGSIZE; if (tipc_sk_connected(sk)) { if (__tipc_nl_add_sk_con(skb, tsk)) return -EMSGSIZE; } else if (!list_empty(&tsk->publications)) { if (nla_put_flag(skb, TIPC_NLA_SOCK_HAS_PUBL)) return -EMSGSIZE; } return 0; }
0
328,976
R_API RBinJavaStackMapFrameMetas *r_bin_java_determine_stack_frame_type(ut8 tag) { ut8 type_value = 0; if (tag < 64) { type_value = R_BIN_JAVA_STACK_FRAME_SAME; } else if (tag < 128) { type_value = R_BIN_JAVA_STACK_FRAME_SAME_LOCALS_1; } else if (247 < tag && tag < 251) { type_value = R_BIN_JAVA_STACK_FRAME_CHOP; } else if (tag == 251) { type_value = R_BIN_JAVA_STACK_FRAME_SAME_FRAME_EXTENDED; } else if (251 < tag && tag < 255) { type_value = R_BIN_JAVA_STACK_FRAME_APPEND; } else if (tag == 255) { type_value = R_BIN_JAVA_STACK_FRAME_FULL_FRAME; } else { type_value = R_BIN_JAVA_STACK_FRAME_RESERVED; } return &R_BIN_JAVA_STACK_MAP_FRAME_METAS[type_value]; }
0
244,361
GF_Box *ihdr_box_new() { ISOM_DECL_BOX_ALLOC(GF_J2KImageHeaderBox, GF_ISOM_BOX_TYPE_IHDR); return (GF_Box *)tmp; }
0
328,861
R_API void r_bin_java_print_fieldref_cp_summary(RBinJavaCPTypeObj *obj) { if (!obj) { eprintf ("Attempting to print an invalid RBinJavaCPTypeObj* FieldRef.\n"); return; } eprintf ("FieldRef ConstantPool Type (%d) ", obj->metas->ord); eprintf (" Offset: 0x%08"PFMT64x"", obj->file_offset); eprintf (" Class Index = %d\n", obj->info.cp_field.class_idx); eprintf (" Name and type Index = %d\n", obj->info.cp_field.name_and_type_idx); }
0
474,054
fetch_token_in_cc(OnigToken* tok, UChar** src, UChar* end, ScanEnv* env) { int num; OnigCodePoint c, c2; const OnigSyntaxType* syn = env->syntax; OnigEncoding enc = env->enc; UChar* prev; UChar* p = *src; PFETCH_READY; if (PEND) { tok->type = TK_EOT; return tok->type; } PFETCH(c); tok->type = TK_CHAR; tok->base = 0; tok->u.c = c; tok->escaped = 0; if (c == ']') { tok->type = TK_CC_CLOSE; } else if (c == '-') { tok->type = TK_CC_RANGE; } else if (c == MC_ESC(syn)) { if (! IS_SYNTAX_BV(syn, ONIG_SYN_BACKSLASH_ESCAPE_IN_CC)) goto end; if (PEND) return ONIGERR_END_PATTERN_AT_ESCAPE; PFETCH(c); tok->escaped = 1; tok->u.c = c; switch (c) { case 'w': tok->type = TK_CHAR_TYPE; tok->u.prop.ctype = ONIGENC_CTYPE_W; tok->u.prop.not = 0; break; case 'W': tok->type = TK_CHAR_TYPE; tok->u.prop.ctype = ONIGENC_CTYPE_W; tok->u.prop.not = 1; break; case 'd': tok->type = TK_CHAR_TYPE; tok->u.prop.ctype = ONIGENC_CTYPE_D; tok->u.prop.not = 0; break; case 'D': tok->type = TK_CHAR_TYPE; tok->u.prop.ctype = ONIGENC_CTYPE_D; tok->u.prop.not = 1; break; case 's': tok->type = TK_CHAR_TYPE; tok->u.prop.ctype = ONIGENC_CTYPE_S; tok->u.prop.not = 0; break; case 'S': tok->type = TK_CHAR_TYPE; tok->u.prop.ctype = ONIGENC_CTYPE_S; tok->u.prop.not = 1; break; case 'h': if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break; tok->type = TK_CHAR_TYPE; tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT; tok->u.prop.not = 0; break; case 'H': if (! IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_H_XDIGIT)) break; tok->type = TK_CHAR_TYPE; tok->u.prop.ctype = ONIGENC_CTYPE_XDIGIT; tok->u.prop.not = 1; break; case 'p': case 'P': c2 = PPEEK; if (c2 == '{' && IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY)) { PINC; tok->type = TK_CHAR_PROPERTY; tok->u.prop.not = (c == 'P' ? 1 : 0); if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT)) { PFETCH(c2); if (c2 == '^') { tok->u.prop.not = (tok->u.prop.not == 0 ? 1 : 0); } else PUNFETCH; } } else { onig_syntax_warn(env, "invalid Unicode Property \\%c", c); } break; case 'x': if (PEND) break; prev = p; if (PPEEK_IS('{') && IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_X_BRACE_HEX8)) { PINC; num = scan_unsigned_hexadecimal_number(&p, end, 8, enc); if (num < 0) return ONIGERR_TOO_BIG_WIDE_CHAR_VALUE; if (!PEND) { c2 = PPEEK; if (ONIGENC_IS_CODE_XDIGIT(enc, c2)) return ONIGERR_TOO_LONG_WIDE_CHAR_VALUE; } if (p > prev + enclen(enc, prev, end) && !PEND && (PPEEK_IS('}'))) { PINC; tok->type = TK_CODE_POINT; tok->base = 16; tok->u.code = (OnigCodePoint )num; } else { /* can't read nothing or invalid format */ p = prev; } } else if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_X_HEX2)) { num = scan_unsigned_hexadecimal_number(&p, end, 2, enc); if (num < 0) return ONIGERR_TOO_BIG_NUMBER; if (p == prev) { /* can't read nothing. */ num = 0; /* but, it's not error */ } tok->type = TK_RAW_BYTE; tok->base = 16; tok->u.c = num; } break; case 'u': if (PEND) break; prev = p; if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_ESC_U_HEX4)) { num = scan_unsigned_hexadecimal_number(&p, end, 4, enc); if (num < 0) return ONIGERR_TOO_BIG_NUMBER; if (p == prev) { /* can't read nothing. */ num = 0; /* but, it's not error */ } tok->type = TK_CODE_POINT; tok->base = 16; tok->u.code = (OnigCodePoint )num; } break; case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_ESC_OCTAL3)) { PUNFETCH; prev = p; num = scan_unsigned_octal_number(&p, end, 3, enc); if (num < 0) return ONIGERR_TOO_BIG_NUMBER; if (p == prev) { /* can't read nothing. */ num = 0; /* but, it's not error */ } tok->type = TK_RAW_BYTE; tok->base = 8; tok->u.c = num; } break; default: PUNFETCH; num = fetch_escaped_value(&p, end, env); if (num < 0) return num; if (tok->u.c != num) { tok->u.code = (OnigCodePoint )num; tok->type = TK_CODE_POINT; } break; } } else if (c == '[') { if (IS_SYNTAX_OP(syn, ONIG_SYN_OP_POSIX_BRACKET) && (PPEEK_IS(':'))) { OnigCodePoint send[] = { (OnigCodePoint )':', (OnigCodePoint )']' }; tok->backp = p; /* point at '[' is readed */ PINC; if (str_exist_check_with_esc(send, 2, p, end, (OnigCodePoint )']', enc, syn)) { tok->type = TK_POSIX_BRACKET_OPEN; } else { PUNFETCH; goto cc_in_cc; } } else { cc_in_cc: if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_CCLASS_SET_OP)) { tok->type = TK_CC_CC_OPEN; } else { CC_ESC_WARN(env, (UChar* )"["); } } } else if (c == '&') { if (IS_SYNTAX_OP2(syn, ONIG_SYN_OP2_CCLASS_SET_OP) && !PEND && (PPEEK_IS('&'))) { PINC; tok->type = TK_CC_AND; } } end: *src = p; return tok->type; }
0
317,223
static void selinux_inode_invalidate_secctx(struct inode *inode) { struct inode_security_struct *isec = selinux_inode(inode); spin_lock(&isec->lock); isec->initialized = LABEL_INVALID; spin_unlock(&isec->lock); }
0
210,393
do_arg_all( int count, int forceit, // hide buffers in current windows int keep_tabs) // keep current tabs, for ":tab drop file" { int i; win_T *wp, *wpnext; char_u *opened; // Array of weight for which args are open: // 0: not opened // 1: opened in other tab // 2: opened in curtab // 3: opened in curtab and curwin // int opened_len; // length of opened[] int use_firstwin = FALSE; // use first window for arglist int tab_drop_empty_window = FALSE; int split_ret = OK; int p_ea_save; alist_T *alist; // argument list to be used buf_T *buf; tabpage_T *tpnext; int had_tab = cmdmod.cmod_tab; win_T *old_curwin, *last_curwin; tabpage_T *old_curtab, *last_curtab; win_T *new_curwin = NULL; tabpage_T *new_curtab = NULL; #ifdef FEAT_CMDWIN if (cmdwin_type != 0) { emsg(_(e_invalid_in_cmdline_window)); return; } #endif if (ARGCOUNT <= 0) { // Don't give an error message. We don't want it when the ":all" // command is in the .vimrc. return; } setpcmark(); opened_len = ARGCOUNT; opened = alloc_clear(opened_len); if (opened == NULL) return; // Autocommands may do anything to the argument list. Make sure it's not // freed while we are working here by "locking" it. We still have to // watch out for its size to be changed. alist = curwin->w_alist; ++alist->al_refcount; old_curwin = curwin; old_curtab = curtab; # ifdef FEAT_GUI need_mouse_correct = TRUE; # endif // Try closing all windows that are not in the argument list. // Also close windows that are not full width; // When 'hidden' or "forceit" set the buffer becomes hidden. // Windows that have a changed buffer and can't be hidden won't be closed. // When the ":tab" modifier was used do this for all tab pages. if (had_tab > 0) goto_tabpage_tp(first_tabpage, TRUE, TRUE); for (;;) { tpnext = curtab->tp_next; for (wp = firstwin; wp != NULL; wp = wpnext) { wpnext = wp->w_next; buf = wp->w_buffer; if (buf->b_ffname == NULL || (!keep_tabs && (buf->b_nwindows > 1 || wp->w_width != Columns))) i = opened_len; else { // check if the buffer in this window is in the arglist for (i = 0; i < opened_len; ++i) { if (i < alist->al_ga.ga_len && (AARGLIST(alist)[i].ae_fnum == buf->b_fnum || fullpathcmp(alist_name(&AARGLIST(alist)[i]), buf->b_ffname, TRUE, TRUE) & FPC_SAME)) { int weight = 1; if (old_curtab == curtab) { ++weight; if (old_curwin == wp) ++weight; } if (weight > (int)opened[i]) { opened[i] = (char_u)weight; if (i == 0) { if (new_curwin != NULL) new_curwin->w_arg_idx = opened_len; new_curwin = wp; new_curtab = curtab; } } else if (keep_tabs) i = opened_len; if (wp->w_alist != alist) { // Use the current argument list for all windows // containing a file from it. alist_unlink(wp->w_alist); wp->w_alist = alist; ++wp->w_alist->al_refcount; } break; } } } wp->w_arg_idx = i; if (i == opened_len && !keep_tabs)// close this window { if (buf_hide(buf) || forceit || buf->b_nwindows > 1 || !bufIsChanged(buf)) { // If the buffer was changed, and we would like to hide it, // try autowriting. if (!buf_hide(buf) && buf->b_nwindows <= 1 && bufIsChanged(buf)) { bufref_T bufref; set_bufref(&bufref, buf); (void)autowrite(buf, FALSE); // check if autocommands removed the window if (!win_valid(wp) || !bufref_valid(&bufref)) { wpnext = firstwin; // start all over... continue; } } // don't close last window if (ONE_WINDOW && (first_tabpage->tp_next == NULL || !had_tab)) use_firstwin = TRUE; else { win_close(wp, !buf_hide(buf) && !bufIsChanged(buf)); // check if autocommands removed the next window if (!win_valid(wpnext)) wpnext = firstwin; // start all over... } } } } // Without the ":tab" modifier only do the current tab page. if (had_tab == 0 || tpnext == NULL) break; // check if autocommands removed the next tab page if (!valid_tabpage(tpnext)) tpnext = first_tabpage; // start all over... goto_tabpage_tp(tpnext, TRUE, TRUE); } // Open a window for files in the argument list that don't have one. // ARGCOUNT may change while doing this, because of autocommands. if (count > opened_len || count <= 0) count = opened_len; // Don't execute Win/Buf Enter/Leave autocommands here. ++autocmd_no_enter; ++autocmd_no_leave; last_curwin = curwin; last_curtab = curtab; win_enter(lastwin, FALSE); // ":tab drop file" should re-use an empty window to avoid "--remote-tab" // leaving an empty tab page when executed locally. if (keep_tabs && BUFEMPTY() && curbuf->b_nwindows == 1 && curbuf->b_ffname == NULL && !curbuf->b_changed) { use_firstwin = TRUE; tab_drop_empty_window = TRUE; } for (i = 0; i < count && !got_int; ++i) { if (alist == &global_alist && i == global_alist.al_ga.ga_len - 1) arg_had_last = TRUE; if (opened[i] > 0) { // Move the already present window to below the current window if (curwin->w_arg_idx != i) { FOR_ALL_WINDOWS(wpnext) { if (wpnext->w_arg_idx == i) { if (keep_tabs) { new_curwin = wpnext; new_curtab = curtab; } else if (wpnext->w_frame->fr_parent != curwin->w_frame->fr_parent) { emsg(_("E249: window layout changed unexpectedly")); i = count; break; } else win_move_after(wpnext, curwin); break; } } } } else if (split_ret == OK) { // trigger events for tab drop if (tab_drop_empty_window && i == count - 1) --autocmd_no_enter; if (!use_firstwin) // split current window { p_ea_save = p_ea; p_ea = TRUE; // use space from all windows split_ret = win_split(0, WSP_ROOM | WSP_BELOW); p_ea = p_ea_save; if (split_ret == FAIL) continue; } else // first window: do autocmd for leaving this buffer --autocmd_no_leave; // edit file "i" curwin->w_arg_idx = i; if (i == 0) { new_curwin = curwin; new_curtab = curtab; } (void)do_ecmd(0, alist_name(&AARGLIST(alist)[i]), NULL, NULL, ECMD_ONE, ((buf_hide(curwin->w_buffer) || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0) + ECMD_OLDBUF, curwin); if (tab_drop_empty_window && i == count - 1) ++autocmd_no_enter; if (use_firstwin) ++autocmd_no_leave; use_firstwin = FALSE; } ui_breakcheck(); // When ":tab" was used open a new tab for a new window repeatedly. if (had_tab > 0 && tabpage_index(NULL) <= p_tpm) cmdmod.cmod_tab = 9999; } // Remove the "lock" on the argument list. alist_unlink(alist); --autocmd_no_enter; // restore last referenced tabpage's curwin if (last_curtab != new_curtab) { if (valid_tabpage(last_curtab)) goto_tabpage_tp(last_curtab, TRUE, TRUE); if (win_valid(last_curwin)) win_enter(last_curwin, FALSE); } // to window with first arg if (valid_tabpage(new_curtab)) goto_tabpage_tp(new_curtab, TRUE, TRUE); if (win_valid(new_curwin)) win_enter(new_curwin, FALSE); --autocmd_no_leave; vim_free(opened); }
1