| 194 | } |
| 195 | |
| 196 | static int cmd_list(const struct buffer *buf, enum elogtool_flag flags) |
| 197 | { |
| 198 | enum eventlog_timezone tz = EVENTLOG_TIMEZONE_LOCALTIME; |
| 199 | const struct event_header *event; |
| 200 | unsigned int count = 0; |
| 201 | |
| 202 | if (flags & ELOGTOOL_FLAG_UTC) |
| 203 | tz = EVENTLOG_TIMEZONE_UTC; |
| 204 | |
| 205 | /* Point to the first event */ |
| 206 | event = buffer_get(buf) + sizeof(struct elog_header); |
| 207 | |
| 208 | while ((const void *)(event) < buffer_end(buf)) { |
| 209 | if (((const void *)event + sizeof(*event)) >= buffer_end(buf) |
| 210 | || event->length <= sizeof(*event) |
| 211 | || event->length > ELOG_MAX_EVENT_SIZE |
| 212 | || ((const void *)event + event->length) >= buffer_end(buf) |
| 213 | || event->type == ELOG_TYPE_EOL) |
| 214 | break; |
| 215 | |
| 216 | eventlog_print_event(event, count, tz); |
| 217 | event = elog_get_next_event(event); |
| 218 | count++; |
| 219 | } |
| 220 | |
| 221 | return ELOGTOOL_EXIT_SUCCESS; |
| 222 | } |
| 223 | |
| 224 | /* |
| 225 | * Clears the elog events from the given buffer, which is a valid RW_ELOG region. |
nothing calls this directly
no test coverage detected