This diff does two things:
1. Remove the unused secondary (wp == NULL) check.
2. Moves the (bp == NULL) check to a more useful place.
I think point 1 is kind of obvious. Currently the logic can never
reach there.
For point 2, bp is used in new_window() so a NULL check would be
better before new_window() than after it. And there is nowhere in
new_window() that can set the value of bp to NULL. So I don't see the
point in having a check afterwards.
Comments/ok?
-lum
Index: main.c
===================================================================
RCS file: /cvs/src/usr.bin/mg/main.c,v
retrieving revision 1.62
diff -u -p -r1.62 main.c
--- main.c 28 Nov 2011 04:41:39 -0000 1.62
+++ main.c 24 Jan 2012 10:53:05 -0000
@@ -204,11 +204,13 @@ edinit(PF init_fcn)
bheadp = NULL;
bp = bfind("*init*", TRUE); /* Text buffer. */
+ if (bp == NULL) /* bp cannot be NULL here */
+ panic("edinit");
+
wp = new_window(bp);
if (wp == NULL)
panic("Out of memory");
- if (bp == NULL || wp == NULL)
- panic("edinit");
+
curbp = bp; /* Current ones. */
wheadp = wp;
curwp = wp;