delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/09/07/14:47:40

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
From: "Dave Korn" <dave DOT korn AT artimi DOT com>
To: <cygwin AT cygwin DOT com>
Subject: RE: happily messing up with raw devices (aka: lseek problems)
Date: Wed, 7 Sep 2005 19:47:28 +0100
MIME-Version: 1.0
In-Reply-To: <431F321C.108@lapo.it>
Message-ID: <SERRANODscdJH7eHVei000001ee@SERRANO.CAM.ARTIMI.COM>

----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 AT 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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019