Hi

Thanks but I don't think this fix is correct.

It was done this way so it won't crash if the pane is freed between the
notify being queued (with cmdq_append) and notify_callback fired.

You could just change the ?: into a proper "if"?



On Mon, 31 Jan 2022, 07:09 'Siva Mahadevan' via tmux-users, <
[email protected]> wrote:

> Fix the warning in the condition `(wp != NULL ? wp->id : -1)` where `id`
> is a u_int but -1 is an int.
> ---
>  control-notify.c | 7 +++++--
>  notify.c         | 6 +++---
>  tmux.h           | 2 +-
>  3 files changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/control-notify.c b/control-notify.c
> index 6ff0e436..865c8f80 100644
> --- a/control-notify.c
> +++ b/control-notify.c
> @@ -27,15 +27,18 @@
>         ((c) != NULL && ((c)->flags & CLIENT_CONTROL))
>
>  void
> -control_notify_pane_mode_changed(int pane)
> +control_notify_pane_mode_changed(struct window_pane *pane)
>  {
>         struct client   *c;
>
> +       if (pane == NULL)
> +               return;
> +
>         TAILQ_FOREACH(c, &clients, entry) {
>                 if (!CONTROL_SHOULD_NOTIFY_CLIENT(c))
>                         continue;
>
> -               control_write(c, "%%pane-mode-changed %%%u", pane);
> +               control_write(c, "%%pane-mode-changed %%%u", pane->id);
>         }
>  }
>
> diff --git a/notify.c b/notify.c
> index 9c55d0b8..d45e4c73 100644
> --- a/notify.c
> +++ b/notify.c
> @@ -31,7 +31,7 @@ struct notify_entry {
>         struct client           *client;
>         struct session          *session;
>         struct window           *window;
> -       int                      pane;
> +       struct window_pane      *pane;
>  };
>
>  static void
> @@ -153,7 +153,7 @@ notify_add(const char *name, struct cmd_find_state
> *fs, struct client *c,
>         ne->client = c;
>         ne->session = s;
>         ne->window = w;
> -       ne->pane = (wp != NULL ? wp->id : -1);
> +       ne->pane = wp;
>
>         ne->formats = format_create(NULL, NULL, 0, FORMAT_NOJOBS);
>         format_add(ne->formats, "hook", "%s", name);
> @@ -199,7 +199,7 @@ notify_hook(struct cmdq_item *item, const char *name)
>         ne.client = cmdq_get_client(item);
>         ne.session = target->s;
>         ne.window = target->w;
> -       ne.pane = (target->wp != NULL ? target->wp->id : -1);
> +       ne.pane = target->wp;
>
>         ne.formats = format_create(NULL, NULL, 0, FORMAT_NOJOBS);
>         format_add(ne.formats, "hook", "%s", name);
> diff --git a/tmux.h b/tmux.h
> index 8a6dec18..3cbcc24f 100644
> --- a/tmux.h
> +++ b/tmux.h
> @@ -3042,7 +3042,7 @@ void      control_remove_sub(struct client *, const
> char *);
>  /* control-notify.c */
>  void   control_notify_input(struct client *, struct window_pane *,
>             const u_char *, size_t);
> -void   control_notify_pane_mode_changed(int);
> +void   control_notify_pane_mode_changed(struct window_pane *);
>  void   control_notify_window_layout_changed(struct window *);
>  void   control_notify_window_pane_changed(struct window *);
>  void   control_notify_window_unlinked(struct session *, struct window *);
> --
> 2.35.1
>
> --
> You received this message because you are subscribed to the Google Groups
> "tmux-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/tmux-users/20220131022339.2800-1-me%40svmhdvn.name
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"tmux-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/tmux-users/CAEdLfcEG31Qyz%3D7S-fnNZpOEAn_M4Gdw-THS4noSy-4tDNEOjw%40mail.gmail.com.

Reply via email to