Bug 2767 - Missing includes in bsd-err.c
Summary: Missing includes in bsd-err.c
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Miscellaneous (show other bugs)
Version: -current
Hardware: Other Linux
: P5 normal
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks: V_7_6
  Show dependency treegraph
 
Reported: 2017-08-26 21:19 AEST by Colin Watson
Modified: 2018-04-06 12:26 AEST (History)
1 user (show)

See Also:


Attachments
Add missing includes to openbsd-compat/bsd-err.c (672 bytes, patch)
2017-08-26 21:19 AEST, Colin Watson
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Colin Watson 2017-08-26 21:19:58 AEST
Created attachment 3040 [details]
Add missing includes to openbsd-compat/bsd-err.c

gcc -g -O2 -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-unused-result -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -ftrapv -fno-builtin-memset -fstack-protector-strong -fPIE  -I. -I.. -I. -I./..  -DHAVE_CONFIG_H -c bsd-err.c
bsd-err.c: In function ‘err’:
bsd-err.c:37:26: warning: implicit declaration of function ‘strerror’; did you mean ‘hstrerror’? [-Wimplicit-function-declaration]
  fprintf(stderr, "%s: ", strerror(errno));
                          ^~~~~~~~
                          hstrerror
bsd-err.c:37:20: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, "%s: ", strerror(errno));
                   ~^     ~~~~~~~~~~~~~~~
                   %d
bsd-err.c: In function ‘warn’:
bsd-err.c:66:20: warning: format ‘%s’ expects argument of type ‘char *’, but argument 3 has type ‘int’ [-Wformat=]
  fprintf(stderr, "%s: ", strerror(errno));
                   ~^     ~~~~~~~~~~~~~~~
                   %d

I went through and added all the missing #includes in the attached patch.  Some duplicate "includes.h", but it seems to be reasonably common practice in OpenSSH to add direct #includes for symbols that are used directly.
Comment 1 Darren Tucker 2017-08-27 08:58:41 AEST
(In reply to Colin Watson from comment #0)
> Created attachment 3040 [details]
> Add missing includes to openbsd-compat/bsd-err.c

Applied, thanks.

> I went through and added all the missing #includes in the attached
> patch.  Some duplicate "includes.h", but it seems to be reasonably
> common practice in OpenSSH to add direct #includes for symbols that
> are used directly.

Current policy is to include system headers in the .c file where they're needed however some of the compat code either needs it earlier, was added prior to the policy or both.
Comment 2 Damien Miller 2018-04-06 12:26:53 AEST
Close all resolved bugs after release of OpenSSH 7.7.