Page MenuHomeFreeBSD

acpiconf(8): Add libxo(3) support
AcceptedPublic

Authored by me_cameronkatri.com on May 19 2021, 8:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 6, 11:41 PM
Unknown Object (File)
Sat, Apr 6, 3:59 PM
Unknown Object (File)
Sat, Apr 6, 10:28 AM
Unknown Object (File)
Mar 20 2024, 10:37 AM
Unknown Object (File)
Feb 26 2024, 4:13 AM
Unknown Object (File)
Feb 13 2024, 4:11 AM
Unknown Object (File)
Jan 8 2024, 4:06 PM
Unknown Object (File)
Jan 8 2024, 4:06 PM

Details

Summary

Simplifies reading battery info from scripts.

Test Plan
  • Ensured text output is the same before and after libxo support.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

me_cameronkatri.com created this revision.

Run xo_finish(3) after all instances of xo_errx(3)

Looks good. You can use {L:} for strings that include slashes by escaping them with double backslashes (one for C, one for me):

xo_emit("{Lc:Warn\\/full granularity}{P:\t}{:granularity-wf/%d}{Uw:/%sh}\n", ...

Thanks,
Phil

FYI: I've just added docs for this, so it will be in the next release, which I'll import shortly, but the functionality's already there.

Thanks,
Phil

Run xo_finish(3) after all instances of xo_errx(3)

xo_errx doesn't return; no further calls are needed/possible.

FWIW xo_errx() calls xo_finish() before calling exit().

Thanks,
Phil

In D30350#687708, @phil wrote:

Run xo_finish(3) after all instances of xo_errx(3)

xo_errx doesn't return; no further calls are needed/possible.

FWIW xo_errx() calls xo_finish() before calling exit().

Thanks,
Phil

However if you don’t encounter any errors you still need to run xo_finish(3).

  • Cameron
In D30350#687688, @phil wrote:

Looks good. You can use {L:} for strings that include slashes by escaping them with double backslashes (one for C, one for me):

xo_emit("{Lc:Warn\\/full granularity}{P:\t}{:granularity-wf/%d}{Uw:/%sh}\n", ...

Thanks,
Phil

I could swear I tried this, I’ll update the patch shortly.

  • Cameron
me_cameronkatri.com edited the test plan for this revision. (Show Details)

Correct escaping of slashes

I could swear I tried this, I’ll update the patch shortly.

Well, retest to ensure I'm not lying, but I just verified it as working in libxo/develop and even added an explicit test case for it, as well as docs.

Thanks,
Phil

In D30350#687753, @phil wrote:

I could swear I tried this, I’ll update the patch shortly.

Well, retest to ensure I'm not lying, but I just verified it as working in libxo/develop and even added an explicit test case for it, as well as docs.

Thanks,
Phil

I checked it already, and it worked.

  • Cameron
imp added inline comments.
usr.sbin/acpi/acpiconf/acpiconf.c
248

You don't check the return value of argc here. Do you need to?

me_cameronkatri.com added inline comments.
usr.sbin/acpi/acpiconf/acpiconf.c
248

I checked quite a few bins and it seems that most check argc.

Yes, you need to check it. See xo_parse_args(3):

       On failure, a message it emitted and -1 is returned.

	       argc = xo_parse_args(argc, argv);
	       if (argc < 0)
		   exit(EXIT_FAILURE);

Cameron,

You said "it seems that most check"; did you find ones that didn't?

Thanks,
Phil

In D30350#714235, @phil wrote:

Cameron,

You said "it seems that most check"; did you find ones that didn't?

Thanks,
Phil

I found one that doesn't check argc: procstat(1).

me_cameronkatri.com retitled this revision from Add libxo(3) support to acpiconf(8) to acpiconf(8): Add libxo(3) support.Dec 22 2021, 10:56 PM

Sorry to bother, but was just wondering if someone could review this as it's been stale for a while.

debdrup added a subscriber: debdrup.

Manual page change looks good to me.

This revision is now accepted and ready to land.Feb 27 2022, 11:38 AM

Looks good. I do see an error on this site that says some nameless file is missing a terminating newline.

Thanks,
Phil

usr.sbin/acpi/acpiconf/acpiconf.8
100

Since you're touching this area.

Good morning, what's the status on getting this landed?

Sorry for the delay.

Thanks,
Phil

usr.sbin/acpi/acpiconf/acpiconf.8
55

Refer to xo_options(7) instead, since it's user-level documentation, rather than programmer level.

108

ditto; hmm... maybe I should write a user-level version of libxo(3).

usr.sbin/acpi/acpiconf/acpiconf.c
248

Yes, you should be checking xo_parse_args return, so that you catch invalid arguments:

argc = xo_parse_args(argc, argv);
if (argc < 0)
    exit(EXIT_FAILURE);
me_cameronkatri.com marked 4 inline comments as done.
  • Check xo_parse_args(3) for error.
  • Reference xo_options(7) in manpage.
This revision now requires review to proceed.Feb 1 2023, 7:30 PM
usr.sbin/acpi/acpiconf/acpiconf.8
55

Wow, can't believe I never knew that page existed. All other programs with libxo seem to reference xo_parse_args(3)...

Manual page change LGTM. Can't assess the source.

This revision is now accepted and ready to land.Feb 1 2023, 10:58 PM
usr.sbin/acpi/acpiconf/acpiconf.8
55

Okay. I'll check and correct as needed.

Thanks,
Phil

Is there some reason that this didn't land?