mirror of
https://github.com/MariaDB/server.git
synced 2025-01-21 06:22:28 +01:00
50bd97a943
Fixed a couple of usage of not initialized warnings (unlikely cases) client/mysqldump.c: Fixed compiler warnings from 'max' build client/mysqltest.c: Removed compiler warnings cmd-line-utils/readline/xmalloc.c: Fixed compiler warnings from 'max' build extra/comp_err.c: Fixed compiler warnings from 'max' build extra/yassl/include/openssl/ssl.h: Changed prototype for SSL_set_fd() to fix compiler warnings (and possible errors) on windows 64 bit extra/yassl/include/socket_wrapper.hpp: Moved socket_t to ssl.h, to be able to removed compiler warnings on windows 64 bit extra/yassl/src/ssl.cpp: Changed prototype for SSL_set_fd() to fix compiler warnings (and possible errors) on windows 64 bit extra/yassl/taocrypt/src/integer.cpp: Fixed compiler warnings include/my_global.h: Added my_offsetof() macro from 5.1 to get rid of compiler warnings innobase/include/ut0byte.ic: Fixed compiler warnings on win64 innobase/include/ut0ut.ic: Fixed compiler warnings on win64 libmysql/libmysql.def: Fixed compiler warnings on win64 myisam/mi_packrec.c: Fixed compiler warnings on win64 myisam/myisamchk.c: Fixed compiler warnings from 'max' build mysys/base64.c: Fixed compiler warnings on win64 mysys/mf_keycache.c: Fixed compiler warnings from 'max' build mysys/my_getopt.c: Fixed compiler warnings from 'max' build mysys/my_init.c: Fixed compiler warnings from 'max' build mysys/my_thr_init.c: Fixed compiler warnings mysys/ptr_cmp.c: Fixed compiler warnings from 'max' build ndb/include/kernel/signaldata/DictTabInfo.hpp: Fixed compiler warnings server-tools/instance-manager/mysql_connection.cc: Fixed compiler warnings server-tools/instance-manager/mysqlmanager.cc: Fixed compiler warnings sql/filesort.cc: Initalize variable that was used unitialized in error conditions sql/ha_berkeley.cc: Moved get_auto_primary_key() here as int5store() gives (wrong) compiler warnings in win64 sql/ha_berkeley.h: Moved get_auto_primary_key() to ha_berkeley.cc sql/ha_innodb.cc: Fixed compiler warnings sql/item.cc: Fixed compiler warnings from 'max' build sql/item_timefunc.cc: Fixed compiler warnings sql/mysqld.cc: Fixed compiler warnings sql/sql_acl.cc: Fixed compiler warnings from 'max' build sql/sql_base.cc: Fixed compiler warnings from 'max' build sql/sql_insert.cc: Initialize variable that may be used unitialized on error conditions (not fatal) sql/sql_prepare.cc: Fixed compiler warnings from 'max' build sql/sql_select.cc: Fixed compiler warnings sql/sql_show.cc: Fixed compiler warnings sql/udf_example.def: Fixed compiler warnings on win64 sql/unireg.cc: Initialize variable that may be used unitialized on error conditions strings/ctype-ucs2.c: Fixed compiler warnings strings/ctype-utf8.c: Fixed compiler warnings strings/decimal.c: Fixed compiler warnings support-files/compiler_warnings.supp: Ignore warnings from sql_yacc.cc that are hard to remove Ignore some not important warnings from windows 64 bit build tools/mysqlmanager.c: Fixed compiler warnings
174 lines
3.6 KiB
Text
174 lines
3.6 KiB
Text
/******************************************************************
|
|
Various utilities
|
|
|
|
(c) 1994, 1995 Innobase Oy
|
|
|
|
Created 5/30/1994 Heikki Tuuri
|
|
*******************************************************************/
|
|
|
|
/**********************************************************
|
|
Calculates the minimum of two ulints. */
|
|
UNIV_INLINE
|
|
ulint
|
|
ut_min(
|
|
/*===*/
|
|
/* out: minimum */
|
|
ulint n1, /* in: first number */
|
|
ulint n2) /* in: second number */
|
|
{
|
|
return((n1 <= n2) ? n1 : n2);
|
|
}
|
|
|
|
/**********************************************************
|
|
Calculates the maximum of two ulints. */
|
|
UNIV_INLINE
|
|
ulint
|
|
ut_max(
|
|
/*===*/
|
|
/* out: maximum */
|
|
ulint n1, /* in: first number */
|
|
ulint n2) /* in: second number */
|
|
{
|
|
return((n1 <= n2) ? n2 : n1);
|
|
}
|
|
|
|
/********************************************************************
|
|
Calculates minimum of two ulint-pairs. */
|
|
UNIV_INLINE
|
|
void
|
|
ut_pair_min(
|
|
/*========*/
|
|
ulint* a, /* out: more significant part of minimum */
|
|
ulint* b, /* out: less significant part of minimum */
|
|
ulint a1, /* in: more significant part of first pair */
|
|
ulint b1, /* in: less significant part of first pair */
|
|
ulint a2, /* in: more significant part of second pair */
|
|
ulint b2) /* in: less significant part of second pair */
|
|
{
|
|
if (a1 == a2) {
|
|
*a = a1;
|
|
*b = ut_min(b1, b2);
|
|
} else if (a1 < a2) {
|
|
*a = a1;
|
|
*b = b1;
|
|
} else {
|
|
*a = a2;
|
|
*b = b2;
|
|
}
|
|
}
|
|
|
|
/**********************************************************
|
|
Compares two ulints. */
|
|
UNIV_INLINE
|
|
int
|
|
ut_ulint_cmp(
|
|
/*=========*/
|
|
/* out: 1 if a > b, 0 if a == b, -1 if a < b */
|
|
ulint a, /* in: ulint */
|
|
ulint b) /* in: ulint */
|
|
{
|
|
if (a < b) {
|
|
return(-1);
|
|
} else if (a == b) {
|
|
return(0);
|
|
} else {
|
|
return(1);
|
|
}
|
|
}
|
|
|
|
/***********************************************************
|
|
Compares two pairs of ulints. */
|
|
UNIV_INLINE
|
|
int
|
|
ut_pair_cmp(
|
|
/*========*/
|
|
/* out: -1 if a < b, 0 if a == b, 1 if a > b */
|
|
ulint a1, /* in: more significant part of first pair */
|
|
ulint a2, /* in: less significant part of first pair */
|
|
ulint b1, /* in: more significant part of second pair */
|
|
ulint b2) /* in: less significant part of second pair */
|
|
{
|
|
if (a1 > b1) {
|
|
return(1);
|
|
} else if (a1 < b1) {
|
|
return(-1);
|
|
} else if (a2 > b2) {
|
|
return(1);
|
|
} else if (a2 < b2) {
|
|
return(-1);
|
|
} else {
|
|
return(0);
|
|
}
|
|
}
|
|
|
|
/*****************************************************************
|
|
Calculates fast the remainder when divided by a power of two. */
|
|
UNIV_INLINE
|
|
ulint
|
|
ut_2pow_remainder(
|
|
/*==============*/ /* out: remainder */
|
|
ulint n, /* in: number to be divided */
|
|
ulint m) /* in: divisor; power of 2 */
|
|
{
|
|
ut_ad(0x80000000UL % m == 0);
|
|
|
|
return(n & (m - 1));
|
|
}
|
|
|
|
/*****************************************************************
|
|
Calculates fast a value rounded to a multiple of a power of 2. */
|
|
UNIV_INLINE
|
|
ulint
|
|
ut_2pow_round(
|
|
/*==========*/ /* out: value of n rounded down to nearest
|
|
multiple of m */
|
|
ulint n, /* in: number to be rounded */
|
|
ulint m) /* in: divisor; power of 2 */
|
|
{
|
|
ut_ad(0x80000000UL % m == 0);
|
|
|
|
return(n & ~(m - 1));
|
|
}
|
|
|
|
/*****************************************************************
|
|
Calculates fast the 2-logarithm of a number, rounded upward to an
|
|
integer. */
|
|
UNIV_INLINE
|
|
ulint
|
|
ut_2_log(
|
|
/*=====*/
|
|
/* out: logarithm in the base 2, rounded upward */
|
|
ulint n) /* in: number != 0 */
|
|
{
|
|
ulint res;
|
|
|
|
res = 0;
|
|
|
|
ut_ad(n > 0);
|
|
|
|
n = n - 1;
|
|
|
|
for (;;) {
|
|
n = n / 2;
|
|
|
|
if (n == 0) {
|
|
break;
|
|
}
|
|
|
|
res++;
|
|
}
|
|
|
|
return(res + 1);
|
|
}
|
|
|
|
/*****************************************************************
|
|
Calculates 2 to power n. */
|
|
UNIV_INLINE
|
|
ulint
|
|
ut_2_exp(
|
|
/*=====*/
|
|
/* out: 2 to power n */
|
|
ulint n) /* in: number */
|
|
{
|
|
return((ulint) 1 << n);
|
|
}
|