Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions torchvision/csrc/io/decoder/gpu/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void Decoder::release() {
if (decoder) {
cuvidDestroyDecoder(decoder);
}
cuCtxPopCurrent(NULL);
cuCtxPopCurrent(nullptr);
}

/* Trigger video decoding.
Expand Down Expand Up @@ -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(
cuvidDecodePicture(decoder, pic_params), __LINE__, __FILE__);
check_for_cuda_errors(cuCtxPopCurrent(NULL), __LINE__, __FILE__);
check_for_cuda_errors(cuCtxPopCurrent(nullptr), __LINE__, __FILE__);
return 1;
}

Expand Down Expand Up @@ -159,7 +159,7 @@ int Decoder::handle_picture_display(CUVIDPARSERDISPINFO* disp_info) {

check_for_cuda_errors(cuStreamSynchronize(cuvidStream), __LINE__, __FILE__);
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(
cuvidUnmapVideoFrame(decoder, source_frame), __LINE__, __FILE__);
Expand All @@ -177,7 +177,7 @@ void Decoder::query_hardware(CUVIDEOFORMAT* video_format) {

check_for_cuda_errors(cuCtxPushCurrent(cu_context), __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) {
TORCH_CHECK(false, "Codec not supported on this GPU");
Expand Down Expand Up @@ -319,7 +319,7 @@ int Decoder::handle_video_sequence(CUVIDEOFORMAT* video_format) {
cuvidCreateDecoder(&decoder, &video_decode_create_info),
__LINE__,
__FILE__);
check_for_cuda_errors(cuCtxPopCurrent(NULL), __LINE__, __FILE__);
check_for_cuda_errors(cuCtxPopCurrent(nullptr), __LINE__, __FILE__);
return decode_surface;
}

Expand Down Expand Up @@ -389,7 +389,7 @@ int Decoder::reconfigure_decoder(CUVIDEOFORMAT* video_format) {
check_for_cuda_errors(cuCtxPushCurrent(cu_context), __LINE__, __FILE__);
check_for_cuda_errors(
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;
}
Expand Down
14 changes: 7 additions & 7 deletions torchvision/csrc/io/image/cpu/encode_png.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,23 +71,23 @@ torch::Tensor encode_png(const torch::Tensor& data, int64_t compression_level) {

// Define output buffer
struct torch_mem_encode buf_info;
buf_info.buffer = NULL;
buf_info.buffer = nullptr;
buf_info.size = 0;

/* Establish the setjmp return context for my_error_exit to use. */
if (setjmp(err_ptr.setjmp_buffer)) {
/* If we get here, the PNG code has signaled an error.
* 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);
}

if (png_write != NULL) {
png_destroy_write_struct(&png_write, NULL);
if (png_write != nullptr) {
png_destroy_write_struct(&png_write, nullptr);
}

if (buf_info.buffer != NULL) {
if (buf_info.buffer != nullptr) {
free(buf_info.buffer);
}

Expand Down Expand Up @@ -121,12 +121,12 @@ torch::Tensor encode_png(const torch::Tensor& data, int64_t compression_level) {

// Initialize PNG structures
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);

// 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
auto color_type = channels == 1 ? PNG_COLOR_TYPE_GRAY : PNG_COLOR_TYPE_RGB;
Expand Down
2 changes: 1 addition & 1 deletion torchvision/csrc/io/image/cpu/read_write_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ std::wstring utf8_decode(const std::string& str) {
return std::wstring();
}
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");
std::wstring wstrTo(size_needed, 0);
MultiByteToWideChar(
Expand Down
2 changes: 1 addition & 1 deletion torchvision/csrc/io/image/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#ifdef _WIN32
PyMODINIT_FUNC PyInit_image(void) {
// No need to do anything.
return NULL;
return nullptr;
}
#endif
#endif // USE_PYTHON
Expand Down
2 changes: 1 addition & 1 deletion torchvision/csrc/io/video_reader/video_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#ifdef _WIN32
PyMODINIT_FUNC PyInit_video_reader(void) {
// No need to do anything.
return NULL;
return nullptr;
}
#endif
#endif // USE_PYTHONs
Expand Down
2 changes: 1 addition & 1 deletion torchvision/csrc/vision.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#ifdef USE_PYTHON
PyMODINIT_FUNC PyInit__C(void) {
// No need to do anything.
return NULL;
return nullptr;
}
#endif // USE_PYTHON
#endif // !defined(MOBILE) && defined(_WIN32)
Expand Down
Loading