Linux Media Controller development
 help / color / mirror / Atom feed
* [PATCH v4l-utils] ir-ctl: fix UNSET sentinel checks for send carrier
@ 2026-11-27 17:10 Laurent Tramoy
  2026-11-29 11:22 ` Sean Young
  0 siblings, 1 reply; 2+ messages in thread
From: Laurent Tramoy @ 2026-11-27 17:10 UTC (permalink / raw)
  To: linux-media; +Cc: Laurent Tramoy, Sean Young

struct send::carrier uses UNSET (UINT32_MAX) to mean "not specified".
Two checks compare against the wrong sentinel instead:

- read_file_pulse_space() tests "if (f->carrier)" instead of
  "!= UNSET", so it always treats carrier as already set and never
  applies the carrier implied by the scancode's protocol.

- convert_keycode() defaults a missing keymap carrier to 0 instead of
  UNSET, so lirc_send() treats it as an explicit 0 Hz and reprograms
  the hardware carrier to 0, silently breaking transmission.

Compare against UNSET in both places, like the existing "carrier"
keyword branch already does.

Signed-off-by: Laurent Tramoy <laurenttramoy@gmail.com>
---
Hi,

This is the first patch I submit through email. I hit this while
testing IR transmission, happy to adjust anything about the patch
if needed.

Thanks,
Laurent

 utils/ir-ctl/ir-ctl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/utils/ir-ctl/ir-ctl.c b/utils/ir-ctl/ir-ctl.c
index d2ff77e4..63aaa803 100644
--- a/utils/ir-ctl/ir-ctl.c
+++ b/utils/ir-ctl/ir-ctl.c
@@ -296,7 +296,7 @@ static struct send *read_file_pulse_space(struct arguments *args, const char *fn
 			}
 
 			carrier = protocol_carrier(proto);
-			if (f->carrier && f->carrier != carrier)
+			if (f->carrier != UNSET && f->carrier != carrier)
 				fprintf(stderr, _("error: %s:%d: carrier already specified\n"), fname, lineno);
 			else
 				f->carrier = carrier;
@@ -756,7 +756,7 @@ static struct send* convert_keycode(struct keymap *map, const char *keycode)
 				s->len = re->raw_length;
 				memcpy(s->buf, re->raw, s->len * sizeof(int));
 				s->ty = SEND_RAW;
-				s->carrier = keymap_param(map, "carrier", 0);
+				s->carrier = keymap_param(map, "carrier", UNSET);
 				s->next = NULL;
 			}
 		}
@@ -788,7 +788,7 @@ static struct send* convert_keycode(struct keymap *map, const char *keycode)
 				s->len = length;
 				memcpy(s->buf, buf, length * sizeof(int));
 				s->ty = SEND_RAW;
-				s->carrier = keymap_param(map, "carrier", 0);
+				s->carrier = keymap_param(map, "carrier", UNSET);
 				s->next = NULL;
 			} else {
 				fprintf(stderr, _("error: protocol '%s' not supported\n"), proto_str);
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v4l-utils] ir-ctl: fix UNSET sentinel checks for send carrier
  2026-11-27 17:10 [PATCH v4l-utils] ir-ctl: fix UNSET sentinel checks for send carrier Laurent Tramoy
@ 2026-11-29 11:22 ` Sean Young
  0 siblings, 0 replies; 2+ messages in thread
From: Sean Young @ 2026-11-29 11:22 UTC (permalink / raw)
  To: Laurent Tramoy; +Cc: linux-media

On Fri, Nov 27, 2026 at 06:10:50PM +0100, Laurent Tramoy wrote:
> struct send::carrier uses UNSET (UINT32_MAX) to mean "not specified".
> Two checks compare against the wrong sentinel instead:
> 
> - read_file_pulse_space() tests "if (f->carrier)" instead of
>   "!= UNSET", so it always treats carrier as already set and never
>   applies the carrier implied by the scancode's protocol.
> 
> - convert_keycode() defaults a missing keymap carrier to 0 instead of
>   UNSET, so lirc_send() treats it as an explicit 0 Hz and reprograms
>   the hardware carrier to 0, silently breaking transmission.
> 
> Compare against UNSET in both places, like the existing "carrier"
> keyword branch already does.
> 
> Signed-off-by: Laurent Tramoy <laurenttramoy@gmail.com>
> ---
> Hi,
> 
> This is the first patch I submit through email. I hit this while
> testing IR transmission, happy to adjust anything about the patch
> if needed.
> 
> Thanks,
> Laurent

Hi Laurent,

Thank you for your patch. Nice catch - this is an old problem you
solved. Very nice, good stuff!

I've applied it.

Sean

> 
>  utils/ir-ctl/ir-ctl.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/utils/ir-ctl/ir-ctl.c b/utils/ir-ctl/ir-ctl.c
> index d2ff77e4..63aaa803 100644
> --- a/utils/ir-ctl/ir-ctl.c
> +++ b/utils/ir-ctl/ir-ctl.c
> @@ -296,7 +296,7 @@ static struct send *read_file_pulse_space(struct arguments *args, const char *fn
>  			}
>  
>  			carrier = protocol_carrier(proto);
> -			if (f->carrier && f->carrier != carrier)
> +			if (f->carrier != UNSET && f->carrier != carrier)
>  				fprintf(stderr, _("error: %s:%d: carrier already specified\n"), fname, lineno);
>  			else
>  				f->carrier = carrier;
> @@ -756,7 +756,7 @@ static struct send* convert_keycode(struct keymap *map, const char *keycode)
>  				s->len = re->raw_length;
>  				memcpy(s->buf, re->raw, s->len * sizeof(int));
>  				s->ty = SEND_RAW;
> -				s->carrier = keymap_param(map, "carrier", 0);
> +				s->carrier = keymap_param(map, "carrier", UNSET);
>  				s->next = NULL;
>  			}
>  		}
> @@ -788,7 +788,7 @@ static struct send* convert_keycode(struct keymap *map, const char *keycode)
>  				s->len = length;
>  				memcpy(s->buf, buf, length * sizeof(int));
>  				s->ty = SEND_RAW;
> -				s->carrier = keymap_param(map, "carrier", 0);
> +				s->carrier = keymap_param(map, "carrier", UNSET);
>  				s->next = NULL;
>  			} else {
>  				fprintf(stderr, _("error: protocol '%s' not supported\n"), proto_str);
> -- 
> 2.56.1
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-29 11:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-27 17:10 [PATCH v4l-utils] ir-ctl: fix UNSET sentinel checks for send carrier Laurent Tramoy
2026-11-29 11:22 ` Sean Young

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox