idx
int64
func
string
target
int64
413,826
void CallInfo::set_handle(Klass* resolved_klass, const methodHandle& resolved_method, Handle resolved_appendix, TRAPS) { guarantee(resolved_method.not_null(), "resolved method is null"); assert(resolved_method->intrinsic_id() == vmIntrinsics::_invokeBasic || resolved_method->is_compiled_lambda_form(), "linkMethod must return one of these"); int vtable_index = Method::nonvirtual_vtable_index; assert(!resolved_method->has_vtable_index(), ""); set_common(resolved_klass, resolved_method, resolved_method, CallInfo::direct_call, vtable_index, CHECK); _resolved_appendix = resolved_appendix; }
0
447,040
long CurlIo::write(const byte* data, long wcount) { if (p_->protocol_ == pHttp || p_->protocol_ == pHttps) { return RemoteIo::write(data, wcount); } else { throw Error(1, "doesnt support write for this protocol."); } }
0
253,565
int open_cached_dir(unsigned int xid, struct cifs_tcon *tcon, const char *path, struct cifs_sb_info *cifs_sb, struct cached_fid **cfid) { struct cifs_ses *ses = tcon->ses; struct TCP_Server_Info *server = ses->server; struct cifs_open_parms oparms; struct smb2_create_rsp *o_rsp = NULL; struct smb2_query_info_rsp *qi_rsp = NULL; int resp_buftype[2]; struct smb_rqst rqst[2]; struct kvec rsp_iov[2]; struct kvec open_iov[SMB2_CREATE_IOV_SIZE]; struct kvec qi_iov[1]; int rc, flags = 0; __le16 utf16_path = 0; /* Null - since an open of top of share */ u8 oplock = SMB2_OPLOCK_LEVEL_II; struct cifs_fid *pfid; struct dentry *dentry; if (tcon->nohandlecache) return -ENOTSUPP; if (cifs_sb->root == NULL) return -ENOENT; if (strlen(path)) return -ENOENT; dentry = cifs_sb->root; mutex_lock(&tcon->crfid.fid_mutex); if (tcon->crfid.is_valid) { cifs_dbg(FYI, "found a cached root file handle\n"); *cfid = &tcon->crfid; kref_get(&tcon->crfid.refcount); mutex_unlock(&tcon->crfid.fid_mutex); return 0; } /* * We do not hold the lock for the open because in case * SMB2_open needs to reconnect, it will end up calling * cifs_mark_open_files_invalid() which takes the lock again * thus causing a deadlock */ mutex_unlock(&tcon->crfid.fid_mutex); if (smb3_encryption_required(tcon)) flags |= CIFS_TRANSFORM_REQ; if (!server->ops->new_lease_key) return -EIO; pfid = tcon->crfid.fid; server->ops->new_lease_key(pfid); memset(rqst, 0, sizeof(rqst)); resp_buftype[0] = resp_buftype[1] = CIFS_NO_BUFFER; memset(rsp_iov, 0, sizeof(rsp_iov)); /* Open */ memset(&open_iov, 0, sizeof(open_iov)); rqst[0].rq_iov = open_iov; rqst[0].rq_nvec = SMB2_CREATE_IOV_SIZE; oparms.tcon = tcon; oparms.create_options = cifs_create_options(cifs_sb, 0); oparms.desired_access = FILE_READ_ATTRIBUTES; oparms.disposition = FILE_OPEN; oparms.fid = pfid; oparms.reconnect = false; rc = SMB2_open_init(tcon, server, &rqst[0], &oplock, &oparms, &utf16_path); if (rc) goto oshr_free; smb2_set_next_command(tcon, &rqst[0]); memset(&qi_iov, 0, sizeof(qi_iov)); rqst[1].rq_iov = qi_iov; rqst[1].rq_nvec = 1; rc = SMB2_query_info_init(tcon, server, &rqst[1], COMPOUND_FID, COMPOUND_FID, FILE_ALL_INFORMATION, SMB2_O_INFO_FILE, 0, sizeof(struct smb2_file_all_info) + PATH_MAX * 2, 0, NULL); if (rc) goto oshr_free; smb2_set_related(&rqst[1]); rc = compound_send_recv(xid, ses, server, flags, 2, rqst, resp_buftype, rsp_iov); mutex_lock(&tcon->crfid.fid_mutex); /* * Now we need to check again as the cached root might have * been successfully re-opened from a concurrent process */ if (tcon->crfid.is_valid) { /* work was already done */ /* stash fids for close() later */ struct cifs_fid fid = { .persistent_fid = pfid->persistent_fid, .volatile_fid = pfid->volatile_fid, }; /* * caller expects this func to set the fid in crfid to valid * cached root, so increment the refcount. */ kref_get(&tcon->crfid.refcount); mutex_unlock(&tcon->crfid.fid_mutex); if (rc == 0) { /* close extra handle outside of crit sec */ SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); } rc = 0; goto oshr_free; } /* Cached root is still invalid, continue normaly */ if (rc) { if (rc == -EREMCHG) { tcon->need_reconnect = true; pr_warn_once("server share %s deleted\n", tcon->treeName); } goto oshr_exit; } atomic_inc(&tcon->num_remote_opens); o_rsp = (struct smb2_create_rsp *)rsp_iov[0].iov_base; oparms.fid->persistent_fid = o_rsp->PersistentFileId; oparms.fid->volatile_fid = o_rsp->VolatileFileId; #ifdef CONFIG_CIFS_DEBUG2 oparms.fid->mid = le64_to_cpu(o_rsp->hdr.MessageId); #endif /* CIFS_DEBUG2 */ tcon->crfid.tcon = tcon; tcon->crfid.is_valid = true; tcon->crfid.dentry = dentry; dget(dentry); kref_init(&tcon->crfid.refcount); /* BB TBD check to see if oplock level check can be removed below */ if (o_rsp->OplockLevel == SMB2_OPLOCK_LEVEL_LEASE) { /* * See commit 2f94a3125b87. Increment the refcount when we * get a lease for root, release it if lease break occurs */ kref_get(&tcon->crfid.refcount); tcon->crfid.has_lease = true; smb2_parse_contexts(server, o_rsp, &oparms.fid->epoch, oparms.fid->lease_key, &oplock, NULL, NULL); } else goto oshr_exit; qi_rsp = (struct smb2_query_info_rsp *)rsp_iov[1].iov_base; if (le32_to_cpu(qi_rsp->OutputBufferLength) < sizeof(struct smb2_file_all_info)) goto oshr_exit; if (!smb2_validate_and_copy_iov( le16_to_cpu(qi_rsp->OutputBufferOffset), sizeof(struct smb2_file_all_info), &rsp_iov[1], sizeof(struct smb2_file_all_info), (char *)&tcon->crfid.file_all_info)) tcon->crfid.file_all_info_is_valid = true; tcon->crfid.time = jiffies; oshr_exit: mutex_unlock(&tcon->crfid.fid_mutex); oshr_free: SMB2_open_free(&rqst[0]); SMB2_query_info_free(&rqst[1]); free_rsp_buf(resp_buftype[0], rsp_iov[0].iov_base); free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base); if (rc == 0) *cfid = &tcon->crfid; return rc; }
0
101,682
void WebProcessProxy::getLaunchOptions(ProcessLauncher::LaunchOptions& launchOptions) { launchOptions.processType = ProcessLauncher::WebProcess; platformGetLaunchOptions(launchOptions); }
0
215,188
void mobi_buffer_move(MOBIBuffer *buf, const int offset, const size_t len) { size_t aoffset = (size_t) abs(offset); unsigned char *source = buf->data + buf->offset; if (offset >= 0) { if (buf->offset + aoffset + len > buf->maxlen) { debug_print("%s", "End of buffer\n"); buf->error = MOBI_BUFFER_END; return; } source += aoffset; } else { if (buf->offset < aoffset) { debug_print("%s", "End of buffer\n"); buf->error = MOBI_BUFFER_END; return; } source -= aoffset; } memmove(buf->data + buf->offset, source, len); buf->offset += len; }
1
198,003
void Compute(OpKernelContext* ctx) override { auto x = ctx->input(0); auto i = ctx->input(1); auto v = ctx->input(2); OP_REQUIRES(ctx, TensorShapeUtils::IsVector(i.shape()), errors::InvalidArgument("i must be a vector. ", i.shape().DebugString())); OP_REQUIRES(ctx, x.dims() == v.dims(), errors::InvalidArgument( "x and v shape doesn't match (ranks differ): ", x.shape().DebugString(), " vs. ", v.shape().DebugString())); for (int i = 1; i < x.dims(); ++i) { OP_REQUIRES( ctx, x.dim_size(i) == v.dim_size(i), errors::InvalidArgument("x and v shape doesn't match at index ", i, " : ", x.shape().DebugString(), " vs. ", v.shape().DebugString())); } OP_REQUIRES(ctx, i.dim_size(0) == v.dim_size(0), errors::InvalidArgument( "i and x shape doesn't match at index 0: ", i.shape().DebugString(), " vs. ", v.shape().DebugString())); Tensor y = x; // This creates an alias intentionally. // Skip processing if tensors are empty. if (x.NumElements() > 0 || v.NumElements() > 0) { OP_REQUIRES_OK(ctx, DoCompute(ctx, i, v, &y)); } ctx->set_output(0, y); }
1
446,100
atusb_set_txpower(struct ieee802154_hw *hw, s32 mbm) { struct atusb *atusb = hw->priv; u32 i; for (i = 0; i < hw->phy->supported.tx_powers_size; i++) { if (hw->phy->supported.tx_powers[i] == mbm) return atusb_write_subreg(atusb, SR_TX_PWR_23X, i); } return -EINVAL; }
0
337,845
static int sctp_process_param(struct sctp_association *asoc, union sctp_params param, const union sctp_addr *peer_addr, gfp_t gfp) { struct sctp_endpoint *ep = asoc->ep; union sctp_addr_param *addr_param; struct net *net = asoc->base.net; struct sctp_transport *t; enum sctp_scope scope; union sctp_addr addr; struct sctp_af *af; int retval = 1, i; u32 stale; __u16 sat; /* We maintain all INIT parameters in network byte order all the * time. This allows us to not worry about whether the parameters * came from a fresh INIT, and INIT ACK, or were stored in a cookie. */ switch (param.p->type) { case SCTP_PARAM_IPV6_ADDRESS: if (PF_INET6 != asoc->base.sk->sk_family) break; goto do_addr_param; case SCTP_PARAM_IPV4_ADDRESS: /* v4 addresses are not allowed on v6-only socket */ if (ipv6_only_sock(asoc->base.sk)) break; do_addr_param: af = sctp_get_af_specific(param_type2af(param.p->type)); if (!af->from_addr_param(&addr, param.addr, htons(asoc->peer.port), 0)) break; scope = sctp_scope(peer_addr); if (sctp_in_scope(net, &addr, scope)) if (!sctp_assoc_add_peer(asoc, &addr, gfp, SCTP_UNCONFIRMED)) return 0; break; case SCTP_PARAM_COOKIE_PRESERVATIVE: if (!net->sctp.cookie_preserve_enable) break; stale = ntohl(param.life->lifespan_increment); /* Suggested Cookie Life span increment's unit is msec, * (1/1000sec). */ asoc->cookie_life = ktime_add_ms(asoc->cookie_life, stale); break; case SCTP_PARAM_HOST_NAME_ADDRESS: pr_debug("%s: unimplemented SCTP_HOST_NAME_ADDRESS\n", __func__); break; case SCTP_PARAM_SUPPORTED_ADDRESS_TYPES: /* Turn off the default values first so we'll know which * ones are really set by the peer. */ asoc->peer.ipv4_address = 0; asoc->peer.ipv6_address = 0; /* Assume that peer supports the address family * by which it sends a packet. */ if (peer_addr->sa.sa_family == AF_INET6) asoc->peer.ipv6_address = 1; else if (peer_addr->sa.sa_family == AF_INET) asoc->peer.ipv4_address = 1; /* Cycle through address types; avoid divide by 0. */ sat = ntohs(param.p->length) - sizeof(struct sctp_paramhdr); if (sat) sat /= sizeof(__u16); for (i = 0; i < sat; ++i) { switch (param.sat->types[i]) { case SCTP_PARAM_IPV4_ADDRESS: asoc->peer.ipv4_address = 1; break; case SCTP_PARAM_IPV6_ADDRESS: if (PF_INET6 == asoc->base.sk->sk_family) asoc->peer.ipv6_address = 1; break; case SCTP_PARAM_HOST_NAME_ADDRESS: asoc->peer.hostname_address = 1; break; default: /* Just ignore anything else. */ break; } } break; case SCTP_PARAM_STATE_COOKIE: asoc->peer.cookie_len = ntohs(param.p->length) - sizeof(struct sctp_paramhdr); kfree(asoc->peer.cookie); asoc->peer.cookie = kmemdup(param.cookie->body, asoc->peer.cookie_len, gfp); if (!asoc->peer.cookie) retval = 0; break; case SCTP_PARAM_HEARTBEAT_INFO: /* Would be odd to receive, but it causes no problems. */ break; case SCTP_PARAM_UNRECOGNIZED_PARAMETERS: /* Rejected during verify stage. */ break; case SCTP_PARAM_ECN_CAPABLE: if (asoc->ep->ecn_enable) { asoc->peer.ecn_capable = 1; break; } /* Fall Through */ goto fall_through; case SCTP_PARAM_ADAPTATION_LAYER_IND: asoc->peer.adaptation_ind = ntohl(param.aind->adaptation_ind); break; case SCTP_PARAM_SET_PRIMARY: if (!ep->asconf_enable) goto fall_through; addr_param = param.v + sizeof(struct sctp_addip_param); af = sctp_get_af_specific(param_type2af(addr_param->p.type)); if (!af) break; if (!af->from_addr_param(&addr, addr_param, htons(asoc->peer.port), 0)) break; if (!af->addr_valid(&addr, NULL, NULL)) break; t = sctp_assoc_lookup_paddr(asoc, &addr); if (!t) break; sctp_assoc_set_primary(asoc, t); break; case SCTP_PARAM_SUPPORTED_EXT: sctp_process_ext_param(asoc, param); break; case SCTP_PARAM_FWD_TSN_SUPPORT: if (asoc->ep->prsctp_enable) { asoc->peer.prsctp_capable = 1; break; } /* Fall Through */ goto fall_through; case SCTP_PARAM_RANDOM: if (!ep->auth_enable) goto fall_through; /* Save peer's random parameter */ kfree(asoc->peer.peer_random); asoc->peer.peer_random = kmemdup(param.p, ntohs(param.p->length), gfp); if (!asoc->peer.peer_random) { retval = 0; break; } break; case SCTP_PARAM_HMAC_ALGO: if (!ep->auth_enable) goto fall_through; /* Save peer's HMAC list */ kfree(asoc->peer.peer_hmacs); asoc->peer.peer_hmacs = kmemdup(param.p, ntohs(param.p->length), gfp); if (!asoc->peer.peer_hmacs) { retval = 0; break; } /* Set the default HMAC the peer requested*/ sctp_auth_asoc_set_default_hmac(asoc, param.hmac_algo); break; case SCTP_PARAM_CHUNKS: if (!ep->auth_enable) goto fall_through; kfree(asoc->peer.peer_chunks); asoc->peer.peer_chunks = kmemdup(param.p, ntohs(param.p->length), gfp); if (!asoc->peer.peer_chunks) retval = 0; break; fall_through: default: /* Any unrecognized parameters should have been caught * and handled by sctp_verify_param() which should be * called prior to this routine. Simply log the error * here. */ pr_debug("%s: ignoring param:%d for association:%p.\n", __func__, ntohs(param.p->type), asoc); break; } return retval; }
0
294,498
m_hour(union DateData *x) { if (simple_dat_p(x)) return 0; else { get_c_time(x); #ifndef USE_PACK return x->c.hour; #else return EX_HOUR(x->c.pc); #endif } }
0
246,744
u32 parse_mpegu(char *arg_val, u32 opt) { pack_file = arg_val; pack_wgt = GF_TRUE; return 0; }
0
259,531
CURLUcode curl_url_set(CURLU *u, CURLUPart what, const char *part, unsigned int flags) { char **storep = NULL; long port = 0; bool urlencode = (flags & CURLU_URLENCODE)? 1 : 0; bool plusencode = FALSE; bool urlskipslash = FALSE; bool appendquery = FALSE; bool equalsencode = FALSE; if(!u) return CURLUE_BAD_HANDLE; if(!part) { /* setting a part to NULL clears it */ switch(what) { case CURLUPART_URL: break; case CURLUPART_SCHEME: storep = &u->scheme; break; case CURLUPART_USER: storep = &u->user; break; case CURLUPART_PASSWORD: storep = &u->password; break; case CURLUPART_OPTIONS: storep = &u->options; break; case CURLUPART_HOST: storep = &u->host; break; case CURLUPART_ZONEID: storep = &u->zoneid; break; case CURLUPART_PORT: u->portnum = 0; storep = &u->port; break; case CURLUPART_PATH: storep = &u->path; break; case CURLUPART_QUERY: storep = &u->query; break; case CURLUPART_FRAGMENT: storep = &u->fragment; break; default: return CURLUE_UNKNOWN_PART; } if(storep && *storep) { Curl_safefree(*storep); } return CURLUE_OK; } switch(what) { case CURLUPART_SCHEME: if(strlen(part) > MAX_SCHEME_LEN) /* too long */ return CURLUE_BAD_SCHEME; if(!(flags & CURLU_NON_SUPPORT_SCHEME) && /* verify that it is a fine scheme */ !Curl_builtin_scheme(part)) return CURLUE_UNSUPPORTED_SCHEME; storep = &u->scheme; urlencode = FALSE; /* never */ break; case CURLUPART_USER: storep = &u->user; break; case CURLUPART_PASSWORD: storep = &u->password; break; case CURLUPART_OPTIONS: storep = &u->options; break; case CURLUPART_HOST: { size_t len = strcspn(part, " \r\n"); if(strlen(part) != len) /* hostname with bad content */ return CURLUE_BAD_HOSTNAME; storep = &u->host; Curl_safefree(u->zoneid); break; } case CURLUPART_ZONEID: storep = &u->zoneid; break; case CURLUPART_PORT: { char *endp; urlencode = FALSE; /* never */ port = strtol(part, &endp, 10); /* Port number must be decimal */ if((port <= 0) || (port > 0xffff)) return CURLUE_BAD_PORT_NUMBER; if(*endp) /* weirdly provided number, not good! */ return CURLUE_BAD_PORT_NUMBER; storep = &u->port; } break; case CURLUPART_PATH: urlskipslash = TRUE; storep = &u->path; break; case CURLUPART_QUERY: plusencode = urlencode; appendquery = (flags & CURLU_APPENDQUERY)?1:0; equalsencode = appendquery; storep = &u->query; break; case CURLUPART_FRAGMENT: storep = &u->fragment; break; case CURLUPART_URL: { /* * Allow a new URL to replace the existing (if any) contents. * * If the existing contents is enough for a URL, allow a relative URL to * replace it. */ CURLUcode result; char *oldurl; char *redired_url; /* if the new thing is absolute or the old one is not * (we could not get an absolute url in 'oldurl'), * then replace the existing with the new. */ if(Curl_is_absolute_url(part, NULL, 0) || curl_url_get(u, CURLUPART_URL, &oldurl, flags)) { return parseurl_and_replace(part, u, flags); } /* apply the relative part to create a new URL * and replace the existing one with it. */ redired_url = concat_url(oldurl, part); free(oldurl); if(!redired_url) return CURLUE_OUT_OF_MEMORY; result = parseurl_and_replace(redired_url, u, flags); free(redired_url); return result; } default: return CURLUE_UNKNOWN_PART; } DEBUGASSERT(storep); { const char *newp = part; size_t nalloc = strlen(part); if(nalloc > CURL_MAX_INPUT_LENGTH) /* excessive input length */ return CURLUE_MALFORMED_INPUT; if(urlencode) { const unsigned char *i; char *o; char *enc = malloc(nalloc * 3 + 1); /* for worst case! */ if(!enc) return CURLUE_OUT_OF_MEMORY; for(i = (const unsigned char *)part, o = enc; *i; i++) { if((*i == ' ') && plusencode) { *o = '+'; o++; } else if(Curl_isunreserved(*i) || ((*i == '/') && urlskipslash) || ((*i == '=') && equalsencode)) { if((*i == '=') && equalsencode) /* only skip the first equals sign */ equalsencode = FALSE; *o = *i; o++; } else { msnprintf(o, 4, "%%%02x", *i); o += 3; } } *o = 0; /* null-terminate */ newp = enc; } else { char *p; newp = strdup(part); if(!newp) return CURLUE_OUT_OF_MEMORY; p = (char *)newp; while(*p) { /* make sure percent encoded are lower case */ if((*p == '%') && ISXDIGIT(p[1]) && ISXDIGIT(p[2]) && (ISUPPER(p[1]) || ISUPPER(p[2]))) { p[1] = (char)TOLOWER(p[1]); p[2] = (char)TOLOWER(p[2]); p += 3; } else p++; } } if(appendquery) { /* Append the string onto the old query. Add a '&' separator if none is present at the end of the exsting query already */ size_t querylen = u->query ? strlen(u->query) : 0; bool addamperand = querylen && (u->query[querylen -1] != '&'); if(querylen) { size_t newplen = strlen(newp); char *p = malloc(querylen + addamperand + newplen + 1); if(!p) { free((char *)newp); return CURLUE_OUT_OF_MEMORY; } strcpy(p, u->query); /* original query */ if(addamperand) p[querylen] = '&'; /* ampersand */ strcpy(&p[querylen + addamperand], newp); /* new suffix */ free((char *)newp); free(*storep); *storep = p; return CURLUE_OK; } } if(what == CURLUPART_HOST) { if(0 == strlen(newp) && (flags & CURLU_NO_AUTHORITY)) { /* Skip hostname check, it's allowed to be empty. */ } else { if(hostname_check(u, (char *)newp)) { free((char *)newp); return CURLUE_BAD_HOSTNAME; } } } free(*storep); *storep = (char *)newp; } /* set after the string, to make it not assigned if the allocation above fails */ if(port) u->portnum = port; return CURLUE_OK; }
0
267,965
R_API bool r_bin_file_deref(RBin *bin, RBinFile *a) { r_return_val_if_fail (bin && a, false); if (!r_bin_cur_object (bin)) { return false; } bin->cur = NULL; return true; }
0
369,260
static void io_free_file_tables(struct io_file_table *table) { kvfree(table->files); table->files = NULL;
0
234,173
print_addr_index (unsigned int idx, unsigned int len) { static char buf[15]; snprintf (buf, sizeof (buf), "[%d]", idx); printf ("%*s ", len, buf); }
0
385,832
int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs, struct file *filp) { int ret; struct iattr newattrs; /* Not pretty: "inode->i_size" shouldn't really be signed. But it is. */ if (length < 0) return -EINVAL; newattrs.ia_size = length; newattrs.ia_valid = ATTR_SIZE | time_attrs; if (filp) { newattrs.ia_file = filp; newattrs.ia_valid |= ATTR_FILE; } /* Remove suid/sgid on truncate too */ ret = should_remove_suid(dentry); if (ret) newattrs.ia_valid |= ret | ATTR_FORCE; mutex_lock(&dentry->d_inode->i_mutex); ret = notify_change(dentry, &newattrs); mutex_unlock(&dentry->d_inode->i_mutex); return ret; }
0
345,137
pxa3xx_gcu_wait_free(struct pxa3xx_gcu_priv *priv) { int ret = 0; QDUMP("Waiting for free..."); /* Does not need to be atomic. There's a lock in user space, * but anyhow, this is just for statistics. */ priv->shared->num_wait_free++; while (!priv->free) { u32 rbexhr = gc_readl(priv, REG_GCRBEXHR); ret = wait_event_interruptible_timeout(priv->wait_free, priv->free, HZ*4); if (ret < 0) break; if (ret > 0) continue; if (gc_readl(priv, REG_GCRBEXHR) == rbexhr) { QERROR("TIMEOUT"); ret = -ETIMEDOUT; break; } } QDUMP("done"); return ret; }
0
486,795
static inline unsigned tx_desc_get_wrap(uint32_t *desc) { return (desc[1] & DESC_1_TX_WRAP) ? 1 : 0; }
0
512,541
bool val_native(THD *thd, Native *to) { return m_value.to_native(to, decimals); }
0
310,285
dirserv_free_all(void) { dirserv_free_fingerprint_list(); cached_dir_decref(the_directory); clear_cached_dir(&the_runningrouters); cached_dir_decref(the_v2_networkstatus); cached_dir_decref(cached_directory); clear_cached_dir(&cached_runningrouters); digestmap_free(cached_v2_networkstatus, _free_cached_dir); cached_v2_networkstatus = NULL; strmap_free(cached_consensuses, _free_cached_dir); cached_consensuses = NULL; }
0
225,074
emitHostIdentityInfo(PGconn *conn, const char *host_addr) { #ifdef HAVE_UNIX_SOCKETS if (IS_AF_UNIX(conn->raddr.addr.ss_family)) { char service[NI_MAXHOST]; pg_getnameinfo_all(&conn->raddr.addr, conn->raddr.salen, NULL, 0, service, sizeof(service), NI_NUMERICSERV); appendPQExpBuffer(&conn->errorMessage, libpq_gettext("connection to server on socket \"%s\" failed: "), service); } else #endif /* HAVE_UNIX_SOCKETS */ { const char *displayed_host; const char *displayed_port; /* To which host and port were we actually connecting? */ if (conn->connhost[conn->whichhost].type == CHT_HOST_ADDRESS) displayed_host = conn->connhost[conn->whichhost].hostaddr; else displayed_host = conn->connhost[conn->whichhost].host; displayed_port = conn->connhost[conn->whichhost].port; if (displayed_port == NULL || displayed_port[0] == '\0') displayed_port = DEF_PGPORT_STR; /* * If the user did not supply an IP address using 'hostaddr', and * 'host' was missing or does not match our lookup, display the * looked-up IP address. */ if (conn->connhost[conn->whichhost].type != CHT_HOST_ADDRESS && host_addr[0] && strcmp(displayed_host, host_addr) != 0) appendPQExpBuffer(&conn->errorMessage, libpq_gettext("connection to server at \"%s\" (%s), port %s failed: "), displayed_host, host_addr, displayed_port); else appendPQExpBuffer(&conn->errorMessage, libpq_gettext("connection to server at \"%s\", port %s failed: "), displayed_host, displayed_port); } }
0
244,262
GF_Err lsrc_box_size(GF_Box *s) { GF_LASERConfigurationBox *ptr = (GF_LASERConfigurationBox *)s; ptr->size += ptr->hdr_size; return GF_OK; }
0
253,728
int ccp_run_cmd(struct ccp_cmd_queue *cmd_q, struct ccp_cmd *cmd) { int ret; cmd->engine_error = 0; cmd_q->cmd_error = 0; cmd_q->int_rcvd = 0; cmd_q->free_slots = cmd_q->ccp->vdata->perform->get_free_slots(cmd_q); switch (cmd->engine) { case CCP_ENGINE_AES: switch (cmd->u.aes.mode) { case CCP_AES_MODE_CMAC: ret = ccp_run_aes_cmac_cmd(cmd_q, cmd); break; case CCP_AES_MODE_GCM: ret = ccp_run_aes_gcm_cmd(cmd_q, cmd); break; default: ret = ccp_run_aes_cmd(cmd_q, cmd); break; } break; case CCP_ENGINE_XTS_AES_128: ret = ccp_run_xts_aes_cmd(cmd_q, cmd); break; case CCP_ENGINE_DES3: ret = ccp_run_des3_cmd(cmd_q, cmd); break; case CCP_ENGINE_SHA: ret = ccp_run_sha_cmd(cmd_q, cmd); break; case CCP_ENGINE_RSA: ret = ccp_run_rsa_cmd(cmd_q, cmd); break; case CCP_ENGINE_PASSTHRU: if (cmd->flags & CCP_CMD_PASSTHRU_NO_DMA_MAP) ret = ccp_run_passthru_nomap_cmd(cmd_q, cmd); else ret = ccp_run_passthru_cmd(cmd_q, cmd); break; case CCP_ENGINE_ECC: ret = ccp_run_ecc_cmd(cmd_q, cmd); break; default: ret = -EINVAL; } return ret; }
0
242,575
handle_image (void *data, unsigned int datasize, EFI_LOADED_IMAGE *li, EFI_IMAGE_ENTRY_POINT *entry_point, EFI_PHYSICAL_ADDRESS *alloc_address, UINTN *alloc_pages) { EFI_STATUS efi_status; char *buffer; int i; EFI_IMAGE_SECTION_HEADER *Section; char *base, *end; UINT32 size; PE_COFF_LOADER_IMAGE_CONTEXT context; unsigned int alignment, alloc_size; int found_entry_point = 0; UINT8 sha1hash[SHA1_DIGEST_SIZE]; UINT8 sha256hash[SHA256_DIGEST_SIZE]; /* * The binary header contains relevant context and section pointers */ efi_status = read_header(data, datasize, &context); if (EFI_ERROR(efi_status)) { perror(L"Failed to read header: %r\n", efi_status); return efi_status; } /* * Perform the image verification before we start copying data around * in order to load it. */ if (secure_mode ()) { efi_status = verify_buffer(data, datasize, &context, sha256hash, sha1hash); if (EFI_ERROR(efi_status)) { if (verbose) console_print(L"Verification failed: %r\n", efi_status); else console_error(L"Verification failed", efi_status); return efi_status; } else { if (verbose) console_print(L"Verification succeeded\n"); } } /* * Calculate the hash for the TPM measurement. * XXX: We're computing these twice in secure boot mode when the * buffers already contain the previously computed hashes. Also, * this is only useful for the TPM1.2 case. We should try to fix * this in a follow-up. */ efi_status = generate_hash(data, datasize, &context, sha256hash, sha1hash); if (EFI_ERROR(efi_status)) return efi_status; /* Measure the binary into the TPM */ #ifdef REQUIRE_TPM efi_status = #endif tpm_log_pe((EFI_PHYSICAL_ADDRESS)(UINTN)data, datasize, (EFI_PHYSICAL_ADDRESS)(UINTN)context.ImageAddress, li->FilePath, sha1hash, 4); #ifdef REQUIRE_TPM if (efi_status != EFI_SUCCESS) { return efi_status; } #endif /* The spec says, uselessly, of SectionAlignment: * ===== * The alignment (in bytes) of sections when they are loaded into * memory. It must be greater than or equal to FileAlignment. The * default is the page size for the architecture. * ===== * Which doesn't tell you whose responsibility it is to enforce the * "default", or when. It implies that the value in the field must * be > FileAlignment (also poorly defined), but it appears visual * studio will happily write 512 for FileAlignment (its default) and * 0 for SectionAlignment, intending to imply PAGE_SIZE. * * We only support one page size, so if it's zero, nerf it to 4096. */ alignment = context.SectionAlignment; if (!alignment) alignment = 4096; alloc_size = ALIGN_VALUE(context.ImageSize + context.SectionAlignment, PAGE_SIZE); *alloc_pages = alloc_size / PAGE_SIZE; efi_status = BS->AllocatePages(AllocateAnyPages, EfiLoaderCode, *alloc_pages, alloc_address); if (EFI_ERROR(efi_status)) { perror(L"Failed to allocate image buffer\n"); return EFI_OUT_OF_RESOURCES; } buffer = (void *)ALIGN_VALUE((unsigned long)*alloc_address, alignment); dprint(L"Loading 0x%llx bytes at 0x%llx\n", (unsigned long long)context.ImageSize, (unsigned long long)(uintptr_t)buffer); update_mem_attrs((uintptr_t)buffer, alloc_size, MEM_ATTR_R|MEM_ATTR_W, MEM_ATTR_X); CopyMem(buffer, data, context.SizeOfHeaders); *entry_point = ImageAddress(buffer, context.ImageSize, context.EntryPoint); if (!*entry_point) { perror(L"Entry point is invalid\n"); BS->FreePages(*alloc_address, *alloc_pages); return EFI_UNSUPPORTED; } char *RelocBase, *RelocBaseEnd; /* * These are relative virtual addresses, so we have to check them * against the image size, not the data size. */ RelocBase = ImageAddress(buffer, context.ImageSize, context.RelocDir->VirtualAddress); /* * RelocBaseEnd here is the address of the last byte of the table */ RelocBaseEnd = ImageAddress(buffer, context.ImageSize, context.RelocDir->VirtualAddress + context.RelocDir->Size - 1); EFI_IMAGE_SECTION_HEADER *RelocSection = NULL; /* * Copy the executable's sections to their desired offsets */ Section = context.FirstSection; for (i = 0; i < context.NumberOfSections; i++, Section++) { /* Don't try to copy discardable sections with zero size */ if ((Section->Characteristics & EFI_IMAGE_SCN_MEM_DISCARDABLE) && !Section->Misc.VirtualSize) continue; /* * Skip sections that aren't marked readable. */ if (!(Section->Characteristics & EFI_IMAGE_SCN_MEM_READ)) continue; if (!(Section->Characteristics & EFI_IMAGE_SCN_MEM_DISCARDABLE) && (Section->Characteristics & EFI_IMAGE_SCN_MEM_WRITE) && (Section->Characteristics & EFI_IMAGE_SCN_MEM_EXECUTE) && (mok_policy & MOK_POLICY_REQUIRE_NX)) { perror(L"Section %d is writable and executable\n", i); return EFI_UNSUPPORTED; } base = ImageAddress (buffer, context.ImageSize, Section->VirtualAddress); end = ImageAddress (buffer, context.ImageSize, Section->VirtualAddress + Section->Misc.VirtualSize - 1); if (end < base) { perror(L"Section %d has negative size\n", i); BS->FreePages(*alloc_address, *alloc_pages); return EFI_UNSUPPORTED; } if (Section->VirtualAddress <= context.EntryPoint && (Section->VirtualAddress + Section->SizeOfRawData - 1) > context.EntryPoint) found_entry_point++; /* We do want to process .reloc, but it's often marked * discardable, so we don't want to memcpy it. */ if (CompareMem(Section->Name, ".reloc\0\0", 8) == 0) { if (RelocSection) { perror(L"Image has multiple relocation sections\n"); return EFI_UNSUPPORTED; } /* If it has nonzero sizes, and our bounds check * made sense, and the VA and size match RelocDir's * versions, then we believe in this section table. */ if (Section->SizeOfRawData && Section->Misc.VirtualSize && base && end && RelocBase == base && RelocBaseEnd == end) { RelocSection = Section; } } if (Section->Characteristics & EFI_IMAGE_SCN_MEM_DISCARDABLE) { continue; } if (!base) { perror(L"Section %d has invalid base address\n", i); return EFI_UNSUPPORTED; } if (!end) { perror(L"Section %d has zero size\n", i); return EFI_UNSUPPORTED; } if (!(Section->Characteristics & EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA) && (Section->VirtualAddress < context.SizeOfHeaders || Section->PointerToRawData < context.SizeOfHeaders)) { perror(L"Section %d is inside image headers\n", i); return EFI_UNSUPPORTED; } if (Section->Characteristics & EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA) { ZeroMem(base, Section->Misc.VirtualSize); } else { if (Section->PointerToRawData < context.SizeOfHeaders) { perror(L"Section %d is inside image headers\n", i); return EFI_UNSUPPORTED; } size = Section->Misc.VirtualSize; if (size > Section->SizeOfRawData) size = Section->SizeOfRawData; if (size > 0) CopyMem(base, data + Section->PointerToRawData, size); if (size < Section->Misc.VirtualSize) ZeroMem(base + size, Section->Misc.VirtualSize - size); } } if (context.NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) { perror(L"Image has no relocation entry\n"); FreePool(buffer); return EFI_UNSUPPORTED; } if (context.RelocDir->Size && RelocSection) { /* * Run the relocation fixups */ efi_status = relocate_coff(&context, RelocSection, data, buffer); if (EFI_ERROR(efi_status)) { perror(L"Relocation failed: %r\n", efi_status); FreePool(buffer); return efi_status; } } /* * Now set the page permissions appropriately. */ Section = context.FirstSection; for (i = 0; i < context.NumberOfSections; i++, Section++) { uint64_t set_attrs = MEM_ATTR_R; uint64_t clear_attrs = MEM_ATTR_W|MEM_ATTR_X; uintptr_t addr; uint64_t length; /* * Skip discardable sections with zero size */ if ((Section->Characteristics & EFI_IMAGE_SCN_MEM_DISCARDABLE) && !Section->Misc.VirtualSize) continue; /* * Skip sections that aren't marked readable. */ if (!(Section->Characteristics & EFI_IMAGE_SCN_MEM_READ)) continue; base = ImageAddress (buffer, context.ImageSize, Section->VirtualAddress); end = ImageAddress (buffer, context.ImageSize, Section->VirtualAddress + Section->Misc.VirtualSize - 1); addr = (uintptr_t)base; length = (uintptr_t)end - (uintptr_t)base + 1; if (Section->Characteristics & EFI_IMAGE_SCN_MEM_WRITE) { set_attrs |= MEM_ATTR_W; clear_attrs &= ~MEM_ATTR_W; } if (Section->Characteristics & EFI_IMAGE_SCN_MEM_EXECUTE) { set_attrs |= MEM_ATTR_X; clear_attrs &= ~MEM_ATTR_X; } update_mem_attrs(addr, length, set_attrs, clear_attrs); } /* * grub needs to know its location and size in memory, so fix up * the loaded image protocol values */ li->ImageBase = buffer; li->ImageSize = context.ImageSize; /* Pass the load options to the second stage loader */ li->LoadOptions = load_options; li->LoadOptionsSize = load_options_size; if (!found_entry_point) { perror(L"Entry point is not within sections\n"); return EFI_UNSUPPORTED; } if (found_entry_point > 1) { perror(L"%d sections contain entry point\n", found_entry_point); return EFI_UNSUPPORTED; } return EFI_SUCCESS; }
0
346,415
get_one_sourceline(source_cookie_T *sp) { garray_T ga; int len; int c; char_u *buf; #ifdef USE_CRNL int has_cr; // CR-LF found #endif int have_read = FALSE; // use a growarray to store the sourced line ga_init2(&ga, 1, 250); // Loop until there is a finished line (or end-of-file). ++sp->sourcing_lnum; for (;;) { // make room to read at least 120 (more) characters if (ga_grow(&ga, 120) == FAIL) break; if (sp->source_from_buf) { if (sp->buf_lnum >= sp->buflines.ga_len) break; // all the lines are processed ga_concat(&ga, ((char_u **)sp->buflines.ga_data)[sp->buf_lnum]); sp->buf_lnum++; if (ga_grow(&ga, 1) == FAIL) break; buf = (char_u *)ga.ga_data; buf[ga.ga_len++] = NUL; len = ga.ga_len; } else { buf = (char_u *)ga.ga_data; if (fgets((char *)buf + ga.ga_len, ga.ga_maxlen - ga.ga_len, sp->fp) == NULL) break; len = ga.ga_len + (int)STRLEN(buf + ga.ga_len); } #ifdef USE_CRNL // Ignore a trailing CTRL-Z, when in Dos mode. Only recognize the // CTRL-Z by its own, or after a NL. if ( (len == 1 || (len >= 2 && buf[len - 2] == '\n')) && sp->fileformat == EOL_DOS && buf[len - 1] == Ctrl_Z) { buf[len - 1] = NUL; break; } #endif have_read = TRUE; ga.ga_len = len; // If the line was longer than the buffer, read more. if (ga.ga_maxlen - ga.ga_len == 1 && buf[len - 1] != '\n') continue; if (len >= 1 && buf[len - 1] == '\n') // remove trailing NL { #ifdef USE_CRNL has_cr = (len >= 2 && buf[len - 2] == '\r'); if (sp->fileformat == EOL_UNKNOWN) { if (has_cr) sp->fileformat = EOL_DOS; else sp->fileformat = EOL_UNIX; } if (sp->fileformat == EOL_DOS) { if (has_cr) // replace trailing CR { buf[len - 2] = '\n'; --len; --ga.ga_len; } else // lines like ":map xx yy^M" will have failed { if (!sp->error) { msg_source(HL_ATTR(HLF_W)); emsg(_("W15: Warning: Wrong line separator, ^M may be missing")); } sp->error = TRUE; sp->fileformat = EOL_UNIX; } } #endif // The '\n' is escaped if there is an odd number of ^V's just // before it, first set "c" just before the 'V's and then check // len&c parities (is faster than ((len-c)%2 == 0)) -- Acevedo for (c = len - 2; c >= 0 && buf[c] == Ctrl_V; c--) ; if ((len & 1) != (c & 1)) // escaped NL, read more { ++sp->sourcing_lnum; continue; } buf[len - 1] = NUL; // remove the NL } // Check for ^C here now and then, so recursive :so can be broken. line_breakcheck(); break; } if (have_read) return (char_u *)ga.ga_data; vim_free(ga.ga_data); return NULL; }
0
256,145
ALWAYS_INLINE void LoadTwoScalars(const float** data, Packet* l1, Packet* l2) { LoadSingleScalar(data, l1); LoadSingleScalar(data, l2); }
0
265,436
static int sqfs_split_path(char **file, char **dir, const char *path) { char *dirc, *basec, *bname, *dname, *tmp_path; int ret = 0; *file = NULL; *dir = NULL; dirc = NULL; basec = NULL; bname = NULL; dname = NULL; tmp_path = NULL; /* check for first slash in path*/ if (path[0] == '/') { tmp_path = strdup(path); if (!tmp_path) { ret = -ENOMEM; goto out; } } else { tmp_path = malloc(strlen(path) + 2); if (!tmp_path) { ret = -ENOMEM; goto out; } tmp_path[0] = '/'; strcpy(tmp_path + 1, path); } /* String duplicates */ dirc = strdup(tmp_path); if (!dirc) { ret = -ENOMEM; goto out; } basec = strdup(tmp_path); if (!basec) { ret = -ENOMEM; goto out; } dname = sqfs_dirname(dirc); bname = sqfs_basename(basec); *file = strdup(bname); if (!*file) { ret = -ENOMEM; goto out; } if (*dname == '\0') { *dir = malloc(2); if (!*dir) { ret = -ENOMEM; goto out; } (*dir)[0] = '/'; (*dir)[1] = '\0'; } else { *dir = strdup(dname); if (!*dir) { ret = -ENOMEM; goto out; } } out: if (ret) { free(*file); free(*dir); *dir = NULL; *file = NULL; } free(basec); free(dirc); free(tmp_path); return ret; }
0
197,632
njs_promise_perform_then(njs_vm_t *vm, njs_value_t *value, njs_value_t *fulfilled, njs_value_t *rejected, njs_promise_capability_t *capability) { njs_int_t ret; njs_value_t arguments[2]; njs_promise_t *promise; njs_function_t *function; njs_promise_data_t *data; njs_promise_reaction_t *fulfilled_reaction, *rejected_reaction; if (!njs_is_function(fulfilled)) { fulfilled = njs_value_arg(&njs_value_undefined); } if (!njs_is_function(rejected)) { rejected = njs_value_arg(&njs_value_undefined); } promise = njs_promise(value); data = njs_data(&promise->value); fulfilled_reaction = njs_mp_alloc(vm->mem_pool, sizeof(njs_promise_reaction_t)); if (njs_slow_path(fulfilled_reaction == NULL)) { njs_memory_error(vm); return NJS_ERROR; } fulfilled_reaction->capability = capability; fulfilled_reaction->handler = *fulfilled; fulfilled_reaction->type = NJS_PROMISE_FULFILL; rejected_reaction = njs_mp_alloc(vm->mem_pool, sizeof(njs_promise_reaction_t)); if (njs_slow_path(rejected_reaction == NULL)) { njs_memory_error(vm); return NJS_ERROR; } rejected_reaction->capability = capability; rejected_reaction->handler = *rejected; rejected_reaction->type = NJS_PROMISE_REJECTED; if (data->state == NJS_PROMISE_PENDING) { njs_queue_insert_tail(&data->fulfill_queue, &fulfilled_reaction->link); njs_queue_insert_tail(&data->reject_queue, &rejected_reaction->link); } else { function = njs_promise_create_function(vm, sizeof(njs_promise_context_t)); function->u.native = njs_promise_reaction_job; if (data->state == NJS_PROMISE_REJECTED) { njs_set_data(&arguments[0], rejected_reaction, 0); ret = njs_promise_host_rejection_tracker(vm, promise, NJS_PROMISE_HANDLE); if (njs_slow_path(ret != NJS_OK)) { return ret; } } else { njs_set_data(&arguments[0], fulfilled_reaction, 0); } arguments[1] = data->result; ret = njs_promise_add_event(vm, function, arguments, 2); if (njs_slow_path(ret != NJS_OK)) { return ret; } } data->is_handled = 1; if (capability == NULL) { njs_vm_retval_set(vm, &njs_value_undefined); } else { njs_vm_retval_set(vm, &capability->promise); } return NJS_OK; }
1
236,197
GF_Box *diST_box_new() { ISOM_DECL_BOX_ALLOC(GF_DIMSScriptTypesBox, GF_ISOM_BOX_TYPE_DIST); return (GF_Box *)tmp; }
0
301,504
score_combine(suginfo_T *su) { int i; int j; garray_T ga; garray_T *gap; langp_T *lp; suggest_T *stp; char_u *p; char_u badsound[MAXWLEN]; int round; int lpi; slang_T *slang = NULL; // Add the alternate score to su_ga. for (lpi = 0; lpi < curwin->w_s->b_langp.ga_len; ++lpi) { lp = LANGP_ENTRY(curwin->w_s->b_langp, lpi); if (lp->lp_slang->sl_sal.ga_len > 0) { // soundfold the bad word slang = lp->lp_slang; spell_soundfold(slang, su->su_fbadword, TRUE, badsound); for (i = 0; i < su->su_ga.ga_len; ++i) { stp = &SUG(su->su_ga, i); stp->st_altscore = stp_sal_score(stp, su, slang, badsound); if (stp->st_altscore == SCORE_MAXMAX) stp->st_score = (stp->st_score * 3 + SCORE_BIG) / 4; else stp->st_score = (stp->st_score * 3 + stp->st_altscore) / 4; stp->st_salscore = FALSE; } break; } } if (slang == NULL) // Using "double" without sound folding. { (void)cleanup_suggestions(&su->su_ga, su->su_maxscore, su->su_maxcount); return; } // Add the alternate score to su_sga. for (i = 0; i < su->su_sga.ga_len; ++i) { stp = &SUG(su->su_sga, i); stp->st_altscore = spell_edit_score(slang, su->su_badword, stp->st_word); if (stp->st_score == SCORE_MAXMAX) stp->st_score = (SCORE_BIG * 7 + stp->st_altscore) / 8; else stp->st_score = (stp->st_score * 7 + stp->st_altscore) / 8; stp->st_salscore = TRUE; } // Remove bad suggestions, sort the suggestions and truncate at "maxcount" // for both lists. check_suggestions(su, &su->su_ga); (void)cleanup_suggestions(&su->su_ga, su->su_maxscore, su->su_maxcount); check_suggestions(su, &su->su_sga); (void)cleanup_suggestions(&su->su_sga, su->su_maxscore, su->su_maxcount); ga_init2(&ga, sizeof(suginfo_T), 1); if (ga_grow(&ga, su->su_ga.ga_len + su->su_sga.ga_len) == FAIL) return; stp = &SUG(ga, 0); for (i = 0; i < su->su_ga.ga_len || i < su->su_sga.ga_len; ++i) { // round 1: get a suggestion from su_ga // round 2: get a suggestion from su_sga for (round = 1; round <= 2; ++round) { gap = round == 1 ? &su->su_ga : &su->su_sga; if (i < gap->ga_len) { // Don't add a word if it's already there. p = SUG(*gap, i).st_word; for (j = 0; j < ga.ga_len; ++j) if (STRCMP(stp[j].st_word, p) == 0) break; if (j == ga.ga_len) stp[ga.ga_len++] = SUG(*gap, i); else vim_free(p); } } } ga_clear(&su->su_ga); ga_clear(&su->su_sga); // Truncate the list to the number of suggestions that will be displayed. if (ga.ga_len > su->su_maxcount) { for (i = su->su_maxcount; i < ga.ga_len; ++i) vim_free(stp[i].st_word); ga.ga_len = su->su_maxcount; } su->su_ga = ga; }
0
259,166
static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom) { // Set by mov_read_tfhd(). mov_read_trun() will reject files missing tfhd. c->fragment.found_tfhd = 0; if (!c->has_looked_for_mfra && c->use_mfra_for > 0) { c->has_looked_for_mfra = 1; if (pb->seekable & AVIO_SEEKABLE_NORMAL) { int ret; av_log(c->fc, AV_LOG_VERBOSE, "stream has moof boxes, will look " "for a mfra\n"); if ((ret = mov_read_mfra(c, pb)) < 0) { av_log(c->fc, AV_LOG_VERBOSE, "found a moof box but failed to " "read the mfra (may be a live ismv)\n"); } } else { av_log(c->fc, AV_LOG_VERBOSE, "found a moof box but stream is not " "seekable, can not look for mfra\n"); } } c->fragment.moof_offset = c->fragment.implicit_offset = avio_tell(pb) - 8; av_log(c->fc, AV_LOG_TRACE, "moof offset %"PRIx64"\n", c->fragment.moof_offset); c->frag_index.current = update_frag_index(c, c->fragment.moof_offset); return mov_read_default(c, pb, atom); }
0
219,001
bool ConstantFolding::IsZeros(const NodeDef& node) const { if (feed_nodes_.find(node.name()) != feed_nodes_.end()) { return false; } if (IsOnesLike(node)) return false; if (IsZerosLike(node)) return true; if (node.op() == "Fill") { NodeDef* values = node_map_->GetNode(NodeName(node.input(1))); return values != nullptr && IsZeros(*values); } if (!IsConstant(node)) return false; if (node.attr().count("dtype") == 0) return false; const auto dtype = node.attr().at("dtype").type(); switch (dtype) { IS_ZEROS_CASE(DT_BOOL); IS_ZEROS_CASE(DT_HALF); IS_ZEROS_CASE(DT_BFLOAT16); IS_ZEROS_CASE(DT_FLOAT); IS_ZEROS_CASE(DT_DOUBLE); IS_ZEROS_CASE(DT_COMPLEX64); IS_ZEROS_CASE(DT_COMPLEX128); IS_ZEROS_CASE(DT_UINT8); IS_ZEROS_CASE(DT_INT8); IS_ZEROS_CASE(DT_UINT16); IS_ZEROS_CASE(DT_INT16); IS_ZEROS_CASE(DT_INT32); IS_ZEROS_CASE(DT_INT64); IS_ZEROS_CASE(DT_QINT32); IS_ZEROS_CASE(DT_QINT16); IS_ZEROS_CASE(DT_QUINT16); IS_ZEROS_CASE(DT_QINT8); IS_ZEROS_CASE(DT_QUINT8); default: VLOG(1) << "Unsupported type " << DataTypeString(dtype); return false; } return false; }
0
222,670
void set_session_token(struct tmate_session *session, const char *token) { session->session_token = xstrdup(token); socket_path = get_socket_path(token); xasprintf((char **)&session->obfuscated_session_token, "%.4s...", session->session_token); size_t size = cmdline_end - cmdline; memset(cmdline, 0, size); snprintf(cmdline, size-1, "tmate-ssh-server [%s] %s %s", tmate_session->obfuscated_session_token, session->ssh_client.role == TMATE_ROLE_DAEMON ? "(daemon)" : "(pty client)", session->ssh_client.ip_address); char *log_prefix; xasprintf(&log_prefix, "[%s] ", session->obfuscated_session_token); set_log_prefix(log_prefix); free(log_prefix); }
0
386,480
void DL_Dxf::addDimRadial(DL_CreationInterface* creationInterface) { DL_DimensionData d = getDimData(); DL_DimRadialData dr( // definition point getRealValue(15, 0.0), getRealValue(25, 0.0), getRealValue(35, 0.0), // leader length: getRealValue(40, 0.0)); creationInterface->addDimRadial(d, dr); }
0
512,657
Field::geometry_type get_geometry_type() const { return Type_geometry_attributes::get_geometry_type(); }
0
294,626
Init_date_core(void) { #ifdef HAVE_RB_EXT_RACTOR_SAFE RB_EXT_RACTOR_SAFE(true); #endif id_cmp = rb_intern_const("<=>"); id_le_p = rb_intern_const("<="); id_ge_p = rb_intern_const(">="); id_eqeq_p = rb_intern_const("=="); half_days_in_day = rb_rational_new2(INT2FIX(1), INT2FIX(2)); #if (LONG_MAX / DAY_IN_SECONDS) > SECOND_IN_NANOSECONDS day_in_nanoseconds = LONG2NUM((long)DAY_IN_SECONDS * SECOND_IN_NANOSECONDS); #elif defined HAVE_LONG_LONG day_in_nanoseconds = LL2NUM((LONG_LONG)DAY_IN_SECONDS * SECOND_IN_NANOSECONDS); #else day_in_nanoseconds = f_mul(INT2FIX(DAY_IN_SECONDS), INT2FIX(SECOND_IN_NANOSECONDS)); #endif rb_gc_register_mark_object(half_days_in_day); rb_gc_register_mark_object(day_in_nanoseconds); positive_inf = +INFINITY; negative_inf = -INFINITY; /* * date and datetime class - Tadayoshi Funaba 1998-2011 * * 'date' provides two classes: Date and DateTime. * * == Terms and Definitions * * Some terms and definitions are based on ISO 8601 and JIS X 0301. * * === Calendar Date * * The calendar date is a particular day of a calendar year, * identified by its ordinal number within a calendar month within * that year. * * In those classes, this is so-called "civil". * * === Ordinal Date * * The ordinal date is a particular day of a calendar year identified * by its ordinal number within the year. * * In those classes, this is so-called "ordinal". * * === Week Date * * The week date is a date identified by calendar week and day numbers. * * The calendar week is a seven day period within a calendar year, * starting on a Monday and identified by its ordinal number within * the year; the first calendar week of the year is the one that * includes the first Thursday of that year. In the Gregorian * calendar, this is equivalent to the week which includes January 4. * * In those classes, this is so-called "commercial". * * === Julian Day Number * * The Julian day number is in elapsed days since noon (Greenwich Mean * Time) on January 1, 4713 BCE (in the Julian calendar). * * In this document, the astronomical Julian day number is the same as * the original Julian day number. And the chronological Julian day * number is a variation of the Julian day number. Its days begin at * midnight on local time. * * In this document, when the term "Julian day number" simply appears, * it just refers to "chronological Julian day number", not the * original. * * In those classes, those are so-called "ajd" and "jd". * * === Modified Julian Day Number * * The modified Julian day number is in elapsed days since midnight * (Coordinated Universal Time) on November 17, 1858 CE (in the * Gregorian calendar). * * In this document, the astronomical modified Julian day number is * the same as the original modified Julian day number. And the * chronological modified Julian day number is a variation of the * modified Julian day number. Its days begin at midnight on local * time. * * In this document, when the term "modified Julian day number" simply * appears, it just refers to "chronological modified Julian day * number", not the original. * * In those classes, those are so-called "amjd" and "mjd". * * == Date * * A subclass of Object that includes the Comparable module and * easily handles date. * * A Date object is created with Date::new, Date::jd, Date::ordinal, * Date::commercial, Date::parse, Date::strptime, Date::today, * Time#to_date, etc. * * require 'date' * * Date.new(2001,2,3) * #=> #<Date: 2001-02-03 ...> * Date.jd(2451944) * #=> #<Date: 2001-02-03 ...> * Date.ordinal(2001,34) * #=> #<Date: 2001-02-03 ...> * Date.commercial(2001,5,6) * #=> #<Date: 2001-02-03 ...> * Date.parse('2001-02-03') * #=> #<Date: 2001-02-03 ...> * Date.strptime('03-02-2001', '%d-%m-%Y') * #=> #<Date: 2001-02-03 ...> * Time.new(2001,2,3).to_date * #=> #<Date: 2001-02-03 ...> * * All date objects are immutable; hence cannot modify themselves. * * The concept of a date object can be represented as a tuple * of the day count, the offset and the day of calendar reform. * * The day count denotes the absolute position of a temporal * dimension. The offset is relative adjustment, which determines * decoded local time with the day count. The day of calendar * reform denotes the start day of the new style. The old style * of the West is the Julian calendar which was adopted by * Caesar. The new style is the Gregorian calendar, which is the * current civil calendar of many countries. * * The day count is virtually the astronomical Julian day number. * The offset in this class is usually zero, and cannot be * specified directly. * * A Date object can be created with an optional argument, * the day of calendar reform as a Julian day number, which * should be 2298874 to 2426355 or negative/positive infinity. * The default value is +Date::ITALY+ (2299161=1582-10-15). * See also sample/cal.rb. * * $ ruby sample/cal.rb -c it 10 1582 * October 1582 * S M Tu W Th F S * 1 2 3 4 15 16 * 17 18 19 20 21 22 23 * 24 25 26 27 28 29 30 * 31 * * $ ruby sample/cal.rb -c gb 9 1752 * September 1752 * S M Tu W Th F S * 1 2 14 15 16 * 17 18 19 20 21 22 23 * 24 25 26 27 28 29 30 * * A Date object has various methods. See each reference. * * d = Date.parse('3rd Feb 2001') * #=> #<Date: 2001-02-03 ...> * d.year #=> 2001 * d.mon #=> 2 * d.mday #=> 3 * d.wday #=> 6 * d += 1 #=> #<Date: 2001-02-04 ...> * d.strftime('%a %d %b %Y') #=> "Sun 04 Feb 2001" * */ cDate = rb_define_class("Date", rb_cObject); eDateError = rb_define_class_under(cDate, "Error", rb_eArgError); rb_include_module(cDate, rb_mComparable); /* An array of strings of full month names in English. The first * element is nil. */ rb_define_const(cDate, "MONTHNAMES", mk_ary_of_str(13, monthnames)); /* An array of strings of abbreviated month names in English. The * first element is nil. */ rb_define_const(cDate, "ABBR_MONTHNAMES", mk_ary_of_str(13, abbr_monthnames)); /* An array of strings of the full names of days of the week in English. * The first is "Sunday". */ rb_define_const(cDate, "DAYNAMES", mk_ary_of_str(7, daynames)); /* An array of strings of abbreviated day names in English. The * first is "Sun". */ rb_define_const(cDate, "ABBR_DAYNAMES", mk_ary_of_str(7, abbr_daynames)); /* The Julian day number of the day of calendar reform for Italy * and some catholic countries. */ rb_define_const(cDate, "ITALY", INT2FIX(ITALY)); /* The Julian day number of the day of calendar reform for England * and her colonies. */ rb_define_const(cDate, "ENGLAND", INT2FIX(ENGLAND)); /* The Julian day number of the day of calendar reform for the * proleptic Julian calendar. */ rb_define_const(cDate, "JULIAN", DBL2NUM(JULIAN)); /* The Julian day number of the day of calendar reform for the * proleptic Gregorian calendar. */ rb_define_const(cDate, "GREGORIAN", DBL2NUM(GREGORIAN)); rb_define_alloc_func(cDate, d_lite_s_alloc_simple); #ifndef NDEBUG rb_define_private_method(CLASS_OF(cDate), "_valid_jd?", date_s__valid_jd_p, -1); rb_define_private_method(CLASS_OF(cDate), "_valid_ordinal?", date_s__valid_ordinal_p, -1); rb_define_private_method(CLASS_OF(cDate), "_valid_civil?", date_s__valid_civil_p, -1); rb_define_private_method(CLASS_OF(cDate), "_valid_date?", date_s__valid_civil_p, -1); rb_define_private_method(CLASS_OF(cDate), "_valid_commercial?", date_s__valid_commercial_p, -1); rb_define_private_method(CLASS_OF(cDate), "_valid_weeknum?", date_s__valid_weeknum_p, -1); rb_define_private_method(CLASS_OF(cDate), "_valid_nth_kday?", date_s__valid_nth_kday_p, -1); #endif rb_define_singleton_method(cDate, "valid_jd?", date_s_valid_jd_p, -1); rb_define_singleton_method(cDate, "valid_ordinal?", date_s_valid_ordinal_p, -1); rb_define_singleton_method(cDate, "valid_civil?", date_s_valid_civil_p, -1); rb_define_singleton_method(cDate, "valid_date?", date_s_valid_civil_p, -1); rb_define_singleton_method(cDate, "valid_commercial?", date_s_valid_commercial_p, -1); #ifndef NDEBUG rb_define_private_method(CLASS_OF(cDate), "valid_weeknum?", date_s_valid_weeknum_p, -1); rb_define_private_method(CLASS_OF(cDate), "valid_nth_kday?", date_s_valid_nth_kday_p, -1); rb_define_private_method(CLASS_OF(cDate), "zone_to_diff", date_s_zone_to_diff, 1); #endif rb_define_singleton_method(cDate, "julian_leap?", date_s_julian_leap_p, 1); rb_define_singleton_method(cDate, "gregorian_leap?", date_s_gregorian_leap_p, 1); rb_define_singleton_method(cDate, "leap?", date_s_gregorian_leap_p, 1); #ifndef NDEBUG rb_define_singleton_method(cDate, "new!", date_s_new_bang, -1); rb_define_alias(rb_singleton_class(cDate), "new_l!", "new"); #endif rb_define_singleton_method(cDate, "jd", date_s_jd, -1); rb_define_singleton_method(cDate, "ordinal", date_s_ordinal, -1); rb_define_singleton_method(cDate, "civil", date_s_civil, -1); rb_define_singleton_method(cDate, "commercial", date_s_commercial, -1); #ifndef NDEBUG rb_define_singleton_method(cDate, "weeknum", date_s_weeknum, -1); rb_define_singleton_method(cDate, "nth_kday", date_s_nth_kday, -1); #endif rb_define_singleton_method(cDate, "today", date_s_today, -1); rb_define_singleton_method(cDate, "_strptime", date_s__strptime, -1); rb_define_singleton_method(cDate, "strptime", date_s_strptime, -1); rb_define_singleton_method(cDate, "_parse", date_s__parse, -1); rb_define_singleton_method(cDate, "parse", date_s_parse, -1); rb_define_singleton_method(cDate, "_iso8601", date_s__iso8601, -1); rb_define_singleton_method(cDate, "iso8601", date_s_iso8601, -1); rb_define_singleton_method(cDate, "_rfc3339", date_s__rfc3339, -1); rb_define_singleton_method(cDate, "rfc3339", date_s_rfc3339, -1); rb_define_singleton_method(cDate, "_xmlschema", date_s__xmlschema, -1); rb_define_singleton_method(cDate, "xmlschema", date_s_xmlschema, -1); rb_define_singleton_method(cDate, "_rfc2822", date_s__rfc2822, -1); rb_define_singleton_method(cDate, "_rfc822", date_s__rfc2822, -1); rb_define_singleton_method(cDate, "rfc2822", date_s_rfc2822, -1); rb_define_singleton_method(cDate, "rfc822", date_s_rfc2822, -1); rb_define_singleton_method(cDate, "_httpdate", date_s__httpdate, -1); rb_define_singleton_method(cDate, "httpdate", date_s_httpdate, -1); rb_define_singleton_method(cDate, "_jisx0301", date_s__jisx0301, -1); rb_define_singleton_method(cDate, "jisx0301", date_s_jisx0301, -1); rb_define_method(cDate, "initialize", date_initialize, -1); rb_define_method(cDate, "initialize_copy", d_lite_initialize_copy, 1); #ifndef NDEBUG rb_define_method(cDate, "fill", d_lite_fill, 0); #endif rb_define_method(cDate, "ajd", d_lite_ajd, 0); rb_define_method(cDate, "amjd", d_lite_amjd, 0); rb_define_method(cDate, "jd", d_lite_jd, 0); rb_define_method(cDate, "mjd", d_lite_mjd, 0); rb_define_method(cDate, "ld", d_lite_ld, 0); rb_define_method(cDate, "year", d_lite_year, 0); rb_define_method(cDate, "yday", d_lite_yday, 0); rb_define_method(cDate, "mon", d_lite_mon, 0); rb_define_method(cDate, "month", d_lite_mon, 0); rb_define_method(cDate, "mday", d_lite_mday, 0); rb_define_method(cDate, "day", d_lite_mday, 0); rb_define_method(cDate, "day_fraction", d_lite_day_fraction, 0); rb_define_method(cDate, "cwyear", d_lite_cwyear, 0); rb_define_method(cDate, "cweek", d_lite_cweek, 0); rb_define_method(cDate, "cwday", d_lite_cwday, 0); #ifndef NDEBUG rb_define_private_method(cDate, "wnum0", d_lite_wnum0, 0); rb_define_private_method(cDate, "wnum1", d_lite_wnum1, 0); #endif rb_define_method(cDate, "wday", d_lite_wday, 0); rb_define_method(cDate, "sunday?", d_lite_sunday_p, 0); rb_define_method(cDate, "monday?", d_lite_monday_p, 0); rb_define_method(cDate, "tuesday?", d_lite_tuesday_p, 0); rb_define_method(cDate, "wednesday?", d_lite_wednesday_p, 0); rb_define_method(cDate, "thursday?", d_lite_thursday_p, 0); rb_define_method(cDate, "friday?", d_lite_friday_p, 0); rb_define_method(cDate, "saturday?", d_lite_saturday_p, 0); #ifndef NDEBUG rb_define_method(cDate, "nth_kday?", d_lite_nth_kday_p, 2); #endif rb_define_private_method(cDate, "hour", d_lite_zero, 0); rb_define_private_method(cDate, "min", d_lite_zero, 0); rb_define_private_method(cDate, "minute", d_lite_zero, 0); rb_define_private_method(cDate, "sec", d_lite_zero, 0); rb_define_private_method(cDate, "second", d_lite_zero, 0); rb_define_method(cDate, "julian?", d_lite_julian_p, 0); rb_define_method(cDate, "gregorian?", d_lite_gregorian_p, 0); rb_define_method(cDate, "leap?", d_lite_leap_p, 0); rb_define_method(cDate, "start", d_lite_start, 0); rb_define_method(cDate, "new_start", d_lite_new_start, -1); rb_define_method(cDate, "italy", d_lite_italy, 0); rb_define_method(cDate, "england", d_lite_england, 0); rb_define_method(cDate, "julian", d_lite_julian, 0); rb_define_method(cDate, "gregorian", d_lite_gregorian, 0); rb_define_method(cDate, "+", d_lite_plus, 1); rb_define_method(cDate, "-", d_lite_minus, 1); rb_define_method(cDate, "next_day", d_lite_next_day, -1); rb_define_method(cDate, "prev_day", d_lite_prev_day, -1); rb_define_method(cDate, "next", d_lite_next, 0); rb_define_method(cDate, "succ", d_lite_next, 0); rb_define_method(cDate, ">>", d_lite_rshift, 1); rb_define_method(cDate, "<<", d_lite_lshift, 1); rb_define_method(cDate, "next_month", d_lite_next_month, -1); rb_define_method(cDate, "prev_month", d_lite_prev_month, -1); rb_define_method(cDate, "next_year", d_lite_next_year, -1); rb_define_method(cDate, "prev_year", d_lite_prev_year, -1); rb_define_method(cDate, "step", d_lite_step, -1); rb_define_method(cDate, "upto", d_lite_upto, 1); rb_define_method(cDate, "downto", d_lite_downto, 1); rb_define_method(cDate, "<=>", d_lite_cmp, 1); rb_define_method(cDate, "===", d_lite_equal, 1); rb_define_method(cDate, "eql?", d_lite_eql_p, 1); rb_define_method(cDate, "hash", d_lite_hash, 0); rb_define_method(cDate, "to_s", d_lite_to_s, 0); #ifndef NDEBUG rb_define_method(cDate, "inspect_raw", d_lite_inspect_raw, 0); #endif rb_define_method(cDate, "inspect", d_lite_inspect, 0); rb_define_method(cDate, "strftime", d_lite_strftime, -1); rb_define_method(cDate, "asctime", d_lite_asctime, 0); rb_define_method(cDate, "ctime", d_lite_asctime, 0); rb_define_method(cDate, "iso8601", d_lite_iso8601, 0); rb_define_method(cDate, "xmlschema", d_lite_iso8601, 0); rb_define_method(cDate, "rfc3339", d_lite_rfc3339, 0); rb_define_method(cDate, "rfc2822", d_lite_rfc2822, 0); rb_define_method(cDate, "rfc822", d_lite_rfc2822, 0); rb_define_method(cDate, "httpdate", d_lite_httpdate, 0); rb_define_method(cDate, "jisx0301", d_lite_jisx0301, 0); #ifndef NDEBUG rb_define_method(cDate, "marshal_dump_old", d_lite_marshal_dump_old, 0); #endif rb_define_method(cDate, "marshal_dump", d_lite_marshal_dump, 0); rb_define_method(cDate, "marshal_load", d_lite_marshal_load, 1); rb_define_singleton_method(cDate, "_load", date_s__load, 1); /* * == DateTime * * A subclass of Date that easily handles date, hour, minute, second, * and offset. * * DateTime class is considered deprecated. Use Time class. * * DateTime does not consider any leap seconds, does not track * any summer time rules. * * A DateTime object is created with DateTime::new, DateTime::jd, * DateTime::ordinal, DateTime::commercial, DateTime::parse, * DateTime::strptime, DateTime::now, Time#to_datetime, etc. * * require 'date' * * DateTime.new(2001,2,3,4,5,6) * #=> #<DateTime: 2001-02-03T04:05:06+00:00 ...> * * The last element of day, hour, minute, or second can be a * fractional number. The fractional number's precision is assumed * at most nanosecond. * * DateTime.new(2001,2,3.5) * #=> #<DateTime: 2001-02-03T12:00:00+00:00 ...> * * An optional argument, the offset, indicates the difference * between the local time and UTC. For example, <tt>Rational(3,24)</tt> * represents ahead of 3 hours of UTC, <tt>Rational(-5,24)</tt> represents * behind of 5 hours of UTC. The offset should be -1 to +1, and * its precision is assumed at most second. The default value is * zero (equals to UTC). * * DateTime.new(2001,2,3,4,5,6,Rational(3,24)) * #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...> * * The offset also accepts string form: * * DateTime.new(2001,2,3,4,5,6,'+03:00') * #=> #<DateTime: 2001-02-03T04:05:06+03:00 ...> * * An optional argument, the day of calendar reform (+start+), denotes * a Julian day number, which should be 2298874 to 2426355 or * negative/positive infinity. * The default value is +Date::ITALY+ (2299161=1582-10-15). * * A DateTime object has various methods. See each reference. * * d = DateTime.parse('3rd Feb 2001 04:05:06+03:30') * #=> #<DateTime: 2001-02-03T04:05:06+03:30 ...> * d.hour #=> 4 * d.min #=> 5 * d.sec #=> 6 * d.offset #=> (7/48) * d.zone #=> "+03:30" * d += Rational('1.5') * #=> #<DateTime: 2001-02-04%16:05:06+03:30 ...> * d = d.new_offset('+09:00') * #=> #<DateTime: 2001-02-04%21:35:06+09:00 ...> * d.strftime('%I:%M:%S %p') * #=> "09:35:06 PM" * d > DateTime.new(1999) * #=> true * * === When should you use DateTime and when should you use Time? * * It's a common misconception that * {William Shakespeare}[https://en.wikipedia.org/wiki/William_Shakespeare] * and * {Miguel de Cervantes}[https://en.wikipedia.org/wiki/Miguel_de_Cervantes] * died on the same day in history - * so much so that UNESCO named April 23 as * {World Book Day because of this fact}[https://en.wikipedia.org/wiki/World_Book_Day]. * However, because England hadn't yet adopted the * {Gregorian Calendar Reform}[https://en.wikipedia.org/wiki/Gregorian_calendar#Gregorian_reform] * (and wouldn't until {1752}[https://en.wikipedia.org/wiki/Calendar_(New_Style)_Act_1750]) * their deaths are actually 10 days apart. * Since Ruby's Time class implements a * {proleptic Gregorian calendar}[https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar] * and has no concept of calendar reform there's no way * to express this with Time objects. This is where DateTime steps in: * * shakespeare = DateTime.iso8601('1616-04-23', Date::ENGLAND) * #=> Tue, 23 Apr 1616 00:00:00 +0000 * cervantes = DateTime.iso8601('1616-04-23', Date::ITALY) * #=> Sat, 23 Apr 1616 00:00:00 +0000 * * Already you can see something is weird - the days of the week * are different. Taking this further: * * cervantes == shakespeare * #=> false * (shakespeare - cervantes).to_i * #=> 10 * * This shows that in fact they died 10 days apart (in reality * 11 days since Cervantes died a day earlier but was buried on * the 23rd). We can see the actual date of Shakespeare's death by * using the #gregorian method to convert it: * * shakespeare.gregorian * #=> Tue, 03 May 1616 00:00:00 +0000 * * So there's an argument that all the celebrations that take * place on the 23rd April in Stratford-upon-Avon are actually * the wrong date since England is now using the Gregorian calendar. * You can see why when we transition across the reform * date boundary: * * # start off with the anniversary of Shakespeare's birth in 1751 * shakespeare = DateTime.iso8601('1751-04-23', Date::ENGLAND) * #=> Tue, 23 Apr 1751 00:00:00 +0000 * * # add 366 days since 1752 is a leap year and April 23 is after February 29 * shakespeare + 366 * #=> Thu, 23 Apr 1752 00:00:00 +0000 * * # add another 365 days to take us to the anniversary in 1753 * shakespeare + 366 + 365 * #=> Fri, 04 May 1753 00:00:00 +0000 * * As you can see, if we're accurately tracking the number of * {solar years}[https://en.wikipedia.org/wiki/Tropical_year] * since Shakespeare's birthday then the correct anniversary date * would be the 4th May and not the 23rd April. * * So when should you use DateTime in Ruby and when should * you use Time? Almost certainly you'll want to use Time * since your app is probably dealing with current dates and * times. However, if you need to deal with dates and times in a * historical context you'll want to use DateTime to avoid * making the same mistakes as UNESCO. If you also have to deal * with timezones then best of luck - just bear in mind that * you'll probably be dealing with * {local solar times}[https://en.wikipedia.org/wiki/Solar_time], * since it wasn't until the 19th century that the introduction * of the railways necessitated the need for * {Standard Time}[https://en.wikipedia.org/wiki/Standard_time#Great_Britain] * and eventually timezones. */ cDateTime = rb_define_class("DateTime", cDate); rb_define_alloc_func(cDateTime, d_lite_s_alloc_complex); rb_define_singleton_method(cDateTime, "jd", datetime_s_jd, -1); rb_define_singleton_method(cDateTime, "ordinal", datetime_s_ordinal, -1); rb_define_singleton_method(cDateTime, "civil", datetime_s_civil, -1); rb_define_singleton_method(cDateTime, "new", datetime_s_civil, -1); rb_define_singleton_method(cDateTime, "commercial", datetime_s_commercial, -1); #ifndef NDEBUG rb_define_singleton_method(cDateTime, "weeknum", datetime_s_weeknum, -1); rb_define_singleton_method(cDateTime, "nth_kday", datetime_s_nth_kday, -1); #endif rb_undef_method(CLASS_OF(cDateTime), "today"); rb_define_singleton_method(cDateTime, "now", datetime_s_now, -1); rb_define_singleton_method(cDateTime, "_strptime", datetime_s__strptime, -1); rb_define_singleton_method(cDateTime, "strptime", datetime_s_strptime, -1); rb_define_singleton_method(cDateTime, "parse", datetime_s_parse, -1); rb_define_singleton_method(cDateTime, "iso8601", datetime_s_iso8601, -1); rb_define_singleton_method(cDateTime, "rfc3339", datetime_s_rfc3339, -1); rb_define_singleton_method(cDateTime, "xmlschema", datetime_s_xmlschema, -1); rb_define_singleton_method(cDateTime, "rfc2822", datetime_s_rfc2822, -1); rb_define_singleton_method(cDateTime, "rfc822", datetime_s_rfc2822, -1); rb_define_singleton_method(cDateTime, "httpdate", datetime_s_httpdate, -1); rb_define_singleton_method(cDateTime, "jisx0301", datetime_s_jisx0301, -1); rb_define_method(cDateTime, "hour", d_lite_hour, 0); rb_define_method(cDateTime, "min", d_lite_min, 0); rb_define_method(cDateTime, "minute", d_lite_min, 0); rb_define_method(cDateTime, "sec", d_lite_sec, 0); rb_define_method(cDateTime, "second", d_lite_sec, 0); rb_define_method(cDateTime, "sec_fraction", d_lite_sec_fraction, 0); rb_define_method(cDateTime, "second_fraction", d_lite_sec_fraction, 0); rb_define_method(cDateTime, "offset", d_lite_offset, 0); rb_define_method(cDateTime, "zone", d_lite_zone, 0); rb_define_method(cDateTime, "new_offset", d_lite_new_offset, -1); rb_define_method(cDateTime, "to_s", dt_lite_to_s, 0); rb_define_method(cDateTime, "strftime", dt_lite_strftime, -1); rb_define_method(cDateTime, "iso8601", dt_lite_iso8601, -1); rb_define_method(cDateTime, "xmlschema", dt_lite_iso8601, -1); rb_define_method(cDateTime, "rfc3339", dt_lite_rfc3339, -1); rb_define_method(cDateTime, "jisx0301", dt_lite_jisx0301, -1); /* conversions */ rb_define_method(rb_cTime, "to_time", time_to_time, 0); rb_define_method(rb_cTime, "to_date", time_to_date, 0); rb_define_method(rb_cTime, "to_datetime", time_to_datetime, 0); rb_define_method(cDate, "to_time", date_to_time, 0); rb_define_method(cDate, "to_date", date_to_date, 0); rb_define_method(cDate, "to_datetime", date_to_datetime, 0); rb_define_method(cDateTime, "to_time", datetime_to_time, 0); rb_define_method(cDateTime, "to_date", datetime_to_date, 0); rb_define_method(cDateTime, "to_datetime", datetime_to_datetime, 0); #ifndef NDEBUG /* tests */ rb_define_singleton_method(cDate, "test_civil", date_s_test_civil, 0); rb_define_singleton_method(cDate, "test_ordinal", date_s_test_ordinal, 0); rb_define_singleton_method(cDate, "test_commercial", date_s_test_commercial, 0); rb_define_singleton_method(cDate, "test_weeknum", date_s_test_weeknum, 0); rb_define_singleton_method(cDate, "test_nth_kday", date_s_test_nth_kday, 0); rb_define_singleton_method(cDate, "test_unit_conv", date_s_test_unit_conv, 0); rb_define_singleton_method(cDate, "test_all", date_s_test_all, 0); #endif }
0
294,524
date_s_jisx0301(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); if (!NIL_P(opt)) argc--; switch (argc) { case 0: str = rb_str_new2("-4712-01-01"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; if (!NIL_P(opt)) argv2[argc2++] = opt; VALUE hash = date_s__jisx0301(argc2, argv2, klass); return d_new_by_frags(klass, hash, sg); } }
0
424,940
iwl_pcie_set_interrupt_capa(struct pci_dev *pdev, struct iwl_trans *trans, const struct iwl_cfg_trans_params *cfg_trans) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); int max_irqs, num_irqs, i, ret; u16 pci_cmd; if (!cfg_trans->mq_rx_supported) goto enable_msi; max_irqs = min_t(u32, num_online_cpus() + 2, IWL_MAX_RX_HW_QUEUES); for (i = 0; i < max_irqs; i++) trans_pcie->msix_entries[i].entry = i; num_irqs = pci_enable_msix_range(pdev, trans_pcie->msix_entries, MSIX_MIN_INTERRUPT_VECTORS, max_irqs); if (num_irqs < 0) { IWL_DEBUG_INFO(trans, "Failed to enable msi-x mode (ret %d). Moving to msi mode.\n", num_irqs); goto enable_msi; } trans_pcie->def_irq = (num_irqs == max_irqs) ? num_irqs - 1 : 0; IWL_DEBUG_INFO(trans, "MSI-X enabled. %d interrupt vectors were allocated\n", num_irqs); /* * In case the OS provides fewer interrupts than requested, different * causes will share the same interrupt vector as follows: * One interrupt less: non rx causes shared with FBQ. * Two interrupts less: non rx causes shared with FBQ and RSS. * More than two interrupts: we will use fewer RSS queues. */ if (num_irqs <= max_irqs - 2) { trans_pcie->trans->num_rx_queues = num_irqs + 1; trans_pcie->shared_vec_mask = IWL_SHARED_IRQ_NON_RX | IWL_SHARED_IRQ_FIRST_RSS; } else if (num_irqs == max_irqs - 1) { trans_pcie->trans->num_rx_queues = num_irqs; trans_pcie->shared_vec_mask = IWL_SHARED_IRQ_NON_RX; } else { trans_pcie->trans->num_rx_queues = num_irqs - 1; } WARN_ON(trans_pcie->trans->num_rx_queues > IWL_MAX_RX_HW_QUEUES); trans_pcie->alloc_vecs = num_irqs; trans_pcie->msix_enabled = true; return; enable_msi: ret = pci_enable_msi(pdev); if (ret) { dev_err(&pdev->dev, "pci_enable_msi failed - %d\n", ret); /* enable rfkill interrupt: hw bug w/a */ pci_read_config_word(pdev, PCI_COMMAND, &pci_cmd); if (pci_cmd & PCI_COMMAND_INTX_DISABLE) { pci_cmd &= ~PCI_COMMAND_INTX_DISABLE; pci_write_config_word(pdev, PCI_COMMAND, pci_cmd); } } }
0
215,976
extract_group_icon_cursor_resource(WinLibrary *fi, WinResource *wr, char *lang, int *ressize, bool is_icon) { Win32CursorIconDir *icondir; Win32CursorIconFileDir *fileicondir; char *memory; int c, size, offset, skipped; /* get resource data and size */ icondir = (Win32CursorIconDir *) get_resource_entry(fi, wr, &size); if (icondir == NULL) { /* get_resource_entry will print error */ return NULL; } /* calculate total size of output file */ RETURN_IF_BAD_POINTER(NULL, icondir->count); skipped = 0; for (c = 0 ; c < icondir->count ; c++) { int level; int iconsize; char name[14]; WinResource *fwr; RETURN_IF_BAD_POINTER(NULL, icondir->entries[c]); /*printf("%d. bytes_in_res=%d width=%d height=%d planes=%d bit_count=%d\n", c, icondir->entries[c].bytes_in_res, (is_icon ? icondir->entries[c].res_info.icon.width : icondir->entries[c].res_info.cursor.width), (is_icon ? icondir->entries[c].res_info.icon.height : icondir->entries[c].res_info.cursor.height), icondir->entries[c].plane_count, icondir->entries[c].bit_count);*/ /* find the corresponding icon resource */ snprintf(name, sizeof(name)/sizeof(char), "-%d", icondir->entries[c].res_id); fwr = find_resource(fi, (is_icon ? "-3" : "-1"), name, lang, &level); if (fwr == NULL) { warn(_("%s: could not find `%s' in `%s' resource."), fi->name, &name[1], (is_icon ? "group_icon" : "group_cursor")); return NULL; } if (get_resource_entry(fi, fwr, &iconsize) != NULL) { if (iconsize == 0) { warn(_("%s: icon resource `%s' is empty, skipping"), fi->name, name); skipped++; continue; } if (iconsize != icondir->entries[c].bytes_in_res) { warn(_("%s: mismatch of size in icon resource `%s' and group (%d vs %d)"), fi->name, name, iconsize, icondir->entries[c].bytes_in_res); } size += iconsize < icondir->entries[c].bytes_in_res ? icondir->entries[c].bytes_in_res : iconsize; /* cursor resources have two additional WORDs that contain * hotspot info */ if (!is_icon) size -= sizeof(uint16_t)*2; } } offset = sizeof(Win32CursorIconFileDir) + (icondir->count-skipped) * sizeof(Win32CursorIconFileDirEntry); size += offset; *ressize = size; /* allocate that much memory */ memory = xmalloc(size); fileicondir = (Win32CursorIconFileDir *) memory; /* transfer Win32CursorIconDir structure members */ fileicondir->reserved = icondir->reserved; fileicondir->type = icondir->type; fileicondir->count = icondir->count - skipped; /* transfer each cursor/icon: Win32CursorIconDirEntry and data */ skipped = 0; for (c = 0 ; c < icondir->count ; c++) { int level; char name[14]; WinResource *fwr; char *data; /* find the corresponding icon resource */ snprintf(name, sizeof(name)/sizeof(char), "-%d", icondir->entries[c].res_id); fwr = find_resource(fi, (is_icon ? "-3" : "-1"), name, lang, &level); if (fwr == NULL) { warn(_("%s: could not find `%s' in `%s' resource."), fi->name, &name[1], (is_icon ? "group_icon" : "group_cursor")); return NULL; } /* get data and size of that resource */ data = get_resource_entry(fi, fwr, &size); if (data == NULL) { /* get_resource_entry has printed error */ return NULL; } if (size == 0) { skipped++; continue; } /* copy ICONDIRENTRY (not including last dwImageOffset) */ memcpy(&fileicondir->entries[c-skipped], &icondir->entries[c], sizeof(Win32CursorIconFileDirEntry)-sizeof(uint32_t)); /* special treatment for cursors */ if (!is_icon) { fileicondir->entries[c-skipped].width = icondir->entries[c].res_info.cursor.width; fileicondir->entries[c-skipped].height = icondir->entries[c].res_info.cursor.height / 2; fileicondir->entries[c-skipped].color_count = 0; fileicondir->entries[c-skipped].reserved = 0; } /* set image offset and increase it */ fileicondir->entries[c-skipped].dib_offset = offset; /* transfer resource into file memory */ if (is_icon) { memcpy(&memory[offset], data, icondir->entries[c].bytes_in_res); } else { fileicondir->entries[c-skipped].hotspot_x = ((uint16_t *) data)[0]; fileicondir->entries[c-skipped].hotspot_y = ((uint16_t *) data)[1]; memcpy(&memory[offset], data+sizeof(uint16_t)*2, icondir->entries[c].bytes_in_res-sizeof(uint16_t)*2); offset -= sizeof(uint16_t)*2; } /* increase the offset pointer */ offset += icondir->entries[c].bytes_in_res; } return (void *) memory; }
1
508,844
bool st_select_lex_node::inc_in_sum_expr() { return 1; }
0
509,481
static void init_aria_psi_keys(void) { const char* category= "aria"; int count; count= array_elements(all_aria_mutexes); mysql_mutex_register(category, all_aria_mutexes, count); count= array_elements(all_aria_rwlocks); mysql_rwlock_register(category, all_aria_rwlocks, count); count= array_elements(all_aria_conds); mysql_cond_register(category, all_aria_conds, count); count= array_elements(all_aria_threads); mysql_thread_register(category, all_aria_threads, count); count= array_elements(all_aria_files); mysql_file_register(category, all_aria_files, count); # ifdef HAVE_PSI_STAGE_INTERFACE count= array_elements(all_aria_stages); mysql_stage_register(category, all_aria_stages, count); # endif /* HAVE_PSI_STAGE_INTERFACE */ }
0
512,881
longlong Item_func_truth::val_int() { return (val_bool() ? 1 : 0); }
0
514,309
int multi_update::prepare(List<Item> &not_used_values, SELECT_LEX_UNIT *lex_unit) { TABLE_LIST *table_ref; SQL_I_List<TABLE_LIST> update; table_map tables_to_update; Item_field *item; List_iterator_fast<Item> field_it(*fields); List_iterator_fast<Item> value_it(*values); uint i, max_fields; uint leaf_table_count= 0; List_iterator<TABLE_LIST> ti(updated_leaves); DBUG_ENTER("multi_update::prepare"); if (prepared) DBUG_RETURN(0); prepared= true; thd->count_cuted_fields= CHECK_FIELD_WARN; thd->cuted_fields=0L; THD_STAGE_INFO(thd, stage_updating_main_table); tables_to_update= get_table_map(fields); if (!tables_to_update) { my_message(ER_NO_TABLES_USED, ER_THD(thd, ER_NO_TABLES_USED), MYF(0)); DBUG_RETURN(1); } /* We gather the set of columns read during evaluation of SET expression in TABLE::tmp_set by pointing TABLE::read_set to it and then restore it after setup_fields(). */ while ((table_ref= ti++)) { if (table_ref->is_jtbm()) continue; TABLE *table= table_ref->table; if (tables_to_update & table->map) { DBUG_ASSERT(table->read_set == &table->def_read_set); table->read_set= &table->tmp_set; bitmap_clear_all(table->read_set); } } /* We have to check values after setup_tables to get covering_keys right in reference tables */ int error= setup_fields(thd, Ref_ptr_array(), *values, MARK_COLUMNS_READ, 0, NULL, 0); ti.rewind(); while ((table_ref= ti++)) { if (table_ref->is_jtbm()) continue; TABLE *table= table_ref->table; if (tables_to_update & table->map) { table->read_set= &table->def_read_set; bitmap_union(table->read_set, &table->tmp_set); } } if (unlikely(error)) DBUG_RETURN(1); /* Save tables beeing updated in update_tables update_table->shared is position for table Don't use key read on tables that are updated */ update.empty(); ti.rewind(); while ((table_ref= ti++)) { /* TODO: add support of view of join support */ if (table_ref->is_jtbm()) continue; TABLE *table=table_ref->table; leaf_table_count++; if (tables_to_update & table->map) { TABLE_LIST *tl= (TABLE_LIST*) thd->memdup(table_ref, sizeof(*tl)); if (!tl) DBUG_RETURN(1); update.link_in_list(tl, &tl->next_local); tl->shared= table_count++; table->no_keyread=1; table->covering_keys.clear_all(); table->pos_in_table_list= tl; table->prepare_triggers_for_update_stmt_or_event(); table->reset_default_fields(); } } table_count= update.elements; update_tables= update.first; tmp_tables = (TABLE**) thd->calloc(sizeof(TABLE *) * table_count); tmp_table_param = (TMP_TABLE_PARAM*) thd->calloc(sizeof(TMP_TABLE_PARAM) * table_count); fields_for_table= (List_item **) thd->alloc(sizeof(List_item *) * table_count); values_for_table= (List_item **) thd->alloc(sizeof(List_item *) * table_count); if (unlikely(thd->is_fatal_error)) DBUG_RETURN(1); for (i=0 ; i < table_count ; i++) { fields_for_table[i]= new List_item; values_for_table[i]= new List_item; } if (unlikely(thd->is_fatal_error)) DBUG_RETURN(1); /* Split fields into fields_for_table[] and values_by_table[] */ while ((item= (Item_field *) field_it++)) { Item *value= value_it++; uint offset= item->field->table->pos_in_table_list->shared; fields_for_table[offset]->push_back(item, thd->mem_root); values_for_table[offset]->push_back(value, thd->mem_root); } if (unlikely(thd->is_fatal_error)) DBUG_RETURN(1); /* Allocate copy fields */ max_fields=0; for (i=0 ; i < table_count ; i++) { set_if_bigger(max_fields, fields_for_table[i]->elements + leaf_table_count); if (fields_for_table[i]->elements) { TABLE *table= ((Item_field*)(fields_for_table[i]->head()))->field->table; switch_to_nullable_trigger_fields(*fields_for_table[i], table); switch_to_nullable_trigger_fields(*values_for_table[i], table); } } copy_field= new (thd->mem_root) Copy_field[max_fields]; DBUG_RETURN(thd->is_fatal_error != 0); }
0
227,022
IRC_PROTOCOL_CALLBACK(352) { char *pos_attr, *pos_hopcount, *pos_realname, *str_host; int arg_start, length; struct t_irc_channel *ptr_channel; struct t_irc_nick *ptr_nick; IRC_PROTOCOL_MIN_ARGS(5); /* silently ignore malformed 352 message (missing infos) */ if (argc < 8) return WEECHAT_RC_OK; pos_attr = NULL; pos_hopcount = NULL; pos_realname = NULL; if (argc > 8) { arg_start = ((argc > 9) && (strcmp (argv[8], "*") == 0)) ? 9 : 8; if (argv[arg_start][0] == ':') { pos_attr = NULL; pos_hopcount = (argc > arg_start) ? argv[arg_start] + 1 : NULL; pos_realname = (argc > arg_start + 1) ? argv_eol[arg_start + 1] : NULL; } else { pos_attr = argv[arg_start]; pos_hopcount = (argc > arg_start + 1) ? argv[arg_start + 1] + 1 : NULL; pos_realname = (argc > arg_start + 2) ? argv_eol[arg_start + 2] : NULL; } } ptr_channel = irc_channel_search (server, argv[3]); ptr_nick = (ptr_channel) ? irc_nick_search (server, ptr_channel, argv[7]) : NULL; /* update host in nick */ if (ptr_nick) { length = strlen (argv[4]) + 1 + strlen (argv[5]) + 1; str_host = malloc (length); if (str_host) { snprintf (str_host, length, "%s@%s", argv[4], argv[5]); irc_nick_set_host (ptr_nick, str_host); free (str_host); } } /* update away flag in nick */ if (ptr_channel && ptr_nick && pos_attr) { irc_nick_set_away (server, ptr_channel, ptr_nick, (pos_attr[0] == 'G') ? 1 : 0); } /* update realname in nick */ if (ptr_channel && ptr_nick && pos_realname) { if (ptr_nick->realname) free (ptr_nick->realname); if (pos_realname && weechat_hashtable_has_key (server->cap_list, "extended-join")) { ptr_nick->realname = strdup (pos_realname); } else { ptr_nick->realname = NULL; } } /* display output of who (manual who from user) */ if (!ptr_channel || (ptr_channel->checking_whox <= 0)) { weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer ( server, NULL, command, "who", NULL), date, irc_protocol_tags (command, "irc_numeric", NULL, NULL), "%s%s[%s%s%s] %s%s %s(%s%s@%s%s)%s %s%s%s%s(%s)", weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_CHANNEL, argv[3], IRC_COLOR_CHAT_DELIMITERS, irc_nick_color_for_msg (server, 1, NULL, argv[7]), argv[7], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_HOST, argv[4], argv[5], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, (pos_attr) ? pos_attr : "", (pos_attr) ? " " : "", (pos_hopcount) ? pos_hopcount : "", (pos_hopcount) ? " " : "", (pos_realname) ? pos_realname : ""); } return WEECHAT_RC_OK; }
0
294,591
datetime_s_ordinal(int argc, VALUE *argv, VALUE klass) { VALUE vy, vd, vh, vmin, vs, vof, vsg, y, fr, fr2, ret; int d, h, min, s, rof; double sg; rb_scan_args(argc, argv, "07", &vy, &vd, &vh, &vmin, &vs, &vof, &vsg); y = INT2FIX(-4712); d = 1; h = min = s = 0; fr2 = INT2FIX(0); rof = 0; sg = DEFAULT_SG; switch (argc) { case 7: val2sg(vsg, sg); case 6: val2off(vof, rof); case 5: check_numeric(vs, "second"); num2int_with_frac(s, positive_inf); case 4: check_numeric(vmin, "minute"); num2int_with_frac(min, 4); case 3: check_numeric(vh, "hour"); num2int_with_frac(h, 3); case 2: check_numeric(vd, "yday"); num2int_with_frac(d, 2); case 1: check_numeric(vy, "year"); y = vy; } { VALUE nth; int ry, rd, rh, rmin, rs, rjd, rjd2, ns; if (!valid_ordinal_p(y, d, sg, &nth, &ry, &rd, &rjd, &ns)) rb_raise(eDateError, "invalid date"); if (!c_valid_time_p(h, min, s, &rh, &rmin, &rs)) rb_raise(eDateError, "invalid date"); canon24oc(); rjd2 = jd_local_to_utc(rjd, time_to_df(rh, rmin, rs), rof); ret = d_complex_new_internal(klass, nth, rjd2, 0, INT2FIX(0), rof, sg, 0, 0, 0, rh, rmin, rs, HAVE_JD | HAVE_TIME); } add_frac(); return ret; }
0
359,399
bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi) { struct peer *peer; struct listnode *node, *nnode; unsigned int count = 0; char timebuf[BGP_UPTIME_LEN]; int len; /* Header string for each address family. */ static char header[] = "Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd"; for (ALL_LIST_ELEMENTS (bgp->peer, node, nnode, peer)) { if (peer->afc[afi][safi]) { if (!count) { unsigned long ents; char memstrbuf[MTYPE_MEMSTR_LEN]; /* Usage summary and header */ vty_out (vty, "BGP router identifier %s, local AS number %d%s", inet_ntoa (bgp->router_id), bgp->as, VTY_NEWLINE); ents = bgp_table_count (bgp->rib[afi][safi]); vty_out (vty, "RIB entries %ld, using %s of memory%s", ents, mtype_memstr (memstrbuf, sizeof (memstrbuf), ents * sizeof (struct bgp_node)), VTY_NEWLINE); /* Peer related usage */ ents = listcount (bgp->peer); vty_out (vty, "Peers %ld, using %s of memory%s", ents, mtype_memstr (memstrbuf, sizeof (memstrbuf), ents * sizeof (struct peer)), VTY_NEWLINE); if ((ents = listcount (bgp->rsclient))) vty_out (vty, "RS-Client peers %ld, using %s of memory%s", ents, mtype_memstr (memstrbuf, sizeof (memstrbuf), ents * sizeof (struct peer)), VTY_NEWLINE); if ((ents = listcount (bgp->group))) vty_out (vty, "Peer groups %ld, using %s of memory%s", ents, mtype_memstr (memstrbuf, sizeof (memstrbuf), ents * sizeof (struct peer_group)), VTY_NEWLINE); if (CHECK_FLAG (bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING)) vty_out (vty, "Dampening enabled.%s", VTY_NEWLINE); vty_out (vty, "%s", VTY_NEWLINE); vty_out (vty, "%s%s", header, VTY_NEWLINE); } count++; len = vty_out (vty, "%s", peer->host); len = 16 - len; if (len < 1) vty_out (vty, "%s%*s", VTY_NEWLINE, 16, " "); else vty_out (vty, "%*s", len, " "); vty_out (vty, "4 "); vty_out (vty, "%5d %7d %7d %8d %4d %4lu ", peer->as, peer->open_in + peer->update_in + peer->keepalive_in + peer->notify_in + peer->refresh_in + peer->dynamic_cap_in, peer->open_out + peer->update_out + peer->keepalive_out + peer->notify_out + peer->refresh_out + peer->dynamic_cap_out, 0, 0, (unsigned long)peer->obuf->count); vty_out (vty, "%8s", peer_uptime (peer->uptime, timebuf, BGP_UPTIME_LEN)); if (peer->status == Established) { vty_out (vty, " %8ld", peer->pcount[afi][safi]); } else { if (CHECK_FLAG (peer->flags, PEER_FLAG_SHUTDOWN)) vty_out (vty, " Idle (Admin)"); else if (CHECK_FLAG (peer->sflags, PEER_STATUS_PREFIX_OVERFLOW)) vty_out (vty, " Idle (PfxCt)"); else vty_out (vty, " %-11s", LOOKUP(bgp_status_msg, peer->status)); } vty_out (vty, "%s", VTY_NEWLINE); } } if (count) vty_out (vty, "%sTotal number of neighbors %d%s", VTY_NEWLINE, count, VTY_NEWLINE); else vty_out (vty, "No %s neighbor is configured%s", afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE); return CMD_SUCCESS; }
0
219,902
GF_Err gf_isom_sdp_clean_track(GF_ISOFile *the_file, u32 trackNumber) { GF_TrackBox *trak; GF_UserDataMap *map; GF_HintTrackInfoBox *hnti; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak) return GF_BAD_PARAM; //currently, only RTP hinting supports SDP if (!CheckHintFormat(trak, GF_ISOM_HINT_RTP)) return GF_BAD_PARAM; map = udta_getEntry(trak->udta, GF_ISOM_BOX_TYPE_HNTI, NULL); if (!map) return GF_ISOM_INVALID_FILE; //we should have only one HNTI in the UDTA if (gf_list_count(map->boxes) != 1) return GF_ISOM_INVALID_FILE; hnti = (GF_HintTrackInfoBox *)gf_list_get(map->boxes, 0); if (!hnti->SDP) return GF_OK; //and free the SDP gf_free(((GF_SDPBox *)hnti->SDP)->sdpText); ((GF_SDPBox *)hnti->SDP)->sdpText = NULL; return GF_OK; }
0
369,434
static int io_register_files_update(struct io_ring_ctx *ctx, void __user *arg, unsigned nr_args) { struct io_uring_rsrc_update2 up; if (!nr_args) return -EINVAL; memset(&up, 0, sizeof(up)); if (copy_from_user(&up, arg, sizeof(struct io_uring_rsrc_update))) return -EFAULT; if (up.resv || up.resv2) return -EINVAL; return __io_register_rsrc_update(ctx, IORING_RSRC_FILE, &up, nr_args);
0
206,417
ins_bs( int c, int mode, int *inserted_space_p) { linenr_T lnum; int cc; int temp = 0; // init for GCC colnr_T save_col; colnr_T mincol; int did_backspace = FALSE; int in_indent; int oldState; int cpc[MAX_MCO]; // composing characters int call_fix_indent = FALSE; /* * can't delete anything in an empty file * can't backup past first character in buffer * can't backup past starting point unless 'backspace' > 1 * can backup to a previous line if 'backspace' == 0 */ if ( BUFEMPTY() || ( #ifdef FEAT_RIGHTLEFT !revins_on && #endif ((curwin->w_cursor.lnum == 1 && curwin->w_cursor.col == 0) || (!can_bs(BS_START) && ((arrow_used #ifdef FEAT_JOB_CHANNEL && !bt_prompt(curbuf) #endif ) || (curwin->w_cursor.lnum == Insstart_orig.lnum && curwin->w_cursor.col <= Insstart_orig.col))) || (!can_bs(BS_INDENT) && !arrow_used && ai_col > 0 && curwin->w_cursor.col <= ai_col) || (!can_bs(BS_EOL) && curwin->w_cursor.col == 0)))) { vim_beep(BO_BS); return FALSE; } if (stop_arrow() == FAIL) return FALSE; in_indent = inindent(0); if (in_indent) can_cindent = FALSE; end_comment_pending = NUL; // After BS, don't auto-end comment #ifdef FEAT_RIGHTLEFT if (revins_on) // put cursor after last inserted char inc_cursor(); #endif // Virtualedit: // BACKSPACE_CHAR eats a virtual space // BACKSPACE_WORD eats all coladd // BACKSPACE_LINE eats all coladd and keeps going if (curwin->w_cursor.coladd > 0) { if (mode == BACKSPACE_CHAR) { --curwin->w_cursor.coladd; return TRUE; } if (mode == BACKSPACE_WORD) { curwin->w_cursor.coladd = 0; return TRUE; } curwin->w_cursor.coladd = 0; } /* * Delete newline! */ if (curwin->w_cursor.col == 0) { lnum = Insstart.lnum; if (curwin->w_cursor.lnum == lnum #ifdef FEAT_RIGHTLEFT || revins_on #endif ) { if (u_save((linenr_T)(curwin->w_cursor.lnum - 2), (linenr_T)(curwin->w_cursor.lnum + 1)) == FAIL) return FALSE; --Insstart.lnum; Insstart.col = (colnr_T)STRLEN(ml_get(Insstart.lnum)); } /* * In replace mode: * cc < 0: NL was inserted, delete it * cc >= 0: NL was replaced, put original characters back */ cc = -1; if (State & REPLACE_FLAG) cc = replace_pop(); // returns -1 if NL was inserted /* * In replace mode, in the line we started replacing, we only move the * cursor. */ if ((State & REPLACE_FLAG) && curwin->w_cursor.lnum <= lnum) { dec_cursor(); } else { if (!(State & VREPLACE_FLAG) || curwin->w_cursor.lnum > orig_line_count) { temp = gchar_cursor(); // remember current char --curwin->w_cursor.lnum; // When "aw" is in 'formatoptions' we must delete the space at // the end of the line, otherwise the line will be broken // again when auto-formatting. if (has_format_option(FO_AUTO) && has_format_option(FO_WHITE_PAR)) { char_u *ptr = ml_get_buf(curbuf, curwin->w_cursor.lnum, TRUE); int len; len = (int)STRLEN(ptr); if (len > 0 && ptr[len - 1] == ' ') ptr[len - 1] = NUL; } (void)do_join(2, FALSE, FALSE, FALSE, FALSE); if (temp == NUL && gchar_cursor() != NUL) inc_cursor(); } else dec_cursor(); /* * In MODE_REPLACE mode we have to put back the text that was * replaced by the NL. On the replace stack is first a * NUL-terminated sequence of characters that were deleted and then * the characters that NL replaced. */ if (State & REPLACE_FLAG) { /* * Do the next ins_char() in MODE_NORMAL state, to * prevent ins_char() from replacing characters and * avoiding showmatch(). */ oldState = State; State = MODE_NORMAL; /* * restore characters (blanks) deleted after cursor */ while (cc > 0) { save_col = curwin->w_cursor.col; mb_replace_pop_ins(cc); curwin->w_cursor.col = save_col; cc = replace_pop(); } // restore the characters that NL replaced replace_pop_ins(); State = oldState; } } did_ai = FALSE; } else { /* * Delete character(s) before the cursor. */ #ifdef FEAT_RIGHTLEFT if (revins_on) // put cursor on last inserted char dec_cursor(); #endif mincol = 0; // keep indent if (mode == BACKSPACE_LINE && (curbuf->b_p_ai || cindent_on()) #ifdef FEAT_RIGHTLEFT && !revins_on #endif ) { save_col = curwin->w_cursor.col; beginline(BL_WHITE); if (curwin->w_cursor.col < save_col) { mincol = curwin->w_cursor.col; // should now fix the indent to match with the previous line call_fix_indent = TRUE; } curwin->w_cursor.col = save_col; } /* * Handle deleting one 'shiftwidth' or 'softtabstop'. */ if ( mode == BACKSPACE_CHAR && ((p_sta && in_indent) || ((get_sts_value() != 0 #ifdef FEAT_VARTABS || tabstop_count(curbuf->b_p_vsts_array) #endif ) && curwin->w_cursor.col > 0 && (*(ml_get_cursor() - 1) == TAB || (*(ml_get_cursor() - 1) == ' ' && (!*inserted_space_p || arrow_used)))))) { int ts; colnr_T vcol; colnr_T want_vcol; colnr_T start_vcol; *inserted_space_p = FALSE; // Compute the virtual column where we want to be. Since // 'showbreak' may get in the way, need to get the last column of // the previous character. getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL); start_vcol = vcol; dec_cursor(); getvcol(curwin, &curwin->w_cursor, NULL, NULL, &want_vcol); inc_cursor(); #ifdef FEAT_VARTABS if (p_sta && in_indent) { ts = (int)get_sw_value(curbuf); want_vcol = (want_vcol / ts) * ts; } else want_vcol = tabstop_start(want_vcol, get_sts_value(), curbuf->b_p_vsts_array); #else if (p_sta && in_indent) ts = (int)get_sw_value(curbuf); else ts = (int)get_sts_value(); want_vcol = (want_vcol / ts) * ts; #endif // delete characters until we are at or before want_vcol while (vcol > want_vcol && (cc = *(ml_get_cursor() - 1), VIM_ISWHITE(cc))) ins_bs_one(&vcol); // insert extra spaces until we are at want_vcol while (vcol < want_vcol) { // Remember the first char we inserted if (curwin->w_cursor.lnum == Insstart_orig.lnum && curwin->w_cursor.col < Insstart_orig.col) Insstart_orig.col = curwin->w_cursor.col; if (State & VREPLACE_FLAG) ins_char(' '); else { ins_str((char_u *)" "); if ((State & REPLACE_FLAG)) replace_push(NUL); } getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL); } // If we are now back where we started delete one character. Can // happen when using 'sts' and 'linebreak'. if (vcol >= start_vcol) ins_bs_one(&vcol); } /* * Delete up to starting point, start of line or previous word. */ else { int cclass = 0, prev_cclass = 0; if (has_mbyte) cclass = mb_get_class(ml_get_cursor()); do { #ifdef FEAT_RIGHTLEFT if (!revins_on) // put cursor on char to be deleted #endif dec_cursor(); cc = gchar_cursor(); // look multi-byte character class if (has_mbyte) { prev_cclass = cclass; cclass = mb_get_class(ml_get_cursor()); } // start of word? if (mode == BACKSPACE_WORD && !vim_isspace(cc)) { mode = BACKSPACE_WORD_NOT_SPACE; temp = vim_iswordc(cc); } // end of word? else if (mode == BACKSPACE_WORD_NOT_SPACE && ((vim_isspace(cc) || vim_iswordc(cc) != temp) || prev_cclass != cclass)) { #ifdef FEAT_RIGHTLEFT if (!revins_on) #endif inc_cursor(); #ifdef FEAT_RIGHTLEFT else if (State & REPLACE_FLAG) dec_cursor(); #endif break; } if (State & REPLACE_FLAG) replace_do_bs(-1); else { if (enc_utf8 && p_deco) (void)utfc_ptr2char(ml_get_cursor(), cpc); (void)del_char(FALSE); /* * If there are combining characters and 'delcombine' is set * move the cursor back. Don't back up before the base * character. */ if (enc_utf8 && p_deco && cpc[0] != NUL) inc_cursor(); #ifdef FEAT_RIGHTLEFT if (revins_chars) { revins_chars--; revins_legal++; } if (revins_on && gchar_cursor() == NUL) break; #endif } // Just a single backspace?: if (mode == BACKSPACE_CHAR) break; } while ( #ifdef FEAT_RIGHTLEFT revins_on || #endif (curwin->w_cursor.col > mincol && (can_bs(BS_NOSTOP) || (curwin->w_cursor.lnum != Insstart_orig.lnum || curwin->w_cursor.col != Insstart_orig.col) ))); } did_backspace = TRUE; } did_si = FALSE; can_si = FALSE; can_si_back = FALSE; if (curwin->w_cursor.col <= 1) did_ai = FALSE; if (call_fix_indent) fix_indent(); /* * It's a little strange to put backspaces into the redo * buffer, but it makes auto-indent a lot easier to deal * with. */ AppendCharToRedobuff(c); // If deleted before the insertion point, adjust it if (curwin->w_cursor.lnum == Insstart_orig.lnum && curwin->w_cursor.col < Insstart_orig.col) Insstart_orig.col = curwin->w_cursor.col; // vi behaviour: the cursor moves backward but the character that // was there remains visible // Vim behaviour: the cursor moves backward and the character that // was there is erased from the screen. // We can emulate the vi behaviour by pretending there is a dollar // displayed even when there isn't. // --pkv Sun Jan 19 01:56:40 EST 2003 if (vim_strchr(p_cpo, CPO_BACKSPACE) != NULL && dollar_vcol == -1) dollar_vcol = curwin->w_virtcol; #ifdef FEAT_FOLDING // When deleting a char the cursor line must never be in a closed fold. // E.g., when 'foldmethod' is indent and deleting the first non-white // char before a Tab. if (did_backspace) foldOpenCursor(); #endif return did_backspace; }
1
358,128
sonmp_suite(void) { Suite *s = suite_create("SONMP"); #ifdef ENABLE_SONMP TCase *tc_send = tcase_create("Send SONMP packets"); TCase *tc_receive = tcase_create("Receive SONMP packets"); tcase_add_checked_fixture(tc_send, pcap_setup, pcap_teardown); tcase_add_test(tc_send, test_send_sonmp); suite_add_tcase(s, tc_send); tcase_add_test(tc_receive, test_recv_sonmp); suite_add_tcase(s, tc_receive); #endif return s; }
0
247,747
TestUtilOptionsV2( const envoy::config::listener::v3::Listener& listener, const envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext& client_ctx_proto, bool expect_success, Network::Address::IpVersion version) : TestUtilOptionsBase(expect_success, version), listener_(listener), client_ctx_proto_(client_ctx_proto), transport_socket_options_(nullptr) { if (expect_success) { setExpectedServerStats("ssl.handshake").setExpectedClientStats("ssl.handshake"); } else { setExpectedServerStats("ssl.fail_verify_error") .setExpectedClientStats("ssl.connection_error"); } }
0
244,102
GF_Err xtra_box_read(GF_Box *s, GF_BitStream *bs) { GF_XtraBox *ptr = (GF_XtraBox *)s; while (ptr->size) { GF_XtraTag *tag; u32 prop_type = 0; char *data=NULL, *data2=NULL; ISOM_DECREASE_SIZE_NO_ERR(ptr, 8) s32 tag_size = gf_bs_read_u32(bs); u32 name_size = gf_bs_read_u32(bs); if (tag_size < 8) return GF_ISOM_INVALID_FILE; tag_size -= 8; if ((tag_size>ptr->size) || (name_size>ptr->size)) { return GF_ISOM_INVALID_FILE; } ISOM_DECREASE_SIZE_NO_ERR(ptr, 10) ISOM_DECREASE_SIZE_NO_ERR(ptr, name_size) data = gf_malloc(sizeof(char) * (name_size+1)); gf_bs_read_data(bs, data, name_size); data[name_size] = 0; tag_size-=name_size; u32 flags = gf_bs_read_u32(bs); u32 prop_size = gf_bs_read_u32(bs); tag_size-=8; if (prop_size>4) { tag_size-=2; prop_type = gf_bs_read_u16(bs); prop_size -= 6; ISOM_DECREASE_SIZE_NO_ERR(ptr, prop_size) //add 3 extra bytes for UTF16 case string dump (3 because we need 0-aligned short value) data2 = gf_malloc(sizeof(char) * (prop_size+3)); gf_bs_read_data(bs, data2, prop_size); data2[prop_size] = 0; data2[prop_size+1] = 0; data2[prop_size+2] = 0; tag_size-=prop_size; } else { prop_size = 0; } GF_SAFEALLOC(tag, GF_XtraTag) tag->flags = flags; tag->name = data; tag->prop_size = prop_size; tag->prop_value = data2; tag->prop_type = prop_type; gf_list_add(ptr->tags, tag); if (tag_size) { GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[isom] invalid tag size in Xtra !\n")); } } return GF_OK; }
0
405,361
void xfrm_dst_ifdown(struct dst_entry *dst, struct net_device *dev) { while ((dst = xfrm_dst_child(dst)) && dst->xfrm && dst->dev == dev) { dst->dev = blackhole_netdev; dev_hold(dst->dev); dev_put(dev); } }
0
344,255
l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) { typeerror(L, o, op, varinfo(L, o)); }
0
514,294
static TABLE *item_rowid_table(Item *item) { if (item->type() != Item::FUNC_ITEM) return NULL; Item_func *func= (Item_func *)item; if (func->functype() != Item_func::TEMPTABLE_ROWID) return NULL; Item_temptable_rowid *itr= (Item_temptable_rowid *)func; return itr->table; }
0
336,521
void RedCharDeviceVDIPort::on_free_self_token() { RedsState *reds = get_server(); if (reds->inputs_channel && reds->pending_mouse_event) { spice_debug("pending mouse event"); reds_handle_agent_mouse_event(reds, reds->inputs_channel->get_mouse_state()); } if (reds->pending_device_display_info_message) { spice_debug("pending device display info message"); reds_send_device_display_info(reds); } }
0
365,623
_asn1_ltostr (long v, char str[LTOSTR_MAX_SIZE]) { long d, r; char temp[LTOSTR_MAX_SIZE]; int count, k, start; if (v < 0) { str[0] = '-'; start = 1; v = -v; } else start = 0; count = 0; do { d = v / 10; r = v - d * 10; temp[start + count] = '0' + (char) r; count++; v = d; } while (v && ((start+count) < LTOSTR_MAX_SIZE-1)); for (k = 0; k < count; k++) str[k + start] = temp[start + count - k - 1]; str[count + start] = 0; return str; }
0
199,712
static void rtrs_clt_dev_release(struct device *dev) { struct rtrs_clt_sess *clt = container_of(dev, struct rtrs_clt_sess, dev); kfree(clt); }
1
300,781
static void tipc_sk_finish_conn(struct tipc_sock *tsk, u32 peer_port, u32 peer_node) { struct sock *sk = &tsk->sk; struct net *net = sock_net(sk); struct tipc_msg *msg = &tsk->phdr; msg_set_syn(msg, 0); msg_set_destnode(msg, peer_node); msg_set_destport(msg, peer_port); msg_set_type(msg, TIPC_CONN_MSG); msg_set_lookup_scope(msg, 0); msg_set_hdr_sz(msg, SHORT_H_SIZE); sk_reset_timer(sk, &sk->sk_timer, jiffies + CONN_PROBING_INTV); tipc_set_sk_state(sk, TIPC_ESTABLISHED); tipc_node_add_conn(net, peer_node, tsk->portid, peer_port); tsk->max_pkt = tipc_node_get_mtu(net, peer_node, tsk->portid, true); tsk->peer_caps = tipc_node_get_capabilities(net, peer_node); tsk_set_nagle(tsk); __skb_queue_purge(&sk->sk_write_queue); if (tsk->peer_caps & TIPC_BLOCK_FLOWCTL) return; /* Fall back to message based flow control */ tsk->rcv_win = FLOWCTL_MSG_WIN; tsk->snd_win = FLOWCTL_MSG_WIN; }
0
231,687
TEST_F(QuicServerTransportTest, RecvStopSendingFrameAfterCloseStream) { server->getNonConstConn().ackStates.appDataAckState.nextPacketNum = 3; std::array<std::string, 4> words = { "Hey Bob, this is Alice, for real.", "What message did I send you last time?", "You don't sound like Alice", "You are a liar!", }; StreamId streamId = 0x00; auto stream = server->getNonConstConn().streamManager->getStream(streamId); stream->readBuffer.emplace_back(IOBuf::copyBuffer(words.at(0)), 0, false); stream->readBuffer.emplace_back( IOBuf::copyBuffer(words.at(1)), words.at(0).length(), false); stream->retransmissionBuffer.emplace( std::piecewise_construct, std::forward_as_tuple(0), std::forward_as_tuple(std::make_unique<StreamBuffer>( IOBuf::copyBuffer(words.at(2)), 0, false))); stream->writeBuffer.append(IOBuf::copyBuffer(words.at(3))); stream->currentWriteOffset = words.at(2).length() + words.at(3).length(); stream->currentReadOffset = words.at(0).length() + words.at(1).length(); server->getNonConstConn().flowControlState.sumCurStreamBufferLen = 100; server->getNonConstConn().ackStates.appDataAckState.nextPacketNum = 5; ShortHeader header( ProtectionType::KeyPhaseZero, *server->getConn().serverConnectionId, clientNextAppDataPacketNum++); RegularQuicPacketBuilder builder( server->getConn().udpSendPacketLen, std::move(header), 0 /* largestAcked */); builder.encodePacketHeader(); StopSendingFrame stopSendingFrame( streamId, GenericApplicationErrorCode::UNKNOWN); ASSERT_TRUE(builder.canBuildPacket()); writeFrame(QuicSimpleFrame(stopSendingFrame), builder); auto packet = std::move(builder).buildPacket(); server->resetStream(streamId, GenericApplicationErrorCode::UNKNOWN); EXPECT_CALL(connCallback, onStopSending(_, _)).Times(0); deliverData(packetToBuf(packet)); }
0
224,995
sendTerminateConn(PGconn *conn) { /* * Note that the protocol doesn't allow us to send Terminate messages * during the startup phase. */ if (conn->sock != PGINVALID_SOCKET && conn->status == CONNECTION_OK) { /* * Try to send "close connection" message to backend. Ignore any * error. */ pqPutMsgStart('X', conn); pqPutMsgEnd(conn); (void) pqFlush(conn); } }
0
312,565
get_nth_entry(qf_list_T *qfl, int errornr, int *new_qfidx) { qfline_T *qf_ptr = qfl->qf_ptr; int qf_idx = qfl->qf_index; // New error number is less than the current error number while (errornr < qf_idx && qf_idx > 1 && qf_ptr->qf_prev != NULL) { --qf_idx; qf_ptr = qf_ptr->qf_prev; } // New error number is greater than the current error number while (errornr > qf_idx && qf_idx < qfl->qf_count && qf_ptr->qf_next != NULL) { ++qf_idx; qf_ptr = qf_ptr->qf_next; } *new_qfidx = qf_idx; return qf_ptr; }
0
225,102
bool HasAttrStyleType(const OpDef::ArgDef& arg) { return arg.type() != DT_INVALID || !arg.type_attr().empty() || !arg.type_list_attr().empty(); }
0
206,123
RCoreSymCacheElement *r_coresym_cache_element_new(RBinFile *bf, RBuffer *buf, ut64 off, int bits, char * file_name) { RCoreSymCacheElement *result = NULL; ut8 *b = NULL; RCoreSymCacheElementHdr *hdr = r_coresym_cache_element_header_new (buf, off, bits); if (!hdr) { return NULL; } if (hdr->version != 1) { eprintf ("Unsupported CoreSymbolication cache version (%d)\n", hdr->version); goto beach; } if (hdr->size == 0 || hdr->size > r_buf_size (buf) - off) { eprintf ("Corrupted CoreSymbolication header: size out of bounds (0x%x)\n", hdr->size); goto beach; } result = R_NEW0 (RCoreSymCacheElement); if (!result) { goto beach; } result->hdr = hdr; b = malloc (hdr->size); if (!b) { goto beach; } if (r_buf_read_at (buf, off, b, hdr->size) != hdr->size) { goto beach; } ut8 *end = b + hdr->size; if (file_name) { result->file_name = file_name; } else if (hdr->file_name_off) { result->file_name = str_dup_safe (b, b + (size_t)hdr->file_name_off, end); } if (hdr->version_off) { result->binary_version = str_dup_safe (b, b + (size_t)hdr->version_off, end); } const size_t word_size = bits / 8; const ut64 start_of_sections = (ut64)hdr->n_segments * R_CS_EL_SIZE_SEG + R_CS_EL_OFF_SEGS; const ut64 sect_size = (bits == 32) ? R_CS_EL_SIZE_SECT_32 : R_CS_EL_SIZE_SECT_64; const ut64 start_of_symbols = start_of_sections + (ut64)hdr->n_sections * sect_size; const ut64 start_of_lined_symbols = start_of_symbols + (ut64)hdr->n_symbols * R_CS_EL_SIZE_SYM; const ut64 start_of_line_info = start_of_lined_symbols + (ut64)hdr->n_lined_symbols * R_CS_EL_SIZE_LSYM; const ut64 start_of_unknown_pairs = start_of_line_info + (ut64)hdr->n_line_info * R_CS_EL_SIZE_LINFO; const ut64 start_of_strings = start_of_unknown_pairs + (ut64)hdr->n_symbols * 8; ut64 page_zero_size = 0; size_t page_zero_idx = 0; if (UT32_MUL_OVFCHK (hdr->n_segments, sizeof (RCoreSymCacheElementSegment))) { goto beach; } else if (UT32_MUL_OVFCHK (hdr->n_sections, sizeof (RCoreSymCacheElementSection))) { goto beach; } else if (UT32_MUL_OVFCHK (hdr->n_symbols, sizeof (RCoreSymCacheElementSymbol))) { goto beach; } else if (UT32_MUL_OVFCHK (hdr->n_lined_symbols, sizeof (RCoreSymCacheElementLinedSymbol))) { goto beach; } else if (UT32_MUL_OVFCHK (hdr->n_line_info, sizeof (RCoreSymCacheElementLineInfo))) { goto beach; } if (hdr->n_segments > 0) { result->segments = R_NEWS0 (RCoreSymCacheElementSegment, hdr->n_segments); if (!result->segments) { goto beach; } size_t i; ut8 *cursor = b + R_CS_EL_OFF_SEGS; for (i = 0; i < hdr->n_segments && cursor + sizeof (RCoreSymCacheElementSegment) < end; i++) { RCoreSymCacheElementSegment *seg = &result->segments[i]; seg->paddr = seg->vaddr = r_read_le64 (cursor); cursor += 8; if (cursor >= end) { break; } seg->size = seg->vsize = r_read_le64 (cursor); cursor += 8; if (cursor >= end) { break; } seg->name = str_dup_safe_fixed (b, cursor, 16, end); cursor += 16; if (!seg->name) { continue; } if (!strcmp (seg->name, "__PAGEZERO")) { page_zero_size = seg->size; page_zero_idx = i; seg->paddr = seg->vaddr = 0; seg->size = 0; } } for (i = 0; i < hdr->n_segments && page_zero_size > 0; i++) { if (i == page_zero_idx) { continue; } RCoreSymCacheElementSegment *seg = &result->segments[i]; if (seg->vaddr < page_zero_size) { seg->vaddr += page_zero_size; } } } bool relative_to_strings = false; ut8* string_origin; if (hdr->n_sections > 0) { result->sections = R_NEWS0 (RCoreSymCacheElementSection, hdr->n_sections); if (!result->sections) { goto beach; } size_t i; ut8 *cursor = b + start_of_sections; for (i = 0; i < hdr->n_sections && cursor < end; i++) { ut8 *sect_start = cursor; RCoreSymCacheElementSection *sect = &result->sections[i]; sect->vaddr = sect->paddr = r_read_ble (cursor, false, bits); if (sect->vaddr < page_zero_size) { sect->vaddr += page_zero_size; } cursor += word_size; if (cursor >= end) { break; } sect->size = r_read_ble (cursor, false, bits); cursor += word_size; if (cursor >= end) { break; } ut64 sect_name_off = r_read_ble (cursor, false, bits); if (!i && !sect_name_off) { relative_to_strings = true; } cursor += word_size; if (bits == 32) { cursor += word_size; } string_origin = relative_to_strings? b + start_of_strings : sect_start; sect->name = str_dup_safe (b, string_origin + (size_t)sect_name_off, end); } } if (hdr->n_symbols) { result->symbols = R_NEWS0 (RCoreSymCacheElementSymbol, hdr->n_symbols); if (!result->symbols) { goto beach; } size_t i; ut8 *cursor = b + start_of_symbols; for (i = 0; i < hdr->n_symbols && cursor + R_CS_EL_SIZE_SYM <= end; i++) { RCoreSymCacheElementSymbol *sym = &result->symbols[i]; sym->paddr = r_read_le32 (cursor); sym->size = r_read_le32 (cursor + 0x4); sym->unk1 = r_read_le32 (cursor + 0x8); size_t name_off = r_read_le32 (cursor + 0xc); size_t mangled_name_off = r_read_le32 (cursor + 0x10); sym->unk2 = (st32)r_read_le32 (cursor + 0x14); string_origin = relative_to_strings? b + start_of_strings : cursor; sym->name = str_dup_safe (b, string_origin + name_off, end); if (!sym->name) { cursor += R_CS_EL_SIZE_SYM; continue; } string_origin = relative_to_strings? b + start_of_strings : cursor; sym->mangled_name = str_dup_safe (b, string_origin + mangled_name_off, end); if (!sym->mangled_name) { cursor += R_CS_EL_SIZE_SYM; continue; } cursor += R_CS_EL_SIZE_SYM; } } if (hdr->n_lined_symbols) { result->lined_symbols = R_NEWS0 (RCoreSymCacheElementLinedSymbol, hdr->n_lined_symbols); if (!result->lined_symbols) { goto beach; } size_t i; ut8 *cursor = b + start_of_lined_symbols; for (i = 0; i < hdr->n_lined_symbols && cursor + R_CS_EL_SIZE_LSYM <= end; i++) { RCoreSymCacheElementLinedSymbol *lsym = &result->lined_symbols[i]; lsym->sym.paddr = r_read_le32 (cursor); lsym->sym.size = r_read_le32 (cursor + 0x4); lsym->sym.unk1 = r_read_le32 (cursor + 0x8); size_t name_off = r_read_le32 (cursor + 0xc); size_t mangled_name_off = r_read_le32 (cursor + 0x10); lsym->sym.unk2 = (st32)r_read_le32 (cursor + 0x14); size_t file_name_off = r_read_le32 (cursor + 0x18); lsym->flc.line = r_read_le32 (cursor + 0x1c); lsym->flc.col = r_read_le32 (cursor + 0x20); string_origin = relative_to_strings? b + start_of_strings : cursor; lsym->sym.name = str_dup_safe (b, string_origin + name_off, end); if (!lsym->sym.name) { cursor += R_CS_EL_SIZE_LSYM; continue; } string_origin = relative_to_strings? b + start_of_strings : cursor; lsym->sym.mangled_name = str_dup_safe (b, string_origin + mangled_name_off, end); if (!lsym->sym.mangled_name) { cursor += R_CS_EL_SIZE_LSYM; continue; } string_origin = relative_to_strings? b + start_of_strings : cursor; lsym->flc.file = str_dup_safe (b, string_origin + file_name_off, end); if (!lsym->flc.file) { cursor += R_CS_EL_SIZE_LSYM; continue; } cursor += R_CS_EL_SIZE_LSYM; meta_add_fileline (bf, r_coresym_cache_element_pa2va (result, lsym->sym.paddr), lsym->sym.size, &lsym->flc); } } if (hdr->n_line_info) { result->line_info = R_NEWS0 (RCoreSymCacheElementLineInfo, hdr->n_line_info); if (!result->line_info) { goto beach; } size_t i; ut8 *cursor = b + start_of_line_info; for (i = 0; i < hdr->n_line_info && cursor + R_CS_EL_SIZE_LINFO <= end; i++) { RCoreSymCacheElementLineInfo *info = &result->line_info[i]; info->paddr = r_read_le32 (cursor); info->size = r_read_le32 (cursor + 4); size_t file_name_off = r_read_le32 (cursor + 8); info->flc.line = r_read_le32 (cursor + 0xc); info->flc.col = r_read_le32 (cursor + 0x10); string_origin = relative_to_strings? b + start_of_strings : cursor; info->flc.file = str_dup_safe (b, string_origin + file_name_off, end); if (!info->flc.file) { break; } cursor += R_CS_EL_SIZE_LINFO; meta_add_fileline (bf, r_coresym_cache_element_pa2va (result, info->paddr), info->size, &info->flc); } } /* * TODO: * Figure out the meaning of the 2 arrays of hdr->n_symbols * 32-bit integers located at the end of line info. * Those are the last info before the strings at the end. */ beach: free (b); return result; }
1
258,082
void Compute(OpKernelContext* context) override { const Tensor& input = context->input(0); // If input is provided, check to make sure the first dimension is valid. if (input.dims() > 0) { OP_REQUIRES( context, input.dim_size(0) != 0, errors::InvalidArgument("Invalid input first dimension. Found 0.")); } const Tensor& dims = context->input(1); if (TensorShapeUtils::IsScalar(input.shape())) { context->set_output(0, input); } else { const int input_dims = input.dims(); OP_REQUIRES(context, TensorShapeUtils::IsVector(dims.shape()), errors::InvalidArgument("'dims' must be 1-dimension, not ", dims.dims())); OP_REQUIRES( context, input_dims == dims.dim_size(0), errors::InvalidArgument( "'dims' must have the same number of values as 'input' has " "dimensions. 'input' has ", input_dims, "'dims' has ", dims.dim_size(0), " values")); OP_REQUIRES(context, input_dims <= 8, errors::Unimplemented( "reverse is not implemented for tensors of rank > 8.")); Tensor* output = nullptr; OP_REQUIRES_OK(context, context->allocate_output(0, input.shape(), &output)); #define HANDLE_REVERSE(NDIMS) \ case NDIMS: \ HandleReverseCase<Device, T, NDIMS>(context, dims.vec<bool>(), output); \ return; switch (input_dims) { HANDLE_REVERSE(0); HANDLE_REVERSE(1); HANDLE_REVERSE(2); HANDLE_REVERSE(3); HANDLE_REVERSE(4); HANDLE_REVERSE(5); HANDLE_REVERSE(6); HANDLE_REVERSE(7); HANDLE_REVERSE(8); } #undef HANDLE_REVERSE } }
0
369,384
static int io_eventfd_unregister(struct io_ring_ctx *ctx) { struct io_ev_fd *ev_fd; ev_fd = rcu_dereference_protected(ctx->io_ev_fd, lockdep_is_held(&ctx->uring_lock)); if (ev_fd) { ctx->has_evfd = false; rcu_assign_pointer(ctx->io_ev_fd, NULL); call_rcu(&ev_fd->rcu, io_eventfd_put); return 0; } return -ENXIO;
0
384,798
buf_init_chartab( buf_T *buf, int global) // FALSE: only set buf->b_chartab[] { int c; int c2; char_u *p; int i; int tilde; int do_isalpha; if (global) { /* * Set the default size for printable characters: * From <Space> to '~' is 1 (printable), others are 2 (not printable). * This also inits all 'isident' and 'isfname' flags to FALSE. */ c = 0; while (c < ' ') g_chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2; while (c <= '~') g_chartab[c++] = 1 + CT_PRINT_CHAR; while (c < 256) { // UTF-8: bytes 0xa0 - 0xff are printable (latin1) if (enc_utf8 && c >= 0xa0) g_chartab[c++] = CT_PRINT_CHAR + 1; // euc-jp characters starting with 0x8e are single width else if (enc_dbcs == DBCS_JPNU && c == 0x8e) g_chartab[c++] = CT_PRINT_CHAR + 1; // other double-byte chars can be printable AND double-width else if (enc_dbcs != 0 && MB_BYTE2LEN(c) == 2) g_chartab[c++] = CT_PRINT_CHAR + 2; else // the rest is unprintable by default g_chartab[c++] = (dy_flags & DY_UHEX) ? 4 : 2; } // Assume that every multi-byte char is a filename character. for (c = 1; c < 256; ++c) if ((enc_dbcs != 0 && MB_BYTE2LEN(c) > 1) || (enc_dbcs == DBCS_JPNU && c == 0x8e) || (enc_utf8 && c >= 0xa0)) g_chartab[c] |= CT_FNAME_CHAR; } /* * Init word char flags all to FALSE */ CLEAR_FIELD(buf->b_chartab); if (enc_dbcs != 0) for (c = 0; c < 256; ++c) { // double-byte characters are probably word characters if (MB_BYTE2LEN(c) == 2) SET_CHARTAB(buf, c); } #ifdef FEAT_LISP /* * In lisp mode the '-' character is included in keywords. */ if (buf->b_p_lisp) SET_CHARTAB(buf, '-'); #endif // Walk through the 'isident', 'iskeyword', 'isfname' and 'isprint' // options Each option is a list of characters, character numbers or // ranges, separated by commas, e.g.: "200-210,x,#-178,-" for (i = global ? 0 : 3; i <= 3; ++i) { if (i == 0) p = p_isi; // first round: 'isident' else if (i == 1) p = p_isp; // second round: 'isprint' else if (i == 2) p = p_isf; // third round: 'isfname' else // i == 3 p = buf->b_p_isk; // fourth round: 'iskeyword' while (*p) { tilde = FALSE; do_isalpha = FALSE; if (*p == '^' && p[1] != NUL) { tilde = TRUE; ++p; } if (VIM_ISDIGIT(*p)) c = getdigits(&p); else if (has_mbyte) c = mb_ptr2char_adv(&p); else c = *p++; c2 = -1; if (*p == '-' && p[1] != NUL) { ++p; if (VIM_ISDIGIT(*p)) c2 = getdigits(&p); else if (has_mbyte) c2 = mb_ptr2char_adv(&p); else c2 = *p++; } if (c <= 0 || c >= 256 || (c2 < c && c2 != -1) || c2 >= 256 || !(*p == NUL || *p == ',')) return FAIL; if (c2 == -1) // not a range { /* * A single '@' (not "@-@"): * Decide on letters being ID/printable/keyword chars with * standard function isalpha(). This takes care of locale for * single-byte characters). */ if (c == '@') { do_isalpha = TRUE; c = 1; c2 = 255; } else c2 = c; } while (c <= c2) { // Use the MB_ functions here, because isalpha() doesn't // work properly when 'encoding' is "latin1" and the locale is // "C". if (!do_isalpha || MB_ISLOWER(c) || MB_ISUPPER(c)) { if (i == 0) // (re)set ID flag { if (tilde) g_chartab[c] &= ~CT_ID_CHAR; else g_chartab[c] |= CT_ID_CHAR; } else if (i == 1) // (re)set printable { if ((c < ' ' || c > '~' // For double-byte we keep the cell width, so // that we can detect it from the first byte. ) && !(enc_dbcs && MB_BYTE2LEN(c) == 2)) { if (tilde) { g_chartab[c] = (g_chartab[c] & ~CT_CELL_MASK) + ((dy_flags & DY_UHEX) ? 4 : 2); g_chartab[c] &= ~CT_PRINT_CHAR; } else { g_chartab[c] = (g_chartab[c] & ~CT_CELL_MASK) + 1; g_chartab[c] |= CT_PRINT_CHAR; } } } else if (i == 2) // (re)set fname flag { if (tilde) g_chartab[c] &= ~CT_FNAME_CHAR; else g_chartab[c] |= CT_FNAME_CHAR; } else // i == 3 (re)set keyword flag { if (tilde) RESET_CHARTAB(buf, c); else SET_CHARTAB(buf, c); } } ++c; } c = *p; p = skip_to_option_part(p); if (c == ',' && *p == NUL) // Trailing comma is not allowed. return FAIL; } } chartab_initialized = TRUE; return OK; }
0
438,677
static struct rpmsg_endpoint *virtio_rpmsg_create_ept(struct rpmsg_device *rpdev, rpmsg_rx_cb_t cb, void *priv, struct rpmsg_channel_info chinfo) { struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev); return __rpmsg_create_ept(vch->vrp, rpdev, cb, priv, chinfo.src); }
0
389,696
eval_interp_string(char_u **arg, typval_T *rettv, int evaluate) { typval_T tv; int ret = OK; int quote; garray_T ga; char_u *p; ga_init2(&ga, 1, 80); // *arg is on the '$' character, move it to the first string character. ++*arg; quote = **arg; ++*arg; for (;;) { // Get the string up to the matching quote or to a single '{'. // "arg" is advanced to either the quote or the '{'. if (quote == '"') ret = eval_string(arg, &tv, evaluate, TRUE); else ret = eval_lit_string(arg, &tv, evaluate, TRUE); if (ret == FAIL) break; if (evaluate) { ga_concat(&ga, tv.vval.v_string); clear_tv(&tv); } if (**arg != '{') { // found terminating quote ++*arg; break; } p = eval_one_expr_in_str(*arg, &ga, evaluate); if (p == NULL) { ret = FAIL; break; } *arg = p; } rettv->v_type = VAR_STRING; if (ret == FAIL || !evaluate || ga_append(&ga, NUL) == FAIL) { ga_clear(&ga); rettv->vval.v_string = NULL; return ret; } rettv->vval.v_string = ga.ga_data; return OK; }
0
513,015
bool val_native_from_field(Field *field, Native *to) { if ((null_value= field->is_null())) return true; return (null_value= field->val_native(to)); }
0
346,430
get_autoload_prefix(scriptitem_T *si) { char_u *p = script_name_after_autoload(si); char_u *prefix; if (p == NULL) return NULL; prefix = vim_strsave(p); if (prefix == NULL) return NULL; // replace all '/' with '#' and locate ".vim" at the end for (p = prefix; *p != NUL; p += mb_ptr2len(p)) { if (vim_ispathsep(*p)) *p = '#'; else if (STRCMP(p, ".vim") == 0) { p[0] = '#'; p[1] = NUL; return prefix; } } // did not find ".vim" at the end vim_free(prefix); return NULL; }
0
411,792
setup_bus_child (gpointer data) { A11yBusLauncher *app = data; (void) app; close (app->pipefd[0]); dup2 (app->pipefd[1], 3); close (app->pipefd[1]); /* On Linux, tell the bus process to exit if this process goes away */ #ifdef __linux #include <sys/prctl.h> prctl (PR_SET_PDEATHSIG, 15); #endif }
0
267,358
append_cap (const char *arg) { exec_options.cap = realloc (exec_options.cap, (exec_options.cap_size + 2) * sizeof (*exec_options.cap)); if (exec_options.cap == NULL) error (EXIT_FAILURE, errno, "cannot allocate memory"); exec_options.cap[exec_options.cap_size + 1] = NULL; exec_options.cap[exec_options.cap_size] = xstrdup (arg); exec_options.cap_size++; }
0
387,640
static int read_tlv_buf(struct snd_kcontrol *kctl, struct snd_ctl_elem_id *id, unsigned int __user *buf, unsigned int size) { struct snd_kcontrol_volatile *vd = &kctl->vd[snd_ctl_get_ioff(kctl, id)]; unsigned int len; if (!(vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_READ)) return -ENXIO; if (kctl->tlv.p == NULL) return -ENXIO; len = sizeof(unsigned int) * 2 + kctl->tlv.p[1]; if (size < len) return -ENOMEM; if (copy_to_user(buf, kctl->tlv.p, len)) return -EFAULT; return 0; }
0
254,745
njs_typed_array_alloc(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, njs_bool_t zeroing, njs_object_type_t type) { double num; int64_t i, length; uint32_t element_size; uint64_t size, offset; njs_int_t ret; njs_value_t *value, prop; njs_typed_array_t *array, *src_tarray; njs_array_buffer_t *buffer; size = 0; length = 0; offset = 0; buffer = NULL; src_tarray = NULL; element_size = njs_typed_array_element_size(type); value = njs_arg(args, nargs, 0); if (njs_is_array_buffer(value)) { buffer = njs_array_buffer(value); ret = njs_value_to_index(vm, njs_arg(args, nargs, 1), &offset); if (njs_slow_path(ret != NJS_OK)) { return NULL; } if (njs_slow_path((offset % element_size) != 0)) { njs_range_error(vm, "start offset must be multiple of %uD", element_size); return NULL; } if (njs_is_defined(njs_arg(args, nargs, 2))) { ret = njs_value_to_index(vm, njs_argument(args, 2), &size); if (njs_slow_path(ret != NJS_OK)) { return NULL; } } if (njs_slow_path(njs_is_detached_buffer(buffer))) { njs_type_error(vm, "detached buffer"); return NULL; } if (njs_is_defined(njs_arg(args, nargs, 2))) { ret = njs_value_to_index(vm, njs_argument(args, 2), &size); if (njs_slow_path(ret != NJS_OK)) { return NULL; } size *= element_size; if (njs_slow_path((offset + size) > buffer->size)) { njs_range_error(vm, "Invalid typed array length: %uL", size); return NULL; } } else { if (njs_slow_path((buffer->size % element_size) != 0)) { njs_range_error(vm, "byteLength of buffer must be " "multiple of %uD", element_size); return NULL; } if (offset > buffer->size) { njs_range_error(vm, "byteOffset %uL is outside the bound of " "the buffer", offset); return NULL; } size = buffer->size - offset; } } else if (njs_is_typed_array(value)) { src_tarray = njs_typed_array(value); if (njs_slow_path(njs_is_detached_buffer(src_tarray->buffer))) { njs_type_error(vm, "detached buffer"); return NULL; } size = (uint64_t) njs_typed_array_length(src_tarray) * element_size; } else if (njs_is_object(value)) { ret = njs_object_length(vm, value, &length); if (njs_slow_path(ret == NJS_ERROR)) { return NULL; } size = length * element_size; } else { ret = njs_value_to_index(vm, value, &size); if (njs_slow_path(ret != NJS_OK)) { return NULL; } size *= element_size; } if (buffer == NULL) { buffer = njs_array_buffer_alloc(vm, size, zeroing); if (njs_slow_path(buffer == NULL)) { return NULL; } } array = njs_mp_zalloc(vm->mem_pool, sizeof(njs_typed_array_t)); if (njs_slow_path(array == NULL)) { goto memory_error; } array->buffer = buffer; array->offset = offset / element_size; array->byte_length = size; array->type = type; if (src_tarray != NULL) { if (type != src_tarray->type) { length = njs_typed_array_length(src_tarray); for (i = 0; i < length; i++) { njs_typed_array_prop_set(vm, array, i, njs_typed_array_prop(src_tarray, i)); } } else { memcpy(&buffer->u.u8[0], &src_tarray->buffer->u.u8[0], size); } } else if (!njs_is_array_buffer(value) && njs_is_object(value)) { for (i = 0; i < length; i++) { ret = njs_value_property_i64(vm, value, i, &prop); if (njs_slow_path(ret == NJS_ERROR)) { return NULL; } num = NAN; if (ret == NJS_OK) { ret = njs_value_to_number(vm, &prop, &num); if (njs_slow_path(ret == NJS_ERROR)) { return NULL; } } njs_typed_array_prop_set(vm, array, i, num); } } njs_lvlhsh_init(&array->object.hash); njs_lvlhsh_init(&array->object.shared_hash); array->object.__proto__ = &vm->prototypes[type].object; array->object.type = NJS_TYPED_ARRAY; array->object.extensible = 1; array->object.fast_array = 1; return array; memory_error: njs_memory_error(vm); return NULL; }
0
253,534
smb2_qfs_tcon(const unsigned int xid, struct cifs_tcon *tcon, struct cifs_sb_info *cifs_sb) { int rc; __le16 srch_path = 0; /* Null - open root of share */ u8 oplock = SMB2_OPLOCK_LEVEL_NONE; struct cifs_open_parms oparms; struct cifs_fid fid; oparms.tcon = tcon; oparms.desired_access = FILE_READ_ATTRIBUTES; oparms.disposition = FILE_OPEN; oparms.create_options = cifs_create_options(cifs_sb, 0); oparms.fid = &fid; oparms.reconnect = false; rc = SMB2_open(xid, &oparms, &srch_path, &oplock, NULL, NULL, NULL, NULL); if (rc) return; SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, FS_ATTRIBUTE_INFORMATION); SMB2_QFS_attr(xid, tcon, fid.persistent_fid, fid.volatile_fid, FS_DEVICE_INFORMATION); SMB2_close(xid, tcon, fid.persistent_fid, fid.volatile_fid); }
0
413,633
static int find_bb(ut64 *addr, RAnalBlock *bb) { return *addr != bb->addr; }
0
261,422
void thread_task_ctb_row::work() { thread_task_ctb_row* data = this; thread_context* tctx = data->tctx; de265_image* img = tctx->img; const seq_parameter_set& sps = img->get_sps(); int ctbW = sps.PicWidthInCtbsY; state = Running; img->thread_run(this); setCtbAddrFromTS(tctx); int ctby = tctx->CtbAddrInRS / ctbW; int myCtbRow = ctby; //printf("start CTB-row decoding at row %d\n", ctby); if (data->firstSliceSubstream) { bool success = initialize_CABAC_at_slice_segment_start(tctx); if (!success) { // could not decode this row, mark whole row as finished for (int x=0;x<ctbW;x++) { img->ctb_progress[myCtbRow*ctbW + x].set_progress(CTB_PROGRESS_PREFILTER); } state = Finished; tctx->sliceunit->finished_threads.increase_progress(1); img->thread_finishes(this); return; } //initialize_CABAC(tctx); } init_CABAC_decoder_2(&tctx->cabac_decoder); bool firstIndependentSubstream = data->firstSliceSubstream && !tctx->shdr->dependent_slice_segment_flag; /*enum DecodeResult result =*/ decode_substream(tctx, true, firstIndependentSubstream); // mark progress on remaining CTBs in row (in case of decoder error and early termination) // TODO: what about slices that end properly in the middle of a CTB row? if (tctx->CtbY == myCtbRow) { int lastCtbX = sps.PicWidthInCtbsY; // assume no tiles when WPP is on for (int x = tctx->CtbX; x<lastCtbX ; x++) { if (x < sps.PicWidthInCtbsY && myCtbRow < sps.PicHeightInCtbsY) { img->ctb_progress[myCtbRow*ctbW + x].set_progress(CTB_PROGRESS_PREFILTER); } } } state = Finished; tctx->sliceunit->finished_threads.increase_progress(1); img->thread_finishes(this); }
0
466,182
static int load_state_from_tss16(struct x86_emulate_ctxt *ctxt, struct tss_segment_16 *tss) { int ret; ctxt->_eip = tss->ip; ctxt->eflags = tss->flag | 2; ctxt->regs[VCPU_REGS_RAX] = tss->ax; ctxt->regs[VCPU_REGS_RCX] = tss->cx; ctxt->regs[VCPU_REGS_RDX] = tss->dx; ctxt->regs[VCPU_REGS_RBX] = tss->bx; ctxt->regs[VCPU_REGS_RSP] = tss->sp; ctxt->regs[VCPU_REGS_RBP] = tss->bp; ctxt->regs[VCPU_REGS_RSI] = tss->si; ctxt->regs[VCPU_REGS_RDI] = tss->di; /* * SDM says that segment selectors are loaded before segment * descriptors */ set_segment_selector(ctxt, tss->ldt, VCPU_SREG_LDTR); set_segment_selector(ctxt, tss->es, VCPU_SREG_ES); set_segment_selector(ctxt, tss->cs, VCPU_SREG_CS); set_segment_selector(ctxt, tss->ss, VCPU_SREG_SS); set_segment_selector(ctxt, tss->ds, VCPU_SREG_DS); /* * Now load segment descriptors. If fault happenes at this stage * it is handled in a context of new task */ ret = load_segment_descriptor(ctxt, tss->ldt, VCPU_SREG_LDTR); if (ret != X86EMUL_CONTINUE) return ret; ret = load_segment_descriptor(ctxt, tss->es, VCPU_SREG_ES); if (ret != X86EMUL_CONTINUE) return ret; ret = load_segment_descriptor(ctxt, tss->cs, VCPU_SREG_CS); if (ret != X86EMUL_CONTINUE) return ret; ret = load_segment_descriptor(ctxt, tss->ss, VCPU_SREG_SS); if (ret != X86EMUL_CONTINUE) return ret; ret = load_segment_descriptor(ctxt, tss->ds, VCPU_SREG_DS); if (ret != X86EMUL_CONTINUE) return ret; return X86EMUL_CONTINUE; }
0
210,204
static struct nlattr *reserve_sfa_size(struct sw_flow_actions **sfa, int attr_len, bool log) { struct sw_flow_actions *acts; int new_acts_size; size_t req_size = NLA_ALIGN(attr_len); int next_offset = offsetof(struct sw_flow_actions, actions) + (*sfa)->actions_len; if (req_size <= (ksize(*sfa) - next_offset)) goto out; new_acts_size = max(next_offset + req_size, ksize(*sfa) * 2); if (new_acts_size > MAX_ACTIONS_BUFSIZE) { if ((MAX_ACTIONS_BUFSIZE - next_offset) < req_size) { OVS_NLERR(log, "Flow action size exceeds max %u", MAX_ACTIONS_BUFSIZE); return ERR_PTR(-EMSGSIZE); } new_acts_size = MAX_ACTIONS_BUFSIZE; } acts = nla_alloc_flow_actions(new_acts_size); if (IS_ERR(acts)) return (void *)acts; memcpy(acts->actions, (*sfa)->actions, (*sfa)->actions_len); acts->actions_len = (*sfa)->actions_len; acts->orig_len = (*sfa)->orig_len; kfree(*sfa); *sfa = acts; out: (*sfa)->actions_len += req_size; return (struct nlattr *) ((unsigned char *)(*sfa) + next_offset); }
1
246,736
u32 parse_ttxt(char *arg_val, u32 opt) { if (opt) //-srt dump_srt = GF_TRUE; else dump_ttxt = GF_TRUE; import_subtitle = 1; trackID = 0; if (arg_val && (!strcmp(arg_val, "*") || !strcmp(arg_val, "@") || !strcmp(arg_val, "all")) ) { trackID = (u32)-1; } else if (arg_val) { if (sscanf(arg_val, "%u", &trackID) == 1) { char szTk[20]; sprintf(szTk, "%d", trackID); if (strcmp(szTk, arg_val)) trackID = 0; } if (!trackID) return 3; } return 0; }
0
310,316
dirserv_have_any_serverdesc(smartlist_t *fps, int spool_src) { time_t publish_cutoff = time(NULL)-ROUTER_MAX_AGE_TO_PUBLISH; SMARTLIST_FOREACH(fps, const char *, fp, { switch (spool_src) { case DIR_SPOOL_EXTRA_BY_DIGEST: if (extrainfo_get_by_descriptor_digest(fp)) return 1; break; case DIR_SPOOL_SERVER_BY_DIGEST: if (router_get_by_descriptor_digest(fp)) return 1; break; case DIR_SPOOL_EXTRA_BY_FP: case DIR_SPOOL_SERVER_BY_FP: if (get_signed_descriptor_by_fp(fp, spool_src == DIR_SPOOL_EXTRA_BY_FP, publish_cutoff)) return 1; break; } }); return 0; }
0
400,719
static int copyout_mc(void __user *to, const void *from, size_t n) { if (access_ok(to, n)) { instrument_copy_to_user(to, from, n); n = copy_mc_to_user((__force void *) to, from, n); } return n; }
0
474,002
code2_hash(OnigCodePoint* x) { return (st_index_t )(x[0] + x[1]); }
0
221,690
void Socket::stopSsl() { #ifdef NETDEBUG std::cout << thread_id << "ssl stopping" << std::endl; #endif if(!isssl) return; isssl = false; if (ssl != NULL) { if (issslserver) { #ifdef NETDEBUG std::cout << thread_id << "this is a server connection" << std::endl; if (SSL_get_shutdown(ssl) & SSL_SENT_SHUTDOWN) { std::cout << thread_id << "SSL_SENT_SHUTDOWN IS SET" << std::endl; } if (SSL_get_shutdown(ssl) & SSL_RECEIVED_SHUTDOWN) { std::cout << thread_id << "SSL_RECEIVED_SHUTDOWN IS SET" << std::endl; } std::cout << thread_id << "calling 1st ssl shutdown" << std::endl; #endif if (!SSL_shutdown(ssl)) { #ifdef NETDEBUG std::cout << thread_id << "need to call SSL shutdown again" << std::endl; if (SSL_get_shutdown(ssl) & SSL_SENT_SHUTDOWN) { std::cout << thread_id << "SSL_SENT_SHUTDOWN IS SET" << std::endl; } if (SSL_get_shutdown(ssl) & SSL_RECEIVED_SHUTDOWN) { std::cout << thread_id << "SSL_RECEIVED_SHUTDOWN IS SET" << std::endl; } std::cout << thread_id << "Discarding extra data from client" << std::endl; #endif shutdown(SSL_get_fd(ssl), SHUT_WR); char junk[1024]; readFromSocket(junk, sizeof(junk), 0, 5); #ifdef NETDEBUG std::cout << thread_id << "done" << std::endl; #endif } } else { #ifdef NETDEBUG std::cout << thread_id << "this is a client connection" << std::endl; if (SSL_get_shutdown(ssl) & SSL_SENT_SHUTDOWN) { std::cout << thread_id << "SSL_SENT_SHUTDOWN IS SET" << std::endl; } if (SSL_get_shutdown(ssl) & SSL_RECEIVED_SHUTDOWN) { std::cout << thread_id << "SSL_RECEIVED_SHUTDOWN IS SET" << std::endl; } std::cout << thread_id << "calling ssl shutdown" << std::endl; #endif SSL_shutdown(ssl); #ifdef NETDEBUG std::cout << thread_id << "done" << std::endl; #endif } } cleanSsl(); }
0
432,315
void memory_region_init(struct uc_struct *uc, MemoryRegion *mr, uint64_t size) { memset(mr, 0, sizeof(*mr)); mr->uc = uc; /* memory_region_initfn */ mr->ops = &unassigned_mem_ops; mr->enabled = true; mr->destructor = memory_region_destructor_none; QTAILQ_INIT(&mr->subregions); mr->size = int128_make64(size); if (size == UINT64_MAX) { mr->size = int128_2_64(); } }
0
487,639
void kernel_power_off(void) { kernel_shutdown_prepare(SYSTEM_POWER_OFF); printk(KERN_EMERG "Power down.\n"); machine_power_off(); }
0
248,286
int strcasecmp(const char *s1, const char *s2) { assert(s1); assert(s2); while (*s1) { int c1 = tolower(*(const unsigned char *)s1); int c2 = tolower(*(const unsigned char *)s2); if (c1 < c2) return -1; if (c1 > c2) return +1; ++s1; ++s2; } if (*s2 != 0) return -1; return 0; }
0
369,409
static enum hrtimer_restart io_link_timeout_fn(struct hrtimer *timer) { struct io_timeout_data *data = container_of(timer, struct io_timeout_data, timer); struct io_kiocb *prev, *req = data->req; struct io_ring_ctx *ctx = req->ctx; unsigned long flags; spin_lock_irqsave(&ctx->timeout_lock, flags); prev = req->timeout.head; req->timeout.head = NULL; /* * We don't expect the list to be empty, that will only happen if we * race with the completion of the linked work. */ if (prev) { io_remove_next_linked(prev); if (!req_ref_inc_not_zero(prev)) prev = NULL; } list_del(&req->timeout.list); req->timeout.prev = prev; spin_unlock_irqrestore(&ctx->timeout_lock, flags); req->io_task_work.func = io_req_task_link_timeout; io_req_task_work_add(req, false); return HRTIMER_NORESTART;
0
281,065
static inline unsigned int idx_hash(struct net *net, u32 index) { return __idx_hash(index, net->xfrm.policy_idx_hmask); }
0
401,557
void del_random_ready_callback(struct random_ready_callback *rdy) { unsigned long flags; struct module *owner = NULL; spin_lock_irqsave(&random_ready_list_lock, flags); if (!list_empty(&rdy->list)) { list_del_init(&rdy->list); owner = rdy->owner; } spin_unlock_irqrestore(&random_ready_list_lock, flags); module_put(owner); }
0
223,486
static void flush_stubs(compiler_common *common) { DEFINE_COMPILER; stub_list *list_item = common->stubs; while (list_item) { JUMPHERE(list_item->start); add_jump(compiler, &common->stackalloc, JUMP(SLJIT_FAST_CALL)); JUMPTO(SLJIT_JUMP, list_item->quit); list_item = list_item->next; } common->stubs = NULL; }
0
500,058
krb5_rc_destroy(krb5_context con, krb5_rcache rc) { if (!krb5_loaded) load_krb5_dll(); if ( p_krb5_rc_destroy ) return(p_krb5_rc_destroy(con, rc)); else return KRB5KRB_ERR_GENERIC; }
0
244,142
GF_Err dac3_box_size(GF_Box *s) { GF_AC3ConfigBox *ptr = (GF_AC3ConfigBox *)s; if (ptr->cfg.is_ec3) { u32 i; s->size += 2; for (i=0; i<ptr->cfg.nb_streams; i++) { s->size += 3; if (ptr->cfg.streams[i].nb_dep_sub) s->size += 1; } } else { s->size += 3; } return GF_OK; }
0
369,316
static void io_flush_apoll_cache(struct io_ring_ctx *ctx) { struct async_poll *apoll; while (!list_empty(&ctx->apoll_cache)) { apoll = list_first_entry(&ctx->apoll_cache, struct async_poll, poll.wait.entry); list_del(&apoll->poll.wait.entry); kfree(apoll); }
0
202,708
fname_match( regmatch_T *rmp, char_u *name, int ignore_case) // when TRUE ignore case, when FALSE use 'fic' { char_u *match = NULL; char_u *p; if (name != NULL) { // Ignore case when 'fileignorecase' or the argument is set. rmp->rm_ic = p_fic || ignore_case; if (vim_regexec(rmp, name, (colnr_T)0)) match = name; else { // Replace $(HOME) with '~' and try matching again. p = home_replace_save(NULL, name); if (p != NULL && vim_regexec(rmp, p, (colnr_T)0)) match = name; vim_free(p); } } return match; }
1
356,679
Napi::Value Statement::Run(const Napi::CallbackInfo& info) { Napi::Env env = info.Env(); Statement* stmt = this; Baton* baton = stmt->Bind<RunBaton>(info); if (baton == NULL) { Napi::Error::New(env, "Data type is not supported").ThrowAsJavaScriptException(); return env.Null(); } else { stmt->Schedule(Work_BeginRun, baton); return info.This(); } }
0
489,150
sctp_disposition_t sctp_sf_do_prm_asoc(const struct sctp_endpoint *ep, const struct sctp_association *asoc, const sctp_subtype_t type, void *arg, sctp_cmd_seq_t *commands) { struct sctp_chunk *repl; struct sctp_association* my_asoc; /* The comment below says that we enter COOKIE-WAIT AFTER * sending the INIT, but that doesn't actually work in our * implementation... */ sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, SCTP_STATE(SCTP_STATE_COOKIE_WAIT)); /* RFC 2960 5.1 Normal Establishment of an Association * * A) "A" first sends an INIT chunk to "Z". In the INIT, "A" * must provide its Verification Tag (Tag_A) in the Initiate * Tag field. Tag_A SHOULD be a random number in the range of * 1 to 4294967295 (see 5.3.1 for Tag value selection). ... */ repl = sctp_make_init(asoc, &asoc->base.bind_addr, GFP_ATOMIC, 0); if (!repl) goto nomem; /* Cast away the const modifier, as we want to just * rerun it through as a sideffect. */ my_asoc = (struct sctp_association *)asoc; sctp_add_cmd_sf(commands, SCTP_CMD_NEW_ASOC, SCTP_ASOC(my_asoc)); /* Choose transport for INIT. */ sctp_add_cmd_sf(commands, SCTP_CMD_INIT_CHOOSE_TRANSPORT, SCTP_CHUNK(repl)); /* After sending the INIT, "A" starts the T1-init timer and * enters the COOKIE-WAIT state. */ sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START, SCTP_TO(SCTP_EVENT_TIMEOUT_T1_INIT)); sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl)); return SCTP_DISPOSITION_CONSUME; nomem: return SCTP_DISPOSITION_NOMEM; }
0
247,571
TEST_P(SslSocketTest, StatelessSessionResumptionEnabledByDefault) { const std::string server_ctx_yaml = R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_key.pem" )EOF"; const std::string client_ctx_yaml = R"EOF( common_tls_context: )EOF"; testSupportForStatelessSessionResumption(server_ctx_yaml, client_ctx_yaml, true, GetParam()); }
0
204,195
static void parse_rtcp_bye(pjmedia_rtcp_session *sess, const void *pkt, pj_size_t size) { pj_str_t reason = {"-", 1}; /* Check and get BYE reason */ if (size > 8) { reason.slen = PJ_MIN(sizeof(sess->stat.peer_sdes_buf_), *((pj_uint8_t*)pkt+8)); pj_memcpy(sess->stat.peer_sdes_buf_, ((pj_uint8_t*)pkt+9), reason.slen); reason.ptr = sess->stat.peer_sdes_buf_; } /* Just print RTCP BYE log */ PJ_LOG(5, (sess->name, "Received RTCP BYE, reason: %.*s", reason.slen, reason.ptr)); }
1
314,527
static pj_status_t validate_sdp_conn(const pjmedia_sdp_conn *c) { CHECK( c, PJ_EINVAL); CHECK( pj_strcmp2(&c->net_type, "IN")==0, PJMEDIA_SDP_EINCONN); CHECK( pj_strcmp2(&c->addr_type, "IP4")==0 || pj_strcmp2(&c->addr_type, "IP6")==0, PJMEDIA_SDP_EINCONN); CHECK( c->addr.slen != 0, PJMEDIA_SDP_EINCONN); return PJ_SUCCESS; }
0