On 01/23/2017 12:39 PM, Frediano Ziglio wrote:
On 01/20/2017 05:30 PM, Christophe Fergeau wrote:Initializing 'node' to NULL silences this warning: stat-file.c: In function 'stat_file_add_node': stat-file.c:180:15: error: 'node' may be used uninitialized in this function [-Werror=maybe-uninitialized] g_strlcpy(node->name, name, sizeof(node->name)); ^~~~ cc1: all warnings being treated as errorsHi Christophe, Looks good to me.it's actually a false positive, from for (ref = 0; ref <= stat_file->max_nodes; ref++) { node = &stat_file->stat->nodes[ref]; node is always initialized as ref and max_nodes are unsigned so at the beginning ref == 0 and start_file->max_nodes >= 0 so ref <= 0 <= start_file->max_nodes and node is initialized.
Yes, you are correct. Actually2: it's safe for the loop to go till ref < stat_file->max_nodes, as the function returns based on the following condition, a few lines above: (stat_file->stat->num_of_nodes >= stat_file->max_nodes) _______________________________________________ Spice-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/spice-devel
