idx
int64
func
string
target
int64
412,330
static Sdb *get_sdb(RzBinFile *bf) { RzBinObject *o = bf->o; if (!o) { return NULL; } QnxObj *qo = o->bin_obj; return qo ? qo->kv : NULL; }
0
197,239
void Compute(OpKernelContext* ctx) override { try { const Tensor& input = ctx->input(kInputTensorIndex); const Tensor& input_min_vec = ctx->input(kInputMinVecIndex); float* input_min_vec_data = (float*)const_cast<void*>( static_cast<const void*>(input_min_vec.flat<float>().data())); const Tensor& input_max_vec = ctx->input(kInputMaxVecIndex); float* input_max_vec_data = (float*)const_cast<void*>( static_cast<const void*>(input_max_vec.flat<float>().data())); const Tensor& input_requested_min = ctx->input(this->kRequestMinIndex); const float input_requested_min_float = input_requested_min.flat<float>()(0); const Tensor& input_requested_max = ctx->input(this->kRequestMaxIndex); const float input_requested_max_float = input_requested_max.flat<float>()(0); size_t depth = input_min_vec.NumElements(); OP_REQUIRES( ctx, input.dims() == 4, errors::InvalidArgument("Current RequantizePerChannel operator" "supports 4D tensors only.")); OP_REQUIRES( ctx, input_min_vec.dim_size(0) == depth, errors::InvalidArgument("input_min has incorrect size, expected ", depth, " was ", input_min_vec.dim_size(0))); OP_REQUIRES( ctx, input_max_vec.dim_size(0) == depth, errors::InvalidArgument("input_max has incorrect size, expected ", depth, " was ", input_max_vec.dim_size(0))); if (out_type_ == DT_QINT8) DCHECK(input_requested_min_float < 0.0f); const float factor = (out_type_ == DT_QINT8) ? 127.0f : 255.0f; const float requested_min_max = std::max(std::abs(input_requested_min_float), std::abs(input_requested_max_float)); Tensor* output = nullptr; OP_REQUIRES_OK(ctx, ctx->allocate_output(kOutputTensorIndex, input.shape(), &output)); std::vector<float> scales(depth); for (int i = 0; i < depth; ++i) { float min_max_from_vec = std::max(std::abs(input_min_vec_data[i]), std::abs(input_max_vec_data[i])); scales[i] = factor * (min_max_from_vec / requested_min_max / static_cast<float>(1L << 31)); } mkldnn::primitive_attr reorder_attr; reorder_attr.set_output_scales(2, scales); memory::dims dims_mkl_order = TFShapeToMklDnnDimsInNCHW(input.shape(), FORMAT_NHWC); memory::desc input_md = memory::desc(dims_mkl_order, MklDnnType<qint32>(), memory::format_tag::nhwc); memory::desc output_md = (out_type_ == DT_QINT8) ? memory::desc(dims_mkl_order, MklDnnType<qint8>(), memory::format_tag::nhwc) : memory::desc(dims_mkl_order, MklDnnType<quint8>(), memory::format_tag::nhwc); void* input_buf = static_cast<void*>(const_cast<qint32*>(input.flat<qint32>().data())); void* output_buf; if (out_type_ == DT_QINT8) { output_buf = static_cast<void*>( const_cast<qint8*>(output->flat<qint8>().data())); } else { output_buf = static_cast<void*>( const_cast<quint8*>(output->flat<quint8>().data())); } std::unique_ptr<memory> input_mem_prim( new memory(input_md, cpu_engine_, input_buf)); std::unique_ptr<memory> output_mem_prim( new memory(output_md, cpu_engine_, output_buf)); mkldnn::reorder::primitive_desc reorder_pd = ReorderPd(cpu_engine_, input_mem_prim->get_desc(), cpu_engine_, output_mem_prim->get_desc(), reorder_attr); std::shared_ptr<stream> reorder_stream; MklDnnThreadPool eigen_tp(ctx); reorder_stream.reset(CreateStream(&eigen_tp, cpu_engine_)); std::unordered_map<int, mkldnn::memory> reorder_args = { {MKLDNN_ARG_FROM, *input_mem_prim}, {MKLDNN_ARG_TO, *output_mem_prim}}; std::unique_ptr<mkldnn::primitive> reorder_prim( new mkldnn::reorder(reorder_pd)); reorder_prim->execute(*reorder_stream, reorder_args); Tensor* output_min = nullptr; Tensor* output_max = nullptr; OP_REQUIRES_OK(ctx, ctx->allocate_output(kOutputMinIndex, {}, &output_min)); OP_REQUIRES_OK(ctx, ctx->allocate_output(kOutputMaxIndex, {}, &output_max)); output_min->flat<float>()(0) = input_requested_min_float; output_max->flat<float>()(0) = input_requested_max_float; } catch (mkldnn::error& e) { string error_msg = "Status: " + std::to_string(e.status) + ", message: " + std::string(e.message) + ", in file " + std::string(__FILE__) + ":" + std::to_string(__LINE__); OP_REQUIRES_OK( ctx, errors::Aborted("Operation received an exception:", error_msg)); } }
1
401,564
static __u32 get_reg(struct fast_pool *f, struct pt_regs *regs) { __u32 *ptr = (__u32 *) regs; unsigned int idx; if (regs == NULL) return 0; idx = READ_ONCE(f->reg_idx); if (idx >= sizeof(struct pt_regs) / sizeof(__u32)) idx = 0; ptr += idx++; WRITE_ONCE(f->reg_idx, idx); return *ptr; }
0
291,838
static int rtrs_clt_ib_dev_init(struct rtrs_ib_dev *dev) { if (!(dev->ib_dev->attrs.device_cap_flags & IB_DEVICE_MEM_MGT_EXTENSIONS)) { pr_err("Memory registrations not supported.\n"); return -ENOTSUPP; } return 0; }
0
225,448
static ssize_t attr_show_format(struct device *cd, struct device_attribute *attr, char *buf) { /* gets the current format as "FOURCC:WxH@f/s", e.g. "YUYV:320x240@1000/30" */ struct v4l2_loopback_device *dev = v4l2loopback_cd2dev(cd); const struct v4l2_fract *tpf; char buf4cc[5], buf_fps[32]; if (!dev || !dev->ready_for_capture) return 0; tpf = &dev->capture_param.timeperframe; fourcc2str(dev->pix_format.pixelformat, buf4cc); buf4cc[4] = 0; if (tpf->numerator == 1) snprintf(buf_fps, sizeof(buf_fps), "%d", tpf->denominator); else snprintf(buf_fps, sizeof(buf_fps), "%d/%d", tpf->denominator, tpf->numerator); return sprintf(buf, "%4s:%dx%d@%s\n", buf4cc, dev->pix_format.width, dev->pix_format.height, buf_fps); }
0
294,471
datetime_s_httpdate(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); if (!NIL_P(opt)) argc--; switch (argc) { case 0: str = rb_str_new2("Mon, 01 Jan -4712 00:00:00 GMT"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; argv2[1] = opt; if (!NIL_P(opt)) argc2++; VALUE hash = date_s__httpdate(argc2, argv2, klass); return dt_new_by_frags(klass, hash, sg); } }
0
462,257
PJ_DEF(pj_status_t) pj_stun_msg_add_attr(pj_stun_msg *msg, pj_stun_attr_hdr *attr) { PJ_ASSERT_RETURN(msg && attr, PJ_EINVAL); PJ_ASSERT_RETURN(msg->attr_count < PJ_STUN_MAX_ATTR, PJ_ETOOMANY); msg->attr[msg->attr_count++] = attr; return PJ_SUCCESS; }
0
195,389
bool RepeatedAttrDefEqual( const protobuf::RepeatedPtrField<OpDef::AttrDef>& a1, const protobuf::RepeatedPtrField<OpDef::AttrDef>& a2) { std::unordered_map<string, const OpDef::AttrDef*> a1_set; for (const OpDef::AttrDef& def : a1) { DCHECK(a1_set.find(def.name()) == a1_set.end()) << "AttrDef names must be unique, but '" << def.name() << "' appears more than once"; a1_set[def.name()] = &def; } for (const OpDef::AttrDef& def : a2) { auto iter = a1_set.find(def.name()); if (iter == a1_set.end()) return false; if (!AttrDefEqual(*iter->second, def)) return false; a1_set.erase(iter); } if (!a1_set.empty()) return false; return true; }
1
484,747
static void xennet_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, u64 * data) { void *np = netdev_priv(dev); int i; for (i = 0; i < ARRAY_SIZE(xennet_stats); i++) data[i] = atomic_read((atomic_t *)(np + xennet_stats[i].offset)); }
0
277,481
uint32_t mobi_get_orth_entry_offset(const MOBIIndexEntry *entry) { uint32_t entry_startpos; MOBI_RET ret = mobi_get_indxentry_tagvalue(&entry_startpos, entry, INDX_TAG_ORTH_POSITION); if (ret != MOBI_SUCCESS) { return MOBI_NOTSET; } return entry_startpos; }
0
252,443
static int rleUncompress(int inLength, int maxLength, const signed char in[], char out[]) { char *outStart = out; while (inLength > 0) { if (*in < 0) { int count = -(static_cast<int>(*in++)); inLength -= count + 1; // Fixes #116: Add bounds check to in buffer. if ((0 > (maxLength -= count)) || (inLength < 0)) return 0; memcpy(out, in, count); out += count; in += count; } else { int count = *in++; inLength -= 2; if (0 > (maxLength -= count + 1)) return 0; memset(out, *reinterpret_cast<const char *>(in), count + 1); out += count + 1; in++; } } return static_cast<int>(out - outStart); }
0
424,923
void iwl_pcie_apm_stop_master(struct iwl_trans *trans) { int ret; /* stop device's busmaster DMA activity */ iwl_set_bit(trans, trans->trans_cfg->csr->addr_sw_reset, BIT(trans->trans_cfg->csr->flag_stop_master)); ret = iwl_poll_bit(trans, trans->trans_cfg->csr->addr_sw_reset, BIT(trans->trans_cfg->csr->flag_master_dis), BIT(trans->trans_cfg->csr->flag_master_dis), 100); if (ret < 0) IWL_WARN(trans, "Master Disable Timed Out, 100 usec\n"); IWL_DEBUG_INFO(trans, "stop master\n"); }
0
310,265
format_versions_list(config_line_t *ln) { smartlist_t *versions; char *result; versions = smartlist_create(); for ( ; ln; ln = ln->next) { smartlist_split_string(versions, ln->value, ",", SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0); } sort_version_list(versions, 1); result = smartlist_join_strings(versions,",",0,NULL); SMARTLIST_FOREACH(versions,char *,s,tor_free(s)); smartlist_free(versions); return result; }
0
234,715
void __exit btrfs_cleanup_fs_uuids(void) { struct btrfs_fs_devices *fs_devices; while (!list_empty(&fs_uuids)) { fs_devices = list_entry(fs_uuids.next, struct btrfs_fs_devices, fs_list); list_del(&fs_devices->fs_list); free_fs_devices(fs_devices); } }
0
400,101
PipeSocketHandler::PipeSocketHandler() {}
0
313,560
void rose_del_loopback_node(const rose_address *address) { struct rose_node *rose_node; spin_lock_bh(&rose_node_list_lock); rose_node = rose_node_list; while (rose_node != NULL) { if ((rose_node->mask == 10) && (rosecmpm(address, &rose_node->address, 10) == 0) && rose_node->loopback) break; rose_node = rose_node->next; } if (rose_node == NULL) goto out; rose_remove_node(rose_node); rose_loopback_neigh->count--; out: spin_unlock_bh(&rose_node_list_lock); }
0
312,418
vgr_jump_to_match( qf_info_T *qi, int forceit, int *redraw_for_dummy, buf_T *first_match_buf, char_u *target_dir) { buf_T *buf; buf = curbuf; qf_jump(qi, 0, 0, forceit); if (buf != curbuf) // If we jumped to another buffer redrawing will already be // taken care of. *redraw_for_dummy = FALSE; // Jump to the directory used after loading the buffer. if (curbuf == first_match_buf && target_dir != NULL) { exarg_T ea; CLEAR_FIELD(ea); ea.arg = target_dir; ea.cmdidx = CMD_lcd; ex_cd(&ea); } }
0
211,699
glob (const char *pattern, int flags, int (*errfunc) (const char *, int), glob_t *pglob) { const char *filename; char *dirname = NULL; size_t dirlen; int status; size_t oldcount; int meta; int dirname_modified; int malloc_dirname = 0; glob_t dirs; int retval = 0; size_t alloca_used = 0; if (pattern == NULL || pglob == NULL || (flags & ~__GLOB_FLAGS) != 0) { __set_errno (EINVAL); return -1; } /* POSIX requires all slashes to be matched. This means that with a trailing slash we must match only directories. */ if (pattern[0] && pattern[strlen (pattern) - 1] == '/') flags |= GLOB_ONLYDIR; if (!(flags & GLOB_DOOFFS)) /* Have to do this so 'globfree' knows where to start freeing. It also makes all the code that uses gl_offs simpler. */ pglob->gl_offs = 0; if (!(flags & GLOB_APPEND)) { pglob->gl_pathc = 0; if (!(flags & GLOB_DOOFFS)) pglob->gl_pathv = NULL; else { size_t i; if (pglob->gl_offs >= ~((size_t) 0) / sizeof (char *)) return GLOB_NOSPACE; pglob->gl_pathv = (char **) malloc ((pglob->gl_offs + 1) * sizeof (char *)); if (pglob->gl_pathv == NULL) return GLOB_NOSPACE; for (i = 0; i <= pglob->gl_offs; ++i) pglob->gl_pathv[i] = NULL; } } if (flags & GLOB_BRACE) { const char *begin; if (flags & GLOB_NOESCAPE) begin = strchr (pattern, '{'); else { begin = pattern; while (1) { if (*begin == '\0') { begin = NULL; break; } if (*begin == '\\' && begin[1] != '\0') ++begin; else if (*begin == '{') break; ++begin; } } if (begin != NULL) { /* Allocate working buffer large enough for our work. Note that we have at least an opening and closing brace. */ size_t firstc; char *alt_start; const char *p; const char *next; const char *rest; size_t rest_len; char *onealt; size_t pattern_len = strlen (pattern) - 1; int alloca_onealt = glob_use_alloca (alloca_used, pattern_len); if (alloca_onealt) onealt = alloca_account (pattern_len, alloca_used); else { onealt = malloc (pattern_len); if (onealt == NULL) return GLOB_NOSPACE; } /* We know the prefix for all sub-patterns. */ alt_start = mempcpy (onealt, pattern, begin - pattern); /* Find the first sub-pattern and at the same time find the rest after the closing brace. */ next = next_brace_sub (begin + 1, flags); if (next == NULL) { /* It is an invalid expression. */ illegal_brace: if (__glibc_unlikely (!alloca_onealt)) free (onealt); flags &= ~GLOB_BRACE; goto no_brace; } /* Now find the end of the whole brace expression. */ rest = next; while (*rest != '}') { rest = next_brace_sub (rest + 1, flags); if (rest == NULL) /* It is an illegal expression. */ goto illegal_brace; } /* Please note that we now can be sure the brace expression is well-formed. */ rest_len = strlen (++rest) + 1; /* We have a brace expression. BEGIN points to the opening {, NEXT points past the terminator of the first element, and END points past the final }. We will accumulate result names from recursive runs for each brace alternative in the buffer using GLOB_APPEND. */ firstc = pglob->gl_pathc; p = begin + 1; while (1) { int result; /* Construct the new glob expression. */ mempcpy (mempcpy (alt_start, p, next - p), rest, rest_len); result = glob (onealt, ((flags & ~(GLOB_NOCHECK | GLOB_NOMAGIC)) | GLOB_APPEND), errfunc, pglob); /* If we got an error, return it. */ if (result && result != GLOB_NOMATCH) { if (__glibc_unlikely (!alloca_onealt)) free (onealt); if (!(flags & GLOB_APPEND)) { globfree (pglob); pglob->gl_pathc = 0; } return result; } if (*next == '}') /* We saw the last entry. */ break; p = next + 1; next = next_brace_sub (p, flags); assert (next != NULL); } if (__glibc_unlikely (!alloca_onealt)) free (onealt); if (pglob->gl_pathc != firstc) /* We found some entries. */ return 0; else if (!(flags & (GLOB_NOCHECK|GLOB_NOMAGIC))) return GLOB_NOMATCH; } } no_brace: oldcount = pglob->gl_pathc + pglob->gl_offs; /* Find the filename. */ filename = strrchr (pattern, '/'); #if defined __MSDOS__ || defined WINDOWS32 /* The case of "d:pattern". Since ':' is not allowed in file names, we can safely assume that wherever it happens in pattern, it signals the filename part. This is so we could some day support patterns like "[a-z]:foo". */ if (filename == NULL) filename = strchr (pattern, ':'); #endif /* __MSDOS__ || WINDOWS32 */ dirname_modified = 0; if (filename == NULL) { /* This can mean two things: a simple name or "~name". The latter case is nothing but a notation for a directory. */ if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && pattern[0] == '~') { dirname = (char *) pattern; dirlen = strlen (pattern); /* Set FILENAME to NULL as a special flag. This is ugly but other solutions would require much more code. We test for this special case below. */ filename = NULL; } else { if (__glibc_unlikely (pattern[0] == '\0')) { dirs.gl_pathv = NULL; goto no_matches; } filename = pattern; dirname = (char *) "."; dirlen = 0; } } else if (filename == pattern || (filename == pattern + 1 && pattern[0] == '\\' && (flags & GLOB_NOESCAPE) == 0)) { /* "/pattern" or "\\/pattern". */ dirname = (char *) "/"; dirlen = 1; ++filename; } else { char *newp; dirlen = filename - pattern; #if defined __MSDOS__ || defined WINDOWS32 if (*filename == ':' || (filename > pattern + 1 && filename[-1] == ':')) { char *drive_spec; ++dirlen; drive_spec = __alloca (dirlen + 1); *((char *) mempcpy (drive_spec, pattern, dirlen)) = '\0'; /* For now, disallow wildcards in the drive spec, to prevent infinite recursion in glob. */ if (__glob_pattern_p (drive_spec, !(flags & GLOB_NOESCAPE))) return GLOB_NOMATCH; /* If this is "d:pattern", we need to copy ':' to DIRNAME as well. If it's "d:/pattern", don't remove the slash from "d:/", since "d:" and "d:/" are not the same.*/ } #endif if (glob_use_alloca (alloca_used, dirlen + 1)) newp = alloca_account (dirlen + 1, alloca_used); else { newp = malloc (dirlen + 1); if (newp == NULL) return GLOB_NOSPACE; malloc_dirname = 1; } *((char *) mempcpy (newp, pattern, dirlen)) = '\0'; dirname = newp; ++filename; #if defined __MSDOS__ || defined WINDOWS32 bool drive_root = (dirlen > 1 && (dirname[dirlen - 1] == ':' || (dirlen > 2 && dirname[dirlen - 2] == ':' && dirname[dirlen - 1] == '/'))); #else bool drive_root = false; #endif if (filename[0] == '\0' && dirlen > 1 && !drive_root) /* "pattern/". Expand "pattern", appending slashes. */ { int orig_flags = flags; if (!(flags & GLOB_NOESCAPE) && dirname[dirlen - 1] == '\\') { /* "pattern\\/". Remove the final backslash if it hasn't been quoted. */ char *p = (char *) &dirname[dirlen - 1]; while (p > dirname && p[-1] == '\\') --p; if ((&dirname[dirlen] - p) & 1) { *(char *) &dirname[--dirlen] = '\0'; flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC); } } int val = glob (dirname, flags | GLOB_MARK, errfunc, pglob); if (val == 0) pglob->gl_flags = ((pglob->gl_flags & ~GLOB_MARK) | (flags & GLOB_MARK)); else if (val == GLOB_NOMATCH && flags != orig_flags) { /* Make sure globfree (&dirs); is a nop. */ dirs.gl_pathv = NULL; flags = orig_flags; oldcount = pglob->gl_pathc + pglob->gl_offs; goto no_matches; } retval = val; goto out; } } if ((flags & (GLOB_TILDE|GLOB_TILDE_CHECK)) && dirname[0] == '~') { if (dirname[1] == '\0' || dirname[1] == '/' || (!(flags & GLOB_NOESCAPE) && dirname[1] == '\\' && (dirname[2] == '\0' || dirname[2] == '/'))) { /* Look up home directory. */ char *home_dir = getenv ("HOME"); int malloc_home_dir = 0; if (home_dir == NULL || home_dir[0] == '\0') { #ifdef WINDOWS32 /* Windows NT defines HOMEDRIVE and HOMEPATH. But give preference to HOME, because the user can change HOME. */ const char *home_drive = getenv ("HOMEDRIVE"); const char *home_path = getenv ("HOMEPATH"); if (home_drive != NULL && home_path != NULL) { size_t home_drive_len = strlen (home_drive); size_t home_path_len = strlen (home_path); char *mem = alloca (home_drive_len + home_path_len + 1); memcpy (mem, home_drive, home_drive_len); memcpy (mem + home_drive_len, home_path, home_path_len + 1); home_dir = mem; } else home_dir = "c:/users/default"; /* poor default */ #else int err; struct passwd *p; struct passwd pwbuf; struct scratch_buffer s; scratch_buffer_init (&s); while (true) { p = NULL; err = __getlogin_r (s.data, s.length); if (err == 0) { # if defined HAVE_GETPWNAM_R || defined _LIBC size_t ssize = strlen (s.data) + 1; err = getpwnam_r (s.data, &pwbuf, s.data + ssize, s.length - ssize, &p); # else p = getpwnam (s.data); if (p == NULL) err = errno; # endif } if (err != ERANGE) break; if (!scratch_buffer_grow (&s)) { retval = GLOB_NOSPACE; goto out; } } if (err == 0) { home_dir = strdup (p->pw_dir); malloc_home_dir = 1; } scratch_buffer_free (&s); if (err == 0 && home_dir == NULL) { retval = GLOB_NOSPACE; goto out; } #endif /* WINDOWS32 */ } if (home_dir == NULL || home_dir[0] == '\0') { if (__glibc_unlikely (malloc_home_dir)) free (home_dir); if (flags & GLOB_TILDE_CHECK) { retval = GLOB_NOMATCH; goto out; } else { home_dir = (char *) "~"; /* No luck. */ malloc_home_dir = 0; } } /* Now construct the full directory. */ if (dirname[1] == '\0') { if (__glibc_unlikely (malloc_dirname)) free (dirname); dirname = home_dir; dirlen = strlen (dirname); malloc_dirname = malloc_home_dir; } else { char *newp; size_t home_len = strlen (home_dir); int use_alloca = glob_use_alloca (alloca_used, home_len + dirlen); if (use_alloca) newp = alloca_account (home_len + dirlen, alloca_used); else { newp = malloc (home_len + dirlen); if (newp == NULL) { if (__glibc_unlikely (malloc_home_dir)) free (home_dir); retval = GLOB_NOSPACE; goto out; } } mempcpy (mempcpy (newp, home_dir, home_len), &dirname[1], dirlen); if (__glibc_unlikely (malloc_dirname)) free (dirname); dirname = newp; dirlen += home_len - 1; malloc_dirname = !use_alloca; if (__glibc_unlikely (malloc_home_dir)) free (home_dir); } dirname_modified = 1; } else { #ifndef WINDOWS32 char *end_name = strchr (dirname, '/'); char *user_name; int malloc_user_name = 0; char *unescape = NULL; if (!(flags & GLOB_NOESCAPE)) { if (end_name == NULL) { unescape = strchr (dirname, '\\'); if (unescape) end_name = strchr (unescape, '\0'); } else unescape = memchr (dirname, '\\', end_name - dirname); } if (end_name == NULL) user_name = dirname + 1; else { char *newp; if (glob_use_alloca (alloca_used, end_name - dirname)) newp = alloca_account (end_name - dirname, alloca_used); else { newp = malloc (end_name - dirname); if (newp == NULL) { retval = GLOB_NOSPACE; goto out; } malloc_user_name = 1; } if (unescape != NULL) { char *p = mempcpy (newp, dirname + 1, unescape - dirname - 1); char *q = unescape; while (*q != '\0') { if (*q == '\\') { if (q[1] == '\0') { /* "~fo\\o\\" unescape to user_name "foo\\", but "~fo\\o\\/" unescape to user_name "foo". */ if (filename == NULL) *p++ = '\\'; break; } ++q; } *p++ = *q++; } *p = '\0'; } else *((char *) mempcpy (newp, dirname + 1, end_name - dirname)) = '\0'; user_name = newp; } /* Look up specific user's home directory. */ { struct passwd *p; struct scratch_buffer pwtmpbuf; scratch_buffer_init (&pwtmpbuf); # if defined HAVE_GETPWNAM_R || defined _LIBC struct passwd pwbuf; while (getpwnam_r (user_name, &pwbuf, pwtmpbuf.data, pwtmpbuf.length, &p) == ERANGE) { if (!scratch_buffer_grow (&pwtmpbuf)) { retval = GLOB_NOSPACE; goto out; } } # else p = getpwnam (user_name); # endif if (__glibc_unlikely (malloc_user_name)) free (user_name); /* If we found a home directory use this. */ if (p != NULL) { size_t home_len = strlen (p->pw_dir); size_t rest_len = end_name == NULL ? 0 : strlen (end_name); char *d; if (__glibc_unlikely (malloc_dirname)) free (dirname); malloc_dirname = 0; if (glob_use_alloca (alloca_used, home_len + rest_len + 1)) dirname = alloca_account (home_len + rest_len + 1, alloca_used); else { dirname = malloc (home_len + rest_len + 1); if (dirname == NULL) { scratch_buffer_free (&pwtmpbuf); retval = GLOB_NOSPACE; goto out; } malloc_dirname = 1; } d = mempcpy (dirname, p->pw_dir, home_len); if (end_name != NULL) d = mempcpy (d, end_name, rest_len); *d = '\0'; dirlen = home_len + rest_len; dirname_modified = 1; } else { if (flags & GLOB_TILDE_CHECK) { /* We have to regard it as an error if we cannot find the home directory. */ retval = GLOB_NOMATCH; goto out; } } scratch_buffer_free (&pwtmpbuf); } #endif /* !WINDOWS32 */ } } /* Now test whether we looked for "~" or "~NAME". In this case we can give the answer now. */ if (filename == NULL) { size_t newcount = pglob->gl_pathc + pglob->gl_offs; char **new_gl_pathv; if (newcount > SIZE_MAX / sizeof (char *) - 2) { nospace: free (pglob->gl_pathv); pglob->gl_pathv = NULL; pglob->gl_pathc = 0; retval = GLOB_NOSPACE; goto out; } new_gl_pathv = realloc (pglob->gl_pathv, (newcount + 2) * sizeof (char *)); if (new_gl_pathv == NULL) goto nospace; pglob->gl_pathv = new_gl_pathv; if (flags & GLOB_MARK && is_dir (dirname, flags, pglob)) { char *p; pglob->gl_pathv[newcount] = malloc (dirlen + 2); if (pglob->gl_pathv[newcount] == NULL) goto nospace; p = mempcpy (pglob->gl_pathv[newcount], dirname, dirlen); p[0] = '/'; p[1] = '\0'; if (__glibc_unlikely (malloc_dirname)) free (dirname); } else { if (__glibc_unlikely (malloc_dirname)) pglob->gl_pathv[newcount] = dirname; else { pglob->gl_pathv[newcount] = strdup (dirname); if (pglob->gl_pathv[newcount] == NULL) goto nospace; } } pglob->gl_pathv[++newcount] = NULL; ++pglob->gl_pathc; pglob->gl_flags = flags; return 0; } meta = __glob_pattern_type (dirname, !(flags & GLOB_NOESCAPE)); /* meta is 1 if correct glob pattern containing metacharacters. If meta has bit (1 << 2) set, it means there was an unterminated [ which we handle the same, using fnmatch. Broken unterminated pattern bracket expressions ought to be rare enough that it is not worth special casing them, fnmatch will do the right thing. */ if (meta & (GLOBPAT_SPECIAL | GLOBPAT_BRACKET)) { /* The directory name contains metacharacters, so we have to glob for the directory, and then glob for the pattern in each directory found. */ size_t i; if (!(flags & GLOB_NOESCAPE) && dirlen > 0 && dirname[dirlen - 1] == '\\') { /* "foo\\/bar". Remove the final backslash from dirname if it has not been quoted. */ char *p = (char *) &dirname[dirlen - 1]; while (p > dirname && p[-1] == '\\') --p; if ((&dirname[dirlen] - p) & 1) *(char *) &dirname[--dirlen] = '\0'; } if (__glibc_unlikely ((flags & GLOB_ALTDIRFUNC) != 0)) { /* Use the alternative access functions also in the recursive call. */ dirs.gl_opendir = pglob->gl_opendir; dirs.gl_readdir = pglob->gl_readdir; dirs.gl_closedir = pglob->gl_closedir; dirs.gl_stat = pglob->gl_stat; dirs.gl_lstat = pglob->gl_lstat; } status = glob (dirname, ((flags & (GLOB_ERR | GLOB_NOESCAPE | GLOB_ALTDIRFUNC)) | GLOB_NOSORT | GLOB_ONLYDIR), errfunc, &dirs); if (status != 0) { if ((flags & GLOB_NOCHECK) == 0 || status != GLOB_NOMATCH) { retval = status; goto out; } goto no_matches; } /* We have successfully globbed the preceding directory name. For each name we found, call glob_in_dir on it and FILENAME, appending the results to PGLOB. */ for (i = 0; i < dirs.gl_pathc; ++i) { size_t old_pathc; old_pathc = pglob->gl_pathc; status = glob_in_dir (filename, dirs.gl_pathv[i], ((flags | GLOB_APPEND) & ~(GLOB_NOCHECK | GLOB_NOMAGIC)), errfunc, pglob, alloca_used); if (status == GLOB_NOMATCH) /* No matches in this directory. Try the next. */ continue; if (status != 0) { globfree (&dirs); globfree (pglob); pglob->gl_pathc = 0; retval = status; goto out; } /* Stick the directory on the front of each name. */ if (prefix_array (dirs.gl_pathv[i], &pglob->gl_pathv[old_pathc + pglob->gl_offs], pglob->gl_pathc - old_pathc)) { globfree (&dirs); globfree (pglob); pglob->gl_pathc = 0; retval = GLOB_NOSPACE; goto out; } } flags |= GLOB_MAGCHAR; /* We have ignored the GLOB_NOCHECK flag in the 'glob_in_dir' calls. But if we have not found any matching entry and the GLOB_NOCHECK flag was set we must return the input pattern itself. */ if (pglob->gl_pathc + pglob->gl_offs == oldcount) { no_matches: /* No matches. */ if (flags & GLOB_NOCHECK) { size_t newcount = pglob->gl_pathc + pglob->gl_offs; char **new_gl_pathv; if (newcount > SIZE_MAX / sizeof (char *) - 2) { nospace2: globfree (&dirs); retval = GLOB_NOSPACE; goto out; } new_gl_pathv = realloc (pglob->gl_pathv, (newcount + 2) * sizeof (char *)); if (new_gl_pathv == NULL) goto nospace2; pglob->gl_pathv = new_gl_pathv; pglob->gl_pathv[newcount] = strdup (pattern); if (pglob->gl_pathv[newcount] == NULL) { globfree (&dirs); globfree (pglob); pglob->gl_pathc = 0; retval = GLOB_NOSPACE; goto out; } ++pglob->gl_pathc; ++newcount; pglob->gl_pathv[newcount] = NULL; pglob->gl_flags = flags; } else { globfree (&dirs); retval = GLOB_NOMATCH; goto out; } } globfree (&dirs); } else { size_t old_pathc = pglob->gl_pathc; int orig_flags = flags; if (meta & GLOBPAT_BACKSLASH) { char *p = strchr (dirname, '\\'), *q; /* We need to unescape the dirname string. It is certainly allocated by alloca, as otherwise filename would be NULL or dirname wouldn't contain backslashes. */ q = p; do { if (*p == '\\') { *q = *++p; --dirlen; } else *q = *p; ++q; } while (*p++ != '\0'); dirname_modified = 1; } if (dirname_modified) flags &= ~(GLOB_NOCHECK | GLOB_NOMAGIC); status = glob_in_dir (filename, dirname, flags, errfunc, pglob, alloca_used); if (status != 0) { if (status == GLOB_NOMATCH && flags != orig_flags && pglob->gl_pathc + pglob->gl_offs == oldcount) { /* Make sure globfree (&dirs); is a nop. */ dirs.gl_pathv = NULL; flags = orig_flags; goto no_matches; } retval = status; goto out; } if (dirlen > 0) { /* Stick the directory on the front of each name. */ if (prefix_array (dirname, &pglob->gl_pathv[old_pathc + pglob->gl_offs], pglob->gl_pathc - old_pathc)) { globfree (pglob); pglob->gl_pathc = 0; retval = GLOB_NOSPACE; goto out; } } } if (flags & GLOB_MARK) { /* Append slashes to directory names. */ size_t i; for (i = oldcount; i < pglob->gl_pathc + pglob->gl_offs; ++i) if (is_dir (pglob->gl_pathv[i], flags, pglob)) { size_t len = strlen (pglob->gl_pathv[i]) + 2; char *new = realloc (pglob->gl_pathv[i], len); if (new == NULL) { globfree (pglob); pglob->gl_pathc = 0; retval = GLOB_NOSPACE; goto out; } strcpy (&new[len - 2], "/"); pglob->gl_pathv[i] = new; } } if (!(flags & GLOB_NOSORT)) { /* Sort the vector. */ qsort (&pglob->gl_pathv[oldcount], pglob->gl_pathc + pglob->gl_offs - oldcount, sizeof (char *), collated_compare); } out: if (__glibc_unlikely (malloc_dirname)) free (dirname); return retval; }
1
222,570
Status GetOpGradientCreator(const string& op, Creator* creator) { auto fac = GetOpGradFactory(); auto iter = fac->find(op); if (iter == fac->end()) { return errors::NotFound("No gradient defined for op: ", op); } *creator = iter->second; return Status::OK(); }
0
509,487
static int table2maria(TABLE *table_arg, data_file_type row_type, MARIA_KEYDEF **keydef_out, MARIA_COLUMNDEF **recinfo_out, uint *records_out, MARIA_CREATE_INFO *create_info) { uint i, j, recpos, minpos, fieldpos, temp_length, length; enum ha_base_keytype type= HA_KEYTYPE_BINARY; uchar *record; KEY *pos; MARIA_KEYDEF *keydef; MARIA_COLUMNDEF *recinfo, *recinfo_pos; HA_KEYSEG *keyseg; TABLE_SHARE *share= table_arg->s; uint options= share->db_options_in_use; DBUG_ENTER("table2maria"); if (row_type == BLOCK_RECORD) options|= HA_OPTION_PACK_RECORD; if (!(my_multi_malloc(PSI_INSTRUMENT_ME, MYF(MY_WME), recinfo_out, (share->fields * 2 + 2) * sizeof(MARIA_COLUMNDEF), keydef_out, share->keys * sizeof(MARIA_KEYDEF), &keyseg, (share->key_parts + share->keys) * sizeof(HA_KEYSEG), NullS))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); /* purecov: inspected */ keydef= *keydef_out; recinfo= *recinfo_out; pos= table_arg->key_info; for (i= 0; i < share->keys; i++, pos++) { keydef[i].flag= (uint16) (pos->flags & (HA_NOSAME | HA_FULLTEXT | HA_SPATIAL)); keydef[i].key_alg= pos->algorithm == HA_KEY_ALG_UNDEF ? (pos->flags & HA_SPATIAL ? HA_KEY_ALG_RTREE : HA_KEY_ALG_BTREE) : pos->algorithm; keydef[i].block_length= pos->block_size; keydef[i].seg= keyseg; keydef[i].keysegs= pos->user_defined_key_parts; for (j= 0; j < pos->user_defined_key_parts; j++) { Field *field= pos->key_part[j].field; if (!table_arg->field[field->field_index]->stored_in_db()) { my_free(*recinfo_out); if (table_arg->s->long_unique_table) { my_error(ER_TOO_LONG_KEY, MYF(0), table_arg->file->max_key_length()); DBUG_RETURN(HA_ERR_INDEX_COL_TOO_LONG); } my_error(ER_KEY_BASED_ON_GENERATED_VIRTUAL_COLUMN, MYF(0)); DBUG_RETURN(HA_ERR_UNSUPPORTED); } type= field->key_type(); keydef[i].seg[j].flag= pos->key_part[j].key_part_flag; if (options & HA_OPTION_PACK_KEYS || (pos->flags & (HA_PACK_KEY | HA_BINARY_PACK_KEY | HA_SPACE_PACK_USED))) { if (pos->key_part[j].length > 8 && (type == HA_KEYTYPE_TEXT || type == HA_KEYTYPE_NUM || (type == HA_KEYTYPE_BINARY && !field->zero_pack()))) { /* No blobs here */ if (j == 0) keydef[i].flag|= HA_PACK_KEY; if (!(field->flags & ZEROFILL_FLAG) && (field->type() == MYSQL_TYPE_STRING || field->type() == MYSQL_TYPE_VAR_STRING || ((int) (pos->key_part[j].length - field->decimals())) >= 4)) keydef[i].seg[j].flag|= HA_SPACE_PACK; } else if (j == 0 && (!(pos->flags & HA_NOSAME) || pos->key_length > 16)) keydef[i].flag|= HA_BINARY_PACK_KEY; } keydef[i].seg[j].type= (int) type; keydef[i].seg[j].start= pos->key_part[j].offset; keydef[i].seg[j].length= pos->key_part[j].length; keydef[i].seg[j].bit_start= keydef[i].seg[j].bit_length= 0; keydef[i].seg[j].bit_pos= 0; keydef[i].seg[j].language= field->charset()->number; if (field->null_ptr) { keydef[i].seg[j].null_bit= field->null_bit; keydef[i].seg[j].null_pos= (uint) (field->null_ptr- (uchar*) table_arg->record[0]); } else { keydef[i].seg[j].null_bit= 0; keydef[i].seg[j].null_pos= 0; } if (field->type() == MYSQL_TYPE_BLOB || field->type() == MYSQL_TYPE_GEOMETRY) { keydef[i].seg[j].flag|= HA_BLOB_PART; /* save number of bytes used to pack length */ keydef[i].seg[j].bit_start= (uint) (field->pack_length() - portable_sizeof_char_ptr); } else if (field->type() == MYSQL_TYPE_BIT) { keydef[i].seg[j].bit_length= ((Field_bit *) field)->bit_len; keydef[i].seg[j].bit_start= ((Field_bit *) field)->bit_ofs; keydef[i].seg[j].bit_pos= (uint) (((Field_bit *) field)->bit_ptr - (uchar*) table_arg->record[0]); } } keyseg+= pos->user_defined_key_parts; } if (table_arg->found_next_number_field) keydef[share->next_number_index].flag|= HA_AUTO_KEY; record= table_arg->record[0]; recpos= 0; recinfo_pos= recinfo; create_info->null_bytes= table_arg->s->null_bytes; while (recpos < (uint) share->stored_rec_length) { Field **field, *found= 0; minpos= share->reclength; length= 0; for (field= table_arg->field; *field; field++) { if ((fieldpos= (*field)->offset(record)) >= recpos && fieldpos <= minpos) { /* skip null fields */ if (!(temp_length= (*field)->pack_length_in_rec())) continue; /* Skip null-fields */ if (! found || fieldpos < minpos || (fieldpos == minpos && temp_length < length)) { minpos= fieldpos; found= *field; length= temp_length; } } } DBUG_PRINT("loop", ("found: %p recpos: %d minpos: %d length: %d", found, recpos, minpos, length)); if (!found) break; if (found->flags & BLOB_FLAG) recinfo_pos->type= FIELD_BLOB; else if (found->type() == MYSQL_TYPE_TIMESTAMP) recinfo_pos->type= FIELD_NORMAL; else if (found->type() == MYSQL_TYPE_VARCHAR) recinfo_pos->type= FIELD_VARCHAR; else if (!(options & HA_OPTION_PACK_RECORD) || (found->zero_pack() && (found->flags & PRI_KEY_FLAG))) recinfo_pos->type= FIELD_NORMAL; else if (found->zero_pack()) recinfo_pos->type= FIELD_SKIP_ZERO; else recinfo_pos->type= ((length <= 3 || (found->flags & ZEROFILL_FLAG)) ? FIELD_NORMAL : found->type() == MYSQL_TYPE_STRING || found->type() == MYSQL_TYPE_VAR_STRING ? FIELD_SKIP_ENDSPACE : FIELD_SKIP_PRESPACE); if (found->null_ptr) { recinfo_pos->null_bit= found->null_bit; recinfo_pos->null_pos= (uint) (found->null_ptr - (uchar*) table_arg->record[0]); } else { recinfo_pos->null_bit= 0; recinfo_pos->null_pos= 0; } (recinfo_pos++)->length= (uint16) length; recpos= minpos + length; DBUG_PRINT("loop", ("length: %d type: %d", recinfo_pos[-1].length,recinfo_pos[-1].type)); } *records_out= (uint) (recinfo_pos - recinfo); DBUG_RETURN(0); }
0
366,167
static struct mountpoint *unhash_mnt(struct mount *mnt) { struct mountpoint *mp; mnt->mnt_parent = mnt; mnt->mnt_mountpoint = mnt->mnt.mnt_root; list_del_init(&mnt->mnt_child); hlist_del_init_rcu(&mnt->mnt_hash); hlist_del_init(&mnt->mnt_mp_list); mp = mnt->mnt_mp; mnt->mnt_mp = NULL; return mp; }
0
418,776
get_fpos_of_mouse(pos_T *mpos) { win_T *wp; int row = mouse_row; int col = mouse_col; if (row < 0 || col < 0) // check if it makes sense return IN_UNKNOWN; // find the window where the row is in wp = mouse_find_win(&row, &col, FAIL_POPUP); if (wp == NULL) return IN_UNKNOWN; // winpos and height may change in win_enter()! if (row >= wp->w_height) // In (or below) status line return IN_STATUS_LINE; if (col >= wp->w_width) // In vertical separator line return IN_SEP_LINE; if (wp != curwin) return IN_UNKNOWN; // compute the position in the buffer line from the posn on the screen if (mouse_comp_pos(curwin, &row, &col, &mpos->lnum, NULL)) return IN_STATUS_LINE; // past bottom mpos->col = vcol2col(wp, mpos->lnum, col); if (mpos->col > 0) --mpos->col; mpos->coladd = 0; return IN_BUFFER; }
0
348,436
static unsigned short calc_crc_flex(unsigned char *cp, int size) { unsigned short crc = 0xffff; while (size--) crc = (crc << 8) ^ crc_flex_table[((crc >> 8) ^ *cp++) & 0xff]; return crc; }
0
450,817
is_dir (char const *filename, int flags, glob_t const *pglob) { struct stat st; struct_stat64 st64; return (__glibc_unlikely (flags & GLOB_ALTDIRFUNC) ? pglob->gl_stat (filename, &st) == 0 && S_ISDIR (st.st_mode) : __stat64 (filename, &st64) == 0 && S_ISDIR (st64.st_mode)); }
0
246,432
static void free_import_entry(RBinWasmImportEntry *entry) { if (entry) { free (entry->module_str); free (entry->field_str); free (entry); } }
0
448,555
void bgp_notify_send(struct peer *peer, uint8_t code, uint8_t sub_code) { bgp_notify_send_with_data(peer, code, sub_code, NULL, 0); }
0
254,063
query_string(std::string params, bool url = true): url_(std::move(params)) { if (url_.empty()) return; key_value_pairs_.resize(MAX_KEY_VALUE_PAIRS_COUNT); int count = qs_parse(&url_[0], &key_value_pairs_[0], MAX_KEY_VALUE_PAIRS_COUNT, url); key_value_pairs_.resize(count); }
0
384,904
vim_isodigit(int c) { return (c >= '0' && c <= '7'); }
0
522,330
int APIF77(gmfstatkwd)( int64_t *MshIdx, int *KwdIdx, int *NmbTyp, int *SolSiz, int *TypTab, int *deg, int *NmbNod) { if(!strcmp(GmfKwdFmt[ *KwdIdx ][2], "hr")) return(GmfStatKwd(*MshIdx, *KwdIdx, NmbTyp, SolSiz, TypTab, deg, NmbNod)); else if(!strcmp(GmfKwdFmt[ *KwdIdx ][2], "sr")) return(GmfStatKwd(*MshIdx, *KwdIdx, NmbTyp, SolSiz, TypTab)); else return(GmfStatKwd(*MshIdx, *KwdIdx)); }
0
264,243
static void vnc_write_pixels_generic(VncState *vs, void *pixels1, int size) { uint8_t buf[4]; if (VNC_SERVER_FB_BYTES == 4) { uint32_t *pixels = pixels1; int n, i; n = size >> 2; for (i = 0; i < n; i++) { vnc_convert_pixel(vs, buf, pixels[i]); vnc_write(vs, buf, vs->client_pf.bytes_per_pixel); } } }
0
317,003
static int smack_sem_semctl(struct kern_ipc_perm *isp, int cmd) { int may; switch (cmd) { case GETPID: case GETNCNT: case GETZCNT: case GETVAL: case GETALL: case IPC_STAT: case SEM_STAT: case SEM_STAT_ANY: may = MAY_READ; break; case SETVAL: case SETALL: case IPC_RMID: case IPC_SET: may = MAY_READWRITE; break; case IPC_INFO: case SEM_INFO: /* * System level information */ return 0; default: return -EINVAL; } return smk_curacc_sem(isp, may); }
0
219,030
Status ConstantFolding::SimplifyTile(const GraphProperties& properties, bool use_shape_info, GraphDef* optimized_graph, NodeDef* node) { Tensor multiplies; if (use_shape_info && IsTile(*node) && GetTensorFromConstNode(node->input(1), &multiplies)) { // The node is replaceable iff all values in multiplies are 1. bool replaceable = true; if (multiplies.dtype() == DT_INT32) { for (int j = 0; replaceable && j < multiplies.vec<int>().size(); ++j) { replaceable &= multiplies.vec<int>()(j) == 1; } } else { for (int j = 0; replaceable && j < multiplies.vec<int64_t>().size(); ++j) { replaceable &= multiplies.vec<int64_t>()(j) == 1; } } if (replaceable) { ReplaceOperationWithIdentity(0, properties, node, optimized_graph); } } return Status::OK(); }
0
214,124
lzw_result lzw_decode(struct lzw_ctx *ctx, const uint8_t ** const stack_pos_out) { lzw_result res; uint32_t code_new; uint32_t code_out; uint8_t last_value; uint8_t *stack_pos = ctx->stack_base; uint32_t clear_code = ctx->clear_code; uint32_t current_entry = ctx->current_entry; struct lzw_dictionary_entry * const table = ctx->table; /* Get a new code from the input */ res = lzw__next_code(&ctx->input, ctx->current_code_size, &code_new); if (res != LZW_OK) { return res; } /* Handle the new code */ if (code_new == clear_code) { /* Got Clear code */ return lzw__clear_codes(ctx, stack_pos_out); } else if (code_new == ctx->eoi_code) { /* Got End of Information code */ return LZW_EOI_CODE; } else if (code_new > current_entry) { /* Code is invalid */ return LZW_BAD_CODE; } else if (code_new < current_entry) { /* Code is in table */ code_out = code_new; last_value = table[code_new].first_value; } else { /* Code not in table */ *stack_pos++ = ctx->previous_code_first; code_out = ctx->previous_code; last_value = ctx->previous_code_first; } /* Add to the dictionary, only if there's space */ if (current_entry < (1 << LZW_CODE_MAX)) { struct lzw_dictionary_entry *entry = table + current_entry; entry->last_value = last_value; entry->first_value = ctx->previous_code_first; entry->previous_entry = ctx->previous_code; ctx->current_entry++; } /* Ensure code size is increased, if needed. */ if (current_entry == ctx->current_code_size_max) { if (ctx->current_code_size < LZW_CODE_MAX) { ctx->current_code_size++; ctx->current_code_size_max = (1 << ctx->current_code_size) - 1; } } /* Store details of this code as "previous code" to the context. */ ctx->previous_code_first = table[code_new].first_value; ctx->previous_code = code_new; /* Put rest of data for this code on output stack. * Note, in the case of "code not in table", the last entry of the * current code has already been placed on the stack above. */ while (code_out > clear_code) { struct lzw_dictionary_entry *entry = table + code_out; *stack_pos++ = entry->last_value; code_out = entry->previous_entry; } *stack_pos++ = table[code_out].last_value; *stack_pos_out = stack_pos; return LZW_OK; }
1
214,282
R_API RBinJavaAttrInfo *r_bin_java_inner_classes_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) { RBinJavaClassesAttribute *icattr; RBinJavaAttrInfo *attr = NULL; RBinJavaCPTypeObj *obj; ut32 i = 0; ut64 offset = 0, curpos; attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset); offset += 6; if (attr == NULL) { // TODO eprintf return attr; } attr->type = R_BIN_JAVA_ATTR_TYPE_INNER_CLASSES_ATTR; attr->info.inner_classes_attr.number_of_classes = R_BIN_JAVA_USHORT (buffer, offset); offset += 2; attr->info.inner_classes_attr.classes = r_list_newf (r_bin_java_inner_classes_attr_entry_free); for (i = 0; i < attr->info.inner_classes_attr.number_of_classes; i++) { curpos = buf_offset + offset; if (offset + 8 > sz) { eprintf ("Invalid amount of inner classes\n"); break; } icattr = R_NEW0 (RBinJavaClassesAttribute); if (!icattr) { break; } icattr->inner_class_info_idx = R_BIN_JAVA_USHORT (buffer, offset); offset += 2; icattr->outer_class_info_idx = R_BIN_JAVA_USHORT (buffer, offset); offset += 2; icattr->inner_name_idx = R_BIN_JAVA_USHORT (buffer, offset); offset += 2; icattr->inner_class_access_flags = R_BIN_JAVA_USHORT (buffer, offset); offset += 2; icattr->flags_str = retrieve_class_method_access_string (icattr->inner_class_access_flags); icattr->file_offset = curpos; icattr->size = 8; obj = r_bin_java_get_item_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, icattr->inner_name_idx); if (obj == NULL) { eprintf ("BINCPLIS IS HULL %d\n", icattr->inner_name_idx); } icattr->name = r_bin_java_get_item_name_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, obj); if (!icattr->name) { obj = r_bin_java_get_item_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, icattr->inner_class_info_idx); if (!obj) { eprintf ("BINCPLIST IS NULL %d\n", icattr->inner_class_info_idx); } icattr->name = r_bin_java_get_item_name_from_bin_cp_list (R_BIN_JAVA_GLOBAL_BIN, obj); if (!icattr->name) { icattr->name = r_str_dup (NULL, "NULL"); eprintf ("r_bin_java_inner_classes_attr: Unable to find the name for %d index.\n", icattr->inner_name_idx); free (icattr); break; } } IFDBG eprintf("r_bin_java_inner_classes_attr: Inner class name %d is %s.\n", icattr->inner_name_idx, icattr->name); r_list_append (attr->info.inner_classes_attr.classes, (void *) icattr); } attr->size = offset; // IFDBG r_bin_java_print_inner_classes_attr_summary(attr); return attr; }
1
477,278
static void *tipc_aead_mem_alloc(struct crypto_aead *tfm, unsigned int crypto_ctx_size, u8 **iv, struct aead_request **req, struct scatterlist **sg, int nsg) { unsigned int iv_size, req_size; unsigned int len; u8 *mem; iv_size = crypto_aead_ivsize(tfm); req_size = sizeof(**req) + crypto_aead_reqsize(tfm); len = crypto_ctx_size; len += iv_size; len += crypto_aead_alignmask(tfm) & ~(crypto_tfm_ctx_alignment() - 1); len = ALIGN(len, crypto_tfm_ctx_alignment()); len += req_size; len = ALIGN(len, __alignof__(struct scatterlist)); len += nsg * sizeof(**sg); mem = kmalloc(len, GFP_ATOMIC); if (!mem) return NULL; *iv = (u8 *)PTR_ALIGN(mem + crypto_ctx_size, crypto_aead_alignmask(tfm) + 1); *req = (struct aead_request *)PTR_ALIGN(*iv + iv_size, crypto_tfm_ctx_alignment()); *sg = (struct scatterlist *)PTR_ALIGN((u8 *)*req + req_size, __alignof__(struct scatterlist)); return (void *)mem; }
0
343,292
static int doinitsupgroups(const char *user, const uid_t uid, const gid_t gid) { #ifndef NON_ROOT_FTP # ifdef HAVE_SETGROUPS if (setgroups(1U, &gid) != 0) { return -1; } # else (void) gid; # endif # ifdef HAVE_INITGROUPS if (user == NULL) { const struct passwd * const lpwd = getpwuid(uid); if (lpwd != NULL && lpwd->pw_name != NULL) { user = lpwd->pw_name; } else { return 0; } } initgroups(user, gid); # else (void) user; (void) uid; # endif #else (void) user; (void) uid; (void) gid; #endif return 0; }
0
309,835
NCURSES_PUBLIC_VAR(_nc_tputs_trace) (void) { return CURRENT_SCREEN ? CURRENT_SCREEN->_tputs_trace : _nc_prescreen._tputs_trace; }
0
275,956
uECC_VLI_API uECC_word_t uECC_vli_add(uECC_word_t *result, const uECC_word_t *left, const uECC_word_t *right, wordcount_t num_words) { uECC_word_t carry = 0; wordcount_t i; for (i = 0; i < num_words; ++i) { uECC_word_t sum = left[i] + right[i] + carry; if (sum != left[i]) { carry = (sum < left[i]); } result[i] = sum; } return carry; }
0
294,603
date_s_iso8601(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); if (!NIL_P(opt)) argc--; switch (argc) { case 0: str = rb_str_new2("-4712-01-01"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; if (!NIL_P(opt)) argv2[argc2++] = opt; VALUE hash = date_s__iso8601(argc2, argv2, klass); return d_new_by_frags(klass, hash, sg); } }
0
219,907
GF_Err gf_isom_hint_sample_data(GF_ISOFile *the_file, u32 trackNumber, GF_ISOTrackID SourceTrackID, u32 SampleNumber, u16 DataLength, u32 offsetInSample, u8 *extra_data, u8 AtBegin) { GF_TrackBox *trak; GF_HintSampleEntryBox *entry; u32 count; u16 refIndex; GF_HintPacket *pck; GF_SampleDTE *dte; GF_Err e; GF_TrackReferenceTypeBox *hint; trak = gf_isom_get_track_from_file(the_file, trackNumber); if (!trak || !IsHintTrack(trak)) return GF_BAD_PARAM; e = Media_GetSampleDesc(trak->Media, trak->Media->information->sampleTable->currentEntryIndex, (GF_SampleEntryBox **) &entry, &count); if (e) return e; if (!entry->hint_sample) return GF_BAD_PARAM; count = gf_list_count(entry->hint_sample->packetTable); if (!count) return GF_BAD_PARAM; pck = (GF_HintPacket *)gf_list_get(entry->hint_sample->packetTable, count - 1); dte = (GF_SampleDTE *) NewDTE(2); dte->dataLength = DataLength; dte->sampleNumber = SampleNumber; dte->byteOffset = offsetInSample; //we're getting data from another track if (SourceTrackID != trak->Header->trackID) { //get (or set) the track reference index e = Track_FindRef(trak, GF_ISOM_REF_HINT, &hint); if (e) return e; e = reftype_AddRefTrack(hint, SourceTrackID, &refIndex); if (e) return e; //WARNING: IN QT, MUST BE 0-based !!! dte->trackRefIndex = (u8) (refIndex - 1); } else { //we're in the hint track dte->trackRefIndex = (s8) -1; //basic check... if (SampleNumber > trak->Media->information->sampleTable->SampleSize->sampleCount + 1) { DelDTE((GF_GenericDTE *)dte); return GF_BAD_PARAM; } //are we in the current sample ?? if (!SampleNumber || (SampleNumber == trak->Media->information->sampleTable->SampleSize->sampleCount + 1)) { //we adding some stuff in the current sample ... dte->byteOffset += entry->hint_sample->dataLength; entry->hint_sample->AdditionalData = (char*)gf_realloc(entry->hint_sample->AdditionalData, sizeof(char) * (entry->hint_sample->dataLength + DataLength)); if (AtBegin) { if (entry->hint_sample->dataLength) memmove(entry->hint_sample->AdditionalData + DataLength, entry->hint_sample->AdditionalData, entry->hint_sample->dataLength); memcpy(entry->hint_sample->AdditionalData, extra_data, DataLength); /*offset existing DTE*/ gf_isom_hint_pck_offset(pck, DataLength, SampleNumber); } else { memcpy(entry->hint_sample->AdditionalData + entry->hint_sample->dataLength, extra_data, DataLength); } entry->hint_sample->dataLength += DataLength; //and set the sample number ... dte->sampleNumber = trak->Media->information->sampleTable->SampleSize->sampleCount + 1; } } //OK, add the entry return gf_isom_hint_pck_add_dte(pck, (GF_GenericDTE *)dte, AtBegin); }
0
416,364
may_adjust_incsearch_highlighting( int firstc, long count, incsearch_state_T *is_state, int c) { int skiplen, patlen; pos_T t; char_u *pat; int search_flags = SEARCH_NOOF; int i; int save; int search_delim; // Parsing range may already set the last search pattern. // NOTE: must call restore_last_search_pattern() before returning! save_last_search_pattern(); if (!do_incsearch_highlighting(firstc, &search_delim, is_state, &skiplen, &patlen)) { restore_last_search_pattern(); return OK; } if (patlen == 0 && ccline.cmdbuff[skiplen] == NUL) { restore_last_search_pattern(); return FAIL; } if (search_delim == ccline.cmdbuff[skiplen]) { pat = last_search_pattern(); if (pat == NULL) { restore_last_search_pattern(); return FAIL; } skiplen = 0; patlen = (int)STRLEN(pat); } else pat = ccline.cmdbuff + skiplen; cursor_off(); out_flush(); if (c == Ctrl_G) { t = is_state->match_end; if (LT_POS(is_state->match_start, is_state->match_end)) // Start searching at the end of the match not at the beginning of // the next column. (void)decl(&t); search_flags += SEARCH_COL; } else t = is_state->match_start; if (!p_hls) search_flags += SEARCH_KEEP; ++emsg_off; save = pat[patlen]; pat[patlen] = NUL; i = searchit(curwin, curbuf, &t, NULL, c == Ctrl_G ? FORWARD : BACKWARD, pat, count, search_flags, RE_SEARCH, NULL); --emsg_off; pat[patlen] = save; if (i) { is_state->search_start = is_state->match_start; is_state->match_end = t; is_state->match_start = t; if (c == Ctrl_T && firstc != '?') { // Move just before the current match, so that when nv_search // finishes the cursor will be put back on the match. is_state->search_start = t; (void)decl(&is_state->search_start); } else if (c == Ctrl_G && firstc == '?') { // Move just after the current match, so that when nv_search // finishes the cursor will be put back on the match. is_state->search_start = t; (void)incl(&is_state->search_start); } if (LT_POS(t, is_state->search_start) && c == Ctrl_G) { // wrap around is_state->search_start = t; if (firstc == '?') (void)incl(&is_state->search_start); else (void)decl(&is_state->search_start); } set_search_match(&is_state->match_end); curwin->w_cursor = is_state->match_start; changed_cline_bef_curs(); update_topline(); validate_cursor(); highlight_match = TRUE; save_viewstate(&is_state->old_viewstate); update_screen(UPD_NOT_VALID); highlight_match = FALSE; redrawcmdline(); curwin->w_cursor = is_state->match_end; } else vim_beep(BO_ERROR); restore_last_search_pattern(); return FAIL; }
0
432,349
static void i2c_ddc_init(Object *obj) { I2CDDCState *s = I2CDDC(obj); qemu_edid_generate(s->edid_blob, sizeof(s->edid_blob), &s->edid_info); }
0
218,972
bool ConstantFolding::IsReductionWithConstantIndices( const NodeDef& node, bool* indices_is_empty) const { // Ensure its an appropriate Reduce node. if (!IsReduction(node) || node.input_size() < 2) { return false; } // Ensure that the axes to reduce by are constant. NodeDef* reductions_indices = node_map_->GetNode(node.input(1)); if (!IsReallyConstant(*reductions_indices) || !reductions_indices->attr().count("value")) { return false; } const TensorShapeProto& reduction_indices_shape = reductions_indices->attr().at("value").tensor().tensor_shape(); *indices_is_empty = TensorShape(reduction_indices_shape).num_elements() == 0; return true; }
0
463,057
static void sungem_update_masks(SunGEMState *s) { uint32_t sz; sz = 1 << (((s->rxdmaregs[RXDMA_CFG >> 2] & RXDMA_CFG_RINGSZ) >> 1) + 5); s->rx_mask = sz - 1; sz = 1 << (((s->txdmaregs[TXDMA_CFG >> 2] & TXDMA_CFG_RINGSZ) >> 1) + 5); s->tx_mask = sz - 1; }
0
256,398
int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf, unsigned int len, gfp_t gfp_mask) { int reading = rq_data_dir(rq) == READ; unsigned long addr = (unsigned long) kbuf; struct bio *bio; int ret; if (len > (queue_max_hw_sectors(q) << 9)) return -EINVAL; if (!len || !kbuf) return -EINVAL; if (!blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf) || blk_queue_may_bounce(q)) bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading); else bio = bio_map_kern(q, kbuf, len, gfp_mask); if (IS_ERR(bio)) return PTR_ERR(bio); bio->bi_opf &= ~REQ_OP_MASK; bio->bi_opf |= req_op(rq); ret = blk_rq_append_bio(rq, bio); if (unlikely(ret)) bio_put(bio); return ret; }
0
398,516
RZ_API void rz_bin_dwarf_line_header_reset_regs(const RzBinDwarfLineHeader *hdr, RzBinDwarfSMRegisters *regs) { rz_return_if_fail(hdr && regs); regs->address = 0; regs->file = 1; regs->line = 1; regs->column = 0; regs->is_stmt = hdr->default_is_stmt; regs->basic_block = DWARF_FALSE; regs->end_sequence = DWARF_FALSE; regs->prologue_end = DWARF_FALSE; regs->epilogue_begin = DWARF_FALSE; regs->isa = 0; }
0
473,930
fetch_name(OnigCodePoint start_code, UChar** src, UChar* end, UChar** rname_end, ScanEnv* env, int* rback_num, int ref) { int r, is_num, sign; OnigCodePoint end_code; OnigCodePoint c = 0; OnigEncoding enc = env->enc; UChar *name_end; UChar *pnum_head; UChar *p = *src; PFETCH_READY; *rback_num = 0; end_code = get_name_end_code_point(start_code); name_end = end; pnum_head = *src; r = 0; is_num = 0; sign = 1; if (PEND) { return ONIGERR_EMPTY_GROUP_NAME; } else { PFETCH(c); if (c == end_code) return ONIGERR_EMPTY_GROUP_NAME; if (ONIGENC_IS_CODE_DIGIT(enc, c)) { if (ref == 1) is_num = 1; else { r = ONIGERR_INVALID_GROUP_NAME; is_num = 0; } } else if (c == '-') { if (ref == 1) { is_num = 2; sign = -1; pnum_head = p; } else { r = ONIGERR_INVALID_GROUP_NAME; is_num = 0; } } else if (!ONIGENC_IS_CODE_WORD(enc, c)) { r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME; } } if (r == 0) { while (!PEND) { name_end = p; PFETCH(c); if (c == end_code || c == ')') { if (is_num == 2) r = ONIGERR_INVALID_GROUP_NAME; break; } if (is_num != 0) { if (ONIGENC_IS_CODE_DIGIT(enc, c)) { is_num = 1; } else { if (!ONIGENC_IS_CODE_WORD(enc, c)) r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME; else r = ONIGERR_INVALID_GROUP_NAME; is_num = 0; } } else { if (!ONIGENC_IS_CODE_WORD(enc, c)) { r = ONIGERR_INVALID_CHAR_IN_GROUP_NAME; } } } if (c != end_code) { r = ONIGERR_INVALID_GROUP_NAME; name_end = end; } if (is_num != 0) { *rback_num = onig_scan_unsigned_number(&pnum_head, name_end, enc); if (*rback_num < 0) return ONIGERR_TOO_BIG_NUMBER; else if (*rback_num == 0) { r = ONIGERR_INVALID_GROUP_NAME; goto err; } *rback_num *= sign; } *rname_end = name_end; *src = p; return 0; } else { while (!PEND) { name_end = p; PFETCH(c); if (c == end_code || c == ')') break; } if (PEND) name_end = end; err: onig_scan_env_set_error_string(env, r, *src, name_end); return r; } }
0
402,603
handle_get_cmd_version(context *ctx, struct pollfd *pollfd, socklen_t size) { struct msghdr msg; struct iovec iov; ssize_t n; int rc = cms_context_alloc(&ctx->cms); if (rc < 0) { send_response(ctx, ctx->backup_cms, pollfd, rc); return; } steal_from_cms(ctx->backup_cms, ctx->cms); char *buffer = malloc(size); if (!buffer) { ctx->cms->log(ctx->cms, ctx->priority|LOG_ERR, "unable to allocate memory: %m"); exit(1); } memset(&msg, '\0', sizeof(msg)); iov.iov_base = buffer; iov.iov_len = size; msg.msg_iov = &iov; msg.msg_iovlen = 1; n = recvmsg(pollfd->fd, &msg, MSG_WAITALL); int32_t version = -1; uint32_t command; if (n < (long long)sizeof(command)) { ctx->cms->log(ctx->cms, ctx->priority|LOG_ERR, "unlock-token: invalid data"); ctx->cms->log(ctx->cms, ctx->priority|LOG_ERR, "possible exploit attempt. closing."); close(pollfd->fd); return; } memcpy(&command, buffer, sizeof (command)); ctx->cms->log(ctx->cms, ctx->priority|LOG_NOTICE, "searching for command %d", command); for (int i = 0; cmd_table[i].cmd != CMD_LIST_END; i++) { if (cmd_table[i].cmd == command) { ctx->cms->log(ctx->cms, ctx->priority|LOG_NOTICE, "cmd-version: found command \"%s\" " "version %d", cmd_table[i].name, cmd_table[i].version); version = cmd_table[i].version; break; } } if (version == -1) { ctx->cms->log(ctx->cms, ctx->priority|LOG_NOTICE, "cmd-version: could not find command %d", command); } send_response(ctx, ctx->cms, pollfd, version); free(buffer); hide_stolen_goods_from_cms(ctx->cms, ctx->backup_cms); cms_context_fini(ctx->cms); }
0
424,916
static void iwl_trans_pcie_write8(struct iwl_trans *trans, u32 ofs, u8 val) { writeb(val, IWL_TRANS_GET_PCIE_TRANS(trans)->hw_base + ofs); }
0
310,257
dirserv_dump_directory_to_string(char **dir_out, crypto_pk_env_t *private_key) { char *cp; char *identity_pkey; /* Identity key, DER64-encoded. */ char *recommended_versions; char digest[DIGEST_LEN]; char published[ISO_TIME_LEN+1]; char *buf = NULL; size_t buf_len; size_t identity_pkey_len; time_t now = time(NULL); tor_assert(dir_out); *dir_out = NULL; if (crypto_pk_write_public_key_to_string(private_key,&identity_pkey, &identity_pkey_len)<0) { log_warn(LD_BUG,"write identity_pkey to string failed!"); return -1; } recommended_versions = format_versions_list(get_options()->RecommendedVersions); format_iso_time(published, now); buf_len = 2048+strlen(recommended_versions); buf = tor_malloc(buf_len); /* We'll be comparing against buf_len throughout the rest of the function, though strictly speaking we shouldn't be able to exceed it. This is C, after all, so we may as well check for buffer overruns.*/ tor_snprintf(buf, buf_len, "signed-directory\n" "published %s\n" "recommended-software %s\n" "router-status %s\n" "dir-signing-key\n%s\n", published, recommended_versions, "", identity_pkey); tor_free(recommended_versions); tor_free(identity_pkey); cp = buf + strlen(buf); *cp = '\0'; /* These multiple strlcat calls are inefficient, but dwarfed by the RSA signature. */ if (strlcat(buf, "directory-signature ", buf_len) >= buf_len) goto truncated; if (strlcat(buf, get_options()->Nickname, buf_len) >= buf_len) goto truncated; if (strlcat(buf, "\n", buf_len) >= buf_len) goto truncated; if (router_get_dir_hash(buf,digest)) { log_warn(LD_BUG,"couldn't compute digest"); tor_free(buf); return -1; } note_crypto_pk_op(SIGN_DIR); if (router_append_dirobj_signature(buf,buf_len,digest,DIGEST_LEN, private_key)<0) { tor_free(buf); return -1; } *dir_out = buf; return 0; truncated: log_warn(LD_BUG,"tried to exceed string length."); tor_free(buf); return -1; }
0
481,271
static void mlx5_fpga_conn_arm_cq(struct mlx5_fpga_conn *conn) { mlx5_cq_arm(&conn->cq.mcq, MLX5_CQ_DB_REQ_NOT, conn->fdev->conn_res.uar->map, conn->cq.wq.cc); }
0
369,220
static __cold int io_sq_offload_create(struct io_ring_ctx *ctx, struct io_uring_params *p) { int ret; /* Retain compatibility with failing for an invalid attach attempt */ if ((ctx->flags & (IORING_SETUP_ATTACH_WQ | IORING_SETUP_SQPOLL)) == IORING_SETUP_ATTACH_WQ) { struct fd f; f = fdget(p->wq_fd); if (!f.file) return -ENXIO; if (f.file->f_op != &io_uring_fops) { fdput(f); return -EINVAL; } fdput(f); } if (ctx->flags & IORING_SETUP_SQPOLL) { struct task_struct *tsk; struct io_sq_data *sqd; bool attached; ret = security_uring_sqpoll(); if (ret) return ret; sqd = io_get_sq_data(p, &attached); if (IS_ERR(sqd)) { ret = PTR_ERR(sqd); goto err; } ctx->sq_creds = get_current_cred(); ctx->sq_data = sqd; ctx->sq_thread_idle = msecs_to_jiffies(p->sq_thread_idle); if (!ctx->sq_thread_idle) ctx->sq_thread_idle = HZ; io_sq_thread_park(sqd); list_add(&ctx->sqd_list, &sqd->ctx_list); io_sqd_update_thread_idle(sqd); /* don't attach to a dying SQPOLL thread, would be racy */ ret = (attached && !sqd->thread) ? -ENXIO : 0; io_sq_thread_unpark(sqd); if (ret < 0) goto err; if (attached) return 0; if (p->flags & IORING_SETUP_SQ_AFF) { int cpu = p->sq_thread_cpu; ret = -EINVAL; if (cpu >= nr_cpu_ids || !cpu_online(cpu)) goto err_sqpoll; sqd->sq_cpu = cpu; } else { sqd->sq_cpu = -1; } sqd->task_pid = current->pid; sqd->task_tgid = current->tgid; tsk = create_io_thread(io_sq_thread, sqd, NUMA_NO_NODE); if (IS_ERR(tsk)) { ret = PTR_ERR(tsk); goto err_sqpoll; } sqd->thread = tsk; ret = io_uring_alloc_task_context(tsk, ctx); wake_up_new_task(tsk); if (ret) goto err; } else if (p->flags & IORING_SETUP_SQ_AFF) { /* Can't have SQ_AFF without SQPOLL */ ret = -EINVAL; goto err; } return 0; err_sqpoll: complete(&ctx->sq_data->exited); err: io_sq_thread_finish(ctx); return ret;
0
312,532
qf_setprop_get_qfidx( qf_info_T *qi, dict_T *what, int action, int *newlist) { dictitem_T *di; int qf_idx = qi->qf_curlist; // default is the current list if ((di = dict_find(what, (char_u *)"nr", -1)) != NULL) { // Use the specified quickfix/location list if (di->di_tv.v_type == VAR_NUMBER) { // for zero use the current list if (di->di_tv.vval.v_number != 0) qf_idx = di->di_tv.vval.v_number - 1; if ((action == ' ' || action == 'a') && qf_idx == qi->qf_listcount) { // When creating a new list, accept qf_idx pointing to the next // non-available list and add the new list at the end of the // stack. *newlist = TRUE; qf_idx = qf_stack_empty(qi) ? 0 : qi->qf_listcount - 1; } else if (qf_idx < 0 || qf_idx >= qi->qf_listcount) return INVALID_QFIDX; else if (action != ' ') *newlist = FALSE; // use the specified list } else if (di->di_tv.v_type == VAR_STRING && di->di_tv.vval.v_string != NULL && STRCMP(di->di_tv.vval.v_string, "$") == 0) { if (!qf_stack_empty(qi)) qf_idx = qi->qf_listcount - 1; else if (*newlist) qf_idx = 0; else return INVALID_QFIDX; } else return INVALID_QFIDX; } if (!*newlist && (di = dict_find(what, (char_u *)"id", -1)) != NULL) { // Use the quickfix/location list with the specified id if (di->di_tv.v_type != VAR_NUMBER) return INVALID_QFIDX; return qf_id2nr(qi, di->di_tv.vval.v_number); } return qf_idx; }
0
386,531
void DL_Dxf::writeInsert(DL_WriterA& dw, const DL_InsertData& data, const DL_Attributes& attrib) { if (data.name.empty()) { std::cerr << "DL_Dxf::writeInsert: " << "Block name must not be empty\n"; return; } dw.entity("INSERT"); if (version==DL_VERSION_2000) { dw.dxfString(100, "AcDbEntity"); } dw.entityAttributes(attrib); if (version==DL_VERSION_2000) { if (data.cols!=1 || data.rows!=1) { dw.dxfString(100, "AcDbMInsertBlock"); } else { dw.dxfString(100, "AcDbBlockReference"); } } dw.dxfString(2, data.name); dw.dxfReal(10, data.ipx); dw.dxfReal(20, data.ipy); dw.dxfReal(30, data.ipz); if (data.sx!=1.0 || data.sy!=1.0) { dw.dxfReal(41, data.sx); dw.dxfReal(42, data.sy); dw.dxfReal(43, 1.0); } if (data.angle!=0.0) { dw.dxfReal(50, data.angle); } if (data.cols!=1 || data.rows!=1) { dw.dxfInt(70, data.cols); dw.dxfInt(71, data.rows); } if (data.colSp!=0.0 || data.rowSp!=0.0) { dw.dxfReal(44, data.colSp); dw.dxfReal(45, data.rowSp); } }
0
222,496
string Print(const AttrValue& attr_value, const bool hash_string_attrs = false) { if (attr_value.value_case() == AttrValue::kType) { return DataTypeString(attr_value.type()); } else if ((attr_value.value_case() == AttrValue::kList) && (attr_value.list().type_size() > 0)) { string ret = "{"; for (int i = 0; i < attr_value.list().type_size(); ++i) { if (i > 0) strings::StrAppend(&ret, ", "); strings::StrAppend(&ret, DataTypeString(attr_value.list().type(i))); } strings::StrAppend(&ret, "}"); return ret; } else if (attr_value.value_case() == AttrValue::kFunc) { if (attr_value.func().attr_size() == 0) { return attr_value.func().name(); } std::vector<string> entries; for (const auto& p : attr_value.func().attr()) { entries.push_back(strings::StrCat(p.first, "=", Print(p.second))); } std::sort(entries.begin(), entries.end()); return strings::StrCat(attr_value.func().name(), "[", absl::StrJoin(entries, ", "), "]"); } else if (attr_value.value_case() == AttrValue::kS && hash_string_attrs) { return strings::StrCat(Fingerprint64(attr_value.s())); } return SummarizeAttrValue(attr_value); }
0
226,303
void minf_box_del(GF_Box *s) { GF_MediaInformationBox *ptr = (GF_MediaInformationBox *)s; if (ptr == NULL) return; //if we have a Handler not self-contained, delete it (the self-contained belongs to the movie) if (ptr->dataHandler) { gf_isom_datamap_close(ptr); } gf_free(ptr); }
0
234,820
static struct btrfs_device *add_missing_dev(struct btrfs_fs_devices *fs_devices, u64 devid, u8 *dev_uuid) { struct btrfs_device *device; unsigned int nofs_flag; /* * We call this under the chunk_mutex, so we want to use NOFS for this * allocation, however we don't want to change btrfs_alloc_device() to * always do NOFS because we use it in a lot of other GFP_KERNEL safe * places. */ nofs_flag = memalloc_nofs_save(); device = btrfs_alloc_device(NULL, &devid, dev_uuid); memalloc_nofs_restore(nofs_flag); if (IS_ERR(device)) return device; list_add(&device->dev_list, &fs_devices->devices); device->fs_devices = fs_devices; fs_devices->num_devices++; set_bit(BTRFS_DEV_STATE_MISSING, &device->dev_state); fs_devices->missing_devices++; return device; }
0
359,317
DEFUN (bgp_graceful_restart_stalepath_time, bgp_graceful_restart_stalepath_time_cmd, "bgp graceful-restart stalepath-time <1-3600>", "BGP specific commands\n" "Graceful restart capability parameters\n" "Set the max time to hold onto restarting peer's stale paths\n" "Delay value (seconds)\n") { struct bgp *bgp; u_int32_t stalepath; bgp = vty->index; if (! bgp) return CMD_WARNING; VTY_GET_INTEGER_RANGE ("stalepath-time", stalepath, argv[0], 1, 3600); bgp->stalepath_time = stalepath; return CMD_SUCCESS; }
0
405,356
static struct xfrm_policy *xfrm_policy_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir, u32 if_id) { #ifdef CONFIG_XFRM_SUB_POLICY struct xfrm_policy *pol; pol = xfrm_policy_lookup_bytype(net, XFRM_POLICY_TYPE_SUB, fl, family, dir, if_id); if (pol != NULL) return pol; #endif return xfrm_policy_lookup_bytype(net, XFRM_POLICY_TYPE_MAIN, fl, family, dir, if_id); }
0
175,688
virtual void EnableWifiNetworkDevice(bool enable) {}
0
244,074
GF_Err sbgp_box_write(GF_Box *s, GF_BitStream *bs) { u32 i; GF_Err e; GF_SampleGroupBox *p = (GF_SampleGroupBox*)s; e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u32(bs, p->grouping_type); if (p->version==1) gf_bs_write_u32(bs, p->grouping_type_parameter); gf_bs_write_u32(bs, p->entry_count); for (i = 0; i<p->entry_count; i++ ) { gf_bs_write_u32(bs, p->sample_entries[i].sample_count); gf_bs_write_u32(bs, p->sample_entries[i].group_description_index); } return GF_OK; }
0
369,225
static bool io_cqring_event_overflow(struct io_ring_ctx *ctx, u64 user_data, s32 res, u32 cflags) { struct io_overflow_cqe *ocqe; ocqe = kmalloc(sizeof(*ocqe), GFP_ATOMIC | __GFP_ACCOUNT); if (!ocqe) { /* * If we're in ring overflow flush mode, or in task cancel mode, * or cannot allocate an overflow entry, then we need to drop it * on the floor. */ io_account_cq_overflow(ctx); return false; } if (list_empty(&ctx->cq_overflow_list)) { set_bit(0, &ctx->check_cq_overflow); WRITE_ONCE(ctx->rings->sq_flags, ctx->rings->sq_flags | IORING_SQ_CQ_OVERFLOW); } ocqe->cqe.user_data = user_data; ocqe->cqe.res = res; ocqe->cqe.flags = cflags; list_add_tail(&ocqe->list, &ctx->cq_overflow_list); return true; }
0
473,864
uniname2ctype_hash (str, len) register const char *str; register unsigned int len; { #ifndef USE_UNICODE_PROPERTIES static const unsigned char asso_values[] = #else /* USE_UNICODE_PROPERTIES */ static const unsigned short asso_values[] = #endif /* USE_UNICODE_PROPERTIES */ { #ifndef USE_UNICODE_PROPERTIES 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 3, 13, 6, 4, 22, 22, 11, 22, 1, 22, 22, 10, 22, 2, 22, 1, 22, 10, 8, 4, 7, 22, 3, 4, 22, 22, 22, 22, 22, 22, 22 #else /* USE_UNICODE_PROPERTIES */ 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 2, 1742, 9, 1, 2, 18, 5, 3, 4, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 1742, 8, 280, 6, 96, 67, 362, 294, 38, 9, 63, 517, 2, 213, 1, 4, 192, 3, 10, 57, 31, 316, 1, 549, 330, 567, 36, 1742, 1742, 1742, 1742, 1742 #endif /* USE_UNICODE_PROPERTIES */ }; #ifndef USE_UNICODE_PROPERTIES return len + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[0]]; #else /* USE_UNICODE_PROPERTIES */ register int hval = len; switch (hval) { default: hval += asso_values[(unsigned char)str[15]]; /*FALLTHROUGH*/ case 15: case 14: case 13: case 12: hval += asso_values[(unsigned char)str[11]]; /*FALLTHROUGH*/ case 11: case 10: case 9: case 8: case 7: case 6: hval += asso_values[(unsigned char)str[5]]; /*FALLTHROUGH*/ case 5: hval += asso_values[(unsigned char)str[4]]; /*FALLTHROUGH*/ case 4: case 3: hval += asso_values[(unsigned char)str[2]]; /*FALLTHROUGH*/ case 2: hval += asso_values[(unsigned char)str[1]]; /*FALLTHROUGH*/ case 1: hval += asso_values[(unsigned char)str[0]]; break; } return hval + asso_values[(unsigned char)str[len - 1]]; #endif /* USE_UNICODE_PROPERTIES */ }
0
232,288
void SampleInterleavedLSScan::FindComponentDimensions(void) { #if ACCUSOFT_CODE UBYTE cx; JPEGLSScan::FindComponentDimensions(); // // Check that all MCU dimensions are 1. for(cx = 0;cx < m_ucCount;cx++) { class Component *comp = ComponentOf(cx); if (comp->MCUHeightOf() != 1 || comp->MCUWidthOf() != 1) JPG_THROW(INVALID_PARAMETER,"SampleInterleavedLSScan::FindComponentDimensions", "sample interleaved JPEG LS does not support subsampling"); } #endif }
0
369,157
*/ static int io_poll_check_events(struct io_kiocb *req, bool locked) { struct io_ring_ctx *ctx = req->ctx; int v; /* req->task == current here, checking PF_EXITING is safe */ if (unlikely(req->task->flags & PF_EXITING)) io_poll_mark_cancelled(req); do { v = atomic_read(&req->poll_refs); /* tw handler should be the owner, and so have some references */ if (WARN_ON_ONCE(!(v & IO_POLL_REF_MASK))) return 0; if (v & IO_POLL_CANCEL_FLAG) return -ECANCELED; if (!req->result) { struct poll_table_struct pt = { ._key = req->apoll_events }; unsigned flags = locked ? 0 : IO_URING_F_UNLOCKED; if (unlikely(!io_assign_file(req, flags))) return -EBADF; req->result = vfs_poll(req->file, &pt) & req->apoll_events; } /* multishot, just fill an CQE and proceed */ if (req->result && !(req->apoll_events & EPOLLONESHOT)) { __poll_t mask = mangle_poll(req->result & req->apoll_events); bool filled; spin_lock(&ctx->completion_lock); filled = io_fill_cqe_aux(ctx, req->user_data, mask, IORING_CQE_F_MORE); io_commit_cqring(ctx); spin_unlock(&ctx->completion_lock); if (unlikely(!filled)) return -ECANCELED; io_cqring_ev_posted(ctx); } else if (req->result) { return 0; } /* * Release all references, retry if someone tried to restart * task_work while we were executing it. */ } while (atomic_sub_return(v & IO_POLL_REF_MASK, &req->poll_refs)); return 1;
0
272,353
match_subject(CERTCertificate *cert, void *cbdatap) { if (!cert->subjectName) return 0; if (!strcmp(cert->subjectName, (char *)cbdatap)) return 1; return 0; }
0
231,652
TEST_F(QuicUnencryptedServerTransportTest, TestUnencryptedStream) { auto data = IOBuf::copyBuffer("bad data"); PacketNum nextPacket = clientNextInitialPacketNum++; StreamId streamId = 3; auto initialCipher = getInitialCipher(); auto headerCipher = getInitialHeaderCipher(); auto packetData = packetToBufCleartext( createStreamPacket( *clientConnectionId, *initialDestinationConnectionId, nextPacket, streamId, *data, initialCipher->getCipherOverhead(), 0 /* largestAcked */, std::make_pair(LongHeader::Types::Initial, QuicVersion::MVFST)), *initialCipher, *headerCipher, nextPacket); EXPECT_THROW(deliverData(std::move(packetData)), std::runtime_error); EXPECT_EQ(server->getConn().streamManager->streamCount(), 0); }
0
455,421
xfs_reclaim_inodes_count( struct xfs_mount *mp) { struct xfs_perag *pag; xfs_agnumber_t ag = 0; int reclaimable = 0; while ((pag = xfs_perag_get_tag(mp, ag, XFS_ICI_RECLAIM_TAG))) { ag = pag->pag_agno + 1; reclaimable += pag->pag_ici_reclaimable; xfs_perag_put(pag); } return reclaimable; }
0
432,189
static void phys_page_compact(struct uc_struct *uc, PhysPageEntry *lp, Node *nodes) { unsigned valid_ptr = P_L2_SIZE; int valid = 0; PhysPageEntry *p; int i; if (lp->ptr == PHYS_MAP_NODE_NIL) { return; } p = nodes[lp->ptr]; for (i = 0; i < P_L2_SIZE; i++) { if (p[i].ptr == PHYS_MAP_NODE_NIL) { continue; } valid_ptr = i; valid++; if (p[i].skip) { phys_page_compact(uc, &p[i], nodes); } } /* We can only compress if there's only one child. */ if (valid != 1) { return; } assert(valid_ptr < P_L2_SIZE); /* Don't compress if it won't fit in the # of bits we have. */ if (P_L2_LEVELS >= (1 << 6) && lp->skip + p[valid_ptr].skip >= (1 << 6)) { return; } lp->ptr = p[valid_ptr].ptr; if (!p[valid_ptr].skip) { /* If our only child is a leaf, make this a leaf. */ /* By design, we should have made this node a leaf to begin with so we * should never reach here. * But since it's so simple to handle this, let's do it just in case we * change this rule. */ lp->skip = 0; } else { lp->skip += p[valid_ptr].skip; } }
0
487,665
asmlinkage long sys_getresgid(gid_t __user *rgid, gid_t __user *egid, gid_t __user *sgid) { int retval; if (!(retval = put_user(current->gid, rgid)) && !(retval = put_user(current->egid, egid))) retval = put_user(current->sgid, sgid); return retval; }
0
417,055
mp_sint32 PlayerGeneric::setBufferSize(mp_uint32 bufferSize) { mp_sint32 res = 0; this->bufferSize = bufferSize; if (mixer) { // If we're told to compensate the samples until we // we reached 2^n buffer sizes if (compensateBufferFlag) { for (mp_uint32 i = 0; i < 16; i++) { if ((unsigned)(1 << i) >= (unsigned)bufferSize) { bufferSize = 1 << i; break; } } } res = mixer->setBufferSize(bufferSize); } return res; }
0
328,970
R_API char *r_bin_java_get_item_desc_from_bin_cp_list(RBinJavaObj *bin, RBinJavaCPTypeObj *obj) { /* Given a constant pool object Class, FieldRef, MethodRef, or InterfaceMethodRef return the actual descriptor string. @param cp_list: RList of RBinJavaCPTypeObj * @param obj object to look up the name for @rvalue char* (user frees) or NULL */ return bin? r_bin_java_get_item_desc_from_cp_item_list (bin->cp_list, obj, MAX_CPITEMS): NULL; }
0
402,588
print_flag_name(FILE *f, int flag) { for (int i = 0; flag_names[i].flag != FLAG_LIST_END; i++) { if (flag_names[i].flag == flag) fprintf(f, "%s ", flag_names[i].name); } }
0
409,481
decode_modifiers(int n) { int code = n - 1; int modifiers = 0; if (code & 1) modifiers |= MOD_MASK_SHIFT; if (code & 2) modifiers |= MOD_MASK_ALT; if (code & 4) modifiers |= MOD_MASK_CTRL; if (code & 8) modifiers |= MOD_MASK_META; return modifiers; }
0
197,615
Status TensorSliceReader::GetTensor( const string& name, std::unique_ptr<tensorflow::Tensor>* out_tensor) const { DataType type; TensorShape shape; TensorSlice slice; { mutex_lock l(mu_); const TensorSliceSet* tss = gtl::FindPtrOrNull(tensors_, name); if (tss == nullptr) { return errors::NotFound(name, " not found in checkpoint file"); } if (tss->Slices().size() > 1) { // TODO(sherrym): Support multi-slice checkpoints. return errors::Unimplemented("Sliced checkpoints are not supported"); } type = tss->type(); shape = tss->shape(); slice = tss->Slices().begin()->second.slice; } std::unique_ptr<tensorflow::Tensor> t(new tensorflow::Tensor(type, shape)); bool success = false; #define READER_COPY(dt) \ case dt: \ success = CopySliceData(name, slice, \ t->flat<EnumToDataType<dt>::Type>().data()); \ break; switch (type) { READER_COPY(DT_FLOAT); READER_COPY(DT_DOUBLE); READER_COPY(DT_INT32); READER_COPY(DT_UINT8); READER_COPY(DT_INT16); READER_COPY(DT_INT8); READER_COPY(DT_INT64); READER_COPY(DT_STRING); default: return errors::Unimplemented("Data type not supported"); } #undef READER_COPY if (!success) { return errors::NotFound(name, " not found in checkpoint file"); } std::swap(*out_tensor, t); return Status::OK(); }
1
101,684
void WebProcessProxy::getPluginPath(const String& mimeType, const String& urlString, String& pluginPath, uint32_t& pluginLoadPolicy) { MESSAGE_CHECK_URL(urlString); String newMimeType = mimeType.lower(); pluginLoadPolicy = PluginModuleLoadNormally; PluginModuleInfo plugin = m_context->pluginInfoStore().findPlugin(newMimeType, KURL(KURL(), urlString)); if (!plugin.path) return; pluginLoadPolicy = PluginInfoStore::policyForPlugin(plugin); if (pluginLoadPolicy != PluginModuleLoadNormally) return; pluginPath = plugin.path; }
0
252,366
static void hufCanonicalCodeTable(long long hcode[HUF_ENCSIZE]) { long long n[59]; // // For each i from 0 through 58, count the // number of different codes of length i, and // store the count in n[i]. // for (int i = 0; i <= 58; ++i) n[i] = 0; for (int i = 0; i < HUF_ENCSIZE; ++i) n[hcode[i]] += 1; // // For each i from 58 through 1, compute the // numerically lowest code with length i, and // store that code in n[i]. // long long c = 0; for (int i = 58; i > 0; --i) { long long nc = ((c + n[i]) >> 1); n[i] = c; c = nc; } // // hcode[i] contains the length, l, of the // code for symbol i. Assign the next available // code of length l to the symbol and store both // l and the code in hcode[i]. // for (int i = 0; i < HUF_ENCSIZE; ++i) { int l = static_cast<int>(hcode[i]); if (l > 0) hcode[i] = l | (n[l]++ << 6); } }
0
225,413
static int vidioc_g_output(struct file *file, void *fh, unsigned int *i) { struct v4l2_loopback_device *dev = v4l2loopback_getdevice(file); if (!dev->announce_all_caps && !dev->ready_for_output) return -ENOTTY; if (i) *i = 0; return 0; }
0
224,761
GF_Err ireftype_box_size(GF_Box *s) { GF_ItemReferenceTypeBox *ptr = (GF_ItemReferenceTypeBox *)s; ptr->size += 4 + (ptr->reference_count * sizeof(u16)); return GF_OK; }
0
488,381
static inline int handle_pte_fault(struct mm_struct *mm, struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, int write_access) { pte_t entry; spinlock_t *ptl; entry = *pte; if (!pte_present(entry)) { if (pte_none(entry)) { if (vma->vm_ops) { if (likely(vma->vm_ops->fault)) return do_linear_fault(mm, vma, address, pte, pmd, write_access, entry); if (unlikely(vma->vm_ops->nopfn)) return do_no_pfn(mm, vma, address, pte, pmd, write_access); } return do_anonymous_page(mm, vma, address, pte, pmd, write_access); } if (pte_file(entry)) return do_nonlinear_fault(mm, vma, address, pte, pmd, write_access, entry); return do_swap_page(mm, vma, address, pte, pmd, write_access, entry); } ptl = pte_lockptr(mm, pmd); spin_lock(ptl); if (unlikely(!pte_same(*pte, entry))) goto unlock; if (write_access) { if (!pte_write(entry)) return do_wp_page(mm, vma, address, pte, pmd, ptl, entry); entry = pte_mkdirty(entry); } entry = pte_mkyoung(entry); if (ptep_set_access_flags(vma, address, pte, entry, write_access)) { update_mmu_cache(vma, address, entry); } else { /* * This is needed only for protection faults but the arch code * is not yet telling us if this is a protection fault or not. * This still avoids useless tlb flushes for .text page faults * with threads. */ if (write_access) flush_tlb_page(vma, address); } unlock: pte_unmap_unlock(pte, ptl); return 0; }
0
415,195
update_reader_status_file (int set_card_removed_flag) { int idx; unsigned int status, changed; /* Note, that we only try to get the status, because it does not make sense to wait here for a operation to complete. If we are busy working with a card, delays in the status file update should be acceptable. */ for (idx=0; idx < DIM(vreader_table); idx++) { struct vreader_s *vr = vreader_table + idx; struct server_local_s *sl; int sw_apdu; if (!vr->valid || vr->slot == -1) continue; /* Not valid or reader not yet open. */ sw_apdu = apdu_get_status (vr->slot, 0, &status, &changed); if (sw_apdu == SW_HOST_NO_READER) { /* Most likely the _reader_ has been unplugged. */ application_notify_card_reset (vr->slot); apdu_close_reader (vr->slot); vr->slot = -1; status = 0; changed = vr->changed; } else if (sw_apdu) { /* Get status failed. Ignore that. */ continue; } if (!vr->any || vr->status != status || vr->changed != changed ) { char *fname; char templ[50]; FILE *fp; log_info ("updating reader %d (%d) status: 0x%04X->0x%04X (%u->%u)\n", idx, vr->slot, vr->status, status, vr->changed, changed); vr->status = status; vr->changed = changed; /* FIXME: Should this be IDX instead of vr->slot? This depends on how client sessions will associate the reader status with their session. */ snprintf (templ, sizeof templ, "reader_%d.status", vr->slot); fname = make_filename (opt.homedir, templ, NULL ); fp = fopen (fname, "w"); if (fp) { fprintf (fp, "%s\n", (status & 1)? "USABLE": (status & 4)? "ACTIVE": (status & 2)? "PRESENT": "NOCARD"); fclose (fp); } xfree (fname); /* If a status script is executable, run it. */ { const char *args[9], *envs[2]; char numbuf1[30], numbuf2[30], numbuf3[30]; char *homestr, *envstr; gpg_error_t err; homestr = make_filename (opt.homedir, NULL); if (gpgrt_asprintf (&envstr, "GNUPGHOME=%s", homestr) < 0) log_error ("out of core while building environment\n"); else { envs[0] = envstr; envs[1] = NULL; sprintf (numbuf1, "%d", vr->slot); sprintf (numbuf2, "0x%04X", vr->status); sprintf (numbuf3, "0x%04X", status); args[0] = "--reader-port"; args[1] = numbuf1; args[2] = "--old-code"; args[3] = numbuf2; args[4] = "--new-code"; args[5] = numbuf3; args[6] = "--status"; args[7] = ((status & 1)? "USABLE": (status & 4)? "ACTIVE": (status & 2)? "PRESENT": "NOCARD"); args[8] = NULL; fname = make_filename (opt.homedir, "scd-event", NULL); err = gnupg_spawn_process_detached (fname, args, envs); if (err && gpg_err_code (err) != GPG_ERR_ENOENT) log_error ("failed to run event handler '%s': %s\n", fname, gpg_strerror (err)); xfree (fname); xfree (envstr); } xfree (homestr); } /* Set the card removed flag for all current sessions. */ if (vr->any && vr->status == 0 && set_card_removed_flag) update_card_removed (idx, 1); vr->any = 1; /* Send a signal to all clients who applied for it. */ send_client_notifications (); } /* Check whether a disconnect is pending. */ if (opt.card_timeout) { for (sl=session_list; sl; sl = sl->next_session) if (!sl->disconnect_allowed) break; if (session_list && !sl) { /* FIXME: Use a real timeout. */ /* At least one connection and all allow a disconnect. */ log_info ("disconnecting card in reader %d (%d)\n", idx, vr->slot); apdu_disconnect (vr->slot); } } } }
0
487,616
asmlinkage long sys_getsid(pid_t pid) { if (!pid) return process_session(current); else { int retval; struct task_struct *p; read_lock(&tasklist_lock); p = find_task_by_pid(pid); retval = -ESRCH; if (p) { retval = security_task_getsid(p); if (!retval) retval = process_session(p); } read_unlock(&tasklist_lock); return retval; } }
0
488,328
static void __init vdso_setup_syscall_map(void) { unsigned int i; extern unsigned long *sys_call_table; extern unsigned long sys_ni_syscall; for (i = 0; i < __NR_syscalls; i++) { #ifdef CONFIG_PPC64 if (sys_call_table[i*2] != sys_ni_syscall) vdso_data->syscall_map_64[i >> 5] |= 0x80000000UL >> (i & 0x1f); if (sys_call_table[i*2+1] != sys_ni_syscall) vdso_data->syscall_map_32[i >> 5] |= 0x80000000UL >> (i & 0x1f); #else /* CONFIG_PPC64 */ if (sys_call_table[i] != sys_ni_syscall) vdso_data->syscall_map_32[i >> 5] |= 0x80000000UL >> (i & 0x1f); #endif /* CONFIG_PPC64 */ } }
0
254,033
static int v4l2_loopback_close(struct file *file) { struct v4l2_loopback_opener *opener; struct v4l2_loopback_device *dev; int iswriter=0; MARK(); opener = file->private_data; dev = v4l2loopback_getdevice(file); if(WRITER == opener->type) iswriter = 1; atomic_dec(&dev->open_count); if (dev->open_count.counter == 0) { del_timer_sync(&dev->sustain_timer); del_timer_sync(&dev->timeout_timer); } try_free_buffers(dev); kfree(opener); if(iswriter) { dev->ready_for_output = 1; } MARK(); return 0; }
0
468,340
g_socket_client_set_enable_proxy (GSocketClient *client, gboolean enable) { enable = !!enable; if (client->priv->enable_proxy == enable) return; client->priv->enable_proxy = enable; g_object_notify (G_OBJECT (client), "enable-proxy"); }
0
409,494
add_long_to_buf(long_u val, char_u *dst) { int i; int shift; for (i = 1; i <= (int)sizeof(long_u); i++) { shift = 8 * (sizeof(long_u) - i); dst[i - 1] = (char_u) ((val >> shift) & 0xff); } }
0
338,100
WasmBinaryBuilder::WasmBinaryBuilder(Module& wasm, FeatureSet features, const std::vector<char>& input) : wasm(wasm), allocator(wasm.allocator), input(input), sourceMap(nullptr), nextDebugLocation(0, {0, 0, 0}), debugLocation() { wasm.features = features; }
0
294,710
d_lite_fill(VALUE self) { get_d1(self); if (simple_dat_p(dat)) { get_s_jd(dat); get_s_civil(dat); } else { get_c_jd(dat); get_c_civil(dat); get_c_df(dat); get_c_time(dat); } return self; }
0
254,072
inline std::unique_ptr<std::pair<std::string, std::string>> qs_dict_name2kv(const char * dict_name, char * const * qs_kv, int qs_kv_size, int nth = 0) { int i; size_t name_len, skip_to_eq, skip_to_brace_open, skip_to_brace_close; name_len = strlen(dict_name); #ifdef _qsSORTING // TODO: binary search for key in the sorted qs_kv #else // _qsSORTING for(i=0; i<qs_kv_size; i++) { if ( strncmp(dict_name, qs_kv[i], name_len) == 0 ) { skip_to_eq = strcspn(qs_kv[i], "="); if ( qs_kv[i][skip_to_eq] == '=' ) skip_to_eq++; skip_to_brace_open = strcspn(qs_kv[i], "["); if ( qs_kv[i][skip_to_brace_open] == '[' ) skip_to_brace_open++; skip_to_brace_close = strcspn(qs_kv[i], "]"); if ( skip_to_brace_open <= skip_to_brace_close && skip_to_brace_open > 0 && skip_to_brace_close > 0 && nth == 0 ) { auto key = std::string(qs_kv[i] + skip_to_brace_open, skip_to_brace_close - skip_to_brace_open); auto value = std::string(qs_kv[i] + skip_to_eq); return std::unique_ptr<std::pair<std::string, std::string>>(new std::pair<std::string, std::string>(key, value)); } else { --nth; } } } #endif // _qsSORTING return nullptr; }
0
233,848
static int de_fmtutil_default_iff_chunk_handler(deark *c, struct de_iffctx *ictx) { i64 dpos = ictx->chunkctx->dpos; i64 dlen = ictx->chunkctx->dlen; u32 chunktype = ictx->chunkctx->chunk4cc.id; switch(chunktype) { // Note that chunks appearing here should also be listed below, // in de_fmtutil_is_standard_iff_chunk(). case CODE__c_: do_iff_text_chunk(c, ictx, dpos, dlen, "copyright"); break; case CODE_ANNO: do_iff_anno(c, ictx, dpos, dlen); break; case CODE_AUTH: do_iff_text_chunk(c, ictx, dpos, dlen, "author"); break; case CODE_NAME: do_iff_text_chunk(c, ictx, dpos, dlen, "name"); break; case CODE_TEXT: do_iff_text_chunk(c, ictx, dpos, dlen, "text"); break; } // Note we do not set ictx->handled. The caller is responsible for that. return 1; }
0
473,979
unpack_entries(register st_table *table) { st_index_t i; struct st_table_entry *packed_bins[MAX_PACKED_NUMHASH*2]; st_table tmp_table = *table; memcpy(packed_bins, table->bins, sizeof(struct st_table_entry *) * table->num_entries*2); table->bins = packed_bins; tmp_table.entries_packed = 0; tmp_table.num_entries = 0; memset(tmp_table.bins, 0, sizeof(struct st_table_entry *) * tmp_table.num_bins); for (i = 0; i < table->num_entries; i++) { st_insert(&tmp_table, (st_data_t)packed_bins[i*2], (st_data_t)packed_bins[i*2+1]); } *table = tmp_table; }
0
221,485
extract_unix_path_from_dbus_address (const char *address) { const char *path, *path_end; if (address == NULL) return NULL; if (!g_str_has_prefix (address, "unix:")) return NULL; path = strstr (address, "path="); if (path == NULL) return NULL; path += strlen ("path="); path_end = path; while (*path_end != 0 && *path_end != ',') path_end++; return g_strndup (path, path_end - path); }
0
294,658
c_jd_to_wday(int jd) { return MOD(jd + 1, 7); }
0
404,730
static struct file *__fget_files(struct files_struct *files, unsigned int fd, fmode_t mask, unsigned int refs) { struct file *file; rcu_read_lock(); loop: file = files_lookup_fd_rcu(files, fd); if (file) { /* File object ref couldn't be taken. * dup2() atomicity guarantee is the reason * we loop to catch the new file (or NULL pointer) */ if (file->f_mode & mask) file = NULL; else if (!get_file_rcu_many(file, refs)) goto loop; else if (files_lookup_fd_raw(files, fd) != file) { fput_many(file, refs); goto loop; } } rcu_read_unlock(); return file; }
0
238,384
njs_function_prototype_thrower(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, njs_index_t unused) { njs_type_error(vm, "\"caller\", \"callee\", \"arguments\" " "properties may not be accessed"); return NJS_ERROR; }
0
417,129
void PlayerGeneric::nextPattern() { if (player) player->nextPattern(); }
0
384,535
void MACH0_(mach_headerfields)(RBinFile *bf) { PrintfCallback cb_printf = bf->rbin->cb_printf; if (!cb_printf) { cb_printf = printf; } RBuffer *buf = bf->buf; ut64 length = r_buf_size (buf); int n = 0; struct MACH0_(mach_header) *mh = MACH0_(get_hdr)(buf); if (!mh) { return; } ut64 pvaddr = pa2va (bf, 0); cb_printf ("pf.mach0_header @ 0x%08"PFMT64x"\n", pvaddr); cb_printf ("0x%08"PFMT64x" Magic 0x%x\n", pvaddr, mh->magic); pvaddr += 4; cb_printf ("0x%08"PFMT64x" CpuType 0x%x\n", pvaddr, mh->cputype); pvaddr += 4; cb_printf ("0x%08"PFMT64x" CpuSubType 0x%x\n", pvaddr, mh->cpusubtype); pvaddr += 4; cb_printf ("0x%08"PFMT64x" FileType 0x%x\n", pvaddr, mh->filetype); pvaddr += 4; cb_printf ("0x%08"PFMT64x" nCmds %d\n", pvaddr, mh->ncmds); pvaddr += 4; cb_printf ("0x%08"PFMT64x" sizeOfCmds %d\n", pvaddr, mh->sizeofcmds); pvaddr += 4; cb_printf ("0x%08"PFMT64x" Flags 0x%x\n", pvaddr, mh->flags); pvaddr += 4; bool is64 = mh->cputype >> 16; ut64 addr = 0x20 - 4; ut32 word = 0; ut8 wordbuf[sizeof (word)]; bool isBe = false; switch (mh->cputype) { case CPU_TYPE_POWERPC: case CPU_TYPE_POWERPC64: isBe = true; break; } #define READWORD() \ if (r_buf_read_at (buf, addr, (ut8*)wordbuf, 4) != 4) { \ eprintf ("Invalid address in buffer."); \ break; \ } \ addr += 4; \ pvaddr += 4;\ word = isBe? r_read_be32 (wordbuf): r_read_le32 (wordbuf); if (is64) { addr += 4; pvaddr += 4; } for (n = 0; n < mh->ncmds && addr < length; n++) { READWORD (); ut32 lcType = word; const char *pf_definition = cmd_to_pf_definition (lcType); if (pf_definition) { cb_printf ("pf.%s @ 0x%08"PFMT64x"\n", pf_definition, pvaddr - 4); } cb_printf ("0x%08"PFMT64x" cmd %7d 0x%x %s\n", pvaddr - 4, n, lcType, cmd_to_string (lcType)); READWORD (); if (addr > length) { break; } int lcSize = word; word &= 0xFFFFFF; cb_printf ("0x%08"PFMT64x" cmdsize %d\n", pvaddr - 4, word); if (lcSize < 1) { eprintf ("Invalid size for a load command\n"); break; } switch (lcType) { case LC_BUILD_VERSION: { cb_printf ("0x%08"PFMT64x" platform %s\n", pvaddr, build_version_platform_to_string (r_buf_read_le32_at (buf, addr))); cb_printf ("0x%08"PFMT64x" minos %d.%d.%d\n", pvaddr + 4, r_buf_read_le16_at (buf, addr + 6), r_buf_read8_at (buf, addr + 5), r_buf_read8_at (buf, addr + 4)); cb_printf ("0x%08"PFMT64x" sdk %d.%d.%d\n", pvaddr + 8, r_buf_read_le16_at (buf, addr + 10), r_buf_read8_at (buf, addr + 9), r_buf_read8_at (buf, addr + 8)); ut32 ntools = r_buf_read_le32_at (buf, addr + 12); cb_printf ("0x%08"PFMT64x" ntools %d\n", pvaddr + 12, ntools); ut64 off = 16; while (off < (lcSize - 8) && ntools--) { cb_printf ("pf.mach0_build_version_tool @ 0x%08"PFMT64x"\n", pvaddr + off); cb_printf ("0x%08"PFMT64x" tool %s\n", pvaddr + off, build_version_tool_to_string (r_buf_read_le32_at (buf, addr + off))); off += 4; if (off >= (lcSize - 8)) { break; } cb_printf ("0x%08"PFMT64x" version %d.%d.%d\n", pvaddr + off, r_buf_read_le16_at (buf, addr + off + 2), r_buf_read8_at (buf, addr + off + 1), r_buf_read8_at (buf, addr + off)); off += 4; } break; } case LC_MAIN: { ut8 data[64] = {0}; r_buf_read_at (buf, addr, data, sizeof (data)); #if R_BIN_MACH064 ut64 ep = r_read_ble64 (&data, false); // bin->big_endian); cb_printf ("0x%08"PFMT64x" entry0 0x%" PFMT64x "\n", pvaddr, ep); ut64 ss = r_read_ble64 (&data[8], false); // bin->big_endian); cb_printf ("0x%08"PFMT64x" stacksize 0x%" PFMT64x "\n", pvaddr + 8, ss); #else ut32 ep = r_read_ble32 (&data, false); // bin->big_endian); cb_printf ("0x%08"PFMT32x" entry0 0x%" PFMT32x "\n", (ut32)pvaddr, ep); ut32 ss = r_read_ble32 (&data[4], false); // bin->big_endian); cb_printf ("0x%08"PFMT32x" stacksize 0x%" PFMT32x "\n", (ut32)pvaddr + 4, ss); #endif } break; case LC_SYMTAB: #if 0 { char *id = r_buf_get_string (buf, addr + 20); cb_printf ("0x%08"PFMT64x" id 0x%x\n", addr + 20, r_str_get (id)); cb_printf ("0x%08"PFMT64x" symooff 0x%x\n", addr + 20, r_str_get (id)); cb_printf ("0x%08"PFMT64x" nsyms %d\n", addr + 20, r_str_get (id)); cb_printf ("0x%08"PFMT64x" stroff 0x%x\n", addr + 20, r_str_get (id)); cb_printf ("0x%08"PFMT64x" strsize 0x%x\n", addr + 20, r_str_get (id)); free (id); } #endif break; case LC_ID_DYLIB: { // install_name_tool ut32 str_off = r_buf_read_ble32_at (buf, addr, isBe); char *id = r_buf_get_string (buf, addr + str_off - 8); cb_printf ("0x%08"PFMT64x" current %d.%d.%d\n", pvaddr + 8, r_buf_read_le16_at (buf, addr + 10), r_buf_read8_at (buf, addr + 9), r_buf_read8_at (buf, addr + 8)); cb_printf ("0x%08"PFMT64x" compat %d.%d.%d\n", pvaddr + 12, r_buf_read_le16_at (buf, addr + 14), r_buf_read8_at (buf, addr + 13), r_buf_read8_at (buf, addr + 12)); cb_printf ("0x%08"PFMT64x" id %s\n", pvaddr + str_off - 8, r_str_get (id)); if (id) { free (id); } break; } case LC_UUID: { ut8 i, uuid[16]; r_buf_read_at (buf, addr, uuid, sizeof (uuid)); cb_printf ("0x%08"PFMT64x" uuid ", pvaddr); for (i = 0; i < sizeof (uuid); i++) { cb_printf ("%02x", uuid[i]); } cb_printf ("\n"); } break; case LC_SEGMENT: case LC_SEGMENT_64: { ut8 name[17] = {0}; r_buf_read_at (buf, addr, name, sizeof (name) - 1); cb_printf ("0x%08"PFMT64x" name %s\n", pvaddr, name); ut32 nsects = r_buf_read_le32_at (buf, addr - 8 + (is64 ? 64 : 48)); ut64 off = is64 ? 72 : 56; while (off < lcSize && nsects--) { if (is64) { cb_printf ("pf.mach0_section64 @ 0x%08"PFMT64x"\n", pvaddr - 8 + off); off += 80; } else { cb_printf ("pf.mach0_section @ 0x%08"PFMT64x"\n", pvaddr - 8 + off); off += 68; } } } break; case LC_LOAD_DYLIB: case LC_LOAD_WEAK_DYLIB: { ut32 str_off = r_buf_read_ble32_at (buf, addr, isBe); char *load_dylib = r_buf_get_string (buf, addr + str_off - 8); cb_printf ("0x%08"PFMT64x" current %d.%d.%d\n", pvaddr + 8, r_buf_read_le16_at (buf, addr + 10), r_buf_read8_at (buf, addr + 9), r_buf_read8_at (buf, addr + 8)); cb_printf ("0x%08"PFMT64x" compat %d.%d.%d\n", pvaddr + 12, r_buf_read_le16_at (buf, addr + 14), r_buf_read8_at (buf, addr + 13), r_buf_read8_at (buf, addr + 12)); cb_printf ("0x%08"PFMT64x" load_dylib %s\n", pvaddr + str_off - 8, r_str_get (load_dylib)); if (load_dylib) { free (load_dylib); } break; } case LC_RPATH: { char *rpath = r_buf_get_string (buf, addr + 4); cb_printf ("0x%08" PFMT64x " rpath %s\n", pvaddr + 4, r_str_get (rpath)); if (rpath) { free (rpath); } break; } case LC_ENCRYPTION_INFO: case LC_ENCRYPTION_INFO_64: { ut32 word = r_buf_read_le32_at (buf, addr); cb_printf ("0x%08"PFMT64x" cryptoff 0x%08x\n", pvaddr, word); word = r_buf_read_le32_at (buf, addr + 4); cb_printf ("0x%08"PFMT64x" cryptsize %d\n", pvaddr + 4, word); word = r_buf_read_le32_at (buf, addr + 8); cb_printf ("0x%08"PFMT64x" cryptid %d\n", pvaddr + 8, word); break; } case LC_CODE_SIGNATURE: { ut32 words[2]; r_buf_read_at (buf, addr, (ut8 *)words, sizeof (words)); cb_printf ("0x%08"PFMT64x" dataoff 0x%08x\n", pvaddr, words[0]); cb_printf ("0x%08"PFMT64x" datasize %d\n", pvaddr + 4, words[1]); cb_printf ("# wtf mach0.sign %d @ 0x%x\n", words[1], words[0]); break; } } addr += word - 8; pvaddr += word - 8; } free (mh); }
0
252,299
static mz_bool tdefl_compress_block(tdefl_compressor *d, mz_bool static_block) { if (static_block) tdefl_start_static_block(d); else tdefl_start_dynamic_block(d); return tdefl_compress_lz_codes(d); }
0
336,581
SPICE_GNUC_VISIBLE void spice_server_set_addr(SpiceServer *reds, const char *addr, int flags) { g_strlcpy(reds->config->spice_addr, addr, sizeof(reds->config->spice_addr)); if (flags == SPICE_ADDR_FLAG_IPV4_ONLY) { reds->config->spice_family = PF_INET; } else if (flags == SPICE_ADDR_FLAG_IPV6_ONLY) { reds->config->spice_family = PF_INET6; } else if (flags == SPICE_ADDR_FLAG_UNIX_ONLY) { reds->config->spice_family = AF_UNIX; } else if (flags != 0) { spice_warning("unknown address flag: 0x%X", flags); } }
0
261,244
static int SN_Client_HandlePacket(MqttClient* client, SN_MsgType packet_type, void* packet_obj, int timeout) { int rc = MQTT_CODE_SUCCESS; word16 packet_id = 0; (void)timeout; switch ((int)packet_type) { case SN_MSG_TYPE_GWINFO: { SN_GwInfo info, *p_info = &info; if (packet_obj) { p_info = (SN_GwInfo*)packet_obj; } else { XMEMSET(p_info, 0, sizeof(SN_GwInfo)); } rc = SN_Decode_GWInfo(client->rx_buf, client->packet.buf_len, p_info); if (rc <= 0) { return rc; } break; } case SN_MSG_TYPE_CONNACK: { /* Decode connect ack */ SN_ConnectAck connect_ack, *p_connect_ack = &connect_ack; if (packet_obj) { p_connect_ack = (SN_ConnectAck*)packet_obj; } else { XMEMSET(p_connect_ack, 0, sizeof(SN_ConnectAck)); } p_connect_ack->return_code = client->rx_buf[client->packet.buf_len-1]; break; } case SN_MSG_TYPE_WILLTOPICREQ: { rc = SN_Decode_WillTopicReq(client->rx_buf, client->packet.buf_len); break; } case SN_MSG_TYPE_WILLMSGREQ: { rc = SN_Decode_WillMsgReq(client->rx_buf, client->packet.buf_len); break; } case SN_MSG_TYPE_REGISTER: { /* Decode register */ SN_Register reg_s; int len; XMEMSET(&reg_s, 0, sizeof(SN_Register)); rc = SN_Decode_Register(client->rx_buf, client->packet.buf_len, &reg_s); if (rc > 0) { /* Initialize the regack */ reg_s.regack.packet_id = reg_s.packet_id; reg_s.regack.topicId = reg_s.topicId; reg_s.regack.return_code = SN_RC_NOTSUPPORTED; /* Call the register callback to allow app to handle new topic ID assignment. */ if (client->reg_cb != NULL) { rc = client->reg_cb(reg_s.topicId, reg_s.topicName, client->reg_ctx); /* Set the regack return code */ reg_s.regack.return_code = (rc >= 0) ? SN_RC_ACCEPTED : SN_RC_INVTOPICNAME; } #ifdef WOLFMQTT_MULTITHREAD /* Lock send socket mutex */ rc = wm_SemLock(&client->lockSend); if (rc != 0) { return rc; } #endif /* Encode the register acknowledgment */ rc = SN_Encode_RegAck(client->tx_buf, client->tx_buf_len, &reg_s.regack); #ifdef WOLFMQTT_DEBUG_CLIENT PRINTF("MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d", rc, SN_Packet_TypeDesc(SN_MSG_TYPE_REGACK), SN_MSG_TYPE_REGACK, reg_s.packet_id); #endif if (rc <= 0) { #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif return rc; } len = rc; /* Send regack packet */ rc = MqttPacket_Write(client, client->tx_buf, len); #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif if (rc != len) { return rc; } } break; } case SN_MSG_TYPE_REGACK: { /* Decode register ack */ SN_RegAck regack_s, *p_regack = &regack_s; if (packet_obj) { p_regack = (SN_RegAck*)packet_obj; } else { XMEMSET(p_regack, 0, sizeof(SN_RegAck)); } rc = SN_Decode_RegAck(client->rx_buf, client->packet.buf_len, p_regack); if (rc > 0) { packet_id = p_regack->packet_id; } break; } case SN_MSG_TYPE_PUBLISH: { SN_Publish pub, *p_pub = &pub; if (packet_obj) { p_pub = (SN_Publish*)packet_obj; } else { XMEMSET(p_pub, 0, sizeof(SN_Publish)); } /* Decode publish message */ rc = SN_Decode_Publish(client->rx_buf, client->packet.buf_len, p_pub); if (rc <= 0) { return rc; } /* Issue callback for new message */ if (client->msg_cb) { /* if using the temp publish message buffer, then populate message context with client context */ if (&client->msgSN.publish == p_pub) p_pub->ctx = client->ctx; rc = client->msg_cb(client, (MqttMessage*)p_pub, 1, 1); if (rc != MQTT_CODE_SUCCESS) { return rc; }; } /* Handle Qos */ if (p_pub->qos > MQTT_QOS_0) { SN_MsgType type; packet_id = p_pub->packet_id; /* Determine packet type to write */ type = (p_pub->qos == MQTT_QOS_1) ? SN_MSG_TYPE_PUBACK : SN_MSG_TYPE_PUBREC; p_pub->resp.packet_id = packet_id; #ifdef WOLFMQTT_MULTITHREAD /* Lock send socket mutex */ rc = wm_SemLock(&client->lockSend); if (rc != 0) { return rc; } #endif /* Encode publish response */ rc = SN_Encode_PublishResp(client->tx_buf, client->tx_buf_len, type, &p_pub->resp); #ifdef WOLFMQTT_DEBUG_CLIENT PRINTF("MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d," " QoS %d", rc, SN_Packet_TypeDesc(type), type, packet_id, p_pub->qos); #endif if (rc <= 0) { #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif return rc; } client->packet.buf_len = rc; /* Send packet */ rc = MqttPacket_Write(client, client->tx_buf, client->packet.buf_len); #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif } break; } case SN_MSG_TYPE_PUBACK: case SN_MSG_TYPE_PUBCOMP: case SN_MSG_TYPE_PUBREC: case SN_MSG_TYPE_PUBREL: { SN_PublishResp publish_resp; XMEMSET(&publish_resp, 0, sizeof(SN_PublishResp)); /* Decode publish response message */ rc = SN_Decode_PublishResp(client->rx_buf, client->packet.buf_len, packet_type, &publish_resp); if (rc <= 0) { return rc; } packet_id = publish_resp.packet_id; /* If Qos then send response */ if (packet_type == SN_MSG_TYPE_PUBREC || packet_type == SN_MSG_TYPE_PUBREL) { byte resp_type = (packet_type == SN_MSG_TYPE_PUBREC) ? SN_MSG_TYPE_PUBREL : SN_MSG_TYPE_PUBCOMP; #ifdef WOLFMQTT_MULTITHREAD /* Lock send socket mutex */ rc = wm_SemLock(&client->lockSend); if (rc != 0) { return rc; } #endif /* Encode publish response */ publish_resp.packet_id = packet_id; rc = SN_Encode_PublishResp(client->tx_buf, client->tx_buf_len, resp_type, &publish_resp); #ifdef WOLFMQTT_DEBUG_CLIENT PRINTF("MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d", rc, MqttPacket_TypeDesc(resp_type), resp_type, packet_id); #endif if (rc <= 0) { #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif return rc; } client->packet.buf_len = rc; /* Send packet */ rc = MqttPacket_Write(client, client->tx_buf, client->packet.buf_len); #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif } break; } case SN_MSG_TYPE_SUBACK: { /* Decode subscribe ack */ SN_SubAck subscribe_ack, *p_subscribe_ack = &subscribe_ack; if (packet_obj) { p_subscribe_ack = (SN_SubAck*)packet_obj; } else { XMEMSET(p_subscribe_ack, 0, sizeof(SN_SubAck)); } rc = SN_Decode_SubscribeAck(client->rx_buf, client->packet.buf_len, p_subscribe_ack); if (rc <= 0) { return rc; } packet_id = p_subscribe_ack->packet_id; break; } case SN_MSG_TYPE_UNSUBACK: { /* Decode unsubscribe ack */ SN_UnsubscribeAck unsubscribe_ack, *p_unsubscribe_ack = &unsubscribe_ack; if (packet_obj) { p_unsubscribe_ack = (SN_UnsubscribeAck*)packet_obj; } else { XMEMSET(p_unsubscribe_ack, 0, sizeof(SN_UnsubscribeAck)); } rc = SN_Decode_UnsubscribeAck(client->rx_buf, client->packet.buf_len, p_unsubscribe_ack); if (rc <= 0) { return rc; } packet_id = p_unsubscribe_ack->packet_id; break; } case SN_MSG_TYPE_PING_RESP: { /* Decode ping */ rc = SN_Decode_Ping(client->rx_buf, client->packet.buf_len); break; } case SN_MSG_TYPE_PING_REQ: { int len; /* Decode ping */ rc = SN_Decode_Ping(client->rx_buf, client->packet.buf_len); if (rc <= 0) { return rc; } #ifdef WOLFMQTT_MULTITHREAD /* Lock send socket mutex */ rc = wm_SemLock(&client->lockSend); if (rc != 0) { return rc; } #endif /* Encode the ping packet as a response */ rc = SN_Encode_Ping(client->tx_buf, client->tx_buf_len, NULL, SN_MSG_TYPE_PING_RESP); #ifdef WOLFMQTT_DEBUG_CLIENT PRINTF("MqttClient_EncodePacket: Len %d, Type %s (%d)", rc, SN_Packet_TypeDesc(SN_MSG_TYPE_PING_RESP), SN_MSG_TYPE_PING_RESP); #endif if (rc <= 0) { #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif return rc; } len = rc; /* Send ping resp packet */ rc = MqttPacket_Write(client, client->tx_buf, len); #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif if (rc != len) { return rc; } break; } case SN_MSG_TYPE_WILLTOPICRESP: { /* Decode Will Topic Response */ SN_WillTopicResp resp_s, *resp = &resp_s; if (packet_obj) { resp = (SN_WillTopicResp*)packet_obj; } else { XMEMSET(resp, 0, sizeof(SN_WillTopicResp)); } rc = SN_Decode_WillTopicResponse(client->rx_buf, client->packet.buf_len, &resp->return_code); break; } case SN_MSG_TYPE_WILLMSGRESP: { /* Decode Will Message Response */ SN_WillMsgResp resp_s, *resp = &resp_s; if (packet_obj) { resp = (SN_WillMsgResp*)packet_obj; } else { XMEMSET(resp, 0, sizeof(SN_WillMsgResp)); } rc = SN_Decode_WillMsgResponse(client->rx_buf, client->packet.buf_len, &resp->return_code); break; } case SN_MSG_TYPE_DISCONNECT: { /* Decode Disconnect */ rc = SN_Decode_Disconnect(client->rx_buf, client->packet.buf_len); break; } default: { /* Other types are server side only, ignore */ #ifdef WOLFMQTT_DEBUG_CLIENT PRINTF("SN_Client_HandlePacket: Invalid client packet type %u!", packet_type); #endif break; } } /* switch (packet_type) */ (void)packet_id; return rc; }
0