clang-tidy: guard optional timer before deref

Fix bugprone-unchecked-optional-access warnings by checking
request->timer before calling cancel(), expires_after(), and
async_wait(). Ensures safe access to optional values without
changing functional behavior.

Fixed below errors

'''
../ipmbbridged.cpp:361:13: error: unchecked access to optional value [bugprone-unchecked-optional-access,-warnings-as-errors]
  361 |             request->timer->cancel();
      |             ^~~~~~~~~~~~~~
../ipmbbridged.cpp:775:9: error: unchecked access to optional value [bugprone-unchecked-optional-access,-warnings-as-errors]
  775 |         request->timer->expires_after(
      |         ^~~~~~~~~~~~~~
../ipmbbridged.cpp:777:9: error: unchecked access to optional value [bugprone-unchecked-optional-access,-warnings-as-errors]
  777 |         request->timer->async_wait(yield[ec]);
'''

Change-Id: I99f34617aecb7d0269ea746eaff2f47dad59f980
Signed-off-by: Jayanth Othayoth <ojayanth@gmail.com>
1 file changed
tree: 4095acba43ede0145fe81afd101231d640ea359a
  1. subprojects/
  2. .clang-format
  3. ipmb-channels.json
  4. ipmb.service
  5. ipmbbridged.cpp
  6. ipmbbridged.hpp
  7. ipmbdefines.hpp
  8. ipmbutils.cpp
  9. ipmbutils.hpp
  10. LICENSE
  11. meson.build
  12. OWNERS
  13. README.md
README.md

ipmbbridge

Sample config options available to configure :

  1. Single channel with one me and ipmb :

    {
      "channels": [
        {
          "type": "me",
          "slave-path": "/dev/ipmb-4",
          "bmc-addr": 32,
          "remote-addr": 44
        },
        {
          "type": "ipmb",
          "slave-path": "/dev/ipmb-9",
          "bmc-addr": 32,
          "remote-addr": 96
        }
      ]
    }
    
  2. Multiple sub channels with me and ipmb :

    {
      "channels": [
        {
          "type": "me",
          "slave-path": "/dev/ipmb-1",
          "bmc-addr": 32,
          "remote-addr": 64,
          "devIndex": 0
        },
        {
          "type": "ipmb",
          "slave-path": "/dev/ipmb-3",
          "bmc-addr": 32,
          "remote-addr": 64,
          "devIndex": 0
        },
        {
          "type": "me",
          "slave-path": "/dev/ipmb-5",
          "bmc-addr": 32,
          "remote-addr": 64,
          "devIndex": 1
        },
        {
          "type": "ipmb",
          "slave-path": "/dev/ipmb-7",
          "bmc-addr": 32,
          "remote-addr": 64,
          "devIndex": 1
        }
      ]
    }
    
Config fields :

type          : This points to the ChannelType. It can be ME or ipmb channel.
slave-path    : The ipmb device path.
bmc-addr      : This is BMC target address to communicate between BMC and device.
remote-addr   : This is Remote/requester target address to communicate between BMC and device.
devIndex      : This devIndex used to identify the particular device/host.