[PATCH 2/2] fbdev: Convert a variable initialisation into a later assignment in fb_alloc_cmap_gfp()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 23 May 2023 21:56:55 +0200

* Assign the value “-ENOMEM” to the local variable “ret” only for
  the exception handling.

* Use an additional label.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
 drivers/video/fbdev/core/fbcmap.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/video/fbdev/core/fbcmap.c b/drivers/video/fbdev/core/fbcmap.c
index 5c1075ed28ab..fbe82a64cf73 100644
--- a/drivers/video/fbdev/core/fbcmap.c
+++ b/drivers/video/fbdev/core/fbcmap.c
@@ -91,7 +91,7 @@ static const struct fb_cmap default_16_colors = {

 int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int transp, gfp_t flags)
 {
-	int ret = -ENOMEM;
+	int ret;

 	if (cmap->len != len) {
 		int size;
@@ -104,17 +104,20 @@ int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int transp, gfp_t flags)
 		flags |= __GFP_NOWARN;
 		cmap->red = kzalloc(size, flags);
 		if (!cmap->red)
-			goto fail;
+			goto e_nomem;
+
 		cmap->green = kzalloc(size, flags);
 		if (!cmap->green)
-			goto fail;
+			goto e_nomem;
+
 		cmap->blue = kzalloc(size, flags);
 		if (!cmap->blue)
-			goto fail;
+			goto e_nomem;
+
 		if (transp) {
 			cmap->transp = kzalloc(size, flags);
 			if (!cmap->transp)
-				goto fail;
+				goto e_nomem;
 		} else {
 			cmap->transp = NULL;
 		}
@@ -126,6 +129,8 @@ int fb_alloc_cmap_gfp(struct fb_cmap *cmap, int len, int transp, gfp_t flags)
 		goto fail;
 	return 0;

+e_nomem:
+	ret = -ENOMEM;
 fail:
 	fb_dealloc_cmap(cmap);
 	return ret;
--
2.40.1





[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux