Cleanup: Correcting default cases in node.cc #107339
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#107339
Loading…
Reference in New Issue
No description provided.
Delete Branch "mod_moder/blender:tmp_cleanup_ensure_default_cases"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Add all other enum items to switch statments
instead of using default (added in #107097 to avoid compiler warnings).
Thanks for the PR, but typically we don't do this, since it prevents warnings for missing cases when adding new values to the enum.
@HooglyBoogly I mean I already did it in #107097
Here I do it for defined int keys (doesn't seem to have warnings for them?)
Also, then can I replace the default with other keys in enum switches?
Hmm, that was not mentioned in the PR description. The best thing to do in that case is to pass around the enum type in the first place, or cast the int to the enum type just for the switch.
This was a related change. The value is stored using an int, so for the switch I converted it to an enum type.
It wasn't mentioned because I just bypassed the compiler warnings, sorry for not giving it that much importance.
@ -246,6 +246,8 @@ static void ntree_free_data(ID *id)
ntreeTexEndExecTree(ntree->runtime->execdata);
ntree->runtime->execdata = nullptr;
break;
default:
I don't see a need for this
default
case, it doesn't make a functional difference or help with warnings.My main motivation is to avoid unsafe behavior. We can't have compiler warnings for this enum items right now, since they're not enums. Likewise below. These are int identifiers. When this is replaced with enums, all elements can be added. But for now, maybe we should just say that the rest are not supported with using
default
?This default case doesn't make things safer, it doesn't change the behavior in this function. The switch case already says "any other value, don't do anything" on its own.
Ah, well, okay, now only a code style guide on my side/
@ -4166,6 +4171,8 @@ void node_type_base(bNodeType *ntype, const int type, const char *name, const sh
switch (type) {
#include "NOD_static_types.h"
default:
Same here
@ -4291,6 +4298,8 @@ void node_type_size_preset(bNodeType *ntype, const eNodeSizePreset size)
case NODE_SIZE_LARGE:
node_type_size(ntype, 240, 140, NODE_DEFAULT_MAX_WIDTH);
break;
default:
And here I think
Cleanup: Ensure default cases in node.ccto Cleanup: Correcting default cases in node.cc