Re: [PATCH 13/19] dmesg: make time format parsing to use enum bit field

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jun 02, 2013 at 06:51:19PM +0100, Sami Kerola wrote:
> +enum {
> +	TIMEFTM_NONE	= (1 << 0),
> +	TIMEFTM_CTIME	= (1 << 1),
> +	TIMEFTM_DELTA	= (1 << 2),
> +	TIMEFTM_RELTIME = (1 << 3),
> +};

 Do we really need to use the time formats as flags? Would be better
 to use it as a real enums?

 I know that it means that for "delta" we need more types, but it's
 probably better than assume arbitrary combination of all the types.

enum {
    DMESG_TIMEFTM_NONE = 0
    DMESG_TIMEFTM_TIME,           /* [time] */
	DMESG_TIMEFTM_CTIME,          /* [ctime] */
    DMESG_TIMEFTM_CTIME_DELTA,    /* [ctime <delta>] */
	DMESG_TIMEFTM_TIME_DELTA,     /* [time <delta>] */
    DMESG_TIMEFTM_DELTA,          /* [<delta>] */
	DMESG_TIMEFTM_RELTIME         /* [relative] */
};

and all you need is to set any default (DMESG_TIMEFTM_TIME) and clear the
default if --notime is specified.

In the code you can check for "if (ctl->time_fmt)" or add

    #define is_timefmt(c, f)   (c->time_fmt == (TIMEFTM_ ##f))

and use

    if (is_timefmt(ctl, DELTA))


  Karel

-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux