1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

tests: check strftime result

This commit is contained in:
Zdenek Kabelac 2024-11-02 21:54:27 +01:00
parent 352b1b1817
commit cf6cbfb7f7

View File

@ -322,8 +322,8 @@ struct Journal {
char buf[64];
time_t t = time( 0 );
if (localtime_r(&t, &time_info)) {
strftime(buf, sizeof(buf), "%F %T", &time_info);
of << "--- " << buf << " ---";
if ( strftime( buf, sizeof(buf), "%F %T", &time_info ) )
of << "--- " << buf << " ---";
}
}
of << std::endl;
@ -716,7 +716,7 @@ struct KMsg : Source {
unsigned level, num, pos;
unsigned long t;
time_t tt;
size_t len;
size_t len, slen;
const char *delimiter;
buf[ *sz ] = 0;
@ -728,8 +728,10 @@ struct KMsg : Source {
memcpy( newbuf, buf, *sz );
tt = time( 0 );
len = snprintf( buf, 64, "[%lu.%06lu] <%u> ", t / 1000000, t % 1000000, level );
if ( localtime_r( &tt, &time_info ) )
len += strftime( buf + len, 64, "%F %T ", &time_info );
if ( localtime_r( &tt, &time_info ) &&
( slen = strftime( buf + len, 64, "%F %T ", &time_info ) ) )
len += slen;
memcpy( buf + len, newbuf + pos, *sz - pos );
*sz = *sz - pos + len;
}