Page MenuHomeFreeBSD

xstr(1): various cleanup
AbandonedPublic

Authored by eadler on Jan 7 2018, 5:12 AM.
Tags
None
Referenced Files
F83731600: D13789.id37602.diff
Tue, May 14, 3:51 AM
Unknown Object (File)
Sat, May 4, 12:15 PM
Unknown Object (File)
Feb 22 2024, 3:28 AM
Unknown Object (File)
Jan 30 2024, 10:08 PM
Unknown Object (File)
Jan 1 2024, 6:10 AM
Unknown Object (File)
Dec 23 2023, 6:56 PM
Unknown Object (File)
Dec 10 2023, 5:37 AM
Unknown Object (File)
Nov 1 2023, 6:37 AM
Subscribers
None

Details

Reviewers
imp
dim
des
Summary
  • use char where possible
  • avoid comma operator
  • remove 'lint' support
  • add attribute noreturn

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 14326
Build 14484: arc lint + arc unit

Event Timeline

use __dead2 instead of naked attribute

des requested changes to this revision.Jan 9 2018, 7:35 AM
des added inline comments.
usr.bin/xstr/xstr.c
138–139

Pull up the else, or just remove it entirely as the result is the same either way (readstd ends up equal to zero).

232

This is unnecessary and forces the compiler to ensure that all arithemetic is done modulo 256, which may increase the code size.

273–274

This can also be written more legibly as

c = c << 3 + *cp++ - '0';
314

c must be an int for EOF detection to work reliably.

This revision now requires changes to proceed.Jan 9 2018, 7:35 AM
eadler added inline comments.
usr.bin/xstr/xstr.c
314

you're right. I forgot about this :\

eadler marked an inline comment as done.

per @des

I'm sorry for the lack of response, I thought this had landed already.

Upon closer inspection, I think I was mistaken about readstd, and the assignment to 0 is necessary. Have you tested all three possible cases (dash only, filenames only, both dash and filenames)?