WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ia64-devel

[Xen-ia64-devel] [PATCH] semget05.c: initialize MAXIDS and getmaxid.

To: ltp-list@xxxxxxxxxxxxxxxxxxxxx
Subject: [Xen-ia64-devel] [PATCH] semget05.c: initialize MAXIDS and getmaxid.
From: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Date: Tue, 19 Dec 2006 21:19:54 +0900
Cc: xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Tue, 19 Dec 2006 04:19:56 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-ia64-devel-request@lists.xensource.com?subject=help>
List-id: Discussion of the ia64 port of Xen <xen-ia64-devel.lists.xensource.com>
List-post: <mailto:xen-ia64-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ia64-devel>, <mailto:xen-ia64-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ia64-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.4.2.1i
semget05.c uses an uninitialized variable, getmaxid, and sets MAXIDS
to garbage value. This patch initialize it properly.
Without this patch, semget05 fails on ia64 as follows

$ ./semget05 
semget05    1  BROK  :  Unexpected signal 11 received.
$ ./semget05 -e
semget05    1  BROK  :  Didn't get ENOSPC in test setup - errno = 17 : File 
exists


thanks.

--- ./semget05.c.orig   2006-12-19 20:57:44.000000000 +0900
+++ ./semget05.c        2006-12-19 21:12:54.000000000 +0900
@@ -72,7 +72,7 @@ int num_sems = 0;             /* count the semaphor
 
 int main(int ac, char **av)
 {
-       int lc,getmaxid;                                /* loop counter */
+       int lc; /* loop counter */
        char *msg;                      /* message returned from parse_opts */
        FILE *fp;
 
@@ -83,21 +83,28 @@ int main(int ac, char **av)
 
        /* Set the MAXIDS for the specific machine by reading the system limit
            for SEMMNI - The maximum number of sempahore sets                  
*/
-       if((fp = fopen("/proc/sys/kernel/sem", "r")) != NULL) 
-         {
-           for(lc= 0; lc < 4; lc++)
-             {
-               if(lc == 3)
-                 {
-                   if(getmaxid > MAXIDS)
-                     MAXIDS=getmaxid;
-                 }
-             }
+       if((fp = fopen("/proc/sys/kernel/sem", "r")) != NULL) {
+               int getmaxid; 
+               for(lc = 0; lc < 4; lc++) {
+                       if (fscanf(fp, "%d", &getmaxid) < 0) {
+                               tst_brkm(TBROK, cleanup,
+                                        "can't parse /proc/sys/kernel/sem %s",
+                                        strerror(errno));
+                       }
+                       if(lc == 3) {
+                               if(getmaxid > MAXIDS)
+                                       MAXIDS=getmaxid;
+                       }
+               }
 
-         }
+       }
        fclose(fp);
 
        sem_id_arr = (int*)malloc(sizeof(int)*MAXIDS);
+       if (sem_id_arr == NULL) {
+               tst_brkm(TBROK, cleanup, "can't allocate memory for sem id %s",
+                        strerror(errno));
+       }
 
        setup();                        /* global setup */      
 


-- 
yamahata

_______________________________________________
Xen-ia64-devel mailing list
Xen-ia64-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ia64-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-ia64-devel] [PATCH] semget05.c: initialize MAXIDS and getmaxid., Isaku Yamahata <=