vvfat: use DIV_ROUND_UP
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Thu, 22 Jun 2017 11:04:16 +0000 (13:04 +0200)
committerMarc-André Lureau <marcandre.lureau@redhat.com>
Thu, 31 Aug 2017 10:29:07 +0000 (12:29 +0200)
I used the clang-tidy qemu-round check to generate the fix:
https://github.com/elmarco/clang-tools-extra

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
block/vvfat.c

index a9e207f7f0a64e9c469a2ab45fcf7ca6063a2b4e..c54fa94651c3930791d7e4e8804dd24ef748b3b0 100644 (file)
@@ -449,7 +449,7 @@ static direntry_t *create_long_filename(BDRVVVFATState *s, const char *filename)
         return NULL;
     }
 
-    number_of_entries = (length * 2 + 25) / 26;
+    number_of_entries = DIV_ROUND_UP(length * 2, 26);
 
     for(i=0;i<number_of_entries;i++) {
         entry=array_get_next(&(s->directory));
@@ -2554,7 +2554,7 @@ static int commit_one_file(BDRVVVFATState* s,
                 (size > offset && c >=2 && !fat_eof(s, c)));
 
         ret = vvfat_read(s->bs, cluster2sector(s, c),
-            (uint8_t*)cluster, (rest_size + 0x1ff) / 0x200);
+            (uint8_t*)cluster, DIV_ROUND_UP(rest_size, 0x200));
 
         if (ret < 0) {
             qemu_close(fd);