mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
Fixing wrong sprintf() calls.
modified: storage/connect/filamap.cpp storage/connect/filamdbf.cpp storage/connect/filamfix.cpp storage/connect/filamtxt.cpp storage/connect/filamvct.cpp storage/connect/ha_connect.cc storage/connect/osutil.c storage/connect/plgdbutl.cpp storage/connect/plugutil.c storage/connect/tabfix.cpp storage/connect/tabxml.cpp storage/connect/user_connect.cc storage/connect/value.cpp storage/connect/xindex.cpp
This commit is contained in:
parent
40398f3660
commit
f8f79d9334
14 changed files with 34 additions and 26 deletions
|
@ -164,7 +164,7 @@ bool MAPFAM::OpenTableFile(PGLOBAL g)
|
|||
|
||||
if (!(*g->Message))
|
||||
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
||||
"map", rc, filename);
|
||||
"map", (int) rc, filename);
|
||||
|
||||
#ifdef DEBTRACE
|
||||
htrc("%s\n", g->Message);
|
||||
|
|
|
@ -731,7 +731,7 @@ bool DBFFAM::CopyHeader(PGLOBAL g)
|
|||
if (fseek(Stream, 0, SEEK_SET))
|
||||
strcpy(g->Message, "Seek error in CopyHeader");
|
||||
else if ((n = fread(hdr, 1, hlen, Stream)) != hlen)
|
||||
sprintf(g->Message, MSG(BAD_READ_NUMBER), n, To_File);
|
||||
sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, To_File);
|
||||
else if ((n = fwrite(hdr, 1, hlen, T_Stream)) != hlen)
|
||||
sprintf(g->Message, MSG(WRITE_STRERROR), To_Fbt->Fname
|
||||
, strerror(errno));
|
||||
|
|
|
@ -308,6 +308,7 @@ int FIXFAM::WriteBuffer(PGLOBAL g)
|
|||
} else { // Mode == MODE_UPDATE
|
||||
// T_Stream is the temporary stream or the table file stream itself
|
||||
if (!T_Stream)
|
||||
{
|
||||
if (UseTemp /*&& Tdbp->GetMode() == MODE_UPDATE*/) {
|
||||
if (OpenTempFile(g))
|
||||
return RC_FX;
|
||||
|
@ -317,7 +318,7 @@ int FIXFAM::WriteBuffer(PGLOBAL g)
|
|||
|
||||
} else
|
||||
T_Stream = Stream;
|
||||
|
||||
}
|
||||
Modif++; // Modified line in Update mode
|
||||
} // endif Mode
|
||||
|
||||
|
@ -488,7 +489,7 @@ bool FIXFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
|
|||
#endif
|
||||
|
||||
if (len != req) {
|
||||
sprintf(g->Message, MSG(DEL_READ_ERROR), req, len);
|
||||
sprintf(g->Message, MSG(DEL_READ_ERROR), (int) req, (int) len);
|
||||
return true;
|
||||
} // endif len
|
||||
|
||||
|
@ -1135,13 +1136,14 @@ int BGXFAM::WriteBuffer(PGLOBAL g)
|
|||
} else { // Mode == MODE_UPDATE
|
||||
// Tfile is the temporary file or the table file handle itself
|
||||
if (Tfile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (UseTemp /*&& Tdbp->GetMode() == MODE_UPDATE*/) {
|
||||
if (OpenTempFile(g))
|
||||
return RC_FX;
|
||||
|
||||
} else
|
||||
Tfile = Hfile;
|
||||
|
||||
}
|
||||
Modif++; // Modified line in Update mode
|
||||
} // endif Mode
|
||||
|
||||
|
|
|
@ -871,7 +871,7 @@ bool DOSFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
|
|||
htrc("after read req=%d len=%d\n", req, len);
|
||||
|
||||
if (len != req) {
|
||||
sprintf(g->Message, MSG(DEL_READ_ERROR), req, len);
|
||||
sprintf(g->Message, MSG(DEL_READ_ERROR), (int) req, (int) len);
|
||||
return true;
|
||||
} // endif len
|
||||
|
||||
|
|
|
@ -899,7 +899,7 @@ bool VCTFAM::MoveIntermediateLines(PGLOBAL g, bool *b)
|
|||
#endif
|
||||
|
||||
if (len != req) {
|
||||
sprintf(g->Message, MSG(DEL_READ_ERROR), req, len);
|
||||
sprintf(g->Message, MSG(DEL_READ_ERROR), (int) req, (int) len);
|
||||
return true;
|
||||
} // endif len
|
||||
|
||||
|
@ -1179,7 +1179,7 @@ bool VCTFAM::ReadBlock(PGLOBAL g, PVCTCOL colp)
|
|||
|
||||
if (n != (size_t)Nrec) {
|
||||
if (errno == NO_ERROR)
|
||||
sprintf(g->Message, MSG(BAD_READ_NUMBER), n, To_File);
|
||||
sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, To_File);
|
||||
else
|
||||
sprintf(g->Message, MSG(READ_ERROR),
|
||||
To_File, strerror(errno));
|
||||
|
@ -1362,7 +1362,7 @@ bool VCMFAM::OpenTableFile(PGLOBAL g)
|
|||
|
||||
if (!(*g->Message))
|
||||
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
||||
"map", rc, filename);
|
||||
"map", (int) rc, filename);
|
||||
|
||||
#ifdef DEBTRACE
|
||||
htrc("%s\n", g->Message);
|
||||
|
@ -2348,7 +2348,7 @@ bool VECFAM::MoveIntermediateLines(PGLOBAL g, bool *bn)
|
|||
#endif
|
||||
|
||||
if (len != req) {
|
||||
sprintf(g->Message, MSG(DEL_READ_ERROR), req, len);
|
||||
sprintf(g->Message, MSG(DEL_READ_ERROR), (int) req, (int) len);
|
||||
return true;
|
||||
} // endif len
|
||||
|
||||
|
@ -2533,7 +2533,7 @@ bool VECFAM::ReadBlock(PGLOBAL g, PVCTCOL colp)
|
|||
#else // !WIN32
|
||||
if (errno == NO_ERROR)
|
||||
#endif // !WIN32
|
||||
sprintf(g->Message, MSG(BAD_READ_NUMBER), n, fn);
|
||||
sprintf(g->Message, MSG(BAD_READ_NUMBER), (int) n, fn);
|
||||
else
|
||||
sprintf(g->Message, MSG(READ_ERROR),
|
||||
fn, strerror(errno));
|
||||
|
@ -2759,7 +2759,7 @@ bool VMPFAM::MapColumnFile(PGLOBAL g, MODE mode, int i)
|
|||
|
||||
if (!(*g->Message))
|
||||
sprintf(g->Message, MSG(OPEN_MODE_ERROR),
|
||||
"map", rc, filename);
|
||||
"map", (int) rc, filename);
|
||||
#ifdef DEBTRACE
|
||||
htrc("%s\n", g->Message);
|
||||
#endif
|
||||
|
|
|
@ -2547,7 +2547,8 @@ int ha_connect::rnd_next(uchar *buf)
|
|||
ulonglong tb2= my_interval_timer();
|
||||
double elapsed= (double) (tb2 - xp->tb1) / 1000000000ULL;
|
||||
DBUG_PRINT("rnd_next", ("rc=%d nrd=%u fnd=%u nfd=%u sec=%.3lf\n",
|
||||
rc, xp->nrd, xp->fnd, xp->nfd, elapsed));
|
||||
rc, (uint) xp->nrd, (uint) xp->fnd,
|
||||
(uint) xp->nfd, elapsed));
|
||||
xp->tb1= tb2;
|
||||
xp->fnd= xp->nfd= 0;
|
||||
} // endif nrd
|
||||
|
@ -2887,7 +2888,8 @@ int ha_connect::external_lock(THD *thd, int lock_type)
|
|||
|
||||
if (xtrace) {
|
||||
printf("%p external_lock: cmdtype=%d\n", this, thd->lex->sql_command);
|
||||
printf("Cmd=%s\n", thd->query_string);
|
||||
printf("Cmd=%.*s\n", (int) thd->query_string.length(),
|
||||
thd->query_string.str());
|
||||
} // endif xtrace
|
||||
|
||||
// Next code is temporarily replaced until sql_command is set
|
||||
|
|
|
@ -14,7 +14,7 @@ my_bool CloseFileHandle(HANDLE h)
|
|||
/* code to handle Linux and Solaris */
|
||||
#include <unistd.h>
|
||||
#include <sys/stat.h>
|
||||
//#include <ctype.h>
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
extern FILE *debug;
|
||||
|
@ -223,7 +223,7 @@ DWORD FormatMessage(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId,
|
|||
//if (dwFlags & FORMAT_MESSAGE_ALLOCATE_BUFFER)
|
||||
// return 0; /* means error */
|
||||
|
||||
n = sprintf(buff, "Error code: %d", dwMessageId);
|
||||
n = sprintf(buff, "Error code: %d", (int) dwMessageId);
|
||||
strncpy(lpBuffer, buff, nSize);
|
||||
return min(n, nSize);
|
||||
} /* end of FormatMessage */
|
||||
|
|
|
@ -164,7 +164,9 @@ global_open_error_msg(GLOBAL *g, int msgid, const char *path, const char *mode)
|
|||
|
||||
case MSGID_OPEN_ERROR_AND_STRERROR:
|
||||
len= snprintf(g->Message, sizeof(g->Message) - 1,
|
||||
MSG(OPEN_ERROR) "%s",// "Open error %d in mode %d on %s: %s"
|
||||
//OPEN_ERROR does not work, as it wants mode %d (not %s)
|
||||
//MSG(OPEN_ERROR) "%s",// "Open error %d in mode %d on %s: %s"
|
||||
"Open error %d in mode %s on %s: %s",
|
||||
errno, mode, path, strerror(errno));
|
||||
break;
|
||||
|
||||
|
@ -1472,6 +1474,7 @@ DllExport void NewPointer(PTABS t, void *oldv, void *newv)
|
|||
return;
|
||||
|
||||
if (!t->P1 || t->P1->Num == 50)
|
||||
{
|
||||
if (!(tp = new TABPTR)) {
|
||||
PGLOBAL g = t->G;
|
||||
|
||||
|
@ -1482,6 +1485,7 @@ DllExport void NewPointer(PTABS t, void *oldv, void *newv)
|
|||
tp->Num = 0;
|
||||
t->P1 = tp;
|
||||
} /* endif tp */
|
||||
}
|
||||
|
||||
t->P1->Old[t->P1->Num] = oldv;
|
||||
t->P1->New[t->P1->Num++] = newv;
|
||||
|
|
|
@ -459,7 +459,7 @@ void *PlugSubAlloc(PGLOBAL g, void *memp, size_t size)
|
|||
|
||||
sprintf(g->Message,
|
||||
"Not enough memory in %s area for request of %u (used=%d free=%d)",
|
||||
pname, size, pph->To_Free, pph->FreeBlk);
|
||||
pname, (uint) size, pph->To_Free, pph->FreeBlk);
|
||||
|
||||
#if defined(DEBUG2) || defined(DEBUG3)
|
||||
htrc("%s\n", g->Message);
|
||||
|
|
|
@ -471,7 +471,7 @@ void BINCOL::WriteColumn(PGLOBAL g)
|
|||
break;
|
||||
case 'C': // Characters
|
||||
if ((n = (signed)strlen(Value->GetCharString(Buf))) > Long) {
|
||||
sprintf(g->Message, MSG(BIN_F_TOO_LONG), Name, n, Long);
|
||||
sprintf(g->Message, MSG(BIN_F_TOO_LONG), Name, (int) n, Long);
|
||||
longjmp(g->jumper[g->jump_level], 31);
|
||||
} // endif n
|
||||
|
||||
|
|
|
@ -1199,7 +1199,7 @@ void XMLCOL::ReadColumn(PGLOBAL g)
|
|||
if (ValNode) {
|
||||
if (ValNode->GetType() != XML_ELEMENT_NODE &&
|
||||
ValNode->GetType() != XML_ATTRIBUTE_NODE) {
|
||||
sprintf(g->Message, MSG(BAD_VALNODE), Name, ValNode->GetType());
|
||||
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name);
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
} // endif type
|
||||
|
||||
|
@ -1392,7 +1392,7 @@ void XMULCOL::ReadColumn(PGLOBAL g)
|
|||
|
||||
if (ValNode->GetType() != XML_ELEMENT_NODE &&
|
||||
ValNode->GetType() != XML_ATTRIBUTE_NODE) {
|
||||
sprintf(g->Message, MSG(BAD_VALNODE), Name, ValNode->GetType());
|
||||
sprintf(g->Message, MSG(BAD_VALNODE), ValNode->GetType(), Name);
|
||||
longjmp(g->jumper[g->jump_level], TYPE_AM_XML);
|
||||
} // endif type
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ bool user_connect::CheckCleanup(void)
|
|||
last_query_id= thdp->query_id;
|
||||
|
||||
if (xtrace)
|
||||
printf("=====> Begin new query %d\n", last_query_id);
|
||||
printf("=====> Begin new query %llu\n", last_query_id);
|
||||
|
||||
return true;
|
||||
} // endif query_id
|
||||
|
|
|
@ -705,7 +705,7 @@ char *STRING::GetShortString(char *p, int n)
|
|||
/***********************************************************************/
|
||||
char *STRING::GetIntString(char *p, int n)
|
||||
{
|
||||
sprintf(p, "%*d", n, atol(Strp));
|
||||
sprintf(p, "%*ld", n, atol(Strp));
|
||||
return p;
|
||||
} // end of GetIntString
|
||||
|
||||
|
@ -4336,7 +4336,7 @@ char *DFVAL::GetShortString(char *p, int n)
|
|||
/***********************************************************************/
|
||||
char *DFVAL::GetIntString(char *p, int n)
|
||||
{
|
||||
sprintf(p, "%*ld", n, (int)Fval);
|
||||
sprintf(p, "%*ld", n, (long) Fval);
|
||||
return p;
|
||||
} // end of GetIntString
|
||||
|
||||
|
|
|
@ -2109,7 +2109,7 @@ bool XFILE::Open(PGLOBAL g, char *filename, MODE mode)
|
|||
/* Position the cursor at end of file so ftell returns file size. */
|
||||
/*******************************************************************/
|
||||
if (fseek(Xfile, 0, SEEK_END)) {
|
||||
sprintf(g->Message, MSG(FUNC_ERRNO), "Xseek", errno);
|
||||
sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Xseek");
|
||||
return true;
|
||||
} // endif
|
||||
|
||||
|
@ -2140,7 +2140,7 @@ bool XFILE::Seek(PGLOBAL g, int low, int high, int origin)
|
|||
#endif // !_DEBUG
|
||||
|
||||
if (fseek(Xfile, low, origin)) {
|
||||
sprintf(g->Message, MSG(FUNC_ERRNO), "Xseek", errno);
|
||||
sprintf(g->Message, MSG(FUNC_ERRNO), errno, "Xseek");
|
||||
return true;
|
||||
} // endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue