HP Code Advisor Diagnostics Reference Guide (5900-1865, July 2011)

An element in an array or an unnamed field of a struct may be referenced prior to its initialization.
Example:
int a[2];
a[0] = 10;
if (cond)
a[1] = 12;
foo(a); // warning 20073: element 1 may be uninitialized
Action:
Ensure that all elements/fields of an array/struct are unconditionally initialized prior to accessing
them.
Reference:
2.162 20074 variable %s (field "%s") may be used before its value is set
Cause:
A field of a struct may be referenced prior to its initialization.
Example:
struct A {
int a;
int b;
};
struct A a;
a.a = 10;
if (cond)
a.b = 12;
foo(a); // warning 20074: field b of struct a may
// be uninitialized.
Action:
Ensure that all fields of a struct are unconditionally initialized prior to accessing them.
Reference:
2.163 20200 Potential null pointer dereference %s%s is detected %s
Cause:
A reference through a pointer whose value may be null has been detected. The pointer could have
been conditionally initialized or assigned with the return value of a function that may return NULL.
Example:
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
void nullptr3 ()
{
char *p = malloc (20); // LINE 6
strcpy (p, "nullptr3");
FILE* f = fopen("blah","r"); // LINE 8
if (p != NULL)
fread(p,20,1,f);
printf ("%s", p);
}
"file1.c", line 7, procedure nullptr3: warning #file1-D: Potential null
pointer dereference through p is detected (null definition:file1.c,
line 6)
"file1.c", line 10, procedure nullptr3: warning #file1-D: Potential null
pointer dereference through f is detected (null definition:file1.c,
line 8)
Action:
2.162 20074 variable %s (field "%s") may be used before its value is set 73