]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
afs: Consolidate fheader initialization
authorAndrew Deason <adeason@sinenomine.net>
Wed, 24 Sep 2014 22:50:02 +0000 (17:50 -0500)
committerBenjamin Kaduk <kaduk@mit.edu>
Wed, 26 Nov 2014 20:45:31 +0000 (15:45 -0500)
We were initializing an afs_fheader structure in two different places,
with the same values. Consolidate these into a single function, so
updating the structure is easier. Also zero the whole structure, just
to make sure everything is initialized, even if the structure changes.

This commit should have no behavior impact; it is just code
reorganization.

Change-Id: If90757166d8490eaa053aa086c7b95349a62332e
Reviewed-on: http://gerrit.openafs.org/11510
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Perry Ruiter <pruiter@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
src/afs/afs_dcache.c
src/afs/afs_init.c
src/afs/afs_prototypes.h

index 235dce6e8fb238afde57e0acb6fa0650cabb4ae6..4a9edbdd87a766fade07204bd7af5e0098484106 100644 (file)
@@ -2681,11 +2681,7 @@ afs_WriteThroughDSlots(void)
         */
        struct afs_fheader theader;
 
-       theader.magic = AFS_FHMAGIC;
-       theader.firstCSize = AFS_FIRSTCSIZE;
-       theader.otherCSize = AFS_OTHERCSIZE;
-       theader.version = AFS_CI_VERSION;
-       theader.dataSize = sizeof(struct fcache);
+       afs_InitFHeader(&theader);
        afs_osi_Write(afs_cacheInodep, 0, &theader, sizeof(theader));
     }
     ReleaseWriteLock(&afs_xdcache);
index d588c75fb71acd01cec6fcfef35aa6731f516c86..acc7bef66d4411b4b42737d7c93394c6b32851e7 100644 (file)
@@ -335,6 +335,17 @@ afs_InitVolumeInfo(char *afile)
     return 0;
 }
 
+void
+afs_InitFHeader(struct afs_fheader *aheader)
+{
+    memset(aheader, 0, sizeof(*aheader));
+    aheader->magic = AFS_FHMAGIC;
+    aheader->version = AFS_CI_VERSION;
+    aheader->dataSize = sizeof(struct fcache);
+    aheader->firstCSize = AFS_FIRSTCSIZE;
+    aheader->otherCSize = AFS_OTHERCSIZE;
+}
+
 /*
  * afs_InitCacheInfo
  *
@@ -490,11 +501,7 @@ afs_InitCacheInfo(char *afile)
     }
     if (!goodFile) {
        /* write out a good file label */
-       theader.magic = AFS_FHMAGIC;
-       theader.firstCSize = AFS_FIRSTCSIZE;
-       theader.otherCSize = AFS_OTHERCSIZE;
-       theader.dataSize = sizeof(struct fcache);
-       theader.version = AFS_CI_VERSION;
+       afs_InitFHeader(&theader);
        afs_osi_Write(tfile, 0, &theader, sizeof(theader));
        /*
         * Truncate the rest of the file, since it may be arbitrarily
index 4495a914f35a90611584e859cf7d93f903e5ab44..178223b7ce21a4eb37a767ce355b26a394984a64 100644 (file)
@@ -442,6 +442,7 @@ extern int afs_CacheInit(afs_int32 astatSize, afs_int32 afiles,
                         afs_int32 aflags, afs_int32 ninodes,
                         afs_int32 nusers, afs_int32 dynamic_vcaches);
 extern void afs_ComputeCacheParms(void);
+extern void afs_InitFHeader(struct afs_fheader *aheader);
 extern int afs_InitCacheInfo(char *afile);
 extern int afs_InitVolumeInfo(char *afile);
 extern int afs_InitCellInfo(char *afile);