diff mbox series

declare getpass in analyzer/sensitive-1.c test

Message ID orwnx6l82u.fsf@lxoliva.fsfla.org
State New
Headers show
Series declare getpass in analyzer/sensitive-1.c test | expand

Commit Message

Alexandre Oliva Dec. 25, 2020, 6:21 a.m. UTC
The getpass function is not available on all systems; and not
necessarily declared in unistd.h, as expected by the sensitive-1
analyzer test.

Since this is a compile-only test, it doesn't really matter if the
function is defined in the system libraries.  All we need is a
declaration, to avoid warnings from calling an undeclared function.
This patch adds the declaration, in a way that is most unlikely to
conflict with any existing declaration.

Regstrapped on x86_64-linux-gnu, also tested on arm-vxworks7r2.
Ok to install?


for  gcc/testsuite/ChangeLog

	* gcc.dg/analyzer/sensitive-1.c: Declare getpass.
---
 gcc/testsuite/gcc.dg/analyzer/sensitive-1.c |    5 +++++
 1 file changed, 5 insertions(+)

Comments

Alexandre Oliva Jan. 13, 2021, 5:35 p.m. UTC | #1
Hello, David,

Long time no see!  I hope you've had a good time during the holidays.

I'd appreciate your review of this and a couple of other analyzer
testsuite patches we've submitted in the past few weeks.

> 	* gcc.dg/analyzer/sensitive-1.c: Declare getpass.

https://gcc.gnu.org/pipermail/gcc-patches/2020-December/562493.html
https://gcc.gnu.org/pipermail/gcc-patches/2020-December/562494.html
https://gcc.gnu.org/pipermail/gcc-patches/2020-December/562266.html

Thanks in advance,
David Malcolm Jan. 13, 2021, 9:48 p.m. UTC | #2
On Fri, 2020-12-25 at 03:21 -0300, Alexandre Oliva wrote:
> The getpass function is not available on all systems; and not
> necessarily declared in unistd.h, as expected by the sensitive-1
> analyzer test.
> 
> Since this is a compile-only test, it doesn't really matter if the
> function is defined in the system libraries.  All we need is a
> declaration, to avoid warnings from calling an undeclared function.
> This patch adds the declaration, in a way that is most unlikely to
> conflict with any existing declaration.
> 
> Regstrapped on x86_64-linux-gnu, also tested on arm-vxworks7r2.
> Ok to install?

The patch looks good to me.  Technically I'm not a reviewer for the
analyzer, but I think you can go ahead under the "obvious" rule.

Thanks
Dave
diff mbox series

Patch

diff --git a/gcc/testsuite/gcc.dg/analyzer/sensitive-1.c b/gcc/testsuite/gcc.dg/analyzer/sensitive-1.c
index 81144af620edf..c66af9276174f 100644
--- a/gcc/testsuite/gcc.dg/analyzer/sensitive-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/sensitive-1.c
@@ -6,6 +6,11 @@ 
 
 #include <string.h>
 
+/* Declare getpass, in case unistd doesn't declare it.
+   Parenthesize it, in case it's a macro.
+   Don't use a prototype, to avoid const mismatches.  */
+extern char *(getpass) ();
+
 char test_1 (FILE *logfile)
 {
   char *password = getpass (">"); /* { dg-message "\\(1\\) sensitive value acquired here" } */