New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PATCH] Coverity: false nesting #13775
Comments
From @jhiIndentation of the code lies about the logic. Attached. |
From @jhi0001-Fix-for-Coverity-perl5-CID-29014.patchFrom add64bbf239e11a941d7672b55c83d9eb93cda93 Mon Sep 17 00:00:00 2001
From: Jarkko Hietaniemi <jhi@iki.fi>
Date: Wed, 23 Apr 2014 12:59:37 -0400
Subject: [PATCH] Fix for Coverity perl5 CID 29014: Nesting level does not
match indentation (NESTING_INDENT_MISMATCH)
---
util.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/util.c b/util.c
index 0a0ee40..3798621 100644
--- a/util.c
+++ b/util.c
@@ -2034,12 +2034,12 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val)
}
else
safesysfree(environ[i]);
- nlen = strlen(nam);
- vlen = strlen(val);
+ nlen = strlen(nam);
+ vlen = strlen(val);
- environ[i] = (char*)safesysmalloc((nlen+vlen+2) * sizeof(char));
- /* all that work just for this */
- my_setenv_format(environ[i], nam, nlen, val, vlen);
+ environ[i] = (char*)safesysmalloc((nlen+vlen+2) * sizeof(char));
+ /* all that work just for this */
+ my_setenv_format(environ[i], nam, nlen, val, vlen);
} else {
# endif
# if defined(__CYGWIN__)|| defined(__SYMBIAN32__) || defined(__riscos__)
--
1.9.2
|
From @tonycozOn Sat Apr 26 12:59:37 2014, jhi wrote:
Added as a blocker, but I wonder if it wouldn't be better to just re-indent that whole if (!PL_use_safe_putenv) block. Tony |
The RT System itself - Status changed from 'new' to 'open' |
From @jhiOn Sunday-201404-27, 23:32, Tony Cook via RT wrote:
I tried to keep the (whitespace) changes to minimum, but sure, works for |
From @jhi0001-Fix-for-Coverity-perl5-CID-29014.patchFrom add64bbf239e11a941d7672b55c83d9eb93cda93 Mon Sep 17 00:00:00 2001
From: Jarkko Hietaniemi <jhi@iki.fi>
Date: Wed, 23 Apr 2014 12:59:37 -0400
Subject: [PATCH] Fix for Coverity perl5 CID 29014: Nesting level does not
match indentation (NESTING_INDENT_MISMATCH)
---
util.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/util.c b/util.c
index 0a0ee40..3798621 100644
--- a/util.c
+++ b/util.c
@@ -2034,12 +2034,12 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val)
}
else
safesysfree(environ[i]);
- nlen = strlen(nam);
- vlen = strlen(val);
+ nlen = strlen(nam);
+ vlen = strlen(val);
- environ[i] = (char*)safesysmalloc((nlen+vlen+2) * sizeof(char));
- /* all that work just for this */
- my_setenv_format(environ[i], nam, nlen, val, vlen);
+ environ[i] = (char*)safesysmalloc((nlen+vlen+2) * sizeof(char));
+ /* all that work just for this */
+ my_setenv_format(environ[i], nam, nlen, val, vlen);
} else {
# endif
# if defined(__CYGWIN__)|| defined(__SYMBIAN32__) || defined(__riscos__)
--
1.9.2
|
From @jhiOn Monday-201404-28, 7:18, Jarkko Hietaniemi wrote:
Argh. Take two of take two attached. |
From @jhi0001-Fix-for-Coverity-perl5-CID-29014.patchFrom 273eb0474b161c9825fc94741964e2db147f5d45 Mon Sep 17 00:00:00 2001
From: Jarkko Hietaniemi <jhi@iki.fi>
Date: Wed, 23 Apr 2014 12:59:37 -0400
Subject: [PATCH] Fix for Coverity perl5 CID 29014: Nesting level does not
match indentation (NESTING_INDENT_MISMATCH)
---
util.c | 92 +++++++++++++++++++++++++++++++++---------------------------------
1 file changed, 46 insertions(+), 46 deletions(-)
diff --git a/util.c b/util.c
index 0a0ee40..11ff6a3 100644
--- a/util.c
+++ b/util.c
@@ -1992,54 +1992,54 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val)
{
#ifndef PERL_USE_SAFE_PUTENV
if (!PL_use_safe_putenv) {
- /* most putenv()s leak, so we manipulate environ directly */
- I32 i;
- const I32 len = strlen(nam);
- int nlen, vlen;
-
- /* where does it go? */
- for (i = 0; environ[i]; i++) {
- if (strnEQ(environ[i],nam,len) && environ[i][len] == '=')
- break;
- }
+ /* most putenv()s leak, so we manipulate environ directly */
+ I32 i;
+ const I32 len = strlen(nam);
+ int nlen, vlen;
+
+ /* where does it go? */
+ for (i = 0; environ[i]; i++) {
+ if (strnEQ(environ[i],nam,len) && environ[i][len] == '=')
+ break;
+ }
- if (environ == PL_origenviron) { /* need we copy environment? */
- I32 j;
- I32 max;
- char **tmpenv;
-
- max = i;
- while (environ[max])
- max++;
- tmpenv = (char**)safesysmalloc((max+2) * sizeof(char*));
- for (j=0; j<max; j++) { /* copy environment */
- const int len = strlen(environ[j]);
- tmpenv[j] = (char*)safesysmalloc((len+1)*sizeof(char));
- Copy(environ[j], tmpenv[j], len+1, char);
- }
- tmpenv[max] = NULL;
- environ = tmpenv; /* tell exec where it is now */
- }
- if (!val) {
- safesysfree(environ[i]);
- while (environ[i]) {
- environ[i] = environ[i+1];
- i++;
- }
- return;
- }
- if (!environ[i]) { /* does not exist yet */
- environ = (char**)safesysrealloc(environ, (i+2) * sizeof(char*));
- environ[i+1] = NULL; /* make sure it's null terminated */
- }
- else
- safesysfree(environ[i]);
- nlen = strlen(nam);
- vlen = strlen(val);
+ if (environ == PL_origenviron) { /* need we copy environment? */
+ I32 j;
+ I32 max;
+ char **tmpenv;
+
+ max = i;
+ while (environ[max])
+ max++;
+ tmpenv = (char**)safesysmalloc((max+2) * sizeof(char*));
+ for (j=0; j<max; j++) { /* copy environment */
+ const int len = strlen(environ[j]);
+ tmpenv[j] = (char*)safesysmalloc((len+1)*sizeof(char));
+ Copy(environ[j], tmpenv[j], len+1, char);
+ }
+ tmpenv[max] = NULL;
+ environ = tmpenv; /* tell exec where it is now */
+ }
+ if (!val) {
+ safesysfree(environ[i]);
+ while (environ[i]) {
+ environ[i] = environ[i+1];
+ i++;
+ }
+ return;
+ }
+ if (!environ[i]) { /* does not exist yet */
+ environ = (char**)safesysrealloc(environ, (i+2) * sizeof(char*));
+ environ[i+1] = NULL; /* make sure it's null terminated */
+ }
+ else
+ safesysfree(environ[i]);
+ nlen = strlen(nam);
+ vlen = strlen(val);
- environ[i] = (char*)safesysmalloc((nlen+vlen+2) * sizeof(char));
- /* all that work just for this */
- my_setenv_format(environ[i], nam, nlen, val, vlen);
+ environ[i] = (char*)safesysmalloc((nlen+vlen+2) * sizeof(char));
+ /* all that work just for this */
+ my_setenv_format(environ[i], nam, nlen, val, vlen);
} else {
# endif
# if defined(__CYGWIN__)|| defined(__SYMBIAN32__) || defined(__riscos__)
--
1.9.2
|
From @khwilliamsonOn 04/28/2014 05:20 AM, Jarkko Hietaniemi wrote:
The procedure we are using nowadays when there is non-trivial white |
From @tonycozOn Mon Apr 28 04:21:12 2014, jhi wrote:
Split and applied as 99e8c55 and b7d8786 by Jarkkoon the 29th. Tony |
@tonycoz - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#121744 (status was 'resolved')
Searchable as RT121744$
The text was updated successfully, but these errors were encountered: