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
Unknown Object (File)
Mon, Jan 6, 4:10 AM
Unknown Object (File)
Thu, Jan 2, 8:51 PM
Unknown Object (File)
Dec 19 2024, 4:57 AM
Unknown Object (File)
Dec 10 2024, 1:35 AM
Unknown Object (File)
Nov 10 2024, 5:27 PM
Unknown Object (File)
Oct 30 2024, 1:18 PM
Unknown Object (File)
Oct 21 2024, 8:01 AM
Unknown Object (File)
Oct 18 2024, 2:52 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.