[En-Nut-Discussion] is there a better set of definitonsfor fcntl.h ???

Douglas Pearless Douglas.Pearless at pearless.co.nz
Tue Nov 23 11:16:22 CET 2004


Hi Harald,

OK, that seems a better compromise.

Douglas

-----Original Message-----
From: en-nut-discussion-bounces at egnite.de
[mailto:en-nut-discussion-bounces at egnite.de] On Behalf Of Harald Kipp
Sent: Tuesday, 23 November 2004 9:59 p.m.
To: Ethernut User Chat (English)
Subject: Re: [En-Nut-Discussion] is there a better set of definitonsfor
fcntl.h ???

Hi Douglas,


>Would it not be better to have:
>
>#define _O_RDONLY       0x0004  /*!< Read only. */

...

>That code could to change to (check my code unless I made an error):
>"if (!(mode & _O_RDONLY)) {"
>and
>"if (!(mode & _O_WRONLY)) {"
>
>Which IMHO is more readable and 'safer' as
>Is this a better idea?

I'd agree, but almost all desktop systems define _O_RDONLY
as zero. Assuming any of the flags being non-zero would
make the code less portable.

Typically the value of 4 is assigned to _O_NONBLOCK,
but this is not used in Nut/OS yet.

How about

   #define FRWMASK (_O_RDONLY | _O_WRONLY | _O_RDWR)
   if((mode & FRWMASK) == _O_RDONLY)...

which would make the code fully independent from defined
values?

Btw. Rich Salz, the author of INN, sometime somewhere stated,
that he very much dislikes using

   if(!(num-expr))

instead of

   if((num-expr) != 0)

He argued, that ! is a boolean operator and should be used
on boolean expressions only. I learned a lot from Rich'
source codes and respect him very much.

Harald




_______________________________________________
En-Nut-Discussion mailing list
En-Nut-Discussion at egnite.de
http://www.egnite.de/mailman/listinfo.cgi/en-nut-discussion

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.799 / Virus Database: 543 - Release Date: 19/11/2004
 

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.799 / Virus Database: 543 - Release Date: 19/11/2004
 




More information about the En-Nut-Discussion mailing list