Ticket #973 (closed task: fixed)
[API] signed/unsigned cleanup
| Reported by: | dgollub | Owned by: | bricks |
|---|---|---|---|
| Priority: | high | Milestone: | OpenSync 0.40 |
| Component: | OpenSync | Version: | 0.38 |
| Severity: | normal | Keywords: | |
| Cc: |
Description
Lots of OpenSync? interface have:
- int osync_xyz_num_xy(...)
- OSyncXyz *osync_xyz_nth_xy(OSyncYyy *, int nth)
.. which need to get changed to use unsigned int.
Internally most of them use OSyncList or GList - nth and length interface of those lists are signed.
| old interface pattern | new interface pattern |
| int osync_xyz_num_xy(...) | unsigned int osync_xyz_num_xy() |
| OSyncYyy *osync_xyz_nth_xy(OSyncZzz *, int nth) | OSyncYyy *osync_xyz_nth_xy(OSyncZzz *, usigned int nth) |
When using GCC this could also help to find more internally wrong use, following CFLAGS might help (man-page gcc(1)):
-Wsign-compare
Warn when a comparison between signed and unsigned values could
produce an incorrect result when the signed value is converted to
unsigned. This warning is also enabled by -Wextra; to get the
other warnings of -Wextra without this warning, use -Wextra
-Wno-sign-compare.
-Wsign-conversion
Warn for implicit conversions that may change the sign of an
integer value, like assigning a signed integer expression to an
unsigned integer variable. An explicit cast silences the warning.
In C, this option is enabled also by -Wconversion.
Change History
Note: See
TracTickets for help on using
tickets.
