Skip to content

Commit

Permalink
Minor refactoring based on static analysis on the code of images: (py…
Browse files Browse the repository at this point in the history
…torch#2891)

- Replace deprecated string.h with cstring.
- Switch to nullptr.
  • Loading branch information
datumbox authored and bryant1410 committed Nov 22, 2020
1 parent 24337cb commit a1dada2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion torchvision/csrc/cpu/image/read_image_cpu.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "read_image_cpu.h"
#include <string.h>
#include <cstring>

torch::Tensor decode_image(const torch::Tensor& data) {
// Check that the input tensor dtype is uint8
Expand Down
2 changes: 1 addition & 1 deletion torchvision/csrc/cpu/image/read_write_file_cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void write_file(std::string filename, torch::Tensor& data) {
auto fileCStr = filename.c_str();
FILE* outfile = fopen(fileCStr, "wb");

TORCH_CHECK(outfile != NULL, "Error opening output file");
TORCH_CHECK(outfile != nullptr, "Error opening output file");

fwrite(fileBytes, sizeof(uint8_t), data.numel(), outfile);
fclose(outfile);
Expand Down

0 comments on commit a1dada2

Please sign in to comment.