Page MenuHomeFreeBSD

mixer(8): fix shorthand syntax bug
ClosedPublic

Authored by christos on Mar 20 2022, 6:10 PM.

Details

Summary

da3d4469ef841be44ac4b346a6b51668d608ed49 had a bug where the whole
volume syntax (floating point values, :, + and -) wasn't accepted. Also moved
the defines into an enum for cleanliness. The mechanism for checking
if we're using the shorthand syntax is a bit of a hack but I can't come up with
something better at the moment.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

usr.sbin/mixer/mixer.c
139–152

Don't you need to set shorthand to zero for every loop?

140

Can you put it like this:

bool shorthand;

		/* Check if we're using the shorthand syntax for volume setting. */
                shorthand = false;
		for (q = p; *q != '\0'; q++) {
			if (*q == '=') {
                             q++;
                             shorthand = ((*q >= '0' && *q <= '9') ||
                               *q == '+' || *q == '-' || *q == '.');
                              break;
                        } else if (*q == '.')
                              break;
		}

....

                else if (shorthand) {
                              .....
                }
christos marked 2 inline comments as done.

Done.

This revision was not accepted when it landed; it landed in state Needs Review.Mar 20 2022, 7:22 PM
This revision was automatically updated to reflect the committed changes.