File maybe-uninitialized.patch of Package ftnchek
Fix some maybe-uninitialized warnings given by the compiler.
The change at prlists.c:182 causes a regression, see patch "fix_alist_null-deref.patch".
diff -Nupr ../ftnchek/comcheck.c ftnchek/comcheck.c
--- ../ftnchek/comcheck.c 2020-09-10 10:41:53.161765667 +0200
+++ ftnchek/comcheck.c 2020-10-29 14:02:29.593210781 +0100
@@ -239,6 +239,9 @@ com_cmp_lax(name,c1,c2)
len1=len2=0;
word1=word2=1;
cmp_error_count=0;
+ defsize1=defsize2=0;
+ type1=type2=0;
+ size1=size2=0;
for(;;) {
if(len1 == 0) { /* move to next variable in list 1 */
if(i1 == n1) {
diff -Nupr ../ftnchek/intake.c ftnchek/intake.c
--- ../ftnchek/intake.c 2020-09-10 10:41:51.741731236 +0200
+++ ftnchek/intake.c 2020-10-29 14:28:16.517697449 +0100
@@ -337,10 +338,10 @@ find_free_contins(srcLine *Buf)
{
int to_be_continued = FALSE; /* remembers '&' of previous line */
int inside_quote = FALSE;
- int quoteChar; /* opening quote character */
+ int quoteChar = '\0'; /* opening quote character */
int inside_number = FALSE; /* used for continued hollerith numbers */
int prev_sig_char = ' '; /* previous significant character */
- int num_val; /* value of number recently seen */
+ int num_val = 0; /* value of number recently seen */
while( Buf != (srcLine *)NULL ) {
Buf->overlength = FALSE;
if( Buf->comment) { /* skip comment lines */
@@ -551,11 +560,11 @@ PRIVATE void
find_fixed_contins(srcLine *Buf)
{
int inside_quote = FALSE;
- int quoteChar; /* opening quote character */
- int hollerith_count=0; /* used to deal with continued holleriths */
+ int quoteChar = '\0'; /* opening quote character */
+ int hollerith_count = 0; /* used to deal with continued holleriths */
int inside_number = FALSE; /* used for continued hollerith numbers */
int prev_sig_char = ' '; /* previous significant character */
- int num_val; /* value of number recently seen */
+ int num_val = 0; /* value of number recently seen */
int tab_count = 0; /* tabs seen, for -port=tab option */
while( Buf != (srcLine *)NULL ) {
Buf->overlength = FALSE;
@@ -567,7 +576,7 @@ find_fixed_contins(srcLine *Buf)
}
else {
COLNO_t col;
- int i,c;
+ int i, c = '\0';
char *s = Buf->line;
/* Handle DEC tabs: followed by nonzero digit
diff -Nupr ../ftnchek/prlists.c ftnchek/prlists.c
--- ../ftnchek/prlists.c 2020-09-10 10:41:54.405795825 +0200
+++ ftnchek/prlists.c 2020-10-29 17:05:00.479537757 +0100
@@ -178,7 +178,7 @@ if((gsymt=hashtab[h].glob_symtab) == NUL
oops_tail(loc_symtab[i].name);
}
else {
- ArgListHeader *a;
+ ArgListHeader *a = NULL;
int implied_type;
extern int interface_block; /* shared with fortran.y */
while (head_ptr != NULL){
diff -Nupr ../ftnchek/prlocsym.c ftnchek/prlocsym.c
--- ../ftnchek/prlocsym.c 2020-09-10 10:41:56.537847502 +0200
+++ ftnchek/prlocsym.c 2020-10-29 14:17:14.934089092 +0100
@@ -655,8 +655,8 @@ print_io_unit_usages(VOID)
static const char* IO_form[] ={"","UNF","FMTD"};
/* variables for remembering what was printed */
- int old_id, old_no, old_op, old_acc, old_form;
- int cols;
+ int old_id = 0, old_no = 0, old_op = 0, old_acc = 0, old_form = 0;
+ int cols = 0;
sort_io_unit_usages(); /* put list into sorted order */
diff -Nupr ../ftnchek/project.c ftnchek/project.c
--- ../ftnchek/project.c 2020-09-10 10:41:54.065787583 +0200
+++ ftnchek/project.c 2020-10-29 15:26:13.811945669 +0100
@@ -699,8 +699,8 @@ alist_out(Gsymtab *gsymt, FILE *fd, int
/* This loop runs thru only those arglists that were
created in the current top file. */
- last_calling_prog_unit = NULL;
- while( a != NULL && (mode == MODE_MODULE || a->topfile == top_filename)) {
+ last_calling_prog_unit = NULL;
+ while( a != NULL && (mode == MODE_MODULE || a->topfile == top_filename)) {
/* do_defns mode: output only definitions */
if( (do_defns && a->is_defn) || (!do_defns && !a->is_defn) ) {
/* keep only externals not satisfied in this file in -lib
@@ -1325,7 +1325,7 @@ mod_type_in(FILE *fd, const char *module
int component_array_dims;
unsigned long component_array_elts;
int duplicate_dtype = FALSE;
- Dtype *dtype;
+ Dtype *dtype = NULL;
DtypeComponent *curr;
int h, home_h;
Lsymtab *symt;
@@ -1586,7 +1586,7 @@ mod_var_in(FILE *fd, const char *filenam
}
#endif
{
- Lsymtab *symt;
+ Lsymtab *symt = NULL;
if (use_this_item) {
int h = hash_lookup(local_name);
int home_h = hash_lookup(id_home);
@@ -1722,8 +1722,8 @@ arg_info_in(fd,filename,is_defn,item_lis
id_pure,
future1;
- unsigned h;
- Gsymtab *gsymt, *prog_unit;
+ unsigned h = 0;
+ Gsymtab *gsymt = NULL, *prog_unit;
unsigned alist_class,alist_type,alist_is_defn,alist_is_call,
alist_external_decl,alist_actual_arg;
unsigned alist_array_result;
@@ -1865,11 +1865,11 @@ id_name,id_class,id_type);
#endif
strcmp(sentinel,(is_defn?"defn":"call")) == 0) {
ArgListHeader *ahead;
- ArgListElement *alist;
+ ArgListElement *alist = NULL;
#ifdef KEEP_ARG_NAMES
- ArgListHeader *prev_ahead;
- ArgListElement *prev_alist;
- unsigned prev_n;
+ ArgListHeader *prev_ahead = NULL;
+ ArgListElement *prev_alist = NULL;
+ unsigned prev_n = 0;
#endif
NEXTLINE;
@@ -2150,7 +2150,7 @@ com_info_in(FILE *fd, const char *filena
clist_saved,
clist_future;
unsigned clist_line,clist_topline;
- unsigned numvars,prev_n,ivar,var_num,var_class,var_type;
+ unsigned numvars, prev_n = 0,ivar,var_num,var_class,var_type;
kind_t var_kind;
int var_dims;
unsigned long var_elts;
@@ -2165,9 +2165,9 @@ com_info_in(FILE *fd, const char *filena
var_future_1;
long var_size;
int h;
- Gsymtab *gsymt, *prog_unit;
- ComListHeader *chead,*prev_chead;
- ComListElement *clist,*prev_clist;
+ Gsymtab *gsymt = NULL, *prog_unit;
+ ComListHeader *chead, *prev_chead = NULL;
+ ComListElement *clist = NULL, *prev_clist = NULL;
/* Items needed for module input */
Token toklist; /* header for list of common block elements */