Uploaded image for project: 'Data Management'
  1. Data Management
  2. DM-31935

Please tests if OSPL_RELEASE env variable exists

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Resolution: Done
    • Fix Version/s: None
    • Component/s: ts_middleware
    • Labels:
      None
    • Story Points:
      0.5
    • Sprint:
      TSSW Sprint - Sep 27 - Oct 11
    • Team:
      Telescope and Site
    • Urgent?:
      No

      Description

      Please check that getenv returns non-null. If that returns null, string exception is raised and that is quite hard to debug if you are catching this exception.

       

       

        Attachments

          Issue Links

            Activity

            No builds found.
            pkubanek Petr Kubanek created issue -
            Hide
            pkubanek Petr Kubanek added a comment -

            This is one possible solution:

            diff --git a/lsstsal/scripts/gensalgetput.tcl b/lsstsal/scripts/gensalgetput.tcl
            index e88e3a0..a07e4ca 100644
            --- a/lsstsal/scripts/gensalgetput.tcl
            +++ b/lsstsal/scripts/gensalgetput.tcl
            @@ -229,8 +229,12 @@ string SAL_SALData::getXMLVersion()
             
             string SAL_SALData::getOSPLVersion()
             \{
            -     string osplver = getenv(\"OSPL_RELEASE\");
            -     return osplver;
            +     char *osplver = getenv(\"OSPL_RELEASE\");
            +     if (osplver == NULL) {
            +         cerr << \"Please define OSPL_RELEASE environment variable!\" << endl;
            +         exit(EXIT_FAILURE);
            +     }
            +     return string(osplver);
             \}
             "
             }
            

            Show
            pkubanek Petr Kubanek added a comment - This is one possible solution: diff --git a/lsstsal/scripts/gensalgetput.tcl b/lsstsal/scripts/gensalgetput.tcl index e88e3a0..a07e4ca 100644 --- a/lsstsal/scripts/gensalgetput.tcl +++ b/lsstsal/scripts/gensalgetput.tcl @@ - 229 , 8 + 229 , 12 @@ string SAL_SALData::getXMLVersion() string SAL_SALData::getOSPLVersion() \{ - string osplver = getenv(\"OSPL_RELEASE\"); - return osplver; + char *osplver = getenv(\"OSPL_RELEASE\"); + if (osplver == NULL) { + cerr << \"Please define OSPL_RELEASE environment variable!\" << endl; + exit(EXIT_FAILURE); + } + return string(osplver); \} " }
            dmills Dave Mills made changes -
            Field Original Value New Value
            Epic Link DM-27719 [ 442124 ]
            Sprint TSSW Sprint - Sep 27 - Oct 11 [ 1121 ]
            Story Points 0.5
            dmills Dave Mills made changes -
            Status To Do [ 10001 ] In Progress [ 3 ]
            Hide
            dmills Dave Mills added a comment -

            In v5.2.5

            Show
            dmills Dave Mills added a comment - In v5.2.5
            dmills Dave Mills made changes -
            Status In Progress [ 3 ] In Review [ 10004 ]
            Hide
            pkubanek Petr Kubanek added a comment -

            OK. I would rather leave return string(osplver), as that's leaner (2 LOC saved), but works as well. Thanks.

             

            Show
            pkubanek Petr Kubanek added a comment - OK. I would rather leave return string(osplver), as that's leaner (2 LOC saved), but works as well. Thanks.  
            pkubanek Petr Kubanek made changes -
            Status In Review [ 10004 ] Reviewed [ 10101 ]
            dmills Dave Mills made changes -
            Resolution Done [ 10000 ]
            Status Reviewed [ 10101 ] Done [ 10002 ]
            aclements Andy Clements made changes -
            Epic Link DM-27719 [ 442124 ] DM-27708 [ 442112 ]
            dmills Dave Mills made changes -
            Link This issue is cloned by DM-32151 [ DM-32151 ]
            aclements Andy Clements made changes -
            Epic Link DM-27708 [ 442112 ] DM-27719 [ 442124 ]

              People

              Assignee:
              dmills Dave Mills
              Reporter:
              pkubanek Petr Kubanek
              Reviewers:
              Petr Kubanek
              Watchers:
              Dave Mills, Michael Reuter, Petr Kubanek, Tiago Ribeiro
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Jenkins

                  No builds found.