lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <555AE7A0.9040505@plexistor.com>
Date:	Tue, 19 May 2015 10:34:56 +0300
From:	Boaz Harrosh <boaz@...xistor.com>
To:	Brian Norris <computersforpeace@...il.com>,
	Jens Axboe <axboe@...com>
CC:	linux-kernel@...r.kernel.org, Christoph Hellwig <hch@...radead.org>
Subject: Re: [RFC] block: remove never-modified global variable

On 05/19/2015 10:19 AM, Boaz Harrosh wrote:
<>
> But specially now that you are unconditionally printing it. It is better
> to just combine the two statements. See suggested patch below:
> 

Actually we can even do better:

diff --git a/block/partitions/check.c b/block/partitions/check.c
index 513c601..9bea23d 100644
--- a/block/partitions/check.c
+++ b/block/partitions/check.c
@@ -160,35 +160,31 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
 
 	i = res = err = 0;
 	while (!res && check_part[i]) {
 		memset(state->parts, 0, state->limit * sizeof(state->parts[0]));
 		res = check_part[i++](state);
 		if (res < 0) {
 			/* We have hit an I/O error which we don't report now.
 		 	* But record it, and let the others do their job.
 		 	*/
 			err = res;
 			res = 0;
 		}
 
 	}

boaz> When we exit the loop res can only be (res >= 0)

 	if (res > 0) {
 		printk(KERN_INFO "%s", state->pp_buf);
 
 		free_page((unsigned long)state->pp_buf);
 		return state;

boaz> When bigger we exit here

 	}
 	if (state->access_beyond_eod)
 		err = -ENOSPC;

boaz> So by this stage res can only be == 0. So we should just do:

 	if (err)
	/* The partition is unrecognized. So report I/O errors if there were any */
-		res = err;
-	if (res) {
-		strlcat(state->pp_buf,
-			" unable to read partition table\n", PAGE_SIZE);
-		printk(KERN_INFO "%s", state->pp_buf);
-	}
+		printk(KERN_INFO "%s unable to read partition table\n",
+		       state->pp_buf);
 
 	free_page((unsigned long)state->pp_buf);
 	free_partitions(state);
 	return ERR_PTR(res);
 }

----
Here is a proper diff:
----
diff --git a/block/partitions/check.c b/block/partitions/check.c
index 513c601..9bea23d 100644
--- a/block/partitions/check.c
+++ b/block/partitions/check.c
@@ -181,12 +181,8 @@ check_partition(struct gendisk *hd, struct block_device *bdev)
 		err = -ENOSPC;
 	if (err)
 	/* The partition is unrecognized. So report I/O errors if there were any */
-		res = err;
-	if (res) {
-		strlcat(state->pp_buf,
-			" unable to read partition table\n", PAGE_SIZE);
-		printk(KERN_INFO "%s", state->pp_buf);
-	}
+		printk(KERN_INFO "%s unable to read partition table\n",
+		       state->pp_buf);
 
 	free_page((unsigned long)state->pp_buf);
 	free_partitions(state);

Thanks
Boaz
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