[OpenAFS-devel] [PATCH] fix various minor problems in aklog

Russ Allbery rra@stanford.edu
Thu, 14 Jul 2005 15:52:51 -0700


--=-=-=

Christopher Allen Wing <wingc@engin.umich.edu> writes:

> Here is a patch against today's CVS to fix some minor problems in the
> aklog source:

>  	- main() returns type int
>  	- various missing #includes
>  	- remove unused variables
>  	- call pr_Initialize() with correct number of arguments
>  	- call pr_SNameToId() with correct argument type (int32 not long)
>  	- use getcwd() not getwd()

This looks good to me, except let's go ahead and get rid of all the
__STDC__ ifdefs while we're at it.  This modified version does that and
also silences a warning from falling off the end of main.


--=-=-=
Content-Disposition: inline; filename=aklog-patch

? src/aklog/Makefile
? src/aklog/aklog
Index: src/aklog/aklog.c
===================================================================
RCS file: /cvs/openafs/src/aklog/aklog.c,v
retrieving revision 1.4
diff -u -p -r1.4 aklog.c
--- src/aklog/aklog.c	30 Jun 2005 21:06:15 -0000	1.4
+++ src/aklog/aklog.c	14 Jul 2005 22:51:12 -0000
@@ -14,15 +14,11 @@ static char *rcsid = "$Id: aklog.c,v 1.4
 
 #ifndef WINDOWS
 
-#ifdef __STDC__
+int
 main(int argc, char *argv[])
-#else
-main(argc, argv)
-  int argc;
-  char *argv[];
-#endif /* __STDC__ */
 {
     aklog(argc, argv);
+    exit(0);
 }
 
 #else /* WINDOWS */
Index: src/aklog/aklog_main.c
===================================================================
RCS file: /cvs/openafs/src/aklog/aklog_main.c,v
retrieving revision 1.8
diff -u -p -r1.8 aklog_main.c
--- src/aklog/aklog_main.c	5 Jul 2005 15:08:34 -0000	1.8
+++ src/aklog/aklog_main.c	14 Jul 2005 22:51:12 -0000
@@ -81,6 +81,7 @@ u_long ntohl(u_long x)
 #include <afs/vice.h>
 #include <afs/venus.h>
 #include <afs/ptserver.h>
+#include <afs/ptuser.h>
 #include <afs/dirpath.h>
 #endif /* WINDOWS */
 
