Page MenuHomeFreeBSD

libusb: implement libusb_setlocale to support different locale of error message as upstream does
ClosedPublic

Authored by aokblast on Jun 12 2025, 7:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Oct 8, 7:27 AM
Unknown Object (File)
Thu, Oct 2, 1:24 AM
Unknown Object (File)
Fri, Sep 26, 3:58 AM
Unknown Object (File)
Fri, Sep 26, 2:19 AM
Unknown Object (File)
Thu, Sep 18, 11:43 AM
Unknown Object (File)
Wed, Sep 17, 1:46 AM
Unknown Object (File)
Sun, Sep 14, 7:07 PM
Unknown Object (File)
Sun, Sep 14, 4:38 PM

Details

Summary

Currently, we only support English and Mandarine as I don't speak other language

The upstream libsub only use first two character to identify a language locale so we would like to follow with them.

Also, we cannot bring upstream GPL language string back as it will violate the GPL License.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 64838
Build 61721: arc lint + arc unit

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
aokblast added reviewers: bapt, USB.
aokblast added a reviewer: lwhsu.

@rcyu Could you please help me check the Mandarine locale?

toto6038_gmail.com added inline comments.
lib/libusb/libusb10.c
112
113
114
115
117

Just in case someone may wonder how this term is translated. Under informal communication, the word "pipe" usually remains untranslated, but if it has to be translated I think Microsoft's translation convention fits well. Please see here.

This revision now requires changes to proceed.Jun 12 2025, 8:42 PM
kevans added inline comments.
lib/libusb/libusb10.c
91

I don't insist, but it might be a good idea to use array initializers here ([-LIBUSB_ERROR_COUNT] = "...")

1789

I think we should spell 13 here as LIBUSB_ERROR_COUNT - 1

1791

Parenthesized return value, as per style(9). While I'm thinking about this, I wonder if we should allow for holes in the translations. I'm thinking mainly for cases where we might add another error in the future; we'll have a NULL slot in other language maps until they get converted, and it probably makes sense to fallback to the english context for those individual entries.

1864

nitems(libusb_language_ctx) and drop the local, please -- macro exists in sys/param.h if you need to pull that in.

1868

Instead of breaking here, you might consider just setting default_language_context and returning LIBUSB_SUCCESS immediately, then assume the post-loop bits are an error path.

lib/libusb/libusb10.h
157

This formatting is valid, but I think it's a little jarring... IMO we should move the comment to the line above so that we don't have to wrap the name to the next line.

lib/libusb/libusb10.c
117

The link opens Microsoft Terminology Search. {F119859017}

Fix comments' problem and add manual

Almost there- let's bring in manpages to sanity check the manpage revision.

lib/libusb/libusb.3
113

New sentences should begin on a new line

lib/libusb/libusb10.c
1859

It's also acceptable to move the declaration down to the for loop entirely these days, if you'd like.

pauamma_gundo.com added inline comments.
lib/libusb/libusb.3
113
114
lib/libusb/libusb10.c
1853–1854
lib/libusb/libusb.3
110
lib/libusb/libusb10.c
1859

I would like to leave it in the same place as it follws the style.

I think I'm happy with the implementation, but I would like to see independent sign-off on the finished Mandarin translations and manpage.

lib/libusb/libusb10.c
1859

👍

lib/libusb/libusb.3
111–113

Maybe?

114
This revision is now accepted and ready to land.Jun 14 2025, 8:53 AM
This revision now requires review to proceed.Jun 16 2025, 2:27 AM
This revision is now accepted and ready to land.Jun 23 2025, 7:10 PM
lib/libusb/libusb.3
118

"Therefore" and "That means" have the same meaning, so you don't need to use both here.

This revision now requires review to proceed.Jul 8 2025, 11:29 AM
lib/libusb/libusb10.c
48

sys/param.h is special, see style(9). It should always come first in the include list. All of the sys/* includes should appear before the rest, but that is an unrelated change. You should just add sys/param.h to the beginning for now, just before ctype.h.

1783
1863

Won't libusb_setlocale("abc") cause a segfault here? strchr() returns NULL if no match is found.

Ok, with these little nits, the manpage looks good to me.

lib/libusb/libusb.3
117

Stray capitalization

120

Macro lines need a space before the final punctuation.

This revision is now accepted and ready to land.Jul 8 2025, 12:25 PM
This revision now requires review to proceed.Jul 8 2025, 3:23 PM

Approved.

There is a typo in the commit message, Mandarine->Mandarin.

This revision was not accepted when it landed; it landed in state Needs Review.Jul 11 2025, 4:19 AM
This revision was automatically updated to reflect the committed changes.