connectedhomeip icon indicating copy to clipboard operation
connectedhomeip copied to clipboard

Sort out saner naming/placement for our "safe cast" helpers

Open bzbarsky-apple opened this issue 4 years ago • 5 comments

Problem

We have src/lib/core/CHIPSafeCasts.h (which does safe uint8_t <-> char casting) and src/lib/support/SafePointerCast.h which allows safe (for some values of safe) casting between two structs.

Proposed Solution

We should probably at least have our "safe cast" files living in the same directory. We should also consider either giving CHIPSafeCasts a less generic name or combining the files.

@Damian-Nordic

bzbarsky-apple avatar Feb 12 '21 14:02 bzbarsky-apple

@bzbarsky-apple Ah, I didn't notice we had CHIPSafeCasts.h. I can fix it, but do you or anyone else understand the difference between support and core directories? I believe utility classes, which don't depend on anything CHIP-specific, suit better the support directory but core also contains things like Optional and I'm confused.

Damian-Nordic avatar Feb 12 '21 16:02 Damian-Nordic

@Damian-Nordic I don't know what the intended difference is.... And to be clear, I have no strong opinion about finer-grained headers vs a single "safe casts" header; just in the former case we should give the uint-to-char one a better name.

@andy31415 Do you know the answer to the organization question? Would be good to toss some README.md in things to document what they're for.

bzbarsky-apple avatar Feb 12 '21 16:02 bzbarsky-apple

These (support vs. core) are latent artifacts of the original Weave tree layout that seeded the Project CHIP layout. support was code that was used across all of the various *Layers whereas core was intended to be the code that supported the Weave core messaging and protocol layer but not profile initiator and responder implementation.

Consequently, I'd agree that if there is anything in core in CHIP that's used more broadly, it should be factored out of core and either put in support or some other "shared" directory.

gerickson avatar Feb 12 '21 17:02 gerickson

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Jul 25 '22 04:07 stale[bot]

This stale issue has been automatically closed. Thank you for your contributions.

stale[bot] avatar Oct 18 '22 18:10 stale[bot]

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Apr 19 '23 14:04 stale[bot]