Skip to content

Commit

Permalink
Simplify readBootID() somewhat to make it more readable
Browse files Browse the repository at this point in the history
  • Loading branch information
Jalle19 committed Aug 5, 2024
1 parent 19cffe3 commit 316a321
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/minisatip.c
Original file line number Diff line number Diff line change
Expand Up @@ -2015,26 +2015,26 @@ int main(int argc, char *argv[]) {
#endif

int readBootID() {
int did = 0;
opts.bootid = 0;
opts.device_id = 0;
char bootid_path[256];
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", &opts.bootid, &did);
rv = fscanf(f, "%d %d", &opts.bootid, &opts.device_id);
fclose(f);
if (opts.device_id < 1)
opts.device_id = did;
}
opts.bootid++;
if (opts.device_id < 1)
if (opts.device_id < 1) {
opts.device_id = 1;
}
f = fopen(bootid_path, "wt");
if (f) {
fprintf(f, "%d %d", opts.bootid, opts.device_id);
fclose(f);
}
LOG("Running with bootid %d, device_id %d", opts.bootid, opts.device_id);
return opts.bootid;
}

Expand Down

0 comments on commit 316a321

Please sign in to comment.