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

[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

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



Follow-Ups:
[PATCH v2 1/5] cmocka: Surround include info with code endcodeKrzysztof Opasiak <k.opasiak@xxxxxxxxxxx>
[PATCH v2 2/5] cmocka: Move some additional definitions to cmocka_extra.hKrzysztof Opasiak <k.opasiak@xxxxxxxxxxx>
[PATCH v2 3/5] cmocka: Make casting macros publicKrzysztof Opasiak <k.opasiak@xxxxxxxxxxx>
[PATCH v2 4/5] cmocka: Use cast_ptr_to_largest_integral_type in suitable placesKrzysztof Opasiak <k.opasiak@xxxxxxxxxxx>
[PATCH v2 5/5] cmocka: examples: Fix assert macros usageKrzysztof Opasiak <k.opasiak@xxxxxxxxxxx>
RE: [PATCH v2 0/5] cmocka: Make casting macros publicKrzysztof Opasiak <k.opasiak@xxxxxxxxxxx>
Re: [PATCH v2 0/5] cmocka: Make casting macros publicAndreas Schneider <asn@xxxxxxxxxxxxxx>