Discussion:
[Linuxptp-devel] [PATCH 1/2] phc2sys: common code exit point for bad usage case
Libor Pechacek
2013-06-17 14:54:02 UTC
Permalink
Removed duplicate calls to usage() by providing common exit point for the case.

Signed-off-by: Libor Pechacek <***@suse.cz>
---
phc2sys.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/phc2sys.c b/phc2sys.c
index d4c9b65..594fc1e 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -684,37 +684,32 @@ int main(int argc, char *argv[])
usage(progname);
return 0;
default:
- usage(progname);
- return -1;
+ goto bad_usage;
}
}

if (pps_fd < 0 && src == CLOCK_INVALID) {
fprintf(stderr,
"valid source clock must be selected.\n");
- usage(progname);
- return -1;
+ goto bad_usage;
}

if (dst_clock.clkid == CLOCK_INVALID) {
fprintf(stderr,
"valid destination clock must be selected.\n");
- usage(progname);
- return -1;
+ goto bad_usage;
}

if (pps_fd >= 0 && dst_clock.clkid != CLOCK_REALTIME) {
fprintf(stderr,
"cannot use a pps device unless destination is CLOCK_REALTIME\n");
- usage(progname);
- return -1;
+ goto bad_usage;
}

if (!wait_sync && !forced_sync_offset) {
fprintf(stderr,
"time offset must be specified using -w or -O\n");
- usage(progname);
- return -1;
+ goto bad_usage;
}

if (dst_clock.stats_max_count > 0) {
@@ -793,4 +788,8 @@ int main(int argc, char *argv[])
phc_readings);

return do_phc_loop(&dst_clock, src, &phc_interval_tp, phc_readings);
+
+bad_usage:
+ usage(progname);
+ return -1;
}
--
1.7.12.4
Libor Pechacek
2013-06-17 14:54:03 UTC
Permalink
Options without parameters are now grouped together at the beginning of line
for better legibility.

Signed-off-by: Libor Pechacek <***@suse.cz>
Cc: Miroslav Lichvar <***@redhat.com>
---
phc2sys.8 | 16 ++++------------
ptp4l.8 | 26 +-------------------------
2 files changed, 5 insertions(+), 37 deletions(-)

diff --git a/phc2sys.8 b/phc2sys.8
index 92081cf..010fa18 100644
--- a/phc2sys.8
+++ b/phc2sys.8
@@ -5,12 +5,16 @@ phc2sys \- synchronize two clocks
.SH SYNOPSIS
.B phc2sys
[
+.B \-wmqvx
+] [
.BI \-d " pps-device"
] [
.BI \-s " device"
] [
.BI \-c " device"
] [
+.BI \-O " offset"
+] [
.BI \-P " kp"
] [
.BI \-I " ki"
@@ -19,23 +23,11 @@ phc2sys \- synchronize two clocks
] [
.BI \-N " clock-readings"
] [
-.BI \-O " offset"
-] [
.BI \-u " summary-updates"
] [
-.B \-w
-] [
.BI \-n " domain-number"
] [
-.B \-x
-] [
.BI \-l " print-level"
-] [
-.B \-m
-] [
-.B \-q
-] [
-.B \-v
]

