[Qemu-devel] [PATCH 00/24] QemuOpts util/cutils: Fix and clean up number conversions

Markus Armbruster posted 24 patches 157 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1487067971-10443-1-git-send-email-armbru@redhat.com
Test checkpatch failed
Test docker passed
Test s390x passed
hmp.c                  |  11 +-
hw/misc/ivshmem.c      |   9 +-
include/qemu/cutils.h  |  29 +--
monitor.c              |   7 +-
qapi/opts-visitor.c    |  11 +-
qemu-img.c             |  62 ++---
qemu-io-cmds.c         |  16 +-
qobject/qdict.c        |   2 +-
qtest.c                |  34 +--
target/i386/cpu.c      |   9 +-
tests/test-cutils.c    | 642 ++++++++++++++++++++++++++++++++-----------------
tests/test-qemu-opts.c | 289 +++++++++++++++++++++-
util/cutils.c          | 239 +++++++++---------
util/log.c             |   4 +-
util/qemu-option.c     |  87 +++----
15 files changed, 959 insertions(+), 492 deletions(-)

[Qemu-devel] [PATCH 00/24] QemuOpts util/cutils: Fix and clean up number conversions

Posted by Markus Armbruster 157 weeks ago
QemuOpts has its own code to convert strings to numbers, and being
QemuOpts, it gets it wrong.  util/cutils is less wrong.  Fix it up
some, and reuse it for QemuOpts.

Markus Armbruster (24):
  tests/test-qemu-opts: Cover qemu_opts_parse()
  QemuOpts: Assert value string isn't null
  tests/test-cutils: Add missing qemu_strtol()... endptr checks
  tests/test-cutils: Clean up qemu_strtoul() result checks
  util/cutils: Rewrite documentation of qemu_strtol() & friends
  util/cutils: Rename qemu_strtoll(), qemu_strtoull()
  util/cutils: Clean up variable names around qemu_strtol()
  util/cutils: Clean up control flow around qemu_strtol() a bit
  QemuOpts: Fix to reject numbers that overflow uint64_t
  tests/test-cutils: Add missing qemu_strtosz()... endptr checks
  tests/test-cutils: Cover qemu_strtosz() invalid input
  tests/test-cutils: Cover qemu_strtosz() with trailing crap
  tests/test-cutils: Cover qemu_strtosz() around range limits
  util/cutils: New qemu_strtosz_metric()
  util/cutils: Rename qemu_strtosz() to qemu_strtosz_mebi()
  util/cutils: New qemu_strtosz()
  util/cutils: Drop QEMU_STRTOSZ_DEFSUFFIX_* macros
  tests/test-cutils: Use qemu_strtosz() more often
  tests/test-cutils: Drop suffix from test_qemu_strtosz_simple()
  qemu-img: Wrap cvtnum() around qemu_strtosz()
  util/cutils: Let qemu_strtosz*() optionally reject trailing crap
  util/cutils: Return qemu_strtosz*() error and value separately
  util/cutils: Change qemu_strtosz*() from int64_t to uint64_t
  QemuOpts: Fix checking of sizes for overflow and trailing crap

 hmp.c                  |  11 +-
 hw/misc/ivshmem.c      |   9 +-
 include/qemu/cutils.h  |  29 +--
 monitor.c              |   7 +-
 qapi/opts-visitor.c    |  11 +-
 qemu-img.c             |  62 ++---
 qemu-io-cmds.c         |  16 +-
 qobject/qdict.c        |   2 +-
 qtest.c                |  34 +--
 target/i386/cpu.c      |   9 +-
 tests/test-cutils.c    | 642 ++++++++++++++++++++++++++++++++-----------------
 tests/test-qemu-opts.c | 289 +++++++++++++++++++++-
 util/cutils.c          | 239 +++++++++---------
 util/log.c             |   4 +-
 util/qemu-option.c     |  87 +++----
 15 files changed, 959 insertions(+), 492 deletions(-)

-- 
2.7.4


Re: [Qemu-devel] [PATCH 00/24] QemuOpts util/cutils: Fix and clean up number conversions

Posted by no-reply@patchew.org 157 weeks ago
Hi,

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

Subject: [Qemu-devel] [PATCH 00/24] QemuOpts util/cutils: Fix and clean up number conversions
Message-id: 1487067971-10443-1-git-send-email-armbru@redhat.com
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash

BASE=base
n=1
total=$(git log --oneline $BASE.. | wc -l)
failed=0

