* ipc/shm.c:494:18: warning: unused variable ‘hs’ [-Wunused-variable]
@ 2013-05-08 14:34 Borislav Petkov
2013-05-08 16:12 ` Naoya Horiguchi
0 siblings, 1 reply; 6+ messages in thread
From: Borislav Petkov @ 2013-05-08 14:34 UTC (permalink / raw)
To: Naoya Horiguchi; +Cc: lkml
Hi,
looks like this warning came in with
af73e4d9506d3b797509f3c030e7dcd554f7d9c4 and fires in the
# CONFIG_HUGETLB_PAGE is not set
case because
struct hstate *hs = hstate_sizelog((shmflg >> SHM_HUGE_SHIFT)
& SHM_HUGE_MASK);
becomes
struct hstate *hs = ((void *)0)
due to
#define hstate_sizelog(s) NULL
Hmmm, I don't have a quick solution off the top of my head from staring
at the code.
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: ipc/shm.c:494:18: warning: unused variable ‘hs’ [-Wunused-variable]
2013-05-08 14:34 ipc/shm.c:494:18: warning: unused variable ‘hs’ [-Wunused-variable] Borislav Petkov
@ 2013-05-08 16:12 ` Naoya Horiguchi
2013-05-08 18:45 ` Borislav Petkov
0 siblings, 1 reply; 6+ messages in thread
From: Naoya Horiguchi @ 2013-05-08 16:12 UTC (permalink / raw)
To: Borislav Petkov; +Cc: lkml
Hi Borislav,
On Wed, May 08, 2013 at 04:34:11PM +0200, Borislav Petkov wrote:
> Hi,
>
> looks like this warning came in with
> af73e4d9506d3b797509f3c030e7dcd554f7d9c4 and fires in the
>
> # CONFIG_HUGETLB_PAGE is not set
>
> case because
>
> struct hstate *hs = hstate_sizelog((shmflg >> SHM_HUGE_SHIFT)
> & SHM_HUGE_MASK);
>
> becomes
>
> struct hstate *hs = ((void *)0)
>
> due to
>
> #define hstate_sizelog(s) NULL
>
> Hmmm, I don't have a quick solution off the top of my head from staring
> at the code.
Thank you for the report.
I believe we can fix it with this one.
---
From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Date: Wed, 8 May 2013 11:48:01 -0400
Subject: [PATCH] ipc/shm.c: don't use auto variable hs in newseg()
This patch fixes "warning: unused variable 'hs'" when !CONFIG_HUGETLB_PAGE
introduced by commit af73e4d9506d "hugetlbfs: fix mmap failure in unaligned
size request".
Reported-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
---
ipc/shm.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/ipc/shm.c b/ipc/shm.c
index e316cb9..9ff741a 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -491,9 +491,8 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
sprintf (name, "SYSV%08x", key);
if (shmflg & SHM_HUGETLB) {
- struct hstate *hs = hstate_sizelog((shmflg >> SHM_HUGE_SHIFT)
- & SHM_HUGE_MASK);
- size_t hugesize = ALIGN(size, huge_page_size(hs));
+ size_t hugesize = ALIGN(size, huge_page_size(hstate_sizelog(
+ (shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK)));
/* hugetlb_file_setup applies strict accounting */
if (shmflg & SHM_NORESERVE)
--
1.7.11.7
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: ipc/shm.c:494:18: warning: unused variable ‘hs’ [-Wunused-variable]
2013-05-08 16:12 ` Naoya Horiguchi
@ 2013-05-08 18:45 ` Borislav Petkov
2013-05-08 20:48 ` [PATCH] ipc/shm.c: don't use auto variable hs in newseg() Naoya Horiguchi
0 siblings, 1 reply; 6+ messages in thread
From: Borislav Petkov @ 2013-05-08 18:45 UTC (permalink / raw)
To: Naoya Horiguchi; +Cc: lkml
On Wed, May 08, 2013 at 12:12:32PM -0400, Naoya Horiguchi wrote:
> Thank you for the report.
> I believe we can fix it with this one.
> ---
> From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> Date: Wed, 8 May 2013 11:48:01 -0400
> Subject: [PATCH] ipc/shm.c: don't use auto variable hs in newseg()
>
> This patch fixes "warning: unused variable 'hs'" when !CONFIG_HUGETLB_PAGE
> introduced by commit af73e4d9506d "hugetlbfs: fix mmap failure in unaligned
> size request".
>
> Reported-by: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> ---
> ipc/shm.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/ipc/shm.c b/ipc/shm.c
> index e316cb9..9ff741a 100644
> --- a/ipc/shm.c
> +++ b/ipc/shm.c
> @@ -491,9 +491,8 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
>
> sprintf (name, "SYSV%08x", key);
> if (shmflg & SHM_HUGETLB) {
> - struct hstate *hs = hstate_sizelog((shmflg >> SHM_HUGE_SHIFT)
> - & SHM_HUGE_MASK);
> - size_t hugesize = ALIGN(size, huge_page_size(hs));
> + size_t hugesize = ALIGN(size, huge_page_size(hstate_sizelog(
> + (shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK)));
Yeah, it fixes the warning alright but makes the code more unreadable.
Which makes me wonder which is worse - to have an innocuous warning or
have unreadable code.
You could also do the below. The line sticks out but it kills the
warning. Readability is hmm, not optimal still though. :)
--
diff --git a/ipc/shm.c b/ipc/shm.c
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -491,9 +491,8 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
sprintf (name, "SYSV%08x", key);
if (shmflg & SHM_HUGETLB) {
- struct hstate *hs = hstate_sizelog((shmflg >> SHM_HUGE_SHIFT)
- & SHM_HUGE_MASK);
- size_t hugesize = ALIGN(size, huge_page_size(hs));
+ unsigned long hsz = huge_page_size(hstate_sizelog((shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK));
+ size_t hugesize = ALIGN(size, hsz);
/* hugetlb_file_setup applies strict accounting */
if (shmflg & SHM_NORESERVE)
--
Yeah, you decide.
Thanks.
--
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] ipc/shm.c: don't use auto variable hs in newseg()
2013-05-08 18:45 ` Borislav Petkov
@ 2013-05-08 20:48 ` Naoya Horiguchi
2013-05-17 20:31 ` KOSAKI Motohiro
0 siblings, 1 reply; 6+ messages in thread
From: Naoya Horiguchi @ 2013-05-08 20:48 UTC (permalink / raw)
To: Borislav Petkov; +Cc: lkml, Andrew Morton, linux-mm
On Wed, May 08, 2013 at 08:45:24PM +0200, Borislav Petkov wrote:
> On Wed, May 08, 2013 at 12:12:32PM -0400, Naoya Horiguchi wrote:
> > Thank you for the report.
> > I believe we can fix it with this one.
> > ---
> > From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> > Date: Wed, 8 May 2013 11:48:01 -0400
> > Subject: [PATCH] ipc/shm.c: don't use auto variable hs in newseg()
> >
> > This patch fixes "warning: unused variable 'hs'" when !CONFIG_HUGETLB_PAGE
> > introduced by commit af73e4d9506d "hugetlbfs: fix mmap failure in unaligned
> > size request".
> >
> > Reported-by: Borislav Petkov <bp@alien8.de>
> > Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> > ---
> > ipc/shm.c | 5 ++---
> > 1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/ipc/shm.c b/ipc/shm.c
> > index e316cb9..9ff741a 100644
> > --- a/ipc/shm.c
> > +++ b/ipc/shm.c
> > @@ -491,9 +491,8 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
> >
> > sprintf (name, "SYSV%08x", key);
> > if (shmflg & SHM_HUGETLB) {
> > - struct hstate *hs = hstate_sizelog((shmflg >> SHM_HUGE_SHIFT)
> > - & SHM_HUGE_MASK);
> > - size_t hugesize = ALIGN(size, huge_page_size(hs));
> > + size_t hugesize = ALIGN(size, huge_page_size(hstate_sizelog(
> > + (shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK)));
>
> Yeah, it fixes the warning alright but makes the code more unreadable.
> Which makes me wonder which is worse - to have an innocuous warning or
> have unreadable code.
>
> You could also do the below. The line sticks out but it kills the
> warning. Readability is hmm, not optimal still though. :)
> --
> diff --git a/ipc/shm.c b/ipc/shm.c
> --- a/ipc/shm.c
> +++ b/ipc/shm.c
> @@ -491,9 +491,8 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
>
> sprintf (name, "SYSV%08x", key);
> if (shmflg & SHM_HUGETLB) {
> - struct hstate *hs = hstate_sizelog((shmflg >> SHM_HUGE_SHIFT)
> - & SHM_HUGE_MASK);
> - size_t hugesize = ALIGN(size, huge_page_size(hs));
> + unsigned long hsz = huge_page_size(hstate_sizelog((shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK));
> + size_t hugesize = ALIGN(size, hsz);
>
> /* hugetlb_file_setup applies strict accounting */
> if (shmflg & SHM_NORESERVE)
> --
>
> Yeah, you decide.
(CCed: Andrew and linux-mm)
OK, personally both are OK (comparably bad) for me, so I'll do the same
as af73e4d9506d3b does for SYSCALL_DEFINE6(mmap_pgoff), where we have
a line break just after '('.
Andrew, could you pick up the following fix?
-----
From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Date: Wed, 8 May 2013 11:48:01 -0400
Subject: [PATCH] ipc/shm.c: don't use auto variable hs in newseg()
This patch fixes "warning: unused variable 'hs'" when !CONFIG_HUGETLB_PAGE
introduced by commit af73e4d9506d "hugetlbfs: fix mmap failure in unaligned
size request".
Reported-by: Borislav Petkov <bp@alien8.de>
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
---
ipc/shm.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/ipc/shm.c b/ipc/shm.c
index e316cb9..9ff741a 100644
--- a/ipc/shm.c
+++ b/ipc/shm.c
@@ -491,9 +491,8 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
sprintf (name, "SYSV%08x", key);
if (shmflg & SHM_HUGETLB) {
- struct hstate *hs = hstate_sizelog((shmflg >> SHM_HUGE_SHIFT)
- & SHM_HUGE_MASK);
- size_t hugesize = ALIGN(size, huge_page_size(hs));
+ size_t hugesize = ALIGN(size, huge_page_size(hstate_sizelog(
+ (shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK)));
/* hugetlb_file_setup applies strict accounting */
if (shmflg & SHM_NORESERVE)
--
1.7.11.7
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] ipc/shm.c: don't use auto variable hs in newseg()
2013-05-08 20:48 ` [PATCH] ipc/shm.c: don't use auto variable hs in newseg() Naoya Horiguchi
@ 2013-05-17 20:31 ` KOSAKI Motohiro
2013-05-18 1:46 ` Naoya Horiguchi
0 siblings, 1 reply; 6+ messages in thread
From: KOSAKI Motohiro @ 2013-05-17 20:31 UTC (permalink / raw)
To: Naoya Horiguchi
Cc: Borislav Petkov, lkml, Andrew Morton, linux-mm, kosaki.motohiro
> From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> Date: Wed, 8 May 2013 11:48:01 -0400
> Subject: [PATCH] ipc/shm.c: don't use auto variable hs in newseg()
>
> This patch fixes "warning: unused variable 'hs'" when !CONFIG_HUGETLB_PAGE
> introduced by commit af73e4d9506d "hugetlbfs: fix mmap failure in unaligned
> size request".
>
> Reported-by: Borislav Petkov <bp@alien8.de>
> Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> ---
> ipc/shm.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/ipc/shm.c b/ipc/shm.c
> index e316cb9..9ff741a 100644
> --- a/ipc/shm.c
> +++ b/ipc/shm.c
> @@ -491,9 +491,8 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
>
> sprintf (name, "SYSV%08x", key);
> if (shmflg & SHM_HUGETLB) {
> - struct hstate *hs = hstate_sizelog((shmflg >> SHM_HUGE_SHIFT)
> - & SHM_HUGE_MASK);
> - size_t hugesize = ALIGN(size, huge_page_size(hs));
> + size_t hugesize = ALIGN(size, huge_page_size(hstate_sizelog(
> + (shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK)));
NAK. This is uglier than before.
You should change !CONFIG_HUGETLB_PAGE specific code instead.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] ipc/shm.c: don't use auto variable hs in newseg()
2013-05-17 20:31 ` KOSAKI Motohiro
@ 2013-05-18 1:46 ` Naoya Horiguchi
0 siblings, 0 replies; 6+ messages in thread
From: Naoya Horiguchi @ 2013-05-18 1:46 UTC (permalink / raw)
To: KOSAKI Motohiro; +Cc: Borislav Petkov, lkml, Andrew Morton, linux-mm
On Fri, May 17, 2013 at 04:31:52PM -0400, KOSAKI Motohiro wrote:
> > From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> > Date: Wed, 8 May 2013 11:48:01 -0400
> > Subject: [PATCH] ipc/shm.c: don't use auto variable hs in newseg()
> >
> > This patch fixes "warning: unused variable 'hs'" when !CONFIG_HUGETLB_PAGE
> > introduced by commit af73e4d9506d "hugetlbfs: fix mmap failure in unaligned
> > size request".
> >
> > Reported-by: Borislav Petkov <bp@alien8.de>
> > Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
> > ---
> > ipc/shm.c | 5 ++---
> > 1 file changed, 2 insertions(+), 3 deletions(-)
> >
> > diff --git a/ipc/shm.c b/ipc/shm.c
> > index e316cb9..9ff741a 100644
> > --- a/ipc/shm.c
> > +++ b/ipc/shm.c
> > @@ -491,9 +491,8 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
> >
> > sprintf (name, "SYSV%08x", key);
> > if (shmflg & SHM_HUGETLB) {
> > - struct hstate *hs = hstate_sizelog((shmflg >> SHM_HUGE_SHIFT)
> > - & SHM_HUGE_MASK);
> > - size_t hugesize = ALIGN(size, huge_page_size(hs));
> > + size_t hugesize = ALIGN(size, huge_page_size(hstate_sizelog(
> > + (shmflg >> SHM_HUGE_SHIFT) & SHM_HUGE_MASK)));
>
> NAK. This is uglier than before.
> You should change !CONFIG_HUGETLB_PAGE specific code instead.
This patch was dropped and replaced with Li Zefan's one which is
available in current upstream.
commit 091d0d55b286c9340201b4ed4470be87fc568228
Author: Li Zefan <lizefan@huawei.com>
Date: Thu May 9 15:08:15 2013 +0800
Thanks,
Naoya Horiguchi
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-05-18 1:47 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-08 14:34 ipc/shm.c:494:18: warning: unused variable ‘hs’ [-Wunused-variable] Borislav Petkov
2013-05-08 16:12 ` Naoya Horiguchi
2013-05-08 18:45 ` Borislav Petkov
2013-05-08 20:48 ` [PATCH] ipc/shm.c: don't use auto variable hs in newseg() Naoya Horiguchi
2013-05-17 20:31 ` KOSAKI Motohiro
2013-05-18 1:46 ` Naoya Horiguchi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox