Where is new libpfm3.6 ?

Erik Christiansen dvalin at internode.on.net
Sun Nov 30 11:38:39 UTC 2008


On Sun, Nov 30, 2008 at 02:14:31PM +0530, Chaman Singh Verma wrote:
> On Sun, Nov 30, 2008 at 1:27 PM, Mario Vukelic <mario.vukelic at dantian.org>wrote:
> >
> > > but couldn't compiler with the latest g++
> > > compiler.
> >
> > What errors?

> 
> make[1]: Entering directory `/home/csv610/Desktop/libpfm-3.6/lib'
> gcc -O2 -g -Wall -Werror -I/home/csv610/Desktop/libpfm-3.6/lib/../include
> -D_REENTRANT -DCONFIG_PFMLIB_ARCH_X86_64 -I. -c pfmlib_os_linux.c
> cc1: warnings being treated as errors
> pfmlib_os_linux.c: In function 'pfm_init_syscalls_sysfs':
> pfmlib_os_linux.c:421: error: ignoring return value of 'fscanf', declared
> with attribute warn_unused_result
> make[1]: *** [pfmlib_os_linux.o] Error 1
> make[1]: Leaving directory `/home/csv610/Desktop/libpfm-3.6/lib'
> make: *** [all] Error 2

That is all pretty self-explanatory, if familiar, and given a glance at
the gcc manpage, if not. The gcc warning options:

-Wall       All of the -W options combined.
-Werror     Make all warnings into errors.      

Maximise sensitivity and censoriousness, to throw an error on harmless
coding peccadillos, as in this case. It's useful for the programmer, who
might have intended to use the return value of 'fscanf'.

But it's all spelled out in the error text, to make it easy:

"cc1: warnings being treated as errors"
"error: ignoring return value of 'fscanf', declared with attribute
warn_unused_result"

How many hints are needed?  ;-)

Seriously, though, it's not a tenth as scary as it looks. You could:

a) Ask the developers to tidy up.
   This may be the safest, since a return value of zero from fscanf can
   be bad news. Some error handling may just possibly be called for.
   (If there are other fscanf invocations, and there are no other error
   messages, then they do have it, and you've encountered a coding bug,
   not just a build bug.)

b) Remove -Werror from the "CFLAGS" line in the [Mm]akefile, or similar place that it
   occurs. Comment out the line, and substitute your modification.

   It will do no harm that isn't already there, and will allow the build
   to complete, if that's the only error. But since you don't have a
   build which has been tested, it could do anything.

c) Modify line 421 of pfmlib_os_linux.c to something like:

   fred = fscanf(...

   Obviously, you'll need to declare an automatic integer variable at
   the start of the function:

   int fred ;

   That'll allow it to build, but camouflages a probable problem. You'd
   want to check the code, to see what would happen in the event of a
   matching failure. How deep do you want to go into it? :-)

Have fun,

Erik

-- 
C hasn't changed much since the 1970s. And let's face it it's ugly.
Can't we do better? C++? (Sorry, never mind.)      - Rob Pike





More information about the ubuntu-users mailing list