Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 Jul 2007 20:17:06 -0700
From:      Garrett Cooper <yanegomi@gmail.com>
To:        Garrett Cooper <gcooper@FreeBSD.org>
Cc:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   Re: PERFORCE change 123578 for review
Message-ID:  <469AE332.5060007@gmail.com>
In-Reply-To: <200707160303.l6G33PoX000247@repoman.freebsd.org>
References:  <200707160303.l6G33PoX000247@repoman.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Garrett Cooper wrote:
> http://perforce.freebsd.org/chv.cgi?CH=123578
>
> Change 123578 by gcooper@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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?469AE332.5060007>