summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-12-25 07:27:29 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-12-25 07:27:29 +0200
commit1c29e992b9c7d17a4e0ca2c394fdf605706c961f (patch)
treeb18a3aa23b54aa4ba4dade24d1ae2b15ec0e1185
parente6a1ff50654f251d6f7b495e46d78d48a0f2a754 (diff)
Cleanup
Warnings about lost precision.
-rw-r--r--src/audio/player.c4
-rw-r--r--src/feeds.c6
-rw-r--r--src/gmcerts.c2
-rw-r--r--src/gmrequest.c5
-rw-r--r--src/media.c2
-rw-r--r--src/sitespec.c2
-rw-r--r--src/ui/color.c2
-rw-r--r--src/ui/command.c2
-rw-r--r--src/ui/mobile.c2
-rw-r--r--src/ui/paint.c2
-rw-r--r--src/ui/scrollwidget.c4
-rw-r--r--src/ui/util.c2
-rw-r--r--src/ui/window.c6
-rw-r--r--src/visited.c2
14 files changed, 22 insertions, 21 deletions
diff --git a/src/audio/player.c b/src/audio/player.c
index bf853e3f..de430b17 100644
--- a/src/audio/player.c
+++ b/src/audio/player.c
@@ -192,7 +192,7 @@ static enum iDecoderStatus decodeVorbis_Decoder_(iDecoder *d) {
192 int error; 192 int error;
193 int consumed; 193 int consumed;
194 d->vorbis = stb_vorbis_open_pushdata( 194 d->vorbis = stb_vorbis_open_pushdata(
195 constData_Block(input), size_Block(input), &consumed, &error, NULL); 195 constData_Block(input), (int) size_Block(input), &consumed, &error, NULL);
196 if (!d->vorbis) { 196 if (!d->vorbis) {
197 return needMoreInput_DecoderStatus; 197 return needMoreInput_DecoderStatus;
198 } 198 }
@@ -225,7 +225,7 @@ static enum iDecoderStatus decodeVorbis_Decoder_(iDecoder *d) {
225 lock_Mutex(&d->input->mtx); 225 lock_Mutex(&d->input->mtx);
226 d->totalInputSize = size_Block(input); 226 d->totalInputSize = size_Block(input);
227 int error = 0; 227 int error = 0;
228 stb_vorbis *vrb = stb_vorbis_open_memory(constData_Block(input), size_Block(input), 228 stb_vorbis *vrb = stb_vorbis_open_memory(constData_Block(input), (int) size_Block(input),
229 &error, NULL); 229 &error, NULL);
230 if (vrb) { 230 if (vrb) {
231 d->totalSamples = stb_vorbis_stream_length_in_samples(vrb); 231 d->totalSamples = stb_vorbis_stream_length_in_samples(vrb);
diff --git a/src/feeds.c b/src/feeds.c
index b7ce739b..7fe13617 100644
--- a/src/feeds.c
+++ b/src/feeds.c
@@ -437,7 +437,7 @@ static iThreadResult fetch_Feeds_(iThread *thread) {
437 iZap(work); 437 iZap(work);
438 iBool gotNew = iFalse; 438 iBool gotNew = iFalse;
439 postCommand_App("feeds.update.started"); 439 postCommand_App("feeds.update.started");
440 const int totalJobs = size_PtrArray(&d->jobs); 440 const size_t totalJobs = size_PtrArray(&d->jobs);
441 int numFinishedJobs = 0; 441 int numFinishedJobs = 0;
442 while (!d->stopWorker) { 442 while (!d->stopWorker) {
443 /* Start new jobs. */ 443 /* Start new jobs. */
@@ -476,7 +476,7 @@ static iThreadResult fetch_Feeds_(iThread *thread) {
476 } 476 }
477 } 477 }
478 if (doNotify) { 478 if (doNotify) {
479 postCommandf_App("feeds.update.progress arg:%d total:%d", numFinishedJobs, totalJobs); 479 postCommandf_App("feeds.update.progress arg:%d total:%zu", numFinishedJobs, totalJobs);
480 } 480 }
481 /* Stop if everything has finished. */ 481 /* Stop if everything has finished. */
482 if (ongoing == 0 && isEmpty_PtrArray(&d->jobs)) { 482 if (ongoing == 0 && isEmpty_PtrArray(&d->jobs)) {
@@ -614,7 +614,7 @@ static void load_Feeds_(iFeeds *d) {
614 /* TODO: Cleanup needed... 614 /* TODO: Cleanup needed...
615 All right, this could maybe use a bit more robust, structured format. 615 All right, this could maybe use a bit more robust, structured format.
616 The code below is messy. */ 616 The code below is messy. */
617 const uint32_t feedId = strtoul(line.start, NULL, 16); 617 const uint32_t feedId = (uint32_t) strtoul(line.start, NULL, 16);
618 if (!nextSplit_Rangecc(range_Block(src), "\n", &line)) { 618 if (!nextSplit_Rangecc(range_Block(src), "\n", &line)) {
619 goto aborted; 619 goto aborted;
620 } 620 }
diff --git a/src/gmcerts.c b/src/gmcerts.c
index ed4759be..8f7bf181 100644
--- a/src/gmcerts.c
+++ b/src/gmcerts.c
@@ -90,7 +90,7 @@ void serialize_GmIdentity(const iGmIdentity *d, iStream *outs) {
90 writeU32_Stream(outs, d->icon); 90 writeU32_Stream(outs, d->icon);
91 serialize_String(&d->notes, outs); 91 serialize_String(&d->notes, outs);
92 write32_Stream(outs, d->flags); 92 write32_Stream(outs, d->flags);
93 writeU32_Stream(outs, size_StringSet(d->useUrls)); 93 writeU32_Stream(outs, (uint32_t) size_StringSet(d->useUrls));
94 iConstForEach(StringSet, i, d->useUrls) { 94 iConstForEach(StringSet, i, d->useUrls) {
95 serialize_String(i.value, outs); 95 serialize_String(i.value, outs);
96 } 96 }
diff --git a/src/gmrequest.c b/src/gmrequest.c
index 23845475..a9c5919d 100644
--- a/src/gmrequest.c
+++ b/src/gmrequest.c
@@ -790,7 +790,8 @@ void submit_GmRequest(iGmRequest *d) {
790 cstr_String(containerUrl)); 790 cstr_String(containerUrl));
791 appendFormat_String(page, "# %s\n\n", cstr_Rangecc(containerName)); 791 appendFormat_String(page, "# %s\n\n", cstr_Rangecc(containerName));
792 appendFormat_String(page, 792 appendFormat_String(page,
793 cstrCount_Lang("archive.summary.n", numEntries_Archive(arch)), 793 cstrCount_Lang("archive.summary.n",
794 (int) numEntries_Archive(arch)),
794 numEntries_Archive(arch), 795 numEntries_Archive(arch),
795 (double) sourceSize_Archive(arch) / 1.0e6); 796 (double) sourceSize_Archive(arch) / 1.0e6);
796 appendCStr_String(page, "\n\n"); 797 appendCStr_String(page, "\n\n");
@@ -802,7 +803,7 @@ void submit_GmRequest(iGmRequest *d) {
802 } 803 }
803 else if (size_StringSet(contents) > 1) { 804 else if (size_StringSet(contents) > 1) {
804 appendFormat_String(page, cstrCount_Lang("dir.summary.n", 805 appendFormat_String(page, cstrCount_Lang("dir.summary.n",
805 size_StringSet(contents)), 806 (int) size_StringSet(contents)),
806 size_StringSet(contents)); 807 size_StringSet(contents));
807 appendCStr_String(page, "\n\n"); 808 appendCStr_String(page, "\n\n");
808 } 809 }
diff --git a/src/media.c b/src/media.c
index a3f381ec..c02090b0 100644
--- a/src/media.c
+++ b/src/media.c
@@ -144,7 +144,7 @@ void makeTexture_GmImage(iGmImage *d) {
144 } 144 }
145 else { 145 else {
146 imgData = stbi_load_from_memory( 146 imgData = stbi_load_from_memory(
147 constData_Block(data), size_Block(data), &d->size.x, &d->size.y, NULL, 4); 147 constData_Block(data), (int) size_Block(data), &d->size.x, &d->size.y, NULL, 4);
148 if (!imgData) { 148 if (!imgData) {
149 fprintf(stderr, "[media] image load failed: %s\n", stbi_failure_reason()); 149 fprintf(stderr, "[media] image load failed: %s\n", stbi_failure_reason());
150 } 150 }
diff --git a/src/sitespec.c b/src/sitespec.c
index f8b77c86..fe80ad13 100644
--- a/src/sitespec.c
+++ b/src/sitespec.c
@@ -141,7 +141,7 @@ static void handleIniKeyValue_SiteSpec_(void *context, const iString *table, con
141 set_String(&d->loadParams->titanIdentity, value->value.string); 141 set_String(&d->loadParams->titanIdentity, value->value.string);
142 } 142 }
143 else if (!cmp_String(key, "dismissWarnings") && value->type == int64_TomlType) { 143 else if (!cmp_String(key, "dismissWarnings") && value->type == int64_TomlType) {
144 d->loadParams->dismissWarnings = value->value.int64; 144 d->loadParams->dismissWarnings = (int) value->value.int64;
145 } 145 }
146 else if (!cmp_String(key, "usedIdentities") && value->type == string_TomlType) { 146 else if (!cmp_String(key, "usedIdentities") && value->type == string_TomlType) {
147 iRangecc seg = iNullRange; 147 iRangecc seg = iNullRange;
diff --git a/src/ui/color.c b/src/ui/color.c
index ed17f580..3c2f0339 100644
--- a/src/ui/color.c
+++ b/src/ui/color.c
@@ -832,7 +832,7 @@ void ansiColors_Color(iRangecc escapeSequence, int fgDefault, int bgDefault,
832 int rgb[3] = { 0, 0, 0 }; 832 int rgb[3] = { 0, 0, 0 };
833 iForIndices(i, rgb) { 833 iForIndices(i, rgb) {
834 if (ch >= escapeSequence.end) break; 834 if (ch >= escapeSequence.end) break;
835 rgb[i] = strtoul(ch + 1, &endPtr, 10); 835 rgb[i] = (int) strtoul(ch + 1, &endPtr, 10);
836 ch = endPtr; 836 ch = endPtr;
837 } 837 }
838 dst->r = iClamp(rgb[0], 0, 255); 838 dst->r = iClamp(rgb[0], 0, 255);
diff --git a/src/ui/command.c b/src/ui/command.c
index d6c668db..a4868ca9 100644
--- a/src/ui/command.c
+++ b/src/ui/command.c
@@ -80,7 +80,7 @@ uint32_t argU32Label_Command(const char *cmd, const char *label) {
80 init_Token(&tok, label); 80 init_Token(&tok, label);
81 const iRangecc ptr = find_Token(&tok, cmd); 81 const iRangecc ptr = find_Token(&tok, cmd);
82 if (ptr.start) { 82 if (ptr.start) {
83 return strtoul(ptr.end, NULL, 10); 83 return (uint32_t) strtoul(ptr.end, NULL, 10);
84 } 84 }
85 return 0; 85 return 0;
86} 86}
diff --git a/src/ui/mobile.c b/src/ui/mobile.c
index bffc2177..08d8dba2 100644
--- a/src/ui/mobile.c
+++ b/src/ui/mobile.c
@@ -210,7 +210,7 @@ static iBool topPanelHandler_(iWidget *topPanel, const char *cmd) {
210 /* Animate the current panel in. */ 210 /* Animate the current panel in. */
211 if (child == panel && isPortrait) { 211 if (child == panel && isPortrait) {
212 setupSheetTransition_Mobile(panel, iTrue); 212 setupSheetTransition_Mobile(panel, iTrue);
213 panelIndex = childIndex; 213 panelIndex = (int) childIndex;
214 } 214 }
215 childIndex++; 215 childIndex++;
216 } 216 }
diff --git a/src/ui/paint.c b/src/ui/paint.c
index c3b22343..5e66f521 100644
--- a/src/ui/paint.c
+++ b/src/ui/paint.c
@@ -175,7 +175,7 @@ void drawLines_Paint(const iPaint *d, const iInt2 *points, size_t n, int color)
175 for (size_t i = 0; i < n; i++) { 175 for (size_t i = 0; i < n; i++) {
176 offsetPoints[i] = add_I2(points[i], origin_Paint); 176 offsetPoints[i] = add_I2(points[i], origin_Paint);
177 } 177 }
178 SDL_RenderDrawLines(renderer_Paint_(d), (const SDL_Point *) offsetPoints, n); 178 SDL_RenderDrawLines(renderer_Paint_(d), (const SDL_Point *) offsetPoints, (int) n);
179 free(offsetPoints); 179 free(offsetPoints);
180} 180}
181 181
diff --git a/src/ui/scrollwidget.c b/src/ui/scrollwidget.c
index b6f73b6c..651669c6 100644
--- a/src/ui/scrollwidget.c
+++ b/src/ui/scrollwidget.c
@@ -107,7 +107,7 @@ static iRect bounds_ScrollWidget_(const iScrollWidget *d) {
107static iRect thumbRect_ScrollWidget_(const iScrollWidget *d) { 107static iRect thumbRect_ScrollWidget_(const iScrollWidget *d) {
108 const iRect bounds = bounds_ScrollWidget_(d); 108 const iRect bounds = bounds_ScrollWidget_(d);
109 iRect rect = init_Rect(bounds.pos.x, bounds.pos.y, bounds.size.x, 0); 109 iRect rect = init_Rect(bounds.pos.x, bounds.pos.y, bounds.size.x, 0);
110 const int total = size_Range(&d->range); 110 const int total = (int) size_Range(&d->range);
111 if (total > 0) { 111 if (total > 0) {
112 const int tsize = thumbSize_ScrollWidget_(d); 112 const int tsize = thumbSize_ScrollWidget_(d);
113// iAssert(tsize <= height_Rect(bounds)); 113// iAssert(tsize <= height_Rect(bounds));
@@ -197,7 +197,7 @@ static iBool processEvent_ScrollWidget_(iScrollWidget *d, const SDL_Event *ev) {
197 case drag_ClickResult: { 197 case drag_ClickResult: {
198 const iRect bounds = bounds_ScrollWidget_(d); 198 const iRect bounds = bounds_ScrollWidget_(d);
199 const int offset = delta_Click(&d->click).y; 199 const int offset = delta_Click(&d->click).y;
200 const int total = size_Range(&d->range); 200 const int total = (int) size_Range(&d->range);
201 int dpos = (float) offset / (float) (height_Rect(bounds) - thumbSize_ScrollWidget_(d)) * total; 201 int dpos = (float) offset / (float) (height_Rect(bounds) - thumbSize_ScrollWidget_(d)) * total;
202 d->thumb = iClamp(d->startThumb + dpos, d->range.start, d->range.end); 202 d->thumb = iClamp(d->startThumb + dpos, d->range.start, d->range.end);
203 postCommand_Widget(w, "scroll.moved arg:%d", d->thumb); 203 postCommand_Widget(w, "scroll.moved arg:%d", d->thumb);
diff --git a/src/ui/util.c b/src/ui/util.c
index 58e49230..4ce40ae4 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1427,7 +1427,7 @@ static iBool tabSwitcher_(iWidget *tabs, const char *cmd) {
1427 iWidget *nextTabs = findChild_Widget(otherRoot_Window(get_Window(), tabs->root)->widget, 1427 iWidget *nextTabs = findChild_Widget(otherRoot_Window(get_Window(), tabs->root)->widget,
1428 "doctabs"); 1428 "doctabs");
1429 iWidget *nextPages = findChild_Widget(nextTabs, "tabs.pages"); 1429 iWidget *nextPages = findChild_Widget(nextTabs, "tabs.pages");
1430 tabIndex = (dir < 0 ? childCount_Widget(nextPages) - 1 : 0); 1430 tabIndex = (int) (dir < 0 ? childCount_Widget(nextPages) - 1 : 0);
1431 showTabPage_Widget(nextTabs, child_Widget(nextPages, tabIndex)); 1431 showTabPage_Widget(nextTabs, child_Widget(nextPages, tabIndex));
1432 postCommand_App("keyroot.next"); 1432 postCommand_App("keyroot.next");
1433 } 1433 }
diff --git a/src/ui/window.c b/src/ui/window.c
index 7f3371c8..d694146a 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -442,7 +442,7 @@ void create_Window_(iWindow *d, iRect rect, uint32_t flags) {
442static SDL_Surface *loadImage_(const iBlock *data, int resized) { 442static SDL_Surface *loadImage_(const iBlock *data, int resized) {
443 int w = 0, h = 0, num = 4; 443 int w = 0, h = 0, num = 4;
444 stbi_uc *pixels = stbi_load_from_memory( 444 stbi_uc *pixels = stbi_load_from_memory(
445 constData_Block(data), size_Block(data), &w, &h, &num, STBI_rgb_alpha); 445 constData_Block(data), (int) size_Block(data), &w, &h, &num, STBI_rgb_alpha);
446 if (resized) { 446 if (resized) {
447 stbi_uc *rsPixels = malloc(num * resized * resized); 447 stbi_uc *rsPixels = malloc(num * resized * resized);
448 stbir_resize_uint8(pixels, w, h, 0, rsPixels, resized, resized, 0, num); 448 stbir_resize_uint8(pixels, w, h, 0, rsPixels, resized, resized, 0, num);
@@ -1549,9 +1549,9 @@ void setSplitMode_MainWindow(iMainWindow *d, int splitFlags) {
1549 iWidget *docTabs1 = findChild_Widget(w->roots[newRootIndex]->widget, "doctabs"); 1549 iWidget *docTabs1 = findChild_Widget(w->roots[newRootIndex]->widget, "doctabs");
1550 /* If the old root has multiple tabs, move the current one to the new split. */ 1550 /* If the old root has multiple tabs, move the current one to the new split. */
1551 if (tabCount_Widget(docTabs0) >= 2) { 1551 if (tabCount_Widget(docTabs0) >= 2) {
1552 int movedIndex = tabPageIndex_Widget(docTabs0, moved); 1552 size_t movedIndex = tabPageIndex_Widget(docTabs0, moved);
1553 removeTabPage_Widget(docTabs0, movedIndex); 1553 removeTabPage_Widget(docTabs0, movedIndex);
1554 showTabPage_Widget(docTabs0, tabPage_Widget(docTabs0, iMax(movedIndex - 1, 0))); 1554 showTabPage_Widget(docTabs0, tabPage_Widget(docTabs0, iMax((int) movedIndex - 1, 0)));
1555 iRelease(removeTabPage_Widget(docTabs1, 0)); /* delete the default tab */ 1555 iRelease(removeTabPage_Widget(docTabs1, 0)); /* delete the default tab */
1556 setRoot_Widget(as_Widget(moved), w->roots[newRootIndex]); 1556 setRoot_Widget(as_Widget(moved), w->roots[newRootIndex]);
1557 prependTabPage_Widget(docTabs1, iClob(moved), "", 0, 0); 1557 prependTabPage_Widget(docTabs1, iClob(moved), "", 0, 0);
diff --git a/src/visited.c b/src/visited.c
index 4552a053..83e09071 100644
--- a/src/visited.c
+++ b/src/visited.c
@@ -105,7 +105,7 @@ void load_Visited(iVisited *d, const char *dirPath) {
105 char *endp = NULL; 105 char *endp = NULL;
106 const unsigned long long ts = strtoull(line.start, &endp, 10); 106 const unsigned long long ts = strtoull(line.start, &endp, 10);
107 if (ts == 0) break; 107 if (ts == 0) break;
108 const uint32_t flags = strtoul(skipSpace_CStr(endp), &endp, 16); 108 const uint32_t flags = (uint32_t) strtoul(skipSpace_CStr(endp), &endp, 16);
109 const char *urlStart = skipSpace_CStr(endp); 109 const char *urlStart = skipSpace_CStr(endp);
110 iVisitedUrl item; 110 iVisitedUrl item;
111 item.when.ts = (struct timespec){ .tv_sec = ts }; 111 item.when.ts = (struct timespec){ .tv_sec = ts };