Skip to content

Commit

Permalink
chore: ensure size is not 0
Browse files Browse the repository at this point in the history
Avoids division by zero errors if you're e.g. using a really small dummy
artifact

Ticket: None

Signed-off-by: Daniel Skinstad Drabitzius <[email protected]>
  • Loading branch information
danielskinstad committed Sep 27, 2024
1 parent 1291e0e commit 7b5d156
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions core/src/mender-client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1170,15 +1170,18 @@ mender_client_download_artifact_callback(char *type, cJSON *meta_data, char *fil
mender_err_t ret = MENDER_FAIL;

#if CONFIG_MENDER_LOG_LEVEL >= MENDER_LOG_LEVEL_INF
static size_t download_progress = 0;
/* New update */
if (0 == index) {
download_progress = 0;
}
/* Update every 10% */
if (((index * 10) / size) > download_progress) {
download_progress = (index * 10) / size;
mender_log_info("Downloading '%s' %zu0%%... [%zu/%zu]", type, download_progress, index, size);
if (0 < size) {
static size_t download_progress = 0;
/* New update */
if (0 == index) {
download_progress = 0;
}

/* Update every 10% */
if (((index * 10) / size) > download_progress) {
download_progress = (index * 10) / size;
mender_log_info("Downloading '%s' %zu0%%... [%zu/%zu]", type, download_progress, index, size);
}
}
#endif

Expand Down

0 comments on commit 7b5d156

Please sign in to comment.