consistency: rename qr_frame_guides_t to qr_guide_type_t
What changed, and why it matters
This commit is a simple code cleanup: it renames an internal type and its values to make naming more consistent, and removes a few unnecessary local variables. There is no change to how the camera or QR scanning works, and no security impact.
No action needed; this is a non-functional refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch renames qr_frame_guides_t to qr_guide_type_t and the enum values from QR_GUIDES_NONE/QR_GUIDES_SHOW to QR_GUIDE_HIDE/QR_GUIDE_SHOW. It updates all call sites and removes intermediate local variables that only passed the constant to jade_camera_scan_qr(). The logic, assertions, and UI behavior remain identical.
Changed components
main/ui.hmain/ui/camera.cmain/camera.cmain/camera.hmain/qrscan.cmain/qrscan.hlibjade/libjade.cmain/bcur.cmain/main.cmain/process/debug_scan_qr.cmain/process/mnemonic.cmain/process/register_otp.cmain/smoketest.cInspect captured patch +29 / −34
diff --git a/libjade/libjade.c b/libjade/libjade.c
index c674cbf..b6d42c4 100644
--- a/libjade/libjade.c
+++ b/libjade/libjade.c
@@ -158,7 +158,7 @@ void camera_set_debug_image(const uint8_t* data, const size_t len)
}
void jade_camera_process_images(camera_process_fn_t fn, void* ctx, const bool show_ui, const char* text_label,
- const bool show_click_button, const qr_frame_guides_t qr_frame_guides, const char* help_url,
+ const bool show_click_button, const qr_guide_type_t qr_guide_type, const char* help_url,
progress_bar_t* progress_bar)
{
if (debug_image_data) {
diff --git a/main/bcur.c b/main/bcur.c
index 4eb8d83..2235be4 100644
--- a/main/bcur.c
+++ b/main/bcur.c
@@ -670,8 +670,7 @@ bool bcur_scan_qr(
qr_data_t qr_data = { .len = 0, .is_valid = collect_any_bcur, .ctx = urdecoder, .progress_bar = &progress_bar };
// Scan qr code using the bcur decoder to collate multiple frames if required
- const qr_frame_guides_t qr_frame_guides = QR_GUIDES_SHOW;
- if (!jade_camera_scan_qr(&qr_data, prompt_text, qr_frame_guides, help_url)) {
+ if (!jade_camera_scan_qr(&qr_data, prompt_text, QR_GUIDE_SHOW, help_url)) {
// User exited without completing scanning
urfree_placement_decoder(urdecoder);
return false;
diff --git a/main/camera.c b/main/camera.c
index d3b5d93..74a45fb 100644
--- a/main/camera.c
+++ b/main/camera.c
@@ -175,7 +175,7 @@ static void copy_camera_image_180(
void await_qr_help_activity(const char* url);
gui_activity_t* make_camera_activity(gui_view_node_t** image_node, gui_view_node_t** label_node, bool show_click_btn,
- qr_frame_guides_t qr_frame_guides, progress_bar_t* progress_bar, bool show_help_btn);
+ qr_guide_type_t qr_guide_type, progress_bar_t* progress_bar, bool show_help_btn);
// Camera-task config data
typedef struct {
@@ -193,8 +193,8 @@ typedef struct {
bool show_click_button;
// Whether to show guides for ideal QR code placement
- // NOTE: qr_frame_guides is only valid if 'show_ui' is set.
- qr_frame_guides_t qr_frame_guides;
+ // NOTE: qr_guide_type is only valid if 'show_ui' is set.
+ qr_guide_type_t qr_guide_type;
// Any progress bar (feedback for multi-frame scanning)
// NOTE: progress_bar is optional, and only valid if 'show_ui' is set.
@@ -366,7 +366,7 @@ static void jade_camera_task(void* data)
JADE_ASSERT(!camera_config->text_label);
JADE_ASSERT(!camera_config->show_click_button);
JADE_ASSERT(!camera_config->help_url);
- JADE_ASSERT(camera_config->qr_frame_guides == QR_GUIDES_NONE);
+ JADE_ASSERT(camera_config->qr_guide_type == QR_GUIDE_HIDE);
JADE_ASSERT(!camera_config->progress_bar);
}
@@ -376,7 +376,7 @@ static void jade_camera_task(void* data)
// camera_config->show_click_button indicates we want the user to select the images presented
// (otherwise all images are presented) to the given callback function ctx.fn_process()
// camera_config->help_url is optional - if preset a '?' (and help screen) are shown
- // camera_config->qr_frame_guides is optional - if set guides for ideal QR placement are shown
+ // camera_config->qr_guide_type is optional - if set guides for ideal QR placement are shown
// camera_config->progress_bar is optional, and is for providing feedback for multi-frame scanning
// NOTE: not valid to have a label, click button, help_url, qr frame or progress bar if no ui shown
// NOTE: atm show_click_btn and help_url are mutually exclusive
@@ -388,7 +388,7 @@ static void jade_camera_task(void* data)
if (camera_config->show_ui) {
// Create camera screen
act = make_camera_activity(&image_node, &label_node, camera_config->show_click_button,
- camera_config->qr_frame_guides, camera_config->progress_bar, camera_config->help_url);
+ camera_config->qr_guide_type, camera_config->progress_bar, camera_config->help_url);
gui_set_current_activity(act);
}
@@ -502,7 +502,7 @@ static void jade_camera_task(void* data)
}
void jade_camera_process_images(camera_process_fn_t fn, void* ctx, const bool show_ui, const char* text_label,
- const bool show_click_button, const qr_frame_guides_t qr_frame_guides, const char* help_url,
+ const bool show_click_button, const qr_guide_type_t qr_guide_type, const char* help_url,
progress_bar_t* progress_bar)
{
JADE_ASSERT(fn);
@@ -521,7 +521,7 @@ void jade_camera_process_images(camera_process_fn_t fn, void* ctx, const bool sh
JADE_ASSERT(!text_label);
JADE_ASSERT(!show_click_button);
JADE_ASSERT(!help_url);
- JADE_ASSERT(qr_frame_guides == QR_GUIDES_NONE);
+ JADE_ASSERT(qr_guide_type == QR_GUIDE_HIDE);
JADE_ASSERT(!progress_bar);
}
@@ -530,7 +530,7 @@ void jade_camera_process_images(camera_process_fn_t fn, void* ctx, const bool sh
.text_label = text_label,
.show_click_button = show_click_button,
.help_url = help_url,
- .qr_frame_guides = qr_frame_guides,
+ .qr_guide_type = qr_guide_type,
.progress_bar = progress_bar,
.fn_process = fn,
.ctx = ctx };
@@ -565,7 +565,7 @@ void jade_camera_process_images(camera_process_fn_t fn, void* ctx, const bool sh
#else // CONFIG_HAS_CAMERA
void jade_camera_process_images(camera_process_fn_t fn, void* ctx, const bool show_ui, const char* text_label,
- const bool show_click_button, const qr_frame_guides_t qr_frame_guides, const char* help_url,
+ const bool show_click_button, const qr_guide_type_t qr_guide_type, const char* help_url,
progress_bar_t* progress_bar)
{
JADE_LOGW("No camera supported for this device");
diff --git a/main/camera.h b/main/camera.h
index a369cf2..19c91d2 100644
--- a/main/camera.h
+++ b/main/camera.h
@@ -33,11 +33,11 @@ void camera_set_debug_image(const uint8_t* data, size_t len);
// If a 'text_label' is passed it is shown with the camera image.
// If 'show_click_button'' is passed, the user must click to process an image, otherwise
// every frame captured is passed to the processing function.
-// 'qr_frame_guides' can be passed to indicate the ideal QR code placement
+// 'qr_guide_type' can be passed to show the QR guide UI
// 'help_url' can be passed to link to a help url/resource.
// 'progress_bar' can be passed to give feedback on multi-frame scanning.
// NOTE: atm show_click_btn and help_url are mutually exclusive
void jade_camera_process_images(camera_process_fn_t fn, void* ctx, bool show_ui, const char* text_label,
- bool show_click_button, qr_frame_guides_t qr_frame_guides, const char* help_url, progress_bar_t* progress_bar);
+ bool show_click_button, qr_guide_type_t qr_guide_type, const char* help_url, progress_bar_t* progress_bar);
#endif /* CAMERA_H_ */
diff --git a/main/main.c b/main/main.c
index fd2a76c..6ab5af4 100644
--- a/main/main.c
+++ b/main/main.c
@@ -232,7 +232,7 @@ static void boot_process(void)
#if defined(CONFIG_HAS_CAMERA) && !defined(CONFIG_ETH_USE_OPENETH)
size_t counter = 0;
- jade_camera_process_images(&rnd_camera_feed, &counter, false, false, NULL, QR_GUIDES_NONE, NULL, NULL);
+ jade_camera_process_images(&rnd_camera_feed, &counter, false, false, NULL, QR_GUIDE_HIDE, NULL, NULL);
#endif
jade_wally_init();
diff --git a/main/process/debug_scan_qr.c b/main/process/debug_scan_qr.c
index aac62a4..ad2187b 100644
--- a/main/process/debug_scan_qr.c
+++ b/main/process/debug_scan_qr.c
@@ -123,9 +123,9 @@ void debug_capture_image_data_process(void* process_ptr)
const bool show_camera_ui = true;
const bool show_click_button = true;
image_capture_into_t info = { .process = process, .check_qr = ret && check_qr };
- const qr_frame_guides_t qr_frame_guides = check_qr ? QR_GUIDES_SHOW : QR_GUIDES_NONE;
+ const qr_guide_type_t qr_guide_type = check_qr ? QR_GUIDE_SHOW : QR_GUIDE_HIDE;
jade_camera_process_images(
- return_image_data, &info, show_camera_ui, NULL, show_click_button, qr_frame_guides, NULL, NULL);
+ return_image_data, &info, show_camera_ui, NULL, show_click_button, qr_guide_type, NULL, NULL);
// Send a 'user cancelled' error reply if the callback was not invoked
// (We can detect as the callback frees the 'current message' on successful completion)
@@ -172,8 +172,7 @@ void debug_scan_qr_process(void* process_ptr)
// Attempt to scan a qr
qr_data_t qr_data = { .len = 0 };
- const qr_frame_guides_t qr_frame_guides = QR_GUIDES_SHOW;
- if (!jade_camera_scan_qr(&qr_data, "Test Scan Image", qr_frame_guides, NULL)) {
+ if (!jade_camera_scan_qr(&qr_data, "Test Scan Image", QR_GUIDE_SHOW, NULL)) {
JADE_LOGW("QR scanning failed!");
}
diff --git a/main/process/mnemonic.c b/main/process/mnemonic.c
index e140d3a..7c72972 100644
--- a/main/process/mnemonic.c
+++ b/main/process/mnemonic.c
@@ -207,8 +207,7 @@ static bool mnemonic_export_qr(const char* mnemonic, bool* export_qr_verified)
// Verify QR by scanning it back
qr_data_t qr_data = { .len = 0 };
- const qr_frame_guides_t qr_frame_guides = QR_GUIDES_SHOW;
- jade_camera_scan_qr(&qr_data, "Scan QR to verify", qr_frame_guides, "blkstrm.com/seedqr");
+ jade_camera_scan_qr(&qr_data, "Scan QR to verify", QR_GUIDE_SHOW, "blkstrm.com/seedqr");
if (qr_data.len == entropy_len && !memcmp(qr_data.data, entropy, entropy_len)) {
// QR Code scanned, and it matched expected entropy
const char* message[] = { "QR Code Verified" };
@@ -1161,9 +1160,8 @@ static bool mnemonic_qr(char* mnemonic, const size_t mnemonic_len)
mnemonic[0] = '\0';
// We return 'true' if we scanned any string data at all
- const qr_frame_guides_t qr_frame_guides = QR_GUIDES_SHOW;
const bool qr_scanned
- = jade_camera_scan_qr(&qr_data, NULL, qr_frame_guides, "blkstrm.com/scanwallet") && qr_data.len > 0;
+ = jade_camera_scan_qr(&qr_data, NULL, QR_GUIDE_SHOW, "blkstrm.com/scanwallet") && qr_data.len > 0;
if (!qr_scanned) {
JADE_LOGW("No qr code scanned");
goto cleanup;
diff --git a/main/process/register_otp.c b/main/process/register_otp.c
index 13ead0f..7735b1b 100644
--- a/main/process/register_otp.c
+++ b/main/process/register_otp.c
@@ -349,8 +349,7 @@ bool register_otp_qr(void)
SENSITIVE_PUSH(&qr_data, sizeof(qr_data));
// Get URI from qr code scan
- const qr_frame_guides_t qr_frame_guides = QR_GUIDES_SHOW;
- if (!jade_camera_scan_qr(&qr_data, NULL, qr_frame_guides, "blkstrm.com/otp") || !qr_data.len) {
+ if (!jade_camera_scan_qr(&qr_data, NULL, QR_GUIDE_SHOW, "blkstrm.com/otp") || !qr_data.len) {
// User exit without scanning
JADE_LOGW("No qr code scanned");
goto cleanup;
diff --git a/main/qrscan.c b/main/qrscan.c
index c87fc63..3abf5b2 100644
--- a/main/qrscan.c
+++ b/main/qrscan.c
@@ -156,11 +156,11 @@ bool scan_qr(const size_t width, const size_t height, const uint8_t* data, const
// Main entry point to run camera task to capture frames and scan each
// image until a valid qr-code is found ('valid' as defined by the caller).
bool jade_camera_scan_qr(
- qr_data_t* qr_data, const char* text_label, const qr_frame_guides_t qr_frame_guides, const char* help_url)
+ qr_data_t* qr_data, const char* text_label, const qr_guide_type_t qr_guide_type, const char* help_url)
{
JADE_ASSERT(qr_data);
// text_label is optional
- JADE_ASSERT(qr_frame_guides != QR_GUIDES_NONE);
+ JADE_ASSERT(qr_guide_type != QR_GUIDE_HIDE);
// help_url is optional
#ifdef CONFIG_HAS_CAMERA
@@ -184,7 +184,7 @@ bool jade_camera_scan_qr(
// Run the camera task trying to interpet frames as qr-codes
const bool show_camera_ui = true;
const bool show_click_button = false;
- jade_camera_process_images(qr_recognize, qr_data, show_camera_ui, text_label, show_click_button, qr_frame_guides,
+ jade_camera_process_images(qr_recognize, qr_data, show_camera_ui, text_label, show_click_button, qr_guide_type,
help_url, qr_data->progress_bar);
// Destroy the quirc structs created above
diff --git a/main/qrscan.h b/main/qrscan.h
index 07a3c6f..b89aa35 100644
--- a/main/qrscan.h
+++ b/main/qrscan.h
@@ -45,6 +45,6 @@ bool scan_qr(const size_t width, const size_t height, const uint8_t* data, const
// is written to the passed qr_data struct, and the function returns true.
// The function returns false if scanning is aborted, and no string is returned.
bool jade_camera_scan_qr(
- qr_data_t* qr_data, const char* text_label, qr_frame_guides_t qr_frame_guides, const char* help_url);
+ qr_data_t* qr_data, const char* text_label, qr_guide_type_t qr_guide_type, const char* help_url);
#endif /* QRSCAN_H_ */
diff --git a/main/smoketest.c b/main/smoketest.c
index abc186a..32bb4be 100644
--- a/main/smoketest.c
+++ b/main/smoketest.c
@@ -471,7 +471,7 @@ static void check_camera(void)
{
// Run the camera task until the user quits
bool ok = false;
- jade_camera_process_images(camera_cb, &ok, true, "Click front button", false, QR_GUIDES_NONE, NULL, NULL);
+ jade_camera_process_images(camera_cb, &ok, true, "Click front button", false, QR_GUIDE_HIDE, NULL, NULL);
JADE_ASSERT(ok); // Must have processed at least one good image
}
diff --git a/main/ui.h b/main/ui.h
index b557edd..b7e5d59 100644
--- a/main/ui.h
+++ b/main/ui.h
@@ -75,7 +75,7 @@ typedef struct {
} home_menu_entry_t;
// Whether QR Frame Guides (box corners) should be shown
-typedef enum { QR_GUIDES_NONE, QR_GUIDES_SHOW } qr_frame_guides_t;
+typedef enum { QR_GUIDE_HIDE, QR_GUIDE_SHOW } qr_guide_type_t;
#define OUTPUT_FLAG_CONFIDENTIAL 1
#define OUTPUT_FLAG_HAS_BLINDING_KEY 2
diff --git a/main/ui/camera.c b/main/ui/camera.c
index aa49fab..5c9334d 100644
--- a/main/ui/camera.c
+++ b/main/ui/camera.c
@@ -4,7 +4,7 @@
#include "../ui.h"
gui_activity_t* make_camera_activity(gui_view_node_t** image_node, gui_view_node_t** label_node,
- const bool show_click_btn, const qr_frame_guides_t qr_frame_guides, progress_bar_t* progress_bar,
+ const bool show_click_btn, const qr_guide_type_t qr_guide_type, progress_bar_t* progress_bar,
const bool show_help_btn)
{
// progress bar is optional
@@ -23,7 +23,7 @@ gui_activity_t* make_camera_activity(gui_view_node_t** image_node, gui_view_node
gui_view_node_t* parent = *image_node;
// QR frame guide if applicable
- if (qr_frame_guides != QR_GUIDES_NONE) {
+ if (qr_guide_type == QR_GUIDE_SHOW) {
gui_make_qrguide(&parent, TFT_WHITE);
gui_set_parent(parent, *image_node);
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.