summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpgen <p.gen.progs@gmail.com>2024-01-03 23:19:55 +0100
committerpgen <p.gen.progs@gmail.com>2024-01-03 23:19:55 +0100
commitb94264e55f4ac61c1d9d39382d96eff38f115a18 (patch)
tree13ad928ea80b8fdf5ce9316feba823d3786f38ea
parent31f6f07d8b3aa4bc9e950ebc5cfc52726b987ea1 (diff)
Normalize NULLity tests and fix a logical error
-rw-r--r--index.c12
-rw-r--r--list.c6
-rw-r--r--smenu.c23
-rw-r--r--utils.c2
-rw-r--r--xmalloc.c2
5 files changed, 23 insertions, 22 deletions
diff --git a/index.c b/index.c
index 903e769..2f886b0 100644
--- a/index.c
+++ b/index.c
@@ -69,10 +69,10 @@ tst_insert(tst_node_t *p, wchar_t *w, void *data)
void
tst_cleanup(tst_node_t *p)
{
- if (p)
+ if (p != NULL)
{
tst_cleanup(p->lokid);
- if (p->splitchar)
+ if (p->splitchar != L'\0')
tst_cleanup(p->eqkid);
tst_cleanup(p->hikid);
free(p);
@@ -95,7 +95,7 @@ tst_traverse(tst_node_t *p, int (*callback)(void *), int first_call)
if (first_call)
rc = 0;
- if (!p)
+ if (p == NULL)
return 0;
tst_traverse(p->lokid, callback, 0);
if (p->splitchar != L'\0')
@@ -123,7 +123,7 @@ tst_substring_traverse(tst_node_t *p,
if (first_call)
rc = 0;
- if (!p)
+ if (p == NULL)
return 0;
if (p->splitchar == w)
@@ -134,7 +134,7 @@ tst_substring_traverse(tst_node_t *p,
node = tst_search_list->tail;
sub_tst_data = (sub_tst_t *)(node->data);
- if (p->eqkid)
+ if (p->eqkid != NULL)
insert_sorted_ptr(&(sub_tst_data->array),
&(sub_tst_data->size),
&(sub_tst_data->count),
@@ -173,7 +173,7 @@ tst_fuzzy_traverse(tst_node_t *p,
if (first_call)
rc = 0;
- if (!p)
+ if (p == NULL)
return 0;
w1s[0] = p->splitchar;
diff --git a/list.c b/list.c
index 1887403..623d6b2 100644
--- a/list.c
+++ b/list.c
@@ -88,7 +88,7 @@ ll_append(ll_t * const list, void * const data)
node->next = NULL; /* This node will be the last. */
node->prev = list->tail; /* NULL if it is a new list. */
- if (list->tail)
+ if (list->tail != NULL)
list->tail->next = node;
else
list->head = node;
@@ -245,7 +245,7 @@ ll_find(ll_t * const list,
void
ll_free(ll_t * const list, void (*clean)(void *))
{
- if (list)
+ if (list != NULL)
{
ll_node_t *node = list->head;
@@ -269,7 +269,7 @@ ll_free(ll_t * const list, void (*clean)(void *))
void
ll_destroy(ll_t *list, void (*clean)(void *))
{
- if (list)
+ if (list != NULL)
{
ll_free(list, clean);
free(list);
diff --git a/smenu.c b/smenu.c
index 261ae97..4addcb1 100644
--- a/smenu.c
+++ b/smenu.c
@@ -839,7 +839,7 @@ ini_load(const char *filename,
/* We do that if the file is not readable as well. */
/* """"""""""""""""""""""""""""""""""""""""""""""" */
f = fopen_safe(filename, "r");
- if (!f)
+ if (f == NULL)
return 0; /* Returns success as the presence of this file *
| is optional. */
@@ -1468,7 +1468,7 @@ clean_matches(search_data_t *search_data, long size)
/* Clean the list of lists data-structure containing the search levels */
/* Note that the first element of the list is never deleted. */
/* """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
- if (tst_search_list)
+ if (tst_search_list != NULL)
{
ll_node_t *fuzzy_node;
sub_tst_t *sub_tst_data;
@@ -10069,7 +10069,7 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- if (include_pattern
+ if (include_pattern != NULL
&& regcomp(&include_re, include_pattern, REG_EXTENDED | REG_NOSUB) != 0)
{
fprintf(stderr, "%s: Bad regular expression.\n", include_pattern);
@@ -10077,7 +10077,7 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- if (exclude_pattern
+ if (exclude_pattern != NULL
&& regcomp(&exclude_re, exclude_pattern, REG_EXTENDED | REG_NOSUB) != 0)
{
fprintf(stderr, "%s: Bad regular expression.\n", exclude_pattern);
@@ -10085,7 +10085,7 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- if (first_word_pattern
+ if (first_word_pattern != NULL
&& regcomp(&first_word_re, first_word_pattern, REG_EXTENDED | REG_NOSUB)
!= 0)
{
@@ -10094,7 +10094,7 @@ main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- if (last_word_pattern
+ if (last_word_pattern != NULL
&& regcomp(&last_word_re, last_word_pattern, REG_EXTENDED | REG_NOSUB)
!= 0)
{
@@ -10105,7 +10105,7 @@ main(int argc, char *argv[])
for (index = 0; index < 9; index++)
{
- if (special_pattern[index]
+ if (special_pattern[index] != NULL
&& regcomp(&special_re[index],
special_pattern[index],
REG_EXTENDED | REG_NOSUB)
@@ -10536,11 +10536,11 @@ main(int argc, char *argv[])
/* """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" */
if (win.col_mode || win.line_mode || win.tab_mode)
{
- if (first_word_pattern
+ if (first_word_pattern != NULL
&& regexec(&first_word_re, word, (int)0, NULL, 0) == 0)
is_first = 1;
- if (last_word_pattern && !is_last
+ if (last_word_pattern != NULL && !is_last
&& regexec(&last_word_re, word, (int)0, NULL, 0) == 0)
is_last = 1;
}
@@ -10733,7 +10733,8 @@ main(int argc, char *argv[])
/* Check if the word will be excluded in the list of selectable */
/* words or not. */
/* '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' */
- if (exclude_pattern && regexec(&exclude_re, word, (int)0, NULL, 0) == 0)
+ if (exclude_pattern != NULL
+ && regexec(&exclude_re, word, (int)0, NULL, 0) == 0)
selectable = EXCLUDE_MARK;
if (selectable != 0 && !line_selected_by_regex)
@@ -10741,7 +10742,7 @@ main(int argc, char *argv[])
/* Check if the word will be included in the list of selectable */
/* words or not. */
/* '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' */
- if (include_pattern)
+ if (include_pattern != NULL)
{
if (regexec(&include_re, word, (int)0, NULL, 0) == 0)
selectable = INCLUDE_MARK;
diff --git a/utils.c b/utils.c
index a5ad569..4f5d89c 100644
--- a/utils.c
+++ b/utils.c
@@ -368,7 +368,7 @@ swap_string_parts(char **s, size_t first)
void
strrep(char *s, const char c1, const char c2)
{
- if (s)
+ if (s != NULL)
while (*s)
{
if (*s == c1)
diff --git a/xmalloc.c b/xmalloc.c
index df00249..4e7f35d 100644
--- a/xmalloc.c
+++ b/xmalloc.c
@@ -157,7 +157,7 @@ xstrndup(const char *str, size_t len)
p = memchr(str, '\0', len);
- if (p)
+ if (p != NULL)
len = p - str;
p = malloc(len + 1);