Skip to contentSkip to conversation

Refactor handling of percent values (towards BZ 654441)

PATCH New Petr Rockai 2 participants 3 messages Nov 25, 2010 – Nov 29, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Refactor handling of percent values (towards BZ 654441)

Hi,

the attached patch changes over the percent handling in the code: it folds all percent values into a single fixed-point value, instead of a floating point and an enum. This simplifies existing code (no need to pass around extra variable/parameter), while also making it possible to expose the percent attributes through the lvm2app API as a single integral value (this is BZ 654441).

The lvm2app patch will follow.

Yours,
Petr.

PS: Passes the testsuite.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: percent-refactor.diff
Type: text/x-diff
Size: 32714 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20101125/ae187aa8/attachment.bin>

#1 lore raw

PATCH 1/1 Refactor handling of percent values (towards BZ 654441)

Hi again,

Quoted 6 lines · Petr Rockai

the attached patch changes over the percent handling in the code: it folds all percent values into a single fixed-point value, instead of a floating point and an enum. This simplifies existing code (no need to pass around extra variable/parameter), while also making it possible to expose the percent attributes through the lvm2app API as a single integral value (this is BZ 654441).

and now an amended patch, taking Alasdair's IRC feedback into account. I have moved the implementation aside to a separate unit, and added a comment explaining how the percent_t type works.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: percent-refactor.diff
Type: text/x-diff
Size: 36005 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20101125/d5653007/attachment.bin>
-------------- next part --------------

Yours,
Petr.

#2 lore raw

PATCH 1/1 Refactor handling of percent values (towards BZ 654441)

Quoted 3 lines · Peter Rockai

and now an amended patch, taking Alasdair's IRC feedback into account. I have moved the implementation aside to a separate unit, and added a comment explaining how the percent_t type works.

Ack. (Not checked line-by-line, but not spotted any problems in a quick read through.)

What's our test coverage like for the code that uses and relies on percentages? - The parts that print them, and the parts like detecting syncs are complete?
Any manual tests done or need doing? I'd like to avoid regressions in the 'mirroring complete' detection in particular.

Alasdair

Review

Quoted 5 lines
(quoted diff) +5 -0
+percent_t make_percent(uint64_t numerator, uint64_t denominator)
+{
+    percent_t percent;
+    if (!denominator)
+        return PERCENT_100; /* FIXME? */

How does current code handle this, or does it never occur?
If not, just define it and state the behaviour in the header file (for example). (or go for 'invalid')

Alasdair