Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Oct 2010 22:04:37 +0000 (UTC)
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r214253 - stable/8/sbin/geom/core
Message-ID:  <201010232204.o9NM4bPW003379@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pjd
Date: Sat Oct 23 22:04:37 2010
New Revision: 214253
URL: http://svn.freebsd.org/changeset/base/214253

Log:
  Constify go_val field.
  
  (Should've been MFC of r212547.)

Modified:
  stable/8/sbin/geom/core/geom.c
  stable/8/sbin/geom/core/geom.h

Modified: stable/8/sbin/geom/core/geom.c
==============================================================================
--- stable/8/sbin/geom/core/geom.c	Sat Oct 23 21:56:50 2010	(r214252)
+++ stable/8/sbin/geom/core/geom.c	Sat Oct 23 22:04:37 2010	(r214253)
@@ -257,10 +257,11 @@ set_option(struct g_command *cmd, struct
 			err(EXIT_FAILURE, "Invalid value for '%c' argument",
 			    opt->go_char);
 		}
-		opt->go_val = malloc(sizeof(intmax_t));
-		if (opt->go_val == NULL)
+		ptr = malloc(sizeof(intmax_t));
+		if (ptr == NULL)
 			errx(EXIT_FAILURE, "No memory.");
-		*(intmax_t *)opt->go_val = number;
+		*(intmax_t *)ptr = number;
+		opt->go_val = ptr;
 		gctl_ro_param(req, opt->go_name, sizeof(intmax_t), opt->go_val);
 	} else if (G_OPT_TYPE(opt) == G_TYPE_ASCNUM) {
 		if (cmd->gc_argname == NULL || *val != '\0') {
@@ -280,10 +281,11 @@ set_option(struct g_command *cmd, struct
 		if (cmd->gc_argname == NULL || *val != '\0')
 			gctl_ro_param(req, opt->go_name, -1, val);
 	} else if (G_OPT_TYPE(opt) == G_TYPE_BOOL) {
-		opt->go_val = malloc(sizeof(int));
-		if (opt->go_val == NULL)
+		ptr = malloc(sizeof(int));
+		if (ptr == NULL)
 			errx(EXIT_FAILURE, "No memory.");
-		*(int *)opt->go_val = *val - '0';
+		*(int *)ptr = *val - '0';
+		opt->go_val = ptr;
 		gctl_ro_param(req, opt->go_name, sizeof(int), opt->go_val);
 	} else {
 		assert(!"Invalid type");
@@ -378,7 +380,7 @@ parse_arguments(struct g_command *cmd, s
 				char val[64];
 
 				snprintf(val, sizeof(val), "%jd",
-				    *(intmax_t *)opt->go_val);
+				    *(const intmax_t *)opt->go_val);
 				set_option(cmd, req, opt, val);
 			}
 		}

Modified: stable/8/sbin/geom/core/geom.h
==============================================================================
--- stable/8/sbin/geom/core/geom.h	Sat Oct 23 21:56:50 2010	(r214252)
+++ stable/8/sbin/geom/core/geom.h	Sat Oct 23 22:04:37 2010	(r214253)
@@ -62,7 +62,7 @@
 struct g_option {
 	char		 go_char;
 	const char	*go_name;
-	void		*go_val;
+	const void	*go_val;
 	unsigned	 go_type;
 };
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201010232204.o9NM4bPW003379>