Skip to content

Commit 5c72504

Browse files
committed
netconf REFACTOR remove duplicit type declarations
1 parent c729df1 commit 5c72504

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

examples/client.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ help_print()
4747
" get-config [datastore] [xpath-filter]\t\t send a <get-config> RPC with optional XPath filter and datastore, the default datastore is \"running\" \n\n");
4848
}
4949

50-
static enum NC_DATASTORE_TYPE
50+
static NC_DATASTORE
5151
string2datastore(const char *str)
5252
{
5353
if (!str) {
@@ -68,7 +68,7 @@ string2datastore(const char *str)
6868
static int
6969
send_rpc(struct nc_session *session, NC_RPC_TYPE rpc_type, const char *param1, const char *param2)
7070
{
71-
enum NC_DATASTORE_TYPE datastore;
71+
NC_DATASTORE datastore;
7272
int r = 0, rc = 0;
7373
uint64_t msg_id = 0;
7474
struct lyd_node *envp = NULL, *op = NULL;

src/netconf.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
/**
22
* @file netconf.h
33
* @author Radek Krejci <[email protected]>
4+
* @author Michal Vasko <[email protected]>
45
* @brief libnetconf2's general public functions and structures definitions.
56
*
67
* @copyright
7-
* Copyright (c) 2015 - 2021 CESNET, z.s.p.o.
8+
* Copyright (c) 2015 - 2025 CESNET, z.s.p.o.
89
*
910
* This source code is licensed under BSD 3-Clause License (the "License").
1011
* You may not use this file except in compliance with the License.
@@ -51,7 +52,7 @@ extern "C" {
5152
/**
5253
* @brief Enumeration of reasons of the NETCONF session termination as defined in RFC 6470.
5354
*/
54-
typedef enum NC_SESSION_TERM_REASON {
55+
typedef enum {
5556
NC_SESSION_TERM_ERR = -1, /**< error return code for function getting the session termination reason */
5657
NC_SESSION_TERM_NONE = 0, /**< session still running */
5758
NC_SESSION_TERM_CLOSED, /**< closed by client in a normal fashion */
@@ -65,7 +66,7 @@ typedef enum NC_SESSION_TERM_REASON {
6566
/**
6667
* @brief Enumeration of NETCONF message types.
6768
*/
68-
typedef enum NC_MSG_TYPE {
69+
typedef enum {
6970
NC_MSG_ERROR, /**< error return value */
7071
NC_MSG_WOULDBLOCK, /**< timeout return value */
7172
NC_MSG_NONE, /**< no message at input or message was processed internally */
@@ -85,7 +86,7 @@ extern const char *nc_msgtype2str[];
8586
/**
8687
* @brief Enumeration of the supported types of datastores defined by NETCONF
8788
*/
88-
typedef enum NC_DATASTORE_TYPE {
89+
typedef enum {
8990
NC_DATASTORE_ERROR = 0, /**< error state of functions returning the datastore type */
9091
NC_DATASTORE_CONFIG, /**< value describing that the datastore is set as config */
9192
NC_DATASTORE_URL, /**< value describing that the datastore data should be given from the URL */
@@ -97,7 +98,7 @@ typedef enum NC_DATASTORE_TYPE {
9798
/**
9899
* @brief Enumeration of NETCONF with-defaults capability modes.
99100
*/
100-
typedef enum NC_WITHDEFAULTS_MODE {
101+
typedef enum {
101102
NC_WD_UNKNOWN = 0, /**< invalid mode */
102103
NC_WD_ALL, /**< report-all mode */
103104
NC_WD_ALL_TAG, /**< report-all-tagged mode */
@@ -108,7 +109,7 @@ typedef enum NC_WITHDEFAULTS_MODE {
108109
/**
109110
* @brief Enumeration of NETCONF (both server and client) rpc-reply types.
110111
*/
111-
typedef enum NC_REPLY {
112+
typedef enum {
112113
NC_RPL_OK, /**< OK rpc-reply */
113114
NC_RPL_DATA, /**< DATA rpc-reply */
114115
NC_RPL_ERROR, /**< ERROR rpc-reply */
@@ -118,7 +119,7 @@ typedef enum NC_REPLY {
118119
/**
119120
* @brief Enumeration of function parameter treatments.
120121
*/
121-
typedef enum NC_PARAMTYPE {
122+
typedef enum {
122123
NC_PARAMTYPE_CONST, /**< use the parameter directly, do not free */
123124
NC_PARAMTYPE_FREE, /**< use the parameter directly, free afterwards */
124125
NC_PARAMTYPE_DUP_AND_FREE /**< make a copy of the argument, free afterwards */

tests/test_client_messages.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ test_nc_rpc_act_generic(void **state)
105105

106106
/* function to check if values of getconfig rpc are set correctly */
107107
void
108-
check_getconfig(struct nc_rpc *rpc, enum NC_DATASTORE_TYPE source, char *filter, NC_WD_MODE wd_mode)
108+
check_getconfig(struct nc_rpc *rpc, NC_DATASTORE source, char *filter, NC_WD_MODE wd_mode)
109109
{
110110
assert_int_equal(nc_rpc_get_type(rpc), NC_RPC_GETCONFIG);
111111
struct nc_rpc_getconfig *getconfig_rpc = (struct nc_rpc_getconfig *)rpc;

0 commit comments

Comments
 (0)