Skip to content

Commit

Permalink
common: make 'lenient_strcmp' arguments const
Browse files Browse the repository at this point in the history
Prevents build failures when calling the function with 'const char *'
arguments.
This is also more accurate since the function is not expected to modify
the args.
  • Loading branch information
paul-ri authored and emersion committed Dec 4, 2020
1 parent 32b93ef commit 4583fee
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion common/stringop.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ char *lenient_strncat(char *dest, const char *src, size_t len) {
}

// strcmp that also handles null pointers.
int lenient_strcmp(char *a, char *b) {
int lenient_strcmp(const char *a, const char *b) {
if (a == b) {
return 0;
} else if (!a) {
Expand Down
2 changes: 1 addition & 1 deletion include/stringop.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ char *lenient_strcat(char *dest, const char *src);
char *lenient_strncat(char *dest, const char *src, size_t len);

// strcmp that also handles null pointers.
int lenient_strcmp(char *a, char *b);
int lenient_strcmp(const char *a, const char *b);

// Simply split a string with delims, free with `list_free_items_and_destroy`
list_t *split_string(const char *str, const char *delims);
Expand Down

0 comments on commit 4583fee

Please sign in to comment.