public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
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: Wed, 20 Jul 2022 14:23:57 -0400	[thread overview]
Message-ID: <a3993f85d20a75a5c222b94cc5865c6661a361aa.camel@redhat.com> (raw)
In-Reply-To: <CY4PR1801MB1910A13D9AB9CA3A02B4FE5AC68E9@CY4PR1801MB1910.namprd18.prod.outlook.com>

On Wed, 2022-07-20 at 23:29 +0530, Immad Mir wrote:


> This patch adds three new function attributes to GCC that
> are used for static analysis of usage of file descriptors:

Thanks for the updated patch.

Some very minor spelling/grammar/whitespace nits...

> 
> 1) __attribute__ ((fd_arg(N))): The attributes may be applied to a function that
> takes on open file descriptor at refrenced argument N.

"on open" -> "an open"

"refrenced" -> "referenced"

[...snip...]

> diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
> index d5ff1018372..9234275ca6d 100644
> --- a/gcc/doc/invoke.texi
> +++ b/gcc/doc/invoke.texi
> @@ -9843,7 +9843,12 @@ This warning requires @option{-fanalyzer}, which enables it; use
>  to disable it.
>  
>  This diagnostic warns for paths through code in which a 
> -@code{read} on a write-only file descriptor is attempted, or vice versa
> +@code{read} on a write-only file descriptor is attempted, or vice versa.
> +
> +This diagnostic also warns for code paths in a which a function with attribute
> +@code{fd_arg_read (N)} is called with a file descriptor opened with @code{O_WRONLY} 
> +at refrenced argument @code{N} or a function with attribute @code{fd_arg_write (N)}

"refrenced" -> "referenced"

> +is called with a file descriptor opened with @code{O_RDONLY} at refrenced argument @var{N},

"refrenced" -> "referenced".

Please wrap these lines to avoid going over 80 columns.

>  
>  @item -Wno-analyzer-fd-double-close
>  @opindex Wanalyzer-fd-double-close
> @@ -9875,6 +9880,11 @@ to disable it.
>  This diagnostic warns for paths through code in which a 
>  read or write is called on a closed file descriptor.
>  
> +This diagnostic also warns for paths through code in which
> +a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
> +or @code{fd_arg_write (N)} is called with a closed file descriptor at
> +refrenced argument @code{N}.

"refrenced" -> "referenced".


> +
>  @item -Wno-analyzer-fd-use-without-check
>  @opindex Wanalyzer-fd-use-without-check
>  @opindex Wno-analyzer-fd-use-without-check
> @@ -9885,6 +9895,11 @@ to disable it.
>  This diagnostic warns for paths through code in which a 
>  file descriptor is used without being checked for validity.
>  
> +This diagnostic also warns for paths through code in which
> +a function with attribute @code{fd_arg (N)} or @code{fd_arg_read (N)}
> +or @code{fd_arg_write (N)} is called with a file descriptor, at refrenced
> +argument @code{N}, without being checked for validity.

"refrenced" -> "referenced".

> +
>  @item -Wno-analyzer-file-leak
>  @opindex Wanalyzer-file-leak
>  @opindex Wno-analyzer-file-leak

[...snip...]

...but with those fixed, this patch is OK for trunk, assuming it
bootstraps and passes regression tests.

Thanks!
Dave


  reply	other threads:[~2022-07-20 18:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-20 17:59 Immad Mir
2022-07-20 18:23 ` David Malcolm [this message]
2022-07-20 18:28 ` Prathamesh Kulkarni
2022-07-20 18:39   ` Mir Immad
  -- strict thread matches above, loose matches on Subject: below --
2022-07-22 15:55 Immad Mir
2022-07-22 18:27 ` David Malcolm
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=a3993f85d20a75a5c222b94cc5865c6661a361aa.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).