Skip to content

Commit

Permalink
Fix -Wconversion warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
capehill committed Mar 13, 2024
1 parent ab34c9b commit 4b0cc83
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ static void logLineImpl(const char * fmt, va_list ap)

while (TRUE) {
char serialBuffer[4 * 1024]; // Sashimi has 4k buffer
const size_t wantedToWrite = snprintf(serialBuffer, sizeof(serialBuffer), "[%.6f] %s\n", time, ptr);
const size_t wantedToWrite = (size_t)snprintf(serialBuffer, sizeof(serialBuffer), "[%.6f] %s\n", time, ptr);

IExec->DebugPrintF("%s", serialBuffer);

Expand Down
4 changes: 2 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ static BOOL parse_args(void)
}

if (params.startTime) {
startTime = *params.startTime;
startTime = (ULONG)*params.startTime;
}

if (params.duration) {
duration = *params.duration;
duration = (ULONG)*params.duration;
}

IDOS->FreeArgs(result);
Expand Down
2 changes: 1 addition & 1 deletion makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ NAME = glSnoop
OBJS = main.o ogles2_module.o warp3dnova_module.o logger.o gui.o common.o filter.o timer.o profiling.o
DEPS = $(OBJS:.o=.d)

CFLAGS = -Wall -Wextra -O3 -gstabs -D__AMIGA_DATE__=\"$(AMIGADATE)\"
CFLAGS = -Wall -Wextra -Wconversion -O3 -gstabs -D__AMIGA_DATE__=\"$(AMIGADATE)\"

# Dependencies
%.d : %.c
Expand Down
26 changes: 13 additions & 13 deletions ogles2_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ static const char* decodeCapability(const GLenum value)
return "Unknown capability";
}

static const char* decodePrimitive(const int value)
static const char* decodePrimitive(const GLenum value)
{
#define MAP_ENUM(x) case x: return #x;

Expand Down Expand Up @@ -1086,10 +1086,10 @@ static void profileResults(struct Ogles2Context* const context)

PROF_FINISH_CONTEXT

const double drawcalls = context->profiling[DrawElements].callCount + context->profiling[DrawArrays].callCount +
context->profiling[DrawElementsBaseVertexOES].callCount;
const double drawcalls = (double)(context->profiling[DrawElements].callCount + context->profiling[DrawArrays].callCount +
context->profiling[DrawElementsBaseVertexOES].callCount);

const uint64 swaps = context->profiling[SwapBuffers].callCount;
const double swaps = (double)context->profiling[SwapBuffers].callCount;

// Copy items, otherwise sorthing will ruin the further profiling
ProfilingItem stats[Ogles2FunctionCount];
Expand Down Expand Up @@ -1117,9 +1117,9 @@ static void profileResults(struct Ogles2Context* const context)
stats[i].callCount,
stats[i].errors,
timer_ticks_to_ms(stats[i].ticks),
timer_ticks_to_us(stats[i].ticks) / stats[i].callCount,
(double)stats[i].ticks * 100.0 / context->ticks,
(double)stats[i].ticks * 100.0 / totalTicks);
timer_ticks_to_us(stats[i].ticks) / (double)stats[i].callCount,
(double)stats[i].ticks * 100.0 / (double)context->ticks,
(double)stats[i].ticks * 100.0 / (double)totalTicks);
}
}

Expand Down Expand Up @@ -1968,7 +1968,7 @@ static void OGLES2_glDrawArrays(struct OGLES2IFace *Self, GLenum mode, GLint fir

GL_CALL(DrawArrays, mode, first, count)

countPrimitive(&context->counter, mode, count);
countPrimitive(&context->counter, mode, (size_t)count);
}

static void OGLES2_glDrawElements(struct OGLES2IFace *Self, GLenum mode, GLsizei count, GLenum type, const void * indices)
Expand All @@ -1983,7 +1983,7 @@ static void OGLES2_glDrawElements(struct OGLES2IFace *Self, GLenum mode, GLsizei

GL_CALL(DrawElements, mode, count, type, indices)

countPrimitive(&context->counter, mode, count);
countPrimitive(&context->counter, mode, (size_t)count);
}

static void OGLES2_glDrawElementsBaseVertexOES(struct OGLES2IFace *Self, GLenum mode, GLsizei count, GLenum type, const void * indices, GLint basevertex)
Expand All @@ -1998,7 +1998,7 @@ static void OGLES2_glDrawElementsBaseVertexOES(struct OGLES2IFace *Self, GLenum

GL_CALL(DrawElementsBaseVertexOES, mode, count, type, indices, basevertex)

countPrimitive(&context->counter, mode, count);
countPrimitive(&context->counter, mode, (size_t)count);
}

