[hackers] [scc] [cc2] Initialize left and right pointers in constnode() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Wed, 14 Sep 2016 15:32:31 +0200 (CEST)

commit db8cf76a3a055a1bc065c842516d7193147ba6e3
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Wed Sep 14 14:57:16 2016 +0200
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Wed Sep 14 15:32:23 2016 +0200

    [cc2] Initialize left and right pointers in constnode()
    
    The code follows these pointers in a few cases without looking the op,
    so it is better to have them initialized.

diff --git a/cc2/code.c b/cc2/code.c
index 5a1170f..68172b5 100644
--- a/cc2/code.c
+++ b/cc2/code.c
_AT_@ -74,8 +74,6 @@ label2node(Node *np, Symbol *sym)
                 sym = newlabel();
         if (!np)
                 np = newnode(OLABEL);
- else
- memset(np, 0, sizeof(np));
         np->op = OLABEL;
         np->u.sym = sym;
 
_AT_@ -87,6 +85,8 @@ constnode(Node *np, TUINT n, Type *tp)
 {
         if (!np)
                 np = newnode(OCONST);
+ np->left = NULL;
+ np->right = NULL;
         np->type = *tp;
         np->u.i = n;
         return np;
Received on Wed Sep 14 2016 - 15:32:31 CEST

This archive was generated by hypermail 2.3.0 : Wed Sep 14 2016 - 15:36:19 CEST