Open registration is disabled at the moment due to spam.If you need a new account, please contact Keto on oftc.net IRC and provide your desired username and email.
This Bugzilla instance is no longer in active use, so you should only need an account if you wish to use the Sailfish OS community OBS.
Bug 1005 - Building libiphb through qmake throws warnings
Summary: Building libiphb through qmake throws warnings
Status: RESOLVED FIXED
Alias: None
Product: Mer Core
Classification: Unclassified
Component: dsme (show other bugs)
Version: unspecified
Hardware: All All
: Undecided trivial
Assignee: Simo Piiroinen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-16 19:10 UTC by Kimmo Lindholm
Modified: 2015-06-01 14:58 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Kimmo Lindholm 2015-05-16 19:10:41 UTC
Due harbour restrictions, my project bundles nemokeepalive (and libiphb) within the executable.

When building this project (in QtCreator) it throws following warnings for libiphb.c:

libiphb.c: In function 'iphb_I_woke_up':
libiphb.c:91:10: warning: missing initializer [-Wmissing-field-initializers]
libiphb.c:91:10: warning: (near initialization for 'req.u') [-Wmissing-field-initializers]
libiphb.c: In function 'iphb_wait2':
libiphb.c:171:10: warning: missing initializer [-Wmissing-field-initializers]
libiphb.c:171:10: warning: (near initialization for 'req.u') [-Wmissing-field-initializers]
libiphb.c:235:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
libiphb.c: In function 'iphb_get_stats':
libiphb.c:273:10: warning: missing initializer [-Wmissing-field-initializers]
libiphb.c:273:10: warning: (near initialization for 'req.u') [-Wmissing-field-initializers]

Three of these are uninitialised fields (see also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36750) maybe appear due oldish gcc version (?)

According to spiiroin these warnings do not appear when building libiphb as standalone.

One is comparison between signed and unsigned.

It would be nice to get rid of these warnings also when building embedded.

Ref: my project Toholed, subproject daemon in github: https://github.com/kimmoli/toholed/tree/master/daemon
Comment 1 Simo Piiroinen 2015-05-18 09:32:39 UTC
(In reply to Kimmo Lindholm from comment #0)
> Due harbour restrictions, my project bundles nemokeepalive (and libiphb)
> within the executable.

compile in toholed tree boils down to:

sb2 gcc\
  -c\
  -g\
  -Wall\
  -W\
  -Wno-missing-field-initializers\
  -D_REENTRANT\
  -fPIE\
  -DAPPVERSION=\"\"\
  -I.\
  -I.\
  -c src/libiphb.c

and "normal" compile in libiphb tree to:

sb2 gcc\
  -I.\
  -D_GNU_SOURCE\
  -Wall\
  -Wmissing-prototypes\
  -std=c99\
  -Os\
  -g\
  -fPIC\
  -O2\
  -g\
  -Wall\
  -Wp,-D_FORTIFY_SOURCE=2\
  -fexceptions\
  -fstack-protector\
  --param=ssp-buffer-size=4\
  -Wformat\
  -Wformat-security\
  -fmessage-length=0\
  -march=armv7-a\
  -mfloat-abi=hard\
  -mfpu=vfpv3-d16\
  -mno-thumb\
  -Wno-psabi\
  -fPIC\
  -DPIC\
  -c src/libiphb.c

The significant difference from warnings point of view is that
"-W" is used in toholed, but not in libiphb itself.

> When building this project (in QtCreator) it throws following warnings for
> libiphb.c:

> libiphb.c: In function 'iphb_wait2':
> libiphb.c:171:10: warning: missing initializer [-Wmissing-field-initializers]
> libiphb.c:171:10: warning: (near initialization for 'req.u')
> [-Wmissing-field-initializers]

Being able to leave out initializer fields for auto structures and
have them initialized to zero or null depending on type is a (c99)
language feature. (IIRC pre c99 initializations like this were
required to be made for global structs only).

It is used on purpose here - in fact we rely on older versions of
libiphb having zero initialized padding in the message data so
that dsme can tell apart iphb_wait() and iphb_wait2() requests on
protocol level (in case there are forked off old versions of
libiphb statically linked to some projects....)

Suggestion:
* Add "-Wno-missing-field-initializers" after "-W" to toholed.
* Use both "-W" and "-Wno-missing-field-initializers" in libiphb.

> libiphb.c:235:37: warning: comparison between signed and unsigned integer
> expressions [-Wsign-compare]
> libiphb.c: In function 'iphb_get_stats':
> libiphb.c:273:10: warning: missing initializer [-Wmissing-field-initializers]
> libiphb.c:273:10: warning: (near initialization for 'req.u')
> [-Wmissing-field-initializers]

This is clearly wrong and must be fixed.

However it should not cause misfunction because it is effectively:
 signed_t0 = monotime();
  :
 signed_t1 = monotime();
 if( signed_t1 - signed_t0 < unsigned_limit ) ...

and (signed_t1 - signed_t0) >= 0
Comment 2 Simo Piiroinen 2015-05-18 12:17:33 UTC
Taking bug.

Looks like using named member style initialization removes
the warning even without "-Wno-missing-field-initializers"

-  struct _iphb_req_t  req = {IPHB_STAT};
+  struct _iphb_req_t  req = { .cmd = IPHB_STAT, };

But warnings are still generated for:
   struct foo bar = { };

Since this is more compact and portable than resetting with
memset() & co [NULL can be != bitwise zero] -> disabling the
warning seems better choice.
Comment 3 Simo Piiroinen 2015-05-18 13:24:50 UTC
(In reply to Simo Piiroinen from comment #2)
> Since this is more compact and portable than resetting with
> memset() & co [NULL can be != bitwise zero] -> disabling the
> warning seems better choice.

That was just one place, in code I just added -> left the warning
active after all.

Pull request:
https://github.com/nemomobile/libiphb/pull/12
Comment 4 Simo Piiroinen 2015-05-27 05:16:33 UTC
(In reply to Simo Piiroinen from comment #3)
> Pull request:
> https://github.com/nemomobile/libiphb/pull/12

kimmoli: When you have time, can you check if that improves things for you?
Comment 5 Simo Piiroinen 2015-06-01 14:58:30 UTC
(In reply to Simo Piiroinen from comment #4)
> (In reply to Simo Piiroinen from comment #3)
> > Pull request:
> > https://github.com/nemomobile/libiphb/pull/12
> 
> kimmoli: When you have time, can you check if that improves things for you?

<kimmoli> spiiroin: clean build with mer1005_enable_extra_warnings
<spiiroin> kimmoli: thanks, I'll merge it now

Merged, libiphb 1.2.4 tagged -> FIXED