lkml.org 
[lkml]   [2012]   [Feb]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [patch cr 2/4] [RFC] syscalls, x86: Add __NR_kcmp syscall v7
On Fri, Feb 03, 2012 at 01:22:41AM -0800, Andrew Morton wrote:
> On Fri, 3 Feb 2012 10:09:29 +0100 Ingo Molnar <mingo@elte.hu> wrote:
>
> >
> > * Cyrill Gorcunov <gorcunov@openvz.org> wrote:
> >
> > > > > + get_random_bytes(&cookies[i][j],
> > > > > + sizeof(cookies[i][j]));
> > > >
> > > > ugly line break.
> > > >
> > >
> > > Why? Looks pretty good to me. But sure I'll change it.
> >
> > It's ugly because it serves no purpose other than pacifying
> > checkpatch and makes the code *uglier*.
>
> No it doesn't. For 80-col displays the code is *already wrapped*. And
> that wrapping to column 0 is vastly worse than the above.
>
> If we want to increase the standard to (say) 96 cols then fine, I'd be
> happy with that. But until we do that we should not create such a
> gruesome mess for those who use 80 cols.
>
> > It's a disease. When checkpatch tells you "this line is too
> > long" then consider it a code cleanliness warning!
>
> Well yes, if it can be fixed by other means then great.
>

Guys, I simply made it as

static __init int kcmp_cookie_init(void)
{
int i, j;

for (i = 0; i < KCMP_TYPES; i++) {
for (j = 0; j < 2; j++)
get_random_bytes(&cookies[i][j], sizeof(long));
cookies[i][1] |= (~(~0UL >> 1) | 1);
}

return 0;
}

I thought in first place that sizeof(cookies[i][j]) would allow me
to change type of cookies in one place (ie at declaration) but
if cookies type will be changed -- the code will need careful review
anway, so sizeof(long) will be enough I think.

On the other hands, maybe more clean variant will be

static __init int kcmp_cookie_init(void)
{
const int size = sizeof(cookies[0][0]);
int i, j;

for (i = 0; i < KCMP_TYPES; i++) {
for (j = 0; j < 2; j++)
get_random_bytes(&cookies[i][j], size);
cookies[i][1] |= (~(~0UL >> 1) | 1);
}

return 0;
}

Hm?

Cyrill


\
 
 \ /
  Last update: 2012-02-03 10:31    [W:0.124 / U:0.512 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site