libbio brdline function error

48 views
Skip to first unread message

8080paco

unread,
Nov 10, 2023, 3:20:24 AM11/10/23
to plan9port-dev
How to handle error result of read function? This is example of them.
I wonder why there is no code to handle the error.  

sqweek

unread,
Nov 12, 2023, 10:18:06 AM11/12/23
to ghwn...@gmail.com, plan9port-dev
The bio(3) man page includes the following:

> Brdline returns a pointer to the start of the line or 0 on end-of-file or read error

And later in the DIAGNOSTICS section:

> All routines set errstr on error.

In plan9 proper I presume errstr is set via `read`/`pread`. In the case of plan9port the unix syscall obviously is not going to set errstr, but it will set errno so I think this is your answer -- if Brdline returns 0 then:

(a) go and check errno to see what went wrong, or
(b) go and call errstr() to see what went wrong

The latter is still possible in plan9port because its errstr() function also considers the unix errno state.

HTH,
-sqweek

On Fri, 10 Nov 2023 at 16:20, 8080paco <ghwn...@gmail.com> wrote:
How to handle error result of read function? This is example of them.
I wonder why there is no code to handle the error.  

--

---
You received this message because you are subscribed to the Google Groups "plan9port-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to plan9port-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/plan9port-dev/06f78408-f506-458a-8945-f09f1659d17fn%40googlegroups.com.

8080paco

unread,
Nov 13, 2023, 3:21:53 AM11/13/23
to plan9port-dev
Thanks for your reply.

Then why not set "inactive" state of buffer?
bread function is handled that case.
Reply all
Reply to author
Forward
0 new messages