diff mbox series

[v2,2/8] qnum: Make qnum_get_double() get const pointer

Message ID 20201116224143.1284278-3-ehabkost@redhat.com
State New
Headers show
Series qom: Use qlit to represent property defaults | expand

Commit Message

Eduardo Habkost Nov. 16, 2020, 10:41 p.m. UTC
qnum_get_double() won't change the object, the argument can be
const.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 include/qapi/qmp/qnum.h | 2 +-
 qobject/qnum.c          | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Comments

Marc-André Lureau Nov. 17, 2020, 8:26 a.m. UTC | #1
On Tue, Nov 17, 2020 at 2:43 AM Eduardo Habkost <ehabkost@redhat.com> wrote:

> qnum_get_double() won't change the object, the argument can be
> const.
>
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
>

No idea why I didn't make it const in the first place.

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

---
>  include/qapi/qmp/qnum.h | 2 +-
>  qobject/qnum.c          | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/qapi/qmp/qnum.h b/include/qapi/qmp/qnum.h
> index 25f4733efc..55c27b1c24 100644
> --- a/include/qapi/qmp/qnum.h
> +++ b/include/qapi/qmp/qnum.h
> @@ -66,7 +66,7 @@ int64_t qnum_get_int(const QNum *qn);
>  bool qnum_get_try_uint(const QNum *qn, uint64_t *val);
>  uint64_t qnum_get_uint(const QNum *qn);
>
> -double qnum_get_double(QNum *qn);
> +double qnum_get_double(const QNum *qn);
>
>  char *qnum_to_string(QNum *qn);
>
> diff --git a/qobject/qnum.c b/qobject/qnum.c
> index 017c8aa739..69fd9a82d9 100644
> --- a/qobject/qnum.c
> +++ b/qobject/qnum.c
> @@ -154,7 +154,7 @@ uint64_t qnum_get_uint(const QNum *qn)
>   *
>   * qnum_get_double() loses precision for integers beyond 53 bits.
>   */
> -double qnum_get_double(QNum *qn)
> +double qnum_get_double(const QNum *qn)
>  {
>      switch (qn->kind) {
>      case QNUM_I64:
> --
> 2.28.0
>
>
>
diff mbox series

Patch

diff --git a/include/qapi/qmp/qnum.h b/include/qapi/qmp/qnum.h
index 25f4733efc..55c27b1c24 100644
--- a/include/qapi/qmp/qnum.h
+++ b/include/qapi/qmp/qnum.h
@@ -66,7 +66,7 @@  int64_t qnum_get_int(const QNum *qn);
 bool qnum_get_try_uint(const QNum *qn, uint64_t *val);
 uint64_t qnum_get_uint(const QNum *qn);
 
-double qnum_get_double(QNum *qn);
+double qnum_get_double(const QNum *qn);
 
 char *qnum_to_string(QNum *qn);
 
diff --git a/qobject/qnum.c b/qobject/qnum.c
index 017c8aa739..69fd9a82d9 100644
--- a/qobject/qnum.c
+++ b/qobject/qnum.c
@@ -154,7 +154,7 @@  uint64_t qnum_get_uint(const QNum *qn)
  *
  * qnum_get_double() loses precision for integers beyond 53 bits.
  */
-double qnum_get_double(QNum *qn)
+double qnum_get_double(const QNum *qn)
 {
     switch (qn->kind) {
     case QNUM_I64: