Global: replaces NULL to nullptr

This commit is contained in:
李通洲
2026-07-10 18:08:04 +08:00
parent 873454191f
commit ba18705d2e
387 changed files with 2411 additions and 2411 deletions
+2 -2
View File
@@ -11,7 +11,7 @@ const char* ffDetectDisks(FFDiskOptions* options, FFlist* disks) {
return error;
}
if (disks->length == 0) {
return NULL;
return nullptr;
}
// We need to sort the disks, so that we can detect, which disk a path resides on
@@ -27,7 +27,7 @@ const char* ffDetectDisks(FFDiskOptions* options, FFlist* disks) {
}
}
return NULL;
return nullptr;
}
#ifndef _WIN32
+6 -6
View File
@@ -51,7 +51,7 @@ static const char* detectFsLabel(struct statfs* fs, FFDisk* disk) {
ffStrbufSetS(&disk->name, str ? str + 1 : provider->lg_name);
}
return NULL;
return nullptr;
}
#else
static const char* detectFsLabel(FF_A_UNUSED struct statfs* fs, FF_A_UNUSED FFDisk* disk) {
@@ -127,14 +127,14 @@ static void detectFsInfo(struct statfs* fs, FFDisk* disk) {
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
#ifndef __NetBSD__
int size = getfsstat(NULL, 0, MNT_WAIT);
int size = getfsstat(nullptr, 0, MNT_WAIT);
if (size <= 0) {
return "getfsstat(NULL, 0, MNT_WAIT) failed";
return "getfsstat(nullptr, 0, MNT_WAIT) failed";
}
#else
int size = getvfsstat(NULL, 0, ST_WAIT);
int size = getvfsstat(nullptr, 0, ST_WAIT);
if (size <= 0) {
return "getvfsstat(NULL, 0, ST_WAIT) failed";
return "getvfsstat(nullptr, 0, ST_WAIT) failed";
}
#endif
@@ -210,5 +210,5 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
#endif
}
return NULL;
return nullptr;
}
+1 -1
View File
@@ -70,5 +70,5 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
disk->createTime = (uint64_t) crTime * 1000;
}
}
return NULL;
return nullptr;
}
+7 -7
View File
@@ -107,14 +107,14 @@ static bool isPhysicalDevice(const struct mntent* device) {
static void detectNameFromPath(FFDisk* disk, const struct stat* deviceStat, FFstrbuf* basePath) {
FF_AUTO_CLOSE_DIR DIR* dir = opendir(basePath->chars);
if (dir == NULL) {
if (dir == nullptr) {
return;
}
uint32_t basePathLength = basePath->length;
struct dirent* entry;
while ((entry = readdir(dir)) != NULL) {
while ((entry = readdir(dir)) != nullptr) {
if (entry->d_name[0] == '.') {
continue;
}
@@ -218,11 +218,11 @@ static bool isRemovable(FFDisk* currentDisk) {
snprintf(sysBlockPartition, ARRAY_SIZE(sysBlockPartition), "/sys/class/block/%s", currentDisk->mountFrom.chars + strlen("/dev/"));
char sysBlockVolume[PATH_MAX]; // /sys/devices/pci0000:00/0000:00:14.0/usb4/4-3/4-3:1.0/host0/target0:0:0/0:0:0:0/block/sda/sda1
if (realpath(sysBlockPartition, sysBlockVolume) == NULL) {
if (realpath(sysBlockPartition, sysBlockVolume) == nullptr) {
return false;
}
char* lastSlash = strrchr(sysBlockVolume, '/');
if (lastSlash == NULL) {
if (lastSlash == nullptr) {
return false;
}
strcpy(lastSlash + 1, "removable");
@@ -284,8 +284,8 @@ static void detectStats(FFDisk* disk) {
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
FILE* mountsFile = setmntent("/proc/mounts", "r");
if (mountsFile == NULL) {
return "setmntent(\"/proc/mounts\", \"r\") == NULL";
if (mountsFile == nullptr) {
return "setmntent(\"/proc/mounts\", \"r\") == nullptr";
}
struct mntent* device;
@@ -333,5 +333,5 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
endmntent(mountsFile);
return NULL;
return nullptr;
}
+3 -3
View File
@@ -107,8 +107,8 @@ static void detectStats(FFDisk* disk) {
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
FF_AUTO_CLOSE_FILE FILE* mountsFile = fopen(MNTTAB, "r");
if (mountsFile == NULL) {
return "fopen(\"" MNTTAB "\", \"r\") == NULL";
if (mountsFile == nullptr) {
return "fopen(\"" MNTTAB "\", \"r\") == nullptr";
}
struct mnttab device;
@@ -141,5 +141,5 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
detectStats(disk);
}
return NULL;
return nullptr;
}
+4 -4
View File
@@ -46,7 +46,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
continue;
}
FF_AUTO_CLOSE_FD HANDLE handle = CreateFileW(mountpointW, FILE_READ_ATTRIBUTES, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
FF_AUTO_CLOSE_FD HANDLE handle = CreateFileW(mountpointW, FILE_READ_ATTRIBUTES, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
if (handle == INVALID_HANDLE_VALUE) {
continue;
}
@@ -56,7 +56,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
alignas(FILE_FS_ATTRIBUTE_INFORMATION) uint8_t bufFsAttr[1024];
FILE_FS_ATTRIBUTE_INFORMATION* fsAttr = NT_SUCCESS(NtQueryVolumeInformationFile(handle, &iosb, bufFsAttr, sizeof(bufFsAttr), FileFsAttributeInformation))
? (FILE_FS_ATTRIBUTE_INFORMATION*) bufFsAttr
: NULL;
: nullptr;
FF_STRBUF_AUTO_DESTROY diskFileSystemBuf = ffStrbufCreate();
if (fsAttr) {
@@ -97,7 +97,7 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
alignas(FILE_FS_VOLUME_INFORMATION) uint8_t bufFsVolume[1024];
FILE_FS_VOLUME_INFORMATION* fsVolume = NT_SUCCESS(NtQueryVolumeInformationFile(handle, &iosb, bufFsVolume, sizeof(bufFsVolume), FileFsVolumeInformation))
? (FILE_FS_VOLUME_INFORMATION*) bufFsVolume
: NULL;
: nullptr;
if (fsVolume) {
if (fsVolume->VolumeLabelLength > 0) {
@@ -124,5 +124,5 @@ const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
}
}
return NULL;
return nullptr;
}