Enable calling clicon_err_fn with fn=NULL

This commit is contained in:
Olof hagsand 2022-07-22 18:36:53 +02:00
parent aaa18897ef
commit f9eacebf68

View file

@ -239,30 +239,48 @@ clicon_err_fn(const char *fn,
if (cec->cec_logfn(cec->cec_handle, suberr, cb) < 0) if (cec->cec_logfn(cec->cec_handle, suberr, cb) < 0)
goto done; goto done;
/* Here we could take care of specific errno, like application-defined errors */ /* Here we could take care of specific errno, like application-defined errors */
clicon_log(LOG_ERR, "%s: %d: %s: %s: %s", if (fn)
fn, clicon_log(LOG_ERR, "%s: %d: %s: %s: %s",
line, fn,
clicon_strerror(category), line,
cbuf_get(cb), clicon_strerror(category),
msg); cbuf_get(cb),
msg);
else
clicon_log(LOG_ERR, "%s: %s: %s",
clicon_strerror(category),
cbuf_get(cb),
msg);
if (cb) if (cb)
cbuf_free(cb); cbuf_free(cb);
} }
else if (suberr){ /* Actually log it */ else if (suberr){ /* Actually log it */
/* Here we could take care of specific errno, like application-defined errors */ /* Here we could take care of specific errno, like application-defined errors */
clicon_log(LOG_ERR, "%s: %d: %s: %s: %s", if (fn)
fn, clicon_log(LOG_ERR, "%s: %d: %s: %s: %s",
line, fn,
clicon_strerror(category), line,
msg, clicon_strerror(category),
suberr==XMLPARSE_ERRNO?"XML parse error":strerror(suberr)); msg,
suberr==XMLPARSE_ERRNO?"XML parse error":strerror(suberr));
else
clicon_log(LOG_ERR, "%s: %s: %s",
clicon_strerror(category),
msg,
suberr==XMLPARSE_ERRNO?"XML parse error":strerror(suberr));
}
else{
if (fn)
clicon_log(LOG_ERR, "%s: %d: %s: %s",
fn,
line,
clicon_strerror(category),
msg);
else
clicon_log(LOG_ERR, "%s: %s",
clicon_strerror(category),
msg);
} }
else
clicon_log(LOG_ERR, "%s: %d: %s: %s",
fn,
line,
clicon_strerror(category),
msg);
retval = 0; retval = 0;
done: done:
if (msg) if (msg)