File: | src/usr.sbin/nsd/obj/conftest.c |
Warning: | line 113, column 4 Value stored to 'str' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
1 | /* confdefs.h */ |
2 | #define PACKAGE_NAME"NSD" "NSD" |
3 | #define PACKAGE_TARNAME"nsd" "nsd" |
4 | #define PACKAGE_VERSION"4.8.0" "4.8.0" |
5 | #define PACKAGE_STRING"NSD 4.8.0" "NSD 4.8.0" |
6 | #define PACKAGE_BUGREPORT"https://github.com/NLnetLabs/nsd/issues or nsd-bugs@nlnetlabs.nl" "https://github.com/NLnetLabs/nsd/issues or nsd-bugs@nlnetlabs.nl" |
7 | #define PACKAGE_URL"" "" |
8 | #define CONFCMDLINE"--prefix=/usr --localstatedir=/var --sysconfdir=/etc --with-ssl=/usr --with-user=_nsd --with-chroot=/var/nsd --with-configdir=/var/nsd/etc --with-pidfile= --with-zonesdir=/var/nsd/zones --with-dbfile= --with-zonelistfile=/var/nsd/db/zone.list --with-xfrdir=/var/nsd/run/xfr --with-xfrdfile=/var/nsd/run/xfrd.state --with-libevent=/usr --enable-ratelimit" "--prefix=/usr --localstatedir=/var --sysconfdir=/etc --with-ssl=/usr --with-user=_nsd --with-chroot=/var/nsd --with-configdir=/var/nsd/etc --with-pidfile= --with-zonesdir=/var/nsd/zones --with-dbfile= --with-zonelistfile=/var/nsd/db/zone.list --with-xfrdir=/var/nsd/run/xfr --with-xfrdfile=/var/nsd/run/xfrd.state --with-libevent=/usr --enable-ratelimit" |
9 | #define STDC_HEADERS1 1 |
10 | #define HAVE_SYS_TYPES_H1 1 |
11 | #define HAVE_SYS_STAT_H1 1 |
12 | #define HAVE_STDLIB_H1 1 |
13 | #define HAVE_STRING_H1 1 |
14 | #define HAVE_MEMORY_H1 1 |
15 | #define HAVE_STRINGS_H1 1 |
16 | #define HAVE_INTTYPES_H1 1 |
17 | #define HAVE_STDINT_H1 1 |
18 | #define HAVE_UNISTD_H1 1 |
19 | #define __EXTENSIONS__1 1 |
20 | #define _ALL_SOURCE1 1 |
21 | #define _GNU_SOURCE1 1 |
22 | #define _POSIX_PTHREAD_SEMANTICS1 1 |
23 | #define _TANDEM_SOURCE1 1 |
24 | #define CONFIGDIR"/var/nsd/etc" "/var/nsd/etc" |
25 | #define CONFIGFILE"/var/nsd/etc/nsd.conf" "/var/nsd/etc/nsd.conf" |
26 | #define PIDFILE"" "" |
27 | #define ZONESDIR"/var/nsd/zones" "/var/nsd/zones" |
28 | #define XFRDFILE"/var/nsd/run/xfrd.state" "/var/nsd/run/xfrd.state" |
29 | #define ZONELISTFILE"/var/nsd/db/zone.list" "/var/nsd/db/zone.list" |
30 | #define XFRDIR"/var/nsd/run/xfr" "/var/nsd/run/xfr" |
31 | #define NSD_START_PATH"/usr/sbin/nsd" "/usr/sbin/nsd" |
32 | #define CHROOTDIR"/var/nsd" "/var/nsd" |
33 | #define USER"_nsd" "_nsd" |
34 | /* end confdefs.h. */ |
35 | #include <stdarg.h> |
36 | #include <stdbool.h> |
37 | #include <stdlib.h> |
38 | #include <wchar.h> |
39 | #include <stdio.h> |
40 | |
41 | // Check varargs macros. These examples are taken from C99 6.10.3.5. |
42 | #define debug(...)fprintf ((&__sF[2]), ...) fprintf (stderr(&__sF[2]), __VA_ARGS__) |
43 | #define showlist(...)puts ("...") puts (#__VA_ARGS__) |
44 | #define report(test,...)((test) ? puts ("test") : printf (...)) ((test) ? puts (#test) : printf (__VA_ARGS__)) |
45 | static void |
46 | test_varargs_macros (void) |
47 | { |
48 | int x = 1234; |
49 | int y = 5678; |
50 | debug ("Flag")fprintf ((&__sF[2]), "Flag"); |
51 | debug ("X = %d\n", x)fprintf ((&__sF[2]), "X = %d\n", x); |
52 | showlist (The first, second, and third items.)puts ("The first, second, and third items."); |
53 | report (x>y, "x is %d but y is %d", x, y)((x>y) ? puts ("x>y") : printf ("x is %d but y is %d", x , y)); |
54 | } |
55 | |
56 | // Check long long types. |
57 | #define BIG6418446744073709551615ull 18446744073709551615ull |
58 | #define BIG324294967295ul 4294967295ul |
59 | #define BIG_OK(18446744073709551615ull / 4294967295ul == 4294967297ull && 18446744073709551615ull % 4294967295ul == 0) (BIG6418446744073709551615ull / BIG324294967295ul == 4294967297ull && BIG6418446744073709551615ull % BIG324294967295ul == 0) |
60 | #if !BIG_OK(18446744073709551615ull / 4294967295ul == 4294967297ull && 18446744073709551615ull % 4294967295ul == 0) |
61 | your preprocessor is broken; |
62 | #endif |
63 | #if BIG_OK(18446744073709551615ull / 4294967295ul == 4294967297ull && 18446744073709551615ull % 4294967295ul == 0) |
64 | #else |
65 | your preprocessor is broken; |
66 | #endif |
67 | static long long int bignum = -9223372036854775807LL; |
68 | static unsigned long long int ubignum = BIG6418446744073709551615ull; |
69 | |
70 | struct incomplete_array |
71 | { |
72 | int datasize; |
73 | double data[]; |
74 | }; |
75 | |
76 | struct named_init { |
77 | int number; |
78 | const wchar_t *name; |
79 | double average; |
80 | }; |
81 | |
82 | typedef const char *ccp; |
83 | |
84 | static inline int |
85 | test_restrict (ccp restrict text) |
86 | { |
87 | // See if C++-style comments work. |
88 | // Iterate through items via the restricted pointer. |
89 | // Also check for declarations in for loops. |
90 | for (unsigned int i = 0; *(text+i) != '\0'; ++i) |
91 | continue; |
92 | return 0; |
93 | } |
94 | |
95 | // Check varargs and va_copy. |
96 | static void |
97 | test_varargs (const char *format, ...) |
98 | { |
99 | va_list args; |
100 | va_start (args, format)__builtin_va_start((args), format); |
101 | va_list args_copy; |
102 | va_copy (args_copy, args)__builtin_va_copy(((args_copy)),((args))); |
103 | |
104 | const char *str; |
105 | int number; |
106 | float fnumber; |
107 | |
108 | while (*format) |
109 | { |
110 | switch (*format++) |
111 | { |
112 | case 's': // string |
113 | str = va_arg (args_copy, const char *)__builtin_va_arg((args_copy), const char *); |
Value stored to 'str' is never read | |
114 | break; |
115 | case 'd': // int |
116 | number = va_arg (args_copy, int)__builtin_va_arg((args_copy), int); |
117 | break; |
118 | case 'f': // float |
119 | fnumber = va_arg (args_copy, double)__builtin_va_arg((args_copy), double); |
120 | break; |
121 | default: |
122 | break; |
123 | } |
124 | } |
125 | va_end (args_copy)__builtin_va_end((args_copy)); |
126 | va_end (args)__builtin_va_end((args)); |
127 | } |
128 | |
129 | int |
130 | main () |
131 | { |
132 | |
133 | // Check bool. |
134 | _Bool success = false0; |
135 | |
136 | // Check restrict. |
137 | if (test_restrict ("String literal") == 0) |
138 | success = true1; |
139 | char *restrict newvar = "Another string"; |
140 | |
141 | // Check varargs. |
142 | test_varargs ("s, d' f .", "string", 65, 34.234); |
143 | test_varargs_macros (); |
144 | |
145 | // Check flexible array members. |
146 | struct incomplete_array *ia = |
147 | malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10)); |
148 | ia->datasize = 10; |
149 | for (int i = 0; i < ia->datasize; ++i) |
150 | ia->data[i] = i * 1.234; |
151 | |
152 | // Check named initializers. |
153 | struct named_init ni = { |
154 | .number = 34, |
155 | .name = L"Test wide string", |
156 | .average = 543.34343, |
157 | }; |
158 | |
159 | ni.number = 58; |
160 | |
161 | int dynamic_array[ni.number]; |
162 | dynamic_array[ni.number - 1] = 543; |
163 | |
164 | // work around unused variable warnings |
165 | return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x' |
166 | || dynamic_array[ni.number - 1] != 543); |
167 | |
168 | ; |
169 | return 0; |
170 | } |