[Ltrace-devel] [PATCH] Fix tautological compare warnings

Adam Trhon adam.trhon at tbs-biometrics.com
Fri May 12 20:55:02 UTC 2017


Hello,

this is the first time I send a patch to a mailing list, so please let
me know whatever I do wrong. 

When we build ltrace with gcc under icecream, the compilation fails
(see the commit mesage). You can reproduce the problem without using 
icecream by adding 

-no-integrated-cpp

to gcc arguments. Below is a patch that fixes the warnings.

Best regards
Adam


From 0af8ced6376f2256b9daac301c851e1c99c3b035 Mon Sep 17 00:00:00 2001
From: Adam Trhon <adam.trhon at tbs-biometrics.com>
Date: Fri, 12 May 2017 13:39:11 +0200
Subject: [PATCH] Fix tautological compare warning

By default, gcc ignores warning from code generated by macros
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80369). When
ltrace is compiled under icecream the warning *is generated*
(https://github.com/icecc/icecream/issues/202)
and the compilation fails (because of -Werror).

Signed-off-by: Adam Trhon <adam.trhon at tbs-biometrics.com>
---
 filter.c                        | 4 ++--
 sysdeps/linux-gnu/arm/fetch.c   | 2 +-
 sysdeps/linux-gnu/arm/trace.c   | 2 +-
 sysdeps/linux-gnu/ia64/fetch.c  | 2 +-
 sysdeps/linux-gnu/metag/trace.c | 2 +-
 sysdeps/linux-gnu/mips/plt.c    | 2 +-
 sysdeps/linux-gnu/ppc/fetch.c   | 2 +-
 sysdeps/linux-gnu/ppc/plt.c     | 2 +-
 sysdeps/linux-gnu/ppc/trace.c   | 4 ++--
 sysdeps/linux-gnu/s390/fetch.c  | 2 +-
 sysdeps/linux-gnu/s390/trace.c  | 4 ++--
 sysdeps/linux-gnu/x86/fetch.c   | 2 +-
 sysdeps/linux-gnu/x86/trace.c   | 4 ++--
 value.c                         | 4 ++--
 14 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/filter.c b/filter.c
index ba50c40..a65856d 100644
--- a/filter.c
+++ b/filter.c
@@ -79,7 +79,7 @@ filter_lib_matcher_name_init(struct filter_lib_matcher *matcher,
 {
 	switch (type) {
 	case FLM_MAIN:
-		assert(type != type);
+		assert(!"Unexpected value of type");
 		abort();
 
 	case FLM_SONAME:
@@ -137,7 +137,7 @@ matcher_matches_library(struct filter_lib_matcher *matcher, struct library *lib)
 	case FLM_MAIN:
 		return lib->type == LT_LIBTYPE_MAIN;
 	}
-	assert(matcher->type != matcher->type);
+	assert(!"Unexpected value of matcher->type");
 	abort();
 }
 
diff --git a/sysdeps/linux-gnu/arm/fetch.c b/sysdeps/linux-gnu/arm/fetch.c
index b500448..8f75fcf 100644
--- a/sysdeps/linux-gnu/arm/fetch.c
+++ b/sysdeps/linux-gnu/arm/fetch.c
@@ -317,7 +317,7 @@ arch_fetch_retval(struct fetch_context *ctx, enum tof type,
 		memmove(data, ctx->regs.uregs, sz);
 		return 0;
 	}
-	assert(info->type != info->type);
+	assert(!"Unexpected value of info->type");
 	abort();
 }
 
diff --git a/sysdeps/linux-gnu/arm/trace.c b/sysdeps/linux-gnu/arm/trace.c
index 5e51e91..e76bf63 100644
--- a/sysdeps/linux-gnu/arm/trace.c
+++ b/sysdeps/linux-gnu/arm/trace.c
@@ -701,7 +701,7 @@ arch_type_sizeof(struct process *proc, struct arg_type_info *info)
 		return (size_t)-2;
 
 	default:
-		assert(info->type != info->type);
+		assert(!"Unexpected value of info->type");
 		abort();
 	}
 }
