File tree Expand file tree Collapse file tree 3 files changed +65
-1
lines changed
Expand file tree Collapse file tree 3 files changed +65
-1
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,21 @@ pfunc_list_filter() {
5050 esac
5151}
5252
53+ rpc_hal_init_filter () {
54+ # What a hack, take 2!
55+ #
56+ # To modify structure initialization to use designated initializers, we
57+ # post-process a cocci patch that simply removes the init to inject
58+ # lines that add the correct initialization, based on the fact that the
59+ # field member is mentioned in a trailing comment. To make that a valid
60+ # diff, we fix it up using recountdiff.
61+ case " $1 " in
62+ pre) ;;
63+ diff) sed ' s|^-\( *\)\([^ ]\+\), *// *\([^ ]\+\)$|&\n+\1.\3 = \2,|' | recountdiff; ;;
64+ post) ;;
65+ esac
66+ }
67+
5368null_filter () {
5469 case " $1 " in
5570 pre) ;;
8297SCRIPT=$1 ; shift
8398SPATCH=$1 ; shift
8499
85- if ! check_prog " $SPATCH " coccinelle; then
100+ if ! check_prog " $SPATCH " coccinelle || \
101+ ! check_prog recountdiff patchutils;
102+ then
86103 echo >&2 " error: missing required programs!"
87104 exit 2
88105fi
Original file line number Diff line number Diff line change 1+ // Coccinelle script to fix structure initialization to use designated
2+ // initializer to make these compatible with Linux's RANDSTRUCT.
3+ //
4+ // Here we handle instances of HAL_IFACE_SETUP:
5+ //
6+ // typedef struct {
7+ // void (*rpcHalIfacesSetupFn)(PRPC_HAL_IFACES pRpcHal);
8+ // void (*rpcstructurecopyHalIfacesSetupFn)(PRPCSTRUCTURECOPY_HAL_IFACES pRpcstructurecopyHal);
9+ // } HAL_IFACE_SETUP
10+ //
11+ // We simply hard-code the field names.
12+ //
13+ // (c) 2026 Open Source Security, Inc. All Rights Reserved.
14+
15+ @@
16+ identifier his;
17+ identifier f1, f2;
18+ @@
19+ static HAL_IFACE_SETUP his = {
20+ - f1,
21+ - f2,
22+ + .rpcHalIfacesSetupFn = f1,
23+ + .rpcstructurecopyHalIfacesSetupFn = f2,
24+ };
Original file line number Diff line number Diff line change 1+ // Coccinelle script to fix structure initialization to use designated
2+ // initializer to make these compatible with Linux's RANDSTRUCT.
3+ //
4+ // As coccinelle has no support for referencing a field's member name, we
5+ // post-process the patch with a sed script to do just that (the field name is
6+ // mentioned by a trailing comment).
7+ //
8+ // (c) 2026 Open Source Security, Inc. All Rights Reserved.
9+
10+ @@
11+ typedef RPC_HAL_IFACES, RPCSTRUCTURECOPY_HAL_IFACES;
12+ identifier id;
13+ @@
14+
15+ static
16+ (
17+ RPC_HAL_IFACES
18+ |
19+ RPCSTRUCTURECOPY_HAL_IFACES
20+ )
21+ id = {
22+ - ...
23+ };
You can’t perform that action at this time.
0 commit comments