Skip to content

Commit 45eca71

Browse files
committed
transfer: explicity typecast to float in size report
* Fixes the file size being reported as 0.00M when size was less than 1M * Thanks for the reports, On the scale of 0 to 10, I rate myself as retard. * Kill trailing white spaces while we are at it. Signed-off-by: dev-harsh1998 <[email protected]>
1 parent dbabf1e commit 45eca71

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

transfer.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* SPDX-License-Identifier: GPL-3.0-or-later
33
*
4-
* Copyright (C) 2018, Harshit Jain
4+
* Copyright (C) 2019, Harshit Jain
55
*/
66

77
#include <stdbool.h>
@@ -75,16 +75,16 @@ int main(int argc, char *argv[]) {
7575
const char curl[5] = "curl";
7676
static bool x;
7777

78-
#ifdef UPLOAD_MULTIPLE
78+
#ifdef UPLOAD_MULTIPLE
7979
int holder = argc;
8080
int q;
81-
#endif
81+
#endif
8282

8383
x = can_run_command(curl);
8484
/* Only run the uploader when curl binary is found & is executable */
8585
if (x) {
8686

87-
#ifdef UPLOAD_MULTIPLE
87+
#ifdef UPLOAD_MULTIPLE
8888
/* Argument check */
8989
if (argc <= 1) {
9090
printf("ERROR: This binary expects atleast one command "
@@ -97,7 +97,7 @@ int main(int argc, char *argv[]) {
9797
}
9898
printf("\n");
9999
/* Display names of file (Ignore the first argument as its transfer itself) */
100-
for (q = 1; q < holder; q++) {
100+
for (q = 1; q < holder; q++) {
101101
printf("File no. %d is %s\n", q, argv[q]);
102102
}
103103
printf("\n");
@@ -116,17 +116,17 @@ int main(int argc, char *argv[]) {
116116
if (getenv("TRANSFER_DISABLE_FILESIZE") == NULL) {
117117
static struct stat st;
118118
#ifdef UPLOAD_MULTIPLE
119-
for (q = 1; q < holder; q++) {
119+
for (q = 1; q < holder; q++) {
120120
stat(argv[q], &st);
121-
const float mb = st.st_size / 1048576;
121+
const float mb = (float)st.st_size / 1048576;
122122
printf("The size of the %d file going to be uploaded is near to %.2f "
123123
"megabytes\n", q, mb);
124124
}
125125
}
126126
#else
127127
stat(argv[1], &st);
128128
// convert bytes to mb (devide by 1024*1024)
129-
const float mb = st.st_size / 1048576;
129+
const float mb = (float)st.st_size / 1048576;
130130
printf("The size of the file going to be uploaded is near to %.2f "
131131
"megabytes\n",
132132
mb);
@@ -150,7 +150,7 @@ int main(int argc, char *argv[]) {
150150
#endif
151151
#else
152152
#ifdef UPLOAD_MULTIPLE
153-
for (q = 1; q < holder; q++) {
153+
for (q = 1; q < holder; q++) {
154154
sprintf(cmdbuf, "curl -T %s %s", argv[q], "https://transfer.sh");
155155
ret = uploader(cmdbuf);
156156
printf("\n");

0 commit comments

Comments
 (0)