Skip to content

Commit 93fb8bb

Browse files
Davi ArnautDavi Arnaut
Davi Arnaut
authored and
Davi Arnaut
committed
Bug#53445: Build with -Wall and fix warnings that it generates
Apart strict-aliasing warnings, fix the remaining warnings generated by GCC 4.4.4 -Wall and -Wextra flags. One major source of warnings was the in-house function my_bcmp which (unconventionally) took pointers to unsigned characters as the byte sequences to be compared. Since my_bcmp and bcmp are deprecated functions whose only difference with memcmp is the return value, every use of the function is replaced with memcmp as the special return value wasn't actually being used by any caller. There were also various other warnings, mostly due to type mismatches, missing return values, missing prototypes, dead code (unreachable) and ignored return values.
1 parent 6d5b440 commit 93fb8bb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+257
-362
lines changed

BUILD/SETUP.sh

+5-8
Original file line numberDiff line numberDiff line change
@@ -90,22 +90,19 @@ SSL_LIBRARY=--with-ssl
9090

9191
if [ "x$warning_mode" != "xpedantic" ]; then
9292
# Both C and C++ warnings
93-
warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W"
94-
warnings="$warnings -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare"
95-
warnings="$warnings -Wwrite-strings -Wunused-function -Wunused-label -Wunused-value -Wunused-variable"
93+
warnings="-Wall -Wextra -Wunused -Wwrite-strings"
9694

9795
# For more warnings, uncomment the following line
98-
# warnings="$global_warnings -Wshadow"
96+
# warnings="$warnings -Wshadow"
9997

10098
# C warnings
101-
c_warnings="$warnings -Wunused-parameter"
99+
c_warnings="$warnings"
102100
# C++ warnings
103-
cxx_warnings="$warnings"
101+
cxx_warnings="$warnings -Wno-unused-parameter"
104102
# cxx_warnings="$cxx_warnings -Woverloaded-virtual -Wsign-promo"
105-
cxx_warnings="$cxx_warnings -Wreorder"
106103
cxx_warnings="$cxx_warnings -Wctor-dtor-privacy -Wnon-virtual-dtor"
107104
# Added unless --with-debug=full
108-
debug_extra_cflags="-O0 -g3 -gdwarf-2" #1 -Wuninitialized"
105+
debug_extra_cflags="-O0 -g3 -gdwarf-2"
109106
else
110107
warnings="-W -Wall -ansi -pedantic -Wno-long-long -Wno-unused -D_POSIX_SOURCE"
111108
c_warnings="$warnings"

BUILD/check-cpu

+13-10
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,17 @@ check_cpu () {
181181
cc=$CC
182182
fi
183183

184-
cc_ver=`$cc --version | sed 1q`
185-
cc_verno=`echo $cc_ver | sed -e 's/^.*(GCC)//g; s/[^0-9. ]//g; s/^ *//g; s/ .*//g'`
186-
set -- `echo $cc_verno | tr '.' ' '`
187-
cc_major=$1
188-
cc_minor=$2
189-
cc_patch=$3
190-
cc_comp=`expr $cc_major '*' 100 '+' $cc_minor`
191-
184+
# check if compiler is gcc and dump its version
185+
cc_verno=`$cc -dumpversion 2>/dev/null`
186+
if test "x$?" = "x0" ; then
187+
set -- `echo $cc_verno | tr '.' ' '`
188+
cc_ver="GCC"
189+
cc_major=$1
190+
cc_minor=$2
191+
cc_patch=$3
192+
cc_comp=`expr $cc_major '*' 100 '+' $cc_minor`
193+
fi
194+
192195
case "$cc_ver--$cc_verno" in
193196
*GCC*)
194197
# different gcc backends (and versions) have different CPU flags
@@ -229,7 +232,7 @@ check_cpu () {
229232
fi
230233
while [ "$cpu_arg" ] ; do
231234
printf "testing $cpu_arg ... " >&2
232-
235+
233236
# compile check
234237
eval "$cc -c $check_cpu_cflags __test.c" 2>/dev/null
235238
if test "x$?" = "x0" ; then
@@ -243,5 +246,5 @@ check_cpu () {
243246
done
244247
rm __test.*
245248
}
246-
249+
247250
check_cpu

client/mysql.cc

-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ extern "C" {
9393
#endif
9494
#endif
9595

96-
#undef bcmp // Fix problem with new readline
9796
#if defined(__WIN__)
9897
#include <conio.h>
9998
#elif !defined(__NETWARE__)

client/mysqltest.cc

+9-12
Original file line numberDiff line numberDiff line change
@@ -5780,7 +5780,7 @@ int read_command(struct st_command** command_ptr)
57805780
(struct st_command*) my_malloc(sizeof(*command),
57815781
MYF(MY_WME|MY_ZEROFILL))) ||
57825782
insert_dynamic(&q_lines, (uchar*) &command))
5783-
die(NullS);
5783+
die("Out of memory");
57845784
command->type= Q_UNKNOWN;
57855785

