From: Gang Yan <yang...@kylinos.cn>

This patch adds a struct named 'params' to save 'target_token' and other
future parameters. This structure facilitates future function expansions.

Co-developed-by: Geliang Tang <geli...@kernel.org>
Signed-off-by: Geliang Tang <geli...@kernel.org>
Signed-off-by: Gang Yan <yang...@kylinos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matt...@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matt...@kernel.org>
---
 tools/testing/selftests/net/mptcp/mptcp_diag.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/net/mptcp/mptcp_diag.c 
b/tools/testing/selftests/net/mptcp/mptcp_diag.c
index 
37d5015ad08c44485f1964593ecb1a7b25d95934..ea7cb1128044ab7f9bad50cb29856c2e290f385f
 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_diag.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_diag.c
@@ -19,6 +19,10 @@
 #define IPPROTO_MPTCP 262
 #endif
 
+struct params {
+       __u32 target_token;
+};
+
 struct mptcp_info {
        __u8    mptcpi_subflows;
        __u8    mptcpi_add_addr_signal;
@@ -237,7 +241,7 @@ static void get_mptcpinfo(__u32 token)
        close(fd);
 }
 
-static void parse_opts(int argc, char **argv, __u32 *target_token)
+static void parse_opts(int argc, char **argv, struct params *p)
 {
        int c;
 
@@ -250,7 +254,7 @@ static void parse_opts(int argc, char **argv, __u32 
*target_token)
                        die_usage(0);
                        break;
                case 't':
-                       sscanf(optarg, "%x", target_token);
+                       sscanf(optarg, "%x", &p->target_token);
                        break;
                default:
                        die_usage(1);
@@ -261,10 +265,12 @@ static void parse_opts(int argc, char **argv, __u32 
*target_token)
 
 int main(int argc, char *argv[])
 {
-       __u32 target_token;
+       struct params p = { 0 };
 
-       parse_opts(argc, argv, &target_token);
-       get_mptcpinfo(target_token);
+       parse_opts(argc, argv, &p);
+
+       if (p.target_token)
+               get_mptcpinfo(p.target_token);
 
        return 0;
 }

-- 
2.48.1


Reply via email to