Skip to content

[RSDK-13421] Improve C++ code quality: constexpr, consistent logging, namespace cleanup #39

Merged
seanavery merged 4 commits intoviam-modules:mainfrom
seanavery:RSDK-13421
Feb 17, 2026
Merged

[RSDK-13421] Improve C++ code quality: constexpr, consistent logging, namespace cleanup #39
seanavery merged 4 commits intoviam-modules:mainfrom
seanavery:RSDK-13421

Conversation

@seanavery
Copy link
Collaborator

@seanavery seanavery commented Feb 13, 2026

Description

Quick clean up C++ best practices:

  • remove using namespace from header to prevent namespace
    pollution
  • replace #define constants with constexpr
  • standardize all logging

Testing

Build and tests passing

Review

No change in functionality, 1 approval

@seanavery seanavery changed the title [RSDK-13421] Clean up namespace polution [RSDK-13421] Clean up namespace pollution Feb 13, 2026
@seanavery seanavery changed the title [RSDK-13421] Clean up namespace pollution [RSDK-13421] Improve C++ code quality: constexpr, consistent logging, namespace cleanup Feb 13, 2026
@hexbabe
Copy link
Collaborator

hexbabe commented Feb 13, 2026

removing myself as a blocking review since I won't be able to approve next week

@hexbabe hexbabe removed their request for review February 13, 2026 19:13
Copy link

@oliviamiller oliviamiller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice! lgtm

if (!pipeline) {
std::cerr << "Failed to create the pipeline" << std::endl;
g_print("Error: %s\n", error->message);
VIAM_SDK_LOG(error) << "Failed to create the pipeline: " << error->message;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can VIAM_SDK_LOG be replaced with VIAM_RESOURCE_LOG to get more precise logs on which specific resource is emitting the logs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing. I think it makes sense to do this in a follow up as I will have to update across the codebase -- created ticket.

utils.cpp Outdated

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be replaced by a std::string?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to std::string. Still need a temporary const char* from std::getenv since it can return nullptr (which would crash if passed directly to std::string constructor)

utils.cpp Outdated

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we change this to shortcircuit the bad case?, and also, if we use a string here instead of a pointer, we would be checking for it being empty.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to std::string and checking .empty(). Kept the same control flow since we need to fall through to device file detection when there's no env override.

@seanavery seanavery merged commit 9216058 into viam-modules:main Feb 17, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants