# HG changeset patch # User Rob Landley # Date 1411390335 18000 # Node ID a2796b4cef49f138fe981ff9c790fab685e9c56b # Parent 4542db35efd8d25bf0328a22dae7db49518e6542 Respond to two static analysis issues in dirtree_path() reported by Ashwini Sharma. dirtree->name is an array, not a pointer, so can't be zero. Remove the test. We dereference plen without checking it for null but calling dirtree_path(0, 0) is pilot error: only the _first_ call can have plen = 0. Add a comment. diff -r 4542db35efd8 -r a2796b4cef49 lib/dirtree.c --- a/lib/dirtree.c Sun Sep 21 22:44:20 2014 -0500 +++ b/lib/dirtree.c Mon Sep 22 07:52:15 2014 -0500 @@ -71,12 +71,16 @@ // Return path to this node, assembled recursively. +// Initial call can pass in NULL to plen, or point to an int initialized to 0 +// to return the length of the path, or a value greater than 0 to allocate +// extra space if you want to append your own text to the string. + char *dirtree_path(struct dirtree *node, int *plen) { char *path; int len; - if (!node || !node->name) { + if (!node) { path = xmalloc(*plen); *plen = 0; return path;