diff --git a/sysdeps/linux-gnu/ia64/fetch.c b/sysdeps/linux-gnu/ia64/fetch.c
index 171c7a2..ee2fbc7 100644
--- a/sysdeps/linux-gnu/ia64/fetch.c
+++ b/sysdeps/linux-gnu/ia64/fetch.c
@@ -409,7 +409,7 @@ arch_fetch_arg_next(struct fetch_context *ctx, enum tof type,
 	case ARGTYPE_ARRAY:
 		/* Arrays decay into pointers.  XXX Fortran?  */
 	default:
-		assert(info->type != info->type);
+		assert(!"Unexpected value of info->type");
 		abort();
 	}
 }
diff --git a/sysdeps/linux-gnu/metag/trace.c b/sysdeps/linux-gnu/metag/trace.c
index ad5fffe..7a843d6 100644
--- a/sysdeps/linux-gnu/metag/trace.c
+++ b/sysdeps/linux-gnu/metag/trace.c
@@ -142,7 +142,7 @@ get_regval_from_unit(enum metag_unitnum unit, unsigned int reg,
 		return regs->ax[reg][0];
 	/* We really shouldn't be here.  */
 	default:
-		assert(unit != unit);
+		assert(!"Unexpected value of unit");
 		abort();
 	}
 	return 0;
diff --git a/sysdeps/linux-gnu/mips/plt.c b/sysdeps/linux-gnu/mips/plt.c
index c7c10ac..ca2307d 100644
--- a/sysdeps/linux-gnu/mips/plt.c
+++ b/sysdeps/linux-gnu/mips/plt.c
@@ -651,7 +651,7 @@ mips_stub_bp_continue(struct breakpoint *bp, struct process *proc)
 		break;
 	}
 
-	assert(bp->libsym->arch.type != bp->libsym->arch.type);
+	assert(!"Unexpected value of bp->libsym->arch.type");
 	abort();
 }
 
diff --git a/sysdeps/linux-gnu/ppc/fetch.c b/sysdeps/linux-gnu/ppc/fetch.c
index c6cbd71..5db5675 100644
--- a/sysdeps/linux-gnu/ppc/fetch.c
+++ b/sysdeps/linux-gnu/ppc/fetch.c
@@ -502,7 +502,7 @@ allocate_argument(struct fetch_context *ctx, struct process *proc,
 	case ARGTYPE_ARRAY:
 		/* Arrays decay into pointers.  XXX Fortran?  */
 	default:
-		assert(info->type != info->type);
+		assert(!"Unexpected value of info->type");
 		abort();
 	}
 
diff --git a/sysdeps/linux-gnu/ppc/plt.c b/sysdeps/linux-gnu/ppc/plt.c
index 5f81889..781da03 100644
--- a/sysdeps/linux-gnu/ppc/plt.c
+++ b/sysdeps/linux-gnu/ppc/plt.c
@@ -1085,7 +1085,7 @@ ppc_plt_bp_continue(struct breakpoint *bp, struct process *proc)
 		break;
 	}
 
-	assert(bp->libsym->arch.type != bp->libsym->arch.type);
+	assert(!"Unexpected value of bp->libsym->arch.type");
 	abort();
 }
 
diff --git a/sysdeps/linux-gnu/ppc/trace.c b/sysdeps/linux-gnu/ppc/trace.c
index 5aab538..caa6035 100644
--- a/sysdeps/linux-gnu/ppc/trace.c
+++ b/sysdeps/linux-gnu/ppc/trace.c
@@ -217,7 +217,7 @@ arch_type_sizeof(struct process *proc, struct arg_type_info *info)
 		return (size_t)-2;
 
 	default:
-		assert(info->type != info->type);
+		assert(!"Unexpected value of info->type");
 		abort();
 		break;
 	}
