Assume non-NULL serial in file_handler
The previous commit guarantees to always initialize the serial, so the file_handle may assume it is never NULL.
This commit is contained in:
parent
b30c3a429f
commit
443cb14d6e
1 changed files with 7 additions and 10 deletions
|
@ -16,6 +16,7 @@ file_handler_request_destroy(struct file_handler_request *req) {
|
||||||
bool
|
bool
|
||||||
file_handler_init(struct file_handler *file_handler, const char *serial,
|
file_handler_init(struct file_handler *file_handler, const char *serial,
|
||||||
const char *push_target) {
|
const char *push_target) {
|
||||||
|
assert(serial);
|
||||||
|
|
||||||
cbuf_init(&file_handler->queue);
|
cbuf_init(&file_handler->queue);
|
||||||
|
|
||||||
|
@ -30,16 +31,12 @@ file_handler_init(struct file_handler *file_handler, const char *serial,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (serial) {
|
file_handler->serial = strdup(serial);
|
||||||
file_handler->serial = strdup(serial);
|
if (!file_handler->serial) {
|
||||||
if (!file_handler->serial) {
|
LOGE("Could not strdup serial");
|
||||||
LOGW("Could not strdup serial");
|
sc_cond_destroy(&file_handler->event_cond);
|
||||||
sc_cond_destroy(&file_handler->event_cond);
|
sc_mutex_destroy(&file_handler->mutex);
|
||||||
sc_mutex_destroy(&file_handler->mutex);
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
file_handler->serial = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// lazy initialization
|
// lazy initialization
|
||||||
|
|
Loading…
Reference in a new issue