# Useful git options
git config --local diff.renamelimit 0
git config --local diff.renames True

commits="$(git log --format=%H --reverse $BASE..)"
for c in $commits; do
    echo "Checking PATCH $n/$total: $(git log -n 1 --format=%s $c)..."
    if ! git show $c --format=email | ./scripts/checkpatch.pl --mailback -; then
        failed=1
        echo
    fi
    n=$((n+1))
done

exit $failed
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]         patchew/1487067971-10443-1-git-send-email-armbru@redhat.com -> patchew/1487067971-10443-1-git-send-email-armbru@redhat.com
Switched to a new branch 'test'
855de21 QemuOpts: Fix checking of sizes for overflow and trailing crap
704c59b util/cutils: Change qemu_strtosz*() from int64_t to uint64_t
926a170 util/cutils: Return qemu_strtosz*() error and value separately
3efa6d4 util/cutils: Let qemu_strtosz*() optionally reject trailing crap
bd4e31d qemu-img: Wrap cvtnum() around qemu_strtosz()
18a3da0 tests/test-cutils: Drop suffix from test_qemu_strtosz_simple()
f2880dd tests/test-cutils: Use qemu_strtosz() more often
8e04b3b util/cutils: Drop QEMU_STRTOSZ_DEFSUFFIX_* macros
25f2bf6 util/cutils: New qemu_strtosz()
d133023 util/cutils: Rename qemu_strtosz() to qemu_strtosz_mebi()
5c33f1b util/cutils: New qemu_strtosz_metric()
567a856 tests/test-cutils: Cover qemu_strtosz() around range limits
5eea8e0 tests/test-cutils: Cover qemu_strtosz() with trailing crap
db765f5 tests/test-cutils: Cover qemu_strtosz() invalid input
958d0f3 tests/test-cutils: Add missing qemu_strtosz()... endptr checks
7c61791 QemuOpts: Fix to reject numbers that overflow uint64_t
29872d3 util/cutils: Clean up control flow around qemu_strtol() a bit
3a696e2 util/cutils: Clean up variable names around qemu_strtol()
b2e8b59 util/cutils: Rename qemu_strtoll(), qemu_strtoull()
5153908 util/cutils: Rewrite documentation of qemu_strtol() & friends
32a7846 tests/test-cutils: Clean up qemu_strtoul() result checks
2a602fb tests/test-cutils: Add missing qemu_strtol()... endptr checks
ebda9f0 QemuOpts: Assert value string isn't null
aced107 tests/test-qemu-opts: Cover qemu_opts_parse()

=== OUTPUT BEGIN ===
Checking PATCH 1/24: tests/test-qemu-opts: Cover qemu_opts_parse()...
Checking PATCH 2/24: QemuOpts: Assert value string isn't null...
ERROR: consider using qemu_strtoull in preference to strtoull
#75: FILE: util/qemu-option.c:147:
+    number = strtoull(value, &postfix, 0);

total: 1 errors, 0 warnings, 117 lines checked

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

Checking PATCH 3/24: tests/test-cutils: Add missing qemu_strtol()... endptr checks...
Checking PATCH 4/24: tests/test-cutils: Clean up qemu_strtoul() result checks...
Checking PATCH 5/24: util/cutils: Rewrite documentation of qemu_strtol() & friends...
Checking PATCH 6/24: util/cutils: Rename qemu_strtoll(), qemu_strtoull()...
Checking PATCH 7/24: util/cutils: Clean up variable names around qemu_strtol()...
ERROR: consider using qemu_strtol in preference to strtol
#76: FILE: util/cutils.c:316:
+        *result = strtol(nptr, &ep, base);

ERROR: consider using qemu_strtoul in preference to strtoul
#95: FILE: util/cutils.c:359:
+        *result = strtoul(nptr, &ep, base);

ERROR: consider using qemu_strtoll in preference to strtoll
#120: FILE: util/cutils.c:388:
+        *result = strtoll(nptr, &ep, base);

ERROR: consider using qemu_strtoull in preference to strtoull
#139: FILE: util/cutils.c:412:
+        *result = strtoull(nptr, &ep, base);

total: 4 errors, 0 warnings, 110 lines checked

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

Checking PATCH 8/24: util/cutils: Clean up control flow around qemu_strtol() a bit...
ERROR: consider using qemu_strtol in preference to strtol
#81: FILE: util/cutils.c:322:
+    *result = strtol(nptr, &ep, base);

