HP-UX Cadvise Diagnostics Reference Guide (5900-1865, August 2012)

Table Of Contents
s = (char*) malloc(128);
if (s == 0) exit(1);
}
sprintf(s,"%d",x); // LINE 25
puts(s);
}
line 9, procedure mod_astring: warning #20213-D: Potential write to
readonly memory through astring is detected
line 25, procedure possible: warning #20213-D: Potential write to
readonly memory through s is detected
Action:
Look at the definition of the memory written to and make sure that it is not defined as "const".
Reference:
20229 variable "%s" is uninitialized if the loop %s is not executed
Cause:
This warning is issued by the compiler if a variable is initialized in the loop body. Initialization of
this variable depends on the loop execution.
Example:
#include<stdio.h>
int foo(int n)
{
int var;
for (int i=0; i<n; i++) {
var = i;
}
printf("var: %d\n", var);
return var;
}
int main()
{
foo(5);
return 0;
}
Action:
Ensure that all the elements declared before the loop are not initialized inside the loop.
Reference:
20231 variable "%s" (field "%s") may be used before its value is set if the
loop %s is not executed
Cause:
Example:
#include <stdio.h>
struct S { int v; int c;};
int foo2(int n)
{
struct S var;
for (int i=10; i<n; i++) {
var.v = i;
}
var.c = 5;
printf ("%d\n",var.v);
return var.c;
}
int main()
78 Diagnostics Details