diff options
| author | Simo Sorce <simo@redhat.com> | 2014-06-09 14:09:20 -0400 |
|---|---|---|
| committer | Simo Sorce <simo@redhat.com> | 2014-06-09 15:34:18 -0400 |
| commit | 3904eae57a79f2c535ab2c8b8ea8a9932e4b5e4e (patch) | |
| tree | 29da7b05a04e7cca016cb4c994d94cffaef33648 | |
| parent | 7d3fb462dc388e4e5d32fb0cf853a946314df87f (diff) | |
| download | lasso-3904eae57a79f2c535ab2c8b8ea8a9932e4b5e4e.tar.gz lasso-3904eae57a79f2c535ab2c8b8ea8a9932e4b5e4e.tar.xz lasso-3904eae57a79f2c535ab2c8b8ea8a9932e4b5e4e.zip | |
Rearrange case checking to avoid compiler warnings
The compiler was complaining that 'compa' could be uninitialized.
USe this occasion to make the code simpler to understand and assign
actually meaningful values to the variable, even though the proper
actions are not implemented yet.
License: MIT
Signed-off-by: Simo Sorce <simo@redhat.com>
| -rw-r--r-- | lasso/id-ff/login.c | 24 | ||||
| -rw-r--r-- | lasso/saml-2.0/login.c | 30 |
2 files changed, 33 insertions, 21 deletions
diff --git a/lasso/id-ff/login.c b/lasso/id-ff/login.c index 8c4b9ae7..b192dfd6 100644 --- a/lasso/id-ff/login.c +++ b/lasso/id-ff/login.c @@ -1824,16 +1824,16 @@ lasso_login_must_authenticate(LassoLogin *login) char *class_ref; GList *class_refs = request->RequestAuthnContext->AuthnContextClassRef; GList *t1, *t2; - int compa; + int compa = -1; if (comparison == NULL || strcmp(comparison, "exact") == 0) { compa = 0; } else if (strcmp(comparison, "minimum") == 0) { message(G_LOG_LEVEL_CRITICAL, "'minimum' comparison is not implemented"); - compa = 0; + compa = 1; } else if (strcmp(comparison, "better") == 0) { message(G_LOG_LEVEL_CRITICAL, "'better' comparison is not implemented"); - compa = 0; + compa = 2; } if (class_refs) { @@ -1867,15 +1867,21 @@ lasso_login_must_authenticate(LassoLogin *login) method = LASSO_LIB_AUTHN_CONTEXT_CLASS_REF_PASSWORD; } - if (compa == 0) { /* exact */ + switch (compa) { + case 1: /* minimum */ + /* XXX: implement 'minimum' comparison */ + case 2: /* better */ + /* XXX: implement 'better' comparison */ + case 0: /* exact */ if (strcmp(method, class_ref) == 0) { matched = TRUE; - break; } - } else if (compa == 1) { /* minimum */ - /* XXX: implement 'minimum' comparison */ - } else if (compa == 2) { /* better */ - /* XXX: implement 'better' comparison */ + break; + default: /* inever reached */ + break; + } + if (matched == TRUE) { + break; } } } diff --git a/lasso/saml-2.0/login.c b/lasso/saml-2.0/login.c index e3d0ff72..b5256ceb 100644 --- a/lasso/saml-2.0/login.c +++ b/lasso/saml-2.0/login.c @@ -405,19 +405,19 @@ lasso_saml20_login_must_authenticate(LassoLogin *login) GList *class_refs = request->RequestedAuthnContext->AuthnContextClassRef; char *class_ref; GList *t1, *t2; - int compa; + int compa = -1; if (comparison == NULL || lasso_strisequal(comparison,"exact")) { compa = 0; } else if (lasso_strisequal(comparison,"minimum")) { message(G_LOG_LEVEL_CRITICAL, "'minimum' comparison is not implemented"); - compa = 0; + compa = 1; } else if (lasso_strisequal(comparison,"better")) { message(G_LOG_LEVEL_CRITICAL, "'better' comparison is not implemented"); - compa = 0; + compa = 2; } else if (lasso_strisequal(comparison,"maximum")) { message(G_LOG_LEVEL_CRITICAL, "'maximum' comparison is not implemented"); - compa = 0; + compa = 3; } if (class_refs) { @@ -454,17 +454,23 @@ lasso_saml20_login_must_authenticate(LassoLogin *login) method = as->AuthnContext->AuthnContextClassRef; - if (compa == 0) { /* exact */ - if (lasso_strisequal(method,class_ref)) { - matched = TRUE; - break; - } - } else if (compa == 1) { /* minimum */ + switch (compa) { + case 1: /* minimum */ /* XXX: implement 'minimum' comparison */ - } else if (compa == 2) { /* better */ + case 2: /* better */ /* XXX: implement 'better' comparison */ - } else if (compa == 3) { /* maximum */ + case 3: /* maximum */ /* XXX: implement 'maximum' comparison */ + case 0: /* exact */ + if (lasso_strisequal(method,class_ref)) { + matched = TRUE; + } + break; + default: /* never reached */ + break; + } + if (matched == TRUE) { + break; } } } |
