Strange Warning COPY_UNINIT_PTR

LegacyForumLegacyForum Posts: 1,669 ✭✭
edited December 2016 in Insure++
Using strerror(errno) in printf gives Warning
Hi,

we get a COPY_UNINIT_PTR warning for this piece of code:

dprintf( ERRORS, "IDM -- Cannot create message queue [%s]. File %s. Key=%d\n", strerror(errno), datafile, msgkey );
The warning says:
Copying uninitialized pointer: strerror(*__errno_location())

Stack trace where the error occurred:
RCVINFO::Initialize(const char *, int, const char *) ../idm.cc, 626
main() ../idm.cc, 3894
__libc_start_main()

The signature of strerror is
extern char *strerror (int __errnum) __THROW;
and errno is defined as
extern int *__errno_location (void) __THROW __attribute__ ((__const__)); # define errno (*__errno_location ())
I expect the returns of glibc functions to be initialized and watching my log file, the dprintf is executed correctly.
Is Insure++ mistaken here or am I ?

Here is what we use:

OS: SLES 9 PL 2
Architekture x86
Compileer gcc 3.3.3
Insure++ Ver. 7.1.1

Any help is appreciated!

Oliver

Comments

  • LegacyForumLegacyForum Posts: 1,669 ✭✭
    Hi,

    Insure++ "scribbles" a known bit-pattern into memory locations; thus if memory remains uninitialized, it will contain the known bit-pattern. Therefore, COPY_UNINIT_PTR can only produce a false-positive if the actual pointer value is the same as the known bit-pattern.

    It's also possible that this is the first call to: errno_location(), thus the cached pointer isn't yet initialized, (and it becomes initialized after the call).

    --Rich
Sign In or Register to comment.