[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH for-4.6 10/13] xl: valid fd can be 0 in main_loadpolicy



On Thu, 2015-07-23 at 08:59 +0100, Wei Liu wrote:
> Also fixed some style problems while I was there.

polFd is initialised to 0, I think it should be initialised to -1 as
well as your change here, otherwise you can unexpectedly close stdin on
some error paths.

(also: studly caps, yuk, not your fault I expect)

> 
> Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
> ---
>  tools/libxl/xl_cmdimpl.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c
> index 7e279cd..3717568 100644
> --- a/tools/libxl/xl_cmdimpl.c
> +++ b/tools/libxl/xl_cmdimpl.c
> @@ -7856,7 +7856,7 @@ int main_loadpolicy(int argc, char **argv)
>  
>      polFName = argv[optind];
>      polFd = open(polFName, O_RDONLY);
> -    if ( polFd < 0 ) {
> +    if (polFd < 0) {
>          fprintf(stderr, "Error occurred opening policy file '%s': 
> %s\n",
>                  polFName, strerror(errno));
>          ret = -1;
> @@ -7864,7 +7864,7 @@ int main_loadpolicy(int argc, char **argv)
>      }
>  
>      ret = stat(polFName, &info);
> -    if ( ret < 0 ) {
> +    if (ret < 0) {
>          fprintf(stderr, "Error occurred retrieving information 
> about"
>                  "policy file '%s': %s\n", polFName, 
> strerror(errno));
>          goto done;
> @@ -7896,7 +7896,7 @@ int main_loadpolicy(int argc, char **argv)
>  
>  done:
>      free(polMemCp);
> -    if ( polFd > 0 )
> +    if (polFd >= 0)
>          close(polFd);
>  
>      return ret;

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.