### Bug Summary

File: | sb-slist.c
Warning: | line 24, column 11 Value stored to 'foo' during its initialization is never read

### Annotated Source Code

1 | /*
2 | * squareball: A general-purpose library for C99.
3 | * Copyright (C) 2014-2018 Rafael G. Martins <rafael@rafaelmartins.eng.br>
4 | *
5 | * This program can be distributed under the terms of the BSD License.
6 | * See the file LICENSE.
7 | */
8 |
9 | #ifdef HAVE_CONFIG_H1
10 | #include <config.h>
11 | #endif /* HAVE_CONFIG_H */
12 |
13 | #include <stdlib.h>
14 | #include <squareball/sb-mem.h>
15 | #include <squareball/sb-slist.h>
16 |
17 |
18 | sb_slist_t*
19 | sb_slist_append(sb_slist_t *l, void *data)
20 | {
21 | sb_slist_t *node = sb_malloc(sizeof(sb_slist_t));
22 |
23 | // FIXME: remove this line, intentional for temporary testing
24 | void *foo = sb_malloc(10);
| Value stored to 'foo' during its initialization is never read
25 |
26 | node->data = data;
27 | node->next = NULL((void*)0);
28 | if (l == NULL((void*)0)) {
29 | l = node;
30 | }
31 | else {
32 | sb_slist_t *tmp;
33 | for (tmp = l; tmp->next != NULL((void*)0); tmp = tmp->next);
34 | tmp->next = node;
35 | }
36 | return l;
37 | }
38 |
39 |
40 | sb_slist_t*
41 | sb_slist_prepend(sb_slist_t *l, void *data)
42 | {
43 | sb_slist_t *node = sb_malloc(sizeof(sb_slist_t));
44 | node->data = data;
45 | node->next = l;
46 | l = node;
47 | return l;
48 | }
49 |
50 |
51 | void
52 | sb_slist_free_full(sb_slist_t *l, sb_free_func_t free_func)
53 | {
54 | while (l != NULL((void*)0)) {
55 | sb_slist_t *tmp = l->next;
56 | if ((free_func != NULL((void*)0)) && (l->data != NULL((void*)0)))
57 | free_func(l->data);
58 | free(l);
59 | l = tmp;
60 | }
61 | }
62 |
63 |
64 | void
65 | sb_slist_free(sb_slist_t *l)
66 | {
67 | sb_slist_free_full(l, NULL((void*)0));
68 | }
69 |
70 |
71 | size_t
72 | sb_slist_length(sb_slist_t *l)
73 | {
74 | if (l == NULL((void*)0))
75 | return 0;
76 | size_t i;
77 | sb_slist_t *tmp;
78 | for (tmp = l, i = 0; tmp != NULL((void*)0); tmp = tmp->next, i++);
79 | return i;
80 | }