2020-03-12 04:23:04

by Zheng Zengkai

[permalink] [raw]
Subject: [PATCH -next] fs/ntfs: fix set but not used variable 'log_page_mask'

Fixes gcc '-Wunused-but-set-variable' warning:

fs/ntfs/logfile.c: In function ntfs_check_logfile:
fs/ntfs/logfile.c:481:21:
warning: variable log_page_mask set but not used [-Wunused-but-set-variable]

Actually log_page_mask can be used to replace 'log_page_size - 1' as it is set.

Signed-off-by: Zheng Zengkai <[email protected]>
---
fs/ntfs/logfile.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ntfs/logfile.c b/fs/ntfs/logfile.c
index a0c40f1be7ac..c35fcf389369 100644
--- a/fs/ntfs/logfile.c
+++ b/fs/ntfs/logfile.c
@@ -507,7 +507,7 @@ bool ntfs_check_logfile(struct inode *log_vi, RESTART_PAGE_HEADER **rp)
* optimize log_page_size and log_page_bits into constants.
*/
log_page_bits = ntfs_ffs(log_page_size) - 1;
- size &= ~(s64)(log_page_size - 1);
+ size &= ~(s64)(log_page_mask);
/*
* Ensure the log file is big enough to store at least the two restart
* pages and the minimum number of log record pages.
--
2.20.1


2020-11-28 01:56:47

by Zheng Zengkai

[permalink] [raw]
Subject: Re: [PATCH -next] fs/ntfs: fix set but not used variable 'log_page_mask'

Ping...
> Fixes gcc '-Wunused-but-set-variable' warning:
>
> fs/ntfs/logfile.c: In function ntfs_check_logfile:
> fs/ntfs/logfile.c:481:21:
> warning: variable log_page_mask set but not used [-Wunused-but-set-variable]
>
> Actually log_page_mask can be used to replace 'log_page_size - 1' as it is set.
>
> Signed-off-by: Zheng Zengkai <[email protected]>
> ---
> fs/ntfs/logfile.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ntfs/logfile.c b/fs/ntfs/logfile.c
> index a0c40f1be7ac..c35fcf389369 100644
> --- a/fs/ntfs/logfile.c
> +++ b/fs/ntfs/logfile.c
> @@ -507,7 +507,7 @@ bool ntfs_check_logfile(struct inode *log_vi, RESTART_PAGE_HEADER **rp)
> * optimize log_page_size and log_page_bits into constants.
> */
> log_page_bits = ntfs_ffs(log_page_size) - 1;
> - size &= ~(s64)(log_page_size - 1);
> + size &= ~(s64)(log_page_mask);
> /*
> * Ensure the log file is big enough to store at least the two restart
> * pages and the minimum number of log record pages.

2020-12-08 12:05:12

by Anton Altaparmakov

[permalink] [raw]
Subject: Re: [PATCH -next] fs/ntfs: fix set but not used variable 'log_page_mask'

Hi Andrew,

Can you please apply this?

Thanks a lot in advance!

Hi Zheng,

Thank you for the patch!

Best regards,

Anton

> On 12 Mar 2020, at 04:13, Zheng Zengkai <[email protected]> wrote:
>
> Fixes gcc '-Wunused-but-set-variable' warning:
>
> fs/ntfs/logfile.c: In function ntfs_check_logfile:
> fs/ntfs/logfile.c:481:21:
> warning: variable log_page_mask set but not used [-Wunused-but-set-variable]
>
> Actually log_page_mask can be used to replace 'log_page_size - 1' as it is set.
>
> Signed-off-by: Zheng Zengkai <[email protected]>
> Acked-by: Anton Altaparmakov <[email protected]>
> ---
> fs/ntfs/logfile.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ntfs/logfile.c b/fs/ntfs/logfile.c
> index a0c40f1be7ac..c35fcf389369 100644
> --- a/fs/ntfs/logfile.c
> +++ b/fs/ntfs/logfile.c
> @@ -507,7 +507,7 @@ bool ntfs_check_logfile(struct inode *log_vi, RESTART_PAGE_HEADER **rp)
> * optimize log_page_size and log_page_bits into constants.
> */
> log_page_bits = ntfs_ffs(log_page_size) - 1;
> - size &= ~(s64)(log_page_size - 1);
> + size &= ~(s64)(log_page_mask);
> /*
> * Ensure the log file is big enough to store at least the two restart
> * pages and the minimum number of log record pages.
> --
> 2.20.1
>


--
Anton Altaparmakov <anton at tuxera.com> (replace at with @)
Lead in File System Development, Tuxera Inc., http://www.tuxera.com/
Linux NTFS maintainer

2020-12-10 02:55:13

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH -next] fs/ntfs: fix set but not used variable 'log_page_mask'

On Tue, 8 Dec 2020 08:24:02 +0000 Anton Altaparmakov <[email protected]> wrote:

> Can you please apply this?
>
> ...
>
> > --- a/fs/ntfs/logfile.c
> > +++ b/fs/ntfs/logfile.c
> > @@ -507,7 +507,7 @@ bool ntfs_check_logfile(struct inode *log_vi, RESTART_PAGE_HEADER **rp)
> > * optimize log_page_size and log_page_bits into constants.
> > */
> > log_page_bits = ntfs_ffs(log_page_size) - 1;
> > - size &= ~(s64)(log_page_size - 1);
> > + size &= ~(s64)(log_page_mask);
> > /*
> > * Ensure the log file is big enough to store at least the two restart
> > * pages and the minimum number of log record pages.

https://lore.kernel.org/lkml/[email protected]/
addressed this?

2020-12-10 02:59:37

by Anton Altaparmakov

[permalink] [raw]
Subject: Re: [PATCH -next] fs/ntfs: fix set but not used variable 'log_page_mask'

Hi Andrew,

Ah, oops! Thank you and apologies. Quite right the alternative patch was even better. No need to apply this patch after all...

Zheng, the log_page_mask variable was removed altogether so your patch no longer makes sense.

Best regards,

Anton

> On 10 Dec 2020, at 02:36, Andrew Morton <[email protected]> wrote:
>
> On Tue, 8 Dec 2020 08:24:02 +0000 Anton Altaparmakov <[email protected]> wrote:
>
>> Can you please apply this?
>>
>> ...
>>
>>> --- a/fs/ntfs/logfile.c
>>> +++ b/fs/ntfs/logfile.c
>>> @@ -507,7 +507,7 @@ bool ntfs_check_logfile(struct inode *log_vi, RESTART_PAGE_HEADER **rp)
>>> * optimize log_page_size and log_page_bits into constants.
>>> */
>>> log_page_bits = ntfs_ffs(log_page_size) - 1;
>>> - size &= ~(s64)(log_page_size - 1);
>>> + size &= ~(s64)(log_page_mask);
>>> /*
>>> * Ensure the log file is big enough to store at least the two restart
>>> * pages and the minimum number of log record pages.
>
> https://lore.kernel.org/lkml/[email protected]/
> addressed this?
>


--
Anton Altaparmakov <anton at tuxera.com> (replace at with @)
Lead in File System Development, Tuxera Inc., http://www.tuxera.com/
Linux NTFS maintainer

2020-12-10 07:28:27

by Zheng Zengkai

[permalink] [raw]
Subject: Re: [PATCH -next] fs/ntfs: fix set but not used variable 'log_page_mask'

Hi Anton and Andrew,

> Hi Andrew,
>
> Ah, oops! Thank you and apologies. Quite right the alternative patch was even better. No need to apply this patch after all...
>
> Zheng, the log_page_mask variable was removed altogether so your patch no longer makes sense.
>
> Best regards,
>
> Anton
>
>> On 10 Dec 2020, at 02:36, Andrew Morton <[email protected]> wrote:
>>
>> On Tue, 8 Dec 2020 08:24:02 +0000 Anton Altaparmakov <[email protected]> wrote:
>>
>>> Can you please apply this?
>>>
>>> ...
>>>
>>>> --- a/fs/ntfs/logfile.c
>>>> +++ b/fs/ntfs/logfile.c
>>>> @@ -507,7 +507,7 @@ bool ntfs_check_logfile(struct inode *log_vi, RESTART_PAGE_HEADER **rp)
>>>> * optimize log_page_size and log_page_bits into constants.
>>>> */
>>>> log_page_bits = ntfs_ffs(log_page_size) - 1;
>>>> - size &= ~(s64)(log_page_size - 1);
>>>> + size &= ~(s64)(log_page_mask);
>>>> /*
>>>> * Ensure the log file is big enough to store at least the two restart
>>>> * pages and the minimum number of log record pages.
>> https://lore.kernel.org/lkml/[email protected]/
>> addressed this?
>>
It's ok, thank you all the same!