Merge lp:~aacid/platform-api/do_not_complain_invalid_option into lp:platform-api

Proposed by Albert Astals Cid on 2016-06-09
Status: Merged
Approved by: Gerry Boland on 2016-06-10
Approved revision: 325
Merged at revision: 328
Proposed branch: lp:~aacid/platform-api/do_not_complain_invalid_option
Merge into: lp:platform-api
Diff against target: 34 lines (+10/-0)
1 file modified
src/ubuntu/application/common/mirclient/application_options_mir.cpp (+10/-0)
To merge this branch: bzr merge lp:~aacid/platform-api/do_not_complain_invalid_option
Reviewer Review Type Date Requested Status
Gerry Boland (community) 2016-06-09 Approve on 2016-06-10
PS Jenkins bot continuous-integration Pending
Review via email: mp+296972@code.launchpad.net

Commit message

Remove spurious warnings about invalid option when parsing command line arguments

To post a comment you must log in.
325. By Albert Astals Cid on 2016-06-09

explain what opterr is

Gerry Boland (gerboland) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ubuntu/application/common/mirclient/application_options_mir.cpp'
2--- src/ubuntu/application/common/mirclient/application_options_mir.cpp 2015-06-18 00:36:42 +0000
3+++ src/ubuntu/application/common/mirclient/application_options_mir.cpp 2016-06-09 17:50:50 +0000
4@@ -30,6 +30,11 @@
5
6 #include <unistd.h>
7
8+// opterr is a extern variable exported by glibc that
9+// controls whether getopt prints warnings on unknown options
10+// see 'man opterr'
11+extern int opterr;
12+
13 namespace uam = ubuntu::application::mir;
14
15 UApplicationOptions* uam::Options::as_u_application_options()
16@@ -112,6 +117,10 @@
17 }
18 }
19
20+ // Do not complain about options we don't know
21+ // the app may have other params
22+ int orig_opterr = opterr;
23+ opterr = 0;
24 while(true)
25 {
26 int option_index = 0;
27@@ -147,6 +156,7 @@
28 break;
29 }
30 }
31+ opterr = orig_opterr;
32
33 return app_options->as_u_application_options();
34 }

Subscribers

People subscribed via source and target branches