From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3B848C433E1 for ; Sun, 23 Aug 2020 16:04:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 260D520706 for ; Sun, 23 Aug 2020 16:04:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726758AbgHWQE4 (ORCPT ); Sun, 23 Aug 2020 12:04:56 -0400 Received: from smtprelay0077.hostedemail.com ([216.40.44.77]:55286 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726502AbgHWQEz (ORCPT ); Sun, 23 Aug 2020 12:04:55 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay06.hostedemail.com (Postfix) with ESMTP id AD30118224D9C; Sun, 23 Aug 2020 16:04:53 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: dirt18_190ae292704b X-Filterd-Recvd-Size: 2134 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf04.hostedemail.com (Postfix) with ESMTPA; Sun, 23 Aug 2020 16:04:52 +0000 (UTC) Message-ID: Subject: Re: [PATCH] hugetlb_cgroup: convert comma to semicolon From: Joe Perches To: Matthew Wilcox , Giuseppe Scrivano Cc: Andrew Morton , Xu Wang , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Tejun Heo Date: Sun, 23 Aug 2020 09:04:51 -0700 In-Reply-To: <20200823152130.GA17456@casper.infradead.org> References: <20200818064333.21759-1-vulab@iscas.ac.cn> <20200818184036.d6c479446b2c3b231d1e3bff@linux-foundation.org> <87eeo32gto.fsf@redhat.com> <20200823152130.GA17456@casper.infradead.org> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.36.4-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 #include 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 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01823C433E1 for ; Sun, 23 Aug 2020 16:04:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id BC1952072D for ; Sun, 23 Aug 2020 16:04:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BC1952072D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=perches.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 1FE956B0002; Sun, 23 Aug 2020 12:04:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 187876B0005; Sun, 23 Aug 2020 12:04:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 04E466B0006; Sun, 23 Aug 2020 12:04:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0157.hostedemail.com [216.40.44.157]) by kanga.kvack.org (Postfix) with ESMTP id DE63A6B0002 for ; Sun, 23 Aug 2020 12:04:54 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9E2FF181AEF1A for ; Sun, 23 Aug 2020 16:04:54 +0000 (UTC) X-FDA: 77182306908.17.pipe74_5511c9e2704b Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 69D7B180D0184 for ; Sun, 23 Aug 2020 16:04:54 +0000 (UTC) X-HE-Tag: pipe74_5511c9e2704b X-Filterd-Recvd-Size: 3291 Received: from smtprelay.hostedemail.com (smtprelay0180.hostedemail.com [216.40.44.180]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Sun, 23 Aug 2020 16:04:53 +0000 (UTC) Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay06.hostedemail.com (Postfix) with ESMTP id AD30118224D9C; Sun, 23 Aug 2020 16:04:53 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: dirt18_190ae292704b X-Filterd-Recvd-Size: 2134 Received: from XPS-9350.home (unknown [47.151.133.149]) (Authenticated sender: joe@perches.com) by omf04.hostedemail.com (Postfix) with ESMTPA; Sun, 23 Aug 2020 16:04:52 +0000 (UTC) Message-ID: Subject: Re: [PATCH] hugetlb_cgroup: convert comma to semicolon From: Joe Perches To: Matthew Wilcox , Giuseppe Scrivano Cc: Andrew Morton , Xu Wang , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Tejun Heo Date: Sun, 23 Aug 2020 09:04:51 -0700 In-Reply-To: <20200823152130.GA17456@casper.infradead.org> References: <20200818064333.21759-1-vulab@iscas.ac.cn> <20200818184036.d6c479446b2c3b231d1e3bff@linux-foundation.org> <87eeo32gto.fsf@redhat.com> <20200823152130.GA17456@casper.infradead.org> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.36.4-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 69D7B180D0184 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 #include 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