Page MenuHomeFreeBSD

bspatch: use sizeof(header) rather than hardcoded size
ClosedPublic

Authored by emaste on Sep 12 2016, 2:53 PM.
Tags
None
Referenced Files
F82042078: D7861.diff
Wed, Apr 24, 10:10 PM
Unknown Object (File)
Thu, Apr 18, 12:05 AM
Unknown Object (File)
Mar 25 2024, 7:34 PM
Unknown Object (File)
Mar 22 2024, 8:22 PM
Unknown Object (File)
Dec 22 2023, 10:23 PM
Unknown Object (File)
Dec 12 2023, 4:33 PM
Unknown Object (File)
Aug 2 2023, 10:13 PM
Unknown Object (File)
Aug 1 2023, 11:58 AM
Subscribers

Details

Summary

Although the header size is fixed, this change provides an explicit indication of what the size is being used for.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

emaste retitled this revision from to bspatch: use sizeof(header) rather than hardcoded size.
emaste updated this object.
emaste edited the test plan for this revision. (Show Details)
emaste added reviewers: cperciva, allanjude, jhb.
allanjude edited edge metadata.

+1 for killing magic numbers

This revision is now accepted and ready to land.Sep 12 2016, 3:04 PM
emaste edited edge metadata.
emaste added a subscriber: kib.
  • update with _Static_assert and use %jd / intmax_t as suggested by @kib
  • add an offset variable that we increment by the header / bzctrllen / bzdatalen to avoid repeating the same expression
This revision now requires review to proceed.Sep 13 2016, 7:52 PM

I looked at this stuff again, and having the construct char header[32] and static_assert(sizeof(header) == 32) feels weird. Might be, instead use a #define HEADER_SIZE 32 and then char header[HEADER_SIZE]; and use HEADER_SIZE.

Sorry for bike-shedding, but this is weird when seen completed.

emaste edited edge metadata.

Incorporate comments from @kib

kib added a reviewer: kib.
This revision is now accepted and ready to land.Sep 14 2016, 1:18 PM

Commit summary will be use #define for header size instead of magic number Also note that the update includes a change to keep an increasing offset rather than repeating the same expression in several places.

This revision was automatically updated to reflect the committed changes.