openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/sys-utils/dmesg.c
static int read_kmsg(struct dmesg_control* ctl)
{
    struct dmesg_record rec;
    ssize_t sz;

    if (ctl->method != DMESG_METHOD_KMSG || ctl->kmsg < 0)
        return -1;

    /*
     * The very first read() call is done in kmsg_init() where we test
     * /dev/kmsg usability. The return code from the initial read() is
     * stored in ctl->kmsg_first_read;
     */
    sz = ctl->kmsg_first_read;

    while (sz > 0)
    {
        *(ctl->kmsg_buf + sz) = '\0'; /* for debug messages */

        if (parse_kmsg_record(ctl, &rec, ctl->kmsg_buf, (size_t)sz) == 0)
            print_record(ctl, &rec);

        sz = read_kmsg_one(ctl);
    }

    return 0;
}
/*
 * Note that each read() call for /dev/kmsg returns always one record. It means
 * that we don't have to read whole message buffer before the records parsing.
 *
 * So this function does not compose one huge buffer (like read_syslog_buffer())
 * and print_buffer() is unnecessary. All is done in this function.
 *
 * Returns 0 on success, -1 on error.
 */
Note that each read() call for /dev/kmsg returns always one record. It means
that we don't have to read whole message buffer before the records parsing.

So this function does not compose one huge buffer (like read_syslog_buffer())
and print_buffer() is unnecessary. All is done in this function.

Returns 0 on success, -1 on error.
Note that each read () call for / dev / kmsg returns always one record . It means that we don ' t have to read whole message buffer before the records parsing . So this function does not compose one huge buffer ( like read_syslog_buffer () ) and print_buffer () is unnecessary . All is done in this function . Returns 0 on success - 1 on error .
static int read_kmsg(struct dmesg_control* ctl)
{
    struct dmesg_record rec;
    ssize_t sz;
    if (ctl->method != DMESG_METHOD_KMSG || ctl->kmsg < 0)
        return -1;
    sz = ctl->kmsg_first_read;
    while (sz > 0)
    {
        *(ctl->kmsg_buf + sz) = '\0'; 
        if (parse_kmsg_record(ctl, &rec, ctl->kmsg_buf, (size_t)sz) == 0)
            print_record(ctl, &rec);
        sz = read_kmsg_one(ctl);
    }
    return 0;
}
static int read_kmsg ( struct dmesg_control * ctl ) { struct dmesg_record rec ; ssize_t sz ; if ( ctl -> method != DMESG_METHOD_KMSG || ctl -> kmsg < 0 ) return -1 ; sz = ctl -> kmsg_first_read ; while ( sz > 0 ) { * ( ctl -> kmsg_buf + sz ) = ' \0 ' ; if ( parse_kmsg_record ( ctl , & rec , ctl -> kmsg_buf , ( size_t ) sz ) == 0 ) print_record ( ctl , & rec ) ; sz = read_kmsg_one ( ctl ) ; } return 0 ; }
Note that each read() call for /dev/kmsg returns always one record.
Note that each read () call for / dev / kmsg returns always one record .
/*
     * The very first read() call is done in kmsg_init() where we test
     * /dev/kmsg usability. The return code from the initial read() is
     * stored in ctl->kmsg_first_read;
     */ /* for debug messages */