Bug#1066694: netdiag: FTBFS: getservent.c:121:38: error: implicit declaration of function ‘atoi’ [-Werror=implicit-function-declaration]

2024-04-10 Thread Zixing Liu
Package: netdiag
Followup-For: Bug #1066694
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu noble ubuntu-patch
Control: tags -1 patch

Dear Maintainer,

In Ubuntu, the attached patch was applied to achieve the following:

  * debian/patches/gcc13.patch: Add multiple missing headers and
function prototypes.  Closes LP: #2060901.


Thanks for considering the patch.


-- System Information:
Debian Release: bookworm/sid
  APT prefers jammy-updates
  APT policy: (500, 'jammy-updates'), (500, 'jammy-security'), (500, 'jammy'), 
(100, 'jammy-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.5.0-26-generic (SMP w/10 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_CA:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff -u netdiag-1.2/debian/patches/series netdiag-1.2/debian/patches/series
--- netdiag-1.2/debian/patches/series
+++ netdiag-1.2/debian/patches/series
@@ -9,3 +9,4 @@
 gcc-10.diff
 pcap_init.diff
 gcc12.patch
+gcc13.patch
only in patch2:
unchanged:
--- netdiag-1.2.orig/debian/patches/gcc13.patch
+++ netdiag-1.2/debian/patches/gcc13.patch
@@ -0,0 +1,106 @@
+Description: Add multiple missing headers and function prototypes
+Author: Zixing Liu 
+Bug: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1066694
+Bug-Ubuntu: https://bugs.launchpad.net/debian/+source/netdiag/+bug/2060901
+Forwarded: no
+Last-Update: 2024-04-10
+Index: netdiag/netwatch-1.3.1-2/netwatch.h
+===
+--- netdiag.orig/netwatch-1.3.1-2/netwatch.h
 netdiag/netwatch-1.3.1-2/netwatch.h
+@@ -38,6 +38,10 @@
+ #define SN_PROT_LOOP  164 /* Pseudo protocol for Loopback */
+ 
+ #include 
++#include 
++#include 
++#include 
++#include 
+ #include "config.h"
+ /*
+ #ifdef NETINET_SUPP_socket
+@@ -84,6 +88,11 @@ typedef unsigned short  sa_family_t;
+ 
+ 
+ #include "core.h"
++int dokeyin(int force);
++int doeth();
++int gh (int opt);
++void setuphelp();
++void uthread_wait(long usec);
+ void dispdata(int errnum);
+ void services();
+ void usage(char *arg);
+Index: netdiag/statnet-3.8/statnet.c
+===
+--- netdiag.orig/statnet-3.8/statnet.c
 netdiag/statnet-3.8/statnet.c
+@@ -7,7 +7,6 @@
+ #define MAIN_LINE 1
+ 
+ #include 
+-#include "stat.h"
+ 
+ #include "curs.h"
+ #include 
+@@ -33,6 +32,8 @@
+ #endif
+ 
+ #include 
++#include 
++#include "stat.h"
+ 
+ #define Stringify(X)  #X
+ #define Quoteify(X)   Stringify(X)
+Index: netdiag/statnet-3.8/getservent.c
+===
+--- netdiag.orig/statnet-3.8/getservent.c
 netdiag/statnet-3.8/getservent.c
+@@ -43,7 +43,7 @@ static char sccsid[] = "@(#)getservent.c
+ #endif /* LIBC_SCCS and not lint */
+ 
+ #include "inetprivate.h"
+-
++#include 
+ #define   MAXALIASES  35
+ 
+ static char SERVDB[] = _PATH_SERVICES;
+Index: netdiag/statnet-3.8/itstime.c
+===
+--- netdiag.orig/statnet-3.8/itstime.c
 netdiag/statnet-3.8/itstime.c
+@@ -8,7 +8,7 @@
+ #include "stat.h"
+ #include 
+ #include 
+-
++#include 
+ extern struct StatMemStruct *StatMem; /* pointer to shared memory segment */
+ 
+ void itstime (int errnum)
+Index: netdiag/statnet-3.8/stat.h
+===
+--- netdiag.orig/statnet-3.8/stat.h
 netdiag/statnet-3.8/stat.h
+@@ -197,7 +197,7 @@ void set_null ( struct StatMemStruct *St
+ void services ();
+ void stat_delta ( struct StatMemStruct *New, struct StatMemStruct *Prev, 
struct StatMemStruct *Delta );
+ void usage (char *arg);
+-#ifdef WINDOW
++#if CURSES_H
+ void win_show_stat( WINDOW *win, int X, int Y, int noframes, struct Tally 
*Now_ts, struct Tally *Prev_ts, struct Tally *Delta_ts, short rewrite_labels, 
short *update_labels, void *show_labels );
+ #endif
+ 
+@@ -226,10 +226,10 @@ void tally_ntoh ( int bytecode,
+ struct Tally *New_t, 
+ struct Tally *Prev_t );
+ 
+-#ifdef WINDOW
++#if CURSES_H
+ void tally_label ( struct Tally *Now_ts, WINDOW *win, int width, int height );
+ #endif
+-
++int tally (int type_wanted, struct Tally *tally);
+ 
+ /* Now some redefinitions of  stuff.  With the Berkeley notice... */
+ 


Bug#1066694: netdiag: FTBFS: getservent.c:121:38: error: implicit declaration of function ‘atoi’ [-Werror=implicit-function-declaration]

2024-03-23 Thread Micha Lenk

Dear maintainer of netdiag,

I tried to fix the build failures introduced by the recently by-default 
enabled compile flag -Werror=implicit-function-declaration.


All build errors inside the statnet sub project could be fixed by the 
attached patch statnet_fix_implicit_function_declarations.patch, 
including the implicit declaration of function `atoi`.


Unfortunately the build fails in the netwatch sub project too. Initial 
attempts to fix that can be found in the attached patch 
netwatch_fix_implicit_declarations.patch. However, for the implicitly 
declared function `uthread_wait` I have no clue what it refers to. So, I 
am stuck with the following build failure now:


make[1]: Entering directory 
'/home/micha/src/netdiag/pkg.git/netwatch-1.3.1-2'
x86_64-linux-gnu-gcc -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 
-Werror=implicit-function-declaration 
-ffile-prefix-map=/home/micha/src/netdiag/pkg.git/netwatch-1.3.1-2=. 
-fstack-protector-strong -fstack-clash-protection -Wformat 
-Werror=format-security -fcf-protection -ggdb -O0 -Wl,-z,relro 
-Wl,-z,now -c  dispdata.c

dispdata.c: In function 'dispdata':
dispdata.c:740:7: error: implicit declaration of function 
'uthread_wait'; did you mean 'pthread_exit'? 
[-Werror=implicit-function-declaration]

  740 |   uthread_wait(1000);
  |   ^~~~
  |   pthread_exit
dispdata.c:1357:48: warning: '%s' directive writing up to 511 bytes into 
a region of size 509 [-Wformat-overflow=]

 1357 | sprintf (_lines[3][3], "%s", ttt);
  |^~   ~~~
dispdata.c:1357:17: note: 'sprintf' output between 1 and 512 bytes into 
a destination of size 509

 1357 | sprintf (_lines[3][3], "%s", ttt);
  | ^~~~
cc1: some warnings being treated as errors
make[1]: *** [Makefile:40: dispdata.o] Error 1
make[1]: Leaving directory 
'/home/micha/src/netdiag/pkg.git/netwatch-1.3.1-2'

make: *** [debian/rules:36: build-stamp] Error 2
dpkg-buildpackage: error: debian/rules build subprocess returned exit 
status 2



A solution could be to selectively disable the 
-Werror=implicit-function-declaration option again, but having seen this 
error I don't feel comfortable moving forward in that direction.


I'll stop here, sharing the changes for how far I got already in the 
hope it is useful to any more skilled or more patient developer.


Kind regards,
MichaAuthor: Micha Lenk 

diff --git a/statnet-3.8/getservent.c b/statnet-3.8/getservent.c
index 1ee6e5e..d99874b 100644
--- a/statnet-3.8/getservent.c
+++ b/statnet-3.8/getservent.c
@@ -42,6 +42,8 @@
 static char sccsid[] = "@(#)getservent.c	8.1 (Berkeley) 6/4/93";
 #endif /* LIBC_SCCS and not lint */
 
+#include 
+
 #include "inetprivate.h"
 
 #define	MAXALIASES	35
diff --git a/statnet-3.8/itstime.c b/statnet-3.8/itstime.c
index 9cace01..ca8ecd5 100644
--- a/statnet-3.8/itstime.c
+++ b/statnet-3.8/itstime.c
@@ -8,6 +8,7 @@
 #include "stat.h"
 #include 
 #include 
+#include 
 
 extern struct StatMemStruct *StatMem;	/* pointer to shared memory segment */
 
diff --git a/statnet-3.8/stat.h b/statnet-3.8/stat.h
index 6686048..19bd2f7 100644
--- a/statnet-3.8/stat.h
+++ b/statnet-3.8/stat.h
@@ -40,6 +40,7 @@
 #define SN_PROT_PPP		163	/* Pseudo protocol for PPP */
 #define SN_PROT_LOOP		164	/* Pseudo protocol for Loopback */
 
+#include 
 #include 
 #include 
 
@@ -197,9 +198,7 @@ void set_null ( struct StatMemStruct *StatMem );
 void services ();
 void stat_delta ( struct StatMemStruct *New, struct StatMemStruct *Prev, struct StatMemStruct *Delta );
 void usage (char *arg);
-#ifdef WINDOW
-void win_show_stat( WINDOW *win, int X, int Y, int noframes, struct Tally *Now_ts, struct Tally *Prev_ts, struct Tally *Delta_ts, short rewrite_labels, short *update_labels, void *show_labels );
-#endif
+void win_show_stat( WINDOW *win, int X, int Y, int noframes, struct Tally *Now_ts, struct Tally *Prev_ts, struct Tally *Delta_ts, short rewrite_labels, short *update_labels, void *show_labels() );
 
 void tally_delta ( struct Tally *New_t, 
 	struct Tally *Prev_t, 
@@ -226,10 +225,9 @@ void tally_ntoh ( int bytecode,
 struct Tally *New_t, 
 struct Tally *Prev_t );
 
-#ifdef WINDOW
 void tally_label ( struct Tally *Now_ts, WINDOW *win, int width, int height );
-#endif
 
+int tally (int type_wanted, struct Tally *tally);
 
 /* Now some redefinitions of  stuff.  With the Berkeley notice... */
 
diff --git a/statnet-3.8/win_show_stat.c b/statnet-3.8/win_show_stat.c
index b7981b5..041a23c 100644
--- a/statnet-3.8/win_show_stat.c
+++ b/statnet-3.8/win_show_stat.c
@@ -4,6 +4,7 @@
 /* 05FEB98: Scot E. Wilcoxon (sewi...@fieldday.mn.org)  */
 
 #include 
+#include 
 #include "stat.h"
 #include "curs.h"
 
Author: Micha Lenk 

diff --git a/netwatch-1.3.1-2/netwatch.h b/netwatch-1.3.1-2/netwatch.h
index c2fd4b7..7d46b3a 100644
--- a/netwatch-1.3.1-2/netwatch.h
+++ b/netwatch-1.3.1-2/netwatch.h
@@ -214,10 

Bug#1066694: netdiag: FTBFS: getservent.c:121:38: error: implicit declaration of function ‘atoi’ [-Werror=implicit-function-declaration]

2024-03-13 Thread Lucas Nussbaum
Source: netdiag
Version: 1.2-1.2
Severity: serious
Justification: FTBFS
Tags: trixie sid ftbfs
User: lu...@debian.org
Usertags: ftbfs-20240313 ftbfs-trixie ftbfs-impfuncdef

Hi,

During a rebuild of all packages in sid, your package failed to build
on amd64.

This is most likely caused by a change in dpkg 1.22.6, that enabled
-Werror=implicit-function-declaration. For more information, see
https://wiki.debian.org/qa.debian.org/FTBFS#A2024-03-13_-Werror.3Dimplicit-function-declaration

Relevant part (hopefully):
> gcc -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 
> -Werror=implicit-function-declaration -ffile-prefix-map=/<>=. 
> -fstack-protector-strong -fstack-clash-protection -Wformat 
> -Werror=format-security -fcf-protection -Wl,-z,relro -Wl,-z,now 
> -I/usr/include/ncurses -g -DSNVERSION=3.8 -Wdate-time -D_FORTIFY_SOURCE=2  -c 
> -o win_show_stat.o win_show_stat.c
> tally_label.c:13:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
>13 | tally_label ( struct Tally *Now_ts, WINDOW *win, int width, int 
> height )
>   | ^~~
> In file included from /usr/include/netdb.h:27,
>  from inetprivate.h:13,
>  from getservent.c:45:
> getservent.c: In function ‘sn_getservent’:
> getservent.c:121:38: error: implicit declaration of function ‘atoi’ 
> [-Werror=implicit-function-declaration]
>   121 | serv.s_port = htons((u_short)atoi(p));
>   |  ^~~~
> gcc -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 
> -Werror=implicit-function-declaration -ffile-prefix-map=/<>=. 
> -fstack-protector-strong -fstack-clash-protection -Wformat 
> -Werror=format-security -fcf-protection -Wl,-z,relro -Wl,-z,now 
> -I/usr/include/ncurses -g -DSNVERSION=3.8 -Wdate-time -D_FORTIFY_SOURCE=2  -c 
> -o statnetd.o statnetd.c
> gcc -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 
> -Werror=implicit-function-declaration -ffile-prefix-map=/<>=. 
> -fstack-protector-strong -fstack-clash-protection -Wformat 
> -Werror=format-security -fcf-protection -Wl,-z,relro -Wl,-z,now 
> -I/usr/include/ncurses -g -DSNVERSION=3.8 -Wdate-time -D_FORTIFY_SOURCE=2  -c 
> -o itstime.o itstime.c
> statnet.c:102:8: warning: type defaults to ‘int’ in declaration of ‘gen_all’ 
> [-Wimplicit-int]
>   102 | static gen_all, gen_eth, gen_plip, gen_slip, gen_ppp, gen_loop, 
> gen_802 = 0;
>   |^~~
> statnet.c:102:17: warning: type defaults to ‘int’ in declaration of ‘gen_eth’ 
> [-Wimplicit-int]
>   102 | static gen_all, gen_eth, gen_plip, gen_slip, gen_ppp, gen_loop, 
> gen_802 = 0;
>   | ^~~
> statnet.c:102:26: warning: type defaults to ‘int’ in declaration of 
> ‘gen_plip’ [-Wimplicit-int]
>   102 | static gen_all, gen_eth, gen_plip, gen_slip, gen_ppp, gen_loop, 
> gen_802 = 0;
>   |  ^~~~
> statnet.c:102:36: warning: type defaults to ‘int’ in declaration of 
> ‘gen_slip’ [-Wimplicit-int]
>   102 | static gen_all, gen_eth, gen_plip, gen_slip, gen_ppp, gen_loop, 
> gen_802 = 0;
>   |^~~~
> statnet.c:102:46: warning: type defaults to ‘int’ in declaration of ‘gen_ppp’ 
> [-Wimplicit-int]
>   102 | static gen_all, gen_eth, gen_plip, gen_slip, gen_ppp, gen_loop, 
> gen_802 = 0;
>   |  ^~~
> statnet.c:102:55: warning: type defaults to ‘int’ in declaration of 
> ‘gen_loop’ [-Wimplicit-int]
>   102 | static gen_all, gen_eth, gen_plip, gen_slip, gen_ppp, gen_loop, 
> gen_802 = 0;
>   |   ^~~~
> statnet.c:102:65: warning: type defaults to ‘int’ in declaration of ‘gen_802’ 
> [-Wimplicit-int]
>   102 | static gen_all, gen_eth, gen_plip, gen_slip, gen_ppp, gen_loop, 
> gen_802 = 0;
>   | 
> ^~~
> statnet.c:106:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
>   106 | main (int argc, char *argv[])
>   | ^~~~
> itstime.c: In function ‘itstime’:
> itstime.c:50:9: error: implicit declaration of function ‘alarm’ 
> [-Werror=implicit-function-declaration]
>50 | alarm (SN_STATS_SECS);
>   | ^
> statnet.c: In function ‘update_display’:
> statnet.c:555:36: warning: '0' flag ignored with '-' flag in gnu_printf 
> format [-Wformat=]
>   555 |   mvwprintw (genwin, 0, 0, "GENERAL  Frame: /%-02d sec", 
> SN_UPDATE_SECS);
>   |^~~~
> statnet.c:681:9: error: implicit declaration of function ‘win_show_stat’ 
> [-Werror=implicit-function-declaration]
>   681 | win_show_stat( protwin, 9, 1, noframes, >prot, 
> >prot, , rewrite_labels, _prot_labels, 
> _prot_labels );
>   | ^
> gcc -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 
> -Werror=implicit-function-declaration -ffile-prefix-map=/<>=. 
> -fstack-protector-strong -fstack-clash-protection -Wformat 
> -Werror=format-security