Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional missing-prototypes fixes #5563

Merged
merged 9 commits into from
Nov 11, 2021

Conversation

jepler
Copy link
Member

@jepler jepler commented Nov 10, 2021

This continues in the vein of #5561 which was incomplete due to an error in a Makefile.

I think this correctly enables missing-prototypes diagnostics (as errors) in atmel-samd, espressif and raspberrypi ports.

Future work can enable this in the remaining ports.

@jepler jepler force-pushed the enable-error-missing-prototypes branch from 9fefe30 to 340d6b9 Compare November 11, 2021 03:00
Comment on lines 860 to 873
int att_find_info_req(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, uint8_t response_buffer[]) {
struct __packed req {
struct bt_att_hdr h;
struct bt_att_find_info_req r;
} req = { {
.code = BT_ATT_OP_FIND_INFO_REQ,
}, {
.start_handle = start_handle,
.end_handle = end_handle,
}};

return send_req_wait_for_rsp(conn_handle, sizeof(req), (uint8_t *)&req, response_buffer);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't delete this; the _bleio HCI implementation is incomplete and this may be needed later. Let's just comment it out for now.

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

Requesting to comment out instead of deleting unused code in _bleio HCI so we don't lose track of it. When we get around to implementing _bleio HCI central mode, we may need this code.

Comment on lines 1012 to 1030
int att_read_group_req(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, uint16_t uuid, uint8_t response_buffer[]) {

typedef struct __packed {
struct bt_att_hdr h;
struct bt_att_read_group_req r;
} req_t;

uint8_t req_bytes[sizeof(req_t) + sizeof(uuid)];
req_t *req = (req_t *)req_bytes;

req->h.code = BT_ATT_OP_READ_GROUP_REQ;
req->r.start_handle = start_handle;
req->r.end_handle = end_handle;
req->r.uuid[0] = uuid & 0xff;
req->r.uuid[1] = uuid >> 8;

return send_req_wait_for_rsp(conn_handle, sizeof(req_bytes), req_bytes, response_buffer);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't delete this; the _bleio HCI implementation is incomplete and this may be needed later. Let's just comment it out for now.

Comment on lines 1308 to 1325
int att_read_type_req(uint16_t conn_handle, uint16_t start_handle, uint16_t end_handle, uint16_t type, uint8_t response_buffer[]) {
typedef struct __packed {
struct bt_att_hdr h;
struct bt_att_read_type_req r;
} req_t;

uint8_t req_bytes[sizeof(req_t) + sizeof(type)];
req_t *req = (req_t *)req_bytes;

req->h.code = BT_ATT_OP_READ_TYPE_REQ;
req->r.start_handle = start_handle;
req->r.end_handle = end_handle;
req->r.uuid[0] = type & 0xff;
req->r.uuid[1] = type >> 8;

return send_req_wait_for_rsp(conn_handle, sizeof(req_bytes), req_bytes, response_buffer);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't delete this; the _bleio HCI implementation is incomplete and this may be needed later. Let's just comment it out for now.

Comment on lines 1716 to 1789

// FIX Do we need all of these?
void check_att_err(uint8_t err) {
const compressed_string_t *msg = NULL;
switch (err) {
case 0:
return;
case BT_ATT_ERR_INVALID_HANDLE:
msg = translate("Invalid handle");
break;
case BT_ATT_ERR_READ_NOT_PERMITTED:
msg = translate("Read not permitted");
break;
case BT_ATT_ERR_WRITE_NOT_PERMITTED:
msg = translate("Write not permitted");
break;
case BT_ATT_ERR_INVALID_PDU:
msg = translate("Invalid PDU");
break;
case BT_ATT_ERR_NOT_SUPPORTED:
msg = translate("Not supported");
break;
case BT_ATT_ERR_INVALID_OFFSET:
msg = translate("Invalid offset");
break;
case BT_ATT_ERR_PREPARE_QUEUE_FULL:
msg = translate("Prepare queue full");
break;
case BT_ATT_ERR_ATTRIBUTE_NOT_FOUND:
msg = translate("Attribute not found");
break;
case BT_ATT_ERR_ATTRIBUTE_NOT_LONG:
msg = translate("Attribute not long");
break;
case BT_ATT_ERR_ENCRYPTION_KEY_SIZE:
msg = translate("Encryption key size");
break;
case BT_ATT_ERR_INVALID_ATTRIBUTE_LEN:
msg = translate("Invalid attribute length");
break;
case BT_ATT_ERR_UNLIKELY:
msg = translate("Unlikely");
break;
case BT_ATT_ERR_UNSUPPORTED_GROUP_TYPE:
msg = translate("Unsupported group type");
break;
case BT_ATT_ERR_INSUFFICIENT_RESOURCES:
msg = translate("Insufficient resources");
break;
case BT_ATT_ERR_DB_OUT_OF_SYNC:
msg = translate("DB out of sync");
break;
case BT_ATT_ERR_VALUE_NOT_ALLOWED:
msg = translate("Value not allowed");
break;
}
if (msg) {
mp_raise_bleio_BluetoothError(msg);
}

switch (err) {
case BT_ATT_ERR_AUTHENTICATION:
msg = translate("Insufficient authentication");
break;
case BT_ATT_ERR_INSUFFICIENT_ENCRYPTION:
msg = translate("Insufficient encryption");
break;
}
if (msg) {
mp_raise_bleio_SecurityError(msg);
}

mp_raise_bleio_BluetoothError(translate("Unknown ATT error: 0x%02x"), err);
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please don't delete this; the _bleio HCI implementation is incomplete and this may be needed later. Let's just comment it out for now.

Copy link
Member Author

Choose a reason for hiding this comment

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

I reverted these changes. Instead, I marked the functions as static but deactivated the diagnostic for unused functions. This should be the most effective way to ensure the functions' code doesn't go into binaries, while leaving the code available for the future when it's needed.

@jepler jepler requested a review from dhalbert November 11, 2021 16:53
@jepler
Copy link
Member Author

jepler commented Nov 11, 2021

It's finally green! 🎉

Copy link
Collaborator

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

Thanks for this cleanup!

@dhalbert dhalbert merged commit adac5ee into adafruit:main Nov 11, 2021
@jepler jepler deleted the enable-error-missing-prototypes branch November 11, 2021 16:57
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.

2 participants