[2/2] Clean up some more function-scope-static abuse

Submitted by Adam Jackson on June 28, 2017, 3:45 p.m.

Details

Message ID 20170628154542.22001-2-ajax@redhat.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in XCB

Not browsing as part of any series.

Commit Message

Adam Jackson June 28, 2017, 3:45 p.m.
Signed-off-by: Adam Jackson <ajax@redhat.com>
---
 src/xcb_conn.c | 2 +-
 src/xcb_out.c  | 4 ++--
 src/xcb_util.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

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;
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;
@@ -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;
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
     const char *base = unix_base;
     size_t filelen;

Comments

Adam Jackson <ajax@redhat.com> writes:

> Signed-off-by: Adam Jackson <ajax@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.