[PATCH 5/8] virSecurityDACSetOwnershipInternal: Drop dead code

Michal Privoznik posted 8 patches 4 years, 7 months ago
[PATCH 5/8] virSecurityDACSetOwnershipInternal: Drop dead code
Posted by Michal Privoznik 4 years, 7 months ago
The virSecurityDACSetOwnershipInternal() function accepts two
arguments (among others): @path and @src. The idea being that in
some cases @path is NULL and @src is not and then @path is filled
from @src->path. However, this is done in both callers already
(because of seclabel remembering/recall). Therefore, this code in
virSecurityDACSetOwnershipInternal() is dead, effectively.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
---
 src/security/security_dac.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/src/security/security_dac.c b/src/security/security_dac.c
index b6323a7df1..e2a6461375 100644
--- a/src/security/security_dac.c
+++ b/src/security/security_dac.c
@@ -688,15 +688,8 @@ virSecurityDACSetOwnershipInternal(const virSecurityDACData *priv,
     } else {
         struct stat sb;
 
-        if (!path) {
-            if (!src || !src->path)
-                return 0;
-
-            if (!virStorageSourceIsLocalStorage(src))
-                return 0;
-
-            path = src->path;
-        }
+        if (!path)
+            return 0;
 
         if (stat(path, &sb) < 0) {
             virReportSystemError(errno, _("unable to stat: %s"), path);
-- 
2.31.1

Re: [PATCH 5/8] virSecurityDACSetOwnershipInternal: Drop dead code
Posted by Jano Tomko 4 years, 7 months ago
On 6/17/21 12:42 PM, Michal Privoznik wrote:
> The virSecurityDACSetOwnershipInternal() function accepts two
> arguments (among others): @path and @src. The idea being that in
> some cases @path is NULL and @src is not and then @path is filled
> from @src->path. However, this is done in both callers already
> (because of seclabel remembering/recall). Therefore, this code in
> virSecurityDACSetOwnershipInternal() is dead, effectively.
> 
> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
> ---
>  src/security/security_dac.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 

Similar dead code is also repeated in debug prints:

    VIR_INFO("Restoring DAC user and group on '%s' to %ld:%ld",
             NULLSTR(src ? src->path : path), (long)uid, (long)gid);

For the next time you get in a cleaning mood ;)

Jano