mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-02 20:08:17 +00:00
import gcc 4.3.2 warning fixes from trunk, with a few changes specific to this branch
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@153710 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -82,7 +82,9 @@ int main(int argc, char *argv[])
|
||||
if (utime(argv[1], NULL)) {
|
||||
/* Recreate the file if it doesn't exist */
|
||||
if ((fd = open(argv[1], O_RDWR | O_TRUNC | O_CREAT, 0777)) > -1) {
|
||||
write(fd, explanation, strlen(explanation));
|
||||
if (write(fd, explanation, strlen(explanation)) < 0) {
|
||||
exit(1);
|
||||
}
|
||||
close(fd);
|
||||
} else {
|
||||
exit(1);
|
||||
|
||||
@@ -151,10 +151,14 @@ static void __attribute__((format (printf, 2, 3))) fdprintf(int fd, char *fmt, .
|
||||
{
|
||||
char stuff[4096];
|
||||
va_list ap;
|
||||
int res;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(stuff, sizeof(stuff), fmt, ap);
|
||||
va_end(ap);
|
||||
write(fd, stuff, strlen(stuff));
|
||||
if ((res = write(fd, stuff, strlen(stuff))) < 0) {
|
||||
fprintf(stderr, "write() failed: %s\n", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
static char *get_header(struct message *m, char *var)
|
||||
@@ -418,13 +422,16 @@ static int __attribute__((format (printf, 2, 3))) manager_action(char *action, c
|
||||
struct ast_mansession *s;
|
||||
char tmp[4096];
|
||||
va_list ap;
|
||||
int res;
|
||||
|
||||
s = &session;
|
||||
fdprintf(s->fd, "Action: %s\r\n", action);
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(tmp, sizeof(tmp), fmt, ap);
|
||||
va_end(ap);
|
||||
write(s->fd, tmp, strlen(tmp));
|
||||
if ((res = write(s->fd, tmp, strlen(tmp))) < 0) {
|
||||
fprintf(stderr, "write() failed: %s\n", strerror(errno));
|
||||
}
|
||||
fdprintf(s->fd, "\r\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
266
utils/frame.c
266
utils/frame.c
@@ -59,14 +59,14 @@ int getremainingfilelength( FILE *anyin, long *result)
|
||||
{
|
||||
long i;
|
||||
|
||||
i = ftell (anyin);
|
||||
i = ftell(anyin);
|
||||
if (i == -1) return FALSE;
|
||||
if (fseek (anyin, 0, SEEK_END) == -1) return FALSE;
|
||||
*result = ftell (anyin);
|
||||
if (fseek(anyin, 0, SEEK_END) == -1) return FALSE;
|
||||
*result = ftell(anyin);
|
||||
if (*result == -1) return FALSE;
|
||||
(*result) -= i;
|
||||
(*result) /= samplewidth;
|
||||
if (fseek (anyin, i, SEEK_SET) == -1) return FALSE;
|
||||
if (fseek(anyin, i, SEEK_SET) == -1) return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -81,31 +81,39 @@ void readpkheader( FILE *anyin)
|
||||
|
||||
for (i = 0; i < 11; i++)
|
||||
{
|
||||
fread( &tempint, 4, 1, anyin);
|
||||
printf( "%d: %d, ", i, tempint);
|
||||
if (!fread( &tempint, 4, 1, anyin)) {
|
||||
return;
|
||||
}
|
||||
printf( "%d: %d, ", i, tempint);
|
||||
}
|
||||
printf( "\n");
|
||||
fread( blood, 1, 8, anyin);
|
||||
if (!fread( blood, 1, 8, anyin)) {
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < 8; i++)
|
||||
printf( "%d ", blood[i]);
|
||||
printf( "%d ", blood[i]);
|
||||
printf( "\n");
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
for (x = 128; x > 0; x /= 2)
|
||||
printf((blood[i] & x) == 0? "0 ":"1 ");
|
||||
printf(i%4==3? "\n":"| ");
|
||||
}
|
||||
printf( "\n");
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
fread( &tempint, 4, 1, anyin);
|
||||
printf( "%d: %d, ", i, tempint);
|
||||
for (x = 128; x > 0; x /= 2)
|
||||
printf((blood[i] & x) == 0? "0 ":"1 ");
|
||||
printf(i%4==3? "\n":"| ");
|
||||
}
|
||||
printf( "\n");
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
fread( &tempushort, 2, 1, anyin);
|
||||
printf( "%d: %d, ", i, tempushort);
|
||||
if (!fread( &tempint, 4, 1, anyin)) {
|
||||
return;
|
||||
}
|
||||
printf( "%d: %d, ", i, tempint);
|
||||
}
|
||||
printf( "\n");
|
||||
for (i = 0; i < 2; i++)
|
||||
{
|
||||
if (!fread( &tempushort, 2, 1, anyin)) {
|
||||
return;
|
||||
}
|
||||
printf( "%d: %d, ", i, tempushort);
|
||||
}
|
||||
printf( "\n");
|
||||
}
|
||||
@@ -125,59 +133,81 @@ void readwavheader( FILE *anyin)
|
||||
iswav = FALSE;
|
||||
|
||||
if (ftell(anyin) == -1) /* If we cannot seek this file */
|
||||
{
|
||||
nowav = TRUE; /* -> Pretend this is no wav-file */
|
||||
chat("File not seekable: not checking for WAV-header.\n");
|
||||
}
|
||||
{
|
||||
nowav = TRUE; /* -> Pretend this is no wav-file */
|
||||
chat("File not seekable: not checking for WAV-header.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Expect four bytes "RIFF" and four bytes filelength */
|
||||
fread (str, 1, 8, anyin); /* 0 */
|
||||
str[4] = '\0';
|
||||
if (strcmp(str, "RIFF") != 0) nowav = TRUE;
|
||||
/* Expect eight bytes "WAVEfmt " */
|
||||
fread (str, 1, 8, anyin); /* 8 */
|
||||
str[8] = '\0';
|
||||
if (strcmp(str, "WAVEfmt ") != 0) nowav = TRUE;
|
||||
/* Expect length of fmt data, which should be 16 */
|
||||
fread (&tempuint, 4, 1, anyin); /* 16 */
|
||||
if (tempuint != 16) nowav = TRUE;
|
||||
/* Expect format tag, which should be 1 for pcm */
|
||||
fread (&tempushort, 2, 1, anyin); /* 20 */
|
||||
if (tempushort != 1)
|
||||
nowav = TRUE;
|
||||
/* Expect number of channels */
|
||||
fread (&cn, 2, 1, anyin); /* 20 */
|
||||
if (cn != 1 && cn != 2) nowav = TRUE;
|
||||
/* Read samplefrequency */
|
||||
fread (&sf, 4, 1, anyin); /* 24 */
|
||||
/* Read bytes per second: Should be samplefreq * channels * 2 */
|
||||
fread (&tempuint, 4, 1, anyin); /* 28 */
|
||||
if (tempuint != sf * cn * 2) nowav = TRUE;
|
||||
/* read bytes per frame: Should be channels * 2 */
|
||||
fread (&tempushort, 2, 1, anyin); /* 32 */
|
||||
if (tempushort != cn * 2) nowav = TRUE;
|
||||
/* Read bits per sample: Should be 16 */
|
||||
fread (&tempushort, 2, 1, anyin); /* 34 */
|
||||
if (tempushort != 16) nowav = TRUE;
|
||||
fread (str, 4, 1, anyin); /* 36 */
|
||||
str[4] = '\0';
|
||||
if (strcmp(str, "data") != 0) nowav = TRUE;
|
||||
fread (&tempuint, 4, 1, anyin); /* 40 */
|
||||
if (nowav)
|
||||
{
|
||||
fseek (anyin, 0, SEEK_SET); /* Back to beginning of file */
|
||||
chat("File has no WAV header.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
samplefrequency = sf;
|
||||
channels = cn;
|
||||
chat ("Read WAV header: %d channels, samplefrequency %d.\n",
|
||||
channels, samplefrequency);
|
||||
iswav = TRUE;
|
||||
}
|
||||
}
|
||||
{
|
||||
/* Expect four bytes "RIFF" and four bytes filelength */
|
||||
if (!fread(str, 1, 8, anyin)) { /* 0 */
|
||||
return;
|
||||
}
|
||||
str[4] = '\0';
|
||||
if (strcmp(str, "RIFF") != 0) nowav = TRUE;
|
||||
/* Expect eight bytes "WAVEfmt " */
|
||||
if (!fread(str, 1, 8, anyin)) { /* 8 */
|
||||
return;
|
||||
}
|
||||
str[8] = '\0';
|
||||
if (strcmp(str, "WAVEfmt ") != 0) nowav = TRUE;
|
||||
/* Expect length of fmt data, which should be 16 */
|
||||
if (!fread(&tempuint, 4, 1, anyin)) { /* 16 */
|
||||
return;
|
||||
}
|
||||
if (tempuint != 16) nowav = TRUE;
|
||||
/* Expect format tag, which should be 1 for pcm */
|
||||
if (!fread(&tempushort, 2, 1, anyin)) { /* 20 */
|
||||
return;
|
||||
}
|
||||
if (tempushort != 1)
|
||||
nowav = TRUE;
|
||||
/* Expect number of channels */
|
||||
if (!fread(&cn, 2, 1, anyin)) { /* 20 */
|
||||
return;
|
||||
}
|
||||
if (cn != 1 && cn != 2) nowav = TRUE;
|
||||
/* Read samplefrequency */
|
||||
if (!fread(&sf, 4, 1, anyin)) { /* 24 */
|
||||
return;
|
||||
}
|
||||
/* Read bytes per second: Should be samplefreq * channels * 2 */
|
||||
if (!fread(&tempuint, 4, 1, anyin)) { /* 28 */
|
||||
return;
|
||||
}
|
||||
if (tempuint != sf * cn * 2) nowav = TRUE;
|
||||
/* read bytes per frame: Should be channels * 2 */
|
||||
if (!fread(&tempushort, 2, 1, anyin)) { /* 32 */
|
||||
return;
|
||||
}
|
||||
if (tempushort != cn * 2) nowav = TRUE;
|
||||
/* Read bits per sample: Should be 16 */
|
||||
if (!fread(&tempushort, 2, 1, anyin)) { /* 34 */
|
||||
return;
|
||||
}
|
||||
if (tempushort != 16) nowav = TRUE;
|
||||
if (!fread(str, 4, 1, anyin)) { /* 36 */
|
||||
return;
|
||||
}
|
||||
str[4] = '\0';
|
||||
if (strcmp(str, "data") != 0) nowav = TRUE;
|
||||
if (!fread(&tempuint, 4, 1, anyin)) { /* 40 */
|
||||
return;
|
||||
}
|
||||
if (nowav)
|
||||
{
|
||||
fseek(anyin, 0, SEEK_SET); /* Back to beginning of file */
|
||||
chat("File has no WAV header.\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
samplefrequency = sf;
|
||||
channels = cn;
|
||||
chat("Read WAV header: %d channels, samplefrequency %d.\n",
|
||||
channels, samplefrequency);
|
||||
iswav = TRUE;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -192,36 +222,62 @@ void makewavheader( void)
|
||||
unsigned short tempushort;
|
||||
|
||||
/* If fseek fails, don't create the header. */
|
||||
if (fseek (out, 0, SEEK_END) != -1)
|
||||
{
|
||||
filelength = ftell (out);
|
||||
chat ("filelength %d, ", filelength);
|
||||
fseek (out, 0, SEEK_SET);
|
||||
fwrite ("RIFF", 1, 4, out); /* 0 */
|
||||
tempuint = filelength - 8; fwrite (&tempuint, 4, 1, out); /* 4 */
|
||||
fwrite ("WAVEfmt ", 1, 8, out); /* 8 */
|
||||
/* length of fmt data 16 bytes */
|
||||
tempuint = 16;
|
||||
fwrite (&tempuint, 4, 1, out); /* 16 */
|
||||
/* Format tag: 1 for pcm */
|
||||
tempushort = 1;
|
||||
fwrite (&tempushort, 2, 1, out); /* 20 */
|
||||
chat ("%d channels\n", channels);
|
||||
fwrite (&channels, 2, 1, out);
|
||||
chat ("samplefrequency %d\n", samplefrequency);
|
||||
fwrite (&samplefrequency, 4, 1, out); /* 24 */
|
||||
/* Bytes per second */
|
||||
tempuint = channels * samplefrequency * 2;
|
||||
fwrite (&tempuint, 4, 1, out); /* 28 */
|
||||
/* Block align */
|
||||
tempushort = 2 * channels;
|
||||
fwrite (&tempushort, 2, 1, out); /* 32 */
|
||||
/* Bits per sample */
|
||||
tempushort = 16;
|
||||
fwrite (&tempushort, 2, 1, out); /* 34 */
|
||||
fwrite ("data", 4, 1, out); /* 36 */
|
||||
tempuint = filelength - 44; fwrite (&tempuint, 4, 1, out); /* 40 */
|
||||
}
|
||||
if (fseek(out, 0, SEEK_END) != -1)
|
||||
{
|
||||
filelength = ftell(out);
|
||||
chat("filelength %d, ", filelength);
|
||||
fseek(out, 0, SEEK_SET);
|
||||
if (!fwrite("RIFF", 1, 4, out)) { /* 0 */
|
||||
return;
|
||||
}
|
||||
tempuint = filelength - 8;
|
||||
if (!fwrite(&tempuint, 4, 1, out)) { /* 4 */
|
||||
return;
|
||||
}
|
||||
if (!fwrite("WAVEfmt ", 1, 8, out)) { /* 8 */
|
||||
return;
|
||||
}
|
||||
/* length of fmt data 16 bytes */
|
||||
tempuint = 16;
|
||||
if (!fwrite(&tempuint, 4, 1, out)) { /* 16 */
|
||||
return;
|
||||
}
|
||||
/* Format tag: 1 for pcm */
|
||||
tempushort = 1;
|
||||
if (!fwrite(&tempushort, 2, 1, out)) { /* 20 */
|
||||
return;
|
||||
}
|
||||
chat("%d channels\n", channels);
|
||||
if (!fwrite(&channels, 2, 1, out)) {
|
||||
return;
|
||||
}
|
||||
chat("samplefrequency %d\n", samplefrequency);
|
||||
if (!fwrite(&samplefrequency, 4, 1, out)) { /* 24 */
|
||||
return;
|
||||
}
|
||||
/* Bytes per second */
|
||||
tempuint = channels * samplefrequency * 2;
|
||||
if (!fwrite(&tempuint, 4, 1, out)) { /* 28 */
|
||||
return;
|
||||
}
|
||||
/* Block align */
|
||||
tempushort = 2 * channels;
|
||||
if (!fwrite(&tempushort, 2, 1, out)) { /* 32 */
|
||||
return;
|
||||
}
|
||||
/* Bits per sample */
|
||||
tempushort = 16;
|
||||
if (!fwrite(&tempushort, 2, 1, out)) { /* 34 */
|
||||
return;
|
||||
}
|
||||
if (!fwrite("data", 4, 1, out)) { /* 36 */
|
||||
return;
|
||||
}
|
||||
tempuint = filelength - 44;
|
||||
if (!fwrite(&tempuint, 4, 1, out)) { /* 40 */
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -870,10 +926,10 @@ int myexit (int value)
|
||||
case 0:
|
||||
if (wavout)
|
||||
makewavheader(); /* Writes a fully informed .WAV header */
|
||||
chat ("Success!\n");
|
||||
chat("Success!\n");
|
||||
break;
|
||||
default:
|
||||
chat ("Failure.\n");
|
||||
chat("Failure.\n");
|
||||
break;
|
||||
}
|
||||
exit (value);
|
||||
@@ -903,7 +959,9 @@ int workloop( FILE *theinfile, FILE *theoutfile,
|
||||
/* Call the routine that does the work */
|
||||
if (!work (buffer, nowlength)) /* On error, stop. */
|
||||
return FALSE;
|
||||
fwrite(buffer, sizeof(short), nowlength, theoutfile);
|
||||
if (!fwrite(buffer, sizeof(short), nowlength, theoutfile)) {
|
||||
return FALSE;
|
||||
}
|
||||
if (ferror( theoutfile) != 0)
|
||||
fatalperror("Error writing to output file");
|
||||
}
|
||||
|
||||
@@ -114,7 +114,9 @@ static int load_config(void)
|
||||
return -1;
|
||||
}
|
||||
while(!feof(f)) {
|
||||
fgets(buf, sizeof(buf), f);
|
||||
if (!fgets(buf, sizeof(buf), f)) {
|
||||
continue;
|
||||
}
|
||||
if (!feof(f)) {
|
||||
lineno++;
|
||||
val = strchr(buf, '#');
|
||||
@@ -682,7 +684,10 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
if (needfork) {
|
||||
#ifndef HAVE_SBIN_LAUNCHD
|
||||
daemon(0,0);
|
||||
if (daemon(0,0) < 0) {
|
||||
fprintf(stderr, "daemon() failed: %s\n", strerror(errno));
|
||||
exit(1);
|
||||
}
|
||||
#else
|
||||
fprintf(stderr, "Mac OS X detected. Use 'launchd -d muted -f' to launch.\n");
|
||||
exit(1);
|
||||
|
||||
@@ -150,10 +150,10 @@ int main( int argcount, char *args[])
|
||||
for (; i < maxk; i++)
|
||||
stereosample[2 * i + 1] = 0;
|
||||
|
||||
fwrite(stereosample, sizeof(*leftsample), 2 * maxk, out);
|
||||
if (ferror( out) != 0)
|
||||
fatalerror("Error writing to file '%s': %s\n",
|
||||
outfilename, strerror(errno));
|
||||
if (!fwrite(stereosample, sizeof(*leftsample), 2 * maxk, out)) {
|
||||
fatalerror("Error writing to file '%s': %s\n",
|
||||
outfilename, strerror(errno));
|
||||
}
|
||||
}
|
||||
/* That was an endless loop. This point is never reached. */
|
||||
}
|
||||
|
||||
@@ -112,8 +112,11 @@ int main(int argc, char *argv[])
|
||||
|
||||
select(2, NULL, &wfds, NULL, &tv);
|
||||
|
||||
if (FD_ISSET(1, &wfds))
|
||||
write(1, buf, res);
|
||||
if (FD_ISSET(1, &wfds)) {
|
||||
if (write(1, buf, res) < 1) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
close(s);
|
||||
|
||||
Reference in New Issue
Block a user