util/cutils: Let qemu_strtosz*() optionally reject trailing crap

Change the qemu_strtosz() & friends to return -EINVAL when @endptr is
null and the conversion doesn't consume the string completely.
Matches how qemu_strtol() & friends work.

Only test_qemu_strtosz_simple() passes a null @endptr.  No functional
change there, because its conversion consumes the string.

Simplify callers that use @endptr only to fail when it doesn't point
to '\0' to pass a null @endptr instead.

Cc: Dr. David Alan Gilbert <dgilbert@redhat.com>
Cc: Eduardo Habkost <ehabkost@redhat.com> (maintainer:X86)
Cc: Kevin Wolf <kwolf@redhat.com> (supporter:Block layer core)
Cc: Max Reitz <mreitz@redhat.com> (supporter:Block layer core)
Cc: qemu-block@nongnu.org (open list:Block layer core)
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <1487708048-2131-22-git-send-email-armbru@redhat.com>
8 files changed
tree: 78ee373aeb4aa5f17f9bd21ae042e985deb836cc
  1. audio/
  2. backends/
  3. block/
  4. bsd-user/
  5. chardev/
  6. contrib/
  7. crypto/
  8. default-configs/
  9. disas/
  10. docs/
  11. fpu/
  12. fsdev/
  13. gdb-xml/
  14. hw/
  15. include/
  16. io/
  17. libdecnumber/
  18. linux-headers/
  19. linux-user/
  20. migration/
  21. nbd/
  22. net/
  23. pc-bios/
  24. po/
  25. qapi/
  26. qga/
  27. qobject/
  28. qom/
  29. replay/
  30. roms/
  31. scripts/
  32. slirp/
  33. stubs/
  34. target/
  35. tcg/
  36. tests/
  37. trace/
  38. ui/
  39. util/
  40. .dir-locals.el
  41. .exrc
  42. .gitignore
  43. .gitmodules
  44. .mailmap
  45. .travis.yml
  46. accel.c
  47. arch_init.c
  48. atomic_template.h
  49. balloon.c
  50. block.c
  51. blockdev-nbd.c
  52. blockdev.c
  53. blockjob.c
  54. bootdevice.c
  55. bt-host.c
  56. bt-vhci.c
  57. Changelog
  58. CODING_STYLE
  59. configure
  60. COPYING
  61. COPYING.LIB
  62. cpu-exec-common.c
  63. cpu-exec.c
  64. cpus-common.c
  65. cpus.c
  66. cputlb.c
  67. device-hotplug.c
  68. device_tree.c
  69. disas.c
  70. dma-helpers.c
  71. dump.c
  72. exec.c
  73. gdbstub.c
  74. HACKING
  75. hax-stub.c
  76. hmp-commands-info.hx
  77. hmp-commands.hx
  78. hmp.c
  79. hmp.h
  80. ioport.c
  81. iothread.c
  82. kvm-all.c
  83. kvm-stub.c
  84. LICENSE
  85. MAINTAINERS
  86. Makefile
  87. Makefile.objs
  88. Makefile.target
  89. memory.c
  90. memory_ldst.inc.c
  91. memory_mapping.c
  92. module-common.c
  93. monitor.c
  94. numa.c
  95. os-posix.c
  96. os-win32.c
  97. page_cache.c
  98. qapi-schema.json
  99. qdev-monitor.c
  100. qdict-test-data.txt
  101. qemu-bridge-helper.c
  102. qemu-doc.texi
  103. qemu-ga.texi
  104. qemu-img-cmds.hx
  105. qemu-img.c
  106. qemu-img.texi
  107. qemu-io-cmds.c
  108. qemu-io.c
  109. qemu-nbd.c
  110. qemu-nbd.texi
  111. qemu-option-trace.texi
  112. qemu-options-wrapper.h
  113. qemu-options.h
  114. qemu-options.hx
  115. qemu-seccomp.c
  116. qemu-tech.texi
  117. qemu.nsi
  118. qemu.sasl
  119. qmp.c
  120. qtest.c
  121. README
  122. replication.c
  123. replication.h
  124. rules.mak
  125. softmmu_template.h
  126. spice-qemu-char.c
  127. tcg-runtime.c
  128. tci.c
  129. thunk.c
  130. tpm.c
  131. trace-events
  132. translate-all.c
  133. translate-all.h
  134. translate-common.c
  135. user-exec-stub.c
  136. user-exec.c
  137. VERSION
  138. version.rc
  139. vl.c
  140. xen-common-stub.c
  141. xen-common.c
  142. xen-hvm-stub.c
  143. xen-hvm.c
  144. xen-mapcache.c