From b509232eb835cd5ded1adfab25706365d68df976 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Wed, 22 Aug 2018 05:07:14 +0200 Subject: [PATCH] MINOR: sample: remove impossible tests on negative smp->data.u.str.data Since commit 843b7cb ("MEDIUM: chunks: make the chunk struct's fields match the buffer struct") a chunk length is unsigned so we can remove negative size checks. --- include/proto/sample.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/include/proto/sample.h b/include/proto/sample.h index 6cca99a6a..4fb5babf4 100644 --- a/include/proto/sample.h +++ b/include/proto/sample.h @@ -92,8 +92,7 @@ int smp_is_safe(struct sample *smp) /* Fall through */ case SMP_T_STR: - if ((smp->data.u.str.data < 0) || - (smp->data.u.str.size && smp->data.u.str.data >= smp->data.u.str.size)) + if (smp->data.u.str.size && smp->data.u.str.data >= smp->data.u.str.size) return 0; if (smp->data.u.str.area[smp->data.u.str.data] == 0) @@ -106,8 +105,7 @@ int smp_is_safe(struct sample *smp) return 1; case SMP_T_BIN: - return (smp->data.u.str.data >= 0) && - (!smp->data.u.str.size || smp->data.u.str.data <= smp->data.u.str.size); + return !smp->data.u.str.size || smp->data.u.str.data <= smp->data.u.str.size; default: return 1; @@ -145,7 +143,6 @@ int smp_is_rw(struct sample *smp) case SMP_T_STR: if (!smp->data.u.str.size || - smp->data.u.str.data < 0 || smp->data.u.str.data >= smp->data.u.str.size) return 0; @@ -155,7 +152,6 @@ int smp_is_rw(struct sample *smp) case SMP_T_BIN: return smp->data.u.str.size && - smp->data.u.str.data >= 0 && smp->data.u.str.data <= smp->data.u.str.size; default: