Bug 2767

Summary: Missing includes in bsd-err.c
Product: Portable OpenSSH Reporter: Colin Watson <cjwatson>
Component: MiscellaneousAssignee: Assigned to nobody <unassigned-bugs>
Status: CLOSED FIXED    
Severity: normal CC: dtucker
Priority: P5    
Version: -current   
Hardware: Other   
OS: Linux   
Bug Depends on:    
Bug Blocks: 2698    
Attachments:
Description Flags
Add missing includes to openbsd-compat/bsd-err.c none

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.