lkml.org 
[lkml]   [2020]   [Aug]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] hugetlb_cgroup: convert comma to semicolon
From
Date
On Sun, 2020-08-23 at 16:21 +0100, Matthew Wilcox wrote:
> On Wed, Aug 19, 2020 at 10:14:11AM +0200, Giuseppe Scrivano wrote:
> > > > - cft->file_offset = offsetof(struct hugetlb_cgroup, events_file[idx]),
> > > > + cft->file_offset = offsetof(struct hugetlb_cgroup, events_file[idx]);
> > > > cft->flags = CFTYPE_NOT_ON_ROOT;
> >
> > I think in this case having two expressions as part of the same
> > statement is equivalent to having two separate statements. Both
> > cft->file_offset and cft->flags get the expected value.
>
> That's not how the comma operator works.
>
> It will evaluate offsetof(struct hugetlb_cgroup, events_file[idx]) and
> then discard the result. Since it has no side-effects, this is effectively
> doing:
>
> cft->file_offset = cft->flags = CFTYPE_NOT_ON_ROOT;

$ gcc -x c -
#include <stdio.h>
#include <stdlib.h>

struct foo {
int a;
char b[50];
};

int main(int argc, char **argv)
{
int a;
int b;

a = sizeof(struct foo), b = 1;

printf("a: %d, b: %d\n", a, b);

return 0;
}
$ ./a.out
a: 56, b: 1


\
 
 \ /
  Last update: 2020-08-23 18:06    [W:0.088 / U:0.148 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site