[lvm-devel] master - coverity: fix compiler warning

Peter Rajnoha prajnoha at fedoraproject.org
Wed Nov 12 08:55:34 UTC 2014


Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=60cc666c949ca16b1d7297eb2a3abc78dfbf3bf9
Commit:        60cc666c949ca16b1d7297eb2a3abc78dfbf3bf9
Parent:        57c618b0edbea321626766d9de2a0640efdc2bc2
Author:        Peter Rajnoha <prajnoha at redhat.com>
AuthorDate:    Wed Nov 12 09:42:53 2014 +0100
Committer:     Peter Rajnoha <prajnoha at redhat.com>
CommitterDate: Wed Nov 12 09:55:12 2014 +0100

coverity: fix compiler warning

LVM2.2.02.112/lib/activate/dev_manager.c:196:5: warning: 'dmtask' may be used uninitialized in this function [-Wmaybe-uninitialized]

In _info_run fn:

switch (type) {
	case INFO:
		...
	case STATUS:
		...
	case MKNODES:
		...
}

The "type" is enum and currently only those three types are supported,
but if we added a new type in the future, this would end up with a bug
(if we forgot to add the new "case" in that "switch"). So let's make
sure proper internal error is printed:

	default:
		log_error(INTERNAL_ERROR "_info_run: unhandled info type");
                return 0;
---
 lib/activate/dev_manager.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 18ecb3a..c62dcb8 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -191,6 +191,9 @@ static int _info_run(info_type_t type, const char *name, const char *dlid,
 		case MKNODES:
 			dmtask = DM_DEVICE_MKNODES;
 			break;
+		default:
+			log_error(INTERNAL_ERROR "_info_run: unhandled info type");
+			return 0;
 	}
 
 	if (!(dmt = _setup_task(type != MKNODES ? name : NULL, dlid, 0, dmtask,




More information about the lvm-devel mailing list