static void OGLES2_glEnable(struct OGLES2IFace *Self, GLenum cap)
Expand Down Expand Up @@ -2929,7 +2929,7 @@ static void OGLES2_glShaderSource(struct OGLES2IFace *Self, GLuint shader, GLsiz
logLine("Line %u: length 0:", i);
} else {
// Use temporary buffer to NUL-terminate strings
const size_t len = length[i] + 1;
const size_t len = (size_t)length[i] + 1;

char* temp = IExec->AllocVecTags(len, TAG_DONE);

Expand Down Expand Up @@ -3028,7 +3028,7 @@ static void OGLES2_glTexImage2D(struct OGLES2IFace *Self, GLenum target, GLint l
logLine("%s: %s: target 0x%X (%s), level %d, internalformat 0x%X (%s), width %u, height %u, border %d, format 0x%X (%s), type 0x%X (%s), pixels %p", context->name, __func__,
target, decodeValue(target),
level,
internalformat, decodeValue(internalformat),
internalformat, decodeValue((GLenum)internalformat),
width, height, border,
format, decodeValue(format),
type, decodeValue(type),
Expand Down Expand Up @@ -3068,7 +3068,7 @@ static void OGLES2_glTexParameteri(struct OGLES2IFace *Self, GLenum target, GLen
logLine("%s: %s: target 0x%X (%s), pname 0x%X (%s), param 0x%X (%s)", context->name, __func__,
target, decodeValue(target),
pname, decodeValue(pname),
param, decodeValue(param));
param, decodeValue((GLenum)param));

GL_CALL(TexParameteri, target, pname, param)
}
Expand Down
16 changes: 8 additions & 8 deletions profiling.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,40 +31,40 @@ void primitiveStats(const PrimitiveCounter* const counter, const double seconds,
return;
}

logAlways(" Total vertices %llu. %.1f vertices/s, %.1f vertices/call, consisting of:", total, total / seconds, total / drawcalls);
logAlways(" Total vertices %llu. %.1f vertices/s, %.1f vertices/call, consisting of:", total, (double)total / seconds, (double)total / drawcalls);

if (counter->triangles) {
logAlways(" - Triangle vertices %llu. %.1f verts/s, %.1f verts/call", counter->triangles,
counter->triangles / seconds, counter->triangles / drawcalls);
(double)counter->triangles / seconds, (double)counter->triangles / drawcalls);
}

if (counter->triangleStrips) {
logAlways(" - Triangle strip vertices %llu. %.1f verts/s, %.1f verts/call", counter->triangleStrips,
counter->triangleStrips / seconds, counter->triangleStrips / drawcalls);
(double)counter->triangleStrips / seconds, (double)counter->triangleStrips / drawcalls);
}

if (counter->triangleFans) {
logAlways(" - Triangle fan vertices %llu. %.1f verts/s, %.1f verts/call", counter->triangleFans,
counter->triangleFans / seconds, counter->triangleFans / drawcalls);
(double)counter->triangleFans / seconds, (double)counter->triangleFans / drawcalls);
}

if (counter->lines) {
logAlways(" - Line vertices %llu. %.1f verts/s, %.1f verts/call", counter->lines,
counter->lines / seconds, counter->lines / drawcalls);
(double)counter->lines / seconds, (double)counter->lines / drawcalls);
}

if (counter->lineStrips) {
logAlways(" - Line strip vertices %llu. %.1f verts/s, %.1f verts/call", counter->lineStrips,
counter->lineStrips / seconds, counter->lineStrips / drawcalls);
(double)counter->lineStrips / seconds, (double)counter->lineStrips / drawcalls);
}

if (counter->lineLoops) {
logAlways(" - Line loop vertices %llu. %.1f verts/s, %.1f verts/call", counter->lineLoops,
counter->lineLoops / seconds, counter->lineLoops / drawcalls);
(double)counter->lineLoops / seconds, (double)counter->lineLoops / drawcalls);
}

if (counter->points) {
logAlways(" - Point vertices %llu. %.1f verts/s, %.1f verts/call", counter->points,
counter->points / seconds, counter->points / drawcalls);
(double)counter->points / seconds, (double)counter->points / drawcalls);
}
}
2 changes: 1 addition & 1 deletion profiling.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ typedef struct PrimitiveCounter {
snprintf(timeUsedBuffer, sizeof(timeUsedBuffer), "%% of %.6f ms", timeUsed); \
logAlways(" Function calls used %.6f ms, %.2f %% of context life-time %.6f ms", \
timeUsed, \
(double)context->ticks * 100.0 / totalTicks, \
(double)context->ticks * 100.0 / (double)totalTicks, \
timer_ticks_to_ms(totalTicks));

int tickComparison(const void* first, const void* second);
Expand Down
2 changes: 1 addition & 1 deletion timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ BOOL timer_init(TimerContext * tc)
goto out;
}

tc->device = IExec->OpenDevice(TIMERNAME, UNIT_WAITUNTIL,
tc->device = (BYTE)IExec->OpenDevice(TIMERNAME, UNIT_WAITUNTIL,
(struct IORequest *) tc->request, 0);

if (tc->device) {
Expand Down
8 changes: 4 additions & 4 deletions warp3dnova_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ static void profileResults(struct NovaContext* const context)

PROF_FINISH_CONTEXT

const double drawcalls = context->profiling[DrawElements].callCount + context->profiling[DrawArrays].callCount;
const double drawcalls = (double)(context->profiling[DrawElements].callCount + context->profiling[DrawArrays].callCount);

// Copy items, otherwise sorthing will ruin the further profiling
ProfilingItem stats[NovaFunctionCount];
Expand All @@ -1326,9 +1326,9 @@ static void profileResults(struct NovaContext* const context)
stats[i].errors,
stats[i].nullptrs,
timer_ticks_to_ms(stats[i].ticks),
timer_ticks_to_us(stats[i].ticks) / stats[i].callCount,
(double)stats[i].ticks * 100.0 / context->ticks,
(double)stats[i].ticks * 100.0 / totalTicks);
timer_ticks_to_us(stats[i].ticks) / (double)stats[i].callCount,
(double)stats[i].ticks * 100.0 / (double)context->ticks,
(double)stats[i].ticks * 100.0 / (double)totalTicks);
}
}

Expand Down

0 comments on commit 4b0cc83

Please sign in to comment.