From mboxrd@z Thu Jan 1 00:00:00 1970 From: john at keeping.me.uk (John Keeping) Date: Sun, 17 Jan 2016 20:25:36 +0000 Subject: [PATCH 0/3] Fix some issues found by Coverity In-Reply-To: References: Message-ID: <20160117202535.GR14056@serenity.lan> On Sun, Jan 17, 2016 at 05:19:04PM +0100, Jason A. Donenfeld wrote: > So there is now only 1 issue remaining: 13839. > > static void add_commit(struct string_list *authors, struct commit *commit, > const struct cgit_period *period) > { > struct commitinfo *info; > struct string_list_item *author, *item; > struct authorstat *authorstat; > struct string_list *items; > char *tmp; > struct tm *date; > time_t t; > > info = cgit_parse_commit(commit); > tmp = xstrdup(info->author); > author = string_list_insert(authors, tmp); > if (!author->util) > author->util = xcalloc(1, sizeof(struct authorstat)); > else > free(tmp); > authorstat = author->util; > items = &authorstat->list; > t = info->committer_date; > date = gmtime(&t); > period->trunc(date); > tmp = xstrdup(period->pretty(date)); > item = string_list_insert(items, tmp); > if (item->util) > free(tmp); > item->util++; > authorstat->total++; > cgit_free_commitinfo(info); > } > > It doesn't like the "item->util++" line, since "if (item->util)" > implies that util could be NULL. That line doesn't make much sense to > me either. Any guesses? We're using "util" as a counter here, not a pointer. But it's declared as "void*" so Coverity doesn't like this. We could try adding in some casts to uintptr_t but that's pretty hideous. Otherwise we need to allocate an unsigned int for the "util" field or just ignore Coverity.