Bug#1066576: nagios-plugins-contrib: FTBFS: check_memcached.l:339:37: error: implicit declaration of function ‘asprintf’; did you mean ‘vsprintf’? [-Werror=implicit-function-declaration]

2024-03-23 Thread Sebastian Andrzej Siewior
control -1 tags patch

the patch attached fixes the warnings in check_memcached.l.

Sebastian
>From 155e35ace12f41bbaa42e4ea19bfea6de416bd95 Mon Sep 17 00:00:00 2001
From: Sebastian Andrzej Siewior 
Date: Fri, 22 Mar 2024 19:48:09 +0100
Subject: [PATCH] Compile warnings.

Address various compile warnings in check_memcached.

Signed-off-by: Sebastian Andrzej Siewior 
---
 check_memcached/check_memcached.l |   14 +++---
 common.mk |2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

--- a/check_memcached/check_memcached.l
+++ b/check_memcached/check_memcached.l
@@ -152,7 +152,7 @@ cmd_set=		{ save_to = _cmd_set; }
 %%
 /*  */
 
-yywrap() {
+int yywrap(void) {
 	return 1;
 }
 
@@ -343,7 +343,7 @@ int check_memcached() {
 	}
 
 	if ( nagios_service_output == NULL ) {
-		str_bytes = asprintf(_service_output,"");
+		str_bytes = asprintf(_service_output," ");
 	}
 	/* - */
 	/*  Analyze the stats, return 0,1,2 as required  */
@@ -351,7 +351,7 @@ int check_memcached() {
 	if ( obj_time == 0 ) {
 		nagios_service_tmp = nagios_service_output;
 		str_bytes = asprintf(_service_output,
-"%sno stats available yet. Come back in %d minutes; ",
+"%sno stats available yet. Come back in %" PRIu64 " minutes; ",
 nagios_service_tmp,
 min_stats_interval - (stats.time - obj_time_oldest ) / 60
 );
@@ -362,7 +362,7 @@ int check_memcached() {
 			nagios_result|=1;
 			nagios_service_tmp = nagios_service_output;
 			str_bytes = asprintf(_service_output,
-	"%sToo many evictions: %d; ",
+	"%sToo many evictions: %llu; ",
 	nagios_service_tmp,
 	stats.evictions - obj_evictions
 	);
@@ -399,7 +399,7 @@ int check_memcached() {
 
 		nagios_service_tmp = nagios_service_output;
 		str_bytes = asprintf(_service_output, 
-			"%shits=%llu misses=%llu evictions=%llu interval=%lu mins",
+			"%shits=%llu misses=%llu evictions=%llu interval=%u mins",
 			nagios_service_tmp,
 			stats.get_hits - obj_get_hits,
 			stats.get_misses - obj_get_misses,
@@ -453,7 +453,7 @@ int check_memcached() {
 		nagios_perfdata = "";
 	} else {
 		str_bytes = asprintf(_perfdata, 
-			"%s delta_time=%lu delta_cmd_get=%llu delta_cmd_set=%llu delta_get_hits=%llu delta_get_misses=%llu delta_evictions=%llu",
+			"%s delta_time=%u delta_cmd_get=%llu delta_cmd_set=%llu delta_get_hits=%llu delta_get_misses=%llu delta_evictions=%llu",
 			current_stats_str,
 			(uint32_t) ( stats.time - obj_time ),
 			stats.cmd_get - obj_cmd_get,
@@ -600,7 +600,7 @@ void usage() {
 	printf("\t-n  ... Keep up to this many items in the history object in memcached (default: %u)\n",max_n_stats);
 	printf("\t-T  ... Minimum time interval (in minutes) to use to analyse stats. (default: %u)\n",min_stats_interval);
 	printf("\t-w  ... Generate warning if quotient of hits/misses falls below this value (default: %1.1f)\n",min_hit_miss);
-	printf("\t-E  ... Generate warning if number of evictions exceeds this threshold. 0=disable. (default: %llu)\n",max_evictions);
+	printf("\t-E  ... Generate warning if number of evictions exceeds this threshold. 0=disable. (default: %" PRIu64 ")\n",max_evictions);
 	printf("\t-t  ... timeout in seconds (default: %1.1f)\n",timeout);
 	printf("\t-k  ... key name for history object (default: %s)\n",memcached_key);
 	printf("\t-K  ... expiry time in seconds for history object (default: %u)\n",memcache_stats_object_expiry_time);
--- a/common.mk
+++ b/common.mk
@@ -1,6 +1,6 @@
 
 # import buildflags
-CFLAGS += $(shell dpkg-buildflags --get CFLAGS)
+CFLAGS += $(shell dpkg-buildflags --get CFLAGS) -D_GNU_SOURCE
 CPPFLAGS += $(shell dpkg-buildflags --get CPPFLAGS)
 CXXFLAGS += $(shell dpkg-buildflags --get CXXFLAGS)
 LDFLAGS += $(shell dpkg-buildflags --get LDFLAGS)


Bug#1066576: nagios-plugins-contrib: FTBFS: check_memcached.l:339:37: error: implicit declaration of function ‘asprintf’; did you mean ‘vsprintf’? [-Werror=implicit-function-declaration]

2024-03-13 Thread Lucas Nussbaum
Source: nagios-plugins-contrib
Version: 45.20231212
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):
> cc -g -O2 -Werror=implicit-function-declaration 
> -ffile-prefix-map=/<>/check_memcached=. -fstack-protector-strong 
> -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection 
> -Wdate-time -D_FORTIFY_SOURCE=2  -c -o check_memcached.o check_memcached.c
> check_memcached.l:155:1: warning: return type defaults to ‘int’ 
> [-Wimplicit-int]
>   155 | yywrap() {
>   | ^~
> check_memcached.l: In function ‘check_memcached’:
> check_memcached.l:339:37: error: implicit declaration of function ‘asprintf’; 
> did you mean ‘vsprintf’? [-Werror=implicit-function-declaration]
>   339 | str_bytes = 
> asprintf(_service_output,"Could not store updated stats object - %s; ",
>   | ^~~~
>   | vsprintf
> check_memcached.l: In function ‘usage’:
> check_memcached.l:603:16: warning: format ‘%llu’ expects argument of type 
> ‘long long unsigned int’, but argument 2 has type ‘uint64_t’ {aka ‘long 
> unsigned int’} [-Wformat=]
>   603 | printf("\t-E  ... Generate warning if number of evictions 
> exceeds this threshold. 0=disable. (default: %llu)\n",max_evictions);
>   |
> ^~~~
>  ~
>   |   
>   |
>   |   
>   uint64_t {aka long unsigned 
> int}
> cc1: some warnings being treated as errors
> make[3]: *** [: check_memcached.o] Error 1


The full build log is available from:
http://qa-logs.debian.net/2024/03/13/nagios-plugins-contrib_45.20231212_unstable.log

All bugs filed during this archive rebuild are listed at:
https://bugs.debian.org/cgi-bin/pkgreport.cgi?tag=ftbfs-20240313;users=lu...@debian.org
or:
https://udd.debian.org/bugs/?release=na=ign=7=7=only=ftbfs-20240313=lu...@debian.org=1=1=1=1#results

A list of current common problems and possible solutions is available at
http://wiki.debian.org/qa.debian.org/FTBFS . You're welcome to contribute!

If you reassign this bug to another package, please mark it as 'affects'-ing
this package. See https://www.debian.org/Bugs/server-control#affects

If you fail to reproduce this, please provide a build log and diff it with mine
so that we can identify if something relevant changed in the meantime.