summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2001-12-11 05:47:26 +0000
committerAndrew Tridgell <tridge@samba.org>2001-12-11 05:47:26 +0000
commit6939dd050bdfc85fa632272594b2076f87b58760 (patch)
treef18c42ba597a654bdabce958694ccfc1c4ba7824
parente5dbe13b58422535569476443ddb20250bb0114c (diff)
downloadsamba-6939dd050bdfc85fa632272594b2076f87b58760.tar.gz
samba-6939dd050bdfc85fa632272594b2076f87b58760.tar.bz2
samba-6939dd050bdfc85fa632272594b2076f87b58760.zip
better error handling
(This used to be commit 75621d528433a9c1af3eada0b748dfbcfdb8ad62)
-rw-r--r--source3/utils/net_time.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/source3/utils/net_time.c b/source3/utils/net_time.c
index 6c5f38c17a..8d0c854e28 100644
--- a/source3/utils/net_time.c
+++ b/source3/utils/net_time.c
@@ -33,7 +33,12 @@ static time_t cli_servertime(const char *host, struct in_addr *ip)
struct cli_state *cli = NULL;
cli = cli_initialise(NULL);
- if (!cli || !cli_connect(cli, host, ip)) goto done;
+ if (!cli) goto done;
+
+ if (!cli_connect(cli, host, ip)) {
+ fprintf(stderr,"Can't contact server\n");
+ goto done;
+ }
make_nmb_name(&calling, global_myname, 0x0);
if (host) {
@@ -42,8 +47,14 @@ static time_t cli_servertime(const char *host, struct in_addr *ip)
make_nmb_name(&called, "*SMBSERVER", 0x20);
}
- if (!cli_session_request(cli, &calling, &called)) goto done;
- if (!cli_negprot(cli)) goto done;
+ if (!cli_session_request(cli, &calling, &called)) {
+ fprintf(stderr,"Session request failed\n");
+ goto done;
+ }
+ if (!cli_negprot(cli)) {
+ fprintf(stderr,"Protocol negotiation failed\n");
+ goto done;
+ }
ret = cli->servertime;
@@ -94,10 +105,7 @@ static int net_time_set(int argc, const char **argv)
time_t t = nettime();
char *cmd;
- if (t == 0) {
- d_printf("Can't contact server\n");
- return -1;
- }
+ if (t == 0) return -1;
/* yes, I know this is cheesy. Use "net time system" if you want to
roll your own. I'm putting this in as it works on a large number
@@ -114,10 +122,7 @@ static int net_time_system(int argc, const char **argv)
{
time_t t = nettime();
- if (t == 0) {
- d_printf("Can't contact server\n");
- return -1;
- }
+ if (t == 0) return -1;
printf("%s\n", systime(t));
@@ -148,6 +153,7 @@ int net_time(int argc, const char **argv)
/* default - print the time */
t = cli_servertime(opt_host, opt_have_ip? &opt_dest_ip : NULL);
+ if (t == 0) return -1;
d_printf("%s", ctime(&t));
return 0;