linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bernd Schubert <bernd.schubert@itwm.fraunhofer.de>
To: neilb@suse.de, piergiorgio.sartor@nexgo.de
Cc: linux-raid@vger.kernel.org, Bernd Schubert <bernd.schubert@fastmail.fm>
Subject: [PATCH 5/6] raid6check: Fix compiler warnings.
Date: Tue, 18 Jun 2013 11:09:36 +0200	[thread overview]
Message-ID: <20130618090936.1161109.67664.stgit@fsdevel7.hpc.devnet.itwm.fhg.de> (raw)
In-Reply-To: <20130618090910.1161109.69430.stgit@fsdevel7.hpc.devnet.itwm.fhg.de>

Fix some compiler warnings appearing with optimization levels.

Signed-off-by: Bernd Schubert <bernd.schubert@fastmail.fm>
---
 raid6check.c |   32 ++++++++++++++++++++++++++------
 1 file changed, 26 insertions(+), 6 deletions(-)

diff --git a/raid6check.c b/raid6check.c
index 480422d..90a7fd3 100644
--- a/raid6check.c
+++ b/raid6check.c
@@ -186,7 +186,12 @@ int check_stripes(struct mdinfo *info, int *source, unsigned long long *offsets,
 		}
 		for (i = 0 ; i < raid_disks ; i++) {
 			lseek64(source[i], offsets[i] + start * chunk_size, 0);
-			read(source[i], stripes[i], chunk_size);
+			int read_res = read(source[i], stripes[i], chunk_size);
+			if (read_res < chunk_size) {
+				fprintf(stderr, "Failed to read complete chunk disk %d, aborting\n", i);
+				unlock_all_stripes(info, sig);
+				goto exitCheck;
+			}
 		}
 		err = unlock_all_stripes(info, sig);
 		if(err != 0)
@@ -282,14 +287,23 @@ int check_stripes(struct mdinfo *info, int *source, unsigned long long *offsets,
 				goto exitCheck;
 			}
 
+			int write_res1, write_res2;
+
 			lseek64(source[failed_disk1], offsets[failed_disk1] + start * chunk_size, 0);
-			write(source[failed_disk1], stripes[failed_disk1], chunk_size);
+			write_res1 = write(source[failed_disk1], stripes[failed_disk1], chunk_size);
 			lseek64(source[failed_disk2], offsets[failed_disk2] + start * chunk_size, 0);
-			write(source[failed_disk2], stripes[failed_disk2], chunk_size);
+			write_res2 = write(source[failed_disk2], stripes[failed_disk2], chunk_size);
 
 			err = unlock_all_stripes(info, sig);
 			if(err != 0)
 				goto exitCheck;
+
+
+			if (write_res1 != chunk_size || write_res2 != chunk_size) {
+				fprintf(stderr, "Failed to write a complete chunk.\n");
+				goto exitCheck;
+			}
+
 		} else if (disk >= 0 && repair == AUTO_REPAIR) {
 			printf("Auto-repairing slot %d (%s)\n", disk, name[disk]);
 			if (disk == diskQ) {
@@ -314,11 +328,16 @@ int check_stripes(struct mdinfo *info, int *source, unsigned long long *offsets,
 			}
 
 			lseek64(source[disk], offsets[disk] + start * chunk_size, 0);
-			write(source[disk], stripes[disk], chunk_size);
+			int write_res = write(source[disk], stripes[disk], chunk_size);
 
 			err = unlock_all_stripes(info, sig);
-			if(err != 0)
+			if(err != 0 || write_res != chunk_size)
 				goto exitCheck;
+
+			if (write_res != chunk_size) {
+				fprintf(stderr, "Failed to write a full chunk.\n");
+				goto exitCheck;
+			}
 		}
 
 
@@ -364,7 +383,8 @@ int main(int argc, char *argv[])
 	int layout = -1;
 	int level = 6;
 	enum repair repair = NO_REPAIR;
-	int failed_disk1, failed_disk2;
+	int failed_disk1 = -1; 
+	int failed_disk2 = -1;
 	unsigned long long start, length;
 	int i;
 	int mdfd;


  parent reply	other threads:[~2013-06-18  9:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-18  9:09 [PATCH 0/6] raid6check fixes Bernd Schubert
2013-06-18  9:09 ` [PATCH 1/6] raid6check: Fix build of raid6check Bernd Schubert
2013-06-18  9:09 ` [PATCH 2/6] Makefile: Allow the user to pass EXTRA_CFLAGS Bernd Schubert
2013-06-19  0:07   ` NeilBrown
2013-06-19  9:48     ` Bernd Schubert
2013-06-24  7:01       ` NeilBrown
2013-06-18  9:09 ` [PATCH 3/6] raid6check: Fix memory leaks detected by valgrind Bernd Schubert
2013-06-18  9:09 ` [PATCH 4/6] raid6check: Use enums for repair type Bernd Schubert
2013-06-18  9:09 ` Bernd Schubert [this message]
2013-06-18  9:09 ` [PATCH 6/6] raid6check: Check return value of lseek64() Bernd Schubert
2013-06-18 17:16 ` [PATCH 0/6] raid6check fixes Piergiorgio Sartor
2013-06-19  0:08 ` NeilBrown
2013-06-20 16:16   ` Piergiorgio Sartor
2013-06-24  7:04     ` NeilBrown
2013-06-24 17:10       ` Piergiorgio Sartor
2013-06-24 23:54         ` NeilBrown
2013-06-25 16:46           ` Piergiorgio Sartor
2013-06-27  4:27             ` NeilBrown
2013-06-27 20:49               ` Piergiorgio Sartor
2013-06-27 21:12                 ` NeilBrown
2013-06-28 17:46                   ` Piergiorgio Sartor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130618090936.1161109.67664.stgit@fsdevel7.hpc.devnet.itwm.fhg.de \
    --to=bernd.schubert@itwm.fraunhofer.de \
    --cc=bernd.schubert@fastmail.fm \
    --cc=linux-raid@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=piergiorgio.sartor@nexgo.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).