linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cxl: Fix an error message
@ 2021-05-05 19:38 Christophe JAILLET
  2021-05-06  2:29 ` Andrew Donnellan
  2021-05-14 11:43 ` Greg KH
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2021-05-05 19:38 UTC (permalink / raw)
  To: fbarrat, ajd, arnd, gregkh, mpe, imunsie, mikey
  Cc: linuxppc-dev, linux-kernel, kernel-janitors, Christophe JAILLET

'rc' is known to be 0 here.
Initialize 'rc' with the expected error code before using it.

While at it, avoid the affectation of 'rc' in a 'if' to make things more
obvious and linux style.

Fixes: f204e0b8ce ("cxl: Driver code for powernv PCIe based cards for userspace access")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/misc/cxl/file.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/cxl/file.c b/drivers/misc/cxl/file.c
index bd3bd32333c5..3dbdce96fae0 100644
--- a/drivers/misc/cxl/file.c
+++ b/drivers/misc/cxl/file.c
@@ -569,7 +569,8 @@ static int cxl_add_chardev(struct cxl_afu *afu, dev_t devt, struct cdev *cdev,
 	int rc;
 
 	cdev_init(cdev, fops);
-	if ((rc = cdev_add(cdev, devt, 1))) {
+	rc = cdev_add(cdev, devt, 1);
+	if (rc) {
 		dev_err(&afu->dev, "Unable to add %s chardev: %i\n", desc, rc);
 		return rc;
 	}
@@ -577,8 +578,8 @@ static int cxl_add_chardev(struct cxl_afu *afu, dev_t devt, struct cdev *cdev,
 	dev = device_create(cxl_class, &afu->dev, devt, afu,
 			"afu%i.%i%s", afu->adapter->adapter_num, afu->slice, postfix);
 	if (IS_ERR(dev)) {
-		dev_err(&afu->dev, "Unable to create %s chardev in sysfs: %i\n", desc, rc);
 		rc = PTR_ERR(dev);
+		dev_err(&afu->dev, "Unable to create %s chardev in sysfs: %i\n", desc, rc);
 		goto err;
 	}
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] cxl: Fix an error message
  2021-05-05 19:38 [PATCH] cxl: Fix an error message Christophe JAILLET
@ 2021-05-06  2:29 ` Andrew Donnellan
  2021-05-14 11:43 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Donnellan @ 2021-05-06  2:29 UTC (permalink / raw)
  To: Christophe JAILLET, fbarrat, arnd, gregkh, mpe, imunsie, mikey
  Cc: linuxppc-dev, linux-kernel, kernel-janitors

On 6/5/21 5:38 am, Christophe JAILLET wrote:
> 'rc' is known to be 0 here.
> Initialize 'rc' with the expected error code before using it.

I would prefer:

"In cxl_add_chardev(), if the call to device_create() fails, we print 
the error message before 'rc' is set correctly, and therefore always 
print 0. Move the error message after setting 'rc'."

> 
> While at it, avoid the affectation of 'rc' in a 'if' to make things more
> obvious and linux style.

I strongly agree with this, some of the other cxl developers don't but 
they are wrong :)

> 
> Fixes: f204e0b8ce ("cxl: Driver code for powernv PCIe based cards for userspace access")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Apart from my comment above:

Acked-by: Andrew Donnellan <ajd@linux.ibm.com>

Thanks for catching this!

-- 
Andrew Donnellan              OzLabs, ADL Canberra
ajd@linux.ibm.com             IBM Australia Limited

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] cxl: Fix an error message
  2021-05-05 19:38 [PATCH] cxl: Fix an error message Christophe JAILLET
  2021-05-06  2:29 ` Andrew Donnellan
@ 2021-05-14 11:43 ` Greg KH
  1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2021-05-14 11:43 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: fbarrat, ajd, arnd, mpe, imunsie, mikey, linuxppc-dev,
	linux-kernel, kernel-janitors

On Wed, May 05, 2021 at 09:38:49PM +0200, Christophe JAILLET wrote:
> 'rc' is known to be 0 here.
> Initialize 'rc' with the expected error code before using it.
> 
> While at it, avoid the affectation of 'rc' in a 'if' to make things more
> obvious and linux style.
> 
> Fixes: f204e0b8ce ("cxl: Driver code for powernv PCIe based cards for userspace access")

You need a full 12 digits for the SHA1, otherwise our scripts complain
about it :(

I'll fix it up here, but please fix your tools.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-05-14 11:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-05 19:38 [PATCH] cxl: Fix an error message Christophe JAILLET
2021-05-06  2:29 ` Andrew Donnellan
2021-05-14 11:43 ` Greg KH

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).