./include/optutils.h:12:18: warning: null pointer dereference [-Wnull-dereference]
for (o = opts; o->name; o++)
~^~~~~~
In file included from libfdisk/src/dos.c:12:0:
./include/pt-mbr.h:25:47: warning: potential null pointer dereference [-Wnull-dereference]
return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
~^~~
Well these should be impossible, so add assert() to catch possible bugs.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
#ifndef UTIL_LINUX_OPTUTILS_H
#define UTIL_LINUX_OPTUTILS_H
+#include <assert.h>
+
#include "c.h"
#include "nls.h"
{
const struct option *o;
+ assert(!(opts == NULL));
for (o = opts; o->name; o++)
if (o->val == c)
return o->name;
#ifndef UTIL_LINUX_PT_MBR_H
#define UTIL_LINUX_PT_MBR_H
+#include <assert.h>
+
struct dos_partition {
unsigned char boot_ind; /* 0x80 - active */
unsigned char bh, bs, bc; /* begin CHS */
static inline void __dos_store_4le(unsigned char *p, unsigned int val)
{
+ assert(!(p == NULL));
p[0] = (val & 0xff);
p[1] = ((val >> 8) & 0xff);
p[2] = ((val >> 16) & 0xff);