From patchwork Sun Jun 26 18:45:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hugo Mills X-Patchwork-Id: 919492 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5QIkuew022265 for ; Sun, 26 Jun 2011 18:47:31 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753560Ab1FZSqY (ORCPT ); Sun, 26 Jun 2011 14:46:24 -0400 Received: from frost.carfax.org.uk ([212.13.194.111]:56923 "EHLO frost.carfax.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754431Ab1FZSps (ORCPT ); Sun, 26 Jun 2011 14:45:48 -0400 Received: from ruthven.carfax.org.uk ([10.0.0.10]) by frost.carfax.org.uk with esmtp (Exim 4.72) (envelope-from ) id 1QauL4-0000u1-4B for linux-btrfs@vger.kernel.org; Sun, 26 Jun 2011 18:45:47 +0000 Received: from [10.0.0.10] (helo=ruthven.carfax.org.uk) by ruthven.carfax.org.uk with esmtp (Exim 4.72) (envelope-from ) id 1QauL3-0003Wp-RH for linux-btrfs@vger.kernel.org; Sun, 26 Jun 2011 19:45:45 +0100 From: Hugo Mills To: Btrfs mailing list Subject: [PATCH] mkfs.btrfs: Fix compilation errors with gcc 4.6 Date: Sun, 26 Jun 2011 19:45:45 +0100 Message-Id: <2d8e41df20f9b3f82cc9796d391c14082c8aae1e.1309113811.git.hugo@carfax.org.uk> X-Mailer: git-send-email 1.7.2.5 To: linux-btrfs@vger.kernel.org X-frost.carfax.org.uk-Spam-Score: -0.0 (/) X-frost.carfax.org.uk-Spam-Report: Spam detection software, running on the system "spamd2.lon.bitfolk.com", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: gcc 4.6 complains about several possible use-before-initialise cases in mkfs, and stops. Fix these by initialising one of the variables in question, and using the correct error-handling paths for the remainder. [...] Content analysis details: (-0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 DOS_RCVD_IP_TWICE_B Received from the same IP twice in a row (only one external relay) -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Sun, 26 Jun 2011 18:47:31 +0000 (UTC) gcc 4.6 complains about several possible use-before-initialise cases in mkfs, and stops. Fix these by initialising one of the variables in question, and using the correct error-handling paths for the remainder. Signed-off-by: Hugo Mills --- mkfs.c | 7 ++++--- 1 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mkfs.c b/mkfs.c index 3a87d6e..edd7018 100644 --- a/mkfs.c +++ b/mkfs.c @@ -750,7 +750,7 @@ static int add_file_items(struct btrfs_trans_handle *trans, ino_t parent_inum, struct stat *st, const char *path_name, int out_fd) { - int ret; + int ret = -1; ssize_t ret_read; u64 bytes_read = 0; char *buffer = NULL; @@ -889,7 +889,7 @@ static int traverse_directory(struct btrfs_trans_handle *trans, ret = btrfs_lookup_inode(trans, root, &path, &root_dir_key, 1); if (ret) { fprintf(stderr, "root dir lookup error\n"); - goto fail; + return -1; } leaf = path.nodes[0]; @@ -913,7 +913,7 @@ static int traverse_directory(struct btrfs_trans_handle *trans, if (chdir(parent_dir_entry->path)) { fprintf(stderr, "chdir error for %s\n", parent_dir_name); - goto fail; + goto fail_no_files; } count = scandir(parent_dir_entry->path, &files, @@ -996,6 +996,7 @@ static int traverse_directory(struct btrfs_trans_handle *trans, return 0; fail: free_namelist(files, count); +fail_no_files: free(parent_dir_entry->path); free(parent_dir_entry); return -1;