Skip to content

Commit 9d6a79c

Browse files
cyyeverhenryiii
authored andcommitted
fix: issuses detected by static analyzer (#4440)
* fix incorrect variable check * remove duplicated check * remove unneeded const cast
1 parent 050de89 commit 9d6a79c

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

include/pybind11/attr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ struct process_attribute<doc> : process_attribute_default<doc> {
399399
template <>
400400
struct process_attribute<const char *> : process_attribute_default<const char *> {
401401
static void init(const char *d, function_record *r) { r->doc = const_cast<char *>(d); }
402-
static void init(const char *d, type_record *r) { r->doc = const_cast<char *>(d); }
402+
static void init(const char *d, type_record *r) { r->doc = d; }
403403
};
404404
template <>
405405
struct process_attribute<char *> : process_attribute<const char *> {};

include/pybind11/eigen/tensor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ struct type_caster<Type, typename eigen_tensor_helper<Type>::ValidType> {
176176
return false;
177177
}
178178

179-
if (!convert && !temp.dtype().is(dtype::of<typename Type::Scalar>())) {
179+
if (!temp.dtype().is(dtype::of<typename Type::Scalar>())) {
180180
return false;
181181
}
182182
}

include/pybind11/pytypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ struct error_fetch_and_normalize {
501501
"active exception.");
502502
}
503503
const char *exc_type_name_norm = detail::obj_class_name(m_type.ptr());
504-
if (exc_type_name_orig == nullptr) {
504+
if (exc_type_name_norm == nullptr) {
505505
pybind11_fail("Internal error: " + std::string(called)
506506
+ " failed to obtain the name "
507507
"of the normalized active exception type.");

0 commit comments

Comments
 (0)