Page MenuHomeFreeBSD

Bump sys_errlist size to keep ABI backward-compatible for some time.
ClosedPublic

Authored by kib on Dec 25 2018, 2:19 PM.

Details

Summary

Addition of the new errno values requires adding new elements to sys_errlist array, which is actually ABI-incompatible, since ELF records the object size. Expand array in advance to 150 elements so that we have to go over the issue only once.

Test Plan

I checked that perror(1) printed expected strings for negative, normal errno, and errnos 96, 97, 149, 150, 151 in C and ru_RU.KOI8-R locales.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

kib created this revision.Dec 25 2018, 2:19 PM
kib edited the test plan for this revision. (Show Details)Dec 25 2018, 2:20 PM
yuripv accepted this revision.Dec 25 2018, 2:57 PM
yuripv added inline comments.
lib/libc/string/strerror.c
55 ↗(On Diff #52313)

Not directly related to your change, but I don't think this is/was correct -- if we have NLS enabled, and catalog for current language has the 32767 (0xffff) entry corresponding to "unknown error", and that text is longer than we calculate here, and the num is big enough, the resulting message will be truncated. I understand that it's really too much "if"s, just noting that errstr() likely should just allocate the buffer big enough instead; that is (20 + 2 + strlen(uprefix) + 1).

This revision is now accepted and ready to land.Dec 25 2018, 2:57 PM
yuripv added inline comments.Dec 25 2018, 3:02 PM
lib/libc/string/strerror.c
55 ↗(On Diff #52313)

Err, that comment got me confused, we don't actually copy the uprefix to tmp, right? So we don't need to reserve the space for __uprefix there?

kib added inline comments.Dec 25 2018, 3:25 PM
lib/libc/string/strerror.c
55 ↗(On Diff #52313)

It seems we don't do that now. It was changed in r108603, 2003.

kib updated this revision to Diff 52317.Dec 25 2018, 3:33 PM

Update EBUFSIZE definition and comment.

This revision now requires review to proceed.Dec 25 2018, 3:33 PM
yuripv added inline comments.Dec 25 2018, 3:39 PM
lib/libc/string/strerror.c
52 ↗(On Diff #52317)

Sorry for making you do the unrelated change..

I think this should now read based on what we actually write into tmp:

Define buffer big enough to contain delimiter (": ", 2 bytes), 64-bit signed integer converted to ASCII decimal (19 bytes) with optional leading sign (1 byte), and a trailing NUL.

The definition of EBUFSIZE should be 23 then according to the above.

kib added inline comments.Dec 25 2018, 3:57 PM
lib/libc/string/strerror.c
52 ↗(On Diff #52317)

Well, num is int which is 32-bit value and not 64-bit, on any supported architecture. That said, lets pretend that we would support ILP64 or larger arch one day.

kib updated this revision to Diff 52318.Dec 25 2018, 3:57 PM

Update EBUFSIZE.

yuripv accepted this revision.Dec 25 2018, 3:58 PM
This revision is now accepted and ready to land.Dec 25 2018, 3:58 PM
mckusick accepted this revision.Dec 27 2018, 7:36 AM

This change now looks good to me.

This revision was automatically updated to reflect the committed changes.