diff mbox

[01/21] e2fuzz: fix build problems on macosx and i386 linux

Message ID 20140805010504.2611.14307.stgit@birch.djwong.org
State Accepted, archived
Headers show

Commit Message

Darrick Wong Aug. 5, 2014, 1:05 a.m. UTC
Fix clang warnings about forgotten header files, dead code, and pwrite
support on OS X.  The unistd.h inclusion also fixes a parameter
truncation bug on i386.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 misc/e2fuzz.c |   21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)



--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Theodore Ts'o Aug. 10, 2014, 10:16 p.m. UTC | #1
On Mon, Aug 04, 2014 at 06:05:04PM -0700, Darrick J. Wong wrote:
> Fix clang warnings about forgotten header files, dead code, and pwrite
> support on OS X.  The unistd.h inclusion also fixes a parameter
> truncation bug on i386.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Applied, thanks.

					- Ted
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/misc/e2fuzz.c b/misc/e2fuzz.c
index 8c989dd..91aafe5 100644
--- a/misc/e2fuzz.c
+++ b/misc/e2fuzz.c
@@ -18,6 +18,7 @@ 
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <stdint.h>
+#include <unistd.h>
 #ifdef HAVE_GETOPT_H
 #include <getopt.h>
 #endif
@@ -31,6 +32,16 @@  static int metadata_only = 1;
 static unsigned long long user_corrupt_bytes = 0;
 static double user_corrupt_pct = 0.0;
 
+#ifndef HAVE_PWRITE
+ssize_t pwrite(int fd, const void *buf, size_t count, off_t offset)
+{
+	if (lseek(fd, offset, SEEK_SET) < 0)
+		return 0;
+
+	return write(fd, buf, count);
+}
+#endif /* HAVE_PWRITE */
+
 int getseed(void)
 {
 	int r;
@@ -70,7 +81,7 @@  errcode_t find_metadata_blocks(ext2_filsys fs, ext2fs_block_bitmap bmap,
 			       off_t *corrupt_bytes)
 {
 	dgrp_t i;
-	blk64_t b, c, d, j, old_desc_blocks;
+	blk64_t b, c;
 	ext2_inode_scan scan;
 	ext2_ino_t ino;
 	struct ext2_inode inode;
@@ -79,12 +90,6 @@  errcode_t find_metadata_blocks(ext2_filsys fs, ext2fs_block_bitmap bmap,
 
 	*corrupt_bytes = 0;
 	fb.corrupt_blocks = 0;
-	if (EXT2_HAS_INCOMPAT_FEATURE(fs->super,
-				      EXT2_FEATURE_INCOMPAT_META_BG))
-		old_desc_blocks = fs->super->s_first_meta_bg;
-	else
-		old_desc_blocks = fs->desc_blocks +
-				  fs->super->s_reserved_gdt_blocks;
 
 	/* Construct bitmaps of super/descriptor blocks */
 	for (i = 0; i < fs->group_desc_count; i++) {
@@ -271,7 +276,7 @@  int process_fs(const char *fsname)
 			       off % fs->blocksize, off / fs->blocksize, c);
 		if (dryrun)
 			continue;
-		if (pwrite64(fd, &c, sizeof(c), off) != sizeof(c)) {
+		if (pwrite(fd, &c, sizeof(c), off) != sizeof(c)) {
 			perror(fsname);
 			goto fail3;
 		}