Re: [PATCH] static analysis support for posix file desccriptor APIs

2022-06-24 Thread David Malcolm via Gcc
On Thu, 2022-06-23 at 23:58 +0530, Mir Immad wrote: >  Hi Dave, > Thanks for the suggestions, > > I changed most of the things that you suggested, however reporting > for > warnings like close of known invalid fd was problematic: > > consider the following code: > > if (fd >= 0) > { write (fd,..

Re: [PATCH] static analysis support for posix file desccriptor APIs

2022-06-23 Thread Mir Immad via Gcc
Hi Dave, Thanks for the suggestions, I changed most of the things that you suggested, however reporting for warnings like close of known invalid fd was problematic: consider the following code: if (fd >= 0) { write (fd,...); } close(fd); As I was checking the exploded graph for this; the "clos

Re: [PATCH] static analysis support for posix file desccriptor APIs

2022-06-21 Thread Joseph Myers
On Tue, 21 Jun 2022, David Malcolm via Gcc wrote: > Joseph: is the target hook the way to go with this? Would it look > something like: > > DEFHOOK (fd_access_mode, "FIXME", int (int)) > > taking the build configuration's O_ access mode, and returning the > target configurations's access mode (

Re: [PATCH] static analysis support for posix file desccriptor APIs

2022-06-21 Thread David Malcolm via Gcc
On Tue, 2022-06-21 at 18:50 +, Joseph Myers wrote: > On Tue, 21 Jun 2022, David Malcolm via Gcc wrote: > > > So ultimately that's something we want to fix, though exactly how, > > I'm > > not quite sure; we presumably want to look up the target's > > definitions > > of those macros - but I don

Re: [PATCH] static analysis support for posix file desccriptor APIs

2022-06-21 Thread Joseph Myers
On Tue, 21 Jun 2022, David Malcolm via Gcc wrote: > So ultimately that's something we want to fix, though exactly how, I'm > not quite sure; we presumably want to look up the target's definitions > of those macros - but I don't think the analyzer has access to the > cpp_reader instance from the fr

Re: [PATCH] static analysis support for posix file desccriptor APIs

2022-06-21 Thread David Malcolm via Gcc
Hi Immad, thanks for this patch. Overall, looks like you're making good progress. Various notes and nitpicks inline below, throughout... On Tue, 2022-06-21 at 22:00 +0530, Mir Immad wrote: [...snip...] > > diff --git a/gcc/analyzer/analyzer.opt b/gcc/analyzer/analyzer.opt > index 23dfc797cea.

Re: [PATCH] static analysis support for posix file desccriptor APIs

2022-06-21 Thread Mir Immad via Gcc
This is a patch for extending static analysis support for posix file descriptor APIs which is a part of my GSoC project. I've written a few testcases, which are all passing. There are a few TODOs like adding the copyright header and adding docs to gcc/doc/invoke.texi. I'm looking for suggestions

[PATCH] static analysis support for posix file desccriptor APIs

2022-06-21 Thread Mir Immad via Gcc
diff --git a/gcc/Makefile.in b/gcc/Makefile.in index b6dcc45a58a..04631f737ea 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -1269,6 +1269,7 @@ ANALYZER_OBJS = \ analyzer/region-model-reachability.o \ analyzer/sm.o \ analyzer/sm-file.o \ + analyzer/sm-fd.o \ analyzer/sm-malloc.o \