Uploaded image for project: 'Lustre'
  1. Lustre
  2. LU-11432

enum constants like lnet_msg_type in LNet should have specific values

Details

    • Improvement
    • Resolution: Unresolved
    • Minor
    • None
    • None
    • 3
    • 9223372036854775807

    Description

      In LNet (lnet-types.h), the enum constants are started from 0 and so the values are given per the position in the struct. It looks like this.

      enum lnet_msg_type {
          LNET_MSG_ACK = 0,                          
          LNET_MSG_PUT,
          LNET_MSG_GET,
          LNET_MSG_REPLY,
          LNET_MSG_HELLO,                                                                                    
      };
      

      This should be fixed and be given specific values.

      As Andreas pointed out - "This avoids bugs in the future if one of these constants is deleted, or if someone accidentally tries to add a value in the middle of the list, which would bump up all of the following values by one and break the network protocol compatibility."

      Attachments

        Activity

          [LU-11432] enum constants like lnet_msg_type in LNet should have specific values
          adilger Andreas Dilger made changes -
          Assignee Original: Core Lustre Triage [ core-lustre-triage ] New: Aryan Gupta [ argupta ]
          adilger Andreas Dilger made changes -
          Labels Original: patch New: easy patch
          adilger Andreas Dilger made changes -
          Assignee Original: WC Triage [ wc-triage ] New: Core Lustre Triage [ core-lustre-triage ]
          adilger Andreas Dilger made changes -
          Assignee Original: Sonia Sharma [ sharmaso ] New: WC Triage [ wc-triage ]
          adilger Andreas Dilger made changes -
          Issue Type Original: Bug [ 1 ] New: Improvement [ 4 ]
          adilger Andreas Dilger made changes -
          Labels New: patch
          sharmaso Sonia Sharma (Inactive) made changes -
          Description Original: In LNet (lnet-types.h), the enum constants are started from 0 and so the values are given per the position in the struct. It looks like this.
          {code:java}
          enum lnet_msg_type {                                                                                         »·······LNET_MSG_ACK = 0,                                                                                    »·······LNET_MSG_PUT,                                                                                        »·······LNET_MSG_GET,                                                                                        »·······LNET_MSG_REPLY,                                                                                      »·······LNET_MSG_HELLO,                                                                                   
          };
          {code}
          This should be fixed and be given specific values.

          As Andreas pointed out - "This avoids bugs in the future if one of these constants is deleted, or if someone accidentally tries to add a value in the middle of the list, which would bump up all of the following values by one and break the network protocol compatibility."
          New: In LNet (lnet-types.h), the enum constants are started from 0 and so the values are given per the position in the struct. It looks like this.
          {code:java}
          enum lnet_msg_type {
              LNET_MSG_ACK = 0,                         
              LNET_MSG_PUT,
              LNET_MSG_GET,
              LNET_MSG_REPLY,
              LNET_MSG_HELLO,                                                                                   
          };
          {code}
          This should be fixed and be given specific values.

          As Andreas pointed out - "This avoids bugs in the future if one of these constants is deleted, or if someone accidentally tries to add a value in the middle of the list, which would bump up all of the following values by one and break the network protocol compatibility."

          Sonia Sharma (sharmaso@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/33251
          Subject: LU-11432 lnet: Assign specific values to enum constt
          Project: fs/lustre-release
          Branch: master
          Current Patch Set: 1
          Commit: 49676250f1eaffb30d50afee71a990db749bc90d

          gerrit Gerrit Updater added a comment - Sonia Sharma (sharmaso@whamcloud.com) uploaded a new patch: https://review.whamcloud.com/33251 Subject: LU-11432 lnet: Assign specific values to enum constt Project: fs/lustre-release Branch: master Current Patch Set: 1 Commit: 49676250f1eaffb30d50afee71a990db749bc90d
          sharmaso Sonia Sharma (Inactive) made changes -
          Description Original: In LNet (lnet-types.h), the enum constants are started from 0 and so the values are given per the position in the struct. It looks like this.
          {code:java}
          enum lnet_msg_type {                                                                                         »·······LNET_MSG_ACK = 0,                                                                                    »·······LNET_MSG_PUT,                                                                                        »·······LNET_MSG_GET,                                                                                        »·······LNET_MSG_REPLY,                                                                                      »·······LNET_MSG_HELLO,                                                                                      };
          {code}
          This should be fixed and be given specific values.

          As Andreas pointed out - "This avoids bugs in the future if one of these constants is deleted, or if someone accidentally tries to add a value in the middle of the list, which would bump up all of the following values by one and break the network protocol compatibility."
          New: In LNet (lnet-types.h), the enum constants are started from 0 and so the values are given per the position in the struct. It looks like this.
          {code:java}
          enum lnet_msg_type {                                                                                         »·······LNET_MSG_ACK = 0,                                                                                    »·······LNET_MSG_PUT,                                                                                        »·······LNET_MSG_GET,                                                                                        »·······LNET_MSG_REPLY,                                                                                      »·······LNET_MSG_HELLO,                                                                                   
          };
          {code}
          This should be fixed and be given specific values.

          As Andreas pointed out - "This avoids bugs in the future if one of these constants is deleted, or if someone accidentally tries to add a value in the middle of the list, which would bump up all of the following values by one and break the network protocol compatibility."
          sharmaso Sonia Sharma (Inactive) made changes -
          Description Original: In LNet (lnet-types.h), the enum constants are started from 0 and so the values are given per the position in the struct. It looks like this.
          {code:java}
          enum lnet_msg_type {                                                                                                                                         »·······LNET_MSG_ACK = 0,                                                                                                                                      »·······LNET_MSG_PUT,                                                                                                                                            »·······LNET_MSG_GET,                                                                                                                                            »·······LNET_MSG_REPLY,                                                                                                                                          »·······LNET_MSG_HELLO,                                                                                                                                          };
          {code}

          This should be fixed and be given specific values.

          As Andreas pointed out - "This avoids bugs in the future if one of these constants is deleted, or if someone accidentally tries to add a value in the middle of the list, which would bump up all of the following values by one and break the network protocol compatibility."
          New: In LNet (lnet-types.h), the enum constants are started from 0 and so the values are given per the position in the struct. It looks like this.
          {code:java}
          enum lnet_msg_type {                                                                                         »·······LNET_MSG_ACK = 0,                                                                                    »·······LNET_MSG_PUT,                                                                                        »·······LNET_MSG_GET,                                                                                        »·······LNET_MSG_REPLY,                                                                                      »·······LNET_MSG_HELLO,                                                                                      };
          {code}
          This should be fixed and be given specific values.

          As Andreas pointed out - "This avoids bugs in the future if one of these constants is deleted, or if someone accidentally tries to add a value in the middle of the list, which would bump up all of the following values by one and break the network protocol compatibility."

          People

            argupta Aryan Gupta
            sharmaso Sonia Sharma (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: