lkml.org 
[lkml]   [2007]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: (trivia) remove useless typecast around `jif' variable
    On Mar 5 2007 19:12, Michael Tokarev wrote:

    >Date: Mon, 5 Mar 2007 19:12:51 +0300 (MSK)
    >From: Michael Tokarev <mjt@tls.msk.ru>
    >To: undisclosed-recipients: ;

    I have no clue what you sent it to, so I added linux-kernel again.



    >Subject: (trivia) remove useless typecast around `jif' variable
    >
    >in fs/proc/proc_misc.c:show_stat() routine (which handles /proc/stat
    >file), there's a local variable named 'jif' of type unsigned long,
    >declared as following:
    >
    >static int show_stat(struct seq_file *p, void *v)
    >{
    > unsigned long jif;
    >
    >But later on, it's explicitly casted to (unsigned long) in printf().
    >Remove the useless cast, to let the compiler to do the work for us
    >in case we'll want to use different type here (say, u64 or something).

    In case we wanted to use different types, we would also have to
    change the accompanying %lu into %llu. Only changing jif to u64 will
    cause a problem, as the compiler does _not_ automatically
    promote/demote types in varargs that already have a certain size. In
    other words,

    int foo(unsigned long x)
    {
    printk("%llu\n", x); /* and */
    printk("%lu\n", x);
    }

    will throw a warning (rightfully if you ask me).



    Jan
    --
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2007-03-05 17:33    [W:0.023 / U:61.188 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site