Skip to content

Commit 5dec0c9

Browse files
Davi ArnautDavi Arnaut
authored andcommitted
Bug#53445: Build with -Wall and fix warnings that it generates
Fix various mismatches between function's language linkage. Any particular function that is declared in C++ but should be callable from C must have C linkage. Note that function types with different linkages are also distinct. Thus, if a function type is declared in C code, it will have C linkage (same if declared in a extern "C" block).
1 parent 7e84f28 commit 5dec0c9

33 files changed

Lines changed: 245 additions & 123 deletions

client/mysql.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,8 +2316,10 @@ static bool add_line(String &buffer,char *line,char *in_string,
23162316

23172317
#ifdef HAVE_READLINE
23182318

2319+
C_MODE_START
23192320
static char *new_command_generator(const char *text, int);
2320-
extern "C" char **new_mysql_completion (const char *text, int start, int end);
2321+
static char **new_mysql_completion(const char *text, int start, int end);
2322+
C_MODE_END
23212323

23222324
/*
23232325
Tell the GNU Readline library how to complete. We want to try to complete
@@ -2449,9 +2451,9 @@ static void initialize_readline (char *name)
24492451
array of matches, or NULL if there aren't any.
24502452
*/
24512453

2452-
char **new_mysql_completion (const char *text,
2453-
int start __attribute__((unused)),
2454-
int end __attribute__((unused)))
2454+
static char **new_mysql_completion(const char *text,
2455+
int start __attribute__((unused)),
2456+
int end __attribute__((unused)))
24552457
{
24562458
if (!status.batch && !quick)
24572459
#if defined(USE_NEW_READLINE_INTERFACE)

client/mysqltest.cc

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@
7777
static int setenv(const char *name, const char *value, int overwrite);
7878
#endif
7979

80+
C_MODE_START
81+
static sig_handler signal_handler(int sig);
82+
static my_bool get_one_option(int optid, const struct my_option *,
83+
char *argument);
84+
C_MODE_END
85+
8086
enum {
8187
OPT_SKIP_SAFEMALLOC=OPT_MAX_CLIENT_OPTION,
8288
OPT_PS_PROTOCOL, OPT_SP_PROTOCOL, OPT_CURSOR_PROTOCOL, OPT_VIEW_PROTOCOL,
@@ -462,7 +468,6 @@ void log_msg(const char *fmt, ...)
462468
VAR* var_from_env(const char *, const char *);
463469
VAR* var_init(VAR* v, const char *name, int name_len, const char *val,
464470
int val_len);
465-
void var_free(void* v);
466471
VAR* var_get(const char *var_name, const char** var_name_end,
467472
my_bool raw, my_bool ignore_not_existing);
468473
void eval_expr(VAR* v, const char *p, const char** p_end);
@@ -1914,6 +1919,8 @@ static void strip_parentheses(struct st_command *command)
19141919
}
19151920

19161921

1922+
C_MODE_START
1923+
19171924
static uchar *get_var_key(const uchar* var, size_t *len,
19181925
my_bool __attribute__((unused)) t)
19191926
{
@@ -1924,6 +1931,16 @@ static uchar *get_var_key(const uchar* var, size_t *len,
19241931
}
19251932

19261933

1934+
static void var_free(void *v)
1935+
{
1936+
my_free(((VAR*) v)->str_val, MYF(MY_WME));
1937+
if (((VAR*)v)->alloced)
1938+
my_free(v, MYF(MY_WME));
1939+
}
1940+
1941+
C_MODE_END
1942+
1943+
19271944
VAR *var_init(VAR *v, const char *name, int name_len, const char *val,
19281945
int val_len)
19291946
{
@@ -1966,14 +1983,6 @@ VAR *var_init(VAR *v, const char *name, int name_len, const char *val,
19661983
}
19671984

19681985

1969-
void var_free(void *v)
1970-
{
1971-
my_free(((VAR*) v)->str_val, MYF(MY_WME));
1972-
if (((VAR*)v)->alloced)
1973-
my_free(v, MYF(MY_WME));
1974-
}
1975-
1976-
19771986
VAR* var_from_env(const char *name, const char *def_val)
19781987
{
19791988
const char *tmp;
@@ -6070,8 +6079,7 @@ void read_embedded_server_arguments(const char *name)
60706079

60716080

60726081
static my_bool
6073-
get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
6074-
char *argument)
6082+
get_one_option(int optid, const struct my_option *, char *argument)
60756083
{
60766084
switch(optid) {
60776085
case '#':

cmd-line-utils/readline/input.c

Lines changed: 2 additions & 0 deletions
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

include/my_alloc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#define ALLOC_MAX_BLOCK_TO_DROP 4096
2424
#define ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP 10
2525

26+
C_MODE_START
27+
2628
typedef struct st_used_mem
2729
{ /* struct for once_alloc (block) */
2830
struct st_used_mem *next; /* Next block in use */
@@ -48,4 +50,7 @@ typedef struct st_mem_root
4850

4951
void (*error_handler)(void);
5052
} MEM_ROOT;
53+
54+
C_MODE_END
55+
5156
#endif

include/my_base.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,8 @@ typedef ulong ha_rows;
562562
#define HA_VARCHAR_PACKLENGTH(field_length) ((field_length) < 256 ? 1 :2)
563563

564564
/* invalidator function reference for Query Cache */
565+
C_MODE_START
565566
typedef void (* invalidator_by_filename)(const char * filename);
567+
C_MODE_END
566568

567569
#endif /* _my_base_h */

include/my_global.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@
7373
#define C_MODE_END
7474
#endif
7575

76+
#ifdef __cplusplus
77+
#define CPP_UNNAMED_NS_START namespace {
78+
#define CPP_UNNAMED_NS_END }
79+
#endif
80+
7681
#if defined(_WIN32)
7782
#include <my_config.h>
7883
#elif defined(__NETWARE__)

include/mysql.h.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
typedef unsigned long long my_ulonglong;
203203
#include "typelib.h"
204204
#include "my_alloc.h"
205+
C_MODE_START
205206
typedef struct st_used_mem
206207
{
207208
struct st_used_mem *next;
@@ -219,6 +220,7 @@
219220
unsigned int first_block_usage;
220221
void (*error_handler)(void);
221222
} MEM_ROOT;
223+
C_MODE_END
222224
typedef struct st_typelib {
223225
unsigned int count;
224226
const char *name;

mysys/my_gethwaddr.c

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -102,47 +102,49 @@ my_bool my_gethwaddr(uchar *to)
102102
}
103103

104104
#elif defined(__WIN__)
105-
106-
/* Workaround for BUG#32082 (Definition of VOID in my_global.h conflicts with
107-
windows headers) */
108-
#ifdef VOID
109-
#undef VOID
110-
#define VOID void
111-
#endif
105+
106+
/*
107+
Workaround for BUG#32082 (Definition of VOID in my_global.h conflicts with
108+
windows headers)
109+
*/
110+
#ifdef VOID
111+
#undef VOID
112+
#define VOID void
113+
#endif
112114

113115
#include <iphlpapi.h>
114116

115-
/*
116-
The following typedef is for dynamically loading
117-
iphlpapi.dll / GetAdaptersAddresses. Dynamic loading is
118-
used because GetAdaptersAddresses is not available on Windows 2000
119-
which MySQL still supports. Static linking would cause an unresolved export.
117+
/*
118+
The following typedef is for dynamically loading iphlpapi.dll /
119+
GetAdaptersAddresses. Dynamic loading is used because
120+
GetAdaptersAddresses is not available on Windows 2000 which MySQL
121+
still supports. Static linking would cause an unresolved export.
120122
*/
121123
typedef DWORD (WINAPI *pfnGetAdaptersAddresses)(IN ULONG Family,
122124
IN DWORD Flags,IN PVOID Reserved,
123-
OUT PIP_ADAPTER_ADDRESSES pAdapterAddresses,
125+
OUT PIP_ADAPTER_ADDRESSES pAdapterAddresses,
124126
IN OUT PULONG pOutBufLen);
125127

126128
/*
127-
my_gethwaddr - Windows version
129+
my_gethwaddr - Windows version
128130
129131
@brief Retrieve MAC address from network hardware
130-
132+
131133
@param[out] to MAC address exactly six bytes
132-
134+
133135
@return Operation status
134136
@retval 0 OK
135-
@retval <>0 FAILED
137+
@retval <>0 FAILED
136138
*/
137139
my_bool my_gethwaddr(uchar *to)
138-
{
140+
{
139141
PIP_ADAPTER_ADDRESSES pAdapterAddresses;
140142
PIP_ADAPTER_ADDRESSES pCurrAddresses;
141143
IP_ADAPTER_ADDRESSES adapterAddresses;
142144
ULONG address_len;
143-
my_bool return_val= 1;
144-
static pfnGetAdaptersAddresses fnGetAdaptersAddresses=
145-
(pfnGetAdaptersAddresses)-1;
145+
my_bool return_val= 1;
146+
static pfnGetAdaptersAddresses fnGetAdaptersAddresses=
147+
(pfnGetAdaptersAddresses)-1;
146148

147149
if(fnGetAdaptersAddresses == (pfnGetAdaptersAddresses)-1)
148150
{
@@ -156,7 +158,7 @@ my_bool my_gethwaddr(uchar *to)
156158
address_len= sizeof (IP_ADAPTER_ADDRESSES);
157159

158160
/* Get the required size for the address data. */
159-
if (fnGetAdaptersAddresses(AF_UNSPEC, 0, 0, &adapterAddresses, &address_len)
161+
if (fnGetAdaptersAddresses(AF_UNSPEC, 0, 0, &adapterAddresses, &address_len)
160162
== ERROR_BUFFER_OVERFLOW)
161163
{
162164
pAdapterAddresses= my_malloc(address_len, 0);
@@ -167,29 +169,29 @@ my_bool my_gethwaddr(uchar *to)
167169
pAdapterAddresses= &adapterAddresses; /* one is enough don't alloc */
168170

169171
/* Get the hardware info. */
170-
if (fnGetAdaptersAddresses(AF_UNSPEC, 0, 0, pAdapterAddresses, &address_len)
172+
if (fnGetAdaptersAddresses(AF_UNSPEC, 0, 0, pAdapterAddresses, &address_len)
171173
== NO_ERROR)
172174
{
173175
pCurrAddresses= pAdapterAddresses;
174176

175-
while (pCurrAddresses)
177+
while (pCurrAddresses)
176178
{
177179
/* Look for ethernet cards. */
178180
if (pCurrAddresses->IfType == IF_TYPE_ETHERNET_CSMACD)
179181
{
180182
/* check for a good address */
181183
if (pCurrAddresses->PhysicalAddressLength < 6)
182-
continue; /* bad address */
184+
continue; /* bad address */
183185

184186
/* save 6 bytes of the address in the 'to' parameter */
185187
memcpy(to, pCurrAddresses->PhysicalAddress, 6);
186188

187189
/* Network card found, we're done. */
188190
return_val= 0;
189-
break;
191+
break;
190192
}
191193
pCurrAddresses= pCurrAddresses->Next;
192-
}
194+
}
193195
}
194196

195197
/* Clean up memory allocation. */

plugin/semisync/semisync_master_plugin.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
ReplSemiSyncMaster repl_semisync;
2222

23+
C_MODE_START
24+
2325
int repl_semi_report_binlog_update(Binlog_storage_param *param,
2426
const char *log_file,
2527
my_off_t log_pos, uint32 flags)
@@ -145,6 +147,8 @@ int repl_semi_reset_master(Binlog_transmit_param *param)
145147
return 0;
146148
}
147149

150+
C_MODE_END
151+
148152
/*
149153
semisync system variables
150154
*/

plugin/semisync/semisync_slave_plugin.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ ReplSemiSyncSlave repl_semisync;
2929
*/
3030
bool semi_sync_need_reply= false;
3131

32+
C_MODE_START
33+
3234
int repl_semi_reset_slave(Binlog_relay_IO_param *param)
3335
{
3436
// TODO: reset semi-sync slave status here
@@ -124,6 +126,7 @@ int repl_semi_slave_io_end(Binlog_relay_IO_param *param)
124126
return repl_semisync.slaveStop(param);
125127
}
126128

129+
C_MODE_END
127130

128131
static void fix_rpl_semi_sync_slave_enabled(MYSQL_THD thd,
129132
SYS_VAR *var,

0 commit comments

Comments
 (0)