Unverified Commit d868be90 authored by Nicolas Hug's avatar Nicolas Hug Committed by GitHub
Browse files

[FBcode->GH] [codemod] Use `nullptr` intead of NULL (#8335)


Co-authored-by: default avatarRichard Barnes <rbarnes@meta.com>
parent 18a1d411
...@@ -59,7 +59,7 @@ void Decoder::release() { ...@@ -59,7 +59,7 @@ void Decoder::release() {
if (decoder) { if (decoder) {
cuvidDestroyDecoder(decoder); cuvidDestroyDecoder(decoder);
} }
cuCtxPopCurrent(NULL); cuCtxPopCurrent(nullptr);
} }
/* Trigger video decoding. /* Trigger video decoding.
...@@ -100,7 +100,7 @@ int Decoder::handle_picture_decode(CUVIDPICPARAMS* pic_params) { ...@@ -100,7 +100,7 @@ int Decoder::handle_picture_decode(CUVIDPICPARAMS* pic_params) {
check_for_cuda_errors(cuCtxPushCurrent(cu_context), __LINE__, __FILE__); check_for_cuda_errors(cuCtxPushCurrent(cu_context), __LINE__, __FILE__);
check_for_cuda_errors( check_for_cuda_errors(
cuvidDecodePicture(decoder, pic_params), __LINE__, __FILE__); cuvidDecodePicture(decoder, pic_params), __LINE__, __FILE__);
check_for_cuda_errors(cuCtxPopCurrent(NULL), __LINE__, __FILE__); check_for_cuda_errors(cuCtxPopCurrent(nullptr), __LINE__, __FILE__);
return 1; return 1;
} }
...@@ -159,7 +159,7 @@ int Decoder::handle_picture_display(CUVIDPARSERDISPINFO* disp_info) { ...@@ -159,7 +159,7 @@ int Decoder::handle_picture_display(CUVIDPARSERDISPINFO* disp_info) {
check_for_cuda_errors(cuStreamSynchronize(cuvidStream), __LINE__, __FILE__); check_for_cuda_errors(cuStreamSynchronize(cuvidStream), __LINE__, __FILE__);
decoded_frames.push(decoded_frame); decoded_frames.push(decoded_frame);
check_for_cuda_errors(cuCtxPopCurrent(NULL), __LINE__, __FILE__); check_for_cuda_errors(cuCtxPopCurrent(nullptr), __LINE__, __FILE__);
check_for_cuda_errors( check_for_cuda_errors(
cuvidUnmapVideoFrame(decoder, source_frame), __LINE__, __FILE__); cuvidUnmapVideoFrame(decoder, source_frame), __LINE__, __FILE__);
...@@ -177,7 +177,7 @@ void Decoder::query_hardware(CUVIDEOFORMAT* video_format) { ...@@ -177,7 +177,7 @@ void Decoder::query_hardware(CUVIDEOFORMAT* video_format) {
check_for_cuda_errors(cuCtxPushCurrent(cu_context), __LINE__, __FILE__); check_for_cuda_errors(cuCtxPushCurrent(cu_context), __LINE__, __FILE__);
check_for_cuda_errors(cuvidGetDecoderCaps(&decode_caps), __LINE__, __FILE__); check_for_cuda_errors(cuvidGetDecoderCaps(&decode_caps), __LINE__, __FILE__);
check_for_cuda_errors(cuCtxPopCurrent(NULL), __LINE__, __FILE__); check_for_cuda_errors(cuCtxPopCurrent(nullptr), __LINE__, __FILE__);
if (!decode_caps.bIsSupported) { if (!decode_caps.bIsSupported) {
TORCH_CHECK(false, "Codec not supported on this GPU"); TORCH_CHECK(false, "Codec not supported on this GPU");
...@@ -319,7 +319,7 @@ int Decoder::handle_video_sequence(CUVIDEOFORMAT* video_format) { ...@@ -319,7 +319,7 @@ int Decoder::handle_video_sequence(CUVIDEOFORMAT* video_format) {
cuvidCreateDecoder(&decoder, &video_decode_create_info), cuvidCreateDecoder(&decoder, &video_decode_create_info),
__LINE__, __LINE__,
__FILE__); __FILE__);
check_for_cuda_errors(cuCtxPopCurrent(NULL), __LINE__, __FILE__); check_for_cuda_errors(cuCtxPopCurrent(nullptr), __LINE__, __FILE__);
return decode_surface; return decode_surface;
} }
...@@ -389,7 +389,7 @@ int Decoder::reconfigure_decoder(CUVIDEOFORMAT* video_format) { ...@@ -389,7 +389,7 @@ int Decoder::reconfigure_decoder(CUVIDEOFORMAT* video_format) {
check_for_cuda_errors(cuCtxPushCurrent(cu_context), __LINE__, __FILE__); check_for_cuda_errors(cuCtxPushCurrent(cu_context), __LINE__, __FILE__);
check_for_cuda_errors( check_for_cuda_errors(
cuvidReconfigureDecoder(decoder, &reconfig_params), __LINE__, __FILE__); cuvidReconfigureDecoder(decoder, &reconfig_params), __LINE__, __FILE__);
check_for_cuda_errors(cuCtxPopCurrent(NULL), __LINE__, __FILE__); check_for_cuda_errors(cuCtxPopCurrent(nullptr), __LINE__, __FILE__);
return decode_surface; return decode_surface;
} }
......
...@@ -71,7 +71,7 @@ torch::Tensor encode_png(const torch::Tensor& data, int64_t compression_level) { ...@@ -71,7 +71,7 @@ torch::Tensor encode_png(const torch::Tensor& data, int64_t compression_level) {
// Define output buffer // Define output buffer
struct torch_mem_encode buf_info; struct torch_mem_encode buf_info;
buf_info.buffer = NULL; buf_info.buffer = nullptr;
buf_info.size = 0; buf_info.size = 0;
/* Establish the setjmp return context for my_error_exit to use. */ /* Establish the setjmp return context for my_error_exit to use. */
...@@ -79,15 +79,15 @@ torch::Tensor encode_png(const torch::Tensor& data, int64_t compression_level) { ...@@ -79,15 +79,15 @@ torch::Tensor encode_png(const torch::Tensor& data, int64_t compression_level) {
/* If we get here, the PNG code has signaled an error. /* If we get here, the PNG code has signaled an error.
* We need to clean up the PNG object and the buffer. * We need to clean up the PNG object and the buffer.
*/ */
if (info_ptr != NULL) { if (info_ptr != nullptr) {
png_destroy_info_struct(png_write, &info_ptr); png_destroy_info_struct(png_write, &info_ptr);
} }
if (png_write != NULL) { if (png_write != nullptr) {
png_destroy_write_struct(&png_write, NULL); png_destroy_write_struct(&png_write, nullptr);
} }
if (buf_info.buffer != NULL) { if (buf_info.buffer != nullptr) {
free(buf_info.buffer); free(buf_info.buffer);
} }
...@@ -121,12 +121,12 @@ torch::Tensor encode_png(const torch::Tensor& data, int64_t compression_level) { ...@@ -121,12 +121,12 @@ torch::Tensor encode_png(const torch::Tensor& data, int64_t compression_level) {
// Initialize PNG structures // Initialize PNG structures
png_write = png_create_write_struct( png_write = png_create_write_struct(
PNG_LIBPNG_VER_STRING, &err_ptr, torch_png_error, NULL); PNG_LIBPNG_VER_STRING, &err_ptr, torch_png_error, nullptr);
info_ptr = png_create_info_struct(png_write); info_ptr = png_create_info_struct(png_write);
// Define custom buffer output // Define custom buffer output
png_set_write_fn(png_write, &buf_info, torch_png_write_data, NULL); png_set_write_fn(png_write, &buf_info, torch_png_write_data, nullptr);
// Set output image information // Set output image information
auto color_type = channels == 1 ? PNG_COLOR_TYPE_GRAY : PNG_COLOR_TYPE_RGB; auto color_type = channels == 1 ? PNG_COLOR_TYPE_GRAY : PNG_COLOR_TYPE_RGB;
......
...@@ -17,7 +17,7 @@ std::wstring utf8_decode(const std::string& str) { ...@@ -17,7 +17,7 @@ std::wstring utf8_decode(const std::string& str) {
return std::wstring(); return std::wstring();
} }
int size_needed = MultiByteToWideChar( int size_needed = MultiByteToWideChar(
CP_UTF8, 0, str.c_str(), static_cast<int>(str.size()), NULL, 0); CP_UTF8, 0, str.c_str(), static_cast<int>(str.size()), nullptr, 0);
TORCH_CHECK(size_needed > 0, "Error converting the content to Unicode"); TORCH_CHECK(size_needed > 0, "Error converting the content to Unicode");
std::wstring wstrTo(size_needed, 0); std::wstring wstrTo(size_needed, 0);
MultiByteToWideChar( MultiByteToWideChar(
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#ifdef _WIN32 #ifdef _WIN32
PyMODINIT_FUNC PyInit_image(void) { PyMODINIT_FUNC PyInit_image(void) {
// No need to do anything. // No need to do anything.
return NULL; return nullptr;
} }
#endif #endif
#endif // USE_PYTHON #endif // USE_PYTHON
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#ifdef _WIN32 #ifdef _WIN32
PyMODINIT_FUNC PyInit_video_reader(void) { PyMODINIT_FUNC PyInit_video_reader(void) {
// No need to do anything. // No need to do anything.
return NULL; return nullptr;
} }
#endif #endif
#endif // USE_PYTHONs #endif // USE_PYTHONs
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
#ifdef USE_PYTHON #ifdef USE_PYTHON
PyMODINIT_FUNC PyInit__C(void) { PyMODINIT_FUNC PyInit__C(void) {
// No need to do anything. // No need to do anything.
return NULL; return nullptr;
} }
#endif // USE_PYTHON #endif // USE_PYTHON
#endif // !defined(MOBILE) && defined(_WIN32) #endif // !defined(MOBILE) && defined(_WIN32)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment