* [PATCH] dax: use correct dev_t value
@ 2016-09-08 13:53 Arnd Bergmann
2016-09-08 14:56 ` Dan Williams
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2016-09-08 13:53 UTC (permalink / raw)
To: Dan Williams; +Cc: Arnd Bergmann, Johannes Thumshirn, linux-kernel
The dev_t variable in devm_create_dax_dev() is used before it's
first set:
drivers/dax/dax.c: In function 'devm_create_dax_dev':
drivers/dax/dax.c:205:39: error: 'dev_t' may be used uninitialized in this function [-Werror=maybe-uninitialized]
inode = iget5_locked(dax_superblock, hash_32(devt + DAXFS_MAGIC, 31),
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/dax/dax.c:688:8: note: 'dev_t' was declared here
This reorders the code to how it looks correct to me.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 3bc52c45bac2 ("dax: define a unified inode/address_space for device-dax mappings")
---
drivers/dax/dax.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c
index 68bb5e35b639..98dbbc12055f 100644
--- a/drivers/dax/dax.c
+++ b/drivers/dax/dax.c
@@ -731,6 +731,8 @@ struct dax_dev *devm_create_dax_dev(struct dax_region *dax_region,
goto err_minor;
}
+ dev_t = MKDEV(MAJOR(dax_devt), minor);
+ dev = &dax_dev->dev;
dax_dev->inode = dax_inode_get(&dax_dev->cdev, dev_t);
if (!dax_dev->inode) {
rc = -ENOMEM;
@@ -738,8 +740,6 @@ struct dax_dev *devm_create_dax_dev(struct dax_region *dax_region,
}
/* device_initialize() so cdev can reference kobj parent */
- dev_t = MKDEV(MAJOR(dax_devt), minor);
- dev = &dax_dev->dev;
device_initialize(dev);
cdev = &dax_dev->cdev;
--
2.9.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] dax: use correct dev_t value
2016-09-08 13:53 [PATCH] dax: use correct dev_t value Arnd Bergmann
@ 2016-09-08 14:56 ` Dan Williams
2016-09-08 15:03 ` Arnd Bergmann
0 siblings, 1 reply; 3+ messages in thread
From: Dan Williams @ 2016-09-08 14:56 UTC (permalink / raw)
To: Arnd Bergmann; +Cc: Johannes Thumshirn, linux-kernel, kbuild test robot
[ adding 0day robot ]
On Thu, Sep 8, 2016 at 6:53 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> The dev_t variable in devm_create_dax_dev() is used before it's
> first set:
>
> drivers/dax/dax.c: In function 'devm_create_dax_dev':
> drivers/dax/dax.c:205:39: error: 'dev_t' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> inode = iget5_locked(dax_superblock, hash_32(devt + DAXFS_MAGIC, 31),
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> drivers/dax/dax.c:688:8: note: 'dev_t' was declared here
>
> This reorders the code to how it looks correct to me.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 3bc52c45bac2 ("dax: define a unified inode/address_space for device-dax mappings")
> ---
> drivers/dax/dax.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/dax/dax.c b/drivers/dax/dax.c
> index 68bb5e35b639..98dbbc12055f 100644
> --- a/drivers/dax/dax.c
> +++ b/drivers/dax/dax.c
> @@ -731,6 +731,8 @@ struct dax_dev *devm_create_dax_dev(struct dax_region *dax_region,
> goto err_minor;
> }
>
> + dev_t = MKDEV(MAJOR(dax_devt), minor);
> + dev = &dax_dev->dev;
> dax_dev->inode = dax_inode_get(&dax_dev->cdev, dev_t);
> if (!dax_dev->inode) {
> rc = -ENOMEM;
> @@ -738,8 +740,6 @@ struct dax_dev *devm_create_dax_dev(struct dax_region *dax_region,
> }
>
> /* device_initialize() so cdev can reference kobj parent */
> - dev_t = MKDEV(MAJOR(dax_devt), minor);
> - dev = &dax_dev->dev;
> device_initialize(dev);
>
> cdev = &dax_dev->cdev;
Looks good to me.
Strange, I don't see this error with gcc-5.3.1, I assume 0day missed
it for a similar reason?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] dax: use correct dev_t value
2016-09-08 14:56 ` Dan Williams
@ 2016-09-08 15:03 ` Arnd Bergmann
0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2016-09-08 15:03 UTC (permalink / raw)
To: Dan Williams; +Cc: Johannes Thumshirn, linux-kernel, kbuild test robot
On Thursday, September 8, 2016 7:56:31 AM CEST Dan Williams wrote:
> On Thu, Sep 8, 2016 at 6:53 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> > The dev_t variable in devm_create_dax_dev() is used before it's
> > first set:
> >
> > drivers/dax/dax.c: In function 'devm_create_dax_dev':
> > drivers/dax/dax.c:205:39: error: 'dev_t' may be used uninitialized in this function [-Werror=maybe-uninitialized]
> > inode = iget5_locked(dax_superblock, hash_32(devt + DAXFS_MAGIC, 31),
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > drivers/dax/dax.c:688:8: note: 'dev_t' was declared here
> >
> > This reorders the code to how it looks correct to me.
> >
>
> Looks good to me.
>
> Strange, I don't see this error with gcc-5.3.1, I assume 0day missed
> it for a similar reason?
No, the warning is disabled by now since 6e8d666e9253 ("Disable
"maybe-uninitialized" warning globally"), which I have reverted
locally.
You can also build with -Wmaybe-uninitialized, but that causes
many false positives if any of these options are enabled:
CONFIG_CC_OPTIMIZE_FOR_SIZE
CONFIG_PROFILE_ALL_BRANCHES
CONFIG_UBSAN_SANITIZE_ALL
CONFIG_GCOV_PROFILE_ALL
I'm still trying to come up with a way to get the warning to
be useful again without annoying Linus too much.
Arnd
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-08 15:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-08 13:53 [PATCH] dax: use correct dev_t value Arnd Bergmann
2016-09-08 14:56 ` Dan Williams
2016-09-08 15:03 ` Arnd Bergmann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).