mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
Added -Wconversion to compiler options
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif()
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wconversion")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "-Wl,-O3")
|
||||
|
||||
if(BUILD_TESTS)
|
||||
|
||||
+1
-1
@@ -430,7 +430,7 @@ void ffAppendFDContent(int fd, FFstrbuf* buffer)
|
||||
(readed = read(fd, buffer->chars + buffer->length, free)) > 0 &&
|
||||
(uint32_t) readed == free
|
||||
) {
|
||||
buffer->length += readed;
|
||||
buffer->length += (uint32_t) readed;
|
||||
ffStrbufEnsureCapacity(buffer, (buffer->allocated * 2) - 1); // -1 for null terminator
|
||||
free = ffStrbufGetFree(buffer);
|
||||
}
|
||||
|
||||
@@ -194,7 +194,7 @@ static void fontPangoParseWord(const char** data, FFfont* font, FFstrbuf* altern
|
||||
while(**data != ' ' && **data != '\t' && **data != ',' && **data != '\0' && **data != '`' && **data != '\\')
|
||||
++(*data);
|
||||
|
||||
uint32_t wordLength = *data - wordStart;
|
||||
uint32_t wordLength = (uint32_t) (*data - wordStart);
|
||||
if(wordLength == 0)
|
||||
return;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#define FF_BATTERY_MODULE_NAME "Battery"
|
||||
#define FF_BATTERY_NUM_FORMAT_ARGS 5
|
||||
|
||||
static void printBattery(FFinstance* instance, FFstrbuf* dir, uint32_t index)
|
||||
static void printBattery(FFinstance* instance, FFstrbuf* dir, uint8_t index)
|
||||
{
|
||||
uint32_t dirLength = dir->length;
|
||||
|
||||
@@ -147,7 +147,7 @@ void ffPrintBattery(FFinstance* instance)
|
||||
return;
|
||||
}
|
||||
|
||||
for(uint32_t i = 0; i < dirs.length; i++)
|
||||
for(uint8_t i = 0; i < dirs.length; i++)
|
||||
{
|
||||
FFstrbuf* name = ffListGet(&dirs, i);
|
||||
ffStrbufAppend(&baseDir, name);
|
||||
|
||||
+4
-4
@@ -26,12 +26,12 @@ static void printStatvfs(FFinstance* instance, FFstrbuf* key, struct statvfs* fs
|
||||
{
|
||||
const uint32_t GB = 1024 * 1024 * 1024;
|
||||
|
||||
uint32_t total = (fs->f_blocks * fs->f_frsize) / GB;
|
||||
uint32_t available = (fs->f_bfree * fs->f_frsize) / GB;
|
||||
uint32_t total = ((uint32_t) (fs->f_blocks * fs->f_frsize)) / GB;
|
||||
uint32_t available = ((uint32_t) (fs->f_bfree * fs->f_frsize)) / GB;
|
||||
uint32_t used = total - available;
|
||||
uint8_t percentage = (used / (double) total) * 100.0;
|
||||
uint8_t percentage = (uint8_t) ((used / (double) total) * 100.0);
|
||||
|
||||
uint32_t files = fs->f_files - fs->f_ffree;
|
||||
uint32_t files = (uint32_t) (fs->f_files - fs->f_ffree);
|
||||
|
||||
if(instance->config.diskFormat.length == 0)
|
||||
{
|
||||
|
||||
+3
-3
@@ -123,11 +123,11 @@ static void pciFillGPUs(FFinstance* instance, FFlist* results)
|
||||
GPUResult* result = ffListAdd(results);
|
||||
|
||||
ffStrbufInitA(&result->vendor, 256);
|
||||
ffpci_lookup_name(pacc, result->vendor.chars, result->vendor.allocated -1, PCI_LOOKUP_VENDOR, dev->vendor_id, dev->device_id);
|
||||
ffpci_lookup_name(pacc, result->vendor.chars, (int) result->vendor.allocated -1, PCI_LOOKUP_VENDOR, dev->vendor_id, dev->device_id);
|
||||
ffStrbufRecalculateLength(&result->vendor);
|
||||
|
||||
ffStrbufInitA(&result->name, 256);
|
||||
ffpci_lookup_name(pacc, result->name.chars, result->name.allocated - 1, PCI_LOOKUP_DEVICE, dev->vendor_id, dev->device_id);
|
||||
ffpci_lookup_name(pacc, result->name.chars, (int) result->name.allocated - 1, PCI_LOOKUP_DEVICE, dev->vendor_id, dev->device_id);
|
||||
ffStrbufRecalculateLength(&result->name);
|
||||
};
|
||||
}
|
||||
@@ -197,7 +197,7 @@ void ffPrintGPU(FFinstance* instance)
|
||||
vulkanFillGPUs(instance, &gpus);
|
||||
#endif
|
||||
|
||||
for(uint32_t i = 0; i < gpus.length; i++)
|
||||
for(uint8_t i = 0; i < gpus.length; i++)
|
||||
printGPUResult(instance, gpus.length == 1 ? 0 : i + 1, &cache, ffListGet(&gpus, i));
|
||||
|
||||
if(gpus.length == 0)
|
||||
|
||||
+18
-18
@@ -9,9 +9,9 @@
|
||||
|
||||
typedef struct ResolutionResult
|
||||
{
|
||||
int width;
|
||||
int height;
|
||||
int refreshRate;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t refreshRate;
|
||||
} ResolutionResult;
|
||||
|
||||
static bool printResolutionResultList(FFinstance* instance, FFlist* results)
|
||||
@@ -19,7 +19,7 @@ static bool printResolutionResultList(FFinstance* instance, FFlist* results)
|
||||
for(uint32_t i = 0; i < results->length; i++)
|
||||
{
|
||||
ResolutionResult* result = ffListGet(results, i);
|
||||
uint8_t moduleIndex = results->length == 1 ? 0 : i + 1;
|
||||
uint8_t moduleIndex = results->length == 1 ? 0 : (uint8_t) i + 1;
|
||||
|
||||
if(instance->config.resolutionFormat.length == 0)
|
||||
{
|
||||
@@ -108,7 +108,7 @@ static void printResolutionDRMBackend(FFinstance* instance)
|
||||
|
||||
#if defined(FF_HAVE_XRANDR) || defined(FF_HAVE_WAYLAND)
|
||||
|
||||
static int parseRefreshRate(int32_t refreshRate)
|
||||
static uint32_t parseRefreshRate(int32_t refreshRate)
|
||||
{
|
||||
if(refreshRate <= 0)
|
||||
return 0;
|
||||
@@ -123,7 +123,7 @@ static int parseRefreshRate(int32_t refreshRate)
|
||||
if(refreshRate == 145)
|
||||
refreshRate = 144;
|
||||
|
||||
return refreshRate;
|
||||
return (uint32_t) refreshRate;
|
||||
}
|
||||
|
||||
#endif //FF_HAVE_XRANDR || FF_HAVE_WAYLAND
|
||||
@@ -131,14 +131,14 @@ static int parseRefreshRate(int32_t refreshRate)
|
||||
#ifdef FF_HAVE_X11
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
static void x11AddScreenAsResult(FFlist* results, Screen* screen, int refreshRate)
|
||||
static void x11AddScreenAsResult(FFlist* results, Screen* screen, uint32_t refreshRate)
|
||||
{
|
||||
if(WidthOfScreen(screen) == 0 || HeightOfScreen(screen) == 0)
|
||||
return;
|
||||
|
||||
ResolutionResult* result = ffListAdd(results);
|
||||
result->width = WidthOfScreen(screen);
|
||||
result->height = HeightOfScreen(screen);
|
||||
result->width = (uint32_t) WidthOfScreen(screen);
|
||||
result->height = (uint32_t) HeightOfScreen(screen);
|
||||
result->refreshRate = refreshRate;
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ typedef struct XrandrData
|
||||
FFlist results;
|
||||
|
||||
//Init per screen
|
||||
int defaultRefreshRate;
|
||||
uint32_t defaultRefreshRate;
|
||||
XRRScreenResources* screenResources;
|
||||
} XrandrData;
|
||||
|
||||
@@ -222,7 +222,7 @@ static bool xrandrHandleOutputInfo(XrandrData* data, XRROutputInfo* outputInfo)
|
||||
ResolutionResult* result = ffListAdd(&data->results);
|
||||
result->width = modeInfo->width;
|
||||
result->height = modeInfo->height;
|
||||
result->refreshRate = parseRefreshRate(modeInfo->dotClock / (modeInfo->hTotal * modeInfo->vTotal));
|
||||
result->refreshRate = parseRefreshRate((int32_t) (modeInfo->dotClock / (modeInfo->hTotal * modeInfo->vTotal)));
|
||||
|
||||
if(result->refreshRate == 0)
|
||||
result->refreshRate = data->defaultRefreshRate;
|
||||
@@ -238,9 +238,9 @@ static bool xrandrHandleMonitorFallback(XrandrData* data, XRRMonitorInfo* monito
|
||||
return false;
|
||||
|
||||
ResolutionResult* result = ffListAdd(&data->results);
|
||||
result->width = monitorInfo->width;
|
||||
result->height = monitorInfo->height;
|
||||
result->refreshRate = data->defaultRefreshRate;
|
||||
result->width = (uint32_t) monitorInfo->width;
|
||||
result->height = (uint32_t) monitorInfo->height;
|
||||
result->refreshRate = (uint32_t) data->defaultRefreshRate;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ static void xrandrHandleScreen(XrandrData* data, Screen* screen)
|
||||
XRRScreenConfiguration* screenConfiguration = data->ffXRRGetScreenInfo(data->display, window);
|
||||
if(screenConfiguration != NULL)
|
||||
{
|
||||
data->defaultRefreshRate = (int) data->ffXRRConfigCurrentRate(screenConfiguration);
|
||||
data->defaultRefreshRate = (uint32_t) data->ffXRRConfigCurrentRate(screenConfiguration);
|
||||
data->ffXRRFreeScreenConfigInfo(screenConfiguration);
|
||||
}
|
||||
else
|
||||
@@ -402,7 +402,7 @@ static void waylandOutputModeListener(void* data, struct wl_output* output, uint
|
||||
|
||||
wldata->ffwl_proxy_destroy((struct wl_proxy*) output);
|
||||
|
||||
if(width == 0 || height == 0)
|
||||
if(width <= 0 || height <= 0)
|
||||
return;
|
||||
|
||||
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
@@ -412,8 +412,8 @@ static void waylandOutputModeListener(void* data, struct wl_output* output, uint
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
result->width = (int) width;
|
||||
result->height = (int) height;
|
||||
result->width = (uint32_t) width;
|
||||
result->height = (uint32_t) height;
|
||||
result->refreshRate = parseRefreshRate(refreshRate / 1000);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
|
||||
void ffPrintUptime(FFinstance* instance)
|
||||
{
|
||||
uint32_t days = instance->state.sysinfo.uptime / 86400;
|
||||
uint32_t hours = (instance->state.sysinfo.uptime - (days * 86400)) / 3600;
|
||||
uint32_t minutes = (instance->state.sysinfo.uptime - (days * 86400) - (hours * 3600)) / 60;
|
||||
uint32_t seconds = instance->state.sysinfo.uptime - (days * 86400) - (hours * 3600) - (minutes * 60);
|
||||
uint32_t days = (uint32_t) instance->state.sysinfo.uptime / 86400;
|
||||
uint32_t hours = (uint32_t) (instance->state.sysinfo.uptime - (days * 86400)) / 3600;
|
||||
uint32_t minutes = (uint32_t) (instance->state.sysinfo.uptime - (days * 86400) - (hours * 3600)) / 60;
|
||||
uint32_t seconds = (uint32_t) instance->state.sysinfo.uptime - (days * 86400) - (hours * 3600) - (minutes * 60);
|
||||
|
||||
if(instance->config.uptimeFormat.length == 0)
|
||||
{
|
||||
|
||||
+3
-3
@@ -201,7 +201,7 @@ void ffStrbufAppendTransformS(FFstrbuf* strbuf, const char* value, int(*transfor
|
||||
{
|
||||
if(i % 16 == 0)
|
||||
ffStrbufEnsureFree(strbuf, 16);
|
||||
strbuf->chars[strbuf->length++] = transformFunc(value[i]);
|
||||
strbuf->chars[strbuf->length++] = (char) transformFunc(value[i]);
|
||||
}
|
||||
strbuf->chars[strbuf->length] = '\0';
|
||||
}
|
||||
@@ -609,7 +609,7 @@ bool ffStrbufStartsWithIgnCaseNS(const FFstrbuf* strbuf, uint32_t length, const
|
||||
|
||||
bool ffStrbufEndsWithS(const FFstrbuf* strbuf, const char* end)
|
||||
{
|
||||
uint32_t endLength = strlen(end);
|
||||
uint32_t endLength = (uint32_t) strlen(end);
|
||||
|
||||
if(endLength > strbuf->length)
|
||||
return false;
|
||||
@@ -625,7 +625,7 @@ bool ffStrbufEndsWithS(const FFstrbuf* strbuf, const char* end)
|
||||
|
||||
static bool testEndsWithIgnCaseS(const FFstrbuf* strbuf, const char* end, uint32_t* endLength)
|
||||
{
|
||||
*endLength = strlen(end);
|
||||
*endLength = (uint32_t) strlen(end);
|
||||
|
||||
if(*endLength > strbuf->length)
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user