summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sys-block/f3/files/f3-6.0-fix-compiler-warnings_f3read.patch')
-rw-r--r--sys-block/f3/files/f3-6.0-fix-compiler-warnings_f3read.patch88
1 files changed, 88 insertions, 0 deletions
diff --git a/sys-block/f3/files/f3-6.0-fix-compiler-warnings_f3read.patch b/sys-block/f3/files/f3-6.0-fix-compiler-warnings_f3read.patch
new file mode 100644
index 000000000000..0e4f61fca816
--- /dev/null
+++ b/sys-block/f3/files/f3-6.0-fix-compiler-warnings_f3read.patch
@@ -0,0 +1,88 @@
+From 52e252f5d6dc6d10fd85a45b0774bb0b29d5f989 Mon Sep 17 00:00:00 2001
+From: Michel Machado <michel@digirati.com.br>
+Date: Mon, 4 Jan 2016 13:22:18 -0500
+Subject: [PATCH] f3read: avoid compiler warning
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+When using -O2, GCC was issuing the following warning:
+
+cc -O2 -std=c99 -Wall -Wextra -pedantic -MMD -ggdb -c -o f3read.o f3read.c
+f3read.c: In function ‘validate_file’:
+f3read.c:95:3: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
+ offset = *((uint64_t *) sector);
+ ^
+---
+ f3read.c | 28 ++++++++++++----------------
+ 1 file changed, 12 insertions(+), 16 deletions(-)
+
+diff --git a/f3read.c b/f3read.c
+index 1514365..2dc6942 100644
+--- a/f3read.c
++++ b/f3read.c
+@@ -42,12 +42,12 @@ static void validate_file(const char *path, int number,
+ {
+ char *full_fn;
+ const char *filename;
+- uint8_t sector[SECTOR_SIZE], *p, *ptr_end;
++ const int num_int64 = SECTOR_SIZE >> 3;
++ uint64_t sector[num_int64];
+ FILE *f;
+ int fd;
+- int offset_match, error_count;
+ size_t sectors_read;
+- uint64_t offset, expected_offset;
++ uint64_t expected_offset;
+ int final_errno;
+ struct timeval t1, t2;
+ /* Progress time. */
+@@ -84,32 +84,24 @@ static void validate_file(const char *path, int number,
+ /* Help the kernel to help us. */
+ assert(!posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL));
+
+- ptr_end = sector + SECTOR_SIZE;
+ sectors_read = fread(sector, SECTOR_SIZE, 1, f);
+ final_errno = errno;
+ expected_offset = (uint64_t)number * GIGABYTES;
+ while (sectors_read > 0) {
+ uint64_t rn;
++ int error_count, i;
+
+ assert(sectors_read == 1);
+- offset = *((uint64_t *) sector);
+- offset_match = offset == expected_offset;
+
+- rn = offset;
+- p = sector + sizeof(offset);
++ rn = sector[0];
+ error_count = 0;
+- for (; error_count <= TOLERANCE && p < ptr_end;
+- p += sizeof(rn)) {
++ for (i = 1; error_count <= TOLERANCE && i < num_int64; i++) {
+ rn = random_number(rn);
+- if (rn != *((__typeof__(rn) *) p))
++ if (rn != sector[i])
+ error_count++;
+ }
+
+- sectors_read = fread(sector, SECTOR_SIZE, 1, f);
+- final_errno = errno;
+- expected_offset += SECTOR_SIZE;
+-
+- if (offset_match) {
++ if (expected_offset == sector[0]) {
+ if (error_count == 0)
+ (*ptr_ok)++;
+ else if (error_count <= TOLERANCE)
+@@ -121,6 +113,10 @@ static void validate_file(const char *path, int number,
+ else
+ (*ptr_corrupted)++;
+
++ sectors_read = fread(sector, SECTOR_SIZE, 1, f);
++ final_errno = errno;
++ expected_offset += SECTOR_SIZE;
++
+ if (progress) {
+ struct timeval pt2;
+ assert(!gettimeofday(&pt2, NULL));