Whamcloud - gitweb
LU-12678 lnet: socklnd: mark all ksock_proto struct 'const'. 94/36894/7
authorMr NeilBrown <neilb@suse.de>
Wed, 13 Nov 2019 01:30:24 +0000 (12:30 +1100)
committerOleg Drokin <green@whamcloud.com>
Fri, 14 Feb 2020 05:50:40 +0000 (05:50 +0000)
These structs are always read-only, so tell the compiler.

Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: Icc7c3209135a2ab0d04a822b7053231fd2d9ff0c
Reviewed-on: https://review.whamcloud.com/36894
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/klnds/socklnd/socklnd.h
lnet/klnds/socklnd/socklnd_cb.c
lnet/klnds/socklnd/socklnd_proto.c

index 83582da..3c3c20a 100644 (file)
@@ -314,7 +314,7 @@ struct ksock_conn {
        unsigned int        ksnc_closing:1;  /* being shut down */
        unsigned int        ksnc_flip:1;     /* flip or not, only for V2.x */
        unsigned int        ksnc_zc_capable:1; /* enable to ZC */
-        struct ksock_proto *ksnc_proto;      /* protocol for the connection */
+       const struct ksock_proto *ksnc_proto; /* protocol for the connection */
 
        /* READER */
 
@@ -392,7 +392,7 @@ struct ksock_peer_ni {
        int                     ksnp_error;     /* errno on closing last conn */
        __u64                   ksnp_zc_next_cookie;/* ZC completion cookie */
        __u64                   ksnp_incarnation;   /* latest known peer_ni incarnation */
-       struct ksock_proto      *ksnp_proto;    /* latest known peer_ni protocol */
+       const struct ksock_proto *ksnp_proto;   /* latest known protocol */
        struct list_head        ksnp_conns;     /* all active connections */
        struct list_head        ksnp_routes;    /* routes */
        struct list_head        ksnp_tx_queue;  /* waiting packets */
@@ -438,9 +438,9 @@ struct ksock_proto {
                                                                                  *   return MATCH_MAY : can be backup */
 };
 
-extern struct ksock_proto ksocknal_protocol_v1x;
-extern struct ksock_proto ksocknal_protocol_v2x;
-extern struct ksock_proto ksocknal_protocol_v3x;
+extern const struct ksock_proto ksocknal_protocol_v1x;
+extern const struct ksock_proto ksocknal_protocol_v2x;
+extern const struct ksock_proto ksocknal_protocol_v3x;
 
 #define KSOCK_PROTO_V1_MAJOR    LNET_PROTO_TCP_VERSION_MAJOR
 #define KSOCK_PROTO_V1_MINOR    LNET_PROTO_TCP_VERSION_MINOR
index bf62b22..f73039e 100644 (file)
@@ -1700,8 +1700,8 @@ void ksocknal_write_callback(struct ksock_conn *conn)
        EXIT;
 }
 
-static struct ksock_proto *
-ksocknal_parse_proto_version (struct ksock_hello_msg *hello)
+static const struct ksock_proto *
+ksocknal_parse_proto_version(struct ksock_hello_msg *hello)
 {
         __u32   version = 0;
 
@@ -1799,7 +1799,7 @@ ksocknal_recv_hello(struct lnet_ni *ni, struct ksock_conn *conn,
         int                  timeout;
         int                  proto_match;
         int                  rc;
-       struct ksock_proto *proto;
+       const struct ksock_proto *proto;
        struct lnet_process_id recv_id;
 
        /* socket type set on active connections - not set on passive */
index c5cc07b..33a92a5 100644 (file)
@@ -748,7 +748,7 @@ ksocknal_unpack_msg_v2(struct ksock_msg *msg)
         return;  /* Do nothing */
 }
 
-struct ksock_proto  ksocknal_protocol_v1x =
+const struct ksock_proto ksocknal_protocol_v1x =
 {
         .pro_version            = KSOCK_PROTO_V1,
         .pro_send_hello         = ksocknal_send_hello_v1,
@@ -762,7 +762,7 @@ struct ksock_proto  ksocknal_protocol_v1x =
         .pro_match_tx           = ksocknal_match_tx
 };
 
-struct ksock_proto  ksocknal_protocol_v2x =
+const struct ksock_proto ksocknal_protocol_v2x =
 {
         .pro_version            = KSOCK_PROTO_V2,
         .pro_send_hello         = ksocknal_send_hello_v2,
@@ -776,7 +776,7 @@ struct ksock_proto  ksocknal_protocol_v2x =
         .pro_match_tx           = ksocknal_match_tx
 };
 
-struct ksock_proto  ksocknal_protocol_v3x =
+const struct ksock_proto ksocknal_protocol_v3x =
 {
         .pro_version            = KSOCK_PROTO_V3,
         .pro_send_hello         = ksocknal_send_hello_v2,