[Xcb] [PATCH 2/2] Clean up some more function-scope-static abuse
Eric Anholt
eric at anholt.net
Wed Jun 28 17:13:53 UTC 2017
Adam Jackson <ajax at redhat.com> writes:
> Signed-off-by: Adam Jackson <ajax at redhat.com>
> ---
> src/xcb_conn.c | 2 +-
> src/xcb_out.c | 4 ++--
> src/xcb_util.c | 4 ++--
> 3 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/src/xcb_conn.c b/src/xcb_conn.c
> index 7d09637..6632d90 100644
> --- a/src/xcb_conn.c
> +++ b/src/xcb_conn.c
> @@ -125,7 +125,7 @@ static int set_fd_flags(const int fd)
>
> static int write_setup(xcb_connection_t *c, xcb_auth_info_t *auth_info)
> {
> - static const char pad[3];
> + const char pad[3];
> xcb_setup_request_t out;
> struct iovec parts[6];
> int count = 0;
Isn't this taking pad from being implicitly zeroed to being stack
garbage? I think you'd need " = { 0 }"
> diff --git a/src/xcb_out.c b/src/xcb_out.c
> index 3601a5f..dc51ae0 100644
> --- a/src/xcb_out.c
> +++ b/src/xcb_out.c
> @@ -70,7 +70,7 @@ static inline void send_request(xcb_connection_t *c, int isvoid, enum workaround
>
> static void send_sync(xcb_connection_t *c)
> {
> - static const union {
> + const union {
> struct {
> uint8_t major;
> uint8_t pad;
Definitely a good one. This union should compile to an immediate
constant in the code.
> @@ -237,7 +237,7 @@ uint64_t xcb_send_request_with_fds64(xcb_connection_t *c, int flags, struct iove
>
> if(!(flags & XCB_REQUEST_RAW))
> {
> - static const char pad[3];
> + const char pad[3];
> unsigned int i;
> uint16_t shortlen = 0;
> size_t longlen = 0;
Same stack concern.
> diff --git a/src/xcb_util.c b/src/xcb_util.c
> index a3357ef..d5605da 100644
> --- a/src/xcb_util.c
> +++ b/src/xcb_util.c
> @@ -227,9 +227,9 @@ static int _xcb_open(const char *host, char *protocol, const int display)
> {
> int fd;
> #ifdef __hpux
> - static const char unix_base[] = "/usr/spool/sockets/X11/";
> + const char unix_base[] = "/usr/spool/sockets/X11/";
> #else
> - static const char unix_base[] = "/tmp/.X11-unix/X";
> + const char unix_base[] = "/tmp/.X11-unix/X";
> #endif
Also good.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 832 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/xcb/attachments/20170628/44273d54/attachment.sig>
More information about the Xcb
mailing list