[coreboot] seemingly wrong code in src/arch/i386/boot/coreboot_table.c

Myles Watson mylesgw at gmail.com
Sat May 9 21:27:36 CEST 2009



> -----Original Message-----
> From: ron minnich [mailto:rminnich at gmail.com]
> Sent: Friday, May 08, 2009 11:27 PM
> To: Myles Watson
> Cc: coreboot
> Subject: Re: [coreboot] seemingly wrong code in
> src/arch/i386/boot/coreboot_table.c
> 
> Found the problem. 4240 broke builtd_option_tbl due to the addition of
> error checking which got the sense of fwrite wrong.
> fwrite returns 0 on error, non-zero otherwise; the code was written to
> assume non-zero was an error.

Guilty.  Thanks for finding it.

> 
> patch attached inline, qemu is booting again.
> If somebody wants to ack this and commit it that is fine with me.
> 
> Signed-off-by: Ronald G. Minnich <rminnich at gmail.com>

Acked-by: Myles Watson <mylesgw at gmail.com>

Thanks,
Myles
 
> Index: util/options/build_opt_tbl.c
> ===================================================================
> --- util/options/build_opt_tbl.c	(revision 4263)
> +++ util/options/build_opt_tbl.c	(working copy)
> @@ -511,13 +511,13 @@
>          	}
>  		/* write the array values */
>  		for(i=0;i<(ct->size-1);i++) {
> -			if(!(i%10) && !err) err=fwrite("\n\t",1,2,fp);
> +			if(!(i%10) && !err) err=!fwrite("\n\t",1,2,fp);
>  			sprintf(buf,"0x%02x,",cmos_table[i]);
> -			if(!err) err=fwrite(buf,1,5,fp);
> +			if(!err) err=!fwrite(buf,1,5,fp);
>  		}
>  		/* write the end */
>  		sprintf(buf,"0x%02x\n",cmos_table[i]);
> -		if(!err) err=fwrite(buf,1,4,fp);
> +		if(!err) err=!fwrite(buf,1,4,fp);
>          	if(!fwrite("};\n",1,3,fp)) {
>          	        perror("Error - Could not write image file");
>          	        fclose(fp);





More information about the coreboot mailing list