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

Re: [PATCH 09/14] tools/console: Use const whenever we point to literal strings


  • To: Julien Grall <julien@xxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Tue, 11 May 2021 16:18:55 +0100
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Julien Grall <jgrall@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Tue, 11 May 2021 15:19:08 +0000
  • Ironport-hdrordr: A9a23:kq9hF6ryfWJjgxxiF5W9TNkaV5oheYIsimQD101hICG9Ffbo8v xG/c5rtyMc5wx8ZJhNo7+90cq7MBDhHPxOgLX5VI3KNGOKhILBFvAH0WKI+V3d8kPFmNK0is xbGJSWoueAamRHsQ==
  • Ironport-sdr: S2mVILq5LMBUghPiJ8hIufZTUZkpE2kBGKqhBCdC45bvBgXGCsenxB7CLNhu8PhJgg6UR5m3fj 5UzMFmG68p4JXtzY364+g84f65UeW3VBszPImKXV0uyZbImbgLj8344JfsKoRm538ywycJ010S wtsa4nJCjXfcmEfHbiqbfNjEIWkZ8IagWx3nySYRJLk3DufSBIniK5TMdTM5PpHwcQmctwWgu6 +0u+IIWw8/sLSiq8hPUuC5h6RXUBoU096Fly351wmqXMJx9wPvzbYo0HqXwDXcGAUzSYbsUiPy gys=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon, Apr 05, 2021 at 04:57:08PM +0100, Julien Grall wrote:
> From: Julien Grall <jgrall@xxxxxxxxxx>
> 
> literal strings are not meant to be modified. So we should use const
> char * rather than char * when we want to store a pointer to them.
> 
> Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
> ---
> diff --git a/tools/console/daemon/io.c b/tools/console/daemon/io.c
> index 4af27ffc5d02..6a8a94e31b65 100644
> --- a/tools/console/daemon/io.c
> +++ b/tools/console/daemon/io.c
> @@ -109,9 +109,9 @@ struct console {
>  };
>  
>  struct console_type {
> -     char *xsname;
> -     char *ttyname;
> -     char *log_suffix;
> +     const char *xsname;

I think that const of `xsname` is lost in console_init() in the same
file.
We have:

    static int console_init(.. )
    {
        struct console_type **con_type = (struct console_type **)data;
        char *xsname, *xspath;
        xsname = (char *)(*con_type)->xsname;
    }

So constify "xsname" in console_init() should be part of the patch, I
think.

Thanks,

-- 
Anthony PERARD



 


Rackspace

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