Cleanup: remove redundant null pointer checks

Based on the surrounding context these checks aren't needed.
This commit is contained in:
Campbell Barton
2024-04-01 22:10:28 +11:00
parent ace64dbf50
commit 7e5a712e58
10 changed files with 23 additions and 38 deletions

View File

@@ -457,9 +457,7 @@ static ImageGPUTextures image_get_gpu_texture(Image *ima,
if (GPU_mipmap_enabled()) {
GPU_texture_update_mipmap_chain(*tex);
if (ima) {
ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
}
ima->gpuflag |= IMA_GPU_MIPMAP_COMPLETE;
GPU_texture_mipmap_mode(*tex, true, true);
}
else {

View File

@@ -431,9 +431,7 @@ static void layer_aov_copy_data(ViewLayer *view_layer_dst,
ListBase *aovs_dst,
const ListBase *aovs_src)
{
if (aovs_src != nullptr) {
BLI_duplicatelist(aovs_dst, aovs_src);
}
BLI_duplicatelist(aovs_dst, aovs_src);
ViewLayerAOV *aov_dst = static_cast<ViewLayerAOV *>(aovs_dst->first);
const ViewLayerAOV *aov_src = static_cast<const ViewLayerAOV *>(aovs_src->first);

View File

@@ -76,7 +76,7 @@ PassMain::Sub &MeshPass::get_subpass(
sub_pass->bind_texture(WB_TEXTURE_SLOT, gputex.texture, sampler_state);
}
sub_pass->push_constant("isImageTile", gputex.tile_mapping != nullptr);
sub_pass->push_constant("imagePremult", image && image->alpha_mode == IMA_ALPHA_PREMUL);
sub_pass->push_constant("imagePremult", image->alpha_mode == IMA_ALPHA_PREMUL);
/* TODO(@pragma37): This setting should be exposed on the user side,
* either as a global parameter (and set it here)
* or by reading the Material Clipping Threshold (and set it per material) */

View File

@@ -2275,7 +2275,7 @@ void uiItemFullR(uiLayout *layout,
char str[2] = {'\0'};
for (int a = 0; a < len; a++) {
str[0] = RNA_property_array_item_char(prop, a);
const bool use_prefix = (a == 0 && name && name[0]);
const bool use_prefix = (a == 0 && name[0]);
if (use_prefix) {
char *s = name_with_suffix;
s += STRNCPY_RLEN(name_with_suffix, name);
@@ -2302,14 +2302,11 @@ void uiItemFullR(uiLayout *layout,
}
}
else {
if (name) {
but = uiDefBut(
block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, nullptr, 0.0, 0.0, "");
but->drawflag |= UI_BUT_TEXT_RIGHT;
but->drawflag &= ~UI_BUT_TEXT_LEFT;
but = uiDefBut(block, UI_BTYPE_LABEL, 0, name, 0, 0, w, UI_UNIT_Y, nullptr, 0.0, 0.0, "");
but->drawflag |= UI_BUT_TEXT_RIGHT;
but->drawflag &= ~UI_BUT_TEXT_LEFT;
label_added = true;
}
label_added = true;
}
if (!label_added && heading_layout) {

View File

@@ -3219,7 +3219,7 @@ void ED_region_panels_layout_ex(const bContext *C,
}
const int width = panel_draw_width_from_max_width_get(region, panel->type, max_panel_width);
if (panel && UI_panel_is_dragging(panel)) {
if (UI_panel_is_dragging(panel)) {
/* Prevent View2d.tot rectangle size changes while dragging panels. */
update_tot_size = false;
}

View File

@@ -596,7 +596,7 @@ static int file_select_exec(bContext *C, wmOperator *op)
int ret_val = OPERATOR_FINISHED;
const FileSelectParams *params = ED_fileselect_get_active_params(sfile);
if (sfile && params) {
if (params) {
int idx = params->highlight_file;
int numfiles = filelist_files_ensure(sfile->files);

View File

@@ -159,16 +159,14 @@ void GpencilIO::create_object_list()
}
else {
float zdepth = 0;
if (rv3d_) {
if (rv3d_->is_persp) {
zdepth = ED_view3d_calc_zfac(rv3d_, object_position);
}
else {
zdepth = -math::dot(camera_z_axis, object_position);
}
ObjectZ obz = {zdepth * -1.0f, object};
ob_list_.append(obz);
if (rv3d_->is_persp) {
zdepth = ED_view3d_calc_zfac(rv3d_, object_position);
}
else {
zdepth = -math::dot(camera_z_axis, object_position);
}
ObjectZ obz = {zdepth * -1.0f, object};
ob_list_.append(obz);
}
}
/* Sort list of objects from point of view. */

View File

@@ -452,9 +452,7 @@ static int rna_find_sdna_member(SDNA *sdna,
smember->offset = -1;
if (structnr == -1) {
if (offset) {
*offset = -1;
}
*offset = -1;
return 0;
}
@@ -506,16 +504,14 @@ static int rna_find_sdna_member(SDNA *sdna,
smember->pointerlevel = 0;
smember->arraylength = 0;
if (offset) {
*offset = -1;
}
*offset = -1;
membername = strstr(membername, "->") + strlen("->");
rna_find_sdna_member(sdna, sdna->alias.types[member->type], membername, smember, offset);
return 1;
}
if (offset && *offset != -1) {
if (*offset != -1) {
*offset += size;
}
}

View File

@@ -1496,10 +1496,8 @@ int pyrna_pydict_to_props(PointerRNA *ptr,
}
if (kw == nullptr) {
PyErr_Format(PyExc_TypeError,
"%.200s: no keywords, expected \"%.200s\"",
error_prefix,
arg_name ? arg_name : "<UNKNOWN>");
PyErr_Format(
PyExc_TypeError, "%.200s: no keywords, expected \"%.200s\"", error_prefix, arg_name);
error_val = -1;
break;
}

View File

@@ -329,7 +329,7 @@ Sequence *SEQ_add_sound_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL
BLI_path_split_dir_file(
load_data->path, strip->dirpath, sizeof(strip->dirpath), se->filename, sizeof(se->filename));
if (seq != nullptr && seq->sound != nullptr) {
if (seq->sound != nullptr) {
if (load_data->flags & SEQ_LOAD_SOUND_MONO) {
seq->sound->flags |= SOUND_FLAGS_MONO;
}