mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-10-30 09:33:39 +01:00
Global: replaces NULL to nullptr
This commit is contained in:
@@ -25,7 +25,7 @@ FFLogoImageResult ffLogoPrintImageIM6(FFLogoRequestData* requestData) {
|
||||
.library = imageMagick,
|
||||
});
|
||||
|
||||
imageMagick = NULL; // leak imageMagick to prevent fastfetch from crashing #552
|
||||
imageMagick = nullptr; // leak imageMagick to prevent fastfetch from crashing #552
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ FFLogoImageResult ffLogoPrintImageIM7(FFLogoRequestData* requestData) {
|
||||
.library = imageMagick,
|
||||
});
|
||||
|
||||
imageMagick = NULL; // leak imageMagick to prevent fastfetch from crashing #552
|
||||
imageMagick = nullptr; // leak imageMagick to prevent fastfetch from crashing #552
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
+16
-16
@@ -156,7 +156,7 @@ static bool printImageKittyIcat(bool printError) {
|
||||
|
||||
uint32_t prevLength = buf.length;
|
||||
|
||||
const char* error = NULL;
|
||||
const char* error = nullptr;
|
||||
|
||||
if (options->width) {
|
||||
char place[64];
|
||||
@@ -176,7 +176,7 @@ static bool printImageKittyIcat(bool printError) {
|
||||
place,
|
||||
"--scale-up",
|
||||
options->source.chars,
|
||||
NULL,
|
||||
nullptr,
|
||||
});
|
||||
} else {
|
||||
error = ffProcessAppendStdOut(&buf, (char*[]) {
|
||||
@@ -185,7 +185,7 @@ static bool printImageKittyIcat(bool printError) {
|
||||
"-n",
|
||||
"--align=left",
|
||||
options->source.chars,
|
||||
NULL,
|
||||
nullptr,
|
||||
});
|
||||
}
|
||||
if (error) {
|
||||
@@ -374,7 +374,7 @@ static bool compressBlob(void** blob, size_t* length) {
|
||||
|
||||
uLong compressedLength = ffcompressBound(*length);
|
||||
void* compressed = malloc(compressedLength);
|
||||
if (compressed == NULL) {
|
||||
if (compressed == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -410,7 +410,7 @@ typedef struct ImageData {
|
||||
} ImageData;
|
||||
|
||||
static inline bool checkAllocationResult(void* data, size_t length) {
|
||||
if (data == NULL) {
|
||||
if (data == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -578,7 +578,7 @@ static bool printImageChafa(FFLogoRequestData* requestData, const ImageData* ima
|
||||
}
|
||||
|
||||
ChafaSymbolMap* symbolMap = ffchafa_symbol_map_new();
|
||||
GError* error = NULL;
|
||||
GError* error = nullptr;
|
||||
if (!ffchafa_symbol_map_apply_selectors(symbolMap, instance.config.logo.chafaSymbols.chars, &error)) {
|
||||
fputs(error->message, stderr);
|
||||
}
|
||||
@@ -621,7 +621,7 @@ static bool printImageChafa(FFLogoRequestData* requestData, const ImageData* ima
|
||||
(gint) imageData->image->rows,
|
||||
(gint) imageData->image->columns * 4);
|
||||
|
||||
GString* str = ffchafa_canvas_print(canvas, NULL);
|
||||
GString* str = ffchafa_canvas_print(canvas, nullptr);
|
||||
FFstrbuf result;
|
||||
result.allocated = (uint32_t) str->allocated_len;
|
||||
result.length = (uint32_t) str->len;
|
||||
@@ -666,16 +666,16 @@ FFLogoImageResult ffLogoPrintImageImpl(FFLogoRequestData* requestData, const FFI
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(imData->library, imageData, ImageToBlob, FF_LOGO_IMAGE_RESULT_INIT_ERROR)
|
||||
FF_LIBRARY_LOAD_SYMBOL_VAR(imData->library, imageData, Base64Encode, FF_LOGO_IMAGE_RESULT_INIT_ERROR)
|
||||
|
||||
ffMagickCoreGenesis(NULL, MagickFalse);
|
||||
ffMagickCoreGenesis(nullptr, MagickFalse);
|
||||
|
||||
imageData.exceptionInfo = ffAcquireExceptionInfo();
|
||||
if (imageData.exceptionInfo == NULL) {
|
||||
if (imageData.exceptionInfo == nullptr) {
|
||||
ffMagickCoreTerminus();
|
||||
return FF_LOGO_IMAGE_RESULT_RUN_ERROR;
|
||||
}
|
||||
|
||||
ImageInfo* imageInfoIn = ffAcquireImageInfo();
|
||||
if (imageInfoIn == NULL) {
|
||||
if (imageInfoIn == nullptr) {
|
||||
ffDestroyExceptionInfo(imageData.exceptionInfo);
|
||||
ffMagickCoreTerminus();
|
||||
return FF_LOGO_IMAGE_RESULT_RUN_ERROR;
|
||||
@@ -686,7 +686,7 @@ FFLogoImageResult ffLogoPrintImageImpl(FFLogoRequestData* requestData, const FFI
|
||||
|
||||
imageData.image = ffReadImage(imageInfoIn, imageData.exceptionInfo);
|
||||
ffDestroyImageInfo(imageInfoIn);
|
||||
if (imageData.image == NULL) {
|
||||
if (imageData.image == nullptr) {
|
||||
ffDestroyExceptionInfo(imageData.exceptionInfo);
|
||||
ffMagickCoreTerminus();
|
||||
return FF_LOGO_IMAGE_RESULT_RUN_ERROR;
|
||||
@@ -713,7 +713,7 @@ FFLogoImageResult ffLogoPrintImageImpl(FFLogoRequestData* requestData, const FFI
|
||||
|
||||
Image* resized = imData->resizeFunc(imageData.image, requestData->logoPixelWidth, requestData->logoPixelHeight, imageData.exceptionInfo);
|
||||
ffDestroyImage(imageData.image);
|
||||
if (resized == NULL) {
|
||||
if (resized == nullptr) {
|
||||
ffDestroyExceptionInfo(imageData.exceptionInfo);
|
||||
ffMagickCoreTerminus();
|
||||
return FF_LOGO_IMAGE_RESULT_RUN_ERROR;
|
||||
@@ -721,7 +721,7 @@ FFLogoImageResult ffLogoPrintImageImpl(FFLogoRequestData* requestData, const FFI
|
||||
imageData.image = resized;
|
||||
|
||||
imageData.imageInfo = ffAcquireImageInfo();
|
||||
if (imageData.imageInfo == NULL) {
|
||||
if (imageData.imageInfo == nullptr) {
|
||||
ffDestroyImage(imageData.image);
|
||||
ffDestroyExceptionInfo(imageData.exceptionInfo);
|
||||
ffMagickCoreTerminus();
|
||||
@@ -757,7 +757,7 @@ static FFNativeFD getCacheFD(FFLogoRequestData* requestData, const char* fileNam
|
||||
#endif
|
||||
);
|
||||
#else
|
||||
HANDLE fd = CreateFileA(requestData->cacheDir.chars, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
HANDLE fd = CreateFileA(requestData->cacheDir.chars, GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
|
||||
#endif
|
||||
ffStrbufSubstrBefore(&requestData->cacheDir, cacheDirLength);
|
||||
return fd;
|
||||
@@ -843,7 +843,7 @@ static bool printCachedPixel(FFLogoRequestData* requestData) {
|
||||
struct stat st;
|
||||
if (fstat(fd, &st) >= 0) {
|
||||
while (st.st_size > 0) {
|
||||
ssize_t bytes = sendfile(STDOUT_FILENO, fd, NULL, (size_t) st.st_size);
|
||||
ssize_t bytes = sendfile(STDOUT_FILENO, fd, nullptr, (size_t) st.st_size);
|
||||
if (bytes > 0) {
|
||||
sent = true;
|
||||
st.st_size -= bytes;
|
||||
@@ -921,7 +921,7 @@ static bool printImageIfExistsSlowPath(FFLogoType type, bool printError) {
|
||||
|
||||
ffStrbufEnsureFree(&requestData.cacheDir, PATH_MAX);
|
||||
char* filePath = requestData.cacheDir.chars + requestData.cacheDir.length;
|
||||
if (realpath(instance.config.logo.source.chars, filePath) == NULL) {
|
||||
if (realpath(instance.config.logo.source.chars, filePath) == nullptr) {
|
||||
// We can safely return here, because if realpath failed, we surely won't be able to read the file
|
||||
ffStrbufDestroy(&requestData.cacheDir);
|
||||
if (printError) {
|
||||
|
||||
+14
-14
@@ -56,7 +56,7 @@ static void logoLineCacheBuild(FFLogoLineCacheState* cache, const char* data, bo
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < options->paddingTop; ++i) {
|
||||
logoLineCachePush(NULL, 0, cache);
|
||||
logoLineCachePush(nullptr, 0, cache);
|
||||
}
|
||||
|
||||
if (*data != '\0') {
|
||||
@@ -184,7 +184,7 @@ static void logoLineCacheBuild(FFLogoLineCacheState* cache, const char* data, bo
|
||||
|
||||
uint32_t totalLines = instance.state.logoHeight + 1;
|
||||
while (cache->lines.length < totalLines) {
|
||||
logoLineCachePush(NULL, 0, cache);
|
||||
logoLineCachePush(nullptr, 0, cache);
|
||||
}
|
||||
|
||||
cache->nextLine = 0;
|
||||
@@ -298,7 +298,7 @@ static void logoApplyColors(const FFlogo* logo, bool replacement) {
|
||||
FFOptionsLogo* options = &instance.config.logo;
|
||||
|
||||
const char* const* colors = logo->colors;
|
||||
for (int i = 0; *colors != NULL && i < FASTFETCH_LOGO_MAX_COLORS; i++, colors++) {
|
||||
for (int i = 0; *colors != nullptr && i < FASTFETCH_LOGO_MAX_COLORS; i++, colors++) {
|
||||
if (options->colors[i].length == 0) {
|
||||
ffStrbufAppendS(&options->colors[i], *colors);
|
||||
}
|
||||
@@ -309,7 +309,7 @@ static void logoApplyColors(const FFlogo* logo, bool replacement) {
|
||||
static bool logoHasName(const FFlogo* logo, const FFstrbuf* name, bool small) {
|
||||
for (
|
||||
const char* const* logoName = logo->names;
|
||||
*logoName != NULL && logoName <= &logo->names[FASTFETCH_LOGO_MAX_NAMES];
|
||||
*logoName != nullptr && logoName <= &logo->names[FASTFETCH_LOGO_MAX_NAMES];
|
||||
++logoName) {
|
||||
if (small) {
|
||||
uint32_t logoNameLength = (uint32_t) (strlen(*logoName) - strlen("_small"));
|
||||
@@ -327,7 +327,7 @@ static bool logoHasName(const FFlogo* logo, const FFstrbuf* name, bool small) {
|
||||
|
||||
static const FFlogo* logoGetBuiltin(const FFstrbuf* name, FFLogoSize size) {
|
||||
if (name->length == 0 || !isalpha(name->chars[0])) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
for (const FFlogo* logo = ffLogoBuiltins[toupper(name->chars[0]) - 'A']; *logo->names; ++logo) {
|
||||
@@ -352,19 +352,19 @@ static const FFlogo* logoGetBuiltin(const FFstrbuf* name, FFLogoSize size) {
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static const FFlogo* logoGetBuiltinDetected(FFLogoSize size) {
|
||||
const FFOSResult* os = ffDetectOS();
|
||||
|
||||
const FFlogo* logo = logoGetBuiltin(&os->id, size);
|
||||
if (logo != NULL) {
|
||||
if (logo != nullptr) {
|
||||
return logo;
|
||||
}
|
||||
|
||||
logo = logoGetBuiltin(&os->name, size);
|
||||
if (logo != NULL) {
|
||||
if (logo != nullptr) {
|
||||
return logo;
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ static const FFlogo* logoGetBuiltinDetected(FFLogoSize size) {
|
||||
start = end + 1, end = ffStrbufNextIndexC(&os->idLike, start, ' ')) {
|
||||
ffStrbufSetNS(&buf, end - start, os->idLike.chars + start);
|
||||
logo = logoGetBuiltin(&buf, size);
|
||||
if (logo != NULL) {
|
||||
if (logo != nullptr) {
|
||||
return logo;
|
||||
}
|
||||
|
||||
@@ -386,13 +386,13 @@ static const FFlogo* logoGetBuiltinDetected(FFLogoSize size) {
|
||||
}
|
||||
} else {
|
||||
logo = logoGetBuiltin(&os->idLike, size);
|
||||
if (logo != NULL) {
|
||||
if (logo != nullptr) {
|
||||
return logo;
|
||||
}
|
||||
}
|
||||
|
||||
logo = logoGetBuiltin(&instance.state.platform.sysinfo.name, size);
|
||||
if (logo != NULL) {
|
||||
if (logo != nullptr) {
|
||||
return logo;
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ static bool logoPrintBuiltinIfExists(const FFstrbuf* name, FFLogoSize size) {
|
||||
}
|
||||
|
||||
const FFlogo* logo = ffLogoGetBuiltinForName(name, size);
|
||||
if (logo == NULL) {
|
||||
if (logo == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -561,7 +561,7 @@ static bool logoTryKnownType(void) {
|
||||
"/bin/sh", "-c",
|
||||
#endif
|
||||
options->source.chars,
|
||||
NULL });
|
||||
nullptr });
|
||||
|
||||
if (error) {
|
||||
if (instance.config.display.showErrors) {
|
||||
@@ -786,7 +786,7 @@ void ffLogoBuiltinList(void) {
|
||||
|
||||
for (
|
||||
const char* const* names = logo->names;
|
||||
*names != NULL && names <= &logo->names[FASTFETCH_LOGO_MAX_NAMES];
|
||||
*names != nullptr && names <= &logo->names[FASTFETCH_LOGO_MAX_NAMES];
|
||||
++names) {
|
||||
printf("\"%s\" ", *names);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user