From ebb209a371f4ce9a7df4b0f83e11de39bc1ca628 Mon Sep 17 00:00:00 2001 From: Andrew Wood Date: Tue, 3 Dec 2024 23:48:44 +0000 Subject: [PATCH] Add support for --extra-display to --remote (#123). --- docs/NEWS.md | 1 + src/main/remote.c | 19 ++++++++++++++----- tests/Integrity_-_When_adjusted_remotely.test | 2 ++ ...mory_safety_-_Remote_control_receiver.test | 2 ++ ...Memory_safety_-_Remote_control_sender.test | 2 ++ 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/docs/NEWS.md b/docs/NEWS.md index 515cd6e..66b4162 100644 --- a/docs/NEWS.md +++ b/docs/NEWS.md @@ -1,6 +1,7 @@ ### UNRELEASED * *fix:* add _configure_ script fallback for **--remote** check when cross-compiling (#120) + * *fix:* allow **extra-display** to be changed by **--remote** (#123) ### 1.9.7 - 2 December 2024 diff --git a/src/main/remote.c b/src/main/remote.c index c62df9a..2627943 100644 --- a/src/main/remote.c +++ b/src/main/remote.c @@ -44,11 +44,13 @@ struct remote_msg { bool height_set_manually; /* height was set manually, not detected */ char name[256]; /* flawfinder: ignore */ char format[256]; /* flawfinder: ignore */ + char extra_display[256]; /* flawfinder: ignore */ }; /* - * flawfinder rationale: name and format are always explicitly zeroed and - * bounded to one less than their size so they are always \0 terminated. + * flawfinder rationale: name, format, and extra_display are always + * explicitly zeroed and bounded to one less than their size so they are + * always \0 terminated. */ @@ -207,11 +209,14 @@ int pv_remote_set(opts_t opts, pvstate_t state) if (opts->format != NULL) { strncpy(msgbuf.format, opts->format, sizeof(msgbuf.format) - 1); /* flawfinder: ignore */ } + if (opts->extra_display != NULL) { + strncpy(msgbuf.extra_display, opts->extra_display, sizeof(msgbuf.extra_display) - 1); /* flawfinder: ignore */ + } /* - * flawfinder rationale: both name and format are explicitly bounded - * to 1 less than the size of their buffer and the buffer is \0 - * terminated by memset() earlier. + * flawfinder rationale: name, format, and extra_display are + * explicitly bounded to 1 less than the size of their buffer and + * the buffer is \0 terminated by memset() earlier. */ /* @@ -364,9 +369,11 @@ void pv_remote_check(pvstate_t state) pv_state_format_string_set(state, NULL); pv_state_name_set(state, NULL); + pv_state_extra_display_set(state, NULL); msgbuf.name[sizeof(msgbuf.name) - 1] = '\0'; msgbuf.format[sizeof(msgbuf.format) - 1] = '\0'; + msgbuf.extra_display[sizeof(msgbuf.extra_display) - 1] = '\0'; pv_state_set_format(state, msgbuf.progress, msgbuf.timer, msgbuf.eta, msgbuf.fineta, msgbuf.rate, @@ -389,6 +396,8 @@ void pv_remote_check(pvstate_t state) pv_state_height_set(state, msgbuf.height, msgbuf.height_set_manually); if (msgbuf.format[0] != '\0') pv_state_format_string_set(state, msgbuf.format); + if (msgbuf.extra_display[0] != '\0') + pv_state_extra_display_set(state, msgbuf.extra_display); } diff --git a/tests/Integrity_-_When_adjusted_remotely.test b/tests/Integrity_-_When_adjusted_remotely.test index bc76d9d..cf4947b 100755 --- a/tests/Integrity_-_When_adjusted_remotely.test +++ b/tests/Integrity_-_When_adjusted_remotely.test @@ -33,6 +33,8 @@ for loopCount in 1 2 3; do (usleep 200000 || sleep 1) 2>/dev/null "${testSubject}" -R "$(cat "${workFile4}")" -F "%e" || exit 1 (usleep 200000 || sleep 1) 2>/dev/null + "${testSubject}" -R "$(cat "${workFile4}")" -x "window:%b" || exit 1 + (usleep 200000 || sleep 1) 2>/dev/null "${testSubject}" -R "$(cat "${workFile4}")" -N "." || exit 1 (usleep 200000 || sleep 1) 2>/dev/null echo "${loopCount}" >/dev/null # dummy for shellcheck diff --git a/tests/Memory_safety_-_Remote_control_receiver.test b/tests/Memory_safety_-_Remote_control_receiver.test index 0b9e18c..44932bc 100755 --- a/tests/Memory_safety_-_Remote_control_receiver.test +++ b/tests/Memory_safety_-_Remote_control_receiver.test @@ -34,6 +34,8 @@ for loopCount in 1 2 3; do (usleep 200000 || sleep 1) 2>/dev/null "${testSubject}" -R "$(cat "${workFile3}")" -F "%e" || exit 1 (usleep 200000 || sleep 1) 2>/dev/null + "${testSubject}" -R "$(cat "${workFile4}")" -x "window:%b" || exit 1 + (usleep 200000 || sleep 1) 2>/dev/null "${testSubject}" -R "$(cat "${workFile3}")" -N "." || exit 1 (usleep 200000 || sleep 1) 2>/dev/null echo "${loopCount}" >/dev/null # dummy for shellcheck diff --git a/tests/Memory_safety_-_Remote_control_sender.test b/tests/Memory_safety_-_Remote_control_sender.test index 2ab90eb..446e35f 100755 --- a/tests/Memory_safety_-_Remote_control_sender.test +++ b/tests/Memory_safety_-_Remote_control_sender.test @@ -33,6 +33,8 @@ runWithValgrind -R "$(cat "${workFile3}")" -N "test" 4>&1 || exit 1 (usleep 200000 || sleep 1) 2>/dev/null runWithValgrind -R "$(cat "${workFile3}")" -F "%e" 4>&1 || exit 1 (usleep 200000 || sleep 1) 2>/dev/null +runWithValgrind -R "$(cat "${workFile3}")" -x "window:%b" 4>&1 || exit 1 +(usleep 200000 || sleep 1) 2>/dev/null runWithValgrind -R "$(cat "${workFile3}")" -N "." 4>&1 || exit 1 (usleep 200000 || sleep 1) 2>/dev/null runWithValgrind -R "$(cat "${workFile3}")" -L 10M 4>&1 || exit 1