{
struct tm tmBuf;
struct tm* ptm;
- time_t time_t_temp;
char timeBuf[32], tzBuf[16];
char recvTimeBuf[32];
char prefixBuf[128], suffixBuf[128];
* in the time stamp. Don't use forward slashes, parenthesis,
* brackets, asterisks, or other special chars here.
*/
+ struct timespec ts_sent = entry_get_ts(entry, p_format.format, TS_SENT);
+ struct timespec ts_recv = entry_get_ts(entry, p_format.format, TS_RECV);
- struct timespec ts;
-
- long int sec_sent, nsec_sent;
- ts = entry_get_ts(entry, p_format.format, TS_SENT);
- sec_sent = ts.tv_sec;
- nsec_sent = ts.tv_nsec;
-
- long int sec_recv, nsec_recv;
- ts = entry_get_ts(entry, p_format.format, TS_RECV);
- sec_recv = ts.tv_sec;
- nsec_recv = ts.tv_nsec;
-
- time_t_temp = sec_sent;
+ time_t time_t_temp = ts_sent.tv_sec;
ptm = localtime_r(&time_t_temp, &tmBuf);
if (!ptm)
return NULL;
strftime(timeBuf, sizeof(timeBuf), "%m-%d %H:%M:%S", ptm);
- time_t_temp = sec_recv;
+ time_t_temp = ts_recv.tv_sec;
ptm = localtime_r(&time_t_temp, &tmBuf);
if (!ptm)
return NULL;
break;
case FORMAT_TIME:
prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
- "%s.%03ld%s %c/%-8s(%5d): ", timeBuf, nsec_sent / 1000000,
+ "%s.%03ld%s %c/%-8s(%5d): ", timeBuf, ts_sent.tv_nsec / 1000000,
tzBuf, priChar, tag, (int)entry->pid);
strncpy(suffixBuf, "\n", 2);
suffixLen = 1;
case FORMAT_THREADTIME:
prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
"%s.%03ld%s %c/%-8s(P%5d, T%5d): ",
- timeBuf, nsec_sent / 1000000,
+ timeBuf, ts_sent.tv_nsec / 1000000,
tzBuf, priChar, tag, (int)entry->pid, (int)entry->tid);
strncpy(suffixBuf, "\n", 2);
suffixLen = 1;
case FORMAT_KERNELTIME:
prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
"%5lu.%03ld %c/%-8s(P%5d, T%5d): ",
- sec_sent, nsec_sent / 1000000,
+ ts_sent.tv_sec, ts_sent.tv_nsec / 1000000,
priChar, tag, (int)entry->pid, (int)entry->tid);
strncpy(suffixBuf, "\n", 2);
suffixLen = 1;
case FORMAT_RECV_REALTIME:
prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
"%s.%03ld %c/%-8s(P%5d, T%5d): ",
- recvTimeBuf, nsec_recv / 1000000,
+ recvTimeBuf, ts_recv.tv_nsec / 1000000,
priChar, tag, (int)entry->pid, (int)entry->tid);
strncpy(suffixBuf, "\n", 2);
suffixLen = 1;
colorSuffix = false;
break;
- case FORMAT_RWTIME:
+ case FORMAT_RWTIME: {
/* This shouldn't be needed. However, sadly, the rwtime format contains two different timestamps.
* Such a situation is impossible to describe as is. Therefore, it calls for an ugly hack :P
* Again, the planned refactor of the format system will fix this. */
- ts = entry_get_ts(entry, FORMAT_KERNELTIME, TS_SENT);
+ struct timespec ts = entry_get_ts(entry, FORMAT_KERNELTIME, TS_SENT);
prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
"%s [%5lu.%03ld] %c/%-8s(P%5d, T%5d): ",
recvTimeBuf, ts.tv_sec, ts.tv_nsec / 1000000,
suffixLen = 1;
colorSuffix = false;
break;
+ }
case FORMAT_LONG:
prefixLen = snprintf(prefixBuf, sizeof(prefixBuf),
"[ %s.%03ld %c/%-8s P%5d, T%5d]\n",
- timeBuf, nsec_sent / 1000000, priChar, tag,
+ timeBuf, ts_sent.tv_nsec / 1000000, priChar, tag,
(int)entry->pid, (int)entry->tid);
strncpy(suffixBuf, "\n\n", 3);
suffixLen = 2;