[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: read system call.

Sumit Rangawala wrote (sumitr@xxxxxxxxxxxx):

> Rewrite :
> >    if (fd = (open("/root/data",O_RDONLY,0) < 0))
> as
>       if((fd = open("/root/data",O_RDONLY,0)) < 0)
> By  now i think you should have figured out what was the problem with your
> code.

Your compiler can _easily_ spot these errors - a boolean expression is
expected in the if statement but an assignment is found. Why do what your
compiler can already do well. Please read your compiler documentation
carefully and enable these warning flags.

If you're using gcc, atleast a -Wall is required. If you're paranoid, search
for a previous post (my me) which contined a wrapper shell script for gcc
which included additional checks.

- Raja