readv() return and errno

readv() return and errno

Post by Andries.Brou.. » Thu, 28 Mar 2002 01:30:13




> According to readv(2) EINVAL is returned for an invalid
> argument.

Right.

Quote:> The examples given were count might be greater than
> MAX_IOVEC or zero.

Wrong, or at least confusingly phrased.

In the good old days, a man page described what the system did,
and the ERRORS section gave the reasons for the possible error
returns.
These days a man page describes a function present on many
Unix-like systems, and not all systems have precisely the
same behaviour. POSIX man pages therefore distinguish under
ERRORS the two possibilities "if foo then this error must be
returned", and "if foo then this error may be returned".

Linux man pages do not (yet) make this distinction -
adding this is a lot of careful work, and so far
nobody is doing this [hint..].
In other words, the ERRORS section in Linux man pages is
to be interpreted as "if foo then this error may be returned".

Note that it may not be desirable at all to do things that way,
there is no need for kernel patches, it just means that systems
exist with this behaviour, so that authors of portable programs
must take this into account.


> Apply this trivial patch, if you want the required behaviour

But the behaviour is not required.
Paul Larson makes the same mistake.

Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

readv() return and errno

Post by Balbir Sing » Thu, 28 Mar 2002 02:10:10


I agree it is not a big thing at all, zero not
returning any error. Yes! I read and understood the
MAY return an error, it makes complete sense.

I agree, the Linux man pages need a lot of work,
if they are going to be even close to reflecting
some of things in the kernel.

Thanks,
Balbir



> > According to readv(2) EINVAL is returned for an
> invalid
> > argument.

> Right.

> > The examples given were count might be greater
> than
> > MAX_IOVEC or zero.

> Wrong, or at least confusingly phrased.

> In the good old days, a man page described what the
> system did,
> and the ERRORS section gave the reasons for the
> possible error
> returns.
> These days a man page describes a function present
> on many
> Unix-like systems, and not all systems have
> precisely the
> same behaviour. POSIX man pages therefore
> distinguish under
> ERRORS the two possibilities "if foo then this error
> must be
> returned", and "if foo then this error may be
> returned".

> Linux man pages do not (yet) make this distinction -
> adding this is a lot of careful work, and so far
> nobody is doing this [hint..].
> In other words, the ERRORS section in Linux man
> pages is
> to be interpreted as "if foo then this error may be
> returned".

> Note that it may not be desirable at all to do
> things that way,
> there is no need for kernel patches, it just means
> that systems
> exist with this behaviour, so that authors of
> portable programs
> must take this into account.


> > Apply this trivial patch, if you want the required
> behaviour

> But the behaviour is not required.
> Paul Larson makes the same mistake.

> Andries

__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards?
http://movies.yahoo.com/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

readv() return and errno

Post by Jim Hollenbac » Thu, 28 Mar 2002 02:20:10


Doesn't seem confusing at all.

RETURN VALUE
       On  success  readv  returns  the number of bytes read.  On
       success writev returns the number of  bytes  written.   On
       error, -1 is returned, and errno is set appropriately.

ERRORS
       EINVAL An  invalid  argument was given. For instance count

             might be greater than MAX_IOVEC, or zero.  fd could
              also  be  attached to an object  which  is  unsuit-
              able  for  reading  (for  readv)  or  writing  (for
              writev).

I don't see much in the way of waffle words. If count is greater than
MAX_IOVEC or zero you get EINVAL. I suppose your next argument is if
count exceeds MAX_IOVEC a return of 0 is okay since, hopefully, nothing
was read? Where do you read a non-error return of zero is acceptable
for count of 0? I states EINVAL for a count of 0.

If your going to rework the manpage, then drop a count of 0 as an error,
otherwise fix the kernel with the trival patch.

Jim


> Subject: Re: readv() return and errno
> I agree it is not a big thing at all, zero not
> returning any error. Yes! I read and understood the
> MAY return an error, it makes complete sense.

> I agree, the Linux man pages need a lot of work,
> if they are going to be even close to reflecting
> some of things in the kernel.

> Thanks,
> Balbir



> > > According to readv(2) EINVAL is returned for an
> > invalid
> > > argument.

> > Right.

> > > The examples given were count might be greater
> > than
> > > MAX_IOVEC or zero.

> > Wrong, or at least confusingly phrased.

> > In the good old days, a man page described what the
> > system did,
> > and the ERRORS section gave the reasons for the
> > possible error
> > returns.
> > These days a man page describes a function present
> > on many
> > Unix-like systems, and not all systems have
> > precisely the
> > same behaviour. POSIX man pages therefore
> > distinguish under
> > ERRORS the two possibilities "if foo then this error
> > must be
> > returned", and "if foo then this error may be
> > returned".