ERROR: consider using qemu_strtoul in preference to strtoul
#109: FILE: util/cutils.c:364:
+    *result = strtoul(nptr, &ep, base);

ERROR: consider using qemu_strtoll in preference to strtoll
#141: FILE: util/cutils.c:392:
+    *result = strtoll(nptr, &ep, base);

ERROR: consider using qemu_strtoull in preference to strtoull
#171: FILE: util/cutils.c:415:
+    *result = strtoull(nptr, &ep, base);

total: 4 errors, 0 warnings, 140 lines checked

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

Checking PATCH 9/24: QemuOpts: Fix to reject numbers that overflow uint64_t...
Checking PATCH 10/24: tests/test-cutils: Add missing qemu_strtosz()... endptr checks...
Checking PATCH 11/24: tests/test-cutils: Cover qemu_strtosz() invalid input...
Checking PATCH 12/24: tests/test-cutils: Cover qemu_strtosz() with trailing crap...
Checking PATCH 13/24: tests/test-cutils: Cover qemu_strtosz() around range limits...
Checking PATCH 14/24: util/cutils: New qemu_strtosz_metric()...
Checking PATCH 15/24: util/cutils: Rename qemu_strtosz() to qemu_strtosz_mebi()...
Checking PATCH 16/24: util/cutils: New qemu_strtosz()...
Checking PATCH 17/24: util/cutils: Drop QEMU_STRTOSZ_DEFSUFFIX_* macros...
Checking PATCH 18/24: tests/test-cutils: Use qemu_strtosz() more often...
Checking PATCH 19/24: tests/test-cutils: Drop suffix from test_qemu_strtosz_simple()...
Checking PATCH 20/24: qemu-img: Wrap cvtnum() around qemu_strtosz()...
Checking PATCH 21/24: util/cutils: Let qemu_strtosz*() optionally reject trailing crap...
Checking PATCH 22/24: util/cutils: Return qemu_strtosz*() error and value separately...
Checking PATCH 23/24: util/cutils: Change qemu_strtosz*() from int64_t to uint64_t...
Checking PATCH 24/24: QemuOpts: Fix checking of sizes for overflow and trailing crap...
=== OUTPUT END ===

Test command exited with code: 1


---
Email generated automatically by Patchew [http://patchew.org/].
Please send your feedback to patchew-devel@freelists.org

Re: [Qemu-devel] [PATCH 00/24] QemuOpts util/cutils: Fix and clean up number conversions

Posted by Paolo Bonzini 157 weeks ago

On 14/02/2017 11:25, Markus Armbruster wrote:
> QemuOpts has its own code to convert strings to numbers, and being
> QemuOpts, it gets it wrong.  util/cutils is less wrong.  Fix it up
> some, and reuse it for QemuOpts.

Nice.  I only had a couple minor remarks.

Paolo

> Markus Armbruster (24):
>   tests/test-qemu-opts: Cover qemu_opts_parse()
>   QemuOpts: Assert value string isn't null
>   tests/test-cutils: Add missing qemu_strtol()... endptr checks
>   tests/test-cutils: Clean up qemu_strtoul() result checks
>   util/cutils: Rewrite documentation of qemu_strtol() & friends
>   util/cutils: Rename qemu_strtoll(), qemu_strtoull()
>   util/cutils: Clean up variable names around qemu_strtol()
>   util/cutils: Clean up control flow around qemu_strtol() a bit
>   QemuOpts: Fix to reject numbers that overflow uint64_t
>   tests/test-cutils: Add missing qemu_strtosz()... endptr checks
>   tests/test-cutils: Cover qemu_strtosz() invalid input
>   tests/test-cutils: Cover qemu_strtosz() with trailing crap
>   tests/test-cutils: Cover qemu_strtosz() around range limits
>   util/cutils: New qemu_strtosz_metric()
>   util/cutils: Rename qemu_strtosz() to qemu_strtosz_mebi()
>   util/cutils: New qemu_strtosz()
>   util/cutils: Drop QEMU_STRTOSZ_DEFSUFFIX_* macros
>   tests/test-cutils: Use qemu_strtosz() more often
>   tests/test-cutils: Drop suffix from test_qemu_strtosz_simple()
>   qemu-img: Wrap cvtnum() around qemu_strtosz()
>   util/cutils: Let qemu_strtosz*() optionally reject trailing crap
>   util/cutils: Return qemu_strtosz*() error and value separately
>   util/cutils: Change qemu_strtosz*() from int64_t to uint64_t
>   QemuOpts: Fix checking of sizes for overflow and trailing crap