[comp.lang.c] Return value ignored warning from lint [was: Why use

jak@sactoh0.SAC.CA.US (Jay A. Konigsberg) (09/30/90)

In article <12141@crdgw1.crd.ge.com> volpe@underdog.crd.ge.com (Christopher R Volpe) writes:
>           What I do mind is when lint warns me about return values from
>printf being ignored, which I, as well as most people, routinely ignore.
>Our dain-bramaged lint does the annoying thing in both circumstances:

Not necessarly. If I happen to write something like:

fd=open("name", O_WRITE);
fprintf(fd, "some string with or without variables");

or dup() a file descriptor to stdout and use printf() to write to a
file, then I definiatly want to know about ignoring the return
value.


-- 
-------------------------------------------------------------
Jay @ SAC-UNIX, Sacramento, Ca.   UUCP=...pacbell!sactoh0!jak
If something is worth doing, it's worth doing correctly.

jh4o+@andrew.cmu.edu (Jeffrey T. Hutzelman) (09/30/90)

jak@sactoh0.SAC.CA.US (Jay A. Konigsberg) writes:

> fd=open("name", O_WRITE);
> fprintf(fd, "some string with or without variables");
>
> or dup() a file descriptor to stdout and use printf() to write to a
> file, then I definiatly want to know about ignoring the return value.

You can't do that.  open() and dup() generate file DESCRIPTORS -
basically ID numbers.  stdin and family and the first argument of
fprintf are file POINTERS of type FILE *.  They are 2 different things.
-----------------
Jeffrey Hutzelman
America Online: JeffreyH11
Internet/BITNET:jh4o+@andrew.cmu.edu, jhutz@drycas.club.cc.cmu.edu

>> Apple // Forever!!! <<

mikep@dirty.csc.ti.com (Michael A. Petonic) (10/02/90)

In article <4068@sactoh0.SAC.CA.US> jak@sactoh0.SAC.CA.US (Jay A. Konigsberg) writes:
>>           What I do mind is when lint warns me about return values from
>>printf being ignored, which I, as well as most people, routinely ignore.
>>Our dain-bramaged lint does the annoying thing in both circumstances:
>
>Not necessarly. If I happen to write something like:
>
>fd=open("name", O_WRITE);
>fprintf(fd, "some string with or without variables");
>
>or dup() a file descriptor to stdout and use printf() to write to a
>file, then I definiatly want to know about ignoring the return
>value.

Oh, come on.  How many times do you put an IF around an FPRINTF?

Now, if you're using sprintf() or fprintf() and want to get a count
of the number of bytes output, then I can understand, but my usage
of these library calls in that manner is less than 1%.  I agree
with Karl H's solution (using the varargs, etc.)

-MikeP

>-------------------------------------------------------------
>Jay @ SAC-UNIX, Sacramento, Ca.   UUCP=...pacbell!sactoh0!jak
>If something is worth doing, it's worth doing correctly.

If something is worth doing, it's worth doing repeatedly.