/** Access the pages of this process through /proc/self/task/<tid>/mem in order to safely print the contents of a memory address range. @param addr The address at the start of the memory region. @param max_len The length of the memory region. @return Zero on success. */ static int safe_print_str(const char *addr, int max_len) { int fd; pid_t tid; off_t offset; ssize_t nbytes= 0; size_t total, count; char buf[256]; tid= (pid_t) syscall(SYS_gettid); sprintf(buf, "/proc/self/task/%d/mem", tid); if ((fd= open(buf, O_RDONLY)) < 0) return -1; /* Ensure that off_t can hold a pointer. */ compile_time_assert(sizeof(off_t) >= sizeof(intptr)); total= max_len; offset= (intptr) addr; /* Read up to the maximum number of bytes. */ while (total) { count= min(sizeof(buf), total); if ((nbytes= pread(fd, buf, count, offset)) < 0) { /* Just in case... */ if (errno == EINTR) continue; else break; } /* Advance offset into memory. */ total-= nbytes; offset+= nbytes; addr+= nbytes; /* Output the printable characters. */ print_buffer(buf, nbytes); /* Break if less than requested... */ if ((count - nbytes)) break; } /* Output a new line if something was printed. */ if (total != (size_t) max_len) my_safe_printf_stderr("%s", "\n"); if (nbytes == -1) my_safe_printf_stderr("Can't read from address %p\n", addr); close(fd); return 0; }
void my_time_init() { #ifdef __WIN__ compile_time_assert(sizeof(LARGE_INTEGER) == sizeof(query_performance_frequency)); if (QueryPerformanceFrequency((LARGE_INTEGER *)&query_performance_frequency) == 0) query_performance_frequency= 0; #endif }
/* checks that the current build of atomic ops can run on this machine RETURN ATOMIC_xxx values, see my_atomic.h */ int my_atomic_initialize() { compile_time_assert(sizeof(intptr) == sizeof(void *)); /* currently the only thing worth checking is SMP/UP issue */ #ifdef MY_ATOMIC_MODE_DUMMY return my_getncpus() == 1 ? MY_ATOMIC_OK : MY_ATOMIC_NOT_1CPU; #else return MY_ATOMIC_OK; #endif }
/* Initialize a pinbox. Normally called from lf_alloc_init. See the latter for details. */ void lf_pinbox_init(LF_PINBOX *pinbox, uint free_ptr_offset, lf_pinbox_free_func *free_func, void *free_func_arg) { DBUG_ASSERT(free_ptr_offset % sizeof(void *) == 0); compile_time_assert(sizeof(LF_PINS) == 64); lf_dynarray_init(&pinbox->pinarray, sizeof(LF_PINS)); pinbox->pinstack_top_ver= 0; pinbox->pins_in_array= 0; pinbox->free_ptr_offset= free_ptr_offset; pinbox->free_func= free_func; pinbox->free_func_arg= free_func_arg; }
static inline struct utspace_trickle_node *_make_node(struct allocman *alloc, int *error) { compile_time_assert(trickle_struct_size, sizeof(struct utspace_trickle_node) == 36); uint32_t addr = (uint32_t)allocman_mspace_alloc(alloc, 68, error); uint32_t ret; struct utspace_trickle_node *node; if (*error) { return NULL; } ret = (addr + 32) & ((uint32_t)~MASK(5)); node = (struct utspace_trickle_node*)ret; node->padding = addr; return node; }
static uint32 maria_page_crc(uint32 start, uchar *data, uint length) { uint32 crc= crc32(start, data, length); /* we need this assert to get following comparison working */ compile_time_assert(MARIA_NO_CRC_BITMAP_PAGE == MARIA_NO_CRC_NORMAL_PAGE - 1 && MARIA_NO_CRC_NORMAL_PAGE == 0xffffffff); if (crc >= MARIA_NO_CRC_BITMAP_PAGE) crc= MARIA_NO_CRC_BITMAP_PAGE - 1; return(crc); }
void my_handler_error_register(void) { /* If you got compilation error here about compile_time_assert array, check that every HA_ERR_xxx constant has a corresponding error message in handler_error_messages[] list (check mysys/ma_handler_errors.h and include/my_base.h). */ compile_time_assert(HA_ERR_FIRST + array_elements(handler_error_messages) == HA_ERR_LAST + 1); my_error_register(get_handler_error_messages, HA_ERR_FIRST, HA_ERR_FIRST+ array_elements(handler_error_messages)-1); }
my_off_t my_win_lseek(File fd, my_off_t pos, int whence) { LARGE_INTEGER offset; LARGE_INTEGER newpos; DBUG_ENTER("my_win_lseek"); /* Check compatibility of Windows and Posix seek constants */ compile_time_assert(FILE_BEGIN == SEEK_SET && FILE_CURRENT == SEEK_CUR && FILE_END == SEEK_END); offset.QuadPart= pos; if(!SetFilePointerEx(my_get_osfhandle(fd), offset, &newpos, whence)) { my_osmaperr(GetLastError()); newpos.QuadPart= -1; } DBUG_RETURN(newpos.QuadPart); }
const char * STDCALL notification_value_to_name(uint16_t notification_value) { #ifdef __GNUC__ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #endif compile_time_assert(ARRAY_SIZE(notification_names) == TOTAL_NUM_OF_NOTIFICATIONS, assert_notification_names_size); #ifdef __GNUC__ #pragma GCC diagnostic pop #endif if (notification_value < avdecc_lib::TOTAL_NUM_OF_NOTIFICATIONS) { return notification_names[notification_value]; } return "UNKNOWN"; }
void * my_malloc(PSI_memory_key key, size_t size, myf flags) { my_memory_header *mh; size_t raw_size; compile_time_assert(sizeof(my_memory_header) <= HEADER_SIZE); raw_size= HEADER_SIZE + size; mh= (my_memory_header*) my_raw_malloc(raw_size, flags); if (likely(mh != NULL)) { void *user_ptr; mh->m_magic= MAGIC; mh->m_size= size; mh->m_key= PSI_MEMORY_CALL(memory_alloc)(key, size, & mh->m_owner); user_ptr= HEADER_TO_USER(mh); MEM_MALLOCLIKE_BLOCK(user_ptr, size, 0, (flags & MY_ZEROFILL)); return user_ptr; } return NULL; }
void init_client_errs(void) { compile_time_assert(array_elements(client_errors) == (CR_ERROR_LAST - CR_ERROR_FIRST + 2)); (void) my_error_register(get_client_errmsgs, CR_ERROR_FIRST, CR_ERROR_LAST); }
/* ======================== idMenuScreen_Shell_Leaderboards::RefreshLeaderboard ======================== */ void idMenuScreen_Shell_Leaderboards::RefreshLeaderboard() { if ( refreshWhenMasterIsOnline ) { SetLeaderboardIndex(); refreshWhenMasterIsOnline = false; } if ( !refreshLeaderboard ) { return; } refreshLeaderboard = false; bool upArrow = false; bool downArrow = false; int focusIndex = -1; idList< idList< idStr, TAG_IDLIB_LIST_MENU >, TAG_IDLIB_LIST_MENU > lbListings; if ( !lbCache->IsLoadingNewLeaderboard() && lbCache->GetErrorCode() == LEADERBOARD_DISPLAY_ERROR_NONE ) { for ( int addIndex = 0; addIndex < MAX_STAT_LISTINGS; ++addIndex ) { idList< idStr > values; int index = lbCache->GetRowOffset() + addIndex; const idLeaderboardCallback::row_t * row = lbCache->GetLeaderboardRow( index ); // If this row is not in the cache, this will kick off a request if ( row != NULL ) { values.Append( va( "%i", (int)row->rank ) ); values.Append( row->name ); values.Append( FormatColumn( &lbCache->GetLeaderboard()->columnDefs[0], row->columns[0] ).ToString() ); } if ( lbCache->GetEntryIndex() == addIndex ) { focusIndex = addIndex; } lbListings.Append( values ); } if ( lbCache->GetRowOffset() != 0 ) { upArrow = true; } if ( ( lbCache->GetRowOffset() + MAX_STAT_LISTINGS ) < lbCache->GetNumRowsInLeaderboard() ) { downArrow = true; } } if ( lbHeading != NULL ) { lbHeading->SetText( leaderboards[ lbIndex ].name ); lbHeading->SetStrokeInfo( true, 0.75f, 1.75f ); } if ( focusIndex >= 0 ) { options->SetFocusIndex( focusIndex ); } if ( btnPageDwn != NULL && btnPageDwn->GetSprite() != NULL ) { btnPageDwn->GetSprite()->SetVisible( downArrow ); } if ( btnPageUp != NULL && btnPageUp->GetSprite() != NULL ) { btnPageUp->GetSprite()->SetVisible( upArrow ); } options->SetListData( lbListings ); Update(); const char * leaderboardErrorStrings[] = { "", "#str_online_leaderboards_error_failed", // failed "", // not online - players are just taken back to multiplayer menu "#str_online_leaderboards_error_not_ranked", // not ranked }; compile_time_assert( sizeof( leaderboardErrorStrings ) / sizeof( leaderboardErrorStrings[0] ) == LEADERBOARD_DISPLAY_ERROR_MAX ); bool isLoading = lbCache->IsLoadingNewLeaderboard(); idStr error = leaderboardErrorStrings[ lbCache->GetErrorCode() ]; if ( isLoading ) { ShowMessage( true, "#str_online_loading", true ); } else { if ( !error.IsEmpty() ) { ShowMessage( true, error, false ); } else { if ( lbCache->GetNumRowsInLeaderboard() > 0 ) { ShowMessage( false, "", false ); } else { ShowMessage( true, "#str_online_leaderboards_no_data", false ); } } } }
static int send_client_reply_packet(MCPVIO_EXT *mpvio, const uchar *data, int data_len) { MYSQL *mysql= mpvio->mysql; NET *net= &mysql->net; char *buff, *end; size_t conn_attr_len= (mysql->options.extension) ? mysql->options.extension->connect_attrs_len : 0; /* see end= buff+32 below, fixed size of the packet is 32 bytes */ buff= my_alloca(33 + USERNAME_LENGTH + data_len + NAME_LEN + NAME_LEN + conn_attr_len + 9); mysql->client_flag|= mysql->options.client_flag; mysql->client_flag|= CLIENT_CAPABILITIES; if (mysql->client_flag & CLIENT_MULTI_STATEMENTS) mysql->client_flag|= CLIENT_MULTI_RESULTS; #if defined(HAVE_OPENSSL) && !defined(EMBEDDED_LIBRARY) if (mysql->options.ssl_key || mysql->options.ssl_cert || mysql->options.ssl_ca || mysql->options.ssl_capath || mysql->options.ssl_cipher) mysql->options.use_ssl= 1; if (mysql->options.use_ssl) mysql->client_flag|= CLIENT_SSL; /* if server doesn't support SSL and verification of server certificate was set to mandatory, we need to return an error */ if (mysql->options.use_ssl && !(mysql->server_capabilities & CLIENT_SSL)) { if ((mysql->client_flag & CLIENT_SSL_VERIFY_SERVER_CERT) || (mysql->options.extension && (mysql->options.extension->ssl_fp || mysql->options.extension->ssl_fp_list))) { my_set_error(mysql, CR_SSL_CONNECTION_ERROR, SQLSTATE_UNKNOWN, ER(CR_SSL_CONNECTION_ERROR), "Server doesn't support SSL"); goto error; } } #endif /* HAVE_OPENSSL && !EMBEDDED_LIBRARY*/ if (mpvio->db) mysql->client_flag|= CLIENT_CONNECT_WITH_DB; /* Remove options that server doesn't support */ mysql->client_flag= mysql->client_flag & (~(CLIENT_COMPRESS | CLIENT_SSL | CLIENT_PROTOCOL_41) | mysql->server_capabilities); #ifndef HAVE_COMPRESS mysql->client_flag&= ~CLIENT_COMPRESS; #endif if (mysql->client_flag & CLIENT_PROTOCOL_41) { /* 4.1 server and 4.1 client has a 32 byte option flag */ int4store(buff,mysql->client_flag); int4store(buff+4, net->max_packet_size); buff[8]= (char) mysql->charset->nr; bzero(buff+9, 32-9); end= buff+32; } else { int2store(buff, mysql->client_flag); int3store(buff+2, net->max_packet_size); end= buff+5; } #ifdef HAVE_OPENSSL if (mysql->options.ssl_key || mysql->options.ssl_cert || mysql->options.ssl_ca || mysql->options.ssl_capath || mysql->options.ssl_cipher #ifdef CRL_IMPLEMENTED || (mysql->options.extension && (mysql->options.extension->ssl_crl || mysql->options.extension->ssl_crlpath)) #endif ) mysql->options.use_ssl= 1; if (mysql->options.use_ssl && (mysql->client_flag & CLIENT_SSL)) { SSL *ssl; /* Send mysql->client_flag, max_packet_size - unencrypted otherwise the server does not know we want to do SSL */ if (my_net_write(net, (char*)buff, (size_t) (end-buff)) || net_flush(net)) { my_set_error(mysql, CR_SERVER_LOST, SQLSTATE_UNKNOWN, ER(CR_SERVER_LOST_EXTENDED), "sending connection information to server", errno); goto error; } /* Create SSL */ if (!(ssl= my_ssl_init(mysql))) goto error; /* Connect to the server */ if (my_ssl_connect(ssl)) { SSL_free(ssl); goto error; } if (mysql->options.extension && (mysql->options.extension->ssl_fp || mysql->options.extension->ssl_fp_list)) { if (ma_ssl_verify_fingerprint(ssl)) goto error; } if ((mysql->options.ssl_ca || mysql->options.ssl_capath) && (mysql->client_flag & CLIENT_SSL_VERIFY_SERVER_CERT) && my_ssl_verify_server_cert(ssl)) goto error; } #endif /* HAVE_OPENSSL */ DBUG_PRINT("info",("Server version = '%s' capabilites: %lu status: %u client_flag: %lu", mysql->server_version, mysql->server_capabilities, mysql->server_status, mysql->client_flag)); compile_time_assert(MYSQL_USERNAME_LENGTH == USERNAME_LENGTH); /* This needs to be changed as it's not useful with big packets */ if (mysql->user[0]) strmake(end, mysql->user, USERNAME_LENGTH); else read_user_name(end); /* We have to handle different version of handshake here */ DBUG_PRINT("info",("user: %s",end)); end= strend(end) + 1; if (data_len) { if (mysql->server_capabilities & CLIENT_SECURE_CONNECTION) { *end++= data_len; memcpy(end, data, data_len); end+= data_len; } else { DBUG_ASSERT(data_len == SCRAMBLE_LENGTH_323 + 1); /* incl. \0 at the end */ memcpy(end, data, data_len); end+= data_len; } } else *end++= 0; /* Add database if needed */ if (mpvio->db && (mysql->server_capabilities & CLIENT_CONNECT_WITH_DB)) { end= strmake(end, mpvio->db, NAME_LEN) + 1; mysql->db= my_strdup(mpvio->db, MYF(MY_WME)); } if (mysql->server_capabilities & CLIENT_PLUGIN_AUTH) end= strmake(end, mpvio->plugin->name, NAME_LEN) + 1; end= ma_send_connect_attr(mysql, end); /* Write authentication package */ if (my_net_write(net, buff, (size_t) (end-buff)) || net_flush(net)) { my_set_error(mysql, CR_SERVER_LOST, SQLSTATE_UNKNOWN, ER(CR_SERVER_LOST_EXTENDED), "sending authentication information", errno); goto error; } my_afree(buff); return 0; error: my_afree(buff); return 1; }
int run_plugin_auth(MYSQL *mysql, char *data, uint data_len, const char *data_plugin, const char *db) { const char *auth_plugin_name; auth_plugin_t *auth_plugin; MCPVIO_EXT mpvio; ulong pkt_length; int res; /* determine the default/initial plugin to use */ if (mysql->options.extension && mysql->options.extension->default_auth && mysql->server_capabilities & CLIENT_PLUGIN_AUTH) { auth_plugin_name= mysql->options.extension->default_auth; if (!(auth_plugin= (auth_plugin_t*) mysql_client_find_plugin(mysql, auth_plugin_name, MYSQL_CLIENT_AUTHENTICATION_PLUGIN))) return 1; /* oops, not found */ } else { auth_plugin= mysql->server_capabilities & CLIENT_PROTOCOL_41 ? &native_password_client_plugin : &old_password_client_plugin; auth_plugin_name= auth_plugin->name; } mysql->net.last_errno= 0; /* just in case */ if (data_plugin && strcmp(data_plugin, auth_plugin_name)) { /* data was prepared for a different plugin, don't show it to this one */ data= 0; data_len= 0; } mpvio.mysql_change_user= data_plugin == 0; mpvio.cached_server_reply.pkt= (uchar*)data; mpvio.cached_server_reply.pkt_len= data_len; mpvio.read_packet= client_mpvio_read_packet; mpvio.write_packet= client_mpvio_write_packet; mpvio.info= client_mpvio_info; mpvio.mysql= mysql; mpvio.packets_read= mpvio.packets_written= 0; mpvio.db= db; mpvio.plugin= auth_plugin; res= auth_plugin->authenticate_user((struct st_plugin_vio *)&mpvio, mysql); compile_time_assert(CR_OK == -1); compile_time_assert(CR_ERROR == 0); if (res > CR_OK && mysql->net.read_pos[0] != 254) { /* the plugin returned an error. write it down in mysql, unless the error code is CR_ERROR and mysql->net.last_errno is already set (the plugin has done it) */ if (res > CR_ERROR) my_set_error(mysql, res, SQLSTATE_UNKNOWN, 0); else if (!mysql->net.last_errno) my_set_error(mysql, CR_UNKNOWN_ERROR, SQLSTATE_UNKNOWN, 0); return 1; } /* read the OK packet (or use the cached value in mysql->net.read_pos */ if (res == CR_OK) pkt_length= net_safe_read(mysql); else /* res == CR_OK_HANDSHAKE_COMPLETE */ pkt_length= mpvio.last_read_packet_len; if (pkt_length == packet_error) { if (mysql->net.last_errno == CR_SERVER_LOST) my_set_error(mysql, CR_SERVER_LOST, SQLSTATE_UNKNOWN, ER(CR_SERVER_LOST_EXTENDED), "reading authorization packet", errno); return 1; } if (mysql->net.read_pos[0] == 254) { /* The server asked to use a different authentication plugin */ if (pkt_length == 1) { /* old "use short scramble" packet */ auth_plugin_name= old_password_plugin_name; mpvio.cached_server_reply.pkt= (uchar*)mysql->scramble_buff; mpvio.cached_server_reply.pkt_len= SCRAMBLE_LENGTH + 1; } else { /* new "use different plugin" packet */ uint len; auth_plugin_name= (char*)mysql->net.read_pos + 1; len= (uint)strlen(auth_plugin_name); /* safe as my_net_read always appends \0 */ mpvio.cached_server_reply.pkt_len= pkt_length - len - 2; mpvio.cached_server_reply.pkt= mysql->net.read_pos + len + 2; } if (!(auth_plugin= (auth_plugin_t *) mysql_client_find_plugin(mysql, auth_plugin_name, MYSQL_CLIENT_AUTHENTICATION_PLUGIN))) return 1; mpvio.plugin= auth_plugin; res= auth_plugin->authenticate_user((struct st_plugin_vio *)&mpvio, mysql); if (res > CR_OK) { if (res > CR_ERROR) my_set_error(mysql, res, SQLSTATE_UNKNOWN, 0); else if (!mysql->net.last_errno) my_set_error(mysql, CR_UNKNOWN_ERROR, SQLSTATE_UNKNOWN, 0); return 1; } if (res != CR_OK_HANDSHAKE_COMPLETE) { /* Read what server thinks about out new auth message report */ if (net_safe_read(mysql) == packet_error) { if (mysql->net.last_errno == CR_SERVER_LOST) my_set_error(mysql, CR_SERVER_LOST, SQLSTATE_UNKNOWN, ER(CR_SERVER_LOST_EXTENDED), "reading final connect information", errno); return 1; } } } /* net->read_pos[0] should always be 0 here if the server implements the protocol correctly */ return mysql->net.read_pos[0] != 0; }
void do_tests() { DBUG_ENTER("do_tests"); skip_all(": this module is not used in MySQL"); plan(12); compile_time_assert(THREADS >= 4); DBUG_PRINT("wt", ("================= initialization ===================")); bad= my_atomic_initialize(); ok(!bad, "my_atomic_initialize() returned %d", bad); mysql_cond_init(0, &thread_sync, 0); mysql_mutex_init(0, &lock, 0); wt_init(); for (cnt=0; cnt < THREADS; cnt++) mysql_mutex_init(0, & thds[cnt].lock, 0); { WT_RESOURCE_ID resid[4]; for (i=0; i < array_elements(resid); i++) { wt_thd_lazy_init(& thds[i].thd, & wt_deadlock_search_depth_short, & wt_timeout_short, & wt_deadlock_search_depth_long, & wt_timeout_long); resid[i].value= i+1; resid[i].type= &restype; } DBUG_PRINT("wt", ("================= manual test ===================")); #define ok_wait(X,Y, R) \ ok(wt_thd_will_wait_for(& thds[X].thd, & thds[Y].thd, &resid[R]) == 0, \ "thd[" #X "] will wait for thd[" #Y "]") #define ok_deadlock(X,Y,R) \ ok(wt_thd_will_wait_for(& thds[X].thd, & thds[Y].thd, &resid[R]) == WT_DEADLOCK, \ "thd[" #X "] will wait for thd[" #Y "] - deadlock") ok_wait(0,1,0); ok_wait(0,2,0); ok_wait(0,3,0); mysql_mutex_lock(&lock); bad= wt_thd_cond_timedwait(& thds[0].thd, &lock); mysql_mutex_unlock(&lock); ok(bad == WT_TIMEOUT, "timeout test returned %d", bad); ok_wait(0,1,0); ok_wait(1,2,1); ok_deadlock(2,0,2); mysql_mutex_lock(&lock); ok(wt_thd_cond_timedwait(& thds[0].thd, &lock) == WT_TIMEOUT, "as always"); ok(wt_thd_cond_timedwait(& thds[1].thd, &lock) == WT_TIMEOUT, "as always"); wt_thd_release_all(& thds[0].thd); wt_thd_release_all(& thds[1].thd); wt_thd_release_all(& thds[2].thd); wt_thd_release_all(& thds[3].thd); for (i=0; i < array_elements(resid); i++) { wt_thd_release_all(& thds[i].thd); wt_thd_destroy(& thds[i].thd); } mysql_mutex_unlock(&lock); } wt_deadlock_search_depth_short=6; wt_timeout_short=1000; wt_timeout_long= 100; wt_deadlock_search_depth_long=16; DBUG_PRINT("wt", ("================= stress test ===================")); diag("timeout_short=%lu us, deadlock_search_depth_short=%lu", wt_timeout_short, wt_deadlock_search_depth_short); diag("timeout_long=%lu us, deadlock_search_depth_long=%lu", wt_timeout_long, wt_deadlock_search_depth_long); #define test_kill_strategy(X) \ diag("kill strategy: " #X); \ DBUG_EXECUTE("reset_file", \ { rewind(DBUG_FILE); my_chsize(fileno(DBUG_FILE), 0, 0, MYF(0)); }); \ DBUG_PRINT("info", ("kill strategy: " #X)); \ kill_strategy=X; \ do_one_test(); test_kill_strategy(LATEST); test_kill_strategy(RANDOM); /* these two take looong time on sol10-amd64-a the server doesn't use this code now, so we disable these tests test_kill_strategy(YOUNGEST); test_kill_strategy(LOCKS); */ DBUG_PRINT("wt", ("================= cleanup ===================")); for (cnt=0; cnt < THREADS; cnt++) mysql_mutex_destroy(& thds[cnt].lock); wt_end(); mysql_mutex_destroy(&lock); mysql_cond_destroy(&thread_sync); DBUG_VOID_RETURN; }
static my_bool maria_page_crc_check(uchar *page, pgcache_page_no_t page_no, MARIA_SHARE *share, uint32 no_crc_val, int data_length) { uint32 crc= uint4korr(page + share->block_size - CRC_SIZE), new_crc; my_bool res; DBUG_ENTER("maria_page_crc_check"); DBUG_ASSERT((uint)data_length <= share->block_size - CRC_SIZE); /* we need this assert to get following comparison working */ compile_time_assert(MARIA_NO_CRC_BITMAP_PAGE == MARIA_NO_CRC_NORMAL_PAGE - 1 && MARIA_NO_CRC_NORMAL_PAGE == 0xffffffff); /* If crc is no_crc_val then the page has no crc, so there is nothing to check. */ if (crc >= MARIA_NO_CRC_BITMAP_PAGE) { DBUG_PRINT("info", ("No crc: %lu crc: %lu page: %lu ", (ulong) no_crc_val, (ulong) crc, (ulong) page_no)); if (crc != no_crc_val) { my_errno= HA_ERR_WRONG_CRC; DBUG_PRINT("error", ("Wrong no CRC value")); DBUG_RETURN(1); } DBUG_RETURN(0); } new_crc= maria_page_crc((uint32) page_no, page, data_length); DBUG_ASSERT(new_crc != no_crc_val); res= MY_TEST(new_crc != crc); if (res) { /* Bitmap pages may be totally zero filled in some cases. This happens when we get a crash after the pagecache has written out a page that is on a newly created bitmap page and we get a crash before the bitmap page is written out. We handle this case with the following logic: When reading, approve of bitmap pages where all bytes are zero (This is after all a bitmap pages where no data is reserved and the CRC will be corrected at next write) */ if (no_crc_val == MARIA_NO_CRC_BITMAP_PAGE && crc == 0 && _ma_check_if_zero(page, data_length)) { DBUG_PRINT("warning", ("Found bitmap page that was not initialized")); DBUG_RETURN(0); } DBUG_PRINT("error", ("Page: %lu crc: %lu calculated crc: %lu", (ulong) page_no, (ulong) crc, (ulong) new_crc)); my_errno= HA_ERR_WRONG_CRC; } DBUG_RETURN(res); }
/* ======================== idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::GetField ======================== */ idSWFScriptVar idMenuScreen_Shell_SystemOptions::idMenuDataSource_SystemSettings::GetField( const int fieldIndex ) const { switch( fieldIndex ) { case SYSTEM_FIELD_FULLSCREEN: { const int fullscreen = r_fullscreen.GetInteger(); const int vidmode = r_vidMode.GetInteger(); if( fullscreen == 0 ) { return "#str_swf_disabled"; } if( fullscreen < 0 || vidmode < 0 || vidmode >= modeList.Num() ) { return "???"; } if( modeList[vidmode].displayHz == 60 ) { return va( "%4i x %4i", modeList[vidmode].width, modeList[vidmode].height ); } else { return va( "%4i x %4i @ %dhz", modeList[vidmode].width, modeList[vidmode].height, modeList[vidmode].displayHz ); } } case SYSTEM_FIELD_FRAMERATE: return va( "%d FPS", com_engineHz.GetInteger() ); case SYSTEM_FIELD_VSYNC: if( r_swapInterval.GetInteger() == 1 ) { return "#str_swf_smart"; } else if( r_swapInterval.GetInteger() == 2 ) { return "#str_swf_enabled"; } else { return "#str_swf_disabled"; } case SYSTEM_FIELD_ANTIALIASING: { if( r_antiAliasing.GetInteger() == 0 ) { return "#str_swf_disabled"; } static const int numValues = 5; static const char* values[numValues] = { "None", "SMAA 1X", "MSAA 2X", "MSAA 4X", "MSAA 8X" }; compile_time_assert( numValues == ( ANTI_ALIASING_MSAA_8X + 1 ) ); return values[ r_antiAliasing.GetInteger() ]; } case SYSTEM_FIELD_MOTIONBLUR: if( r_motionBlur.GetInteger() == 0 ) { return "#str_swf_disabled"; } return va( "%dx", idMath::IPow( 2, r_motionBlur.GetInteger() ) ); // RB begin case SYSTEM_FIELD_SHADOWMAPPING: if( r_useShadowMapping.GetInteger() == 1 ) { return "#str_swf_enabled"; } else { return "#str_swf_disabled"; } //case SYSTEM_FIELD_LODBIAS: // return LinearAdjust( r_lodBias.GetFloat(), -1.0f, 1.0f, 0.0f, 100.0f ); // RB end case SYSTEM_FIELD_BRIGHTNESS: return LinearAdjust( r_exposure.GetFloat(), 0.0f, 1.0f, 0.0f, 100.0f ); case SYSTEM_FIELD_VOLUME: { return 100.0f * Square( 1.0f - ( s_volume_dB.GetFloat() / DB_SILENCE ) ); } } return false; }