INN commit: trunk/storage/buffindexed (buffindexed.c)

INN Commit rra at isc.org
Sun May 24 16:31:42 UTC 2015


    Date: Sunday, May 24, 2015 @ 09:31:42
  Author: iulius
Revision: 9881

storage/buffindexed/buffindexed.c:  fix alignment warnings

Given that GROUPheader is already a pointer to a GROUPHEADER, just
use &GROUPheader[1].

Thanks to Russ Allbery for the patch.

These are all problems with assigning the mmap'd address to a variable
that points to the first element of the structure.  A better way of
representing this in C would have been to have a pointer to GROUPENTRY be
the last element of GROUPHEADER, although I'm not sure what other
assumptions that would break, somewhere else.

These alignment cast warnings are mostly because the way that mmap'd data
structures are handled are probably correct in terms of code generation
but aren't represented very well for the C type checker.

Modified:
  trunk/storage/buffindexed/buffindexed.c

---------------+
 buffindexed.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Modified: buffindexed.c
===================================================================
--- buffindexed.c	2015-05-24 14:27:32 UTC (rev 9880)
+++ buffindexed.c	2015-05-24 16:31:42 UTC (rev 9881)
@@ -1048,7 +1048,7 @@
       close(GROUPfd);
       return false;
     }
-    GROUPentries = (GROUPENTRY *)((char *)GROUPheader + sizeof(GROUPHEADER));
+    GROUPentries = (void *) &GROUPheader[1];
   } else {
     GROUPcount = 0;
     if (!GROUPexpand(mode)) {
@@ -1203,7 +1203,7 @@
     syswarn("buffindexed: Could not mmap group.index in GROUPremapifneeded");
     return false;
   }
-  GROUPentries = (GROUPENTRY *)((char *)GROUPheader + sizeof(GROUPHEADER));
+  GROUPentries = (void *) &GROUPheader[1];
   return true;
 }
 
@@ -1238,7 +1238,7 @@
     syswarn("buffindexed: Could not mmap group.index in GROUPexpand");
     return false;
   }
-  GROUPentries = (GROUPENTRY *)((char *)GROUPheader + sizeof(GROUPHEADER));
+  GROUPentries = (void *) &GROUPheader[1];
   if (GROUPheader->magic != GROUPHEADERMAGIC) {
     GROUPheader->magic = GROUPHEADERMAGIC;
     GROUPLOCclear(&GROUPheader->freelist);
@@ -1664,7 +1664,7 @@
       ovgroupunmap();
       return false;
     }
-    ovblock = (OVBLOCK *)((char *)addr + pagefudge);
+    ovblock = (void *)((char *)addr + pagefudge);
     if (ov.index == ge->curindex.index && ov.blocknum == ge->curindex.blocknum) {
       limit = ge->curindexoffset;
     } else {



More information about the inn-committers mailing list