PERFORCE change 123578 for review

Garrett Cooper yanegomi at gmail.com
Mon Jul 16 03:17:09 UTC 2007


Garrett Cooper wrote:
> http://perforce.freebsd.org/chv.cgi?CH=123578
>
> Change 123578 by gcooper at optimus-revised_pkgtools on 2007/07/16 03:02:24
>
> 	2 mistakes.
> 		-Make sure that fd isn't NULL, instead of NULL.
> 		-It's not O_RDONLY, it's "r" for fopen. Funny why gcc didn't pick up that error...
>
> Affected files ...
>
> .. //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/file.c#7 edit
>
> Differences ...
>
> ==== //depot/projects/soc2007/revised_fbsd_pkgtools/usr/src/usr.sbin/pkg_install/lib/file.c#7 (text+ko) ====
>
> @@ -195,9 +195,9 @@
>  {
>      char *contents;
>  
> -    FILE *fd = fopen(fname, O_RDONLY);
> +    FILE *fd = fopen(fname, "r");
>  
> -    if (fd != NULL) {
> +    if (fd == NULL) {
>  	cleanup(0);
>  	errx(2, "%s: unable to open '%s' for reading", __func__, fname);
>      }
>
>   
Of course.. O_RDONLY was being interpreted as NULL most likely since its 
decimal value's 0..
-Garrett


More information about the p4-projects mailing list