From 869513a1ec3406c16ab245929103f535f4c8160e Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 6 Oct 2018 23:25:13 +0100 Subject: [PATCH] Fix alloc size warning when building with recent GCC. (cherry picked from commit 5cd0ba08b1c8dbc3174ee7b0e86654da721e1dd1) --- tgt-vvp/vvp_scope.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tgt-vvp/vvp_scope.c b/tgt-vvp/vvp_scope.c index 80534c429..1e27aa0f2 100644 --- a/tgt-vvp/vvp_scope.c +++ b/tgt-vvp/vvp_scope.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001-2016 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2018 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -823,6 +823,7 @@ static void draw_udp_in_scope(ivl_net_logic_t lptr) * (.resolv, etc.) can be built before we build the .udp call. * This matches what is done for the other primitives. */ + assert(ivl_logic_pins(lptr) > 0); ninp = ivl_logic_pins(lptr) - 1; input_strings = calloc(ninp, sizeof(char*)); for (pdx = 0 ; pdx < ninp ; pdx += 1) { @@ -885,7 +886,7 @@ static void draw_logic_in_scope(ivl_net_logic_t lptr) ivl_drive_t str1 = ivl_logic_drive1(lptr); int level; - int ninp; + unsigned ninp; const char **input_strings; switch (ivl_logic_type(lptr)) { @@ -1018,8 +1019,8 @@ static void draw_logic_in_scope(ivl_net_logic_t lptr) /* Get all the input label that I will use for parameters to the functor that I create later. */ + assert(ivl_logic_pins(lptr) > 0); ninp = ivl_logic_pins(lptr) - 1; - assert(ninp >= 0); input_strings = calloc(ninp, sizeof(char*)); for (pdx = 0 ; pdx < (unsigned)ninp ; pdx += 1) input_strings[pdx] = draw_net_input(ivl_logic_pin(lptr, pdx+1));