Skip to content

Commit

Permalink
check osdp close file status (according prototype function comments)
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Gouraud committed Jun 16, 2023
1 parent 6dc2e4a commit d97c4e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion include/osdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1092,7 +1092,7 @@ struct osdp_file_ops {
*
* @retval 0 on success. -1 on errors.
*/
void (*close)(void *arg);
int (*close)(void *arg);
};

/**
Expand Down
10 changes: 8 additions & 2 deletions src/osdp_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ int osdp_file_cmd_stat_decode(struct osdp_pd *pd, uint8_t *buf, int len)

assert(f->offset <= f->size);
if (f->offset == f->size) { /* EOF */
f->ops.close(f->ops.arg);
if (f->ops.close(f->ops.arg) < 0) {
LOG_ERR("Stat_Decode: Close failed!");
return -1;
}
f->state = OSDP_FILE_DONE;
LOG_INF("Stat_Decode: File transfer complete");
}
Expand Down Expand Up @@ -224,7 +227,10 @@ int osdp_file_cmd_stat_build(struct osdp_pd *pd, uint8_t *buf, int max_len)

assert(f->offset <= f->size);
if (f->offset == f->size) { /* EOF */
f->ops.close(f->ops.arg);
if (f->ops.close(f->ops.arg) < 0) {
LOG_ERR("Stat_Build: Close failed!");
return -1;
}
f->state = OSDP_FILE_DONE;
LOG_INF("TX_Decode: File receive complete");
}
Expand Down

0 comments on commit d97c4e3

Please sign in to comment.