* [PATCH 2/4] uuidd: set options to be mutually exclusive
2014-05-25 10:59 [PATCH 1/4] uuidd: ensure pid file is wrote when it is requested Sami Kerola
@ 2014-05-25 10:59 ` Sami Kerola
2014-05-26 9:50 ` Karel Zak
2014-05-25 10:59 ` [PATCH 3/4] uuidgen: use type definitions from uuid.h Sami Kerola
2014-05-25 10:59 ` [PATCH 4/4] uuidd: do not mix signed type and unsigned code Sami Kerola
2 siblings, 1 reply; 6+ messages in thread
From: Sami Kerola @ 2014-05-25 10:59 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
--pid || --no-pid
--debug || --quiet
--timeout || --socket-activation
--random || --time
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
misc-utils/uuidd.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c
index 5730919..1f4a38b 100644
--- a/misc-utils/uuidd.c
+++ b/misc-utils/uuidd.c
@@ -37,6 +37,7 @@ extern int optind;
#include "c.h"
#include "closestream.h"
#include "strutils.h"
+#include "optutils.h"
#ifdef HAVE_LIBSYSTEMD
# include <systemd/sd-daemon.h>
@@ -510,6 +511,14 @@ int main(int argc, char **argv)
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}
};
+ static const ul_excl_t excl[] = {
+ { 'P', 'p' },
+ { 'S', 'T' },
+ { 'd', 'q' },
+ { 'r', 't' },
+ { 0 }
+ };
+ int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
@@ -519,6 +528,7 @@ int main(int argc, char **argv)
while ((c =
getopt_long(argc, argv, "p:s:T:krtn:PFSdqVh", longopts,
NULL)) != -1) {
+ err_exclusive_options(c, longopts, excl, excl_st);
switch (c) {
case 'd':
uuidd_cxt.debug = 1;
@@ -576,9 +586,6 @@ int main(int argc, char **argv)
}
}
- if (no_pid && pidfile_path_param && !uuidd_cxt.quiet)
- warnx(_("Both --pid and --no-pid specified. Ignoring --no-pid."));
-
if (!no_pid && !pidfile_path_param)
pidfile_path = UUIDD_PIDFILE_PATH;
else if (pidfile_path_param)
--
1.9.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 3/4] uuidgen: use type definitions from uuid.h
2014-05-25 10:59 [PATCH 1/4] uuidd: ensure pid file is wrote when it is requested Sami Kerola
2014-05-25 10:59 ` [PATCH 2/4] uuidd: set options to be mutually exclusive Sami Kerola
@ 2014-05-25 10:59 ` Sami Kerola
2014-05-25 10:59 ` [PATCH 4/4] uuidd: do not mix signed type and unsigned code Sami Kerola
2 siblings, 0 replies; 6+ messages in thread
From: Sami Kerola @ 2014-05-25 10:59 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
There is no need to re-invent wheel.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
misc-utils/uuidgen.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
diff --git a/misc-utils/uuidgen.c b/misc-utils/uuidgen.c
index 450e26a..0c844d2 100644
--- a/misc-utils/uuidgen.c
+++ b/misc-utils/uuidgen.c
@@ -26,9 +26,6 @@ extern int optind;
#include "c.h"
#include "closestream.h"
-#define DO_TYPE_TIME 1
-#define DO_TYPE_RANDOM 2
-
static void __attribute__ ((__noreturn__)) usage(FILE * out)
{
fputs(_("\nUsage:\n"), out);
@@ -68,10 +65,10 @@ main (int argc, char *argv[])
while ((c = getopt_long(argc, argv, "rtVh", longopts, NULL)) != -1)
switch (c) {
case 't':
- do_type = DO_TYPE_TIME;
+ do_type = UUID_TYPE_DCE_TIME;
break;
case 'r':
- do_type = DO_TYPE_RANDOM;
+ do_type = UUID_TYPE_DCE_RANDOM;
break;
case 'V':
printf(UTIL_LINUX_VERSION);
@@ -83,10 +80,10 @@ main (int argc, char *argv[])
}
switch (do_type) {
- case DO_TYPE_TIME:
+ case UUID_TYPE_DCE_TIME:
uuid_generate_time(uu);
break;
- case DO_TYPE_RANDOM:
+ case UUID_TYPE_DCE_RANDOM:
uuid_generate_random(uu);
break;
default:
--
1.9.3
^ permalink raw reply related [flat|nested] 6+ messages in thread* [PATCH 4/4] uuidd: do not mix signed type and unsigned code
2014-05-25 10:59 [PATCH 1/4] uuidd: ensure pid file is wrote when it is requested Sami Kerola
2014-05-25 10:59 ` [PATCH 2/4] uuidd: set options to be mutually exclusive Sami Kerola
2014-05-25 10:59 ` [PATCH 3/4] uuidgen: use type definitions from uuid.h Sami Kerola
@ 2014-05-25 10:59 ` Sami Kerola
2 siblings, 0 replies; 6+ messages in thread
From: Sami Kerola @ 2014-05-25 10:59 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
Both the strtou32_or_err() and alarm() expect timeout to be unsigned.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
misc-utils/uuidd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c
index 1f4a38b..f728e2e 100644
--- a/misc-utils/uuidd.c
+++ b/misc-utils/uuidd.c
@@ -59,7 +59,7 @@ extern int optind;
/* server loop control structure */
struct uuidd_cxt_t {
- int timeout;
+ uint32_t timeout;
unsigned int debug: 1,
quiet: 1,
no_fork: 1,
@@ -366,7 +366,7 @@ static void server_loop(const char *socket_path, const char *pidfile_path,
while (1) {
fromlen = sizeof(from_addr);
- if (uuidd_cxt->timeout > 0)
+ if (uuidd_cxt->timeout != 0)
alarm(uuidd_cxt->timeout);
ns = accept(s, (struct sockaddr *) &from_addr, &fromlen);
alarm(0);
--
1.9.3
^ permalink raw reply related [flat|nested] 6+ messages in thread