57865786
read_command_buf[0]= 0;
@@ -6260,7 +6260,7 @@ void init_win_path_patterns()
62606260
}
62616261

62626262
if (insert_dynamic(&patterns, (uchar*) &p))
6263-
die(NullS);
6263+
die("Out of memory");
62646264

62656265
DBUG_PRINT("info", ("p: %s", p));
62666266
while (*p)
@@ -9331,8 +9331,7 @@ REPLACE *init_replace(char * *from, char * *to,uint count,
93319331
for (i=1 ; i <= found_sets ; i++)
93329332
{
93339333
pos=from[found_set[i-1].table_offset];
9334-
rep_str[i].found= !bcmp((const uchar*) pos,
9335-
(const uchar*) "\\^", 3) ? 2 : 1;
9334+
rep_str[i].found= !memcmp(pos, "\\^", 3) ? 2 : 1;
93369335
rep_str[i].replace_string=to_array[found_set[i-1].table_offset];
93379336
rep_str[i].to_offset=found_set[i-1].found_offset-start_at_word(pos);
93389337
rep_str[i].from_offset=found_set[i-1].found_offset-replace_len(pos)+
@@ -9460,8 +9459,8 @@ void copy_bits(REP_SET *to,REP_SET *from)
94609459

94619460
int cmp_bits(REP_SET *set1,REP_SET *set2)
94629461
{
9463-
return bcmp((uchar*) set1->bits,(uchar*) set2->bits,
9464-
sizeof(uint) * set1->size_of_bits);
9462+
return memcmp(set1->bits, set2->bits,
9463+
sizeof(uint) * set1->size_of_bits);
94659464
}
94669465

94679466

@@ -9530,17 +9529,15 @@ int find_found(FOUND_SET *found_set,uint table_offset, int found_offset)
95309529

95319530
uint start_at_word(char * pos)
95329531
{
9533-
return (((!bcmp((const uchar*) pos, (const uchar*) "\\b",2) && pos[2]) ||
9534-
!bcmp((const uchar*) pos, (const uchar*) "\\^", 2)) ? 1 : 0);
9532+
return (((!memcmp(pos, "\\b",2) && pos[2]) ||
9533+
!memcmp(pos, "\\^", 2)) ? 1 : 0);
95359534
}
95369535

95379536
uint end_of_word(char * pos)
95389537
{
95399538
char * end=strend(pos);
9540-
return ((end > pos+2 && !bcmp((const uchar*) end-2,
9541-
(const uchar*) "\\b", 2)) ||
9542-
(end >= pos+2 && !bcmp((const uchar*) end-2,
9543-
(const uchar*) "\\$",2))) ? 1 : 0;
9539+
return ((end > pos+2 && !memcmp(end-2, "\\b", 2)) ||
9540+
(end >= pos+2 && !memcmp(end-2, "\\$",2))) ? 1 : 0;
95449541
}
95459542

95469543
/****************************************************************************

cmd-line-utils/readline/Makefile.am

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ noinst_HEADERS = readline.h chardefs.h keymaps.h \
3131

3232
EXTRA_DIST= emacs_keymap.c vi_keymap.c
3333

34-
DEFS = -DMYSQL_CLIENT_NO_THREADS -DHAVE_CONFIG_H -DNO_KILL_INTR
34+
DEFS = -DMYSQL_CLIENT_NO_THREADS -DHAVE_CONFIG_H -DNO_KILL_INTR -D_GNU_SOURCE=1
3535

3636
# Don't update the files from bitkeeper
3737
%::SCCS/s.%

cmd-line-utils/readline/input.c

+2
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,9 @@ _rl_input_available ()
318318
return (_kbhit ());
319319
#endif
320320

321+
#if !defined (HAVE_SELECT)
321322
return 0;
323+
#endif
322324
}
323325

324326
int

configure.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -2102,7 +2102,7 @@ MYSQL_TYPE_QSORT
21022102
AC_FUNC_UTIME_NULL
21032103
AC_FUNC_VPRINTF
21042104

2105-
AC_CHECK_FUNCS(alarm bcmp bfill bmove bsearch bzero \
2105+
AC_CHECK_FUNCS(alarm bfill bmove bsearch bzero \
21062106
chsize cuserid fchmod fcntl \
21072107
fconvert fdatasync fesetround finite fpresetsticky fpsetmask fsync ftruncate \
21082108
getcwd gethostbyaddr_r gethostbyname_r getpass getpassphrase getpwnam \

extra/comp_err.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,9 @@ static struct message *find_message(struct errors *err, const char *lang,
639639
static ha_checksum checksum_format_specifier(const char* msg)
640640
{
641641
ha_checksum chksum= 0;
642-
const char* p= msg;
643-
const char* start= 0;
644-
int num_format_specifiers= 0;
642+
const uchar* p= (const uchar*) msg;
643+
const uchar* start= NULL;
644+
uint32 num_format_specifiers= 0;
645645
while (*p)
646646
{
647647

extra/replace.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ static REPLACE *init_replace(char * *from, char * *to,uint count,
648648
for (i=1 ; i <= found_sets ; i++)
649649
{
650650
pos=from[found_set[i-1].table_offset];
651-
rep_str[i].found= (my_bool) (!bcmp(pos,"\\^",3) ? 2 : 1);
651+
rep_str[i].found= (my_bool) (!memcmp(pos,"\\^",3) ? 2 : 1);
652652
rep_str[i].replace_string=to_array[found_set[i-1].table_offset];
653653
rep_str[i].to_offset=found_set[i-1].found_offset-start_at_word(pos);
654654
rep_str[i].from_offset=found_set[i-1].found_offset-replace_len(pos)+
@@ -776,8 +776,8 @@ static void copy_bits(REP_SET *to,REP_SET *from)
776776

777777
static int cmp_bits(REP_SET *set1,REP_SET *set2)
778778
{
779-
return bcmp((uchar*) set1->bits,(uchar*) set2->bits,
780-
sizeof(uint) * set1->size_of_bits);
779+
return memcmp(set1->bits, set2->bits,
780+
sizeof(uint) * set1->size_of_bits);
781781
}
782782

783783

@@ -849,14 +849,14 @@ static short find_found(FOUND_SET *found_set,uint table_offset,
849849

850850
static uint start_at_word(char * pos)
851851
{
852-
return (((!bcmp(pos,"\\b",2) && pos[2]) || !bcmp(pos,"\\^",2)) ? 1 : 0);
852+
return (((!memcmp(pos,"\\b",2) && pos[2]) || !memcmp(pos,"\\^",2)) ? 1 : 0);
853853
}
854854

855855
static uint end_of_word(char * pos)
856856
{
857857
char * end=strend(pos);
858-
return ((end > pos+2 && !bcmp(end-2,"\\b",2)) ||
859-
(end >= pos+2 && !bcmp(end-2,"\\$",2))) ?
858+
return ((end > pos+2 && !memcmp(end-2,"\\b",2)) ||
859+
(end >= pos+2 && !memcmp(end-2,"\\$",2))) ?
860860
1 : 0;
861861
}
862862

extra/yassl/src/crypto_wrapper.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -953,8 +953,9 @@ x509* PemToDer(FILE* file, CertType type, EncryptedInfo* info)
953953
info->set = true;
954954
}
955955
}
956-
fgets(line,sizeof(line), file); // get blank line
957-
begin = ftell(file);
956+
// get blank line
957+
if (fgets(line, sizeof(line), file))
958+
begin = ftell(file);
958959
}
959960

960961
}

extra/yassl/taocrypt/include/blowfish.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Blowfish : public Mode_BASE {
5151
enum { BLOCK_SIZE = BLOWFISH_BLOCK_SIZE, ROUNDS = 16 };
5252

5353
Blowfish(CipherDir DIR, Mode MODE)
54-
: Mode_BASE(BLOCK_SIZE, DIR, MODE) {}
54+
: Mode_BASE(BLOCK_SIZE, DIR, MODE), sbox_(pbox_ + ROUNDS + 2) {}
5555

5656
#ifdef DO_BLOWFISH_ASM
5757
void Process(byte*, const byte*, word32);
@@ -62,8 +62,8 @@ class Blowfish : public Mode_BASE {
6262
static const word32 p_init_[ROUNDS + 2];
6363
static const word32 s_init_[4 * 256];
6464

65-
word32 pbox_[ROUNDS + 2];
66-
word32 sbox_[4 * 256];
65+
word32 pbox_[ROUNDS + 2 + 4 * 256];
66+
word32* sbox_;
6767

6868
void crypt_block(const word32 in[2], word32 out[2]) const;
6969
void AsmProcess(const byte* in, byte* out) const;

extra/yassl/taocrypt/include/runtime.hpp

+2-14
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,7 @@
3535

3636
// Handler for pure virtual functions
3737
namespace __Crun {
38-
static void pure_error(void)
39-
{
40-
assert("Pure virtual method called." == "Aborted");
41-
}
38+
void pure_error(void);
4239
} // namespace __Crun
4340

4441
#endif // __sun
@@ -54,16 +51,7 @@ extern "C" {
5451
#else
5552
#include "kernelc.hpp"
5653
#endif
57-
58-
/* Disallow inline __cxa_pure_virtual() */
59-
static int __cxa_pure_virtual() __attribute__((noinline, used));
60-
static int __cxa_pure_virtual()
61-
{
62-
// oops, pure virtual called!
63-
assert("Pure virtual method called." == "Aborted");
64-
return 0;
65-
}
66-
54+
int __cxa_pure_virtual () __attribute__ ((weak));
6755
} // extern "C"
6856

6957
#endif // __GNUC__ > 2

extra/yassl/taocrypt/src/aes.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void AES::Process(byte* out, const byte* in, word32 sz)
5151
out += BLOCK_SIZE;
5252
in += BLOCK_SIZE;
5353
}
54-
else if (mode_ == CBC)
54+
else if (mode_ == CBC) {
5555
if (dir_ == ENCRYPTION)
5656
while (blocks--) {
5757
r_[0] ^= *(word32*)in;
@@ -78,6 +78,7 @@ void AES::Process(byte* out, const byte* in, word32 sz)
7878
out += BLOCK_SIZE;
7979
in += BLOCK_SIZE;
8080
}
81+
}
8182
}
8283

