Patch for Bug#120386: lilo misconfigured

2002-02-01 Thread Michael Tiedtke

This solves the bug, but could someone please explain me why it
doesn't work in the original code?

Old:
   if ( (res = menuBox(prtbuf, _(Where should the LILO boot loader be installed?), 
opt, 2, 1) == -1 ))
   ...
 The return value of menuBox is not assigned to res.
 It still has the inital value of 0.
 
New:
   res = menuBox(prtbuf, _(Where should the LILO boot loader be installed?), opt, 2, 
1);
   if ( res == -1 ) ...
 The return value of menuBox is assigned to res.

-- 
ShdW [EMAIL PROTECTED]


--- bootconfig.cSat Feb  2 00:09:52 2002
+++ bootconfig.new.cSat Feb  2 00:28:20 2002
@@ -2360,7 +2360,8 @@
 opt[1].string = _(Install LILO in the root partition's boot sector.);
   snprintf(prtbuf, sizeof(prtbuf), _(LILO can be installed either into the 
master boot record (MBR), or into the %s boot block. If installed into the MBR, LILO 
will take control of the boot process. If you choose not to install LILO into the MBR, 
you will have the opportunity later on to install an alternative MBR program (for 
bootstrapping LILO).\n),
   Boot-name);
-  if ( (res = menuBox(prtbuf, _(Where should the LILO boot loader be 
installed?), opt, 2, 1) == -1 ))
+ res = menuBox(prtbuf, _(Where should the LILO boot loader be installed?), 
+opt, 2, 1);
+  if ( res == -1 )
  return 0;
   
   boot = opt[res].tag;



Re: Patch for Bug#120386: lilo misconfigured

2002-02-01 Thread Matt Kraai

On Sat, Feb 02, 2002 at 01:02:22AM +0100, Michael Tiedtke wrote:
 This solves the bug, but could someone please explain me why it
 doesn't work in the original code?

Sure.  The parentheses are wrong.  The equality test has higher
precedence than the assignment, so it assigns the comparison
result to res.  The assignment needs to be parenthesized so that
it happens before the equality test, which is what I committed.

Many thanks for finding this.

Matt



msg15302/pgp0.pgp
Description: PGP signature