[nas] Compiler warnings
Steve McIntyre
stevem at chiark.greenend.org.uk
Mon Dec 11 16:23:43 MST 2000
I've gone through the build I've just done and picked up several
warning fixes. See the attached diff for details. Highlights:
clients/audio/auconvert/auconvert.c:
clients/audio/auedit/auedit.c:
warnings about mktemp(3) safety. The suggestion is to use mkstemp()
instead; I think I've done the right thing - comments please.
clients/audio/audemo/audemo.c:
Redefinition of strdup, easily fixed for Linux.
lib/audio/Alibint.c:
Losing "const" on sys_errlist[]: simple cast applied.
server/include/os.h:
Redefinition of alloca, easily fixed.
--
Steve McIntyre, Cambridge, UK. stevem at chiark.greenend.org.uk
<a href=http://www.chiark.greenend.org.uk/~stevem/>My home page</a>
"Can't keep my eyes from the circling sky, +------------------
"Tongue-tied & twisted, Just an earth-bound misfit, I..." |Finger for PGP key
-------------- next part --------------
--- nas-1.4.1.orig/clients/audio/auconvert/auconvert.c
+++ nas-1.4.1/clients/audio/auconvert/auconvert.c
@@ -229,7 +229,8 @@
vol,
rawFormat = -1,
rawTracks,
- outputDataFormat;
+ outputDataFormat,
+ fd = 0;
AuUint32 rate = 0,
numBytes;
Sound in,
@@ -354,12 +355,12 @@
fatalError("Malloc error");
sprintf(outName, "%sXXXXXX", inputFile);
- outName = mktemp(outName);
+ fd = mkstemp(outName);
}
else
outName = outputFile;
- if (!SoundOpenFileForWriting(outName, out))
+ if ((-1 == fd) || (!SoundOpenFileForWriting(outName, out))
fatalError("Can't open output file %s", outName);
numBytes = numBytes / sizeof(short) * SoundBytesPerSample(out);
@@ -376,8 +377,11 @@
fatalError("Error closing output file");
if (!outputFile)
+ {
+ close(fd);
if (rename(outName, inputFile))
fatalError("Error renaming temp file");
-
+ }
+
exit(0);
}
--- nas-1.4.1.orig/clients/audio/audemo/audemo.c
+++ nas-1.4.1/clients/audio/audemo/audemo.c
@@ -259,8 +259,7 @@
static int ElementCount,
MonitorCount;
-#ifndef sun /* who else doesn't have
- * this? */
+#if !defined(sun) && !defined(linux) /* who else doesn't have this? */
#define strdup ncd_strdup /* To avoid conflicting with
* headers on hosts that *do*
* have strdup... */
--- nas-1.4.1.orig/clients/audio/auedit/auedit.c
+++ nas-1.4.1/clients/audio/auedit/auedit.c
@@ -2230,6 +2230,7 @@
short *p;
String st;
int n,
+ fd=0,
fileFormat,
dataFormat,
status;
@@ -2254,9 +2255,9 @@
}
sprintf(tmpName, "%sXXXXXX", name);
- tmpName = mktemp(tmpName);
+ fd = mkstemp(tmpName);
- if (!SoundOpenFileForWriting(tmpName, s))
+ if (-1 == fd || !SoundOpenFileForWriting(tmpName, s))
{
free(tmpName);
SoundDestroy(s);
@@ -2274,6 +2275,7 @@
if (status || SoundCloseFile(s))
{
+ close(fd);
free(tmpName);
ERRORf("Error writing output file");
}
--- nas-1.4.1.orig/lib/audio/Alibint.c
+++ nas-1.4.1/lib/audio/Alibint.c
@@ -1340,7 +1340,7 @@
extern char *sys_errlist[];
#endif
extern int sys_nerr;
- char *s = ((n >= 0 && n < sys_nerr) ? sys_errlist[n] : "unknown error");
+ char *s = (char *)((n >= 0 && n < sys_nerr) ? sys_errlist[n] : "unknown error");
return (s ? s : "no such error");
}
--- nas-1.4.1.orig/server/include/os.h
+++ nas-1.4.1/server/include/os.h
@@ -72,7 +72,7 @@
#endif /* defined(__HIGHC__) */
-#ifdef __GNUC__
+#if defined(__GNUC__) && !defined(alloca)
#define alloca __builtin_alloca
#endif
More information about the Nas
mailing list