[PATCH 0/3] Fix some issues found by Coverity

Jason A. Donenfeld Jason at zx2c4.com
Sun Jan 17 17:19:04 CET 2016


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?


Jason


More information about the CGit mailing list