idx
int64
func
string
target
int64
263,296
bool _q_countsave(const char *filepath, int number) { int fd = open(filepath, O_CREAT|O_WRONLY|O_TRUNC, DEF_FILE_MODE); if (fd < 0) return false; char buf[10+1]; snprintf(buf, sizeof(buf), "%d", number); ssize_t updated = write(fd, buf, strlen(buf)); close(fd); if (updated > 0) return true; return false; }
0
352,943
csnSidNormalize( slap_mask_t usage, Syntax *syntax, MatchingRule *mr, struct berval *val, struct berval *normalized, void *ctx ) { struct berval bv; char *ptr, buf[ 4 ]; if ( BER_BVISEMPTY( val ) ) { return LDAP_INVALID_SYNTAX; } if ( SLAP_MR_IS_VALUE_OF_ASSERTION_SYNTAX(usage) ) { return sidNormalize( 0, NULL, NULL, val, normalized, ctx ); } assert( SLAP_MR_IS_VALUE_OF_ATTRIBUTE_SYNTAX(usage) != 0 ); ptr = ber_bvchr( val, '#' ); if ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) { return LDAP_INVALID_SYNTAX; } bv.bv_val = ptr + 1; bv.bv_len = val->bv_len - ( ptr + 1 - val->bv_val ); ptr = ber_bvchr( &bv, '#' ); if ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) { return LDAP_INVALID_SYNTAX; } bv.bv_val = ptr + 1; bv.bv_len = val->bv_len - ( ptr + 1 - val->bv_val ); ptr = ber_bvchr( &bv, '#' ); if ( ptr == NULL || ptr == &val->bv_val[val->bv_len] ) { return LDAP_INVALID_SYNTAX; } bv.bv_len = ptr - bv.bv_val; if ( bv.bv_len == 2 ) { /* OpenLDAP 2.3 SID */ buf[ 0 ] = '0'; buf[ 1 ] = bv.bv_val[ 0 ]; buf[ 2 ] = bv.bv_val[ 1 ]; buf[ 3 ] = '\0'; bv.bv_val = buf; bv.bv_len = 3; } return sidNormalize( 0, NULL, NULL, &bv, normalized, ctx ); }
0
477,300
static int tipc_aead_clone(struct tipc_aead **dst, struct tipc_aead *src) { struct tipc_aead *aead; int cpu; if (!src) return -ENOKEY; if (src->mode != CLUSTER_KEY) return -EINVAL; if (unlikely(*dst)) return -EEXIST; aead = kzalloc(sizeof(*aead), GFP_ATOMIC); if (unlikely(!aead)) return -ENOMEM; aead->tfm_entry = alloc_percpu_gfp(struct tipc_tfm *, GFP_ATOMIC); if (unlikely(!aead->tfm_entry)) { kfree_sensitive(aead); return -ENOMEM; } for_each_possible_cpu(cpu) { *per_cpu_ptr(aead->tfm_entry, cpu) = *per_cpu_ptr(src->tfm_entry, cpu); } memcpy(aead->hint, src->hint, sizeof(src->hint)); aead->mode = src->mode; aead->salt = src->salt; aead->authsize = src->authsize; atomic_set(&aead->users, 0); atomic64_set(&aead->seqno, 0); refcount_set(&aead->refcnt, 1); WARN_ON(!refcount_inc_not_zero(&src->refcnt)); aead->cloned = src; *dst = aead; return 0; }
0
337,811
int sctp_chunk_iif(const struct sctp_chunk *chunk) { struct sk_buff *skb = chunk->skb; return SCTP_INPUT_CB(skb)->af->skb_iif(skb); }
0
482,687
gst_flxdec_dispose (GstFlxDec * flxdec) { if (flxdec->adapter) { g_object_unref (flxdec->adapter); flxdec->adapter = NULL; } G_OBJECT_CLASS (parent_class)->dispose ((GObject *) flxdec); }
0
317,177
static int smack_netlbl_add(struct sock *sk) { struct socket_smack *ssp = sk->sk_security; struct smack_known *skp = ssp->smk_out; int rc; local_bh_disable(); bh_lock_sock_nested(sk); rc = netlbl_sock_setattr(sk, sk->sk_family, &skp->smk_netlabel); switch (rc) { case 0: ssp->smk_state = SMK_NETLBL_LABELED; break; case -EDESTADDRREQ: ssp->smk_state = SMK_NETLBL_REQSKB; rc = 0; break; } bh_unlock_sock(sk); local_bh_enable(); return rc; }
0
213,515
spell_suggest(int count) { char_u *line; pos_T prev_cursor = curwin->w_cursor; char_u wcopy[MAXWLEN + 2]; char_u *p; int i; int c; suginfo_T sug; suggest_T *stp; int mouse_used; int need_cap; int limit; int selected = count; int badlen = 0; int msg_scroll_save = msg_scroll; int wo_spell_save = curwin->w_p_spell; if (!curwin->w_p_spell) { did_set_spelllang(curwin); curwin->w_p_spell = TRUE; } if (*curwin->w_s->b_p_spl == NUL) { emsg(_(e_spell_checking_is_not_possible)); return; } if (VIsual_active) { // Use the Visually selected text as the bad word. But reject // a multi-line selection. if (curwin->w_cursor.lnum != VIsual.lnum) { vim_beep(BO_SPELL); return; } badlen = (int)curwin->w_cursor.col - (int)VIsual.col; if (badlen < 0) badlen = -badlen; else curwin->w_cursor.col = VIsual.col; ++badlen; end_visual_mode(); } // Find the start of the badly spelled word. else if (spell_move_to(curwin, FORWARD, TRUE, TRUE, NULL) == 0 || curwin->w_cursor.col > prev_cursor.col) { // No bad word or it starts after the cursor: use the word under the // cursor. curwin->w_cursor = prev_cursor; line = ml_get_curline(); p = line + curwin->w_cursor.col; // Backup to before start of word. while (p > line && spell_iswordp_nmw(p, curwin)) MB_PTR_BACK(line, p); // Forward to start of word. while (*p != NUL && !spell_iswordp_nmw(p, curwin)) MB_PTR_ADV(p); if (!spell_iswordp_nmw(p, curwin)) // No word found. { beep_flush(); return; } curwin->w_cursor.col = (colnr_T)(p - line); } // Get the word and its length. // Figure out if the word should be capitalised. need_cap = check_need_cap(curwin->w_cursor.lnum, curwin->w_cursor.col); // Make a copy of current line since autocommands may free the line. line = vim_strsave(ml_get_curline()); if (line == NULL) goto skip; // Get the list of suggestions. Limit to 'lines' - 2 or the number in // 'spellsuggest', whatever is smaller. if (sps_limit > (int)Rows - 2) limit = (int)Rows - 2; else limit = sps_limit; spell_find_suggest(line + curwin->w_cursor.col, badlen, &sug, limit, TRUE, need_cap, TRUE); if (sug.su_ga.ga_len == 0) msg(_("Sorry, no suggestions")); else if (count > 0) { if (count > sug.su_ga.ga_len) smsg(_("Sorry, only %ld suggestions"), (long)sug.su_ga.ga_len); } else { #ifdef FEAT_RIGHTLEFT // When 'rightleft' is set the list is drawn right-left. cmdmsg_rl = curwin->w_p_rl; if (cmdmsg_rl) msg_col = Columns - 1; #endif // List the suggestions. msg_start(); msg_row = Rows - 1; // for when 'cmdheight' > 1 lines_left = Rows; // avoid more prompt vim_snprintf((char *)IObuff, IOSIZE, _("Change \"%.*s\" to:"), sug.su_badlen, sug.su_badptr); #ifdef FEAT_RIGHTLEFT if (cmdmsg_rl && STRNCMP(IObuff, "Change", 6) == 0) { // And now the rabbit from the high hat: Avoid showing the // untranslated message rightleft. vim_snprintf((char *)IObuff, IOSIZE, ":ot \"%.*s\" egnahC", sug.su_badlen, sug.su_badptr); } #endif msg_puts((char *)IObuff); msg_clr_eos(); msg_putchar('\n'); msg_scroll = TRUE; for (i = 0; i < sug.su_ga.ga_len; ++i) { stp = &SUG(sug.su_ga, i); // The suggested word may replace only part of the bad word, add // the not replaced part. vim_strncpy(wcopy, stp->st_word, MAXWLEN); if (sug.su_badlen > stp->st_orglen) vim_strncpy(wcopy + stp->st_wordlen, sug.su_badptr + stp->st_orglen, sug.su_badlen - stp->st_orglen); vim_snprintf((char *)IObuff, IOSIZE, "%2d", i + 1); #ifdef FEAT_RIGHTLEFT if (cmdmsg_rl) rl_mirror(IObuff); #endif msg_puts((char *)IObuff); vim_snprintf((char *)IObuff, IOSIZE, " \"%s\"", wcopy); msg_puts((char *)IObuff); // The word may replace more than "su_badlen". if (sug.su_badlen < stp->st_orglen) { vim_snprintf((char *)IObuff, IOSIZE, _(" < \"%.*s\""), stp->st_orglen, sug.su_badptr); msg_puts((char *)IObuff); } if (p_verbose > 0) { // Add the score. if (sps_flags & (SPS_DOUBLE | SPS_BEST)) vim_snprintf((char *)IObuff, IOSIZE, " (%s%d - %d)", stp->st_salscore ? "s " : "", stp->st_score, stp->st_altscore); else vim_snprintf((char *)IObuff, IOSIZE, " (%d)", stp->st_score); #ifdef FEAT_RIGHTLEFT if (cmdmsg_rl) // Mirror the numbers, but keep the leading space. rl_mirror(IObuff + 1); #endif msg_advance(30); msg_puts((char *)IObuff); } msg_putchar('\n'); } #ifdef FEAT_RIGHTLEFT cmdmsg_rl = FALSE; msg_col = 0; #endif // Ask for choice. selected = prompt_for_number(&mouse_used); if (mouse_used) selected -= lines_left; lines_left = Rows; // avoid more prompt // don't delay for 'smd' in normal_cmd() msg_scroll = msg_scroll_save; } if (selected > 0 && selected <= sug.su_ga.ga_len && u_save_cursor() == OK) { // Save the from and to text for :spellrepall. VIM_CLEAR(repl_from); VIM_CLEAR(repl_to); stp = &SUG(sug.su_ga, selected - 1); if (sug.su_badlen > stp->st_orglen) { // Replacing less than "su_badlen", append the remainder to // repl_to. repl_from = vim_strnsave(sug.su_badptr, sug.su_badlen); vim_snprintf((char *)IObuff, IOSIZE, "%s%.*s", stp->st_word, sug.su_badlen - stp->st_orglen, sug.su_badptr + stp->st_orglen); repl_to = vim_strsave(IObuff); } else { // Replacing su_badlen or more, use the whole word. repl_from = vim_strnsave(sug.su_badptr, stp->st_orglen); repl_to = vim_strsave(stp->st_word); } // Replace the word. p = alloc(STRLEN(line) - stp->st_orglen + stp->st_wordlen + 1); if (p != NULL) { c = (int)(sug.su_badptr - line); mch_memmove(p, line, c); STRCPY(p + c, stp->st_word); STRCAT(p, sug.su_badptr + stp->st_orglen); // For redo we use a change-word command. ResetRedobuff(); AppendToRedobuff((char_u *)"ciw"); AppendToRedobuffLit(p + c, stp->st_wordlen + sug.su_badlen - stp->st_orglen); AppendCharToRedobuff(ESC); // "p" may be freed here ml_replace(curwin->w_cursor.lnum, p, FALSE); curwin->w_cursor.col = c; changed_bytes(curwin->w_cursor.lnum, c); } } else curwin->w_cursor = prev_cursor; spell_find_cleanup(&sug); skip: vim_free(line); curwin->w_p_spell = wo_spell_save; }
1
273,074
keyval_sort(struct keyval *kv) { struct onekeyval *head; struct onekeyval *okv; struct onekeyval *sokv; if (!kv || !kv->head) return; head = kv->head; for (okv = kv->head; okv; okv = okv->next) { okv->sort = NULL; for (sokv = kv->head; sokv; sokv = sokv->next) { // We try to find a name which is greater than okv->name // but less than our current candidate (okv->sort->name) if ( (strcmp(sokv->name, okv->name) > 0) && ((okv->sort == NULL) || (strcmp(sokv->name, okv->sort->name) < 0)) ) okv->sort = sokv; } // Find smallest name, which will be the new head if (strcmp(okv->name, head->name) < 0) head = okv; } while ((okv = kv->head)) { kv->head = okv->next; okv->next = okv->sort; } kv->head = head; for (okv = kv->head; okv; okv = okv->next) kv->tail = okv; DPRINTF(E_DBG, L_MISC, "Keyval sorted. New head: %s. New tail: %s.\n", kv->head->name, kv->tail->name); }
0
220,858
inline int16_t lut_lookup(int8_t value, const int16_t* lut) { return lut[128 + value]; }
0
252,464
static bool DecompressZfp(float *dst, int dst_width, int dst_num_lines, int num_channels, const unsigned char *src, unsigned long src_size, const ZFPCompressionParam &param) { size_t uncompressed_size = dst_width * dst_num_lines * num_channels; if (uncompressed_size == src_size) { // Data is not compressed(Issue 40). memcpy(dst, src, src_size); } zfp_stream *zfp = NULL; zfp_field *field = NULL; assert((dst_width % 4) == 0); assert((dst_num_lines % 4) == 0); if ((dst_width & 3U) || (dst_num_lines & 3U)) { return false; } field = zfp_field_2d(reinterpret_cast<void *>(const_cast<unsigned char *>(src)), zfp_type_float, dst_width, dst_num_lines * num_channels); zfp = zfp_stream_open(NULL); if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_RATE) { zfp_stream_set_rate(zfp, param.rate, zfp_type_float, /* dimention */ 2, /* write random access */ 0); } else if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_PRECISION) { zfp_stream_set_precision(zfp, param.precision, zfp_type_float); } else if (param.type == TINYEXR_ZFP_COMPRESSIONTYPE_ACCURACY) { zfp_stream_set_accuracy(zfp, param.tolerance, zfp_type_float); } else { assert(0); } size_t buf_size = zfp_stream_maximum_size(zfp, field); std::vector<unsigned char> buf(buf_size); memcpy(&buf.at(0), src, src_size); bitstream *stream = stream_open(&buf.at(0), buf_size); zfp_stream_set_bit_stream(zfp, stream); zfp_stream_rewind(zfp); size_t image_size = dst_width * dst_num_lines; for (int c = 0; c < num_channels; c++) { // decompress 4x4 pixel block. for (int y = 0; y < dst_num_lines; y += 4) { for (int x = 0; x < dst_width; x += 4) { float fblock[16]; zfp_decode_block_float_2(zfp, fblock); for (int j = 0; j < 4; j++) { for (int i = 0; i < 4; i++) { dst[c * image_size + ((y + j) * dst_width + (x + i))] = fblock[j * 4 + i]; } } } } } zfp_field_free(field); zfp_stream_close(zfp); stream_close(stream); return true; }
0
294,455
d_lite_day_fraction(VALUE self) { get_d1(self); if (simple_dat_p(dat)) return INT2FIX(0); return m_fr(dat); }
0
195,022
int callback_glewlwyd_user_auth (const struct _u_request * request, struct _u_response * response, void * user_data) { struct config_elements * config = (struct config_elements *)user_data; json_t * j_param = ulfius_get_json_body_request(request, NULL), * j_result = NULL; const char * ip_source = get_ip_source(request); char * issued_for = get_client_hostname(request); char * session_uid, expires[129]; time_t now; struct tm ts; time(&now); now += GLEWLWYD_DEFAULT_SESSION_EXPIRATION_COOKIE; gmtime_r(&now, &ts); strftime(expires, 128, "%a, %d %b %Y %T %Z", &ts); if (j_param != NULL) { if (json_string_length(json_object_get(j_param, "username"))) { if (json_object_get(j_param, "scheme_type") == NULL || 0 == o_strcmp(json_string_value(json_object_get(j_param, "scheme_type")), "password")) { if (json_string_length(json_object_get(j_param, "password"))) { j_result = auth_check_user_credentials(config, json_string_value(json_object_get(j_param, "username")), json_string_value(json_object_get(j_param, "password"))); if (check_result_value(j_result, G_OK)) { if ((session_uid = get_session_id(config, request)) == NULL) { session_uid = generate_session_id(); } if (user_session_update(config, session_uid, u_map_get_case(request->map_header, "user-agent"), issued_for, json_string_value(json_object_get(j_param, "username")), NULL, 1) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_auth - Error user_session_update (1)"); response->status = 500; } else { ulfius_add_cookie_to_response(response, config->session_key, session_uid, expires, 0, config->cookie_domain, "/", config->cookie_secure, 0); y_log_message(Y_LOG_LEVEL_INFO, "Event - User '%s' authenticated with password", json_string_value(json_object_get(j_param, "username"))); } o_free(session_uid); glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_VALID, 1, NULL); glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_VALID_SCHEME, 1, "scheme_type", "password", NULL); } else { if (check_result_value(j_result, G_ERROR_UNAUTHORIZED)) { y_log_message(Y_LOG_LEVEL_WARNING, "Security - Authorization invalid for username %s at IP Address %s", json_string_value(json_object_get(j_param, "username")), ip_source); } if ((session_uid = get_session_id(config, request)) != NULL && user_session_update(config, session_uid, u_map_get_case(request->map_header, "user-agent"), issued_for, json_string_value(json_object_get(j_param, "username")), NULL, 1) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_auth - Error user_session_update (2)"); } o_free(session_uid); response->status = 401; glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_INVALID, 1, NULL); glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_INVALID_SCHEME, 1, "scheme_type", "password", NULL); } json_decref(j_result); } else if (json_object_get(j_param, "password") != NULL && !json_is_string(json_object_get(j_param, "password"))) { ulfius_set_string_body_response(response, 400, "password must be a string"); } else { session_uid = get_session_id(config, request); j_result = get_users_for_session(config, session_uid); if (check_result_value(j_result, G_OK)) { // Refresh username to set as default if (user_session_update(config, u_map_get(request->map_cookie, config->session_key), u_map_get_case(request->map_header, "user-agent"), issued_for, json_string_value(json_object_get(j_param, "username")), NULL, 0) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_auth - Error user_session_update (3)"); response->status = 500; } else { ulfius_add_cookie_to_response(response, config->session_key, session_uid, expires, 0, config->cookie_domain, "/", config->cookie_secure, 0); } } else if (check_result_value(j_result, G_ERROR_NOT_FOUND)) { response->status = 401; } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_auth - Error get_users_for_session"); response->status = 500; } o_free(session_uid); json_decref(j_result); } } else { if (json_string_length(json_object_get(j_param, "scheme_type")) && json_string_length(json_object_get(j_param, "scheme_name")) && json_is_object(json_object_get(j_param, "value"))) { j_result = auth_check_user_scheme(config, json_string_value(json_object_get(j_param, "scheme_type")), json_string_value(json_object_get(j_param, "scheme_name")), json_string_value(json_object_get(j_param, "username")), json_object_get(j_param, "value"), request); if (check_result_value(j_result, G_ERROR_PARAM)) { ulfius_set_string_body_response(response, 400, "bad scheme response"); } else if (check_result_value(j_result, G_ERROR_UNAUTHORIZED)) { y_log_message(Y_LOG_LEVEL_WARNING, "Security - Authorization invalid for username %s at IP Address %s", json_string_value(json_object_get(j_param, "username")), ip_source); response->status = 401; glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_INVALID, 1, NULL); glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_INVALID_SCHEME, 1, "scheme_type", json_string_value(json_object_get(j_param, "scheme_type")), "scheme_name", json_string_value(json_object_get(j_param, "scheme_name")), NULL); } else if (check_result_value(j_result, G_ERROR_NOT_FOUND)) { response->status = 404; } else if (check_result_value(j_result, G_OK)) { if ((session_uid = get_session_id(config, request)) == NULL) { session_uid = generate_session_id(); } if (user_session_update(config, session_uid, u_map_get_case(request->map_header, "user-agent"), issued_for, json_string_value(json_object_get(j_param, "username")), json_string_value(json_object_get(j_param, "scheme_name")), 1) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_auth - Error user_session_update (4)"); response->status = 500; } else { ulfius_add_cookie_to_response(response, config->session_key, session_uid, expires, 0, config->cookie_domain, "/", config->cookie_secure, 0); y_log_message(Y_LOG_LEVEL_INFO, "Event - User '%s' authenticated with scheme '%s/%s'", json_string_value(json_object_get(j_param, "username")), json_string_value(json_object_get(j_param, "scheme_type")), json_string_value(json_object_get(j_param, "scheme_name"))); } o_free(session_uid); glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_VALID, 1, NULL); glewlwyd_metrics_increment_counter_va(config, GLWD_METRICS_AUTH_USER_VALID_SCHEME, 1, "scheme_type", json_string_value(json_object_get(j_param, "scheme_type")), "scheme_name", json_string_value(json_object_get(j_param, "scheme_name")), NULL); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_auth - Error auth_check_user_scheme"); response->status = 500; } json_decref(j_result); } else { ulfius_set_string_body_response(response, 400, "scheme_type, scheme_name and value are mandatory"); } } } else { if (json_string_length(json_object_get(j_param, "scheme_type")) && json_string_length(json_object_get(j_param, "scheme_name")) && json_is_object(json_object_get(j_param, "value"))) { j_result = auth_check_identify_scheme(config, json_string_value(json_object_get(j_param, "scheme_type")), json_string_value(json_object_get(j_param, "scheme_name")), json_object_get(j_param, "value"), request); if (check_result_value(j_result, G_ERROR_PARAM)) { ulfius_set_string_body_response(response, 400, "bad scheme response"); } else if (check_result_value(j_result, G_ERROR_UNAUTHORIZED)) { y_log_message(Y_LOG_LEVEL_WARNING, "Security - Authorization invalid for username <UNKNOWN> at IP Address %s", ip_source); response->status = 401; } else if (check_result_value(j_result, G_ERROR_NOT_FOUND)) { response->status = 404; } else if (check_result_value(j_result, G_OK)) { if ((session_uid = get_session_id(config, request)) == NULL) { session_uid = generate_session_id(); } if (user_session_update(config, session_uid, u_map_get_case(request->map_header, "user-agent"), issued_for, json_string_value(json_object_get(j_result, "username")), json_string_value(json_object_get(j_param, "scheme_name")), 1) != G_OK) { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_auth - Error user_session_update (4)"); response->status = 500; } else { ulfius_add_cookie_to_response(response, config->session_key, session_uid, expires, 0, config->cookie_domain, "/", config->cookie_secure, 0); y_log_message(Y_LOG_LEVEL_INFO, "Event - User '%s' authenticated with scheme '%s/%s'", json_string_value(json_object_get(j_result, "username")), json_string_value(json_object_get(j_param, "scheme_type")), json_string_value(json_object_get(j_param, "scheme_name"))); } o_free(session_uid); } else { y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_auth - Error auth_check_user_scheme"); response->status = 500; } json_decref(j_result); } else { ulfius_set_string_body_response(response, 400, "username is mandatory"); } } } else { ulfius_set_string_body_response(response, 400, "Input parameters must be in JSON format"); } json_decref(j_param); o_free(issued_for); return U_CALLBACK_CONTINUE; }
1
314,753
_cdf_tole8(uint64_t sv) { uint64_t rv; uint8_t *s = (uint8_t *)(void *)&sv; uint8_t *d = (uint8_t *)(void *)&rv; d[0] = s[7]; d[1] = s[6]; d[2] = s[5]; d[3] = s[4]; d[4] = s[3]; d[5] = s[2]; d[6] = s[1]; d[7] = s[0]; return rv; }
0
222,867
void GraphProperties::ClearOutputProperties(const string& node_name) { output_properties_.erase(node_name); }
0
503,887
SCM_DEFINE (scm_stat, "stat", 1, 1, 0, (SCM object, SCM exception_on_error), "Return an object containing various information about the file\n" "determined by @var{object}. @var{object} can be a string containing\n" "a file name or a port or integer file descriptor which is open\n" "on a file (in which case @code{fstat} is used as the underlying\n" "system call).\n" "\n" "If the optional @var{exception_on_error} argument is true, which\n" "is the default, an exception will be raised if the underlying\n" "system call returns an error, for example if the file is not\n" "found or is not readable. Otherwise, an error will cause\n" "@code{stat} to return @code{#f}." "\n" "The object returned by a successful call to @code{stat} can be\n" "passed as a single parameter to the following procedures, all of\n" "which return integers:\n" "\n" "@table @code\n" "@item stat:dev\n" "The device containing the file.\n" "@item stat:ino\n" "The file serial number, which distinguishes this file from all\n" "other files on the same device.\n" "@item stat:mode\n" "The mode of the file. This includes file type information and\n" "the file permission bits. See @code{stat:type} and\n" "@code{stat:perms} below.\n" "@item stat:nlink\n" "The number of hard links to the file.\n" "@item stat:uid\n" "The user ID of the file's owner.\n" "@item stat:gid\n" "The group ID of the file.\n" "@item stat:rdev\n" "Device ID; this entry is defined only for character or block\n" "special files.\n" "@item stat:size\n" "The size of a regular file in bytes.\n" "@item stat:atime\n" "The last access time for the file.\n" "@item stat:mtime\n" "The last modification time for the file.\n" "@item stat:ctime\n" "The last modification time for the attributes of the file.\n" "@item stat:blksize\n" "The optimal block size for reading or writing the file, in\n" "bytes.\n" "@item stat:blocks\n" "The amount of disk space that the file occupies measured in\n" "units of 512 byte blocks.\n" "@end table\n" "\n" "In addition, the following procedures return the information\n" "from stat:mode in a more convenient form:\n" "\n" "@table @code\n" "@item stat:type\n" "A symbol representing the type of file. Possible values are\n" "regular, directory, symlink, block-special, char-special, fifo,\n" "socket and unknown\n" "@item stat:perms\n" "An integer representing the access permission bits.\n" "@end table") #define FUNC_NAME s_scm_stat { int rv; int fdes; struct stat_or_stat64 stat_temp; if (scm_is_integer (object)) { SCM_SYSCALL (rv = fstat_or_fstat64 (scm_to_int (object), &stat_temp)); } else if (scm_is_string (object)) { char *file = scm_to_locale_string (object); SCM_SYSCALL (rv = stat_or_stat64 (file, &stat_temp)); free (file); } else { object = SCM_COERCE_OUTPORT (object); SCM_VALIDATE_OPFPORT (1, object); fdes = SCM_FPORT_FDES (object); SCM_SYSCALL (rv = fstat_or_fstat64 (fdes, &stat_temp)); } if (rv == -1) { if (SCM_UNBNDP (exception_on_error) || scm_is_true (exception_on_error)) { int en = errno; SCM_SYSERROR_MSG ("~A: ~S", scm_list_2 (scm_strerror (scm_from_int (en)), object), en); } else return SCM_BOOL_F; } return scm_stat2scm (&stat_temp); }
0
238,658
static int resolve_map_arg_type(struct bpf_verifier_env *env, const struct bpf_call_arg_meta *meta, enum bpf_arg_type *arg_type) { if (!meta->map_ptr) { /* kernel subsystem misconfigured verifier */ verbose(env, "invalid map_ptr to access map->type\n"); return -EACCES; } switch (meta->map_ptr->map_type) { case BPF_MAP_TYPE_SOCKMAP: case BPF_MAP_TYPE_SOCKHASH: if (*arg_type == ARG_PTR_TO_MAP_VALUE) { *arg_type = ARG_PTR_TO_BTF_ID_SOCK_COMMON; } else { verbose(env, "invalid arg_type for sockmap/sockhash\n"); return -EINVAL; } break; case BPF_MAP_TYPE_BLOOM_FILTER: if (meta->func_id == BPF_FUNC_map_peek_elem) *arg_type = ARG_PTR_TO_MAP_VALUE; break; default: break; } return 0; }
0
369,107
/* Returns true if we found and killed one or more timeouts */ static __cold bool io_kill_timeouts(struct io_ring_ctx *ctx, struct task_struct *tsk, bool cancel_all) { struct io_kiocb *req, *tmp; int canceled = 0; spin_lock(&ctx->completion_lock); spin_lock_irq(&ctx->timeout_lock); list_for_each_entry_safe(req, tmp, &ctx->timeout_list, timeout.list) { if (io_match_task(req, tsk, cancel_all)) { io_kill_timeout(req, -ECANCELED); canceled++; } } spin_unlock_irq(&ctx->timeout_lock); if (canceled != 0) io_commit_cqring(ctx); spin_unlock(&ctx->completion_lock); if (canceled != 0) io_cqring_ev_posted(ctx); return canceled != 0;
0
369,396
static __cold int io_uring_create(unsigned entries, struct io_uring_params *p, struct io_uring_params __user *params) { struct io_ring_ctx *ctx; struct file *file; int ret; if (!entries) return -EINVAL; if (entries > IORING_MAX_ENTRIES) { if (!(p->flags & IORING_SETUP_CLAMP)) return -EINVAL; entries = IORING_MAX_ENTRIES; } /* * Use twice as many entries for the CQ ring. It's possible for the * application to drive a higher depth than the size of the SQ ring, * since the sqes are only used at submission time. This allows for * some flexibility in overcommitting a bit. If the application has * set IORING_SETUP_CQSIZE, it will have passed in the desired number * of CQ ring entries manually. */ p->sq_entries = roundup_pow_of_two(entries); if (p->flags & IORING_SETUP_CQSIZE) { /* * If IORING_SETUP_CQSIZE is set, we do the same roundup * to a power-of-two, if it isn't already. We do NOT impose * any cq vs sq ring sizing. */ if (!p->cq_entries) return -EINVAL; if (p->cq_entries > IORING_MAX_CQ_ENTRIES) { if (!(p->flags & IORING_SETUP_CLAMP)) return -EINVAL; p->cq_entries = IORING_MAX_CQ_ENTRIES; } p->cq_entries = roundup_pow_of_two(p->cq_entries); if (p->cq_entries < p->sq_entries) return -EINVAL; } else { p->cq_entries = 2 * p->sq_entries; } ctx = io_ring_ctx_alloc(p); if (!ctx) return -ENOMEM; ctx->compat = in_compat_syscall(); if (!capable(CAP_IPC_LOCK)) ctx->user = get_uid(current_user()); /* * This is just grabbed for accounting purposes. When a process exits, * the mm is exited and dropped before the files, hence we need to hang * on to this mm purely for the purposes of being able to unaccount * memory (locked/pinned vm). It's not used for anything else. */ mmgrab(current->mm); ctx->mm_account = current->mm; ret = io_allocate_scq_urings(ctx, p); if (ret) goto err; ret = io_sq_offload_create(ctx, p); if (ret) goto err; /* always set a rsrc node */ ret = io_rsrc_node_switch_start(ctx); if (ret) goto err; io_rsrc_node_switch(ctx, NULL); memset(&p->sq_off, 0, sizeof(p->sq_off)); p->sq_off.head = offsetof(struct io_rings, sq.head); p->sq_off.tail = offsetof(struct io_rings, sq.tail); p->sq_off.ring_mask = offsetof(struct io_rings, sq_ring_mask); p->sq_off.ring_entries = offsetof(struct io_rings, sq_ring_entries); p->sq_off.flags = offsetof(struct io_rings, sq_flags); p->sq_off.dropped = offsetof(struct io_rings, sq_dropped); p->sq_off.array = (char *)ctx->sq_array - (char *)ctx->rings; memset(&p->cq_off, 0, sizeof(p->cq_off)); p->cq_off.head = offsetof(struct io_rings, cq.head); p->cq_off.tail = offsetof(struct io_rings, cq.tail); p->cq_off.ring_mask = offsetof(struct io_rings, cq_ring_mask); p->cq_off.ring_entries = offsetof(struct io_rings, cq_ring_entries); p->cq_off.overflow = offsetof(struct io_rings, cq_overflow); p->cq_off.cqes = offsetof(struct io_rings, cqes); p->cq_off.flags = offsetof(struct io_rings, cq_flags); p->features = IORING_FEAT_SINGLE_MMAP | IORING_FEAT_NODROP | IORING_FEAT_SUBMIT_STABLE | IORING_FEAT_RW_CUR_POS | IORING_FEAT_CUR_PERSONALITY | IORING_FEAT_FAST_POLL | IORING_FEAT_POLL_32BITS | IORING_FEAT_SQPOLL_NONFIXED | IORING_FEAT_EXT_ARG | IORING_FEAT_NATIVE_WORKERS | IORING_FEAT_RSRC_TAGS | IORING_FEAT_CQE_SKIP | IORING_FEAT_LINKED_FILE; if (copy_to_user(params, p, sizeof(*p))) { ret = -EFAULT; goto err; } file = io_uring_get_file(ctx); if (IS_ERR(file)) { ret = PTR_ERR(file); goto err; } /* * Install ring fd as the very last thing, so we don't risk someone * having closed it before we finish setup */ ret = io_uring_install_fd(ctx, file); if (ret < 0) { /* fput will clean it up */ fput(file); return ret; } trace_io_uring_create(ret, ctx, p->sq_entries, p->cq_entries, p->flags); return ret; err: io_ring_ctx_wait_and_kill(ctx); return ret;
0
244,337
GF_Box *proj_type_box_new() { ISOM_DECL_BOX_ALLOC(GF_ProjectionTypeBox, GF_ISOM_BOX_TYPE_EQUI); //will be overwritten return (GF_Box *)tmp; }
0
231,532
__getcwd_generic (char *buf, size_t size) { /* Lengths of big file name components and entire file names, and a deep level of file name nesting. These numbers are not upper bounds; they are merely large values suitable for initial allocations, designed to be large enough for most real-world uses. */ enum { BIG_FILE_NAME_COMPONENT_LENGTH = 255, BIG_FILE_NAME_LENGTH = MIN (4095, PATH_MAX - 1), DEEP_NESTING = 100 }; #if HAVE_OPENAT_SUPPORT int fd = AT_FDCWD; bool fd_needs_closing = false; #else char dots[DEEP_NESTING * sizeof ".." + BIG_FILE_NAME_COMPONENT_LENGTH + 1]; char *dotlist = dots; size_t dotsize = sizeof dots; size_t dotlen = 0; #endif DIR *dirstream = NULL; dev_t rootdev, thisdev; ino_t rootino, thisino; char *dir; register char *dirp; struct __stat64_t64 st; size_t allocated = size; size_t used; /* A size of 1 byte is never useful. */ if (allocated == 1) { __set_errno (ERANGE); return NULL; } #if HAVE_MINIMALLY_WORKING_GETCWD /* If AT_FDCWD is not defined, the algorithm below is O(N**2) and this is much slower than the system getcwd (at least on GNU/Linux). So trust the system getcwd's results unless they look suspicious. Use the system getcwd even if we have openat support, since the system getcwd works even when a parent is unreadable, while the openat-based approach does not. But on AIX 5.1..7.1, the system getcwd is not even minimally working: If the current directory name is slightly longer than PATH_MAX, it omits the first directory component and returns this wrong result with errno = 0. */ # undef getcwd dir = getcwd_system (buf, size); if (dir || (size && errno == ERANGE)) return dir; /* Solaris getcwd (NULL, 0) fails with errno == EINVAL, but it has internal magic that lets it work even if an ancestor directory is inaccessible, which is better in many cases. So in this case try again with a buffer that's almost always big enough. */ if (errno == EINVAL && buf == NULL && size == 0) { char big_buffer[BIG_FILE_NAME_LENGTH + 1]; dir = getcwd_system (big_buffer, sizeof big_buffer); if (dir) return strdup (dir); } # if HAVE_PARTLY_WORKING_GETCWD /* The system getcwd works, except it sometimes fails when it shouldn't, setting errno to ERANGE, ENAMETOOLONG, or ENOENT. */ if (errno != ERANGE && errno != ENAMETOOLONG && errno != ENOENT) return NULL; # endif #endif if (size == 0) { if (buf != NULL) { __set_errno (EINVAL); return NULL; } allocated = BIG_FILE_NAME_LENGTH + 1; } if (buf == NULL) { dir = malloc (allocated); if (dir == NULL) return NULL; } else dir = buf; dirp = dir + allocated; *--dirp = '\0'; if (__lstat64_time64 (".", &st) < 0) goto lose; thisdev = st.st_dev; thisino = st.st_ino; if (__lstat64_time64 ("/", &st) < 0) goto lose; rootdev = st.st_dev; rootino = st.st_ino; while (!(thisdev == rootdev && thisino == rootino)) { struct dirent64 *d; dev_t dotdev; ino_t dotino; bool mount_point; int parent_status; size_t dirroom; size_t namlen; bool use_d_ino = true; /* Look at the parent directory. */ #if HAVE_OPENAT_SUPPORT fd = __openat64 (fd, "..", O_RDONLY); if (fd < 0) goto lose; fd_needs_closing = true; parent_status = __fstat64_time64 (fd, &st); #else dotlist[dotlen++] = '.'; dotlist[dotlen++] = '.'; dotlist[dotlen] = '\0'; parent_status = __lstat64_time64 (dotlist, &st); #endif if (parent_status != 0) goto lose; if (dirstream && __closedir (dirstream) != 0) { dirstream = NULL; goto lose; } /* Figure out if this directory is a mount point. */ dotdev = st.st_dev; dotino = st.st_ino; mount_point = dotdev != thisdev; /* Search for the last directory. */ #if HAVE_OPENAT_SUPPORT dirstream = __fdopendir (fd); if (dirstream == NULL) goto lose; fd_needs_closing = false; #else dirstream = __opendir (dotlist); if (dirstream == NULL) goto lose; dotlist[dotlen++] = '/'; #endif for (;;) { /* Clear errno to distinguish EOF from error if readdir returns NULL. */ __set_errno (0); d = __readdir64 (dirstream); /* When we've iterated through all directory entries without finding one with a matching d_ino, rewind the stream and consider each name again, but this time, using lstat. This is necessary in a chroot on at least one system (glibc-2.3.6 + linux 2.6.12), where .., ../.., ../../.., etc. all had the same device number, yet the d_ino values for entries in / did not match those obtained via lstat. */ if (d == NULL && errno == 0 && use_d_ino) { use_d_ino = false; __rewinddir (dirstream); d = __readdir64 (dirstream); } if (d == NULL) { if (errno == 0) /* EOF on dirstream, which can mean e.g., that the current directory has been removed. */ __set_errno (ENOENT); goto lose; } if (d->d_name[0] == '.' && (d->d_name[1] == '\0' || (d->d_name[1] == '.' && d->d_name[2] == '\0'))) continue; if (use_d_ino) { bool match = (MATCHING_INO (d, thisino) || mount_point); if (! match) continue; } { int entry_status; #if HAVE_OPENAT_SUPPORT entry_status = __fstatat64_time64 (fd, d->d_name, &st, AT_SYMLINK_NOFOLLOW); #else /* Compute size needed for this file name, or for the file name ".." in the same directory, whichever is larger. Room for ".." might be needed the next time through the outer loop. */ size_t name_alloc = _D_ALLOC_NAMLEN (d); size_t filesize = dotlen + MAX (sizeof "..", name_alloc); if (filesize < dotlen) goto memory_exhausted; if (dotsize < filesize) { /* My, what a deep directory tree you have, Grandma. */ size_t newsize = MAX (filesize, dotsize * 2); size_t i; if (newsize < dotsize) goto memory_exhausted; if (dotlist != dots) free (dotlist); dotlist = malloc (newsize); if (dotlist == NULL) goto lose; dotsize = newsize; i = 0; do { dotlist[i++] = '.'; dotlist[i++] = '.'; dotlist[i++] = '/'; } while (i < dotlen); } memcpy (dotlist + dotlen, d->d_name, _D_ALLOC_NAMLEN (d)); entry_status = __lstat64_time64 (dotlist, &st); #endif /* We don't fail here if we cannot stat() a directory entry. This can happen when (network) file systems fail. If this entry is in fact the one we are looking for we will find out soon as we reach the end of the directory without having found anything. */ if (entry_status == 0 && S_ISDIR (st.st_mode) && st.st_dev == thisdev && st.st_ino == thisino) break; } } dirroom = dirp - dir; namlen = _D_EXACT_NAMLEN (d); if (dirroom <= namlen) { if (size != 0) { __set_errno (ERANGE); goto lose; } else { char *tmp; size_t oldsize = allocated; allocated += MAX (allocated, namlen); if (allocated < oldsize || ! (tmp = realloc (dir, allocated))) goto memory_exhausted; /* Move current contents up to the end of the buffer. This is guaranteed to be non-overlapping. */ dirp = memcpy (tmp + allocated - (oldsize - dirroom), tmp + dirroom, oldsize - dirroom); dir = tmp; } } dirp -= namlen; memcpy (dirp, d->d_name, namlen); *--dirp = '/'; thisdev = dotdev; thisino = dotino; } if (dirstream && __closedir (dirstream) != 0) { dirstream = NULL; goto lose; } if (dirp == &dir[allocated - 1]) *--dirp = '/'; #if ! HAVE_OPENAT_SUPPORT if (dotlist != dots) free (dotlist); #endif used = dir + allocated - dirp; memmove (dir, dirp, used); if (size == 0) /* Ensure that the buffer is only as large as necessary. */ buf = (used < allocated ? realloc (dir, used) : dir); if (buf == NULL) /* Either buf was NULL all along, or 'realloc' failed but we still have the original string. */ buf = dir; return buf; memory_exhausted: __set_errno (ENOMEM); lose: { int save = errno; if (dirstream) __closedir (dirstream); #if HAVE_OPENAT_SUPPORT if (fd_needs_closing) __close_nocancel_nostatus (fd); #else if (dotlist != dots) free (dotlist); #endif if (buf == NULL) free (dir); __set_errno (save); } return NULL; }
0
359,637
DEFUN (neighbor_attr_unchanged, neighbor_attr_unchanged_cmd, NEIGHBOR_CMD2 "attribute-unchanged", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "BGP attribute is propagated unchanged to this neighbor\n") { return peer_af_flag_set_vty (vty, argv[0], bgp_node_afi (vty), bgp_node_safi (vty), (PEER_FLAG_AS_PATH_UNCHANGED | PEER_FLAG_NEXTHOP_UNCHANGED | PEER_FLAG_MED_UNCHANGED)); }
0
389,712
check_for_string_or_func_arg(typval_T *args, int idx) { if (args[idx].v_type != VAR_PARTIAL && args[idx].v_type != VAR_FUNC && args[idx].v_type != VAR_STRING) { semsg(_(e_string_or_function_required_for_argument_nr), idx + 1); return FAIL; } return OK; }
0
271,526
void ReshapeSparseTensor(OpKernelContext *context, const Tensor &input_indices_in, const Tensor &input_shape_in, const Tensor &target_shape_in, int output_indices_idx, int output_shape_idx) { OP_REQUIRES(context, TensorShapeUtils::IsMatrix(input_indices_in.shape()), errors::InvalidArgument( "Input indices should be a matrix but received shape ", input_indices_in.shape().DebugString())); OP_REQUIRES(context, TensorShapeUtils::IsVector(input_shape_in.shape()), errors::InvalidArgument( "Input shape should be a vector but received shape ", input_shape_in.shape().DebugString())); OP_REQUIRES(context, TensorShapeUtils::IsVector(target_shape_in.shape()), errors::InvalidArgument( "Target shape should be a vector but received shape ", target_shape_in.shape().DebugString())); const int64_t output_rank = target_shape_in.NumElements(); const TensorShape input_shape(input_shape_in.vec<int64>()); const int64_t dense_size = input_shape.num_elements(); const int64_t nnz = input_indices_in.shape().dim_size(0); // Compute the output shape. Determine product of specified dimensions, and // find the index of the unspecified one. TensorShape output_shape; int64_t product = 1; int unknown_index = -1; auto target_shape = target_shape_in.vec<int64>(); for (int d = 0; d < output_rank; ++d) { const int64_t size = target_shape(d); if (size == -1) { OP_REQUIRES( context, unknown_index == -1, errors::InvalidArgument("only one output dimension may be -1, " "not both ", unknown_index, " and ", d)); unknown_index = d; output_shape.AddDim(1); } else { OP_REQUIRES(context, size >= 0, errors::InvalidArgument("size ", d, " must be non-negative, not ", size)); product *= size; output_shape.AddDim(size); } } if (unknown_index != -1) { OP_REQUIRES( context, product > 0, errors::InvalidArgument("reshape cannot infer the missing " "input size for an empty tensor unless all " "specified input sizes are non-zero")); const int64_t missing = dense_size / product; OP_REQUIRES( context, product * missing == dense_size, errors::InvalidArgument( "Input to reshape is a SparseTensor with ", dense_size, " dense values, but the requested shape requires a multiple of ", product, ". input_shape=", input_shape.DebugString(), " output_shape=", output_shape.DebugString())); output_shape.set_dim(unknown_index, missing); } OP_REQUIRES( context, output_shape.num_elements() == dense_size, errors::InvalidArgument("Input to reshape is a tensor with ", dense_size, " dense values, but the requested shape has ", output_shape.num_elements(), ". input_shape=", input_shape.DebugString(), " output_shape=", output_shape.DebugString())); // Optimize for reshaping to the same shape. if (input_shape == output_shape) { context->set_output(output_indices_idx, input_indices_in); context->set_output(output_shape_idx, input_shape_in); return; } Tensor *result_shape = nullptr; OP_REQUIRES_OK(context, context->allocate_output(output_shape_idx, TensorShape({output_rank}), &result_shape)); auto output_shape_vec = result_shape->vec<int64>(); for (int j = 0; j < output_shape.dims(); ++j) { output_shape_vec(j) = output_shape.dim_size(j); } Tensor *result_indices = nullptr; OP_REQUIRES_OK(context, context->allocate_output(output_indices_idx, TensorShape({nnz, output_rank}), &result_indices)); if (nnz > 0) { OP_REQUIRES( context, dense_size > 0 && product > 0, errors::InvalidArgument( "Input tensor has ", nnz, " non zero elements but input shape (", input_shape.DebugString(), ") or output shape (", output_shape.DebugString(), ") is empty")); OP_REQUIRES_OK(context, functor::ReshapeSparseTensorFunctor<Device>()( context, input_shape, output_shape, input_indices_in.matrix<int64>(), result_indices->matrix<int64>())); } }
0
175,691
virtual void ForgetWifiNetwork(const std::string& service_path) {}
0
264,682
lexer_hex_to_code_point (const uint8_t *source_p, /**< current source position */ parser_line_counter_t length) /**< source length */ { lit_code_point_t result = 0; do { uint32_t byte = *source_p++; result <<= 4; if (byte >= LIT_CHAR_0 && byte <= LIT_CHAR_9) { result += byte - LIT_CHAR_0; } else { byte = LEXER_TO_ASCII_LOWERCASE (byte); if (byte >= LIT_CHAR_LOWERCASE_A && byte <= LIT_CHAR_LOWERCASE_F) { result += byte - (LIT_CHAR_LOWERCASE_A - 10); } else { return UINT32_MAX; } } } while (--length > 0); return result; } /* lexer_hex_to_code_point */
0
317,313
static int selinux_inode_readlink(struct dentry *dentry) { const struct cred *cred = current_cred(); return dentry_has_perm(cred, dentry, FILE__READ); }
0
458,987
http_DoConnection(struct http *hp, stream_close_t sc_close) { const char *h, *b, *e; stream_close_t retval; unsigned u, v; struct http_hdrflg *f; CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); assert(sc_close == SC_REQ_CLOSE || sc_close == SC_RESP_CLOSE); if (hp->protover == 10) retval = SC_REQ_HTTP10; else retval = SC_NULL; http_CollectHdr(hp, H_Connection); if (!http_GetHdr(hp, H_Connection, &h)) return (retval); AN(h); while (http_split(&h, NULL, ",", &b, &e)) { u = pdiff(b, e); if (u == 5 && http_hdr_at(b, "close", u)) retval = sc_close; if (u == 10 && http_hdr_at(b, "keep-alive", u)) retval = SC_NULL; /* Refuse removal of well-known-headers if they would pass. */ f = http_hdr_flags(b, e); if (f != NULL && !(f->flag & HTTPH_R_PASS)) return (SC_RX_BAD); for (v = HTTP_HDR_FIRST; v < hp->nhd; v++) { Tcheck(hp->hd[v]); if (hp->hd[v].e < hp->hd[v].b + u + 1) continue; if (hp->hd[v].b[u] != ':') continue; if (!http_hdr_at(b, hp->hd[v].b, u)) continue; hp->hdf[v] |= HDF_FILTER; } } CHECK_OBJ_NOTNULL(retval, STREAM_CLOSE_MAGIC); return (retval); }
0
437,304
print_optimize_info(FILE* f, regex_t* reg) { static const char* on[] = { "NONE", "EXACT", "EXACT_FAST", "EXACT_FAST_STEP_FORWARD", "EXACT_IC", "MAP" }; fprintf(f, "optimize: %s\n", on[reg->optimize]); fprintf(f, " anchor: "); print_anchor(f, reg->anchor); if ((reg->anchor & ANCHOR_END_BUF_MASK) != 0) print_distance_range(f, reg->anchor_dmin, reg->anchor_dmax); fprintf(f, "\n"); if (reg->optimize) { fprintf(f, " sub anchor: "); print_anchor(f, reg->sub_anchor); fprintf(f, "\n"); } fprintf(f, "\n"); if (reg->exact) { UChar *p; fprintf(f, "exact: ["); for (p = reg->exact; p < reg->exact_end; p++) { fputc(*p, f); } fprintf(f, "]: length: %ld\n", (reg->exact_end - reg->exact)); } else if (reg->optimize & OPTIMIZE_MAP) { int c, i, n = 0; for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) if (reg->map[i]) n++; fprintf(f, "map: n=%d\n", n); if (n > 0) { c = 0; fputc('[', f); for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) { if (reg->map[i] != 0) { if (c > 0) fputs(", ", f); c++; if (ONIGENC_MBC_MAXLEN(reg->enc) == 1 && ONIGENC_IS_CODE_PRINT(reg->enc, (OnigCodePoint )i)) fputc(i, f); else fprintf(f, "%d", i); } } fprintf(f, "]\n"); } } }
0
333,508
int gdTransformAffineGetImage(gdImagePtr *dst, const gdImagePtr src, gdRectPtr src_area, const double affine[6]) { int res; double m[6]; gdRect bbox; gdRect area_full; if (src_area == NULL) { area_full.x = 0; area_full.y = 0; area_full.width = gdImageSX(src); area_full.height = gdImageSY(src); src_area = &area_full; } gdTransformAffineBoundingBox(src_area, affine, &bbox); *dst = gdImageCreateTrueColor(bbox.width, bbox.height); if (*dst == NULL) { return GD_FALSE; } (*dst)->saveAlphaFlag = 1; if (!src->trueColor) { gdImagePaletteToTrueColor(src); } /* Translate to dst origin (0,0) */ gdAffineTranslate(m, -bbox.x, -bbox.y); gdAffineConcat(m, affine, m); gdImageAlphaBlending(*dst, 0); res = gdTransformAffineCopy(*dst, 0,0, src, src_area, m); if (res != GD_TRUE) { gdImageDestroy(*dst); dst = NULL; return GD_FALSE; } else { return GD_TRUE; } }
0
224,758
GF_Err iref_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem) { GF_ItemReferenceBox *ptr = (GF_ItemReferenceBox *)s; BOX_FIELD_LIST_ASSIGN(references) return GF_OK; }
0
336,687
GArray* reds_get_renderers(RedsState *reds) { return reds->config->renderers; }
0
432,723
static void ipa_device_close(wmfAPI * API) { wmf_magick_t *ddata = WMF_MAGICK_GetData(API); if (ddata->draw_wand != (DrawingWand *) NULL) { DestroyDrawingWand(ddata->draw_wand); ddata->draw_wand=(DrawingWand *) NULL; } if (ddata->draw_info != (DrawInfo *) NULL) { DestroyDrawInfo(ddata->draw_info); ddata->draw_info=(DrawInfo *)NULL; } RelinquishMagickMemory(WMF_MAGICK_GetFontData(API)->ps_name); }
0
292,153
void LinkResolver::check_klass_accessability(Klass* ref_klass, Klass* sel_klass, bool fold_type_to_class, TRAPS) { Klass* base_klass = sel_klass; if (fold_type_to_class) { if (sel_klass->is_objArray_klass()) { base_klass = ObjArrayKlass::cast(sel_klass)->bottom_klass(); } // The element type could be a typeArray - we only need the access // check if it is a reference to another class. if (!base_klass->is_instance_klass()) { return; // no relevant check to do } } Reflection::VerifyClassAccessResults vca_result = Reflection::verify_class_access(ref_klass, InstanceKlass::cast(base_klass), true); if (vca_result != Reflection::ACCESS_OK) { ResourceMark rm(THREAD); char* msg = Reflection::verify_class_access_msg(ref_klass, InstanceKlass::cast(base_klass), vca_result); bool same_module = (base_klass->module() == ref_klass->module()); if (msg == NULL) { Exceptions::fthrow( THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalAccessError(), "failed to access class %s from class %s (%s%s%s)", base_klass->external_name(), ref_klass->external_name(), (same_module) ? base_klass->joint_in_module_of_loader(ref_klass) : base_klass->class_in_module_of_loader(), (same_module) ? "" : "; ", (same_module) ? "" : ref_klass->class_in_module_of_loader()); } else { // Use module specific message returned by verify_class_access_msg(). Exceptions::fthrow( THREAD_AND_LOCATION, vmSymbols::java_lang_IllegalAccessError(), "%s", msg); } } }
0
240,589
void Compute(OpKernelContext* context) override { const Tensor& value = context->input(1); core::RefCountPtr<Var> variable; OP_REQUIRES_OK(context, LookupOrCreateResource<Var>( context, HandleFromInput(context, 0), &variable, [](Var** ptr) { // Created on host. *ptr = new Var(DT_VARIANT); return Status::OK(); })); // For purposes of forwarding DT_VARIANT, we want the least // restrictive attr; we already know the input is on host. AllocatorAttributes attr; // Copying is unnecessary if we are the last user of the value // tensor, we can just adopt the input tensor's buffer instead. // Note that Variant objects themselves always reside on host. // // We nevertheless want to signal to the runtime that the tensor // should reside in memory of the associated device, as Variant // tensors may be marked as sitting on either CPU or GPU. This // helps to elide one or more copies. std::unique_ptr<Tensor> input_alias = context->forward_input( 1, OpKernelContext::Params::kNoReservation /*output_index*/, DT_VARIANT, value.shape(), DEVICE_MEMORY /* HOST_MEMORY is only reserved for special cases */, attr); mutex_lock ml(*variable->mu()); OP_REQUIRES(context, variable->tensor()->dtype() == DT_VARIANT, errors::InvalidArgument( "Trying to assign variable with wrong dtype. Expected ", DataTypeString(variable->tensor()->dtype()), " got ", DataTypeString(DT_VARIANT))); variable->is_initialized = true; *variable->tensor() = Tensor(DT_VARIANT, value.shape()); if (input_alias) { *variable->tensor() = *input_alias; return; } // Need to copy, but maybe we can re-use variable's buffer? if (!variable->tensor()->RefCountIsOne() || !variable->tensor()->shape().IsSameSize(value.shape())) { // Allocation of DT_VARIANT is always on host. attr.set_on_host(true); OP_REQUIRES_OK(context, context->allocate_temp(DT_VARIANT, value.shape(), variable->tensor(), attr)); } const auto elements_in = value.flat<Variant>(); auto elements_out = variable->tensor()->flat<Variant>(); for (int64_t i = 0; i < elements_in.size(); ++i) { elements_out(i) = elements_in(i); } }
0
255,783
svn_repos_authz_check_access(svn_authz_t *authz, const char *repos_name, const char *path, const char *user, svn_repos_authz_access_t required_access, svn_boolean_t *access_granted, apr_pool_t *pool) { const authz_access_t required = ((required_access & svn_authz_read ? authz_access_read_flag : 0) | (required_access & svn_authz_write ? authz_access_write_flag : 0)); /* Pick or create the suitable pre-filtered path rule tree. */ authz_user_rules_t *rules = get_user_rules( authz, (repos_name ? repos_name : AUTHZ_ANY_REPOSITORY), user); /* In many scenarios, users have uniform access to a repository * (blanket access or no access at all). * * In these cases, don't bother creating or consulting the filtered tree. */ if ((rules->global_rights.min_access & required) == required) { *access_granted = TRUE; return SVN_NO_ERROR; } if ((rules->global_rights.max_access & required) != required) { *access_granted = FALSE; return SVN_NO_ERROR; } /* No specific path given, i.e. looking for anywhere in the tree? */ if (!path) { *access_granted = ((rules->global_rights.max_access & required) == required); return SVN_NO_ERROR; } /* Rules tree lookup */ /* Did we already filter the data model? */ if (!rules->root) SVN_ERR(filter_tree(authz, pool)); /* Re-use previous lookup results, if possible. */ path = init_lockup_state(authz->filtered->lookup_state, authz->filtered->root, path); /* Sanity check. */ SVN_ERR_ASSERT(path[0] == '/'); /* Determine the granted access for the requested path. * PATH does not need to be normalized for lockup(). */ *access_granted = lookup(rules->lookup_state, path, required, !!(required_access & svn_authz_recursive), pool); return SVN_NO_ERROR; }
0
462,572
bool controller::trylock_reload_mutex() { if (reload_mutex.try_lock()) { LOG(level::DEBUG, "controller::trylock_reload_mutex succeeded"); return true; } LOG(level::DEBUG, "controller::trylock_reload_mutex failed"); return false; }
0
447,054
void HttpIo::HttpImpl::writeRemote(const byte* data, size_t size, long from, long to) { std::string scriptPath(getEnv(envHTTPPOST)); if (scriptPath == "") { throw Error(1, "Please set the path of the server script to handle http post data to EXIV2_HTTP_POST environmental variable."); } // standadize the path without "/" at the beginning. std::size_t protocolIndex = scriptPath.find("://"); if (protocolIndex == std::string::npos && scriptPath[0] != '/') { scriptPath = "/" + scriptPath; } Exiv2::Dictionary response; Exiv2::Dictionary request; std::string errors; Uri scriptUri = Exiv2::Uri::Parse(scriptPath); request["server"] = scriptUri.Host == "" ? hostInfo_.Host : scriptUri.Host; if (scriptUri.Port != "") request["port"] = scriptUri.Port; request["page"] = scriptUri.Path; request["verb"] = "POST"; // encode base64 size_t encodeLength = ((size + 2) / 3) * 4 + 1; char* encodeData = new char[encodeLength]; base64encode(data, size, encodeData, encodeLength); // url encode char* urlencodeData = urlencode(encodeData); delete[] encodeData; std::stringstream ss; ss << "path=" << hostInfo_.Path << "&" << "from=" << from << "&" << "to=" << to << "&" << "data=" << urlencodeData; std::string postData = ss.str(); delete[] urlencodeData; // create the header ss.str(""); ss << "Content-Length: " << postData.length() << "\n" << "Content-Type: application/x-www-form-urlencoded\n" << "\n" << postData << "\r\n"; request["header"] = ss.str(); int serverCode = http(request, response, errors); if (serverCode < 0 || serverCode >= 400 || errors.compare("") != 0) { throw Error(55, "Server", serverCode); } }
0
220,810
inline int32_t MultiplyByQuantizedMultiplier(int32_t x, int32_t quantized_multiplier, int shift) { using gemmlowp::RoundingDivideByPOT; using gemmlowp::SaturatingRoundingDoublingHighMul; int left_shift = shift > 0 ? shift : 0; int right_shift = shift > 0 ? 0 : -shift; return RoundingDivideByPOT(SaturatingRoundingDoublingHighMul( x * (1 << left_shift), quantized_multiplier), right_shift); }
0
317,368
static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr) { const struct cred *cred = current_cred(); struct inode *inode = d_backing_inode(dentry); unsigned int ia_valid = iattr->ia_valid; __u32 av = FILE__WRITE; /* ATTR_FORCE is just used for ATTR_KILL_S[UG]ID. */ if (ia_valid & ATTR_FORCE) { ia_valid &= ~(ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_MODE | ATTR_FORCE); if (!ia_valid) return 0; } if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_ATIME_SET | ATTR_MTIME_SET | ATTR_TIMES_SET)) return dentry_has_perm(cred, dentry, FILE__SETATTR); if (selinux_policycap_openperm() && inode->i_sb->s_magic != SOCKFS_MAGIC && (ia_valid & ATTR_SIZE) && !(ia_valid & ATTR_FILE)) av |= FILE__OPEN; return dentry_has_perm(cred, dentry, av); }
0
261,232
int wm_SemUnlock(wm_Sem *s){ pthread_mutex_lock(&s->mutex); s->lockCount--; pthread_cond_signal(&s->cond); pthread_mutex_unlock(&s->mutex); return 0; }
0
513,188
void plugin_thdvar_init(THD *thd) { plugin_ref old_table_plugin= thd->variables.table_plugin; plugin_ref old_tmp_table_plugin= thd->variables.tmp_table_plugin; plugin_ref old_enforced_table_plugin= thd->variables.enforced_table_plugin; DBUG_ENTER("plugin_thdvar_init"); // This function may be called many times per THD (e.g. on COM_CHANGE_USER) thd->variables.table_plugin= NULL; thd->variables.tmp_table_plugin= NULL; thd->variables.enforced_table_plugin= NULL; cleanup_variables(&thd->variables); thd->variables= global_system_variables; /* we are going to allocate these lazily */ thd->variables.dynamic_variables_version= 0; thd->variables.dynamic_variables_size= 0; thd->variables.dynamic_variables_ptr= 0; mysql_mutex_lock(&LOCK_plugin); thd->variables.table_plugin= intern_plugin_lock(NULL, global_system_variables.table_plugin); if (global_system_variables.tmp_table_plugin) thd->variables.tmp_table_plugin= intern_plugin_lock(NULL, global_system_variables.tmp_table_plugin); if (global_system_variables.enforced_table_plugin) thd->variables.enforced_table_plugin= intern_plugin_lock(NULL, global_system_variables.enforced_table_plugin); intern_plugin_unlock(NULL, old_table_plugin); intern_plugin_unlock(NULL, old_tmp_table_plugin); intern_plugin_unlock(NULL, old_enforced_table_plugin); mysql_mutex_unlock(&LOCK_plugin); DBUG_VOID_RETURN; }
0
336,535
MainDispatcher* reds_get_main_dispatcher(RedsState *reds) { return reds->main_dispatcher.get(); }
0
416,358
cmdline_wildchar_complete( int c, int escape, int *did_wild_list, int *wim_index_p, expand_T *xp, int *gotesc) { int wim_index = *wim_index_p; int res; int j; int options = WILD_NO_BEEP; if (wim_flags[wim_index] & WIM_BUFLASTUSED) options |= WILD_BUFLASTUSED; if (xp->xp_numfiles > 0) // typed p_wc at least twice { // if 'wildmode' contains "list" may still need to list if (xp->xp_numfiles > 1 && !*did_wild_list && ((wim_flags[wim_index] & WIM_LIST) || (p_wmnu && (wim_flags[wim_index] & WIM_FULL) != 0))) { (void)showmatches(xp, p_wmnu && ((wim_flags[wim_index] & WIM_LIST) == 0)); redrawcmd(); *did_wild_list = TRUE; } if (wim_flags[wim_index] & WIM_LONGEST) res = nextwild(xp, WILD_LONGEST, options, escape); else if (wim_flags[wim_index] & WIM_FULL) res = nextwild(xp, WILD_NEXT, options, escape); else res = OK; // don't insert 'wildchar' now } else // typed p_wc first time { wim_index = 0; j = ccline.cmdpos; // if 'wildmode' first contains "longest", get longest // common part if (wim_flags[0] & WIM_LONGEST) res = nextwild(xp, WILD_LONGEST, options, escape); else res = nextwild(xp, WILD_EXPAND_KEEP, options, escape); // if interrupted while completing, behave like it failed if (got_int) { (void)vpeekc(); // remove <C-C> from input stream got_int = FALSE; // don't abandon the command line (void)ExpandOne(xp, NULL, NULL, 0, WILD_FREE); xp->xp_context = EXPAND_NOTHING; *wim_index_p = wim_index; return CMDLINE_CHANGED; } // when more than one match, and 'wildmode' first contains // "list", or no change and 'wildmode' contains "longest,list", // list all matches if (res == OK && xp->xp_numfiles > 1) { // a "longest" that didn't do anything is skipped (but not // "list:longest") if (wim_flags[0] == WIM_LONGEST && ccline.cmdpos == j) wim_index = 1; if ((wim_flags[wim_index] & WIM_LIST) || (p_wmnu && (wim_flags[wim_index] & WIM_FULL) != 0)) { if (!(wim_flags[0] & WIM_LONGEST)) { int p_wmnu_save = p_wmnu; p_wmnu = 0; // remove match nextwild(xp, WILD_PREV, 0, escape); p_wmnu = p_wmnu_save; } (void)showmatches(xp, p_wmnu && ((wim_flags[wim_index] & WIM_LIST) == 0)); redrawcmd(); *did_wild_list = TRUE; if (wim_flags[wim_index] & WIM_LONGEST) nextwild(xp, WILD_LONGEST, options, escape); else if (wim_flags[wim_index] & WIM_FULL) nextwild(xp, WILD_NEXT, options, escape); } else vim_beep(BO_WILD); } else if (xp->xp_numfiles == -1) xp->xp_context = EXPAND_NOTHING; } if (wim_index < 3) ++wim_index; if (c == ESC) *gotesc = TRUE; *wim_index_p = wim_index; return (res == OK) ? CMDLINE_CHANGED : CMDLINE_NOT_CHANGED; }
0
336,006
static int sr_read(struct usbnet *dev, u8 reg, u16 length, void *data) { int err; err = usbnet_read_cmd(dev, SR_RD_REGS, SR_REQ_RD_REG, 0, reg, data, length); if ((err != length) && (err >= 0)) err = -EINVAL; return err; }
0
328,937
R_API char *r_bin_java_print_methodref_cp_stringify(RBinJavaCPTypeObj *obj) { return r_str_newf ("%d.0x%04"PFMT64x ".%s.%d.%d", obj->metas->ord, obj->file_offset + obj->loadaddr, ((RBinJavaCPTypeMetas *) obj->metas->type_info)->name, obj->info.cp_method.class_idx, obj->info.cp_method.name_and_type_idx); }
0
509,480
int ha_maria::create(const char *name, TABLE *table_arg, HA_CREATE_INFO *ha_create_info) { int error; uint create_flags= 0, record_count= 0, i; char buff[FN_REFLEN]; MARIA_KEYDEF *keydef; MARIA_COLUMNDEF *recinfo; MARIA_CREATE_INFO create_info; TABLE_SHARE *share= table_arg->s; uint options= share->db_options_in_use; ha_table_option_struct *table_options= table_arg->s->option_struct; enum data_file_type row_type; THD *thd= current_thd; DBUG_ENTER("ha_maria::create"); for (i= 0; i < share->keys; i++) { if (table_arg->key_info[i].flags & HA_USES_PARSER) { create_flags|= HA_CREATE_RELIES_ON_SQL_LAYER; break; } } /* Note: BLOCK_RECORD is used if table is transactional */ row_type= maria_row_type(ha_create_info); if (ha_create_info->transactional == HA_CHOICE_YES && ha_create_info->row_type != ROW_TYPE_PAGE && ha_create_info->row_type != ROW_TYPE_NOT_USED && ha_create_info->row_type != ROW_TYPE_DEFAULT) push_warning(thd, Sql_condition::WARN_LEVEL_NOTE, ER_ILLEGAL_HA_CREATE_OPTION, "Row format set to PAGE because of TRANSACTIONAL=1 option"); if (share->table_type == TABLE_TYPE_SEQUENCE) { /* For sequences, the simples record type is appropriate */ row_type= STATIC_RECORD; ha_create_info->transactional= HA_CHOICE_NO; } bzero((char*) &create_info, sizeof(create_info)); if ((error= table2maria(table_arg, row_type, &keydef, &recinfo, &record_count, &create_info))) DBUG_RETURN(error); /* purecov: inspected */ create_info.max_rows= share->max_rows; create_info.reloc_rows= share->min_rows; create_info.with_auto_increment= share->next_number_key_offset == 0; create_info.auto_increment= (ha_create_info->auto_increment_value ? ha_create_info->auto_increment_value -1 : (ulonglong) 0); create_info.data_file_length= ((ulonglong) share->max_rows * share->avg_row_length); create_info.data_file_name= ha_create_info->data_file_name; create_info.index_file_name= ha_create_info->index_file_name; create_info.language= share->table_charset->number; if (ht != maria_hton) { /* S3 engine */ create_info.s3_block_size= (ulong) table_options->s3_block_size; create_info.compression_algorithm= table_options->compression_algorithm; } /* Table is transactional: - If the user specify that table is transactional (in this case row type is forced to BLOCK_RECORD) - If they specify BLOCK_RECORD without specifying transactional behaviour Shouldn't this test be pushed down to maria_create()? Because currently, ma_test1 -T crashes: it creates a table with DYNAMIC_RECORD but has born_transactional==1, which confuses some recovery-related code. */ create_info.transactional= (row_type == BLOCK_RECORD && ha_create_info->transactional != HA_CHOICE_NO); if (ha_create_info->tmp_table()) { create_flags|= HA_CREATE_TMP_TABLE | HA_CREATE_DELAY_KEY_WRITE; create_info.transactional= 0; } if (ha_create_info->options & HA_CREATE_KEEP_FILES) create_flags|= HA_CREATE_KEEP_FILES; if (options & HA_OPTION_PACK_RECORD) create_flags|= HA_PACK_RECORD; if (options & HA_OPTION_CHECKSUM) create_flags|= HA_CREATE_CHECKSUM; if (options & HA_OPTION_DELAY_KEY_WRITE) create_flags|= HA_CREATE_DELAY_KEY_WRITE; if ((ha_create_info->page_checksum == HA_CHOICE_UNDEF && maria_page_checksums) || ha_create_info->page_checksum == HA_CHOICE_YES) create_flags|= HA_CREATE_PAGE_CHECKSUM; (void) translog_log_debug_info(0, LOGREC_DEBUG_INFO_QUERY, (uchar*) thd->query(), thd->query_length()); create_info.encrypted= maria_encrypt_tables && ht == maria_hton; /* TODO: Check that the following fn_format is really needed */ error= maria_create(fn_format(buff, name, "", "", MY_UNPACK_FILENAME | MY_APPEND_EXT), row_type, share->keys, keydef, record_count, recinfo, 0, (MARIA_UNIQUEDEF *) 0, &create_info, create_flags); my_free(recinfo); DBUG_RETURN(error); }
0
404,752
struct file *fget_raw(unsigned int fd) { return __fget(fd, 0, 1); }
0
387,594
static int snd_ctl_card_info(struct snd_card *card, struct snd_ctl_file * ctl, unsigned int cmd, void __user *arg) { struct snd_ctl_card_info *info; info = kzalloc(sizeof(*info), GFP_KERNEL); if (! info) return -ENOMEM; down_read(&snd_ioctl_rwsem); info->card = card->number; strscpy(info->id, card->id, sizeof(info->id)); strscpy(info->driver, card->driver, sizeof(info->driver)); strscpy(info->name, card->shortname, sizeof(info->name)); strscpy(info->longname, card->longname, sizeof(info->longname)); strscpy(info->mixername, card->mixername, sizeof(info->mixername)); strscpy(info->components, card->components, sizeof(info->components)); up_read(&snd_ioctl_rwsem); if (copy_to_user(arg, info, sizeof(struct snd_ctl_card_info))) { kfree(info); return -EFAULT; } kfree(info); return 0; }
0
310,125
get_baudrate(TERMINAL *termp) { int my_ospeed; int result; if (GET_TTY(termp->Filedes, &termp->Nttyb) == OK) { #ifdef TERMIOS termp->Nttyb.c_oflag &= (unsigned) (~OFLAGS_TABS); #else termp->Nttyb.sg_flags &= (unsigned) (~XTABS); #endif } #ifdef USE_OLD_TTY result = (int) cfgetospeed(&(termp->Nttyb)); my_ospeed = (NCURSES_OSPEED) _nc_ospeed(result); #else /* !USE_OLD_TTY */ #ifdef TERMIOS my_ospeed = (NCURSES_OSPEED) cfgetospeed(&(termp->Nttyb)); #else my_ospeed = (NCURSES_OSPEED) termp->Nttyb.sg_ospeed; #endif result = _nc_baudrate(my_ospeed); #endif termp->_baudrate = result; ospeed = (NCURSES_OSPEED) my_ospeed; }
0
314,517
PJ_DEF(pjmedia_sdp_media*) pjmedia_sdp_media_clone_deactivate( pj_pool_t *pool, const pjmedia_sdp_media *rhs) { unsigned int i; pjmedia_sdp_media *m; PJ_ASSERT_RETURN(pool && rhs, NULL); m = PJ_POOL_ZALLOC_T(pool, pjmedia_sdp_media); pj_memcpy(m, rhs, sizeof(*m)); /* Clone the media line only */ pj_strdup (pool, &m->desc.media, &rhs->desc.media); pj_strdup (pool, &m->desc.transport, &rhs->desc.transport); for (i=0; i<rhs->desc.fmt_count; ++i) pj_strdup(pool, &m->desc.fmt[i], &rhs->desc.fmt[i]); if (rhs->conn) { m->conn = pjmedia_sdp_conn_clone (pool, rhs->conn); PJ_ASSERT_RETURN(m->conn != NULL, NULL); } m->bandw_count = rhs->bandw_count; for (i=0; i < rhs->bandw_count; ++i) { m->bandw[i] = pjmedia_sdp_bandw_clone (pool, rhs->bandw[i]); PJ_ASSERT_RETURN(m->bandw[i] != NULL, NULL); } /* And deactivate it */ pjmedia_sdp_media_deactivate(pool, m); return m; }
0
387,770
void InstanceKlass::set_implementor(Klass* k) { assert_lock_strong(Compile_lock); assert(is_interface(), "not interface"); Klass** addr = adr_implementor(); assert(addr != NULL, "null addr"); if (addr != NULL) { *addr = k; } }
0
436,156
static int io_epoll_ctl_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) { #if defined(CONFIG_EPOLL) if (sqe->ioprio || sqe->buf_index) return -EINVAL; if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL)) return -EINVAL; req->epoll.epfd = READ_ONCE(sqe->fd); req->epoll.op = READ_ONCE(sqe->len); req->epoll.fd = READ_ONCE(sqe->off); if (ep_op_has_event(req->epoll.op)) { struct epoll_event __user *ev; ev = u64_to_user_ptr(READ_ONCE(sqe->addr)); if (copy_from_user(&req->epoll.event, ev, sizeof(*ev))) return -EFAULT; } return 0; #else return -EOPNOTSUPP; #endif }
0
331,786
void QPaintEngineEx::drawPath(const QPainterPath &path) { if (!path.isEmpty()) draw(qtVectorPathForPath(path)); }
0
439,169
static MagickBooleanType WriteTXTImage(const ImageInfo *image_info,Image *image) { char buffer[MaxTextExtent], colorspace[MaxTextExtent], tuple[MaxTextExtent]; MagickBooleanType status; MagickOffsetType scene; MagickPixelPacket pixel; register const IndexPacket *indexes; register const PixelPacket *p; register ssize_t x; size_t imageListLength; ssize_t y; /* Open output image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickCoreSignature); assert(image != (Image *) NULL); assert(image->signature == MagickCoreSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); status=OpenBlob(image_info,image,WriteBlobMode,&image->exception); if (status == MagickFalse) return(status); scene=0; imageListLength=GetImageListLength(image); do { ComplianceType compliance; const char *value; (void) CopyMagickString(colorspace,CommandOptionToMnemonic( MagickColorspaceOptions,(ssize_t) image->colorspace),MaxTextExtent); LocaleLower(colorspace); image->depth=GetImageQuantumDepth(image,MagickTrue); if (image->matte != MagickFalse) (void) ConcatenateMagickString(colorspace,"a",MaxTextExtent); compliance=NoCompliance; value=GetImageOption(image_info,"txt:compliance"); if (value != (char *) NULL) compliance=(ComplianceType) ParseCommandOption(MagickComplianceOptions, MagickFalse,value); if (LocaleCompare(image_info->magick,"SPARSE-COLOR") != 0) { size_t depth; depth=compliance == SVGCompliance ? image->depth : MAGICKCORE_QUANTUM_DEPTH; (void) FormatLocaleString(buffer,MaxTextExtent, "# ImageMagick pixel enumeration: %.20g,%.20g,%.20g,%s\n",(double) image->columns,(double) image->rows,(double) ((MagickOffsetType) GetQuantumRange(depth)),colorspace); (void) WriteBlobString(image,buffer); } GetMagickPixelPacket(image,&pixel); for (y=0; y < (ssize_t) image->rows; y++) { p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception); if (p == (const PixelPacket *) NULL) break; indexes=GetVirtualIndexQueue(image); for (x=0; x < (ssize_t) image->columns; x++) { SetMagickPixelPacket(image,p,indexes+x,&pixel); if (pixel.colorspace == LabColorspace) { pixel.green-=(QuantumRange+1)/2.0; pixel.blue-=(QuantumRange+1)/2.0; } if (LocaleCompare(image_info->magick,"SPARSE-COLOR") == 0) { /* Sparse-color format. */ if ((image->matte == MagickFalse) || (GetPixelOpacity(p) == (Quantum) OpaqueOpacity)) { GetColorTuple(&pixel,MagickFalse,tuple); (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g,%.20g,", (double) x,(double) y); (void) WriteBlobString(image,buffer); (void) WriteBlobString(image,tuple); (void) WriteBlobString(image," "); } p++; continue; } (void) FormatLocaleString(buffer,MaxTextExtent,"%.20g,%.20g: ",(double) x,(double) y); (void) WriteBlobString(image,buffer); (void) CopyMagickString(tuple,"(",MaxTextExtent); ConcatenateColorComponent(&pixel,RedChannel,compliance,tuple); (void) ConcatenateMagickString(tuple,",",MaxTextExtent); ConcatenateColorComponent(&pixel,GreenChannel,compliance,tuple); (void) ConcatenateMagickString(tuple,",",MaxTextExtent); ConcatenateColorComponent(&pixel,BlueChannel,compliance,tuple); if (pixel.colorspace == CMYKColorspace) { (void) ConcatenateMagickString(tuple,",",MaxTextExtent); ConcatenateColorComponent(&pixel,IndexChannel,compliance,tuple); } if (pixel.matte != MagickFalse) { (void) ConcatenateMagickString(tuple,",",MaxTextExtent); ConcatenateColorComponent(&pixel,AlphaChannel,compliance,tuple); } (void) ConcatenateMagickString(tuple,")",MaxTextExtent); (void) WriteBlobString(image,tuple); (void) WriteBlobString(image," "); GetColorTuple(&pixel,MagickTrue,tuple); (void) FormatLocaleString(buffer,MaxTextExtent,"%s",tuple); (void) WriteBlobString(image,buffer); (void) WriteBlobString(image," "); (void) QueryMagickColorname(image,&pixel,SVGCompliance,tuple, &image->exception); (void) WriteBlobString(image,tuple); (void) WriteBlobString(image,"\n"); p++; } status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, image->rows); if (status == MagickFalse) break; } if (GetNextImageInList(image) == (Image *) NULL) break; image=SyncNextImageInList(image); status=SetImageProgress(image,SaveImagesTag,scene++,imageListLength); if (status == MagickFalse) break; } while (image_info->adjoin != MagickFalse); (void) CloseBlob(image); return(MagickTrue); }
0
379,668
static void var_free(RAnalVar *var) { if (var) { r_anal_var_clear_accesses (var); r_vector_fini (&var->constraints); free (var->name); free (var->regname); free (var->type); free (var->comment); free (var); } }
0
463,106
static int _annotate_getdb(const char *mboxname, unsigned int uid, int dbflags, annotate_db_t **dbp) { annotate_db_t *d, *prev = NULL; char *fname = NULL; struct db *db; int r; *dbp = NULL; /* * The incoming (mboxname,uid) tuple tells us which scope we * need a database for. Translate into the mboxname used to * key annotate_db_t's, which is slightly different: message * scope goes into a per-mailbox db, others in the global db. */ if (!strcmpsafe(mboxname, NULL) /*server scope*/ || !uid /* mailbox scope*/) mboxname = NULL; /* try to find an existing db for the mbox */ for (d = all_dbs_head ; d ; prev = d, d = d->next) { if (!strcmpsafe(mboxname, d->mboxname)) { /* found it, bump the refcount */ d->refcount++; *dbp = d; /* * Splay the db_t to the end of the global list. * This ensures the list remains in getdb() call * order, and in particular that the dbs are * committed in getdb() call order. This is * necessary to ensure safety should a commit fail * while moving annotations between per-mailbox dbs */ detach_db(prev, d); append_db(d); return 0; } } /* not found, open/create a new one */ r = annotate_dbname(mboxname, &fname); if (r) goto error; #if DEBUG syslog(LOG_ERR, "Opening annotations db %s\n", fname); #endif r = cyrusdb_open(DB, fname, dbflags | CYRUSDB_CONVERT, &db); if (r != 0) { if (!(dbflags & CYRUSDB_CREATE) && r == CYRUSDB_NOTFOUND) goto error; syslog(LOG_ERR, "DBERROR: opening %s: %s", fname, cyrusdb_strerror(r)); goto error; } /* record all the above */ d = xzmalloc(sizeof(*d)); d->refcount = 1; d->mboxname = xstrdupnull(mboxname); d->filename = fname; d->db = db; append_db(d); *dbp = d; return 0; error: free(fname); *dbp = NULL; return r; }
0
366,229
static void unlock_mount(struct mountpoint *where) { struct dentry *dentry = where->m_dentry; read_seqlock_excl(&mount_lock); put_mountpoint(where); read_sequnlock_excl(&mount_lock); namespace_unlock(); inode_unlock(dentry->d_inode); }
0
512,759
int Arg_comparator::compare_row() { int res= 0; bool was_null= 0; (*a)->bring_value(); (*b)->bring_value(); if ((*a)->null_value || (*b)->null_value) { owner->null_value= 1; return -1; } uint n= (*a)->cols(); for (uint i= 0; i<n; i++) { res= comparators[i].compare(); /* Aggregate functions don't need special null handling. */ if (owner->null_value && owner->type() == Item::FUNC_ITEM) { // NULL was compared switch (((Item_func*)owner)->functype()) { case Item_func::NE_FUNC: break; // NE never aborts on NULL even if abort_on_null is set case Item_func::LT_FUNC: case Item_func::LE_FUNC: case Item_func::GT_FUNC: case Item_func::GE_FUNC: return -1; // <, <=, > and >= always fail on NULL case Item_func::EQ_FUNC: if (((Item_func_eq*)owner)->abort_on_null) return -1; // We do not need correct NULL returning break; default: DBUG_ASSERT(0); break; } was_null= 1; owner->null_value= 0; res= 0; // continue comparison (maybe we will meet explicit difference) } else if (res) return res; } if (was_null) { /* There was NULL(s) in comparison in some parts, but there was no explicit difference in other parts, so we have to return NULL. */ owner->null_value= 1; return -1; } return 0; }
0
328,924
R_API void r_bin_java_annotation_array_free(void /*RBinJavaAnnotationsArray*/ *a) { RBinJavaAnnotationsArray *annotation_array = a; RListIter *iter = NULL, *iter_tmp = NULL; RBinJavaAnnotation *annotation; if (!annotation_array->annotations) { // TODO eprintf return; } r_list_foreach_safe (annotation_array->annotations, iter, iter_tmp, annotation) { if (annotation) { r_bin_java_annotation_free (annotation); } // r_list_delete (annotation_array->annotations, iter); } r_list_free (annotation_array->annotations); free (annotation_array); }
0
261,381
static int decode_explicit_rdpcm_flag(thread_context* tctx,int cIdx) { context_model* model = &tctx->ctx_model[CONTEXT_MODEL_RDPCM_FLAG]; int value = decode_CABAC_bit(&tctx->cabac_decoder, &model[cIdx ? 1 : 0]); return value; }
0
232,947
exit_zlib(struct Curl_easy *data, z_stream *z, zlibInitState *zlib_init, CURLcode result) { if(*zlib_init == ZLIB_GZIP_HEADER) Curl_safefree(z->next_in); if(*zlib_init != ZLIB_UNINIT) { if(inflateEnd(z) != Z_OK && result == CURLE_OK) result = process_zlib_error(data, z); *zlib_init = ZLIB_UNINIT; } return result; }
0
359,198
static unsigned long ringbuf_avail_data_sz(struct bpf_ringbuf *rb) { unsigned long cons_pos, prod_pos; cons_pos = smp_load_acquire(&rb->consumer_pos); prod_pos = smp_load_acquire(&rb->producer_pos); return prod_pos - cons_pos; }
0
484,052
main(void) { Suite *s = testSuite_SecureChannel(); SRunner *sr = srunner_create(s); srunner_set_fork_status(sr, CK_NOFORK); srunner_run_all(sr, CK_NORMAL); int number_failed = srunner_ntests_failed(sr); srunner_free(sr); return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE; }
0
462,324
pcstatus_do_reset(pcl_state_t * pcs, pcl_reset_type_t type) { if (type & (pcl_reset_initial | pcl_reset_printer)) { if (type & pcl_reset_initial) { pcs->status.buffer = 0; pcs->status.write_pos = 0; pcs->status.read_pos = 0; } pcs->location_type = 0; pcs->location_unit = 0; } return 0; }
0
512,534
cmp_item* cmp_item_sort_string::make_same() { return new cmp_item_sort_string_in_static(cmp_charset); }
0
364,743
findtags_in_help_init(findtags_state_T *st) { int i; char_u *s; // Keep 'en' as the language if the file extension is '.txt' if (st->is_txt) STRCPY(st->help_lang, "en"); else { // Prefer help tags according to 'helplang'. Put the two-letter // language name in help_lang[]. i = (int)STRLEN(st->tag_fname); if (i > 3 && st->tag_fname[i - 3] == '-') vim_strncpy(st->help_lang, st->tag_fname + i - 2, 2); else STRCPY(st->help_lang, "en"); } // When searching for a specific language skip tags files for other // languages. if (st->help_lang_find != NULL && STRICMP(st->help_lang, st->help_lang_find) != 0) return FALSE; // For CTRL-] in a help file prefer a match with the same language. if ((st->flags & TAG_KEEP_LANG) && st->help_lang_find == NULL && curbuf->b_fname != NULL && (i = (int)STRLEN(curbuf->b_fname)) > 4 && curbuf->b_fname[i - 1] == 'x' && curbuf->b_fname[i - 4] == '.' && STRNICMP(curbuf->b_fname + i - 3, st->help_lang, 2) == 0) st->help_pri = 0; else { // search for the language in 'helplang' st->help_pri = 1; for (s = p_hlg; *s != NUL; ++s) { if (STRNICMP(s, st->help_lang, 2) == 0) break; ++st->help_pri; if ((s = vim_strchr(s, ',')) == NULL) break; } if (s == NULL || *s == NUL) { // Language not in 'helplang': use last, prefer English, unless // found already. ++st->help_pri; if (STRICMP(st->help_lang, "en") != 0) ++st->help_pri; } } return TRUE; }
0
459,150
static void tcf_block_remove(struct tcf_block *block, struct net *net) { struct tcf_net *tn = net_generic(net, tcf_net_id); spin_lock(&tn->idr_lock); idr_remove(&tn->idr, block->index); spin_unlock(&tn->idr_lock); }
0
482,519
includeFile(const FileInfo *file, CharsString *includedFile, TranslationTableHeader **table, DisplayTableHeader **displayTable) { int k; char includeThis[MAXSTRING]; char **tableFiles; int rv; for (k = 0; k < includedFile->length; k++) includeThis[k] = (char)includedFile->chars[k]; if (k >= MAXSTRING) { compileError(file, "Include statement too long: 'include %s'", includeThis); return 0; } includeThis[k] = 0; tableFiles = _lou_resolveTable(includeThis, file->fileName); if (tableFiles == NULL) { errorCount++; return 0; } if (tableFiles[1] != NULL) { free_tablefiles(tableFiles); compileError(file, "Table list not supported in include statement: 'include %s'", includeThis); return 0; } rv = compileFile(*tableFiles, table, displayTable); free_tablefiles(tableFiles); if (!rv) _lou_logMessage(LOU_LOG_ERROR, "%s:%d: Error in included file", file->fileName, file->lineNumber); return rv; }
0
487,662
static int __kprobes notifier_call_chain(struct notifier_block **nl, unsigned long val, void *v) { int ret = NOTIFY_DONE; struct notifier_block *nb, *next_nb; nb = rcu_dereference(*nl); while (nb) { next_nb = rcu_dereference(nb->next); ret = nb->notifier_call(nb, val, v); if ((ret & NOTIFY_STOP_MASK) == NOTIFY_STOP_MASK) break; nb = next_nb; } return ret; }
0
317,077
static int smack_syslog(int typefrom_file) { int rc = 0; struct smack_known *skp = smk_of_current(); if (smack_privileged(CAP_MAC_OVERRIDE)) return 0; if (smack_syslog_label != NULL && smack_syslog_label != skp) rc = -EACCES; return rc; }
0
207,803
void add_interrupt_randomness(int irq, int irq_flags) { struct entropy_store *r; struct fast_pool *fast_pool = this_cpu_ptr(&irq_randomness); struct pt_regs *regs = get_irq_regs(); unsigned long now = jiffies; cycles_t cycles = random_get_entropy(); __u32 c_high, j_high; __u64 ip; unsigned long seed; int credit = 0; if (cycles == 0) cycles = get_reg(fast_pool, regs); c_high = (sizeof(cycles) > 4) ? cycles >> 32 : 0; j_high = (sizeof(now) > 4) ? now >> 32 : 0; fast_pool->pool[0] ^= cycles ^ j_high ^ irq; fast_pool->pool[1] ^= now ^ c_high; ip = regs ? instruction_pointer(regs) : _RET_IP_; fast_pool->pool[2] ^= ip; fast_pool->pool[3] ^= (sizeof(ip) > 4) ? ip >> 32 : get_reg(fast_pool, regs); fast_mix(fast_pool); add_interrupt_bench(cycles); if (unlikely(crng_init == 0)) { if ((fast_pool->count >= 64) && crng_fast_load((char *) fast_pool->pool, sizeof(fast_pool->pool))) { fast_pool->count = 0; fast_pool->last = now; } return; } if ((fast_pool->count < 64) && !time_after(now, fast_pool->last + HZ)) return; r = &input_pool; if (!spin_trylock(&r->lock)) return; fast_pool->last = now; __mix_pool_bytes(r, &fast_pool->pool, sizeof(fast_pool->pool)); /* * If we have architectural seed generator, produce a seed and * add it to the pool. For the sake of paranoia don't let the * architectural seed generator dominate the input from the * interrupt noise. */ if (arch_get_random_seed_long(&seed)) { __mix_pool_bytes(r, &seed, sizeof(seed)); credit = 1; } spin_unlock(&r->lock); fast_pool->count = 0; /* award one bit for the contents of the fast pool */ credit_entropy_bits(r, credit + 1); }
1
309,830
NCURSES_SP_NAME(mouseinterval) (NCURSES_SP_DCLx int maxclick) /* set the maximum mouse interval within which to recognize a click */ { int oldval; T((T_CALLED("mouseinterval(%p,%d)"), (void *) SP_PARM, maxclick)); if (SP_PARM != 0) { oldval = SP_PARM->_maxclick; if (maxclick >= 0) SP_PARM->_maxclick = maxclick; } else { oldval = DEFAULT_MAXCLICK; } returnCode(oldval); }
0
313,563
__acquires(rose_node_list_lock) { struct rose_node *rose_node; int i = 1; spin_lock_bh(&rose_node_list_lock); if (*pos == 0) return SEQ_START_TOKEN; for (rose_node = rose_node_list; rose_node && i < *pos; rose_node = rose_node->next, ++i); return (i == *pos) ? rose_node : NULL; }
0
337,843
struct sctp_chunk *sctp_make_ifwdtsn(const struct sctp_association *asoc, __u32 new_cum_tsn, size_t nstreams, struct sctp_ifwdtsn_skip *skiplist) { struct sctp_chunk *retval = NULL; struct sctp_ifwdtsn_hdr ftsn_hdr; size_t hint; hint = (nstreams + 1) * sizeof(__u32); retval = sctp_make_control(asoc, SCTP_CID_I_FWD_TSN, 0, hint, GFP_ATOMIC); if (!retval) return NULL; ftsn_hdr.new_cum_tsn = htonl(new_cum_tsn); retval->subh.ifwdtsn_hdr = sctp_addto_chunk(retval, sizeof(ftsn_hdr), &ftsn_hdr); sctp_addto_chunk(retval, nstreams * sizeof(skiplist[0]), skiplist); return retval; }
0
236,177
GF_Err tx3g_on_child_box(GF_Box *s, GF_Box *a, Bool is_rem) { GF_Tx3gSampleEntryBox *ptr = (GF_Tx3gSampleEntryBox*)s; switch (a->type) { case GF_ISOM_BOX_TYPE_FTAB: BOX_FIELD_ASSIGN(font_table, GF_FontTableBox) break; default: return GF_OK; } return GF_OK; }
0
369,196
static int __io_sqe_buffers_update(struct io_ring_ctx *ctx, struct io_uring_rsrc_update2 *up, unsigned int nr_args) { u64 __user *tags = u64_to_user_ptr(up->tags); struct iovec iov, __user *iovs = u64_to_user_ptr(up->data); struct page *last_hpage = NULL; bool needs_switch = false; __u32 done; int i, err; if (!ctx->buf_data) return -ENXIO; if (up->offset + nr_args > ctx->nr_user_bufs) return -EINVAL; for (done = 0; done < nr_args; done++) { struct io_mapped_ubuf *imu; int offset = up->offset + done; u64 tag = 0; err = io_copy_iov(ctx, &iov, iovs, done); if (err) break; if (tags && copy_from_user(&tag, &tags[done], sizeof(tag))) { err = -EFAULT; break; } err = io_buffer_validate(&iov); if (err) break; if (!iov.iov_base && tag) { err = -EINVAL; break; } err = io_sqe_buffer_register(ctx, &iov, &imu, &last_hpage); if (err) break; i = array_index_nospec(offset, ctx->nr_user_bufs); if (ctx->user_bufs[i] != ctx->dummy_ubuf) { err = io_queue_rsrc_removal(ctx->buf_data, i, ctx->rsrc_node, ctx->user_bufs[i]); if (unlikely(err)) { io_buffer_unmap(ctx, &imu); break; } ctx->user_bufs[i] = NULL; needs_switch = true; } ctx->user_bufs[i] = imu; *io_get_tag_slot(ctx->buf_data, offset) = tag; } if (needs_switch) io_rsrc_node_switch(ctx, ctx->buf_data); return done ? done : err;
0
386,542
void DL_Dxf::writeUcs(DL_WriterA& dw) { dw.dxfString( 0, "TABLE"); dw.dxfString( 2, "UCS"); if (version==DL_VERSION_2000) { dw.dxfHex(5, 7); } //dw.dxfHex(330, 0); if (version==DL_VERSION_2000) { dw.dxfString(100, "AcDbSymbolTable"); } dw.dxfInt( 70, 0); dw.dxfString( 0, "ENDTAB"); }
0
457,872
gegl_op_class_init (GeglOpClass *klass) { GeglOperationClass *operation_class; GObjectClass *object_class; operation_class = GEGL_OPERATION_CLASS (klass); object_class = G_OBJECT_CLASS (klass); object_class->finalize = finalize; operation_class->process = process; operation_class->get_bounding_box = get_bounding_box; operation_class->get_cached_region = get_cached_region;; gegl_operation_class_set_keys (operation_class, "name" , "gegl:magick-load", "categories" , "hidden", "description", _("Image Magick wrapper using the png op."), NULL); }
0
196,328
find_pattern_in_path( char_u *ptr, // pointer to search pattern int dir UNUSED, // direction of expansion int len, // length of search pattern int whole, // match whole words only int skip_comments, // don't match inside comments int type, // Type of search; are we looking for a type? // a macro? long count, int action, // What to do when we find it linenr_T start_lnum, // first line to start searching linenr_T end_lnum) // last line for searching { SearchedFile *files; // Stack of included files SearchedFile *bigger; // When we need more space int max_path_depth = 50; long match_count = 1; char_u *pat; char_u *new_fname; char_u *curr_fname = curbuf->b_fname; char_u *prev_fname = NULL; linenr_T lnum; int depth; int depth_displayed; // For type==CHECK_PATH int old_files; int already_searched; char_u *file_line; char_u *line; char_u *p; char_u save_char; int define_matched; regmatch_T regmatch; regmatch_T incl_regmatch; regmatch_T def_regmatch; int matched = FALSE; int did_show = FALSE; int found = FALSE; int i; char_u *already = NULL; char_u *startp = NULL; char_u *inc_opt = NULL; #if defined(FEAT_QUICKFIX) win_T *curwin_save = NULL; #endif regmatch.regprog = NULL; incl_regmatch.regprog = NULL; def_regmatch.regprog = NULL; file_line = alloc(LSIZE); if (file_line == NULL) return; if (type != CHECK_PATH && type != FIND_DEFINE // when CONT_SOL is set compare "ptr" with the beginning of the // line is faster than quote_meta/regcomp/regexec "ptr" -- Acevedo && !compl_status_sol()) { pat = alloc(len + 5); if (pat == NULL) goto fpip_end; sprintf((char *)pat, whole ? "\\<%.*s\\>" : "%.*s", len, ptr); // ignore case according to p_ic, p_scs and pat regmatch.rm_ic = ignorecase(pat); regmatch.regprog = vim_regcomp(pat, magic_isset() ? RE_MAGIC : 0); vim_free(pat); if (regmatch.regprog == NULL) goto fpip_end; } inc_opt = (*curbuf->b_p_inc == NUL) ? p_inc : curbuf->b_p_inc; if (*inc_opt != NUL) { incl_regmatch.regprog = vim_regcomp(inc_opt, magic_isset() ? RE_MAGIC : 0); if (incl_regmatch.regprog == NULL) goto fpip_end; incl_regmatch.rm_ic = FALSE; // don't ignore case in incl. pat. } if (type == FIND_DEFINE && (*curbuf->b_p_def != NUL || *p_def != NUL)) { def_regmatch.regprog = vim_regcomp(*curbuf->b_p_def == NUL ? p_def : curbuf->b_p_def, magic_isset() ? RE_MAGIC : 0); if (def_regmatch.regprog == NULL) goto fpip_end; def_regmatch.rm_ic = FALSE; // don't ignore case in define pat. } files = lalloc_clear(max_path_depth * sizeof(SearchedFile), TRUE); if (files == NULL) goto fpip_end; old_files = max_path_depth; depth = depth_displayed = -1; lnum = start_lnum; if (end_lnum > curbuf->b_ml.ml_line_count) end_lnum = curbuf->b_ml.ml_line_count; if (lnum > end_lnum) // do at least one line lnum = end_lnum; line = ml_get(lnum); for (;;) { if (incl_regmatch.regprog != NULL && vim_regexec(&incl_regmatch, line, (colnr_T)0)) { char_u *p_fname = (curr_fname == curbuf->b_fname) ? curbuf->b_ffname : curr_fname; if (inc_opt != NULL && strstr((char *)inc_opt, "\\zs") != NULL) // Use text from '\zs' to '\ze' (or end) of 'include'. new_fname = find_file_name_in_path(incl_regmatch.startp[0], (int)(incl_regmatch.endp[0] - incl_regmatch.startp[0]), FNAME_EXP|FNAME_INCL|FNAME_REL, 1L, p_fname); else // Use text after match with 'include'. new_fname = file_name_in_line(incl_regmatch.endp[0], 0, FNAME_EXP|FNAME_INCL|FNAME_REL, 1L, p_fname, NULL); already_searched = FALSE; if (new_fname != NULL) { // Check whether we have already searched in this file for (i = 0;; i++) { if (i == depth + 1) i = old_files; if (i == max_path_depth) break; if (fullpathcmp(new_fname, files[i].name, TRUE, TRUE) & FPC_SAME) { if (type != CHECK_PATH && action == ACTION_SHOW_ALL && files[i].matched) { msg_putchar('\n'); // cursor below last one if (!got_int) // don't display if 'q' // typed at "--more--" // message { msg_home_replace_hl(new_fname); msg_puts(_(" (includes previously listed match)")); prev_fname = NULL; } } VIM_CLEAR(new_fname); already_searched = TRUE; break; } } } if (type == CHECK_PATH && (action == ACTION_SHOW_ALL || (new_fname == NULL && !already_searched))) { if (did_show) msg_putchar('\n'); // cursor below last one else { gotocmdline(TRUE); // cursor at status line msg_puts_title(_("--- Included files ")); if (action != ACTION_SHOW_ALL) msg_puts_title(_("not found ")); msg_puts_title(_("in path ---\n")); } did_show = TRUE; while (depth_displayed < depth && !got_int) { ++depth_displayed; for (i = 0; i < depth_displayed; i++) msg_puts(" "); msg_home_replace(files[depth_displayed].name); msg_puts(" -->\n"); } if (!got_int) // don't display if 'q' typed // for "--more--" message { for (i = 0; i <= depth_displayed; i++) msg_puts(" "); if (new_fname != NULL) { // using "new_fname" is more reliable, e.g., when // 'includeexpr' is set. msg_outtrans_attr(new_fname, HL_ATTR(HLF_D)); } else { /* * Isolate the file name. * Include the surrounding "" or <> if present. */ if (inc_opt != NULL && strstr((char *)inc_opt, "\\zs") != NULL) { // pattern contains \zs, use the match p = incl_regmatch.startp[0]; i = (int)(incl_regmatch.endp[0] - incl_regmatch.startp[0]); } else { // find the file name after the end of the match for (p = incl_regmatch.endp[0]; *p && !vim_isfilec(*p); p++) ; for (i = 0; vim_isfilec(p[i]); i++) ; } if (i == 0) { // Nothing found, use the rest of the line. p = incl_regmatch.endp[0]; i = (int)STRLEN(p); } // Avoid checking before the start of the line, can // happen if \zs appears in the regexp. else if (p > line) { if (p[-1] == '"' || p[-1] == '<') { --p; ++i; } if (p[i] == '"' || p[i] == '>') ++i; } save_char = p[i]; p[i] = NUL; msg_outtrans_attr(p, HL_ATTR(HLF_D)); p[i] = save_char; } if (new_fname == NULL && action == ACTION_SHOW_ALL) { if (already_searched) msg_puts(_(" (Already listed)")); else msg_puts(_(" NOT FOUND")); } } out_flush(); // output each line directly } if (new_fname != NULL) { // Push the new file onto the file stack if (depth + 1 == old_files) { bigger = ALLOC_MULT(SearchedFile, max_path_depth * 2); if (bigger != NULL) { for (i = 0; i <= depth; i++) bigger[i] = files[i]; for (i = depth + 1; i < old_files + max_path_depth; i++) { bigger[i].fp = NULL; bigger[i].name = NULL; bigger[i].lnum = 0; bigger[i].matched = FALSE; } for (i = old_files; i < max_path_depth; i++) bigger[i + max_path_depth] = files[i]; old_files += max_path_depth; max_path_depth *= 2; vim_free(files); files = bigger; } } if ((files[depth + 1].fp = mch_fopen((char *)new_fname, "r")) == NULL) vim_free(new_fname); else { if (++depth == old_files) { /* * lalloc() for 'bigger' must have failed above. We * will forget one of our already visited files now. */ vim_free(files[old_files].name); ++old_files; } files[depth].name = curr_fname = new_fname; files[depth].lnum = 0; files[depth].matched = FALSE; if (action == ACTION_EXPAND) { msg_hist_off = TRUE; // reset in msg_trunc_attr() vim_snprintf((char*)IObuff, IOSIZE, _("Scanning included file: %s"), (char *)new_fname); msg_trunc_attr((char *)IObuff, TRUE, HL_ATTR(HLF_R)); } else if (p_verbose >= 5) { verbose_enter(); smsg(_("Searching included file %s"), (char *)new_fname); verbose_leave(); } } } } else { /* * Check if the line is a define (type == FIND_DEFINE) */ p = line; search_line: define_matched = FALSE; if (def_regmatch.regprog != NULL && vim_regexec(&def_regmatch, line, (colnr_T)0)) { /* * Pattern must be first identifier after 'define', so skip * to that position before checking for match of pattern. Also * don't let it match beyond the end of this identifier. */ p = def_regmatch.endp[0]; while (*p && !vim_iswordc(*p)) p++; define_matched = TRUE; } /* * Look for a match. Don't do this if we are looking for a * define and this line didn't match define_prog above. */ if (def_regmatch.regprog == NULL || define_matched) { if (define_matched || compl_status_sol()) { // compare the first "len" chars from "ptr" startp = skipwhite(p); if (p_ic) matched = !MB_STRNICMP(startp, ptr, len); else matched = !STRNCMP(startp, ptr, len); if (matched && define_matched && whole && vim_iswordc(startp[len])) matched = FALSE; } else if (regmatch.regprog != NULL && vim_regexec(&regmatch, line, (colnr_T)(p - line))) { matched = TRUE; startp = regmatch.startp[0]; /* * Check if the line is not a comment line (unless we are * looking for a define). A line starting with "# define" * is not considered to be a comment line. */ if (!define_matched && skip_comments) { if ((*line != '#' || STRNCMP(skipwhite(line + 1), "define", 6) != 0) && get_leader_len(line, NULL, FALSE, TRUE)) matched = FALSE; /* * Also check for a "/ *" or "/ /" before the match. * Skips lines like "int backwards; / * normal index * * /" when looking for "normal". * Note: Doesn't skip "/ *" in comments. */ p = skipwhite(line); if (matched || (p[0] == '/' && p[1] == '*') || p[0] == '*') for (p = line; *p && p < startp; ++p) { if (matched && p[0] == '/' && (p[1] == '*' || p[1] == '/')) { matched = FALSE; // After "//" all text is comment if (p[1] == '/') break; ++p; } else if (!matched && p[0] == '*' && p[1] == '/') { // Can find match after "* /". matched = TRUE; ++p; } } } } } } if (matched) { if (action == ACTION_EXPAND) { int cont_s_ipos = FALSE; int add_r; char_u *aux; if (depth == -1 && lnum == curwin->w_cursor.lnum) break; found = TRUE; aux = p = startp; if (compl_status_adding()) { p += ins_compl_len(); if (vim_iswordp(p)) goto exit_matched; p = find_word_start(p); } p = find_word_end(p); i = (int)(p - aux); if (compl_status_adding() && i == ins_compl_len()) { // IOSIZE > compl_length, so the STRNCPY works STRNCPY(IObuff, aux, i); // Get the next line: when "depth" < 0 from the current // buffer, otherwise from the included file. Jump to // exit_matched when past the last line. if (depth < 0) { if (lnum >= end_lnum) goto exit_matched; line = ml_get(++lnum); } else if (vim_fgets(line = file_line, LSIZE, files[depth].fp)) goto exit_matched; // we read a line, set "already" to check this "line" later // if depth >= 0 we'll increase files[depth].lnum far // below -- Acevedo already = aux = p = skipwhite(line); p = find_word_start(p); p = find_word_end(p); if (p > aux) { if (*aux != ')' && IObuff[i-1] != TAB) { if (IObuff[i-1] != ' ') IObuff[i++] = ' '; // IObuf =~ "\(\k\|\i\).* ", thus i >= 2 if (p_js && (IObuff[i-2] == '.' || (vim_strchr(p_cpo, CPO_JOINSP) == NULL && (IObuff[i-2] == '?' || IObuff[i-2] == '!')))) IObuff[i++] = ' '; } // copy as much as possible of the new word if (p - aux >= IOSIZE - i) p = aux + IOSIZE - i - 1; STRNCPY(IObuff + i, aux, p - aux); i += (int)(p - aux); cont_s_ipos = TRUE; } IObuff[i] = NUL; aux = IObuff; if (i == ins_compl_len()) goto exit_matched; } add_r = ins_compl_add_infercase(aux, i, p_ic, curr_fname == curbuf->b_fname ? NULL : curr_fname, dir, cont_s_ipos); if (add_r == OK) // if dir was BACKWARD then honor it just once dir = FORWARD; else if (add_r == FAIL) break; } else if (action == ACTION_SHOW_ALL) { found = TRUE; if (!did_show) gotocmdline(TRUE); // cursor at status line if (curr_fname != prev_fname) { if (did_show) msg_putchar('\n'); // cursor below last one if (!got_int) // don't display if 'q' typed // at "--more--" message msg_home_replace_hl(curr_fname); prev_fname = curr_fname; } did_show = TRUE; if (!got_int) show_pat_in_path(line, type, TRUE, action, (depth == -1) ? NULL : files[depth].fp, (depth == -1) ? &lnum : &files[depth].lnum, match_count++); // Set matched flag for this file and all the ones that // include it for (i = 0; i <= depth; ++i) files[i].matched = TRUE; } else if (--count <= 0) { found = TRUE; if (depth == -1 && lnum == curwin->w_cursor.lnum #if defined(FEAT_QUICKFIX) && g_do_tagpreview == 0 #endif ) emsg(_(e_match_is_on_current_line)); else if (action == ACTION_SHOW) { show_pat_in_path(line, type, did_show, action, (depth == -1) ? NULL : files[depth].fp, (depth == -1) ? &lnum : &files[depth].lnum, 1L); did_show = TRUE; } else { #ifdef FEAT_GUI need_mouse_correct = TRUE; #endif #if defined(FEAT_QUICKFIX) // ":psearch" uses the preview window if (g_do_tagpreview != 0) { curwin_save = curwin; prepare_tagpreview(TRUE, TRUE, FALSE); } #endif if (action == ACTION_SPLIT) { if (win_split(0, 0) == FAIL) break; RESET_BINDING(curwin); } if (depth == -1) { // match in current file #if defined(FEAT_QUICKFIX) if (g_do_tagpreview != 0) { if (!win_valid(curwin_save)) break; if (!GETFILE_SUCCESS(getfile( curwin_save->w_buffer->b_fnum, NULL, NULL, TRUE, lnum, FALSE))) break; // failed to jump to file } else #endif setpcmark(); curwin->w_cursor.lnum = lnum; check_cursor(); } else { if (!GETFILE_SUCCESS(getfile( 0, files[depth].name, NULL, TRUE, files[depth].lnum, FALSE))) break; // failed to jump to file // autocommands may have changed the lnum, we don't // want that here curwin->w_cursor.lnum = files[depth].lnum; } } if (action != ACTION_SHOW) { curwin->w_cursor.col = (colnr_T)(startp - line); curwin->w_set_curswant = TRUE; } #if defined(FEAT_QUICKFIX) if (g_do_tagpreview != 0 && curwin != curwin_save && win_valid(curwin_save)) { // Return cursor to where we were validate_cursor(); redraw_later(VALID); win_enter(curwin_save, TRUE); } # ifdef FEAT_PROP_POPUP else if (WIN_IS_POPUP(curwin)) // can't keep focus in popup window win_enter(firstwin, TRUE); # endif #endif break; } exit_matched: matched = FALSE; // look for other matches in the rest of the line if we // are not at the end of it already if (def_regmatch.regprog == NULL && action == ACTION_EXPAND && !compl_status_sol() && *startp != NUL && *(p = startp + mb_ptr2len(startp)) != NUL) goto search_line; } line_breakcheck(); if (action == ACTION_EXPAND) ins_compl_check_keys(30, FALSE); if (got_int || ins_compl_interrupted()) break; /* * Read the next line. When reading an included file and encountering * end-of-file, close the file and continue in the file that included * it. */ while (depth >= 0 && !already && vim_fgets(line = file_line, LSIZE, files[depth].fp)) { fclose(files[depth].fp); --old_files; files[old_files].name = files[depth].name; files[old_files].matched = files[depth].matched; --depth; curr_fname = (depth == -1) ? curbuf->b_fname : files[depth].name; if (depth < depth_displayed) depth_displayed = depth; } if (depth >= 0) // we could read the line { files[depth].lnum++; // Remove any CR and LF from the line. i = (int)STRLEN(line); if (i > 0 && line[i - 1] == '\n') line[--i] = NUL; if (i > 0 && line[i - 1] == '\r') line[--i] = NUL; } else if (!already) { if (++lnum > end_lnum) break; line = ml_get(lnum); } already = NULL; } // End of big for (;;) loop. // Close any files that are still open. for (i = 0; i <= depth; i++) { fclose(files[i].fp); vim_free(files[i].name); } for (i = old_files; i < max_path_depth; i++) vim_free(files[i].name); vim_free(files); if (type == CHECK_PATH) { if (!did_show) { if (action != ACTION_SHOW_ALL) msg(_("All included files were found")); else msg(_("No included files")); } } else if (!found && action != ACTION_EXPAND) { if (got_int || ins_compl_interrupted()) emsg(_(e_interrupted)); else if (type == FIND_DEFINE) emsg(_(e_couldnt_find_definition)); else emsg(_(e_couldnt_find_pattern)); } if (action == ACTION_SHOW || action == ACTION_SHOW_ALL) msg_end(); fpip_end: vim_free(file_line); vim_regfree(regmatch.regprog); vim_regfree(incl_regmatch.regprog); vim_regfree(def_regmatch.regprog); }
1
415,205
cmd_setattr (assuan_context_t ctx, char *orig_line) { ctrl_t ctrl = assuan_get_pointer (ctx); int rc; char *keyword; int keywordlen; size_t nbytes; char *line, *linebuf; if ( IS_LOCKED (ctrl) ) return gpg_error (GPG_ERR_LOCKED); if ((rc = open_card (ctrl, NULL))) return rc; /* We need to use a copy of LINE, because PIN_CB uses the same context and thus reuses the Assuan provided LINE. */ line = linebuf = xtrystrdup (orig_line); if (!line) return out_of_core (); keyword = line; for (keywordlen=0; *line && !spacep (line); line++, keywordlen++) ; if (*line) *line++ = 0; while (spacep (line)) line++; nbytes = percent_plus_unescape_inplace (line, 0); rc = app_setattr (ctrl->app_ctx, keyword, pin_cb, ctx, (const unsigned char*)line, nbytes); xfree (linebuf); TEST_CARD_REMOVAL (ctrl, rc); return rc; }
0
236,186
void text_box_del(GF_Box *s) { GF_TextSampleEntryBox *ptr = (GF_TextSampleEntryBox*)s; gf_isom_sample_entry_predestroy((GF_SampleEntryBox *)s); if (ptr->textName) gf_free(ptr->textName); gf_free(ptr); }
0
366,319
int path_mount(const char *dev_name, struct path *path, const char *type_page, unsigned long flags, void *data_page) { unsigned int mnt_flags = 0, sb_flags; int ret; /* Discard magic */ if ((flags & MS_MGC_MSK) == MS_MGC_VAL) flags &= ~MS_MGC_MSK; /* Basic sanity checks */ if (data_page) ((char *)data_page)[PAGE_SIZE - 1] = 0; if (flags & MS_NOUSER) return -EINVAL; ret = security_sb_mount(dev_name, path, type_page, flags, data_page); if (ret) return ret; if (!may_mount()) return -EPERM; if ((flags & SB_MANDLOCK) && !may_mandlock()) return -EPERM; /* Default to relatime unless overriden */ if (!(flags & MS_NOATIME)) mnt_flags |= MNT_RELATIME; /* Separate the per-mountpoint flags */ if (flags & MS_NOSUID) mnt_flags |= MNT_NOSUID; if (flags & MS_NODEV) mnt_flags |= MNT_NODEV; if (flags & MS_NOEXEC) mnt_flags |= MNT_NOEXEC; if (flags & MS_NOATIME) mnt_flags |= MNT_NOATIME; if (flags & MS_NODIRATIME) mnt_flags |= MNT_NODIRATIME; if (flags & MS_STRICTATIME) mnt_flags &= ~(MNT_RELATIME | MNT_NOATIME); if (flags & MS_RDONLY) mnt_flags |= MNT_READONLY; if (flags & MS_NOSYMFOLLOW) mnt_flags |= MNT_NOSYMFOLLOW; /* The default atime for remount is preservation */ if ((flags & MS_REMOUNT) && ((flags & (MS_NOATIME | MS_NODIRATIME | MS_RELATIME | MS_STRICTATIME)) == 0)) { mnt_flags &= ~MNT_ATIME_MASK; mnt_flags |= path->mnt->mnt_flags & MNT_ATIME_MASK; } sb_flags = flags & (SB_RDONLY | SB_SYNCHRONOUS | SB_MANDLOCK | SB_DIRSYNC | SB_SILENT | SB_POSIXACL | SB_LAZYTIME | SB_I_VERSION); if ((flags & (MS_REMOUNT | MS_BIND)) == (MS_REMOUNT | MS_BIND)) return do_reconfigure_mnt(path, mnt_flags); if (flags & MS_REMOUNT) return do_remount(path, flags, sb_flags, mnt_flags, data_page); if (flags & MS_BIND) return do_loopback(path, dev_name, flags & MS_REC); if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE)) return do_change_type(path, flags); if (flags & MS_MOVE) return do_move_mount_old(path, dev_name); return do_new_mount(path, type_page, sb_flags, mnt_flags, dev_name, data_page); }
0
261,428
static int decode_cbf_chroma(thread_context* tctx, int trafoDepth) { logtrace(LogSlice,"# cbf_chroma\n"); int bit = decode_CABAC_bit(&tctx->cabac_decoder, &tctx->ctx_model[CONTEXT_MODEL_CBF_CHROMA + trafoDepth]); logtrace(LogSymbols,"$1 cbf_chroma=%d\n",bit); return bit; }
0
463,192
static void init_internal() { if (!annotate_initialized) { annotate_init(NULL, NULL); cyrus_modules_add(done_cb, NULL); } if (!annotatemore_dbopen) { annotatemore_open(); } }
0
404,701
int receive_fd_replace(int new_fd, struct file *file, unsigned int o_flags) { int error; error = security_file_receive(file); if (error) return error; error = replace_fd(new_fd, file, o_flags); if (error) return error; __receive_sock(file); return new_fd; }
0
274,667
callbacks_switch_to_correct_cursor (void) { GdkWindow *drawing_area_window = screen.drawing_area->window; GdkCursor *cursor; if (screen.state == IN_MOVE) { cursor = gdk_cursor_new(GDK_FLEUR); gdk_window_set_cursor(drawing_area_window, cursor); gdk_cursor_destroy(cursor); return; } else if (screen.state == IN_ZOOM_OUTLINE) { cursor = gdk_cursor_new(GDK_SIZING); gdk_window_set_cursor(drawing_area_window, cursor); gdk_cursor_destroy(cursor); return; } callbacks_switch_to_normal_tool_cursor (screen.tool); }
0
400,119
set<int> PipeSocketHandler::getEndpointFds(const SocketEndpoint& endpoint) { lock_guard<std::recursive_mutex> guard(globalMutex); string pipePath = endpoint.name(); if (pipeServerSockets.find(pipePath) == pipeServerSockets.end()) { STFATAL << "Tried to getPipeFd on a pipe without calling listen() first: " << pipePath; } return pipeServerSockets[pipePath]; }
0
226,066
GF_Err dref_box_write(GF_Box *s, GF_BitStream *bs) { GF_Err e; u32 count; GF_DataReferenceBox *ptr = (GF_DataReferenceBox *)s; if (!s) return GF_BAD_PARAM; e = gf_isom_full_box_write(s, bs); if (e) return e; count = ptr->child_boxes ? gf_list_count(ptr->child_boxes) : 0; gf_bs_write_u32(bs, count); return GF_OK; }
0
502,691
void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx, void (*cb) (SSL_CTX *ctx, SSL_SESSION *sess)) { ctx->remove_session_cb = cb; }
0
95,906
void AddUsageStatsWorkItems(const InstallationState& original_state, const InstallerState& installer_state, WorkItemList* install_list) { DCHECK(installer_state.operation() == InstallerState::MULTI_INSTALL || installer_state.operation() == InstallerState::MULTI_UPDATE); HKEY root_key = installer_state.root_key(); bool value_found = false; DWORD usagestats = 0; const Products& products = installer_state.products(); for (Products::const_iterator scan = products.begin(), end = products.end(); !value_found && scan != end; ++scan) { BrowserDistribution* dist = (*scan)->distribution(); const ProductState* product_state = original_state.GetNonVersionedProductState( installer_state.system_install(), dist->GetType()); value_found = product_state->GetUsageStats(&usagestats); } if (value_found) { std::wstring state_key( installer_state.multi_package_binaries_distribution()->GetStateKey()); install_list->AddCreateRegKeyWorkItem(root_key, state_key); install_list->AddSetRegValueWorkItem(root_key, state_key, google_update::kRegUsageStatsField, usagestats, false); for (Products::const_iterator scan = products.begin(), end = products.end(); scan != end; ++scan) { BrowserDistribution* dist = (*scan)->distribution(); if (installer_state.system_install()) { install_list->AddDeleteRegValueWorkItem( root_key, dist->GetStateMediumKey(), google_update::kRegUsageStatsField); install_list->AddDeleteRegValueWorkItem( HKEY_CURRENT_USER, dist->GetStateKey(), google_update::kRegUsageStatsField); } install_list->AddDeleteRegValueWorkItem(root_key, dist->GetStateKey(), google_update::kRegUsageStatsField); } } }
0
234,145
cmalloc (size_t nmemb, size_t size) { /* Check for overflow. */ if (nmemb >= ~(size_t) 0 / size) return NULL; return xmalloc (nmemb * size); }
0
236,146
GF_Err dims_box_size(GF_Box *s) { u32 pos = 0; GF_DIMSSampleEntryBox *p = (GF_DIMSSampleEntryBox *)s; s->size += 8; gf_isom_check_position(s, (GF_Box *) p->config, &pos); gf_isom_check_position(s, (GF_Box *) p->scripts, &pos); return GF_OK; }
0
424,909
static void iwl_trans_pcie_write_prph(struct iwl_trans *trans, u32 addr, u32 val) { u32 mask = iwl_trans_pcie_prph_msk(trans); iwl_trans_pcie_write32(trans, HBUS_TARG_PRPH_WADDR, ((addr & mask) | (3 << 24))); iwl_trans_pcie_write32(trans, HBUS_TARG_PRPH_WDAT, val); }
0
359,474
quagga_timestamp(int timestamp_precision, char *buf, size_t buflen) { static struct { time_t last; size_t len; char buf[28]; } cache; struct timeval clock; /* would it be sufficient to use global 'recent_time' here? I fear not... */ gettimeofday(&clock, NULL); /* first, we update the cache if the time has changed */ if (cache.last != clock.tv_sec) { struct tm *tm; cache.last = clock.tv_sec; tm = localtime(&cache.last); cache.len = strftime(cache.buf, sizeof(cache.buf), "%Y/%m/%d %H:%M:%S", tm); } /* note: it's not worth caching the subsecond part, because chances are that back-to-back calls are not sufficiently close together for the clock not to have ticked forward */ if (buflen > cache.len) { memcpy(buf, cache.buf, cache.len); if ((timestamp_precision > 0) && (buflen > cache.len+1+timestamp_precision)) { /* should we worry about locale issues? */ static const int divisor[] = {0, 100000, 10000, 1000, 100, 10, 1}; int prec; char *p = buf+cache.len+1+(prec = timestamp_precision); *p-- = '\0'; while (prec > 6) /* this is unlikely to happen, but protect anyway */ { *p-- = '0'; prec--; } clock.tv_usec /= divisor[prec]; do { *p-- = '0'+(clock.tv_usec % 10); clock.tv_usec /= 10; } while (--prec > 0); *p = '.'; return cache.len+1+timestamp_precision; } buf[cache.len] = '\0'; return cache.len; } if (buflen > 0) buf[0] = '\0'; return 0; }
0
462,325
pcl_set_readback_loc_unit(pcl_args_t * pargs, pcl_state_t * pcs) { pcs->location_unit = uint_arg(pargs); return 0; }
0
450,413
static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len) { int i; uint16_t limit; uint32_t freq; VncDisplay *vd = vs->vd; if (data[0] > 3) { update_displaychangelistener(&vd->dcl, VNC_REFRESH_INTERVAL_BASE); } switch (data[0]) { case VNC_MSG_CLIENT_SET_PIXEL_FORMAT: if (len == 1) return 20; set_pixel_format(vs, read_u8(data, 4), read_u8(data, 6), read_u8(data, 7), read_u16(data, 8), read_u16(data, 10), read_u16(data, 12), read_u8(data, 14), read_u8(data, 15), read_u8(data, 16)); break; case VNC_MSG_CLIENT_SET_ENCODINGS: if (len == 1) return 4; if (len == 4) { limit = read_u16(data, 2); if (limit > 0) return 4 + (limit * 4); } else limit = read_u16(data, 2); for (i = 0; i < limit; i++) { int32_t val = read_s32(data, 4 + (i * 4)); memcpy(data + 4 + (i * 4), &val, sizeof(val)); } set_encodings(vs, (int32_t *)(data + 4), limit); break; case VNC_MSG_CLIENT_FRAMEBUFFER_UPDATE_REQUEST: if (len == 1) return 10; framebuffer_update_request(vs, read_u8(data, 1), read_u16(data, 2), read_u16(data, 4), read_u16(data, 6), read_u16(data, 8)); break; case VNC_MSG_CLIENT_KEY_EVENT: if (len == 1) return 8; key_event(vs, read_u8(data, 1), read_u32(data, 4)); break; case VNC_MSG_CLIENT_POINTER_EVENT: if (len == 1) return 6; pointer_event(vs, read_u8(data, 1), read_u16(data, 2), read_u16(data, 4)); break; case VNC_MSG_CLIENT_CUT_TEXT: if (len == 1) { return 8; } if (len == 8) { uint32_t dlen = read_u32(data, 4); if (dlen > (1 << 20)) { error_report("vnc: client_cut_text msg payload has %u bytes" " which exceeds our limit of 1MB.", dlen); vnc_client_error(vs); break; } if (dlen > 0) { return 8 + dlen; } } client_cut_text(vs, read_u32(data, 4), data + 8); break; case VNC_MSG_CLIENT_QEMU: if (len == 1) return 2; switch (read_u8(data, 1)) { case VNC_MSG_CLIENT_QEMU_EXT_KEY_EVENT: if (len == 2) return 12; ext_key_event(vs, read_u16(data, 2), read_u32(data, 4), read_u32(data, 8)); break; case VNC_MSG_CLIENT_QEMU_AUDIO: if (len == 2) return 4; switch (read_u16 (data, 2)) { case VNC_MSG_CLIENT_QEMU_AUDIO_ENABLE: audio_add(vs); break; case VNC_MSG_CLIENT_QEMU_AUDIO_DISABLE: audio_del(vs); break; case VNC_MSG_CLIENT_QEMU_AUDIO_SET_FORMAT: if (len == 4) return 10; switch (read_u8(data, 4)) { case 0: vs->as.fmt = AUDIO_FORMAT_U8; break; case 1: vs->as.fmt = AUDIO_FORMAT_S8; break; case 2: vs->as.fmt = AUDIO_FORMAT_U16; break; case 3: vs->as.fmt = AUDIO_FORMAT_S16; break; case 4: vs->as.fmt = AUDIO_FORMAT_U32; break; case 5: vs->as.fmt = AUDIO_FORMAT_S32; break; default: VNC_DEBUG("Invalid audio format %d\n", read_u8(data, 4)); vnc_client_error(vs); break; } vs->as.nchannels = read_u8(data, 5); if (vs->as.nchannels != 1 && vs->as.nchannels != 2) { VNC_DEBUG("Invalid audio channel count %d\n", read_u8(data, 5)); vnc_client_error(vs); break; } freq = read_u32(data, 6); /* No official limit for protocol, but 48khz is a sensible * upper bound for trustworthy clients, and this limit * protects calculations involving 'vs->as.freq' later. */ if (freq > 48000) { VNC_DEBUG("Invalid audio frequency %u > 48000", freq); vnc_client_error(vs); break; } vs->as.freq = freq; break; default: VNC_DEBUG("Invalid audio message %d\n", read_u8(data, 4)); vnc_client_error(vs); break; } break; default: VNC_DEBUG("Msg: %d\n", read_u16(data, 0)); vnc_client_error(vs); break; } break; default: VNC_DEBUG("Msg: %d\n", data[0]); vnc_client_error(vs); break; } vnc_update_throttle_offset(vs); vnc_read_when(vs, protocol_client_msg, 1); return 0; }
0
293,533
PJ_DEF(void) pj_scan_get_newline( pj_scanner *scanner ) { if (!PJ_SCAN_IS_NEWLINE(*scanner->curptr)) { pj_scan_syntax_err(scanner); return; } if (*scanner->curptr == '\r') { ++scanner->curptr; } if (*scanner->curptr == '\n') { ++scanner->curptr; } ++scanner->line; scanner->start_line = scanner->curptr; /** * This probably is a bug, see PROTOS test #2480. * This would cause scanner to incorrectly eat two new lines, e.g. * when parsing: * * Content-Length: 120\r\n * \r\n * <space><space><space>... * * When pj_scan_get_newline() is called to parse the first newline * in the Content-Length header, it will eat the second newline * too because it thinks that it's a header continuation. * * if (PJ_SCAN_IS_PROBABLY_SPACE(*scanner->curptr) && scanner->skip_ws) { * pj_scan_skip_whitespace(scanner); * } */ }
0
481,281
static void mlx5_fpga_conn_unmap_buf(struct mlx5_fpga_conn *conn, struct mlx5_fpga_dma_buf *buf) { struct device *dma_device; dma_device = &conn->fdev->mdev->pdev->dev; if (buf->sg[1].data) dma_unmap_single(dma_device, buf->sg[1].dma_addr, buf->sg[1].size, buf->dma_dir); if (likely(buf->sg[0].data)) dma_unmap_single(dma_device, buf->sg[0].dma_addr, buf->sg[0].size, buf->dma_dir); }
0
424,918
static int iwl_pcie_init_msix_handler(struct pci_dev *pdev, struct iwl_trans_pcie *trans_pcie) { int i; for (i = 0; i < trans_pcie->alloc_vecs; i++) { int ret; struct msix_entry *msix_entry; const char *qname = queue_name(&pdev->dev, trans_pcie, i); if (!qname) return -ENOMEM; msix_entry = &trans_pcie->msix_entries[i]; ret = devm_request_threaded_irq(&pdev->dev, msix_entry->vector, iwl_pcie_msix_isr, (i == trans_pcie->def_irq) ? iwl_pcie_irq_msix_handler : iwl_pcie_irq_rx_msix_handler, IRQF_SHARED, qname, msix_entry); if (ret) { IWL_ERR(trans_pcie->trans, "Error allocating IRQ %d\n", i); return ret; } } iwl_pcie_irq_set_affinity(trans_pcie->trans); return 0; }
0
459,184
void tc_cleanup_offload_action(struct flow_action *flow_action) { struct flow_action_entry *entry; int i; flow_action_for_each(i, entry, flow_action) { tcf_act_put_cookie(entry); if (entry->destructor) entry->destructor(entry->destructor_priv); } }
0