[PATCH] sftp-server: constify & localize state

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

 



From: Mike Frysinger <vapier@xxxxxxxxxxxx>

Mark variables static that aren't used outside of this file, and
mark the handlers structures as const as they're never modified.
---
 sftp-server.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/sftp-server.c b/sftp-server.c
index ab1b063f2136..beac78ed0324 100644
--- a/sftp-server.c
+++ b/sftp-server.c
@@ -117,7 +117,7 @@ struct sftp_handler {
 	int does_write;		/* if nonzero, banned for readonly mode */
 };
 
-struct sftp_handler handlers[] = {
+static const struct sftp_handler handlers[] = {
 	/* NB. SSH2_FXP_OPEN does the readonly check in the handler itself */
 	{ "open", NULL, SSH2_FXP_OPEN, process_open, 0 },
 	{ "close", NULL, SSH2_FXP_CLOSE, process_close, 0 },
@@ -141,7 +141,7 @@ struct sftp_handler handlers[] = {
 };
 
 /* SSH2_FXP_EXTENDED submessages */
-struct sftp_handler extended_handlers[] = {
+static const struct sftp_handler extended_handlers[] = {
 	{ "posix-rename", "posix-rename@xxxxxxxxxxx", 0,
 	   process_extended_posix_rename, 1 },
 	{ "statvfs", "statvfs@xxxxxxxxxxx", 0, process_extended_statvfs, 0 },
@@ -152,7 +152,7 @@ struct sftp_handler extended_handlers[] = {
 };
 
 static int
-request_permitted(struct sftp_handler *h)
+request_permitted(const struct sftp_handler *h)
 {
 	char *result;
 
@@ -285,9 +285,9 @@ enum {
 	HANDLE_FILE
 };
 
-Handle *handles = NULL;
-u_int num_handles = 0;
-int first_unused_handle = -1;
+static Handle *handles = NULL;
+static u_int num_handles = 0;
+static int first_unused_handle = -1;
 
 static void handle_unused(int i)
 {
-- 
2.17.1

_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@xxxxxxxxxxx
https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev



[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux