summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-04-20 16:01:52 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-04-20 16:01:52 (EDT)
commit2dfff6604492b72f3dd990571e2925a8cea746f5 (patch)
tree474ea357b8753c226017def73151008911c256a1 /src
parent8865acffee909d1d528d30444b44dad359913c0a (diff)
opk: Fix column width calculation
Also fix possibly uninitialized list tail.
Diffstat (limited to 'src')
-rw-r--r--src/opk.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/opk.c b/src/opk.c
index ddcacea..015ad96 100644
--- a/src/opk.c
+++ b/src/opk.c
@@ -251,6 +251,7 @@ opkg_opk_opk_list_members(struct opkg_opk_opk *opk)
/* Build singly-linked list and find maximum column widths. */
head = NULL;
+ tail = NULL;
uname_len_max = 0;
gname_len_max = 0;
size_max = 0;
@@ -279,14 +280,16 @@ opkg_opk_opk_list_members(struct opkg_opk_opk *opk)
_opkg_opk_opk_free_inner(opk);
return OPKG_OPK_ERROR;
}
- tail->next = NULL;
+ if (tail != NULL) {
+ tail->next = NULL;
+ }
/* Print and free members. */
ret = OPKG_OPK_OK;
size_len_max = lrint(ceil(log10(size_max)));
snprintf(fmt, sizeof(fmt), "%%c%%s %%-%zus/%%-%zus %%%lid %%s %%s\n",
- uname_len, gname_len, size_len_max);
- len = 35 + uname_len + gname_len + size_len_max;
+ uname_len_max, gname_len_max, size_len_max);
+ len = 35 + uname_len_max + gname_len_max + size_len_max;
for (member = head; member != NULL;) {
if (member->mode & 00400) mode[0] = 'r'; else mode[0] = '-';
if (member->mode & 00200) mode[1] = 'w'; else mode[1] = '-';