Commit e6c1883
committed
fix: use union-based cast to resolve const-correctness without warnings
The previous cast approach triggered -Wcast-qual warnings in CI.
This implementation uses a union to safely convert const to non-const
pointer, which is a standard C technique that avoids compiler warnings.
How it works:
- Data array is const (preventing modification)
- Union allows type-punning between const and non-const pointers
- Accessing via .ptr member gives non-const pointer for struct assignment
- No undefined behavior as per C standard union rules
This maintains const-correctness of the underlying data while being
compatible with struct s2n_blob's non-const data pointer member.1 parent 131f3f2 commit e6c1883
1 file changed
+7
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
73 | | - | |
74 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
0 commit comments