Hi,

Recently Gentoo ~ARCH pushed out gcc-4.3.3 and one of the things it enabled
was -D_FORTIFY_SOURCE=2.
Unfortunately within the osspartysh.c there is a couple of function calls
that causes gcc to catch a violation


make[2]: Entering directory
`/var/tmp/portage/media-sound/oss-devel-9999/work/build/cmd/osspartysh'
cc -ffreestanding -c -O -fno-common -fno-stack-protector -Wall -Werror
-DOSS_LITTLE_ENDIAN  -I../../include -I../../kernel/framework/include
-I../../kernel/OS/Linux -I../../kernel/nonfree/include -I../..
-I/usr/src/uts/x86_64 osspartysh.c -o ./osspartysh.o
cc1: warnings being treated as errors
osspartysh.c: In function 'shell_loop':
osspartysh.c:215: error: ignoring return value of 'write', declared
with attribute warn_unused_result
osspartysh.c: In function 'pty_session':
osspartysh.c:338: error: ignoring return value of 'mkstemp', declared
with attribute warn_unused_result
make[2]: *** [osspartysh.o] Error 1
make[2]: Leaving directory
`/var/tmp/portage/media-sound/oss-devel-9999/work/build/cmd/osspartysh'
make[1]: *** [subdirs] Error 1
make[1]: Leaving directory
`/var/tmp/portage/media-sound/oss-devel-9999/work/build/cmd'
make: *** [subdirs] Error 1

Likewise in a ossphone.c similar errors (warnings on non-fortified)
for read/writes


All I did was declare the return of the lines in questions to a tmp
variable to keep gcc happy - I don't know if this is what you would
want todo in practice.
Since more and more distro's are using -D_FORTIFY_SOURCE=2 by default
its probably good to nip this is the bud early on

JonRB
diff -u -r mercurial.opensound.com-orig/cmd/osspartysh/osspartysh.c mercurial.opensound.com/cmd/osspartysh/osspartysh.c
--- mercurial.opensound.com-orig/cmd/osspartysh/osspartysh.c	2009-01-31 01:07:44.000000000 +0000
+++ mercurial.opensound.com/cmd/osspartysh/osspartysh.c	2009-01-31 01:08:13.000000000 +0000
@@ -174,7 +174,7 @@
 shell_loop(int connfd, int infd, int outfd)
 {
 	fd_set readfds;
-	int n, l;
+	int n, l, tmp;
 	char buf[512];
 
 	while (1)
@@ -212,7 +212,7 @@
 				return;
 			}
 
-			write(1, buf, l); // Echo to the local terminal
+			tmp = write(1, buf, l); // Echo to the local terminal
 		}
 
 		if (FD_ISSET(connfd, &readfds))
@@ -332,10 +332,10 @@
 pty_session(int connfd)
 {
 	pid_t pid;
-	int ptyfd;
+	int ptyfd, tmp;
 	FILE *f;
 	char tmpl[32]="/tmp/osspartyshXXXXXX";
-	mkstemp(tmpl);
+	tmp = mkstemp(tmpl);
 
 	chmod(tmpl, 0700);
 
diff -u -r mercurial.opensound.com-orig/cmd/ossphone/ossphone.c mercurial.opensound.com/cmd/ossphone/ossphone.c
--- mercurial.opensound.com-orig/cmd/ossphone/ossphone.c	2009-01-31 01:07:44.000000000 +0000
+++ mercurial.opensound.com/cmd/ossphone/ossphone.c	2009-01-31 01:08:00.000000000 +0000
@@ -116,14 +116,14 @@
   
   uint16_t buf[4096];
 
-  int retries = 0;
+  int retries = 0, tmp;
   const int max_retries = 10;
 
   printf("Waiting for dial tone...\n");
   while (dc_level < min_dc_level)
        {
-         read(in_fd, buf, sizeof(buf));
-         write(snd_fd, buf, sizeof(buf));
+         tmp = read(in_fd, buf, sizeof(buf));
+         tmp = write(snd_fd, buf, sizeof(buf));
 
          dc_level = evaluate_dc_level(buf, sizeof(buf)/sizeof(uint16_t));
 
@@ -148,6 +148,8 @@
   uint16_t *silence = (uint16_t *)malloc(silence_size);
   uint16_t *buf = (uint16_t *)malloc(silence_size);
 
+  int tmp;
+
   dtmf_fill_silence (silence, silence_len);
 
   printf("Dialing... ");
@@ -160,13 +162,13 @@
              printf("%c", *phone_number);
              fflush(stdout);
 
-             write (out_fd, digit, digit_size);
-             read (in_fd, digit, digit_size);
-             write (snd_fd, digit, digit_size);
-
-             write (out_fd, silence, silence_size);
-             read (in_fd, buf, silence_size);
-             write (snd_fd, buf, silence_size);
+             tmp = write (out_fd, digit, digit_size);
+             tmp = read (in_fd, digit, digit_size);
+             tmp = write (snd_fd, digit, digit_size);
+
+             tmp = write (out_fd, silence, silence_size);
+             tmp = read (in_fd, buf, silence_size);
+             tmp = write (snd_fd, buf, silence_size);
            }
          phone_number++;
        }
@@ -341,7 +343,7 @@
   {
     uint16_t buf[128];
     fd_set rfds;
-    int retval;
+    int retval, tmp;
 
     int max_fd = in_fd;
     if (snd_fd > max_fd)
@@ -362,13 +364,13 @@
              {
                if (FD_ISSET(in_fd, &rfds))
                  {
-                   read(in_fd, buf, sizeof(buf));
-                   write(snd_fd, buf, sizeof(buf));
+                   tmp = read(in_fd, buf, sizeof(buf));
+                   tmp = write(snd_fd, buf, sizeof(buf));
                  }
                if (FD_ISSET(snd_fd, &rfds))
                  {
-                   read(snd_fd, buf, sizeof(buf));
-                   write(out_fd, buf, sizeof(buf));
+                   tmp = read(snd_fd, buf, sizeof(buf));
+                   tmp = write(out_fd, buf, sizeof(buf));
                  }
              }
          }
_______________________________________________
oss-devel mailing list
oss-devel@mailman.opensound.com
http://mailman.opensound.com/mailman/listinfo/oss-devel

Reply via email to