idx
int64
func
string
target
int64
253,984
static int vidioc_g_std(struct file *file, void *private_data, v4l2_std_id *norm) { if (norm) *norm = V4L2_STD_ALL; return 0; }
0
90,895
void ClientUsageTracker::GetCachedOrigins(std::set<GURL>* origins) const { DCHECK(origins); for (HostUsageMap::const_iterator host_iter = cached_usage_.begin(); host_iter != cached_usage_.end(); host_iter++) { const UsageMap& origin_map = host_iter->second; for (UsageMap::const_iterator origin_iter = origin_map.begin(); origin_iter != origin_map.end(); origin_iter++) { origins->insert(origin_iter->first); } } }
0
220,108
static void __nfs42_ssc_close(struct file *filep) { struct nfs_open_context *ctx = nfs_file_open_context(filep); ctx->state->flags = 0; }
0
294,686
date_s_jd(int argc, VALUE *argv, VALUE klass) { VALUE vjd, vsg, jd, fr, fr2, ret; double sg; rb_scan_args(argc, argv, "02", &vjd, &vsg); jd = INT2FIX(0); fr2 = INT2FIX(0); sg = DEFAULT_SG; switch (argc) { case 2: val2sg(vsg, sg); case 1: check_numeric(vjd, "jd"); num2num_with_frac(jd, positive_inf); } { VALUE nth; int rjd; decode_jd(jd, &nth, &rjd); ret = d_simple_new_internal(klass, nth, rjd, sg, 0, 0, 0, HAVE_JD); } add_frac(); return ret; }
0
365,619
_asn1_delete_list_and_nodes (void) { list_type *listElement; while (firstElement) { listElement = firstElement; firstElement = firstElement->next; _asn1_remove_node (listElement->node, 0); free (listElement); } }
0
411,786
handle_method_call (GDBusConnection *connection, const gchar *sender, const gchar *object_path, const gchar *interface_name, const gchar *method_name, GVariant *parameters, GDBusMethodInvocation *invocation, gpointer user_data) { A11yBusLauncher *app = user_data; if (g_strcmp0 (method_name, "GetAddress") == 0) { ensure_a11y_bus (app); if (app->a11y_bus_pid > 0) g_dbus_method_invocation_return_value (invocation, g_variant_new ("(s)", app->a11y_bus_address)); else g_dbus_method_invocation_return_dbus_error (invocation, "org.a11y.Bus.Error", app->a11y_launch_error_message); } }
0
453,029
int nft_flow_rule_stats(const struct nft_chain *chain, const struct nft_rule *rule) { struct flow_cls_offload cls_flow = {}; struct nft_expr *expr, *next; int err; err = nft_flow_offload_cmd(chain, rule, NULL, FLOW_CLS_STATS, &cls_flow); if (err < 0) return err; nft_rule_for_each_expr(expr, next, rule) { if (expr->ops->offload_stats) expr->ops->offload_stats(expr, &cls_flow.stats); } return 0; }
0
294,508
decode_jd(VALUE jd, VALUE *nth, int *rjd) { *nth = f_idiv(jd, INT2FIX(CM_PERIOD)); if (f_zero_p(*nth)) { *rjd = FIX2INT(jd); return; } *rjd = FIX2INT(f_mod(jd, INT2FIX(CM_PERIOD))); }
0
236,156
GF_Err href_box_write(GF_Box *s, GF_BitStream *bs) { u32 len; GF_Err e; GF_TextHyperTextBox*ptr = (GF_TextHyperTextBox*)s; e = gf_isom_box_write_header(s, bs); if (e) return e; gf_bs_write_u16(bs, ptr->startcharoffset); gf_bs_write_u16(bs, ptr->endcharoffset); if (ptr->URL) { len = (u32) strlen(ptr->URL); gf_bs_write_u8(bs, len); gf_bs_write_data(bs, ptr->URL, len); } else { gf_bs_write_u8(bs, 0); } if (ptr->URL_hint) { len = (u32) strlen(ptr->URL_hint); gf_bs_write_u8(bs, len); gf_bs_write_data(bs, ptr->URL_hint, len); } else { gf_bs_write_u8(bs, 0); } return GF_OK; }
0
447,068
void FileIo::transfer(BasicIo& src) { const bool wasOpen = (p_->fp_ != 0); const std::string lastMode(p_->openMode_); FileIo *fileIo = dynamic_cast<FileIo*>(&src); if (fileIo) { // Optimization if src is another instance of FileIo fileIo->close(); // Check if the file can be written to, if it already exists if (open("a+b") != 0) { // Remove the (temporary) file #ifdef EXV_UNICODE_PATH if (fileIo->p_->wpMode_ == Impl::wpUnicode) { ::_wremove(fileIo->wpath().c_str()); } else #endif { ::remove(fileIo->path().c_str()); } #ifdef EXV_UNICODE_PATH if (p_->wpMode_ == Impl::wpUnicode) { throw WError(10, wpath(), "a+b", strError().c_str()); } else #endif { throw Error(10, path(), "a+b", strError()); } } close(); bool statOk = true; mode_t origStMode = 0; std::string spf; char* pf = 0; #ifdef EXV_UNICODE_PATH std::wstring wspf; wchar_t* wpf = 0; if (p_->wpMode_ == Impl::wpUnicode) { wspf = wpath(); wpf = const_cast<wchar_t*>(wspf.c_str()); } else #endif { spf = path(); pf = const_cast<char*>(spf.c_str()); } // Get the permissions of the file, or linked-to file, on platforms which have lstat #ifdef EXV_HAVE_LSTAT # ifdef EXV_UNICODE_PATH # error EXV_UNICODE_PATH and EXV_HAVE_LSTAT are not compatible. Stop. # endif struct stat buf1; if (::lstat(pf, &buf1) == -1) { statOk = false; #ifndef SUPPRESS_WARNINGS EXV_WARNING << Error(2, pf, strError(), "::lstat") << "\n"; #endif } origStMode = buf1.st_mode; DataBuf lbuf; // So that the allocated memory is freed. Must have same scope as pf // In case path() is a symlink, get the path of the linked-to file if (statOk && S_ISLNK(buf1.st_mode)) { lbuf.alloc(buf1.st_size + 1); memset(lbuf.pData_, 0x0, lbuf.size_); pf = reinterpret_cast<char*>(lbuf.pData_); if (::readlink(path().c_str(), pf, lbuf.size_ - 1) == -1) { throw Error(2, path(), strError(), "readlink"); } // We need the permissions of the file, not the symlink if (::stat(pf, &buf1) == -1) { statOk = false; #ifndef SUPPRESS_WARNINGS EXV_WARNING << Error(2, pf, strError(), "::stat") << "\n"; #endif } origStMode = buf1.st_mode; } #else // EXV_HAVE_LSTAT Impl::StructStat buf1; if (p_->stat(buf1) == -1) { statOk = false; } origStMode = buf1.st_mode; #endif // !EXV_HAVE_LSTAT // MSVCRT rename that does not overwrite existing files #ifdef EXV_UNICODE_PATH if (p_->wpMode_ == Impl::wpUnicode) { #if defined(WIN32) && defined(REPLACEFILE_IGNORE_MERGE_ERRORS) // Windows implementation that deals with the fact that ::rename fails // if the target filename still exists, which regularly happens when // that file has been opened with FILE_SHARE_DELETE by another process, // like a virus scanner or disk indexer // (see also http://stackoverflow.com/a/11023068) typedef BOOL (WINAPI * ReplaceFileW_t)(LPCWSTR, LPCWSTR, LPCWSTR, DWORD, LPVOID, LPVOID); HMODULE hKernel = ::GetModuleHandleA("kernel32.dll"); if (hKernel) { ReplaceFileW_t pfcn_ReplaceFileW = (ReplaceFileW_t)GetProcAddress(hKernel, "ReplaceFileW"); if (pfcn_ReplaceFileW) { BOOL ret = pfcn_ReplaceFileW(wpf, fileIo->wpath().c_str(), NULL, REPLACEFILE_IGNORE_MERGE_ERRORS, NULL, NULL); if (ret == 0) { if (GetLastError() == ERROR_FILE_NOT_FOUND) { if (::_wrename(fileIo->wpath().c_str(), wpf) == -1) { throw WError(17, fileIo->wpath(), wpf, strError().c_str()); } ::_wremove(fileIo->wpath().c_str()); } else { throw WError(17, fileIo->wpath(), wpf, strError().c_str()); } } } else { if (fileExists(wpf) && ::_wremove(wpf) != 0) { throw WError(2, wpf, strError().c_str(), "::_wremove"); } if (::_wrename(fileIo->wpath().c_str(), wpf) == -1) { throw WError(17, fileIo->wpath(), wpf, strError().c_str()); } ::_wremove(fileIo->wpath().c_str()); } } #else if (fileExists(wpf) && ::_wremove(wpf) != 0) { throw WError(2, wpf, strError().c_str(), "::_wremove"); } if (::_wrename(fileIo->wpath().c_str(), wpf) == -1) { throw WError(17, fileIo->wpath(), wpf, strError().c_str()); } ::_wremove(fileIo->wpath().c_str()); #endif // Check permissions of new file struct _stat buf2; if (statOk && ::_wstat(wpf, &buf2) == -1) { statOk = false; #ifndef SUPPRESS_WARNINGS EXV_WARNING << Error(2, wpf, strError(), "::_wstat") << "\n"; #endif } if (statOk && origStMode != buf2.st_mode) { // Set original file permissions if (::_wchmod(wpf, origStMode) == -1) { #ifndef SUPPRESS_WARNINGS EXV_WARNING << Error(2, wpf, strError(), "::_wchmod") << "\n"; #endif } } } // if (p_->wpMode_ == Impl::wpUnicode) else #endif // EXV_UNICODE_PATH { #if defined(WIN32) && defined(REPLACEFILE_IGNORE_MERGE_ERRORS) // Windows implementation that deals with the fact that ::rename fails // if the target filename still exists, which regularly happens when // that file has been opened with FILE_SHARE_DELETE by another process, // like a virus scanner or disk indexer // (see also http://stackoverflow.com/a/11023068) typedef BOOL (WINAPI * ReplaceFileA_t)(LPCSTR, LPCSTR, LPCSTR, DWORD, LPVOID, LPVOID); HMODULE hKernel = ::GetModuleHandleA("kernel32.dll"); if (hKernel) { ReplaceFileA_t pfcn_ReplaceFileA = (ReplaceFileA_t)GetProcAddress(hKernel, "ReplaceFileA"); if (pfcn_ReplaceFileA) { BOOL ret = pfcn_ReplaceFileA(pf, fileIo->path().c_str(), NULL, REPLACEFILE_IGNORE_MERGE_ERRORS, NULL, NULL); if (ret == 0) { if (GetLastError() == ERROR_FILE_NOT_FOUND) { if (::rename(fileIo->path().c_str(), pf) == -1) { throw Error(17, fileIo->path(), pf, strError()); } ::remove(fileIo->path().c_str()); } else { throw Error(17, fileIo->path(), pf, strError()); } } } else { if (fileExists(pf) && ::remove(pf) != 0) { throw Error(2, pf, strError(), "::remove"); } if (::rename(fileIo->path().c_str(), pf) == -1) { throw Error(17, fileIo->path(), pf, strError()); } ::remove(fileIo->path().c_str()); } } #else if (fileExists(pf) && ::remove(pf) != 0) { throw Error(2, pf, strError(), "::remove"); } if (::rename(fileIo->path().c_str(), pf) == -1) { throw Error(17, fileIo->path(), pf, strError()); } ::remove(fileIo->path().c_str()); #endif // Check permissions of new file struct stat buf2; if (statOk && ::stat(pf, &buf2) == -1) { statOk = false; #ifndef SUPPRESS_WARNINGS EXV_WARNING << Error(2, pf, strError(), "::stat") << "\n"; #endif } if (statOk && origStMode != buf2.st_mode) { // Set original file permissions if (::chmod(pf, origStMode) == -1) { #ifndef SUPPRESS_WARNINGS EXV_WARNING << Error(2, pf, strError(), "::chmod") << "\n"; #endif } } } } // if (fileIo) else { // Generic handling, reopen both to reset to start if (open("w+b") != 0) { #ifdef EXV_UNICODE_PATH if (p_->wpMode_ == Impl::wpUnicode) { throw WError(10, wpath(), "w+b", strError().c_str()); } else #endif { throw Error(10, path(), "w+b", strError()); } } if (src.open() != 0) { #ifdef EXV_UNICODE_PATH if (p_->wpMode_ == Impl::wpUnicode) { throw WError(9, src.wpath(), strError().c_str()); } else #endif { throw Error(9, src.path(), strError()); } } write(src); src.close(); } if (wasOpen) { if (open(lastMode) != 0) { #ifdef EXV_UNICODE_PATH if (p_->wpMode_ == Impl::wpUnicode) { throw WError(10, wpath(), lastMode.c_str(), strError().c_str()); } else #endif { throw Error(10, path(), lastMode, strError()); } } } else close(); if (error() || src.error()) { #ifdef EXV_UNICODE_PATH if (p_->wpMode_ == Impl::wpUnicode) { throw WError(18, wpath(), strError().c_str()); } else #endif { throw Error(18, path(), strError()); } } } // FileIo::transfer
0
384,899
getnextcomp(char_u *fname) { while (*fname && !vim_ispathsep(*fname)) MB_PTR_ADV(fname); if (*fname) ++fname; return fname; }
0
254,751
njs_typed_array_prototype_slice(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, njs_index_t copy) { int64_t start, end, count, offset; uint32_t i, element_size, length; njs_int_t ret; njs_value_t arguments[3], *this, *value; njs_typed_array_t *array, *new_array; njs_array_buffer_t *buffer, *new_buffer; this = njs_argument(args, 0); if (njs_slow_path(!njs_is_typed_array(this))) { njs_type_error(vm, "this is not a typed array"); return NJS_ERROR; } array = njs_typed_array(this); length = njs_typed_array_length(array); buffer = njs_typed_array_buffer(array); if (njs_slow_path(copy && njs_is_detached_buffer(buffer))) { njs_type_error(vm, "detached buffer"); return NJS_ERROR; } ret = njs_value_to_integer(vm, njs_arg(args, nargs, 1), &start); if (njs_slow_path(ret != NJS_OK)) { njs_range_error(vm, "invalid start"); return NJS_ERROR; } start = (start < 0) ? njs_max(length + start, 0) : njs_min(start, length); value = njs_arg(args, nargs, 2); if (njs_is_undefined(value)) { end = length; } else { ret = njs_value_to_integer(vm, value, &end); if (njs_slow_path(ret != NJS_OK)) { njs_range_error(vm, "invalid end"); return NJS_ERROR; } } end = (end < 0) ? njs_max(length + end, 0) : njs_min(end, length); element_size = njs_typed_array_element_size(array->type); if (copy) { count = njs_max(end - start, 0); njs_set_number(&arguments[0], count); ret = njs_typed_array_species_create(vm, this, njs_value_arg(arguments), 1, &vm->retval); if (njs_slow_path(ret != NJS_OK)) { return ret; } if (count == 0) { return NJS_OK; } if (njs_slow_path(njs_is_detached_buffer(buffer))) { njs_type_error(vm, "detached buffer"); return NJS_ERROR; } new_array = njs_typed_array(&vm->retval); new_buffer = njs_typed_array_buffer(new_array); element_size = njs_typed_array_element_size(array->type); if (njs_fast_path(array->type == new_array->type)) { start = start * element_size; count = count * element_size; memcpy(&new_buffer->u.u8[0], &buffer->u.u8[start], count); } else { for (i = 0; i < count; i++) { njs_typed_array_prop_set(vm, new_array, i, njs_typed_array_prop(array, i + start)); } } return NJS_OK; } offset = array->offset * element_size; offset += start * element_size; njs_set_array_buffer(&arguments[0], buffer); njs_set_number(&arguments[1], offset); njs_set_number(&arguments[2], njs_max(end - start, 0)); return njs_typed_array_species_create(vm, this, njs_value_arg(arguments), 3, &vm->retval); }
0
404,700
int __close_fd_get_file(unsigned int fd, struct file **res) { struct files_struct *files = current->files; struct file *file; struct fdtable *fdt; fdt = files_fdtable(files); if (fd >= fdt->max_fds) goto out_err; file = fdt->fd[fd]; if (!file) goto out_err; rcu_assign_pointer(fdt->fd[fd], NULL); __put_unused_fd(files, fd); get_file(file); *res = file; return 0; out_err: *res = NULL; return -ENOENT; }
0
261,230
int MqttClient_NetConnect(MqttClient *client, const char* host, word16 port, int timeout_ms, int use_tls, MqttTlsCb cb) { return MqttSocket_Connect(client, host, port, timeout_ms, use_tls, cb); }
0
352,980
booleanMatch( int *matchp, slap_mask_t flags, Syntax *syntax, MatchingRule *mr, struct berval *value, void *assertedValue ) { /* simplistic matching allowed by rigid validation */ struct berval *asserted = (struct berval *) assertedValue; *matchp = (int) asserted->bv_len - (int) value->bv_len; return LDAP_SUCCESS; }
0
386,500
void DL_Dxf::addVertex(DL_CreationInterface* creationInterface) { // vertex defines a face of the mesh if its vertex flags group has the // 128 bit set but not the 64 bit. 10, 20, 30 are irrelevant and set to // 0 in this case if ((getIntValue(70, 0)&128) && !(getIntValue(70, 0)&64)) { return; } DL_VertexData d(getRealValue(10, 0.0), getRealValue(20, 0.0), getRealValue(30, 0.0), getRealValue(42, 0.0)); creationInterface->addVertex(d); }
0
449,293
normal_cmd( oparg_T *oap, int toplevel UNUSED) // TRUE when called from main() { cmdarg_T ca; // command arguments int c; int ctrl_w = FALSE; // got CTRL-W command int old_col = curwin->w_curswant; #ifdef FEAT_CMDL_INFO int need_flushbuf; // need to call out_flush() #endif pos_T old_pos; // cursor position before command int mapped_len; static int old_mapped_len = 0; int idx; #ifdef FEAT_EVAL int set_prevcount = FALSE; #endif int save_did_cursorhold = did_cursorhold; CLEAR_FIELD(ca); // also resets ca.retval ca.oap = oap; // Use a count remembered from before entering an operator. After typing // "3d" we return from normal_cmd() and come back here, the "3" is // remembered in "opcount". ca.opcount = opcount; /* * If there is an operator pending, then the command we take this time * will terminate it. Finish_op tells us to finish the operation before * returning this time (unless the operation was cancelled). */ #ifdef CURSOR_SHAPE c = finish_op; #endif finish_op = (oap->op_type != OP_NOP); #ifdef CURSOR_SHAPE if (finish_op != c) { ui_cursor_shape(); // may show different cursor shape # ifdef FEAT_MOUSESHAPE update_mouseshape(-1); # endif } #endif trigger_modechanged(); // When not finishing an operator and no register name typed, reset the // count. if (!finish_op && !oap->regname) { ca.opcount = 0; #ifdef FEAT_EVAL set_prevcount = TRUE; #endif } // Restore counts from before receiving K_CURSORHOLD. This means after // typing "3", handling K_CURSORHOLD and then typing "2" we get "32", not // "3 * 2". if (oap->prev_opcount > 0 || oap->prev_count0 > 0) { ca.opcount = oap->prev_opcount; ca.count0 = oap->prev_count0; oap->prev_opcount = 0; oap->prev_count0 = 0; } mapped_len = typebuf_maplen(); State = NORMAL_BUSY; #ifdef USE_ON_FLY_SCROLL dont_scroll = FALSE; // allow scrolling here #endif #ifdef FEAT_EVAL // Set v:count here, when called from main() and not a stuffed // command, so that v:count can be used in an expression mapping // when there is no count. Do set it for redo. if (toplevel && readbuf1_empty()) set_vcount_ca(&ca, &set_prevcount); #endif /* * Get the command character from the user. */ c = safe_vgetc(); LANGMAP_ADJUST(c, get_real_state() != SELECTMODE); /* * If a mapping was started in Visual or Select mode, remember the length * of the mapping. This is used below to not return to Insert mode for as * long as the mapping is being executed. */ if (restart_edit == 0) old_mapped_len = 0; else if (old_mapped_len || (VIsual_active && mapped_len == 0 && typebuf_maplen() > 0)) old_mapped_len = typebuf_maplen(); if (c == NUL) c = K_ZERO; /* * In Select mode, typed text replaces the selection. */ if (VIsual_active && VIsual_select && (vim_isprintc(c) || c == NL || c == CAR || c == K_KENTER)) { // Fake a "c"hange command. When "restart_edit" is set (e.g., because // 'insertmode' is set) fake a "d"elete command, Insert mode will // restart automatically. // Insert the typed character in the typeahead buffer, so that it can // be mapped in Insert mode. Required for ":lmap" to work. ins_char_typebuf(vgetc_char, vgetc_mod_mask); if (restart_edit != 0) c = 'd'; else c = 'c'; msg_nowait = TRUE; // don't delay going to insert mode old_mapped_len = 0; // do go to Insert mode } #ifdef FEAT_CMDL_INFO need_flushbuf = add_to_showcmd(c); #endif getcount: if (!(VIsual_active && VIsual_select)) { /* * Handle a count before a command and compute ca.count0. * Note that '0' is a command and not the start of a count, but it's * part of a count after other digits. */ while ( (c >= '1' && c <= '9') || (ca.count0 != 0 && (c == K_DEL || c == K_KDEL || c == '0'))) { if (c == K_DEL || c == K_KDEL) { ca.count0 /= 10; #ifdef FEAT_CMDL_INFO del_from_showcmd(4); // delete the digit and ~@% #endif } else ca.count0 = ca.count0 * 10 + (c - '0'); if (ca.count0 < 0) // overflow ca.count0 = 999999999L; #ifdef FEAT_EVAL // Set v:count here, when called from main() and not a stuffed // command, so that v:count can be used in an expression mapping // right after the count. Do set it for redo. if (toplevel && readbuf1_empty()) set_vcount_ca(&ca, &set_prevcount); #endif if (ctrl_w) { ++no_mapping; ++allow_keys; // no mapping for nchar, but keys } ++no_zero_mapping; // don't map zero here c = plain_vgetc(); LANGMAP_ADJUST(c, TRUE); --no_zero_mapping; if (ctrl_w) { --no_mapping; --allow_keys; } #ifdef FEAT_CMDL_INFO need_flushbuf |= add_to_showcmd(c); #endif } /* * If we got CTRL-W there may be a/another count */ if (c == Ctrl_W && !ctrl_w && oap->op_type == OP_NOP) { ctrl_w = TRUE; ca.opcount = ca.count0; // remember first count ca.count0 = 0; ++no_mapping; ++allow_keys; // no mapping for nchar, but keys c = plain_vgetc(); // get next character LANGMAP_ADJUST(c, TRUE); --no_mapping; --allow_keys; #ifdef FEAT_CMDL_INFO need_flushbuf |= add_to_showcmd(c); #endif goto getcount; // jump back } } if (c == K_CURSORHOLD) { // Save the count values so that ca.opcount and ca.count0 are exactly // the same when coming back here after handling K_CURSORHOLD. oap->prev_opcount = ca.opcount; oap->prev_count0 = ca.count0; } else if (ca.opcount != 0) { /* * If we're in the middle of an operator (including after entering a * yank buffer with '"') AND we had a count before the operator, then * that count overrides the current value of ca.count0. * What this means effectively, is that commands like "3dw" get turned * into "d3w" which makes things fall into place pretty neatly. * If you give a count before AND after the operator, they are * multiplied. */ if (ca.count0) ca.count0 *= ca.opcount; else ca.count0 = ca.opcount; if (ca.count0 < 0) // overflow ca.count0 = 999999999L; } /* * Always remember the count. It will be set to zero (on the next call, * above) when there is no pending operator. * When called from main(), save the count for use by the "count" built-in * variable. */ ca.opcount = ca.count0; ca.count1 = (ca.count0 == 0 ? 1 : ca.count0); #ifdef FEAT_EVAL /* * Only set v:count when called from main() and not a stuffed command. * Do set it for redo. */ if (toplevel && readbuf1_empty()) set_vcount(ca.count0, ca.count1, set_prevcount); #endif /* * Find the command character in the table of commands. * For CTRL-W we already got nchar when looking for a count. */ if (ctrl_w) { ca.nchar = c; ca.cmdchar = Ctrl_W; } else ca.cmdchar = c; idx = find_command(ca.cmdchar); if (idx < 0) { // Not a known command: beep. clearopbeep(oap); goto normal_end; } if (text_locked() && (nv_cmds[idx].cmd_flags & NV_NCW)) { // This command is not allowed while editing a cmdline: beep. clearopbeep(oap); text_locked_msg(); goto normal_end; } if ((nv_cmds[idx].cmd_flags & NV_NCW) && curbuf_locked()) goto normal_end; /* * In Visual/Select mode, a few keys are handled in a special way. */ if (VIsual_active) { // when 'keymodel' contains "stopsel" may stop Select/Visual mode if (km_stopsel && (nv_cmds[idx].cmd_flags & NV_STS) && !(mod_mask & MOD_MASK_SHIFT)) { end_visual_mode(); redraw_curbuf_later(INVERTED); } // Keys that work different when 'keymodel' contains "startsel" if (km_startsel) { if (nv_cmds[idx].cmd_flags & NV_SS) { unshift_special(&ca); idx = find_command(ca.cmdchar); if (idx < 0) { // Just in case clearopbeep(oap); goto normal_end; } } else if ((nv_cmds[idx].cmd_flags & NV_SSS) && (mod_mask & MOD_MASK_SHIFT)) mod_mask &= ~MOD_MASK_SHIFT; } } #ifdef FEAT_RIGHTLEFT if (curwin->w_p_rl && KeyTyped && !KeyStuffed && (nv_cmds[idx].cmd_flags & NV_RL)) { // Invert horizontal movements and operations. Only when typed by the // user directly, not when the result of a mapping or "x" translated // to "dl". switch (ca.cmdchar) { case 'l': ca.cmdchar = 'h'; break; case K_RIGHT: ca.cmdchar = K_LEFT; break; case K_S_RIGHT: ca.cmdchar = K_S_LEFT; break; case K_C_RIGHT: ca.cmdchar = K_C_LEFT; break; case 'h': ca.cmdchar = 'l'; break; case K_LEFT: ca.cmdchar = K_RIGHT; break; case K_S_LEFT: ca.cmdchar = K_S_RIGHT; break; case K_C_LEFT: ca.cmdchar = K_C_RIGHT; break; case '>': ca.cmdchar = '<'; break; case '<': ca.cmdchar = '>'; break; } idx = find_command(ca.cmdchar); } #endif /* * Get an additional character if we need one. */ if ((nv_cmds[idx].cmd_flags & NV_NCH) && (((nv_cmds[idx].cmd_flags & NV_NCH_NOP) == NV_NCH_NOP && oap->op_type == OP_NOP) || (nv_cmds[idx].cmd_flags & NV_NCH_ALW) == NV_NCH_ALW || (ca.cmdchar == 'q' && oap->op_type == OP_NOP && reg_recording == 0 && reg_executing == 0) || ((ca.cmdchar == 'a' || ca.cmdchar == 'i') && (oap->op_type != OP_NOP || VIsual_active)))) { int *cp; int repl = FALSE; // get character for replace mode int lit = FALSE; // get extra character literally int langmap_active = FALSE; // using :lmap mappings int lang; // getting a text character #ifdef HAVE_INPUT_METHOD int save_smd; // saved value of p_smd #endif ++no_mapping; ++allow_keys; // no mapping for nchar, but allow key codes // Don't generate a CursorHold event here, most commands can't handle // it, e.g., nv_replace(), nv_csearch(). did_cursorhold = TRUE; if (ca.cmdchar == 'g') { /* * For 'g' get the next character now, so that we can check for * "gr", "g'" and "g`". */ ca.nchar = plain_vgetc(); LANGMAP_ADJUST(ca.nchar, TRUE); #ifdef FEAT_CMDL_INFO need_flushbuf |= add_to_showcmd(ca.nchar); #endif if (ca.nchar == 'r' || ca.nchar == '\'' || ca.nchar == '`' || ca.nchar == Ctrl_BSL) { cp = &ca.extra_char; // need to get a third character if (ca.nchar != 'r') lit = TRUE; // get it literally else repl = TRUE; // get it in replace mode } else cp = NULL; // no third character needed } else { if (ca.cmdchar == 'r') // get it in replace mode repl = TRUE; cp = &ca.nchar; } lang = (repl || (nv_cmds[idx].cmd_flags & NV_LANG)); /* * Get a second or third character. */ if (cp != NULL) { if (repl) { State = REPLACE; // pretend Replace mode #ifdef CURSOR_SHAPE ui_cursor_shape(); // show different cursor shape #endif } if (lang && curbuf->b_p_iminsert == B_IMODE_LMAP) { // Allow mappings defined with ":lmap". --no_mapping; --allow_keys; if (repl) State = LREPLACE; else State = LANGMAP; langmap_active = TRUE; } #ifdef HAVE_INPUT_METHOD save_smd = p_smd; p_smd = FALSE; // Don't let the IM code show the mode here if (lang && curbuf->b_p_iminsert == B_IMODE_IM) im_set_active(TRUE); #endif if ((State & INSERT) && !p_ek) { #ifdef FEAT_JOB_CHANNEL ch_log_output = TRUE; #endif // Disable bracketed paste and modifyOtherKeys here, we won't // recognize the escape sequences with 'esckeys' off. out_str(T_BD); out_str(T_CTE); } *cp = plain_vgetc(); if ((State & INSERT) && !p_ek) { #ifdef FEAT_JOB_CHANNEL ch_log_output = TRUE; #endif // Re-enable bracketed paste mode and modifyOtherKeys out_str(T_BE); out_str(T_CTI); } if (langmap_active) { // Undo the decrement done above ++no_mapping; ++allow_keys; State = NORMAL_BUSY; } #ifdef HAVE_INPUT_METHOD if (lang) { if (curbuf->b_p_iminsert != B_IMODE_LMAP) im_save_status(&curbuf->b_p_iminsert); im_set_active(FALSE); } p_smd = save_smd; #endif State = NORMAL_BUSY; #ifdef FEAT_CMDL_INFO need_flushbuf |= add_to_showcmd(*cp); #endif if (!lit) { #ifdef FEAT_DIGRAPHS // Typing CTRL-K gets a digraph. if (*cp == Ctrl_K && ((nv_cmds[idx].cmd_flags & NV_LANG) || cp == &ca.extra_char) && vim_strchr(p_cpo, CPO_DIGRAPH) == NULL) { c = get_digraph(FALSE); if (c > 0) { *cp = c; # ifdef FEAT_CMDL_INFO // Guessing how to update showcmd here... del_from_showcmd(3); need_flushbuf |= add_to_showcmd(*cp); # endif } } #endif // adjust chars > 127, except after "tTfFr" commands LANGMAP_ADJUST(*cp, !lang); #ifdef FEAT_RIGHTLEFT // adjust Hebrew mapped char if (p_hkmap && lang && KeyTyped) *cp = hkmap(*cp); #endif } /* * When the next character is CTRL-\ a following CTRL-N means the * command is aborted and we go to Normal mode. */ if (cp == &ca.extra_char && ca.nchar == Ctrl_BSL && (ca.extra_char == Ctrl_N || ca.extra_char == Ctrl_G)) { ca.cmdchar = Ctrl_BSL; ca.nchar = ca.extra_char; idx = find_command(ca.cmdchar); } else if ((ca.nchar == 'n' || ca.nchar == 'N') && ca.cmdchar == 'g') ca.oap->op_type = get_op_type(*cp, NUL); else if (*cp == Ctrl_BSL) { long towait = (p_ttm >= 0 ? p_ttm : p_tm); // There is a busy wait here when typing "f<C-\>" and then // something different from CTRL-N. Can't be avoided. while ((c = vpeekc()) <= 0 && towait > 0L) { do_sleep(towait > 50L ? 50L : towait, FALSE); towait -= 50L; } if (c > 0) { c = plain_vgetc(); if (c != Ctrl_N && c != Ctrl_G) vungetc(c); else { ca.cmdchar = Ctrl_BSL; ca.nchar = c; idx = find_command(ca.cmdchar); } } } // When getting a text character and the next character is a // multi-byte character, it could be a composing character. // However, don't wait for it to arrive. Also, do enable mapping, // because if it's put back with vungetc() it's too late to apply // mapping. --no_mapping; while (enc_utf8 && lang && (c = vpeekc()) > 0 && (c >= 0x100 || MB_BYTE2LEN(vpeekc()) > 1)) { c = plain_vgetc(); if (!utf_iscomposing(c)) { vungetc(c); // it wasn't, put it back break; } else if (ca.ncharC1 == 0) ca.ncharC1 = c; else ca.ncharC2 = c; } ++no_mapping; } --no_mapping; --allow_keys; } #ifdef FEAT_CMDL_INFO /* * Flush the showcmd characters onto the screen so we can see them while * the command is being executed. Only do this when the shown command was * actually displayed, otherwise this will slow down a lot when executing * mappings. */ if (need_flushbuf) out_flush(); #endif if (ca.cmdchar != K_IGNORE) { if (ex_normal_busy) did_cursorhold = save_did_cursorhold; else did_cursorhold = FALSE; } State = NORMAL; if (ca.nchar == ESC) { clearop(oap); if (restart_edit == 0 && goto_im()) restart_edit = 'a'; goto normal_end; } if (ca.cmdchar != K_IGNORE) { msg_didout = FALSE; // don't scroll screen up for normal command msg_col = 0; } old_pos = curwin->w_cursor; // remember where cursor was // When 'keymodel' contains "startsel" some keys start Select/Visual // mode. if (!VIsual_active && km_startsel) { if (nv_cmds[idx].cmd_flags & NV_SS) { start_selection(); unshift_special(&ca); idx = find_command(ca.cmdchar); } else if ((nv_cmds[idx].cmd_flags & NV_SSS) && (mod_mask & MOD_MASK_SHIFT)) { start_selection(); mod_mask &= ~MOD_MASK_SHIFT; } } /* * Execute the command! * Call the command function found in the commands table. */ ca.arg = nv_cmds[idx].cmd_arg; (nv_cmds[idx].cmd_func)(&ca); /* * If we didn't start or finish an operator, reset oap->regname, unless we * need it later. */ if (!finish_op && !oap->op_type && (idx < 0 || !(nv_cmds[idx].cmd_flags & NV_KEEPREG))) { clearop(oap); #ifdef FEAT_EVAL reset_reg_var(); #endif } // Get the length of mapped chars again after typing a count, second // character or "z333<cr>". if (old_mapped_len > 0) old_mapped_len = typebuf_maplen(); /* * If an operation is pending, handle it. But not for K_IGNORE or * K_MOUSEMOVE. */ if (ca.cmdchar != K_IGNORE && ca.cmdchar != K_MOUSEMOVE) do_pending_operator(&ca, old_col, FALSE); /* * Wait for a moment when a message is displayed that will be overwritten * by the mode message. * In Visual mode and with "^O" in Insert mode, a short message will be * overwritten by the mode message. Wait a bit, until a key is hit. * In Visual mode, it's more important to keep the Visual area updated * than keeping a message (e.g. from a /pat search). * Only do this if the command was typed, not from a mapping. * Don't wait when emsg_silent is non-zero. * Also wait a bit after an error message, e.g. for "^O:". * Don't redraw the screen, it would remove the message. */ if ( ((p_smd && msg_silent == 0 && (restart_edit != 0 || (VIsual_active && old_pos.lnum == curwin->w_cursor.lnum && old_pos.col == curwin->w_cursor.col) ) && (clear_cmdline || redraw_cmdline) && (msg_didout || (msg_didany && msg_scroll)) && !msg_nowait && KeyTyped) || (restart_edit != 0 && !VIsual_active && (msg_scroll || emsg_on_display))) && oap->regname == 0 && !(ca.retval & CA_COMMAND_BUSY) && stuff_empty() && typebuf_typed() && emsg_silent == 0 && !in_assert_fails && !did_wait_return && oap->op_type == OP_NOP) { int save_State = State; // Draw the cursor with the right shape here if (restart_edit != 0) State = INSERT; // If need to redraw, and there is a "keep_msg", redraw before the // delay if (must_redraw && keep_msg != NULL && !emsg_on_display) { char_u *kmsg; kmsg = keep_msg; keep_msg = NULL; // Showmode() will clear keep_msg, but we want to use it anyway. // First update w_topline. setcursor(); update_screen(0); // now reset it, otherwise it's put in the history again keep_msg = kmsg; kmsg = vim_strsave(keep_msg); if (kmsg != NULL) { msg_attr((char *)kmsg, keep_msg_attr); vim_free(kmsg); } } setcursor(); #ifdef CURSOR_SHAPE ui_cursor_shape(); // may show different cursor shape #endif cursor_on(); out_flush(); if (msg_scroll || emsg_on_display) ui_delay(1003L, TRUE); // wait at least one second ui_delay(3003L, FALSE); // wait up to three seconds State = save_State; msg_scroll = FALSE; emsg_on_display = FALSE; } /* * Finish up after executing a Normal mode command. */ normal_end: msg_nowait = FALSE; #ifdef FEAT_EVAL if (finish_op) reset_reg_var(); #endif // Reset finish_op, in case it was set #ifdef CURSOR_SHAPE c = finish_op; #endif finish_op = FALSE; trigger_modechanged(); #ifdef CURSOR_SHAPE // Redraw the cursor with another shape, if we were in Operator-pending // mode or did a replace command. if (c || ca.cmdchar == 'r') { ui_cursor_shape(); // may show different cursor shape # ifdef FEAT_MOUSESHAPE update_mouseshape(-1); # endif } #endif #ifdef FEAT_CMDL_INFO if (oap->op_type == OP_NOP && oap->regname == 0 && ca.cmdchar != K_CURSORHOLD) clear_showcmd(); #endif checkpcmark(); // check if we moved since setting pcmark vim_free(ca.searchbuf); if (has_mbyte) mb_adjust_cursor(); if (curwin->w_p_scb && toplevel) { validate_cursor(); // may need to update w_leftcol do_check_scrollbind(TRUE); } if (curwin->w_p_crb && toplevel) { validate_cursor(); // may need to update w_leftcol do_check_cursorbind(); } #ifdef FEAT_TERMINAL // don't go to Insert mode if a terminal has a running job if (term_job_running(curbuf->b_term)) restart_edit = 0; #endif /* * May restart edit(), if we got here with CTRL-O in Insert mode (but not * if still inside a mapping that started in Visual mode). * May switch from Visual to Select mode after CTRL-O command. */ if ( oap->op_type == OP_NOP && ((restart_edit != 0 && !VIsual_active && old_mapped_len == 0) || restart_VIsual_select == 1) && !(ca.retval & CA_COMMAND_BUSY) && stuff_empty() && oap->regname == 0) { if (restart_VIsual_select == 1) { VIsual_select = TRUE; trigger_modechanged(); showmode(); restart_VIsual_select = 0; } if (restart_edit != 0 && !VIsual_active && old_mapped_len == 0) (void)edit(restart_edit, FALSE, 1L); } if (restart_VIsual_select == 2) restart_VIsual_select = 1; // Save count before an operator for next time. opcount = ca.opcount; }
0
270,401
static inline void ok_png_unpremultiply(uint8_t *dst) { const uint8_t a = dst[3]; if (a > 0 && a < 255) { dst[0] = 255 * dst[0] / a; dst[1] = 255 * dst[1] / a; dst[2] = 255 * dst[2] / a; } }
0
313,804
nv_kundo(cmdarg_T *cap) { if (!checkclearopq(cap->oap)) { #ifdef FEAT_JOB_CHANNEL if (bt_prompt(curbuf)) { clearopbeep(cap->oap); return; } #endif u_undo((int)cap->count1); curwin->w_set_curswant = TRUE; } }
0
439,090
static MagickBooleanType WriteYUVImage(const ImageInfo *image_info,Image *image) { Image *chroma_image, *yuv_image; InterlaceType interlace; MagickBooleanType status; MagickOffsetType scene; register const PixelPacket *p, *s; register ssize_t x; size_t height, imageListLength, quantum, width; ssize_t horizontal_factor, vertical_factor, y; assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); assert(image != (Image *) NULL); assert(image->signature == MagickCoreSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); quantum=(size_t) (image->depth <= 8 ? 1 : 2); interlace=image->interlace; horizontal_factor=2; vertical_factor=2; if (image_info->sampling_factor != (char *) NULL) { GeometryInfo geometry_info; MagickStatusType flags; flags=ParseGeometry(image_info->sampling_factor,&geometry_info); horizontal_factor=(ssize_t) geometry_info.rho; vertical_factor=(ssize_t) geometry_info.sigma; if ((flags & SigmaValue) == 0) vertical_factor=horizontal_factor; if ((horizontal_factor != 1) && (horizontal_factor != 2) && (vertical_factor != 1) && (vertical_factor != 2)) ThrowWriterException(CorruptImageError,"UnexpectedSamplingFactor"); } if ((interlace == UndefinedInterlace) || ((interlace == NoInterlace) && (vertical_factor == 2))) { interlace=NoInterlace; /* CCIR 4:2:2 */ if (vertical_factor == 2) interlace=PlaneInterlace; /* CCIR 4:1:1 */ } if (interlace != PartitionInterlace) { /* Open output image file. */ status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); if (status == MagickFalse) return(status); } else { AppendImageFormat("Y",image->filename); status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); if (status == MagickFalse) return(status); } scene=0; imageListLength=GetImageListLength(image); do { /* Sample image to an even width and height, if necessary. */ image->depth=(size_t) (quantum == 1 ? 8 : 16); width=image->columns+(image->columns & (horizontal_factor-1)); height=image->rows+(image->rows & (vertical_factor-1)); yuv_image=ResizeImage(image,width,height,TriangleFilter,1.0, &image->exception); if (yuv_image == (Image *) NULL) ThrowWriterException(ResourceLimitError,image->exception.reason); (void) TransformImageColorspace(yuv_image,YCbCrColorspace); /* Downsample image. */ chroma_image=ResizeImage(image,width/horizontal_factor, height/vertical_factor,TriangleFilter,1.0,&image->exception); if (chroma_image == (Image *) NULL) ThrowWriterException(ResourceLimitError,image->exception.reason); (void) TransformImageColorspace(chroma_image,YCbCrColorspace); if (interlace == NoInterlace) { /* Write noninterlaced YUV. */ for (y=0; y < (ssize_t) yuv_image->rows; y++) { p=GetVirtualPixels(yuv_image,0,y,yuv_image->columns,1, &yuv_image->exception); if (p == (const PixelPacket *) NULL) break; s=GetVirtualPixels(chroma_image,0,y,chroma_image->columns,1, &chroma_image->exception); if (s == (const PixelPacket *) NULL) break; for (x=0; x < (ssize_t) yuv_image->columns; x+=2) { if (quantum == 1) { (void) WriteBlobByte(image,ScaleQuantumToChar( GetPixelGreen(s))); (void) WriteBlobByte(image,ScaleQuantumToChar(GetPixelRed(p))); p++; (void) WriteBlobByte(image,ScaleQuantumToChar(GetPixelBlue(s))); (void) WriteBlobByte(image,ScaleQuantumToChar(GetPixelRed(p))); } else { (void) WriteBlobByte(image,ScaleQuantumToChar( GetPixelGreen(s))); (void) WriteBlobShort(image,ScaleQuantumToShort( GetPixelRed(p))); p++; (void) WriteBlobByte(image,ScaleQuantumToChar(GetPixelBlue(s))); (void) WriteBlobShort(image,ScaleQuantumToShort( GetPixelRed(p))); } p++; s++; } if (image->previous == (Image *) NULL) { status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, image->rows); if (status == MagickFalse) break; } } yuv_image=DestroyImage(yuv_image); } else { /* Initialize Y channel. */ for (y=0; y < (ssize_t) yuv_image->rows; y++) { p=GetVirtualPixels(yuv_image,0,y,yuv_image->columns,1, &yuv_image->exception); if (p == (const PixelPacket *) NULL) break; for (x=0; x < (ssize_t) yuv_image->columns; x++) { if (quantum == 1) (void) WriteBlobByte(image,ScaleQuantumToChar(GetPixelRed(p))); else (void) WriteBlobShort(image,ScaleQuantumToShort(GetPixelRed(p))); p++; } if (image->previous == (Image *) NULL) { status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, image->rows); if (status == MagickFalse) break; } } yuv_image=DestroyImage(yuv_image); if (image->previous == (Image *) NULL) { status=SetImageProgress(image,SaveImageTag,1,3); if (status == MagickFalse) break; } /* Initialize U channel. */ if (interlace == PartitionInterlace) { (void) CloseBlob(image); AppendImageFormat("U",image->filename); status=OpenBlob(image_info,image,WriteBinaryBlobMode, &image->exception); if (status == MagickFalse) return(status); } for (y=0; y < (ssize_t) chroma_image->rows; y++) { p=GetVirtualPixels(chroma_image,0,y,chroma_image->columns,1, &chroma_image->exception); if (p == (const PixelPacket *) NULL) break; for (x=0; x < (ssize_t) chroma_image->columns; x++) { if (quantum == 1) (void) WriteBlobByte(image,ScaleQuantumToChar(GetPixelGreen(p))); else (void) WriteBlobShort(image,ScaleQuantumToShort( GetPixelGreen(p))); p++; } } if (image->previous == (Image *) NULL) { status=SetImageProgress(image,SaveImageTag,2,3); if (status == MagickFalse) break; } /* Initialize V channel. */ if (interlace == PartitionInterlace) { (void) CloseBlob(image); AppendImageFormat("V",image->filename); status=OpenBlob(image_info,image,WriteBinaryBlobMode, &image->exception); if (status == MagickFalse) return(status); } for (y=0; y < (ssize_t) chroma_image->rows; y++) { p=GetVirtualPixels(chroma_image,0,y,chroma_image->columns,1, &chroma_image->exception); if (p == (const PixelPacket *) NULL) break; for (x=0; x < (ssize_t) chroma_image->columns; x++) { if (quantum == 1) (void) WriteBlobByte(image,ScaleQuantumToChar(GetPixelBlue(p))); else (void) WriteBlobShort(image,ScaleQuantumToShort(GetPixelBlue(p))); p++; } } if (image->previous == (Image *) NULL) { status=SetImageProgress(image,SaveImageTag,2,3); if (status == MagickFalse) break; } } chroma_image=DestroyImage(chroma_image); if (interlace == PartitionInterlace) (void) CopyMagickString(image->filename,image_info->filename, MaxTextExtent); if (GetNextImageInList(image) == (Image *) NULL) break; image=SyncNextImageInList(image); status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength); if (status == MagickFalse) break; } while (image_info->adjoin != MagickFalse); (void) CloseBlob(image); return(MagickTrue); }
0
500,698
sftp_statvfs_t sftp_fstatvfs(sftp_file file) { sftp_status_message status = NULL; sftp_message msg = NULL; sftp_session sftp; ssh_string ext; ssh_buffer buffer; uint32_t id; if (file == NULL) { return NULL; } sftp = file->sftp; buffer = ssh_buffer_new(); if (buffer == NULL) { ssh_set_error_oom(sftp->session); return NULL; } ext = ssh_string_from_char("fstatvfs@openssh.com"); if (ext == NULL) { ssh_set_error_oom(sftp->session); ssh_buffer_free(buffer); return NULL; } id = sftp_get_new_id(sftp); if (buffer_add_u32(buffer, id) < 0 || buffer_add_ssh_string(buffer, ext) < 0 || buffer_add_ssh_string(buffer, file->handle) < 0) { ssh_set_error_oom(sftp->session); ssh_buffer_free(buffer); ssh_string_free(ext); return NULL; } if (sftp_packet_write(sftp, SSH_FXP_EXTENDED, buffer) < 0) { ssh_buffer_free(buffer); ssh_string_free(ext); return NULL; } ssh_buffer_free(buffer); ssh_string_free(ext); while (msg == NULL) { if (sftp_read_and_dispatch(sftp) < 0) { return NULL; } msg = sftp_dequeue(sftp, id); } if (msg->packet_type == SSH_FXP_EXTENDED_REPLY) { sftp_statvfs_t buf = sftp_parse_statvfs(sftp, msg->payload); sftp_message_free(msg); if (buf == NULL) { return NULL; } return buf; } else if (msg->packet_type == SSH_FXP_STATUS) { /* bad response (error) */ status = parse_status_msg(msg); sftp_message_free(msg); if (status == NULL) { return NULL; } ssh_set_error(sftp->session, SSH_REQUEST_DENIED, "SFTP server: %s", status->errormsg); status_msg_free(status); } else { /* this shouldn't happen */ ssh_set_error(sftp->session, SSH_FATAL, "Received message %d when attempting to set stats", msg->packet_type); sftp_message_free(msg); } return NULL; }
0
250,679
int HttpFile::save(const std::string &path) const { return implPtr_->save(path); }
0
279,926
check_restricted(void) { if (restricted) { emsg(_(e_shell_commands_and_some_functionality_not_allowed_in_rvim)); return TRUE; } return FALSE; }
0
357,672
SQInstance::SQInstance(SQSharedState *ss, SQClass *c, SQInteger memsize) { _memsize = memsize; _class = c; SQUnsignedInteger nvalues = _class->_defaultvalues.size(); for(SQUnsignedInteger n = 0; n < nvalues; n++) { new (&_values[n]) SQObjectPtr(_class->_defaultvalues[n].val); } Init(ss); }
0
455,394
xfs_eofblocks_worker( struct work_struct *work) { struct xfs_mount *mp = container_of(to_delayed_work(work), struct xfs_mount, m_eofblocks_work); xfs_icache_free_eofblocks(mp, NULL); xfs_queue_eofblocks(mp); }
0
218,932
Status GetAssetFileDefs(const MetaGraphDef& meta_graph_def, std::vector<AssetFileDef>* asset_file_defs) { // With SavedModel v2, we write asset file def into metagraph instead of // collection, so read from metagraph first. if (meta_graph_def.asset_file_def_size() > 0) { for (const auto& asset : meta_graph_def.asset_file_def()) { asset_file_defs->push_back(asset); } return Status::OK(); } // Fall back to read from collection to be backward compatible with v1. const auto& collection_def_map = meta_graph_def.collection_def(); const auto assets_it = collection_def_map.find(kSavedModelAssetsKey); if (assets_it == collection_def_map.end()) { return Status::OK(); } const auto& any_assets = assets_it->second.any_list().value(); for (const auto& any_asset : any_assets) { AssetFileDef asset_file_def; TF_RETURN_IF_ERROR( ParseAny(any_asset, &asset_file_def, "tensorflow.AssetFileDef")); asset_file_defs->push_back(asset_file_def); } return Status::OK(); }
0
442,791
static ParameterError add2list(struct curl_slist **list, char *ptr) { struct curl_slist *newlist = curl_slist_append(*list, ptr); if(newlist) *list = newlist; else return PARAM_NO_MEM; return PARAM_OK; }
0
224,747
void pitm_box_del(GF_Box *s) { GF_PrimaryItemBox *ptr = (GF_PrimaryItemBox *)s; if (ptr == NULL) return; gf_free(ptr); }
0
194,998
Status ConstantFolding::IsSimplifiableReshape( const NodeDef& node, const GraphProperties& properties) const { if (!IsReshape(node)) { return errors::Internal("Node ", node.name(), " is not a Reshape node"); } if (2 > node.input_size()) { return errors::Internal("Node ", node.name(), " must have at most 2 inputs but has ", node.input_size()); } const NodeDef* new_shape = node_map_->GetNode(node.input(1)); if (!IsReallyConstant(*new_shape)) { return errors::Internal("Node ", node.name(), " has shape ", new_shape->DebugString(), " which is not a constant"); } TensorVector outputs; auto outputs_cleanup = gtl::MakeCleanup([&outputs] { for (const auto& output : outputs) { delete output.tensor; } }); Status s = EvaluateNode(*new_shape, TensorVector(), &outputs); if (!s.ok()) { return errors::Internal("Could not evaluate node ", node.name()); } if (outputs.size() != 1) { return errors::Internal("Node ", node.name(), " must have exactly 1 output but has ", outputs.size()); } const std::vector<OpInfo::TensorProperties>& props = properties.GetInputProperties(node.name()); if (props.empty()) { return errors::Internal("Node ", node.name(), " has no properties"); } const OpInfo::TensorProperties& prop = props[0]; if (prop.dtype() == DT_INVALID) { return errors::Internal("Node ", node.name(), " has property ", prop.DebugString(), " with invalid dtype"); } const PartialTensorShape shape(prop.shape()); if (!shape.IsFullyDefined()) { return errors::Internal("Node ", node.name(), " has property ", prop.DebugString(), " with shape ", shape.DebugString(), " which is not fully defined"); } PartialTensorShape new_dims; if (outputs[0]->dtype() == DT_INT32) { std::vector<int32> shp; for (int i = 0; i < outputs[0]->NumElements(); ++i) { int32_t dim = outputs[0]->flat<int32>()(i); shp.push_back(dim); } TF_CHECK_OK(TensorShapeUtils::MakeShape(shp, &new_dims)); } else { std::vector<int64_t> shp; for (int i = 0; i < outputs[0]->NumElements(); ++i) { int64_t dim = outputs[0]->flat<int64_t>()(i); shp.push_back(dim); } TF_CHECK_OK(TensorShapeUtils::MakeShape(shp, &new_dims)); } if (!shape.IsCompatibleWith(new_dims)) { return errors::Internal("Expected shape ", shape.DebugString(), "to be compatible with ", new_dims.DebugString()); } return Status::OK(); }
1
236,132
GF_Box *href_box_new() { ISOM_DECL_BOX_ALLOC(GF_TextHyperTextBox, GF_ISOM_BOX_TYPE_HREF); return (GF_Box *) tmp; }
0
474,039
cp949_is_allowed_reverse_match(const UChar* s, const UChar* end ARG_UNUSED, OnigEncoding enc ARG_UNUSED) { const UChar c = *s; return (CP949_ISMB_TRAIL(c) ? FALSE : TRUE); }
0
232,958
static void client_close_writer(struct Curl_easy *data, struct contenc_writer *writer) { (void) data; (void) writer; }
0
364,765
findtags_copy_matches(findtags_state_T *st, char_u ***matchesp) { int name_only = (st->flags & TAG_NAMES); char_u **matches; int mtt; int i; char_u *mfp; char_u *p; if (st->match_count > 0) matches = ALLOC_MULT(char_u *, st->match_count); else matches = NULL; st->match_count = 0; for (mtt = 0; mtt < MT_COUNT; ++mtt) { for (i = 0; i < st->ga_match[mtt].ga_len; ++i) { mfp = ((char_u **)(st->ga_match[mtt].ga_data))[i]; if (matches == NULL) vim_free(mfp); else { if (!name_only) { // Change mtt back to zero-based. *mfp = *mfp - 1; // change the TAG_SEP back to NUL for (p = mfp + 1; *p != NUL; ++p) if (*p == TAG_SEP) *p = NUL; } matches[st->match_count++] = mfp; } } ga_clear(&st->ga_match[mtt]); hash_clear(&st->ht_match[mtt]); } *matchesp = matches; return st->match_count; }
0
293,751
static int kernelcache_io_read(RIO *io, RIODesc *fd, ut8 *buf, int count) { r_return_val_if_fail (io, -1); RCore *core = (RCore*) io->corebind.core; if (!fd || !core || !core->bin || !core->bin->binfiles) { return -1; } RKernelCacheObj *cache = NULL; RListIter *iter; RBinFile *bf; r_list_foreach (core->bin->binfiles, iter, bf) { if (bf->fd == fd->fd && bf->o && bf->o->bin_obj) { cache = bf->o->bin_obj; if (pending_bin_files) { RListIter *to_remove = r_list_contains (pending_bin_files, bf); if (to_remove) { r_list_delete (pending_bin_files, to_remove); if (r_list_empty (pending_bin_files)) { r_list_free (pending_bin_files); pending_bin_files = NULL; } } } break; } } if (!cache) { r_list_foreach (pending_bin_files, iter, bf) { if (bf->fd == fd->fd && bf->o) { cache = bf->o->bin_obj; break; } } } if (!cache || !cache->original_io_read || cache->rebasing_buffer) { if (cache) { if ((!cache->rebasing_buffer && fd->plugin->read == &kernelcache_io_read) || (cache->rebasing_buffer && !cache->original_io_read)) { return -1; } if (cache->rebasing_buffer) { return cache->original_io_read (io, fd, buf, count); } } if (fd->plugin->read == kernelcache_io_read) { if (core->bin->verbose) { eprintf ("Avoid recursive reads\n"); } return -1; } return fd->plugin->read (io, fd, buf, count); } if (cache->rebase_info) { r_rebase_info_populate (cache->rebase_info, cache); } static ut8 *internal_buffer = NULL; static int internal_buf_size = 0; if (count > internal_buf_size) { if (internal_buffer) { R_FREE (internal_buffer); internal_buffer = NULL; } internal_buffer = (ut8 *) malloc (count); internal_buf_size = count; } if (!cache->original_io_read) { return -1; } ut64 io_off = io->off; int result = cache->original_io_read (io, fd, internal_buffer, count); if (result == count) { if (cache->mach0->chained_starts) { rebase_buffer_fixup (cache, io_off, fd, internal_buffer, count); } else if (cache->rebase_info) { rebase_buffer (cache, io_off, fd, internal_buffer, count); } memcpy (buf, internal_buffer, result); } return result; }
0
259,546
static size_t strlen_url(const char *url, bool relative) { const unsigned char *ptr; size_t newlen = 0; bool left = TRUE; /* left side of the ? */ const unsigned char *host_sep = (const unsigned char *) url; if(!relative) host_sep = (const unsigned char *) find_host_sep(url); for(ptr = (unsigned char *)url; *ptr; ptr++) { if(ptr < host_sep) { ++newlen; continue; } if(*ptr == ' ') { if(left) newlen += 3; else newlen++; continue; } if (*ptr == '?') left = FALSE; if(urlchar_needs_escaping(*ptr)) newlen += 2; newlen++; } return newlen; }
0
521,452
InputStream* ZipFile::createStreamForEntry (const int index) { InputStream* stream = nullptr; if (auto* zei = entries[index]) { stream = new ZipInputStream (*this, *zei); if (zei->isCompressed) { stream = new GZIPDecompressorInputStream (stream, true, GZIPDecompressorInputStream::deflateFormat, zei->entry.uncompressedSize); // (much faster to unzip in big blocks using a buffer..) stream = new BufferedInputStream (stream, 32768, true); } } return stream; }
0
445,927
fr_window_construct (FrWindow *window) { GtkWidget *toolbar; GtkWidget *list_scrolled_window; GtkWidget *location_box; GtkStatusbar *statusbar; GtkWidget *statusbar_box; GtkWidget *filter_box; GtkWidget *tree_scrolled_window; GtkTreeSelection *selection; GtkActionGroup *actions; GtkAction *action; GtkAction *other_actions_action; GtkUIManager *ui; GtkSizeGroup *toolbar_size_group; GError *error = NULL; const char * const *schemas; /* Create the settings objects */ window->priv->settings_listing = g_settings_new (FILE_ROLLER_SCHEMA_LISTING); window->priv->settings_ui = g_settings_new (FILE_ROLLER_SCHEMA_UI); window->priv->settings_general = g_settings_new (FILE_ROLLER_SCHEMA_GENERAL); window->priv->settings_dialogs = g_settings_new (FILE_ROLLER_SCHEMA_DIALOGS); /* Only use the nautilus schema if it's installed */ for (schemas = g_settings_list_schemas (); *schemas != NULL; schemas++) { if (g_strcmp0 (*schemas, NAUTILUS_SCHEMA) == 0) { window->priv->settings_nautilus = g_settings_new (NAUTILUS_SCHEMA); break; } } /* Create the application. */ window->priv->layout = gtk_grid_new (); gtk_container_add (GTK_CONTAINER (window), window->priv->layout); gtk_widget_show (window->priv->layout); gtk_window_set_title (GTK_WINDOW (window), _("Archive Manager")); gtk_window_set_has_resize_grip (GTK_WINDOW (window), TRUE); g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (fr_window_delete_event_cb), window); g_signal_connect (G_OBJECT (window), "show", G_CALLBACK (fr_window_show_cb), window); window->priv->theme_changed_handler_id = g_signal_connect (gtk_icon_theme_get_default (), "changed", G_CALLBACK (theme_changed_cb), window); gtk_window_set_default_size (GTK_WINDOW (window), g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_WIDTH), g_settings_get_int (window->priv->settings_ui, PREF_UI_WINDOW_HEIGHT)); gtk_drag_dest_set (GTK_WIDGET (window), GTK_DEST_DEFAULT_ALL, target_table, G_N_ELEMENTS (target_table), GDK_ACTION_COPY); g_signal_connect (G_OBJECT (window), "drag_data_received", G_CALLBACK (fr_window_drag_data_received), window); g_signal_connect (G_OBJECT (window), "drag_motion", G_CALLBACK (fr_window_drag_motion), window); g_signal_connect (G_OBJECT (window), "key_press_event", G_CALLBACK (key_press_cb), window); /* Initialize Data. */ window->priv->list_mode = window->priv->last_list_mode = g_settings_get_enum (window->priv->settings_listing, PREF_LISTING_LIST_MODE); g_settings_set_boolean (window->priv->settings_listing, PREF_LISTING_SHOW_PATH, (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT)); window->priv->history = NULL; window->priv->history_current = NULL; window->priv->action = FR_ACTION_NONE; window->priv->open_default_dir = g_object_ref (_g_file_get_home ()); window->priv->add_default_dir = NULL; window->priv->extract_default_dir = g_object_ref (_g_file_get_home ()); window->priv->give_focus_to_the_list = FALSE; window->priv->activity_ref = 0; window->priv->activity_timeout_handle = 0; window->priv->update_timeout_handle = 0; window->priv->archive_present = FALSE; window->priv->archive_new = FALSE; window->priv->reload_archive = FALSE; window->priv->archive_file = NULL; window->priv->drag_destination_folder = NULL; window->priv->drag_base_dir = NULL; window->priv->drag_error = NULL; window->priv->drag_file_list = NULL; window->priv->batch_mode = FALSE; window->priv->batch_action_list = NULL; window->priv->batch_action = NULL; window->priv->extract_interact_use_default_dir = FALSE; window->priv->password = NULL; window->priv->compression = g_settings_get_enum (window->priv->settings_general, PREF_GENERAL_COMPRESSION_LEVEL); window->priv->encrypt_header = g_settings_get_boolean (window->priv->settings_general, PREF_GENERAL_ENCRYPT_HEADER); window->priv->volume_size = 0; window->priv->stoppable = TRUE; window->priv->batch_adding_one_file = FALSE; window->priv->path_clicked = NULL; window->priv->current_view_length = 0; window->priv->current_batch_action.type = FR_BATCH_ACTION_NONE; window->priv->current_batch_action.data = NULL; window->priv->current_batch_action.free_func = NULL; window->priv->pd_last_archive = NULL; window->priv->pd_last_message = NULL; window->priv->pd_last_fraction = 0.0; /* Create the widgets. */ /* * File list. */ window->priv->list_store = fr_list_model_new (NUMBER_OF_COLUMNS, G_TYPE_POINTER, GDK_TYPE_PIXBUF, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); g_object_set_data (G_OBJECT (window->priv->list_store), "FrWindow", window); window->priv->list_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (window->priv->list_store)); gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (window->priv->list_view), TRUE); add_file_list_columns (window, GTK_TREE_VIEW (window->priv->list_view)); gtk_tree_view_set_enable_search (GTK_TREE_VIEW (window->priv->list_view), TRUE); gtk_tree_view_set_search_column (GTK_TREE_VIEW (window->priv->list_view), COLUMN_NAME); gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store), FR_WINDOW_SORT_BY_NAME, name_column_sort_func, NULL, NULL); gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store), FR_WINDOW_SORT_BY_SIZE, size_column_sort_func, NULL, NULL); gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store), FR_WINDOW_SORT_BY_TYPE, type_column_sort_func, NULL, NULL); gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store), FR_WINDOW_SORT_BY_TIME, time_column_sort_func, NULL, NULL); gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (window->priv->list_store), FR_WINDOW_SORT_BY_PATH, path_column_sort_func, NULL, NULL); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->list_view)); gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE); g_signal_connect (selection, "changed", G_CALLBACK (selection_changed_cb), window); g_signal_connect (G_OBJECT (window->priv->list_view), "row_activated", G_CALLBACK (row_activated_cb), window); g_signal_connect (G_OBJECT (window->priv->list_view), "button_press_event", G_CALLBACK (file_button_press_cb), window); g_signal_connect (G_OBJECT (window->priv->list_view), "button_release_event", G_CALLBACK (file_button_release_cb), window); g_signal_connect (G_OBJECT (window->priv->list_view), "motion_notify_event", G_CALLBACK (file_motion_notify_callback), window); g_signal_connect (G_OBJECT (window->priv->list_view), "leave_notify_event", G_CALLBACK (file_leave_notify_callback), window); g_signal_connect (G_OBJECT (window->priv->list_view), "drag_begin", G_CALLBACK (file_list_drag_begin), window); g_signal_connect (G_OBJECT (window->priv->list_view), "drag_end", G_CALLBACK (file_list_drag_end), window); egg_tree_multi_drag_add_drag_support (GTK_TREE_VIEW (window->priv->list_view)); list_scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (list_scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (list_scrolled_window), window->priv->list_view); /* filter bar */ window->priv->filter_bar = filter_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); g_object_set (window->priv->filter_bar, "halign", GTK_ALIGN_CENTER, "margin-left", 6, "border-width", 3, NULL); fr_window_attach (FR_WINDOW (window), window->priv->filter_bar, FR_WINDOW_AREA_FILTERBAR); /* * filter entry */ window->priv->filter_entry = GTK_WIDGET (gtk_entry_new ()); gtk_entry_set_icon_from_icon_name (GTK_ENTRY (window->priv->filter_entry), GTK_ENTRY_ICON_SECONDARY, "edit-find-symbolic"); gtk_entry_set_icon_activatable (GTK_ENTRY (window->priv->filter_entry), GTK_ENTRY_ICON_SECONDARY, FALSE); gtk_entry_set_width_chars (GTK_ENTRY (window->priv->filter_entry), 40); gtk_box_pack_start (GTK_BOX (filter_box), window->priv->filter_entry, FALSE, FALSE, 6); g_signal_connect (G_OBJECT (window->priv->filter_entry), "activate", G_CALLBACK (filter_entry_activate_cb), window); gtk_widget_show_all (filter_box); /* tree view */ window->priv->tree_store = gtk_tree_store_new (TREE_NUMBER_OF_COLUMNS, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING, PANGO_TYPE_WEIGHT); window->priv->tree_view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (window->priv->tree_store)); gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (window->priv->tree_view), FALSE); add_dir_tree_columns (window, GTK_TREE_VIEW (window->priv->tree_view)); g_signal_connect (G_OBJECT (window->priv->tree_view), "button_press_event", G_CALLBACK (dir_tree_button_press_cb), window); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (window->priv->tree_view)); g_signal_connect (selection, "changed", G_CALLBACK (dir_tree_selection_changed_cb), window); g_signal_connect (G_OBJECT (window->priv->tree_view), "drag_begin", G_CALLBACK (file_list_drag_begin), window); g_signal_connect (G_OBJECT (window->priv->tree_view), "drag_end", G_CALLBACK (file_list_drag_end), window); g_signal_connect (G_OBJECT (window->priv->tree_view), "drag_data_get", G_CALLBACK (fr_window_folder_tree_drag_data_get), window); gtk_drag_source_set (window->priv->tree_view, GDK_BUTTON1_MASK, folder_tree_targets, G_N_ELEMENTS (folder_tree_targets), GDK_ACTION_COPY); tree_scrolled_window = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (tree_scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (tree_scrolled_window), window->priv->tree_view); /* side pane */ window->priv->sidepane = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_pack_start (GTK_BOX (window->priv->sidepane), tree_scrolled_window, TRUE, TRUE, 0); /* main content */ window->priv->paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); gtk_paned_pack1 (GTK_PANED (window->priv->paned), window->priv->sidepane, FALSE, TRUE); gtk_paned_pack2 (GTK_PANED (window->priv->paned), list_scrolled_window, TRUE, TRUE); gtk_paned_set_position (GTK_PANED (window->priv->paned), g_settings_get_int (window->priv->settings_ui, PREF_UI_SIDEBAR_WIDTH)); fr_window_attach (FR_WINDOW (window), window->priv->paned, FR_WINDOW_AREA_CONTENTS); gtk_widget_show_all (window->priv->paned); /* Build the menu and the toolbar. */ ui = gtk_ui_manager_new (); window->priv->actions = actions = gtk_action_group_new ("Actions"); /* open recent menu item action */ action = g_object_new (GTK_TYPE_RECENT_ACTION, "name", "OpenRecent", /* Translators: this is the label for the "open recent file" sub-menu. */ "label", _("Open _Recent"), "tooltip", _("Open a recently used archive"), "stock-id", GTK_STOCK_OPEN, NULL); fr_window_init_recent_chooser (window, GTK_RECENT_CHOOSER (action)); gtk_action_group_add_action (actions, action); g_object_unref (action); /* open recent toolbar item action */ action = g_object_new (GTK_TYPE_RECENT_ACTION, "name", "OpenRecent_Toolbar", "label", _("Open"), "tooltip", _("Open a recently used archive"), "stock-id", GTK_STOCK_OPEN, "is-important", TRUE, NULL); fr_window_init_recent_chooser (window, GTK_RECENT_CHOOSER (action)); g_signal_connect (action, "activate", G_CALLBACK (activate_action_open), window); gtk_action_group_add_action (actions, action); g_object_unref (action); /* menu actions */ other_actions_action = action = g_object_new (GTH_TYPE_TOGGLE_MENU_ACTION, "name", "OtherActions", "label", _("_Other Actions"), "tooltip", _("Other actions"), "menu-halign", GTK_ALIGN_CENTER, "show-arrow", TRUE, NULL); gtk_action_group_add_action (actions, action); /* other actions */ gtk_action_group_set_translation_domain (actions, NULL); gtk_action_group_add_actions (actions, action_entries, n_action_entries, window); gtk_action_group_add_toggle_actions (actions, action_toggle_entries, n_action_toggle_entries, window); gtk_action_group_add_radio_actions (actions, view_as_entries, n_view_as_entries, window->priv->list_mode, G_CALLBACK (view_as_radio_action), window); g_signal_connect (ui, "connect_proxy", G_CALLBACK (connect_proxy_cb), window); g_signal_connect (ui, "disconnect_proxy", G_CALLBACK (disconnect_proxy_cb), window); gtk_ui_manager_insert_action_group (ui, actions, 0); gtk_window_add_accel_group (GTK_WINDOW (window), gtk_ui_manager_get_accel_group (ui)); /* Add a hidden short cut Ctrl-Q for power users */ gtk_accel_group_connect (gtk_ui_manager_get_accel_group (ui), GDK_KEY_q, GDK_CONTROL_MASK, 0, g_cclosure_new_swap (G_CALLBACK (fr_window_close), window, NULL)); if (! gtk_ui_manager_add_ui_from_resource (ui, "/org/gnome/FileRoller/ui/menus-toolbars.ui", &error)) { g_message ("building menus failed: %s", error->message); g_error_free (error); } g_object_set (other_actions_action, "menu", gtk_ui_manager_get_widget (ui, "/OtherActionsMenu"), NULL); g_object_unref (other_actions_action); window->priv->toolbar = toolbar = gtk_ui_manager_get_widget (ui, "/ToolBar"); gtk_toolbar_set_show_arrow (GTK_TOOLBAR (toolbar), TRUE); gtk_style_context_add_class (gtk_widget_get_style_context (toolbar), GTK_STYLE_CLASS_PRIMARY_TOOLBAR); set_action_important (ui, "/ToolBar/Extract_Toolbar"); set_action_important (ui, "/ToolBar/Add_Toolbar"); /* location bar */ window->priv->location_bar = gtk_ui_manager_get_widget (ui, "/LocationBar"); gtk_toolbar_set_show_arrow (GTK_TOOLBAR (window->priv->location_bar), FALSE); gtk_toolbar_set_style (GTK_TOOLBAR (window->priv->location_bar), GTK_TOOLBAR_BOTH_HORIZ); gtk_style_context_add_class (gtk_widget_get_style_context (window->priv->location_bar), GTK_STYLE_CLASS_TOOLBAR); set_action_important (ui, "/LocationBar/GoBack"); /* current location */ location_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6); /* Translators: after the colon there is a folder name. */ window->priv->location_label = gtk_label_new_with_mnemonic (_("_Location:")); gtk_box_pack_start (GTK_BOX (location_box), window->priv->location_label, FALSE, FALSE, 5); window->priv->location_entry = gtk_entry_new (); gtk_entry_set_icon_from_stock (GTK_ENTRY (window->priv->location_entry), GTK_ENTRY_ICON_PRIMARY, GTK_STOCK_DIRECTORY); gtk_box_pack_start (GTK_BOX (location_box), window->priv->location_entry, TRUE, TRUE, 5); g_signal_connect (G_OBJECT (window->priv->location_entry), "key_press_event", G_CALLBACK (location_entry_key_press_event_cb), window); { GtkToolItem *tool_item; tool_item = gtk_separator_tool_item_new (); gtk_widget_show_all (GTK_WIDGET (tool_item)); gtk_toolbar_insert (GTK_TOOLBAR (window->priv->location_bar), tool_item, -1); tool_item = gtk_tool_item_new (); gtk_tool_item_set_expand (tool_item, TRUE); gtk_container_add (GTK_CONTAINER (tool_item), location_box); gtk_widget_show_all (GTK_WIDGET (tool_item)); gtk_toolbar_insert (GTK_TOOLBAR (window->priv->location_bar), tool_item, -1); } fr_window_attach (FR_WINDOW (window), window->priv->location_bar, FR_WINDOW_AREA_LOCATIONBAR); if (window->priv->list_mode == FR_WINDOW_LIST_MODE_FLAT) gtk_widget_hide (window->priv->location_bar); else gtk_widget_show (window->priv->location_bar); /**/ fr_window_attach (FR_WINDOW (window), window->priv->toolbar, FR_WINDOW_AREA_TOOLBAR); gtk_widget_show (toolbar); window->priv->file_popup_menu = gtk_ui_manager_get_widget (ui, "/FilePopupMenu"); window->priv->folder_popup_menu = gtk_ui_manager_get_widget (ui, "/FolderPopupMenu"); window->priv->sidebar_folder_popup_menu = gtk_ui_manager_get_widget (ui, "/SidebarFolderPopupMenu"); /* Create the statusbar. */ window->priv->statusbar = gtk_statusbar_new (); window->priv->help_message_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->priv->statusbar), "help_message"); window->priv->list_info_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->priv->statusbar), "list_info"); window->priv->progress_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (window->priv->statusbar), "progress"); statusbar = GTK_STATUSBAR (window->priv->statusbar); statusbar_box = gtk_statusbar_get_message_area (statusbar); gtk_box_set_homogeneous (GTK_BOX (statusbar_box), FALSE); gtk_box_set_spacing (GTK_BOX (statusbar_box), 4); gtk_box_set_child_packing (GTK_BOX (statusbar_box), gtk_statusbar_get_message_area (statusbar), TRUE, TRUE, 0, GTK_PACK_START ); window->priv->progress_bar = gtk_progress_bar_new (); gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (window->priv->progress_bar), ACTIVITY_PULSE_STEP); gtk_widget_set_size_request (window->priv->progress_bar, -1, PROGRESS_BAR_HEIGHT); { GtkWidget *vbox; vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_pack_start (GTK_BOX (statusbar_box), vbox, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), window->priv->progress_bar, TRUE, TRUE, 1); gtk_widget_show (vbox); } gtk_widget_show (statusbar_box); fr_window_attach (FR_WINDOW (window), window->priv->statusbar, FR_WINDOW_AREA_STATUSBAR); if (g_settings_get_boolean (window->priv->settings_ui, PREF_UI_VIEW_STATUSBAR)) gtk_widget_show (window->priv->statusbar); else gtk_widget_hide (window->priv->statusbar); /**/ toolbar_size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); gtk_size_group_add_widget (toolbar_size_group, window->priv->location_bar); gtk_size_group_add_widget (toolbar_size_group, window->priv->filter_bar); /**/ fr_window_update_title (window); fr_window_update_sensitivity (window); fr_window_update_current_location (window); fr_window_update_columns_visibility (window); /* Add notification callbacks. */ g_signal_connect (window->priv->settings_ui, "changed::" PREF_UI_HISTORY_LEN, G_CALLBACK (pref_history_len_changed), window); g_signal_connect (window->priv->settings_ui, "changed::" PREF_UI_VIEW_STATUSBAR, G_CALLBACK (pref_view_statusbar_changed), window); g_signal_connect (window->priv->settings_ui, "changed::" PREF_UI_VIEW_FOLDERS, G_CALLBACK (pref_view_folders_changed), window); g_signal_connect (window->priv->settings_listing, "changed::" PREF_LISTING_SHOW_TYPE, G_CALLBACK (pref_show_field_changed), window); g_signal_connect (window->priv->settings_listing, "changed::" PREF_LISTING_SHOW_SIZE, G_CALLBACK (pref_show_field_changed), window); g_signal_connect (window->priv->settings_listing, "changed::" PREF_LISTING_SHOW_TIME, G_CALLBACK (pref_show_field_changed), window); g_signal_connect (window->priv->settings_listing, "changed::" PREF_LISTING_SHOW_PATH, G_CALLBACK (pref_show_field_changed), window); g_signal_connect (window->priv->settings_listing, "changed::" PREF_LISTING_LIST_MODE, G_CALLBACK (pref_list_mode_changed), window); if (window->priv->settings_nautilus) g_signal_connect (window->priv->settings_nautilus, "changed::" NAUTILUS_CLICK_POLICY, G_CALLBACK (pref_click_policy_changed), window); /* Give focus to the list. */ gtk_widget_grab_focus (window->priv->list_view); }
0
344,815
get_sock_af(int fd) { struct sockaddr_storage to; socklen_t tolen = sizeof(to); memset(&to, 0, sizeof(to)); if (getsockname(fd, (struct sockaddr *)&to, &tolen) == -1) return -1; #ifdef IPV4_IN_IPV6 if (to.ss_family == AF_INET6 && IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)&to)->sin6_addr)) return AF_INET; #endif return to.ss_family; }
0
248,753
static struct curl_slist *cookie_list(struct Curl_easy *data) { struct curl_slist *list = NULL; struct curl_slist *beg; struct Cookie *c; char *line; unsigned int i; if(!data->cookies || (data->cookies->numcookies == 0)) return NULL; for(i = 0; i < COOKIE_HASH_SIZE; i++) { for(c = data->cookies->cookies[i]; c; c = c->next) { if(!c->domain) continue; line = get_netscape_format(c); if(!line) { curl_slist_free_all(list); return NULL; } beg = Curl_slist_append_nodup(list, line); if(!beg) { free(line); curl_slist_free_all(list); return NULL; } list = beg; } } return list; }
0
509,569
int maria_checkpoint_state(handlerton *hton, bool disabled) { maria_checkpoint_disabled= (my_bool) disabled; return 0; }
0
455,410
xfs_queue_cowblocks( struct xfs_mount *mp) { rcu_read_lock(); if (radix_tree_tagged(&mp->m_perag_tree, XFS_ICI_COWBLOCKS_TAG)) queue_delayed_work(mp->m_eofblocks_workqueue, &mp->m_cowblocks_work, msecs_to_jiffies(xfs_cowb_secs * 1000)); rcu_read_unlock(); }
0
500,702
const char *sftp_extensions_get_data(sftp_session sftp, unsigned int idx) { if (sftp == NULL) return NULL; if (sftp->ext == NULL || sftp->ext->name == NULL) { ssh_set_error_invalid(sftp->session, __FUNCTION__); return NULL; } if (idx > sftp->ext->count) { ssh_set_error_invalid(sftp->session, __FUNCTION__); return NULL; } return sftp->ext->data[idx]; }
0
231,753
TEST_P( QuicServerTransportAllowMigrationTest, MigrateToUnvalidatedPeerOverwritesCachedRttState) { folly::SocketAddress newPeer("100.101.102.103", 23456); server->getNonConstConn().migrationState.previousPeerAddresses.push_back( newPeer); CongestionAndRttState state; state.peerAddress = newPeer; state.recordTime = Clock::now(); state.congestionController = ccFactory_->makeCongestionController( server->getNonConstConn(), server->getNonConstConn().transportSettings.defaultCongestionController); state.srtt = 1000us; state.lrtt = 2000us; state.rttvar = 3000us; state.mrtt = 800us; server->getNonConstConn().migrationState.lastCongestionAndRtt = std::move(state); auto data = IOBuf::copyBuffer("bad data"); auto packetData = packetToBuf(createStreamPacket( *clientConnectionId, *server->getConn().serverConnectionId, clientNextAppDataPacketNum++, 2, *data, 0 /* cipherOverhead */, 0 /* largestAcked */)); EXPECT_EQ(server->getConn().migrationState.previousPeerAddresses.size(), 1); auto peerAddress = server->getConn().peerAddress; auto congestionController = server->getConn().congestionController.get(); auto srtt = server->getConn().lossState.srtt; auto lrtt = server->getConn().lossState.lrtt; auto rttvar = server->getConn().lossState.rttvar; auto mrtt = server->getConn().lossState.mrtt; folly::SocketAddress newPeer2("200.101.102.103", 2345); deliverData(std::move(packetData), false, &newPeer2); EXPECT_TRUE(server->getConn().pendingEvents.pathChallenge); EXPECT_EQ(server->getConn().peerAddress, newPeer2); EXPECT_EQ(server->getConn().migrationState.previousPeerAddresses.size(), 2); EXPECT_EQ( server->getConn().migrationState.previousPeerAddresses.front(), newPeer); EXPECT_EQ( server->getConn().migrationState.previousPeerAddresses.back(), peerAddress); EXPECT_EQ(server->getConn().lossState.srtt, 0us); EXPECT_EQ(server->getConn().lossState.lrtt, 0us); EXPECT_EQ(server->getConn().lossState.rttvar, 0us); EXPECT_EQ(server->getConn().lossState.mrtt, kDefaultMinRtt); EXPECT_NE(server->getConn().congestionController.get(), nullptr); EXPECT_NE(server->getConn().congestionController.get(), congestionController); EXPECT_EQ( server->getConn().migrationState.lastCongestionAndRtt->peerAddress, clientAddr); EXPECT_EQ( server->getConn() .migrationState.lastCongestionAndRtt->congestionController.get(), congestionController); EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->srtt, srtt); EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->lrtt, lrtt); EXPECT_EQ( server->getConn().migrationState.lastCongestionAndRtt->rttvar, rttvar); EXPECT_EQ(server->getConn().migrationState.lastCongestionAndRtt->mrtt, mrtt); }
0
430,441
static int parse_flow_mask_nlattrs(const struct nlattr *attr, const struct nlattr *a[], u64 *attrsp, bool log) { return __parse_flow_nlattrs(attr, a, attrsp, log, true); }
0
312,461
qf_buf_add_line( buf_T *buf, // quickfix window buffer linenr_T lnum, qfline_T *qfp, char_u *dirname, int first_bufline, char_u *qftf_str) { int len; buf_T *errbuf; // If the 'quickfixtextfunc' function returned a non-empty custom string // for this entry, then use it. if (qftf_str != NULL && *qftf_str != NUL) vim_strncpy(IObuff, qftf_str, IOSIZE - 1); else { if (qfp->qf_module != NULL) { vim_strncpy(IObuff, qfp->qf_module, IOSIZE - 1); len = (int)STRLEN(IObuff); } else if (qfp->qf_fnum != 0 && (errbuf = buflist_findnr(qfp->qf_fnum)) != NULL && errbuf->b_fname != NULL) { if (qfp->qf_type == 1) // :helpgrep vim_strncpy(IObuff, gettail(errbuf->b_fname), IOSIZE - 1); else { // Shorten the file name if not done already. // For optimization, do this only for the first entry in a // buffer. if (first_bufline && (errbuf->b_sfname == NULL || mch_isFullName(errbuf->b_sfname))) { if (*dirname == NUL) mch_dirname(dirname, MAXPATHL); shorten_buf_fname(errbuf, dirname, FALSE); } vim_strncpy(IObuff, errbuf->b_fname, IOSIZE - 1); } len = (int)STRLEN(IObuff); } else len = 0; if (len < IOSIZE - 1) IObuff[len++] = '|'; if (qfp->qf_lnum > 0) { qf_range_text(qfp, IObuff + len, IOSIZE - len); len += (int)STRLEN(IObuff + len); vim_snprintf((char *)IObuff + len, IOSIZE - len, "%s", (char *)qf_types(qfp->qf_type, qfp->qf_nr)); len += (int)STRLEN(IObuff + len); } else if (qfp->qf_pattern != NULL) { qf_fmt_text(qfp->qf_pattern, IObuff + len, IOSIZE - len); len += (int)STRLEN(IObuff + len); } if (len < IOSIZE - 2) { IObuff[len++] = '|'; IObuff[len++] = ' '; } // Remove newlines and leading whitespace from the text. // For an unrecognized line keep the indent, the compiler may // mark a word with ^^^^. qf_fmt_text(len > 3 ? skipwhite(qfp->qf_text) : qfp->qf_text, IObuff + len, IOSIZE - len); } if (ml_append_buf(buf, lnum, IObuff, (colnr_T)STRLEN(IObuff) + 1, FALSE) == FAIL) return FAIL; return OK; }
0
252,279
static void tdefl_huffman_enforce_max_code_size(int *pNum_codes, int code_list_len, int max_code_size) { int i; mz_uint32 total = 0; if (code_list_len <= 1) return; for (i = max_code_size + 1; i <= TDEFL_MAX_SUPPORTED_HUFF_CODESIZE; i++) pNum_codes[max_code_size] += pNum_codes[i]; for (i = max_code_size; i > 0; i--) total += (((mz_uint32)pNum_codes[i]) << (max_code_size - i)); while (total != (1UL << max_code_size)) { pNum_codes[max_code_size]--; for (i = max_code_size - 1; i > 0; i--) if (pNum_codes[i]) { pNum_codes[i]--; pNum_codes[i + 1] += 2; break; } total--; } }
0
222,576
Status FunctionLibraryDefinition::RemoveFunction(const string& func) { mutex_lock l(mu_); TF_RETURN_IF_ERROR(RemoveFunctionHelper(func)); return Status::OK(); }
0
389,698
free_tv(typval_T *varp) { if (varp != NULL) { switch (varp->v_type) { case VAR_FUNC: func_unref(varp->vval.v_string); // FALLTHROUGH case VAR_STRING: vim_free(varp->vval.v_string); break; case VAR_PARTIAL: partial_unref(varp->vval.v_partial); break; case VAR_BLOB: blob_unref(varp->vval.v_blob); break; case VAR_LIST: list_unref(varp->vval.v_list); break; case VAR_DICT: dict_unref(varp->vval.v_dict); break; case VAR_JOB: #ifdef FEAT_JOB_CHANNEL job_unref(varp->vval.v_job); break; #endif case VAR_CHANNEL: #ifdef FEAT_JOB_CHANNEL channel_unref(varp->vval.v_channel); break; #endif case VAR_NUMBER: case VAR_FLOAT: case VAR_ANY: case VAR_UNKNOWN: case VAR_VOID: case VAR_BOOL: case VAR_SPECIAL: case VAR_INSTR: break; } vim_free(varp); } }
0
226,985
IRC_PROTOCOL_CALLBACK(354) { char *pos_attr, *pos_hopcount, *pos_account, *pos_realname, *str_host; int length; struct t_irc_channel *ptr_channel; struct t_irc_nick *ptr_nick; IRC_PROTOCOL_MIN_ARGS(4); ptr_channel = irc_channel_search (server, argv[3]); /* * if there are less than 11 arguments, we are unable to parse the message, * some infos are missing but we don't know which ones; in this case we * just display the message as-is */ if (argc < 11) { if (!ptr_channel || (ptr_channel->checking_whox <= 0)) { weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer ( server, NULL, command, "who", NULL), date, irc_protocol_tags (command, "irc_numeric", NULL, NULL), "%s%s[%s%s%s]%s%s%s", weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_CHANNEL, argv[3], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, (argc > 4) ? " " : "", (argc > 4) ? argv_eol[4] : ""); } return WEECHAT_RC_OK; } ptr_nick = (ptr_channel) ? irc_nick_search (server, ptr_channel, argv[7]) : NULL; pos_attr = argv[8]; pos_hopcount = argv[9]; pos_account = (strcmp (argv[10], "0") != 0) ? argv[10] : NULL; pos_realname = (argc > 11) ? ((argv_eol[11][0] == ':') ? argv_eol[11] + 1 : argv_eol[11]) : NULL; /* update host in nick */ if (ptr_nick) { length = strlen (argv[4]) + 1 + strlen (argv[5]) + 1; str_host = malloc (length); if (str_host) { snprintf (str_host, length, "%s@%s", argv[4], argv[5]); irc_nick_set_host (ptr_nick, str_host); free (str_host); } } /* update away flag in nick */ if (ptr_channel && ptr_nick) { irc_nick_set_away (server, ptr_channel, ptr_nick, (pos_attr && (pos_attr[0] == 'G')) ? 1 : 0); } /* update account flag in nick */ if (ptr_nick) { if (ptr_nick->account) free (ptr_nick->account); if (ptr_channel && pos_account && weechat_hashtable_has_key (server->cap_list, "account-notify")) { ptr_nick->account = strdup (pos_account); } else { ptr_nick->account = NULL; } } /* update realname in nick */ if (ptr_nick) { if (ptr_nick->realname) free (ptr_nick->realname); if (ptr_channel && pos_realname && weechat_hashtable_has_key (server->cap_list, "extended-join")) { ptr_nick->realname = strdup (pos_realname); } else { ptr_nick->realname = NULL; } } /* display output of who (manual who from user) */ if (!ptr_channel || (ptr_channel->checking_whox <= 0)) { weechat_printf_date_tags ( irc_msgbuffer_get_target_buffer ( server, NULL, command, "who", NULL), date, irc_protocol_tags (command, "irc_numeric", NULL, NULL), "%s%s[%s%s%s] %s%s %s%s%s%s%s%s(%s%s@%s%s)%s %s%s%s%s(%s)", weechat_prefix ("network"), IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_CHAT_CHANNEL, argv[3], IRC_COLOR_CHAT_DELIMITERS, irc_nick_color_for_msg (server, 1, NULL, argv[7]), argv[7], IRC_COLOR_CHAT_DELIMITERS, (pos_account) ? "[" : "", (pos_account) ? IRC_COLOR_CHAT_HOST : "", (pos_account) ? pos_account : "", (pos_account) ? IRC_COLOR_CHAT_DELIMITERS : "", (pos_account) ? "] " : "", IRC_COLOR_CHAT_HOST, argv[4], argv[5], IRC_COLOR_CHAT_DELIMITERS, IRC_COLOR_RESET, (pos_attr) ? pos_attr : "", (pos_attr) ? " " : "", (pos_hopcount) ? pos_hopcount : "", (pos_hopcount) ? " " : "", (pos_realname) ? pos_realname : ""); } return WEECHAT_RC_OK; }
0
221,500
flatpak_run_add_session_dbus_args (FlatpakBwrap *app_bwrap, FlatpakBwrap *proxy_arg_bwrap, FlatpakContext *context, FlatpakRunFlags flags, const char *app_id) { static const char sandbox_socket_path[] = "/run/flatpak/bus"; static const char sandbox_dbus_address[] = "unix:path=/run/flatpak/bus"; gboolean unrestricted, no_proxy; const char *dbus_address = g_getenv ("DBUS_SESSION_BUS_ADDRESS"); g_autofree char *dbus_session_socket = NULL; unrestricted = (context->sockets & FLATPAK_CONTEXT_SOCKET_SESSION_BUS) != 0; if (dbus_address != NULL) { dbus_session_socket = extract_unix_path_from_dbus_address (dbus_address); } else { g_autofree char *user_runtime_dir = flatpak_get_real_xdg_runtime_dir (); struct stat statbuf; dbus_session_socket = g_build_filename (user_runtime_dir, "bus", NULL); if (stat (dbus_session_socket, &statbuf) < 0 || (statbuf.st_mode & S_IFMT) != S_IFSOCK || statbuf.st_uid != getuid ()) return FALSE; } if (unrestricted) g_debug ("Allowing session-dbus access"); no_proxy = (flags & FLATPAK_RUN_FLAG_NO_SESSION_BUS_PROXY) != 0; if (dbus_session_socket != NULL && unrestricted) { flatpak_bwrap_add_args (app_bwrap, "--ro-bind", dbus_session_socket, sandbox_socket_path, NULL); flatpak_bwrap_set_env (app_bwrap, "DBUS_SESSION_BUS_ADDRESS", sandbox_dbus_address, TRUE); flatpak_bwrap_add_runtime_dir_member (app_bwrap, "bus"); return TRUE; } else if (!no_proxy && dbus_address != NULL) { g_autofree char *proxy_socket = create_proxy_socket ("session-bus-proxy-XXXXXX"); if (proxy_socket == NULL) return FALSE; flatpak_bwrap_add_args (proxy_arg_bwrap, dbus_address, proxy_socket, NULL); if (!unrestricted) { flatpak_context_add_bus_filters (context, app_id, TRUE, flags & FLATPAK_RUN_FLAG_SANDBOX, proxy_arg_bwrap); /* Allow calling any interface+method on all portals, but only receive broadcasts under /org/desktop/portal */ flatpak_bwrap_add_arg (proxy_arg_bwrap, "--call=org.freedesktop.portal.*=*"); flatpak_bwrap_add_arg (proxy_arg_bwrap, "--broadcast=org.freedesktop.portal.*=@/org/freedesktop/portal/*"); } if ((flags & FLATPAK_RUN_FLAG_LOG_SESSION_BUS) != 0) flatpak_bwrap_add_args (proxy_arg_bwrap, "--log", NULL); flatpak_bwrap_add_args (app_bwrap, "--ro-bind", proxy_socket, sandbox_socket_path, NULL); flatpak_bwrap_set_env (app_bwrap, "DBUS_SESSION_BUS_ADDRESS", sandbox_dbus_address, TRUE); flatpak_bwrap_add_runtime_dir_member (app_bwrap, "bus"); return TRUE; } return FALSE; }
0
459,220
static struct tcf_block *__tcf_block_find(struct net *net, struct Qdisc *q, unsigned long cl, int ifindex, u32 block_index, struct netlink_ext_ack *extack) { struct tcf_block *block; if (ifindex == TCM_IFINDEX_MAGIC_BLOCK) { block = tcf_block_refcnt_get(net, block_index); if (!block) { NL_SET_ERR_MSG(extack, "Block of given index was not found"); return ERR_PTR(-EINVAL); } } else { const struct Qdisc_class_ops *cops = q->ops->cl_ops; block = cops->tcf_block(q, cl, extack); if (!block) return ERR_PTR(-EINVAL); if (tcf_block_shared(block)) { NL_SET_ERR_MSG(extack, "This filter block is shared. Please use the block index to manipulate the filters"); return ERR_PTR(-EOPNOTSUPP); } /* Always take reference to block in order to support execution * of rules update path of cls API without rtnl lock. Caller * must release block when it is finished using it. 'if' block * of this conditional obtain reference to block by calling * tcf_block_refcnt_get(). */ refcount_inc(&block->refcnt); } return block; }
0
441,815
SProcXkbGetIndicatorState(ClientPtr client) { REQUEST(xkbGetIndicatorStateReq); swaps(&stuff->length); REQUEST_SIZE_MATCH(xkbGetIndicatorStateReq); swaps(&stuff->deviceSpec); return ProcXkbGetIndicatorState(client); }
0
338,168
void WasmBinaryBuilder::visitTryOrTryInBlock(Expression*& out) { BYN_TRACE("zz node: Try\n"); auto* curr = allocator.alloc<Try>(); startControlFlow(curr); // For simplicity of implementation, like if scopes, we create a hidden block // within each try-body and catch-body, and let branches target those inner // blocks instead. curr->type = getType(); curr->body = getBlockOrSingleton(curr->type); Builder builder(wasm); // A nameless label shared by all catch body blocks Name catchLabel = getNextLabel(); breakStack.push_back({catchLabel, curr->type}); auto readCatchBody = [&](Type tagType) { auto start = expressionStack.size(); if (tagType != Type::none) { pushExpression(builder.makePop(tagType)); } processExpressions(); size_t end = expressionStack.size(); if (start > end) { throwError("block cannot pop from outside"); } if (end - start == 1) { curr->catchBodies.push_back(popExpression()); } else { auto* block = allocator.alloc<Block>(); pushBlockElements(block, curr->type, start); block->finalize(curr->type); curr->catchBodies.push_back(block); } }; while (lastSeparator == BinaryConsts::Catch || lastSeparator == BinaryConsts::CatchAll) { if (lastSeparator == BinaryConsts::Catch) { auto index = getU32LEB(); if (index >= wasm.tags.size()) { throwError("bad tag index"); } auto* tag = wasm.tags[index].get(); curr->catchTags.push_back(tag->name); readCatchBody(tag->sig.params); } else { // catch_all if (curr->hasCatchAll()) { throwError("there should be at most one 'catch_all' clause per try"); } readCatchBody(Type::none); } } breakStack.pop_back(); if (lastSeparator == BinaryConsts::Delegate) { curr->delegateTarget = getExceptionTargetName(getU32LEB()); } // For simplicity, we ensure that try's labels can only be targeted by // delegates and rethrows, and delegates/rethrows can only target try's // labels. (If they target blocks or loops, it is a validation failure.) // Because we create an inner block within each try and catch body, if any // delegate/rethrow targets those inner blocks, we should make them target the // try's label instead. curr->name = getNextLabel(); if (auto* block = curr->body->dynCast<Block>()) { if (block->name.is()) { if (exceptionTargetNames.find(block->name) != exceptionTargetNames.end()) { BranchUtils::replaceExceptionTargets(block, block->name, curr->name); exceptionTargetNames.erase(block->name); } } } if (exceptionTargetNames.find(catchLabel) != exceptionTargetNames.end()) { for (auto* catchBody : curr->catchBodies) { BranchUtils::replaceExceptionTargets(catchBody, catchLabel, curr->name); } exceptionTargetNames.erase(catchLabel); } // If catch bodies contained stacky code, 'pop's can be nested within a block. // Fix that up. EHUtils::handleBlockNestedPop(curr, currFunction, wasm); curr->finalize(curr->type); // For simplicity, we create an inner block within the catch body too, but the // one within the 'catch' *must* be omitted when we write out the binary back // later, because the 'catch' instruction pushes a value onto the stack and // the inner block does not support block input parameters without multivalue // support. // try // ... // catch $e ;; Pushes value(s) onto the stack // block ;; Inner block. Should be deleted when writing binary! // use the pushed value // end // end // // But when input binary code is like // try // ... // catch $e // br 0 // end // // 'br 0' accidentally happens to target the inner block, creating code like // this in Binaryen IR, making the inner block not deletable, resulting in a // validation error: // (try // ... // (catch $e // (block $label0 ;; Cannot be deleted, because there's a branch to this // ... // (br $label0) // ) // ) // ) // // When this happens, we fix this by creating a block that wraps the whole // try-catch, and making the branches target that block instead, like this: // (block $label ;; New enclosing block, new target for the branch // (try // ... // (catch $e // (block ;; Now this can be deleted when writing binary // ... // (br $label) // ) // ) // ) // ) if (breakTargetNames.find(catchLabel) == breakTargetNames.end()) { out = curr; } else { // Create a new block that encloses the whole try-catch auto* block = builder.makeBlock(catchLabel, curr); out = block; } breakTargetNames.erase(catchLabel); }
0
307,842
int ciEnv::num_inlined_bytecodes() const { return _num_inlined_bytecodes; }
0
220,935
static GF_Err mpgviddmx_initialize(GF_Filter *filter) { GF_MPGVidDmxCtx *ctx = gf_filter_get_udta(filter); ctx->hdr_store_size = 0; ctx->hdr_store_alloc = 8; ctx->hdr_store = gf_malloc(sizeof(char)*8); return GF_OK; }
0
472,366
ciConstant ciEnv::get_constant_by_index_impl(const constantPoolHandle& cpool, int pool_index, int cache_index, ciInstanceKlass* accessor) { int index = pool_index; if (cache_index >= 0) { assert(index < 0, "only one kind of index at a time"); index = cpool->object_to_cp_index(cache_index); oop obj = cpool->resolved_references()->obj_at(cache_index); if (obj != NULL) { if (obj == Universe::the_null_sentinel()) { return ciConstant(T_OBJECT, get_object(NULL)); } BasicType bt = T_OBJECT; if (cpool->tag_at(index).is_dynamic_constant()) { bt = Signature::basic_type(cpool->uncached_signature_ref_at(index)); } if (!is_reference_type(bt)) { // we have to unbox the primitive value if (!is_java_primitive(bt)) { return ciConstant(); } jvalue value; BasicType bt2 = java_lang_boxing_object::get_value(obj, &value); assert(bt2 == bt, ""); switch (bt2) { case T_DOUBLE: return ciConstant(value.d); case T_FLOAT: return ciConstant(value.f); case T_LONG: return ciConstant(value.j); case T_INT: return ciConstant(bt2, value.i); case T_SHORT: return ciConstant(bt2, value.s); case T_BYTE: return ciConstant(bt2, value.b); case T_CHAR: return ciConstant(bt2, value.c); case T_BOOLEAN: return ciConstant(bt2, value.z); default: return ciConstant(); } } ciObject* ciobj = get_object(obj); if (ciobj->is_array()) { return ciConstant(T_ARRAY, ciobj); } else { assert(ciobj->is_instance(), "should be an instance"); return ciConstant(T_OBJECT, ciobj); } } } constantTag tag = cpool->tag_at(index); if (tag.is_int()) { return ciConstant(T_INT, (jint)cpool->int_at(index)); } else if (tag.is_long()) { return ciConstant((jlong)cpool->long_at(index)); } else if (tag.is_float()) { return ciConstant((jfloat)cpool->float_at(index)); } else if (tag.is_double()) { return ciConstant((jdouble)cpool->double_at(index)); } else if (tag.is_string()) { EXCEPTION_CONTEXT; oop string = NULL; assert(cache_index >= 0, "should have a cache index"); string = cpool->string_at(index, cache_index, THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; record_out_of_memory_failure(); return ciConstant(); } ciObject* constant = get_object(string); if (constant->is_array()) { return ciConstant(T_ARRAY, constant); } else { assert (constant->is_instance(), "must be an instance, or not? "); return ciConstant(T_OBJECT, constant); } } else if (tag.is_unresolved_klass_in_error()) { return ciConstant(T_OBJECT, get_unloaded_klass_mirror(NULL)); } else if (tag.is_klass() || tag.is_unresolved_klass()) { bool will_link; ciKlass* klass = get_klass_by_index_impl(cpool, index, will_link, accessor); assert (klass->is_instance_klass() || klass->is_array_klass(), "must be an instance or array klass "); ciInstance* mirror = (will_link ? klass->java_mirror() : get_unloaded_klass_mirror(klass)); return ciConstant(T_OBJECT, mirror); } else if (tag.is_method_type() || tag.is_method_type_in_error()) { // must execute Java code to link this CP entry into cache[i].f1 ciSymbol* signature = get_symbol(cpool->method_type_signature_at(index)); ciObject* ciobj = get_unloaded_method_type_constant(signature); return ciConstant(T_OBJECT, ciobj); } else if (tag.is_method_handle() || tag.is_method_handle_in_error()) { // must execute Java code to link this CP entry into cache[i].f1 bool ignore_will_link; int ref_kind = cpool->method_handle_ref_kind_at(index); int callee_index = cpool->method_handle_klass_index_at(index); ciKlass* callee = get_klass_by_index_impl(cpool, callee_index, ignore_will_link, accessor); ciSymbol* name = get_symbol(cpool->method_handle_name_ref_at(index)); ciSymbol* signature = get_symbol(cpool->method_handle_signature_ref_at(index)); ciObject* ciobj = get_unloaded_method_handle_constant(callee, name, signature, ref_kind); return ciConstant(T_OBJECT, ciobj); } else if (tag.is_dynamic_constant() || tag.is_dynamic_constant_in_error()) { return ciConstant(); // not supported } else { assert(false, "unknown tag: %d (%s)", tag.value(), tag.internal_name()); return ciConstant(); } }
0
253,589
smb2_get_enc_key(struct TCP_Server_Info *server, __u64 ses_id, int enc, u8 *key) { struct cifs_ses *ses; u8 *ses_enc_key; spin_lock(&cifs_tcp_ses_lock); list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) { list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) { if (ses->Suid == ses_id) { ses_enc_key = enc ? ses->smb3encryptionkey : ses->smb3decryptionkey; memcpy(key, ses_enc_key, SMB3_ENC_DEC_KEY_SIZE); spin_unlock(&cifs_tcp_ses_lock); return 0; } } } spin_unlock(&cifs_tcp_ses_lock); return -EAGAIN; }
0
413,674
static int fcn_print_detail(RCore *core, RAnalFunction *fcn) { const char *defaultCC = r_anal_cc_default (core->anal); char *name = r_core_anal_fcn_name (core, fcn); char *paren = strchr (name, '('); if (paren) { *paren = '\0'; } r_cons_printf ("\"f %s %"PFMT64u" 0x%08"PFMT64x"\"\n", name, r_anal_function_linear_size (fcn), fcn->addr); r_cons_printf ("\"af+ 0x%08"PFMT64x" %s %c %c\"\n", fcn->addr, name, //r_anal_function_size (fcn), name, fcn->type == R_ANAL_FCN_TYPE_LOC?'l': fcn->type == R_ANAL_FCN_TYPE_SYM?'s': fcn->type == R_ANAL_FCN_TYPE_IMP?'i':'f', fcn->diff->type == R_ANAL_DIFF_TYPE_MATCH?'m': fcn->diff->type == R_ANAL_DIFF_TYPE_UNMATCH?'u':'n'); // FIXME: this command prints something annoying. Does it have important side-effects? fcn_list_bbs (fcn); if (fcn->bits != 0) { r_cons_printf ("afB %d @ 0x%08"PFMT64x"\n", fcn->bits, fcn->addr); } // FIXME command injection vuln here if (fcn->cc || defaultCC) { r_cons_printf ("s 0x%"PFMT64x"\n", fcn->addr); r_cons_printf ("\"afc %s\"\n", fcn->cc? fcn->cc: defaultCC); r_cons_println ("s-"); } if (fcn->folded) { r_cons_printf ("afF @ 0x%08"PFMT64x"\n", fcn->addr); } if (fcn) { /* show variables and arguments */ r_core_cmdf (core, "afvb* @ 0x%"PFMT64x"\n", fcn->addr); r_core_cmdf (core, "afvr* @ 0x%"PFMT64x"\n", fcn->addr); r_core_cmdf (core, "afvs* @ 0x%"PFMT64x"\n", fcn->addr); } /* Show references */ RListIter *refiter; RAnalRef *refi; RList *refs = r_anal_function_get_refs (fcn); r_list_foreach (refs, refiter, refi) { switch (refi->type) { case R_ANAL_REF_TYPE_CALL: r_cons_printf ("axC 0x%"PFMT64x" 0x%"PFMT64x"\n", refi->addr, refi->at); break; case R_ANAL_REF_TYPE_DATA: r_cons_printf ("axd 0x%"PFMT64x" 0x%"PFMT64x"\n", refi->addr, refi->at); break; case R_ANAL_REF_TYPE_CODE: r_cons_printf ("axc 0x%"PFMT64x" 0x%"PFMT64x"\n", refi->addr, refi->at); break; case R_ANAL_REF_TYPE_STRING: r_cons_printf ("axs 0x%"PFMT64x" 0x%"PFMT64x"\n", refi->addr, refi->at); break; case R_ANAL_REF_TYPE_NULL: default: r_cons_printf ("ax 0x%"PFMT64x" 0x%"PFMT64x"\n", refi->addr, refi->at); break; } } r_list_free (refs); /*Saving Function stack frame*/ r_cons_printf ("afS %d @ 0x%"PFMT64x"\n", fcn->maxstack, fcn->addr); free (name); return 0; }
0
402,627
get_str(Pe *pe, char *strnum) { size_t sz; unsigned long num; char *strtab; uint32_t strtabsz; /* no idea what the real max size for these is, so... we're not going * to have 4B strings, and this can't be the end of the binary, so * this is big enough. */ sz = strnlen(strnum, 11); if (sz == 11) return NULL; errno = 0; num = strtoul(strnum, NULL, 10); if (errno != 0) return NULL; strtab = get_strtab(pe); if (!strtab) return NULL; strtabsz = *(uint32_t *)strtab; if (num >= strtabsz) return NULL; if (strnlen(&strtab[num], strtabsz - num) > strtabsz - num - 1) return NULL; return &strtab[num]; }
0
240,608
void VarHandleOp::Compute(OpKernelContext* ctx) { if (is_anonymous_) { AllocatorAttributes attr; attr.set_on_host(true); Tensor handle; OP_REQUIRES_OK( ctx, ctx->allocate_temp(DT_RESOURCE, TensorShape({}), &handle, attr)); handle.scalar<ResourceHandle>()() = MakeResourceHandle<Var>( ctx, container_, name_, std::vector<DtypeAndPartialTensorShape>{dtype_and_shape_}, ctx->stack_trace()); ctx->set_output(0, handle); } else { ctx->set_output(0, resource_); } }
0
216,938
bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx) { TABLE *table; const char *key; uint key_length; const char *alias= table_list->alias.str; uint flags= ot_ctx->get_flags(); MDL_ticket *mdl_ticket; TABLE_SHARE *share; uint gts_flags; bool from_share= false; #ifdef WITH_PARTITION_STORAGE_ENGINE int part_names_error=0; #endif DBUG_ENTER("open_table"); /* The table must not be opened already. The table can be pre-opened for some statements if it is a temporary table. open_temporary_table() must be used to open temporary tables. */ DBUG_ASSERT(!table_list->table); /* an open table operation needs a lot of the stack space */ if (check_stack_overrun(thd, STACK_MIN_SIZE_FOR_OPEN, (uchar *)&alias)) DBUG_RETURN(TRUE); if (!(flags & MYSQL_OPEN_IGNORE_KILLED) && thd->killed) { thd->send_kill_message(); DBUG_RETURN(TRUE); } /* Check if we're trying to take a write lock in a read only transaction. Note that we allow write locks on log tables as otherwise logging to general/slow log would be disabled in read only transactions. */ if (table_list->mdl_request.is_write_lock_request() && thd->tx_read_only && !(flags & (MYSQL_LOCK_LOG_TABLE | MYSQL_OPEN_HAS_MDL_LOCK))) { my_error(ER_CANT_EXECUTE_IN_READ_ONLY_TRANSACTION, MYF(0)); DBUG_RETURN(true); } if (!table_list->db.str) { my_error(ER_NO_DB_ERROR, MYF(0)); DBUG_RETURN(true); } key_length= get_table_def_key(table_list, &key); /* If we're in pre-locked or LOCK TABLES mode, let's try to find the requested table in the list of pre-opened and locked tables. If the table is not there, return an error - we can't open not pre-opened tables in pre-locked/LOCK TABLES mode. TODO: move this block into a separate function. */ if (thd->locked_tables_mode && ! (flags & MYSQL_OPEN_GET_NEW_TABLE)) { // Using table locks TABLE *best_table= 0; int best_distance= INT_MIN; for (table=thd->open_tables; table ; table=table->next) { if (table->s->table_cache_key.length == key_length && !memcmp(table->s->table_cache_key.str, key, key_length)) { if (!my_strcasecmp(system_charset_info, table->alias.c_ptr(), alias) && table->query_id != thd->query_id && /* skip tables already used */ (thd->locked_tables_mode == LTM_LOCK_TABLES || table->query_id == 0)) { int distance= ((int) table->reginfo.lock_type - (int) table_list->lock_type); /* Find a table that either has the exact lock type requested, or has the best suitable lock. In case there is no locked table that has an equal or higher lock than requested, we us the closest matching lock to be able to produce an error message about wrong lock mode on the table. The best_table is changed if bd < 0 <= d or bd < d < 0 or 0 <= d < bd. distance < 0 - No suitable lock found distance > 0 - we have lock mode higher then we require distance == 0 - we have lock mode exactly which we need */ if ((best_distance < 0 && distance > best_distance) || (distance >= 0 && distance < best_distance)) { best_distance= distance; best_table= table; if (best_distance == 0) { /* We have found a perfect match and can finish iterating through open tables list. Check for table use conflict between calling statement and SP/trigger is done in lock_tables(). */ break; } } } } } if (best_table) { table= best_table; table->query_id= thd->query_id; table->init(thd, table_list); DBUG_PRINT("info",("Using locked table")); #ifdef WITH_PARTITION_STORAGE_ENGINE part_names_error= set_partitions_as_used(table_list, table); #endif goto reset; } if (is_locked_view(thd, table_list)) { if (table_list->sequence) { my_error(ER_NOT_SEQUENCE, MYF(0), table_list->db.str, table_list->alias.str); DBUG_RETURN(true); } DBUG_RETURN(FALSE); // VIEW } /* No table in the locked tables list. In case of explicit LOCK TABLES this can happen if a user did not include the table into the list. In case of pre-locked mode locked tables list is generated automatically, so we may only end up here if the table did not exist when locked tables list was created. */ if (thd->locked_tables_mode == LTM_PRELOCKED) my_error(ER_NO_SUCH_TABLE, MYF(0), table_list->db.str, table_list->alias.str); else my_error(ER_TABLE_NOT_LOCKED, MYF(0), alias); DBUG_RETURN(TRUE); } /* Non pre-locked/LOCK TABLES mode, and the table is not temporary. This is the normal use case. */ if (! (flags & MYSQL_OPEN_HAS_MDL_LOCK)) { /* We are not under LOCK TABLES and going to acquire write-lock/ modify the base table. We need to acquire protection against global read lock until end of this statement in order to have this statement blocked by active FLUSH TABLES WITH READ LOCK. We don't need to acquire this protection under LOCK TABLES as such protection already acquired at LOCK TABLES time and not released until UNLOCK TABLES. We don't block statements which modify only temporary tables as these tables are not preserved by any form of backup which uses FLUSH TABLES WITH READ LOCK. TODO: The fact that we sometimes acquire protection against GRL only when we encounter table to be write-locked slightly increases probability of deadlock. This problem will be solved once Alik pushes his temporary table refactoring patch and we can start pre-acquiring metadata locks at the beggining of open_tables() call. */ if (table_list->mdl_request.is_write_lock_request() && ! (flags & (MYSQL_OPEN_IGNORE_GLOBAL_READ_LOCK | MYSQL_OPEN_FORCE_SHARED_MDL | MYSQL_OPEN_FORCE_SHARED_HIGH_PRIO_MDL | MYSQL_OPEN_SKIP_SCOPED_MDL_LOCK)) && ! ot_ctx->has_protection_against_grl()) { MDL_request protection_request; MDL_deadlock_handler mdl_deadlock_handler(ot_ctx); if (thd->global_read_lock.can_acquire_protection()) DBUG_RETURN(TRUE); protection_request.init(MDL_key::GLOBAL, "", "", MDL_INTENTION_EXCLUSIVE, MDL_STATEMENT); /* Install error handler which if possible will convert deadlock error into request to back-off and restart process of opening tables. */ thd->push_internal_handler(&mdl_deadlock_handler); bool result= thd->mdl_context.acquire_lock(&protection_request, ot_ctx->get_timeout()); thd->pop_internal_handler(); if (result) DBUG_RETURN(TRUE); ot_ctx->set_has_protection_against_grl(); } if (open_table_get_mdl_lock(thd, ot_ctx, &table_list->mdl_request, flags, &mdl_ticket) || mdl_ticket == NULL) { DEBUG_SYNC(thd, "before_open_table_wait_refresh"); DBUG_RETURN(TRUE); } DEBUG_SYNC(thd, "after_open_table_mdl_shared"); } else { /* Grab reference to the MDL lock ticket that was acquired by the caller. */ mdl_ticket= table_list->mdl_request.ticket; } if (table_list->open_strategy == TABLE_LIST::OPEN_IF_EXISTS) { if (!ha_table_exists(thd, &table_list->db, &table_list->table_name)) DBUG_RETURN(FALSE); } else if (table_list->open_strategy == TABLE_LIST::OPEN_STUB) DBUG_RETURN(FALSE); /* Table exists. Let us try to open it. */ if (table_list->i_s_requested_object & OPEN_TABLE_ONLY) gts_flags= GTS_TABLE; else if (table_list->i_s_requested_object & OPEN_VIEW_ONLY) gts_flags= GTS_VIEW; else gts_flags= GTS_TABLE | GTS_VIEW; retry_share: share= tdc_acquire_share(thd, table_list, gts_flags, &table); if (unlikely(!share)) { /* Hide "Table doesn't exist" errors if the table belongs to a view. The check for thd->is_error() is necessary to not push an unwanted error in case the error was already silenced. @todo Rework the alternative ways to deal with ER_NO_SUCH TABLE. */ if (thd->is_error()) { if (table_list->parent_l) { thd->clear_error(); my_error(ER_WRONG_MRG_TABLE, MYF(0)); } else if (table_list->belong_to_view) { TABLE_LIST *view= table_list->belong_to_view; thd->clear_error(); my_error(ER_VIEW_INVALID, MYF(0), view->view_db.str, view->view_name.str); } } DBUG_RETURN(TRUE); } /* Check if this TABLE_SHARE-object corresponds to a view. Note, that there is no need to check TABLE_SHARE::tdc.flushed as we do for regular tables, because view shares are always up to date. */ if (share->is_view) { /* If parent_l of the table_list is non null then a merge table has this view as child table, which is not supported. */ if (table_list->parent_l) { my_error(ER_WRONG_MRG_TABLE, MYF(0)); goto err_lock; } if (table_list->sequence) { my_error(ER_NOT_SEQUENCE, MYF(0), table_list->db.str, table_list->alias.str); goto err_lock; } /* This table is a view. Validate its metadata version: in particular, that it was a view when the statement was prepared. */ if (check_and_update_table_version(thd, table_list, share)) goto err_lock; /* Open view */ if (mysql_make_view(thd, share, table_list, false)) goto err_lock; /* TODO: Don't free this */ tdc_release_share(share); DBUG_ASSERT(table_list->view); DBUG_RETURN(FALSE); } #ifdef WITH_WSREP if (!((flags & MYSQL_OPEN_IGNORE_FLUSH) || (thd->wsrep_applier))) #else if (!(flags & MYSQL_OPEN_IGNORE_FLUSH)) #endif { if (share->tdc->flushed) { DBUG_PRINT("info", ("Found old share version: %lld current: %lld", share->tdc->version, tdc_refresh_version())); /* We already have an MDL lock. But we have encountered an old version of table in the table definition cache which is possible when someone changes the table version directly in the cache without acquiring a metadata lock (e.g. this can happen during "rolling" FLUSH TABLE(S)). Release our reference to share, wait until old version of share goes away and then try to get new version of table share. */ if (table) tc_release_table(table); else tdc_release_share(share); MDL_deadlock_handler mdl_deadlock_handler(ot_ctx); bool wait_result; thd->push_internal_handler(&mdl_deadlock_handler); wait_result= tdc_wait_for_old_version(thd, table_list->db.str, table_list->table_name.str, ot_ctx->get_timeout(), mdl_ticket->get_deadlock_weight()); thd->pop_internal_handler(); if (wait_result) DBUG_RETURN(TRUE); goto retry_share; } if (thd->open_tables && thd->open_tables->s->tdc->flushed) { /* If the version changes while we're opening the tables, we have to back off, close all the tables opened-so-far, and try to reopen them. Note: refresh_version is currently changed only during FLUSH TABLES. */ if (table) tc_release_table(table); else tdc_release_share(share); (void)ot_ctx->request_backoff_action(Open_table_context::OT_REOPEN_TABLES, NULL); DBUG_RETURN(TRUE); } } if (table) { DBUG_ASSERT(table->file != NULL); MYSQL_REBIND_TABLE(table->file); #ifdef WITH_PARTITION_STORAGE_ENGINE part_names_error= set_partitions_as_used(table_list, table); #endif } else { enum open_frm_error error; /* make a new table */ if (!(table=(TABLE*) my_malloc(sizeof(*table),MYF(MY_WME)))) goto err_lock; error= open_table_from_share(thd, share, &table_list->alias, HA_OPEN_KEYFILE | HA_TRY_READ_ONLY, EXTRA_RECORD, thd->open_options, table, FALSE, IF_PARTITIONING(table_list->partition_names,0)); if (unlikely(error)) { my_free(table); if (error == OPEN_FRM_DISCOVER) (void) ot_ctx->request_backoff_action(Open_table_context::OT_DISCOVER, table_list); else if (share->crashed) { if (!(flags & MYSQL_OPEN_IGNORE_REPAIR)) (void) ot_ctx->request_backoff_action(Open_table_context::OT_REPAIR, table_list); else table_list->crashed= 1; /* Mark that table was crashed */ } goto err_lock; } if (open_table_entry_fini(thd, share, table)) { closefrm(table); my_free(table); goto err_lock; } /* Add table to the share's used tables list. */ tc_add_table(thd, table); from_share= true; } table->mdl_ticket= mdl_ticket; table->reginfo.lock_type=TL_READ; /* Assume read */ table->init(thd, table_list); table->next= thd->open_tables; /* Link into simple list */ thd->set_open_tables(table); reset: /* Check that there is no reference to a condition from an earlier query (cf. Bug#58553). */ DBUG_ASSERT(table->file->pushed_cond == NULL); table_list->updatable= 1; // It is not derived table nor non-updatable VIEW table_list->table= table; if (!from_share && table->vcol_fix_expr(thd)) goto err_lock; #ifdef WITH_PARTITION_STORAGE_ENGINE if (unlikely(table->part_info)) { /* Partitions specified were incorrect.*/ if (part_names_error) { table->file->print_error(part_names_error, MYF(0)); DBUG_RETURN(true); } } else if (table_list->partition_names) { /* Don't allow PARTITION () clause on a nonpartitioned table */ my_error(ER_PARTITION_CLAUSE_ON_NONPARTITIONED, MYF(0)); DBUG_RETURN(true); } #endif if (table_list->sequence && table->s->table_type != TABLE_TYPE_SEQUENCE) { my_error(ER_NOT_SEQUENCE, MYF(0), table_list->db.str, table_list->alias.str); DBUG_RETURN(true); } DBUG_RETURN(FALSE); err_lock: tdc_release_share(share); DBUG_PRINT("exit", ("failed")); DBUG_RETURN(TRUE); }
1
294,715
d_lite_rshift(VALUE self, VALUE other) { VALUE t, y, nth, rjd2; int m, d, rjd; double sg; get_d1(self); t = f_add3(f_mul(m_real_year(dat), INT2FIX(12)), INT2FIX(m_mon(dat) - 1), other); if (FIXNUM_P(t)) { long it = FIX2LONG(t); y = LONG2NUM(DIV(it, 12)); it = MOD(it, 12); m = (int)it + 1; } else { y = f_idiv(t, INT2FIX(12)); t = f_mod(t, INT2FIX(12)); m = FIX2INT(t) + 1; } d = m_mday(dat); sg = m_sg(dat); while (1) { int ry, rm, rd, ns; if (valid_civil_p(y, m, d, sg, &nth, &ry, &rm, &rd, &rjd, &ns)) break; if (--d < 1) rb_raise(eDateError, "invalid date"); } encode_jd(nth, rjd, &rjd2); return d_lite_plus(self, f_sub(rjd2, m_real_local_jd(dat))); }
0
462,545
void controller::import_read_information(const std::string& readinfofile) { std::vector<std::string> guids; std::ifstream f(readinfofile.c_str()); std::string line; getline(f,line); if (!f.is_open()) { return; } while (f.is_open() && !f.eof()) { guids.push_back(line); getline(f, line); } rsscache->mark_items_read_by_guid(guids); }
0
387,763
void InstanceKlass::mark_newly_obsolete_methods(Array<Method*>* old_methods, int emcp_method_count) { int obsolete_method_count = old_methods->length() - emcp_method_count; if (emcp_method_count != 0 && obsolete_method_count != 0 && _previous_versions != NULL) { // We have a mix of obsolete and EMCP methods so we have to // clear out any matching EMCP method entries the hard way. int local_count = 0; for (int i = 0; i < old_methods->length(); i++) { Method* old_method = old_methods->at(i); if (old_method->is_obsolete()) { // only obsolete methods are interesting Symbol* m_name = old_method->name(); Symbol* m_signature = old_method->signature(); // previous versions are linked together through the InstanceKlass int j = 0; for (InstanceKlass* prev_version = _previous_versions; prev_version != NULL; prev_version = prev_version->previous_versions(), j++) { Array<Method*>* method_refs = prev_version->methods(); for (int k = 0; k < method_refs->length(); k++) { Method* method = method_refs->at(k); if (!method->is_obsolete() && method->name() == m_name && method->signature() == m_signature) { // The current RedefineClasses() call has made all EMCP // versions of this method obsolete so mark it as obsolete log_trace(redefine, class, iklass, add) ("%s(%s): flush obsolete method @%d in version @%d", m_name->as_C_string(), m_signature->as_C_string(), k, j); method->set_is_obsolete(); break; } } // The previous loop may not find a matching EMCP method, but // that doesn't mean that we can optimize and not go any // further back in the PreviousVersion generations. The EMCP // method for this generation could have already been made obsolete, // but there still may be an older EMCP method that has not // been made obsolete. } if (++local_count >= obsolete_method_count) { // no more obsolete methods so bail out now break; } } } } }
0
359,581
peer_default_originate_set_vty (struct vty *vty, const char *peer_str, afi_t afi, safi_t safi, const char *rmap, int set) { int ret; struct peer *peer; peer = peer_and_group_lookup_vty (vty, peer_str); if (! peer) return CMD_WARNING; if (set) ret = peer_default_originate_set (peer, afi, safi, rmap); else ret = peer_default_originate_unset (peer, afi, safi); return bgp_vty_return (vty, ret); }
0
242,571
if (datasize > SumOfBytesHashed) { hashbase = data + SumOfBytesHashed; hashsize = datasize - SumOfBytesHashed; check_size(data, datasize, hashbase, hashsize); if (!(Sha256Update(sha256ctx, hashbase, hashsize)) || !(Sha1Update(sha1ctx, hashbase, hashsize))) { perror(L"Unable to generate hash\n"); efi_status = EFI_OUT_OF_RESOURCES; goto done; } SumOfBytesHashed += hashsize; }
0
310,273
dirserv_set_cached_consensus_networkstatus(const char *networkstatus, const char *flavor_name, const digests_t *digests, time_t published) { cached_dir_t *new_networkstatus; cached_dir_t *old_networkstatus; if (!cached_consensuses) cached_consensuses = strmap_new(); new_networkstatus = new_cached_dir(tor_strdup(networkstatus), published); memcpy(&new_networkstatus->digests, digests, sizeof(digests_t)); old_networkstatus = strmap_set(cached_consensuses, flavor_name, new_networkstatus); if (old_networkstatus) cached_dir_decref(old_networkstatus); }
0
508,359
TABLE *open_ltable(THD *thd, TABLE_LIST *table_list, thr_lock_type lock_type, uint lock_flags) { TABLE *table; Open_table_context ot_ctx(thd, lock_flags); bool error; DBUG_ENTER("open_ltable"); /* Ignore temporary tables as they have already been opened. */ if (table_list->table) DBUG_RETURN(table_list->table); /* should not be used in a prelocked_mode context, see NOTE above */ DBUG_ASSERT(thd->locked_tables_mode < LTM_PRELOCKED); THD_STAGE_INFO(thd, stage_opening_tables); thd->current_tablenr= 0; /* open_ltable can be used only for BASIC TABLEs */ table_list->required_type= FRMTYPE_TABLE; /* This function can't properly handle requests for such metadata locks. */ DBUG_ASSERT(table_list->mdl_request.type < MDL_SHARED_UPGRADABLE); while ((error= open_table(thd, table_list, &ot_ctx)) && ot_ctx.can_recover_from_failed_open()) { /* Even though we have failed to open table we still need to call release_transactional_locks() to release metadata locks which might have been acquired successfully. */ thd->mdl_context.rollback_to_savepoint(ot_ctx.start_of_statement_svp()); table_list->mdl_request.ticket= 0; if (ot_ctx.recover_from_failed_open()) break; } if (!error) { /* We can't have a view or some special "open_strategy" in this function so there should be a TABLE instance. */ DBUG_ASSERT(table_list->table); table= table_list->table; if (table->file->ht->db_type == DB_TYPE_MRG_MYISAM) { /* A MERGE table must not come here. */ /* purecov: begin tested */ my_error(ER_WRONG_OBJECT, MYF(0), table->s->db.str, table->s->table_name.str, "BASE TABLE"); table= 0; goto end; /* purecov: end */ } table_list->lock_type= lock_type; table->grant= table_list->grant; if (thd->locked_tables_mode) { if (check_lock_and_start_stmt(thd, thd->lex, table_list)) table= 0; } else { DBUG_ASSERT(thd->lock == 0); // You must lock everything at once if ((table->reginfo.lock_type= lock_type) != TL_UNLOCK) if (! (thd->lock= mysql_lock_tables(thd, &table_list->table, 1, lock_flags))) { table= 0; } } } else table= 0; end: if (table == NULL) { if (!thd->in_sub_stmt) trans_rollback_stmt(thd); close_thread_tables(thd); } THD_STAGE_INFO(thd, stage_after_opening_tables); thd_proc_info(thd, 0); DBUG_RETURN(table); }
0
256,168
inline DSizes dsizes_10() { return DSizes(1, 0); }
0
282,868
static int rsi_load_9116_bootup_params(struct rsi_common *common) { struct sk_buff *skb; struct rsi_boot_params_9116 *boot_params; rsi_dbg(MGMT_TX_ZONE, "%s: Sending boot params frame\n", __func__); skb = dev_alloc_skb(sizeof(struct rsi_boot_params_9116)); if (!skb) return -ENOMEM; memset(skb->data, 0, sizeof(struct rsi_boot_params)); boot_params = (struct rsi_boot_params_9116 *)skb->data; if (common->channel_width == BW_40MHZ) { memcpy(&boot_params->bootup_params, &boot_params_9116_40, sizeof(struct bootup_params_9116)); rsi_dbg(MGMT_TX_ZONE, "%s: Packet 40MHZ <=== %d\n", __func__, UMAC_CLK_40BW); boot_params->umac_clk = cpu_to_le16(UMAC_CLK_40BW); } else { memcpy(&boot_params->bootup_params, &boot_params_9116_20, sizeof(struct bootup_params_9116)); if (boot_params_20.valid != cpu_to_le32(VALID_20)) { boot_params->umac_clk = cpu_to_le16(UMAC_CLK_20BW); rsi_dbg(MGMT_TX_ZONE, "%s: Packet 20MHZ <=== %d\n", __func__, UMAC_CLK_20BW); } else { boot_params->umac_clk = cpu_to_le16(UMAC_CLK_40MHZ); rsi_dbg(MGMT_TX_ZONE, "%s: Packet 20MHZ <=== %d\n", __func__, UMAC_CLK_40MHZ); } } rsi_set_len_qno(&boot_params->desc_dword0.len_qno, sizeof(struct bootup_params_9116), RSI_WIFI_MGMT_Q); boot_params->desc_dword0.frame_type = BOOTUP_PARAMS_REQUEST; skb_put(skb, sizeof(struct rsi_boot_params_9116)); return rsi_send_internal_mgmt_frame(common, skb); }
0
197,719
void Compute(OpKernelContext* context) override { // Read ragged_splits inputs. OpInputList ragged_nested_splits_in; OP_REQUIRES_OK(context, context->input_list("rt_nested_splits", &ragged_nested_splits_in)); const int ragged_nested_splits_len = ragged_nested_splits_in.size(); RaggedTensorVariant batched_ragged_input; // Read ragged_values input. batched_ragged_input.set_values(context->input(ragged_nested_splits_len)); batched_ragged_input.mutable_nested_splits()->reserve( ragged_nested_splits_len); for (int i = 0; i < ragged_nested_splits_len; i++) { batched_ragged_input.append_splits(ragged_nested_splits_in[i]); } if (!batched_input_) { // Encode as a Scalar Variant Tensor. Tensor* encoded_scalar; OP_REQUIRES_OK(context, context->allocate_output(0, TensorShape({}), &encoded_scalar)); encoded_scalar->scalar<Variant>()() = std::move(batched_ragged_input); return; } // Unbatch the Ragged Tensor and encode the components. std::vector<RaggedTensorVariant> unbatched_ragged_input; auto batched_splits_top_vec = batched_ragged_input.splits(0).vec<SPLIT_TYPE>(); int num_components = batched_splits_top_vec.size() - 1; OP_REQUIRES(context, num_components >= 0, errors::Internal("Invalid split argument.")); OP_REQUIRES_OK(context, UnbatchRaggedZerothDim<VALUE_TYPE, SPLIT_TYPE>( batched_ragged_input, &unbatched_ragged_input)); // Bundle the encoded scalar Variant Tensors into a rank-1 Variant Tensor. Tensor* encoded_vector; int output_size = unbatched_ragged_input.size(); OP_REQUIRES_OK(context, context->allocate_output(0, TensorShape({output_size}), &encoded_vector)); auto encoded_vector_t = encoded_vector->vec<Variant>(); for (int i = 0; i < output_size; i++) { encoded_vector_t(i) = unbatched_ragged_input[i]; } }
1
328,983
R_API void r_bin_java_print_rtv_annotations_attr_summary(RBinJavaAttrInfo *attr) { if (attr && attr->type == R_BIN_JAVA_ATTR_TYPE_RUNTIME_VISIBLE_ANNOTATION_ATTR) { printf ("Runtime Visible Annotations Attribute Information:\n"); printf (" Attribute Offset: 0x%08"PFMT64x "\n", attr->file_offset); printf (" Attribute Name Index: %d (%s)\n", attr->name_idx, attr->name); printf (" Attribute Length: %d\n", attr->length); r_bin_java_print_annotation_array_summary (&attr->info.annotation_array); } }
0
281,121
static void xfrm_dst_hash_transfer(struct net *net, struct hlist_head *list, struct hlist_head *ndsttable, unsigned int nhashmask, int dir) { struct hlist_node *tmp, *entry0 = NULL; struct xfrm_policy *pol; unsigned int h0 = 0; u8 dbits; u8 sbits; redo: hlist_for_each_entry_safe(pol, tmp, list, bydst) { unsigned int h; __get_hash_thresh(net, pol->family, dir, &dbits, &sbits); h = __addr_hash(&pol->selector.daddr, &pol->selector.saddr, pol->family, nhashmask, dbits, sbits); if (!entry0) { hlist_del_rcu(&pol->bydst); hlist_add_head_rcu(&pol->bydst, ndsttable + h); h0 = h; } else { if (h != h0) continue; hlist_del_rcu(&pol->bydst); hlist_add_behind_rcu(&pol->bydst, entry0); } entry0 = &pol->bydst; } if (!hlist_empty(list)) { entry0 = NULL; goto redo; } }
0
513,159
static char **mysql_sys_var_str(THD* thd, int offset) { return (char **) intern_sys_var_ptr(thd, offset, true); }
0
270,387
static bool ok_inflater_inflate_huffman_tree(ok_inflater *inflater, ok_inflater_huffman_tree *tree, ok_inflater_huffman_tree *code_length_huffman, int num_codes) { if (num_codes < 0 || num_codes >= MAX_NUM_CODES) { ok_inflater_error(inflater, "Invalid num_codes"); return false; } const uint16_t *tree_lookup_table = code_length_huffman->lookup_table; const unsigned int tree_bits = code_length_huffman->bits; // 0 - 15: Represent code lengths of 0 - 15 // 16: Copy the previous code length 3 - 6 times. // (2 bits of length) // 17: Repeat a code length of 0 for 3 - 10 times. // (3 bits of length) // 18: Repeat a code length of 0 for 11 - 138 times // (7 bits of length) while (inflater->state_count < num_codes) { if (inflater->huffman_code < 0) { inflater->huffman_code = ok_inflater_decode_literal(inflater, tree_lookup_table, tree_bits); if (inflater->huffman_code < 0) { return false; } } if (inflater->huffman_code <= 15) { inflater->tree_codes[inflater->state_count++] = (uint8_t)inflater->huffman_code; } else { int value = 0; int len; unsigned int len_bits; switch (inflater->huffman_code) { case 16: len = 3; len_bits = 2; if (inflater->state_count == 0) { ok_inflater_error(inflater, "Invalid previous code"); return false; } value = inflater->tree_codes[inflater->state_count - 1]; break; case 17: len = 3; len_bits = 3; break; case 18: len = 11; len_bits = 7; break; default: ok_inflater_error(inflater, "Invalid huffman code"); return false; } if (!ok_inflater_load_bits(inflater, len_bits)) { return false; } len += ok_inflater_read_bits(inflater, len_bits); if (len > num_codes - inflater->state_count) { ok_inflater_error(inflater, "Invalid length"); return false; } memset(inflater->tree_codes + inflater->state_count, value, (size_t)len); inflater->state_count += len; } inflater->huffman_code = -1; } ok_inflater_make_huffman_tree_from_array(tree, inflater->tree_codes, num_codes); return true; }
0
220,906
void DependencyOptimizer::GroupCrossDeviceControlEdges(bool host_granularity) { VLOG(1) << "DependencyOptimizer::GroupCrossDeviceControlEdges host_granularity=" << host_granularity; const int num_nodes = optimized_graph_->node_size(); for (int i = 0; i < num_nodes; ++i) { NodeDef* node = optimized_graph_->mutable_node(i); if (node->device().empty()) continue; string rest, node_device = node->device(); if (host_granularity) { DeviceNameUtils::SplitDeviceName(node->device(), &node_device, &rest); } // Creates new noop nodes for devices on which multiple control inputs are // located. // Map keyed by device name to the newly introduced Noop node for that // device. A nullptr value means that we have only seen a single node on // that device. std::map<string, NodeDef*> noops; int num_noops = 0; for (int j = 0; j < node->input_size(); ++j) { if (IsControlInput(node->input(j))) { const NodeDef* input = node_map_->GetNode(node->input(j)); if (input == nullptr || input->device().empty()) continue; string input_device = input->device(); if (host_granularity) { DeviceNameUtils::SplitDeviceName(input->device(), &input_device, &rest); } if (input_device != node_device) { VLOG(2) << "Cross-device " << node->name() << " " << input->device() << " -> " << node->device(); auto emplace_result = noops.emplace(input_device, nullptr); if (!emplace_result.second && emplace_result.first->second == nullptr) { VLOG(2) << "Duplicate input device from " << node->name(); // This is the second cross-device control input from the same // device. Creates an intermediate noop node on that device. string group_name; NodeDef* noop; // Creates a fresh node name; there may be conflicting names from // a previous iteration of the optimizer. do { group_name = AddPrefixToNodeName( node->name(), strings::StrCat("GroupCrossDeviceControlEdges_", num_noops)); noop = node_map_->GetNode(group_name); ++num_noops; } while (noop != nullptr); noop = optimized_graph_->add_node(); noop->set_name(group_name); noop->set_device(input->device()); noop->set_op("NoOp"); node_map_->AddNode(noop->name(), noop); emplace_result.first->second = noop; VLOG(1) << "GroupCrossDeviceControlEdges: Added " << SummarizeNodeDef(*noop); } } } } // Reroute existing control edges to go via the newly introduced NoOp nodes. int pos = 0; while (pos < node->input_size()) { const string& input_name = node->input(pos); if (IsControlInput(input_name)) { NodeDef* input = node_map_->GetNode(input_name); if (input == nullptr) { ++pos; } else { string input_device = input->device(); if (host_granularity) { DeviceNameUtils::SplitDeviceName(input->device(), &input_device, &rest); } auto it = noops.find(input_device); if (it == noops.end() || it->second == nullptr) { ++pos; } else { VLOG(2) << "Rewriting input from " << input_name; node->mutable_input()->SwapElements(pos, node->input_size() - 1); node->mutable_input()->RemoveLast(); it->second->add_input(AsControlDependency(*input)); node_map_->UpdateOutput(input_name, node->name(), it->second->name()); } } } else { ++pos; } } for (const auto& entry : noops) { if (entry.second) { node->add_input(AsControlDependency(*entry.second)); node_map_->AddOutput(entry.second->name(), node->name()); } } } }
0
413,688
static void loganal(ut64 from, ut64 to, int depth) { r_cons_clear_line (1); eprintf ("0x%08"PFMT64x" > 0x%08"PFMT64x" %d\r", from, to, depth); }
0
220,228
const VersionDef& Graph::versions() const { return *versions_; }
0
307,856
ciInstance* ciEnv::the_null_string() { if (_the_null_string == NULL) { VM_ENTRY_MARK; _the_null_string = get_object(Universe::the_null_string())->as_instance(); } return _the_null_string; }
0
437,710
static inline void control_tx_irq_watermark(struct cx23885_dev *dev, enum tx_fifo_watermark level) { cx23888_ir_and_or4(dev, CX23888_IR_CNTRL_REG, ~CNTRL_TIC, level); }
0
225,975
GF_Err metx_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem) { GF_MetaDataSampleEntryBox *ptr = (GF_MetaDataSampleEntryBox *)s; switch (a->type) { case GF_ISOM_BOX_TYPE_TXTC: //we allow the config box on metx BOX_FIELD_ASSIGN(config, GF_TextConfigBox) break; } return GF_OK;
0
427,169
static int explist (LexState *ls, expdesc *v) { /* explist -> expr { ',' expr } */ int n = 1; /* at least one expression */ expr(ls, v); while (testnext(ls, ',')) { luaK_exp2nextreg(ls->fs, v); expr(ls, v); n++; } return n; }
0
430,454
static inline void add_nested_action_end(struct sw_flow_actions *sfa, int st_offset) { struct nlattr *a = (struct nlattr *) ((unsigned char *)sfa->actions + st_offset); a->nla_len = sfa->actions_len - st_offset; }
0
353,204
SplashAxialPattern::~SplashAxialPattern() { }
0
310,134
trace_normalized_cost(NCURSES_SP_DCLx const char *capname, const char *cap, int affcnt) { int result = normalized_cost(NCURSES_SP_ARGx cap, affcnt); TR(TRACE_CHARPUT | TRACE_MOVE, ("NormalizedCost %s %d %s", capname, result, _nc_visbuf(cap))); return result; }
0
246,730
static void PrintHelp(char *arg_name, Bool search_desc, Bool no_match) { GF_FilterSession *fs; Bool res; fs = gf_fs_new_defaults(0); if (arg_name[0]=='-') arg_name++; if (search_desc) { char *_arg_name = gf_strdup(arg_name); strlwr(_arg_name); GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("Possible options mentionning `%s`:\n", arg_name)); PrintHelpArg(_arg_name, SEARCH_DESC, fs); gf_free(_arg_name); } else { res = no_match ? GF_FALSE : PrintHelpArg(arg_name, SEARCH_ARG_EXACT, fs); if (!res) { GF_LOG(GF_LOG_ERROR, GF_LOG_APP, ("Option -%s unknown, please check usage.\n", arg_name)); GF_LOG(GF_LOG_INFO, GF_LOG_APP, ("Possible options are:\n")); PrintHelpArg(arg_name, SEARCH_ARG_CLOSE, fs); } } if (fs) gf_fs_del(fs); }
0
484,764
static int xennet_init_queue(struct netfront_queue *queue) { unsigned short i; int err = 0; char *devid; spin_lock_init(&queue->tx_lock); spin_lock_init(&queue->rx_lock); spin_lock_init(&queue->rx_cons_lock); timer_setup(&queue->rx_refill_timer, rx_refill_timeout, 0); devid = strrchr(queue->info->xbdev->nodename, '/') + 1; snprintf(queue->name, sizeof(queue->name), "vif%s-q%u", devid, queue->id); /* Initialise tx_skb_freelist as a free chain containing every entry. */ queue->tx_skb_freelist = 0; queue->tx_pend_queue = TX_LINK_NONE; for (i = 0; i < NET_TX_RING_SIZE; i++) { queue->tx_link[i] = i + 1; queue->grant_tx_ref[i] = INVALID_GRANT_REF; queue->grant_tx_page[i] = NULL; } queue->tx_link[NET_TX_RING_SIZE - 1] = TX_LINK_NONE; /* Clear out rx_skbs */ for (i = 0; i < NET_RX_RING_SIZE; i++) { queue->rx_skbs[i] = NULL; queue->grant_rx_ref[i] = INVALID_GRANT_REF; } /* A grant for every tx ring slot */ if (gnttab_alloc_grant_references(NET_TX_RING_SIZE, &queue->gref_tx_head) < 0) { pr_alert("can't alloc tx grant refs\n"); err = -ENOMEM; goto exit; } /* A grant for every rx ring slot */ if (gnttab_alloc_grant_references(NET_RX_RING_SIZE, &queue->gref_rx_head) < 0) { pr_alert("can't alloc rx grant refs\n"); err = -ENOMEM; goto exit_free_tx; } return 0; exit_free_tx: gnttab_free_grant_references(queue->gref_tx_head); exit: return err; }
0
484,796
static void add_id_to_list(unsigned *head, unsigned short *list, unsigned short id) { list[id] = *head; *head = id; }
0
221,499
flatpak_run_add_ssh_args (FlatpakBwrap *bwrap) { static const char sandbox_auth_socket[] = "/run/flatpak/ssh-auth"; const char * auth_socket; auth_socket = g_getenv ("SSH_AUTH_SOCK"); if (!auth_socket) return; /* ssh agent not present */ if (!g_file_test (auth_socket, G_FILE_TEST_EXISTS)) { /* Let's clean it up, so that the application will not try to connect */ flatpak_bwrap_unset_env (bwrap, "SSH_AUTH_SOCK"); return; } flatpak_bwrap_add_args (bwrap, "--ro-bind", auth_socket, sandbox_auth_socket, NULL); flatpak_bwrap_set_env (bwrap, "SSH_AUTH_SOCK", sandbox_auth_socket, TRUE); }
0
366,200
static void __put_mountpoint(struct mountpoint *mp, struct list_head *list) { if (!--mp->m_count) { struct dentry *dentry = mp->m_dentry; BUG_ON(!hlist_empty(&mp->m_list)); spin_lock(&dentry->d_lock); dentry->d_flags &= ~DCACHE_MOUNTED; spin_unlock(&dentry->d_lock); dput_to_list(dentry, list); hlist_del(&mp->m_hash); kfree(mp); } }
0
484,731
void mobi_buffer_setpos(MOBIBuffer *buf, const size_t pos) { if (pos <= buf->maxlen) { buf->offset = pos; return; } buf->error = MOBI_BUFFER_END; debug_print("%s", "End of buffer\n"); }
0
198,545
static int do_i2c_md(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { uint chip; uint addr, length; int alen; int j, nbytes, linebytes; int ret; #if CONFIG_IS_ENABLED(DM_I2C) struct udevice *dev; #endif /* We use the last specified parameters, unless new ones are * entered. */ chip = i2c_dp_last_chip; addr = i2c_dp_last_addr; alen = i2c_dp_last_alen; length = i2c_dp_last_length; if (argc < 3) return CMD_RET_USAGE; if ((flag & CMD_FLAG_REPEAT) == 0) { /* * New command specified. */ /* * I2C chip address */ chip = hextoul(argv[1], NULL); /* * I2C data address within the chip. This can be 1 or * 2 bytes long. Some day it might be 3 bytes long :-). */ addr = hextoul(argv[2], NULL); alen = get_alen(argv[2], DEFAULT_ADDR_LEN); if (alen > 3) return CMD_RET_USAGE; /* * If another parameter, it is the length to display. * Length is the number of objects, not number of bytes. */ if (argc > 3) length = hextoul(argv[3], NULL); } #if CONFIG_IS_ENABLED(DM_I2C) ret = i2c_get_cur_bus_chip(chip, &dev); if (!ret && alen != -1) ret = i2c_set_chip_offset_len(dev, alen); if (ret) return i2c_report_err(ret, I2C_ERR_READ); #endif /* * Print the lines. * * We buffer all read data, so we can make sure data is read only * once. */ nbytes = length; do { unsigned char linebuf[DISP_LINE_LEN]; unsigned char *cp; linebytes = (nbytes > DISP_LINE_LEN) ? DISP_LINE_LEN : nbytes; #if CONFIG_IS_ENABLED(DM_I2C) ret = dm_i2c_read(dev, addr, linebuf, linebytes); #else ret = i2c_read(chip, addr, alen, linebuf, linebytes); #endif if (ret) return i2c_report_err(ret, I2C_ERR_READ); else { printf("%04x:", addr); cp = linebuf; for (j=0; j<linebytes; j++) { printf(" %02x", *cp++); addr++; } puts (" "); cp = linebuf; for (j=0; j<linebytes; j++) { if ((*cp < 0x20) || (*cp > 0x7e)) puts ("."); else printf("%c", *cp); cp++; } putc ('\n'); } nbytes -= linebytes; } while (nbytes > 0); i2c_dp_last_chip = chip; i2c_dp_last_addr = addr; i2c_dp_last_alen = alen; i2c_dp_last_length = length; return 0; }
1
500,672
int sftp_async_read(sftp_file file, void *data, uint32_t size, uint32_t id){ sftp_session sftp = file->sftp; sftp_message msg = NULL; sftp_status_message status; ssh_string datastring; int err = SSH_OK; uint32_t len; sftp_enter_function(); if (file->eof) { sftp_leave_function(); return 0; } /* handle an existing request */ while (msg == NULL) { if (file->nonblocking){ if (ssh_channel_poll(sftp->channel, 0) == 0) { /* we cannot block */ return SSH_AGAIN; } } if (sftp_read_and_dispatch(sftp) < 0) { /* something nasty has happened */ sftp_leave_function(); return SSH_ERROR; } msg = sftp_dequeue(sftp,id); } switch (msg->packet_type) { case SSH_FXP_STATUS: status = parse_status_msg(msg); sftp_message_free(msg); if (status == NULL) { sftp_leave_function(); return -1; } sftp_set_error(sftp, status->status); if (status->status != SSH_FX_EOF) { ssh_set_error(sftp->session, SSH_REQUEST_DENIED, "SFTP server : %s", status->errormsg); sftp_leave_function(); err = SSH_ERROR; } else { file->eof = 1; } status_msg_free(status); sftp_leave_function(); return err; case SSH_FXP_DATA: datastring = buffer_get_ssh_string(msg->payload); sftp_message_free(msg); if (datastring == NULL) { ssh_set_error(sftp->session, SSH_FATAL, "Received invalid DATA packet from sftp server"); sftp_leave_function(); return SSH_ERROR; } if (ssh_string_len(datastring) > size) { ssh_set_error(sftp->session, SSH_FATAL, "Received a too big DATA packet from sftp server: " "%" PRIdS " and asked for %u", ssh_string_len(datastring), size); ssh_string_free(datastring); sftp_leave_function(); return SSH_ERROR; } len = ssh_string_len(datastring); /* Update the offset with the correct value */ file->offset = file->offset - (size - len); memcpy(data, ssh_string_data(datastring), len); ssh_string_free(datastring); sftp_leave_function(); return len; default: ssh_set_error(sftp->session,SSH_FATAL,"Received message %d during read!",msg->packet_type); sftp_message_free(msg); sftp_leave_function(); return SSH_ERROR; } sftp_leave_function(); return SSH_ERROR; }
0
219,899
Bool IsHintTrack(GF_TrackBox *trak) { if (trak->Media->handler->handlerType != GF_ISOM_MEDIA_HINT) return GF_FALSE; //QT doesn't specify any InfoHeader on HintTracks if (trak->Media->information->InfoHeader && (trak->Media->information->InfoHeader->type != GF_ISOM_BOX_TYPE_HMHD) && (trak->Media->information->InfoHeader->type != GF_ISOM_BOX_TYPE_NMHD) ) return GF_FALSE; return GF_TRUE; }
0
267,958
R_API ut64 r_bin_file_delete_all(RBin *bin) { if (bin) { ut64 counter = r_list_length (bin->binfiles); r_list_purge (bin->binfiles); bin->cur = NULL; return counter; } return 0; }
0
512,513
Item *get_copy(THD *thd) { return get_item_copy<Item_name_const>(thd, this); }
0
365,616
_asn1_remove_node (asn1_node node, unsigned int flags) { if (node == NULL) return; if (node->value != NULL) { if (flags & ASN1_DELETE_FLAG_ZEROIZE) { safe_memset(node->value, 0, node->value_len); } if (node->value != node->small_value) free (node->value); } free (node); }
0
205,870
static RList *symbols(RBinFile *bf) { RList *res = r_list_newf ((RListFree)r_bin_symbol_free); r_return_val_if_fail (res && bf->o && bf->o->bin_obj, res); RCoreSymCacheElement *element = bf->o->bin_obj; size_t i; HtUU *hash = ht_uu_new0 (); if (!hash) { return res; } bool found = false; for (i = 0; i < element->hdr->n_lined_symbols; i++) { RCoreSymCacheElementSymbol *sym = (RCoreSymCacheElementSymbol *)&element->lined_symbols[i]; ht_uu_find (hash, sym->paddr, &found); if (found) { continue; } RBinSymbol *s = bin_symbol_from_symbol (element, sym); if (s) { r_list_append (res, s); ht_uu_insert (hash, sym->paddr, 1); } } if (element->symbols) { for (i = 0; i < element->hdr->n_symbols; i++) { RCoreSymCacheElementSymbol *sym = &element->symbols[i]; ht_uu_find (hash, sym->paddr, &found); if (found) { continue; } RBinSymbol *s = bin_symbol_from_symbol (element, sym); if (s) { r_list_append (res, s); } } } ht_uu_free (hash); return res; }
1
446,111
static int atusb_get_and_show_revision(struct atusb *atusb) { struct usb_device *usb_dev = atusb->usb_dev; char *hw_name; unsigned char *buffer; int ret; buffer = kmalloc(3, GFP_KERNEL); if (!buffer) return -ENOMEM; /* Get a couple of the ATMega Firmware values */ ret = atusb_control_msg(atusb, usb_rcvctrlpipe(usb_dev, 0), ATUSB_ID, ATUSB_REQ_FROM_DEV, 0, 0, buffer, 3, 1000); if (ret >= 0) { atusb->fw_ver_maj = buffer[0]; atusb->fw_ver_min = buffer[1]; atusb->fw_hw_type = buffer[2]; switch (atusb->fw_hw_type) { case ATUSB_HW_TYPE_100813: case ATUSB_HW_TYPE_101216: case ATUSB_HW_TYPE_110131: hw_name = "ATUSB"; atusb->data = &atusb_chip_data; break; case ATUSB_HW_TYPE_RZUSB: hw_name = "RZUSB"; atusb->data = &atusb_chip_data; break; case ATUSB_HW_TYPE_HULUSB: hw_name = "HULUSB"; atusb->data = &hulusb_chip_data; break; default: hw_name = "UNKNOWN"; atusb->err = -ENOTSUPP; ret = -ENOTSUPP; break; } dev_info(&usb_dev->dev, "Firmware: major: %u, minor: %u, hardware type: %s (%d)\n", atusb->fw_ver_maj, atusb->fw_ver_min, hw_name, atusb->fw_hw_type); } if (atusb->fw_ver_maj == 0 && atusb->fw_ver_min < 2) { dev_info(&usb_dev->dev, "Firmware version (%u.%u) predates our first public release.", atusb->fw_ver_maj, atusb->fw_ver_min); dev_info(&usb_dev->dev, "Please update to version 0.2 or newer"); } kfree(buffer); return ret; }
0
356,705
void Statement::Finalize_(Baton* b) { std::unique_ptr<Baton> baton(b); Napi::Env env = baton->stmt->Env(); Napi::HandleScope scope(env); baton->stmt->Finalize_(); // Fire callback in case there was one. Napi::Function cb = baton->callback.Value(); if (!cb.IsUndefined() && cb.IsFunction()) { TRY_CATCH_CALL(baton->stmt->Value(), cb, 0, NULL); } }
0