[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-ia64-devel] [PATCH] semget05.c: initialize MAXIDS and getmaxid.
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
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |