Skip to content

Commit 5a46daf

Browse files
author
Magnus Svensson
committed
Merge
2 parents 8190895 + 02b123d commit 5a46daf

24 files changed

+79
-51
lines changed

BUILD/SETUP.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ prefix="/usr/local/mysql"
6161
just_print=
6262
just_configure=
6363
full_debug=
64-
warning_mode=
64+
warning_mode="pedantic"
6565

6666
parse_options "$@"
6767

@@ -94,6 +94,9 @@ if [ "x$warning_mode" != "xpedantic" ]; then
9494
warnings="$warnings -Wchar-subscripts -Wformat -Wparentheses -Wsign-compare"
9595
warnings="$warnings -Wwrite-strings -Wunused-function -Wunused-label -Wunused-value -Wunused-variable"
9696

97+
# Make "printf like format specifier warnings" into error
98+
#warnings="$warnings -Werror=format"
99+
97100
# For more warnings, uncomment the following line
98101
# warnings="$global_warnings -Wshadow"
99102

storage/ndb/include/debugger/SignalLoggerManager.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ class SignalLoggerManager
8686
/**
8787
* Generic messages in the signal log
8888
*/
89-
void log(BlockNumber bno, const char * msg, ...);
89+
void log(BlockNumber bno, const char * msg, ...)
90+
ATTRIBUTE_FORMAT(printf, 3, 4);
9091

9192
/**
9293
* LogModes

storage/ndb/include/logger/Logger.hpp

+12-6
Original file line numberDiff line numberDiff line change
@@ -228,47 +228,53 @@ class Logger
228228
*
229229
* @param pMsg the message.
230230
*/
231-
virtual void alert(const char* pMsg, ...) const;
231+
virtual void alert(const char* pMsg, ...) const
232+
ATTRIBUTE_FORMAT(printf, 2, 3);
232233
virtual void alert(BaseString &pMsg) const { alert(pMsg.c_str()); };
233234

234235
/**
235236
* Log a critical message.
236237
*
237238
* @param pMsg the message.
238239
*/
239-
virtual void critical(const char* pMsg, ...) const;
240+
virtual void critical(const char* pMsg, ...) const
241+
ATTRIBUTE_FORMAT(printf, 2, 3);
240242
virtual void critical(BaseString &pMsg) const { critical(pMsg.c_str()); };
241243

242244
/**
243245
* Log an error message.
244246
*
245247
* @param pMsg the message.
246248
*/
247-
virtual void error(const char* pMsg, ...) const;
249+
virtual void error(const char* pMsg, ...) const
250+
ATTRIBUTE_FORMAT(printf, 2, 3);
248251
virtual void error(BaseString &pMsg) const { error(pMsg.c_str()); };
249252

250253
/**
251254
* Log a warning message.
252255
*
253256
* @param pMsg the message.
254257
*/
255-
virtual void warning(const char* pMsg, ...) const;
258+
virtual void warning(const char* pMsg, ...) const
259+
ATTRIBUTE_FORMAT(printf, 2, 3);
256260
virtual void warning(BaseString &pMsg) const { warning(pMsg.c_str()); };
257261

258262
/**
259263
* Log an info message.
260264
*
261265
* @param pMsg the message.
262266
*/
263-
virtual void info(const char* pMsg, ...) const;
267+
virtual void info(const char* pMsg, ...) const
268+
ATTRIBUTE_FORMAT(printf, 2, 3);
264269
virtual void info(BaseString &pMsg) const { info(pMsg.c_str()); };
265270

266271
/**
267272
* Log a debug message.
268273
*
269274
* @param pMsg the message.
270275
*/
271-
virtual void debug(const char* pMsg, ...) const;
276+
virtual void debug(const char* pMsg, ...) const
277+
ATTRIBUTE_FORMAT(printf, 2, 3);
272278
virtual void debug(BaseString &pMsg) const { debug(pMsg.c_str()); };
273279

274280
/*

storage/ndb/include/ndbapi/Ndb.hpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1881,7 +1881,9 @@ class Ndb
18811881
struct LinearSectionPtr ptr[3]);
18821882
static void statusMessage(void*, Uint32, bool, bool);
18831883
#ifdef VM_TRACE
1884-
void printState(const char* fmt, ...);
1884+
#include <my_attribute.h>
1885+
void printState(const char* fmt, ...)
1886+
ATTRIBUTE_FORMAT(printf, 2, 3);
18851887
#endif
18861888
};
18871889

storage/ndb/include/util/BaseString.hpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,12 @@ class BaseString {
9797
const BaseString &separator = BaseString(" "));
9898

9999
/** @brief Assigns from a format string a la printf() */
100-
BaseString& assfmt(const char* ftm, ...);
100+
BaseString& assfmt(const char* ftm, ...)
101+
ATTRIBUTE_FORMAT(printf, 2, 3);
101102

