mirror of https://github.com/BOINC/boinc.git
- api: check return values of functions used in boinc_msg_prefix(),
return a (valid) empty string if an error occurred svn path=/trunk/boinc/; revision=22781
This commit is contained in:
parent
16147b7dd7
commit
0220ab3319
|
@ -195,16 +195,35 @@ static int start_worker_signals();
|
||||||
|
|
||||||
char* boinc_msg_prefix(char* sbuf, int len) {
|
char* boinc_msg_prefix(char* sbuf, int len) {
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
struct tm* tm;
|
||||||
time_t x = time(0);
|
time_t x = time(0);
|
||||||
struct tm* tm = localtime(&x);
|
|
||||||
strftime(buf, sizeof(buf)-1, "%H:%M:%S", tm);
|
if(x == (time_t)-1) {
|
||||||
|
*sbuf='\0'; // make sure there is a valid (empty) string returned
|
||||||
|
return sbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!(tm = localtime(&x))) {
|
||||||
|
*sbuf='\0'; // make sure there is a valid (empty) string returned
|
||||||
|
return sbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!strftime(buf, sizeof(buf)-1, "%H:%M:%S", tm)) {
|
||||||
|
*sbuf='\0'; // make sure there is a valid (empty) string returned
|
||||||
|
return sbuf;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
_snprintf(sbuf, len, "%s (%d):", buf, GetCurrentProcessId());
|
if(_snprintf(sbuf, len, "%s (%d):", buf, GetCurrentProcessId()) < 0)
|
||||||
#else
|
#else
|
||||||
snprintf(sbuf, len, "%s (%d):", buf, getpid());
|
if(snprintf(sbuf, len, "%s (%d):", buf, getpid()) < 0)
|
||||||
#endif
|
#endif
|
||||||
sbuf[len-1] = 0; // just in case
|
{
|
||||||
|
*sbuf='\0'; // make sure there is a valid (empty) string returned
|
||||||
|
return sbuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
sbuf[len-1] = '\0'; // just in case
|
||||||
return sbuf;
|
return sbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8518,3 +8518,10 @@ David 30 Nov 2010
|
||||||
client/
|
client/
|
||||||
client_state.cpp
|
client_state.cpp
|
||||||
cpu_sched.cpp
|
cpu_sched.cpp
|
||||||
|
|
||||||
|
Bernd 01 Dec 2010
|
||||||
|
- api: check return values of functions used in boinc_msg_prefix(),
|
||||||
|
return a (valid) empty string if an error occurred
|
||||||
|
|
||||||
|
api/
|
||||||
|
boinc-api.cpp
|
||||||
|
|
Loading…
Reference in New Issue