From cd990a81489d9581500410d7018616e0cac8c809 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 22 Feb 2022 08:17:37 -0800 Subject: [PATCH] lib/pathplan/shortest.c: [nfc] separate assignments from conditionals MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Squashes a number of MSVC “C4706: assignment within conditional expression” warnings. --- lib/pathplan/shortest.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/pathplan/shortest.c b/lib/pathplan/shortest.c index ec20b63b8..8f9bd9a47 100644 --- a/lib/pathplan/shortest.c +++ b/lib/pathplan/shortest.c @@ -502,11 +502,13 @@ static int growpnls(int newpnln) { if (newpnln <= pnln) return 0; - if (!(pnls = realloc(pnls, POINTNLINKSIZE * newpnln))) { + pnls = realloc(pnls, POINTNLINKSIZE * newpnln); + if (pnls == NULL) { prerror("cannot realloc pnls"); return -1; } - if (!(pnlps = realloc(pnlps, POINTNLINKPSIZE * newpnln))) { + pnlps = realloc(pnlps, POINTNLINKPSIZE * newpnln); + if (pnlps == NULL) { prerror("cannot realloc pnlps"); return -1; } @@ -518,7 +520,8 @@ static int growtris(int newtrin) { if (newtrin <= trin) return 0; - if (!(tris = realloc(tris, TRIANGLESIZE * newtrin))) { + tris = realloc(tris, TRIANGLESIZE * newtrin); + if (tris == NULL) { prerror("cannot realloc tris"); return -1; } @@ -531,7 +534,8 @@ static int growdq(int newdqn) { if (newdqn <= dq.pnlpn) return 0; - if (!(dq.pnlps = realloc(dq.pnlps, POINTNLINKPSIZE * newdqn))) { + dq.pnlps = realloc(dq.pnlps, POINTNLINKPSIZE * newdqn); + if (dq.pnlps == NULL) { prerror("cannot realloc dq.pnls"); return -1; } @@ -543,7 +547,8 @@ static int growops(int newopn) { if (newopn <= opn) return 0; - if (!(ops = realloc(ops, POINTSIZE * newopn))) { + ops = realloc(ops, POINTSIZE * newopn); + if (ops == NULL) { prerror("cannot realloc ops"); return -1; } -- 2.40.0