8384
#endif // DO_AES_ASM

extra/yassl/taocrypt/src/algebra.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ Integer AbstractGroup::CascadeScalarMultiply(const Element &x,
186186

187187
struct WindowSlider
188188
{
189-
WindowSlider(const Integer &exp, bool fastNegate,
189+
WindowSlider(const Integer &expIn, bool fastNegateIn,
190190
unsigned int windowSizeIn=0)
191-
: exp(exp), windowModulus(Integer::One()), windowSize(windowSizeIn),
192-
windowBegin(0), fastNegate(fastNegate), firstTime(true),
191+
: exp(expIn), windowModulus(Integer::One()), windowSize(windowSizeIn),
192+
windowBegin(0), fastNegate(fastNegateIn), firstTime(true),
193193
finished(false)
194194
{
195195
if (windowSize == 0)

extra/yassl/taocrypt/src/blowfish.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void Blowfish::Process(byte* out, const byte* in, word32 sz)
5353
out += BLOCK_SIZE;
5454
in += BLOCK_SIZE;
5555
}
56-
else if (mode_ == CBC)
56+
else if (mode_ == CBC) {
5757
if (dir_ == ENCRYPTION)
5858
while (blocks--) {
5959
r_[0] ^= *(word32*)in;
@@ -78,6 +78,7 @@ void Blowfish::Process(byte* out, const byte* in, word32 sz)
7878
out += BLOCK_SIZE;
7979
in += BLOCK_SIZE;
8080
}
81+
}
8182
}
8283

8384
#endif // DO_BLOWFISH_ASM

extra/yassl/taocrypt/src/integer.cpp

+19-13
Original file line numberDiff line numberDiff line change
@@ -283,21 +283,23 @@ DWord() {}
283283
word GetHighHalfAsBorrow() const {return 0-halfs_.high;}
284284

285285
private:
286+
struct dword_struct
287+
{
288+
#ifdef LITTLE_ENDIAN_ORDER
289+
word low;
290+
word high;
291+
#else
292+
word high;
293+
word low;
294+
#endif
295+
};
296+
286297
union
287298
{
288299
#ifdef TAOCRYPT_NATIVE_DWORD_AVAILABLE
289300
dword whole_;
290301
#endif
291-
struct
292-
{
293-
#ifdef LITTLE_ENDIAN_ORDER
294-
word low;
295-
word high;
296-
#else
297-
word high;
298-
word low;
299-
#endif
300-
} halfs_;
302+
struct dword_struct halfs_;
301303
};
302304
};
303305

@@ -1214,20 +1216,24 @@ class LowLevel : public PentiumOptimized
12141216
#define AS1(x) #x ";"
12151217
#define AS2(x, y) #x ", " #y ";"
12161218
#define AddPrologue \
1219+
word res; \
12171220
__asm__ __volatile__ \
12181221
( \
12191222
"push %%ebx;" /* save this manually, in case of -fPIC */ \
1220-
"mov %2, %%ebx;" \
1223+
"mov %3, %%ebx;" \
12211224
".intel_syntax noprefix;" \
12221225
"push ebp;"
12231226
#define AddEpilogue \
12241227
"pop ebp;" \
12251228
".att_syntax prefix;" \
12261229
"pop %%ebx;" \
1227-
: \
1230+
"mov %%eax, %0;" \
1231+
: "=g" (res) \
12281232
: "c" (C), "d" (A), "m" (B), "S" (N) \
12291233
: "%edi", "memory", "cc" \
1230-
);
1234+
); \
1235+
return res;
1236+
12311237
#define MulPrologue \
12321238
__asm__ __volatile__ \
12331239
( \

0 commit comments

Comments
 (0)