@@ -231,7 +231,7 @@ arch_type_alignof(struct process *proc, struct arg_type_info *info)
 
 	switch (info->type) {
 	default:
-		assert(info->type != info->type);
+		assert(!"Unexpected value of info->type");
 		abort();
 		break;
 
diff --git a/sysdeps/linux-gnu/s390/fetch.c b/sysdeps/linux-gnu/s390/fetch.c
index 4ad5951..4721c30 100644
--- a/sysdeps/linux-gnu/s390/fetch.c
+++ b/sysdeps/linux-gnu/s390/fetch.c
@@ -266,7 +266,7 @@ arch_fetch_arg_next(struct fetch_context *ctx, enum tof type,
 		return allocate_gpr(ctx, proc, info, valuep, sz);
 
 	default:
-		assert(info->type != info->type);
+		assert(!"Unexpected value of info->type");
 		abort();
 	}
 	return -1;
diff --git a/sysdeps/linux-gnu/s390/trace.c b/sysdeps/linux-gnu/s390/trace.c
index 78b04c3..24f7801 100644
--- a/sysdeps/linux-gnu/s390/trace.c
+++ b/sysdeps/linux-gnu/s390/trace.c
@@ -213,7 +213,7 @@ arch_type_sizeof(struct process *proc, struct arg_type_info *info)
 		return (size_t)-2;
 
 	default:
-		assert(info->type != info->type);
+		assert(!"Unexpected value of info->type");
 		abort();
 	}
 }
@@ -226,7 +226,7 @@ arch_type_alignof(struct process *proc, struct arg_type_info *info)
 
 	switch (info->type) {
 	default:
-		assert(info->type != info->type);
+		assert(!"Unexpected value of info->type");
 		break;
 
 	case ARGTYPE_CHAR:
diff --git a/sysdeps/linux-gnu/x86/fetch.c b/sysdeps/linux-gnu/x86/fetch.c
index 6868101..ae2ed79 100644
--- a/sysdeps/linux-gnu/x86/fetch.c
+++ b/sysdeps/linux-gnu/x86/fetch.c
@@ -523,7 +523,7 @@ classify(struct process *proc, struct fetch_context *context,
 
 	default:
 		/* Unsupported type.  */
-		assert(info->type != info->type);
+		assert(!"Unexpected value of info->type");
 		abort();
 	}
 	abort();
diff --git a/sysdeps/linux-gnu/x86/trace.c b/sysdeps/linux-gnu/x86/trace.c
index 6a1a6a5..d8d2115 100644
--- a/sysdeps/linux-gnu/x86/trace.c
+++ b/sysdeps/linux-gnu/x86/trace.c
@@ -145,7 +145,7 @@ arch_type_sizeof(struct process *proc, struct arg_type_info *info)
 		return (size_t)-2;
 
 	default:
-		assert(info->type != info->type);
+		assert(!"Unexpected value of info->type");
 		abort();
 	}
 }
@@ -158,7 +158,7 @@ arch_type_alignof(struct process *proc, struct arg_type_info *info)
 
 	switch (info->type) {
 	default:
-		assert(info->type != info->type);
+		assert(!"Unexpected value of info->type");
 		abort();
 		break;
 
diff --git a/value.c b/value.c
index 2125ba9..30edb4e 100644
--- a/value.c
+++ b/value.c
@@ -363,7 +363,7 @@ value_set_word(struct value *value, long word)
 		u.u64 = word;
 		break;
 	default:
-		assert(sz != sz);
+		assert(!"Unexpected value of sz");
 		abort();
 	}
 
@@ -414,7 +414,7 @@ value_extract_word(struct value *value, long *retp,
 		*retp = (long)u.u64;
 		return 0;
 	default:
-		assert(sz != sz);
+		assert(!"Unexpected value of sz");
 		abort();
 	}
 }
-- 
2.12.0




-- 
Ing. Adam Trhoň, Software Engineer
Touchless Biometric Systems s.r.o. | 
Palackého třída 180/44 | 61200 Brno | CZECH REPUBLIC | 
Mobile: +42(0) 721 565 113 | tbs-biometrics.cz



More information about the Ltrace-devel mailing list