From: john at keeping.me.uk (John Keeping)
Subject: [PATCH 0/3] Fix some issues found by Coverity
Date: Sun, 17 Jan 2016 20:25:36 +0000 [thread overview]
Message-ID: <20160117202535.GR14056@serenity.lan> (raw)
In-Reply-To: <CAHmME9rVx=GjsAn7pNNS0NAJdMO869S0eGLDE9hCKfYN9s0xag@mail.gmail.com>
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.
next prev parent reply other threads:[~2016-01-17 20:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-16 11:03 john
2016-01-16 11:03 ` [PATCH 1/3] ui-log: handle parse_commit() errors john
2016-01-16 11:03 ` [PATCH 2/3] cache: use size_t for string lengths john
2016-01-16 11:03 ` [PATCH 3/3] cache: don't check for match with no key john
2016-01-17 16:04 ` [PATCH 0/3] Fix some issues found by Coverity Jason
2016-01-17 16:19 ` Jason
2016-01-17 20:25 ` john [this message]
2016-02-03 4:46 ` mathstuf
2016-02-08 13:35 ` Jason
2016-02-08 14:16 ` john
2016-02-08 14:33 ` Jason
2016-02-08 16:31 ` john
2016-02-08 17:26 ` Jason
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160117202535.GR14056@serenity.lan \
--to=cgit@lists.zx2c4.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).