Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Strange Warning COPY_UNINIT_PTR

LegacyForum
LegacyForum Posts: 1,664 ✭✭
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

  • LegacyForum
    LegacyForum Posts: 1,664 ✭✭
    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