No need to handle impossible things.
The string given to logmanager_write_log cannot be NULL. The id given to logmanager_write_log cannot be invalid. Consequently we need not handle those possibilities.
This commit is contained in:
@ -627,30 +627,14 @@ static int logmanager_write_log(logfile_id_t id,
|
|||||||
size_t timestamp_len;
|
size_t timestamp_len;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
assert(str);
|
||||||
|
assert(logmanager_is_valid_id(id));
|
||||||
CHK_LOGMANAGER(lm);
|
CHK_LOGMANAGER(lm);
|
||||||
|
|
||||||
if (!logmanager_is_valid_id(id))
|
|
||||||
{
|
|
||||||
err = -1;
|
|
||||||
ss_dassert(false);
|
|
||||||
goto return_err;
|
|
||||||
}
|
|
||||||
// All messages are now logged to the error log file.
|
// All messages are now logged to the error log file.
|
||||||
lf = &lm->lm_logfile;
|
lf = &lm->lm_logfile;
|
||||||
CHK_LOGFILE(lf);
|
CHK_LOGFILE(lf);
|
||||||
|
|
||||||
/**
|
|
||||||
* When string pointer is NULL, operation is flush.
|
|
||||||
*/
|
|
||||||
if (str == NULL)
|
|
||||||
{
|
|
||||||
if (flush)
|
|
||||||
{
|
|
||||||
logfile_flush(lf); /*< wakes up file writer */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/** Length of string that will be written, limited by bufsize */
|
/** Length of string that will be written, limited by bufsize */
|
||||||
size_t safe_str_len;
|
size_t safe_str_len;
|
||||||
/** Length of session id */
|
/** Length of session id */
|
||||||
@ -812,9 +796,7 @@ static int logmanager_write_log(logfile_id_t id,
|
|||||||
{
|
{
|
||||||
free(wp);
|
free(wp);
|
||||||
}
|
}
|
||||||
} /* if (str == NULL) */
|
|
||||||
|
|
||||||
return_err:
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user