Skip to contentSkip to conversation

query_krb5_ccache: Removed dead code that was flagged by a covscan

PATCH In review Steve Dickson 2 participants 5 messages Feb 7, 2020 – Feb 8, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 query_krb5_ccache: Removed dead code that was flagged by a covscan

---
 utils/gssd/krb5_util.c | 2 --
 1 file changed, 2 deletions(-)
utils/gssd/krb5_util.c +0 -2
index bff759f..a1c43d2 100644
@@ -1066,8 +1066,6 @@ query_krb5_ccache(const char* cred_cache, char **ret_princname,
 			    *ret_realm = strdup(str+1);
 		    }
 		    k5_free_unparsed_name(context, princstring);
-		} else {
-			found = 0;
 		}
 	}
 	krb5_free_principal(context, principal);
Signature · 1 line
2.24.1
#1 lore raw
Quoted 1 line · Steve Dickson

Committed... (tag: nfs-utils-2-4-3-rc7)

steved.

Quoted 18 lines
---
 utils/gssd/krb5_util.c | 2 --
 1 file changed, 2 deletions(-)
utils/gssd/krb5_util.c +0 -2
index bff759f..a1c43d2 100644
@@ -1066,8 +1066,6 @@ query_krb5_ccache(const char* cred_cache, char **ret_princname,
 			    *ret_realm = strdup(str+1);
 		    }
 		    k5_free_unparsed_name(context, princstring);
-		} else {
-			found = 0;
 		}
 	}
 	krb5_free_principal(context, principal);
#2 lore raw
In reply to Steve Dickson
Quoted 11 lines · Steve Dickson
---
 utils/gssd/krb5_util.c | 2 --
 1 file changed, 2 deletions(-)
utils/gssd/krb5_util.c +0 -0
index bff759f..a1c43d2 100644

utils/gssd/krb5_util.c query_krb5_ccache(const char* cred_cache, char **ret_princname, · line 1069

Quoted 6 lines
utils/gssd/krb5_util.c +0 -2
@@ -1066,8 +1066,6 @@ query_krb5_ccache(const char* cred_cache, char **ret_princname,
                            *ret_realm = strdup(str+1);
                    }
                    k5_free_unparsed_name(context, princstring);
-               } else {
-                       found = 0;
                }

Uhm, sorry wasn't fast enough for you commit decision but I don't see that this a dead code? krb5_unparse_string() could return an error so "else" is a valid condition. I mean it's probably unlikely that check_for_tgt() returns found and they you can't parse the principal name out of it. But things like memory errors could still be valid error conditions?

Quoted 5 lines
utils/gssd/krb5_util.c +0 -1
        }
        krb5_free_principal(context, principal);
--

2.24.1

#3 lore raw
Quoted 17 lines · Olga Kornievskaia
Quoted 16 lines · Steve Dickson
---
 utils/gssd/krb5_util.c | 2 --
 1 file changed, 2 deletions(-)
utils/gssd/krb5_util.c +0 -2
index bff759f..a1c43d2 100644
@@ -1066,8 +1066,6 @@ query_krb5_ccache(const char* cred_cache, char **ret_princname,
                            *ret_realm = strdup(str+1);
                    }
                    k5_free_unparsed_name(context, princstring);
-               } else {
-                       found = 0;
Quoted 8 lines

utils/gssd/krb5_util.c query_krb5_ccache(const char* cred_cache, char **ret_princname, · line 1069

Quoted 1 line
utils/gssd/krb5_util.c +0 -0
                }

Uhm, sorry wasn't fast enough for you commit decision but I don't see that this a dead code? krb5_unparse_string() could return an error so "else" is a valid condition. I mean it's probably unlikely that check_for_tgt() returns found and they you can't parse the principal name out of it. But things like memory errors could still be valid error conditions?

Sorry for being so quick with the commit...

The covscan complained "warning: Value stored to 'found' is never read" which was true... after setting found = 0, found was never used.

Yes, the "else" is a valid condition but not necessary since setting 'found' to zero does not do anything...

steved.

Quoted 8 lines
Quoted 7 lines
utils/gssd/krb5_util.c +0 -1
        }
        krb5_free_principal(context, principal);
--

2.24.1

#4 lore raw
Quoted 29 lines · Steve Dickson
Quoted 17 lines · Olga Kornievskaia
Quoted 16 lines · Steve Dickson
---
 utils/gssd/krb5_util.c | 2 --
 1 file changed, 2 deletions(-)
utils/gssd/krb5_util.c +0 -2
index bff759f..a1c43d2 100644
@@ -1066,8 +1066,6 @@ query_krb5_ccache(const char* cred_cache, char **ret_princname,
                            *ret_realm = strdup(str+1);
                    }
                    k5_free_unparsed_name(context, princstring);
-               } else {
-                       found = 0;
Quoted 8 lines

utils/gssd/krb5_util.c query_krb5_ccache(const char* cred_cache, char **ret_princname, · line 1069

Quoted 1 line
utils/gssd/krb5_util.c +0 -0
                }

Uhm, sorry wasn't fast enough for you commit decision but I don't see that this a dead code? krb5_unparse_string() could return an error so "else" is a valid condition. I mean it's probably unlikely that check_for_tgt() returns found and they you can't parse the principal name out of it. But things like memory errors could still be valid error conditions?

Quoted 7 lines

Sorry for being so quick with the commit...

The covscan complained "warning: Value stored to 'found' is never read" which was true... after setting found = 0, found was never used.

Yes, the "else" is a valid condition but not necessary since setting 'found' to zero does not do anything...

Got it. Thanks Steve for the explanation.

Quoted 12 lines

steved.

Quoted 8 lines
Quoted 7 lines
utils/gssd/krb5_util.c +0 -1
        }
        krb5_free_principal(context, principal);
--

2.24.1