From: David Malcolm <dmalcolm@redhat.com>
To: mirimnan017@gmail.com, gcc-patches@gcc.gnu.org
Cc: Immad Mir <mirimmad@outlook.com>
Subject: Re: [PATCH] Adding three new function attributes for static analysis of file descriptors
Date: Fri, 22 Jul 2022 14:27:39 -0400 [thread overview]
Message-ID: <1f26d57a28c70da7bd2bdec0182816ebdaaede6f.camel@redhat.com> (raw)
In-Reply-To: <CY4PR1801MB1910A6D505E82758738412B5C6909@CY4PR1801MB1910.namprd18.prod.outlook.com>
On Fri, 2022-07-22 at 21:25 +0530, Immad Mir wrote:
> This patch adds three new function attributes to GCC that
> are used for static analysis of usage of file descriptors:
>
> 1) __attribute__ ((fd_arg(N))): The attributes may be applied to a
> function that
> takes an open file descriptor at refrenced argument N.
>
> It indicates that the passed filedescriptor must not have been
> closed.
> Therefore, when the analyzer is enabled with -fanalyzer, the
> analyzer may emit a -Wanalyzer-fd-use-after-close diagnostic
> if it detects a code path in which a function with this attribute is
> called with a closed file descriptor.
>
> The attribute also indicates that the file descriptor must have been
> checked for
> validity before usage. Therefore, analyzer may emit
> -Wanalyzer-fd-use-without-check diagnostic if it detects a code path
> in
> which a function with this attribute is called with a file descriptor
> that has
> not been checked for validity.
>
> 2) __attribute__((fd_arg_read(N))): The attribute is identical to
> fd_arg, but with the additional requirement that it might read from
> the file descriptor, and thus, the file descriptor must not have been
> opened
> as write-only.
>
> The analyzer may emit a -Wanalyzer-access-mode-mismatch
> diagnostic if it detects a code path in which a function with this
> attribute is called on a file descriptor opened with O_WRONLY.
>
> 3) __attribute__((fd_arg_write(N))): The attribute is identical to
> fd_arg_read
> except that the analyzer may emit a -Wanalyzer-access-mode-mismatch
> diagnostic if
> it detects a code path in which a function with this attribute is
> called on a
> file descriptor opened with O_RDONLY.
[...snip...]
Thanks for the updated patch.
This version looks good for trunk. You indicated (in an off-list
email) that you've tested this, so please go ahead and push this.
Thanks
Dave
next prev parent reply other threads:[~2022-07-22 18:27 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-22 15:55 Immad Mir
2022-07-22 18:27 ` David Malcolm [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-07-20 17:59 Immad Mir
2022-07-20 18:23 ` David Malcolm
2022-07-20 18:28 ` Prathamesh Kulkarni
2022-07-20 18:39 ` Mir Immad
2022-07-19 16:06 Immad Mir
2022-07-19 18:18 ` David Malcolm
2022-07-19 20:08 ` David Malcolm
2022-07-15 15:38 Immad Mir
2022-07-15 16:57 ` David Malcolm
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=1f26d57a28c70da7bd2bdec0182816ebdaaede6f.camel@redhat.com \
--to=dmalcolm@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=mirimmad@outlook.com \
--cc=mirimnan017@gmail.com \
/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).