C++ msgpack-0.5.7/src/msgpack/object.hpp: function parameter should be passed by reference.

27 views
Skip to first unread message

Kira Yamato

unread,
Sep 7, 2012, 10:09:24 AM9/7/12
to msgpa...@googlegroups.com

Hi,
Just for your information,

I applied the static code analysis tool 'cppcheck' to msgpack c++ code of version 0.5.7.

cppcheck reported some issues:

| object.hpp:229
| inline bool operator==(const object x, const object y)
| > Function parameter 'x' and 'y' should be passed by reference.

It could be following.
--> inline bool operator==(const object& x, const object& y)

| object.hpp:242
| inline bool operator!=(const object x, const object y)
| > Function parameter 'x' and 'y' should be passed by reference.

It could be following.
--> inline bool operator!=(const object& x, const object& y)

| object.cpp: 23
| std::ostream& operator<< (std::ostream& s, const object o)
| > Function parameter 'o' should be passed by reference.

It could be following.
--> std::ostream& operator<< (std::ostream& s, const object& o)

 

XXX| objectc.c: 171
XXX| bool msgpack_object_equal(const msgpack_object x, const msgpack_object y)
XXX| > Function parameter 'x' and 'y' should be passed by reference.

It could not be following.
--> bool msgpack_object_equal(const msgpack_object& x, const msgpack_object& y)
(compile error. Because  function msgpack_object_equal is c code, so cannot use reference.)


Regards,
 
msgpack-0.5.7-object.patch

Kira Yamato

unread,
Sep 7, 2012, 10:08:45 PM9/7/12
to msgpa...@googlegroups.com

Hi,

> XXX| objectc.c: 171
> XXX| bool msgpack_object_equal(const msgpack_object x, const msgpack_object y)
> XXX| > Function parameter 'x' and 'y' should be passed by reference.
>
> It could not be following.
> --> bool msgpack_object_equal(const msgpack_object& x, const msgpack_object& y)
> (compile error. Because  function msgpack_object_equal is c code, so cannot use reference.)

Also, I show the example corrected about this point.
(See attached file)

The function msgpack_object_equal is c language interface, so I used pointer instead of reference.


Regards,
Kira Yamato:
msgpack-0.5.7-object2.patch
Reply all
Reply to author
Forward
0 new messages