This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: socket module fix warning build on FreeBSD
Type: compile error Stage: resolved
Components: FreeBSD Versions: Python 3.11
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: devnexen, koobs, vstinner
Priority: normal Keywords:

Created on 2022-01-12 18:30 by devnexen, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 30560 closed devnexen, 2022-01-12 18:30
Messages (5)
msg410419 - (view) Author: David CARLIER (devnexen) * Date: 2022-01-12 18:30
- Solves the "Make sure new member of socket address initialized." warning for the bluetooth sockaddr_l2cap usage.
msg410432 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-01-12 21:43
> Solves the "Make sure new member of socket address initialized." warning for the bluetooth sockaddr_l2cap usage.

You would to elaborate how you checked that all members of the socket address are initialized? Which socketmodule.c functions use this type? Are all members initialized?

https://www.leidinger.net/FreeBSD/dox/netgraph/html/d2/de3/structsockaddr__l2cap.html

A quick search points me to:
https://www.leidinger.net/FreeBSD/dox/netgraph/html/d2/de3/structsockaddr__l2cap.html
---
u_char 	l2cap_len 
u_char 	l2cap_family 
u_int16_t 	l2cap_psm 
bdaddr_t 	l2cap_bdaddr 
u_int16_t 	l2cap_cid 
u_int8_t 	l2cap_bdaddr_type
---

In BTPROTO_L2CAP case of getsockaddrarg(), it seems like only l2cap_family and l2cap_bdaddr are set, other members are set to 0. Is it enough? It seems like the important call is:

memset(addr, 0, sizeof(struct sockaddr_l2));

On FreeBSD, socketmodule.c uses:

#define sockaddr_l2 sockaddr_l2cap
msg410434 - (view) Author: David CARLIER (devnexen) * Date: 2022-01-12 22:09
I took as initialized to avoid undefined behavior rather than anything.
msg410522 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2022-01-13 20:38
> I took as initialized to avoid undefined behavior rather than anything.

I don't get what you mean.

Can you please show me which functions initialize sockaddr_l2cap structures and explain how the current code fills all members?

I don't know the code well enough to approve your PR 30560.
msg410527 - (view) Author: David CARLIER (devnexen) * Date: 2022-01-13 21:21
I get what you mean now I thought memset was enough.
History
Date User Action Args
2022-04-11 14:59:54adminsetgithub: 90515
2022-01-13 21:22:09devnexensetstatus: open -> closed
stage: resolved
2022-01-13 21:21:57devnexensetmessages: + msg410527
2022-01-13 20:38:18vstinnersetmessages: + msg410522
2022-01-12 22:09:36devnexensetmessages: + msg410434
2022-01-12 21:43:47vstinnersetnosy: + vstinner
messages: + msg410432
2022-01-12 18:30:57devnexencreate