Skip to content

Conversation

eivindj-nordic
Copy link
Contributor

Change error codes to nrf_errors.

This is the first PR for updating the error codes for BLE libraries. Starting with the ble_adv library.
Moving forward all non-BLE libraries and components will return errnos, while BLE related code as BLE services, libraries and the SoftDevice will return nrf_errors.

@eivindj-nordic eivindj-nordic self-assigned this Oct 22, 2025
@eivindj-nordic eivindj-nordic requested review from a team as code owners October 22, 2025 07:14
@github-actions github-actions bot added changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. doc-required PR must not be merged without tech writer approval. labels Oct 22, 2025
@github-actions
Copy link

You can find the documentation preview for this PR here.

@eivindj-nordic eivindj-nordic force-pushed the error_code_alignment_ble_adv branch 3 times, most recently from c94cb69 to 6fc813d Compare October 22, 2025 07:22

if (err) {
LOG_ERR("Failed to start advertising, err %d", err);
if (nrf_err != nrf_success) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be if (nrf_err != NRF_SUCCESS) {?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, corrected.

@eivindj-nordic eivindj-nordic force-pushed the error_code_alignment_ble_adv branch from 6fc813d to c2fa6b6 Compare October 22, 2025 08:01

if (err) {
LOG_ERR("Failed to initialize advertising, err %d", err);
if (nrf_err != NRF_SUCCESS) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to be this explicit? I think it's easier to read if (nrf_err)

Copy link
Contributor Author

@eivindj-nordic eivindj-nordic Oct 22, 2025

Choose a reason for hiding this comment

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

I think we should for good practice, as we don't have full control over the nrf_error values (although in practice it is very unlikely that NRF_SUCCESS will change). It also makes a clear distinction between errnos and nrf_errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can safely stick to the simpler:

if (nrf_err) {
}


if (err) {
LOG_ERR("Failed to initialize advertising, err %d", err);
if (nrf_err != NRF_SUCCESS) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can safely stick to the simpler:

if (nrf_err) {
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Why are you changing this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should not be part of it...

/* Check parameter consistency */
if (ble_adv_data->srv_list.service == NULL) {
return -EFAULT;
return NRF_ERROR_INVALID_PARAM;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use NRF_ERROR_NULL

if (service_data->len > 0) {
if (service_data->data == NULL) {
return -EINVAL;
return NRF_ERROR_INVALID_PARAM;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use NRF_ERROR_NULL when a check against NULL fails

{
#if CONFIG_BLE_ADV_FAST_ADVERTISING
int err;
uint32_t err;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should decide whether we want to store nrf_error values into nrf_err or whether it can be called generically err where there is only one error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I was thinking about that as well. For now I've only updated in the samples where it collides.

const struct ble_adv_data *sr_data)
{
int err;
uint32_t err;
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"And here" does not make sense, what are you referring to?

Copy link
Contributor

Choose a reason for hiding this comment

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

Nevermind :) left over comment, it was probably to say we needed to decide whether it was going to be err or nrf_err.

@eivindj-nordic eivindj-nordic force-pushed the error_code_alignment_ble_adv branch 3 times, most recently from 7902739 to 031b124 Compare October 22, 2025 11:50
Change error codes to nrf_errors.

Signed-off-by: Eivind Jølsgard <[email protected]>
@eivindj-nordic eivindj-nordic force-pushed the error_code_alignment_ble_adv branch from 031b124 to 89653ba Compare October 22, 2025 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog-entry-required Update changelog before merge. Remove label if entry is not needed or already added. doc-required PR must not be merged without tech writer approval.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants