idx
int64 | func
string | target
int64 |
|---|---|---|
484,753
|
static bool xennet_handle_rx(struct netfront_queue *queue, unsigned int *eoi)
{
unsigned int work_queued;
unsigned long flags;
if (unlikely(queue->info->broken))
return false;
spin_lock_irqsave(&queue->rx_cons_lock, flags);
work_queued = XEN_RING_NR_UNCONSUMED_RESPONSES(&queue->rx);
if (work_queued > queue->rx_rsp_unconsumed) {
queue->rx_rsp_unconsumed = work_queued;
*eoi = 0;
} else if (unlikely(work_queued < queue->rx_rsp_unconsumed)) {
const struct device *dev = &queue->info->netdev->dev;
spin_unlock_irqrestore(&queue->rx_cons_lock, flags);
dev_alert(dev, "RX producer index going backwards\n");
dev_alert(dev, "Disabled for further use\n");
queue->info->broken = true;
return false;
}
spin_unlock_irqrestore(&queue->rx_cons_lock, flags);
if (likely(netif_carrier_ok(queue->info->netdev) && work_queued))
napi_schedule(&queue->napi);
return true;
}
| 0
|
232,309
|
GF_Err gf_isom_box_read(GF_Box *a, GF_BitStream *bs)
{
if (!a) return GF_BAD_PARAM;
if (!a->registry) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Read invalid box type %s without registry\n", gf_4cc_to_str(a->type) ));
return GF_ISOM_INVALID_FILE;
}
return a->registry->read_fn(a, bs);
| 0
|
482,514
|
_lou_getDotsForChar(widechar c, const DisplayTableHeader *table) {
CharDotsMapping *cdPtr = getDotsForChar(c, table);
if (cdPtr) return cdPtr->found;
return LOU_DOTS;
}
| 0
|
292,177
|
void LinkResolver::resolve_invokeinterface(CallInfo& result, Handle recv, const constantPoolHandle& pool, int index, TRAPS) {
LinkInfo link_info(pool, index, CHECK);
Klass* recvrKlass = recv.is_null() ? (Klass*)NULL : recv->klass();
resolve_interface_call(result, recv, recvrKlass, link_info, true, CHECK);
}
| 0
|
450,390
|
static int send_rect_simple(VncState *vs, int x, int y, int w, int h,
bool split)
{
int max_size, max_width;
int max_sub_width, max_sub_height;
int dx, dy;
int rw, rh;
int n = 0;
max_size = tight_conf[vs->tight->compression].max_rect_size;
max_width = tight_conf[vs->tight->compression].max_rect_width;
if (split && (w > max_width || w * h > max_size)) {
max_sub_width = (w > max_width) ? max_width : w;
max_sub_height = max_size / max_sub_width;
for (dy = 0; dy < h; dy += max_sub_height) {
for (dx = 0; dx < w; dx += max_width) {
rw = MIN(max_sub_width, w - dx);
rh = MIN(max_sub_height, h - dy);
n += send_sub_rect(vs, x+dx, y+dy, rw, rh);
}
}
} else {
n += send_sub_rect(vs, x, y, w, h);
}
return n;
}
| 0
|
512,750
|
Item_cond::used_tables() const
{ // This caches used_tables
return used_tables_cache;
}
| 0
|
348,441
|
static void __exit mkiss_exit_driver(void)
{
tty_unregister_ldisc(&ax_ldisc);
}
| 0
|
343,183
|
static int esp6_init_state(struct xfrm_state *x)
{
struct crypto_aead *aead;
u32 align;
int err;
x->data = NULL;
if (x->aead)
err = esp_init_aead(x);
else
err = esp_init_authenc(x);
if (err)
goto error;
aead = x->data;
x->props.header_len = sizeof(struct ip_esp_hdr) +
crypto_aead_ivsize(aead);
switch (x->props.mode) {
case XFRM_MODE_BEET:
if (x->sel.family != AF_INET6)
x->props.header_len += IPV4_BEET_PHMAXLEN +
(sizeof(struct ipv6hdr) - sizeof(struct iphdr));
break;
default:
case XFRM_MODE_TRANSPORT:
break;
case XFRM_MODE_TUNNEL:
x->props.header_len += sizeof(struct ipv6hdr);
break;
}
if (x->encap) {
struct xfrm_encap_tmpl *encap = x->encap;
switch (encap->encap_type) {
default:
err = -EINVAL;
goto error;
case UDP_ENCAP_ESPINUDP:
x->props.header_len += sizeof(struct udphdr);
break;
case UDP_ENCAP_ESPINUDP_NON_IKE:
x->props.header_len += sizeof(struct udphdr) + 2 * sizeof(u32);
break;
#ifdef CONFIG_INET6_ESPINTCP
case TCP_ENCAP_ESPINTCP:
/* only the length field, TCP encap is done by
* the socket
*/
x->props.header_len += 2;
break;
#endif
}
}
align = ALIGN(crypto_aead_blocksize(aead), 4);
x->props.trailer_len = align + 1 + crypto_aead_authsize(aead);
error:
return err;
}
| 0
|
222,550
|
Status FunctionCallFrame::ConsumeRetvals(std::vector<Tensor>* rets,
bool allow_dead_tensors) {
rets->clear();
rets->reserve(rets_.size());
for (size_t i = 0; i < rets_.size(); ++i) {
if (rets_[i].has_val) {
rets->emplace_back(std::move(rets_[i].val));
} else if (allow_dead_tensors) {
rets->emplace_back();
} else {
return errors::Internal("Retval[", i, "] does not have value");
}
}
return Status::OK();
}
| 0
|
359,468
|
DEFUN (neighbor_allowas_in,
neighbor_allowas_in_cmd,
NEIGHBOR_CMD2 "allowas-in",
NEIGHBOR_STR
NEIGHBOR_ADDR_STR2
"Accept as-path with my AS present in it\n")
{
int ret;
struct peer *peer;
unsigned int allow_num;
peer = peer_and_group_lookup_vty (vty, argv[0]);
if (! peer)
return CMD_WARNING;
if (argc == 1)
allow_num = 3;
else
VTY_GET_INTEGER_RANGE ("AS number", allow_num, argv[1], 1, 10);
ret = peer_allowas_in_set (peer, bgp_node_afi (vty), bgp_node_safi (vty),
allow_num);
return bgp_vty_return (vty, ret);
}
| 0
|
498,157
|
void cgit_print_snapshot_links(const char *repo, const char *head,
const char *hex, int snapshots)
{
const struct cgit_snapshot_format* f;
struct strbuf filename = STRBUF_INIT;
size_t prefixlen;
unsigned char sha1[20];
if (get_sha1(fmt("refs/tags/%s", hex), sha1) == 0 &&
(hex[0] == 'v' || hex[0] == 'V') && isdigit(hex[1]))
hex++;
strbuf_addf(&filename, "%s-%s", cgit_repobasename(repo), hex);
prefixlen = filename.len;
for (f = cgit_snapshot_formats; f->suffix; f++) {
if (!(snapshots & f->bit))
continue;
strbuf_setlen(&filename, prefixlen);
strbuf_addstr(&filename, f->suffix);
cgit_snapshot_link(filename.buf, NULL, NULL, NULL, NULL,
filename.buf);
html("<br/>");
}
strbuf_release(&filename);
}
| 0
|
246,747
|
u32 parse_multi_rtp(char *arg_val, u32 opt)
{
hint_flags |= GP_RTP_PCK_USE_MULTI;
if (arg_val)
max_ptime = atoi(arg_val);
return 0;
}
| 0
|
390,599
|
XkbWriteVirtualModMap(XkbDescPtr xkb,xkbGetMapReply *rep,char *buf,
ClientPtr client)
{
unsigned i;
xkbVModMapWireDesc * wire;
unsigned short * pMap;
wire= (xkbVModMapWireDesc *)buf;
pMap= &xkb->server->vmodmap[rep->firstVModMapKey];
for (i=0;i<rep->nVModMapKeys-1;i++,pMap++) {
if (*pMap!=0) {
wire->key= i+rep->firstVModMapKey;
wire->vmods= *pMap;
wire++;
}
}
return (char *)wire;
}
| 0
|
253,522
|
smb2_close_cached_fid(struct kref *ref)
{
struct cached_fid *cfid = container_of(ref, struct cached_fid,
refcount);
if (cfid->is_valid) {
cifs_dbg(FYI, "clear cached root file handle\n");
SMB2_close(0, cfid->tcon, cfid->fid->persistent_fid,
cfid->fid->volatile_fid);
}
/*
* We only check validity above to send SMB2_close,
* but we still need to invalidate these entries
* when this function is called
*/
cfid->is_valid = false;
cfid->file_all_info_is_valid = false;
cfid->has_lease = false;
if (cfid->dentry) {
dput(cfid->dentry);
cfid->dentry = NULL;
}
}
| 0
|
309,853
|
mouse_server(unsigned long param)
#endif
{
SCREEN *sp = (SCREEN *) param;
unsigned short fWait = MOU_WAIT;
/* NOPTRRECT mourt = { 0,0,24,79 }; */
MOUEVENTINFO mouev;
HMOU hmou;
unsigned short mask = MOUSE_BN1_DOWN | MOUSE_BN2_DOWN | MOUSE_BN3_DOWN;
int nbuttons = 3;
int oldstate = 0;
char err[80];
unsigned long rc;
/* open the handle for the mouse */
if (MouOpen(NULL, &hmou) == 0) {
rc = MouSetEventMask(&mask, hmou);
if (rc) { /* retry with 2 buttons */
mask = MOUSE_BN1_DOWN | MOUSE_BN2_DOWN;
rc = MouSetEventMask(&mask, hmou);
nbuttons = 2;
}
if (rc == 0 && MouDrawPtr(hmou) == 0) {
for (;;) {
/* sit and wait on the event queue */
rc = MouReadEventQue(&mouev, &fWait, hmou);
if (rc) {
_nc_SPRINTF(err, _nc_SLIMIT(sizeof(err))
"Error reading mouse queue, rc=%lu.\r\n", rc);
break;
}
if (!sp->_emxmouse_activated)
goto finish;
/*
* OS/2 numbers a 3-button mouse inconsistently from other
* platforms:
* 1 = left
* 2 = right
* 3 = middle.
*/
if ((mouev.fs ^ oldstate) & MOUSE_BN1_DOWN)
write_event(sp, mouev.fs & MOUSE_BN1_DOWN,
sp->_emxmouse_buttons[1], mouev.col, mouev.row);
if ((mouev.fs ^ oldstate) & MOUSE_BN2_DOWN)
write_event(sp, mouev.fs & MOUSE_BN2_DOWN,
sp->_emxmouse_buttons[3], mouev.col, mouev.row);
if ((mouev.fs ^ oldstate) & MOUSE_BN3_DOWN)
write_event(sp, mouev.fs & MOUSE_BN3_DOWN,
sp->_emxmouse_buttons[2], mouev.col, mouev.row);
finish:
oldstate = mouev.fs;
}
} else {
_nc_SPRINTF(err, _nc_SLIMIT(sizeof(err))
"Error setting event mask, buttons=%d, rc=%lu.\r\n",
nbuttons, rc);
}
DosWrite(2, err, strlen(err), &rc);
MouClose(hmou);
}
DosExit(EXIT_THREAD, 0L);
}
| 0
|
335,431
|
ex_redir(exarg_T *eap)
{
char *mode;
char_u *fname;
char_u *arg = eap->arg;
#ifdef FEAT_EVAL
if (redir_execute)
{
emsg(_(e_cannot_use_redir_inside_execute));
return;
}
#endif
if (STRICMP(eap->arg, "END") == 0)
close_redir();
else
{
if (*arg == '>')
{
++arg;
if (*arg == '>')
{
++arg;
mode = "a";
}
else
mode = "w";
arg = skipwhite(arg);
close_redir();
// Expand environment variables and "~/".
fname = expand_env_save(arg);
if (fname == NULL)
return;
#ifdef FEAT_BROWSE
if (cmdmod.cmod_flags & CMOD_BROWSE)
{
char_u *browseFile;
browseFile = do_browse(BROWSE_SAVE,
(char_u *)_("Save Redirection"),
fname, NULL, NULL,
(char_u *)_(BROWSE_FILTER_ALL_FILES), curbuf);
if (browseFile == NULL)
return; // operation cancelled
vim_free(fname);
fname = browseFile;
eap->forceit = TRUE; // since dialog already asked
}
#endif
redir_fd = open_exfile(fname, eap->forceit, mode);
vim_free(fname);
}
#ifdef FEAT_EVAL
else if (*arg == '@')
{
// redirect to a register a-z (resp. A-Z for appending)
close_redir();
++arg;
if (ASCII_ISALPHA(*arg)
# ifdef FEAT_CLIPBOARD
|| *arg == '*'
|| *arg == '+'
# endif
|| *arg == '"')
{
redir_reg = *arg++;
if (*arg == '>' && arg[1] == '>') // append
arg += 2;
else
{
// Can use both "@a" and "@a>".
if (*arg == '>')
arg++;
// Make register empty when not using @A-@Z and the
// command is valid.
if (*arg == NUL && !isupper(redir_reg))
write_reg_contents(redir_reg, (char_u *)"", -1, FALSE);
}
}
if (*arg != NUL)
{
redir_reg = 0;
semsg(_(e_invalid_argument_str), eap->arg);
}
}
else if (*arg == '=' && arg[1] == '>')
{
int append;
// redirect to a variable
close_redir();
arg += 2;
if (*arg == '>')
{
++arg;
append = TRUE;
}
else
append = FALSE;
if (var_redir_start(skipwhite(arg), append) == OK)
redir_vname = 1;
}
#endif
// TODO: redirect to a buffer
else
semsg(_(e_invalid_argument_str), eap->arg);
}
// Make sure redirection is not off. Can happen for cmdline completion
// that indirectly invokes a command to catch its output.
if (redir_fd != NULL
#ifdef FEAT_EVAL
|| redir_reg || redir_vname
#endif
)
redir_off = FALSE;
}
| 0
|
432,697
|
static float lite_font_stringwidth( wmfAPI* API, wmfFont* font, char* str)
{
#if 0
wmf_magick_t
*ddata = WMF_MAGICK_GetData(API);
Image
*image = ddata->image;
DrawInfo
*draw_info;
ExceptionInfo
*exception;
TypeMetric
metrics;
float
stringwidth = 0;
double
orig_x_resolution,
orig_y_resolution;
ResolutionType
orig_resolution_units;
orig_x_resolution = image->resolution.x;
orig_y_resolution = image->resolution.y;
orig_resolution_units = image->units;
draw_info=ddata->draw_info;
if (draw_info == (const DrawInfo *) NULL)
return 0;
draw_info->font=WMF_FONT_PSNAME(font);
draw_info->pointsize=12;
draw_info->text=str;
image->resolution.x = 72;
image->resolution.y = 72;
image->units = PixelsPerInchResolution;
exception=ddata->exception;
if (GetTypeMetrics(image, draw_info, &metrics, exception) != MagickFalse)
stringwidth = ((metrics.width * 72)/(image->resolution.x * draw_info->pointsize)); /* *0.916348; */
draw_info->font=NULL;
draw_info->text=NULL;
#if 0
printf("\nlite_font_stringwidth\n");
printf("string = \"%s\"\n", str);
printf("WMF_FONT_NAME = \"%s\"\n", WMF_FONT_NAME(font));
printf("WMF_FONT_PSNAME = \"%s\"\n", WMF_FONT_PSNAME(font));
printf("stringwidth = %g\n", stringwidth);
/* printf("WMF_FONT_HEIGHT = %i\n", (int)WMF_FONT_HEIGHT(font)); */
/* printf("WMF_FONT_WIDTH = %i\n", (int)WMF_FONT_WIDTH(font)); */
fflush(stdout);
#endif
image->resolution.x = orig_x_resolution;
image->resolution.y = orig_y_resolution;
image->units = orig_resolution_units;
return stringwidth;
#else
(void) API;
(void) font;
(void) str;
return 0;
#endif
}
| 0
|
231,781
|
TEST_F(QuicUnencryptedServerTransportTest, TestSendHandshakeDone) {
getFakeHandshakeLayer()->allowZeroRttKeys();
setupClientReadCodec();
recvClientHello(true, QuicVersion::QUIC_DRAFT);
recvClientFinished(true, nullptr, QuicVersion::QUIC_DRAFT);
auto& packets = server->getConn().outstandings.packets;
ASSERT_FALSE(packets.empty());
int numHandshakeDone = 0;
for (auto& p : packets) {
for (auto& f : p.packet.frames) {
auto s = f.asQuicSimpleFrame();
if (s) {
if (s->asHandshakeDoneFrame()) {
numHandshakeDone++;
}
}
}
}
EXPECT_EQ(numHandshakeDone, 1);
}
| 0
|
369,276
|
static void io_init_poll_iocb(struct io_poll_iocb *poll, __poll_t events,
wait_queue_func_t wake_func)
{
poll->head = NULL;
#define IO_POLL_UNMASK (EPOLLERR|EPOLLHUP|EPOLLNVAL|EPOLLRDHUP)
/* mask in events that we always want/need */
poll->events = events | IO_POLL_UNMASK;
INIT_LIST_HEAD(&poll->wait.entry);
init_waitqueue_func_entry(&poll->wait, wake_func);
| 0
|
261,219
|
int wm_SemInit(wm_Sem *s) {
*s = CreateSemaphore( NULL, 0, 1, NULL);
return 0;
}
| 0
|
462,583
|
void controller::mark_article_read(const std::string& guid, bool read) {
if (api) {
api->mark_article_read(guid, read);
}
}
| 0
|
223,482
|
static void read_char7_type(compiler_common *common, jump_list **backtracks, BOOL negated)
{
/* Reads the precise character type of a character into TMP1, if the character
is less than 128. Otherwise it returns with zero. Does not check STR_END. The
full_read argument tells whether characters above max are accepted or not. */
DEFINE_COMPILER;
struct sljit_jump *jump;
SLJIT_ASSERT(common->utf);
OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), 0);
OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
/* All values > 127 are zero in ctypes. */
OP1(SLJIT_MOV_U8, TMP1, 0, SLJIT_MEM1(TMP2), common->ctypes);
if (negated)
{
jump = CMP(SLJIT_LESS, TMP2, 0, SLJIT_IMM, 0x80);
if (common->invalid_utf)
{
add_jump(compiler, &common->utfreadchar_invalid, JUMP(SLJIT_FAST_CALL));
add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_IMM, INVALID_UTF_CHAR));
OP1(SLJIT_MOV, TMP1, 0, SLJIT_IMM, 0);
}
else
{
OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP2), (sljit_sw)PRIV(utf8_table4) - 0xc0);
OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
}
JUMPHERE(jump);
}
}
| 0
|
384,128
|
raptor_xml_writer_end_element_common(raptor_xml_writer* xml_writer,
raptor_xml_element *element,
int is_empty)
{
raptor_iostream* iostr = xml_writer->iostr;
if(is_empty)
raptor_iostream_write_byte('/', iostr);
else {
raptor_iostream_write_byte('<', iostr);
raptor_iostream_write_byte('/', iostr);
if(element->name->nspace && element->name->nspace->prefix_length > 0) {
raptor_iostream_counted_string_write((const char*)element->name->nspace->prefix,
element->name->nspace->prefix_length,
iostr);
raptor_iostream_write_byte(':', iostr);
}
raptor_iostream_counted_string_write((const char*)element->name->local_name,
element->name->local_name_length,
iostr);
}
raptor_iostream_write_byte('>', iostr);
return 0;
}
| 0
|
432,173
|
static void memory_region_update_container_subregions(MemoryRegion *subregion)
{
MemoryRegion *mr = subregion->container;
MemoryRegion *other;
memory_region_transaction_begin();
QTAILQ_FOREACH(other, &mr->subregions, subregions_link) {
QTAILQ_INSERT_BEFORE(other, subregion, subregions_link);
goto done;
}
QTAILQ_INSERT_TAIL(&mr->subregions, subregion, subregions_link);
done:
mr->uc->memory_region_update_pending = true;
memory_region_transaction_commit(mr);
}
| 0
|
359,494
|
DEFUN (clear_bgp_all_soft_out,
clear_bgp_all_soft_out_cmd,
"clear bgp * soft out",
CLEAR_STR
BGP_STR
"Clear all peers\n"
"Soft reconfig\n"
"Soft reconfig outbound update\n")
{
if (argc == 1)
return bgp_clear_vty (vty, argv[0], AFI_IP6, SAFI_UNICAST, clear_all,
BGP_CLEAR_SOFT_OUT, NULL);
return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_all,
BGP_CLEAR_SOFT_OUT, NULL);
}
| 0
|
222,597
|
gen_call(codegen_scope *s, node *tree, int val, int safe)
{
mrb_sym sym = nsym(tree->cdr->car);
int skip = 0, n = 0, nk = 0, noop = 0, noself = 0, blk = 0, sp_save = cursp();
if (!tree->car) {
noself = noop = 1;
push();
}
else {
codegen(s, tree->car, VAL); /* receiver */
}
if (safe) {
int recv = cursp()-1;
gen_move(s, cursp(), recv, 1);
skip = genjmp2_0(s, OP_JMPNIL, cursp(), val);
}
tree = tree->cdr->cdr->car;
if (tree) {
if (tree->car) { /* positional arguments */
n = gen_values(s, tree->car, VAL, 14);
if (n < 0) { /* variable length */
noop = 1; /* not operator */
n = 15;
push();
}
}
if (tree->cdr->car) { /* keyword arguments */
noop = 1;
nk = gen_hash(s, tree->cdr->car->cdr, VAL, 14);
if (nk < 0) nk = 15;
}
}
if (tree && tree->cdr && tree->cdr->cdr) {
codegen(s, tree->cdr->cdr, VAL);
pop();
noop = 1;
blk = 1;
}
push();pop();
s->sp = sp_save;
if (!noop && sym == MRB_OPSYM_2(s->mrb, add) && n == 1) {
gen_addsub(s, OP_ADD, cursp());
}
else if (!noop && sym == MRB_OPSYM_2(s->mrb, sub) && n == 1) {
gen_addsub(s, OP_SUB, cursp());
}
else if (!noop && sym == MRB_OPSYM_2(s->mrb, mul) && n == 1) {
gen_muldiv(s, OP_MUL, cursp());
}
else if (!noop && sym == MRB_OPSYM_2(s->mrb, div) && n == 1) {
gen_muldiv(s, OP_DIV, cursp());
}
else if (!noop && sym == MRB_OPSYM_2(s->mrb, lt) && n == 1) {
genop_1(s, OP_LT, cursp());
}
else if (!noop && sym == MRB_OPSYM_2(s->mrb, le) && n == 1) {
genop_1(s, OP_LE, cursp());
}
else if (!noop && sym == MRB_OPSYM_2(s->mrb, gt) && n == 1) {
genop_1(s, OP_GT, cursp());
}
else if (!noop && sym == MRB_OPSYM_2(s->mrb, ge) && n == 1) {
genop_1(s, OP_GE, cursp());
}
else if (!noop && sym == MRB_OPSYM_2(s->mrb, eq) && n == 1) {
genop_1(s, OP_EQ, cursp());
}
else if (!noop && sym == MRB_OPSYM_2(s->mrb, aset) && n == 2) {
genop_1(s, OP_SETIDX, cursp());
}
else if (!noop && n == 0 && gen_uniop(s, sym, cursp())) {
/* constant folding succeeded */
}
else if (!noop && n == 1 && gen_binop(s, sym, cursp())) {
/* constant folding succeeded */
}
else if (noself){
genop_3(s, blk ? OP_SSENDB : OP_SSEND, cursp(), new_sym(s, sym), n|(nk<<4));
}
else {
genop_3(s, blk ? OP_SENDB : OP_SEND, cursp(), new_sym(s, sym), n|(nk<<4));
}
if (safe) {
dispatch(s, skip);
}
if (val) {
push();
}
}
| 0
|
226,369
|
GF_Err padb_box_size(GF_Box *s)
{
GF_PaddingBitsBox *ptr = (GF_PaddingBitsBox *)s;
ptr->size += 4;
if (ptr->SampleCount) ptr->size += (ptr->SampleCount + 1) / 2;
return GF_OK;
}
| 0
|
230,132
|
static int generate_fake_user_id(json_t * j_params, const char * username, unsigned char * user_id) {
char * seed;
unsigned char seed_hash[32];
size_t seed_hash_len = 32, seed_hash_b64_len;
int ret;
if ((seed = msprintf("%s%s-user_id", username, json_string_value(json_object_get(j_params, "seed")))) != NULL) {
if (generate_digest_raw(digest_SHA256, (unsigned char *)seed, o_strlen(seed), seed_hash, &seed_hash_len)) {
if (o_base64_encode(seed_hash, seed_hash_len, user_id, &seed_hash_b64_len)) {
ret = G_OK;
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "generate_credential_fake_from_seed - Error o_base64_encode");
ret = G_ERROR;
}
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "generate_credential_fake_from_seed - Error generate_digest_raw");
ret = G_ERROR;
}
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "generate_credential_fake_from_seed - Error allocating resources for seed");
ret = G_ERROR_MEMORY;
}
o_free(seed);
return ret;
}
| 0
|
252,397
|
static void WriteAttributeToMemory(std::vector<unsigned char> *out,
const char *name, const char *type,
const unsigned char *data, int len) {
out->insert(out->end(), name, name + strlen(name) + 1);
out->insert(out->end(), type, type + strlen(type) + 1);
int outLen = len;
tinyexr::swap4(reinterpret_cast<unsigned int *>(&outLen));
out->insert(out->end(), reinterpret_cast<unsigned char *>(&outLen),
reinterpret_cast<unsigned char *>(&outLen) + sizeof(int));
out->insert(out->end(), data, data + len);
}
| 0
|
256,391
|
static void bio_copy_kern_endio_read(struct bio *bio)
{
char *p = bio->bi_private;
struct bio_vec *bvec;
struct bvec_iter_all iter_all;
bio_for_each_segment_all(bvec, bio, iter_all) {
memcpy_from_bvec(p, bvec);
p += bvec->bv_len;
}
bio_copy_kern_endio(bio);
}
| 0
|
430,444
|
static int masked_set_action_to_set_action_attr(const struct nlattr *a,
struct sk_buff *skb)
{
const struct nlattr *ovs_key = nla_data(a);
struct nlattr *nla;
size_t key_len = nla_len(ovs_key) / 2;
/* Revert the conversion we did from a non-masked set action to
* masked set action.
*/
nla = nla_nest_start_noflag(skb, OVS_ACTION_ATTR_SET);
if (!nla)
return -EMSGSIZE;
if (nla_put(skb, nla_type(ovs_key), key_len, nla_data(ovs_key)))
return -EMSGSIZE;
nla_nest_end(skb, nla);
return 0;
}
| 0
|
509,566
|
void ha_maria::get_auto_increment(ulonglong offset, ulonglong increment,
ulonglong nb_desired_values,
ulonglong *first_value,
ulonglong *nb_reserved_values)
{
ulonglong nr;
int error;
uchar key[MARIA_MAX_KEY_BUFF];
if (!table->s->next_number_key_offset)
{ // Autoincrement at key-start
ha_maria::info(HA_STATUS_AUTO);
*first_value= stats.auto_increment_value;
/* Maria has only table-level lock for now, so reserves to +inf */
*nb_reserved_values= ULONGLONG_MAX;
return;
}
/* it's safe to call the following if bulk_insert isn't on */
maria_flush_bulk_insert(file, table->s->next_number_index);
(void) extra(HA_EXTRA_KEYREAD);
key_copy(key, table->record[0],
table->key_info + table->s->next_number_index,
table->s->next_number_key_offset);
error= maria_rkey(file, table->record[1], (int) table->s->next_number_index,
key, make_prev_keypart_map(table->s->next_number_keypart),
HA_READ_PREFIX_LAST);
if (error)
nr= 1;
else
{
/* Get data from record[1] */
nr= ((ulonglong) table->next_number_field->
val_int_offset(table->s->rec_buff_length) + 1);
}
extra(HA_EXTRA_NO_KEYREAD);
*first_value= nr;
/*
MySQL needs to call us for next row: assume we are inserting ("a",null)
here, we return 3, and next this statement will want to insert ("b",null):
there is no reason why ("b",3+1) would be the good row to insert: maybe it
already exists, maybe 3+1 is too large...
*/
*nb_reserved_values= 1;
}
| 0
|
353,015
|
issuerAndThisUpdateCheck(
struct berval *in,
struct berval *is,
struct berval *tu,
void *ctx )
{
int numdquotes = 0;
struct berval x = *in;
struct berval ni = BER_BVNULL;
/* Parse GSER format */
enum {
HAVE_NONE = 0x0,
HAVE_ISSUER = 0x1,
HAVE_THISUPDATE = 0x2,
HAVE_ALL = ( HAVE_ISSUER | HAVE_THISUPDATE )
} have = HAVE_NONE;
if ( in->bv_len < STRLENOF( "{issuer \"\",thisUpdate \"YYMMDDhhmmssZ\"}" ) ) return LDAP_INVALID_SYNTAX;
if ( in->bv_val[0] != '{' || in->bv_val[in->bv_len-1] != '}' ) {
return LDAP_INVALID_SYNTAX;
}
x.bv_val++;
x.bv_len -= STRLENOF("{}");
do {
/* eat leading spaces */
for ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {
/* empty */;
}
/* should be at issuer or thisUpdate */
if ( strncasecmp( x.bv_val, "issuer", STRLENOF("issuer") ) == 0 ) {
if ( have & HAVE_ISSUER ) return LDAP_INVALID_SYNTAX;
/* parse issuer */
x.bv_val += STRLENOF("issuer");
x.bv_len -= STRLENOF("issuer");
if ( x.bv_val[0] != ' ' ) return LDAP_INVALID_SYNTAX;
x.bv_val++;
x.bv_len--;
/* eat leading spaces */
for ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {
/* empty */;
}
/* For backward compatibility, this part is optional */
if ( strncasecmp( x.bv_val, "rdnSequence:", STRLENOF("rdnSequence:") ) != 0 ) {
return LDAP_INVALID_SYNTAX;
}
x.bv_val += STRLENOF("rdnSequence:");
x.bv_len -= STRLENOF("rdnSequence:");
if ( x.bv_val[0] != '"' ) return LDAP_INVALID_SYNTAX;
x.bv_val++;
x.bv_len--;
is->bv_val = x.bv_val;
is->bv_len = 0;
for ( ; is->bv_len < x.bv_len; ) {
if ( is->bv_val[is->bv_len] != '"' ) {
is->bv_len++;
continue;
}
if ( is->bv_val[is->bv_len+1] == '"' ) {
/* double dquote */
numdquotes++;
is->bv_len += 2;
continue;
}
break;
}
x.bv_val += is->bv_len + 1;
x.bv_len -= is->bv_len + 1;
have |= HAVE_ISSUER;
} else if ( strncasecmp( x.bv_val, "thisUpdate", STRLENOF("thisUpdate") ) == 0 )
{
if ( have & HAVE_THISUPDATE ) return LDAP_INVALID_SYNTAX;
/* parse thisUpdate */
x.bv_val += STRLENOF("thisUpdate");
x.bv_len -= STRLENOF("thisUpdate");
if ( x.bv_val[0] != ' ' ) return LDAP_INVALID_SYNTAX;
x.bv_val++;
x.bv_len--;
/* eat leading spaces */
for ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {
/* empty */;
}
if ( !x.bv_len || x.bv_val[0] != '"' ) return LDAP_INVALID_SYNTAX;
x.bv_val++;
x.bv_len--;
tu->bv_val = x.bv_val;
tu->bv_len = 0;
for ( ; tu->bv_len < x.bv_len; tu->bv_len++ ) {
if ( tu->bv_val[tu->bv_len] == '"' ) {
break;
}
}
if ( tu->bv_len < STRLENOF("YYYYmmddHHmmssZ") ) return LDAP_INVALID_SYNTAX;
x.bv_val += tu->bv_len + 1;
x.bv_len -= tu->bv_len + 1;
have |= HAVE_THISUPDATE;
} else {
return LDAP_INVALID_SYNTAX;
}
/* eat leading spaces */
for ( ; (x.bv_val[0] == ' ') && x.bv_len; x.bv_val++, x.bv_len-- ) {
/* empty */;
}
if ( have == HAVE_ALL ) {
break;
}
if ( x.bv_val[0] != ',' ) {
return LDAP_INVALID_SYNTAX;
}
x.bv_val++;
x.bv_len--;
} while ( 1 );
/* should have no characters left... */
if ( x.bv_len ) return LDAP_INVALID_SYNTAX;
if ( numdquotes == 0 ) {
ber_dupbv_x( &ni, is, ctx );
} else {
ber_len_t src, dst;
ni.bv_len = is->bv_len - numdquotes;
ni.bv_val = slap_sl_malloc( ni.bv_len + 1, ctx );
for ( src = 0, dst = 0; src < is->bv_len; src++, dst++ ) {
if ( is->bv_val[src] == '"' ) {
src++;
}
ni.bv_val[dst] = is->bv_val[src];
}
ni.bv_val[dst] = '\0';
}
*is = ni;
return 0;
}
| 0
|
247,094
|
Bool gf_fs_solve_js_script(char *szPath, const char *file_name, const char *file_ext)
{
const char *js_dirs;
if (gf_opts_default_shared_directory(szPath)) {
strcat(szPath, "/scripts/jsf/");
GF_LOG(GF_LOG_DEBUG, GF_LOG_FILTER, ("Trying JS filter %s\n", szPath));
if (locate_js_script(szPath, file_name, file_ext)) {
return GF_TRUE;
}
} else {
GF_LOG(GF_LOG_INFO, GF_LOG_FILTER, ("Failed to get default shared dir\n"));
}
js_dirs = gf_opts_get_key("core", "js-dirs");
while (js_dirs && js_dirs[0]) {
char *sep = strchr(js_dirs, ',');
if (sep) {
u32 cplen = (u32) (sep-js_dirs);
if (cplen>=GF_MAX_PATH) cplen = GF_MAX_PATH-1;
strncpy(szPath, js_dirs, cplen);
szPath[cplen]=0;
js_dirs = sep+1;
} else {
strcpy(szPath, js_dirs);
}
if (strcmp(szPath, "$GJS")) {
u32 len = (u32) strlen(szPath);
if (len && (szPath[len-1]!='/') && (szPath[len-1]!='\\'))
strcat(szPath, "/");
GF_LOG(GF_LOG_DEBUG, GF_LOG_FILTER, ("Trying JS filter in %s\n", szPath));
if (locate_js_script(szPath, file_name, file_ext))
return GF_TRUE;
}
if (!sep) break;
}
return GF_FALSE;
}
| 0
|
343,129
|
static int esp_output_tcp_encap_cb(struct net *net, struct sock *sk,
struct sk_buff *skb)
{
struct dst_entry *dst = skb_dst(skb);
struct xfrm_state *x = dst->xfrm;
return esp_output_tcp_finish(x, skb);
}
| 0
|
234,704
|
static void free_fs_devices(struct btrfs_fs_devices *fs_devices)
{
struct btrfs_device *device;
WARN_ON(fs_devices->opened);
while (!list_empty(&fs_devices->devices)) {
device = list_entry(fs_devices->devices.next,
struct btrfs_device, dev_list);
list_del(&device->dev_list);
btrfs_free_device(device);
}
kfree(fs_devices);
}
| 0
|
218,801
|
static void XDrawMatteText(Display *display,const XWindowInfo *window_info,
XWidgetInfo *text_info)
{
const char
*text;
int
n,
x,
y;
int
i;
unsigned int
height,
width;
XFontStruct
*font_info;
XRectangle
crop_info;
/*
Clear the text area.
*/
XSetMatteColor(display,window_info,MagickFalse);
(void) XFillRectangle(display,window_info->id,window_info->widget_context,
text_info->x,text_info->y,text_info->width,text_info->height);
if (text_info->text == (char *) NULL)
return;
XSetTextColor(display,window_info,text_info->highlight);
font_info=window_info->font_info;
x=text_info->x+(QuantumMargin >> 2);
y=text_info->y+font_info->ascent+(text_info->height >> 2);
width=text_info->width-(QuantumMargin >> 1);
height=(unsigned int) (font_info->ascent+font_info->descent);
if (*text_info->text == '\0')
{
/*
No text-- just draw cursor.
*/
(void) XDrawLine(display,window_info->id,window_info->annotate_context,
x,y+3,x,y-height+3);
return;
}
/*
Set cropping region.
*/
crop_info.width=(unsigned short) text_info->width;
crop_info.height=(unsigned short) text_info->height;
crop_info.x=text_info->x;
crop_info.y=text_info->y;
/*
Determine beginning of the visible text.
*/
if (text_info->cursor < text_info->marker)
text_info->marker=text_info->cursor;
else
{
text=text_info->marker;
if (XTextWidth(font_info,(char *) text,(int) (text_info->cursor-text)) >
(int) width)
{
text=text_info->text;
for (i=0; i < Extent(text); i++)
{
n=XTextWidth(font_info,(char *) text+i,(int)
(text_info->cursor-text-i));
if (n <= (int) width)
break;
}
text_info->marker=(char *) text+i;
}
}
/*
Draw text and cursor.
*/
if (text_info->highlight == MagickFalse)
{
(void) XSetClipRectangles(display,window_info->widget_context,0,0,
&crop_info,1,Unsorted);
(void) XDrawString(display,window_info->id,window_info->widget_context,
x,y,text_info->marker,Extent(text_info->marker));
(void) XSetClipMask(display,window_info->widget_context,None);
}
else
{
(void) XSetClipRectangles(display,window_info->annotate_context,0,0,
&crop_info,1,Unsorted);
width=WidgetTextWidth(font_info,text_info->marker);
(void) XFillRectangle(display,window_info->id,
window_info->annotate_context,x,y-font_info->ascent,width,height);
(void) XSetClipMask(display,window_info->annotate_context,None);
(void) XSetClipRectangles(display,window_info->highlight_context,0,0,
&crop_info,1,Unsorted);
(void) XDrawString(display,window_info->id,
window_info->highlight_context,x,y,text_info->marker,
Extent(text_info->marker));
(void) XSetClipMask(display,window_info->highlight_context,None);
}
x+=XTextWidth(font_info,text_info->marker,(int)
(text_info->cursor-text_info->marker));
(void) XDrawLine(display,window_info->id,window_info->annotate_context,x,y+3,
x,y-height+3);
}
| 0
|
246,735
|
u32 parse_cp_loc(char *arg_val, u32 opt)
{
if (!strcmp(arg_val, "both")) cp_location_mode = GF_DASH_CPMODE_BOTH;
else if (!strcmp(arg_val, "as")) cp_location_mode = GF_DASH_CPMODE_ADAPTATION_SET;
else if (!strcmp(arg_val, "rep")) cp_location_mode = GF_DASH_CPMODE_REPRESENTATION;
else {
M4_LOG(GF_LOG_ERROR, ("Unrecognized ContentProtection loction mode \"%s\" - please check usage\n", arg_val));
return 2;
}
return 0;
}
| 0
|
336,680
|
SPICE_GNUC_VISIBLE int spice_server_set_listen_socket_fd(SpiceServer *s, int listen_fd)
{
s->config->spice_listen_socket_fd = listen_fd;
return 0;
}
| 0
|
387,580
|
struct snd_kcontrol *snd_ctl_new1(const struct snd_kcontrol_new *ncontrol,
void *private_data)
{
struct snd_kcontrol *kctl;
unsigned int count;
unsigned int access;
int err;
if (snd_BUG_ON(!ncontrol || !ncontrol->info))
return NULL;
count = ncontrol->count;
if (count == 0)
count = 1;
access = ncontrol->access;
if (access == 0)
access = SNDRV_CTL_ELEM_ACCESS_READWRITE;
access &= (SNDRV_CTL_ELEM_ACCESS_READWRITE |
SNDRV_CTL_ELEM_ACCESS_VOLATILE |
SNDRV_CTL_ELEM_ACCESS_INACTIVE |
SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE |
SNDRV_CTL_ELEM_ACCESS_TLV_COMMAND |
SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK |
SNDRV_CTL_ELEM_ACCESS_LED_MASK |
SNDRV_CTL_ELEM_ACCESS_SKIP_CHECK);
err = snd_ctl_new(&kctl, count, access, NULL);
if (err < 0)
return NULL;
/* The 'numid' member is decided when calling snd_ctl_add(). */
kctl->id.iface = ncontrol->iface;
kctl->id.device = ncontrol->device;
kctl->id.subdevice = ncontrol->subdevice;
if (ncontrol->name) {
strscpy(kctl->id.name, ncontrol->name, sizeof(kctl->id.name));
if (strcmp(ncontrol->name, kctl->id.name) != 0)
pr_warn("ALSA: Control name '%s' truncated to '%s'\n",
ncontrol->name, kctl->id.name);
}
kctl->id.index = ncontrol->index;
kctl->info = ncontrol->info;
kctl->get = ncontrol->get;
kctl->put = ncontrol->put;
kctl->tlv.p = ncontrol->tlv.p;
kctl->private_value = ncontrol->private_value;
kctl->private_data = private_data;
return kctl;
}
| 0
|
512,412
|
Item *get_copy(THD *thd)
{ return get_item_copy<Item_int>(thd, this); }
| 0
|
269,314
|
static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer *sb, IDWTELEM *dst, uint8_t *dst8, const uint8_t *obmc, int src_x, int src_y, int b_w, int b_h, int w, int h, int dst_stride, int src_stride, int obmc_stride, int b_x, int b_y, int add, int offset_dst, int plane_index){
const int b_width = s->b_width << s->block_max_depth;
const int b_height= s->b_height << s->block_max_depth;
const int b_stride= b_width;
BlockNode *lt= &s->block[b_x + b_y*b_stride];
BlockNode *rt= lt+1;
BlockNode *lb= lt+b_stride;
BlockNode *rb= lb+1;
uint8_t *block[4];
int tmp_step= src_stride >= 7*MB_SIZE ? MB_SIZE : MB_SIZE*src_stride;
uint8_t *tmp = s->scratchbuf;
uint8_t *ptmp;
int x,y;
if(b_x<0){
lt= rt;
lb= rb;
}else if(b_x + 1 >= b_width){
rt= lt;
rb= lb;
}
if(b_y<0){
lt= lb;
rt= rb;
}else if(b_y + 1 >= b_height){
lb= lt;
rb= rt;
}
if(src_x<0){ //FIXME merge with prev & always round internal width up to *16
obmc -= src_x;
b_w += src_x;
if(!sliced && !offset_dst)
dst -= src_x;
src_x=0;
}
if(src_x + b_w > w){
b_w = w - src_x;
}
if(src_y<0){
obmc -= src_y*obmc_stride;
b_h += src_y;
if(!sliced && !offset_dst)
dst -= src_y*dst_stride;
src_y=0;
}
if(src_y + b_h> h){
b_h = h - src_y;
}
if(b_w<=0 || b_h<=0) return;
av_assert2(src_stride > 2*MB_SIZE + 5);
if(!sliced && offset_dst)
dst += src_x + src_y*dst_stride;
dst8+= src_x + src_y*src_stride;
// src += src_x + src_y*src_stride;
ptmp= tmp + 3*tmp_step;
block[0]= ptmp;
ptmp+=tmp_step;
ff_snow_pred_block(s, block[0], tmp, src_stride, src_x, src_y, b_w, b_h, lt, plane_index, w, h);
if(same_block(lt, rt)){
block[1]= block[0];
}else{
block[1]= ptmp;
ptmp+=tmp_step;
ff_snow_pred_block(s, block[1], tmp, src_stride, src_x, src_y, b_w, b_h, rt, plane_index, w, h);
}
if(same_block(lt, lb)){
block[2]= block[0];
}else if(same_block(rt, lb)){
block[2]= block[1];
}else{
block[2]= ptmp;
ptmp+=tmp_step;
ff_snow_pred_block(s, block[2], tmp, src_stride, src_x, src_y, b_w, b_h, lb, plane_index, w, h);
}
if(same_block(lt, rb) ){
block[3]= block[0];
}else if(same_block(rt, rb)){
block[3]= block[1];
}else if(same_block(lb, rb)){
block[3]= block[2];
}else{
block[3]= ptmp;
ff_snow_pred_block(s, block[3], tmp, src_stride, src_x, src_y, b_w, b_h, rb, plane_index, w, h);
}
if(sliced){
s->dwt.inner_add_yblock(obmc, obmc_stride, block, b_w, b_h, src_x,src_y, src_stride, sb, add, dst8);
}else{
for(y=0; y<b_h; y++){
//FIXME ugly misuse of obmc_stride
const uint8_t *obmc1= obmc + y*obmc_stride;
const uint8_t *obmc2= obmc1+ (obmc_stride>>1);
const uint8_t *obmc3= obmc1+ obmc_stride*(obmc_stride>>1);
const uint8_t *obmc4= obmc3+ (obmc_stride>>1);
for(x=0; x<b_w; x++){
int v= obmc1[x] * block[3][x + y*src_stride]
+obmc2[x] * block[2][x + y*src_stride]
+obmc3[x] * block[1][x + y*src_stride]
+obmc4[x] * block[0][x + y*src_stride];
v <<= 8 - LOG2_OBMC_MAX;
if(FRAC_BITS != 8){
v >>= 8 - FRAC_BITS;
}
if(add){
v += dst[x + y*dst_stride];
v = (v + (1<<(FRAC_BITS-1))) >> FRAC_BITS;
if(v&(~255)) v= ~(v>>31);
dst8[x + y*src_stride] = v;
}else{
dst[x + y*dst_stride] -= v;
}
}
}
}
}
| 0
|
229,268
|
virtual void visit(const messages::result_message::set_keyspace& m) override {
_response.write_int(0x0003);
_response.write_string(m.get_keyspace());
}
| 0
|
175,774
|
void QuotaManager::DidOriginDataEvicted(
QuotaStatusCode status) {
DCHECK(io_thread_->BelongsToCurrentThread());
if (status != kQuotaStatusOk)
origins_in_error_[eviction_context_.evicted_origin]++;
eviction_context_.evict_origin_data_callback->Run(status);
eviction_context_.evict_origin_data_callback.reset();
}
| 0
|
482,652
|
xt_get_per_cpu_counter(struct xt_counters *cnt, unsigned int cpu)
{
if (nr_cpu_ids > 1)
return per_cpu_ptr((void __percpu *) (unsigned long) cnt->pcnt, cpu);
return cnt;
}
| 0
|
453,043
|
static int nft_flow_offload_chain(struct nft_chain *chain, u8 *ppolicy,
enum flow_block_command cmd)
{
struct nft_base_chain *basechain;
u8 policy;
if (!nft_is_base_chain(chain))
return -EOPNOTSUPP;
basechain = nft_base_chain(chain);
policy = ppolicy ? *ppolicy : basechain->policy;
/* Only default policy to accept is supported for now. */
if (cmd == FLOW_BLOCK_BIND && policy == NF_DROP)
return -EOPNOTSUPP;
return nft_flow_block_chain(basechain, NULL, cmd);
}
| 0
|
271,525
|
Status operator()(OpKernelContext *context, const TensorShape &input_shape,
const TensorShape &output_shape,
typename TTypes<int64>::ConstMatrix input_indices,
typename TTypes<int64>::Matrix output_indices) const {
(void)context; // Unused (only used in GPU implementation)
const int64_t input_rank = input_shape.dims();
const int64_t output_rank = output_shape.dims();
const int64_t nnz = input_indices.dimension(0);
gtl::InlinedVector<int64, 8> input_strides(input_rank);
if (input_rank > 0) {
input_strides[input_rank - 1] = 1;
for (int d = input_rank - 2; d >= 0; --d) {
input_strides[d] = input_strides[d + 1] * input_shape.dim_size(d + 1);
}
}
gtl::InlinedVector<int64, 8> output_strides(output_rank);
if (output_rank > 0) {
output_strides[output_rank - 1] = 1;
for (int d = output_rank - 2; d >= 0; --d) {
output_strides[d] =
output_strides[d + 1] * output_shape.dim_size(d + 1);
}
}
for (int i = 0; i < nnz; ++i) {
int64_t id = 0;
for (int j = 0; j < input_rank; ++j) {
id += input_indices(i, j) * input_strides[j];
}
for (int j = 0; j < output_rank; ++j) {
output_indices(i, j) = id / output_strides[j];
id %= output_strides[j];
}
}
return Status::OK();
}
| 0
|
356,701
|
Napi::Value Statement::Bind(const Napi::CallbackInfo& info) {
Napi::Env env = info.Env();
Statement* stmt = this;
Baton* baton = stmt->Bind<Baton>(info);
if (baton == NULL) {
Napi::TypeError::New(env, "Data type is not supported").ThrowAsJavaScriptException();
return env.Null();
}
else {
stmt->Schedule(Work_BeginBind, baton);
return info.This();
}
}
| 0
|
204,017
|
static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset,
struct inode **i)
{
squashfs_dir_header_3 dirh;
char buffer[sizeof(squashfs_dir_entry_3) + SQUASHFS_NAME_LEN + 1]
__attribute__((aligned));
squashfs_dir_entry_3 *dire = (squashfs_dir_entry_3 *) buffer;
long long start;
int bytes = 0;
int dir_count, size, res;
struct dir_ent *ent, *cur_ent = NULL;
struct dir *dir;
TRACE("squashfs_opendir: inode start block %d, offset %d\n",
block_start, offset);
*i = read_inode(block_start, offset);
dir = malloc(sizeof(struct dir));
if(dir == NULL)
MEM_ERROR();
dir->dir_count = 0;
dir->cur_entry = NULL;
dir->mode = (*i)->mode;
dir->uid = (*i)->uid;
dir->guid = (*i)->gid;
dir->mtime = (*i)->time;
dir->xattr = (*i)->xattr;
dir->dirs = NULL;
if ((*i)->data == 3)
/*
* if the directory is empty, skip the unnecessary
* lookup_entry, this fixes the corner case with
* completely empty filesystems where lookup_entry correctly
* returning -1 is incorrectly treated as an error
*/
return dir;
start = sBlk.s.directory_table_start + (*i)->start;
offset = (*i)->offset;
size = (*i)->data + bytes - 3;
while(bytes < size) {
if(swap) {
squashfs_dir_header_3 sdirh;
res = read_directory_data(&sdirh, &start, &offset, sizeof(sdirh));
if(res)
SQUASHFS_SWAP_DIR_HEADER_3(&dirh, &sdirh);
} else
res = read_directory_data(&dirh, &start, &offset, sizeof(dirh));
if(res == FALSE)
goto corrupted;
dir_count = dirh.count + 1;
TRACE("squashfs_opendir: Read directory header @ byte position "
"%d, %d directory entries\n", bytes, dir_count);
bytes += sizeof(dirh);
/* dir_count should never be larger than SQUASHFS_DIR_COUNT */
if(dir_count > SQUASHFS_DIR_COUNT) {
ERROR("File system corrupted: too many entries in directory\n");
goto corrupted;
}
while(dir_count--) {
if(swap) {
squashfs_dir_entry_3 sdire;
res = read_directory_data(&sdire, &start,
&offset, sizeof(sdire));
if(res)
SQUASHFS_SWAP_DIR_ENTRY_3(dire, &sdire);
} else
res = read_directory_data(dire, &start,
&offset, sizeof(*dire));
if(res == FALSE)
goto corrupted;
bytes += sizeof(*dire);
/* size should never be SQUASHFS_NAME_LEN or larger */
if(dire->size >= SQUASHFS_NAME_LEN) {
ERROR("File system corrupted: filename too long\n");
goto corrupted;
}
res = read_directory_data(dire->name, &start, &offset,
dire->size + 1);
if(res == FALSE)
goto corrupted;
dire->name[dire->size + 1] = '\0';
/* check name for invalid characters (i.e /, ., ..) */
if(check_name(dire->name, dire->size + 1) == FALSE) {
ERROR("File system corrupted: invalid characters in name\n");
goto corrupted;
}
TRACE("squashfs_opendir: directory entry %s, inode "
"%d:%d, type %d\n", dire->name,
dirh.start_block, dire->offset, dire->type);
ent = malloc(sizeof(struct dir_ent));
if(ent == NULL)
MEM_ERROR();
ent->name = strdup(dire->name);
ent->start_block = dirh.start_block;
ent->offset = dire->offset;
ent->type = dire->type;
ent->next = NULL;
if(cur_ent == NULL)
dir->dirs = ent;
else
cur_ent->next = ent;
cur_ent = ent;
dir->dir_count ++;
bytes += dire->size + 1;
}
}
return dir;
corrupted:
squashfs_closedir(dir);
return NULL;
}
| 1
|
462,276
|
static pj_status_t encode_msgint_attr(const void *a, pj_uint8_t *buf,
unsigned len,
const pj_stun_msg_hdr *msghdr,
unsigned *printed)
{
const pj_stun_msgint_attr *ca = (const pj_stun_msgint_attr*)a;
PJ_CHECK_STACK();
PJ_UNUSED_ARG(msghdr);
if (len < 24)
return PJ_ETOOSMALL;
/* Copy and convert attribute to network byte order */
PUTVAL16H(buf, 0, ca->hdr.type);
PUTVAL16H(buf, 2, ca->hdr.length);
pj_memcpy(buf+4, ca->hmac, 20);
/* Done */
*printed = 24;
return PJ_SUCCESS;
}
| 0
|
282,883
|
static int rsi_send_internal_mgmt_frame(struct rsi_common *common,
struct sk_buff *skb)
{
struct skb_info *tx_params;
struct rsi_cmd_desc *desc;
if (skb == NULL) {
rsi_dbg(ERR_ZONE, "%s: Unable to allocate skb\n", __func__);
return -ENOMEM;
}
desc = (struct rsi_cmd_desc *)skb->data;
desc->desc_dword0.len_qno |= cpu_to_le16(DESC_IMMEDIATE_WAKEUP);
skb->priority = MGMT_SOFT_Q;
tx_params = (struct skb_info *)&IEEE80211_SKB_CB(skb)->driver_data;
tx_params->flags |= INTERNAL_MGMT_PKT;
skb_queue_tail(&common->tx_queue[MGMT_SOFT_Q], skb);
rsi_set_event(&common->tx_thread.event);
return 0;
}
| 0
|
221,509
|
apply_exports (char **envp,
const ExportData *exports,
gsize n_exports)
{
int i;
for (i = 0; i < n_exports; i++)
{
const char *value = exports[i].val;
if (value)
envp = g_environ_setenv (envp, exports[i].env, value, TRUE);
else
envp = g_environ_unsetenv (envp, exports[i].env);
}
return envp;
}
| 0
|
393,508
|
static bool _hsort(HSQUIRRELVM v,SQObjectPtr &arr, SQInteger SQ_UNUSED_ARG(l), SQInteger SQ_UNUSED_ARG(r),SQInteger func)
{
SQArray *a = _array(arr);
SQInteger i;
SQInteger array_size = a->Size();
for (i = (array_size / 2); i >= 0; i--) {
if(!_hsort_sift_down(v,a, i, array_size - 1,func)) return false;
}
for (i = array_size-1; i >= 1; i--)
{
_Swap(a->_values[0],a->_values[i]);
if(!_hsort_sift_down(v,a, 0, i-1,func)) return false;
}
return true;
}
| 0
|
221,143
|
GF_Err gf_odf_hevc_cfg_write_bs(GF_HEVCConfig *cfg, GF_BitStream *bs)
{
u32 i, count;
count = gf_list_count(cfg->param_array);
if (!cfg->write_annex_b) {
gf_bs_write_int(bs, cfg->configurationVersion, 8);
if (!cfg->is_lhvc) {
gf_bs_write_int(bs, cfg->profile_space, 2);
gf_bs_write_int(bs, cfg->tier_flag, 1);
gf_bs_write_int(bs, cfg->profile_idc, 5);
gf_bs_write_int(bs, cfg->general_profile_compatibility_flags, 32);
gf_bs_write_int(bs, cfg->progressive_source_flag, 1);
gf_bs_write_int(bs, cfg->interlaced_source_flag, 1);
gf_bs_write_int(bs, cfg->non_packed_constraint_flag, 1);
gf_bs_write_int(bs, cfg->frame_only_constraint_flag, 1);
/*only lowest 44 bits used*/
gf_bs_write_long_int(bs, cfg->constraint_indicator_flags, 44);
gf_bs_write_int(bs, cfg->level_idc, 8);
}
gf_bs_write_int(bs, 0xFF, 4);
gf_bs_write_int(bs, cfg->min_spatial_segmentation_idc, 12);
gf_bs_write_int(bs, 0xFF, 6);
gf_bs_write_int(bs, cfg->parallelismType, 2);
if (!cfg->is_lhvc) {
gf_bs_write_int(bs, 0xFF, 6);
gf_bs_write_int(bs, cfg->chromaFormat, 2);
gf_bs_write_int(bs, 0xFF, 5);
gf_bs_write_int(bs, cfg->luma_bit_depth-8, 3);
gf_bs_write_int(bs, 0xFF, 5);
gf_bs_write_int(bs, cfg->chroma_bit_depth-8, 3);
gf_bs_write_int(bs, cfg->avgFrameRate, 16);
gf_bs_write_int(bs, cfg->constantFrameRate, 2);
} else {
gf_bs_write_int(bs, 0xFF, 2);
}
gf_bs_write_int(bs, cfg->numTemporalLayers, 3);
gf_bs_write_int(bs, cfg->temporalIdNested, 1);
gf_bs_write_int(bs, cfg->nal_unit_size - 1, 2);
gf_bs_write_int(bs, count, 8);
}
for (i=0; i<count; i++) {
u32 nalucount, j;
GF_NALUFFParamArray *ar = (GF_NALUFFParamArray*)gf_list_get(cfg->param_array, i);
nalucount = gf_list_count(ar->nalus);
if (!cfg->write_annex_b) {
gf_bs_write_int(bs, ar->array_completeness, 1);
gf_bs_write_int(bs, 0, 1);
gf_bs_write_int(bs, ar->type, 6);
gf_bs_write_int(bs, nalucount, 16);
}
for (j=0; j<nalucount; j++) {
GF_NALUFFParam *sl = (GF_NALUFFParam *)gf_list_get(ar->nalus, j);
if (!cfg->write_annex_b) {
gf_bs_write_int(bs, sl->size, 16);
} else {
gf_bs_write_u32(bs, 1);
}
gf_bs_write_data(bs, sl->data, sl->size);
}
}
return GF_OK;
}
| 0
|
234,152
|
display_formatted_table (unsigned char *data,
unsigned char *start,
unsigned char *end,
const DWARF2_Internal_LineInfo *linfo,
struct dwarf_section *section,
bool is_dir)
{
unsigned char *format_start, format_count, *format, formati;
dwarf_vma data_count, datai;
unsigned int namepass, last_entry = 0;
const char * table_name = is_dir ? N_("Directory Table") : N_("File Name Table");
SAFE_BYTE_GET_AND_INC (format_count, data, 1, end);
if (do_checks && format_count > 5)
warn (_("Unexpectedly large number of columns in the %s (%u)\n"),
table_name, format_count);
format_start = data;
for (formati = 0; formati < format_count; formati++)
{
SKIP_ULEB (data, end);
SKIP_ULEB (data, end);
if (data >= end)
{
warn (_("%s: Corrupt format description entry\n"), table_name);
return data;
}
}
READ_ULEB (data_count, data, end);
if (data_count == 0)
{
printf (_("\n The %s is empty.\n"), table_name);
return data;
}
else if (data >= end)
{
warn (_("%s: Corrupt entry count - expected %s but none found\n"),
table_name, dwarf_vmatoa ("x", data_count));
return data;
}
else if (format_count == 0)
{
warn (_("%s: format count is zero, but the table is not empty\n"),
table_name);
return end;
}
printf (_("\n The %s (offset 0x%lx, lines %s, columns %u):\n"),
table_name, (long) (data - start), dwarf_vmatoa ("u", data_count),
format_count);
printf (_(" Entry"));
/* Delay displaying name as the last entry for better screen layout. */
for (namepass = 0; namepass < 2; namepass++)
{
format = format_start;
for (formati = 0; formati < format_count; formati++)
{
dwarf_vma content_type;
READ_ULEB (content_type, format, end);
if ((content_type == DW_LNCT_path) == (namepass == 1))
switch (content_type)
{
case DW_LNCT_path:
printf (_("\tName"));
break;
case DW_LNCT_directory_index:
printf (_("\tDir"));
break;
case DW_LNCT_timestamp:
printf (_("\tTime"));
break;
case DW_LNCT_size:
printf (_("\tSize"));
break;
case DW_LNCT_MD5:
printf (_("\tMD5\t\t\t"));
break;
default:
printf (_("\t(Unknown format content type %s)"),
dwarf_vmatoa ("u", content_type));
}
SKIP_ULEB (format, end);
}
}
putchar ('\n');
for (datai = 0; datai < data_count; datai++)
{
unsigned char *datapass = data;
printf (" %d", last_entry++);
/* Delay displaying name as the last entry for better screen layout. */
for (namepass = 0; namepass < 2; namepass++)
{
format = format_start;
data = datapass;
for (formati = 0; formati < format_count; formati++)
{
dwarf_vma content_type, form;
READ_ULEB (content_type, format, end);
READ_ULEB (form, format, end);
data = read_and_display_attr_value (0, form, 0, start, data, end,
0, 0, linfo->li_offset_size,
linfo->li_version, NULL,
((content_type == DW_LNCT_path) != (namepass == 1)),
section, NULL, '\t', -1);
}
}
if (data >= end && (datai < data_count - 1))
{
warn (_("\n%s: Corrupt entries list\n"), table_name);
return data;
}
putchar ('\n');
}
return data;
}
| 0
|
427,738
|
parse_options(const char *data, struct parsed_mount_info *parsed_info)
{
char *value = NULL;
char *equals = NULL;
char *next_keyword = NULL;
char *out = parsed_info->options;
unsigned long *filesys_flags = &parsed_info->flags;
int out_len = 0;
int word_len;
int rc = 0;
int got_bkupuid = 0;
int got_bkupgid = 0;
int got_uid = 0;
int got_cruid = 0;
int got_gid = 0;
int got_snapshot = 0;
uid_t uid, cruid = 0, bkupuid = 0;
gid_t gid, bkupgid = 0;
char *ep;
struct passwd *pw;
struct group *gr;
/*
* max 64-bit uint in decimal is 18446744073709551615 which is 20 chars
* wide +1 for NULL, and +1 for good measure
*/
char txtbuf[22];
unsigned long long snapshot;
struct tm tm;
/* make sure we're starting from beginning */
out[0] = '\0';
/* BB fixme check for separator override BB */
uid = getuid();
if (uid != 0)
got_uid = 1;
gid = getgid();
if (gid != 0)
got_gid = 1;
if (!data)
return EX_USAGE;
/*
* format is keyword,keyword2=value2,keyword3=value3...
* data = next keyword
* value = next value ie stuff after equal sign
*/
while (data && *data) {
next_keyword = strchr(data, ','); /* BB handle sep= */
/* temporarily null terminate end of keyword=value pair */
if (next_keyword)
*next_keyword++ = 0;
/* temporarily null terminate keyword if there's a value */
value = NULL;
if ((equals = strchr(data, '=')) != NULL) {
*equals = '\0';
value = equals + 1;
}
switch(parse_opt_token(data)) {
case OPT_USERS:
if (!value || !*value) {
*filesys_flags |= MS_USERS;
goto nocopy;
}
break;
case OPT_USER:
if (!value || !*value) {
if (data[4] == '\0') {
*filesys_flags |= MS_USER;
goto nocopy;
} else {
fprintf(stderr,
"username specified with no parameter\n");
return EX_USAGE;
}
} else {
strlcpy(parsed_info->username, value,
sizeof(parsed_info->username));
parsed_info->got_user = 1;
goto nocopy;
}
case OPT_PASS:
if (parsed_info->got_password) {
fprintf(stderr,
"password specified twice, ignoring second\n");
goto nocopy;
}
if (!value || !*value) {
parsed_info->got_password = 1;
goto nocopy;
}
rc = set_password(parsed_info, value);
if (rc)
return rc;
goto nocopy;
case OPT_SEC:
if (value) {
if (!strncmp(value, "none", 4) ||
!strncmp(value, "krb5", 4))
parsed_info->got_password = 1;
}
break;
case OPT_IP:
if (!value || !*value) {
fprintf(stderr,
"target ip address argument missing\n");
} else if (strnlen(value, MAX_ADDRESS_LEN) <=
MAX_ADDRESS_LEN) {
strcpy(parsed_info->addrlist, value);
if (parsed_info->verboseflag)
fprintf(stderr,
"ip address %s override specified\n",
value);
goto nocopy;
} else {
fprintf(stderr, "ip address too long\n");
return EX_USAGE;
}
break;
/* unc || target || path */
case OPT_UNC:
if (!value || !*value) {
fprintf(stderr,
"invalid path to network resource\n");
return EX_USAGE;
}
rc = parse_unc(value, parsed_info, thisprogram);
if (rc)
return rc;
break;
/* dom || workgroup */
case OPT_DOM:
if (!value) {
/*
* An empty domain has been passed
*/
/* not necessary but better safe than.. */
parsed_info->domain[0] = '\0';
parsed_info->got_domain = 1;
goto nocopy;
}
if (strnlen(value, sizeof(parsed_info->domain)) >=
sizeof(parsed_info->domain)) {
fprintf(stderr, "domain name too long\n");
return EX_USAGE;
}
strlcpy(parsed_info->domain, value,
sizeof(parsed_info->domain));
goto nocopy;
case OPT_CRED:
if (!value || !*value) {
fprintf(stderr,
"invalid credential file name specified\n");
return EX_USAGE;
}
rc = open_cred_file(value, parsed_info);
if (rc) {
fprintf(stderr,
"error %d (%s) opening credential file %s\n",
rc, strerror(rc), value);
return rc;
}
goto nocopy;
case OPT_UID:
if (!value || !*value)
goto nocopy;
got_uid = 1;
pw = getpwnam(value);
if (pw) {
uid = pw->pw_uid;
goto nocopy;
}
errno = 0;
uid = strtoul(value, &ep, 10);
if (errno == 0 && *ep == '\0')
goto nocopy;
fprintf(stderr, "bad option uid=\"%s\"\n", value);
return EX_USAGE;
case OPT_CRUID:
if (!value || !*value)
goto nocopy;
got_cruid = 1;
pw = getpwnam(value);
if (pw) {
cruid = pw->pw_uid;
goto nocopy;
}
errno = 0;
cruid = strtoul(value, &ep, 10);
if (errno == 0 && *ep == '\0')
goto nocopy;
fprintf(stderr, "bad option: cruid=\"%s\"\n", value);
return EX_USAGE;
case OPT_GID:
if (!value || !*value)
goto nocopy;
got_gid = 1;
gr = getgrnam(value);
if (gr) {
gid = gr->gr_gid;
goto nocopy;
}
errno = 0;
gid = strtoul(value, &ep, 10);
if (errno == 0 && *ep == '\0')
goto nocopy;
fprintf(stderr, "bad option: gid=\"%s\"\n", value);
return EX_USAGE;
/* fmask falls through to file_mode */
case OPT_FMASK:
fprintf(stderr,
"WARNING: CIFS mount option 'fmask' is\
deprecated. Use 'file_mode' instead.\n");
data = "file_mode"; /* BB fix this */
/* Fallthrough */
case OPT_FILE_MODE:
if (!value || !*value) {
fprintf(stderr,
"Option '%s' requires a numerical argument\n",
data);
return EX_USAGE;
}
if (value[0] != '0')
fprintf(stderr,
"WARNING: '%s' not expressed in octal.\n",
data);
break;
/* dmask falls through to dir_mode */
case OPT_DMASK:
fprintf(stderr,
"WARNING: CIFS mount option 'dmask' is\
deprecated. Use 'dir_mode' instead.\n");
data = "dir_mode";
/* Fallthrough */
case OPT_DIR_MODE:
if (!value || !*value) {
fprintf(stderr,
"Option '%s' requires a numerical argument\n",
data);
return EX_USAGE;
}
if (value[0] != '0')
fprintf(stderr,
"WARNING: '%s' not expressed in octal.\n",
data);
break;
case OPT_NO_SUID:
*filesys_flags |= MS_NOSUID;
goto nocopy;
case OPT_SUID:
*filesys_flags &= ~MS_NOSUID;
goto nocopy;
case OPT_NO_DEV:
*filesys_flags |= MS_NODEV;
goto nocopy;
case OPT_NO_LOCK:
*filesys_flags &= ~MS_MANDLOCK;
break;
case OPT_MAND:
*filesys_flags |= MS_MANDLOCK;
goto nocopy;
case OPT_NOMAND:
*filesys_flags &= ~MS_MANDLOCK;
goto nocopy;
case OPT_DEV:
*filesys_flags &= ~MS_NODEV;
goto nocopy;
case OPT_NO_EXEC:
*filesys_flags |= MS_NOEXEC;
goto nocopy;
case OPT_EXEC:
*filesys_flags &= ~MS_NOEXEC;
goto nocopy;
case OPT_GUEST:
parsed_info->got_user = 1;
parsed_info->got_password = 1;
goto nocopy;
case OPT_RO:
*filesys_flags |= MS_RDONLY;
goto nocopy;
case OPT_RW:
*filesys_flags &= ~MS_RDONLY;
goto nocopy;
case OPT_REMOUNT:
*filesys_flags |= MS_REMOUNT;
goto nocopy;
case OPT_IGNORE:
goto nocopy;
case OPT_BKUPUID:
if (!value || !*value)
goto nocopy;
got_bkupuid = 1;
errno = 0;
bkupuid = strtoul(value, &ep, 10);
if (errno == 0 && *ep == '\0')
goto nocopy;
pw = getpwnam(value);
if (pw == NULL) {
fprintf(stderr,
"bad user name \"%s\"\n", value);
return EX_USAGE;
}
bkupuid = pw->pw_uid;
goto nocopy;
case OPT_BKUPGID:
if (!value || !*value)
goto nocopy;
got_bkupgid = 1;
errno = 0;
bkupgid = strtoul(value, &ep, 10);
if (errno == 0 && *ep == '\0')
goto nocopy;
gr = getgrnam(value);
if (gr == NULL) {
fprintf(stderr,
"bad group name \"%s\"\n", value);
return EX_USAGE;
}
bkupgid = gr->gr_gid;
goto nocopy;
case OPT_NOFAIL:
parsed_info->nofail = 1;
goto nocopy;
case OPT_SNAPSHOT:
if (!value || !*value)
goto nocopy;
if (strncmp(value, "@GMT-", 5))
break;
if ((strlen(value) != GMT_NAME_LEN) ||
(strptime(value, GMT_FORMAT, &tm) == NULL)) {
fprintf(stderr, "bad snapshot token\n");
return EX_USAGE;
}
snapshot = timegm(&tm) * 10000000 + NTFS_TIME_OFFSET;
got_snapshot = 1;
goto nocopy;
}
/* check size before copying option to buffer */
word_len = strlen(data);
if (value)
word_len += 1 + strlen(value);
/* need 2 extra bytes for comma and null byte */
if (out_len + word_len + 2 > MAX_OPTIONS_LEN) {
fprintf(stderr, "Options string too long\n");
return EX_USAGE;
}
/* put back equals sign, if any */
if (equals)
*equals = '=';
/* go ahead and copy */
if (out_len)
strlcat(out, ",", MAX_OPTIONS_LEN);
strlcat(out, data, MAX_OPTIONS_LEN);
out_len = strlen(out);
nocopy:
data = next_keyword;
}
/* special-case the uid and gid */
if (got_uid) {
word_len = snprintf(txtbuf, sizeof(txtbuf), "%u", uid);
/* comma + "uid=" + terminating NULL == 6 */
if (out_len + word_len + 6 > MAX_OPTIONS_LEN) {
fprintf(stderr, "Options string too long\n");
return EX_USAGE;
}
if (out_len) {
strlcat(out, ",", MAX_OPTIONS_LEN);
out_len++;
}
snprintf(out + out_len, word_len + 5, "uid=%s", txtbuf);
out_len = strlen(out);
}
if (got_cruid) {
word_len = snprintf(txtbuf, sizeof(txtbuf), "%u", cruid);
/* comma + "cruid=" + terminating NULL == 8 */
if (out_len + word_len + 8 > MAX_OPTIONS_LEN) {
fprintf(stderr, "Options string too long\n");
return EX_USAGE;
}
if (out_len) {
strlcat(out, ",", MAX_OPTIONS_LEN);
out_len++;
}
snprintf(out + out_len, word_len + 7, "cruid=%s", txtbuf);
out_len = strlen(out);
}
if (got_gid) {
word_len = snprintf(txtbuf, sizeof(txtbuf), "%u", gid);
/* comma + "gid=" + terminating NULL == 6 */
if (out_len + word_len + 6 > MAX_OPTIONS_LEN) {
fprintf(stderr, "Options string too long\n");
return EX_USAGE;
}
if (out_len) {
strlcat(out, ",", MAX_OPTIONS_LEN);
out_len++;
}
snprintf(out + out_len, word_len + 5, "gid=%s", txtbuf);
}
if (got_bkupuid) {
word_len = snprintf(txtbuf, sizeof(txtbuf), "%u", bkupuid);
/* comma + "backupuid=" + terminating NULL == 12 */
if (out_len + word_len + 12 > MAX_OPTIONS_LEN) {
fprintf(stderr, "Options string too long\n");
return EX_USAGE;
}
if (out_len) {
strlcat(out, ",", MAX_OPTIONS_LEN);
out_len++;
}
snprintf(out + out_len, word_len + 11, "backupuid=%s", txtbuf);
out_len = strlen(out);
}
if (got_bkupgid) {
word_len = snprintf(txtbuf, sizeof(txtbuf), "%u", bkupgid);
/* comma + "backupgid=" + terminating NULL == 12 */
if (out_len + word_len + 12 > MAX_OPTIONS_LEN) {
fprintf(stderr, "Options string too long\n");
return EX_USAGE;
}
if (out_len) {
strlcat(out, ",", MAX_OPTIONS_LEN);
out_len++;
}
snprintf(out + out_len, word_len + 11, "backupgid=%s", txtbuf);
}
if (got_snapshot) {
word_len = snprintf(txtbuf, sizeof(txtbuf), "%llu", snapshot);
/* comma + "snapshot=" + terminating NULL == 11 */
if (out_len + word_len + 11 > MAX_OPTIONS_LEN) {
fprintf(stderr, "Options string too long\n");
return EX_USAGE;
}
if (out_len) {
strlcat(out, ",", MAX_OPTIONS_LEN);
out_len++;
}
snprintf(out + out_len, word_len + 11, "snapshot=%s", txtbuf);
}
return 0;
}
| 0
|
274,648
|
void callbacks_force_expose_event_for_screen (void)
{
GdkRectangle update_rect;
update_rect.x = 0;
update_rect.y = 0;
update_rect.width = screenRenderInfo.displayWidth;
update_rect.height = screenRenderInfo.displayHeight;
/* Calls expose_event */
gdk_window_invalidate_rect (screen.drawing_area->window, &update_rect, FALSE);
/* update other gui things that could have changed */
callbacks_update_ruler_scales ();
callbacks_update_scrollbar_limits ();
callbacks_update_scrollbar_positions ();
}
| 0
|
229,281
|
cql_server::unadvertise_connection(shared_ptr<generic_server::connection> raw_conn) {
--_stats.connections;
if (auto conn = dynamic_pointer_cast<connection>(raw_conn)) {
const auto ip = conn->get_client_state().get_client_address().addr();
const auto port = conn->get_client_state().get_client_port();
clogger.trace("Advertising disconnection of CQL client {}:{}", ip, port);
}
return make_ready_future<>();
}
| 0
|
512,907
|
longlong Item_func_dyncol_exists::val_int()
{
char buff[STRING_BUFFER_USUAL_SIZE], nmstrbuf[11];
String tmp(buff, sizeof(buff), &my_charset_bin),
nmbuf(nmstrbuf, sizeof(nmstrbuf), system_charset_info);
DYNAMIC_COLUMN col;
String *str;
LEX_STRING buf, *name= NULL;
ulonglong num= 0;
enum enum_dyncol_func_result rc;
if (args[1]->result_type() == INT_RESULT)
num= args[1]->val_int();
else
{
String *nm= args[1]->val_str(&nmbuf);
if (!nm || args[1]->null_value)
{
null_value= 1;
return 1;
}
if (my_charset_same(nm->charset(), DYNCOL_UTF))
{
buf.str= (char *) nm->ptr();
buf.length= nm->length();
}
else
{
uint strlen= nm->length() * DYNCOL_UTF->mbmaxlen + 1;
uint dummy_errors;
buf.str= (char *) current_thd->alloc(strlen);
if (buf.str)
{
buf.length=
copy_and_convert(buf.str, strlen, DYNCOL_UTF,
nm->ptr(), nm->length(), nm->charset(),
&dummy_errors);
}
else
buf.length= 0;
}
name= &buf;
}
str= args[0]->val_str(&tmp);
if (args[0]->null_value || args[1]->null_value || num > UINT_MAX16)
goto null;
col.length= str->length();
/* We do not change the string, so could do this trick */
col.str= (char *)str->ptr();
rc= ((name == NULL) ?
mariadb_dyncol_exists_num(&col, (uint) num) :
mariadb_dyncol_exists_named(&col, name));
if (rc < 0)
{
dynamic_column_error_message(rc);
goto null;
}
null_value= FALSE;
return rc == ER_DYNCOL_YES;
null:
null_value= TRUE;
return 0;
}
| 0
|
253,558
|
get_smb2_acl(struct cifs_sb_info *cifs_sb,
struct inode *inode, const char *path,
u32 *pacllen, u32 info)
{
struct cifs_ntsd *pntsd = NULL;
struct cifsFileInfo *open_file = NULL;
if (inode && !(info & SACL_SECINFO))
open_file = find_readable_file(CIFS_I(inode), true);
if (!open_file || (info & SACL_SECINFO))
return get_smb2_acl_by_path(cifs_sb, path, pacllen, info);
pntsd = get_smb2_acl_by_fid(cifs_sb, &open_file->fid, pacllen, info);
cifsFileInfo_put(open_file);
return pntsd;
}
| 0
|
466,131
|
static int em_push(struct x86_emulate_ctxt *ctxt)
{
struct segmented_address addr;
register_address_increment(ctxt, &ctxt->regs[VCPU_REGS_RSP], -ctxt->op_bytes);
addr.ea = register_address(ctxt, ctxt->regs[VCPU_REGS_RSP]);
addr.seg = VCPU_SREG_SS;
/* Disable writeback. */
ctxt->dst.type = OP_NONE;
return segmented_write(ctxt, addr, &ctxt->src.val, ctxt->op_bytes);
}
| 0
|
450,361
|
static int tight_init_stream(VncState *vs, int stream_id,
int level, int strategy)
{
z_streamp zstream = &vs->tight->stream[stream_id];
if (zstream->opaque == NULL) {
int err;
VNC_DEBUG("VNC: TIGHT: initializing zlib stream %d\n", stream_id);
VNC_DEBUG("VNC: TIGHT: opaque = %p | vs = %p\n", zstream->opaque, vs);
zstream->zalloc = vnc_zlib_zalloc;
zstream->zfree = vnc_zlib_zfree;
err = deflateInit2(zstream, level, Z_DEFLATED, MAX_WBITS,
MAX_MEM_LEVEL, strategy);
if (err != Z_OK) {
fprintf(stderr, "VNC: error initializing zlib\n");
return -1;
}
vs->tight->levels[stream_id] = level;
zstream->opaque = vs;
}
if (vs->tight->levels[stream_id] != level) {
if (deflateParams(zstream, level, strategy) != Z_OK) {
return -1;
}
vs->tight->levels[stream_id] = level;
}
return 0;
}
| 0
|
252,466
|
static mz_bool mz_zip_writer_add_put_buf_callback(const void *pBuf, int len,
void *pUser) {
mz_zip_writer_add_state *pState = (mz_zip_writer_add_state *)pUser;
if ((int)pState->m_pZip->m_pWrite(pState->m_pZip->m_pIO_opaque,
pState->m_cur_archive_file_ofs, pBuf,
len) != len)
return MZ_FALSE;
pState->m_cur_archive_file_ofs += len;
pState->m_comp_size += len;
return MZ_TRUE;
}
| 0
|
337,786
|
struct sctp_chunk *sctp_make_abort_violation(
const struct sctp_association *asoc,
const struct sctp_chunk *chunk,
const __u8 *payload,
const size_t paylen)
{
struct sctp_chunk *retval;
struct sctp_paramhdr phdr;
retval = sctp_make_abort(asoc, chunk, sizeof(struct sctp_errhdr) +
paylen + sizeof(phdr));
if (!retval)
goto end;
sctp_init_cause(retval, SCTP_ERROR_PROTO_VIOLATION, paylen +
sizeof(phdr));
phdr.type = htons(chunk->chunk_hdr->type);
phdr.length = chunk->chunk_hdr->length;
sctp_addto_chunk(retval, paylen, payload);
sctp_addto_param(retval, sizeof(phdr), &phdr);
end:
return retval;
}
| 0
|
309,918
|
my_napms(int ms)
{
if (ms > 0) {
#if defined(_WIN32) || !HAVE_GETTIMEOFDAY
Sleep((DWORD) ms);
#else
struct timeval data;
data.tv_sec = 0;
data.tv_usec = ms * 1000;
select(0, NULL, NULL, NULL, &data);
#endif
}
}
| 0
|
226,035
|
GF_Err dmlp_box_size(GF_Box *s)
{
s->size += 10;
return GF_OK;
| 0
|
247,331
|
int pgpPubKeyCertLen(const uint8_t *pkts, size_t pktslen, size_t *certlen)
{
const uint8_t *p = pkts;
const uint8_t *pend = pkts + pktslen;
struct pgpPkt pkt;
while (p < pend) {
if (decodePkt(p, (pend - p), &pkt))
return -1;
if (pkt.tag == PGPTAG_PUBLIC_KEY && pkts != p) {
*certlen = p - pkts;
return 0;
}
p += (pkt.body - pkt.head) + pkt.blen;
}
*certlen = pktslen;
return 0;
}
| 0
|
366,276
|
static struct mountpoint *get_mountpoint(struct dentry *dentry)
{
struct mountpoint *mp, *new = NULL;
int ret;
if (d_mountpoint(dentry)) {
/* might be worth a WARN_ON() */
if (d_unlinked(dentry))
return ERR_PTR(-ENOENT);
mountpoint:
read_seqlock_excl(&mount_lock);
mp = lookup_mountpoint(dentry);
read_sequnlock_excl(&mount_lock);
if (mp)
goto done;
}
if (!new)
new = kmalloc(sizeof(struct mountpoint), GFP_KERNEL);
if (!new)
return ERR_PTR(-ENOMEM);
/* Exactly one processes may set d_mounted */
ret = d_set_mounted(dentry);
/* Someone else set d_mounted? */
if (ret == -EBUSY)
goto mountpoint;
/* The dentry is not available as a mountpoint? */
mp = ERR_PTR(ret);
if (ret)
goto done;
/* Add the new mountpoint to the hash table */
read_seqlock_excl(&mount_lock);
new->m_dentry = dget(dentry);
new->m_count = 1;
hlist_add_head(&new->m_hash, mp_hash(dentry));
INIT_HLIST_HEAD(&new->m_list);
read_sequnlock_excl(&mount_lock);
mp = new;
new = NULL;
done:
kfree(new);
return mp;
}
| 0
|
231,644
|
TEST_F(QuicServerTransportTest, ReceivePacketAfterLocalError) {
ShortHeader header(
ProtectionType::KeyPhaseZero,
*server->getConn().serverConnectionId,
clientNextAppDataPacketNum++);
RegularQuicPacketBuilder builder(
server->getConn().udpSendPacketLen,
std::move(header),
0 /* largestAcked */);
builder.encodePacketHeader();
ASSERT_TRUE(builder.canBuildPacket());
// Deliver a reset to non existent stream to trigger a local conn error
StreamId streamId = 0x01;
RstStreamFrame rstFrame(streamId, GenericApplicationErrorCode::UNKNOWN, 0);
writeFrame(std::move(rstFrame), builder);
auto packet = std::move(builder).buildPacket();
deliverDataWithoutErrorCheck(packetToBuf(packet));
EXPECT_TRUE(verifyFramePresent(
serverWrites,
*makeClientEncryptedCodec(),
QuicFrame::Type::ConnectionCloseFrame));
serverWrites.clear();
ShortHeader header2(
ProtectionType::KeyPhaseZero,
*server->getConn().serverConnectionId,
clientNextAppDataPacketNum++);
RegularQuicPacketBuilder builder2(
server->getConn().udpSendPacketLen,
std::move(header2),
0 /* largestAcked */);
builder2.encodePacketHeader();
RstStreamFrame rstFrame2(streamId, GenericApplicationErrorCode::UNKNOWN, 0);
writeFrame(std::move(rstFrame2), builder2);
auto packet2 = std::move(builder2).buildPacket();
deliverDataWithoutErrorCheck(packetToBuf(packet2));
EXPECT_TRUE(hasNotReceivedNewPacketsSinceLastCloseSent(server->getConn()));
EXPECT_TRUE(verifyFramePresent(
serverWrites,
*makeClientEncryptedCodec(),
QuicFrame::Type::ConnectionCloseFrame));
}
| 0
|
512,795
|
String *val_str(String*)
{
return (String*) &str_value;
}
| 0
|
226,435
|
string DebugString() const override {
return "SparseTensorSliceDatasetOp::Dataset";
}
| 0
|
427,717
|
cdf_print_elapsed_time(char *buf, size_t bufsiz, cdf_timestamp_t ts)
{
int len = 0;
int days, hours, mins, secs;
ts /= CDF_TIME_PREC;
secs = CAST(int, ts % 60);
ts /= 60;
mins = CAST(int, ts % 60);
ts /= 60;
hours = CAST(int, ts % 24);
ts /= 24;
days = CAST(int, ts);
if (days) {
len += snprintf(buf + len, bufsiz - len, "%dd+", days);
if (CAST(size_t, len) >= bufsiz)
return len;
}
if (days || hours) {
len += snprintf(buf + len, bufsiz - len, "%.2d:", hours);
if (CAST(size_t, len) >= bufsiz)
return len;
}
len += snprintf(buf + len, bufsiz - len, "%.2d:", mins);
if (CAST(size_t, len) >= bufsiz)
return len;
len += snprintf(buf + len, bufsiz - len, "%.2d", secs);
return len;
}
| 0
|
231,022
|
TaskHandle_t xQueueGetMutexHolderFromISR( QueueHandle_t xSemaphore )
{
TaskHandle_t pxReturn;
configASSERT( xSemaphore );
/* Mutexes cannot be used in interrupt service routines, so the mutex
* holder should not change in an ISR, and therefore a critical section is
* not required here. */
if( ( ( Queue_t * ) xSemaphore )->uxQueueType == queueQUEUE_IS_MUTEX )
{
pxReturn = ( ( Queue_t * ) xSemaphore )->u.xSemaphore.xMutexHolder;
}
else
{
pxReturn = NULL;
}
return pxReturn;
} /*lint !e818 xSemaphore cannot be a pointer to const because it is a typedef. */
| 0
|
219,956
|
int callback_glewlwyd_get_client_module_list (const struct _u_request * request, struct _u_response * response, void * client_data) {
UNUSED(request);
struct config_elements * config = (struct config_elements *)client_data;
json_t * j_module;
j_module = get_client_module_list(config);
if (check_result_value(j_module, G_OK)) {
ulfius_set_json_body_response(response, 200, json_object_get(j_module, "module"));
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_get_client_module_list - Error get_client_module_list");
response->status = 500;
}
json_decref(j_module);
return U_CALLBACK_CONTINUE;
}
| 0
|
349,892
|
int hw_atl_utils_mpi_get_link_status(struct aq_hw_s *self)
{
struct aq_hw_link_status_s *link_status = &self->aq_link_status;
u32 mpi_state;
u32 speed;
mpi_state = hw_atl_utils_mpi_get_state(self);
speed = mpi_state >> HW_ATL_MPI_SPEED_SHIFT;
if (!speed) {
link_status->mbps = 0U;
} else {
switch (speed) {
case HAL_ATLANTIC_RATE_10G:
link_status->mbps = 10000U;
break;
case HAL_ATLANTIC_RATE_5G:
case HAL_ATLANTIC_RATE_5GSR:
link_status->mbps = 5000U;
break;
case HAL_ATLANTIC_RATE_2G5:
link_status->mbps = 2500U;
break;
case HAL_ATLANTIC_RATE_1G:
link_status->mbps = 1000U;
break;
case HAL_ATLANTIC_RATE_100M:
link_status->mbps = 100U;
break;
default:
return -EBUSY;
}
}
link_status->full_duplex = true;
return 0;
}
| 0
|
345,127
|
static inline void pxa3xx_gcu_init_debug_timer(struct pxa3xx_gcu_priv *priv) {}
| 0
|
439,148
|
static MagickBooleanType WriteICONImage(const ImageInfo *image_info,
Image *image)
{
const char
*option;
IconFile
icon_file;
IconInfo
icon_info;
Image
*images,
*next;
MagickBooleanType
status;
MagickOffsetType
offset,
scene;
register const IndexPacket
*indexes;
register const PixelPacket
*p;
register ssize_t
i,
x;
register unsigned char
*q;
size_t
bytes_per_line,
imageListLength,
scanline_pad;
ssize_t
y;
unsigned char
bit,
byte,
*pixels;
/*
Open output image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),"%s",image->filename);
status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
if (status == MagickFalse)
return(status);
images=(Image *) NULL;
option=GetImageOption(image_info,"icon:auto-resize");
if (option != (const char *) NULL)
{
images=AutoResizeImage(image,option,&scene,&image->exception);
if (images == (Image *) NULL)
ThrowWriterException(ImageError,"InvalidDimensions");
}
else
{
scene=0;
next=image;
do
{
if ((image->columns > 256L) || (image->rows > 256L))
ThrowWriterException(ImageError,"WidthOrHeightExceedsLimit");
scene++;
next=SyncNextImageInList(next);
} while ((next != (Image *) NULL) && (image_info->adjoin !=
MagickFalse));
}
/*
Dump out a ICON header template to be properly initialized later.
*/
(void) WriteBlobLSBShort(image,0);
(void) WriteBlobLSBShort(image,1);
(void) WriteBlobLSBShort(image,(unsigned char) scene);
(void) memset(&icon_file,0,sizeof(icon_file));
(void) memset(&icon_info,0,sizeof(icon_info));
scene=0;
next=(images != (Image *) NULL) ? images : image;
do
{
(void) WriteBlobByte(image,icon_file.directory[scene].width);
(void) WriteBlobByte(image,icon_file.directory[scene].height);
(void) WriteBlobByte(image,icon_file.directory[scene].colors);
(void) WriteBlobByte(image,icon_file.directory[scene].reserved);
(void) WriteBlobLSBShort(image,icon_file.directory[scene].planes);
(void) WriteBlobLSBShort(image,icon_file.directory[scene].bits_per_pixel);
(void) WriteBlobLSBLong(image,(unsigned int)
icon_file.directory[scene].size);
(void) WriteBlobLSBLong(image,(unsigned int)
icon_file.directory[scene].offset);
scene++;
next=SyncNextImageInList(next);
} while ((next != (Image *) NULL) && (image_info->adjoin != MagickFalse));
scene=0;
next=(images != (Image *) NULL) ? images : image;
imageListLength=GetImageListLength(image);
do
{
if ((next->columns > 255L) && (next->rows > 255L) &&
((next->compression == UndefinedCompression) ||
(next->compression == ZipCompression)))
{
Image
*write_image;
ImageInfo
*write_info;
size_t
length;
unsigned char
*png;
write_image=CloneImage(next,0,0,MagickTrue,&image->exception);
if (write_image == (Image *) NULL)
{
images=DestroyImageList(images);
return(MagickFalse);
}
write_info=CloneImageInfo(image_info);
(void) CopyMagickString(write_info->magick,"PNG",MagickPathExtent);
length=0;
/* Don't write any ancillary chunks except for gAMA */
(void) SetImageArtifact(write_image,"png:include-chunk","none,gama");
/* Only write PNG32 formatted PNG (32-bit RGBA), 8 bits per channel */
(void) SetImageArtifact(write_image,"png:format","png32");
png=(unsigned char *) ImageToBlob(write_info,write_image,&length,
&image->exception);
write_image=DestroyImageList(write_image);
write_info=DestroyImageInfo(write_info);
if (png == (unsigned char *) NULL)
{
images=DestroyImageList(images);
return(MagickFalse);
}
icon_file.directory[scene].width=0;
icon_file.directory[scene].height=0;
icon_file.directory[scene].colors=0;
icon_file.directory[scene].reserved=0;
icon_file.directory[scene].planes=1;
icon_file.directory[scene].bits_per_pixel=32;
icon_file.directory[scene].size=(size_t) length;
icon_file.directory[scene].offset=(size_t) TellBlob(image);
(void) WriteBlob(image,(size_t) length,png);
png=(unsigned char *) RelinquishMagickMemory(png);
}
else
{
/*
Initialize ICON raster file header.
*/
(void) TransformImageColorspace(image,sRGBColorspace);
icon_info.file_size=14+12+28;
icon_info.offset_bits=icon_info.file_size;
icon_info.compression=BI_RGB;
if ((next->storage_class != DirectClass) && (next->colors > 256))
(void) SetImageStorageClass(next,DirectClass);
if (next->storage_class == DirectClass)
{
/*
Full color ICON raster.
*/
icon_info.number_colors=0;
icon_info.bits_per_pixel=32;
icon_info.compression=(size_t) BI_RGB;
}
else
{
size_t
one;
/*
Colormapped ICON raster.
*/
icon_info.bits_per_pixel=8;
if (next->colors <= 256)
icon_info.bits_per_pixel=8;
if (next->colors <= 16)
icon_info.bits_per_pixel=4;
if (next->colors <= 2)
icon_info.bits_per_pixel=1;
one=1;
icon_info.number_colors=one << icon_info.bits_per_pixel;
if (icon_info.number_colors < next->colors)
{
(void) SetImageStorageClass(next,DirectClass);
icon_info.number_colors=0;
icon_info.bits_per_pixel=(unsigned short) 24;
icon_info.compression=(size_t) BI_RGB;
}
else
{
size_t
one;
one=1;
icon_info.file_size+=3*(one << icon_info.bits_per_pixel);
icon_info.offset_bits+=3*(one << icon_info.bits_per_pixel);
icon_info.file_size+=(one << icon_info.bits_per_pixel);
icon_info.offset_bits+=(one << icon_info.bits_per_pixel);
}
}
bytes_per_line=(((next->columns*icon_info.bits_per_pixel)+31) &
~31) >> 3;
icon_info.ba_offset=0;
icon_info.width=(ssize_t) next->columns;
icon_info.height=(ssize_t) next->rows;
icon_info.planes=1;
icon_info.image_size=bytes_per_line*next->rows;
icon_info.size=40;
icon_info.size+=(4*icon_info.number_colors);
icon_info.size+=icon_info.image_size;
icon_info.size+=(((icon_info.width+31) & ~31) >> 3)*icon_info.height;
icon_info.file_size+=icon_info.image_size;
icon_info.x_pixels=0;
icon_info.y_pixels=0;
switch (next->units)
{
case UndefinedResolution:
case PixelsPerInchResolution:
{
icon_info.x_pixels=(size_t) (100.0*next->x_resolution/2.54);
icon_info.y_pixels=(size_t) (100.0*next->y_resolution/2.54);
break;
}
case PixelsPerCentimeterResolution:
{
icon_info.x_pixels=(size_t) (100.0*next->x_resolution);
icon_info.y_pixels=(size_t) (100.0*next->y_resolution);
break;
}
}
icon_info.colors_important=icon_info.number_colors;
/*
Convert MIFF to ICON raster pixels.
*/
pixels=(unsigned char *) AcquireQuantumMemory((size_t)
icon_info.image_size,sizeof(*pixels));
if (pixels == (unsigned char *) NULL)
{
images=DestroyImageList(images);
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
}
(void) memset(pixels,0,(size_t) icon_info.image_size);
switch (icon_info.bits_per_pixel)
{
case 1:
{
size_t
bit,
byte;
/*
Convert PseudoClass image to a ICON monochrome image.
*/
for (y=0; y < (ssize_t) next->rows; y++)
{
p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);
if (p == (const PixelPacket *) NULL)
break;
indexes=GetVirtualIndexQueue(next);
q=pixels+(next->rows-y-1)*bytes_per_line;
bit=0;
byte=0;
for (x=0; x < (ssize_t) next->columns; x++)
{
byte<<=1;
byte|=GetPixelIndex(indexes+x) != 0 ? 0x01 : 0x00;
bit++;
if (bit == 8)
{
*q++=(unsigned char) byte;
bit=0;
byte=0;
}
}
if (bit != 0)
*q++=(unsigned char) (byte << (8-bit));
if (next->previous == (Image *) NULL)
{
status=SetImageProgress(next,SaveImageTag,y,next->rows);
if (status == MagickFalse)
break;
}
}
break;
}
case 4:
{
size_t
nibble,
byte;
/*
Convert PseudoClass image to a ICON monochrome image.
*/
for (y=0; y < (ssize_t) next->rows; y++)
{
p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);
if (p == (const PixelPacket *) NULL)
break;
indexes=GetVirtualIndexQueue(next);
q=pixels+(next->rows-y-1)*bytes_per_line;
nibble=0;
byte=0;
for (x=0; x < (ssize_t) next->columns; x++)
{
byte<<=4;
byte|=((size_t) GetPixelIndex(indexes+x) & 0x0f);
nibble++;
if (nibble == 2)
{
*q++=(unsigned char) byte;
nibble=0;
byte=0;
}
}
if (nibble != 0)
*q++=(unsigned char) (byte << 4);
if (next->previous == (Image *) NULL)
{
status=SetImageProgress(next,SaveImageTag,y,next->rows);
if (status == MagickFalse)
break;
}
}
break;
}
case 8:
{
/*
Convert PseudoClass packet to ICON pixel.
*/
for (y=0; y < (ssize_t) next->rows; y++)
{
p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);
if (p == (const PixelPacket *) NULL)
break;
indexes=GetVirtualIndexQueue(next);
q=pixels+(next->rows-y-1)*bytes_per_line;
for (x=0; x < (ssize_t) next->columns; x++)
*q++=(unsigned char) GetPixelIndex(indexes+x);
if (next->previous == (Image *) NULL)
{
status=SetImageProgress(next,SaveImageTag,y,next->rows);
if (status == MagickFalse)
break;
}
}
break;
}
case 24:
case 32:
{
/*
Convert DirectClass packet to ICON BGR888 or BGRA8888 pixel.
*/
for (y=0; y < (ssize_t) next->rows; y++)
{
p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);
if (p == (const PixelPacket *) NULL)
break;
q=pixels+(next->rows-y-1)*bytes_per_line;
for (x=0; x < (ssize_t) next->columns; x++)
{
*q++=ScaleQuantumToChar(GetPixelBlue(p));
*q++=ScaleQuantumToChar(GetPixelGreen(p));
*q++=ScaleQuantumToChar(GetPixelRed(p));
if (next->matte == MagickFalse)
*q++=ScaleQuantumToChar(QuantumRange);
else
*q++=ScaleQuantumToChar(GetPixelAlpha(p));
p++;
}
if (icon_info.bits_per_pixel == 24)
for (x=3L*(ssize_t) next->columns; x < (ssize_t) bytes_per_line; x++)
*q++=0x00;
if (next->previous == (Image *) NULL)
{
status=SetImageProgress(next,SaveImageTag,y,next->rows);
if (status == MagickFalse)
break;
}
}
break;
}
}
/*
Write 40-byte version 3+ bitmap header.
*/
icon_file.directory[scene].width=(unsigned char) icon_info.width;
icon_file.directory[scene].height=(unsigned char) icon_info.height;
icon_file.directory[scene].colors=(unsigned char)
icon_info.number_colors;
icon_file.directory[scene].reserved=0;
icon_file.directory[scene].planes=icon_info.planes;
icon_file.directory[scene].bits_per_pixel=icon_info.bits_per_pixel;
icon_file.directory[scene].size=icon_info.size;
icon_file.directory[scene].offset=(size_t) TellBlob(image);
(void) WriteBlobLSBLong(image,(unsigned int) 40);
(void) WriteBlobLSBLong(image,(unsigned int) icon_info.width);
(void) WriteBlobLSBLong(image,(unsigned int) icon_info.height*2);
(void) WriteBlobLSBShort(image,icon_info.planes);
(void) WriteBlobLSBShort(image,icon_info.bits_per_pixel);
(void) WriteBlobLSBLong(image,(unsigned int) icon_info.compression);
(void) WriteBlobLSBLong(image,(unsigned int) icon_info.image_size);
(void) WriteBlobLSBLong(image,(unsigned int) icon_info.x_pixels);
(void) WriteBlobLSBLong(image,(unsigned int) icon_info.y_pixels);
(void) WriteBlobLSBLong(image,(unsigned int) icon_info.number_colors);
(void) WriteBlobLSBLong(image,(unsigned int) icon_info.colors_important);
if (next->storage_class == PseudoClass)
{
unsigned char
*icon_colormap;
/*
Dump colormap to file.
*/
icon_colormap=(unsigned char *) AcquireQuantumMemory((size_t)
(1UL << icon_info.bits_per_pixel),4UL*sizeof(*icon_colormap));
if (icon_colormap == (unsigned char *) NULL)
{
images=DestroyImageList(images);
ThrowWriterException(ResourceLimitError,
"MemoryAllocationFailed");
}
q=icon_colormap;
for (i=0; i < (ssize_t) next->colors; i++)
{
*q++=ScaleQuantumToChar(next->colormap[i].blue);
*q++=ScaleQuantumToChar(next->colormap[i].green);
*q++=ScaleQuantumToChar(next->colormap[i].red);
*q++=(unsigned char) 0x0;
}
for ( ; i < (ssize_t) (1UL << icon_info.bits_per_pixel); i++)
{
*q++=(unsigned char) 0x00;
*q++=(unsigned char) 0x00;
*q++=(unsigned char) 0x00;
*q++=(unsigned char) 0x00;
}
(void) WriteBlob(image,(size_t) (4UL*(1UL <<
icon_info.bits_per_pixel)),icon_colormap);
icon_colormap=(unsigned char *) RelinquishMagickMemory(
icon_colormap);
}
(void) WriteBlob(image,(size_t) icon_info.image_size,pixels);
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
/*
Write matte mask.
*/
scanline_pad=(((next->columns+31) & ~31)-next->columns) >> 3;
for (y=((ssize_t) next->rows - 1); y >= 0; y--)
{
p=GetVirtualPixels(next,0,y,next->columns,1,&next->exception);
if (p == (const PixelPacket *) NULL)
break;
bit=0;
byte=0;
for (x=0; x < (ssize_t) next->columns; x++)
{
byte<<=1;
if ((next->matte != MagickFalse) &&
(GetPixelOpacity(p) == (Quantum) TransparentOpacity))
byte|=0x01;
bit++;
if (bit == 8)
{
(void) WriteBlobByte(image,(unsigned char) byte);
bit=0;
byte=0;
}
p++;
}
if (bit != 0)
(void) WriteBlobByte(image,(unsigned char) (byte << (8-bit)));
for (i=0; i < (ssize_t) scanline_pad; i++)
(void) WriteBlobByte(image,(unsigned char) 0);
}
}
if (GetNextImageInList(next) == (Image *) NULL)
break;
status=SetImageProgress(next,SaveImagesTag,scene++,imageListLength);
if (status == MagickFalse)
break;
next=SyncNextImageInList(next);
} while ((next != (Image *) NULL) && (image_info->adjoin != MagickFalse));
offset=SeekBlob(image,0,SEEK_SET);
(void) offset;
(void) WriteBlobLSBShort(image,0);
(void) WriteBlobLSBShort(image,1);
(void) WriteBlobLSBShort(image,(unsigned short) (scene+1));
scene=0;
next=(images != (Image *) NULL) ? images : image;
do
{
(void) WriteBlobByte(image,icon_file.directory[scene].width);
(void) WriteBlobByte(image,icon_file.directory[scene].height);
(void) WriteBlobByte(image,icon_file.directory[scene].colors);
(void) WriteBlobByte(image,icon_file.directory[scene].reserved);
(void) WriteBlobLSBShort(image,icon_file.directory[scene].planes);
(void) WriteBlobLSBShort(image,icon_file.directory[scene].bits_per_pixel);
(void) WriteBlobLSBLong(image,(unsigned int)
icon_file.directory[scene].size);
(void) WriteBlobLSBLong(image,(unsigned int)
icon_file.directory[scene].offset);
scene++;
next=SyncNextImageInList(next);
} while ((next != (Image *) NULL) && (image_info->adjoin != MagickFalse));
(void) CloseBlob(image);
images=DestroyImageList(images);
return(MagickTrue);
}
| 0
|
481,794
|
void qh_deinit(const char *path)
{
struct query_handler *qh = NULL;
for (qh = qhandlers; qh != NULL; qh = qh->next_qh) {
qh_deregister_handler(qh->name);
}
dkhash_destroy(qh_table);
qh_table = NULL;
qhandlers = NULL;
if (path == NULL) {
return;
}
unlink(path);
}
| 0
|
274,713
|
callbacks_window_key_release_event (GtkWidget *widget, GdkEventKey *event)
{
return TRUE;
} /* key_release_event */
| 0
|
263,497
|
static int sco_connect(struct hci_dev *hdev, struct sock *sk)
{
struct sco_conn *conn;
struct hci_conn *hcon;
int err, type;
BT_DBG("%pMR -> %pMR", &sco_pi(sk)->src, &sco_pi(sk)->dst);
if (lmp_esco_capable(hdev) && !disable_esco)
type = ESCO_LINK;
else
type = SCO_LINK;
if (sco_pi(sk)->setting == BT_VOICE_TRANSPARENT &&
(!lmp_transp_capable(hdev) || !lmp_esco_capable(hdev)))
return -EOPNOTSUPP;
hcon = hci_connect_sco(hdev, type, &sco_pi(sk)->dst,
sco_pi(sk)->setting);
if (IS_ERR(hcon))
return PTR_ERR(hcon);
conn = sco_conn_add(hcon);
if (!conn) {
hci_conn_drop(hcon);
return -ENOMEM;
}
/* Update source addr of the socket */
bacpy(&sco_pi(sk)->src, &hcon->src);
err = sco_chan_add(conn, sk, NULL);
if (err)
return err;
if (hcon->state == BT_CONNECTED) {
sco_sock_clear_timer(sk);
sk->sk_state = BT_CONNECTED;
} else {
sk->sk_state = BT_CONNECT;
sco_sock_set_timer(sk, sk->sk_sndtimeo);
}
return err;
}
| 0
|
513,004
|
void cmp_item_decimal::store_value(Item *item)
{
my_decimal *val= item->val_decimal(&value);
/* val may be zero if item is nnull */
if (val && val != &value)
my_decimal2decimal(val, &value);
m_null_value= item->null_value;
}
| 0
|
338,188
|
void WasmBinaryBuilder::readNextDebugLocation() {
if (!sourceMap) {
return;
}
while (nextDebugLocation.first && nextDebugLocation.first <= pos) {
debugLocation.clear();
// use debugLocation only for function expressions
if (currFunction) {
debugLocation.insert(nextDebugLocation.second);
}
char ch;
*sourceMap >> ch;
if (ch == '\"') { // end of records
nextDebugLocation.first = 0;
break;
}
if (ch != ',') {
throw MapParseException("Unexpected delimiter");
}
int32_t positionDelta = readBase64VLQ(*sourceMap);
uint32_t position = nextDebugLocation.first + positionDelta;
int32_t fileIndexDelta = readBase64VLQ(*sourceMap);
uint32_t fileIndex = nextDebugLocation.second.fileIndex + fileIndexDelta;
int32_t lineNumberDelta = readBase64VLQ(*sourceMap);
uint32_t lineNumber = nextDebugLocation.second.lineNumber + lineNumberDelta;
int32_t columnNumberDelta = readBase64VLQ(*sourceMap);
uint32_t columnNumber =
nextDebugLocation.second.columnNumber + columnNumberDelta;
nextDebugLocation = {position, {fileIndex, lineNumber, columnNumber}};
}
}
| 0
|
512,697
|
int cmp_item_timestamp::cmp(Item *arg)
{
THD *thd= current_thd;
Timestamp_or_zero_datetime_native_null tmp(thd, arg, true);
return m_null_value || tmp.is_null() ? UNKNOWN :
type_handler_timestamp2.cmp_native(m_native, tmp) != 0;
}
| 0
|
234,177
|
fetch_indirect_line_string (dwarf_vma offset)
{
struct dwarf_section *section = &debug_displays [line_str].section;
const unsigned char * ret;
if (section->start == NULL)
return (const unsigned char *) _("<no .debug_line_str section>");
if (offset >= section->size)
{
warn (_("DW_FORM_line_strp offset too big: 0x%s\n"),
dwarf_vmatoa ("x", offset));
return (const unsigned char *) _("<offset is too big>");
}
ret = section->start + offset;
/* Unfortunately we cannot rely upon the .debug_line_str section ending
with a NUL byte. Since our caller is expecting to receive a well formed
C string we test for the lack of a terminating byte here. */
if (strnlen ((const char *) ret, section->size - offset)
== section->size - offset)
ret = (const unsigned char *)
_("<no NUL byte at end of .debug_line_str section>");
return ret;
}
| 0
|
313,768
|
reset_VIsual_and_resel(void)
{
if (VIsual_active)
{
end_visual_mode();
redraw_curbuf_later(INVERTED); // delete the inversion later
}
VIsual_reselect = FALSE;
}
| 0
|
225,053
|
parse_connection_string(const char *connstr, PQExpBuffer errorMessage,
bool use_defaults)
{
/* Parse as URI if connection string matches URI prefix */
if (uri_prefix_length(connstr) != 0)
return conninfo_uri_parse(connstr, errorMessage, use_defaults);
/* Parse as default otherwise */
return conninfo_parse(connstr, errorMessage, use_defaults);
}
| 0
|
226,206
|
GF_Err vmhd_box_size(GF_Box *s)
{
GF_VideoMediaHeaderBox *ptr = (GF_VideoMediaHeaderBox *)s;
ptr->size += 8;
return GF_OK;
| 0
|
409,478
|
termcode_star(char_u *code, int len)
{
// Shortest is <M-O>*X. With ; shortest is <CSI>@;*X
if (len >= 3 && code[len - 2] == '*')
{
if (len >= 5 && code[len - 3] == ';')
return 2;
else
return 1;
}
return 0;
}
| 0
|
474,462
|
HandleCoRREBPP (rfbClient* client, int rx, int ry, int rw, int rh)
{
rfbRREHeader hdr;
int i;
CARDBPP pix;
uint8_t *ptr;
int x, y, w, h;
if (!ReadFromRFBServer(client, (char *)&hdr, sz_rfbRREHeader))
return FALSE;
hdr.nSubrects = rfbClientSwap32IfLE(hdr.nSubrects);
if (!ReadFromRFBServer(client, (char *)&pix, sizeof(pix)))
return FALSE;
client->GotFillRect(client, rx, ry, rw, rh, pix);
if (hdr.nSubrects > RFB_BUFFER_SIZE / (4 + (BPP / 8)) || !ReadFromRFBServer(client, client->buffer, hdr.nSubrects * (4 + (BPP / 8))))
return FALSE;
ptr = (uint8_t *)client->buffer;
for (i = 0; i < hdr.nSubrects; i++) {
pix = *(CARDBPP *)ptr;
ptr += BPP/8;
x = *ptr++;
y = *ptr++;
w = *ptr++;
h = *ptr++;
client->GotFillRect(client, rx+x, ry+y, w, h, pix);
}
return TRUE;
}
| 0
|
512,984
|
Item *Item_cond_or::neg_transformer(THD *thd) /* NOT(a OR b OR ...) -> */
/* NOT a AND NOT b AND ... */
{
neg_arguments(thd);
Item *item= new (thd->mem_root) Item_cond_and(thd, list);
return item;
}
| 0
|
277,478
|
uint32_t mobi_get_orth_entry_length(const MOBIIndexEntry *entry) {
uint32_t entry_textlen;
MOBI_RET ret = mobi_get_indxentry_tagvalue(&entry_textlen, entry, INDX_TAG_ORTH_LENGTH);
if (ret != MOBI_SUCCESS) {
return MOBI_NOTSET;
}
return entry_textlen;
}
| 0
|
310,272
|
dirserv_load_fingerprint_file(void)
{
char *fname;
char *cf;
char *nickname, *fingerprint;
authdir_config_t *fingerprint_list_new;
int result;
config_line_t *front=NULL, *list;
or_options_t *options = get_options();
fname = get_datadir_fname("approved-routers");
log_info(LD_GENERAL,
"Reloading approved fingerprints from \"%s\"...", fname);
cf = read_file_to_str(fname, RFTS_IGNORE_MISSING, NULL);
if (!cf) {
if (options->NamingAuthoritativeDir) {
log_warn(LD_FS, "Cannot open fingerprint file '%s'. Failing.", fname);
tor_free(fname);
return -1;
} else {
log_info(LD_FS, "Cannot open fingerprint file '%s'. That's ok.", fname);
tor_free(fname);
return 0;
}
}
tor_free(fname);
result = config_get_lines(cf, &front);
tor_free(cf);
if (result < 0) {
log_warn(LD_CONFIG, "Error reading from fingerprint file");
return -1;
}
fingerprint_list_new = authdir_config_new();
for (list=front; list; list=list->next) {
char digest_tmp[DIGEST_LEN];
nickname = list->key; fingerprint = list->value;
if (strlen(nickname) > MAX_NICKNAME_LEN) {
log_notice(LD_CONFIG,
"Nickname '%s' too long in fingerprint file. Skipping.",
nickname);
continue;
}
if (!is_legal_nickname(nickname) &&
strcasecmp(nickname, "!reject") &&
strcasecmp(nickname, "!invalid") &&
strcasecmp(nickname, "!badexit")) {
log_notice(LD_CONFIG,
"Invalid nickname '%s' in fingerprint file. Skipping.",
nickname);
continue;
}
tor_strstrip(fingerprint, " "); /* remove spaces */
if (strlen(fingerprint) != HEX_DIGEST_LEN ||
base16_decode(digest_tmp, sizeof(digest_tmp),
fingerprint, HEX_DIGEST_LEN) < 0) {
log_notice(LD_CONFIG,
"Invalid fingerprint (nickname '%s', "
"fingerprint %s). Skipping.",
nickname, fingerprint);
continue;
}
if (0==strcasecmp(nickname, DEFAULT_CLIENT_NICKNAME)) {
/* If you approved an OR called "client", then clients who use
* the default nickname could all be rejected. That's no good. */
log_notice(LD_CONFIG,
"Authorizing nickname '%s' would break "
"many clients; skipping.",
DEFAULT_CLIENT_NICKNAME);
continue;
}
if (0==strcasecmp(nickname, UNNAMED_ROUTER_NICKNAME)) {
/* If you approved an OR called "unnamed", then clients will be
* confused. */
log_notice(LD_CONFIG,
"Authorizing nickname '%s' is not allowed; skipping.",
UNNAMED_ROUTER_NICKNAME);
continue;
}
if (add_fingerprint_to_dir(nickname, fingerprint, fingerprint_list_new)
!= 0)
log_notice(LD_CONFIG, "Duplicate nickname '%s'.", nickname);
}
config_free_lines(front);
dirserv_free_fingerprint_list();
fingerprint_list = fingerprint_list_new;
/* Delete any routers whose fingerprints we no longer recognize */
directory_remove_invalid();
return 0;
}
| 0
|
513,112
|
bool Item_func_in::fix_for_row_comparison_using_bisection(THD *thd)
{
if (unlikely(!(array= new (thd->mem_root) in_row(thd, arg_count-1, 0))))
return true;
cmp_item_row *cmp= &((in_row*)array)->tmp;
if (cmp->prepare_comparators(thd, func_name(), this, 0))
return true;
fix_in_vector();
return false;
}
| 0
|
244,002
|
GF_Box *txtc_box_new()
{
ISOM_DECL_BOX_ALLOC(GF_TextConfigBox, GF_ISOM_BOX_TYPE_TXTC);
return (GF_Box *)tmp;
}
| 0
|
225,073
|
PQtransactionStatus(const PGconn *conn)
{
if (!conn || conn->status != CONNECTION_OK)
return PQTRANS_UNKNOWN;
if (conn->asyncStatus != PGASYNC_IDLE)
return PQTRANS_ACTIVE;
return conn->xactStatus;
}
| 0
|
254,873
|
int DocumentSourceGroup::freeMemory() {
invariant(_groups);
int totalMemorySaved = 0;
for (auto&& group : *_groups) {
for (auto&& groupObj : group.second) {
auto prevMemUsage = groupObj->memUsageForSorter();
groupObj->reduceMemoryConsumptionIfAble();
// Update the memory usage for this group.
totalMemorySaved += (prevMemUsage - groupObj->memUsageForSorter());
}
}
return totalMemorySaved;
}
| 0
|
488,419
|
static inline int remap_pmd_range(struct mm_struct *mm, pud_t *pud,
unsigned long addr, unsigned long end,
unsigned long pfn, pgprot_t prot)
{
pmd_t *pmd;
unsigned long next;
pfn -= addr >> PAGE_SHIFT;
pmd = pmd_alloc(mm, pud, addr);
if (!pmd)
return -ENOMEM;
do {
next = pmd_addr_end(addr, end);
if (remap_pte_range(mm, pmd, addr, next,
pfn + (addr >> PAGE_SHIFT), prot))
return -ENOMEM;
} while (pmd++, addr = next, addr != end);
return 0;
}
| 0
|
256,407
|
PJ_DEF(pj_status_t) pjmedia_rtcp_fb_parse_sli(
const void *buf,
pj_size_t length,
unsigned *sli_cnt,
pjmedia_rtcp_fb_sli sli[])
{
pjmedia_rtcp_fb_common *hdr = (pjmedia_rtcp_fb_common*) buf;
pj_uint8_t *p;
unsigned cnt, i;
PJ_ASSERT_RETURN(buf && sli_cnt && sli, PJ_EINVAL);
PJ_ASSERT_RETURN(length >= sizeof(pjmedia_rtcp_fb_common), PJ_ETOOSMALL);
/* PLI uses pt==RTCP_PSFB and FMT==2 */
if (hdr->rtcp_common.pt != RTCP_PSFB || hdr->rtcp_common.count != 2)
return PJ_ENOTFOUND;
cnt = pj_ntohs((pj_uint16_t)hdr->rtcp_common.length) - 2;
if (length < (cnt+3)*4)
return PJ_ETOOSMALL;
*sli_cnt = PJ_MIN(*sli_cnt, cnt);
p = (pj_uint8_t*)hdr + sizeof(*hdr);
for (i = 0; i < *sli_cnt; ++i) {
/* 'first' takes 13 bit */
sli[i].first = (p[0] << 5) + ((p[1] & 0xF8) >> 3);
/* 'number' takes 13 bit */
sli[i].number = ((p[1] & 0x07) << 10) +
(p[2] << 2) +
((p[3] & 0xC0) >> 6);
/* 'pict_id' takes 6 bit */
sli[i].pict_id = (p[3] & 0x3F);
p += 4;
}
return PJ_SUCCESS;
}
| 0
|
432,254
|
static MemoryRegionSection *phys_page_find(AddressSpaceDispatch *d, hwaddr addr)
{
#ifdef TARGET_ARM
struct uc_struct *uc = d->uc;
#endif
PhysPageEntry lp = d->phys_map, *p;
Node *nodes = d->map.nodes;
MemoryRegionSection *sections = d->map.sections;
hwaddr index = addr >> TARGET_PAGE_BITS;
int i;
for (i = P_L2_LEVELS; lp.skip && (i -= lp.skip) >= 0;) {
if (lp.ptr == PHYS_MAP_NODE_NIL) {
return §ions[PHYS_SECTION_UNASSIGNED];
}
p = nodes[lp.ptr];
lp = p[(index >> (i * P_L2_BITS)) & (P_L2_SIZE - 1)];
}
if (section_covers_addr(§ions[lp.ptr], addr)) {
return §ions[lp.ptr];
} else {
return §ions[PHYS_SECTION_UNASSIGNED];
}
}
| 0
|
289,242
|
static inline void snd_pcm_oss_proc_init(struct snd_pcm *pcm)
{
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.