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

            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); \} " }
            Hide
            dmills Dave Mills added a comment -

            In v5.2.5

            Show
            dmills Dave Mills added a comment - In v5.2.5
            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.  

              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.