Merge lp:~sforshee/powerd/fix-warnings into lp:powerd

Proposed by Seth Forshee on 2013-10-01
Status: Needs review
Proposed branch: lp:~sforshee/powerd/fix-warnings
Merge into: lp:powerd
Diff against target: 44 lines (+6/-5)
3 files modified
src/display.c (+1/-1)
src/powerd-internal.h (+1/-1)
src/powerd-object.c (+4/-3)
To merge this branch: bzr merge lp:~sforshee/powerd/fix-warnings
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2013-10-01
Matt Fischer 2013-10-01 Pending
Review via email: mp+188613@code.launchpad.net

Commit message

Fix build warnings

Description of the change

Fix build warnings

To post a comment you must log in.
lp:~sforshee/powerd/fix-warnings updated on 2013-10-01
98. By Seth Forshee on 2013-10-01

powerd-object: Fix tabs/space indentation in previous commit

PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Matt Fischer (mfisch) wrote :

Looks good. Not sure I understand why the last change was needed but it works the same either way.

Seth Forshee (sforshee) wrote :

I don't understand why gcc complains about it, but that last change does eliminate a warning. I'm also pretty sure gcc wasn't complaining about it originally, and I don't know what changed to make it start.

Unmerged revisions

98. By Seth Forshee on 2013-10-01

powerd-object: Fix tabs/space indentation in previous commit

97. By Seth Forshee on 2013-10-01

powerd-object: Fix warning about format string

Something changed recently to cause gcc to start warning about
some code that it had no problem with previously:

 src/powerd-object.c: In function 'handle_ack_state_change':
 src/powerd-object.c:131:47: warning: format not a string literal and no format arguments [-Wformat-security]
                                                G_DBUS_ERROR_INVALID_ARGS, msg);
                                                ^

This is probably just gcc being pedantic. Change it to something
which is completely equivalent but does not generate warnings.

96. By Seth Forshee on 2013-10-01

display: Make power_mode argument to display_set_power_mode() const

This fixes a warning:

 powerd.cpp: In function 'gboolean {anonymous}::call_shutdown(gpointer)':
 powerd.cpp:127:40: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

The argument is read-only, so it really ought to be const anyway.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/display.c'
2--- src/display.c 2013-09-25 21:29:09 +0000
3+++ src/display.c 2013-10-01 14:32:46 +0000
4@@ -107,7 +107,7 @@
5 return (flags & AB_ENABLED_MASK) == AB_ENABLED;
6 }
7
8-void display_set_power_mode(int display, char *power_mode)
9+void display_set_power_mode(int display, const char *power_mode)
10 {
11 GError *error = NULL;
12 GDBusProxy *unity_proxy = NULL;
13
14=== modified file 'src/powerd-internal.h'
15--- src/powerd-internal.h 2013-09-24 13:15:40 +0000
16+++ src/powerd-internal.h 2013-10-01 14:32:46 +0000
17@@ -74,7 +74,7 @@
18 /* Display functions */
19 void powerd_brightness_set_value(gint value);
20 gboolean powerd_display_enabled(void);
21-void display_set_power_mode(int display, char *powerd_mode);
22+void display_set_power_mode(int display, const char *powerd_mode);
23 void powerd_set_display_state(struct powerd_display_request *req);
24 int powerd_display_init(void);
25 void powerd_proximity_event(gboolean near);
26
27=== modified file 'src/powerd-object.c'
28--- src/powerd-object.c 2013-08-12 02:46:09 +0000
29+++ src/powerd-object.c 2013-10-01 14:32:46 +0000
30@@ -125,10 +125,11 @@
31 owner = g_dbus_method_invocation_get_sender(invocation);
32 ret = powerd_client_ack(owner, state);
33 if (ret) {
34- const char *msg = (ret == -EINVAL) ? "Invalid state" :
35- "Client not registered";
36 g_dbus_method_invocation_return_error(invocation, G_DBUS_ERROR,
37- G_DBUS_ERROR_INVALID_ARGS, msg);
38+ G_DBUS_ERROR_INVALID_ARGS,
39+ ret == -EINVAL ?
40+ "Invalid state" :
41+ "Client not registered");
42 } else {
43 g_dbus_method_invocation_return_value(invocation, NULL);
44 }

Subscribers

People subscribed via source and target branches