[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#6266) uninitialized var in overlays/dynlist.c:dl_cfgen()

hyc@symas.com wrote:
> masarati@aero.polimi.it wrote:
>>> gcc complains
>>>     dynlist.c:1537: warning: 'dlml' may be used uninitialized in this
>>> function
>>> Looks like its declaration at least should be moved outside the loop below
>>> and it should be initialized to something.  This is the complete use of
>>> dlml:
>>> 		for ( ... ) {
>>> 			dynlist_map_t *dlml;
>>> 			if ( dlm == NULL ) {
>>> 				dlml = NULL;
>>> 			}
>>> 			if ( dlml != NULL )
>>> 				dlml->dlm_next = dlmp;
>>> 			dlml = dlmp;
>>> 		}
>> Not even sure about what that piece of code is supposed to do...
> Indeed. It has no visible effect; an optimizer would just elide the entire block.

Never mind, the above code snippet was quite abbreviated.

In the actual code, dlm is initialized to NULL. Therefore, dlml will get 
initialized to NULL. The effect is to make sure that new dlmp's are appended 
to the existing singly-linked list. It's pretty obvious when looking at the 
actual file. And also obvious that the uninit warning is false.

   -- Howard Chu
   CTO, Symas Corp.           http://www.symas.com
   Director, Highland Sun     http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP  http://www.openldap.org/project/