From: Jeffrey Hutzelman Date: Wed, 19 Jun 2013 03:12:46 +0000 (-0400) Subject: viced/callback.c: Ignore dump write errors harder X-Git-Tag: upstream/1.8.0_pre1^2~1124 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=e16bef6136f83d0fc9a691051fc54a2ae5f573c9;p=packages%2Fo%2Fopenafs.git viced/callback.c: Ignore dump write errors harder When writing a callback state dump, test the return values from write(2), but don't do anything based on the test. This avoids compiler warnings when building on Ubuntu 12.10, with gcc 4.7.2 and eglibc 2.15-0ubuntu20.1. This adds a new macro, WriteBytes(), which handles writing a requested number of bytes to a file and ignoring errors. Change-Id: Icead6b25a290cea09a91184dc12b7449cfaaf6f7 Reviewed-on: http://gerrit.openafs.org/9991 Tested-by: BuildBot Reviewed-by: Benjamin Kaduk Reviewed-by: Derrick Brashear --- diff --git a/src/viced/callback.c b/src/viced/callback.c index 5460702db..edc2c6383 100644 --- a/src/viced/callback.c +++ b/src/viced/callback.c @@ -2646,6 +2646,8 @@ cb_OldToNew(struct fs_dump_state * state, afs_uint32 old, afs_uint32 * new) } #endif /* AFS_DEMAND_ATTACH_FS */ +#define DumpBytes(fd,buf,req) if (write(fd, buf, req) < 0) ; /* don't care */ + static int DumpCallBackState_r(void) { @@ -2663,19 +2665,23 @@ DumpCallBackState_r(void) AFSDIR_SERVER_CBKDUMP_FILEPATH)); return 0; } - (void)write(fd, &magic, sizeof(magic)); - (void)write(fd, &now, sizeof(now)); - (void)write(fd, &cbstuff, sizeof(cbstuff)); - (void)write(fd, TimeOuts, sizeof(TimeOuts)); - (void)write(fd, timeout, sizeof(timeout)); - (void)write(fd, &tfirst, sizeof(tfirst)); + /* + * Collect but ignoring the return value of write(2) here, + * to avoid compiler warnings on some platforms. + */ + DumpBytes(fd, &magic, sizeof(magic)); + DumpBytes(fd, &now, sizeof(now)); + DumpBytes(fd, &cbstuff, sizeof(cbstuff)); + DumpBytes(fd, TimeOuts, sizeof(TimeOuts)); + DumpBytes(fd, timeout, sizeof(timeout)); + DumpBytes(fd, &tfirst, sizeof(tfirst)); freelisthead = cbtoi((struct CallBack *)CBfree); - (void)write(fd, &freelisthead, sizeof(freelisthead)); /* This is a pointer */ + DumpBytes(fd, &freelisthead, sizeof(freelisthead)); /* This is a pointer */ freelisthead = fetoi((struct FileEntry *)FEfree); - (void)write(fd, &freelisthead, sizeof(freelisthead)); /* This is a pointer */ - (void)write(fd, HashTable, sizeof(HashTable)); - (void)write(fd, &CB[1], sizeof(CB[1]) * cbstuff.nblks); /* CB stuff */ - (void)write(fd, &FE[1], sizeof(FE[1]) * cbstuff.nblks); /* FE stuff */ + DumpBytes(fd, &freelisthead, sizeof(freelisthead)); /* This is a pointer */ + DumpBytes(fd, HashTable, sizeof(HashTable)); + DumpBytes(fd, &CB[1], sizeof(CB[1]) * cbstuff.nblks); /* CB stuff */ + DumpBytes(fd, &FE[1], sizeof(FE[1]) * cbstuff.nblks); /* FE stuff */ close(fd); return 0;