diff mbox

[3/6] btrfs-progs: fragments, close output file on error

Message ID fe4faae136f941466325234ba2a2f6b347d1dbb4.1419005022.git.dsterba@suse.cz (mailing list archive)
State Accepted
Headers show

Commit Message

David Sterba Dec. 19, 2014, 4:06 p.m. UTC
Resolves-Coverity-CID: 1258794
Signed-off-by: David Sterba <dsterba@suse.cz>
---
 btrfs-fragments.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Comments

Eric Sandeen Dec. 19, 2014, 4:50 p.m. UTC | #1
On 12/19/14 10:06 AM, David Sterba wrote:
> Resolves-Coverity-CID: 1258794
> Signed-off-by: David Sterba <dsterba@suse.cz>

Reviewed-by: Eric Sandeen <sandeen@redhat.com>

> ---
>  btrfs-fragments.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/btrfs-fragments.c b/btrfs-fragments.c
> index d03c2c3e7319..360f10f87bfa 100644
> --- a/btrfs-fragments.c
> +++ b/btrfs-fragments.c
> @@ -233,7 +233,7 @@ list_fragments(int fd, u64 flags, char *dir)
>  		ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
>  		if (ret < 0) {
>  			fprintf(stderr, "ERROR: can't perform the search\n");
> -			return ret;
> +			goto out_close;
>  		}
>  		/* the ioctl returns the number of item it found in nr_items */
>  		if (sk->nr_items == 0)
> @@ -373,7 +373,10 @@ skip:;
>  		fprintf(html, "</p>");
>  	}
>  	fprintf(html, "</body></html>\n");
> -	
> +
> +out_close:
> +	fclose(html);
> +
>  	return ret;
>  }
>  
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/btrfs-fragments.c b/btrfs-fragments.c
index d03c2c3e7319..360f10f87bfa 100644
--- a/btrfs-fragments.c
+++ b/btrfs-fragments.c
@@ -233,7 +233,7 @@  list_fragments(int fd, u64 flags, char *dir)
 		ret = ioctl(fd, BTRFS_IOC_TREE_SEARCH, &args);
 		if (ret < 0) {
 			fprintf(stderr, "ERROR: can't perform the search\n");
-			return ret;
+			goto out_close;
 		}
 		/* the ioctl returns the number of item it found in nr_items */
 		if (sk->nr_items == 0)
@@ -373,7 +373,10 @@  skip:;
 		fprintf(html, "</p>");
 	}
 	fprintf(html, "</body></html>\n");
-	
+
+out_close:
+	fclose(html);
+
 	return ret;
 }