Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit 168388d

Browse files
author
Ikey Doherty
committed
Restore: Make clang happy
Turns out this was a ccache issue. Alternative implementation to this is is forcing clang diagnostics via a pragma but that seems nasty, besides this is still within C99 compliance, though it'd be nice if clang would choose the members itself vs being told one to start with. Signed-off-by: Ikey Doherty <[email protected]>
1 parent 1b19d2c commit 168388d

File tree

9 files changed

+11
-33
lines changed

9 files changed

+11
-33
lines changed

src/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ static void process_node(CveDB *self, xmlTextReaderPtr r)
270270
{
271271
const xmlChar *name = NULL;
272272
const xmlChar *value = NULL;
273-
struct vulnerability_t vuln = {0};
273+
struct vulnerability_t vuln = {.vendor = 0};
274274
xmlChar *uri = NULL;
275275
int64_t last_mod = -1;
276276

src/library/template.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ char *template_context_process_line(TemplateContext *self, const char *original,
307307

308308
while ((c = memchr(input->str+offset, '{', input->len-offset))) {
309309
autofree(cve_string) *newstr = NULL;
310-
autofree(cve_string) *left = NULL;
311310
TCValue *val = NULL;
312311

313312
int oldoffset = offset;

src/library/util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ DEF_AUTOFREE(char, free)
3434

3535
bool find_sources(const char *path, package_match_func match, bool recurse)
3636
{
37-
struct stat st = {0};
37+
struct stat st = {.st_ino = 0};
3838
bool ret = false;
3939
DIR *dir = NULL;
4040
struct dirent *ent = NULL;
@@ -85,7 +85,7 @@ PackageType guess_package_type(gchar *path, bool recurse)
8585
DIR *dir = NULL;
8686
struct dirent *ent = NULL;
8787
PackageType type = PACKAGE_TYPE_UNKNOWN;
88-
struct stat st = {0}, stc = {0};
88+
struct stat st = {.st_ino = 0}, stc = {.st_ino = 0};
8989
char *p = realpath(path, NULL);
9090

9191
if (!p) {

src/library/util.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,13 @@ static inline void package_free(void *p)
254254

255255
static inline bool cve_file_exists(const char *p)
256256
{
257-
struct stat st = {0};
257+
struct stat st = {.st_ino = 0};
258258
return (stat(p,&st) == 0);
259259
}
260260

261261
static inline bool cve_is_dir(const char *p)
262262
{
263-
struct stat st = {0};
263+
struct stat st = {.st_ino = 0};
264264
if (stat(p, &st) != 0) {
265265
return false;
266266
}

src/main.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ static GOptionEntry _entries[] = {
248248
{ "auto-bug", 'b', 0, G_OPTION_ARG_NONE, &auto_bug, "Enable automatic bug tracking", NULL },
249249
{ "auto-bug-template", 'j', 0, G_OPTION_ARG_STRING, &auto_bug_template, "Path to optional auto-bug json template file", NULL },
250250
{ "mapping", 'M', 0, G_OPTION_ARG_STRING, &mapping_file, "Path to a mapping file", NULL},
251-
{ NULL }
251+
{ .short_name = 0 }
252252
};
253253

254254
static bool set_package_type(PackageType type)
@@ -283,7 +283,7 @@ static bool set_package_type(PackageType type)
283283
/**
284284
* Helper utility to free the bug struct
285285
*/
286-
static inline void bug_free(void *p)
286+
__attribute__ ((unused)) static inline void bug_free(void *p)
287287
{
288288
struct jira_issue_t *t = p;
289289

@@ -422,7 +422,7 @@ int main(int argc, char **argv)
422422
autofree(CveDB) *cve_db = NULL;
423423
int ret = EXIT_FAILURE;
424424
PackageType type = PACKAGE_TYPE_UNKNOWN;
425-
CveCheckTool instance = {0};
425+
CveCheckTool instance = {.is_patched = 0};
426426
instance.modified = -1;
427427
time_t ti;
428428
CvePlugin *report = NULL;

src/output/html.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,6 @@
2323

2424
#define NVD_CVE_URI "http://web.nvd.nist.gov/view/vuln/detail?vulnId="
2525

26-
static inline gchar *_concat(gchar *source, gchar *moar)
27-
{
28-
gchar *ret = g_strconcat(source, moar, NULL);
29-
if (ret) {
30-
g_free(source);
31-
return ret;
32-
}
33-
return source;
34-
}
35-
36-
static inline gchar *dotemplate(GHashTable *k, char *p)
37-
{
38-
gchar *ret = template_string(p, k);
39-
g_free(p);
40-
return ret;
41-
}
42-
4326
static inline bool load_template(const char *tmpl_name, gchar **ret)
4427
{
4528
autofree(GError) *error = NULL;
@@ -129,7 +112,6 @@ bool write_report(CveCheckTool *self)
129112
}
130113

131114
for (c = v->issues; c; c = c->next) {
132-
autofree(gchar) *ent = NULL;
133115
c_entry = cve_db_get_cve(self->cve_db, (gchar*)c->data);
134116
if (self->modified > 0 && c_entry->modified > self->modified) {
135117
cve_free(c_entry);
@@ -159,7 +141,6 @@ bool write_report(CveCheckTool *self)
159141
}
160142
if (!self->hide_patched && v->patched) {
161143
for (c = v->patched; c; c = c->next) {
162-
autofree(gchar) *ent = NULL;
163144
c_entry = cve_db_get_cve(self->cve_db, (gchar*)c->data);
164145

165146
if (self->modified > 0 && c_entry->modified > self->modified) {

src/update-main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ static bool _quiet = false;
4545
static GOptionEntry _entries[] = {
4646
{ "version", 'v', 0, G_OPTION_ARG_NONE, &_show_version, "Show version", NULL },
4747
{ "quiet", 'q', 0, G_OPTION_ARG_NONE, &_quiet, "Run silently", NULL },
48-
{ NULL }
48+
{ .short_name = 0 }
4949
};
5050

5151
/**

src/update.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ bool update_required()
4646
time_t t;
4747

4848
autofree(gchar) *db = get_db_path();
49-
struct stat st = {0};
49+
struct stat st = {.st_ino = 0};
5050
if (stat(db, &st) != 0) {
5151
return true;
5252
}
@@ -61,8 +61,6 @@ bool update_required()
6161

6262
bool update_db(bool quiet)
6363
{
64-
autofree(GError) *error = NULL;
65-
autofree(GOptionContext) *context = NULL;
6664
autofree(gchar) *db_path = NULL;
6765
autofree(cve_string) *workdir = NULL;
6866
autofree(CveDB) *cve_db = NULL;

tests/check-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ START_TEST(cve_string_test)
126126
fail_if(cve_string_const_equal(NULL, NULL), "const_equal on NULL string");
127127

128128
/* Forced empty ->str tests */
129-
cve_string st = { 0 };
129+
cve_string st = { .len = 0 };
130130
fail_if(cve_string_equal(&st, &st), "equal on NULL ->str");
131131
fail_if(cve_string_const_equal(&st, "TEST"), "const_equal on NULL ->str");
132132
}

0 commit comments

Comments
 (0)