102103
/** @brief Appends a format string a la printf() to the end */
103-
BaseString& appfmt(const char* ftm, ...);
104+
BaseString& appfmt(const char* ftm, ...)
105+
ATTRIBUTE_FORMAT(printf, 2, 3);
104106

105107
/**
106108
* Split a string into a vector of strings. Separate the string where
@@ -183,7 +185,8 @@ class BaseString {
183185
/**
184186
* snprintf on some platforms need special treatment
185187
*/
186-
static int snprintf(char *str, size_t size, const char *format, ...);
188+
static int snprintf(char *str, size_t size, const char *format, ...)
189+
ATTRIBUTE_FORMAT(printf, 3, 4);
187190
static int vsnprintf(char *str, size_t size, const char *format, va_list ap);
188191
private:
189192
char* m_chr;

storage/ndb/include/util/NdbOut.hpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,10 @@ class NdbOut
7676
NdbOut(OutputStream &);
7777
virtual ~NdbOut();
7878

79-
void print(const char * fmt, ...);
80-
void println(const char * fmt, ...);
79+
void print(const char * fmt, ...)
80+
ATTRIBUTE_FORMAT(printf, 2, 3);
81+
void println(const char * fmt, ...)
82+
ATTRIBUTE_FORMAT(printf, 2, 3);
8183

8284
OutputStream * m_out;
8385
private:
@@ -125,7 +127,7 @@ class FilteredNdbOut : public NdbOut {
125127
};
126128

