Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(139)

Issue 798041: There are C library functions including some

Can't Edit
Can't Publish+Mail
Start Review
Created:
15 years, 9 months ago by giles
Modified:
2 years, 1 month ago
Reviewers:
CC:
golang-dev
Visibility:
Public.

Description

There are C library functions including some standardised by POSIX that require setting errno to zero and examining it after calling the function in question to differentiate between errors and other conditions. An example is getpwuid(), where to tell the difference between a user-id for which there is no information and an error, the standard says this: http://www.opengroup.org/onlinepubs/7990989775/xsh/getpwuid.html "Applications wishing to check for error situations should set errno to 0 before calling getpwuid(). If getpwuid() returns a null pointer and errno is set to non-zero, an error occurred." It can be argued that library functions should not use errno (a position I agree with) but it can also be argued that it's too late now, particularly for functions specified by standards and functions from third party libraries for which a developer may not have the source. There has been a thread discussing this issue on the golang-nuts mailing list: http://groups.google.com/group/golang-nuts/browse_thread/thread/5ef21e2af40a03e From that thread, the most succinct comment was made by Russ Cox: "C makes it safe by making errno a thread-local variable in a threaded program. "Cgo can easily, and should, make it equally safe." I'm opening this issue so that the discussion is not lost, and in the hope that at some future time I or someone else will be able to address it. ight now I don't know what code changess are needed. As the issue tracker requires a diff, I have settled for a diff that adds a TODO to src/cmd/cgo/main.go, which I cheerfully admit is a cop-out! [ Edit: found what I should have done, and have now opened issue 709 http://code.google.com/p/go/issues/detail?id=709&colspec=ID%20Priority%20Status%20Owner%20Reporter%20Summary and referenced this CL. ]

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+3 lines, -0 lines) Patch
M src/cmd/cgo/main.go View 1 chunk +3 lines, -0 lines 0 comments Download

Messages

Total messages: 1
rsc1
15 years, 8 months ago (2010-04-13 23:21:35 UTC) #1

          
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b