qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/3] envlist.c: handle strdup failure


From: Jim Meyering
Subject: Re: [Qemu-devel] [PATCH 1/3] envlist.c: handle strdup failure
Date: Tue, 22 May 2012 11:05:55 +0200

Kevin Wolf wrote:
> A patch replacing tabs by spaces isn't really the kind of patches that
> we would want to avoid during freeze. It's easy enough to check with git
> diff -w that it doesn't change anything semantically.

That makes sense, so I've posted two patches:

    1) two patches: one replacing all leading TABs with equivalent spaces,
          then the above patch

Note however, that envlist.c must predate checkpatch.pl, since
that patch provokes numerous warnings about style issues:
(hmm... I've just noticed these first two, which seem to suggest
that even for comments I should remove the TABs.  Is it worth
a V2 to fix those two lines?  Or are they false positives, since
they're not really "code" indentation?  )

ERROR: code indent should never use tabs
#23: FILE: envlist.c:11:
+        const char *ev_var;^I^I^I/* actual env value */$

ERROR: code indent should never use tabs
#30: FILE: envlist.c:16:
+        QLIST_HEAD(, envlist_entry) el_entries;^I/* actual entries */$

ERROR: code indent should never use tabs
#31: FILE: envlist.c:17:
+        size_t el_count;^I^I^I/* number of entries */$

WARNING: space prohibited between function name and open parenthesis '('
#44: FILE: envlist.c:32:
+        if ((envlist = malloc(sizeof (*envlist))) == NULL)

ERROR: do not use assignment in if condition
#44: FILE: envlist.c:32:
+        if ((envlist = malloc(sizeof (*envlist))) == NULL)

WARNING: braces {} are necessary for all arms of this statement
#44: FILE: envlist.c:32:
+        if ((envlist = malloc(sizeof (*envlist))) == NULL)
[...]

ERROR: return is not a function, parentheses are not required
#45: FILE: envlist.c:33:
+                return (NULL);

ERROR: return is not a function, parentheses are not required
#53: FILE: envlist.c:38:
+        return (envlist);

ERROR: return is not a function, parentheses are not required
#90: FILE: envlist.c:75:
+        return (envlist_parse(envlist, env, &envlist_setenv));

ERROR: return is not a function, parentheses are not required
#99: FILE: envlist.c:87:
+        return (envlist_parse(envlist, env, &envlist_unsetenv));

WARNING: braces {} are necessary for all arms of this statement
#138: FILE: envlist.c:105:
+        if ((envlist == NULL) || (env == NULL))
[...]

ERROR: return is not a function, parentheses are not required
#139: FILE: envlist.c:106:
+                return (EINVAL);

ERROR: do not use assignment in if condition
#145: FILE: envlist.c:112:
+        if ((tmpenv = strdup(env)) == NULL)

WARNING: braces {} are necessary for all arms of this statement
#145: FILE: envlist.c:112:
+        if ((tmpenv = strdup(env)) == NULL)
[...]

ERROR: return is not a function, parentheses are not required
#146: FILE: envlist.c:113:
+                return (errno);

ERROR: return is not a function, parentheses are not required
#152: FILE: envlist.c:119:
+                        return (errno);

ERROR: return is not a function, parentheses are not required
#158: FILE: envlist.c:125:
+        return (0);

WARNING: braces {} are necessary for all arms of this statement
#210: FILE: envlist.c:141:
+        if ((envlist == NULL) || (env == NULL))
[...]

ERROR: return is not a function, parentheses are not required
#211: FILE: envlist.c:142:
+                return (EINVAL);

ERROR: do not use assignment in if condition
#214: FILE: envlist.c:145:
+        if ((eq_sign = strchr(env, '=')) == NULL)

WARNING: braces {} are necessary for all arms of this statement
#214: FILE: envlist.c:145:
+        if ((eq_sign = strchr(env, '=')) == NULL)
[...]

ERROR: return is not a function, parentheses are not required
#215: FILE: envlist.c:146:
+                return (EINVAL);

WARNING: braces {} are necessary for all arms of this statement
#225: FILE: envlist.c:156:
+                if (strncmp(entry->ev_var, env, envname_len) == 0)
[...]

WARNING: space prohibited between function name and open parenthesis '('
#237: FILE: envlist.c:168:
+        if ((entry = malloc(sizeof (*entry))) == NULL)

ERROR: do not use assignment in if condition
#237: FILE: envlist.c:168:
+        if ((entry = malloc(sizeof (*entry))) == NULL)

WARNING: braces {} are necessary for all arms of this statement
#237: FILE: envlist.c:168:
+        if ((entry = malloc(sizeof (*entry))) == NULL)
[...]

ERROR: return is not a function, parentheses are not required
#238: FILE: envlist.c:169:
+                return (errno);

ERROR: do not use assignment in if condition
#239: FILE: envlist.c:170:
+        if ((entry->ev_var = strdup(env)) == NULL) {

ERROR: return is not a function, parentheses are not required
#241: FILE: envlist.c:172:
+                return (errno);

ERROR: return is not a function, parentheses are not required
#245: FILE: envlist.c:176:
+        return (0);

WARNING: braces {} are necessary for all arms of this statement
#284: FILE: envlist.c:189:
+        if ((envlist == NULL) || (env == NULL))
[...]

ERROR: return is not a function, parentheses are not required
#285: FILE: envlist.c:190:
+                return (EINVAL);

WARNING: braces {} are necessary for all arms of this statement
#288: FILE: envlist.c:193:
+        if (strchr(env, '=') != NULL)
[...]

ERROR: return is not a function, parentheses are not required
#289: FILE: envlist.c:194:
+                return (EINVAL);

WARNING: braces {} are necessary for all arms of this statement
#298: FILE: envlist.c:203:
+                if (strncmp(entry->ev_var, env, envname_len) == 0)
[...]

ERROR: return is not a function, parentheses are not required
#308: FILE: envlist.c:213:
+        return (0);

WARNING: space prohibited between function name and open parenthesis '('
#324: FILE: envlist.c:232:
+        penv = env = malloc((envlist->el_count + 1) * sizeof (char *));

WARNING: braces {} are necessary for all arms of this statement
#325: FILE: envlist.c:233:
+        if (env == NULL)
[...]

ERROR: return is not a function, parentheses are not required
#326: FILE: envlist.c:234:
+                return (NULL);

WARNING: braces {} are necessary for all arms of this statement
#341: FILE: envlist.c:242:
+        if (count != NULL)
[...]

ERROR: return is not a function, parentheses are not required
#345: FILE: envlist.c:245:
+        return (env);

total: 26 errors, 15 warnings, 321 lines checked

.qe-strdup/0001-envlist.c-convert-many-leading-TABs-to-spaces-via-ex.patch has 
style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
total: 0 errors, 0 warnings, 18 lines checked

.qe-strdup/0002-envlist.c-handle-strdup-failure.patch has no obvious style 
problems and is ready for submission.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]