.SH DESCRIPTION
diff --git a/ptp4l.8 b/ptp4l.8
index f3d2251..a722d77 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -5,37 +5,13 @@ ptp4l \- PTP Boundary/Ordinary Clock
.SH SYNOPSIS
.B ptp4l
[
-.B \-A
-|
-.B \-E
-|
-.B \-P
-] [
-.B \-2
-|
-.B \-4
-|
-.B \-6
-] [
-.B \-H
-|
-.B \-S
-|
-.B \-L
+.B \-AEP246HSLmqsv
] [
.BI \-f " config"
] [
.BI \-p " phc-device"
] [
-.B \-s
-] [
.BI \-l " print-level"
-] [
-.B \-m
-] [
-.B \-q
-] [
-.B \-v
]
[
.BI \-i " interface"
--
1.7.12.4
Ken ICHIKAWA
2013-06-18 03:29:49 UTC
Permalink
comment below
Post by Libor Pechacek
Options without parameters are now grouped together at the beginning of line
for better legibility.
---
phc2sys.8 | 16 ++++------------
ptp4l.8 | 26 +-------------------------
2 files changed, 5 insertions(+), 37 deletions(-)
diff --git a/phc2sys.8 b/phc2sys.8
index 92081cf..010fa18 100644
--- a/phc2sys.8
+++ b/phc2sys.8
@@ -5,12 +5,16 @@ phc2sys \- synchronize two clocks
.SH SYNOPSIS
.B phc2sys
[
+.B \-wmqvx
+] [
.BI \-d " pps-device"
] [
.BI \-s " device"
] [
.BI \-c " device"
] [
+.BI \-O " offset"
+] [
.BI \-P " kp"
] [
.BI \-I " ki"
@@ -19,23 +23,11 @@ phc2sys \- synchronize two clocks
] [
.BI \-N " clock-readings"
] [
-.BI \-O " offset"
-] [
.BI \-u " summary-updates"
] [
-.B \-w
-] [
.BI \-n " domain-number"
] [
-.B \-x
-] [
.BI \-l " print-level"
-] [
-.B \-m
-] [
-.B \-q
-] [
-.B \-v
]
.SH DESCRIPTION
diff --git a/ptp4l.8 b/ptp4l.8
index f3d2251..a722d77 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -5,37 +5,13 @@ ptp4l \- PTP Boundary/Ordinary Clock
.SH SYNOPSIS
.B ptp4l
[
-.B \-A
-|
-.B \-E
-|
-.B \-P
-] [
-.B \-2
-|
-.B \-4
-|
-.B \-6
-] [
-.B \-H
-|
-.B \-S
-|
-.B \-L
+.B \-AEP246HSLmqsv
IMHO, this is not clear that AEP, 246, HSL are exclusive, is it?
Grouping mqsv is fine.

Ken ICHIKAWA
Post by Libor Pechacek
] [
.BI \-f " config"
] [
.BI \-p " phc-device"
] [
-.B \-s
-] [
.BI \-l " print-level"
-] [
-.B \-m
-] [
-.B \-q
-] [
-.B \-v
]
[
.BI \-i " interface"
Ken ICHIKAWA
2013-06-18 05:43:28 UTC
Permalink
Libor,

Very sorry I did not read previous discussion well.
I agree now to this change if this style is better for standard.

Ken ICHIKAWA
Post by Ken ICHIKAWA
comment below
Post by Libor Pechacek
Options without parameters are now grouped together at the beginning of line
for better legibility.
---
phc2sys.8 | 16 ++++------------
ptp4l.8 | 26 +-------------------------
2 files changed, 5 insertions(+), 37 deletions(-)
diff --git a/phc2sys.8 b/phc2sys.8
index 92081cf..010fa18 100644
--- a/phc2sys.8
+++ b/phc2sys.8
@@ -5,12 +5,16 @@ phc2sys \- synchronize two clocks
.SH SYNOPSIS
.B phc2sys
[
+.B \-wmqvx
+] [
.BI \-d " pps-device"
] [
.BI \-s " device"
] [
.BI \-c " device"
] [
+.BI \-O " offset"
+] [
.BI \-P " kp"
] [
.BI \-I " ki"
@@ -19,23 +23,11 @@ phc2sys \- synchronize two clocks
] [
.BI \-N " clock-readings"
] [
-.BI \-O " offset"
-] [
.BI \-u " summary-updates"
] [
-.B \-w
-] [
.BI \-n " domain-number"
] [
-.B \-x
-] [
.BI \-l " print-level"
-] [
-.B \-m
-] [
-.B \-q
-] [
-.B \-v
]
.SH DESCRIPTION
diff --git a/ptp4l.8 b/ptp4l.8
index f3d2251..a722d77 100644
--- a/ptp4l.8
+++ b/ptp4l.8
@@ -5,37 +5,13 @@ ptp4l \- PTP Boundary/Ordinary Clock
.SH SYNOPSIS
.B ptp4l
[
-.B \-A
-|
-.B \-E
-|
-.B \-P
-] [
-.B \-2
-|
-.B \-4
-|
-.B \-6
-] [
-.B \-H
-|
-.B \-S
-|
-.B \-L
+.B \-AEP246HSLmqsv
IMHO, this is not clear that AEP, 246, HSL are exclusive, is it?
Grouping mqsv is fine.
Ken ICHIKAWA
Post by Libor Pechacek
] [
.BI \-f " config"
] [
.BI \-p " phc-device"
] [
-.B \-s
-] [
.BI \-l " print-level"
-] [
-.B \-m
-] [
-.B \-q
-] [
-.B \-v
]
[
.BI \-i " interface"
------------------------------------------------------------------------------
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Linuxptp-devel mailing list
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
Miroslav Lichvar
2013-06-18 09:28:01 UTC
Permalink
Post by Libor Pechacek
Options without parameters are now grouped together at the beginning of line
for better legibility.
Looks good to me.

Thanks,
--
Miroslav Lichvar
Keller, Jacob E
2013-06-17 18:00:49 UTC
Permalink
Looks good :)

- Jake
-----Original Message-----
Sent: Monday, June 17, 2013 7:54 AM
Subject: [Linuxptp-devel] [PATCH 1/2] phc2sys: common code exit point
for bad usage case
Removed duplicate calls to usage() by providing common exit point for the case.
---
phc2sys.c | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/phc2sys.c b/phc2sys.c
index d4c9b65..594fc1e 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -684,37 +684,32 @@ int main(int argc, char *argv[])
usage(progname);
return 0;
- usage(progname);
- return -1;
+ goto bad_usage;
}
}
if (pps_fd < 0 && src == CLOCK_INVALID) {
fprintf(stderr,
"valid source clock must be selected.\n");
- usage(progname);
- return -1;
+ goto bad_usage;
}
if (dst_clock.clkid == CLOCK_INVALID) {
fprintf(stderr,
"valid destination clock must be selected.\n");
- usage(progname);
- return -1;
+ goto bad_usage;
}
if (pps_fd >= 0 && dst_clock.clkid != CLOCK_REALTIME) {
fprintf(stderr,
"cannot use a pps device unless destination is
CLOCK_REALTIME\n");
- usage(progname);
- return -1;
+ goto bad_usage;
}
if (!wait_sync && !forced_sync_offset) {
fprintf(stderr,
"time offset must be specified using -w or -
O\n");
- usage(progname);
- return -1;
+ goto bad_usage;
}
if (dst_clock.stats_max_count > 0) {
@@ -793,4 +788,8 @@ int main(int argc, char *argv[])
phc_readings);
return do_phc_loop(&dst_clock, src, &phc_interval_tp,
phc_readings);
+
+ usage(progname);
+ return -1;
}
--
1.7.12.4
------------------------------------------------------------------------------
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Linuxptp-devel mailing list
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
Richard Cochran
2013-06-18 15:55:19 UTC
Permalink
phc2sys: common code exit point for bad usage case
Reordered options in manual page synopsis
Both patches applied.

Thanks,
Richard

Loading...