127129
#else
128-
void ndbout_c(const char * fmt, ...);
130+
void ndbout_c(const char * fmt, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
129131
#endif
130132

131133
#endif

storage/ndb/include/util/OutputStream.hpp

+18-10
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@ class OutputStream {
2626
public:
2727
OutputStream() {}
2828
virtual ~OutputStream() {}
29-
virtual int print(const char * fmt, ...) = 0;
30-
virtual int println(const char * fmt, ...) = 0;
31-
virtual void flush() {}
32-
virtual void reset_timeout() {}
29+
virtual int print(const char * fmt, ...)
30+
ATTRIBUTE_FORMAT(printf, 2, 3) = 0;
31+
virtual int println(const char * fmt, ...)
32+
ATTRIBUTE_FORMAT(printf, 2, 3) = 0;
33+
virtual void flush() {};
34+
virtual void reset_timeout() {};
3335
};
3436

3537
class FileOutputStream : public OutputStream {
@@ -39,8 +41,10 @@ class FileOutputStream : public OutputStream {
3941
virtual ~FileOutputStream() {}
4042
FILE *getFile() { return f; }
4143

42-
int print(const char * fmt, ...);
43-
int println(const char * fmt, ...);
44+
int print(const char * fmt, ...)
45+
ATTRIBUTE_FORMAT(printf, 2, 3);
46+
int println(const char * fmt, ...)
47+
ATTRIBUTE_FORMAT(printf, 2, 3);
4448
void flush() { fflush(f); }
4549
};
4650

@@ -56,8 +60,10 @@ class SocketOutputStream : public OutputStream {
5660
bool timedout() { return m_timedout; }
5761
void reset_timeout() { m_timedout= false; m_timeout_remain= m_timeout_ms;}
5862

59-
int print(const char * fmt, ...);
60-
int println(const char * fmt, ...);
63+
int print(const char * fmt, ...)
64+
ATTRIBUTE_FORMAT(printf, 2, 3);
65+
int println(const char * fmt, ...)
66+
ATTRIBUTE_FORMAT(printf, 2, 3);
6167
};
6268

6369

@@ -68,8 +74,10 @@ class BufferedSockOutputStream : public SocketOutputStream {
6874
unsigned write_timeout_ms = 1000);
6975
virtual ~BufferedSockOutputStream();
7076

71-
int print(const char * fmt, ...);
72-
int println(const char * fmt, ...);
77+
int print(const char * fmt, ...)
78+
ATTRIBUTE_FORMAT(printf, 2, 3);
79+
int println(const char * fmt, ...)
80+
ATTRIBUTE_FORMAT(printf, 2, 3);
7381

7482
void flush();
7583
};

storage/ndb/include/util/basestring_vsnprintf.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,14 @@
1515

1616
#ifndef BASESTRING_VSNPRINTF_H
1717
#define BASESTRING_VSNPRINTF_H
18+
#include <ndb_global.h>
1819
#include <stdarg.h>
1920
#if defined(__cplusplus)
2021
extern "C"
2122
{
2223
#endif
23-
int basestring_snprintf(char*, size_t, const char*, ...);
24+
int basestring_snprintf(char*, size_t, const char*, ...)
25+
ATTRIBUTE_FORMAT(printf, 3, 4);
2426
int basestring_vsnprintf(char*,size_t, const char*,va_list);
2527
#if defined(__cplusplus)
2628
}

storage/ndb/include/util/socket_io.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ extern "C" {
3535
const char[], int len);
3636

3737
int print_socket(NDB_SOCKET_TYPE, int timeout_ms, int *time,
38-
const char *, ...);
38+
const char *, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
3939
int println_socket(NDB_SOCKET_TYPE, int timeout_ms, int *time,
40-
const char *, ...);
40+
const char *, ...) ATTRIBUTE_FORMAT(printf, 4, 5);
4141
int vprint_socket(NDB_SOCKET_TYPE, int timeout_ms, int *time,
4242
const char *, va_list);
4343
int vprintln_socket(NDB_SOCKET_TYPE, int timeout_ms, int *time,

storage/ndb/src/common/debugger/EventLogger.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,7 @@ void getTextEventBufferStatus(QQQQ) {
758758
convert_unit(alloc, alloc_unit);
759759
convert_unit(max_, max_unit);
760760
BaseString::snprintf(m_text, m_text_len,
761-
"Event buffer status: used=%d%s(%d%) alloc=%d%s(%d%) "
761+
"Event buffer status: used=%d%s(%d%%) alloc=%d%s(%d%%) "
762762
"max=%d%s apply_epoch=%u/%u latest_epoch=%u/%u",
763763
used, used_unit,
764764
theData[2] ? (Uint32)((((Uint64)theData[1])*100)/theData[2]) : 0,

storage/ndb/src/kernel/blocks/dbdict/Dbdict.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -12608,7 +12608,7 @@ Dbdict::buildIndex_recvReply(Signal* signal, const BuildIndxConf* conf,
1260812608
if (ref == 0) {
1260912609
infoEvent("DICT: index %u rebuild done", (unsigned)key);
1261012610
} else {
12611-
warningEvent("DICT: index %u rebuild failed: code=%d line=%d node=%d",
12611+
warningEvent("DICT: index %u rebuild failed: code=%d",
1261212612
(unsigned)key, ref->getErrorCode());
1261312613
}
1261412614
rebuildIndexes(signal, key + 1);

storage/ndb/src/kernel/blocks/dblqh/DblqhMain.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -19270,7 +19270,7 @@ Dblqh::execDUMP_STATE_ORD(Signal* signal)
1927019270
TlcpPtr.p->lcpQueued,
1927119271
TlcpPtr.p->reportEmpty);
1927219272
char buf[8*_NDB_NODE_BITMASK_SIZE+1];
19273-
infoEvent(" m_EMPTY_LCP_REQ=%d",
19273+
infoEvent(" m_EMPTY_LCP_REQ=%s",
1927419274
TlcpPtr.p->m_EMPTY_LCP_REQ.getText(buf));
1927519275

1927619276
return;

storage/ndb/src/kernel/blocks/ndbfs/Ndbfs.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ Ndbfs::execDUMP_STATE_ORD(Signal* signal)
10401040

10411041
for (unsigned i = 0; i < theOpenFiles.size(); i++){
10421042
AsyncFile* file = theOpenFiles.getFile(i);
1043-
infoEvent("%2d (0x%x): %s", i,file, file->theFileName.c_str());
1043+
infoEvent("%2d (0x%lx): %s", i, (long)file, file->theFileName.c_str());
10441044
}
10451045
return;
10461046
}
@@ -1049,7 +1049,7 @@ Ndbfs::execDUMP_STATE_ORD(Signal* signal)
10491049

10501050
for (unsigned i = 0; i < theFiles.size(); i++){
10511051
AsyncFile* file = theFiles[i];
1052-
infoEvent("%2d (0x%x): %s", i,file, file->isOpen()?"OPEN":"CLOSED");
1052+
infoEvent("%2d (0x%lx): %s", i, (long)file, file->isOpen()?"OPEN":"CLOSED");
10531053
}
10541054
return;
10551055
}
@@ -1058,7 +1058,7 @@ Ndbfs::execDUMP_STATE_ORD(Signal* signal)
10581058

10591059
for (unsigned i = 0; i < theIdleFiles.size(); i++){
10601060
AsyncFile* file = theIdleFiles[i];
1061-
infoEvent("%2d (0x%x): %s", i,file, file->isOpen()?"OPEN":"CLOSED");
1061+
infoEvent("%2d (0x%lx): %s", i, (long)file, file->isOpen()?"OPEN":"CLOSED");
10621062
}
10631063
return;
10641064
}

storage/ndb/src/kernel/blocks/suma/Suma.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ Suma::execDUMP_STATE_ORD(Signal* signal){
11621162
for(Uint32 i = 0; i<c_no_of_buckets; i++)
11631163
{
11641164
Bucket* ptr= c_buckets + i;
1165-
infoEvent("Bucket %d %d%d-%x switch gci: %d max_acked_gci: %d max_gci: %d tail: %d head: %d",
1165+
infoEvent("Bucket %d %d%d-%x switch gci: %llu max_acked_gci: %llu max_gci: %llu tail: %d head: %d",
11661166
i,
11671167
m_active_buckets.get(i),
11681168
m_switchover_buckets.get(i),
@@ -3803,7 +3803,7 @@ Suma::execSUB_GCP_COMPLETE_REP(Signal* signal)
38033803
rep->flags = flags;
38043804
rep->senderRef = reference();
38053805
rep->gcp_complete_rep_count = m_gcp_complete_rep_count;
3806-
3806+
38073807
if(m_gcp_complete_rep_count && !c_subscriber_nodes.isclear())
38083808
{
38093809
CRASH_INSERTION(13033);

storage/ndb/src/kernel/blocks/suma/Suma.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class Suma : public SimulatedBlock {
200200
R_SUB_STOP_REQ,
201201
R_START_ME_REQ,
202202
R_API_FAIL_REQ,
203-
R_SUB_ABORT_START_REQ,
203+
R_SUB_ABORT_START_REQ
204204
};
205205

206206
Uint32 m_opType;

storage/ndb/src/kernel/vm/SimulatedBlock.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,10 @@ class SimulatedBlock {
393393
/**
394394
* General info event (sent to cluster log)
395395
*/
396-
void infoEvent(const char * msg, ...) const ;
397-
void warningEvent(const char * msg, ...) const ;
396+
void infoEvent(const char * msg, ...) const
397+
ATTRIBUTE_FORMAT(printf, 2, 3);
398+
void warningEvent(const char * msg, ...) const
399+
ATTRIBUTE_FORMAT(printf, 2, 3);
398400

399401
/**
400402
* Get node state

storage/ndb/src/kernel/vm/WatchDog.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ WatchDog::run()
139139
g_eventLogger->info("Watchdog: User time: %llu System time: %llu",
140140
(Uint64)my_tms.tms_utime,
141141
(Uint64)my_tms.tms_stime);
142-
g_eventLogger->warning("Watchdog: Warning overslept %u ms, expected %u ms.",
142+
g_eventLogger->warning("Watchdog: Warning overslept %llu ms, expected %u ms.",
143143
NdbTick_getMicrosPassed(last_time, now)/1000,
144144
sleep_time);
145145
}

storage/ndb/src/mgmapi/LocalConfig.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ LocalConfig::readConnectString(const char * connectString,
286286
bool return_value = parseString(connectString, err);
287287
if (!return_value) {
288288
BaseString err2;
289-
err2.assfmt("Reading %d \"%s\": %s", info, connectString, err.c_str());
289+
err2.assfmt("Reading %s \"%s\": %s", info, connectString, err.c_str());
290290
setError(0,err2.c_str());
291291
}
292292
return return_value;

storage/ndb/src/ndbapi/Ndb.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,7 @@ Ndb::startTransactionLocal(Uint32 aPriority, Uint32 nodeId)
687687
}//if
688688
#ifdef VM_TRACE
689689
if (tConnection->theListState != NdbTransaction::NotInList) {
690-
printState("startTransactionLocal %x", tConnection);
690+
printState("startTransactionLocal %lx", (long)tConnection);
691691
abort();
692692
}
693693
#endif

storage/ndb/src/ndbapi/NdbInterpretedCode.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ NdbInterpretedCode::ret_sub()
850850
m_flags&= ~(InSubroutineDef);
851851

852852
return add1(Interpreter::RETURN);
853-
};
853+
}
854854

855855
/* Get a CodeMetaInfo object given a number
856856
* Label numbers start from 0. Subroutine numbers start from

storage/ndb/src/ndbapi/NdbScanOperation.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ NdbScanOperation::addInterpretedCode(Uint32 aTC_ConnectPtr,
227227
theAI_LenInCurrAI= theCurrentATTRINFO->getLength();
228228

229229
return res;
230-
};
230+
}
231231

232232
/* Method for handling scanoptions passed into
233233
* NdbTransaction::scanTable or scanIndex
@@ -969,7 +969,7 @@ NdbScanOperation::readTuples(NdbScanOperation::LockMode lm,
969969
m_savedBatchOldApi= batch;
970970

971971
return 0;
972-
};
972+
}
973973

974974
/* Most of the scan definition work for old + NdbRecord API scans is done here */
975975
int
@@ -1350,7 +1350,7 @@ NdbScanOperation::nextResult(bool fetchAllowed, bool forceSend)
13501350
return nextResult(&dummyOutRowPtr,
13511351
fetchAllowed,
13521352
forceSend);
1353-
};
1353+
}
13541354

13551355
/* nextResult() for NdbRecord operation. */
13561356
int

0 commit comments

Comments
 (0)