mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-10-03 23:38:25 +00:00
Fix integer to float conversion errors
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
This commit is contained in:
@@ -126,9 +126,9 @@ static int check_disk_space_availability(struct list *to_install_bundles)
|
||||
timelist_timer_stop(globals.global_times); // closing: Check disk space availability
|
||||
|
||||
/* Add 10% to bundle_size as a 'fudge factor' */
|
||||
if (((bundle_size * 1.1) > fs_free) || fs_free < 0) {
|
||||
if ((((double)bundle_size * 1.1) > fs_free) || fs_free < 0) {
|
||||
if (fs_free > 0) {
|
||||
error("Bundle too large by %ldM\n", (bundle_size - fs_free) / 1000 / 1000);
|
||||
error("Bundle too large by %ldM\n", (bundle_size - long_to_ulong(fs_free)) / 1000 / 1000);
|
||||
} else {
|
||||
error("Unable to determine free space on filesystem\n");
|
||||
}
|
||||
|
||||
+1
-1
@@ -469,7 +469,7 @@ clean_exit:
|
||||
|
||||
clean_curl:
|
||||
clock_gettime(CLOCK_MONOTONIC_RAW, &ts_stop);
|
||||
delta = ts_stop.tv_sec - ts_start.tv_sec + ts_stop.tv_nsec / 1000000000.0 - ts_start.tv_nsec / 1000000000.0;
|
||||
delta = (double)ts_stop.tv_sec - (double)ts_start.tv_sec + (double)ts_stop.tv_nsec / 1000000000.0 - (double)ts_start.tv_nsec / 1000000000.0;
|
||||
telemetry(ret ? TELEMETRY_CRIT : TELEMETRY_LOW,
|
||||
"update",
|
||||
"current_version=%d\n"
|
||||
|
||||
+1
-1
@@ -332,7 +332,7 @@ static void check_warn_freespace(struct file *file)
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (fs_free < st.st_size * 1.1) {
|
||||
if (fs_free < (double)st.st_size * 1.1) {
|
||||
warn("File to install (%s) too large by %ldK\n",
|
||||
file->filename, (st.st_size - fs_free) / 1000);
|
||||
/* set flag to skip checking space on the second failure, assume we're still out of space */
|
||||
|
||||
+2
-2
@@ -147,7 +147,7 @@ void timelist_print_stats(timelist *head)
|
||||
TAILQ_FOREACH_REVERSE(t, head, timelist, times)
|
||||
{
|
||||
if (t->complete == true) {
|
||||
delta = (t->rawstop.tv_sec - t->rawstart.tv_sec) * 1000 + (t->rawstop.tv_nsec / 1000000.0) - (t->rawstart.tv_nsec / 1000000.0);
|
||||
delta = (double)(t->rawstop.tv_sec - t->rawstart.tv_sec) * 1000 + ((double)t->rawstop.tv_nsec / 1000000.0) - ((double)t->rawstart.tv_nsec / 1000000.0);
|
||||
info("%10.2f ms: %s\n", delta, t->name);
|
||||
}
|
||||
}
|
||||
@@ -155,7 +155,7 @@ void timelist_print_stats(timelist *head)
|
||||
TAILQ_FOREACH_REVERSE(t, head, timelist, times)
|
||||
{
|
||||
if (t->complete == true) {
|
||||
delta = (t->procstop.tv_sec - t->procstart.tv_sec) * 1000 + (t->procstop.tv_nsec / 1000000.0) - (t->procstart.tv_nsec / 1000000.0);
|
||||
delta = (double)(t->procstop.tv_sec - t->procstart.tv_sec) * 1000 + ((double)t->procstop.tv_nsec / 1000000.0) - ((double)t->procstart.tv_nsec / 1000000.0);
|
||||
info("%10.2f ms: %s\n", delta, t->name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ static bool download_successful(void *data)
|
||||
|
||||
static double fullfile_query_total_download_size(struct list *files)
|
||||
{
|
||||
long size = 0;
|
||||
long total_size = 0;
|
||||
double size = 0;
|
||||
double total_size = 0;
|
||||
struct file *file = NULL;
|
||||
struct list *list = NULL;
|
||||
char *url = NULL;
|
||||
@@ -70,7 +70,7 @@ static double fullfile_query_total_download_size(struct list *files)
|
||||
|
||||
string_or_die(&url, "%s/%i/files/%s.tar", globals.content_url, file->last_change, file->hash);
|
||||
size = swupd_curl_query_content_size(url);
|
||||
if (size != -1) {
|
||||
if (size > 0) {
|
||||
total_size += size;
|
||||
} else {
|
||||
debug("The header for file %s could not be downloaded\n", file->filename);
|
||||
@@ -79,12 +79,12 @@ static double fullfile_query_total_download_size(struct list *files)
|
||||
}
|
||||
|
||||
count++;
|
||||
debug("File: %s (%.2lf MB)\n", url, (double)size / 1000000);
|
||||
debug("File: %s (%.2lf MB)\n", url, size / 1000000);
|
||||
FREE(url);
|
||||
}
|
||||
|
||||
debug("Number of files to download: %d\n", count);
|
||||
debug("Total size of files to be downloaded: %.2lf MB\n", (double)total_size / 1000000);
|
||||
debug("Total size of files to be downloaded: %.2lf MB\n", total_size / 1000000);
|
||||
return total_size;
|
||||
}
|
||||
|
||||
|
||||
@@ -143,8 +143,8 @@ static int download_pack(struct swupd_curl_parallel_handle *download_handle, int
|
||||
|
||||
static double packs_query_total_download_size(struct list *subs, struct manifest *mom)
|
||||
{
|
||||
long size = 0;
|
||||
long total_size = 0;
|
||||
double size = 0;
|
||||
double total_size = 0;
|
||||
struct sub *sub = NULL;
|
||||
struct list *list = NULL;
|
||||
struct file *bundle = NULL;
|
||||
@@ -171,12 +171,12 @@ static double packs_query_total_download_size(struct list *subs, struct manifest
|
||||
}
|
||||
|
||||
count++;
|
||||
debug("Pack: %s (%.2lf MB)\n", url, (double)size / 1000000);
|
||||
debug("Pack: %s (%.2lf MB)\n", url, size / 1000000);
|
||||
FREE(url);
|
||||
}
|
||||
|
||||
debug("Number of packs to download: %d\n", count);
|
||||
debug("Total size of packs to be downloaded: %.2lf MB\n", (double)total_size / 1000000);
|
||||
debug("Total size of packs to be downloaded: %.2lf MB\n", total_size / 1000000);
|
||||
return total_size;
|
||||
}
|
||||
|
||||
@@ -278,8 +278,8 @@ int download_subscribed_packs(struct list *subs, struct manifest *mom, bool requ
|
||||
}
|
||||
|
||||
/* show the packs size only if > 1 MB */
|
||||
string_or_die(&packs_size, "(%.2lf MB) ", (double)download_progress.total_download_size / 1000000);
|
||||
info("Downloading packs %sfor:\n", ((double)download_progress.total_download_size / 1000000) > 1 ? packs_size : "");
|
||||
string_or_die(&packs_size, "(%.2lf MB) ", download_progress.total_download_size / 1000000);
|
||||
info("Downloading packs %sfor:\n", (download_progress.total_download_size / 1000000) > 1 ? packs_size : "");
|
||||
FREE(packs_size);
|
||||
for (iter = list_head(need_download); iter; iter = iter->next) {
|
||||
sub = iter->data;
|
||||
|
||||
@@ -17,7 +17,7 @@ extern "C" {
|
||||
*/
|
||||
struct download_progress {
|
||||
/** @brief total number of bytes to download. */
|
||||
long total_download_size;
|
||||
double total_download_size;
|
||||
/** @brief total of bytes downloaded so far. */
|
||||
long downloaded;
|
||||
};
|
||||
|
||||
@@ -92,19 +92,20 @@ out:
|
||||
|
||||
static int get_sig_inmemory(char *url, struct curl_file_data *tmp_version_sig)
|
||||
{
|
||||
static const int sig_size = 4096;
|
||||
static const size_t default_sig_size = 4096;
|
||||
int ret = -1;
|
||||
double file_size;
|
||||
char *sig_fname;
|
||||
string_or_die(&sig_fname, "%s.sig", url);
|
||||
ret = swupd_curl_query_content_size(sig_fname);
|
||||
if (ret <= 0) {
|
||||
debug("Failed to retrieve size for signature file: %s - assuming %d\n", sig_fname, sig_size);
|
||||
ret = sig_size;
|
||||
file_size = swupd_curl_query_content_size(sig_fname);
|
||||
if (file_size <= 0) {
|
||||
debug("Failed to retrieve size for signature file: %s - assuming %d\n", sig_fname, default_sig_size);
|
||||
tmp_version_sig->capacity = default_sig_size;
|
||||
} else {
|
||||
tmp_version_sig->capacity = (size_t)file_size;
|
||||
}
|
||||
|
||||
tmp_version_sig->capacity = int_to_uint(ret);
|
||||
|
||||
tmp_version_sig->data = malloc_or_die(int_to_uint(ret) * sizeof(char));
|
||||
tmp_version_sig->data = malloc_or_die(tmp_version_sig->capacity * sizeof(char));
|
||||
|
||||
ret = swupd_curl_get_file_memory(sig_fname, tmp_version_sig);
|
||||
if (ret != 0) {
|
||||
|
||||
Reference in New Issue
Block a user