fota_tar: Improve a bit gTarFd handling 38/271538/2 accepted/tizen/unified/20220223.231318 submit/tizen/20220223.125107
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Tue, 22 Feb 2022 14:39:02 +0000 (15:39 +0100)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Tue, 22 Feb 2022 15:05:23 +0000 (16:05 +0100)
commita951dbd0419e3cc045ede249050195e63bd91190
tree2113e72c07383be45ece2721eb5a8ac20c1f7471
parent0d2c51ad81cc1530bd9cc3d3762c1767ba2e437b
fota_tar: Improve a bit gTarFd handling

gTarFd is global fd for tar file, as managed by tar_open() & tar_close().

This commit fixes case when returned fd equals 0 (ie. program working with closed stdin)
and avoids depending on local, overwritten vars for cleanup functions, ie:

  if (gTarFd > 0)
     fd = gTarFd
  if (gTarFd < 0)
     fd = open(..)
  ...
cleanup:
  if (fd > 0)
     close(fd) // what fd it closes? gTarFd? locally opened one?

Change-Id: I83b227709ad5a97d0b0e3062f3f060cd052d98b4
ss_engine/fota_tar.c