idx
int64
func
string
target
int64
226,240
GF_Err stsg_box_size(GF_Box *s) { GF_SubTrackSampleGroupBox *ptr = (GF_SubTrackSampleGroupBox *)s; ptr->size += 6 + 4 * ptr->nb_groups; return GF_OK;
0
437,006
static void mcba_usb_write_bulk_callback(struct urb *urb) { struct mcba_usb_ctx *ctx = urb->context; struct net_device *netdev; WARN_ON(!ctx); netdev = ctx->priv->netdev; /* free up our allocated buffer */ usb_free_coherent(urb->dev, urb->transfer_buffer_length, urb->transfer_buffer, urb->transfer_dma); if (ctx->can) { if (!netif_device_present(netdev)) return; netdev->stats.tx_packets++; netdev->stats.tx_bytes += can_get_echo_skb(netdev, ctx->ndx, NULL); can_led_event(netdev, CAN_LED_EVENT_TX); } if (urb->status) netdev_info(netdev, "Tx URB aborted (%d)\n", urb->status); /* Release the context */ mcba_usb_free_ctx(ctx); }
0
285,157
RList *r_bin_ne_get_entrypoints(r_bin_ne_obj_t *bin) { if (!bin->entry_table) { return NULL; } RList *entries = r_list_newf (free); if (!entries) { return NULL; } RList *segments = r_bin_ne_get_segments (bin); if (!segments) { r_list_free (entries); return NULL; } if (bin->ne_header->csEntryPoint) { RBinAddr *entry = R_NEW0 (RBinAddr); if (!entry) { r_list_free (entries); return NULL; } entry->bits = 16; ut32 entry_cs = bin->ne_header->csEntryPoint; RBinSection *s = r_list_get_n (segments, entry_cs - 1); entry->paddr = bin->ne_header->ipEntryPoint + (s? s->paddr: 0); r_list_append (entries, entry); } int off = 0; size_t tableat = bin->header_offset + bin->ne_header->EntryTableOffset; while (off < bin->ne_header->EntryTableLength) { if (tableat + off >= r_buf_size (bin->buf)) { break; } ut8 bundle_length = *(ut8 *)(bin->entry_table + off); if (!bundle_length) { break; } off++; ut8 bundle_type = *(ut8 *)(bin->entry_table + off); off++; int i; for (i = 0; i < bundle_length; i++) { if (tableat + off + 4 >= r_buf_size (bin->buf)) { break; } RBinAddr *entry = R_NEW0 (RBinAddr); if (!entry) { r_list_free (entries); return NULL; } off++; if (!bundle_type) { // Skip off--; free (entry); break; } else if (bundle_type == 0xff) { // moveable off += 2; ut8 segnum = *(bin->entry_table + off); off++; if (off > bin->ne_header->EntryTableLength) { break; } ut16 segoff = r_read_le16 (bin->entry_table + off); if (segnum > 0 && segnum < bin->ne_header->SegCount) { entry->paddr = (ut64)bin->segment_entries[segnum - 1].offset * bin->alignment + segoff; } } else { // Fixed if (off + 2 >= bin->ne_header->EntryTableLength) { break; } ut16 delta = r_read_le16 (bin->entry_table + off); if (bundle_type < bin->ne_header->SegCount) { entry->paddr = (ut64)bin->segment_entries[bundle_type - 1].offset * bin->alignment + delta; } } off += 2; r_list_append (entries, entry); } } r_list_free (segments); bin->entries = entries; return entries; }
0
261,956
njs_string_prototype_includes(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, njs_index_t unused) { int64_t index, length, search_length; njs_int_t ret; njs_value_t *value; const u_char *p, *end; const njs_value_t *retval; njs_string_prop_t string, search; ret = njs_string_object_validate(vm, njs_argument(args, 0)); if (njs_slow_path(ret != NJS_OK)) { return ret; } retval = &njs_value_true; if (nargs > 1) { value = njs_argument(args, 1); if (njs_slow_path(!njs_is_string(value))) { ret = njs_value_to_string(vm, value, value); if (njs_slow_path(ret != NJS_OK)) { return ret; } } search_length = njs_string_prop(&search, value); if (nargs > 2) { value = njs_argument(args, 2); if (njs_slow_path(!njs_is_number(value))) { ret = njs_value_to_integer(vm, value, &index); if (njs_slow_path(ret != NJS_OK)) { return ret; } } else { index = njs_number_to_integer(njs_number(value)); } if (index < 0) { index = 0; } } else { index = 0; } if (search_length == 0) { goto done; } length = njs_string_prop(&string, &args[0]); if (length - index >= search_length) { end = string.start + string.size; if (string.size == (size_t) length) { /* Byte or ASCII string. */ p = string.start + index; } else { /* UTF-8 string. */ p = njs_string_offset(string.start, end, index); } end -= search.size - 1; while (p < end) { if (memcmp(p, search.start, search.size) == 0) { goto done; } p++; } } } retval = &njs_value_false; done: vm->retval = *retval; return NJS_OK; }
0
418,791
mouse_comp_pos( win_T *win, int *rowp, int *colp, linenr_T *lnump, int *plines_cache) { int col = *colp; int row = *rowp; linenr_T lnum; int retval = FALSE; int off; int count; #ifdef FEAT_RIGHTLEFT if (win->w_p_rl) col = win->w_width - 1 - col; #endif lnum = win->w_topline; while (row > 0) { int cache_idx = lnum - win->w_topline; // Only "Rows" lines are cached, with folding we'll run out of entries // and use the slow way. if (plines_cache != NULL && cache_idx < Rows && plines_cache[cache_idx] > 0) count = plines_cache[cache_idx]; else { #ifdef FEAT_DIFF // Don't include filler lines in "count" if (win->w_p_diff # ifdef FEAT_FOLDING && !hasFoldingWin(win, lnum, NULL, NULL, TRUE, NULL) # endif ) { if (lnum == win->w_topline) row -= win->w_topfill; else row -= diff_check_fill(win, lnum); count = plines_win_nofill(win, lnum, TRUE); } else #endif count = plines_win(win, lnum, TRUE); if (plines_cache != NULL && cache_idx < Rows) plines_cache[cache_idx] = count; } if (count > row) break; // Position is in this buffer line. #ifdef FEAT_FOLDING (void)hasFoldingWin(win, lnum, NULL, &lnum, TRUE, NULL); #endif if (lnum == win->w_buffer->b_ml.ml_line_count) { retval = TRUE; break; // past end of file } row -= count; ++lnum; } if (!retval) { // Compute the column without wrapping. off = win_col_off(win) - win_col_off2(win); if (col < off) col = off; col += row * (win->w_width - off); // add skip column (for long wrapping line) col += win->w_skipcol; } if (!win->w_p_wrap) col += win->w_leftcol; // skip line number and fold column in front of the line col -= win_col_off(win); if (col <= 0) { #ifdef FEAT_NETBEANS_INTG // if mouse is clicked on the gutter, then inform the netbeans server if (*colp < win_col_off(win)) netbeans_gutter_click(lnum); #endif col = 0; } *colp = col; *rowp = row; *lnump = lnum; return retval; }
0
384,783
vim_islower(int c) { if (c <= '@') return FALSE; if (c >= 0x80) { if (enc_utf8) return utf_islower(c); if (c >= 0x100) { #ifdef HAVE_ISWLOWER if (has_mbyte) return iswlower(c); #endif // islower() can't handle these chars and may crash return FALSE; } if (enc_latin1like) return (latin1flags[c] & LATIN1LOWER) == LATIN1LOWER; } return islower(c); }
0
380,956
edit( int cmdchar, int startln, // if set, insert at start of line long count) { int c = 0; char_u *ptr; int lastc = 0; int mincol; static linenr_T o_lnum = 0; int i; int did_backspace = TRUE; // previous char was backspace int line_is_white = FALSE; // line is empty before insert linenr_T old_topline = 0; // topline before insertion #ifdef FEAT_DIFF int old_topfill = -1; #endif int inserted_space = FALSE; // just inserted a space int replaceState = MODE_REPLACE; int nomove = FALSE; // don't move cursor on return #ifdef FEAT_JOB_CHANNEL int cmdchar_todo = cmdchar; #endif #ifdef FEAT_CONCEAL int cursor_line_was_concealed; #endif // Remember whether editing was restarted after CTRL-O. did_restart_edit = restart_edit; // sleep before redrawing, needed for "CTRL-O :" that results in an // error message check_for_delay(TRUE); // set Insstart_orig to Insstart update_Insstart_orig = TRUE; #ifdef HAVE_SANDBOX // Don't allow inserting in the sandbox. if (sandbox != 0) { emsg(_(e_not_allowed_in_sandbox)); return FALSE; } #endif // Don't allow changes in the buffer while editing the cmdline. The // caller of getcmdline() may get confused. // Don't allow recursive insert mode when busy with completion. if (textlock != 0 || ins_compl_active() || compl_busy || pum_visible()) { emsg(_(e_not_allowed_to_change_text_or_change_window)); return FALSE; } ins_compl_clear(); // clear stuff for CTRL-X mode /* * Trigger InsertEnter autocommands. Do not do this for "r<CR>" or "grx". */ if (cmdchar != 'r' && cmdchar != 'v') { pos_T save_cursor = curwin->w_cursor; #ifdef FEAT_EVAL if (cmdchar == 'R') ptr = (char_u *)"r"; else if (cmdchar == 'V') ptr = (char_u *)"v"; else ptr = (char_u *)"i"; set_vim_var_string(VV_INSERTMODE, ptr, 1); set_vim_var_string(VV_CHAR, NULL, -1); // clear v:char #endif ins_apply_autocmds(EVENT_INSERTENTER); // Check for changed highlighting, e.g. for ModeMsg. if (need_highlight_changed) highlight_changed(); // Make sure the cursor didn't move. Do call check_cursor_col() in // case the text was modified. Since Insert mode was not started yet // a call to check_cursor_col() may move the cursor, especially with // the "A" command, thus set State to avoid that. Also check that the // line number is still valid (lines may have been deleted). // Do not restore if v:char was set to a non-empty string. if (!EQUAL_POS(curwin->w_cursor, save_cursor) #ifdef FEAT_EVAL && *get_vim_var_str(VV_CHAR) == NUL #endif && save_cursor.lnum <= curbuf->b_ml.ml_line_count) { int save_state = State; curwin->w_cursor = save_cursor; State = MODE_INSERT; check_cursor_col(); State = save_state; } } #ifdef FEAT_CONCEAL // Check if the cursor line was concealed before changing State. cursor_line_was_concealed = curwin->w_p_cole > 0 && conceal_cursor_line(curwin); #endif /* * When doing a paste with the middle mouse button, Insstart is set to * where the paste started. */ if (where_paste_started.lnum != 0) Insstart = where_paste_started; else { Insstart = curwin->w_cursor; if (startln) Insstart.col = 0; } Insstart_textlen = (colnr_T)linetabsize(ml_get_curline()); Insstart_blank_vcol = MAXCOL; if (!did_ai) ai_col = 0; if (cmdchar != NUL && restart_edit == 0) { ResetRedobuff(); AppendNumberToRedobuff(count); if (cmdchar == 'V' || cmdchar == 'v') { // "gR" or "gr" command AppendCharToRedobuff('g'); AppendCharToRedobuff((cmdchar == 'v') ? 'r' : 'R'); } else { if (cmdchar == K_PS) AppendCharToRedobuff('a'); else AppendCharToRedobuff(cmdchar); if (cmdchar == 'g') // "gI" command AppendCharToRedobuff('I'); else if (cmdchar == 'r') // "r<CR>" command count = 1; // insert only one <CR> } } if (cmdchar == 'R') { State = MODE_REPLACE; } else if (cmdchar == 'V' || cmdchar == 'v') { State = MODE_VREPLACE; replaceState = MODE_VREPLACE; orig_line_count = curbuf->b_ml.ml_line_count; vr_lines_changed = 1; } else State = MODE_INSERT; may_trigger_modechanged(); stop_insert_mode = FALSE; #ifdef FEAT_CONCEAL // Check if the cursor line needs redrawing after changing State. If // 'concealcursor' is "n" it needs to be redrawn without concealing. conceal_check_cursor_line(cursor_line_was_concealed); #endif // need to position cursor again when on a TAB if (gchar_cursor() == TAB) curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL); /* * Enable langmap or IME, indicated by 'iminsert'. * Note that IME may enabled/disabled without us noticing here, thus the * 'iminsert' value may not reflect what is actually used. It is updated * when hitting <Esc>. */ if (curbuf->b_p_iminsert == B_IMODE_LMAP) State |= MODE_LANGMAP; #ifdef HAVE_INPUT_METHOD im_set_active(curbuf->b_p_iminsert == B_IMODE_IM); #endif setmouse(); #ifdef FEAT_CMDL_INFO clear_showcmd(); #endif #ifdef FEAT_RIGHTLEFT // there is no reverse replace mode revins_on = (State == MODE_INSERT && p_ri); if (revins_on) undisplay_dollar(); revins_chars = 0; revins_legal = 0; revins_scol = -1; #endif if (!p_ek) { MAY_WANT_TO_LOG_THIS; // Disable bracketed paste mode, we won't recognize the escape // sequences. out_str(T_BD); // Disable modifyOtherKeys, keys with modifiers would cause exiting // Insert mode. out_str(T_CTE); } /* * Handle restarting Insert mode. * Don't do this for "CTRL-O ." (repeat an insert): In that case we get * here with something in the stuff buffer. */ if (restart_edit != 0 && stuff_empty()) { /* * After a paste we consider text typed to be part of the insert for * the pasted text. You can backspace over the pasted text too. */ if (where_paste_started.lnum) arrow_used = FALSE; else arrow_used = TRUE; restart_edit = 0; /* * If the cursor was after the end-of-line before the CTRL-O and it is * now at the end-of-line, put it after the end-of-line (this is not * correct in very rare cases). * Also do this if curswant is greater than the current virtual * column. Eg after "^O$" or "^O80|". */ validate_virtcol(); update_curswant(); if (((ins_at_eol && curwin->w_cursor.lnum == o_lnum) || curwin->w_curswant > curwin->w_virtcol) && *(ptr = ml_get_curline() + curwin->w_cursor.col) != NUL) { if (ptr[1] == NUL) ++curwin->w_cursor.col; else if (has_mbyte) { i = (*mb_ptr2len)(ptr); if (ptr[i] == NUL) curwin->w_cursor.col += i; } } ins_at_eol = FALSE; } else arrow_used = FALSE; // we are in insert mode now, don't need to start it anymore need_start_insertmode = FALSE; // Need to save the line for undo before inserting the first char. ins_need_undo = TRUE; where_paste_started.lnum = 0; can_cindent = TRUE; #ifdef FEAT_FOLDING // The cursor line is not in a closed fold, unless 'insertmode' is set or // restarting. if (!p_im && did_restart_edit == 0) foldOpenCursor(); #endif /* * If 'showmode' is set, show the current (insert/replace/..) mode. * A warning message for changing a readonly file is given here, before * actually changing anything. It's put after the mode, if any. */ i = 0; if (p_smd && msg_silent == 0) i = showmode(); if (!p_im && did_restart_edit == 0) change_warning(i == 0 ? 0 : i + 1); #ifdef CURSOR_SHAPE ui_cursor_shape(); // may show different cursor shape #endif #ifdef FEAT_DIGRAPHS do_digraph(-1); // clear digraphs #endif /* * Get the current length of the redo buffer, those characters have to be * skipped if we want to get to the inserted characters. */ ptr = get_inserted(); if (ptr == NULL) new_insert_skip = 0; else { new_insert_skip = (int)STRLEN(ptr); vim_free(ptr); } old_indent = 0; /* * Main loop in Insert mode: repeat until Insert mode is left. */ for (;;) { #ifdef FEAT_RIGHTLEFT if (!revins_legal) revins_scol = -1; // reset on illegal motions else revins_legal = 0; #endif if (arrow_used) // don't repeat insert when arrow key used count = 0; if (update_Insstart_orig) Insstart_orig = Insstart; if (stop_insert_mode && !ins_compl_active()) { // ":stopinsert" used or 'insertmode' reset count = 0; goto doESCkey; } // set curwin->w_curswant for next K_DOWN or K_UP if (!arrow_used) curwin->w_set_curswant = TRUE; // If there is no typeahead may check for timestamps (e.g., for when a // menu invoked a shell command). if (stuff_empty()) { did_check_timestamps = FALSE; if (need_check_timestamps) check_timestamps(FALSE); } /* * When emsg() was called msg_scroll will have been set. */ msg_scroll = FALSE; #ifdef FEAT_GUI // When 'mousefocus' is set a mouse movement may have taken us to // another window. "need_mouse_correct" may then be set because of an // autocommand. if (need_mouse_correct) gui_mouse_correct(); #endif #ifdef FEAT_FOLDING // Open fold at the cursor line, according to 'foldopen'. if (fdo_flags & FDO_INSERT) foldOpenCursor(); // Close folds where the cursor isn't, according to 'foldclose' if (!char_avail()) foldCheckClose(); #endif #ifdef FEAT_JOB_CHANNEL if (bt_prompt(curbuf)) { init_prompt(cmdchar_todo); cmdchar_todo = NUL; } #endif /* * If we inserted a character at the last position of the last line in * the window, scroll the window one line up. This avoids an extra * redraw. * This is detected when the cursor column is smaller after inserting * something. * Don't do this when the topline changed already, it has * already been adjusted (by insertchar() calling open_line())). */ if (curbuf->b_mod_set && curwin->w_p_wrap && !did_backspace && curwin->w_topline == old_topline #ifdef FEAT_DIFF && curwin->w_topfill == old_topfill #endif ) { mincol = curwin->w_wcol; validate_cursor_col(); if ( #ifdef FEAT_VARTABS curwin->w_wcol < mincol - tabstop_at( get_nolist_virtcol(), curbuf->b_p_ts, curbuf->b_p_vts_array) #else (int)curwin->w_wcol < mincol - curbuf->b_p_ts #endif && curwin->w_wrow == W_WINROW(curwin) + curwin->w_height - 1 - get_scrolloff_value() && (curwin->w_cursor.lnum != curwin->w_topline #ifdef FEAT_DIFF || curwin->w_topfill > 0 #endif )) { #ifdef FEAT_DIFF if (curwin->w_topfill > 0) --curwin->w_topfill; else #endif #ifdef FEAT_FOLDING if (hasFolding(curwin->w_topline, NULL, &old_topline)) set_topline(curwin, old_topline + 1); else #endif set_topline(curwin, curwin->w_topline + 1); } } // May need to adjust w_topline to show the cursor. update_topline(); did_backspace = FALSE; validate_cursor(); // may set must_redraw /* * Redraw the display when no characters are waiting. * Also shows mode, ruler and positions cursor. */ ins_redraw(TRUE); if (curwin->w_p_scb) do_check_scrollbind(TRUE); if (curwin->w_p_crb) do_check_cursorbind(); update_curswant(); old_topline = curwin->w_topline; #ifdef FEAT_DIFF old_topfill = curwin->w_topfill; #endif #ifdef USE_ON_FLY_SCROLL dont_scroll = FALSE; // allow scrolling here #endif /* * Get a character for Insert mode. Ignore K_IGNORE and K_NOP. */ if (c != K_CURSORHOLD) lastc = c; // remember the previous char for CTRL-D // After using CTRL-G U the next cursor key will not break undo. if (dont_sync_undo == MAYBE) dont_sync_undo = TRUE; else dont_sync_undo = FALSE; if (cmdchar == K_PS) // Got here from normal mode when bracketed paste started. c = K_PS; else do { c = safe_vgetc(); if (stop_insert_mode #ifdef FEAT_TERMINAL || (c == K_IGNORE && term_use_loop()) #endif ) { // Insert mode ended, possibly from a callback, or a timer // must have opened a terminal window. if (c != K_IGNORE && c != K_NOP) vungetc(c); count = 0; nomove = TRUE; ins_compl_prep(ESC); goto doESCkey; } } while (c == K_IGNORE || c == K_NOP); // Don't want K_CURSORHOLD for the second key, e.g., after CTRL-V. did_cursorhold = TRUE; #ifdef FEAT_RIGHTLEFT if (p_hkmap && KeyTyped) c = hkmap(c); // Hebrew mode mapping #endif // If the window was made so small that nothing shows, make it at least // one line and one column when typing. if (KeyTyped && !KeyStuffed) win_ensure_size(); /* * Special handling of keys while the popup menu is visible or wanted * and the cursor is still in the completed word. Only when there is * a match, skip this when no matches were found. */ if (ins_compl_active() && pum_wanted() && curwin->w_cursor.col >= ins_compl_col() && ins_compl_has_shown_match()) { // BS: Delete one character from "compl_leader". if ((c == K_BS || c == Ctrl_H) && curwin->w_cursor.col > ins_compl_col() && (c = ins_compl_bs()) == NUL) continue; // When no match was selected or it was edited. if (!ins_compl_used_match()) { // CTRL-L: Add one character from the current match to // "compl_leader". Except when at the original match and // there is nothing to add, CTRL-L works like CTRL-P then. if (c == Ctrl_L && (!ctrl_x_mode_line_or_eval() || ins_compl_long_shown_match())) { ins_compl_addfrommatch(); continue; } // A non-white character that fits in with the current // completion: Add to "compl_leader". if (ins_compl_accept_char(c)) { #if defined(FEAT_EVAL) // Trigger InsertCharPre. char_u *str = do_insert_char_pre(c); char_u *p; if (str != NULL) { for (p = str; *p != NUL; MB_PTR_ADV(p)) ins_compl_addleader(PTR2CHAR(p)); vim_free(str); } else #endif ins_compl_addleader(c); continue; } // Pressing CTRL-Y selects the current match. When // ins_compl_enter_selects() is set the Enter key does the // same. if ((c == Ctrl_Y || (ins_compl_enter_selects() && (c == CAR || c == K_KENTER || c == NL))) && stop_arrow() == OK) { ins_compl_delete(); ins_compl_insert(FALSE); } } } // Prepare for or stop CTRL-X mode. This doesn't do completion, but // it does fix up the text when finishing completion. ins_compl_init_get_longest(); if (ins_compl_prep(c)) continue; // CTRL-\ CTRL-N goes to Normal mode, // CTRL-\ CTRL-G goes to mode selected with 'insertmode', // CTRL-\ CTRL-O is like CTRL-O but without moving the cursor. if (c == Ctrl_BSL) { // may need to redraw when no more chars available now ins_redraw(FALSE); ++no_mapping; ++allow_keys; c = plain_vgetc(); --no_mapping; --allow_keys; if (c != Ctrl_N && c != Ctrl_G && c != Ctrl_O) { // it's something else vungetc(c); c = Ctrl_BSL; } else if (c == Ctrl_G && p_im) continue; else { if (c == Ctrl_O) { ins_ctrl_o(); ins_at_eol = FALSE; // cursor keeps its column nomove = TRUE; } count = 0; goto doESCkey; } } #ifdef FEAT_DIGRAPHS c = do_digraph(c); #endif if ((c == Ctrl_V || c == Ctrl_Q) && ctrl_x_mode_cmdline()) goto docomplete; if (c == Ctrl_V || c == Ctrl_Q) { ins_ctrl_v(); c = Ctrl_V; // pretend CTRL-V is last typed character continue; } if (cindent_on() && ctrl_x_mode_none()) { // A key name preceded by a bang means this key is not to be // inserted. Skip ahead to the re-indenting below. // A key name preceded by a star means that indenting has to be // done before inserting the key. line_is_white = inindent(0); if (in_cinkeys(c, '!', line_is_white)) goto force_cindent; if (can_cindent && in_cinkeys(c, '*', line_is_white) && stop_arrow() == OK) do_c_expr_indent(); } #ifdef FEAT_RIGHTLEFT if (curwin->w_p_rl) switch (c) { case K_LEFT: c = K_RIGHT; break; case K_S_LEFT: c = K_S_RIGHT; break; case K_C_LEFT: c = K_C_RIGHT; break; case K_RIGHT: c = K_LEFT; break; case K_S_RIGHT: c = K_S_LEFT; break; case K_C_RIGHT: c = K_C_LEFT; break; } #endif /* * If 'keymodel' contains "startsel", may start selection. If it * does, a CTRL-O and c will be stuffed, we need to get these * characters. */ if (ins_start_select(c)) continue; /* * The big switch to handle a character in insert mode. */ switch (c) { case ESC: // End input mode if (echeck_abbr(ESC + ABBR_OFF)) break; // FALLTHROUGH case Ctrl_C: // End input mode #ifdef FEAT_CMDWIN if (c == Ctrl_C && cmdwin_type != 0) { // Close the cmdline window. cmdwin_result = K_IGNORE; got_int = FALSE; // don't stop executing autocommands et al. nomove = TRUE; goto doESCkey; } #endif #ifdef FEAT_JOB_CHANNEL if (c == Ctrl_C && bt_prompt(curbuf)) { if (invoke_prompt_interrupt()) { if (!bt_prompt(curbuf)) // buffer changed to a non-prompt buffer, get out of // Insert mode goto doESCkey; break; } } #endif #ifdef UNIX do_intr: #endif // when 'insertmode' set, and not halfway a mapping, don't leave // Insert mode if (goto_im()) { if (got_int) { (void)vgetc(); // flush all buffers got_int = FALSE; } else vim_beep(BO_IM); break; } doESCkey: /* * This is the ONLY return from edit()! */ // Always update o_lnum, so that a "CTRL-O ." that adds a line // still puts the cursor back after the inserted text. if (ins_at_eol && gchar_cursor() == NUL) o_lnum = curwin->w_cursor.lnum; if (ins_esc(&count, cmdchar, nomove)) { // When CTRL-C was typed got_int will be set, with the result // that the autocommands won't be executed. When mapped got_int // is not set, but let's keep the behavior the same. if (cmdchar != 'r' && cmdchar != 'v' && c != Ctrl_C) ins_apply_autocmds(EVENT_INSERTLEAVE); did_cursorhold = FALSE; return (c == Ctrl_O); } continue; case Ctrl_Z: // suspend when 'insertmode' set if (!p_im) goto normalchar; // insert CTRL-Z as normal char do_cmdline_cmd((char_u *)"stop"); #ifdef CURSOR_SHAPE ui_cursor_shape(); // may need to update cursor shape #endif continue; case Ctrl_O: // execute one command #ifdef FEAT_COMPL_FUNC if (ctrl_x_mode_omni()) goto docomplete; #endif if (echeck_abbr(Ctrl_O + ABBR_OFF)) break; ins_ctrl_o(); // don't move the cursor left when 'virtualedit' has "onemore". if (get_ve_flags() & VE_ONEMORE) { ins_at_eol = FALSE; nomove = TRUE; } count = 0; goto doESCkey; case K_INS: // toggle insert/replace mode case K_KINS: ins_insert(replaceState); break; case K_SELECT: // end of Select mode mapping - ignore break; case K_HELP: // Help key works like <ESC> <Help> case K_F1: case K_XF1: stuffcharReadbuff(K_HELP); if (p_im) need_start_insertmode = TRUE; goto doESCkey; #ifdef FEAT_NETBEANS_INTG case K_F21: // NetBeans command ++no_mapping; // don't map the next key hits i = plain_vgetc(); --no_mapping; netbeans_keycommand(i); break; #endif case K_ZERO: // Insert the previously inserted text. case NUL: case Ctrl_A: // For ^@ the trailing ESC will end the insert, unless there is an // error. if (stuff_inserted(NUL, 1L, (c == Ctrl_A)) == FAIL && c != Ctrl_A && !p_im) goto doESCkey; // quit insert mode inserted_space = FALSE; break; case Ctrl_R: // insert the contents of a register ins_reg(); auto_format(FALSE, TRUE); inserted_space = FALSE; break; case Ctrl_G: // commands starting with CTRL-G ins_ctrl_g(); break; case Ctrl_HAT: // switch input mode and/or langmap ins_ctrl_hat(); break; #ifdef FEAT_RIGHTLEFT case Ctrl__: // switch between languages if (!p_ari) goto normalchar; ins_ctrl_(); break; #endif case Ctrl_D: // Make indent one shiftwidth smaller. #if defined(FEAT_FIND_ID) if (ctrl_x_mode_path_defines()) goto docomplete; #endif // FALLTHROUGH case Ctrl_T: // Make indent one shiftwidth greater. if (c == Ctrl_T && ctrl_x_mode_thesaurus()) { if (has_compl_option(FALSE)) goto docomplete; break; } ins_shift(c, lastc); auto_format(FALSE, TRUE); inserted_space = FALSE; break; case K_DEL: // delete character under the cursor case K_KDEL: ins_del(); auto_format(FALSE, TRUE); break; case K_BS: // delete character before the cursor case K_S_BS: case Ctrl_H: did_backspace = ins_bs(c, BACKSPACE_CHAR, &inserted_space); auto_format(FALSE, TRUE); break; case Ctrl_W: // delete word before the cursor #ifdef FEAT_JOB_CHANNEL if (bt_prompt(curbuf) && (mod_mask & MOD_MASK_SHIFT) == 0) { // In a prompt window CTRL-W is used for window commands. // Use Shift-CTRL-W to delete a word. stuffcharReadbuff(Ctrl_W); restart_edit = 'A'; nomove = TRUE; count = 0; goto doESCkey; } #endif did_backspace = ins_bs(c, BACKSPACE_WORD, &inserted_space); auto_format(FALSE, TRUE); break; case Ctrl_U: // delete all inserted text in current line # ifdef FEAT_COMPL_FUNC // CTRL-X CTRL-U completes with 'completefunc'. if (ctrl_x_mode_function()) goto docomplete; # endif did_backspace = ins_bs(c, BACKSPACE_LINE, &inserted_space); auto_format(FALSE, TRUE); inserted_space = FALSE; break; case K_LEFTMOUSE: // mouse keys case K_LEFTMOUSE_NM: case K_LEFTDRAG: case K_LEFTRELEASE: case K_LEFTRELEASE_NM: case K_MOUSEMOVE: case K_MIDDLEMOUSE: case K_MIDDLEDRAG: case K_MIDDLERELEASE: case K_RIGHTMOUSE: case K_RIGHTDRAG: case K_RIGHTRELEASE: case K_X1MOUSE: case K_X1DRAG: case K_X1RELEASE: case K_X2MOUSE: case K_X2DRAG: case K_X2RELEASE: ins_mouse(c); break; case K_MOUSEDOWN: // Default action for scroll wheel up: scroll up ins_mousescroll(MSCR_DOWN); break; case K_MOUSEUP: // Default action for scroll wheel down: scroll down ins_mousescroll(MSCR_UP); break; case K_MOUSELEFT: // Scroll wheel left ins_mousescroll(MSCR_LEFT); break; case K_MOUSERIGHT: // Scroll wheel right ins_mousescroll(MSCR_RIGHT); break; case K_PS: bracketed_paste(PASTE_INSERT, FALSE, NULL); if (cmdchar == K_PS) // invoked from normal mode, bail out goto doESCkey; break; case K_PE: // Got K_PE without K_PS, ignore. break; #ifdef FEAT_GUI_TABLINE case K_TABLINE: case K_TABMENU: ins_tabline(c); break; #endif case K_IGNORE: // Something mapped to nothing break; case K_COMMAND: // <Cmd>command<CR> case K_SCRIPT_COMMAND: // <ScriptCmd>command<CR> do_cmdkey_command(c, 0); #ifdef FEAT_TERMINAL if (term_use_loop()) // Started a terminal that gets the input, exit Insert mode. goto doESCkey; #endif break; case K_CURSORHOLD: // Didn't type something for a while. ins_apply_autocmds(EVENT_CURSORHOLDI); did_cursorhold = TRUE; // If CTRL-G U was used apply it to the next typed key. if (dont_sync_undo == TRUE) dont_sync_undo = MAYBE; break; #ifdef FEAT_GUI_MSWIN // On MS-Windows ignore <M-F4>, we get it when closing the window // was cancelled. case K_F4: if (mod_mask != MOD_MASK_ALT) goto normalchar; break; #endif #ifdef FEAT_GUI case K_VER_SCROLLBAR: ins_scroll(); break; case K_HOR_SCROLLBAR: ins_horscroll(); break; #endif case K_HOME: // <Home> case K_KHOME: case K_S_HOME: case K_C_HOME: ins_home(c); break; case K_END: // <End> case K_KEND: case K_S_END: case K_C_END: ins_end(c); break; case K_LEFT: // <Left> if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)) ins_s_left(); else ins_left(); break; case K_S_LEFT: // <S-Left> case K_C_LEFT: ins_s_left(); break; case K_RIGHT: // <Right> if (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)) ins_s_right(); else ins_right(); break; case K_S_RIGHT: // <S-Right> case K_C_RIGHT: ins_s_right(); break; case K_UP: // <Up> if (pum_visible()) goto docomplete; if (mod_mask & MOD_MASK_SHIFT) ins_pageup(); else ins_up(FALSE); break; case K_S_UP: // <S-Up> case K_PAGEUP: case K_KPAGEUP: if (pum_visible()) goto docomplete; ins_pageup(); break; case K_DOWN: // <Down> if (pum_visible()) goto docomplete; if (mod_mask & MOD_MASK_SHIFT) ins_pagedown(); else ins_down(FALSE); break; case K_S_DOWN: // <S-Down> case K_PAGEDOWN: case K_KPAGEDOWN: if (pum_visible()) goto docomplete; ins_pagedown(); break; #ifdef FEAT_DND case K_DROP: // drag-n-drop event ins_drop(); break; #endif case K_S_TAB: // When not mapped, use like a normal TAB c = TAB; // FALLTHROUGH case TAB: // TAB or Complete patterns along path #if defined(FEAT_FIND_ID) if (ctrl_x_mode_path_patterns()) goto docomplete; #endif inserted_space = FALSE; if (ins_tab()) goto normalchar; // insert TAB as a normal char auto_format(FALSE, TRUE); break; case K_KENTER: // <Enter> c = CAR; // FALLTHROUGH case CAR: case NL: #if defined(FEAT_QUICKFIX) // In a quickfix window a <CR> jumps to the error under the // cursor. if (bt_quickfix(curbuf) && c == CAR) { if (curwin->w_llist_ref == NULL) // quickfix window do_cmdline_cmd((char_u *)".cc"); else // location list window do_cmdline_cmd((char_u *)".ll"); break; } #endif #ifdef FEAT_CMDWIN if (cmdwin_type != 0) { // Execute the command in the cmdline window. cmdwin_result = CAR; goto doESCkey; } #endif #ifdef FEAT_JOB_CHANNEL if (bt_prompt(curbuf)) { invoke_prompt_callback(); if (!bt_prompt(curbuf)) // buffer changed to a non-prompt buffer, get out of // Insert mode goto doESCkey; break; } #endif if (ins_eol(c) == FAIL && !p_im) goto doESCkey; // out of memory auto_format(FALSE, FALSE); inserted_space = FALSE; break; case Ctrl_K: // digraph or keyword completion if (ctrl_x_mode_dictionary()) { if (has_compl_option(TRUE)) goto docomplete; break; } #ifdef FEAT_DIGRAPHS c = ins_digraph(); if (c == NUL) break; #endif goto normalchar; case Ctrl_X: // Enter CTRL-X mode ins_ctrl_x(); break; case Ctrl_RSB: // Tag name completion after ^X if (!ctrl_x_mode_tags()) goto normalchar; goto docomplete; case Ctrl_F: // File name completion after ^X if (!ctrl_x_mode_files()) goto normalchar; goto docomplete; case 's': // Spelling completion after ^X case Ctrl_S: if (!ctrl_x_mode_spell()) goto normalchar; goto docomplete; case Ctrl_L: // Whole line completion after ^X if (!ctrl_x_mode_whole_line()) { // CTRL-L with 'insertmode' set: Leave Insert mode if (p_im) { if (echeck_abbr(Ctrl_L + ABBR_OFF)) break; goto doESCkey; } goto normalchar; } // FALLTHROUGH case Ctrl_P: // Do previous/next pattern completion case Ctrl_N: // if 'complete' is empty then plain ^P is no longer special, // but it is under other ^X modes if (*curbuf->b_p_cpt == NUL && (ctrl_x_mode_normal() || ctrl_x_mode_whole_line()) && !compl_status_local()) goto normalchar; docomplete: compl_busy = TRUE; #ifdef FEAT_FOLDING disable_fold_update++; // don't redraw folds here #endif if (ins_complete(c, TRUE) == FAIL) compl_status_clear(); #ifdef FEAT_FOLDING disable_fold_update--; #endif compl_busy = FALSE; can_si = may_do_si(); // allow smartindenting break; case Ctrl_Y: // copy from previous line or scroll down case Ctrl_E: // copy from next line or scroll up c = ins_ctrl_ey(c); break; default: #ifdef UNIX if (c == intr_char) // special interrupt char goto do_intr; #endif normalchar: /* * Insert a normal character. */ #if defined(FEAT_EVAL) if (!p_paste) { // Trigger InsertCharPre. char_u *str = do_insert_char_pre(c); char_u *p; if (str != NULL) { if (*str != NUL && stop_arrow() != FAIL) { // Insert the new value of v:char literally. for (p = str; *p != NUL; MB_PTR_ADV(p)) { c = PTR2CHAR(p); if (c == CAR || c == K_KENTER || c == NL) ins_eol(c); else ins_char(c); } AppendToRedobuffLit(str, -1); } vim_free(str); c = NUL; } // If the new value is already inserted or an empty string // then don't insert any character. if (c == NUL) break; } #endif // Try to perform smart-indenting. ins_try_si(c); if (c == ' ') { inserted_space = TRUE; if (inindent(0)) can_cindent = FALSE; if (Insstart_blank_vcol == MAXCOL && curwin->w_cursor.lnum == Insstart.lnum) Insstart_blank_vcol = get_nolist_virtcol(); } // Insert a normal character and check for abbreviations on a // special character. Let CTRL-] expand abbreviations without // inserting it. if (vim_iswordc(c) || (!echeck_abbr( // Add ABBR_OFF for characters above 0x100, this is // what check_abbr() expects. (has_mbyte && c >= 0x100) ? (c + ABBR_OFF) : c) && c != Ctrl_RSB)) { insert_special(c, FALSE, FALSE); #ifdef FEAT_RIGHTLEFT revins_legal++; revins_chars++; #endif } auto_format(FALSE, TRUE); #ifdef FEAT_FOLDING // When inserting a character the cursor line must never be in a // closed fold. foldOpenCursor(); #endif break; } // end of switch (c) // If typed something may trigger CursorHoldI again. if (c != K_CURSORHOLD #ifdef FEAT_COMPL_FUNC // but not in CTRL-X mode, a script can't restore the state && ctrl_x_mode_normal() #endif ) did_cursorhold = FALSE; // If the cursor was moved we didn't just insert a space if (arrow_used) inserted_space = FALSE; if (can_cindent && cindent_on() && ctrl_x_mode_normal()) { force_cindent: /* * Indent now if a key was typed that is in 'cinkeys'. */ if (in_cinkeys(c, ' ', line_is_white)) { if (stop_arrow() == OK) // re-indent the current line do_c_expr_indent(); } } } // for (;;) // NOTREACHED }
0
436,066
static int io_read(struct io_kiocb *req, unsigned int issue_flags) { struct iovec inline_vecs[UIO_FASTIOV], *iovec = inline_vecs; struct kiocb *kiocb = &req->rw.kiocb; struct iov_iter __iter, *iter = &__iter; struct io_async_rw *rw = req->async_data; ssize_t io_size, ret, ret2; bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK; if (rw) { iter = &rw->iter; iovec = NULL; } else { ret = io_import_iovec(READ, req, &iovec, iter, !force_nonblock); if (ret < 0) return ret; } io_size = iov_iter_count(iter); req->result = io_size; /* Ensure we clear previously set non-block flag */ if (!force_nonblock) kiocb->ki_flags &= ~IOCB_NOWAIT; else kiocb->ki_flags |= IOCB_NOWAIT; /* If the file doesn't support async, just async punt */ if (force_nonblock && !io_file_supports_async(req, READ)) { ret = io_setup_async_rw(req, iovec, inline_vecs, iter, true); return ret ?: -EAGAIN; } ret = rw_verify_area(READ, req->file, io_kiocb_ppos(kiocb), io_size); if (unlikely(ret)) { kfree(iovec); return ret; } ret = io_iter_do_read(req, iter); if (ret == -EAGAIN || (req->flags & REQ_F_REISSUE)) { req->flags &= ~REQ_F_REISSUE; /* IOPOLL retry should happen for io-wq threads */ if (!force_nonblock && !(req->ctx->flags & IORING_SETUP_IOPOLL)) goto done; /* no retry on NONBLOCK nor RWF_NOWAIT */ if (req->flags & REQ_F_NOWAIT) goto done; /* some cases will consume bytes even on error returns */ iov_iter_reexpand(iter, iter->count + iter->truncated); iov_iter_revert(iter, io_size - iov_iter_count(iter)); ret = 0; } else if (ret == -EIOCBQUEUED) { goto out_free; } else if (ret <= 0 || ret == io_size || !force_nonblock || (req->flags & REQ_F_NOWAIT) || !(req->flags & REQ_F_ISREG)) { /* read all, failed, already did sync or don't want to retry */ goto done; } ret2 = io_setup_async_rw(req, iovec, inline_vecs, iter, true); if (ret2) return ret2; iovec = NULL; rw = req->async_data; /* now use our persistent iterator, if we aren't already */ iter = &rw->iter; do { io_size -= ret; rw->bytes_done += ret; /* if we can retry, do so with the callbacks armed */ if (!io_rw_should_retry(req)) { kiocb->ki_flags &= ~IOCB_WAITQ; return -EAGAIN; } /* * Now retry read with the IOCB_WAITQ parts set in the iocb. If * we get -EIOCBQUEUED, then we'll get a notification when the * desired page gets unlocked. We can also get a partial read * here, and if we do, then just retry at the new offset. */ ret = io_iter_do_read(req, iter); if (ret == -EIOCBQUEUED) return 0; /* we got some bytes, but not all. retry. */ kiocb->ki_flags &= ~IOCB_WAITQ; } while (ret > 0 && ret < io_size); done: kiocb_done(kiocb, ret, issue_flags); out_free: /* it's faster to check here then delegate to kfree */ if (iovec) kfree(iovec); return 0; }
0
505,649
smtp_command_parse_data_with_size(struct smtp_command_parser *parser, uoff_t size) { i_assert(parser->data == NULL); if (size > parser->limits.max_data_size) { /* not supposed to happen; command should check size */ parser->data = i_stream_create_error_str(EMSGSIZE, "Command data size exceeds maximum " "(%"PRIuUOFF_T" > %"PRIuUOFF_T")", size, parser->limits.max_data_size); } else { // FIXME: make exact_size stream type struct istream *limit_input = i_stream_create_limit(parser->input, size); parser->data = i_stream_create_min_sized(limit_input, size); i_stream_unref(&limit_input); } i_stream_ref(parser->data); return parser->data; }
0
224,538
Status QuantizedConv2DShape(InferenceContext* c) { TF_RETURN_IF_ERROR(shape_inference::Conv2DShape(c)); ShapeHandle unused; TF_RETURN_IF_ERROR(c->WithRank(c->input(2), 0, &unused)); TF_RETURN_IF_ERROR(c->WithRank(c->input(3), 0, &unused)); TF_RETURN_IF_ERROR(c->WithRank(c->input(4), 0, &unused)); TF_RETURN_IF_ERROR(c->WithRank(c->input(5), 0, &unused)); c->set_output(1, c->Scalar()); c->set_output(2, c->Scalar()); return Status::OK(); }
0
215,374
static int sctp_setsockopt_auth_key(struct sock *sk, char __user *optval, int optlen) { struct sctp_authkey *authkey; struct sctp_association *asoc; int ret; if (!sctp_auth_enable) return -EACCES; if (optlen <= sizeof(struct sctp_authkey)) return -EINVAL; authkey = kmalloc(optlen, GFP_KERNEL); if (!authkey) return -ENOMEM; if (copy_from_user(authkey, optval, optlen)) { ret = -EFAULT; goto out; } if (authkey->sca_keylength > optlen) { ret = -EINVAL; goto out; } asoc = sctp_id2assoc(sk, authkey->sca_assoc_id); if (!asoc && authkey->sca_assoc_id && sctp_style(sk, UDP)) { ret = -EINVAL; goto out; } ret = sctp_auth_set_key(sctp_sk(sk)->ep, asoc, authkey); out: kfree(authkey); return ret; }
1
424,959
static void iwl_trans_pcie_write_shr(struct iwl_trans *trans, u32 reg, u32 val) { iwl_write32(trans, HEEP_CTRL_WRD_PCIEX_DATA_REG, val); iwl_write32(trans, HEEP_CTRL_WRD_PCIEX_CTRL_REG, ((reg & 0x0000ffff) | (3 << 28))); }
0
247,524
TEST_P(SslSocketTest, TestConnectionFailsOnMultipleCertificatesNonePassOcspPolicy) { const std::string server_ctx_yaml = R"EOF( common_tls_context: tls_certificates: - certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/ocsp/test_data/revoked_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/ocsp/test_data/revoked_key.pem" ocsp_staple: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/ocsp/test_data/revoked_ocsp_resp.der" - certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/ocsp/test_data/ecdsa_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/ocsp/test_data/ecdsa_key.pem" ocsp_staple: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/ocsp/test_data/ecdsa_ocsp_resp.der" ocsp_staple_policy: must_staple )EOF"; const std::string client_ctx_yaml = R"EOF( common_tls_context: tls_params: cipher_suites: - ECDHE-ECDSA-AES128-GCM-SHA256 - TLS_RSA_WITH_AES_128_GCM_SHA256 )EOF"; TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, false, GetParam()); testUtil(test_options.setExpectedServerStats("ssl.ocsp_staple_failed").enableOcspStapling()); }
0
432,287
static MemTxResult memory_region_read_accessor(struct uc_struct *uc, MemoryRegion *mr, hwaddr addr, uint64_t *value, unsigned size, signed shift, uint64_t mask, MemTxAttrs attrs) { uint64_t tmp; tmp = mr->ops->read(uc, mr->opaque, addr, size); memory_region_shift_read_access(value, shift, mask, tmp); return MEMTX_OK; }
0
312,525
qf_set_title_var(qf_list_T *qfl) { if (qfl->qf_title != NULL) set_internal_string_var((char_u *)"w:quickfix_title", qfl->qf_title); }
0
292,190
inbound_user_info (session *sess, char *chan, char *user, char *host, char *servname, char *nick, char *realname, char *account, unsigned int away, const message_tags_data *tags_data) { server *serv = sess->server; session *who_sess; GSList *list; char *uhost = NULL; if (user && host) { uhost = g_strdup_printf ("%s@%s", user, host); } if (chan) { who_sess = find_channel (serv, chan); if (who_sess) userlist_add_hostname (who_sess, nick, uhost, realname, servname, account, away); else { if (serv->doing_dns && nick && host) do_dns (sess, nick, host, tags_data); } } else { /* came from WHOIS, not channel specific */ for (list = sess_list; list; list = list->next) { sess = list->data; if (sess->type == SESS_CHANNEL && sess->server == serv) { userlist_add_hostname (sess, nick, uhost, realname, servname, account, away); } } } g_free (uhost); }
0
458,916
cin_is_cpp_namespace(char_u *s) { char_u *p; int has_name = FALSE; int has_name_start = FALSE; s = cin_skipcomment(s); if (STRNCMP(s, "namespace", 9) == 0 && (s[9] == NUL || !vim_iswordc(s[9]))) { p = cin_skipcomment(skipwhite(s + 9)); while (*p != NUL) { if (VIM_ISWHITE(*p)) { has_name = TRUE; // found end of a name p = cin_skipcomment(skipwhite(p)); } else if (*p == '{') { break; } else if (vim_iswordc(*p)) { has_name_start = TRUE; if (has_name) return FALSE; // word character after skipping past name ++p; } else if (p[0] == ':' && p[1] == ':' && vim_iswordc(p[2])) { if (!has_name_start || has_name) return FALSE; // C++ 17 nested namespace p += 3; } else { return FALSE; } } return TRUE; } return FALSE; }
0
229,292
std::unique_ptr<cql_server::response> cql_server::connection::make_auth_success(int16_t stream, bytes b, const tracing::trace_state_ptr& tr_state) const { auto response = std::make_unique<cql_server::response>(stream, cql_binary_opcode::AUTH_SUCCESS, tr_state); response->write_bytes(std::move(b)); return response; }
0
489,167
sctp_disposition_t sctp_sf_do_5_1E_ca(const struct sctp_endpoint *ep, const struct sctp_association *asoc, const sctp_subtype_t type, void *arg, sctp_cmd_seq_t *commands) { struct sctp_chunk *chunk = arg; struct sctp_ulpevent *ev; if (!sctp_vtag_verify(chunk, asoc)) return sctp_sf_pdiscard(ep, asoc, type, arg, commands); /* Verify that the chunk length for the COOKIE-ACK is OK. * If we don't do this, any bundled chunks may be junked. */ if (!sctp_chunk_length_valid(chunk, sizeof(sctp_chunkhdr_t))) return sctp_sf_violation_chunklen(ep, asoc, type, arg, commands); /* Reset init error count upon receipt of COOKIE-ACK, * to avoid problems with the managemement of this * counter in stale cookie situations when a transition back * from the COOKIE-ECHOED state to the COOKIE-WAIT * state is performed. */ sctp_add_cmd_sf(commands, SCTP_CMD_INIT_COUNTER_RESET, SCTP_NULL()); /* RFC 2960 5.1 Normal Establishment of an Association * * E) Upon reception of the COOKIE ACK, endpoint "A" will move * from the COOKIE-ECHOED state to the ESTABLISHED state, * stopping the T1-cookie timer. */ sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_STOP, SCTP_TO(SCTP_EVENT_TIMEOUT_T1_COOKIE)); sctp_add_cmd_sf(commands, SCTP_CMD_NEW_STATE, SCTP_STATE(SCTP_STATE_ESTABLISHED)); SCTP_INC_STATS(SCTP_MIB_CURRESTAB); SCTP_INC_STATS(SCTP_MIB_ACTIVEESTABS); sctp_add_cmd_sf(commands, SCTP_CMD_HB_TIMERS_START, SCTP_NULL()); if (asoc->autoclose) sctp_add_cmd_sf(commands, SCTP_CMD_TIMER_START, SCTP_TO(SCTP_EVENT_TIMEOUT_AUTOCLOSE)); /* It may also notify its ULP about the successful * establishment of the association with a Communication Up * notification (see Section 10). */ ev = sctp_ulpevent_make_assoc_change(asoc, 0, SCTP_COMM_UP, 0, asoc->c.sinit_num_ostreams, asoc->c.sinit_max_instreams, NULL, GFP_ATOMIC); if (!ev) goto nomem; sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev)); /* Sockets API Draft Section 5.3.1.6 * When a peer sends a Adaptation Layer Indication parameter , SCTP * delivers this notification to inform the application that of the * peers requested adaptation layer. */ if (asoc->peer.adaptation_ind) { ev = sctp_ulpevent_make_adaptation_indication(asoc, GFP_ATOMIC); if (!ev) goto nomem; sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev)); } return SCTP_DISPOSITION_CONSUME; nomem: return SCTP_DISPOSITION_NOMEM; }
0
447,066
SshIo::SshImpl::SshImpl(const std::string& url, size_t blockSize):Impl(url, blockSize) { hostInfo_ = Exiv2::Uri::Parse(url); Exiv2::Uri::Decode(hostInfo_); // remove / at the beginning of the path if (hostInfo_.Path[0] == '/') { hostInfo_.Path = hostInfo_.Path.substr(1); } ssh_ = new SSH(hostInfo_.Host, hostInfo_.Username, hostInfo_.Password, hostInfo_.Port); if (protocol_ == pSftp) { ssh_->getFileSftp(hostInfo_.Path, fileHandler_); if (fileHandler_ == NULL) throw Error(1, "Unable to open the file"); } else { fileHandler_ = NULL; } }
0
512,990
virtual bool set_extraction_flag_processor(void *arg) { set_extraction_flag(*(int*)arg); return 0; }
0
442,786
static const char *param2text(int res) { ParameterError error = (ParameterError)res; switch(error) { case PARAM_GOT_EXTRA_PARAMETER: return "had unsupported trailing garbage"; case PARAM_OPTION_UNKNOWN: return "is unknown"; case PARAM_OPTION_AMBIGUOUS: return "is ambiguous"; case PARAM_REQUIRES_PARAMETER: return "requires parameter"; case PARAM_BAD_USE: return "is badly used here"; case PARAM_BAD_NUMERIC: return "expected a proper numerical parameter"; case PARAM_LIBCURL_DOESNT_SUPPORT: return "the installed libcurl version doesn't support this"; case PARAM_NO_MEM: return "out of memory"; default: return "unknown error"; } }
0
512,959
bool with_sum_func() const { return m_with_sum_func; }
0
212,871
std::string controller::bookmark( const std::string& url, const std::string& title, const std::string& description, const std::string& feed_title) { std::string bookmark_cmd = cfg.get_configvalue("bookmark-cmd"); bool is_interactive = cfg.get_configvalue_as_bool("bookmark-interactive"); if (bookmark_cmd.length() > 0) { std::string cmdline = strprintf::fmt("%s '%s' %s %s %s", bookmark_cmd, utils::replace_all(url,"'", "%27"), quote_empty(stfl::quote(title)), quote_empty(stfl::quote(description)), quote_empty(stfl::quote(feed_title))); LOG(level::DEBUG, "controller::bookmark: cmd = %s", cmdline); if (is_interactive) { v->push_empty_formaction(); stfl::reset(); utils::run_interactively(cmdline, "controller::bookmark"); v->pop_current_formaction(); return ""; } else { char * my_argv[4]; my_argv[0] = const_cast<char *>("/bin/sh"); my_argv[1] = const_cast<char *>("-c"); my_argv[2] = const_cast<char *>(cmdline.c_str()); my_argv[3] = nullptr; return utils::run_program(my_argv, ""); } } else { return _("bookmarking support is not configured. Please set the configuration variable `bookmark-cmd' accordingly."); } }
1
225,959
GF_Err padb_box_write(GF_Box *s, GF_BitStream *bs) { u32 i; GF_Err e; GF_PaddingBitsBox *ptr = (GF_PaddingBitsBox *) s; e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_int(bs, ptr->SampleCount, 32); for (i=0 ; i<ptr->SampleCount; i += 2) { gf_bs_write_int(bs, 0, 1); if (i+1 < ptr->SampleCount) { gf_bs_write_int(bs, ptr->padbits[i+1], 3); } else { gf_bs_write_int(bs, 0, 3); } gf_bs_write_int(bs, 0, 1); gf_bs_write_int(bs, ptr->padbits[i], 3); } return GF_OK; }
0
317,178
static void selinux_inet_conn_established(struct sock *sk, struct sk_buff *skb) { u16 family = sk->sk_family; struct sk_security_struct *sksec = sk->sk_security; /* handle mapped IPv4 packets arriving via IPv6 sockets */ if (family == PF_INET6 && skb->protocol == htons(ETH_P_IP)) family = PF_INET; selinux_skb_peerlbl_sid(skb, family, &sksec->peer_sid); }
0
225,946
GF_Err prft_box_read(GF_Box *s,GF_BitStream *bs) { GF_ProducerReferenceTimeBox *ptr = (GF_ProducerReferenceTimeBox *) s; ISOM_DECREASE_SIZE(ptr, 12); ptr->refTrackID = gf_bs_read_u32(bs); ptr->ntp = gf_bs_read_u64(bs); if (ptr->version==0) { ISOM_DECREASE_SIZE(ptr, 4); ptr->timestamp = gf_bs_read_u32(bs); } else { ISOM_DECREASE_SIZE(ptr, 8); ptr->timestamp = gf_bs_read_u64(bs); } return GF_OK;
0
252,369
void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out) { // Level 6 corresponds to TDEFL_DEFAULT_MAX_PROBES or MZ_DEFAULT_LEVEL (but we // can't depend on MZ_DEFAULT_LEVEL being available in case the zlib API's // where #defined out) return tdefl_write_image_to_png_file_in_memory_ex(pImage, w, h, num_chans, pLen_out, 6, MZ_FALSE); }
0
236,196
void gppc_box_del(GF_Box *s) { GF_3GPPConfigBox *ptr = (GF_3GPPConfigBox *)s; if (ptr == NULL) return; gf_free(ptr); }
0
294,562
datetime_s_xmlschema(int argc, VALUE *argv, VALUE klass) { VALUE str, sg, opt; rb_scan_args(argc, argv, "02:", &str, &sg, &opt); if (!NIL_P(opt)) argc--; switch (argc) { case 0: str = rb_str_new2("-4712-01-01T00:00:00+00:00"); case 1: sg = INT2FIX(DEFAULT_SG); } { int argc2 = 1; VALUE argv2[2]; argv2[0] = str; argv2[1] = opt; if (!NIL_P(opt)) argc2++; VALUE hash = date_s__xmlschema(argc2, argv2, klass); return dt_new_by_frags(klass, hash, sg); } }
0
424,924
static void iwl_trans_pcie_stop_device(struct iwl_trans *trans) { struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); bool was_in_rfkill; mutex_lock(&trans_pcie->mutex); trans_pcie->opmode_down = true; was_in_rfkill = test_bit(STATUS_RFKILL_OPMODE, &trans->status); _iwl_trans_pcie_stop_device(trans); iwl_trans_pcie_handle_stop_rfkill(trans, was_in_rfkill); mutex_unlock(&trans_pcie->mutex); }
0
245,188
select_history() { if (opt_incremental_history_name || opt_incremental_history_uuid) { if (!select_incremental_lsn_from_history( &incremental_lsn)) { return(false); } } return(true); }
0
279,937
get_old_sub(void) { return old_sub; }
0
369,241
static __poll_t io_uring_poll(struct file *file, poll_table *wait) { struct io_ring_ctx *ctx = file->private_data; __poll_t mask = 0; poll_wait(file, &ctx->cq_wait, wait); /* * synchronizes with barrier from wq_has_sleeper call in * io_commit_cqring */ smp_rmb(); if (!io_sqring_full(ctx)) mask |= EPOLLOUT | EPOLLWRNORM; /* * Don't flush cqring overflow list here, just do a simple check. * Otherwise there could possible be ABBA deadlock: * CPU0 CPU1 * ---- ---- * lock(&ctx->uring_lock); * lock(&ep->mtx); * lock(&ctx->uring_lock); * lock(&ep->mtx); * * Users may get EPOLLIN meanwhile seeing nothing in cqring, this * pushs them to do the flush. */ if (io_cqring_events(ctx) || test_bit(0, &ctx->check_cq_overflow)) mask |= EPOLLIN | EPOLLRDNORM; return mask;
0
484,804
static bool xennet_can_sg(struct net_device *dev) { return dev->features & NETIF_F_SG; }
0
443,708
is_valid_mbc_string(const UChar* p, const UChar* end) { const UChar* end1 = end - 1; while (p < end1) { p += utf16le_mbc_enc_len(p); } if (p != end) return FALSE; else return TRUE; }
0
389,680
check_for_opt_lnum_arg(typval_T *args, int idx) { return (args[idx].v_type == VAR_UNKNOWN || check_for_lnum_arg(args, idx)); }
0
492,695
_vte_terminal_clear_current_line (VteTerminal *terminal) { VteRowData *rowdata; VteScreen *screen; screen = terminal->pvt->screen; /* If the cursor is actually on the screen, clear data in the row * which corresponds to the cursor. */ if (_vte_ring_next(screen->row_data) > screen->cursor_current.row) { /* Get the data for the row which the cursor points to. */ rowdata = _vte_ring_index_writable (screen->row_data, screen->cursor_current.row); g_assert(rowdata != NULL); /* Remove it. */ _vte_row_data_shrink (rowdata, 0); /* Add enough cells to the end of the line to fill out the row. */ _vte_row_data_fill (rowdata, &screen->fill_defaults, terminal->column_count); rowdata->attr.soft_wrapped = 0; /* Repaint this row. */ _vte_invalidate_cells(terminal, 0, terminal->column_count, screen->cursor_current.row, 1); } /* We've modified the display. Make a note of it. */ terminal->pvt->text_deleted_flag = TRUE; }
0
343,240
void client_fflush(void) { if (replybuf_pos == replybuf) { return; } safe_write(clientfd, replybuf, (size_t) (replybuf_pos - replybuf), -1); client_init_reply_buf(); }
0
413,827
void LinkResolver::runtime_resolve_special_method(CallInfo& result, const LinkInfo& link_info, const methodHandle& resolved_method, Handle recv, TRAPS) { Klass* resolved_klass = link_info.resolved_klass(); // resolved method is selected method unless we have an old-style lookup // for a superclass method // Invokespecial for a superinterface, resolved method is selected method, // no checks for shadowing methodHandle sel_method(THREAD, resolved_method()); if (link_info.check_access() && // check if the method is not <init> resolved_method->name() != vmSymbols::object_initializer_name()) { Klass* current_klass = link_info.current_klass(); // Check if the class of the resolved_klass is a superclass // (not supertype in order to exclude interface classes) of the current class. // This check is not performed for super.invoke for interface methods // in super interfaces. if (current_klass->is_subclass_of(resolved_klass) && current_klass != resolved_klass) { // Lookup super method Klass* super_klass = current_klass->super(); Method* instance_method = lookup_instance_method_in_klasses(super_klass, resolved_method->name(), resolved_method->signature(), Klass::PrivateLookupMode::find); sel_method = methodHandle(THREAD, instance_method); // check if found if (sel_method.is_null()) { ResourceMark rm(THREAD); stringStream ss; ss.print("'"); resolved_method->print_external_name(&ss); ss.print("'"); THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), ss.as_string()); // check loader constraints if found a different method } else if (link_info.check_loader_constraints() && sel_method() != resolved_method()) { check_method_loader_constraints(link_info, sel_method, "method", CHECK); } } // Check that the class of objectref (the receiver) is the current class or interface, // or a subtype of the current class or interface (the sender), otherwise invokespecial // throws IllegalAccessError. // The verifier checks that the sender is a subtype of the class in the I/MR operand. // The verifier also checks that the receiver is a subtype of the sender, if the sender is // a class. If the sender is an interface, the check has to be performed at runtime. InstanceKlass* sender = InstanceKlass::cast(current_klass); if (sender->is_interface() && recv.not_null()) { Klass* receiver_klass = recv->klass(); if (!receiver_klass->is_subtype_of(sender)) { ResourceMark rm(THREAD); char buf[500]; jio_snprintf(buf, sizeof(buf), "Receiver class %s must be the current class or a subtype of interface %s", receiver_klass->external_name(), sender->external_name()); THROW_MSG(vmSymbols::java_lang_IllegalAccessError(), buf); } } } // check if not static if (sel_method->is_static()) { ResourceMark rm(THREAD); stringStream ss; ss.print("Expecting non-static method '"); resolved_method->print_external_name(&ss); ss.print("'"); THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), ss.as_string()); } // check if abstract if (sel_method->is_abstract()) { ResourceMark rm(THREAD); stringStream ss; ss.print("'"); Method::print_external_name(&ss, resolved_klass, sel_method->name(), sel_method->signature()); ss.print("'"); THROW_MSG(vmSymbols::java_lang_AbstractMethodError(), ss.as_string()); } if (log_develop_is_enabled(Trace, itables)) { trace_method_resolution("invokespecial selected method: resolved-class:", resolved_klass, resolved_klass, sel_method(), true); } // setup result result.set_static(resolved_klass, sel_method, CHECK); }
0
400,752
struct iovec *iovec_from_user(const struct iovec __user *uvec, unsigned long nr_segs, unsigned long fast_segs, struct iovec *fast_iov, bool compat) { struct iovec *iov = fast_iov; int ret; /* * SuS says "The readv() function *may* fail if the iovcnt argument was * less than or equal to 0, or greater than {IOV_MAX}. Linux has * traditionally returned zero for zero segments, so... */ if (nr_segs == 0) return iov; if (nr_segs > UIO_MAXIOV) return ERR_PTR(-EINVAL); if (nr_segs > fast_segs) { iov = kmalloc_array(nr_segs, sizeof(struct iovec), GFP_KERNEL); if (!iov) return ERR_PTR(-ENOMEM); } if (compat) ret = copy_compat_iovec_from_user(iov, uvec, nr_segs); else ret = copy_iovec_from_user(iov, uvec, nr_segs); if (ret) { if (iov != fast_iov) kfree(iov); return ERR_PTR(ret); } return iov; }
0
220,828
inline void NdArrayDescsForElementwiseBroadcast(const Dims<N>& input0_dims, const Dims<N>& input1_dims, NdArrayDesc<N>* desc0_out, NdArrayDesc<N>* desc1_out) { TFLITE_DCHECK(desc0_out != nullptr); TFLITE_DCHECK(desc1_out != nullptr); // Copy dims to desc. for (int i = 0; i < N; ++i) { desc0_out->extents[i] = input0_dims.sizes[i]; desc0_out->strides[i] = input0_dims.strides[i]; desc1_out->extents[i] = input1_dims.sizes[i]; desc1_out->strides[i] = input1_dims.strides[i]; } // Walk over each dimension. If the extents are equal do nothing. // Otherwise, set the desc with extent 1 to have extent equal to the other and // stride 0. for (int i = 0; i < N; ++i) { const int extent0 = ArraySize(input0_dims, i); const int extent1 = ArraySize(input1_dims, i); if (extent0 != extent1) { if (extent0 == 1) { desc0_out->strides[i] = 0; desc0_out->extents[i] = extent1; } else { TFLITE_DCHECK_EQ(extent1, 1); desc1_out->strides[i] = 0; desc1_out->extents[i] = extent0; } } } }
0
345,140
run_ready(struct pxa3xx_gcu_priv *priv) { unsigned int num = 0; struct pxa3xx_gcu_shared *shared = priv->shared; struct pxa3xx_gcu_batch *ready = priv->ready; QDUMP("Start"); BUG_ON(!ready); shared->buffer[num++] = 0x05000000; while (ready) { shared->buffer[num++] = 0x00000001; shared->buffer[num++] = ready->phys; ready = ready->next; } shared->buffer[num++] = 0x05000000; priv->running = priv->ready; priv->ready = priv->ready_last = NULL; gc_writel(priv, REG_GCRBLR, 0); shared->hw_running = 1; /* ring base address */ gc_writel(priv, REG_GCRBBR, shared->buffer_phys); /* ring tail address */ gc_writel(priv, REG_GCRBTR, shared->buffer_phys + num * 4); /* ring length */ gc_writel(priv, REG_GCRBLR, ((num + 63) & ~63) * 4); }
0
503,981
escape_none(const char *string, const struct auth_request *request ATTR_UNUSED) { return string; }
0
437,314
comp_opt_exact_or_map(OptExact* e, OptMap* m) { #define COMP_EM_BASE 20 int ae, am; if (m->value <= 0) return -1; ae = COMP_EM_BASE * e->len * (e->ignore_case ? 1 : 2); am = COMP_EM_BASE * 5 * 2 / m->value; return comp_distance_value(&e->mmd, &m->mmd, ae, am); }
0
218,991
Status ConstantFolding::SimplifyPad(const GraphProperties& properties, bool use_shape_info, GraphDef* optimized_graph, NodeDef* node) { if (!use_shape_info || !IsPad(*node)) return Status::OK(); Tensor paddings; if (GetTensorFromConstNode(node->input(1), &paddings)) { // The node is replaceable iff all values in paddings are 0. bool replaceable = true; if (paddings.dtype() == DT_INT32) { const auto flatten = paddings.flat<int32>(); for (int j = 0; replaceable && j < flatten.size(); ++j) { replaceable &= flatten(j) == 0; } } else { const auto flatten = paddings.flat<int64_t>(); for (int j = 0; replaceable && j < flatten.size(); ++j) { replaceable &= flatten(j) == 0; } } if (replaceable) { ReplaceOperationWithIdentity(0, properties, node, optimized_graph); } } return Status::OK(); }
0
259,235
static int mov_read_adrm(MOVContext *c, AVIOContext *pb, MOVAtom atom) { uint8_t intermediate_key[20]; uint8_t intermediate_iv[20]; uint8_t input[64]; uint8_t output[64]; uint8_t file_checksum[20]; uint8_t calculated_checksum[20]; char checksum_string[2 * sizeof(file_checksum) + 1]; struct AVSHA *sha; int i; int ret = 0; uint8_t *activation_bytes = c->activation_bytes; uint8_t *fixed_key = c->audible_fixed_key; c->aax_mode = 1; sha = av_sha_alloc(); if (!sha) return AVERROR(ENOMEM); av_free(c->aes_decrypt); c->aes_decrypt = av_aes_alloc(); if (!c->aes_decrypt) { ret = AVERROR(ENOMEM); goto fail; } /* drm blob processing */ avio_read(pb, output, 8); // go to offset 8, absolute position 0x251 avio_read(pb, input, DRM_BLOB_SIZE); avio_read(pb, output, 4); // go to offset 4, absolute position 0x28d avio_read(pb, file_checksum, 20); // required by external tools ff_data_to_hex(checksum_string, file_checksum, sizeof(file_checksum), 1); av_log(c->fc, AV_LOG_INFO, "[aax] file checksum == %s\n", checksum_string); /* verify activation data */ if (!activation_bytes) { av_log(c->fc, AV_LOG_WARNING, "[aax] activation_bytes option is missing!\n"); ret = 0; /* allow ffprobe to continue working on .aax files */ goto fail; } if (c->activation_bytes_size != 4) { av_log(c->fc, AV_LOG_FATAL, "[aax] activation_bytes value needs to be 4 bytes!\n"); ret = AVERROR(EINVAL); goto fail; } /* verify fixed key */ if (c->audible_fixed_key_size != 16) { av_log(c->fc, AV_LOG_FATAL, "[aax] audible_fixed_key value needs to be 16 bytes!\n"); ret = AVERROR(EINVAL); goto fail; } /* AAX (and AAX+) key derivation */ av_sha_init(sha, 160); av_sha_update(sha, fixed_key, 16); av_sha_update(sha, activation_bytes, 4); av_sha_final(sha, intermediate_key); av_sha_init(sha, 160); av_sha_update(sha, fixed_key, 16); av_sha_update(sha, intermediate_key, 20); av_sha_update(sha, activation_bytes, 4); av_sha_final(sha, intermediate_iv); av_sha_init(sha, 160); av_sha_update(sha, intermediate_key, 16); av_sha_update(sha, intermediate_iv, 16); av_sha_final(sha, calculated_checksum); if (memcmp(calculated_checksum, file_checksum, 20)) { // critical error av_log(c->fc, AV_LOG_ERROR, "[aax] mismatch in checksums!\n"); ret = AVERROR_INVALIDDATA; goto fail; } av_aes_init(c->aes_decrypt, intermediate_key, 128, 1); av_aes_crypt(c->aes_decrypt, output, input, DRM_BLOB_SIZE >> 4, intermediate_iv, 1); for (i = 0; i < 4; i++) { // file data (in output) is stored in big-endian mode if (activation_bytes[i] != output[3 - i]) { // critical error av_log(c->fc, AV_LOG_ERROR, "[aax] error in drm blob decryption!\n"); ret = AVERROR_INVALIDDATA; goto fail; } } memcpy(c->file_key, output + 8, 16); memcpy(input, output + 26, 16); av_sha_init(sha, 160); av_sha_update(sha, input, 16); av_sha_update(sha, c->file_key, 16); av_sha_update(sha, fixed_key, 16); av_sha_final(sha, c->file_iv); fail: av_free(sha); return ret; }
0
219,965
int callback_glewlwyd_add_client_module (const struct _u_request * request, struct _u_response * response, void * client_data) { struct config_elements * config = (struct config_elements *)client_data; json_t * j_module, * j_module_valid, * j_result; j_module = ulfius_get_json_body_request(request, NULL); if (j_module != NULL) { j_module_valid = is_client_module_valid(config, j_module, 1); if (check_result_value(j_module_valid, G_OK)) { j_result = add_client_module(config, j_module); if (check_result_value(j_result, G_ERROR_PARAM)) { if (json_object_get(j_result, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_result, "error")); } else { response->status = 400; } } else if (!check_result_value(j_result, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_client_module - Error add_client_module"); response->status = 500; } else { y_log_message(Y_LOG_LEVEL_INFO, "Event - Client backend module '%s' added (%s)", json_string_value(json_object_get(j_module, "name")), json_string_value(json_object_get(j_module, "module"))); } json_decref(j_result); } else if (check_result_value(j_module_valid, G_ERROR_PARAM)) { if (json_object_get(j_module_valid, "error") != NULL) { ulfius_set_json_body_response(response, 400, json_object_get(j_module_valid, "error")); } else { response->status = 400; } } else if (!check_result_value(j_module_valid, G_OK)) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_add_client_module - Error is_client_module_valid"); response->status = 500; } json_decref(j_module_valid); } else { response->status = 400; } json_decref(j_module); return U_CALLBACK_CONTINUE; }
0
310,292
dirserv_set_router_is_running(routerinfo_t *router, time_t now) { /*XXXX023 This function is a mess. Separate out the part that calculates whether it's reachable and the part that tells rephist that the router was unreachable. */ int answer; if (router_is_me(router)) { /* We always know if we are down ourselves. */ answer = ! we_are_hibernating(); } else if (router->is_hibernating && (router->cache_info.published_on + HIBERNATION_PUBLICATION_SKEW) > router->last_reachable) { /* A hibernating router is down unless we (somehow) had contact with it * since it declared itself to be hibernating. */ answer = 0; } else if (get_options()->AssumeReachable) { /* If AssumeReachable, everybody is up unless they say they are down! */ answer = 1; } else { /* Otherwise, a router counts as up if we found it reachable in the last REACHABLE_TIMEOUT seconds. */ answer = (now < router->last_reachable + REACHABLE_TIMEOUT); } if (!answer && running_long_enough_to_decide_unreachable()) { /* Not considered reachable. tell rephist about that. Because we launch a reachability test for each router every REACHABILITY_TEST_CYCLE_PERIOD seconds, then the router has probably been down since at least that time after we last successfully reached it. */ time_t when = now; if (router->last_reachable && router->last_reachable + REACHABILITY_TEST_CYCLE_PERIOD < now) when = router->last_reachable + REACHABILITY_TEST_CYCLE_PERIOD; rep_hist_note_router_unreachable(router->cache_info.identity_digest, when); } router->is_running = answer; }
0
236,125
GF_Err diST_box_read(GF_Box *s, GF_BitStream *bs) { GF_DIMSScriptTypesBox *p = (GF_DIMSScriptTypesBox *)s; p->content_script_types = gf_malloc(sizeof(char) * (s->size+1)); if (!p->content_script_types) return GF_OUT_OF_MEM; gf_bs_read_data(bs, p->content_script_types, s->size); p->content_script_types[s->size] = 0; return GF_OK; }
0
244,010
GF_Box *leva_box_new() { ISOM_DECL_BOX_ALLOC(GF_LevelAssignmentBox, GF_ISOM_BOX_TYPE_LEVA); return (GF_Box *)tmp; }
0
439,153
static Image *ReadAVSImage(const ImageInfo *image_info,ExceptionInfo *exception) { Image *image; MagickBooleanType status; MemoryInfo *pixel_info; register PixelPacket *q; register ssize_t x; register unsigned char *p; size_t height, width; ssize_t count, y; unsigned char *pixels; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickCoreSignature); image=AcquireImage(image_info); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == MagickFalse) { image=DestroyImageList(image); return((Image *) NULL); } /* Read AVS X image. */ width=ReadBlobMSBLong(image); height=ReadBlobMSBLong(image); if (EOFBlob(image) != MagickFalse) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); if ((width == 0UL) || (height == 0UL)) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); do { ssize_t length; /* Convert AVS raster image to pixel packets. */ image->columns=width; image->rows=height; image->depth=8; if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) if (image->scene >= (image_info->scene+image_info->number_scenes-1)) break; status=SetImageExtent(image,image->columns,image->rows); if (status == MagickFalse) { InheritException(exception,&image->exception); return(DestroyImageList(image)); } pixel_info=AcquireVirtualMemory(image->columns,4*sizeof(*pixels)); if (pixel_info == (MemoryInfo *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info); length=(size_t) 4*image->columns; for (y=0; y < (ssize_t) image->rows; y++) { count=ReadBlob(image,length,pixels); if (count != length) { pixel_info=RelinquishVirtualMemory(pixel_info); ThrowReaderException(CorruptImageError,"UnableToReadImageData"); } p=pixels; q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) break; for (x=0; x < (ssize_t) image->columns; x++) { SetPixelAlpha(q,ScaleCharToQuantum(*p++)); SetPixelRed(q,ScaleCharToQuantum(*p++)); SetPixelGreen(q,ScaleCharToQuantum(*p++)); SetPixelBlue(q,ScaleCharToQuantum(*p++)); if (q->opacity != OpaqueOpacity) image->matte=MagickTrue; q++; } if (SyncAuthenticPixels(image,exception) == MagickFalse) break; if (image->previous == (Image *) NULL) { status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y, image->rows); if (status == MagickFalse) break; } } pixel_info=RelinquishVirtualMemory(pixel_info); if (EOFBlob(image) != MagickFalse) { ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", image->filename); break; } /* Proceed to next image. */ if (image_info->number_scenes != 0) if (image->scene >= (image_info->scene+image_info->number_scenes-1)) break; width=ReadBlobMSBLong(image); height=ReadBlobMSBLong(image); if ((width != 0UL) && (height != 0UL)) { /* Allocate next image structure. */ AcquireNextImage(image_info,image); if (GetNextImageInList(image) == (Image *) NULL) { status=MagickFalse; break; } image=SyncNextImageInList(image); status=SetImageProgress(image,LoadImagesTag,TellBlob(image), GetBlobSize(image)); if (status == MagickFalse) break; } } while ((width != 0UL) && (height != 0UL)); (void) CloseBlob(image); if (status == MagickFalse) return(DestroyImageList(image)); return(GetFirstImageInList(image)); }
0
313,727
nv_suspend(cmdarg_T *cap) { clearop(cap->oap); if (VIsual_active) end_visual_mode(); // stop Visual mode do_cmdline_cmd((char_u *)"stop"); }
0
333,045
check_char_class(int class, int c) { switch (class) { case NFA_CLASS_ALNUM: if (c >= 1 && c < 128 && isalnum(c)) return OK; break; case NFA_CLASS_ALPHA: if (c >= 1 && c < 128 && isalpha(c)) return OK; break; case NFA_CLASS_BLANK: if (c == ' ' || c == '\t') return OK; break; case NFA_CLASS_CNTRL: if (c >= 1 && c <= 127 && iscntrl(c)) return OK; break; case NFA_CLASS_DIGIT: if (VIM_ISDIGIT(c)) return OK; break; case NFA_CLASS_GRAPH: if (c >= 1 && c <= 127 && isgraph(c)) return OK; break; case NFA_CLASS_LOWER: if (MB_ISLOWER(c) && c != 170 && c != 186) return OK; break; case NFA_CLASS_PRINT: if (vim_isprintc(c)) return OK; break; case NFA_CLASS_PUNCT: if (c >= 1 && c < 128 && ispunct(c)) return OK; break; case NFA_CLASS_SPACE: if ((c >= 9 && c <= 13) || (c == ' ')) return OK; break; case NFA_CLASS_UPPER: if (MB_ISUPPER(c)) return OK; break; case NFA_CLASS_XDIGIT: if (vim_isxdigit(c)) return OK; break; case NFA_CLASS_TAB: if (c == '\t') return OK; break; case NFA_CLASS_RETURN: if (c == '\r') return OK; break; case NFA_CLASS_BACKSPACE: if (c == '\b') return OK; break; case NFA_CLASS_ESCAPE: if (c == '\033') return OK; break; case NFA_CLASS_IDENT: if (vim_isIDc(c)) return OK; break; case NFA_CLASS_KEYWORD: if (reg_iswordc(c)) return OK; break; case NFA_CLASS_FNAME: if (vim_isfilec(c)) return OK; break; default: // should not be here :P siemsg(_(e_ill_char_class), class); return FAIL; } return FAIL; }
0
364,768
findtags_state_init( findtags_state_T *st, char_u *pat, int flags, int mincount) { int mtt; st->tag_fname = alloc(MAXPATHL + 1); st->fp = NULL; st->orgpat = ALLOC_ONE(pat_T); st->orgpat->pat = pat; st->orgpat->len = (int)STRLEN(pat); st->orgpat->regmatch.regprog = NULL; st->flags = flags; st->tag_file_sorted = NUL; st->help_only = (flags & TAG_HELP); st->get_searchpat = FALSE; #ifdef FEAT_MULTI_LANG st->help_lang[0] = NUL; st->help_pri = 0; st->help_lang_find = NULL; st->is_txt = FALSE; #endif st->did_open = FALSE; st->mincount = mincount; st->lbuf_size = LSIZE; st->lbuf = alloc(st->lbuf_size); #ifdef FEAT_EMACS_TAGS st->ebuf = alloc(LSIZE); #endif st->match_count = 0; st->stop_searching = FALSE; for (mtt = 0; mtt < MT_COUNT; ++mtt) { ga_init2(&st->ga_match[mtt], sizeof(char_u *), 100); hash_init(&st->ht_match[mtt]); } // check for out of memory situation if (st->tag_fname == NULL || st->lbuf == NULL #ifdef FEAT_EMACS_TAGS || st->ebuf == NULL #endif ) return FAIL; return OK; }
0
505,461
static int chacha20_poly1305_tls_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, const unsigned char *in, size_t len) { EVP_CHACHA_AEAD_CTX *actx = aead_data(ctx); size_t tail, tohash_len, buf_len, plen = actx->tls_payload_length; unsigned char *buf, *tohash, *ctr, storage[sizeof(zero) + 32]; if (len != plen + POLY1305_BLOCK_SIZE) return -1; buf = storage + ((0 - (size_t)storage) & 15); /* align */ ctr = buf + CHACHA_BLK_SIZE; tohash = buf + CHACHA_BLK_SIZE - POLY1305_BLOCK_SIZE; # ifdef XOR128_HELPERS if (plen <= 3 * CHACHA_BLK_SIZE) { actx->key.counter[0] = 0; buf_len = (plen + 2 * CHACHA_BLK_SIZE - 1) & (0 - CHACHA_BLK_SIZE); ChaCha20_ctr32(buf, zero, buf_len, actx->key.key.d, actx->key.counter); Poly1305_Init(POLY1305_ctx(actx), buf); actx->key.partial_len = 0; memcpy(tohash, actx->tls_aad, POLY1305_BLOCK_SIZE); tohash_len = POLY1305_BLOCK_SIZE; actx->len.aad = EVP_AEAD_TLS1_AAD_LEN; actx->len.text = plen; if (plen) { if (ctx->encrypt) ctr = xor128_encrypt_n_pad(out, in, ctr, plen); else ctr = xor128_decrypt_n_pad(out, in, ctr, plen); in += plen; out += plen; tohash_len = (size_t)(ctr - tohash); } } # else if (plen <= CHACHA_BLK_SIZE) { size_t i; actx->key.counter[0] = 0; ChaCha20_ctr32(buf, zero, (buf_len = 2 * CHACHA_BLK_SIZE), actx->key.key.d, actx->key.counter); Poly1305_Init(POLY1305_ctx(actx), buf); actx->key.partial_len = 0; memcpy(tohash, actx->tls_aad, POLY1305_BLOCK_SIZE); tohash_len = POLY1305_BLOCK_SIZE; actx->len.aad = EVP_AEAD_TLS1_AAD_LEN; actx->len.text = plen; if (ctx->encrypt) { for (i = 0; i < plen; i++) { out[i] = ctr[i] ^= in[i]; } } else { for (i = 0; i < plen; i++) { unsigned char c = in[i]; out[i] = ctr[i] ^ c; ctr[i] = c; } } in += i; out += i; tail = (0 - i) & (POLY1305_BLOCK_SIZE - 1); memset(ctr + i, 0, tail); ctr += i + tail; tohash_len += i + tail; } # endif else { actx->key.counter[0] = 0; ChaCha20_ctr32(buf, zero, (buf_len = CHACHA_BLK_SIZE), actx->key.key.d, actx->key.counter); Poly1305_Init(POLY1305_ctx(actx), buf); actx->key.counter[0] = 1; actx->key.partial_len = 0; Poly1305_Update(POLY1305_ctx(actx), actx->tls_aad, POLY1305_BLOCK_SIZE); tohash = ctr; tohash_len = 0; actx->len.aad = EVP_AEAD_TLS1_AAD_LEN; actx->len.text = plen; if (ctx->encrypt) { ChaCha20_ctr32(out, in, plen, actx->key.key.d, actx->key.counter); Poly1305_Update(POLY1305_ctx(actx), out, plen); } else { Poly1305_Update(POLY1305_ctx(actx), in, plen); ChaCha20_ctr32(out, in, plen, actx->key.key.d, actx->key.counter); } in += plen; out += plen; tail = (0 - plen) & (POLY1305_BLOCK_SIZE - 1); Poly1305_Update(POLY1305_ctx(actx), zero, tail); } { const union { long one; char little; } is_endian = { 1 }; if (is_endian.little) { memcpy(ctr, (unsigned char *)&actx->len, POLY1305_BLOCK_SIZE); } else { ctr[0] = (unsigned char)(actx->len.aad); ctr[1] = (unsigned char)(actx->len.aad>>8); ctr[2] = (unsigned char)(actx->len.aad>>16); ctr[3] = (unsigned char)(actx->len.aad>>24); ctr[4] = (unsigned char)(actx->len.aad>>32); ctr[5] = (unsigned char)(actx->len.aad>>40); ctr[6] = (unsigned char)(actx->len.aad>>48); ctr[7] = (unsigned char)(actx->len.aad>>56); ctr[8] = (unsigned char)(actx->len.text); ctr[9] = (unsigned char)(actx->len.text>>8); ctr[10] = (unsigned char)(actx->len.text>>16); ctr[11] = (unsigned char)(actx->len.text>>24); ctr[12] = (unsigned char)(actx->len.text>>32); ctr[13] = (unsigned char)(actx->len.text>>40); ctr[14] = (unsigned char)(actx->len.text>>48); ctr[15] = (unsigned char)(actx->len.text>>56); } tohash_len += POLY1305_BLOCK_SIZE; } Poly1305_Update(POLY1305_ctx(actx), tohash, tohash_len); OPENSSL_cleanse(buf, buf_len); Poly1305_Final(POLY1305_ctx(actx), ctx->encrypt ? actx->tag : tohash); actx->tls_payload_length = NO_TLS_PAYLOAD_LENGTH; if (ctx->encrypt) { memcpy(out, actx->tag, POLY1305_BLOCK_SIZE); } else { if (CRYPTO_memcmp(tohash, in, POLY1305_BLOCK_SIZE)) { memset(out - (len - POLY1305_BLOCK_SIZE), 0, len - POLY1305_BLOCK_SIZE); return -1; } } return len; }
0
244,255
GF_Err fiin_box_read(GF_Box *s, GF_BitStream *bs) { FDItemInformationBox *ptr = (FDItemInformationBox *)s; ISOM_DECREASE_SIZE(ptr, 2); gf_bs_read_u16(bs); return gf_isom_box_array_read(s, bs); }
0
221,520
flatpak_ensure_data_dir (GFile *app_id_dir, GCancellable *cancellable, GError **error) { g_autoptr(GFile) data_dir = g_file_get_child (app_id_dir, "data"); g_autoptr(GFile) cache_dir = g_file_get_child (app_id_dir, "cache"); g_autoptr(GFile) fontconfig_cache_dir = g_file_get_child (cache_dir, "fontconfig"); g_autoptr(GFile) tmp_dir = g_file_get_child (cache_dir, "tmp"); g_autoptr(GFile) config_dir = g_file_get_child (app_id_dir, "config"); if (!flatpak_mkdir_p (data_dir, cancellable, error)) return FALSE; if (!flatpak_mkdir_p (cache_dir, cancellable, error)) return FALSE; if (!flatpak_mkdir_p (fontconfig_cache_dir, cancellable, error)) return FALSE; if (!flatpak_mkdir_p (tmp_dir, cancellable, error)) return FALSE; if (!flatpak_mkdir_p (config_dir, cancellable, error)) return FALSE; return TRUE; }
0
427,789
void sev_free_vcpu(struct kvm_vcpu *vcpu) { struct vcpu_svm *svm; if (!sev_es_guest(vcpu->kvm)) return; svm = to_svm(vcpu); if (vcpu->arch.guest_state_protected) sev_flush_guest_memory(svm, svm->vmsa, PAGE_SIZE); __free_page(virt_to_page(svm->vmsa)); if (svm->ghcb_sa_free) kfree(svm->ghcb_sa); }
0
336,127
static int ip6gre_rcv(struct sk_buff *skb, const struct tnl_ptk_info *tpi) { const struct ipv6hdr *ipv6h; struct ip6_tnl *tunnel; ipv6h = ipv6_hdr(skb); tunnel = ip6gre_tunnel_lookup(skb->dev, &ipv6h->saddr, &ipv6h->daddr, tpi->key, tpi->proto); if (tunnel) { ip6_tnl_rcv(tunnel, skb, tpi, NULL, false); return PACKET_RCVD; } return PACKET_REJECT; }
0
238,636
static int check_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn) { const struct btf_type *t, *func, *func_proto, *ptr_type; struct bpf_reg_state *regs = cur_regs(env); const char *func_name, *ptr_type_name; u32 i, nargs, func_id, ptr_type_id; struct module *btf_mod = NULL; const struct btf_param *args; struct btf *desc_btf; int err; /* skip for now, but return error when we find this in fixup_kfunc_call */ if (!insn->imm) return 0; desc_btf = find_kfunc_desc_btf(env, insn->imm, insn->off, &btf_mod); if (IS_ERR(desc_btf)) return PTR_ERR(desc_btf); func_id = insn->imm; func = btf_type_by_id(desc_btf, func_id); func_name = btf_name_by_offset(desc_btf, func->name_off); func_proto = btf_type_by_id(desc_btf, func->type); if (!env->ops->check_kfunc_call || !env->ops->check_kfunc_call(func_id, btf_mod)) { verbose(env, "calling kernel function %s is not allowed\n", func_name); return -EACCES; } /* Check the arguments */ err = btf_check_kfunc_arg_match(env, desc_btf, func_id, regs); if (err) return err; for (i = 0; i < CALLER_SAVED_REGS; i++) mark_reg_not_init(env, regs, caller_saved[i]); /* Check return type */ t = btf_type_skip_modifiers(desc_btf, func_proto->type, NULL); if (btf_type_is_scalar(t)) { mark_reg_unknown(env, regs, BPF_REG_0); mark_btf_func_reg_size(env, BPF_REG_0, t->size); } else if (btf_type_is_ptr(t)) { ptr_type = btf_type_skip_modifiers(desc_btf, t->type, &ptr_type_id); if (!btf_type_is_struct(ptr_type)) { ptr_type_name = btf_name_by_offset(desc_btf, ptr_type->name_off); verbose(env, "kernel function %s returns pointer type %s %s is not supported\n", func_name, btf_type_str(ptr_type), ptr_type_name); return -EINVAL; } mark_reg_known_zero(env, regs, BPF_REG_0); regs[BPF_REG_0].btf = desc_btf; regs[BPF_REG_0].type = PTR_TO_BTF_ID; regs[BPF_REG_0].btf_id = ptr_type_id; mark_btf_func_reg_size(env, BPF_REG_0, sizeof(void *)); } /* else { add_kfunc_call() ensures it is btf_type_is_void(t) } */ nargs = btf_type_vlen(func_proto); args = (const struct btf_param *)(func_proto + 1); for (i = 0; i < nargs; i++) { u32 regno = i + 1; t = btf_type_skip_modifiers(desc_btf, args[i].type, NULL); if (btf_type_is_ptr(t)) mark_btf_func_reg_size(env, regno, sizeof(void *)); else /* scalar. ensured by btf_check_kfunc_arg_match() */ mark_btf_func_reg_size(env, regno, t->size); } return 0; }
0
251,515
static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception) { #define ThrowDCMException(exception,message) \ { \ RelinquishDCMMemory(&info,&map,stream_info,stack,data); \ if (info_copy != (DCMInfo *) NULL) \ info_copy=(DCMInfo *) RelinquishDCMInfo(info_copy); \ ThrowReaderException((exception),(message)); \ } char explicit_vr[MagickPathExtent], implicit_vr[MagickPathExtent], magick[MagickPathExtent], photometric[MagickPathExtent]; DCMInfo info, *info_copy = (DCMInfo *) NULL; DCMMap map; DCMStreamInfo *stream_info; Image *image; int datum; LinkedListInfo *stack; MagickBooleanType explicit_file, explicit_retry, use_explicit; MagickOffsetType blob_size, offset; unsigned char *p; ssize_t i; size_t colors, length, number_scenes, quantum, status; ssize_t count, scene, sequence_depth; unsigned char *data; unsigned short group, element; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickCoreSignature); image=AcquireImage(image_info,exception); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == MagickFalse) { image=DestroyImageList(image); return((Image *) NULL); } image->depth=8UL; image->endian=LSBEndian; /* Read DCM preamble. */ (void) memset(&info,0,sizeof(info)); (void) memset(&map,0,sizeof(map)); data=(unsigned char *) NULL; stream_info=(DCMStreamInfo *) AcquireMagickMemory(sizeof(*stream_info)); sequence_depth=0; stack=NewLinkedList(256); if (stream_info == (DCMStreamInfo *) NULL) ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed") (void) memset(stream_info,0,sizeof(*stream_info)); count=ReadBlob(image,128,(unsigned char *) magick); if (count != 128) ThrowDCMException(CorruptImageError,"ImproperImageHeader") count=ReadBlob(image,4,(unsigned char *) magick); if ((count != 4) || (LocaleNCompare(magick,"DICM",4) != 0)) { offset=SeekBlob(image,0L,SEEK_SET); if (offset < 0) ThrowDCMException(CorruptImageError,"ImproperImageHeader") } /* Read DCM Medical image. */ (void) CopyMagickString(photometric,"MONOCHROME1 ",MagickPathExtent); info.bits_allocated=8; info.bytes_per_pixel=1; info.depth=8; info.mask=0xffff; info.max_value=255UL; info.samples_per_pixel=1; info.signed_data=(~0UL); info.rescale_slope=1.0; element=0; explicit_vr[2]='\0'; explicit_file=MagickFalse; colors=0; number_scenes=1; use_explicit=MagickFalse; explicit_retry=MagickFalse; blob_size=(MagickOffsetType) GetBlobSize(image); while (TellBlob(image) < blob_size) { for (group=0; (group != 0x7FE0) || (element != 0x0010) ; ) { /* Read a group. */ image->offset=(ssize_t) TellBlob(image); group=ReadBlobLSBShort(image); element=ReadBlobLSBShort(image); if ((group == 0xfffc) && (element == 0xfffc)) break; if ((group != 0x0002) && (image->endian == MSBEndian)) { group=(unsigned short) ((group << 8) | ((group >> 8) & 0xFF)); element=(unsigned short) ((element << 8) | ((element >> 8) & 0xFF)); } quantum=0; /* Find corresponding VR for this group and element. */ for (i=0; dicom_info[i].group < 0xffff; i++) if ((group == dicom_info[i].group) && (element == dicom_info[i].element)) break; (void) CopyMagickString(implicit_vr,dicom_info[i].vr,MagickPathExtent); count=ReadBlob(image,2,(unsigned char *) explicit_vr); if (count != 2) ThrowDCMException(CorruptImageError,"ImproperImageHeader") /* Check for "explicitness", but meta-file headers always explicit. */ if ((explicit_file == MagickFalse) && (group != 0x0002)) explicit_file=(isupper((int) ((unsigned char) *explicit_vr)) != 0) && (isupper((int) ((unsigned char) *(explicit_vr+1))) != 0) ? MagickTrue : MagickFalse; use_explicit=((group == 0x0002) && (explicit_retry == MagickFalse)) || (explicit_file != MagickFalse) ? MagickTrue : MagickFalse; if ((use_explicit != MagickFalse) && (strncmp(implicit_vr,"xs",2) == 0)) (void) CopyMagickString(implicit_vr,explicit_vr,MagickPathExtent); if ((use_explicit == MagickFalse) || (strncmp(implicit_vr,"!!",2) == 0)) { offset=SeekBlob(image,(MagickOffsetType) -2,SEEK_CUR); if (offset < 0) ThrowDCMException(CorruptImageError,"ImproperImageHeader") quantum=4; } else { /* Assume explicit type. */ quantum=2; if ((strcmp(explicit_vr,"OB") == 0) || (strcmp(explicit_vr,"OW") == 0) || (strcmp(explicit_vr,"OF") == 0) || (strcmp(explicit_vr,"SQ") == 0) || (strcmp(explicit_vr,"UN") == 0) || (strcmp(explicit_vr,"UT") == 0)) { (void) ReadBlobLSBShort(image); quantum=4; } } if ((group == 0xFFFE) && (element == 0xE0DD)) { /* If we're exiting a sequence, restore the previous image parameters, effectively undoing any parameter changes that happened inside the sequence. */ sequence_depth--; info_copy=(DCMInfo *) RemoveLastElementFromLinkedList(stack); if (info_copy == (DCMInfo *)NULL) { /* The sequence's entry and exit points don't line up (tried to exit one more sequence than we entered). */ ThrowDCMException(CorruptImageError,"ImproperImageHeader") } if (info.scale != (Quantum *) NULL) info.scale=(Quantum *) RelinquishMagickMemory(info.scale); (void) memcpy(&info,info_copy,sizeof(info)); info_copy=(DCMInfo *) RelinquishMagickMemory(info_copy); } if (strcmp(explicit_vr,"SQ") == 0) { /* If we're entering a sequence, push the current image parameters onto the stack, so we can restore them at the end of the sequence. */ DCMInfo *clone_info = (DCMInfo *) AcquireMagickMemory(sizeof(info)); if (clone_info == (DCMInfo *) NULL) ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed") (void) memcpy(clone_info,&info,sizeof(info)); clone_info->scale=(Quantum *) AcquireQuantumMemory( clone_info->scale_size+1,sizeof(*clone_info->scale)); if (clone_info->scale == (Quantum *) NULL) ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed") (void) memcpy(clone_info->scale,info.scale,clone_info->scale_size* sizeof(*clone_info->scale)); AppendValueToLinkedList(stack,clone_info); sequence_depth++; } datum=0; if (quantum == 4) { if (group == 0x0002) datum=ReadBlobLSBSignedLong(image); else datum=ReadBlobSignedLong(image); } else if (quantum == 2) { if (group == 0x0002) datum=ReadBlobLSBSignedShort(image); else datum=ReadBlobSignedShort(image); } quantum=0; length=1; if (datum != 0) { if ((strncmp(implicit_vr,"OW",2) == 0) || (strncmp(implicit_vr,"SS",2) == 0) || (strncmp(implicit_vr,"US",2) == 0)) quantum=2; else if ((strncmp(implicit_vr,"FL",2) == 0) || (strncmp(implicit_vr,"OF",2) == 0) || (strncmp(implicit_vr,"SL",2) == 0) || (strncmp(implicit_vr,"UL",2) == 0)) quantum=4; else if (strncmp(implicit_vr,"FD",2) == 0) quantum=8; else quantum=1; if (datum != ~0) length=(size_t) datum/quantum; else { /* Sequence and item of undefined length. */ quantum=0; length=0; } } if (image_info->verbose != MagickFalse) { /* Display Dicom info. */ if (use_explicit == MagickFalse) explicit_vr[0]='\0'; for (i=0; dicom_info[i].description != (char *) NULL; i++) if ((group == dicom_info[i].group) && (element == dicom_info[i].element)) break; (void) FormatLocaleFile(stdout, "0x%04lX %4ld S%ld %s-%s (0x%04lx,0x%04lx)", (unsigned long) image->offset,(long) length,(long) sequence_depth, implicit_vr,explicit_vr,(unsigned long) group, (unsigned long) element); if (dicom_info[i].description != (char *) NULL) (void) FormatLocaleFile(stdout," %s",dicom_info[i].description); (void) FormatLocaleFile(stdout,": "); } if ((group == 0x7FE0) && (element == 0x0010)) { if (image_info->verbose != MagickFalse) (void) FormatLocaleFile(stdout,"\n"); break; } /* Allocate space and read an array. */ data=(unsigned char *) NULL; if ((length == 1) && (quantum == 1)) datum=ReadBlobByte(image); else if ((length == 1) && (quantum == 2)) { if (group == 0x0002) datum=ReadBlobLSBSignedShort(image); else datum=ReadBlobSignedShort(image); } else if ((length == 1) && (quantum == 4)) { if (group == 0x0002) datum=ReadBlobLSBSignedLong(image); else datum=ReadBlobSignedLong(image); } else if ((quantum != 0) && (length != 0)) { if (length > (size_t) GetBlobSize(image)) ThrowDCMException(CorruptImageError, "InsufficientImageDataInFile") if (~length >= 1) data=(unsigned char *) AcquireQuantumMemory(length+1,quantum* sizeof(*data)); if (data == (unsigned char *) NULL) ThrowDCMException(ResourceLimitError, "MemoryAllocationFailed") count=ReadBlob(image,(size_t) quantum*length,data); if (count != (ssize_t) (quantum*length)) { if (image_info->verbose != MagickFalse) (void) FormatLocaleFile(stdout,"count=%d quantum=%d " "length=%d group=%d\n",(int) count,(int) quantum,(int) length,(int) group); ThrowDCMException(CorruptImageError, "InsufficientImageDataInFile") } data[length*quantum]='\0'; } if ((((unsigned int) group << 16) | element) == 0xFFFEE0DD) { if (data != (unsigned char *) NULL) data=(unsigned char *) RelinquishMagickMemory(data); continue; } switch (group) { case 0x0002: { switch (element) { case 0x0010: { char transfer_syntax[MagickPathExtent]; /* Transfer Syntax. */ if ((datum == 0) && (explicit_retry == MagickFalse)) { explicit_retry=MagickTrue; (void) SeekBlob(image,(MagickOffsetType) 0,SEEK_SET); group=0; element=0; if (image_info->verbose != MagickFalse) (void) FormatLocaleFile(stdout, "Corrupted image - trying explicit format\n"); break; } *transfer_syntax='\0'; if (data != (unsigned char *) NULL) (void) CopyMagickString(transfer_syntax,(char *) data, MagickPathExtent); if (image_info->verbose != MagickFalse) (void) FormatLocaleFile(stdout,"transfer_syntax=%s\n", (const char *) transfer_syntax); if (strncmp(transfer_syntax,"1.2.840.10008.1.2",17) == 0) { int subtype, type; type=1; subtype=0; if (strlen(transfer_syntax) > 17) { count=(ssize_t) sscanf(transfer_syntax+17,".%d.%d",&type, &subtype); if (count < 1) ThrowDCMException(CorruptImageError, "ImproperImageHeader") } switch (type) { case 1: { image->endian=LSBEndian; break; } case 2: { image->endian=MSBEndian; break; } case 4: { if ((subtype >= 80) && (subtype <= 81)) image->compression=JPEGCompression; else if ((subtype >= 90) && (subtype <= 93)) image->compression=JPEG2000Compression; else image->compression=JPEGCompression; break; } case 5: { image->compression=RLECompression; break; } } } break; } default: break; } break; } case 0x0028: { switch (element) { case 0x0002: { /* Samples per pixel. */ info.samples_per_pixel=(size_t) datum; if ((info.samples_per_pixel == 0) || (info.samples_per_pixel > 4)) ThrowDCMException(CorruptImageError,"ImproperImageHeader") break; } case 0x0004: { /* Photometric interpretation. */ if (data == (unsigned char *) NULL) break; for (i=0; i < (ssize_t) MagickMin(length,MagickPathExtent-1); i++) photometric[i]=(char) data[i]; photometric[i]='\0'; info.polarity=LocaleCompare(photometric,"MONOCHROME1 ") == 0 ? MagickTrue : MagickFalse; break; } case 0x0006: { /* Planar configuration. */ if (datum == 1) image->interlace=PlaneInterlace; break; } case 0x0008: { /* Number of frames. */ if (data == (unsigned char *) NULL) break; number_scenes=StringToUnsignedLong((char *) data); break; } case 0x0010: { /* Image rows. */ info.height=(size_t) datum; break; } case 0x0011: { /* Image columns. */ info.width=(size_t) datum; break; } case 0x0100: { /* Bits allocated. */ info.bits_allocated=(size_t) datum; info.bytes_per_pixel=1; if (datum > 8) info.bytes_per_pixel=2; info.depth=info.bits_allocated; if ((info.depth == 0) || (info.depth > 32)) ThrowDCMException(CorruptImageError,"ImproperImageHeader") info.max_value=(1UL << info.bits_allocated)-1; image->depth=info.depth; break; } case 0x0101: { /* Bits stored. */ info.significant_bits=(size_t) datum; info.bytes_per_pixel=1; if (info.significant_bits > 8) info.bytes_per_pixel=2; info.depth=info.significant_bits; if ((info.depth == 0) || (info.depth > 16)) ThrowDCMException(CorruptImageError,"ImproperImageHeader") info.max_value=(1UL << info.significant_bits)-1; info.mask=(size_t) GetQuantumRange(info.significant_bits); image->depth=info.depth; break; } case 0x0102: { /* High bit. */ break; } case 0x0103: { /* Pixel representation. */ info.signed_data=(size_t) datum; break; } case 0x1050: { /* Visible pixel range: center. */ if (data != (unsigned char *) NULL) info.window_center=StringToDouble((char *) data,(char **) NULL); break; } case 0x1051: { /* Visible pixel range: width. */ if (data != (unsigned char *) NULL) info.window_width=StringToDouble((char *) data,(char **) NULL); break; } case 0x1052: { /* Rescale intercept */ if (data != (unsigned char *) NULL) info.rescale_intercept=StringToDouble((char *) data, (char **) NULL); break; } case 0x1053: { /* Rescale slope */ if (data != (unsigned char *) NULL) info.rescale_slope=StringToDouble((char *) data,(char **) NULL); break; } case 0x1200: case 0x3006: { /* Populate graymap. */ if (data == (unsigned char *) NULL) break; colors=(size_t) (length/info.bytes_per_pixel); datum=(int) colors; if (map.gray != (int *) NULL) map.gray=(int *) RelinquishMagickMemory(map.gray); map.gray=(int *) AcquireQuantumMemory(MagickMax(colors,65536), sizeof(*map.gray)); if (map.gray == (int *) NULL) ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed") (void) memset(map.gray,0,MagickMax(colors,65536)* sizeof(*map.gray)); for (i=0; i < (ssize_t) colors; i++) if (info.bytes_per_pixel == 1) map.gray[i]=(int) data[i]; else map.gray[i]=(int) ((short *) data)[i]; break; } case 0x1201: { unsigned short index; /* Populate redmap. */ if (data == (unsigned char *) NULL) break; colors=(size_t) (length/info.bytes_per_pixel); datum=(int) colors; if (map.red != (int *) NULL) map.red=(int *) RelinquishMagickMemory(map.red); map.red=(int *) AcquireQuantumMemory(MagickMax(colors,65536), sizeof(*map.red)); if (map.red == (int *) NULL) ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed") (void) memset(map.red,0,MagickMax(colors,65536)* sizeof(*map.red)); p=data; for (i=0; i < (ssize_t) colors; i++) { if (image->endian == MSBEndian) index=(unsigned short) ((*p << 8) | *(p+1)); else index=(unsigned short) (*p | (*(p+1) << 8)); map.red[i]=(int) index; p+=2; } break; } case 0x1202: { unsigned short index; /* Populate greenmap. */ if (data == (unsigned char *) NULL) break; colors=(size_t) (length/info.bytes_per_pixel); datum=(int) colors; if (map.green != (int *) NULL) map.green=(int *) RelinquishMagickMemory(map.green); map.green=(int *) AcquireQuantumMemory(MagickMax(colors,65536), sizeof(*map.green)); if (map.green == (int *) NULL) ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed") (void) memset(map.green,0,MagickMax(colors,65536)* sizeof(*map.green)); p=data; for (i=0; i < (ssize_t) colors; i++) { if (image->endian == MSBEndian) index=(unsigned short) ((*p << 8) | *(p+1)); else index=(unsigned short) (*p | (*(p+1) << 8)); map.green[i]=(int) index; p+=2; } break; } case 0x1203: { unsigned short index; /* Populate bluemap. */ if (data == (unsigned char *) NULL) break; colors=(size_t) (length/info.bytes_per_pixel); datum=(int) colors; if (map.blue != (int *) NULL) map.blue=(int *) RelinquishMagickMemory(map.blue); map.blue=(int *) AcquireQuantumMemory(MagickMax(colors,65536), sizeof(*map.blue)); if (map.blue == (int *) NULL) ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed") (void) memset(map.blue,0,MagickMax(colors,65536)* sizeof(*map.blue)); p=data; for (i=0; i < (ssize_t) colors; i++) { if (image->endian == MSBEndian) index=(unsigned short) ((*p << 8) | *(p+1)); else index=(unsigned short) (*p | (*(p+1) << 8)); map.blue[i]=(int) index; p+=2; } break; } default: break; } break; } case 0x2050: { switch (element) { case 0x0020: { if ((data != (unsigned char *) NULL) && (strncmp((char *) data,"INVERSE",7) == 0)) info.polarity=MagickTrue; break; } default: break; } break; } default: break; } if (data != (unsigned char *) NULL) { char *attribute; for (i=0; dicom_info[i].description != (char *) NULL; i++) if ((group == dicom_info[i].group) && (element == dicom_info[i].element)) break; if (dicom_info[i].description != (char *) NULL) { attribute=AcquireString("dcm:"); (void) ConcatenateString(&attribute,dicom_info[i].description); for (i=0; i < (ssize_t) MagickMax(length,4); i++) if (isprint((int) data[i]) == 0) break; if ((i == (ssize_t) length) || (length > 4)) { (void) SubstituteString(&attribute," ",""); (void) SetImageProperty(image,attribute,(char *) data, exception); } attribute=DestroyString(attribute); } } if (image_info->verbose != MagickFalse) { if (data == (unsigned char *) NULL) (void) FormatLocaleFile(stdout,"%d\n",datum); else { /* Display group data. */ for (i=0; i < (ssize_t) MagickMax(length,4); i++) if (isprint((int) data[i]) == 0) break; if ((i != (ssize_t) length) && (length <= 4)) { ssize_t j; datum=0; for (j=(ssize_t) length-1; j >= 0; j--) datum=(256*datum+data[j]); (void) FormatLocaleFile(stdout,"%d",datum); } else for (i=0; i < (ssize_t) length; i++) if (isprint((int) data[i]) != 0) (void) FormatLocaleFile(stdout,"%c",data[i]); else (void) FormatLocaleFile(stdout,"%c",'.'); (void) FormatLocaleFile(stdout,"\n"); } } if (data != (unsigned char *) NULL) data=(unsigned char *) RelinquishMagickMemory(data); if (EOFBlob(image) != MagickFalse) { ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", image->filename); group=0xfffc; break; } } if ((group == 0xfffc) && (element == 0xfffc)) { Image *last; last=RemoveLastImageFromList(&image); if (last != (Image *) NULL) last=DestroyImage(last); break; } if ((info.width == 0) || (info.height == 0)) ThrowDCMException(CorruptImageError,"ImproperImageHeader") image->columns=info.width; image->rows=info.height; if (info.signed_data == 0xffff) info.signed_data=(size_t) (info.significant_bits == 16 ? 1 : 0); if ((image->compression == JPEGCompression) || (image->compression == JPEG2000Compression)) { Image *images; ImageInfo *read_info; int c; /* Read offset table. */ for (i=0; i < (ssize_t) stream_info->remaining; i++) if (ReadBlobByte(image) == EOF) break; (void) (((ssize_t) ReadBlobLSBShort(image) << 16) | ReadBlobLSBShort(image)); length=(size_t) ReadBlobLSBLong(image); if (length > (size_t) GetBlobSize(image)) ThrowDCMException(CorruptImageError,"InsufficientImageDataInFile") stream_info->offset_count=length >> 2; if (stream_info->offset_count != 0) { if (stream_info->offsets != (ssize_t *) NULL) stream_info->offsets=(ssize_t *) RelinquishMagickMemory( stream_info->offsets); stream_info->offsets=(ssize_t *) AcquireQuantumMemory( stream_info->offset_count,sizeof(*stream_info->offsets)); if (stream_info->offsets == (ssize_t *) NULL) ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed") for (i=0; i < (ssize_t) stream_info->offset_count; i++) stream_info->offsets[i]=(ssize_t) ReadBlobLSBSignedLong(image); offset=TellBlob(image); for (i=0; i < (ssize_t) stream_info->offset_count; i++) stream_info->offsets[i]+=offset; } /* Handle non-native image formats. */ read_info=CloneImageInfo(image_info); SetImageInfoBlob(read_info,(void *) NULL,0); images=NewImageList(); for (scene=0; scene < (ssize_t) number_scenes; scene++) { char filename[MagickPathExtent]; const char *property; FILE *file; Image *jpeg_image; int unique_file; unsigned int tag; tag=((unsigned int) ReadBlobLSBShort(image) << 16) | ReadBlobLSBShort(image); length=(size_t) ReadBlobLSBLong(image); if (length > (size_t) GetBlobSize(image)) { images=DestroyImageList(images); read_info=DestroyImageInfo(read_info); ThrowDCMException(CorruptImageError,"InsufficientImageDataInFile") } if (EOFBlob(image) != MagickFalse) { status=MagickFalse; break; } if (tag == 0xFFFEE0DD) break; /* sequence delimiter tag */ if (tag != 0xFFFEE000) { status=MagickFalse; break; } file=(FILE *) NULL; unique_file=AcquireUniqueFileResource(filename); if (unique_file != -1) file=fdopen(unique_file,"wb"); if (file == (FILE *) NULL) { (void) RelinquishUniqueFileResource(filename); ThrowFileException(exception,FileOpenError, "UnableToCreateTemporaryFile",filename); break; } for (c=EOF; length != 0; length--) { c=ReadBlobByte(image); if (c == EOF) { ThrowFileException(exception,CorruptImageError, "UnexpectedEndOfFile",image->filename); break; } if (fputc(c,file) != c) break; } (void) fclose(file); if (c == EOF) break; (void) FormatLocaleString(read_info->filename,MagickPathExtent, "jpeg:%s",filename); if (image->compression == JPEG2000Compression) (void) FormatLocaleString(read_info->filename,MagickPathExtent, "j2k:%s",filename); jpeg_image=ReadImage(read_info,exception); if (jpeg_image != (Image *) NULL) { ResetImagePropertyIterator(image); property=GetNextImageProperty(image); while (property != (const char *) NULL) { (void) SetImageProperty(jpeg_image,property, GetImageProperty(image,property,exception),exception); property=GetNextImageProperty(image); } AppendImageToList(&images,jpeg_image); } (void) RelinquishUniqueFileResource(filename); } read_info=DestroyImageInfo(read_info); image=DestroyImageList(image); if ((status == MagickFalse) && (exception->severity < ErrorException)) { images=DestroyImageList(images); ThrowDCMException(CorruptImageError,"CorruptImageError") } else RelinquishDCMMemory(&info,&map,stream_info,stack,data); return(GetFirstImageInList(images)); } if (info.depth != (1UL*MAGICKCORE_QUANTUM_DEPTH)) { QuantumAny range; /* Compute pixel scaling table. */ length=(size_t) (GetQuantumRange(info.depth)+1); if (length > (size_t) GetBlobSize(image)) ThrowDCMException(CorruptImageError,"InsufficientImageDataInFile") if (info.scale != (Quantum *) NULL) info.scale=(Quantum *) RelinquishMagickMemory(info.scale); info.scale_size=MagickMax(length,MaxMap)+1; info.scale=(Quantum *) AcquireQuantumMemory(info.scale_size, sizeof(*info.scale)); if (info.scale == (Quantum *) NULL) ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed") (void) memset(info.scale,0,(MagickMax(length,MaxMap)+1)* sizeof(*info.scale)); range=GetQuantumRange(info.depth); for (i=0; i <= (ssize_t) GetQuantumRange(info.depth); i++) info.scale[i]=ScaleAnyToQuantum((size_t) i,range); } if (image->compression == RLECompression) { unsigned int tag; /* Read RLE offset table. */ for (i=0; i < (ssize_t) stream_info->remaining; i++) { int c; c=ReadBlobByte(image); if (c == EOF) break; } tag=((unsigned int) ReadBlobLSBShort(image) << 16) | ReadBlobLSBShort(image); (void) tag; length=(size_t) ReadBlobLSBLong(image); if (length > (size_t) GetBlobSize(image)) ThrowDCMException(CorruptImageError,"InsufficientImageDataInFile") stream_info->offset_count=length >> 2; if (stream_info->offset_count != 0) { if (stream_info->offsets != (ssize_t *) NULL) stream_info->offsets=(ssize_t *) RelinquishMagickMemory(stream_info->offsets); stream_info->offsets=(ssize_t *) AcquireQuantumMemory( stream_info->offset_count,sizeof(*stream_info->offsets)); if (stream_info->offsets == (ssize_t *) NULL) ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed") for (i=0; i < (ssize_t) stream_info->offset_count; i++) { offset=(MagickOffsetType) ReadBlobLSBSignedLong(image); if (offset > (MagickOffsetType) GetBlobSize(image)) ThrowDCMException(CorruptImageError, "InsufficientImageDataInFile") stream_info->offsets[i]=(ssize_t) offset; if (EOFBlob(image) != MagickFalse) break; } offset=TellBlob(image)+8; for (i=0; i < (ssize_t) stream_info->offset_count; i++) stream_info->offsets[i]+=offset; } } for (scene=0; scene < (ssize_t) number_scenes; scene++) { image->columns=info.width; image->rows=info.height; image->depth=info.depth; status=SetImageExtent(image,image->columns,image->rows,exception); if (status == MagickFalse) break; image->colorspace=RGBColorspace; (void) SetImageBackgroundColor(image,exception); if ((image->colormap == (PixelInfo *) NULL) && (info.samples_per_pixel == 1)) { int index; size_t one; one=1; if (colors == 0) colors=one << info.depth; if (AcquireImageColormap(image,colors,exception) == MagickFalse) ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed") if (map.red != (int *) NULL) for (i=0; i < (ssize_t) colors; i++) { index=map.red[i]; if ((info.scale != (Quantum *) NULL) && (index >= 0) && (index <= (int) info.max_value)) index=(int) info.scale[index]; image->colormap[i].red=(MagickRealType) index; } if (map.green != (int *) NULL) for (i=0; i < (ssize_t) colors; i++) { index=map.green[i]; if ((info.scale != (Quantum *) NULL) && (index >= 0) && (index <= (int) info.max_value)) index=(int) info.scale[index]; image->colormap[i].green=(MagickRealType) index; } if (map.blue != (int *) NULL) for (i=0; i < (ssize_t) colors; i++) { index=map.blue[i]; if ((info.scale != (Quantum *) NULL) && (index >= 0) && (index <= (int) info.max_value)) index=(int) info.scale[index]; image->colormap[i].blue=(MagickRealType) index; } if (map.gray != (int *) NULL) for (i=0; i < (ssize_t) colors; i++) { index=map.gray[i]; if ((info.scale != (Quantum *) NULL) && (index >= 0) && (index <= (int) info.max_value)) index=(int) info.scale[index]; image->colormap[i].red=(MagickRealType) index; image->colormap[i].green=(MagickRealType) index; image->colormap[i].blue=(MagickRealType) index; } } if (image->compression == RLECompression) { unsigned int tag; /* Read RLE segment table. */ for (i=0; i < (ssize_t) stream_info->remaining; i++) { int c; c=ReadBlobByte(image); if (c == EOF) break; } tag=((unsigned int) ReadBlobLSBShort(image) << 16) | ReadBlobLSBShort(image); stream_info->remaining=(size_t) ReadBlobLSBLong(image); if ((tag != 0xFFFEE000) || (stream_info->remaining <= 64) || (EOFBlob(image) != MagickFalse)) { if (stream_info->offsets != (ssize_t *) NULL) stream_info->offsets=(ssize_t *) RelinquishMagickMemory(stream_info->offsets); ThrowDCMException(CorruptImageError,"ImproperImageHeader") } stream_info->count=0; stream_info->segment_count=ReadBlobLSBLong(image); for (i=0; i < 15; i++) stream_info->segments[i]=(ssize_t) ReadBlobLSBSignedLong(image); stream_info->remaining-=64; if (stream_info->segment_count > 1) { info.bytes_per_pixel=1; info.depth=8; if (stream_info->offset_count > 0) (void) SeekBlob(image,(MagickOffsetType) stream_info->offsets[0]+stream_info->segments[0],SEEK_SET); } } if ((info.samples_per_pixel > 1) && (image->interlace == PlaneInterlace)) { Quantum *q; ssize_t x, y; /* Convert Planar RGB DCM Medical image to pixel packets. */ for (i=0; i < (ssize_t) info.samples_per_pixel; i++) { for (y=0; y < (ssize_t) image->rows; y++) { q=GetAuthenticPixels(image,0,y,image->columns,1,exception); if (q == (Quantum *) NULL) break; for (x=0; x < (ssize_t) image->columns; x++) { switch ((int) i) { case 0: { SetPixelRed(image,ScaleCharToQuantum((unsigned char) ReadDCMByte(stream_info,image)),q); break; } case 1: { SetPixelGreen(image,ScaleCharToQuantum((unsigned char) ReadDCMByte(stream_info,image)),q); break; } case 2: { SetPixelBlue(image,ScaleCharToQuantum((unsigned char) ReadDCMByte(stream_info,image)),q); break; } case 3: { SetPixelAlpha(image,ScaleCharToQuantum((unsigned char) ReadDCMByte(stream_info,image)),q); break; } default: break; } q+=GetPixelChannels(image); } if (SyncAuthenticPixels(image,exception) == MagickFalse) break; if (image->previous == (Image *) NULL) { status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,image->rows); if (status == MagickFalse) break; } } } } else { const char *option; /* Convert DCM Medical image to pixel packets. */ option=GetImageOption(image_info,"dcm:display-range"); if (option != (const char *) NULL) { if (LocaleCompare(option,"reset") == 0) info.window_width=0; } option=GetImageOption(image_info,"dcm:window"); if (option != (char *) NULL) { GeometryInfo geometry_info; MagickStatusType flags; flags=ParseGeometry(option,&geometry_info); if (flags & RhoValue) info.window_center=geometry_info.rho; if (flags & SigmaValue) info.window_width=geometry_info.sigma; info.rescale=MagickTrue; } option=GetImageOption(image_info,"dcm:rescale"); if (option != (char *) NULL) info.rescale=IsStringTrue(option); if ((info.window_center != 0) && (info.window_width == 0)) info.window_width=info.window_center; status=ReadDCMPixels(image,&info,stream_info,MagickTrue,exception); if ((status != MagickFalse) && (stream_info->segment_count > 1)) { if (stream_info->offset_count > 0) (void) SeekBlob(image,(MagickOffsetType) stream_info->offsets[0]+stream_info->segments[1],SEEK_SET); (void) ReadDCMPixels(image,&info,stream_info,MagickFalse, exception); } } if (IdentifyImageCoderGray(image,exception) != MagickFalse) (void) SetImageColorspace(image,GRAYColorspace,exception); if (EOFBlob(image) != MagickFalse) { ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", image->filename); break; } /* Proceed to next image. */ if (image_info->number_scenes != 0) if (image->scene >= (image_info->scene+image_info->number_scenes-1)) break; if (scene < (ssize_t) (number_scenes-1)) { /* Allocate next image structure. */ AcquireNextImage(image_info,image,exception); if (GetNextImageInList(image) == (Image *) NULL) { status=MagickFalse; break; } image=SyncNextImageInList(image); status=SetImageProgress(image,LoadImagesTag,TellBlob(image), GetBlobSize(image)); if (status == MagickFalse) break; } } if (TellBlob(image) < (MagickOffsetType) GetBlobSize(image)) { /* Allocate next image structure. */ AcquireNextImage(image_info,image,exception); if (GetNextImageInList(image) == (Image *) NULL) { status=MagickFalse; break; } image=SyncNextImageInList(image); status=SetImageProgress(image,LoadImagesTag,TellBlob(image), GetBlobSize(image)); if (status == MagickFalse) break; } } /* Free resources. */ RelinquishDCMMemory(&info,&map,stream_info,stack,data); if (image == (Image *) NULL) return(image); (void) CloseBlob(image); if (status == MagickFalse) return(DestroyImageList(image)); return(GetFirstImageInList(image)); }
0
317,359
static void selinux_secmark_refcount_dec(void) { atomic_dec(&selinux_secmark_refcount); }
0
240,279
get_expr_register(void) { char_u *new_line; new_line = getcmdline('=', 0L, 0, 0); if (new_line == NULL) return NUL; if (*new_line == NUL) // use previous line vim_free(new_line); else set_expr_line(new_line, NULL); return '='; }
0
255,773
svn_repos_authz_read4(svn_authz_t **authz_p, const char *path, const char *groups_path, svn_boolean_t must_exist, svn_repos_t *repos_hint, svn_repos_authz_warning_func_t warning_func, void *warning_baton, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { svn_authz_t *authz = apr_pcalloc(result_pool, sizeof(*authz)); authz->pool = result_pool; SVN_ERR(authz_read(&authz->full, &authz->authz_id, path, groups_path, must_exist, repos_hint, warning_func, warning_baton, result_pool, scratch_pool)); *authz_p = authz; return SVN_NO_ERROR; }
0
366,328
vfs_submount(const struct dentry *mountpoint, struct file_system_type *type, const char *name, void *data) { /* Until it is worked out how to pass the user namespace * through from the parent mount to the submount don't support * unprivileged mounts with submounts. */ if (mountpoint->d_sb->s_user_ns != &init_user_ns) return ERR_PTR(-EPERM); return vfs_kern_mount(type, SB_SUBMOUNT, name, data); }
0
211,567
static char *getsistring(FILE *f, uint32_t ptr, uint32_t len) { char *name; uint32_t i; if (!len) return NULL; if (len>400) len=400; name = cli_malloc(len); if (!name) { cli_dbgmsg("SIS: OOM\n"); return NULL; } fseek(f, ptr, SEEK_SET); if (fread(name, len, 1, f)!=1) { cli_dbgmsg("SIS: Unable to read string\n"); free(name); return NULL; } for (i = 0 ; i < len; i+=2) name[i/2] = name[i]; name[i/2]='\0'; return name; }
1
259,620
void HierarchicalBitmapRequester::DefineRegion(LONG x,const struct Line *const *line, const LONG *buffer,UBYTE comp) { int cnt = 8; assert(comp < m_ucCount); NOREF(comp); x <<= 3; do { if (*line) memcpy((*line)->m_pData + x,buffer,8 * sizeof(LONG)); buffer += 8; line++; } while(--cnt); }
0
512,256
Item_func_nullif::decimal_op(my_decimal * decimal_value) { DBUG_ASSERT(fixed == 1); my_decimal *res; if (!compare()) { null_value=1; return 0; } res= args[2]->val_decimal(decimal_value); null_value= args[2]->null_value; return res; }
0
402,642
cms_context_fini(cms_context *cms) { if (cms->cert) { CERT_DestroyCertificate(cms->cert); cms->cert = NULL; } switch (cms->pwdata.source) { case PW_SOURCE_INVALID: case PW_PROMPT: case PW_DEVICE: case PW_FROMFILEDB: case PW_FROMENV: case PW_SOURCE_MAX: break; case PW_DATABASE: xfree(cms->pwdata.data); break; case PW_PLAINTEXT: memset(cms->pwdata.data, 0, strlen(cms->pwdata.data)); xfree(cms->pwdata.data); break; } cms->pwdata.source = PW_SOURCE_INVALID; cms->pwdata.orig_source = PW_SOURCE_INVALID; if (cms->privkey) { free(cms->privkey); cms->privkey = NULL; } /* These were freed when the arena was destroyed */ if (cms->tokenname) cms->tokenname = NULL; if (cms->certname) cms->certname = NULL; if (cms->newsig.data) { free_poison(cms->newsig.data, cms->newsig.len); free(cms->newsig.data); memset(&cms->newsig, '\0', sizeof (cms->newsig)); } cms->selected_digest = -1; if (cms->ci_digest) { free_poison(cms->ci_digest->data, cms->ci_digest->len); /* XXX sure seems like we should be freeing it here, but * that's segfaulting, and we know it'll get cleaned up with * PORT_FreeArena a couple of lines down. */ cms->ci_digest = NULL; } teardown_digests(cms); if (cms->raw_signed_attrs) { free_poison(cms->raw_signed_attrs->data, cms->raw_signed_attrs->len); /* XXX sure seems like we should be freeing it here, but * that's segfaulting, and we know it'll get cleaned up with * PORT_FreeArena a couple of lines down. */ cms->raw_signed_attrs = NULL; } if (cms->raw_signature) { free_poison(cms->raw_signature->data, cms->raw_signature->len); /* XXX sure seems like we should be freeing it here, but * that's segfaulting, and we know it'll get cleaned up with * PORT_FreeArena a couple of lines down. */ cms->raw_signature = NULL; } for (int i = 0; i < cms->num_signatures; i++) { free(cms->signatures[i]->data); free(cms->signatures[i]); } xfree(cms->signatures); cms->num_signatures = 0; if (cms->authbuf) { xfree(cms->authbuf); cms->authbuf_len = 0; } PORT_FreeArena(cms->arena, PR_TRUE); memset(cms, '\0', sizeof(*cms)); xfree(cms); }
0
195,028
void DecodePngV2(OpKernelContext* context, StringPiece input) { int channel_bits = (data_type_ == DataType::DT_UINT8) ? 8 : 16; png::DecodeContext decode; OP_REQUIRES( context, png::CommonInitDecode(input, channels_, channel_bits, &decode), errors::InvalidArgument("Invalid PNG. Failed to initialize decoder.")); // Verify that width and height are not too large: // - verify width and height don't overflow int. // - width can later be multiplied by channels_ and sizeof(uint16), so // verify single dimension is not too large. // - verify when width and height are multiplied together, there are a few // bits to spare as well. const int width = static_cast<int>(decode.width); const int height = static_cast<int>(decode.height); const int64_t total_size = static_cast<int64_t>(width) * static_cast<int64_t>(height); if (width != static_cast<int64_t>(decode.width) || width <= 0 || width >= (1LL << 27) || height != static_cast<int64_t>(decode.height) || height <= 0 || height >= (1LL << 27) || total_size >= (1LL << 29)) { OP_REQUIRES(context, false, errors::InvalidArgument("PNG size too large for int: ", decode.width, " by ", decode.height)); } Tensor* output = nullptr; // By the existing API, we support decoding PNG with `DecodeGif` op. // We need to make sure to return 4-D shapes when using `DecodeGif`. if (op_type_ == "DecodeGif") { OP_REQUIRES_OK( context, context->allocate_output( 0, TensorShape({1, height, width, decode.channels}), &output)); } else { OP_REQUIRES_OK( context, context->allocate_output( 0, TensorShape({height, width, decode.channels}), &output)); } if (op_type_ == "DecodeBmp") { // TODO(b/171060723): Only DecodeBmp as op_type_ is not acceptable here // because currently `decode_(jpeg|png|gif)` ops can decode any one of // jpeg, png or gif but not bmp. Similarly, `decode_bmp` cannot decode // anything but bmp formats. This behavior needs to be revisited. For more // details, please refer to the bug. OP_REQUIRES(context, false, errors::InvalidArgument( "Trying to decode PNG format using DecodeBmp op. Use " "`decode_png` or `decode_image` instead.")); } else if (op_type_ == "DecodeAndCropJpeg") { OP_REQUIRES(context, false, errors::InvalidArgument( "DecodeAndCropJpeg operation can run on JPEG only, but " "detected PNG.")); } if (data_type_ == DataType::DT_UINT8) { OP_REQUIRES( context, png::CommonFinishDecode( reinterpret_cast<png_bytep>(output->flat<uint8>().data()), decode.channels * width * sizeof(uint8), &decode), errors::InvalidArgument("Invalid PNG data, size ", input.size())); } else if (data_type_ == DataType::DT_UINT16) { OP_REQUIRES( context, png::CommonFinishDecode( reinterpret_cast<png_bytep>(output->flat<uint16>().data()), decode.channels * width * sizeof(uint16), &decode), errors::InvalidArgument("Invalid PNG data, size ", input.size())); } else if (data_type_ == DataType::DT_FLOAT) { // `png::CommonFinishDecode` does not support `float`. First allocate // uint16 buffer for the image and decode in uint16 (lossless). Wrap the // buffer in `unique_ptr` so that we don't forget to delete the buffer. std::unique_ptr<uint16[]> buffer( new uint16[height * width * decode.channels]); OP_REQUIRES( context, png::CommonFinishDecode(reinterpret_cast<png_bytep>(buffer.get()), decode.channels * width * sizeof(uint16), &decode), errors::InvalidArgument("Invalid PNG data, size ", input.size())); // Convert uint16 image data to desired data type. // Use eigen threadpooling to speed up the copy operation. const auto& device = context->eigen_device<Eigen::ThreadPoolDevice>(); TTypes<uint16, 3>::UnalignedConstTensor buf(buffer.get(), height, width, decode.channels); float scale = 1. / std::numeric_limits<uint16>::max(); // Fill output tensor with desired dtype. output->tensor<float, 3>().device(device) = buf.cast<float>() * scale; } }
1
275,973
static void HMAC_init(const uECC_HashContext *hash_context, const uint8_t *K) { uint8_t *pad = hash_context->tmp + 2 * hash_context->result_size; unsigned i; for (i = 0; i < hash_context->result_size; ++i) pad[i] = K[i] ^ 0x36; for (; i < hash_context->block_size; ++i) pad[i] = 0x36; hash_context->init_hash(hash_context); hash_context->update_hash(hash_context, pad, hash_context->block_size); }
0
257,712
handler_t mod_wstunnel_handshake_create_response(handler_ctx *hctx) { request_st * const r = hctx->gw.r; #ifdef _MOD_WEBSOCKET_SPEC_RFC_6455_ if (hctx->hybivers >= 8) { DEBUG_LOG_DEBUG("%s", "send handshake response"); if (0 != create_response_rfc_6455(hctx)) { r->http_status = 400; /* Bad Request */ return HANDLER_ERROR; } return HANDLER_GO_ON; } #endif /* _MOD_WEBSOCKET_SPEC_RFC_6455_ */ #ifdef _MOD_WEBSOCKET_SPEC_IETF_00_ if (hctx->hybivers == 0 && r->http_version == HTTP_VERSION_1_1) { #ifdef _MOD_WEBSOCKET_SPEC_IETF_00_ /* 8 bytes should have been sent with request * for draft-ietf-hybi-thewebsocketprotocol-00 */ chunkqueue *cq = &r->reqbody_queue; if (chunkqueue_length(cq) < 8) return HANDLER_WAIT_FOR_EVENT; #endif /* _MOD_WEBSOCKET_SPEC_IETF_00_ */ DEBUG_LOG_DEBUG("%s", "send handshake response"); if (0 != create_response_ietf_00(hctx)) { r->http_status = 400; /* Bad Request */ return HANDLER_ERROR; } return HANDLER_GO_ON; } #endif /* _MOD_WEBSOCKET_SPEC_IETF_00_ */ DEBUG_LOG_ERR("%s", "not supported WebSocket Version"); r->http_status = 503; /* Service Unavailable */ return HANDLER_ERROR; }
0
244,353
GF_Err st3d_box_write(GF_Box *s, GF_BitStream *bs) { GF_Err e; GF_Stereo3DBox *ptr = (GF_Stereo3DBox *)s; e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u8(bs, ptr->stereo_type); return GF_OK; }
0
245,705
static void handle_connection_failure(struct conn_s *connptr, int got_headers) { /* * First, get the body if there is one. * If we don't read all there is from the socket first, * it is still marked for reading and we won't be able * to send our data properly. */ if (!got_headers && get_request_entity (connptr) < 0) { log_message (LOG_WARNING, "Could not retrieve request entity"); indicate_http_error (connptr, 400, "Bad Request", "detail", "Could not retrieve the request entity " "the client.", NULL); update_stats (STAT_BADCONN); } if (connptr->error_variables) { send_http_error_message (connptr); } else if (connptr->show_stats) { showstats (connptr); } }
0
195,984
GF_Err diST_box_read(GF_Box *s, GF_BitStream *bs) { u32 i; char str[1024]; GF_DIMSScriptTypesBox *p = (GF_DIMSScriptTypesBox *)s; i=0; str[0]=0; while (1) { str[i] = gf_bs_read_u8(bs); if (!str[i]) break; i++; } ISOM_DECREASE_SIZE(p, i); p->content_script_types = gf_strdup(str); return GF_OK; }
1
233,850
static double pict_read_fixed(dbuf *f, i64 pos) { i64 n; // I think QuickDraw's "Fixed point" numbers are signed, but I don't know // how negative numbers are handled. n = dbuf_geti32be(f, pos); return ((double)n)/65536.0; }
0
261,408
bool initialize_CABAC_at_slice_segment_start(thread_context* tctx) { de265_image* img = tctx->img; const pic_parameter_set& pps = img->get_pps(); const seq_parameter_set& sps = img->get_sps(); slice_segment_header* shdr = tctx->shdr; if (shdr->dependent_slice_segment_flag) { int prevCtb = pps.CtbAddrTStoRS[ pps.CtbAddrRStoTS[shdr->slice_segment_address] -1 ]; int sliceIdx = img->get_SliceHeaderIndex_atIndex(prevCtb); if (sliceIdx >= img->slices.size()) { return false; } slice_segment_header* prevCtbHdr = img->slices[ sliceIdx ]; if (pps.is_tile_start_CTB(shdr->slice_segment_address % sps.PicWidthInCtbsY, shdr->slice_segment_address / sps.PicWidthInCtbsY )) { initialize_CABAC_models(tctx); } else { // wait for previous slice to finish decoding //printf("wait for previous slice to finish decoding\n"); slice_unit* prevSliceSegment = tctx->imgunit->get_prev_slice_segment(tctx->sliceunit); //assert(prevSliceSegment); if (prevSliceSegment==NULL) { return false; } prevSliceSegment->finished_threads.wait_for_progress(prevSliceSegment->nThreads); /* printf("wait for %d,%d (init)\n", prevCtb / sps->PicWidthInCtbsY, prevCtb % sps->PicWidthInCtbsY); tctx->img->wait_for_progress(tctx->task, prevCtb, CTB_PROGRESS_PREFILTER); */ if (!prevCtbHdr->ctx_model_storage_defined) { return false; } tctx->ctx_model = prevCtbHdr->ctx_model_storage; prevCtbHdr->ctx_model_storage.release(); } } else { initialize_CABAC_models(tctx); } return true; }
0
346,439
add_pack_start_dirs(void) { do_in_path(p_pp, (char_u *)"pack/*/start/*", DIP_ALL + DIP_DIR, add_pack_plugin, &APP_ADD_DIR); }
0
289,291
static int snd_pcm_oss_get_block_size(struct snd_pcm_oss_file *pcm_oss_file) { struct snd_pcm_substream *substream; int err; err = snd_pcm_oss_get_active_substream(pcm_oss_file, &substream); if (err < 0) return err; return substream->runtime->oss.period_bytes; }
0
255,078
void ompl::geometric::VFRRT::updateExplorationEfficiency(Motion *m) { Motion *near = nn_->nearest(m); if (distanceFunction(m, near) < si_->getStateValidityCheckingResolution()) inefficientCount_++; else efficientCount_++; explorationInefficiency_ = inefficientCount_ / (double)(efficientCount_ + inefficientCount_); }
0
336,504
static void reds_start_auth_sasl(RedLinkInfo *link) { if (!red_sasl_start_auth(link->stream, reds_handle_sasl_result, link)) { reds_link_free(link); } }
0
204,830
struct vfsmount *clone_private_mount(const struct path *path) { struct mount *old_mnt = real_mount(path->mnt); struct mount *new_mnt; if (IS_MNT_UNBINDABLE(old_mnt)) return ERR_PTR(-EINVAL); new_mnt = clone_mnt(old_mnt, path->dentry, CL_PRIVATE); if (IS_ERR(new_mnt)) return ERR_CAST(new_mnt); /* Longterm mount to be removed by kern_unmount*() */ new_mnt->mnt_ns = MNT_NS_INTERNAL; return &new_mnt->mnt; }
1
221,686
unsigned long int Socket::getPeerSourceAddr() { return (unsigned long int) ntohl(peer_adr.sin_addr.s_addr); }
0
329,946
__fill_reduces_to_source (cairo_operator_t op, const cairo_color_t *color, const cairo_image_surface_t *dst) { if (op == CAIRO_OPERATOR_SOURCE || op == CAIRO_OPERATOR_CLEAR) return TRUE; if (op == CAIRO_OPERATOR_OVER && CAIRO_COLOR_IS_OPAQUE (color)) return TRUE; if (dst->base.is_clear) return op == CAIRO_OPERATOR_OVER || op == CAIRO_OPERATOR_ADD; return FALSE; }
0
486,798
static void gem_get_rx_desc(CadenceGEMState *s, int q) { hwaddr desc_addr = gem_get_rx_desc_addr(s, q); DB_PRINT("read descriptor 0x%" HWADDR_PRIx "\n", desc_addr); /* read current descriptor */ address_space_read(&s->dma_as, desc_addr, MEMTXATTRS_UNSPECIFIED, s->rx_desc[q], sizeof(uint32_t) * gem_get_desc_len(s, true)); /* Descriptor owned by software ? */ if (rx_desc_get_ownership(s->rx_desc[q]) == 1) { DB_PRINT("descriptor 0x%" HWADDR_PRIx " owned by sw.\n", desc_addr); s->regs[GEM_RXSTATUS] |= GEM_RXSTATUS_NOBUF; gem_set_isr(s, q, GEM_INT_RXUSED); /* Handle interrupt consequences */ gem_update_int_status(s); } }
0
221,152
GF_Err gf_odf_av1_cfg_write_bs(GF_AV1Config *cfg, GF_BitStream *bs) { u32 i = 0; gf_bs_write_int(bs, cfg->marker, 1); assert(cfg->marker == 1); gf_bs_write_int(bs, cfg->version, 7); assert(cfg->version == 1); gf_bs_write_int(bs, cfg->seq_profile, 3); gf_bs_write_int(bs, cfg->seq_level_idx_0, 5); gf_bs_write_int(bs, cfg->seq_tier_0, 1); gf_bs_write_int(bs, cfg->high_bitdepth, 1); gf_bs_write_int(bs, cfg->twelve_bit, 1); gf_bs_write_int(bs, cfg->monochrome, 1); gf_bs_write_int(bs, cfg->chroma_subsampling_x, 1); gf_bs_write_int(bs, cfg->chroma_subsampling_y, 1); gf_bs_write_int(bs, cfg->chroma_sample_position, 2); gf_bs_write_int(bs, 0, 3); /*reserved*/ gf_bs_write_int(bs, cfg->initial_presentation_delay_present, 1); gf_bs_write_int(bs, cfg->initial_presentation_delay_minus_one, 4); /*TODO: compute initial_presentation_delay_minus_one*/ for (i = 0; i < gf_list_count(cfg->obu_array); ++i) { GF_AV1_OBUArrayEntry *a = gf_list_get(cfg->obu_array, i); gf_bs_write_data(bs, a->obu, (u32)a->obu_length); //TODO: we are supposed to omit the size on the last OBU... } return GF_OK; }
0
512,414
longlong Item_func_not_all::val_int() { DBUG_ASSERT(fixed == 1); bool value= args[0]->val_bool(); /* return TRUE if there was records in underlying select in max/min optimization (ALL subquery) */ if (empty_underlying_subquery()) return 1; null_value= args[0]->null_value; return ((!null_value && value == 0) ? 1 : 0); }
0
225,481
absl::flat_hash_set<MutableGraphView::OutputPort> MutableGraphView::GetFanin( const GraphView::InputPort& port) const { return GetFanin(MutableGraphView::InputPort(const_cast<NodeDef*>(port.node), port.port_id)); }
0
405,713
static int xemaclite_of_remove(struct platform_device *of_dev) { struct net_device *ndev = platform_get_drvdata(of_dev); struct net_local *lp = netdev_priv(ndev); /* Un-register the mii_bus, if configured */ if (lp->mii_bus) { mdiobus_unregister(lp->mii_bus); mdiobus_free(lp->mii_bus); lp->mii_bus = NULL; } unregister_netdev(ndev); of_node_put(lp->phy_node); lp->phy_node = NULL; free_netdev(ndev); return 0; }
0
309,942
_nc_locked_tracef(const char *fmt, ...) { va_list ap; va_start(ap, fmt); _nc_va_tracef(fmt, ap); va_end(ap); if (--(MyNested) == 0) { _nc_unlock_global(tracef); } }
0
512,612
Item_func_ifnull::int_op() { DBUG_ASSERT(fixed == 1); longlong value=args[0]->val_int(); if (!args[0]->null_value) { null_value=0; return value; } value=args[1]->val_int(); if ((null_value=args[1]->null_value)) return 0; return value; }
0
353,127
bool matches(const Ref *idA, double m11A, double m12A, double m21A, double m22A) { return fontID == *idA && m11 == m11A && m12 == m12A && m21 == m21A && m22 == m22A; }
0
512,846
bool is_order_clause_position() const { return state == SHORT_DATA_VALUE && type_handler()->is_order_clause_position_type(); }
0
365,617
_asn1_set_value_lv (asn1_node node, const void *value, unsigned int len) { int len2; void *temp; if (node == NULL) return node; asn1_length_der (len, NULL, &len2); temp = malloc (len + len2); if (temp == NULL) return NULL; asn1_octet_der (value, len, temp, &len2); return _asn1_set_value_m (node, temp, len2); }
0
238,566
static int check_attach_btf_id(struct bpf_verifier_env *env) { struct bpf_prog *prog = env->prog; struct bpf_prog *tgt_prog = prog->aux->dst_prog; struct bpf_attach_target_info tgt_info = {}; u32 btf_id = prog->aux->attach_btf_id; struct bpf_trampoline *tr; int ret; u64 key; if (prog->type == BPF_PROG_TYPE_SYSCALL) { if (prog->aux->sleepable) /* attach_btf_id checked to be zero already */ return 0; verbose(env, "Syscall programs can only be sleepable\n"); return -EINVAL; } if (prog->aux->sleepable && prog->type != BPF_PROG_TYPE_TRACING && prog->type != BPF_PROG_TYPE_LSM) { verbose(env, "Only fentry/fexit/fmod_ret and lsm programs can be sleepable\n"); return -EINVAL; } if (prog->type == BPF_PROG_TYPE_STRUCT_OPS) return check_struct_ops_btf_id(env); if (prog->type != BPF_PROG_TYPE_TRACING && prog->type != BPF_PROG_TYPE_LSM && prog->type != BPF_PROG_TYPE_EXT) return 0; ret = bpf_check_attach_target(&env->log, prog, tgt_prog, btf_id, &tgt_info); if (ret) return ret; if (tgt_prog && prog->type == BPF_PROG_TYPE_EXT) { /* to make freplace equivalent to their targets, they need to * inherit env->ops and expected_attach_type for the rest of the * verification */ env->ops = bpf_verifier_ops[tgt_prog->type]; prog->expected_attach_type = tgt_prog->expected_attach_type; } /* store info about the attachment target that will be used later */ prog->aux->attach_func_proto = tgt_info.tgt_type; prog->aux->attach_func_name = tgt_info.tgt_name; if (tgt_prog) { prog->aux->saved_dst_prog_type = tgt_prog->type; prog->aux->saved_dst_attach_type = tgt_prog->expected_attach_type; } if (prog->expected_attach_type == BPF_TRACE_RAW_TP) { prog->aux->attach_btf_trace = true; return 0; } else if (prog->expected_attach_type == BPF_TRACE_ITER) { if (!bpf_iter_prog_supported(prog)) return -EINVAL; return 0; } if (prog->type == BPF_PROG_TYPE_LSM) { ret = bpf_lsm_verify_prog(&env->log, prog); if (ret < 0) return ret; } else if (prog->type == BPF_PROG_TYPE_TRACING && btf_id_set_contains(&btf_id_deny, btf_id)) { return -EINVAL; } key = bpf_trampoline_compute_key(tgt_prog, prog->aux->attach_btf, btf_id); tr = bpf_trampoline_get(key, &tgt_info); if (!tr) return -ENOMEM; prog->aux->dst_trampoline = tr; return 0; }
0
294,476
d_lite_min(VALUE self) { get_d1(self); return INT2FIX(m_min(dat)); }
0
234,227
display_debug_macinfo (struct dwarf_section *section, void *file ATTRIBUTE_UNUSED) { unsigned char *start = section->start; unsigned char *end = start + section->size; unsigned char *curr = start; enum dwarf_macinfo_record_type op; introduce (section, false); while (curr < end) { unsigned int lineno; const unsigned char *string; op = (enum dwarf_macinfo_record_type) *curr; curr++; switch (op) { case DW_MACINFO_start_file: { unsigned int filenum; READ_ULEB (lineno, curr, end); READ_ULEB (filenum, curr, end); printf (_(" DW_MACINFO_start_file - lineno: %d filenum: %d\n"), lineno, filenum); } break; case DW_MACINFO_end_file: printf (_(" DW_MACINFO_end_file\n")); break; case DW_MACINFO_define: READ_ULEB (lineno, curr, end); string = curr; curr += strnlen ((char *) string, end - string); printf (_(" DW_MACINFO_define - lineno : %d macro : %*s\n"), lineno, (int) (curr - string), string); if (curr < end) curr++; break; case DW_MACINFO_undef: READ_ULEB (lineno, curr, end); string = curr; curr += strnlen ((char *) string, end - string); printf (_(" DW_MACINFO_undef - lineno : %d macro : %*s\n"), lineno, (int) (curr - string), string); if (curr < end) curr++; break; case DW_MACINFO_vendor_ext: { unsigned int constant; READ_ULEB (constant, curr, end); string = curr; curr += strnlen ((char *) string, end - string); printf (_(" DW_MACINFO_vendor_ext - constant : %d string : %*s\n"), constant, (int) (curr - string), string); if (curr < end) curr++; } break; } } return 1; }
0
273,057
safe_hextou64(const char *str, uint64_t *val) { char *end; unsigned long long intval; *val = 0; errno = 0; intval = strtoull(str, &end, 16); if (((errno == ERANGE) && (intval == ULLONG_MAX)) || ((errno != 0) && (intval == 0))) { DPRINTF(E_DBG, L_MISC, "Invalid integer in string (%s): %s\n", str, strerror(errno)); return -1; } if (end == str) { DPRINTF(E_DBG, L_MISC, "No integer found in string (%s)\n", str); return -1; } if (intval > UINT64_MAX) { DPRINTF(E_DBG, L_MISC, "Integer value too large (%s)\n", str); return -1; } *val = (uint64_t)intval; return 0; }
0
264,254
static void set_pixel_conversion(VncState *vs) { pixman_format_code_t fmt = qemu_pixman_get_format(&vs->client_pf); if (fmt == VNC_SERVER_FB_FORMAT) { vs->write_pixels = vnc_write_pixels_copy; vnc_hextile_set_pixel_conversion(vs, 0); } else { vs->write_pixels = vnc_write_pixels_generic; vnc_hextile_set_pixel_conversion(vs, 1); } }
0