Skip to content

Commit

Permalink
Global: silence warnings when building in 32bit environments
Browse files Browse the repository at this point in the history
  • Loading branch information
CarterLi committed Jan 17, 2024
1 parent d0d9831 commit c749f21
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/common/format.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static inline uint32_t getArgumentIndex(const FFstrbuf* placeholderValue)
uint32_t result = UINT32_MAX;

if(placeholderValue->chars[0] != '-')
sscanf(placeholderValue->chars, "%u", &result);
sscanf(placeholderValue->chars, "%" PRIu32, &result);

return result == 0 ? UINT32_MAX : result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/common/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ static inline void ffTimeSleep(uint32_t msec)
#ifdef _WIN32
SleepEx(msec, TRUE);
#else
nanosleep(&(struct timespec){ msec / 1000, (msec % 1000) * 1000000 }, NULL);
nanosleep(&(struct timespec){ msec / 1000, (long) (msec % 1000) * 1000000 }, NULL);
#endif
}
3 changes: 2 additions & 1 deletion src/detection/diskio/diskio_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <ctype.h>
#include <limits.h>
#include <inttypes.h>

const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
{
Expand Down Expand Up @@ -89,7 +90,7 @@ const char* ffDiskIOGetIoCounters(FFlist* result, FFDiskIOOptions* options)
ssize_t fileSize = ffReadFileData(pathSysBlock, sizeof(sysBlockStat) - 1, sysBlockStat);
if (fileSize <= 0) continue;
sysBlockStat[fileSize] = '\0';
if (sscanf(sysBlockStat, "%lu%*u%lu%*u%lu%*u%lu%*u", &nRead, &sectorRead, &nWritten, &sectorWritten) <= 0)
if (sscanf(sysBlockStat, "%" PRIu64 "%*u%" PRIu64 "%*u%" PRIu64 "%*u%" PRIu64 "%*u", &nRead, &sectorRead, &nWritten, &sectorWritten) <= 0)
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion src/detection/displayserver/linux/drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static const char* drmParseSysfs(FFDisplayServerResult* result)
continue;
}

uint32_t width = 0, height = 0;
unsigned width = 0, height = 0;

int scanned = sscanf(modes, "%ux%u", &width, &height);
if(scanned == 2 && width > 0 && height > 0)
Expand Down
2 changes: 1 addition & 1 deletion src/detection/gpu/gpu_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*

// See: https://download.nvidia.com/XFree86/Linux-x86_64/545.23.06/README/supportedchips.html
// displayDevice.DeviceID = MatchingDeviceId "PCI\\VEN_10DE&DEV_2782&SUBSYS_513417AA&REV_A1"
uint32_t vendorId = 0, deviceId = 0, subSystemId = 0, revId = 0;
unsigned vendorId = 0, deviceId = 0, subSystemId = 0, revId = 0;
swscanf(displayDevice.DeviceID, L"PCI\\VEN_%x&DEV_%x&SUBSYS_%x&REV_%x", &vendorId, &deviceId, &subSystemId, &revId);

FFGPUResult* gpu = (FFGPUResult*)ffListAdd(gpus);
Expand Down
1 change: 1 addition & 0 deletions src/detection/terminalshell/terminalshell_linux.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ static const char* getProcessNameAndPpid(pid_t pid, char* name, pid_t* ppid)
buf[nRead] = '\0';

*ppid = 0;
static_assert(sizeof(*ppid) == sizeof(int), "");
if(
sscanf(buf, "%*s (%255[^)]) %*c %d", name, ppid) != 2 || //stat (comm) state ppid
!ffStrSet(name) ||
Expand Down

0 comments on commit c749f21

Please sign in to comment.