diff options
author | 2016-08-14 17:18:37 +0200 | |
---|---|---|
committer | 2016-08-14 17:18:37 +0200 | |
commit | 5923229d2c7b63be3ffbad51070c29499300b030 (patch) | |
tree | d67f732162fa69ab8f2c7ed7e3ebb07aafd572af /sys-block/f3/files/f3-6.0-fix-compiler-warnings_f3read.patch | |
parent | sys-apps/hponcfg: New package (diff) | |
download | gentoo-5923229d2c7b63be3ffbad51070c29499300b030.tar.gz gentoo-5923229d2c7b63be3ffbad51070c29499300b030.tar.bz2 gentoo-5923229d2c7b63be3ffbad51070c29499300b030.zip |
sys-block/f3: New package
The "Fight Flash Fraud" or "Fight Fake Flash" tool represents
a GPLv3 implementation of the algorithm of h2testw and further
improvements to speed up the identification of fake drives
as well as making them usable.
You can also use these utilities if you want to test the
integrity of your USB/flash medium.
Package-Manager: portage-2.3.0
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.patch | 88 |
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)); |