[Pkg-shadow-commits] r2772 - upstream/trunk/lib

Nicolas FRANÇOIS nekral-guest at alioth.debian.org
Thu Apr 23 11:46:46 UTC 2009


Author: nekral-guest
Date: 2009-04-23 11:46:46 +0000 (Thu, 23 Apr 2009)
New Revision: 2772

Modified:
   upstream/trunk/lib/getdef.c
Log:
	* lib/getdef.c: Added splint annotations.
	* lib/getdef.c: Ignore fputs() return value.
	* lib/getdef.c: Use EXIT_FAILURE / EXIT_SUCCESS for exit()


Modified: upstream/trunk/lib/getdef.c
===================================================================
--- upstream/trunk/lib/getdef.c	2009-04-23 11:46:06 UTC (rev 2771)
+++ upstream/trunk/lib/getdef.c	2009-04-23 11:46:46 UTC (rev 2772)
@@ -45,8 +45,8 @@
  * A configuration item definition.
  */
 struct itemdef {
-	const char *name;	/* name of the item                     */
-	char *value;		/* value given, or NULL if no value     */
+	/*@null@*/const char *name;	/* name of the item                     */
+	/*@null@*/char *value;		/* value given, or NULL if no value     */
 };
 
 #define NUMDEFS	(sizeof(def_table)/sizeof(def_table[0]))
@@ -135,7 +135,7 @@
 static bool def_loaded = false;		/* are defs already loaded?     */
 
 /* local function prototypes */
-static struct itemdef *def_find (const char *);
+static /*@observer@*/ /*@null@*/struct itemdef *def_find (const char *);
 static void def_load (void);
 
 
@@ -146,7 +146,7 @@
  * defined.  First time invoked, will load definitions from the file.
  */
 
-char *getdef_str (const char *item)
+/*@observer@*/ /*@null@*/const char *getdef_str (const char *item)
 {
 	struct itemdef *d;
 
@@ -155,7 +155,7 @@
 	}
 
 	d = def_find (item);
-	return ((NULL == d)? (char *) NULL : d->value);
+	return ((NULL == d)? (const char *) NULL : d->value);
 }
 
 
@@ -295,7 +295,7 @@
 unsigned long getdef_ulong (const char *item, unsigned long dflt)
 {
 	struct itemdef *d;
-	long val;
+	unsigned long val;
 
 	if (!def_loaded) {
 		def_load ();
@@ -306,7 +306,7 @@
 		return dflt;
 	}
 
-	if (getlong (d->value, &val) == 0) {
+	if (getulong (d->value, &val) == 0) {
 		/* FIXME: we should have a getulong */
 		fprintf (stderr,
 		         _("configuration error - cannot parse %s value: '%s'"),
@@ -345,8 +345,8 @@
 	 */
 	cp = strdup (value);
 	if (NULL == cp) {
-		fputs (_("Could not allocate space for config info.\n"),
-		       stderr);
+		(void) fputs (_("Could not allocate space for config info.\n"),
+		              stderr);
 		SYSLOG ((LOG_ERR, "could not allocate space for config info"));
 		return -1;
 	}
@@ -367,7 +367,7 @@
  * specified configuration option.
  */
 
-static struct itemdef *def_find (const char *name)
+static /*@observer@*/ /*@null@*/struct itemdef *def_find (const char *name)
 {
 	struct itemdef *ptr;
 
@@ -413,7 +413,7 @@
 		int err = errno;
 		SYSLOG ((LOG_CRIT, "cannot open login definitions %s [%s]",
 		         def_fname, strerror (err)));
-		exit (1);
+		exit (EXIT_FAILURE);
 	}
 
 	/*
@@ -455,15 +455,19 @@
 
 		/*
 		 * Store the value in def_table.
+		 *
+		 * Ignore failures to load the login.defs file.
+		 * The error was already reported to the user and to
+		 * syslog. The tools will just use their default values.
 		 */
-		putdef_str (name, value);
+		(void)putdef_str (name, value);
 	}
 
 	if (ferror (fp) != 0) {
 		int err = errno;
 		SYSLOG ((LOG_CRIT, "cannot read login definitions %s [%s]",
 		         def_fname, strerror (err)));
-		exit (1);
+		exit (EXIT_FAILURE);
 	}
 
 	(void) fclose (fp);
@@ -496,6 +500,6 @@
 			printf ("%s not found\n", argv[1]);
 		}
 	}
-	exit (0);
+	exit (EXIT_SUCCESS);
 }
 #endif




More information about the Pkg-shadow-commits mailing list