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
2 changes: 1 addition & 1 deletion src/in.c
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ ly_in_filepath(struct ly_in *in, const char *filepath, size_t len)
int fd, prev_fd;
char *fp = NULL;

LY_CHECK_ARG_RET(NULL, in, in->type == LY_IN_FILEPATH, filepath ? NULL : ((void *)-1));
LY_CHECK_ARG_RET(NULL, in, in->type == LY_IN_FILEPATH, ((void *)-1));

if (!filepath) {
return in->method.fpath.filepath;
Expand Down
7 changes: 7 additions & 0 deletions tests/utests/basic/test_inout.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ test_input_filepath(void **UNUSED(state))
assert_int_equal(LY_EINVAL, ly_in_new_filepath(NULL, 0, NULL));
assert_int_equal(LY_EINVAL, ly_in_new_filepath(path1, 0, NULL));
assert_ptr_equal(((void *)-1), ly_in_filepath(NULL, NULL, 0));
assert_ptr_equal(((void *)-1), ly_in_filepath(NULL, path1, 0));

/* changing the file path of a handler of another type is an error */
assert_int_equal(LY_SUCCESS, ly_in_new_memory("data", &in));
assert_ptr_equal(((void *)-1), ly_in_filepath(in, path1, 0));
assert_int_equal(LY_IN_MEMORY, ly_in_type(in));
ly_in_free(in, 0);

assert_int_equal(LY_SUCCESS, ly_in_new_filepath(path1, 0, &in));
assert_int_equal(LY_IN_FILEPATH, ly_in_type(in));
Expand Down