[nas] [patch] clients cleanup

Stefan Huehner stefan at huehner.org
Sun Aug 20 04:28:38 MDT 2006


Hi,

attached patch cleans up several of the client programs. Mostly adding
const to parameter/variable declarations. Additionally an unsused variable was removed and some prototype in audemo.c were fixed.

While modifying i noticed that at least the fatalError method is
included in every client program as a copy. What about extracting this
and perhaps more common code (i.e. argument parsing) in an extra object
file and linking this into each binary?

Regards,
Stefan

-------------- next part --------------
Index: clients/audio/aupanel/aupanel.c
===================================================================
--- clients/audio/aupanel/aupanel.c	(revision 180)
+++ clients/audio/aupanel/aupanel.c	(working copy)
@@ -149,7 +149,7 @@
 };
 
 static void
-fatalError(char *message, char *arg)
+fatalError(const char *message, const char *arg)
 {
     fprintf(stderr, message, arg);
     fprintf(stderr, "\n");
Index: clients/audio/auwave/auwave.c
===================================================================
--- clients/audio/auwave/auwave.c	(revision 180)
+++ clients/audio/auwave/auwave.c	(working copy)
@@ -154,7 +154,7 @@
 };
 
 static void
-fatalError(char *message, char *arg)
+fatalError(const char *message, const char *arg)
 {
     fprintf(stderr, message, arg);
     fprintf(stderr, "\n");
Index: clients/audio/audial/audial.c
===================================================================
--- clients/audio/audial/audial.c	(revision 180)
+++ clients/audio/audial/audial.c	(working copy)
@@ -161,7 +161,7 @@
 #endif						/* NEEDUSLEEP */
 
 static void
-fatalError(char *message, char *arg1)
+fatalError(const char *message, const char *arg1)
 {
     fprintf(stderr, message, arg1);
     fprintf(stderr, "\n");
Index: clients/audio/auphone/auphone.c
===================================================================
--- clients/audio/auphone/auphone.c	(revision 180)
+++ clients/audio/auphone/auphone.c	(working copy)
@@ -220,7 +220,7 @@
                *busyData;
 
 static int
-fatalError(char *message, char *arg)
+fatalError(const char *message, const char *arg)
 {
     fprintf(stderr, message, arg);
     fprintf(stderr, "\n");
Index: clients/audio/autool/audiotool.c
===================================================================
--- clients/audio/autool/audiotool.c	(revision 180)
+++ clients/audio/autool/audiotool.c	(working copy)
@@ -116,7 +116,7 @@
     NULL
 };
 
-static void     fatalError(char *message, char *arg);
+static void     fatalError(const char *message, const char *arg);
 
 #define Invert(w)							       \
 {									       \
@@ -608,7 +608,7 @@
 }
 
 static void
-fatalError(char *message, char *arg)
+fatalError(const char *message, const char *arg)
 {
     fprintf(stderr, message, arg);
     fprintf(stderr, ".\n");
Index: clients/audio/aurecord/aurecord.c
===================================================================
--- clients/audio/aurecord/aurecord.c	(revision 180)
+++ clients/audio/aurecord/aurecord.c	(working copy)
@@ -96,7 +96,7 @@
 }
 
 static void
-fatalError(char *message, char *arg)
+fatalError(const char *message, const char *arg)
 {
     fprintf(stderr, message, arg);
     fprintf(stderr, "\n");
Index: clients/audio/auconvert/auconvert.c
===================================================================
--- clients/audio/auconvert/auconvert.c	(revision 180)
+++ clients/audio/auconvert/auconvert.c	(working copy)
@@ -65,7 +65,7 @@
 
 static struct
 {
-    char           *string;
+    const char     *string;
     int             value;
 }
                 dataFormats[] =
@@ -80,7 +80,7 @@
 };
 
 static void
-fatalError(char *message, char *arg)
+fatalError(const char *message, const char *arg)
 {
     fprintf(stderr, message, arg);
     fprintf(stderr, "\n");
@@ -112,10 +112,9 @@
 }
 
 static int
-convertDataFormat(char *s)
+convertDataFormat(const char *s)
 {
-    int             f,
-                    i;
+    int             i;
 
     for (i = 0; i < sizeof(dataFormats) / sizeof(dataFormats[0]); i++)
 	if (!strcasecmp(s, dataFormats[i].string))
@@ -125,7 +124,7 @@
 }
 
 static int
-convertFileFormat(char *s)
+convertFileFormat(const char *s)
 {
     int             f;
 
Index: clients/audio/auctl/execute.c
===================================================================
--- clients/audio/auctl/execute.c	(revision 180)
+++ clients/audio/auctl/execute.c	(working copy)
@@ -44,7 +44,7 @@
 int execute_command (AuServer *aud, int argc, char **argv, AuBool *donep)
 {
     static struct {
-	char *name;
+	const char *name;
 	int (*proc) PROTO((AuServer *, int, char **));
 	AuBool done;
     } keytab[] = {
@@ -414,7 +414,7 @@
     AuDeviceAttributes attr;
     AuStatus status;
     static struct {
-	char *name;
+	const char *name;
 	int value;
     } lmtab[] = {
 	{ "none",	AuDeviceLineModeNone },
@@ -481,7 +481,7 @@
 
 static AuInt32 _parse_long (register char *s, register AuBool *ishexp)
 {
-    char *fmt = "%ld";
+    const char *fmt = "%ld";
     AuInt32 val = 0;
 
     if (*s == '0') s++;
Index: clients/audio/audemo/audemo.c
===================================================================
--- clients/audio/audemo/audemo.c	(revision 180)
+++ clients/audio/audemo/audemo.c	(working copy)
@@ -152,9 +152,11 @@
     NULL
 };
 
-static char   **makeFileList();
-static int      getFileNames();
-static void     fatalError(), bucketQueryCB(), bucketRecordDismissCB(),
+static char   **makeFileList(char **fileNames, int nfiles);
+static int      getFileNames(char *dir, char ***fileNames, char *template);
+static void     fatalError(const char *message, const char *arg), 
+                bucketQueryCB(Widget w, XtPointer globalsp, XtPointer call_data),
+                bucketRecordDismissCB(Widget w, XtPointer globalsp, XtPointer call_data),
                 meterCB();
 
 #ifdef XT
@@ -1701,7 +1703,7 @@
 #endif						/* XT */
 
 static void
-fatalError(char *message, char *arg)
+fatalError(const char *message, const char *arg)
 {
     fprintf(stderr, message, arg);
     fprintf(stderr, "\n");
Index: clients/audio/util/playbucket.c
===================================================================
--- clients/audio/util/playbucket.c	(revision 180)
+++ clients/audio/util/playbucket.c	(working copy)
@@ -31,7 +31,7 @@
 #define USAGE "usage: playbucket [-a audioServer] [-v volume] file"
 
 static void
-fatalError(char *message, char *arg)
+fatalError(const char *message, const char *arg)
 {
     fprintf(stderr, message, arg);
     fprintf(stderr, "\n");
Index: clients/audio/util/soundtoh.c
===================================================================
--- clients/audio/util/soundtoh.c	(revision 180)
+++ clients/audio/util/soundtoh.c	(working copy)
@@ -44,7 +44,7 @@
 #include <audio/sound.h>
 
 static void
-fatalError(char *message, char *arg)
+fatalError(const char *message, const char *arg)
 {
     fprintf(stderr, message, arg);
     fprintf(stderr, "\n");
Index: clients/audio/examples/playRaw.c
===================================================================
--- clients/audio/examples/playRaw.c	(revision 180)
+++ clients/audio/examples/playRaw.c	(working copy)
@@ -28,7 +28,7 @@
 }               InfoRec, *InfoPtr;
 
 static void
-fatalError(char *message, char *arg)
+fatalError(const char *message, const char *arg)
 {
     fprintf(stderr, message, arg);
     fprintf(stderr, "\n");
Index: clients/audio/examples/plyBcktAsync.c
===================================================================
--- clients/audio/examples/plyBcktAsync.c	(revision 180)
+++ clients/audio/examples/plyBcktAsync.c	(working copy)
@@ -12,7 +12,7 @@
 #include <audio/soundlib.h>
 
 static void
-fatalError(char *message, char *arg)
+fatalError(const char *message, const char *arg)
 {
     fprintf(stderr, message, arg);
     fprintf(stderr, "\n");
Index: clients/audio/examples/loopBucket.c
===================================================================
--- clients/audio/examples/loopBucket.c	(revision 180)
+++ clients/audio/examples/loopBucket.c	(working copy)
@@ -15,7 +15,7 @@
 #include <audio/soundlib.h>
 
 static void
-fatalError(char *message, char *arg)
+fatalError(const char *message, const char *arg)
 {
     fprintf(stderr, message, arg);
     fprintf(stderr, "\n");
Index: clients/audio/examples/bundle.c
===================================================================
--- clients/audio/examples/bundle.c	(revision 180)
+++ clients/audio/examples/bundle.c	(working copy)
@@ -22,7 +22,7 @@
 #include <audio/soundlib.h>
 
 static void
-fatalError(char *message, char *arg)
+fatalError(const char *message, const char *arg)
 {
     fprintf(stderr, message, arg);
     fprintf(stderr, "\n");
Index: clients/audio/examples/recordBucket.c
===================================================================
--- clients/audio/examples/recordBucket.c	(revision 180)
+++ clients/audio/examples/recordBucket.c	(working copy)
@@ -16,7 +16,7 @@
 #include <audio/soundlib.h>
 
 static void
-fatalError(char *message, char *arg)
+fatalError(const char *message, const char *arg)
 {
     fprintf(stderr, message, arg);
     fprintf(stderr, "\n");
Index: clients/audio/examples/playFromBckt.c
===================================================================
--- clients/audio/examples/playFromBckt.c	(revision 180)
+++ clients/audio/examples/playFromBckt.c	(working copy)
@@ -14,7 +14,7 @@
 #include <audio/soundlib.h>
 
 static void
-fatalError(char *message, char *arg)
+fatalError(const char *message, const char *arg)
 {
     fprintf(stderr, message, arg);
     fprintf(stderr, "\n");


More information about the Nas mailing list