> > Linux man pages do not (yet) make this distinction -
> > adding this is a lot of careful work, and so far
> > nobody is doing this [hint..].
> > In other words, the ERRORS section in Linux man
> > pages is
> > to be interpreted as "if foo then this error may be
> > returned".

> > Note that it may not be desirable at all to do
> > things that way,
> > there is no need for kernel patches, it just means
> > that systems
> > exist with this behaviour, so that authors of
> > portable programs
> > must take this into account.


> > > Apply this trivial patch, if you want the required
> > behaviour

> > But the behaviour is not required.
> > Paul Larson makes the same mistake.

> > Andries

> __________________________________________________
> Do You Yahoo!?
> Yahoo! Movies - coverage of the 74th Academy Awards?
> http://movies.yahoo.com/
>-- End of excerpt from Balbir Singh

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
 
 
 

readv() return and errno

Post by Alan Co » Thu, 28 Mar 2002 03:00:22


Quote:> I don't see much in the way of waffle words. If count is greater than
> MAX_IOVEC or zero you get EINVAL. I suppose your next argument is if

SuS is definitive not the man page. That page btw is woefully out of date

Quote:> If your going to rework the manpage, then drop a count of 0 as an error=
> ,
> otherwise fix the kernel with the trival patch.

The man page is buggy if anything is.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
 
 
 

readv() return and errno

Post by Andries.Brou.. » Thu, 28 Mar 2002 06:20:08



    Doesn't seem confusing at all.

    RETURN VALUE
           On  success  readv  returns  the number of bytes read.  On
           success writev returns the number of  bytes  written.   On
           error, -1 is returned, and errno is set appropriately.

    ERRORS
           EINVAL An  invalid  argument was given. For instance count
                  might be greater than MAX_IOVEC, or zero.  fd could
                  also  be  attached to an object  which  is  unsuit-
                  able  for  reading  (for  readv)  or  writing  (for
                  writev).

    I don't see much in the way of waffle words. If count is greater than
    MAX_IOVEC or zero you get EINVAL.

Yes, without hesitation you choose the wrong interpretation.
That is why I explained in so much detail what the right
interpretation is. Since you perhaps still do not understand,
let me reiterate:

The above ERRORS section says: In case this call returns EINVAL
one of the possible reasons is that an invalid argument was given.
There do exist Unix-like systems (not necessarily Linux) that
consider a zero count invalid.

Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

readv() return and errno

Post by Andries.Brou.. » Thu, 28 Mar 2002 06:40:09


Quote:> The man page is buggy if anything is.

Hmm. So far nobody pointed out anything buggy.
Now that I look myself I see outdated prototypes
(like int instead of ssize_t).
What else did you find buggy?

Andries
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

readv() return and errno

Post by Alan Co » Thu, 28 Mar 2002 08:40:12


Quote:> > The man page is buggy if anything is.

> Hmm. So far nobody pointed out anything buggy.
> Now that I look myself I see outdated prototypes
> (like int instead of ssize_t).
> What else did you find buggy?

Specifying zero vectors is not an error in Linux (and not required to be
by SuSv3)

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

readv() return and errno

Post by Alan Co » Thu, 28 Mar 2002 08:40:11


Quote:> The above ERRORS section says: In case this call returns EINVAL
> one of the possible reasons is that an invalid argument was given.
> There do exist Unix-like systems (not necessarily Linux) that
> consider a zero count invalid.

Got me as well - by that meaning you are correct -  the man page is only
wrong for ssize_t type stuff.

Sorry

Alan
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

1. readv() return and errno

 In doing some testing on the project I'm working on I came
 across something that is causing a bit of confusion on my part.

 According to readv(2) EINVAL is returned for an invalid
 argument.  The examples given were count might be greater than
 MAX_IOVEC or zero. The test case I am working with has count = 0
 and I get return of 0 and errno 0 instead of the expected -1
 and errno EINVAL.

 Am I missing something?

Thanks!

Jim Hollenback
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

2. bootup/kern.securelevel

3. 2.4.19-pre3 - readv/writev should return EINVAL for count=0

4. rpm error

5. realloc() returns NULL, errno == 0

6. 2.4.19-rc1,2 + ext3 data=journal: data loss on unmount

7. Q: TCP/IP accept returns -1, errno == ENOBUFS

8. Newbie Linux Site

9. dbm_open returns errno=9

10. nlist() always returns -1 but errno=0 on Solaris7&8

11. getpwuid return values and errno?

12. shutdown(3N) returns -1 but errno==0 -- wassagoinon ?

13. Can poll() return errno 89??