Commit 17b790bc authored by Bas Zoetekouw's avatar Bas Zoetekouw

Fix gcc warnings and enable -Wextra -Werror

parent b6b25adf
......@@ -6,6 +6,7 @@ blktrace (1.2.0-3) UNRELEASED; urgency=medium
* update homepage
* update watch file to look at kernel git repo
* extend DEB_BUILD_MAINT_OPTIONS
* fix gcc warnings (including a possible buffer overflow)
-- Ondřej Nový <onovy@debian.org> Mon, 01 Oct 2018 09:57:21 +0200
......
Fix gcc warnings.
Patch was sent upstream to Jens Axboe <axboe@kernel.dk> on 2019-02-12
Index: blktrace-1.2.0/jhash.h
===================================================================
--- blktrace-1.2.0.orig/jhash.h
+++ blktrace-1.2.0/jhash.h
@@ -23,6 +23,12 @@
* any bugs present are my fault. Jozsef
*/
+#if defined(__GNUC__) && __GNUC__ >= 7
+ #define FALL_THROUGH __attribute__ ((fallthrough))
+#else
+ #define FALL_THROUGH ((void)0)
+#endif /* __GNUC__ >= 7 */
+
#define __rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
/* __jhash_mix - mix 3 32-bit values reversibly. */
@@ -76,19 +82,19 @@ static inline u32 jhash(const void *key,
/* last block: affect all 32 bits of (c) */
/* all the case statements fall through */
switch (length) {
- case 12: c += (u32)k[11]<<24;
- case 11: c += (u32)k[10]<<16;
- case 10: c += (u32)k[9]<<8;
- case 9 : c += k[8];
- case 8 : b += (u32)k[7]<<24;
- case 7 : b += (u32)k[6]<<16;
- case 6 : b += (u32)k[5]<<8;
- case 5 : b += k[4];
- case 4 : a += (u32)k[3]<<24;
- case 3 : a += (u32)k[2]<<16;
- case 2 : a += (u32)k[1]<<8;
+ case 12: c += (u32)k[11]<<24; FALL_THROUGH;
+ case 11: c += (u32)k[10]<<16; FALL_THROUGH;
+ case 10: c += (u32)k[9]<<8; FALL_THROUGH;
+ case 9 : c += k[8]; FALL_THROUGH;
+ case 8 : b += (u32)k[7]<<24; FALL_THROUGH;
+ case 7 : b += (u32)k[6]<<16; FALL_THROUGH;
+ case 6 : b += (u32)k[5]<<8; FALL_THROUGH;
+ case 5 : b += k[4]; FALL_THROUGH;
+ case 4 : a += (u32)k[3]<<24; FALL_THROUGH;
+ case 3 : a += (u32)k[2]<<16; FALL_THROUGH;
+ case 2 : a += (u32)k[1]<<8; FALL_THROUGH;
case 1 : a += k[0];
- __jhash_final(a, b, c);
+ __jhash_final(a, b, c); FALL_THROUGH;
case 0 :
break;
}
Index: blktrace-1.2.0/btt/devs.c
===================================================================
--- blktrace-1.2.0.orig/btt/devs.c
+++ blktrace-1.2.0/btt/devs.c
@@ -108,9 +108,9 @@ void dip_exit(void)
static inline FILE *open_pit(struct d_info *dip)
{
FILE *fp;
- char str[256];
+ char str[sizeof(dip->dip_name)+8]; /* "_pit.dat" is 8 chars */
- sprintf(str, "%s_pit.dat", dip->dip_name);
+ snprintf(str, sizeof(str), "%s_pit.dat", dip->dip_name);
if ((fp = my_fopen(str, "w")) == NULL)
perror(str);
......@@ -5,3 +5,4 @@ procnum.patch
spelling.patch
cve-2018-10689
python3-support.patch
gcc_warnings.patch
......@@ -5,7 +5,7 @@
include /usr/share/dpkg/architecture.mk
include /usr/share/dpkg/pkg-info.mk
CFLAGS += -Wall -Wextra -Wno-shadow -g
CFLAGS += -Wall -Wextra -Wno-shadow -Werror -g
export DEB_BUILD_MAINT_OPTIONS = hardening=+all future=+all qa=+all reproducible=+all
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment