[Pkg-wmaker-commits] [wmbiff] 70/77: lclint cleanups - strdup_ordie, some null annotations

Doug Torrance dtorrance-guest at moszumanska.debian.org
Thu Aug 20 03:01:18 UTC 2015


This is an automated email from the git hooks/post-receive script.

dtorrance-guest pushed a commit to tag wmbiff_0_4_0
in repository wmbiff.

commit 3352e4d1cb46425cc31fb6366295a55b19b5dca3
Author: bluehal <bluehal>
Date:   Mon Apr 29 02:01:50 2002 +0000

    lclint cleanups - strdup_ordie, some null annotations
---
 wmbiff/Client.h      |  7 ++++---
 wmbiff/ShellClient.c | 24 ++++++++++++++++--------
 wmbiff/charutil.c    | 11 ++++++++++-
 wmbiff/charutil.h    |  5 ++++-
 4 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/wmbiff/Client.h b/wmbiff/Client.h
index f092e98..d4e5222 100644
--- a/wmbiff/Client.h
+++ b/wmbiff/Client.h
@@ -1,11 +1,11 @@
-/* $Id: Client.h,v 1.21 2002/04/27 08:54:01 bluehal Exp $ */
+/* $Id: Client.h,v 1.22 2002/04/29 02:01:50 bluehal Exp $ */
 /* Author : Scott Holden ( scotth at thezone.net )
    Modified : Yong-iL Joh ( tolkien at mizi.com )
    Modified : Jorge Garc�a ( Jorge.Garcia at uv.es )
  *
  * Email Checker Pop3/Imap4/Licq/Gicu/mbox/maildir/finger
  *
- * Last Updated : $Date: 2002/04/27 08:54:01 $
+ * Last Updated : $Date: 2002/04/29 02:01:50 $
  *
  */
 
@@ -85,10 +85,11 @@ int shellCreate(Pop3 pc, const char *str);
 int mboxCreate(Pop3 pc, const char *str);
 int maildirCreate(Pop3 pc, char *str);
 FILE *openMailbox(Pop3 pc, const char *mbox_filename);
+/* backtickExpand returns null on failure */ /*@null@*/ 
 char *backtickExpand(Pop3 pc, const char *path);
 int fileHasChanged(const char *mbox_filename, time_t * atime,
 				   time_t * mtime, off_t * size);
-int grabCommandOutput(Pop3 pc, const char *command, char **output);
+int grabCommandOutput(Pop3 pc, const char *command, /*@out@*/ char **output);
 
 /* _NONE is for silent operation.  _ERROR is for things that should
    be printed assuming that the user might possibly see them. _INFO is
diff --git a/wmbiff/ShellClient.c b/wmbiff/ShellClient.c
index 23971f0..8eed082 100644
--- a/wmbiff/ShellClient.c
+++ b/wmbiff/ShellClient.c
@@ -25,8 +25,13 @@
 /* kind_popen bumps off the sigchld handler - we care whether
    a checking program fails. */
 
+#ifdef __LCLINT__
+void (*old_signal_handler)(int);
+#else
 sig_t old_signal_handler;
+#endif
 
