Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions libutils/mutex.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ void __ThreadLock(pthread_mutex_t *mutex,
fprintf(stderr,
"Locking failure at %s:%d function %s! "
"(pthread_mutex_lock: %s)",
filename, lineno, funcname, GetErrorStrFromCode(result));
filename, lineno, funcname, strerror(result));
fflush(stdout);
fflush(stderr);
DoCleanupAndExit(101);
Expand All @@ -60,7 +60,7 @@ void __ThreadUnlock(pthread_mutex_t *mutex,
fprintf(stderr,
"Locking failure at %s:%d function %s! "
"(pthread_mutex_unlock: %s)",
filename, lineno, funcname, GetErrorStrFromCode(result));
filename, lineno, funcname, strerror(result));
fflush(stdout);
fflush(stderr);
DoCleanupAndExit(101);
Expand Down Expand Up @@ -92,7 +92,7 @@ int __ThreadWait(pthread_cond_t *pcond, pthread_mutex_t *mutex, int timeout,
Log(LOG_LEVEL_DEBUG,
"Thread condition timed out at %s:%d function %s! "
"(pthread_cond_timewait): %s)",
filename, lineno, funcname, GetErrorStrFromCode(result));
filename, lineno, funcname, strerror(result));
}
else
{
Expand All @@ -101,7 +101,7 @@ int __ThreadWait(pthread_cond_t *pcond, pthread_mutex_t *mutex, int timeout,
fprintf(stderr,
"Failed to wait for thread condition at %s:%d function "
"%s! (pthread_cond_(wait|timewait)): %s)",
filename, lineno, funcname, GetErrorStrFromCode(result));
filename, lineno, funcname, strerror(result));
fflush(stdout);
fflush(stderr);
DoCleanupAndExit(101);
Expand Down
2 changes: 1 addition & 1 deletion libutils/sequence.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

static const size_t EXPAND_FACTOR = 2;

Seq *SeqNew(size_t initialCapacity, void (ItemDestroy) (void *item))
Seq *(SeqNew)(size_t initialCapacity, void (ItemDestroy) (void *item))
{
Seq *seq = xmalloc(sizeof(Seq));

Expand Down
7 changes: 6 additions & 1 deletion libutils/sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,12 @@ size_t SeqLength(const Seq *seq);
@param [in] ItemDestroy Optional item destructor to clean up memory when needed.
@return A pointer to the created Sequence
*/
Seq *SeqNew(size_t initial_capacity, void (*ItemDestroy) ());
Seq *SeqNew(size_t initial_capacity, void (*ItemDestroy) (void *item));
/* Cast so callers may pass a destroyer taking a typed pointer, e.g.
* JsonDestroy(JsonElement *). The old 'void (*ItemDestroy) ()' prototype
* meant 'unspecified arguments' before C23, but means '(void)' in C23. */
#define SeqNew(initial_capacity, ItemDestroy) \
SeqNew((initial_capacity), (void (*)(void *)) (ItemDestroy))

/**
@brief Destroy an existing Sequence
Expand Down
2 changes: 1 addition & 1 deletion libutils/stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <logging.h>
#include <stack_base.c>

Stack *StackNew(size_t initial_capacity, void (ItemDestroy) (void *item))
Stack *(StackNew)(size_t initial_capacity, void (ItemDestroy) (void *item))
{
Stack *stack = xmalloc(sizeof(Stack));

Expand Down
5 changes: 4 additions & 1 deletion libutils/stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ typedef struct Stack_ Stack;
@param [in] initial_capacity Initial capacity, defaults to 1.
@param [in] ItemDestroy Function used to destroy data elements.
*/
Stack *StackNew(size_t initial_capacity, void (*ItemDestroy) ());
Stack *StackNew(size_t initial_capacity, void (*ItemDestroy) (void *item));
/* Cast so callers may pass a destroyer taking a typed pointer (see SeqNew). */
#define StackNew(initial_capacity, ItemDestroy) \
StackNew((initial_capacity), (void (*)(void *)) (ItemDestroy))

/**
@brief Destroys the stack and frees the memory it occupies.
Expand Down
16 changes: 8 additions & 8 deletions libutils/threaded_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ ThreadedQueue *ThreadedQueueNew(size_t initial_capacity,
Log(LOG_LEVEL_ERR,
"Failed to use error-checking mutexes for queue, "
"falling back to normal ones (pthread_mutexattr_settype: %s)",
GetErrorStrFromCode(ret));
strerror(ret));
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
}

Expand All @@ -83,7 +83,7 @@ ThreadedQueue *ThreadedQueueNew(size_t initial_capacity,
{
Log(LOG_LEVEL_ERR,
"Failed to initialize mutex (pthread_mutex_init: %s)",
GetErrorStrFromCode(ret));
strerror(ret));
pthread_mutexattr_destroy(&attr);
free(queue->lock);
free(queue);
Expand All @@ -98,7 +98,7 @@ ThreadedQueue *ThreadedQueueNew(size_t initial_capacity,
{
Log(LOG_LEVEL_ERR,
"Failed to initialize thread condition (pthread_cond_init: %s)",
GetErrorStrFromCode(ret));
strerror(ret));
free(queue->lock);
free(queue->cond_non_empty);
free(queue);
Expand All @@ -112,7 +112,7 @@ ThreadedQueue *ThreadedQueueNew(size_t initial_capacity,
Log(LOG_LEVEL_ERR,
"Failed to initialize thread condition "
"(pthread_cond_init: %s)",
GetErrorStrFromCode(ret));
strerror(ret));
free(queue->lock);
free(queue->cond_empty);
free(queue->cond_non_empty);
Expand Down Expand Up @@ -462,7 +462,7 @@ ThreadedQueue *ThreadedQueueCopy(ThreadedQueue *queue)
Log(LOG_LEVEL_ERR,
"Failed to use error-checking mutexes for queue, "
"falling back to normal ones (pthread_mutexattr_settype: %s)",
GetErrorStrFromCode(ret));
strerror(ret));
pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
}

Expand All @@ -472,7 +472,7 @@ ThreadedQueue *ThreadedQueueCopy(ThreadedQueue *queue)
{
Log(LOG_LEVEL_ERR,
"Failed to initialize mutex (pthread_mutex_init: %s)",
GetErrorStrFromCode(ret));
strerror(ret));
pthread_mutexattr_destroy(&attr);
free(new_queue->lock);
free(new_queue);
Expand All @@ -486,7 +486,7 @@ ThreadedQueue *ThreadedQueueCopy(ThreadedQueue *queue)
Log(LOG_LEVEL_ERR,
"Failed to initialize thread condition "
"(pthread_cond_init: %s)",
GetErrorStrFromCode(ret));
strerror(ret));
free(new_queue->lock);
free(new_queue->cond_non_empty);
free(new_queue);
Expand All @@ -500,7 +500,7 @@ ThreadedQueue *ThreadedQueueCopy(ThreadedQueue *queue)
Log(LOG_LEVEL_ERR,
"Failed to initialize thread condition "
"(pthread_cond_init: %s)",
GetErrorStrFromCode(ret));
strerror(ret));
free(new_queue->lock);
free(new_queue->cond_empty);
free(new_queue->cond_non_empty);
Expand Down
2 changes: 1 addition & 1 deletion libutils/threaded_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct ThreadedStack_ {
pthread_mutex_t *lock; /**< Thread lock for accessing data. */
};

ThreadedStack *ThreadedStackNew(size_t initial_capacity, void (ItemDestroy) (void *item))
ThreadedStack *(ThreadedStackNew)(size_t initial_capacity, void (ItemDestroy) (void *item))
{
ThreadedStack *stack = xmalloc(sizeof(ThreadedStack));

Expand Down
5 changes: 4 additions & 1 deletion libutils/threaded_stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ typedef struct ThreadedStack_ ThreadedStack;
@param [in] initial_capacity Initial capacity, defaults to 1.
@param [in] ItemDestroy Function used to destroy data elements.
*/
ThreadedStack *ThreadedStackNew(size_t initial_capacity, void (*ItemDestroy) ());
ThreadedStack *ThreadedStackNew(size_t initial_capacity, void (*ItemDestroy) (void *item));
/* Cast so callers may pass a destroyer taking a typed pointer (see SeqNew). */
#define ThreadedStackNew(initial_capacity, ItemDestroy) \
ThreadedStackNew((initial_capacity), (void (*)(void *)) (ItemDestroy))

/**
@brief Destroys the stack and frees the memory it occupies.
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/json_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -2425,7 +2425,7 @@ static void test_json_get_type_as_string()
}

{
JsonElement *element = JsonNullCreate(true);
JsonElement *element = JsonNullCreate();
const char *expected = "null";
const char *actual = JsonGetTypeAsString(element);
assert_string_equal(expected, actual);
Expand Down
Loading