Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect device_id initialization #1184

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions src/minisatip.c
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ void set_options(int argc, char *argv[]) {
opts.timeout_sec = 30000;
opts.adapter_timeout = 30000;
opts.daemon = 1;
opts.device_id = 1;
opts.device_id = 0;
opts.dvr_buffer = DVR_BUFFER;
opts.adapter_buffer = ADAPTER_BUFFER;
opts.udp_threshold = 25;
Expand Down Expand Up @@ -2010,27 +2010,31 @@ int main(int argc, char *argv[]) {

int readBootID() {
opts.bootid = 0;
opts.device_id = 0;
int local_device_id = 0;
char bootid_path[256];

// Read existing values
snprintf(bootid_path, sizeof(bootid_path) - 1, "%s/bootid", opts.cache_dir);
FILE *f = fopen(bootid_path, "rt");
__attribute__((unused)) int rv;
if (f) {
rv = fscanf(f, "%d %d %s", &opts.bootid, &opts.device_id, opts.uuid);
rv = fscanf(f, "%d %d %s", &opts.bootid, &local_device_id, opts.uuid);
fclose(f);
}

// Increment bootid and set defaults if values are missing
opts.bootid++;
if (opts.device_id < 1) {
opts.device_id = 1;
if (local_device_id < 1) {
local_device_id = 1;
}
if (!strcmp(opts.uuid, "")) {
uuid4_generate(opts.uuid);
}

if (opts.device_id < 1) {
opts.device_id = local_device_id;
}

// Store new values
f = fopen(bootid_path, "wt");
if (f) {
Expand Down
Loading