1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +03:00

Bug #43414 Parenthesis (and other) warnings compiling MySQL

with gcc 4.3.2
      
This patch fixes a number of GCC warnings about variables used
before initialized. A new macro UNINIT_VAR() is introduced for
use in the variable declaration, and LINT_INIT() usage will be
gradually deprecated. (A workaround is used for g++, pending a
patch for a g++ bug.)
      
GCC warnings for unused results (attribute warn_unused_result)
for a number of system calls (present at least in later
Ubuntus, where the usual void cast trick doesn't work) are
also fixed.


client/mysqlmanager-pwgen.c:
  A fix for warn_unused_result, adding fallback to use of
  srand()/rand() if /dev/random cannot be used. Also actually
  adds calls to rand() in the second branch so that it actually
  creates a random password.
This commit is contained in:
Staale Smedseng
2009-08-28 17:51:31 +02:00
parent 5edd807a7a
commit 1ba25ae47c
51 changed files with 142 additions and 191 deletions

View File

@ -1359,8 +1359,7 @@ int bin2decimal(char *from, decimal_t *to, int precision, int scale)
if (intg0x)
{
int i=dig2bytes[intg0x];
dec1 x;
LINT_INIT(x);
dec1 UNINIT_VAR(x);
switch (i)
{
case 1: x=mi_sint1korr(from); break;
@ -1401,8 +1400,7 @@ int bin2decimal(char *from, decimal_t *to, int precision, int scale)
if (frac0x)
{
int i=dig2bytes[frac0x];
dec1 x;
LINT_INIT(x);
dec1 UNINIT_VAR(x);
switch (i)
{
case 1: x=mi_sint1korr(from); break;
@ -1480,7 +1478,7 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
decimal_round_mode mode)
{
int frac0=scale>0 ? ROUND_UP(scale) : scale/DIG_PER_DEC1,
frac1=ROUND_UP(from->frac), round_digit,
frac1=ROUND_UP(from->frac), UNINIT_VAR(round_digit),
intg0=ROUND_UP(from->intg), error=E_DEC_OK, len=to->len,
intg1=ROUND_UP(from->intg +
(((intg0 + frac0)>0) && (from->buf[0] == DIG_MAX)));
@ -1489,7 +1487,6 @@ decimal_round(decimal_t *from, decimal_t *to, int scale,
sanity(to);
LINT_INIT(round_digit);
switch (mode) {
case HALF_UP:
case HALF_EVEN: round_digit=5; break;
@ -2117,13 +2114,11 @@ static int do_div_mod(decimal_t *from1, decimal_t *from2,
{
int frac1=ROUND_UP(from1->frac)*DIG_PER_DEC1, prec1=from1->intg+frac1,
frac2=ROUND_UP(from2->frac)*DIG_PER_DEC1, prec2=from2->intg+frac2,
error, i, intg0, frac0, len1, len2, dintg, div_mod=(!mod);
UNINIT_VAR(error), i, intg0, frac0, len1, len2, dintg, div_mod=(!mod);
dec1 *buf0, *buf1=from1->buf, *buf2=from2->buf, *tmp1,
*start2, *stop2, *stop1, *stop0, norm2, carry, *start1, dcarry;
dec2 norm_factor, x, guess, y;
LINT_INIT(error);
if (mod)
to=mod;