idx
int64
func
string
target
int64
498,086
void html_txtf(const char *format, ...) { va_list args; va_start(args, format); html_vtxtf(format, args); va_end(args); }
0
462,215
static pj_status_t decode_sockaddr_attr(pj_pool_t *pool, const pj_uint8_t *buf, const pj_stun_msg_hdr *msghdr, void **p_attr) { pj_stun_sockaddr_attr *attr; int af; unsigned addr_len; pj_uint32_t val; PJ_CHECK_STACK(); PJ_UNUSED_ARG(msghdr); /* Create the attribute */ attr = PJ_POOL_ZALLOC_T(pool, pj_stun_sockaddr_attr); GETATTRHDR(buf, &attr->hdr); /* Check that the attribute length is valid */ if (attr->hdr.length != STUN_GENERIC_IPV4_ADDR_LEN && attr->hdr.length != STUN_GENERIC_IPV6_ADDR_LEN) { return PJNATH_ESTUNINATTRLEN; } /* Check address family */ val = *(pj_uint8_t*)(buf + ATTR_HDR_LEN + 1); /* Check address family is valid */ if (val == 1) { if (attr->hdr.length != STUN_GENERIC_IPV4_ADDR_LEN) return PJNATH_ESTUNINATTRLEN; af = pj_AF_INET(); addr_len = 4; } else if (val == 2) { if (attr->hdr.length != STUN_GENERIC_IPV6_ADDR_LEN) return PJNATH_ESTUNINATTRLEN; af = pj_AF_INET6(); addr_len = 16; } else { /* Invalid address family */ return PJNATH_EINVAF; } /* Get port and address */ pj_sockaddr_init(af, &attr->sockaddr, NULL, 0); pj_sockaddr_set_port(&attr->sockaddr, GETVAL16H(buf, ATTR_HDR_LEN+2)); pj_memcpy(pj_sockaddr_get_addr(&attr->sockaddr), buf+ATTR_HDR_LEN+4, addr_len); /* Done */ *p_attr = (void*)attr; return PJ_SUCCESS; }
0
225,769
GF_Err metx_box_write(GF_Box *s, GF_BitStream *bs) { GF_MetaDataSampleEntryBox *ptr = (GF_MetaDataSampleEntryBox *)s; GF_Err e = gf_isom_box_write_header(s, bs); if (e) return e; gf_bs_write_data(bs, ptr->reserved, 6); gf_bs_write_u16(bs, ptr->dataReferenceIndex); if (ptr->type!=GF_ISOM_BOX_TYPE_STPP) { if (ptr->content_encoding) gf_bs_write_data(bs, ptr->content_encoding, (u32) strlen(ptr->content_encoding)); gf_bs_write_u8(bs, 0); } if ((ptr->type==GF_ISOM_BOX_TYPE_METX) || (ptr->type==GF_ISOM_BOX_TYPE_STPP)) { if (ptr->xml_namespace) gf_bs_write_data(bs, ptr->xml_namespace, (u32) strlen(ptr->xml_namespace)); gf_bs_write_u8(bs, 0); if (ptr->xml_schema_loc) gf_bs_write_data(bs, ptr->xml_schema_loc, (u32) strlen(ptr->xml_schema_loc)); gf_bs_write_u8(bs, 0); if (ptr->type==GF_ISOM_BOX_TYPE_STPP) { if (ptr->mime_type) gf_bs_write_data(bs, ptr->mime_type, (u32) strlen(ptr->mime_type)); gf_bs_write_u8(bs, 0); } } //mett, sbtt, stxt else { if (ptr->mime_type) gf_bs_write_data(bs, ptr->mime_type, (u32) strlen(ptr->mime_type)); gf_bs_write_u8(bs, 0); } return GF_OK;
0
276,921
static int do_i2c_md(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { uint chip; uint addr, length; uint alen; uint j, nbytes, linebytes; int ret; #if CONFIG_IS_ENABLED(DM_I2C) struct udevice *dev; #endif /* We use the last specified parameters, unless new ones are * entered. */ chip = i2c_dp_last_chip; addr = i2c_dp_last_addr; alen = i2c_dp_last_alen; length = i2c_dp_last_length; if (argc < 3) return CMD_RET_USAGE; if ((flag & CMD_FLAG_REPEAT) == 0) { /* * New command specified. */ /* * I2C chip address */ chip = hextoul(argv[1], NULL); /* * I2C data address within the chip. This can be 1 or * 2 bytes long. Some day it might be 3 bytes long :-). */ addr = hextoul(argv[2], NULL); alen = get_alen(argv[2], DEFAULT_ADDR_LEN); if (alen > 3) return CMD_RET_USAGE; /* * If another parameter, it is the length to display. * Length is the number of objects, not number of bytes. */ if (argc > 3) length = hextoul(argv[3], NULL); } #if CONFIG_IS_ENABLED(DM_I2C) ret = i2c_get_cur_bus_chip(chip, &dev); if (!ret && alen != -1) ret = i2c_set_chip_offset_len(dev, alen); if (ret) return i2c_report_err(ret, I2C_ERR_READ); #endif /* * Print the lines. * * We buffer all read data, so we can make sure data is read only * once. */ nbytes = length; do { unsigned char linebuf[DISP_LINE_LEN]; unsigned char *cp; linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes; #if CONFIG_IS_ENABLED(DM_I2C) ret = dm_i2c_read(dev, addr, linebuf, linebytes); #else ret = i2c_read(chip, addr, alen, linebuf, linebytes); #endif if (ret) return i2c_report_err(ret, I2C_ERR_READ); else { printf("%04x:", addr); cp = linebuf; for (j=0; j<linebytes; j++) { printf(" %02x", *cp++); addr++; } puts (" "); cp = linebuf; for (j=0; j<linebytes; j++) { if ((*cp < 0x20) || (*cp > 0x7e)) puts ("."); else printf("%c", *cp); cp++; } putc ('\n'); } nbytes -= linebytes; } while (nbytes > 0); i2c_dp_last_chip = chip; i2c_dp_last_addr = addr; i2c_dp_last_alen = alen; i2c_dp_last_length = length; return 0; }
0
466,107
static int load_segment_descriptor(struct x86_emulate_ctxt *ctxt, u16 selector, int seg) { struct desc_struct seg_desc; u8 dpl, rpl, cpl; unsigned err_vec = GP_VECTOR; u32 err_code = 0; bool null_selector = !(selector & ~0x3); /* 0000-0003 are null */ int ret; memset(&seg_desc, 0, sizeof seg_desc); if ((seg <= VCPU_SREG_GS && ctxt->mode == X86EMUL_MODE_VM86) || ctxt->mode == X86EMUL_MODE_REAL) { /* set real mode segment descriptor */ set_desc_base(&seg_desc, selector << 4); set_desc_limit(&seg_desc, 0xffff); seg_desc.type = 3; seg_desc.p = 1; seg_desc.s = 1; goto load; } /* NULL selector is not valid for TR, CS and SS */ if ((seg == VCPU_SREG_CS || seg == VCPU_SREG_SS || seg == VCPU_SREG_TR) && null_selector) goto exception; /* TR should be in GDT only */ if (seg == VCPU_SREG_TR && (selector & (1 << 2))) goto exception; if (null_selector) /* for NULL selector skip all following checks */ goto load; ret = read_segment_descriptor(ctxt, selector, &seg_desc); if (ret != X86EMUL_CONTINUE) return ret; err_code = selector & 0xfffc; err_vec = GP_VECTOR; /* can't load system descriptor into segment selecor */ if (seg <= VCPU_SREG_GS && !seg_desc.s) goto exception; if (!seg_desc.p) { err_vec = (seg == VCPU_SREG_SS) ? SS_VECTOR : NP_VECTOR; goto exception; } rpl = selector & 3; dpl = seg_desc.dpl; cpl = ctxt->ops->cpl(ctxt); switch (seg) { case VCPU_SREG_SS: /* * segment is not a writable data segment or segment * selector's RPL != CPL or segment selector's RPL != CPL */ if (rpl != cpl || (seg_desc.type & 0xa) != 0x2 || dpl != cpl) goto exception; break; case VCPU_SREG_CS: if (!(seg_desc.type & 8)) goto exception; if (seg_desc.type & 4) { /* conforming */ if (dpl > cpl) goto exception; } else { /* nonconforming */ if (rpl > cpl || dpl != cpl) goto exception; } /* CS(RPL) <- CPL */ selector = (selector & 0xfffc) | cpl; break; case VCPU_SREG_TR: if (seg_desc.s || (seg_desc.type != 1 && seg_desc.type != 9)) goto exception; break; case VCPU_SREG_LDTR: if (seg_desc.s || seg_desc.type != 2) goto exception; break; default: /* DS, ES, FS, or GS */ /* * segment is not a data or readable code segment or * ((segment is a data or nonconforming code segment) * and (both RPL and CPL > DPL)) */ if ((seg_desc.type & 0xa) == 0x8 || (((seg_desc.type & 0xc) != 0xc) && (rpl > dpl && cpl > dpl))) goto exception; break; } if (seg_desc.s) { /* mark segment as accessed */ seg_desc.type |= 1; ret = write_segment_descriptor(ctxt, selector, &seg_desc); if (ret != X86EMUL_CONTINUE) return ret; } load: ctxt->ops->set_segment(ctxt, selector, &seg_desc, 0, seg); return X86EMUL_CONTINUE; exception: emulate_exception(ctxt, err_vec, err_code, true); return X86EMUL_PROPAGATE_FAULT; }
0
409,430
set_mouse_topline(win_T *wp) { orig_topline = wp->w_topline; # ifdef FEAT_DIFF orig_topfill = wp->w_topfill; # endif }
0
90,900
void GetUsageForOrigins(const std::set<GURL>& origins, StorageType type) { DCHECK(original_message_loop()->BelongsToCurrentThread()); std::vector<GURL> origins_to_gather; std::set<GURL> cached_origins; client_tracker()->GetCachedOrigins(&cached_origins); std::set<GURL> already_added; for (std::set<GURL>::const_iterator iter = origins.begin(); iter != origins.end(); ++iter) { if (cached_origins.find(*iter) == cached_origins.end() && already_added.insert(*iter).second) { origins_to_gather.push_back(*iter); } } if (origins_to_gather.empty()) { CallCompleted(); DeleteSoon(); return; } std::sort(origins_to_gather.begin(), origins_to_gather.end(), SortByHost); for (std::vector<GURL>::const_iterator iter = origins_to_gather.begin(); iter != origins_to_gather.end(); iter++) pending_origins_.push_back(*iter); for (std::vector<GURL>::const_iterator iter = origins_to_gather.begin(); iter != origins_to_gather.end(); iter++) client_->GetOriginUsage( *iter, tracker_->type(), callback_factory_.NewCallback(&GatherUsageTaskBase::DidGetUsage)); }
0
256,450
JANET_CORE_FN(cfun_array_push, "(array/push arr x)", "Insert an element in the end of an array. Modifies the input array and returns it.") { janet_arity(argc, 1, -1); JanetArray *array = janet_getarray(argv, 0); if (INT32_MAX - argc + 1 <= array->count) { janet_panic("array overflow"); } int32_t newcount = array->count - 1 + argc; janet_array_ensure(array, newcount, 2); if (argc > 1) memcpy(array->data + array->count, argv + 1, (size_t)(argc - 1) * sizeof(Janet)); array->count = newcount; return argv[0]; }
0
256,435
static void parse_rtcp_report( pjmedia_rtcp_session *sess, const void *pkt, pj_size_t size) { pjmedia_rtcp_common *common = (pjmedia_rtcp_common*) pkt; const pjmedia_rtcp_rr *rr = NULL; const pjmedia_rtcp_sr *sr = NULL; pj_uint32_t last_loss, jitter_samp, jitter; /* Parse RTCP */ if (common->pt == RTCP_SR) { if (sizeof (pjmedia_rtcp_common) + sizeof (pjmedia_rtcp_sr) > size) { TRACE_((sess->name, "Discarding RTCP SR due to truncated size " "%d bytes", size)); return; } sr = (pjmedia_rtcp_sr*) (((char*)pkt) + sizeof(pjmedia_rtcp_common)); if (common->count > 0 && size >= (sizeof(pjmedia_rtcp_sr_pkt))) { rr = (pjmedia_rtcp_rr*)(((char*)pkt) + (sizeof(pjmedia_rtcp_common) + sizeof(pjmedia_rtcp_sr))); } } else if (common->pt == RTCP_RR && common->count > 0) { if (sizeof (pjmedia_rtcp_common) + sizeof (pjmedia_rtcp_rr) > size) { TRACE_((sess->name, "Discarding RTCP RR due to truncated size " "%d bytes", size)); return; } rr = (pjmedia_rtcp_rr*)(((char*)pkt) + sizeof(pjmedia_rtcp_common)); #if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0) } else if (common->pt == RTCP_XR) { if (sess->xr_enabled) pjmedia_rtcp_xr_rx_rtcp_xr(&sess->xr_session, pkt, size); return; #endif } if (sr) { /* Save LSR from NTP timestamp of RTCP packet */ sess->rx_lsr = ((pj_ntohl(sr->ntp_sec) & 0x0000FFFF) << 16) | ((pj_ntohl(sr->ntp_frac) >> 16) & 0xFFFF); /* Calculate SR arrival time for DLSR */ pj_get_timestamp(&sess->rx_lsr_time); TRACE_((sess->name, "Rx RTCP SR: ntp_ts=%p", sess->rx_lsr, (pj_uint32_t)(sess->rx_lsr_time.u64*65536/sess->ts_freq.u64))); } /* Nothing more to do if there's no RR packet */ if (rr == NULL) return; last_loss = sess->stat.tx.loss; /* Get packet loss */ sess->stat.tx.loss = (rr->total_lost_2 << 16) + (rr->total_lost_1 << 8) + rr->total_lost_0; TRACE_((sess->name, "Rx RTCP RR: total_lost_2=%x, 1=%x, 0=%x, lost=%d", (int)rr->total_lost_2, (int)rr->total_lost_1, (int)rr->total_lost_0, sess->stat.tx.loss)); /* We can't calculate the exact loss period for TX, so just give the * best estimation. */ if (sess->stat.tx.loss > last_loss) { unsigned period; /* Loss period in msec */ period = (sess->stat.tx.loss - last_loss) * sess->pkt_size * 1000 / sess->clock_rate; /* Loss period in usec */ period *= 1000; /* Update loss period stat */ pj_math_stat_update(&sess->stat.tx.loss_period, period); } /* Get jitter value in usec */ jitter_samp = pj_ntohl(rr->jitter); /* Calculate jitter in usec, avoiding overflows */ if (jitter_samp <= 4294) jitter = jitter_samp * 1000000 / sess->clock_rate; else { jitter = jitter_samp * 1000 / sess->clock_rate; jitter *= 1000; } /* Update jitter statistics */ pj_math_stat_update(&sess->stat.tx.jitter, jitter); /* Can only calculate if LSR and DLSR is present in RR */ if (rr->lsr && rr->dlsr) { pj_uint32_t lsr, now, dlsr; pj_uint64_t eedelay; pjmedia_rtcp_ntp_rec ntp; /* LSR is the middle 32bit of NTP. It has 1/65536 second * resolution */ lsr = pj_ntohl(rr->lsr); /* DLSR is delay since LSR, also in 1/65536 resolution */ dlsr = pj_ntohl(rr->dlsr); /* Get current time, and convert to 1/65536 resolution */ pjmedia_rtcp_get_ntp_time(sess, &ntp); now = ((ntp.hi & 0xFFFF) << 16) + (ntp.lo >> 16); /* End-to-end delay is (now-lsr-dlsr) */ eedelay = now - lsr - dlsr; /* Convert end to end delay to usec (keeping the calculation in * 64bit space):: * sess->ee_delay = (eedelay * 1000) / 65536; */ if (eedelay < 4294) { eedelay = (eedelay * 1000000) >> 16; } else { eedelay = (eedelay * 1000) >> 16; eedelay *= 1000; } TRACE_((sess->name, "Rx RTCP RR: lsr=%p, dlsr=%p (%d:%03dms), " "now=%p, rtt=%p", lsr, dlsr, dlsr/65536, (dlsr%65536)*1000/65536, now, (pj_uint32_t)eedelay)); /* Only save calculation if "now" is greater than lsr, or * otherwise rtt will be invalid */ if (now-dlsr >= lsr) { unsigned rtt = (pj_uint32_t)eedelay; /* Check that eedelay value really makes sense. * We allow up to 30 seconds RTT! */ if (eedelay > 30 * 1000 * 1000UL) { TRACE_((sess->name, "RTT not making any sense, ignored..")); goto end_rtt_calc; } #if defined(PJMEDIA_RTCP_NORMALIZE_FACTOR) && PJMEDIA_RTCP_NORMALIZE_FACTOR!=0 /* "Normalize" rtt value that is exceptionally high. For such * values, "normalize" the rtt to be PJMEDIA_RTCP_NORMALIZE_FACTOR * times the average value. */ if (rtt > ((unsigned)sess->stat.rtt.mean * PJMEDIA_RTCP_NORMALIZE_FACTOR) && sess->stat.rtt.n!=0) { unsigned orig_rtt = rtt; rtt = sess->stat.rtt.mean * PJMEDIA_RTCP_NORMALIZE_FACTOR; PJ_LOG(5,(sess->name, "RTT value %d usec is normalized to %d usec", orig_rtt, rtt)); } #endif TRACE_((sess->name, "RTCP RTT is set to %d usec", rtt)); /* Update RTT stat */ pj_math_stat_update(&sess->stat.rtt, rtt); } else { PJ_LOG(5, (sess->name, "Internal RTCP NTP clock skew detected: " "lsr=%p, now=%p, dlsr=%p (%d:%03dms), " "diff=%d", lsr, now, dlsr, dlsr/65536, (dlsr%65536)*1000/65536, dlsr-(now-lsr))); } } end_rtt_calc: pj_gettimeofday(&sess->stat.tx.update); sess->stat.tx.update_cnt++; }
0
415,214
cmd_disconnect (assuan_context_t ctx, char *line) { ctrl_t ctrl = assuan_get_pointer (ctx); (void)line; ctrl->server_local->disconnect_allowed = 1; return 0; }
0
348,444
static void ax_changedmtu(struct mkiss *ax) { struct net_device *dev = ax->dev; unsigned char *xbuff, *rbuff, *oxbuff, *orbuff; int len; len = dev->mtu * 2; /* * allow for arrival of larger UDP packets, even if we say not to * also fixes a bug in which SunOS sends 512-byte packets even with * an MSS of 128 */ if (len < 576 * 2) len = 576 * 2; xbuff = kmalloc(len + 4, GFP_ATOMIC); rbuff = kmalloc(len + 4, GFP_ATOMIC); if (xbuff == NULL || rbuff == NULL) { printk(KERN_ERR "mkiss: %s: unable to grow ax25 buffers, " "MTU change cancelled.\n", ax->dev->name); dev->mtu = ax->mtu; kfree(xbuff); kfree(rbuff); return; } spin_lock_bh(&ax->buflock); oxbuff = ax->xbuff; ax->xbuff = xbuff; orbuff = ax->rbuff; ax->rbuff = rbuff; if (ax->xleft) { if (ax->xleft <= len) { memcpy(ax->xbuff, ax->xhead, ax->xleft); } else { ax->xleft = 0; dev->stats.tx_dropped++; } } ax->xhead = ax->xbuff; if (ax->rcount) { if (ax->rcount <= len) { memcpy(ax->rbuff, orbuff, ax->rcount); } else { ax->rcount = 0; dev->stats.rx_over_errors++; set_bit(AXF_ERROR, &ax->flags); } } ax->mtu = dev->mtu + 73; ax->buffsize = len; spin_unlock_bh(&ax->buflock); kfree(oxbuff); kfree(orbuff); }
0
301,423
static NTSTATUS vfswrap_fget_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info, TALLOC_CTX *mem_ctx, struct security_descriptor **ppdesc) { NTSTATUS result; START_PROFILE(fget_nt_acl); result = posix_fget_nt_acl(fsp, security_info, mem_ctx, ppdesc); END_PROFILE(fget_nt_acl); return result; }
0
500,682
int sftp_unlink(sftp_session sftp, const char *file) { sftp_status_message status = NULL; sftp_message msg = NULL; ssh_string filename; ssh_buffer buffer; uint32_t id; buffer = ssh_buffer_new(); if (buffer == NULL) { ssh_set_error_oom(sftp->session); return -1; } filename = ssh_string_from_char(file); if (filename == NULL) { ssh_set_error_oom(sftp->session); ssh_buffer_free(buffer); return -1; } id = sftp_get_new_id(sftp); if (buffer_add_u32(buffer, id) < 0 || buffer_add_ssh_string(buffer, filename) < 0) { ssh_set_error_oom(sftp->session); ssh_buffer_free(buffer); ssh_string_free(filename); return -1; } if (sftp_packet_write(sftp, SSH_FXP_REMOVE, buffer) < 0) { ssh_buffer_free(buffer); ssh_string_free(filename); return -1; } ssh_string_free(filename); ssh_buffer_free(buffer); while (msg == NULL) { if (sftp_read_and_dispatch(sftp)) { return -1; } msg = sftp_dequeue(sftp, id); } if (msg->packet_type == SSH_FXP_STATUS) { /* by specification, this command's only supposed to return SSH_FXP_STATUS */ status = parse_status_msg(msg); sftp_message_free(msg); if (status == NULL) { return -1; } sftp_set_error(sftp, status->status); switch (status->status) { case SSH_FX_OK: status_msg_free(status); return 0; default: break; } /* * The status should be SSH_FX_OK if the command was successful, if it * didn't, then there was an error */ ssh_set_error(sftp->session, SSH_REQUEST_DENIED, "SFTP server: %s", status->errormsg); status_msg_free(status); return -1; } else { ssh_set_error(sftp->session,SSH_FATAL, "Received message %d when attempting to remove file", msg->packet_type); sftp_message_free(msg); } return -1; }
0
310,000
npop(void) { int result = 0; if (TPS(stack_ptr) > 0) { TPS(stack_ptr)--; if (TPS(stack)[TPS(stack_ptr)].num_type) result = TPS(stack)[TPS(stack_ptr)].data.num; } else { DEBUG(2, ("npop: stack underflow: %s", _nc_visbuf(TPS(tparam_base)))); _nc_tparm_err++; } return result; }
0
224,285
gopher_request_parse(const HttpRequest * req, char *type_id, char *request) { ::Parser::Tokenizer tok(req->url.path()); if (request) *request = 0; tok.skip('/'); // ignore failures? path could be ab-empty if (tok.atEnd()) { *type_id = GOPHER_DIRECTORY; return; } static const CharacterSet anyByte("UTF-8",0x00, 0xFF); SBuf typeId; (void)tok.prefix(typeId, anyByte, 1); // never fails since !atEnd() *type_id = typeId[0]; if (request) { SBufToCstring(request, tok.remaining().substr(0, MAX_URL-1)); /* convert %xx to char */ rfc1738_unescape(request); } }
0
463,156
static int cleanup_cb(void *rock, const char *key, size_t keylen, const char *data __attribute__((unused)), size_t datalen __attribute__((unused))) { annotate_db_t *d = (annotate_db_t *)rock; return cyrusdb_delete(d->db, key, keylen, tid(d), /*force*/1); }
0
246,486
RPVector *r_bin_wasm_get_codes(RBinWasmObj *bin) { r_return_val_if_fail (bin && bin->g_sections, NULL); return bin->g_codes? bin->g_codes: parse_unique_subsec_vec_by_id (bin, R_BIN_WASM_SECTION_CODE); }
0
355,641
eval7_leader( typval_T *rettv, int numeric_only, char_u *start_leader, char_u **end_leaderp) { char_u *end_leader = *end_leaderp; int ret = OK; int error = FALSE; varnumber_T val = 0; vartype_T type = rettv->v_type; #ifdef FEAT_FLOAT float_T f = 0.0; if (rettv->v_type == VAR_FLOAT) f = rettv->vval.v_float; else #endif { while (VIM_ISWHITE(end_leader[-1])) --end_leader; if (in_vim9script() && end_leader[-1] == '!') val = tv2bool(rettv); else val = tv_get_number_chk(rettv, &error); } if (error) { clear_tv(rettv); ret = FAIL; } else { while (end_leader > start_leader) { --end_leader; if (*end_leader == '!') { if (numeric_only) { ++end_leader; break; } #ifdef FEAT_FLOAT if (rettv->v_type == VAR_FLOAT) { if (in_vim9script()) { rettv->v_type = VAR_BOOL; val = f == 0.0 ? VVAL_TRUE : VVAL_FALSE; } else f = !f; } else #endif { val = !val; type = VAR_BOOL; } } else if (*end_leader == '-') { #ifdef FEAT_FLOAT if (rettv->v_type == VAR_FLOAT) f = -f; else #endif { val = -val; type = VAR_NUMBER; } } } #ifdef FEAT_FLOAT if (rettv->v_type == VAR_FLOAT) { clear_tv(rettv); rettv->vval.v_float = f; } else #endif { clear_tv(rettv); if (in_vim9script()) rettv->v_type = type; else rettv->v_type = VAR_NUMBER; rettv->vval.v_number = val; } } *end_leaderp = end_leader; return ret; }
0
383,320
gdImageDashedLine (gdImagePtr im, int x1, int y1, int x2, int y2, int color) { int dx, dy, incr1, incr2, d, x, y, xend, yend, xdirflag, ydirflag; int dashStep = 0; int on = 1; int wid; int vert; int thick = im->thick; dx = abs (x2 - x1); dy = abs (y2 - y1); if (dy <= dx) { /* More-or-less horizontal. use wid for vertical stroke */ wid = (int)(thick * sin (atan2 (dy, dx))); vert = 1; d = 2 * dy - dx; incr1 = 2 * dy; incr2 = 2 * (dy - dx); if (x1 > x2) { x = x2; y = y2; ydirflag = (-1); xend = x1; } else { x = x1; y = y1; ydirflag = 1; xend = x2; } dashedSet (im, x, y, color, &on, &dashStep, wid, vert); if (((y2 - y1) * ydirflag) > 0) { while (x < xend) { x++; if (d < 0) { d += incr1; } else { y++; d += incr2; } dashedSet (im, x, y, color, &on, &dashStep, wid, vert); } } else { while (x < xend) { x++; if (d < 0) { d += incr1; } else { y--; d += incr2; } dashedSet (im, x, y, color, &on, &dashStep, wid, vert); } } } else { /* More-or-less vertical. use wid for horizontal stroke */ wid = (int)(thick * sin (atan2 (dy, dx))); vert = 0; d = 2 * dx - dy; incr1 = 2 * dx; incr2 = 2 * (dx - dy); if (y1 > y2) { y = y2; x = x2; yend = y1; xdirflag = (-1); } else { y = y1; x = x1; yend = y2; xdirflag = 1; } dashedSet (im, x, y, color, &on, &dashStep, wid, vert); if (((x2 - x1) * xdirflag) > 0) { while (y < yend) { y++; if (d < 0) { d += incr1; } else { x++; d += incr2; } dashedSet (im, x, y, color, &on, &dashStep, wid, vert); } } else { while (y < yend) { y++; if (d < 0) { d += incr1; } else { x--; d += incr2; } dashedSet (im, x, y, color, &on, &dashStep, wid, vert); } } } }
0
217,551
int parse(char *elf) { int fd; struct stat st; uint8_t *elf_map; int count; char *tmp; char *name; char flag[4]; MODE = get_elf_class(elf); fd = open(elf, O_RDONLY); if (fd < 0) { perror("open"); return -1; } if (fstat(fd, &st) < 0) { perror("fstat"); return -1; } elf_map = mmap(0, st.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); if (elf_map == MAP_FAILED) { perror("mmap"); return -1; } /* 32bit */ if (MODE == ELFCLASS32) { /* ELF Header Information */ Elf32_Ehdr *ehdr; ehdr = (Elf32_Ehdr *)elf_map; INFO("ELF Header\n"); switch (ehdr->e_type) { case ET_NONE: tmp = "An unknown type"; break; case ET_REL: tmp = "A relocatable file"; break; case ET_EXEC: tmp = "An executable file"; break; case ET_DYN: tmp = "A shared object"; break; case ET_CORE: tmp = "A core file"; break; default: tmp = "An unknown type"; break; } PRINT_HEADER_EXP("e_type:", ehdr->e_type, tmp); switch (ehdr->e_type) { case EM_NONE: tmp = "An unknown machine"; break; case EM_M32: tmp = "AT&T WE 32100"; break; case EM_SPARC: tmp = "Sun Microsystems SPARC"; break; case EM_386: tmp = "Intel 80386"; break; case EM_68K: tmp = "Motorola 68000"; break; case EM_88K: tmp = "Motorola 88000"; break; case EM_860: tmp = "Intel 80860"; break; case EM_MIPS: tmp = "MIPS RS3000 (big-endian only)"; break; case EM_PARISC: tmp = "HP/PA"; break; case EM_SPARC32PLUS: tmp = "SPARC with enhanced instruction set"; break; case EM_PPC: tmp = "PowerPC"; break; case EM_PPC64: tmp = "PowerPC 64-bit"; break; case EM_S390: tmp = "IBM S/390"; break; case EM_ARM: tmp = "Advanced RISC Machines"; break; case EM_SH: tmp = "Renesas SuperH"; break; case EM_SPARCV9: tmp = "SPARC v9 64-bit"; break; case EM_IA_64: tmp = "Intel Itanium"; break; case EM_X86_64: tmp = "AMD x86-64"; break; case EM_VAX: tmp = "DEC Vax"; break; default: tmp = "An unknown machine"; break; } PRINT_HEADER_EXP("e_machine:", ehdr->e_machine, tmp); switch (ehdr->e_version) { case EV_NONE: tmp = "Invalid version"; break; case EV_CURRENT: tmp = "Current version"; break; default: tmp = "Known version"; break; } PRINT_HEADER_EXP("e_version:", ehdr->e_version, tmp); PRINT_HEADER("e_entry:", ehdr->e_entry); PRINT_HEADER("e_phoff:", ehdr->e_phoff); PRINT_HEADER("e_shoff:", ehdr->e_shoff); PRINT_HEADER("e_flags:", ehdr->e_flags); PRINT_HEADER("e_ehsize:", ehdr->e_ehsize); PRINT_HEADER("e_phentsize:", ehdr->e_phentsize); PRINT_HEADER("e_phnum:", ehdr->e_phnum); PRINT_HEADER("e_shentsize:", ehdr->e_shentsize); PRINT_HEADER("e_shentsize:", ehdr->e_shentsize); PRINT_HEADER("e_shstrndx:", ehdr->e_shstrndx); /* Section Information */ Elf32_Shdr *shdr; Elf32_Phdr *phdr; Elf32_Shdr shstrtab; shdr = (Elf32_Shdr *)&elf_map[ehdr->e_shoff]; phdr = (Elf32_Phdr *)&elf_map[ehdr->e_phoff]; shstrtab = shdr[ehdr->e_shstrndx]; INFO("Section Header Table\n"); PRINT_SECTION_TITLE("Nr", "Name", "Type", "Addr", "Off", "Size", "Es", "Flg", "Lk", "Inf", "Al"); for (int i = 0; i < ehdr->e_shnum; i++) { name = elf_map + shstrtab.sh_offset + shdr[i].sh_name; switch (shdr[i].sh_type) { case SHT_NULL: tmp = "SHT_NULL"; break; case SHT_PROGBITS: tmp = "SHT_PROGBITS"; break; case SHT_SYMTAB: tmp = "SHT_SYMTAB"; break; case SHT_STRTAB: tmp = "SHT_STRTAB"; break; case SHT_RELA: tmp = "SHT_RELA"; break; case SHT_HASH: tmp = "SHT_HASH"; break; case SHT_DYNAMIC: tmp = "SHT_DYNAMIC"; break; case SHT_NOTE: tmp = "SHT_NOTE"; break; case SHT_NOBITS: tmp = "SHT_NOBITS"; break; case SHT_REL: tmp = "SHT_REL"; break; case SHT_SHLIB: tmp = "SHT_SHLIB"; break; case SHT_DYNSYM: tmp = "SHT_DYNSYM"; break; case SHT_LOPROC: tmp = "SHT_LOPROC"; break; case SHT_HIPROC: tmp = "SHT_HIPROC"; break; case SHT_LOUSER: tmp = "SHT_LOUSER"; break; case SHT_HIUSER: tmp = "SHT_HIUSER"; break; default: break; } if (strlen(name) > 15) { strcpy(&name[15 - 6], "[...]"); } strcpy(flag, " "); flag2str_sh(shdr[i].sh_flags, flag); PRINT_SECTION(i, name, tmp, shdr[i].sh_addr, shdr[i].sh_offset, shdr[i].sh_size, shdr[i].sh_entsize, \ flag, shdr[i].sh_link, shdr[i].sh_info, shdr[i].sh_addralign); } INFO("Program Header Table\n"); PRINT_PROGRAM_TITLE("Nr", "Type", "Offset", "Virtaddr", "Physaddr", "Filesiz", "Memsiz", "Flg", "Align"); for (int i = 0; i < ehdr->e_phnum; i++) { switch (phdr[i].p_type) { case PT_NULL: tmp = "PT_NULL"; break; case PT_LOAD: tmp = "PT_LOAD"; break; case PT_DYNAMIC: tmp = "PT_DYNAMIC"; break; case PT_INTERP: tmp = "PT_INTERP"; break; case PT_NOTE: tmp = "PT_NOTE"; break; case PT_SHLIB: tmp = "PT_SHLIB"; break; case PT_PHDR: tmp = "PT_PHDR"; break; case PT_LOPROC: tmp = "PT_LOPROC"; break; case PT_HIPROC: tmp = "PT_HIPROC"; break; case PT_GNU_STACK: tmp = "PT_GNU_STACK"; break; default: break; } strcpy(flag, " "); flag2str(phdr[i].p_flags, flag); PRINT_PROGRAM(i, tmp, phdr[i].p_offset, phdr[i].p_vaddr, phdr[i].p_paddr, phdr[i].p_filesz, phdr[i].p_memsz, flag, phdr[i].p_align); } INFO("Section to segment mapping\n"); for (int i = 0; i < ehdr->e_phnum; i++) { printf(" [%2d]", i); for (int j = 0; j < ehdr->e_shnum; j++) { name = elf_map + shstrtab.sh_offset + shdr[j].sh_name; if (shdr[j].sh_addr >= phdr[i].p_vaddr && shdr[j].sh_addr + shdr[j].sh_size <= phdr[i].p_vaddr + phdr[i].p_memsz && shdr[j].sh_type != SHT_NULL) { if (shdr[j].sh_flags >> 1 & 0x1) { printf(" %s", name); } } } printf("\n"); } INFO("Dynamic link information\n"); int dynstr; int dynamic; Elf32_Dyn *dyn; for (int i = 0; i < ehdr->e_shnum; i++) { name = elf_map + shstrtab.sh_offset + shdr[i].sh_name; if (!strcmp(name, ".dynstr")) { dynstr = i; } if (!strcmp(name, ".dynamic")) { dynamic = i; } } char value[50]; name = ""; dyn = (Elf32_Dyn *)&elf_map[shdr[dynamic].sh_offset]; count = shdr[dynamic].sh_size / sizeof(Elf32_Dyn); INFO("Dynamic section at offset 0x%x contains %d entries\n", shdr[dynamic].sh_offset, count); PRINT_DYN_TITLE("Tag", "Type", "Name/Value"); for(int i = 0; i < count; i++) { tmp = ""; memset(value, 0, 50); snprintf(value, 50, "0x%x", dyn[i].d_un.d_val); switch (dyn[i].d_tag) { /* Legal values for d_tag (dynamic entry type). */ case DT_NULL: tmp = "DT_NULL"; break; case DT_NEEDED: tmp = "DT_NEEDED"; name = elf_map + shdr[dynstr].sh_offset + dyn[i].d_un.d_val; snprintf(value, 50, "Shared library: [%s]", name); break; case DT_PLTRELSZ: tmp = "DT_PLTRELSZ"; break; case DT_PLTGOT: tmp = "DT_PLTGOT"; break; case DT_HASH: tmp = "DT_HASH"; break; case DT_STRTAB: tmp = "DT_STRTAB"; break; case DT_SYMTAB: tmp = "DT_SYMTAB"; break; case DT_RELA: tmp = "DT_RELA"; break; case DT_RELASZ: tmp = "DT_RELASZ"; break; case DT_RELAENT: tmp = "DT_RELAENT"; break; case DT_STRSZ: tmp = "DT_STRSZ"; break; case DT_SYMENT: tmp = "DT_SYMENT"; break; case DT_INIT: tmp = "DT_INIT"; break; case DT_FINI: tmp = "DT_FINI"; break; case DT_SONAME: tmp = "DT_SONAME"; break; case DT_RPATH: tmp = "DT_RPATH"; break; case DT_SYMBOLIC: tmp = "DT_SYMBOLIC"; break; case DT_REL: tmp = "DT_REL"; break; case DT_RELSZ: tmp = "DT_RELSZ"; break; case DT_RELENT: tmp = "DT_RELENT"; break; case DT_PLTREL: tmp = "DT_PLTREL"; break; case DT_DEBUG: tmp = "DT_DEBUG"; break; case DT_TEXTREL: tmp = "DT_TEXTREL"; break; case DT_JMPREL: tmp = "DT_JMPREL"; break; case DT_BIND_NOW: tmp = "DT_BIND_NOW"; break; case DT_INIT_ARRAY: tmp = "DT_INIT_ARRAY"; break; case DT_FINI_ARRAY: tmp = "DT_FINI_ARRAY"; break; case DT_INIT_ARRAYSZ: tmp = "DT_INIT_ARRAYSZ"; break; case DT_FINI_ARRAYSZ: tmp = "DT_FINI_ARRAYSZ"; break; case DT_RUNPATH: tmp = "DT_RUNPATH"; break; case DT_FLAGS: tmp = "DT_FLAGS"; snprintf(value, 50, "Flags: %d", dyn[i].d_un.d_val); break; case DT_ENCODING: tmp = "DT_ENCODING"; break; case DT_PREINIT_ARRAYSZ: tmp = "DT_PREINIT_ARRAYSZ"; break; case DT_SYMTAB_SHNDX: tmp = "DT_SYMTAB_SHNDX"; break; case DT_NUM: tmp = "DT_NUM"; break; case DT_LOOS: tmp = "DT_LOOS"; break; case DT_HIOS: tmp = "DT_HIOS"; break; case DT_LOPROC: tmp = "DT_LOPROC"; break; case DT_HIPROC: tmp = "DT_HIPROC"; break; case DT_PROCNUM: tmp = "DT_LOPROC"; break; /* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the * Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's * approach. */ case DT_VALRNGLO: tmp = "DT_VALRNGLO"; break; case DT_GNU_PRELINKED: tmp = "DT_GNU_PRELINKED"; break; case DT_GNU_CONFLICTSZ: tmp = "DT_GNU_CONFLICTSZ"; break; case DT_GNU_LIBLISTSZ: tmp = "DT_GNU_LIBLISTSZ"; break; case DT_CHECKSUM: tmp = "DT_CHECKSUM"; break; case DT_PLTPADSZ: tmp = "DT_PLTPADSZ"; break; case DT_MOVEENT: tmp = "DT_MOVEENT"; break; case DT_MOVESZ: tmp = "DT_MOVESZ"; break; case DT_FEATURE_1: tmp = "DT_FEATURE_1"; break; case DT_POSFLAG_1: tmp = "DT_POSFLAG_1"; break; case DT_SYMINSZ: tmp = "DT_SYMINSZ"; break; case DT_SYMINENT: tmp = "DT_SYMINENT"; break; /* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the * Dyn.d_un.d_ptr field of the Elf*_Dyn structure. * If any adjustment is made to the ELF object after it has been * built these entries will need to be adjusted. */ case DT_ADDRRNGLO: tmp = "DT_ADDRRNGLO"; break; case DT_GNU_HASH: tmp = "DT_GNU_HASH"; break; case DT_TLSDESC_PLT: tmp = "DT_TLSDESC_PLT"; break; case DT_TLSDESC_GOT: tmp = "DT_TLSDESC_GOT"; break; case DT_GNU_CONFLICT: tmp = "DT_GNU_CONFLICT"; break; case DT_GNU_LIBLIST: tmp = "DT_GNU_LIBLIST"; break; case DT_CONFIG: tmp = "DT_CONFIG"; break; case DT_DEPAUDIT: tmp = "DT_DEPAUDIT"; break; case DT_AUDIT: tmp = "DT_AUDIT"; break; case DT_PLTPAD: tmp = "DT_PLTPAD"; break; case DT_MOVETAB: tmp = "DT_MOVETAB"; break; case DT_SYMINFO: tmp = "DT_SYMINFO"; break; /* The versioning entry types. The next are defined as part of the * GNU extension. */ case DT_VERSYM: tmp = "DT_VERSYM"; break; case DT_RELACOUNT: tmp = "DT_RELACOUNT"; break; case DT_RELCOUNT: tmp = "DT_RELCOUNT"; break; /* These were chosen by Sun. */ case DT_FLAGS_1: tmp = "DT_FLAGS_1"; switch (dyn[i].d_un.d_val) { case DF_1_PIE: snprintf(value, 50, "Flags: %s", "PIE"); break; default: snprintf(value, 50, "Flags: %d", dyn[i].d_un.d_val); break; } break; case DT_VERDEF: tmp = "DT_VERDEF"; break; case DT_VERDEFNUM: tmp = "DT_VERDEFNUM"; break; case DT_VERNEED: tmp = "DT_VERNEED"; break; case DT_VERNEEDNUM: tmp = "DT_VERNEEDNUM"; break; default: break; } PRINT_DYN(dyn[i].d_tag, tmp, value); } } /* 64bit */ if (MODE == ELFCLASS64) { /* ELF Header Information */ Elf64_Ehdr *ehdr; ehdr = (Elf64_Ehdr *)elf_map; INFO("ELF Header\n"); switch (ehdr->e_type) { case ET_NONE: tmp = "An unknown type"; break; case ET_REL: tmp = "A relocatable file"; break; case ET_EXEC: tmp = "An executable file"; break; case ET_DYN: tmp = "A shared object"; break; case ET_CORE: tmp = "A core file"; break; default: tmp = "An unknown type"; break; } PRINT_HEADER_EXP("e_type:", ehdr->e_type, tmp); switch (ehdr->e_type) { case EM_NONE: tmp = "An unknown machine"; break; case EM_M32: tmp = "AT&T WE 32100"; break; case EM_SPARC: tmp = "Sun Microsystems SPARC"; break; case EM_386: tmp = "Intel 80386"; break; case EM_68K: tmp = "Motorola 68000"; break; case EM_88K: tmp = "Motorola 88000"; break; case EM_860: tmp = "Intel 80860"; break; case EM_MIPS: tmp = "MIPS RS3000 (big-endian only)"; break; case EM_PARISC: tmp = "HP/PA"; break; case EM_SPARC32PLUS: tmp = "SPARC with enhanced instruction set"; break; case EM_PPC: tmp = "PowerPC"; break; case EM_PPC64: tmp = "PowerPC 64-bit"; break; case EM_S390: tmp = "IBM S/390"; break; case EM_ARM: tmp = "Advanced RISC Machines"; break; case EM_SH: tmp = "Renesas SuperH"; break; case EM_SPARCV9: tmp = "SPARC v9 64-bit"; break; case EM_IA_64: tmp = "Intel Itanium"; break; case EM_X86_64: tmp = "AMD x86-64"; break; case EM_VAX: tmp = "DEC Vax"; break; default: tmp = "An unknown machine"; break; } PRINT_HEADER_EXP("e_machine:", ehdr->e_machine, tmp); switch (ehdr->e_version) { case EV_NONE: tmp = "Invalid version"; break; case EV_CURRENT: tmp = "Current version"; break; default: tmp = "Known version"; break; } PRINT_HEADER_EXP("e_version:", ehdr->e_version, tmp); PRINT_HEADER("e_entry:", ehdr->e_entry); PRINT_HEADER("e_phoff:", ehdr->e_phoff); PRINT_HEADER("e_shoff:", ehdr->e_shoff); PRINT_HEADER("e_flags:", ehdr->e_flags); PRINT_HEADER("e_ehsize:", ehdr->e_ehsize); PRINT_HEADER("e_phentsize:", ehdr->e_phentsize); PRINT_HEADER("e_phnum:", ehdr->e_phnum); PRINT_HEADER("e_shentsize:", ehdr->e_shentsize); PRINT_HEADER("e_shentsize:", ehdr->e_shentsize); PRINT_HEADER("e_shstrndx:", ehdr->e_shstrndx); /* Section Information */ Elf64_Shdr *shdr; Elf64_Phdr *phdr; Elf64_Shdr shstrtab; shdr = (Elf64_Shdr *)&elf_map[ehdr->e_shoff]; phdr = (Elf64_Phdr *)&elf_map[ehdr->e_phoff]; shstrtab = shdr[ehdr->e_shstrndx]; INFO("Section Header Table\n"); PRINT_SECTION_TITLE("Nr", "Name", "Type", "Addr", "Off", "Size", "Es", "Flg", "Lk", "Inf", "Al"); for (int i = 0; i < ehdr->e_shnum; i++) { name = elf_map + shstrtab.sh_offset + shdr[i].sh_name; switch (shdr[i].sh_type) { case SHT_NULL: tmp = "SHT_NULL"; break; case SHT_PROGBITS: tmp = "SHT_PROGBITS"; break; case SHT_SYMTAB: tmp = "SHT_SYMTAB"; break; case SHT_STRTAB: tmp = "SHT_STRTAB"; break; case SHT_RELA: tmp = "SHT_RELA"; break; case SHT_HASH: tmp = "SHT_HASH"; break; case SHT_DYNAMIC: tmp = "SHT_DYNAMIC"; break; case SHT_NOTE: tmp = "SHT_NOTE"; break; case SHT_NOBITS: tmp = "SHT_NOBITS"; break; case SHT_REL: tmp = "SHT_REL"; break; case SHT_SHLIB: tmp = "SHT_SHLIB"; break; case SHT_DYNSYM: tmp = "SHT_DYNSYM"; break; case SHT_LOPROC: tmp = "SHT_LOPROC"; break; case SHT_HIPROC: tmp = "SHT_HIPROC"; break; case SHT_LOUSER: tmp = "SHT_LOUSER"; break; case SHT_HIUSER: tmp = "SHT_HIUSER"; break; default: break; } if (strlen(name) > 15) { strcpy(&name[15 - 6], "[...]"); } strcpy(flag, " "); flag2str_sh(shdr[i].sh_flags, flag); PRINT_SECTION(i, name, tmp, shdr[i].sh_addr, shdr[i].sh_offset, shdr[i].sh_size, shdr[i].sh_entsize, \ flag, shdr[i].sh_link, shdr[i].sh_info, shdr[i].sh_addralign); } INFO("Program Header Table\n"); PRINT_PROGRAM_TITLE("Nr", "Type", "Offset", "Virtaddr", "Physaddr", "Filesiz", "Memsiz", "Flg", "Align"); for (int i = 0; i < ehdr->e_phnum; i++) { switch (phdr[i].p_type) { case PT_NULL: tmp = "PT_NULL"; break; case PT_LOAD: tmp = "PT_LOAD"; break; case PT_DYNAMIC: tmp = "PT_DYNAMIC"; break; case PT_INTERP: tmp = "PT_INTERP"; break; case PT_NOTE: tmp = "PT_NOTE"; break; case PT_SHLIB: tmp = "PT_SHLIB"; break; case PT_PHDR: tmp = "PT_PHDR"; break; case PT_LOPROC: tmp = "PT_LOPROC"; break; case PT_HIPROC: tmp = "PT_HIPROC"; break; case PT_GNU_STACK: tmp = "PT_GNU_STACK"; break; default: break; } strcpy(flag, " "); flag2str(phdr[i].p_flags, flag); PRINT_PROGRAM(i, tmp, phdr[i].p_offset, phdr[i].p_vaddr, phdr[i].p_paddr, phdr[i].p_filesz, phdr[i].p_memsz, flag, phdr[i].p_align); } INFO("Section to segment mapping\n"); for (int i = 0; i < ehdr->e_phnum; i++) { printf(" [%2d]", i); for (int j = 0; j < ehdr->e_shnum; j++) { name = elf_map + shstrtab.sh_offset + shdr[j].sh_name; if (shdr[j].sh_addr >= phdr[i].p_vaddr && shdr[j].sh_addr + shdr[j].sh_size <= phdr[i].p_vaddr + phdr[i].p_memsz && shdr[j].sh_type != SHT_NULL) { if (shdr[j].sh_flags >> 1 & 0x1) { printf(" %s", name); } } } printf("\n"); } INFO("Dynamic link information\n"); int dynstr; int dynamic; Elf64_Dyn *dyn; for (int i = 0; i < ehdr->e_shnum; i++) { name = elf_map + shstrtab.sh_offset + shdr[i].sh_name; if (!strcmp(name, ".dynstr")) { dynstr = i; } if (!strcmp(name, ".dynamic")) { dynamic = i; } } char value[50]; name = ""; dyn = (Elf64_Dyn *)&elf_map[shdr[dynamic].sh_offset]; count = shdr[dynamic].sh_size / sizeof(Elf64_Dyn); INFO("Dynamic section at offset 0x%x contains %d entries\n", shdr[dynamic].sh_offset, count); PRINT_DYN_TITLE("Tag", "Type", "Name/Value"); for(int i = 0; i < count; i++) { tmp = ""; memset(value, 0, 50); snprintf(value, 50, "0x%x", dyn[i].d_un.d_val); switch (dyn[i].d_tag) { /* Legal values for d_tag (dynamic entry type). */ case DT_NULL: tmp = "DT_NULL"; break; case DT_NEEDED: tmp = "DT_NEEDED"; name = elf_map + shdr[dynstr].sh_offset + dyn[i].d_un.d_val; snprintf(value, 50, "Shared library: [%s]", name); break; case DT_PLTRELSZ: tmp = "DT_PLTRELSZ"; break; case DT_PLTGOT: tmp = "DT_PLTGOT"; break; case DT_HASH: tmp = "DT_HASH"; break; case DT_STRTAB: tmp = "DT_STRTAB"; break; case DT_SYMTAB: tmp = "DT_SYMTAB"; break; case DT_RELA: tmp = "DT_RELA"; break; case DT_RELASZ: tmp = "DT_RELASZ"; break; case DT_RELAENT: tmp = "DT_RELAENT"; break; case DT_STRSZ: tmp = "DT_STRSZ"; break; case DT_SYMENT: tmp = "DT_SYMENT"; break; case DT_INIT: tmp = "DT_INIT"; break; case DT_FINI: tmp = "DT_FINI"; break; case DT_SONAME: tmp = "DT_SONAME"; break; case DT_RPATH: tmp = "DT_RPATH"; break; case DT_SYMBOLIC: tmp = "DT_SYMBOLIC"; break; case DT_REL: tmp = "DT_REL"; break; case DT_RELSZ: tmp = "DT_RELSZ"; break; case DT_RELENT: tmp = "DT_RELENT"; break; case DT_PLTREL: tmp = "DT_PLTREL"; break; case DT_DEBUG: tmp = "DT_DEBUG"; break; case DT_TEXTREL: tmp = "DT_TEXTREL"; break; case DT_JMPREL: tmp = "DT_JMPREL"; break; case DT_BIND_NOW: tmp = "DT_BIND_NOW"; break; case DT_INIT_ARRAY: tmp = "DT_INIT_ARRAY"; break; case DT_FINI_ARRAY: tmp = "DT_FINI_ARRAY"; break; case DT_INIT_ARRAYSZ: tmp = "DT_INIT_ARRAYSZ"; break; case DT_FINI_ARRAYSZ: tmp = "DT_FINI_ARRAYSZ"; break; case DT_RUNPATH: tmp = "DT_RUNPATH"; break; case DT_FLAGS: tmp = "DT_FLAGS"; snprintf(value, 50, "Flags: %d", dyn[i].d_un.d_val); break; case DT_ENCODING: tmp = "DT_ENCODING"; break; case DT_PREINIT_ARRAYSZ: tmp = "DT_PREINIT_ARRAYSZ"; break; case DT_SYMTAB_SHNDX: tmp = "DT_SYMTAB_SHNDX"; break; case DT_NUM: tmp = "DT_NUM"; break; case DT_LOOS: tmp = "DT_LOOS"; break; case DT_HIOS: tmp = "DT_HIOS"; break; case DT_LOPROC: tmp = "DT_LOPROC"; break; case DT_HIPROC: tmp = "DT_HIPROC"; break; case DT_PROCNUM: tmp = "DT_LOPROC"; break; /* DT_* entries which fall between DT_VALRNGHI & DT_VALRNGLO use the * Dyn.d_un.d_val field of the Elf*_Dyn structure. This follows Sun's * approach. */ case DT_VALRNGLO: tmp = "DT_VALRNGLO"; break; case DT_GNU_PRELINKED: tmp = "DT_GNU_PRELINKED"; break; case DT_GNU_CONFLICTSZ: tmp = "DT_GNU_CONFLICTSZ"; break; case DT_GNU_LIBLISTSZ: tmp = "DT_GNU_LIBLISTSZ"; break; case DT_CHECKSUM: tmp = "DT_CHECKSUM"; break; case DT_PLTPADSZ: tmp = "DT_PLTPADSZ"; break; case DT_MOVEENT: tmp = "DT_MOVEENT"; break; case DT_MOVESZ: tmp = "DT_MOVESZ"; break; case DT_FEATURE_1: tmp = "DT_FEATURE_1"; break; case DT_POSFLAG_1: tmp = "DT_POSFLAG_1"; break; case DT_SYMINSZ: tmp = "DT_SYMINSZ"; break; case DT_SYMINENT: tmp = "DT_SYMINENT"; break; /* DT_* entries which fall between DT_ADDRRNGHI & DT_ADDRRNGLO use the * Dyn.d_un.d_ptr field of the Elf*_Dyn structure. * If any adjustment is made to the ELF object after it has been * built these entries will need to be adjusted. */ case DT_ADDRRNGLO: tmp = "DT_ADDRRNGLO"; break; case DT_GNU_HASH: tmp = "DT_GNU_HASH"; break; case DT_TLSDESC_PLT: tmp = "DT_TLSDESC_PLT"; break; case DT_TLSDESC_GOT: tmp = "DT_TLSDESC_GOT"; break; case DT_GNU_CONFLICT: tmp = "DT_GNU_CONFLICT"; break; case DT_GNU_LIBLIST: tmp = "DT_GNU_LIBLIST"; break; case DT_CONFIG: tmp = "DT_CONFIG"; break; case DT_DEPAUDIT: tmp = "DT_DEPAUDIT"; break; case DT_AUDIT: tmp = "DT_AUDIT"; break; case DT_PLTPAD: tmp = "DT_PLTPAD"; break; case DT_MOVETAB: tmp = "DT_MOVETAB"; break; case DT_SYMINFO: tmp = "DT_SYMINFO"; break; /* The versioning entry types. The next are defined as part of the * GNU extension. */ case DT_VERSYM: tmp = "DT_VERSYM"; break; case DT_RELACOUNT: tmp = "DT_RELACOUNT"; break; case DT_RELCOUNT: tmp = "DT_RELCOUNT"; break; /* These were chosen by Sun. */ case DT_FLAGS_1: tmp = "DT_FLAGS_1"; switch (dyn[i].d_un.d_val) { case DF_1_PIE: snprintf(value, 50, "Flags: %s", "PIE"); break; default: snprintf(value, 50, "Flags: %d", dyn[i].d_un.d_val); break; } break; case DT_VERDEF: tmp = "DT_VERDEF"; break; case DT_VERDEFNUM: tmp = "DT_VERDEFNUM"; break; case DT_VERNEED: tmp = "DT_VERNEED"; break; case DT_VERNEEDNUM: tmp = "DT_VERNEEDNUM"; break; default: break; } PRINT_DYN(dyn[i].d_tag, tmp, value); } } return 0; }
1
488,339
int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address) { pmd_t *new = pmd_alloc_one(mm, address); if (!new) return -ENOMEM; smp_wmb(); /* See comment in __pte_alloc */ spin_lock(&mm->page_table_lock); #ifndef __ARCH_HAS_4LEVEL_HACK if (pud_present(*pud)) /* Another has populated it */ pmd_free(mm, new); else pud_populate(mm, pud, new); #else if (pgd_present(*pud)) /* Another has populated it */ pmd_free(mm, new); else pgd_populate(mm, pud, new); #endif /* __ARCH_HAS_4LEVEL_HACK */ spin_unlock(&mm->page_table_lock); return 0; }
0
289,253
static int snd_pcm_oss_get_ptr(struct snd_pcm_oss_file *pcm_oss_file, int stream, struct count_info __user * _info) { struct snd_pcm_substream *substream; struct snd_pcm_runtime *runtime; snd_pcm_sframes_t delay; int fixup; struct count_info info; int err; if (_info == NULL) return -EFAULT; substream = pcm_oss_file->streams[stream]; if (substream == NULL) return -EINVAL; err = snd_pcm_oss_make_ready(substream); if (err < 0) return err; runtime = substream->runtime; if (runtime->oss.params || runtime->oss.prepare) { memset(&info, 0, sizeof(info)); if (copy_to_user(_info, &info, sizeof(info))) return -EFAULT; return 0; } if (stream == SNDRV_PCM_STREAM_PLAYBACK) { err = snd_pcm_kernel_ioctl(substream, SNDRV_PCM_IOCTL_DELAY, &delay); if (err == -EPIPE || err == -ESTRPIPE || (! err && delay < 0)) { err = 0; delay = 0; fixup = 0; } else { fixup = runtime->oss.buffer_used; } } else { err = snd_pcm_oss_capture_position_fixup(substream, &delay); fixup = -runtime->oss.buffer_used; } if (err < 0) return err; info.ptr = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr % runtime->buffer_size); if (atomic_read(&substream->mmap_count)) { snd_pcm_sframes_t n; delay = get_hw_ptr_period(runtime); n = delay - runtime->oss.prev_hw_ptr_period; if (n < 0) n += runtime->boundary; info.blocks = n / runtime->period_size; runtime->oss.prev_hw_ptr_period = delay; if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) snd_pcm_oss_simulate_fill(substream, delay); info.bytes = snd_pcm_oss_bytes(substream, runtime->status->hw_ptr) & INT_MAX; } else { delay = snd_pcm_oss_bytes(substream, delay); if (stream == SNDRV_PCM_STREAM_PLAYBACK) { if (substream->oss.setup.buggyptr) info.blocks = (runtime->oss.buffer_bytes - delay - fixup) / runtime->oss.period_bytes; else info.blocks = (delay + fixup) / runtime->oss.period_bytes; info.bytes = (runtime->oss.bytes - delay) & INT_MAX; } else { delay += fixup; info.blocks = delay / runtime->oss.period_bytes; info.bytes = (runtime->oss.bytes + delay) & INT_MAX; } } if (copy_to_user(_info, &info, sizeof(info))) return -EFAULT; return 0; }
0
225,956
GF_Err stsh_box_size(GF_Box *s) { GF_ShadowSyncBox *ptr = (GF_ShadowSyncBox *)s; ptr->size += 4 + (8 * gf_list_count(ptr->entries)); return GF_OK; }
0
233,937
DocumentSource::GetNextResult DocumentSourceUnionWith::doGetNext() { if (!_pipeline) { // We must have already been disposed, so we're finished. return GetNextResult::makeEOF(); } if (_executionState == ExecutionProgress::kIteratingSource) { auto nextInput = pSource->getNext(); if (!nextInput.isEOF()) { return nextInput; } _executionState = ExecutionProgress::kStartingSubPipeline; // All documents from the base collection have been returned, switch to iterating the sub- // pipeline by falling through below. } if (_executionState == ExecutionProgress::kStartingSubPipeline) { auto serializedPipe = _pipeline->serializeToBson(); // $$SEARCH_META can be set during runtime earlier in the pipeline, and therefore must be // copied to the subpipeline manually. if (pExpCtx->variables.hasConstantValue(Variables::kSearchMetaId)) { _pipeline->getContext()->variables.setReservedValue( Variables::kSearchMetaId, pExpCtx->variables.getValue(Variables::kSearchMetaId, Document()), true); } logStartingSubPipeline(serializedPipe); try { _pipeline = pExpCtx->mongoProcessInterface->attachCursorSourceToPipeline(_pipeline.release()); _executionState = ExecutionProgress::kIteratingSubPipeline; } catch (const ExceptionFor<ErrorCodes::CommandOnShardedViewNotSupportedOnMongod>& e) { _pipeline = buildPipelineFromViewDefinition( pExpCtx, ExpressionContext::ResolvedNamespace{e->getNamespace(), e->getPipeline()}, serializedPipe); logShardedViewFound(e); return doGetNext(); } } auto res = _pipeline->getNext(); if (res) return std::move(*res); // Record the plan summary stats after $unionWith operation is done. recordPlanSummaryStats(*_pipeline); _executionState = ExecutionProgress::kFinished; return GetNextResult::makeEOF(); }
0
417,477
virNodeDeviceCapPCIDefFormat(virBufferPtr buf, const virNodeDevCapData *data) { size_t i; if (data->pci_dev.klass >= 0) virBufferAsprintf(buf, "<class>0x%.6x</class>\n", data->pci_dev.klass); virBufferAsprintf(buf, "<domain>%d</domain>\n", data->pci_dev.domain); virBufferAsprintf(buf, "<bus>%d</bus>\n", data->pci_dev.bus); virBufferAsprintf(buf, "<slot>%d</slot>\n", data->pci_dev.slot); virBufferAsprintf(buf, "<function>%d</function>\n", data->pci_dev.function); virBufferAsprintf(buf, "<product id='0x%04x'", data->pci_dev.product); if (data->pci_dev.product_name) virBufferEscapeString(buf, ">%s</product>\n", data->pci_dev.product_name); else virBufferAddLit(buf, "/>\n"); virBufferAsprintf(buf, "<vendor id='0x%04x'", data->pci_dev.vendor); if (data->pci_dev.vendor_name) virBufferEscapeString(buf, ">%s</vendor>\n", data->pci_dev.vendor_name); else virBufferAddLit(buf, "/>\n"); if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION) { virBufferAddLit(buf, "<capability type='phys_function'>\n"); virBufferAdjustIndent(buf, 2); virBufferAsprintf(buf, "<address domain='0x%04x' bus='0x%02x' " "slot='0x%02x' function='0x%d'/>\n", data->pci_dev.physical_function->domain, data->pci_dev.physical_function->bus, data->pci_dev.physical_function->slot, data->pci_dev.physical_function->function); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</capability>\n"); } if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION) { virBufferAddLit(buf, "<capability type='virt_functions'"); if (data->pci_dev.max_virtual_functions) virBufferAsprintf(buf, " maxCount='%u'", data->pci_dev.max_virtual_functions); if (data->pci_dev.num_virtual_functions == 0) { virBufferAddLit(buf, "/>\n"); } else { virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); for (i = 0; i < data->pci_dev.num_virtual_functions; i++) { virBufferAsprintf(buf, "<address domain='0x%04x' bus='0x%02x' " "slot='0x%02x' function='0x%d'/>\n", data->pci_dev.virtual_functions[i]->domain, data->pci_dev.virtual_functions[i]->bus, data->pci_dev.virtual_functions[i]->slot, data->pci_dev.virtual_functions[i]->function); } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</capability>\n"); } } if (data->pci_dev.hdrType) { virBufferAsprintf(buf, "<capability type='%s'/>\n", virPCIHeaderTypeToString(data->pci_dev.hdrType)); } if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCI_MDEV) { virNodeDeviceCapMdevTypesFormat(buf, data->pci_dev.mdev_types, data->pci_dev.nmdev_types); } if (data->pci_dev.nIommuGroupDevices) { virBufferAsprintf(buf, "<iommuGroup number='%d'>\n", data->pci_dev.iommuGroupNumber); virBufferAdjustIndent(buf, 2); for (i = 0; i < data->pci_dev.nIommuGroupDevices; i++) { virBufferAsprintf(buf, "<address domain='0x%04x' bus='0x%02x' " "slot='0x%02x' function='0x%d'/>\n", data->pci_dev.iommuGroupDevices[i]->domain, data->pci_dev.iommuGroupDevices[i]->bus, data->pci_dev.iommuGroupDevices[i]->slot, data->pci_dev.iommuGroupDevices[i]->function); } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</iommuGroup>\n"); } if (data->pci_dev.numa_node >= 0) virBufferAsprintf(buf, "<numa node='%d'/>\n", data->pci_dev.numa_node); if (data->pci_dev.flags & VIR_NODE_DEV_CAP_FLAG_PCIE) virPCIEDeviceInfoFormat(buf, data->pci_dev.pci_express); }
0
229,351
Fprint128 GetDeviceCacheKey(EagerOperation* op, const EagerContext& ctx) { Fprint128 device_cache_key = op->MutableAttrs()->CacheKey(op->DeviceName()); device_cache_key = FingerprintCat128(device_cache_key, ctx.AllowSoftPlacement()); return device_cache_key; }
0
459,523
static long __bpf_get_stackid(struct bpf_map *map, struct perf_callchain_entry *trace, u64 flags) { struct bpf_stack_map *smap = container_of(map, struct bpf_stack_map, map); struct stack_map_bucket *bucket, *new_bucket, *old_bucket; u32 max_depth = map->value_size / stack_map_data_size(map); /* stack_map_alloc() checks that max_depth <= sysctl_perf_event_max_stack */ u32 init_nr = sysctl_perf_event_max_stack - max_depth; u32 skip = flags & BPF_F_SKIP_FIELD_MASK; u32 hash, id, trace_nr, trace_len; bool user = flags & BPF_F_USER_STACK; u64 *ips; bool hash_matches; /* get_perf_callchain() guarantees that trace->nr >= init_nr * and trace-nr <= sysctl_perf_event_max_stack, so trace_nr <= max_depth */ trace_nr = trace->nr - init_nr; if (trace_nr <= skip) /* skipping more than usable stack trace */ return -EFAULT; trace_nr -= skip; trace_len = trace_nr * sizeof(u64); ips = trace->ip + skip + init_nr; hash = jhash2((u32 *)ips, trace_len / sizeof(u32), 0); id = hash & (smap->n_buckets - 1); bucket = READ_ONCE(smap->buckets[id]); hash_matches = bucket && bucket->hash == hash; /* fast cmp */ if (hash_matches && flags & BPF_F_FAST_STACK_CMP) return id; if (stack_map_use_build_id(map)) { /* for build_id+offset, pop a bucket before slow cmp */ new_bucket = (struct stack_map_bucket *) pcpu_freelist_pop(&smap->freelist); if (unlikely(!new_bucket)) return -ENOMEM; new_bucket->nr = trace_nr; stack_map_get_build_id_offset( (struct bpf_stack_build_id *)new_bucket->data, ips, trace_nr, user); trace_len = trace_nr * sizeof(struct bpf_stack_build_id); if (hash_matches && bucket->nr == trace_nr && memcmp(bucket->data, new_bucket->data, trace_len) == 0) { pcpu_freelist_push(&smap->freelist, &new_bucket->fnode); return id; } if (bucket && !(flags & BPF_F_REUSE_STACKID)) { pcpu_freelist_push(&smap->freelist, &new_bucket->fnode); return -EEXIST; } } else { if (hash_matches && bucket->nr == trace_nr && memcmp(bucket->data, ips, trace_len) == 0) return id; if (bucket && !(flags & BPF_F_REUSE_STACKID)) return -EEXIST; new_bucket = (struct stack_map_bucket *) pcpu_freelist_pop(&smap->freelist); if (unlikely(!new_bucket)) return -ENOMEM; memcpy(new_bucket->data, ips, trace_len); } new_bucket->hash = hash; new_bucket->nr = trace_nr; old_bucket = xchg(&smap->buckets[id], new_bucket); if (old_bucket) pcpu_freelist_push(&smap->freelist, &old_bucket->fnode); return id; }
0
238,327
int digest_file_by_name(const char *algo, const char *filename, unsigned char *hash, const unsigned char *sig) { struct digest *d; int ret; d = digest_alloc(algo); if (!d) return -EIO; ret = digest_file(d, filename, hash, sig); digest_free(d); return ret; }
0
463,147
EXPORTED int annotatemore_rawwrite(const char *mboxname, const char *entry, const char *userid, const struct buf *value) { char key[MAX_MAILBOX_PATH+1]; int keylen, r; annotate_db_t *d = NULL; uint32_t uid = 0; init_internal(); r = _annotate_getdb(mboxname, uid, CYRUSDB_CREATE, &d); if (r) goto done; /* must be in a transaction to modify the db */ annotate_begin(d); keylen = make_key(mboxname, uid, entry, userid, key, sizeof(key)); if (value->s == NULL) { do { r = cyrusdb_delete(d->db, key, keylen, tid(d), /*force*/1); } while (r == CYRUSDB_AGAIN); } else { struct buf data = BUF_INITIALIZER; make_entry(&data, value, uid, /*flags*/0); do { r = cyrusdb_store(d->db, key, keylen, data.s, data.len, tid(d)); } while (r == CYRUSDB_AGAIN); buf_free(&data); } if (r) goto done; r = annotate_commit(d); done: annotate_putdb(&d); return r; }
0
226,214
GF_Err subs_box_read(GF_Box *s, GF_BitStream *bs) { GF_SubSampleInformationBox *ptr = (GF_SubSampleInformationBox *)s; u32 entry_count, i, j; u16 subsample_count; ISOM_DECREASE_SIZE(ptr, 4); entry_count = gf_bs_read_u32(bs); for (i=0; i<entry_count; i++) { u32 subs_size=0; GF_SubSampleInfoEntry *pSamp = (GF_SubSampleInfoEntry*) gf_malloc(sizeof(GF_SubSampleInfoEntry)); if (!pSamp) return GF_OUT_OF_MEM; memset(pSamp, 0, sizeof(GF_SubSampleInfoEntry)); pSamp->SubSamples = gf_list_new(); pSamp->sample_delta = gf_bs_read_u32(bs); subsample_count = gf_bs_read_u16(bs); subs_size=6; for (j=0; j<subsample_count; j++) { GF_SubSampleEntry *pSubSamp = (GF_SubSampleEntry*) gf_malloc(sizeof(GF_SubSampleEntry)); if (!pSubSamp) return GF_OUT_OF_MEM; memset(pSubSamp, 0, sizeof(GF_SubSampleEntry)); if (ptr->version==1) { pSubSamp->subsample_size = gf_bs_read_u32(bs); subs_size+=4; } else { pSubSamp->subsample_size = gf_bs_read_u16(bs); subs_size+=2; } pSubSamp->subsample_priority = gf_bs_read_u8(bs); pSubSamp->discardable = gf_bs_read_u8(bs); pSubSamp->reserved = gf_bs_read_u32(bs); subs_size+=6; gf_list_add(pSamp->SubSamples, pSubSamp); } gf_list_add(ptr->Samples, pSamp); ISOM_DECREASE_SIZE(ptr, subs_size); } return GF_OK;
0
333,550
gdImagePtr gdImageRotateGeneric(gdImagePtr src, const float degrees, const int bgColor) { float _angle = ((float) (-degrees / 180.0f) * (float)M_PI); const int angle_rounded = (int)floor(degrees * 100); const int src_w = gdImageSX(src); const int src_h = gdImageSY(src); const unsigned int new_width = (unsigned int)(abs((int)(src_w * cos(_angle))) + abs((int)(src_h * sin(_angle))) + 0.5f); const unsigned int new_height = (unsigned int)(abs((int)(src_w * sin(_angle))) + abs((int)(src_h * cos(_angle))) + 0.5f); const gdFixed f_0_5 = gd_ftofx(0.5f); const gdFixed f_H = gd_itofx(src_h/2); const gdFixed f_W = gd_itofx(src_w/2); const gdFixed f_cos = gd_ftofx(cos(-_angle)); const gdFixed f_sin = gd_ftofx(sin(-_angle)); unsigned int dst_offset_x; unsigned int dst_offset_y = 0; unsigned int i; gdImagePtr dst; const gdFixed f_slop_y = f_sin; const gdFixed f_slop_x = f_cos; const gdFixed f_slop = f_slop_x > 0 && f_slop_x > 0 ? f_slop_x > f_slop_y ? gd_divfx(f_slop_y, f_slop_x) : gd_divfx(f_slop_x, f_slop_y) : 0; if (bgColor < 0) { return NULL; } dst = gdImageCreateTrueColor(new_width, new_height); if (!dst) { return NULL; } dst->saveAlphaFlag = 1; for (i = 0; i < new_height; i++) { unsigned int j; dst_offset_x = 0; for (j = 0; j < new_width; j++) { gdFixed f_i = gd_itofx((int)i - (int)new_height/ 2); gdFixed f_j = gd_itofx((int)j - (int)new_width / 2); gdFixed f_m = gd_mulfx(f_j,f_sin) + gd_mulfx(f_i,f_cos) + f_0_5 + f_H; gdFixed f_n = gd_mulfx(f_j,f_cos) - gd_mulfx(f_i,f_sin) + f_0_5 + f_W; long m = gd_fxtoi(f_m); long n = gd_fxtoi(f_n); if ((n <= 0) || (m <= 0) || (m >= src_h) || (n >= src_w)) { dst->tpixels[dst_offset_y][dst_offset_x++] = bgColor; } else if ((n <= 1) || (m <= 1) || (m >= src_h - 1) || (n >= src_w - 1)) { gdFixed f_127 = gd_itofx(127); register int c = getPixelInterpolated(src, n, m, bgColor); c = c | (( gdTrueColorGetAlpha(c) + ((int)(127* gd_fxtof(f_slop)))) << 24); dst->tpixels[dst_offset_y][dst_offset_x++] = _color_blend(bgColor, c); } else { dst->tpixels[dst_offset_y][dst_offset_x++] = getPixelInterpolated(src, n, m, bgColor); } } dst_offset_y++; } return dst; }
0
238,524
static int check_attach_modify_return(unsigned long addr, const char *func_name) { if (within_error_injection_list(addr) || !strncmp(SECURITY_PREFIX, func_name, sizeof(SECURITY_PREFIX) - 1)) return 0; return -EINVAL; }
0
329,877
span_renderer_init (cairo_abstract_span_renderer_t *_r, const cairo_composite_rectangles_t *composite, cairo_antialias_t antialias, cairo_bool_t needs_clip) { cairo_image_span_renderer_t *r = (cairo_image_span_renderer_t *)_r; cairo_image_surface_t *dst = (cairo_image_surface_t *)composite->surface; const cairo_pattern_t *source = &composite->source_pattern.base; cairo_operator_t op = composite->op; cairo_int_status_t status; TRACE ((stderr, "%s: antialias=%d, needs_clip=%d\n", __FUNCTION__, antialias, needs_clip)); if (needs_clip) return CAIRO_INT_STATUS_UNSUPPORTED; r->composite = composite; r->mask = NULL; r->src = NULL; r->base.finish = NULL; status = mono_renderer_init (r, composite, antialias, needs_clip); if (status != CAIRO_INT_STATUS_UNSUPPORTED) return status; status = inplace_renderer_init (r, composite, antialias, needs_clip); if (status != CAIRO_INT_STATUS_UNSUPPORTED) return status; r->bpp = 0; if (op == CAIRO_OPERATOR_CLEAR) { #if PIXMAN_HAS_OP_LERP op = PIXMAN_OP_LERP_CLEAR; #else source = &_cairo_pattern_white.base; op = PIXMAN_OP_OUT_REVERSE; #endif } else if (dst->base.is_clear && (op == CAIRO_OPERATOR_SOURCE || op == CAIRO_OPERATOR_OVER || op == CAIRO_OPERATOR_ADD)) { op = PIXMAN_OP_SRC; } else if (op == CAIRO_OPERATOR_SOURCE) { if (_cairo_pattern_is_opaque (&composite->source_pattern.base, &composite->source_sample_area)) { op = PIXMAN_OP_OVER; } else { #if PIXMAN_HAS_OP_LERP op = PIXMAN_OP_LERP_SRC; #else return CAIRO_INT_STATUS_UNSUPPORTED; #endif } } else { op = _pixman_operator (op); } r->op = op; r->src = _pixman_image_for_pattern (dst, source, FALSE, &composite->unbounded, &composite->source_sample_area, &r->u.mask.src_x, &r->u.mask.src_y); if (unlikely (r->src == NULL)) return _cairo_error (CAIRO_STATUS_NO_MEMORY); r->opacity = 1.0; if (composite->mask_pattern.base.type == CAIRO_PATTERN_TYPE_SOLID) { r->opacity = composite->mask_pattern.solid.color.alpha; } else { pixman_image_t *mask; int mask_x, mask_y; mask = _pixman_image_for_pattern (dst, &composite->mask_pattern.base, TRUE, &composite->unbounded, &composite->mask_sample_area, &mask_x, &mask_y); if (unlikely (mask == NULL)) return _cairo_error (CAIRO_STATUS_NO_MEMORY); /* XXX Component-alpha? */ if ((dst->base.content & CAIRO_CONTENT_COLOR) == 0 && _cairo_pattern_is_opaque (source, &composite->source_sample_area)) { pixman_image_unref (r->src); r->src = mask; r->u.mask.src_x = mask_x; r->u.mask.src_y = mask_y; mask = NULL; } if (mask) { pixman_image_unref (mask); return CAIRO_INT_STATUS_UNSUPPORTED; } } r->u.mask.extents = composite->unbounded; r->u.mask.stride = (r->u.mask.extents.width + 3) & ~3; if (r->u.mask.extents.height * r->u.mask.stride > SZ_BUF) { r->mask = pixman_image_create_bits (PIXMAN_a8, r->u.mask.extents.width, r->u.mask.extents.height, NULL, 0); r->base.render_rows = _cairo_image_spans; r->base.finish = NULL; } else { r->mask = pixman_image_create_bits (PIXMAN_a8, r->u.mask.extents.width, r->u.mask.extents.height, (uint32_t *)r->_buf, r->u.mask.stride); r->base.render_rows = _cairo_image_spans_and_zero; r->base.finish = _cairo_image_finish_spans_and_zero; } if (unlikely (r->mask == NULL)) return _cairo_error (CAIRO_STATUS_NO_MEMORY); r->u.mask.data = (uint8_t *) pixman_image_get_data (r->mask); r->u.mask.stride = pixman_image_get_stride (r->mask); r->u.mask.extents.height += r->u.mask.extents.y; return CAIRO_STATUS_SUCCESS; }
0
427,726
cdf_calloc(const char *file __attribute__((__unused__)), size_t line __attribute__((__unused__)), size_t n, size_t u) { DPRINTF(("%s,%" SIZE_T_FORMAT "u: %s %" SIZE_T_FORMAT "u %" SIZE_T_FORMAT "u\n", file, line, __func__, n, u)); return calloc(n, u); }
0
336,509
SPICE_GNUC_VISIBLE int spice_server_is_server_mouse(SpiceServer *reds) { return reds->mouse_mode == SPICE_MOUSE_MODE_SERVER; }
0
317,041
static int may_create(struct inode *dir, struct dentry *dentry, u16 tclass) { const struct task_security_struct *tsec = selinux_cred(current_cred()); struct inode_security_struct *dsec; struct superblock_security_struct *sbsec; u32 sid, newsid; struct common_audit_data ad; int rc; dsec = inode_security(dir); sbsec = selinux_superblock(dir->i_sb); sid = tsec->sid; ad.type = LSM_AUDIT_DATA_DENTRY; ad.u.dentry = dentry; rc = avc_has_perm(&selinux_state, sid, dsec->sid, SECCLASS_DIR, DIR__ADD_NAME | DIR__SEARCH, &ad); if (rc) return rc; rc = selinux_determine_inode_label(tsec, dir, &dentry->d_name, tclass, &newsid); if (rc) return rc; rc = avc_has_perm(&selinux_state, sid, newsid, tclass, FILE__CREATE, &ad); if (rc) return rc; return avc_has_perm(&selinux_state, newsid, sbsec->sid, SECCLASS_FILESYSTEM, FILESYSTEM__ASSOCIATE, &ad); }
0
393,532
static SQInteger base_setdebughook(HSQUIRRELVM v) { sq_setdebughook(v); return 0; }
0
214,909
static int mlx5_fpga_conn_create_cq(struct mlx5_fpga_conn *conn, int cq_size) { struct mlx5_fpga_device *fdev = conn->fdev; struct mlx5_core_dev *mdev = fdev->mdev; u32 temp_cqc[MLX5_ST_SZ_DW(cqc)] = {0}; u32 out[MLX5_ST_SZ_DW(create_cq_out)]; struct mlx5_wq_param wqp; struct mlx5_cqe64 *cqe; int inlen, err, eqn; unsigned int irqn; void *cqc, *in; __be64 *pas; u32 i; cq_size = roundup_pow_of_two(cq_size); MLX5_SET(cqc, temp_cqc, log_cq_size, ilog2(cq_size)); wqp.buf_numa_node = mdev->priv.numa_node; wqp.db_numa_node = mdev->priv.numa_node; err = mlx5_cqwq_create(mdev, &wqp, temp_cqc, &conn->cq.wq, &conn->cq.wq_ctrl); if (err) return err; for (i = 0; i < mlx5_cqwq_get_size(&conn->cq.wq); i++) { cqe = mlx5_cqwq_get_wqe(&conn->cq.wq, i); cqe->op_own = MLX5_CQE_INVALID << 4 | MLX5_CQE_OWNER_MASK; } inlen = MLX5_ST_SZ_BYTES(create_cq_in) + sizeof(u64) * conn->cq.wq_ctrl.buf.npages; in = kvzalloc(inlen, GFP_KERNEL); if (!in) { err = -ENOMEM; goto err_cqwq; } err = mlx5_vector2eqn(mdev, smp_processor_id(), &eqn, &irqn); if (err) goto err_cqwq; cqc = MLX5_ADDR_OF(create_cq_in, in, cq_context); MLX5_SET(cqc, cqc, log_cq_size, ilog2(cq_size)); MLX5_SET(cqc, cqc, c_eqn, eqn); MLX5_SET(cqc, cqc, uar_page, fdev->conn_res.uar->index); MLX5_SET(cqc, cqc, log_page_size, conn->cq.wq_ctrl.buf.page_shift - MLX5_ADAPTER_PAGE_SHIFT); MLX5_SET64(cqc, cqc, dbr_addr, conn->cq.wq_ctrl.db.dma); pas = (__be64 *)MLX5_ADDR_OF(create_cq_in, in, pas); mlx5_fill_page_frag_array(&conn->cq.wq_ctrl.buf, pas); err = mlx5_core_create_cq(mdev, &conn->cq.mcq, in, inlen, out, sizeof(out)); kvfree(in); if (err) goto err_cqwq; conn->cq.mcq.cqe_sz = 64; conn->cq.mcq.set_ci_db = conn->cq.wq_ctrl.db.db; conn->cq.mcq.arm_db = conn->cq.wq_ctrl.db.db + 1; *conn->cq.mcq.set_ci_db = 0; *conn->cq.mcq.arm_db = 0; conn->cq.mcq.vector = 0; conn->cq.mcq.comp = mlx5_fpga_conn_cq_complete; conn->cq.mcq.event = mlx5_fpga_conn_cq_event; conn->cq.mcq.irqn = irqn; conn->cq.mcq.uar = fdev->conn_res.uar; tasklet_init(&conn->cq.tasklet, mlx5_fpga_conn_cq_tasklet, (unsigned long)conn); mlx5_fpga_dbg(fdev, "Created CQ #0x%x\n", conn->cq.mcq.cqn); goto out; err_cqwq: mlx5_wq_destroy(&conn->cq.wq_ctrl); out: return err; }
1
273,914
static void handle_PWD(ctrl_t *ctrl, char *arg) { char buf[sizeof(ctrl->cwd) + 10]; snprintf(buf, sizeof(buf), "257 \"%s\"\r\n", ctrl->cwd); send_msg(ctrl->sd, buf); }
0
369,916
static ssize_t oom_adjust_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) { struct task_struct *task; char buffer[PROC_NUMBUF]; int oom_adjust; unsigned long flags; int err; memset(buffer, 0, sizeof(buffer)); if (count > sizeof(buffer) - 1) count = sizeof(buffer) - 1; if (copy_from_user(buffer, buf, count)) { err = -EFAULT; goto out; } err = kstrtoint(strstrip(buffer), 0, &oom_adjust); if (err) goto out; if ((oom_adjust < OOM_ADJUST_MIN || oom_adjust > OOM_ADJUST_MAX) && oom_adjust != OOM_DISABLE) { err = -EINVAL; goto out; } task = get_proc_task(file->f_path.dentry->d_inode); if (!task) { err = -ESRCH; goto out; } task_lock(task); if (!task->mm) { err = -EINVAL; goto err_task_lock; } if (!lock_task_sighand(task, &flags)) { err = -ESRCH; goto err_task_lock; } if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) { err = -EACCES; goto err_sighand; } /* * Warn that /proc/pid/oom_adj is deprecated, see * Documentation/feature-removal-schedule.txt. */ printk_once(KERN_WARNING "%s (%d): /proc/%d/oom_adj is deprecated, please use /proc/%d/oom_score_adj instead.\n", current->comm, task_pid_nr(current), task_pid_nr(task), task_pid_nr(task)); task->signal->oom_adj = oom_adjust; /* * Scale /proc/pid/oom_score_adj appropriately ensuring that a maximum * value is always attainable. */ if (task->signal->oom_adj == OOM_ADJUST_MAX) task->signal->oom_score_adj = OOM_SCORE_ADJ_MAX; else task->signal->oom_score_adj = (oom_adjust * OOM_SCORE_ADJ_MAX) / -OOM_DISABLE; trace_oom_score_adj_update(task); err_sighand: unlock_task_sighand(task, &flags); err_task_lock: task_unlock(task); put_task_struct(task); out: return err < 0 ? err : count; }
0
513,092
void Item_func_isnull::print(String *str, enum_query_type query_type) { if (const_item() && !args[0]->maybe_null && !(query_type & (QT_NO_DATA_EXPANSION | QT_VIEW_INTERNAL))) str->append("/*always not null*/ 1"); else args[0]->print_parenthesised(str, query_type, precedence()); str->append(STRING_WITH_LEN(" is null")); }
0
244,324
GF_Err reftype_AddRefTrack(GF_TrackReferenceTypeBox *ref, GF_ISOTrackID trackID, u16 *outRefIndex) { u32 i; if (!ref || !trackID) return GF_BAD_PARAM; if (outRefIndex) *outRefIndex = 0; //don't add a dep if already here !! for (i = 0; i < ref->trackIDCount; i++) { if (ref->trackIDs[i] == trackID) { if (outRefIndex) *outRefIndex = i+1; return GF_OK; } } ref->trackIDs = (GF_ISOTrackID *) gf_realloc(ref->trackIDs, (ref->trackIDCount + 1) * sizeof(GF_ISOTrackID) ); if (!ref->trackIDs) return GF_OUT_OF_MEM; ref->trackIDs[ref->trackIDCount] = trackID; ref->trackIDCount++; if (outRefIndex) *outRefIndex = ref->trackIDCount; return GF_OK; }
0
345,210
int con_copy_unimap(struct vc_data *dst_vc, struct vc_data *src_vc) { struct uni_pagedir *q; if (!*src_vc->vc_uni_pagedir_loc) return -EINVAL; if (*dst_vc->vc_uni_pagedir_loc == *src_vc->vc_uni_pagedir_loc) return 0; con_free_unimap(dst_vc); q = *src_vc->vc_uni_pagedir_loc; q->refcount++; *dst_vc->vc_uni_pagedir_loc = q; return 0; }
0
256,431
static pj_status_t get_codec_info_from_sdp(pjmedia_endpt *endpt, const pjmedia_sdp_media *m, unsigned *sci_cnt, sdp_codec_info_t sci[]) { pjmedia_codec_mgr *codec_mgr; unsigned j, cnt = 0; pjmedia_type type = PJMEDIA_TYPE_UNKNOWN; pj_status_t status; type = pjmedia_get_type(&m->desc.media); if (type != PJMEDIA_TYPE_AUDIO && type != PJMEDIA_TYPE_VIDEO) return PJMEDIA_EUNSUPMEDIATYPE; codec_mgr = pjmedia_endpt_get_codec_mgr(endpt); for (j = 0; j < m->desc.fmt_count && cnt < *sci_cnt; ++j) { unsigned pt = 0; pt = pj_strtoul(&m->desc.fmt[j]); if (pt < 96) { if (type == PJMEDIA_TYPE_AUDIO) { const pjmedia_codec_info *ci; status = pjmedia_codec_mgr_get_codec_info(codec_mgr, pt, &ci); if (status != PJ_SUCCESS) continue; pjmedia_codec_info_to_id(ci, sci[cnt].id, sizeof(sci[0].id)); } else { #if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0) const pjmedia_vid_codec_info *ci; status = pjmedia_vid_codec_mgr_get_codec_info(NULL, pt, &ci); if (status != PJ_SUCCESS) continue; pjmedia_vid_codec_info_to_id(ci, sci[cnt].id, sizeof(sci[0].id)); #else continue; #endif } } else { pjmedia_sdp_attr *a; pjmedia_sdp_rtpmap r; a = pjmedia_sdp_media_find_attr2(m, "rtpmap", &m->desc.fmt[j]); if (a == NULL) continue; status = pjmedia_sdp_attr_get_rtpmap(a, &r); if (status != PJ_SUCCESS) continue; if (type == PJMEDIA_TYPE_AUDIO) { /* Audio codec id format: "name/clock-rate/channel-count" */ if (r.param.slen) { pj_ansi_snprintf(sci[cnt].id, sizeof(sci[0].id), "%.*s/%d/%.*s", (int)r.enc_name.slen, r.enc_name.ptr, r.clock_rate, (int)r.param.slen, r.param.ptr); } else { pj_ansi_snprintf(sci[cnt].id, sizeof(sci[0].id), "%.*s/%d/1", (int)r.enc_name.slen, r.enc_name.ptr, r.clock_rate); } } else { /* Video codec id format: "name/payload-type" */ pj_ansi_snprintf(sci[cnt].id, sizeof(sci[0].id), "%.*s/%d", (int)r.enc_name.slen, r.enc_name.ptr, pt); } } sci[cnt++].pt = pt; } *sci_cnt = cnt; return PJ_SUCCESS; }
0
273,107
buildopts_get() { return buildopts; }
0
384,130
raptor_new_xml_writer(raptor_world* world, raptor_namespace_stack *nstack, raptor_iostream* iostr) { raptor_xml_writer* xml_writer; RAPTOR_CHECK_CONSTRUCTOR_WORLD(world); if(!iostr) return NULL; raptor_world_open(world); xml_writer = RAPTOR_CALLOC(raptor_xml_writer*, 1, sizeof(*xml_writer)); if(!xml_writer) return NULL; xml_writer->world = world; xml_writer->nstack_depth = 0; xml_writer->nstack = nstack; if(!xml_writer->nstack) { xml_writer->nstack = raptor_new_namespaces(world, 1); xml_writer->my_nstack = 1; } xml_writer->iostr = iostr; raptor_object_options_init(&xml_writer->options, RAPTOR_OPTION_AREA_XML_WRITER); return xml_writer; }
0
484,053
testSuite_SecureChannel(void) { Suite *s = suite_create("SecureChannel"); TCase *tc_initAndDelete = tcase_create("Initialize and delete Securechannel"); tcase_add_checked_fixture(tc_initAndDelete, setup_funcs_called, teardown_funcs_called); tcase_add_checked_fixture(tc_initAndDelete, setup_key_sizes, teardown_key_sizes); tcase_add_test(tc_initAndDelete, SecureChannel_initAndDelete); suite_add_tcase(s, tc_initAndDelete); TCase *tc_sendAsymmetricOPNMessage = tcase_create("Test sendAsymmetricOPNMessage function"); tcase_add_checked_fixture(tc_sendAsymmetricOPNMessage, setup_funcs_called, teardown_funcs_called); tcase_add_checked_fixture(tc_sendAsymmetricOPNMessage, setup_key_sizes, teardown_key_sizes); tcase_add_checked_fixture(tc_sendAsymmetricOPNMessage, setup_secureChannel, teardown_secureChannel); tcase_add_test(tc_sendAsymmetricOPNMessage, SecureChannel_sendAsymmetricOPNMessage_withoutConnection); tcase_add_test(tc_sendAsymmetricOPNMessage, SecureChannel_sendAsymmetricOPNMessage_invalidParameters); tcase_add_test(tc_sendAsymmetricOPNMessage, SecureChannel_sendAsymmetricOPNMessage_SecurityModeInvalid); tcase_add_test(tc_sendAsymmetricOPNMessage, SecureChannel_sendAsymmetricOPNMessage_SecurityModeNone); tcase_add_test(tc_sendAsymmetricOPNMessage, SecureChannel_sendAsymmetricOPNMessage_sentDataIsValid); #ifdef UA_ENABLE_ENCRYPTION tcase_add_test(tc_sendAsymmetricOPNMessage, SecureChannel_sendAsymmetricOPNMessage_SecurityModeSign); tcase_add_test(tc_sendAsymmetricOPNMessage, SecureChannel_sendAsymmetricOPNMessage_SecurityModeSignAndEncrypt); tcase_add_test(tc_sendAsymmetricOPNMessage, Securechannel_sendAsymmetricOPNMessage_extraPaddingPresentWhenKeyLargerThan2048Bits); #endif suite_add_tcase(s, tc_sendAsymmetricOPNMessage); TCase *tc_sendSymmetricMessage = tcase_create("Test sendSymmetricMessage function"); tcase_add_checked_fixture(tc_sendSymmetricMessage, setup_funcs_called, teardown_funcs_called); tcase_add_checked_fixture(tc_sendSymmetricMessage, setup_key_sizes, teardown_key_sizes); tcase_add_checked_fixture(tc_sendSymmetricMessage, setup_secureChannel, teardown_secureChannel); tcase_add_test(tc_sendSymmetricMessage, SecureChannel_sendSymmetricMessage); tcase_add_test(tc_sendSymmetricMessage, SecureChannel_sendSymmetricMessage_invalidParameters); tcase_add_test(tc_sendSymmetricMessage, SecureChannel_sendSymmetricMessage_modeNone); #ifdef UA_ENABLE_ENCRYPTION tcase_add_test(tc_sendSymmetricMessage, SecureChannel_sendSymmetricMessage_modeSign); tcase_add_test(tc_sendSymmetricMessage, SecureChannel_sendSymmetricMessage_modeSignAndEncrypt); #endif suite_add_tcase(s, tc_sendSymmetricMessage); TCase *tc_processBuffer = tcase_create("Test chunk assembly"); tcase_add_checked_fixture(tc_processBuffer, setup_funcs_called, teardown_funcs_called); tcase_add_checked_fixture(tc_processBuffer, setup_key_sizes, teardown_key_sizes); tcase_add_checked_fixture(tc_processBuffer, setup_secureChannel, teardown_secureChannel); tcase_add_test(tc_processBuffer, SecureChannel_assemblePartialChunks); suite_add_tcase(s, tc_processBuffer); return s; }
0
220,862
inline int16_t lut_lookup(int16_t value, const int16_t* lut) { return lut_lookup_with_interpolation(value, lut); }
0
210,484
static int io_read(struct io_kiocb *req, unsigned int issue_flags) { struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs; struct kiocb *kiocb = &req->rw.kiocb; struct iov_iter __iter, *iter = &__iter; struct io_async_rw *rw = req->async_data; ssize_t io_size, ret, ret2; bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK; if (rw) { iter = &rw->iter; iovec = NULL; } else { ret = io_import_iovec(READ, req, &iovec, iter, !force_nonblock); if (ret < 0) return ret; } io_size = iov_iter_count(iter); req->result = io_size; /* Ensure we clear previously set non-block flag */ if (!force_nonblock) kiocb->ki_flags &= ~IOCB_NOWAIT; else kiocb->ki_flags |= IOCB_NOWAIT; /* If the file doesn't support async, just async punt */ if (force_nonblock && !io_file_supports_async(req, READ)) { ret = io_setup_async_rw(req, iovec, inline_vecs, iter, true); return ret ?: -EAGAIN; } ret = rw_verify_area(READ, req->file, io_kiocb_ppos(kiocb), io_size); if (unlikely(ret)) { kfree(iovec); return ret; } ret = io_iter_do_read(req, iter); if (ret == -EAGAIN || (req->flags & REQ_F_REISSUE)) { req->flags &= ~REQ_F_REISSUE; /* IOPOLL retry should happen for io-wq threads */ if (!force_nonblock && !(req->ctx->flags & IORING_SETUP_IOPOLL)) goto done; /* no retry on NONBLOCK nor RWF_NOWAIT */ if (req->flags & REQ_F_NOWAIT) goto done; /* some cases will consume bytes even on error returns */ iov_iter_revert(iter, io_size - iov_iter_count(iter)); ret = 0; } else if (ret == -EIOCBQUEUED) { goto out_free; } else if (ret <= 0 || ret == io_size || !force_nonblock || (req->flags & REQ_F_NOWAIT) || !(req->flags & REQ_F_ISREG)) { /* read all, failed, already did sync or don't want to retry */ goto done; } ret2 = io_setup_async_rw(req, iovec, inline_vecs, iter, true); if (ret2) return ret2; iovec = NULL; rw = req->async_data; /* now use our persistent iterator, if we aren't already */ iter = &rw->iter; do { io_size -= ret; rw->bytes_done += ret; /* if we can retry, do so with the callbacks armed */ if (!io_rw_should_retry(req)) { kiocb->ki_flags &= ~IOCB_WAITQ; return -EAGAIN; } /* * Now retry read with the IOCB_WAITQ parts set in the iocb. If * we get -EIOCBQUEUED, then we'll get a notification when the * desired page gets unlocked. We can also get a partial read * here, and if we do, then just retry at the new offset. */ ret = io_iter_do_read(req, iter); if (ret == -EIOCBQUEUED) return 0; /* we got some bytes, but not all. retry. */ kiocb->ki_flags &= ~IOCB_WAITQ; } while (ret > 0 && ret < io_size); done: kiocb_done(kiocb, ret, issue_flags); out_free: /* it's faster to check here then delegate to kfree */ if (iovec) kfree(iovec); return 0; }
1
244,322
GF_Err paen_box_write(GF_Box *s, GF_BitStream *bs) { if (!s) return GF_BAD_PARAM; return gf_isom_box_write_header(s, bs); }
0
512,304
longlong val_int_from_real() { DBUG_ASSERT(is_fixed()); return Converter_double_to_longlong_with_warn(val_real(), false).result(); }
0
343,267
static void displayopenfailure(const char * const name) { char buffer[PATH_MAX + 42U]; const int e = errno; if (SNCHECK(snprintf(buffer, sizeof buffer, MSG_OPEN_FAILURE, name), sizeof buffer)) { _EXIT(EXIT_FAILURE); } errno = e; error(550, buffer); }
0
242,990
static int ssl_check_ctr_renegotiate( mbedtls_ssl_context *ssl ) { size_t ep_len = mbedtls_ssl_ep_len( ssl ); int in_ctr_cmp; int out_ctr_cmp; if( ssl->state != MBEDTLS_SSL_HANDSHAKE_OVER || ssl->renego_status == MBEDTLS_SSL_RENEGOTIATION_PENDING || ssl->conf->disable_renegotiation == MBEDTLS_SSL_RENEGOTIATION_DISABLED ) { return( 0 ); } in_ctr_cmp = memcmp( ssl->in_ctr + ep_len, ssl->conf->renego_period + ep_len, 8 - ep_len ); out_ctr_cmp = memcmp( ssl->cur_out_ctr + ep_len, ssl->conf->renego_period + ep_len, 8 - ep_len ); if( in_ctr_cmp <= 0 && out_ctr_cmp <= 0 ) { return( 0 ); } MBEDTLS_SSL_DEBUG_MSG( 1, ( "record counter limit reached: renegotiate" ) ); return( mbedtls_ssl_renegotiate( ssl ) ); }
0
482,689
gst_flxdec_src_query_handler (GstPad * pad, GstObject * parent, GstQuery * query) { GstFlxDec *flxdec = (GstFlxDec *) parent; gboolean ret = FALSE; switch (GST_QUERY_TYPE (query)) { case GST_QUERY_DURATION: { GstFormat format; gst_query_parse_duration (query, &format, NULL); if (format != GST_FORMAT_TIME) goto done; gst_query_set_duration (query, format, flxdec->duration); ret = TRUE; } default: break; } done: if (!ret) ret = gst_pad_query_default (pad, parent, query); return ret; }
0
387,774
bool InstanceKlass::should_be_initialized() const { return !is_initialized(); }
0
261,890
njs_string_prototype_char_at(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, njs_index_t unused) { size_t length; int64_t start; njs_int_t ret; njs_slice_prop_t slice; njs_string_prop_t string; ret = njs_string_object_validate(vm, njs_argument(args, 0)); if (njs_slow_path(ret != NJS_OK)) { return ret; } slice.string_length = njs_string_prop(&string, njs_argument(args, 0)); ret = njs_value_to_integer(vm, njs_arg(args, nargs, 1), &start); if (njs_slow_path(ret != NJS_OK)) { return ret; } length = 1; if (start < 0 || start >= (int64_t) slice.string_length) { start = 0; length = 0; } slice.start = start; slice.length = length; return njs_string_slice(vm, &vm->retval, &string, &slice); }
0
224,590
Status BiasAddGradShape(shape_inference::InferenceContext* c) { ShapeHandle input_shape; // Fetch the data_format attribute, which may not exist. string data_format; Status s = c->GetAttr("data_format", &data_format); if (s.ok() && data_format == "NCHW") { TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), 3, &input_shape)); c->set_output(0, c->Vector(c->Dim(input_shape, 1))); } else { TF_RETURN_IF_ERROR(c->WithRankAtLeast(c->input(0), 2, &input_shape)); c->set_output(0, c->Vector(c->Dim(input_shape, -1))); } return Status::OK(); }
0
401,582
write_pool(struct entropy_store *r, const char __user *buffer, size_t count) { size_t bytes; __u32 t, buf[16]; const char __user *p = buffer; while (count > 0) { int b, i = 0; bytes = min(count, sizeof(buf)); if (copy_from_user(&buf, p, bytes)) return -EFAULT; for (b = bytes ; b > 0 ; b -= sizeof(__u32), i++) { if (!arch_get_random_int(&t)) break; buf[i] ^= t; } count -= bytes; p += bytes; mix_pool_bytes(r, buf, bytes); cond_resched(); } return 0; }
0
436,132
static int io_timeout_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe, bool is_timeout_link) { struct io_timeout_data *data; unsigned flags; u32 off = READ_ONCE(sqe->off); if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL)) return -EINVAL; if (sqe->ioprio || sqe->buf_index || sqe->len != 1) return -EINVAL; if (off && is_timeout_link) return -EINVAL; flags = READ_ONCE(sqe->timeout_flags); if (flags & ~IORING_TIMEOUT_ABS) return -EINVAL; req->timeout.off = off; if (unlikely(off && !req->ctx->off_timeout_used)) req->ctx->off_timeout_used = true; if (!req->async_data && io_alloc_async_data(req)) return -ENOMEM; data = req->async_data; data->req = req; if (get_timespec64(&data->ts, u64_to_user_ptr(sqe->addr))) return -EFAULT; data->mode = io_translate_timeout_mode(flags); hrtimer_init(&data->timer, CLOCK_MONOTONIC, data->mode); if (is_timeout_link) io_req_track_inflight(req); return 0;
0
225,949
GF_Err svhd_box_size(GF_Box *s) { GF_SphericalVideoInfoBox *ptr = (GF_SphericalVideoInfoBox *)s; if (ptr->string) s->size += (u32) strlen(ptr->string); s->size += 1; return GF_OK;
0
270,111
TfLiteStatus CalculateActivationRangeQuantizedImpl( TfLiteContext* context, TfLiteFusedActivation activation, int32_t qmin, int32_t qmax, TfLiteTensor* output, int32_t* act_min, int32_t* act_max) { const auto scale = output->params.scale; const auto zero_point = output->params.zero_point; int32_t tmp_q; if (activation == kTfLiteActRelu) { TF_LITE_ENSURE_OK(context, Quantize(context, scale, zero_point, 0.0, tmp_q)); *act_min = std::max(qmin, tmp_q); *act_max = qmax; } else if (activation == kTfLiteActRelu6) { TF_LITE_ENSURE_OK(context, Quantize(context, scale, zero_point, 0.0, tmp_q)); *act_min = std::max(qmin, tmp_q); TF_LITE_ENSURE_OK(context, Quantize(context, scale, zero_point, 6.0, tmp_q)); *act_max = std::min(qmax, tmp_q); } else if (activation == kTfLiteActReluN1To1) { TF_LITE_ENSURE_OK(context, Quantize(context, scale, zero_point, -1.0, tmp_q)); *act_min = std::max(qmin, tmp_q); TF_LITE_ENSURE_OK(context, Quantize(context, scale, zero_point, 1.0, tmp_q)); *act_max = std::min(qmax, tmp_q); } else { *act_min = qmin; *act_max = qmax; } return kTfLiteOk; }
0
384,207
static int nf_tables_dump_flowtable(struct sk_buff *skb, struct netlink_callback *cb) { const struct nfgenmsg *nfmsg = nlmsg_data(cb->nlh); struct nft_flowtable_filter *filter = cb->data; unsigned int idx = 0, s_idx = cb->args[0]; struct net *net = sock_net(skb->sk); int family = nfmsg->nfgen_family; struct nft_flowtable *flowtable; struct nftables_pernet *nft_net; const struct nft_table *table; rcu_read_lock(); nft_net = nft_pernet(net); cb->seq = READ_ONCE(nft_net->base_seq); list_for_each_entry_rcu(table, &nft_net->tables, list) { if (family != NFPROTO_UNSPEC && family != table->family) continue; list_for_each_entry_rcu(flowtable, &table->flowtables, list) { if (!nft_is_active(net, flowtable)) goto cont; if (idx < s_idx) goto cont; if (idx > s_idx) memset(&cb->args[1], 0, sizeof(cb->args) - sizeof(cb->args[0])); if (filter && filter->table && strcmp(filter->table, table->name)) goto cont; if (nf_tables_fill_flowtable_info(skb, net, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, NFT_MSG_NEWFLOWTABLE, NLM_F_MULTI | NLM_F_APPEND, table->family, flowtable, &flowtable->hook_list) < 0) goto done; nl_dump_check_consistent(cb, nlmsg_hdr(skb)); cont: idx++; } } done: rcu_read_unlock(); cb->args[0] = idx; return skb->len; }
0
384,281
gs_heap_stable(gs_memory_t *mem) { return mem; /* heap memory is stable */ }
0
212,927
static void sungem_send_packet(SunGEMState *s, const uint8_t *buf, int size) { NetClientState *nc = qemu_get_queue(s->nic); if (s->macregs[MAC_XIFCFG >> 2] & MAC_XIFCFG_LBCK) { nc->info->receive(nc, buf, size); } else { qemu_send_packet(nc, buf, size); } }
1
244,072
GF_Err prhd_box_write(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_ProjectionHeaderBox *ptr = (GF_ProjectionHeaderBox *)s; e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u32(bs, ptr->yaw); gf_bs_write_u32(bs, ptr->pitch); gf_bs_write_u32(bs, ptr->roll); return GF_OK; }
0
448,549
static struct stream *bgp_update_packet_eor(struct peer *peer, afi_t afi, safi_t safi) { struct stream *s; iana_afi_t pkt_afi = IANA_AFI_IPV4; iana_safi_t pkt_safi = IANA_SAFI_UNICAST; if (DISABLE_BGP_ANNOUNCE) return NULL; if (bgp_debug_neighbor_events(peer)) zlog_debug("send End-of-RIB for %s to %s", get_afi_safi_str(afi, safi, false), peer->host); s = stream_new(peer->max_packet_size); /* Make BGP update packet. */ bgp_packet_set_marker(s, BGP_MSG_UPDATE); /* Unfeasible Routes Length */ stream_putw(s, 0); if (afi == AFI_IP && safi == SAFI_UNICAST) { /* Total Path Attribute Length */ stream_putw(s, 0); } else { /* Convert AFI, SAFI to values for packet. */ bgp_map_afi_safi_int2iana(afi, safi, &pkt_afi, &pkt_safi); /* Total Path Attribute Length */ stream_putw(s, 6); stream_putc(s, BGP_ATTR_FLAG_OPTIONAL); stream_putc(s, BGP_ATTR_MP_UNREACH_NLRI); stream_putc(s, 3); stream_putw(s, pkt_afi); stream_putc(s, pkt_safi); } bgp_packet_set_size(s); return s; }
0
269,515
static void TIFFWarnings(const char *module,const char *format,va_list warning) { char message[MagickPathExtent]; ExceptionInfo *exception; #if defined(MAGICKCORE_HAVE_VSNPRINTF) (void) vsnprintf(message,MagickPathExtent-2,format,warning); #else (void) vsprintf(message,format,warning); #endif message[MagickPathExtent-2]='\0'; (void) ConcatenateMagickString(message,".",MagickPathExtent); exception=(ExceptionInfo *) GetMagickThreadValue(tiff_exception); if (exception != (ExceptionInfo *) NULL) (void) ThrowMagickException(exception,GetMagickModule(),CoderWarning, message,"`%s'",module); }
0
512,732
longlong Item_func_bit_or::val_int() { DBUG_ASSERT(fixed == 1); ulonglong arg1= (ulonglong) args[0]->val_int(); if (args[0]->null_value) { null_value=1; /* purecov: inspected */ return 0; /* purecov: inspected */ } ulonglong arg2= (ulonglong) args[1]->val_int(); if (args[1]->null_value) { null_value=1; return 0; } null_value=0; return (longlong) (arg1 | arg2); }
0
314,525
PJ_DEF(pj_uint32_t) pjmedia_sdp_transport_get_proto(const pj_str_t *tp) { pj_str_t token, rest = {0}; pj_ssize_t idx; PJ_ASSERT_RETURN(tp, PJMEDIA_TP_PROTO_NONE); idx = pj_strtok2(tp, "/", &token, 0); if (idx != tp->slen) pj_strset(&rest, tp->ptr + token.slen + 1, tp->slen - token.slen - 1); if (pj_stricmp2(&token, "RTP") == 0) { /* Starts with "RTP" */ /* RTP/AVP */ if (pj_stricmp2(&rest, "AVP") == 0) return PJMEDIA_TP_PROTO_RTP_AVP; /* RTP/SAVP */ if (pj_stricmp2(&rest, "SAVP") == 0) return PJMEDIA_TP_PROTO_RTP_SAVP; /* RTP/AVPF */ if (pj_stricmp2(&rest, "AVPF") == 0) return PJMEDIA_TP_PROTO_RTP_AVPF; /* RTP/SAVPF */ if (pj_stricmp2(&rest, "SAVPF") == 0) return PJMEDIA_TP_PROTO_RTP_SAVPF; } else if (pj_stricmp2(&token, "UDP") == 0) { /* Starts with "UDP" */ /* Plain UDP */ if (rest.slen == 0) return PJMEDIA_TP_PROTO_UDP; /* DTLS-SRTP */ if (pj_stricmp2(&rest, "TLS/RTP/SAVP") == 0) return PJMEDIA_TP_PROTO_DTLS_SRTP; /* DTLS-SRTP with RTCP-FB */ if (pj_stricmp2(&rest, "TLS/RTP/SAVPF") == 0) return PJMEDIA_TP_PROTO_DTLS_SRTPF; } /* Unknown transport */ return PJMEDIA_TP_PROTO_UNKNOWN; }
0
421,385
static void pc(int c) { putchar(c); }
0
488,411
static void * __init find_section64(Elf64_Ehdr *ehdr, const char *secname, unsigned long *size) { Elf64_Shdr *sechdrs; unsigned int i; char *secnames; /* Grab section headers and strings so we can tell who is who */ sechdrs = (void *)ehdr + ehdr->e_shoff; secnames = (void *)ehdr + sechdrs[ehdr->e_shstrndx].sh_offset; /* Find the section they want */ for (i = 1; i < ehdr->e_shnum; i++) { if (strcmp(secnames+sechdrs[i].sh_name, secname) == 0) { if (size) *size = sechdrs[i].sh_size; return (void *)ehdr + sechdrs[i].sh_offset; } } if (size) *size = 0; return NULL; }
0
247,641
bool expectNoCertChain() const { return expect_no_cert_chain_; }
0
387,626
static int snd_ctl_elem_read_user(struct snd_card *card, struct snd_ctl_elem_value __user *_control) { struct snd_ctl_elem_value *control; int result; control = memdup_user(_control, sizeof(*control)); if (IS_ERR(control)) return PTR_ERR(control); down_read(&card->controls_rwsem); result = snd_ctl_elem_read(card, control); up_read(&card->controls_rwsem); if (result < 0) goto error; if (copy_to_user(_control, control, sizeof(*control))) result = -EFAULT; error: kfree(control); return result; }
0
353,203
SplashPattern *SplashOutputDev::getColor(GfxGray gray) { SplashColor color; if (reverseVideo) { gray = gfxColorComp1 - gray; } color[0] = colToByte(gray); return new SplashSolidColor(color); }
0
244,357
GF_Box *svhd_box_new() { ISOM_DECL_BOX_ALLOC(GF_SphericalVideoInfoBox, GF_ISOM_BOX_TYPE_SVHD); return (GF_Box *)tmp; }
0
211,155
int tcp_emu(struct socket *so, struct mbuf *m) { Slirp *slirp = so->slirp; unsigned n1, n2, n3, n4, n5, n6; char buff[257]; uint32_t laddr; unsigned lport; char *bptr; DEBUG_CALL("tcp_emu"); DEBUG_ARG("so = %p", so); DEBUG_ARG("m = %p", m); switch (so->so_emu) { int x, i; /* TODO: IPv6 */ case EMU_IDENT: /* * Identification protocol as per rfc-1413 */ { struct socket *tmpso; struct sockaddr_in addr; socklen_t addrlen = sizeof(struct sockaddr_in); char *eol = g_strstr_len(m->m_data, m->m_len, "\r\n"); if (!eol) { return 1; } *eol = '\0'; if (sscanf(m->m_data, "%u%*[ ,]%u", &n1, &n2) == 2) { HTONS(n1); HTONS(n2); /* n2 is the one on our host */ for (tmpso = slirp->tcb.so_next; tmpso != &slirp->tcb; tmpso = tmpso->so_next) { if (tmpso->so_laddr.s_addr == so->so_laddr.s_addr && tmpso->so_lport == n2 && tmpso->so_faddr.s_addr == so->so_faddr.s_addr && tmpso->so_fport == n1) { if (getsockname(tmpso->s, (struct sockaddr *)&addr, &addrlen) == 0) n2 = addr.sin_port; break; } } NTOHS(n1); NTOHS(n2); m_inc(m, snprintf(NULL, 0, "%d,%d\r\n", n1, n2) + 1); m->m_len = snprintf(m->m_data, M_ROOM(m), "%d,%d\r\n", n1, n2); assert(m->m_len < M_ROOM(m)); } else { *eol = '\r'; } return 1; } case EMU_FTP: /* ftp */ m_inc(m, m->m_len + 1); *(m->m_data + m->m_len) = 0; /* NUL terminate for strstr */ if ((bptr = (char *)strstr(m->m_data, "ORT")) != NULL) { /* * Need to emulate the PORT command */ x = sscanf(bptr, "ORT %u,%u,%u,%u,%u,%u\r\n%256[^\177]", &n1, &n2, &n3, &n4, &n5, &n6, buff); if (x < 6) return 1; laddr = htonl((n1 << 24) | (n2 << 16) | (n3 << 8) | (n4)); lport = htons((n5 << 8) | (n6)); if ((so = tcp_listen(slirp, INADDR_ANY, 0, laddr, lport, SS_FACCEPTONCE)) == NULL) { return 1; } n6 = ntohs(so->so_fport); n5 = (n6 >> 8) & 0xff; n6 &= 0xff; laddr = ntohl(so->so_faddr.s_addr); n1 = ((laddr >> 24) & 0xff); n2 = ((laddr >> 16) & 0xff); n3 = ((laddr >> 8) & 0xff); n4 = (laddr & 0xff); m->m_len = bptr - m->m_data; /* Adjust length */ m->m_len += snprintf(bptr, m->m_size - m->m_len, "ORT %d,%d,%d,%d,%d,%d\r\n%s", n1, n2, n3, n4, n5, n6, x == 7 ? buff : ""); return 1; } else if ((bptr = (char *)strstr(m->m_data, "27 Entering")) != NULL) { /* * Need to emulate the PASV response */ x = sscanf( bptr, "27 Entering Passive Mode (%u,%u,%u,%u,%u,%u)\r\n%256[^\177]", &n1, &n2, &n3, &n4, &n5, &n6, buff); if (x < 6) return 1; laddr = htonl((n1 << 24) | (n2 << 16) | (n3 << 8) | (n4)); lport = htons((n5 << 8) | (n6)); if ((so = tcp_listen(slirp, INADDR_ANY, 0, laddr, lport, SS_FACCEPTONCE)) == NULL) { return 1; } n6 = ntohs(so->so_fport); n5 = (n6 >> 8) & 0xff; n6 &= 0xff; laddr = ntohl(so->so_faddr.s_addr); n1 = ((laddr >> 24) & 0xff); n2 = ((laddr >> 16) & 0xff); n3 = ((laddr >> 8) & 0xff); n4 = (laddr & 0xff); m->m_len = bptr - m->m_data; /* Adjust length */ m->m_len += snprintf(bptr, m->m_size - m->m_len, "27 Entering Passive Mode (%d,%d,%d,%d,%d,%d)\r\n%s", n1, n2, n3, n4, n5, n6, x == 7 ? buff : ""); return 1; } return 1; case EMU_KSH: /* * The kshell (Kerberos rsh) and shell services both pass * a local port port number to carry signals to the server * and stderr to the client. It is passed at the beginning * of the connection as a NUL-terminated decimal ASCII string. */ so->so_emu = 0; for (lport = 0, i = 0; i < m->m_len - 1; ++i) { if (m->m_data[i] < '0' || m->m_data[i] > '9') return 1; /* invalid number */ lport *= 10; lport += m->m_data[i] - '0'; } if (m->m_data[m->m_len - 1] == '\0' && lport != 0 && (so = tcp_listen(slirp, INADDR_ANY, 0, so->so_laddr.s_addr, htons(lport), SS_FACCEPTONCE)) != NULL) m->m_len = snprintf(m->m_data, m->m_size, "%d", ntohs(so->so_fport)) + 1; return 1; case EMU_IRC: /* * Need to emulate DCC CHAT, DCC SEND and DCC MOVE */ m_inc(m, m->m_len + 1); *(m->m_data + m->m_len) = 0; /* NULL terminate the string for strstr */ if ((bptr = (char *)strstr(m->m_data, "DCC")) == NULL) return 1; /* The %256s is for the broken mIRC */ if (sscanf(bptr, "DCC CHAT %256s %u %u", buff, &laddr, &lport) == 3) { if ((so = tcp_listen(slirp, INADDR_ANY, 0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL) { return 1; } m->m_len = bptr - m->m_data; /* Adjust length */ m->m_len += snprintf(bptr, m->m_size, "DCC CHAT chat %lu %u%c\n", (unsigned long)ntohl(so->so_faddr.s_addr), ntohs(so->so_fport), 1); } else if (sscanf(bptr, "DCC SEND %256s %u %u %u", buff, &laddr, &lport, &n1) == 4) { if ((so = tcp_listen(slirp, INADDR_ANY, 0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL) { return 1; } m->m_len = bptr - m->m_data; /* Adjust length */ m->m_len += snprintf(bptr, m->m_size, "DCC SEND %s %lu %u %u%c\n", buff, (unsigned long)ntohl(so->so_faddr.s_addr), ntohs(so->so_fport), n1, 1); } else if (sscanf(bptr, "DCC MOVE %256s %u %u %u", buff, &laddr, &lport, &n1) == 4) { if ((so = tcp_listen(slirp, INADDR_ANY, 0, htonl(laddr), htons(lport), SS_FACCEPTONCE)) == NULL) { return 1; } m->m_len = bptr - m->m_data; /* Adjust length */ m->m_len += snprintf(bptr, m->m_size, "DCC MOVE %s %lu %u %u%c\n", buff, (unsigned long)ntohl(so->so_faddr.s_addr), ntohs(so->so_fport), n1, 1); } return 1; case EMU_REALAUDIO: /* * RealAudio emulation - JP. We must try to parse the incoming * data and try to find the two characters that contain the * port number. Then we redirect an udp port and replace the * number with the real port we got. * * The 1.0 beta versions of the player are not supported * any more. * * A typical packet for player version 1.0 (release version): * * 0000:50 4E 41 00 05 * 0000:00 01 00 02 1B D7 00 00 67 E6 6C DC 63 00 12 50 ........g.l.c..P * 0010:4E 43 4C 49 45 4E 54 20 31 30 31 20 41 4C 50 48 NCLIENT 101 ALPH * 0020:41 6C 00 00 52 00 17 72 61 66 69 6C 65 73 2F 76 Al..R..rafiles/v * 0030:6F 61 2F 65 6E 67 6C 69 73 68 5F 2E 72 61 79 42 oa/english_.rayB * * Now the port number 0x1BD7 is found at offset 0x04 of the * Now the port number 0x1BD7 is found at offset 0x04 of the * second packet. This time we received five bytes first and * then the rest. You never know how many bytes you get. * * A typical packet for player version 2.0 (beta): * * 0000:50 4E 41 00 06 00 02 00 00 00 01 00 02 1B C1 00 PNA............. * 0010:00 67 75 78 F5 63 00 0A 57 69 6E 32 2E 30 2E 30 .gux.c..Win2.0.0 * 0020:2E 35 6C 00 00 52 00 1C 72 61 66 69 6C 65 73 2F .5l..R..rafiles/ * 0030:77 65 62 73 69 74 65 2F 32 30 72 65 6C 65 61 73 website/20releas * 0040:65 2E 72 61 79 53 00 00 06 36 42 e.rayS...6B * * Port number 0x1BC1 is found at offset 0x0d. * * This is just a horrible switch statement. Variable ra tells * us where we're going. */ bptr = m->m_data; while (bptr < m->m_data + m->m_len) { uint16_t p; static int ra = 0; char ra_tbl[4]; ra_tbl[0] = 0x50; ra_tbl[1] = 0x4e; ra_tbl[2] = 0x41; ra_tbl[3] = 0; switch (ra) { case 0: case 2: case 3: if (*bptr++ != ra_tbl[ra]) { ra = 0; continue; } break; case 1: /* * We may get 0x50 several times, ignore them */ if (*bptr == 0x50) { ra = 1; bptr++; continue; } else if (*bptr++ != ra_tbl[ra]) { ra = 0; continue; } break; case 4: /* * skip version number */ bptr++; break; case 5: /* * The difference between versions 1.0 and * 2.0 is here. For future versions of * the player this may need to be modified. */ if (*(bptr + 1) == 0x02) bptr += 8; else bptr += 4; break; case 6: /* This is the field containing the port * number that RA-player is listening to. */ lport = (((uint8_t *)bptr)[0] << 8) + ((uint8_t *)bptr)[1]; if (lport < 6970) lport += 256; /* don't know why */ if (lport < 6970 || lport > 7170) return 1; /* failed */ /* try to get udp port between 6970 - 7170 */ for (p = 6970; p < 7071; p++) { if (udp_listen(slirp, INADDR_ANY, htons(p), so->so_laddr.s_addr, htons(lport), SS_FACCEPTONCE)) { break; } } if (p == 7071) p = 0; *(uint8_t *)bptr++ = (p >> 8) & 0xff; *(uint8_t *)bptr = p & 0xff; ra = 0; return 1; /* port redirected, we're done */ break; default: ra = 0; } ra++; } return 1; default: /* Ooops, not emulated, won't call tcp_emu again */ so->so_emu = 0; return 1; } }
1
481,266
static void mlx5_fpga_conn_event(struct mlx5_core_qp *mqp, int event) { struct mlx5_fpga_conn *conn; conn = container_of(mqp, struct mlx5_fpga_conn, qp.mqp); mlx5_fpga_warn(conn->fdev, "QP event %u on QP #%u\n", event, mqp->qpn); }
0
359,255
bgp_show_rsclient_summary (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi) { struct peer *peer; struct listnode *node, *nnode; int count = 0; /* Header string for each address family. */ static char header[] = "Neighbor V AS Export-Policy Import-Policy Up/Down State"; for (ALL_LIST_ELEMENTS (bgp->rsclient, node, nnode, peer)) { if (peer->afc[afi][safi] && CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_RSERVER_CLIENT)) { if (! count) { vty_out (vty, "Route Server's BGP router identifier %s%s", inet_ntoa (bgp->router_id), VTY_NEWLINE); vty_out (vty, "Route Server's local AS number %d%s", bgp->as, VTY_NEWLINE); vty_out (vty, "%s", VTY_NEWLINE); vty_out (vty, "%s%s", header, VTY_NEWLINE); } count += bgp_write_rsclient_summary (vty, peer, afi, safi); } } if (count) vty_out (vty, "%sTotal number of Route Server Clients %d%s", VTY_NEWLINE, count, VTY_NEWLINE); else vty_out (vty, "No %s Route Server Client is configured%s", afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE); return CMD_SUCCESS; }
0
231,779
void handleCipherUnavailable( CipherUnavailable* originalData, QuicServerConnectionState& conn, size_t packetSize, ServerEvents::ReadData& readData) { if (!originalData->packet || originalData->packet->empty()) { VLOG(10) << "drop because no data " << conn; if (conn.qLogger) { conn.qLogger->addPacketDrop(packetSize, kNoData); } QUIC_TRACE(packet_drop, conn, "no_data"); return; } if (originalData->protectionType != ProtectionType::ZeroRtt && originalData->protectionType != ProtectionType::KeyPhaseZero) { VLOG(10) << "drop because unexpected protection level " << conn; if (conn.qLogger) { conn.qLogger->addPacketDrop(packetSize, kUnexpectedProtectionLevel); } QUIC_TRACE(packet_drop, conn, "unexpected_protection_level"); return; } size_t combinedSize = (conn.pendingZeroRttData ? conn.pendingZeroRttData->size() : 0) + (conn.pendingOneRttData ? conn.pendingOneRttData->size() : 0); if (combinedSize >= conn.transportSettings.maxPacketsToBuffer) { VLOG(10) << "drop because max buffered " << conn; if (conn.qLogger) { conn.qLogger->addPacketDrop(packetSize, kMaxBuffered); } QUIC_TRACE(packet_drop, conn, "max_buffered"); return; } auto& pendingData = originalData->protectionType == ProtectionType::ZeroRtt ? conn.pendingZeroRttData : conn.pendingOneRttData; if (pendingData) { QUIC_TRACE( packet_buffered, conn, originalData->packetNum, originalData->protectionType, packetSize); if (conn.qLogger) { conn.qLogger->addPacketBuffered( originalData->packetNum, originalData->protectionType, packetSize); } ServerEvents::ReadData pendingReadData; pendingReadData.peer = readData.peer; pendingReadData.networkData = NetworkDataSingle( std::move(originalData->packet), readData.networkData.receiveTimePoint); pendingData->emplace_back(std::move(pendingReadData)); VLOG(10) << "Adding pending data to " << toString(originalData->protectionType) << " buffer size=" << pendingData->size() << " " << conn; } else { VLOG(10) << "drop because " << toString(originalData->protectionType) << " buffer no longer available " << conn; if (conn.qLogger) { conn.qLogger->addPacketDrop(packetSize, kBufferUnavailable); } QUIC_TRACE(packet_drop, conn, "buffer_unavailable"); } }
0
222,519
void FunctionLibraryDefinition::Clear() { mutex_lock l(mu_); function_defs_.clear(); func_grad_.clear(); }
0
434,093
do_arg_all( int count, int forceit, // hide buffers in current windows int keep_tabs) // keep current tabs, for ":tab drop file" { int i; win_T *wp, *wpnext; char_u *opened; // Array of weight for which args are open: // 0: not opened // 1: opened in other tab // 2: opened in curtab // 3: opened in curtab and curwin // int opened_len; // length of opened[] int use_firstwin = FALSE; // use first window for arglist int tab_drop_empty_window = FALSE; int split_ret = OK; int p_ea_save; alist_T *alist; // argument list to be used buf_T *buf; tabpage_T *tpnext; int had_tab = cmdmod.cmod_tab; win_T *old_curwin, *last_curwin; tabpage_T *old_curtab, *last_curtab; win_T *new_curwin = NULL; tabpage_T *new_curtab = NULL; int prev_arglist_locked = arglist_locked; #ifdef FEAT_CMDWIN if (cmdwin_type != 0) { emsg(_(e_invalid_in_cmdline_window)); return; } #endif if (ARGCOUNT <= 0) { // Don't give an error message. We don't want it when the ":all" // command is in the .vimrc. return; } setpcmark(); opened_len = ARGCOUNT; opened = alloc_clear(opened_len); if (opened == NULL) return; // Autocommands may do anything to the argument list. Make sure it's not // freed while we are working here by "locking" it. We still have to // watch out for its size to be changed. alist = curwin->w_alist; ++alist->al_refcount; arglist_locked = TRUE; old_curwin = curwin; old_curtab = curtab; # ifdef FEAT_GUI need_mouse_correct = TRUE; # endif // Try closing all windows that are not in the argument list. // Also close windows that are not full width; // When 'hidden' or "forceit" set the buffer becomes hidden. // Windows that have a changed buffer and can't be hidden won't be closed. // When the ":tab" modifier was used do this for all tab pages. if (had_tab > 0) goto_tabpage_tp(first_tabpage, TRUE, TRUE); for (;;) { tpnext = curtab->tp_next; for (wp = firstwin; wp != NULL; wp = wpnext) { wpnext = wp->w_next; buf = wp->w_buffer; if (buf->b_ffname == NULL || (!keep_tabs && (buf->b_nwindows > 1 || wp->w_width != Columns))) i = opened_len; else { // check if the buffer in this window is in the arglist for (i = 0; i < opened_len; ++i) { if (i < alist->al_ga.ga_len && (AARGLIST(alist)[i].ae_fnum == buf->b_fnum || fullpathcmp(alist_name(&AARGLIST(alist)[i]), buf->b_ffname, TRUE, TRUE) & FPC_SAME)) { int weight = 1; if (old_curtab == curtab) { ++weight; if (old_curwin == wp) ++weight; } if (weight > (int)opened[i]) { opened[i] = (char_u)weight; if (i == 0) { if (new_curwin != NULL) new_curwin->w_arg_idx = opened_len; new_curwin = wp; new_curtab = curtab; } } else if (keep_tabs) i = opened_len; if (wp->w_alist != alist) { // Use the current argument list for all windows // containing a file from it. alist_unlink(wp->w_alist); wp->w_alist = alist; ++wp->w_alist->al_refcount; } break; } } } wp->w_arg_idx = i; if (i == opened_len && !keep_tabs)// close this window { if (buf_hide(buf) || forceit || buf->b_nwindows > 1 || !bufIsChanged(buf)) { // If the buffer was changed, and we would like to hide it, // try autowriting. if (!buf_hide(buf) && buf->b_nwindows <= 1 && bufIsChanged(buf)) { bufref_T bufref; set_bufref(&bufref, buf); (void)autowrite(buf, FALSE); // check if autocommands removed the window if (!win_valid(wp) || !bufref_valid(&bufref)) { wpnext = firstwin; // start all over... continue; } } // don't close last window if (ONE_WINDOW && (first_tabpage->tp_next == NULL || !had_tab)) use_firstwin = TRUE; else { win_close(wp, !buf_hide(buf) && !bufIsChanged(buf)); // check if autocommands removed the next window if (!win_valid(wpnext)) wpnext = firstwin; // start all over... } } } } // Without the ":tab" modifier only do the current tab page. if (had_tab == 0 || tpnext == NULL) break; // check if autocommands removed the next tab page if (!valid_tabpage(tpnext)) tpnext = first_tabpage; // start all over... goto_tabpage_tp(tpnext, TRUE, TRUE); } // Open a window for files in the argument list that don't have one. // ARGCOUNT may change while doing this, because of autocommands. if (count > opened_len || count <= 0) count = opened_len; // Don't execute Win/Buf Enter/Leave autocommands here. ++autocmd_no_enter; ++autocmd_no_leave; last_curwin = curwin; last_curtab = curtab; win_enter(lastwin, FALSE); // ":tab drop file" should re-use an empty window to avoid "--remote-tab" // leaving an empty tab page when executed locally. if (keep_tabs && BUFEMPTY() && curbuf->b_nwindows == 1 && curbuf->b_ffname == NULL && !curbuf->b_changed) { use_firstwin = TRUE; tab_drop_empty_window = TRUE; } for (i = 0; i < count && !got_int; ++i) { if (alist == &global_alist && i == global_alist.al_ga.ga_len - 1) arg_had_last = TRUE; if (opened[i] > 0) { // Move the already present window to below the current window if (curwin->w_arg_idx != i) { FOR_ALL_WINDOWS(wpnext) { if (wpnext->w_arg_idx == i) { if (keep_tabs) { new_curwin = wpnext; new_curtab = curtab; } else if (wpnext->w_frame->fr_parent != curwin->w_frame->fr_parent) { emsg(_("E249: window layout changed unexpectedly")); i = count; break; } else win_move_after(wpnext, curwin); break; } } } } else if (split_ret == OK) { // trigger events for tab drop if (tab_drop_empty_window && i == count - 1) --autocmd_no_enter; if (!use_firstwin) // split current window { p_ea_save = p_ea; p_ea = TRUE; // use space from all windows split_ret = win_split(0, WSP_ROOM | WSP_BELOW); p_ea = p_ea_save; if (split_ret == FAIL) continue; } else // first window: do autocmd for leaving this buffer --autocmd_no_leave; // edit file "i" curwin->w_arg_idx = i; if (i == 0) { new_curwin = curwin; new_curtab = curtab; } (void)do_ecmd(0, alist_name(&AARGLIST(alist)[i]), NULL, NULL, ECMD_ONE, ((buf_hide(curwin->w_buffer) || bufIsChanged(curwin->w_buffer)) ? ECMD_HIDE : 0) + ECMD_OLDBUF, curwin); if (tab_drop_empty_window && i == count - 1) ++autocmd_no_enter; if (use_firstwin) ++autocmd_no_leave; use_firstwin = FALSE; } ui_breakcheck(); // When ":tab" was used open a new tab for a new window repeatedly. if (had_tab > 0 && tabpage_index(NULL) <= p_tpm) cmdmod.cmod_tab = 9999; } // Remove the "lock" on the argument list. alist_unlink(alist); arglist_locked = prev_arglist_locked; --autocmd_no_enter; // restore last referenced tabpage's curwin if (last_curtab != new_curtab) { if (valid_tabpage(last_curtab)) goto_tabpage_tp(last_curtab, TRUE, TRUE); if (win_valid(last_curwin)) win_enter(last_curwin, FALSE); } // to window with first arg if (valid_tabpage(new_curtab)) goto_tabpage_tp(new_curtab, TRUE, TRUE); if (win_valid(new_curwin)) win_enter(new_curwin, FALSE); --autocmd_no_leave; vim_free(opened); }
0
508,368
bool extend_table_list(THD *thd, TABLE_LIST *tables, Prelocking_strategy *prelocking_strategy, bool has_prelocking_list) { bool error= false; LEX *lex= thd->lex; if (thd->locked_tables_mode <= LTM_LOCK_TABLES && ! has_prelocking_list && tables->updating && tables->lock_type >= TL_WRITE_ALLOW_WRITE) { bool need_prelocking= FALSE; TABLE_LIST **save_query_tables_last= lex->query_tables_last; /* Extend statement's table list and the prelocking set with tables and routines according to the current prelocking strategy. For example, for DML statements we need to add tables and routines used by triggers which are going to be invoked for this element of table list and also add tables required for handling of foreign keys. */ error= prelocking_strategy->handle_table(thd, lex, tables, &need_prelocking); if (need_prelocking && ! lex->requires_prelocking()) lex->mark_as_requiring_prelocking(save_query_tables_last); } return error; }
0
216,965
multi_update::initialize_tables(JOIN *join) { TABLE_LIST *table_ref; DBUG_ENTER("initialize_tables"); if (unlikely((thd->variables.option_bits & OPTION_SAFE_UPDATES) && error_if_full_join(join))) DBUG_RETURN(1); main_table=join->join_tab->table; table_to_update= 0; /* Any update has at least one pair (field, value) */ DBUG_ASSERT(fields->elements); /* Only one table may be modified by UPDATE of an updatable view. For an updatable view first_table_for_update indicates this table. For a regular multi-update it refers to some updated table. */ TABLE *first_table_for_update= ((Item_field *) fields->head())->field->table; /* Create a temporary table for keys to all tables, except main table */ for (table_ref= update_tables; table_ref; table_ref= table_ref->next_local) { TABLE *table=table_ref->table; uint cnt= table_ref->shared; List<Item> temp_fields; ORDER group; TMP_TABLE_PARAM *tmp_param; if (ignore) table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); if (table == main_table) // First table in join { if (safe_update_on_fly(thd, join->join_tab, table_ref, all_tables)) { table_to_update= table; // Update table on the fly has_vers_fields= table->vers_check_update(*fields); continue; } } table->prepare_for_position(); join->map2table[table->tablenr]->keep_current_rowid= true; /* enable uncacheable flag if we update a view with check option and check option has a subselect, otherwise, the check option can be evaluated after the subselect was freed as independent (See full_local in JOIN::join_free()). */ if (table_ref->check_option && !join->select_lex->uncacheable) { SELECT_LEX_UNIT *tmp_unit; SELECT_LEX *sl; for (tmp_unit= join->select_lex->first_inner_unit(); tmp_unit; tmp_unit= tmp_unit->next_unit()) { for (sl= tmp_unit->first_select(); sl; sl= sl->next_select()) { if (sl->master_unit()->item) { join->select_lex->uncacheable|= UNCACHEABLE_CHECKOPTION; goto loop_end; } } } } loop_end: if (table == first_table_for_update && table_ref->check_option) { table_map unupdated_tables= table_ref->check_option->used_tables() & ~first_table_for_update->map; List_iterator<TABLE_LIST> ti(*leaves); TABLE_LIST *tbl_ref; while ((tbl_ref= ti++) && unupdated_tables) { if (unupdated_tables & tbl_ref->table->map) unupdated_tables&= ~tbl_ref->table->map; else continue; if (unupdated_check_opt_tables.push_back(tbl_ref->table)) DBUG_RETURN(1); } } tmp_param= tmp_table_param+cnt; /* Create a temporary table to store all fields that are changed for this table. The first field in the temporary table is a pointer to the original row so that we can find and update it. For the updatable VIEW a few following fields are rowids of tables used in the CHECK OPTION condition. */ List_iterator_fast<TABLE> tbl_it(unupdated_check_opt_tables); TABLE *tbl= table; do { LEX_CSTRING field_name; field_name.str= tbl->alias.c_ptr(); field_name.length= strlen(field_name.str); /* Signal each table (including tables referenced by WITH CHECK OPTION clause) for which we will store row position in the temporary table that we need a position to be read first. */ tbl->prepare_for_position(); join->map2table[tbl->tablenr]->keep_current_rowid= true; Item_temptable_rowid *item= new (thd->mem_root) Item_temptable_rowid(tbl); if (!item) DBUG_RETURN(1); item->fix_fields(thd, 0); if (temp_fields.push_back(item, thd->mem_root)) DBUG_RETURN(1); } while ((tbl= tbl_it++)); temp_fields.append(fields_for_table[cnt]); /* Make an unique key over the first field to avoid duplicated updates */ bzero((char*) &group, sizeof(group)); group.direction= ORDER::ORDER_ASC; group.item= (Item**) temp_fields.head_ref(); tmp_param->quick_group= 1; tmp_param->field_count= temp_fields.elements; tmp_param->func_count= temp_fields.elements - 1; calc_group_buffer(tmp_param, &group); /* small table, ignore SQL_BIG_TABLES */ my_bool save_big_tables= thd->variables.big_tables; thd->variables.big_tables= FALSE; tmp_tables[cnt]=create_tmp_table(thd, tmp_param, temp_fields, (ORDER*) &group, 0, 0, TMP_TABLE_ALL_COLUMNS, HA_POS_ERROR, &empty_clex_str); thd->variables.big_tables= save_big_tables; if (!tmp_tables[cnt]) DBUG_RETURN(1); tmp_tables[cnt]->file->extra(HA_EXTRA_WRITE_CACHE); } join->tmp_table_keep_current_rowid= TRUE; DBUG_RETURN(0); }
1
472,120
int proc_cgroupstats_show(struct seq_file *m, void *v) { struct cgroup_subsys *ss; int i; seq_puts(m, "#subsys_name\thierarchy\tnum_cgroups\tenabled\n"); /* * ideally we don't want subsystems moving around while we do this. * cgroup_mutex is also necessary to guarantee an atomic snapshot of * subsys/hierarchy state. */ mutex_lock(&cgroup_mutex); for_each_subsys(ss, i) seq_printf(m, "%s\t%d\t%d\t%d\n", ss->legacy_name, ss->root->hierarchy_id, atomic_read(&ss->root->nr_cgrps), cgroup_ssid_enabled(i)); mutex_unlock(&cgroup_mutex); return 0; }
0
432,176
static bool addrrange_equal(AddrRange r1, AddrRange r2) { return int128_eq(r1.start, r2.start) && int128_eq(r1.size, r2.size); }
0
225,685
GF_Box *trep_box_new() { ISOM_DECL_BOX_ALLOC(GF_TrackExtensionPropertiesBox, GF_ISOM_BOX_TYPE_TREP); tmp->child_boxes = gf_list_new(); return (GF_Box *)tmp;
0
273,913
static int recv_msg(int sd, char *msg, size_t len, char **cmd, char **argument) { char *ptr; ssize_t bytes; uint8_t *raw = (uint8_t *)msg; /* Clear for every new command. */ memset(msg, 0, len); /* Save one byte (-1) for NUL termination */ bytes = recv(sd, msg, len - 1, 0); if (bytes < 0) { if (EINTR == errno) return 1; if (ECONNRESET == errno) DBG("Connection reset by client."); else ERR(errno, "Failed reading client command"); return 1; } if (!bytes) { INFO("Client disconnected."); return 1; } if (raw[0] == 0xff) { char tmp[4]; char buf[20] = { 0 }; int i; i = recv(sd, &msg[bytes], len - bytes - 1, MSG_OOB | MSG_DONTWAIT); if (i > 0) bytes += i; for (i = 0; i < bytes; i++) { snprintf(tmp, sizeof(tmp), "%2X%s", raw[i], i + 1 < bytes ? " " : ""); strlcat(buf, tmp, sizeof(buf)); } strlcpy(msg, buf, len); *cmd = msg; *argument = NULL; DBG("Recv: [%s], %zd bytes", msg, bytes); return 0; } /* NUL terminate for strpbrk() */ msg[bytes] = 0; *cmd = msg; ptr = strpbrk(msg, " "); if (ptr) { *ptr = 0; ptr++; *argument = ptr; } else { *argument = NULL; ptr = msg; } ptr = strpbrk(ptr, "\r\n"); if (ptr) *ptr = 0; /* Convert command to std ftp upper case, issue #18 */ for (ptr = msg; *ptr; ++ptr) *ptr = toupper(*ptr); DBG("Recv: %s %s", *cmd, *argument ?: ""); return 0; }
0
513,150
static int plugin_initialize(MEM_ROOT *tmp_root, struct st_plugin_int *plugin, int *argc, char **argv, bool options_only) { int ret= 1; DBUG_ENTER("plugin_initialize"); mysql_mutex_assert_owner(&LOCK_plugin); uint state= plugin->state; DBUG_ASSERT(state == PLUGIN_IS_UNINITIALIZED); mysql_mutex_unlock(&LOCK_plugin); mysql_prlock_wrlock(&LOCK_system_variables_hash); if (test_plugin_options(tmp_root, plugin, argc, argv)) state= PLUGIN_IS_DISABLED; mysql_prlock_unlock(&LOCK_system_variables_hash); if (options_only || state == PLUGIN_IS_DISABLED) { ret= !options_only && plugin_is_forced(plugin); state= PLUGIN_IS_DISABLED; goto err; } if (plugin_type_initialize[plugin->plugin->type]) { if ((*plugin_type_initialize[plugin->plugin->type])(plugin)) { sql_print_error("Plugin '%s' registration as a %s failed.", plugin->name.str, plugin_type_names[plugin->plugin->type].str); goto err; } } else if (plugin->plugin->init) { if (plugin->plugin->init(plugin)) { sql_print_error("Plugin '%s' init function returned error.", plugin->name.str); goto err; } } state= PLUGIN_IS_READY; // plugin->init() succeeded if (plugin->plugin->status_vars) { /* historical ndb behavior caused MySQL plugins to specify status var names in full, with the plugin name prefix. this was never fixed in MySQL. MariaDB fixes that but supports MySQL style too. */ SHOW_VAR *show_vars= plugin->plugin->status_vars; SHOW_VAR tmp_array[2]= { {plugin->plugin->name, (char*)plugin->plugin->status_vars, SHOW_ARRAY}, {0, 0, SHOW_UNDEF} }; if (strncasecmp(show_vars->name, plugin->name.str, plugin->name.length)) show_vars= tmp_array; if (add_status_vars(show_vars)) goto err; } ret= 0; err: if (ret) plugin_variables_deinit(plugin); mysql_mutex_lock(&LOCK_plugin); plugin->state= state; DBUG_RETURN(ret); }
0
244,168
GF_Err trgr_box_size(GF_Box *s) { u32 pos=0; GF_TrackGroupBox *ptr = (GF_TrackGroupBox *) s; gf_isom_check_position_list(s, ptr->groups, &pos); return GF_OK; }
0
269,307
static av_always_inline int same_block(BlockNode *a, BlockNode *b){ if((a->type&BLOCK_INTRA) && (b->type&BLOCK_INTRA)){ return !((a->color[0] - b->color[0]) | (a->color[1] - b->color[1]) | (a->color[2] - b->color[2])); }else{ return !((a->mx - b->mx) | (a->my - b->my) | (a->ref - b->ref) | ((a->type ^ b->type)&BLOCK_INTRA)); } }
0
341,817
search_impl(i_ctx_t *i_ctx_p, bool forward) { os_ptr op = osp; os_ptr op1 = op - 1; uint size = r_size(op); uint count; byte *pat; byte *ptr; byte ch; int incr = forward ? 1 : -1; check_read_type(*op1, t_string); check_read_type(*op, t_string); if (size > r_size(op1)) { /* can't match */ make_false(op); return 0; } count = r_size(op1) - size; ptr = op1->value.bytes; if (size == 0) goto found; if (!forward) ptr += count; pat = op->value.bytes; ch = pat[0]; do { if (*ptr == ch && (size == 1 || !memcmp(ptr, pat, size))) goto found; ptr += incr; } while (count--); /* No match */ make_false(op); return 0; found: op->tas.type_attrs = op1->tas.type_attrs; op->value.bytes = ptr; /* match */ op->tas.rsize = size; /* match */ push(2); op[-1] = *op1; /* pre */ op[-3].value.bytes = ptr + size; /* post */ if (forward) { op[-1].tas.rsize = ptr - op[-1].value.bytes; /* pre */ op[-3].tas.rsize = count; /* post */ } else { op[-1].tas.rsize = count; /* pre */ op[-3].tas.rsize -= count + size; /* post */ } make_true(op); return 0; }
0
267,963
R_API RBinFile *r_bin_file_find_by_fd(RBin *bin, ut32 bin_fd) { RListIter *iter; RBinFile *bf; r_return_val_if_fail (bin, NULL); r_list_foreach (bin->binfiles, iter, bf) { if (bf->fd == bin_fd) { return bf; } } return NULL; }
0
437,692
static int cx23888_ir_rx_shutdown(struct v4l2_subdev *sd) { struct cx23888_ir_state *state = to_state(sd); struct cx23885_dev *dev = state->dev; mutex_lock(&state->rx_params_lock); /* Disable or slow down all IR Rx circuits and counters */ irqenable_rx(dev, 0); control_rx_enable(dev, false); control_rx_demodulation_enable(dev, false); control_rx_s_edge_detection(dev, CNTRL_EDG_NONE); filter_rx_s_min_width(dev, 0); cx23888_ir_write4(dev, CX23888_IR_RXCLK_REG, RXCLK_RCD); state->rx_params.shutdown = true; mutex_unlock(&state->rx_params_lock); return 0; }
0
252,280
int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len) { mz_stream stream; int status; memset(&stream, 0, sizeof(stream)); // In case mz_ulong is 64-bits (argh I hate longs). if ((source_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR; stream.next_in = pSource; stream.avail_in = (mz_uint32)source_len; stream.next_out = pDest; stream.avail_out = (mz_uint32)*pDest_len; status = mz_inflateInit(&stream); if (status != MZ_OK) return status; status = mz_inflate(&stream, MZ_FINISH); if (status != MZ_STREAM_END) { mz_inflateEnd(&stream); return ((status == MZ_BUF_ERROR) && (!stream.avail_in)) ? MZ_DATA_ERROR : status; } *pDest_len = stream.total_out; return mz_inflateEnd(&stream); }
0
405,387
static void xfrm_policy_inexact_list_reinsert(struct net *net, struct xfrm_pol_inexact_node *n, u16 family) { unsigned int matched_s, matched_d; struct xfrm_policy *policy, *p; matched_s = 0; matched_d = 0; list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) { struct hlist_node *newpos = NULL; bool matches_s, matches_d; if (!policy->bydst_reinsert) continue; WARN_ON_ONCE(policy->family != family); policy->bydst_reinsert = false; hlist_for_each_entry(p, &n->hhead, bydst) { if (policy->priority > p->priority) newpos = &p->bydst; else if (policy->priority == p->priority && policy->pos > p->pos) newpos = &p->bydst; else break; } if (newpos) hlist_add_behind_rcu(&policy->bydst, newpos); else hlist_add_head_rcu(&policy->bydst, &n->hhead); /* paranoia checks follow. * Check that the reinserted policy matches at least * saddr or daddr for current node prefix. * * Matching both is fine, matching saddr in one policy * (but not daddr) and then matching only daddr in another * is a bug. */ matches_s = xfrm_policy_addr_delta(&policy->selector.saddr, &n->addr, n->prefixlen, family) == 0; matches_d = xfrm_policy_addr_delta(&policy->selector.daddr, &n->addr, n->prefixlen, family) == 0; if (matches_s && matches_d) continue; WARN_ON_ONCE(!matches_s && !matches_d); if (matches_s) matched_s++; if (matches_d) matched_d++; WARN_ON_ONCE(matched_s && matched_d); } }
0
244,204
GF_Err trgr_box_write(GF_Box *s, GF_BitStream *bs) { return gf_isom_box_write_header(s, bs); }
0
366,340
static void *m_start(struct seq_file *m, loff_t *pos) { struct proc_mounts *p = m->private; struct list_head *prev; down_read(&namespace_sem); if (!*pos) { prev = &p->ns->list; } else { prev = &p->cursor.mnt_list; /* Read after we'd reached the end? */ if (list_empty(prev)) return NULL; } return mnt_list_next(p->ns, prev); }
0
326,912
static struct vidtv_access_unit *vidtv_s302m_access_unit_init(struct vidtv_access_unit *head) { struct vidtv_access_unit *au; au = kzalloc(sizeof(*au), GFP_KERNEL); if (!au) return NULL; if (head) { while (head->next) head = head->next; head->next = au; } return au; }
0
300,735
static int tipc_wait_for_accept(struct socket *sock, long timeo) { struct sock *sk = sock->sk; DEFINE_WAIT_FUNC(wait, woken_wake_function); int err; /* True wake-one mechanism for incoming connections: only * one process gets woken up, not the 'whole herd'. * Since we do not 'race & poll' for established sockets * anymore, the common case will execute the loop only once. */ for (;;) { if (timeo && skb_queue_empty(&sk->sk_receive_queue)) { add_wait_queue(sk_sleep(sk), &wait); release_sock(sk); timeo = wait_woken(&wait, TASK_INTERRUPTIBLE, timeo); lock_sock(sk); remove_wait_queue(sk_sleep(sk), &wait); } err = 0; if (!skb_queue_empty(&sk->sk_receive_queue)) break; err = -EAGAIN; if (!timeo) break; err = sock_intr_errno(timeo); if (signal_pending(current)) break; } return err; }
0
440,899
LogMessageTypeVerbString(MessageType type, int verb) { if (type == X_ERROR) verb = 0; if (logVerbosity < verb && logFileVerbosity < verb) return NULL; switch (type) { case X_PROBED: return X_PROBE_STRING; case X_CONFIG: return X_CONFIG_STRING; case X_DEFAULT: return X_DEFAULT_STRING; case X_CMDLINE: return X_CMDLINE_STRING; case X_NOTICE: return X_NOTICE_STRING; case X_ERROR: return X_ERROR_STRING; case X_WARNING: return X_WARNING_STRING; case X_INFO: return X_INFO_STRING; case X_NOT_IMPLEMENTED: return X_NOT_IMPLEMENTED_STRING; case X_UNKNOWN: return X_UNKNOWN_STRING; case X_NONE: return X_NONE_STRING; case X_DEBUG: return X_DEBUG_STRING; default: return X_UNKNOWN_STRING; } }
0