0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 04:42:18 +02:00

libobs: Minor fixes / code cleanups

Fixes some warnings generated by code analysis tools, removing redundant
checks etc.
This commit is contained in:
Richard Stanway 2021-01-24 15:30:10 +01:00
parent 13cfd95fef
commit 6c0d234385
6 changed files with 22 additions and 14 deletions

View File

@ -791,7 +791,7 @@ static void set_item_data(struct obs_data *data, struct obs_data_item **item,
{
obs_data_item_t *new_item = NULL;
if ((!item || (item && !*item)) && data) {
if ((!item || !*item) && data) {
new_item = obs_data_item_create(name, ptr, size, type,
default_data, autoselect_data);
@ -860,7 +860,7 @@ static inline void set_item_def(struct obs_data *data, obs_data_item_t **item,
item = &actual_item;
}
if (item && *item && (*item)->type != type)
if (*item && (*item)->type != type)
return;
set_item_data(data, item, name, ptr, size, type, true, false);

View File

@ -31,7 +31,7 @@ static inline bool delay_capturing(const struct obs_output *output)
static inline void push_packet(struct obs_output *output,
struct encoder_packet *packet, uint64_t t)
{
struct delay_data dd = {0};
struct delay_data dd;
dd.msg = DELAY_MSG_PACKET;
dd.ts = t;

View File

@ -2865,8 +2865,7 @@ obs_source_output_video_internal(obs_source_t *source,
return;
}
struct obs_source_frame *output = !!frame ? cache_video(source, frame)
: NULL;
struct obs_source_frame *output = cache_video(source, frame);
/* ------------------------------------------- */
pthread_mutex_lock(&source->async_mutex);

View File

@ -135,8 +135,7 @@ static inline void circlebuf_place(struct circlebuf *cb, size_t position,
size_t back_size = data_end_pos - cb->capacity;
size_t loop_size = size - back_size;
if (back_size)
memcpy((uint8_t *)cb->data + position, data, loop_size);
memcpy((uint8_t *)cb->data + position, data, loop_size);
memcpy(cb->data, (uint8_t *)data + loop_size, back_size);
} else {
memcpy((uint8_t *)cb->data + position, data, size);

View File

@ -88,10 +88,12 @@ static inline void darray_reserve(const size_t element_size, struct darray *dst,
return;
ptr = bmalloc(element_size * capacity);
if (dst->num)
memcpy(ptr, dst->array, element_size * dst->num);
if (dst->array)
if (dst->array) {
if (dst->num)
memcpy(ptr, dst->array, element_size * dst->num);
bfree(dst->array);
}
dst->array = ptr;
dst->capacity = capacity;
}
@ -109,10 +111,12 @@ static inline void darray_ensure_capacity(const size_t element_size,
if (new_size > new_cap)
new_cap = new_size;
ptr = bmalloc(element_size * new_cap);
if (dst->capacity)
memcpy(ptr, dst->array, element_size * dst->capacity);
if (dst->array)
if (dst->array) {
if (dst->capacity)
memcpy(ptr, dst->array, element_size * dst->capacity);
bfree(dst->array);
}
dst->array = ptr;
dst->capacity = new_cap;
}
@ -405,6 +409,9 @@ static inline void darray_move_item(const size_t element_size,
return;
temp = malloc(element_size);
if (!temp)
bcrash("darray_move_item: out of memory");
p_from = darray_item(element_size, dst, from);
p_to = darray_item(element_size, dst, to);
@ -433,6 +440,9 @@ static inline void darray_swap(const size_t element_size, struct darray *dst,
return;
temp = malloc(element_size);
if (!temp)
bcrash("darray_swap: out of memory");
a_ptr = darray_item(element_size, dst, a);
b_ptr = darray_item(element_size, dst, b);

View File

@ -392,7 +392,7 @@ size_t os_wcs_to_mbs(const wchar_t *str, size_t len, char *dst, size_t dst_size)
if (!str)
return 0;
out_len = dst ? (dst_size - 1) : wcstombs(NULL, str, len);
out_len = dst ? (dst_size - 1) : wcstombs(NULL, str, 0);
if (dst) {
if (!dst_size)