Skip to contentSkip to conversation

Fix some style problems in qobject

PATCH In review Zhang Han 4 participants 11 messages Dec 28, 2020 – Feb 1, 2021

lore
Share & tools
lore

Zhang Han

author
#0 lore raw

cover Fix some style problems in qobject

Some style problems in qobject directory are found by checkpatch.pl. Fix these style problems.

Zhang Han (4):
qobject: open brace '{' following struct go on the same line
qobject: code indent should never use tabs
qobject: spaces required around that operators
qobject: braces {} are necessary for all arms of this statement

 qobject/json-parser.c |  3 +--
 qobject/qdict.c       | 12 +++++++-----
 qobject/qjson.c       |  3 +--
 3 files changed, 9 insertions(+), 9 deletions(-)
Signature · 1 line
2.29.1.59.gf9b6481aed
author
#1 lore raw

PATCH 1/4 qobject: open brace '{' following struct go on the same line

Put open brace '{' on the same line of struct.

---
 qobject/json-parser.c | 3 +--
 qobject/qjson.c       | 3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
qobject/json-parser.c +1 -2
index c0f521b56b..18b87a42f3 100644
@@ -31,8 +31,7 @@ struct JSONToken {
     char str[];
 };
 
-typedef struct JSONParserContext
-{
+typedef struct JSONParserContext {
     Error *err;
     JSONToken *current;
     GQueue *buf;
qobject/qjson.c +1 -2
index f1f2c69704..f5623081e3 100644
@@ -22,8 +22,7 @@
 #include "qapi/qmp/qstring.h"
 #include "qemu/unicode.h"
 
-typedef struct JSONParsingState
-{
+typedef struct JSONParsingState {
     JSONMessageParser parser;
     QObject *result;
     Error *err;
Signature · 1 line
2.29.1.59.gf9b6481aed
#5 lore raw
Quoted 3 lines · zhanghan (J)

ping?This patch set about code style problem in qobject receives no replies.

Did I miss any response?

The Christmas break ate your patches. My apologies!

[...]

author
#6 lore raw

PATCH 2/4 qobject: code indent should never use tabs

In reply to Zhang Han

Transfer tabs to spaces.

---
 qobject/qdict.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
qobject/qdict.c +2 -2
index 1079bd3f6f..2c07b3c87f 100644
@@ -38,8 +38,8 @@ QDict *qdict_new(void)
  */
 static unsigned int tdb_hash(const char *name)
 {
-    unsigned value;	/* Used to compute the hash value.  */
-    unsigned   i;	/* Used to cycle through random values. */
+    unsigned value;    /* Used to compute the hash value.  */
+    unsigned   i;      /* Used to cycle through random values. */
 
     /* Set the initial value from the key size. */
     for (value = 0x238F13AF * strlen(name), i=0; name[i]; i++)
Signature · 1 line
2.29.1.59.gf9b6481aed
author
#7 lore raw

PATCH 3/4 qobject: spaces required around that operators

In reply to Zhang Han

Add spaces around operators.

---
 qobject/qdict.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
qobject/qdict.c +2 -2
index 2c07b3c87f..05ec950e05 100644
@@ -42,8 +42,8 @@ static unsigned int tdb_hash(const char *name)
     unsigned   i;      /* Used to cycle through random values. */
 
     /* Set the initial value from the key size. */
-    for (value = 0x238F13AF * strlen(name), i=0; name[i]; i++)
-        value = (value + (((const unsigned char *)name)[i] << (i*5 % 24)));
+    for (value = 0x238F13AF * strlen(name), i = 0; name[i]; i++)
+        value = (value + (((const unsigned char *)name)[i] << (i * 5 % 24)));
 
     return (1103515243 * value + 12345);
 }
Signature · 1 line
2.29.1.59.gf9b6481aed
author
#8 lore raw

PATCH 4/4 qobject: braces {} are necessary for all arms of this statement

In reply to Zhang Han

Add braces {} for arms of if/for statement

---
 qobject/qdict.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
qobject/qdict.c +4 -2
index 05ec950e05..0a49b787ab 100644
@@ -42,8 +42,9 @@ static unsigned int tdb_hash(const char *name)
     unsigned   i;      /* Used to cycle through random values. */
 
     /* Set the initial value from the key size. */
-    for (value = 0x238F13AF * strlen(name), i = 0; name[i]; i++)
+    for (value = 0x238F13AF * strlen(name), i = 0; name[i]; i++) {
         value = (value + (((const unsigned char *)name)[i] << (i * 5 % 24)));
+    }
 
     return (1103515243 * value + 12345);
 }
@@ -92,8 +93,9 @@ static QDictEntry *qdict_find(const QDict *qdict,
     QDictEntry *entry;
 
     QLIST_FOREACH(entry, &qdict->table[bucket], next)
-        if (!strcmp(entry->key, key))
+        if (!strcmp(entry->key, key)) {
             return entry;
+        }
 
     return NULL;
 }
Signature · 1 line
2.29.1.59.gf9b6481aed
#10 lore raw
In reply to Zhang Han
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [PATCH 0/4] Fix some style problems in qobject

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu

 - [tag update]      patchew/[email protected] -> patchew/[email protected]
 - [tag update]      patchew/[email protected] -> patchew/[email protected]
 * [new tag]         patchew/[email protected] -> patchew/[email protected]

Switched to a new branch 'test'
1caa0fd qobject: braces {} are necessary for all arms of this statement b0ca07e qobject: spaces required around that operators 0adae60 qobject: code indent should never use tabs
4eea991 qobject: open brace '{' following struct go on the same line

=== OUTPUT BEGIN ===
1/4 Checking commit 4eea9919361d (qobject: open brace '{' following struct go on the same line) 2/4 Checking commit 0adae6079b21 (qobject: code indent should never use tabs) 3/4 Checking commit b0ca07e6cac6 (qobject: spaces required around that operators)
ERROR: braces {} are necessary for all arms of this statement
#22: FILE: qobject/qdict.c:45:
+ for (value = 0x238F13AF * strlen(name), i = 0; name[i]; i++)
[...]

total: 1 errors, 0 warnings, 10 lines checked

Patch 3/4 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

4/4 Checking commit 1caa0fdbcda9 (qobject: braces {} are necessary for all arms of this statement) === OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]