Sure makes sense in this case. Cheers.

On 3 November 2017 at 14:50, Willy Tarreau <w...@1wt.eu> wrote:

> On Fri, Nov 03, 2017 at 02:45:43PM +0000, David CARLIER wrote:
> > Hi again,
> >
> > while testing a build, clang spotted the health desc field improper check
> > so here a little patch proposal. That should be all after it :-).
>
> I *think* that in fact we just have to remove the test. We need to
> look through history to find the original need, but I guess that the
> description field used to be allocated using malloc() or strdup() in
> the past and changed to an array afterwards.
>
> Willy
>
From 8c66a15fe7300f90280ca1e047aeada03a9fe54e Mon Sep 17 00:00:00 2001
From: David Carlier <devne...@gmail.com>
Date: Fri, 3 Nov 2017 14:41:46 +0000
Subject: [PATCH] BUG/MINOR: server: removing desc field check.

Seemingly, desc field was dynamically allocated before, now
it is an array we jsut remove the check.
---
 src/server.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/server.c b/src/server.c
index 37f90d8c..35115f25 100644
--- a/src/server.c
+++ b/src/server.c
@@ -872,8 +872,7 @@ void srv_set_stopped(struct server *s, const char *reason, struct check *check)
 		strlcpy2(s->op_st_chg.reason, reason, sizeof(s->op_st_chg.reason));
 	}
 	else if (check) {
-		if (check->desc)
-			strlcpy2(s->op_st_chg.reason, check->desc, sizeof(s->op_st_chg.reason));
+		strlcpy2(s->op_st_chg.reason, check->desc, sizeof(s->op_st_chg.reason));
 		s->op_st_chg.code = check->code;
 		s->op_st_chg.status = check->status;
 		s->op_st_chg.duration = check->duration;
@@ -911,8 +910,7 @@ void srv_set_running(struct server *s, const char *reason, struct check *check)
 		strlcpy2(s->op_st_chg.reason, reason, sizeof(s->op_st_chg.reason));
 	}
 	else if (check) {
-		if (check->desc)
-			strlcpy2(s->op_st_chg.reason, check->desc, sizeof(s->op_st_chg.reason));
+		strlcpy2(s->op_st_chg.reason, check->desc, sizeof(s->op_st_chg.reason));
 		s->op_st_chg.code = check->code;
 		s->op_st_chg.status = check->status;
 		s->op_st_chg.duration = check->duration;
@@ -955,8 +953,7 @@ void srv_set_stopping(struct server *s, const char *reason, struct check *check)
 		strlcpy2(s->op_st_chg.reason, reason, sizeof(s->op_st_chg.reason));
 	}
 	else if (check) {
-		if (check->desc)
-			strlcpy2(s->op_st_chg.reason, check->desc, sizeof(s->op_st_chg.reason));
+		strlcpy2(s->op_st_chg.reason, check->desc, sizeof(s->op_st_chg.reason));
 		s->op_st_chg.code = check->code;
 		s->op_st_chg.status = check->status;
 		s->op_st_chg.duration = check->duration;
-- 
2.14.2

Reply via email to