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

Commit 70dc673

Browse files
author
Ikey Doherty
committed
Revert "Make clang happy"
This reverts commit 3b57d46. It would seem this causes some clang versions to explode quite violently. And in truth, parts of this change should not be necessary (the struct zero initialisation)
1 parent 3b57d46 commit 70dc673

File tree

9 files changed

+33
-11
lines changed

9 files changed

+33
-11
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 = {.vendor = 0};
273+
struct vulnerability_t vuln = {0};
274274
xmlChar *uri = NULL;
275275
int64_t last_mod = -1;
276276

src/library/template.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ 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;
310311
TCValue *val = NULL;
311312

312313
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 = {.st_ino = 0};
37+
struct stat st = {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 = {.st_ino = 0}, stc = {.st_ino = 0};
88+
struct stat st = {0}, stc = {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 = {.st_ino = 0};
257+
struct stat st = {0};
258258
return (stat(p,&st) == 0);
259259
}
260260

261261
static inline bool cve_is_dir(const char *p)
262262
{
263-
struct stat st = {.st_ino = 0};
263+
struct stat st = {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-
{ .short_name = 0 }
251+
{ NULL }
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-
__attribute__ ((unused)) static inline void bug_free(void *p)
286+
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 = {.is_patched = 0};
425+
CveCheckTool instance = {0};
426426
instance.modified = -1;
427427
time_t ti;
428428
CvePlugin *report = NULL;

src/output/html.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,23 @@
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+
2643
static inline bool load_template(const char *tmpl_name, gchar **ret)
2744
{
2845
autofree(GError) *error = NULL;
@@ -112,6 +129,7 @@ bool write_report(CveCheckTool *self)
112129
}
113130

114131
for (c = v->issues; c; c = c->next) {
132+
autofree(gchar) *ent = NULL;
115133
c_entry = cve_db_get_cve(self->cve_db, (gchar*)c->data);
116134
if (self->modified > 0 && c_entry->modified > self->modified) {
117135
cve_free(c_entry);
@@ -141,6 +159,7 @@ bool write_report(CveCheckTool *self)
141159
}
142160
if (!self->hide_patched && v->patched) {
143161
for (c = v->patched; c; c = c->next) {
162+
autofree(gchar) *ent = NULL;
144163
c_entry = cve_db_get_cve(self->cve_db, (gchar*)c->data);
145164

146165
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-
{ .short_name = 0 }
48+
{ NULL }
4949
};
5050

5151
/**

src/update.c

Lines changed: 3 additions & 1 deletion
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 = {.st_ino = 0};
49+
struct stat st = {0};
5050
if (stat(db, &st) != 0) {
5151
return true;
5252
}
@@ -61,6 +61,8 @@ bool update_required()
6161

6262
bool update_db(bool quiet)
6363
{
64+
autofree(GError) *error = NULL;
65+
autofree(GOptionContext) *context = NULL;
6466
autofree(gchar) *db_path = NULL;
6567
autofree(cve_string) *workdir = NULL;
6668
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 = { .len = 0 };
129+
cve_string st = { 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)