* Ensure all fopen check for NULL (not -1)

* Improve test-perf cycles
This commit is contained in:
Olof hagsand 2020-12-07 09:56:07 +01:00
parent 344dcacf6f
commit e1b94d94d2
20 changed files with 24 additions and 23 deletions

View file

@ -453,7 +453,7 @@ xmldb_readfile(clicon_handle h,
goto done;
}
/* Parse file into internal XML tree from different formats */
if ((fp = fopen(dbfile, "r")) < 0) {
if ((fp = fopen(dbfile, "r")) == NULL) {
clicon_err(OE_UNIX, errno, "open(%s)", dbfile);
goto done;
}

View file

@ -211,7 +211,7 @@ parse_configfile_one(const char *filename,
cbuf *cbret = NULL;
int ret;
if ((fp = fopen(filename, "r")) < 0){
if ((fp = fopen(filename, "r")) == NULL){
clicon_err(OE_UNIX, errno, "open configure file: %s", filename);
return -1;
}

View file

@ -445,7 +445,7 @@ clixon_xml_changelog_init(clicon_handle h)
yspec = clicon_dbspec_yang(h);
if ((filename = clicon_option_str(h, "CLICON_XML_CHANGELOG_FILE")) != NULL){
if ((fp = fopen(filename, "r")) < 0){
if ((fp = fopen(filename, "r")) == NULL){
clicon_err(OE_UNIX, errno, "fopen(%s)", filename);
goto done;
}

View file

@ -582,7 +582,8 @@ FSM(char *tag,
* cxobj *xt = NULL;
* cxobj *xerr = NULL;
* FILE *f;
* f = fopen(filename, "r");
* if ((f = fopen(filename, "r")) == NULL)
* err;
* if ((ret = clixon_xml_parse_file(f, YB_MODULE, yspec, "</config>", &xt, &xerr)) < 0)
* err;
* xml_free(xt);