Skip to contentSkip to conversation

dm verity: use sector_div for division

PATCH In review Arnd Bergmann 2 participants 2 messages Dec 8, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm verity: use sector_div for division

The dm verity sec implementation uses do_div for dividing a sector_t, which is slower than necessary when sector_t is a 32-bit type, and we now get a warning for this case:

include/asm-generic/div64.h:224:22: warning: passing argument 1 of '__div64_32' from incompatible pointer type [-Wincompatible-pointer-types] drivers/md/dm-verity-fec.c:725:6: note: in expansion of macro 'do_div'
if (do_div(f->rounds, f->rsn))

This changes the code to use sector_div instead, which does the right thing and avoids the warning.

---
 drivers/md/dm-verity-fec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

I believe we had a fix for this in the series that introduced the optimized do_div, but the file got moved around and the fix got lost.

drivers/md/dm-verity-fec.c +1 -1
index e722ce57520f..1bddaca37e98 100644
@@ -722,7 +722,7 @@ int verity_fec_ctr(struct dm_verity *v)
 	}
 
 	f->rounds = f->blocks;
-	if (do_div(f->rounds, f->rsn))
+	if (sector_div(f->rounds, f->rsn))
 		f->rounds++;
 
 	/*
Signature · 1 line
2.1.0.rc2
#1 lore raw
Quoted 10 lines · Arnd Bergmann

The dm verity sec implementation uses do_div for dividing a sector_t, which is slower than necessary when sector_t is a 32-bit type, and we now get a warning for this case:

include/asm-generic/div64.h:224:22: warning: passing argument 1 of '__div64_32' from incompatible pointer type [-Wincompatible-pointer-types] drivers/md/dm-verity-fec.c:725:6: note: in expansion of macro 'do_div'
if (do_div(f->rounds, f->rsn))

This changes the code to use sector_div instead, which does the right thing and avoids the warning.

Thanks, I'll fold this in.

(Btw, I did review this use of do_div(): but only to answer whether there was potential for a 64bit divide. I concluded do_div() was fine but didn't look to see the data type for f->rounds was actually sector_t.)