Skip to contentSkip to conversation

Address a malloc failure, a typo, and an indent issue in pan.c

PATCH In review Garrett Cooper 2 participants 2 messages Oct 14, 2009 – Oct 15, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Address a malloc failure, a typo, and an indent issue in pan.c

While trying to figure out why entries don't get entered in the exec log, I found the following issue with a malloc call. I also fixed a typo and a whacky indentation item as well.

Index: pan/ltp-pan.c
===================================================================
RCS file: /cvsroot/ltp/ltp/pan/ltp-pan.c,v
retrieving revision 1.3

ltp-pan.c 14 Oct 2009 19:05:59 -0000 renamed from ltp-pan.c 9 Jun 2009 16:14:40 -0000 1.3 +0 -0
diff -u -r1.3 ltp-pan.c
@@ -337,6 +337,11 @@
 
     /* a place to store the pgrps we're watching */
     running = (struct tag_pgrp *)malloc((keep_active + 1) *

sizeof(struct tag_pgrp));
+ if (running == NULL) {
+ fprintf(stderr, "pan(%s): Failed to allocate memory: %s\n", panname,
+ strerror(errno));
+ exit(2);
+ }
memset(running, 0, keep_active * sizeof(struct tag_pgrp));
running[keep_active].pgrp = -1; /* end sentinel */

@@ -397,7 +402,7 @@

     if (outputfilename) {
        if (!freopen(outputfilename, "a+", stdout)) {
            fprintf(stderr,
-                   "pan(%s): Error %s (%d) openning output file '%s'\n",
+                   "pan(%s): Error %s (%d) opening output file '%s'\n",
                    panname, strerror(errno), errno, outputfilename);
            exit(1);
        }
@@ -743,7 +748,7 @@
                                                        w);
                        }

- fflush(logfile);

+                       fflush(logfile);
                }

                if ((failcmdfile != NULL) && (w !=0)) {

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#1 lore raw
Quoted 5 lines · Garrett Cooper

While trying to figure out why entries don't get entered in the exec log, I found the following issue with a malloc call. I also fixed a typo and a whacky indentation item as well.

Garret,

Please apply them directly to CVS:

patching file pan/ltp-pan.c
Hunk #1 succeeded at 337 with fuzz 2.
Hunk #2 FAILED at 402.
Hunk #3 FAILED at 748.
2 out of 3 hunks FAILED -- saving rejects to file pan/ltp-pan.c.rej

Regards--
Subrata

Quoted 42 lines

Index: pan/ltp-pan.c
===================================================================
RCS file: /cvsroot/ltp/ltp/pan/ltp-pan.c,v
retrieving revision 1.3
diff -u -r1.3 ltp-pan.c

ltp-pan.c 14 Oct 2009 19:05:59 -0000 renamed from ltp-pan.c 9 Jun 2009 16:14:40 -0000 1.3 +7 -3
@@ -337,6 +337,11 @@
 
     /* a place to store the pgrps we're watching */
     running = (struct tag_pgrp *)malloc((keep_active + 1) *
 sizeof(struct tag_pgrp));
+    if (running == NULL) {
+        fprintf(stderr, "pan(%s): Failed to allocate memory: %s\n", panname,
+                strerror(errno));
+       exit(2);
+    }
     memset(running, 0, keep_active * sizeof(struct tag_pgrp));
     running[keep_active].pgrp = -1;    /* end sentinel */
@@ -397,7 +402,7 @@
     if (outputfilename) {
        if (!freopen(outputfilename, "a+", stdout)) {
            fprintf(stderr,
-                   "pan(%s): Error %s (%d) openning output file '%s'\n",
+                   "pan(%s): Error %s (%d) opening output file '%s'\n",
                    panname, strerror(errno), errno, outputfilename);
            exit(1);
        }
@@ -743,7 +748,7 @@
                                                        w);
                        }
 
-                               fflush(logfile);
+                       fflush(logfile);
                }
 
                if ((failcmdfile != NULL) && (w !=0)) {
 
------------------------------------------------------------------------------

Come build with us! The BlackBerry(R) Developer Conference in SF, CA

Quoted 8 lines

is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA is the only developer event you need to attend this year. Jumpstart your developing skills, take BlackBerry mobile applications to market and stay ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list