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

More of static analysis fixes #1496

Merged
merged 1 commit into from Nov 25, 2019
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 15 additions & 3 deletions dali/kernels/alloc.cc
Expand Up @@ -39,7 +39,11 @@ struct Allocator<AllocType::Host> {
template <>
struct Allocator<AllocType::Pinned> {
static void Deallocate(void *ptr, int device) noexcept {
DeviceGuard guard(device);
try {
DeviceGuard guard(device);
} catch (...) {
std::terminate();
}
cudaFreeHost(ptr);
}

Expand All @@ -53,7 +57,11 @@ struct Allocator<AllocType::Pinned> {
template <>
struct Allocator<AllocType::GPU> {
static void Deallocate(void *ptr, int device) noexcept {
DeviceGuard guard(device);
try {
DeviceGuard guard(device);
} catch (...) {
std::terminate();
}
cudaFree(ptr);
}

Expand All @@ -68,7 +76,11 @@ struct Allocator<AllocType::GPU> {
template <>
struct Allocator<AllocType::Unified> {
static void Deallocate(void *ptr, int device) noexcept {
DeviceGuard guard(device);
try {
DeviceGuard guard(device);
} catch (...) {
std::terminate();
}
cudaFree(ptr);
}

Expand Down
6 changes: 5 additions & 1 deletion dali/operators/decoder/cache/image_cache_blob.cc
Expand Up @@ -39,7 +39,11 @@ ImageCacheBlob::ImageCacheBlob(std::size_t cache_size,
}

ImageCacheBlob::~ImageCacheBlob() {
if (stats_enabled_ && images_seen() > 0) print_stats();
try {
if (stats_enabled_ && images_seen() > 0) print_stats();
} catch (...) {
std::terminate();
}
}

bool ImageCacheBlob::IsCached(const ImageKey& image_key) const {
Expand Down
1 change: 1 addition & 0 deletions dali/operators/reader/loader/video_loader.h
Expand Up @@ -137,6 +137,7 @@ class VideoLoader : public Loader<GPUBackend, SequenceWrapper> {
codec_id_(0),
skip_vfr_check_(spec.GetArgument<bool>("skip_vfr_check")),
stats_({0, 0, 0, 0, 0}),
current_frame_idx_(-1),
stop_(false) {
if (step_ < 0)
step_ = count_ * stride_;
Expand Down
6 changes: 5 additions & 1 deletion dali/operators/reader/nvdecoder/cuvideoparser.h
Expand Up @@ -94,7 +94,11 @@ class CUVideoParser {

~CUVideoParser() {
if (initialized_) {
NVCUVID_CALL(cuvidDestroyVideoParser(parser_));
try {
NVCUVID_CALL(cuvidDestroyVideoParser(parser_));
} catch (...) {
std::terminate();
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions dali/operators/reader/parser/tf_feature.h
Expand Up @@ -41,7 +41,7 @@ class Feature {
float float32;
};

Feature() {}
Feature() : has_shape_(false), type_(int64) {}

Feature(std::vector<Index> shape, FeatureType type, Value val) {
has_shape_ = true;
Expand Down Expand Up @@ -181,7 +181,7 @@ class Feature {

// default value
DaliProtoPriv value_arg = arg.extra_args(3);
TFUtil::Feature::Value val;
TFUtil::Feature::Value val = {};
switch (type) {
case TFUtil::FeatureType::int64:
val.int64 = value_arg.ints(0);
Expand Down
2 changes: 1 addition & 1 deletion dali/test/dali_test_config.cc
Expand Up @@ -45,7 +45,7 @@ const std::string &dali_extra_path() {
}
auto check_hash = "cd " + *_dali_extra_path + " ; git rev-parse HEAD";
constexpr int kHashLen = 40;
char hash[kHashLen + 1] = {0, };
char hash[kHashLen + 1] = {};
auto pipe = popen(check_hash.c_str(), "r");
if (pipe == NULL) {
std::cerr << "WARNING: Could not read the sha of DALI_extra at " << *_dali_extra_path
Expand Down
2 changes: 1 addition & 1 deletion dali/test/dali_test_info.h.in
Expand Up @@ -15,6 +15,6 @@
#ifndef DALI_TEST_DALI_TEST_INFO_H_
#define DALI_TEST_DALI_TEST_INFO_H_

#cmakedefine DALI_EXTRA_VERSION "@DALI_EXTRA_VERSION@"
#cmakedefine DALI_EXTRA_VERSION "@DALI_EXTRA_VERSION@\0"

#endif // DALI_TEST_DALI_TEST_INFO_H_
5 changes: 3 additions & 2 deletions dali/util/local_file.cc
Expand Up @@ -44,7 +44,7 @@ static int get_max_vm_cnt() {
#if !defined(__aarch64__)
size_t vm_cnt_sz = sizeof(vm_cnt);
int name[] = { CTL_VM, VM_MAX_MAP_COUNT };
struct __sysctl_args args = {0, };
struct __sysctl_args args = {};

args.name = name;
args.nlen = sizeof(name)/sizeof(name[0]);
Expand All @@ -57,12 +57,13 @@ static int get_max_vm_cnt() {
// fallback to reading /proc
FILE * fp;
int constexpr MAX_BUFF_SIZE = 256;
char buffer[MAX_BUFF_SIZE + 1] = {0, };
char buffer[MAX_BUFF_SIZE + 1];
fp = std::fopen("/proc/sys/vm/max_map_count", "r");
if (fp == nullptr) {
return vm_cnt;
}
auto elements_read = std::fread(buffer, 1, MAX_BUFF_SIZE, fp);
buffer[elements_read] = '\0';
std::fclose(fp);
if (!elements_read) {
return vm_cnt;
Expand Down