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.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Feb 28, 4:13 PM
Unknown Object (File)
Feb 7 2024, 1:17 PM
Unknown Object (File)
Dec 23 2023, 2:47 AM
Unknown Object (File)
Dec 22 2023, 12:44 AM
Unknown Object (File)
Nov 10 2023, 11:13 AM
Unknown Object (File)
Nov 9 2023, 10:57 PM
Unknown Object (File)
Nov 7 2023, 11:06 PM
Unknown Object (File)
Nov 6 2023, 1:06 PM
Subscribers

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 - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

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
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?

lib/libc/string/strerror.c
55 ↗(On Diff #52313)

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

Update EBUFSIZE definition and comment.

This revision now requires review to proceed.Dec 25 2018, 3:33 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.

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.

This revision is now accepted and ready to land.Dec 25 2018, 3:58 PM

This change now looks good to me.

This revision was automatically updated to reflect the committed changes.