Skip to content

Commit 33a4f90

Browse files
committed
fix a few warnings
1 parent a09c048 commit 33a4f90

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ ALL_CFLAGS += -Wundef -Wshadow -Wc++-compat -Wcast-qual -Wcast-align
3131
ALL_CFLAGS += -Wconversion -Wsign-conversion -Wjump-misses-init
3232
ALL_CFLAGS += -Wno-multichar -Wpacked -Wstrict-overflow -Wvla
3333
ALL_CFLAGS += -Wformat -Wno-format-zero-length -Wstrict-prototypes
34-
ALL_CFLAGS += -Wno-unknown-warning-option
34+
ALL_CFLAGS += -Wno-unknown-warning-option -Wno-cast-qual
3535

3636
# Version Generation
3737
VER := $(shell git describe --tags --always --dirty)

src/tldr.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void print_version (char const* arg);
107107
void print_usage (char const* arg);
108108

109109
/* functionality */
110-
int check_localdate (void);
110+
long check_localdate (void);
111111
int update_localdate (void);
112112
int has_localdb (void);
113113
int update_localdb (int verbose);
@@ -244,7 +244,7 @@ main(int argc, char** argv)
244244

245245
if (optind < argc)
246246
{
247-
int len, sum;
247+
size_t len, sum;
248248
char buf[4096];
249249

250250
sum = 0;
@@ -328,7 +328,7 @@ parse_tldrpage(char const* input)
328328
int i, len;
329329
int start = -1;
330330

331-
len = strlen(input);
331+
len = (int)strlen(input);
332332

333333
fprintf(stdout, "\n");
334334
for (i = 0; i < len; ++i)
@@ -547,7 +547,7 @@ print_usage(char const* arg)
547547
/* *INDENT-ON* */
548548
}
549549

550-
int
550+
long
551551
check_localdate(void)
552552
{
553553
FILE* fp;
@@ -561,19 +561,19 @@ check_localdate(void)
561561
time_t difftime;
562562

563563
homedir = _gethome();
564-
if (homedir == NULL) { return 1; }
564+
if (homedir == NULL) { return -1; }
565565

566566
curlen = 0;
567567
if (sstrncat(outdir, &curlen, STRBUFSIZ, homedir, strlen(homedir)))
568-
{ return 1; }
568+
{ return -1; }
569569
if (sstrncat(outdir, &curlen, STRBUFSIZ, TLDR_DATE, TLDR_DATE_LEN))
570-
{ return 1; }
570+
{ return -1; }
571571

572572
fp = fopen(outdir, "rb");
573573
if (!fp) { return -1; }
574574

575575
if (fseek(fp, 0, SEEK_END)) { goto error; }
576-
len = ftell(fp);
576+
if ((len = (size_t)ftell(fp)) == (size_t)EOF) { goto error; }
577577
if (fseek(fp, 0, SEEK_SET)) { goto error; }
578578

579579
read = fread(buffer, 1, len, fp);
@@ -777,7 +777,7 @@ get_file_content(char const* path, char** out, int verbose)
777777
if (!fp) { return 1; }
778778

779779
if (fseek(fp, 0, SEEK_END)) { goto error; }
780-
len = ftell(fp);
780+
if ((len = (size_t)ftell(fp)) == (size_t)EOF) { goto error; }
781781
if (fseek(fp, 0, SEEK_SET)) { goto error; }
782782

783783
*out = malloc(len);
@@ -874,7 +874,7 @@ int
874874
_unzip(char const* path, char const* outpath)
875875
{
876876
int err;
877-
int i, len;
877+
long i, len;
878878
size_t filelen;
879879
struct zip* archive;
880880
struct zip_file* file;
@@ -893,7 +893,7 @@ _unzip(char const* path, char const* outpath)
893893
len = zip_get_num_entries(archive, 0);
894894
for (i = 0; i < len; i++)
895895
{
896-
if (zip_stat_index(archive, i, 0, &stat))
896+
if (zip_stat_index(archive, (zip_uint64_t)i, 0, &stat))
897897
{
898898
goto error;
899899
}
@@ -918,7 +918,7 @@ _unzip(char const* path, char const* outpath)
918918
}
919919
else
920920
{
921-
file = zip_fopen_index(archive, i, 0);
921+
file = zip_fopen_index(archive, (zip_uint64_t)i, 0);
922922
if (!file)
923923
{
924924
fprintf(stderr, "Error: Opening zip content: %s", tmp);
@@ -936,7 +936,7 @@ _unzip(char const* path, char const* outpath)
936936
sum = 0;
937937
while (sum != stat.size)
938938
{
939-
filelen = zip_fread(file, buf, 4096);
939+
filelen = (size_t)zip_fread(file, buf, 4096);
940940
if (len < 0)
941941
{
942942
fprintf(stderr, "Error: Reading file: %s\n", tmp);
@@ -999,7 +999,7 @@ progress_callback(void* clientp, curl_off_t dltotal, curl_off_t dlnow,
999999
if (dltotal <= 0) { return 0; }
10001000

10011001
progress = dlnow / dltotal;
1002-
total = _round(progress * 40.0);
1002+
total = (int)_round(progress * 40.0);
10031003

10041004
printf("%s [", (char*)clientp);
10051005
for (i = 0; i < total; i++)
@@ -1033,7 +1033,8 @@ download_file(char const* url, char const* outfile, int verbose)
10331033
curl = curl_easy_init();
10341034
if (curl)
10351035
{
1036-
int len, ret = 1;
1036+
size_t len;
1037+
int ret = 1;
10371038
FILE* file;
10381039
char* base;
10391040
char filename[FILENAME_MAX];

0 commit comments

Comments
 (0)