manifest/os: fix SUPPRESSED_ERROR issue reported by Coverity

Fix the following error reported by Coverity:
```
Defect type: SUPPRESSED_ERROR
1. osbuild-composer-75/_build/src/github.com/osbuild/osbuild-composer/internal/manifest/os.go:546: suppressed_error: The error returned by the function "GetVerStrFromPackageSpecList(p.packageSpecs, "dracut-config-rescue")" is not explicitly checked.
2. osbuild-composer-75/_build/src/github.com/osbuild/osbuild-composer/internal/manifest/os.go:546: remediation: Explicitly check the return error.
   544|   				}
   545|
   546|-> 				rescueVer, _ := rpmmd.GetVerStrFromPackageSpecList(p.packageSpecs, "dracut-config-rescue")
   547|   				hasRescue := rescueVer != ""
   548|   				bootloader = osbuild.NewGrub2LegacyStage(
```

Change the code to check if the called function returned an error or
not. If not error is returned, then the function returns a package
version string.

Signed-off-by: Tomáš Hozza <thozza@redhat.com>
This commit is contained in:
Tomáš Hozza 2023-02-23 10:59:24 +01:00 committed by Achilleas Koutsou
parent 75e6333b9e
commit f8b39cd34e

View file

@ -544,8 +544,8 @@ func (p *OS) serialize() osbuild.Pipeline {
Nick: p.OSNick,
}
rescueVer, _ := rpmmd.GetVerStrFromPackageSpecList(p.packageSpecs, "dracut-config-rescue")
hasRescue := rescueVer != ""
_, err := rpmmd.GetVerStrFromPackageSpecList(p.packageSpecs, "dracut-config-rescue")
hasRescue := err == nil
bootloader = osbuild.NewGrub2LegacyStage(
osbuild.NewGrub2LegacyStageOptions(
p.Grub2Config,