LCOV - code coverage report
Current view: top level - spdk/module/keyring/linux - keyring_rpc.c (source / functions) Hit Total Coverage
Test: Combined Lines: 8 12 66.7 %
Date: 2024-07-12 18:33:17 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 4 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright (c) 2024 Intel Corporation. All rights reserved.
       3                 :            :  */
       4                 :            : 
       5                 :            : #include "keyring_linux.h"
       6                 :            : #include "spdk/rpc.h"
       7                 :            : #include "spdk/string.h"
       8                 :            : #include "spdk/util.h"
       9                 :            : 
      10                 :            : static const struct spdk_json_object_decoder rpc_keyring_linux_set_options_decoders[] = {
      11                 :            :         {"enable", offsetof(struct keyring_linux_opts, enable), spdk_json_decode_bool, true},
      12                 :            : };
      13                 :            : 
      14                 :            : static void
      15                 :          3 : rpc_keyring_linux_set_options(struct spdk_jsonrpc_request *request,
      16                 :            :                               const struct spdk_json_val *params)
      17                 :            : {
      18                 :          3 :         struct keyring_linux_opts opts = {};
      19                 :            :         int rc;
      20                 :            : 
      21                 :          3 :         keyring_linux_get_opts(&opts);
      22         [ -  + ]:          3 :         if (spdk_json_decode_object(params, rpc_keyring_linux_set_options_decoders,
      23                 :            :                                     SPDK_COUNTOF(rpc_keyring_linux_set_options_decoders), &opts)) {
      24                 :          0 :                 spdk_jsonrpc_send_error_response(request, SPDK_JSONRPC_ERROR_INVALID_PARAMS,
      25                 :            :                                                  spdk_strerror(EINVAL));
      26                 :          0 :                 return;
      27                 :            :         }
      28                 :            : 
      29                 :          3 :         rc = keyring_linux_set_opts(&opts);
      30         [ -  + ]:          3 :         if (rc != 0) {
      31                 :          0 :                 spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
      32                 :          0 :                 return;
      33                 :            :         }
      34                 :            : 
      35                 :          3 :         spdk_jsonrpc_send_bool_response(request, true);
      36                 :            : }
      37                 :       2135 : SPDK_RPC_REGISTER("keyring_linux_set_options", rpc_keyring_linux_set_options, SPDK_RPC_STARTUP)

Generated by: LCOV version 1.14