This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: happily messing up with raw devices (aka: lseek problems)


----Original Message----
>From: Lapo Luchini
>Sent: 07 September 2005 19:32

> Corinna Vinschen wrote:
>> Try this:
>>   #include <unistd.h>
> 
> It works.
> Silly me, I didn't think about checking headers, as it was good at
> compile-time 

  No, it wasn't "good at compile-time".  It was bad at compile-time, but you
chose to compile without enabling any warnings.

dk@mace /mboa> gcc -Wall short.c -o short
short.c:8: warning: return type defaults to `int'
short.c: In function `main':
short.c:13: warning: implicit declaration of function `lseek'
short.c:9: warning: unused variable `sect'
short.c:15: warning: control reaches end of non-void function

  Each of those warnings represents incorrect code on your part.  Your
coding techniques would have barely scraped by back in 1979.  Since 1989,
they've just been completely invalid.  Stop taking these crude shortcuts -
they don't work.  Do a bit of cost-benefit analysis:  how much time does it
save you to not bother writing a #include line?  How much time does it cost
you to diagnose these very hard-to-spot bugs?  It isn't worth it.

> (strange thing, tough, read did work, but lseek didn't).

  That's because all the arguments to read are 32-bits in size, whereas
lseek has a variety of differently-sized arguments.  Of course, the compiler
would have known that if you had given it a prototype for the function.

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]