public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
From: zkabelac@sourceware.org
To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org
Subject: LVM2 lib/metadata/lv.c lib/metadata/lv_manip.c ...
Date: Mon, 13 Feb 2012 11:25:00 -0000	[thread overview]
Message-ID: <20120213112557.30367.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-02-13 11:25:56

Modified files:
	lib/metadata   : lv.c lv_manip.c 
	liblvm         : lvm_lv.c 
	tools          : reporter.c 

Log message:
	Add internal error for unsupported code paths
	
	Patch mainly helps static analyzers to better work with code paths
	lvm code should never trigger.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.360&r2=1.361
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_lv.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68

--- LVM2/lib/metadata/lv.c	2012/01/24 00:55:03	1.36
+++ LVM2/lib/metadata/lv.c	2012/02/13 11:25:56	1.37
@@ -53,6 +53,9 @@
 		case AREA_UNASSIGNED:
 			name = "unassigned";
 			extent = 0;
+		default:
+			log_error(INTERNAL_ERROR "Unknown area segtype.");
+			return NULL;
 		}
 
 		if (!dm_pool_grow_object(mem, name, strlen(name))) {
--- LVM2/lib/metadata/lv_manip.c	2012/02/12 21:37:03	1.360
+++ LVM2/lib/metadata/lv_manip.c	2012/02/13 11:25:56	1.361
@@ -2116,6 +2116,11 @@
 		return NULL;
 	}
 
+	if (!allocatable_pvs) {
+		log_error(INTERNAL_ERROR "Missing allocatable pvs.");
+		return NULL;
+	}
+
 	if (vg->fid->fmt->ops->segtype_supported &&
 	    !vg->fid->fmt->ops->segtype_supported(vg->fid, segtype)) {
 		log_error("Metadata format (%s) does not support required "
--- LVM2/liblvm/lvm_lv.c	2012/02/08 11:41:18	1.37
+++ LVM2/liblvm/lvm_lv.c	2012/02/13 11:25:56	1.38
@@ -124,12 +124,18 @@
 }
 
 /* Set default for linear segment specific LV parameters */
-static void _lv_set_default_linear_params(struct cmd_context *cmd,
+static int _lv_set_default_linear_params(struct cmd_context *cmd,
 					  struct lvcreate_params *lp)
 {
-	lp->segtype = get_segtype_from_string(cmd, "striped");
+	if (!(lp->segtype = get_segtype_from_string(cmd, "striped"))) {
+		log_error(INTERNAL_ERROR "Segtype striped not found.");
+		return 0;
+	}
+
 	lp->stripes = 1;
 	lp->stripe_size = DEFAULT_STRIPESIZE * 2;
+
+	return 1;
 }
 
 /*
@@ -151,7 +157,8 @@
 	extents = extents_from_size(vg->cmd, size / SECTOR_SIZE,
 				    vg->extent_size);
 	_lv_set_default_params(&lp, vg, name, extents);
-	_lv_set_default_linear_params(vg->cmd, &lp);
+	if (!_lv_set_default_linear_params(vg->cmd, &lp))
+		return_NULL;
 	if (!lv_create_single(vg, &lp))
 		return NULL;
 	lvl = find_lv_in_vg(vg, name);
--- LVM2/tools/reporter.c	2011/08/10 20:25:31	1.67
+++ LVM2/tools/reporter.c	2012/02/13 11:25:56	1.68
@@ -315,6 +315,9 @@
 						  "report/pvsegs_cols_verbose",
 						  DEFAULT_PVSEGS_COLS_VERB);
 		break;
+	default:
+		log_error(INTERNAL_ERROR "Unknown report type.");
+		return ECMD_FAILED;
 	}
 
 	/* If -o supplied use it, else use default for report_type */


                 reply	other threads:[~2012-02-13 11:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20120213112557.30367.qmail@sourceware.org \
    --to=zkabelac@sourceware.org \
    --cc=lvm-devel@redhat.com \
    --cc=lvm2-cvs@sourceware.org \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).