summaryrefslogtreecommitdiff
path: root/constlist.c
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2023-11-04 11:28:44 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2023-11-06 14:19:08 -0800
commit19137ec2f129f91ce3adb46218c86e1bf547e661 (patch)
tree237a5a879a738a18009863ecd12464eaff3af544 /constlist.c
parentffd69eb38f153229f5033ef5cc789c0ab3704edd (diff)
Variable scope reductions as recommended by cppcheck
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Diffstat (limited to 'constlist.c')
-rw-r--r--constlist.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/constlist.c b/constlist.c
index bdff352..076a33a 100644
--- a/constlist.c
+++ b/constlist.c
@@ -45,7 +45,7 @@ appendConstList(ConstListPtr first, ConstListPtr second)
ConstListPtr
makeConstList(const char **a, int n, ConstListPtr old, int begin)
{
- ConstListPtr first, current, next;
+ ConstListPtr first, current;
int i;
if (n == 0)
@@ -60,7 +60,7 @@ makeConstList(const char **a, int n, ConstListPtr old, int begin)
current = first;
for (i = 1; i < n; i++) {
- next = malloc(sizeof(ConstListRec));
+ ConstListPtr next = malloc(sizeof(ConstListRec));
if (!next) {
destroyConstList(first);
return NULL;
@@ -83,12 +83,10 @@ makeConstList(const char **a, int n, ConstListPtr old, int begin)
void
destroyConstList(ConstListPtr old)
{
- ConstListPtr next;
-
if (!old)
return;
while (old) {
- next = old->next;
+ ConstListPtr next = old->next;
free(old);
old = next;
}