<h3>Contribution description</h3>
<p>This PR removes all netdev<->driver dereferences and replace them with <code>container_of</code>.<br>
This step is important to prevent wrong dereferences when migrating the IEEE 802.15.4 path to the Radio HAL/SubMAC.<br>
Since I already touched several files, I decided to do it tree-wide since this also adds a layer of security.</p>

<h3>Testing procedure</h3>
<p>This should be tested carefully, although I think a compile test should suffice. Wrong conversions will be pointed out by the compiler.</p>

<h3>Issues/PRs references</h3>
<p>Related to <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="606435613" data-permission-text="Title is private" data-url="https://github.com/RIOT-OS/RIOT/issues/13943" data-hovercard-type="pull_request" data-hovercard-url="/RIOT-OS/RIOT/pull/13943/hovercard" href="https://github.com/RIOT-OS/RIOT/pull/13943">#13943</a></p>


<hr>

<h4>You can view, comment on, or merge this pull request online at:</h4>
<p>  <a href='https://github.com/RIOT-OS/RIOT/pull/16577'>https://github.com/RIOT-OS/RIOT/pull/16577</a></p>

<h4>Commit Summary</h4>
<ul>
  <li>at86rf2xx: avoid netdev dereference</li>
  <li>mrf24j40: avoid netdev dereference</li>
  <li>kw2xrf: avoid netdev dereference</li>
  <li>kw41zrf: avoid netdev dereference</li>
  <li>cc2538_rf: avoid netdev dereference</li>
  <li>nrf802154: avoid netdev dereference</li>
  <li>at86rf215: avoid netdev dereference</li>
  <li>cc2420: avoid netdev dereference</li>
  <li>socket_zep: avoid netdev dereference</li>
  <li>esp-eth: avoid netdev dereference</li>
  <li>esp-now: avoid netdev dereference</li>
  <li>esp-wifi: avoid netdev dereference</li>
  <li>netdev_tap: avoid netdev dereference</li>
  <li>stm32/eth: avoid netdev dereference</li>
  <li>netdev_ieee802154_submac: avoid netdev dereference</li>
  <li>nrf24l01p_ng: avoid netdev dereference</li>
  <li>rn2xx3: avoid netdev dereference</li>
  <li>sx126x: avoid netdev dereference</li>
  <li>sx127x: avoid netdev dereference</li>
  <li>examples/lorawan: avoid netdev dereference</li>
  <li>lwip: avoid netdev dereference</li>
  <li>openthread: avoid netdev dereference</li>
  <li>openwsn: avoid netdev dereference</li>
  <li>auto_init/loramac: avoid netdev dereference</li>
  <li>link_layer/gomach: avoid netdev dereference</li>
  <li>link_layer/lwmac: avoid netdev dereference</li>
  <li>gnrc_netif_ieee802154: avoid netdev dereference</li>
  <li>netdev_test: avoid netdev dereference</li>
  <li>tests/gnrc_netif: avoid netdev dereference</li>
  <li>tests/ieee802154_submac: avoid netdev dereference</li>
  <li>semtech-loramac: avoid netdev dereference</li>
</ul>

