[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [PATCH v2 0/5] cmocka: Make casting macros public



> -----Original Message-----
> From: Krzysztof Opasiak [mailto:k.opasiak@xxxxxxxxxxx]
> Sent: Thursday, February 12, 2015 2:12 PM
> To: asn@xxxxxxxxxxxxxx; jakub.hrozek@xxxxxxxxx
> Cc: cmocka@xxxxxxxxxxxxxx; p.szewczyk@xxxxxxxxxxx;
> s.wadas@xxxxxxxxxxx; Krzysztof Opasiak
> Subject: [PATCH v2 0/5] cmocka: Make casting macros public
> 
> Dear Andreas and Jakub,
> 
> I'm using cmocka to wrap file system operations. Some functions,
> for example fopen() takes path as its argument. In linux path
> elements can be separated using unlimited number of slashes.
> So, for example:
> 
> /my/home/dir
> //my//////home////dir
> 
> points to the same directory and both are correct. To check
> if argument which contains path is correct we have implemented
> our own comparison function and use expect_check() macro to
> store its value. To use this macro, our function should take
> LargestIntegralType parameter. We need to cast this int to
> const char * but it causes ugly warnings:
> 
> warning: cast to pointer from integer of different size [-Wint-to-
> pointer-cast]
> 
> After reading cmocka source I have found some macros which
> does exactly the job. My commit makes those macros available
> for all cmocka users by moving their definitions to public
> headers.
> 
> First commit helps doxygen generate more suitable documentation
> by adding code section around include suggestions.
> 
> Second commit takes all the ifndef stuff from cmocka.h to
> separate header to improve cmocka API readability.
> 
> Third commit make casting macros public to fix issues described
> above.
> 
> Fourth commit replace usage of cast_to_largest_integral_type()
> with cast_ptr_to_largest_integral_type() in places where macros
> are supposed to take pointer as its parameter.
> 
> Last one is a small fix of examples to use correct assert macros
> make them simpler and avoid compiler warnings.
> 
> Best regards,
> 
> --
> Krzysztof Opasiak
> Samsung R&D Institute Poland
> Samsung Electronics
> k.opasiak@xxxxxxxxxxx
> 

I forget about changes. Here they are:

Changes since v1:
- rebased onto 328288bd88a043cf2fefcd10f1efd892414f4a11 which is current
HEAD

> Krzysztof Opasiak (5):
>   cmocka: Surround include info with code endcode
>   cmocka: Move some additional definitions to cmocka_extra.h
>   cmocka: Make casting macros public
>   cmocka: Use cast_ptr_to_largest_integral_type in suitable places
>   cmocka: examples: Fix assert macros usage
> 
>  example/calculator_test.c |   13 +---
>  include/CMakeLists.txt    |   14 ++++
>  include/cmocka.h          |  128 ++-------------------------------
>  include/cmocka_extra.h.in |  171
> +++++++++++++++++++++++++++++++++++++++++++++
>  src/CMakeLists.txt        |    1 +
>  src/cmocka.c              |   33 ---------
>  6 files changed, 196 insertions(+), 164 deletions(-)
>  create mode 100644 include/cmocka_extra.h.in
> 
> --
> 1.7.9.5



References:
[PATCH v2 0/5] cmocka: Make casting macros publicKrzysztof Opasiak <k.opasiak@xxxxxxxxxxx>