Skip to content

Conversation

@gniezen
Copy link
Member

@gniezen gniezen commented Oct 27, 2025

See UPLOAD-1512 for details.

@gniezen gniezen requested review from krystophv and removed request for krystophv November 13, 2025 16:58
@gniezen gniezen requested a review from krystophv November 17, 2025 14:19
@gniezen
Copy link
Member Author

gniezen commented Nov 17, 2025

@krystophv I have reviewed this myself, but it would be good to have another set of eyes even if you haven't programmed in Zig yet.

@krystophv krystophv requested a review from Copilot November 17, 2025 17:51
Copilot finished reviewing on behalf of krystophv November 17, 2025 17:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds macOS and Linux support to the uploader helper utility, expanding it from Windows-only to a cross-platform solution for detecting and communicating with LifeScan devices.

Key Changes:

  • Implemented platform-specific device discovery for Linux (via /sys/block) and macOS (via /dev)
  • Added cross-platform build configuration supporting Windows x64, Linux x64, macOS ARM64, and macOS x64
  • Refactored Windows-specific code into conditional compilation blocks with platform detection

Reviewed Changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 19 comments.

Show a summary per file
File Description
testing.js Adds a Node.js test script that detects the OS/architecture and spawns the appropriate helper binary for testing
helper.zig Implements cross-platform device detection and I/O, with platform-specific functions for Linux/macOS alongside refactored Windows code
build.zig Configures multi-target builds for all supported platforms (Windows, Linux, macOS ARM64/x64)
README.md Documents the new testing procedure for different platforms
.gitignore Adds .zig-cache/ to ignored build artifacts
.github/workflows/build-helper.yml Updates CI to build on macOS runner with executables for all platforms, packages them into a zip, and updates Zig to 0.15.2
Comments suppressed due to low confidence (1)

helper.zig:613

  • Memory leak: When "closeDevice" command is received, the loop breaks without calling parsed.deinit() first. This will leak the memory allocated for the parsed JSON. Call parsed.deinit() before the break statement.
        if (std.mem.eql(u8, data.command, "closeDevice")) {
            try sendReply("info", "Closing device");
            break;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

helper.zig Outdated
Comment on lines 662 to 664
var string = std.array_list.Managed(u8).init(allocator);
defer string.deinit();
try string.appendSlice(json_string);
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The string ArrayList is unnecessary since json_string already contains the serialized JSON. You can directly write json_string to stdout without creating an ArrayList and copying the data. Simply use json_string.len for the length calculation and write json_string directly.

Copilot uses AI. Check for mistakes.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense, I'll do this.

@gniezen
Copy link
Member Author

gniezen commented Nov 18, 2025

@krystophv Ready for re-review

Copy link
Member

@krystophv krystophv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants