Fix the following classes of errors reported by gcc 12:
* ${variable} may be used uninitialized.
* ${variable} is set but not used.
* argument 2 is null but the corresponding size argument 3 value is 1 [-Werror=nonnull]
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
#include <sched.h>
int main(int argc, char **argv)
{
#include <sched.h>
int main(int argc, char **argv)
{
+ cpu_set_t mask = { };
+
return sched_setaffinity(0, sizeof(mask), &mask);
}
EOF
return sched_setaffinity(0, sizeof(mask), &mask);
}
EOF
#include <sched.h>
int main(int argc, char **argv)
{
#include <sched.h>
int main(int argc, char **argv)
{
+ cpu_set_t mask = { };
+
return sched_setaffinity(0, &mask);
}
EOF
return sched_setaffinity(0, &mask);
}
EOF
#include <sched.h>
int main(int argc, char **argv)
{
#include <sched.h>
int main(int argc, char **argv)
{
+ struct sched_param p = { };
+
return sched_setscheduler(0, SCHED_IDLE, &p);
}
EOF
return sched_setscheduler(0, SCHED_IDLE, &p);
}
EOF
#include <sys/uio.h>
int main(int argc, char **argv)
{
#include <sys/uio.h>
int main(int argc, char **argv)
{
- return pwritev(0, NULL, 1, 0) + preadv(0, NULL, 1, 0);
+ struct iovec iov[1] = { };
+
+ return pwritev(0, iov, 1, 0) + preadv(0, iov, 1, 0);
}
EOF
if compile_prog "" "" "pwritev"; then
}
EOF
if compile_prog "" "" "pwritev"; then
#include <sys/uio.h>
int main(int argc, char **argv)
{
#include <sys/uio.h>
int main(int argc, char **argv)
{
- return pwritev2(0, NULL, 1, 0, 0) + preadv2(0, NULL, 1, 0, 0);
+ struct iovec iov[1] = { };
+
+ return pwritev2(0, iov, 1, 0, 0) + preadv2(0, iov, 1, 0, 0);
}
EOF
if compile_prog "" "" "pwritev2"; then
}
EOF
if compile_prog "" "" "pwritev2"; then
#include <stdio.h>
int main(int argc, char **argv)
{
#include <stdio.h>
int main(int argc, char **argv)
{
- struct addrinfo hints;
- struct in6_addr addr;
+ struct addrinfo hints = { };
+ struct in6_addr addr = in6addr_any;
int ret;
ret = getaddrinfo(NULL, NULL, &hints, NULL);
freeaddrinfo(NULL);
int ret;
ret = getaddrinfo(NULL, NULL, &hints, NULL);
freeaddrinfo(NULL);
- printf("%s\n", gai_strerror(ret));
- addr = in6addr_any;
+ printf("%s %d\n", gai_strerror(ret), addr.s6_addr[0]);
+
#include <stdlib.h>
int main(int argc, char **argv)
{
#include <stdlib.h>
int main(int argc, char **argv)
{
- int rc;
- rc = pmem_is_pmem(NULL, 0);
- return 0;
+ return pmem_is_pmem(NULL, 0);
}
EOF
if compile_prog "" "-lpmem" "libpmem"; then
}
EOF
if compile_prog "" "-lpmem" "libpmem"; then
#include <stdlib.h>
int main(int argc, char **argv)
{
#include <stdlib.h>
int main(int argc, char **argv)
{
- pmem_memcpy(NULL, NULL, NULL, NULL);
+ pmem_memcpy(NULL, NULL, 0, 0);
FILE *mtab = setmntent(NULL, "r");
struct mntent *mnt = getmntent(mtab);
endmntent(mtab);
FILE *mtab = setmntent(NULL, "r");
struct mntent *mnt = getmntent(mtab);
endmntent(mtab);
}
EOF
if compile_prog "" "" "getmntent"; then
}
EOF
if compile_prog "" "" "getmntent"; then