int main(int argc, char *argv[])
{
char *buf = NULL;
- ssize_t n;
+ ssize_t n, r;
int c;
int console_level = 0;
static struct dmesg_control ctl = {
argc -= optind;
argv += optind;
n = 0;
+ r = 0;
if (argc > 1)
usage(stderr);
if (ctl.method == DMESG_METHOD_KMSG && init_kmsg(&ctl) != 0)
ctl.method = DMESG_METHOD_SYSLOG;
- n = read_buffer(&ctl, &buf);
- if (n > 0)
- print_buffer(&ctl, buf, n);
+ r = read_buffer(&ctl, &buf);
+ if (r > 0)
+ print_buffer(&ctl, buf, r);
if (!ctl.mmap_buff)
free(buf);
break;
if (ctl.kmsg >= 0)
close(ctl.kmsg);
- if (n < 0 && ctl.method == DMESG_METHOD_SYSLOG)
+ if (n < 0)
err(EXIT_FAILURE, _("klogctl failed"));
+ if (r < 0)
+ err(EXIT_FAILURE, _("read_buffer failed"));
return EXIT_SUCCESS;
}