+/*@null@*/
 FILE *kind_popen(const char *command, const char *type)
 {
 	FILE *ret;
@@ -37,7 +42,7 @@ FILE *kind_popen(const char *command, const char *type)
 	if (ret == NULL) {
 		DMA(DEBUG_ERROR, "popen: error while reading '%s': %s\n",
 			command, strerror(errno));
-		signal(SIGCHLD, old_signal_handler);
+		(void)signal(SIGCHLD, old_signal_handler);
 		old_signal_handler = NULL;
 	}
 	return (ret);
@@ -50,12 +55,13 @@ FILE *kind_popen(const char *command, const char *type)
    so no error checking can be done here until that's disabled */
 
 /* returns as a mailcheck function does: -1 on fail, 0 on success */
-static int kind_pclose(FILE * F, const char *command, Pop3 pc)
-{
+static int kind_pclose(/*@only@*/ FILE * F, 
+                       const char *command, 
+                       /*@null@*/ Pop3 pc) {
 	int exit_status = pclose(F);
 
 	if (old_signal_handler != NULL) {
-		signal(SIGCHLD, old_signal_handler);
+		(void)signal(SIGCHLD, old_signal_handler);
 		old_signal_handler = NULL;
 	}
 
@@ -74,7 +80,7 @@ static int kind_pclose(FILE * F, const char *command, Pop3 pc)
 	return (exit_status);
 }
 
-int grabCommandOutput(Pop3 pc, const char *command, char **output)
+int grabCommandOutput(Pop3 pc, const char *command, /*@out@*/ char **output)
 {
 	FILE *F;
 	char linebuf[512];
@@ -89,11 +95,13 @@ int grabCommandOutput(Pop3 pc, const char *command, char **output)
 			  strerror(errno));
 	} else {
 		chomp(linebuf);
-		*output = strdup(linebuf);
+		*output = strdup_ordie(linebuf);
 	}
 	return (kind_pclose(F, command, pc));
 }
 
+/* returns null on failure */
+/*@null@*/ 
 char *backtickExpand(Pop3 pc, const char *path)
 {
 	char bigbuffer[1024];
@@ -109,7 +117,7 @@ char *backtickExpand(Pop3 pc, const char *path)
 			return NULL;
 		}
 		strncat(bigbuffer, path, tickstart - path);
-		command = strdup(tickstart + 1);
+		command = strdup_ordie(tickstart + 1);
 		command[tickend - tickstart - 1] = '\0';
 		(void) grabCommandOutput(pc, command, &commandoutput);
 		free(command);
@@ -122,7 +130,7 @@ char *backtickExpand(Pop3 pc, const char *path)
 	/* grab the rest */
 	strcat(bigbuffer, path);
 	SH_DM(pc, DEBUG_INFO, "expanded to %s\n", bigbuffer);
-	return (strdup(bigbuffer));
+	return (strdup_ordie(bigbuffer));
 }
 
 int shellCmdCheck(Pop3 pc)
diff --git a/wmbiff/charutil.c b/wmbiff/charutil.c
index cb4a4d1..6b8e853 100644
--- a/wmbiff/charutil.c
+++ b/wmbiff/charutil.c
@@ -1,4 +1,4 @@
-/* $Id: charutil.c,v 1.9 2002/04/27 08:29:59 bluehal Exp $ */
+/* $Id: charutil.c,v 1.10 2002/04/29 02:01:51 bluehal Exp $ */
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -227,3 +227,12 @@ void chomp(char *s)
 	if (l >= 0 && s[l] == '\n')
 		s[l] = '\0';
 }
+
+char *strdup_ordie(const char *c) {
+  char *ret = strdup(c);
+  if(ret == NULL) {
+    fprintf(stderr, "ran out of memory\n");
+    exit(EXIT_FAILURE);
+  }
+  return(ret);
+}
diff --git a/wmbiff/charutil.h b/wmbiff/charutil.h
index 014047e..25f3a38 100644
--- a/wmbiff/charutil.h
+++ b/wmbiff/charutil.h
@@ -1,4 +1,4 @@
-/* $Id: charutil.h,v 1.7 2002/04/15 01:26:21 bluehal Exp $ */
+/* $Id: charutil.h,v 1.8 2002/04/29 02:01:51 bluehal Exp $ */
 /* Author: Mark Hurley  (debian4tux at telocity.com)
  *
  * Character / string manipulation utilities. 
@@ -40,4 +40,7 @@ int compile_and_match_regex(const char *regex, const char *str,
 
 /* acts like perl's function of the same name */
 void chomp(char *s);
+
+/* same as xstrdup, just better named ;) */
+char *strdup_ordie(const char *c);
 #endif

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbiff.git



More information about the Pkg-wmaker-commits mailing list