<h4>File Changes</h4>
<ul>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-13d4fe29da56bce4abaf9aa23e00b4b15150960324d37f2e6970f2f50ef0a3a2">cpu/cc2538/radio/cc2538_rf.c</a>
    (4)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-d74e8898ee73b88570fb74a244921e0de42c22505f6053d5bb3e10ec31dfb994">cpu/cc2538/radio/cc2538_rf_netdev.c</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-d4bde0fe43c2537840359c400cdd5bc1eb9ccf12eb110a8701269643b4cfef3c">cpu/esp32/esp-eth/esp_eth_netdev.c</a>
    (10)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-617535d3e3ea8d84b9221f59ba640ac01c7cb82cccccc4a696bcbd0a70bb1e43">cpu/esp_common/esp-now/esp_now_gnrc.c</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-8a31fb94a428f0bc21e8fdb0f1362c463cad4608f1daa755501a90af3672606e">cpu/esp_common/esp-now/esp_now_netdev.c</a>
    (12)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-4eac069fdb789d8eaf73dc8e1dbbd390556fd36aff7009a0db4374c5a0584336">cpu/esp_common/esp-wifi/esp_wifi_netdev.c</a>
    (8)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-90fd60765945effe6f354d042d79d30295060d7abeeb704e0db893ec2c43c523">cpu/native/netdev_tap/netdev_tap.c</a>
    (16)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-80cfee376c74c3316aaf3dd8bec216dd5ac6b3e924af9280abf754e3cfb2d06a">cpu/native/socket_zep/socket_zep.c</a>
    (12)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-8d59d803745d274334b224ed3dc8e900c26305e33b4fe4588611ed9b70fda592">cpu/nrf52/radio/nrf802154/nrf802154.c</a>
    (4)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-8401bee06d5cdee99d629e1c04c687458931e9ba02b2a41662dd322ad6fee6ee">cpu/nrf52/radio/nrf802154/nrf802154_radio.c</a>
    (4)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-7ede1d9b5a6304a6afb76a6d8015b8a574f242541ca6759c33973fee35cd1bd2">cpu/stm32/periph/eth.c</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-5cec682ff390ad439de6c8a67d1e1c47ac943bdffc484ba65a4514c7942555ab">drivers/at86rf215/at86rf215.c</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-b35ef68217e08c051831a5f1a4ab50f33adb253c9ec58d48d1f61382b8b886c8">drivers/at86rf215/at86rf215_netdev.c</a>
    (18)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-7d3d4627820157dc7cdf671f4d581362ec248de9e3ff6717b77bfb89c563d58f">drivers/at86rf2xx/at86rf2xx.c</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-f507c63bddcd8d2d547b478062d0f1e26952a8ce1ac8057687f561809f429292">drivers/at86rf2xx/at86rf2xx_netdev.c</a>
    (32)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-3197e1507a9ec6e7ca9971c8776b8f3f8b164e79322ada223b0980f63bcbeffe">drivers/cc2420/cc2420_netdev.c</a>
    (14)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-fa9a6f5d042940f97d78bb9c46ace3e767cf8501e0ff4c99ff435210294b19c4">drivers/kw2xrf/kw2xrf.c</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-e307e927bb0908fed2d60ef4ee5167c8de9d47fd682d114a9e2b1574967855af">drivers/kw2xrf/kw2xrf_netdev.c</a>
    (26)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-a030c0ff624db56753be8bb1d3e36dda19c17494b179c21e6b6128b633250fbf">drivers/kw41zrf/kw41zrf.c</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-f358fad198b7a49990429385d1060501410cbce49d5ac1576e3ab7fbd36e692a">drivers/kw41zrf/kw41zrf_netdev.c</a>
    (14)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-1111396ecc4a7e5e43a006d822dd4abe19f5dcbc77696e8111f8af320790e78d">drivers/mrf24j40/mrf24j40.c</a>
    (5)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-fce7af969cf577ae4dd54c7ae257366e697bb51103fb9d0d09193555e7571bc2">drivers/mrf24j40/mrf24j40_netdev.c</a>
    (16)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-68b2ce720fb85edf7d2d151b240c06e4e94653c2efd1088a0c143c670739e32c">drivers/netdev_ieee802154_submac/netdev_ieee802154_submac.c</a>
    (20)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-efe46729230e8c35c896ffd7f938d15be54e03add2e9bf100540996b038710a8">drivers/nrf24l01p_ng/gnrc_netif_nrf24l01p_ng.c</a>
    (4)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-9388b8bb0e22fad27c84770a7145aeb8d191263fa63fa1d34c9f0c529d462a57">drivers/nrf24l01p_ng/nrf24l01p_ng_netdev.c</a>
    (14)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-16e8486942efca2091ce5871a98eac8c1ce1631718d88b269835fa9e6bbf0b29">drivers/rn2xx3/rn2xx3.c</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-80d3ca30737384f2e8198f653ff14ca9d2cfbac884f5d85d1f73936fae95a121">drivers/sx126x/sx126x.c</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-ee715b9f64a52711cd7bae97088cb7928d23f0858751c81b51e863435a196aea">drivers/sx126x/sx126x_netdev.c</a>
    (14)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-132c840355701c41c45687b27534e56d14681e5ad41c63ded75f4511175555e6">drivers/sx127x/sx127x.c</a>
    (14)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-f19304ed7b939ccb50b28a7b1c8dd7f465a792aa2b1e70a7981d75b36a21ff14">drivers/sx127x/sx127x_netdev.c</a>
    (28)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-24624d079ee1e7b9cdd2ba73ddf3d1ac6b5904b3d3c64cb550a54a7f8a07ccc5">examples/lorawan/main.c</a>
    (4)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-6ee66bc619e740238ae7db48bc69990b08d917a7c8a2bd1569f8fe1012f3cfc1">pkg/lwip/contrib/netdev/lwip_netdev.c</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-6a4996bb95d9cebf272ddc2d1490ed94893f7bf219a9d606cd706af0516a659d">pkg/openthread/contrib/openthread.c</a>
    (8)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-03acf57a64f88ebe5ec8a7060a7a3cf4f5805f52d097aab146e80a3157074ec7">pkg/openwsn/contrib/radio_netdev.c</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-342498cf6593aa01eba3fd7414d5be9f3ca43a8c1eececb8158824790379b375">pkg/semtech-loramac/contrib/semtech_loramac.c</a>
    (10)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-5a7d37de054bfdef0a501d88cc0159e36067b34f061b1cfce96ea4a358da4873">sys/auto_init/loramac/auto_init_loramac.c</a>
    (4)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-090a76a430dc1f52a7f2358195599a43ada390f84c2507961c32f97135a4bbfd">sys/net/gnrc/link_layer/gomach/gomach.c</a>
    (35)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-f4ead10aeca6ec8afb6edd77e105eb8c4aa26cc4d400fbc116de12b46bbfccaa">sys/net/gnrc/link_layer/gomach/gomach_internal.c</a>
    (5)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-7b68c4395b14dd941c4478ee3585e2ebf6d372082a7f55be99144c741a64934e">sys/net/gnrc/link_layer/lwmac/lwmac.c</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-0b3c138dab95da3fe5e632fd385f4e3a58a5e7ce4ca6914ee784807e3ec9eb77">sys/net/gnrc/link_layer/lwmac/lwmac_internal.c</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-5f22025532e6e67791af1cd83b3c491489d58024ef6b5110e130298b85c5b092">sys/net/gnrc/netif/ieee802154/gnrc_netif_ieee802154.c</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-3edc7431edab7f6a6dacf8ccd2acae11d624b25258e7d6bef1f46b9dc2f4a2a9">sys/net/netdev_test/netdev_test.c</a>
    (14)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-3a5c518de2da1b13dd0a7a79ffb5b21949f2cc01987dc6af3caa3fcbefa30c4f">tests/driver_at86rf215/main.c</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-9b388d1fda66667befe88398937afa3300584a7648600d0989dfbb297571ecf7">tests/driver_at86rf2xx/cmd.c</a>
    (4)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-0a52ca724b4f203e4cc52295c2353756ba965f5f60a5c651e7f7eb02f0e46bc0">tests/driver_at86rf2xx/main.c</a>
    (2)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-3d947c31fef4c64c01be5cee17c045f3f486e67f652fa5789a4de89a6dda92cb">tests/driver_sx126x/main.c</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-1bcf542b7c0f8291a15519d1813f294cca2baf7bb37cf4876ce7d31ac7efbc36">tests/driver_sx127x/main.c</a>
    (26)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-ba800e0eec31580ff224f9f0fbebd527e72d2d383a7abe11f104f89651737f97">tests/gnrc_netif/common.c</a>
    (10)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-8293a7f345d3797c9b838d1a66276017eb0033f07fe780ec2dcde95757731627">tests/ieee802154_submac/main.c</a>
    (6)
  </li>
  <li>
    <strong>M</strong>
    <a href="https://github.com/RIOT-OS/RIOT/pull/16577/files#diff-b465457d75960e4ad8552a25e49f511fb4740b8f4539279a8630850abac7bc31">tests/socket_zep/main.c</a>
    (8)
  </li>
</ul>

<h4>Patch Links:</h4>
<ul>
  <li><a href='https://github.com/RIOT-OS/RIOT/pull/16577.patch'>https://github.com/RIOT-OS/RIOT/pull/16577.patch</a></li>
  <li><a href='https://github.com/RIOT-OS/RIOT/pull/16577.diff'>https://github.com/RIOT-OS/RIOT/pull/16577.diff</a></li>
</ul>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/RIOT-OS/RIOT/pull/16577">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABE7WYH6PRAVSR43LVMTIEDTUBLD5ANCNFSM47DJ4VMQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/ABE7WYFUYFN7HY46Q25ZOELTUBLD5A5CNFSM47DJ4VM2YY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4N2BPXQQ.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/RIOT-OS/RIOT/pull/16577",
"url": "https://github.com/RIOT-OS/RIOT/pull/16577",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>