@@ -259,7 +260,6 @@ static int get_cellconfig(char *cell, st
 {
     int status = AKLOG_SUCCESS;
     struct afsconf_dir *configdir;
-    char *dirpath;
 
     memset(local_cell, 0, sizeof(local_cell));
     memset((char *)cellconfig, 0, sizeof(*cellconfig));
@@ -392,19 +392,11 @@ cm_SearchCellFile_CallBack(void *rock /*
  * doing anything.  Otherwise, log to it and mark that it has been logged
  * to.
  */
-#ifdef __STDC__
 static int auth_to_cell(krb5_context context, char *cell, char *realm)
-#else
-static int auth_to_cell(context, cell, realm)
-
-  krb5_context context;
-  char *cell;
-  char *realm;
-#endif /* __STDC__ */
 {
     int status = AKLOG_SUCCESS;
     char username[BUFSIZ];	/* To hold client username structure */
-    long viceId;		/* AFS uid of user */
+    afs_int32 viceId;		/* AFS uid of user */
 
     char name[ANAME_SZ];	/* Name of afs key */
     char primary_instance[INST_SZ];	/* Instance of afs key */
@@ -720,7 +712,7 @@ static int auth_to_cell(context, cell, r
 
 	    strcpy(lastcell, aserver.cell);
 
-	    if (!pr_Initialize (0, confname, aserver.cell, 0))
+	    if (!pr_Initialize (0, confname, aserver.cell))
 		    status = pr_SNameToId (username, &viceId);
 	    
 	    if (dflag) {
@@ -775,7 +767,7 @@ static int auth_to_cell(context, cell, r
 		 * level
 		 */
 
-		if ((status = pr_Initialize(1L, confname, aserver.cell, 0))) {
+		if ((status = pr_Initialize(1L, confname, aserver.cell))) {
 		    printf("Error %d\n", status);
 		}
 
@@ -860,14 +852,7 @@ static int auth_to_cell(context, cell, r
 
 #ifndef WINDOWS /* struct ViceIoctl missing */
 
-#ifdef __STDC__
 static int get_afs_mountpoint(char *file, char *mountpoint, int size)
-#else
-static int get_afs_mountpoint(file, mountpoint, size)
-  char *file;
-  char *mountpoint;
-  int size;
-#endif /* __STDC__ */
 {
 #ifdef AFS_SUN_ENV
 	char V ='V'; /* AFS has problem on Sun with pioctl */
@@ -924,12 +909,7 @@ static int get_afs_mountpoint(file, moun
  * to be descended.  After that, it should be called with the arguemnt
  * NULL.
  */
-#ifdef __STDC__
 static char *next_path(char *origpath)
-#else
-static char *next_path(origpath)
-  char *origpath;
-#endif /* __STDC__ */
 {
     static char path[MAXPATHLEN + 1];
     static char pathtocheck[MAXPATHLEN + 1];
@@ -1047,12 +1027,7 @@ int dee_gettokens()
 
 #ifndef WINDOWS /* struct ViceIoctl missing */
 
-#ifdef __STDC__
 static void add_hosts(char *file)
-#else
-static void add_hosts(file)
-  char *file;
-#endif /* __STDC__ */
 {
 #ifdef AFS_SUN_ENV
 	char V = 'V'; /* AFS has problem on SunOS */
@@ -1119,13 +1094,7 @@ static void add_hosts(file)
  * This routine descends through a path to a directory, logging to 
  * every cell it encounters along the way.
  */
-#ifdef __STDC__
 static int auth_to_path(krb5_context context, char *path)
-#else
-static int auth_to_path(context, path)
-  krb5_context context;
-  char *path;			/* The path to which we try to authenticate */
-#endif /* __STDC__ */
 {
     int status = AKLOG_SUCCESS;
     int auth_to_cell_status = AKLOG_SUCCESS;
@@ -1143,7 +1112,7 @@ static int auth_to_path(context, path)
     if (path[0] == DIR)
 	strcpy(pathtocheck, path);
     else {
-	if (getwd(pathtocheck) == NULL) {
+	if (getcwd(pathtocheck, sizeof(pathtocheck)) == NULL) {
 	    fprintf(stderr, "Unable to find current working directory:\n");
 	    fprintf(stderr, "%s\n", pathtocheck);
 	    fprintf(stderr, "Try an absolute pathname.\n");
@@ -1212,11 +1181,7 @@ static int auth_to_path(context, path)
 
 
 /* Print usage message and exit */
-#ifdef __STDC__
 static void usage(void)
-#else
-static void usage()
-#endif /* __STDC__ */
 {
     fprintf(stderr, "\nUsage: %s %s%s%s\n", progname,
 	    "[-d] [[-cell | -c] cell [-k krb_realm]] ",
Index: src/aklog/krb_util.c
===================================================================
RCS file: /cvs/openafs/src/aklog/krb_util.c,v
retrieving revision 1.3
diff -u -p -r1.3 krb_util.c
--- src/aklog/krb_util.c	30 Jun 2005 21:06:15 -0000	1.3
+++ src/aklog/krb_util.c	14 Jul 2005 22:51:12 -0000
@@ -36,13 +36,12 @@ static char rcsid_send_to_kdc_c[] =
 
 #endif /* WINDOWS */
 
+#include <string.h>
+
 #define S_AD_SZ sizeof(struct sockaddr_in)
 
-char *afs_realm_of_cell(context, cellconfig)
-    krb5_context context;
-    struct afsconf_cell *cellconfig;
+char *afs_realm_of_cell(krb5_context context, struct afsconf_cell *cellconfig)
 {
-    char krbhst[MAX_HSTNM];
     static char krbrlm[REALM_SZ+1];
 	char **hrealms = 0;
 	krb5_error_code retval;
Index: src/aklog/linked_list.c
===================================================================
RCS file: /cvs/openafs/src/aklog/linked_list.c,v
retrieving revision 1.1
diff -u -p -r1.1 linked_list.c
--- src/aklog/linked_list.c	19 Nov 2004 20:01:29 -0000	1.1
+++ src/aklog/linked_list.c	14 Jul 2005 22:51:12 -0000
@@ -12,6 +12,8 @@ static char *rcsid_list_c = "$Id: linked
 #endif /* lint || SABER */
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 #include "linked_list.h"
 
 #ifndef NULL
@@ -26,9 +28,6 @@ static char *rcsid_list_c = "$Id: linked
 #define FALSE 0
 #endif
 
-char *calloc();
-
-#ifdef __STDC__
 void ll_init(linked_list *list)
   /* 
    * Requires:
@@ -40,10 +39,6 @@ void ll_init(linked_list *list)
    *   Initializes the list to be one with no elements.  If list is
    *   NULL, prints an error message and causes the program to crash.
    */
-#else
-void ll_init(list)
-  linked_list *list;
-#endif /* __STDC__ */
 {
     if (list == NULL) {
 	fprintf(stderr, "Error: calling ll_init with null pointer.\n");
@@ -58,7 +53,6 @@ void ll_init(list)
 #endif /* WINDOWS */
 }
 
-#ifdef __STDC__
 ll_node *ll_add_node(linked_list *list, ll_end which_end)
   /*
    * Modifies:
@@ -70,11 +64,6 @@ ll_node *ll_add_node(linked_list *list, 
    *   list.h.  If there is not enough memory to allocate a node, 
    *   the program returns NULL.
    */
-#else
-ll_node *ll_add_node(list, which_end)
-  linked_list *list;
-  ll_end which_end;
-#endif /* __STDC__ */
 {
     ll_node *node = NULL;
     
@@ -110,7 +99,6 @@ ll_node *ll_add_node(list, which_end)
 }
 
 
-#ifdef __STDC__
 int ll_delete_node(linked_list *list, ll_node *node)
   /* 
    * Modifies: 
@@ -122,11 +110,6 @@ int ll_delete_node(linked_list *list, ll
    *   this routine frees node, after the routine is called, "node"
    *   won't point to valid data.
    */
-#else
-int ll_delete_node(list, node)
-  linked_list *list;
-  ll_node *node;
-#endif /* __STDC__ */
 {
     int status = LL_SUCCESS;
     ll_node *cur_node = NULL;
@@ -166,14 +149,7 @@ int ll_delete_node(list, node)
 /* ll_add_data is a macro defined in linked_list.h */
 
 /* This routine maintains a list of strings preventing duplication. */
-#ifdef __STDC__
 int ll_string(linked_list *list, ll_s_action action, char *string)
-#else
-int ll_string(list, action, string)
-  linked_list *list;
-  ll_s_action action;
-  char *string;
-#endif /* __STDC__ */
 {
     int status = LL_SUCCESS;
     ll_node *cur_node;

--=-=-=


-- 
Russ Allbery (rra@stanford.edu)             <http://www.eyrie.org/~eagle/>

--=-=-=--