From: Volker Lendecke Date: Mon, 5 May 2025 10:47:07 +0000 (+0200) Subject: libsmb: Reduce indentation in SMBC_check_server() with a "goto done" X-Git-Tag: tevent-0.17.0~192 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1a11f1dcc6a35c30e992f80d8a70bb0bc452ad90;p=thirdparty%2Fsamba.git libsmb: Reduce indentation in SMBC_check_server() with a "goto done" Signed-off-by: Volker Lendecke Reviewed-by: Stefan Metzmacher --- diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c index 44ed9ac4005..c7516639fa3 100644 --- a/source3/libsmb/libsmb_server.c +++ b/source3/libsmb/libsmb_server.c @@ -50,6 +50,7 @@ SMBC_check_server(SMBCCTX * context, time_t now, next_echo; unsigned char data[16] = {0}; NTSTATUS status; + bool ok = false; if (!cli_state_is_connected(cli)) { return 1; @@ -63,38 +64,39 @@ SMBC_check_server(SMBCCTX * context, } status = cli_echo(cli, 1, data_blob_const(data, sizeof(data))); - if (!NT_STATUS_IS_OK(status)) { - bool ok = false; - /* - * Some SMB2 servers (not Samba or Windows) - * check the session status on SMB2_ECHO and return - * NT_STATUS_USER_SESSION_DELETED - * if the session was not set. That's OK, they still - * replied. - * BUG: https://bugzilla.samba.org/show_bug.cgi?id=13218 - */ - if (smbXcli_conn_protocol(cli->conn) >= - PROTOCOL_SMB2_02) { - if (NT_STATUS_EQUAL(status, - NT_STATUS_USER_SESSION_DELETED)) { - ok = true; - } - } - /* - * Some NetApp servers return - * NT_STATUS_INVALID_PARAMETER.That's OK, they still - * replied. - * BUG: https://bugzilla.samba.org/show_bug.cgi?id=13007 - */ + if (NT_STATUS_IS_OK(status)) { + goto done; + } + + /* + * Some SMB2 servers (not Samba or Windows) + * check the session status on SMB2_ECHO and return + * NT_STATUS_USER_SESSION_DELETED + * if the session was not set. That's OK, they still + * replied. + * BUG: https://bugzilla.samba.org/show_bug.cgi?id=13218 + */ + if (smbXcli_conn_protocol(cli->conn) >= + PROTOCOL_SMB2_02) { if (NT_STATUS_EQUAL(status, - NT_STATUS_INVALID_PARAMETER)) { + NT_STATUS_USER_SESSION_DELETED)) { ok = true; } - if (!ok) { - return 1; - } } - + /* + * Some NetApp servers return + * NT_STATUS_INVALID_PARAMETER.That's OK, they still + * replied. + * BUG: https://bugzilla.samba.org/show_bug.cgi?id=13007 + */ + if (NT_STATUS_EQUAL(status, + NT_STATUS_INVALID_PARAMETER)) { + ok = true; + } + if (!ok) { + return 1; + } +done: server->last_echo_time = now; return 0; }