Coccinelle archive mirror
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: cocci@inria.fr
Subject: [cocci] Checking addition of local error code checks
Date: Tue, 2 Jan 2024 19:00:13 +0100	[thread overview]
Message-ID: <913bb6fa-c168-46f7-ba39-5fdaae586b6e@web.de> (raw)

Hello,

I applied the following SmPL script also together with the software
combination “Coccinelle 1.1.1-00628-gd7ca09d1” on a known source file.


@addition@
@@
+{
+int rc =
 fb_alloc_cmap(...);
+if (rc)
+   return rc;
+}


See also:
https://elixir.bootlin.com/linux/v6.7-rc8/source/drivers/video/fbdev/atafb.c#L2988
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/video/fbdev/atafb.c?id=425562be861b46ba8dac78e3927c1cbff5fbb514#n2988


Test result:
Markus_Elfring@Sonne:…/Projekte/Linux/next-analyses> spatch …/Projekte/Coccinelle/janitor/return_error_code_for_fb_alloc_cmap_call_failure.cocci drivers/video/fbdev/atafb.c
…
@@ -3126,7 +3126,11 @@ static int __init atafb_probe(struct pla

        atafb_set_disp(&fb_info);

-       fb_alloc_cmap(&(fb_info.cmap), 1 << fb_info.var.bits_per_pixel, 0);
+       {
+               int rc =fb_alloc_cmap(&(fb_info.cmap), 1 << fb_info.var.bits_per_pixel, 0);
+               if (rc)
+                       return rc;
+       }
…


Such diff output indicates opportunities for pretty-printing improvements.

* Additional space character for variable initialisation

* Line length limit


Regards,
Markus

             reply	other threads:[~2024-01-02 18:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-02 18:00 Markus Elfring [this message]
2024-01-03  9:06 ` [cocci] [RFC] fbdev: Completing error handling for fb_alloc_cmap() calls Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=913bb6fa-c168-46f7-ba39-5fdaae586b6e@web.de \
    --to=markus.elfring@web.de \
    --cc=cocci@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).