From 74aad61be45584b8a90235ea72d7208d12996e86 Mon Sep 17 00:00:00 2001 From: Stathis Kamperis Date: Wed, 2 Jan 2008 12:49:42 +0200 Subject: [PATCH] Comments start with a capital letter plus some cosmetic stuff --- fileops/listdir.c | 10 +++++----- fileops/listdir_recursive.c | 28 +++++++++++++--------------- fileops/readwd.c | 16 ++++++++-------- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/fileops/listdir.c b/fileops/listdir.c index 57381b1..6195459 100644 --- a/fileops/listdir.c +++ b/fileops/listdir.c @@ -10,21 +10,21 @@ int main(int argc, char *argv[]) struct dirent *pdent; DIR *pdir; - /* check argument count */ + /* Check argument count */ if (argc != 2) { fprintf(stderr, "Usage: %s directory\n", argv[0]); exit(EXIT_FAILURE); } - /* open directory named by argv[1], associate a directory stream - with it and return a pointer to it - */ + /* Open directory named by argv[1], associate a directory stream + * with it and return a pointer to it + */ if ((pdir = opendir(argv[1])) == NULL) { perror("opendir"); exit(EXIT_FAILURE); } - /* get all directory entries */ + /* Get all directory entries */ while((pdent = readdir(pdir)) != NULL) printf("%s\n", pdent->d_name); diff --git a/fileops/listdir_recursive.c b/fileops/listdir_recursive.c index 6c7ac91..5804ef3 100644 --- a/fileops/listdir_recursive.c +++ b/fileops/listdir_recursive.c @@ -9,9 +9,9 @@ /* Since listdir() uses a static variable to keep track of the call depth, - it is not safe to use it in a multi threading environment. If this is the - case, then you need to pass 'dirdepth' as an argument to listdir(). -*/ + * it is not safe to use it in a multi threading environment. If this is the + * case, then you need to pass 'dirdepth' as an argument to listdir(). + */ int listdir(const char *path) { struct dirent *pdent; @@ -20,21 +20,21 @@ int listdir(const char *path) static unsigned int dirdepth = 0; unsigned int i; - /* open directory named by path, associate a directory stream - with it and return a pointer to it - */ + /* Open directory named by path, associate a directory stream + * with it and return a pointer to it + */ if ((pdir = opendir(path)) == NULL) { perror("opendir"); return -1; } - /* get all directory entries */ + /* Get all directory entries */ while((pdent = readdir(pdir)) != NULL) { - /* indent according to the depth we are */ + /* Indent according to the depth we are */ for (i = 0; i < dirdepth; i++) printf(" "); - /* print current entry, or [entry] if it's a directory */ + /* Print current entry, or [entry] if it's a directory */ if (pdent->d_type == DT_DIR) printf("[%s]\n", pdent->d_name); else @@ -46,20 +46,18 @@ int listdir(const char *path) && strcmp(pdent->d_name, "..")) { dirdepth++; - /* allocate memory for new path - don't forget +1 for the '\0' - */ + /* Allocate memory for new path (don't forget +1 for the '\0') */ if ((newpath = malloc(strlen(path) + strlen(pdent->d_name) + 2)) == NULL) { perror("malloc"); return -1; } - /* construct new path */ + /* Construct new path */ strcpy(newpath, path); strcat(newpath, "/"); strcat(newpath, pdent->d_name); - /* to iterate is human, to recurse, divine */ + /* To iterate is human, to recurse, divine */ if (listdir(newpath) == -1) { closedir(pdir); free(newpath); @@ -78,7 +76,7 @@ int listdir(const char *path) int main(int argc, char *argv[]) { - /* check argument count */ + /* Check argument count */ if (argc != 2) { fprintf(stderr, "Usage: %s directory\n", argv[0]); exit(EXIT_FAILURE); diff --git a/fileops/readwd.c b/fileops/readwd.c index 3cb77db..6312915 100644 --- a/fileops/readwd.c +++ b/fileops/readwd.c @@ -23,19 +23,19 @@ int main(int argc, char *argv[]) } inbuf; u_int16_t *p; - /* check argument count */ + /* Check argument count */ if (argc != 2) { fprintf(stderr, "usage: %s /dev/file\n", argv[0]); exit(EXIT_FAILURE); } - /* open device file descriptor */ + /* Open device file descriptor */ if ((fd = open(argv[1], O_RDONLY)) == -1) { perror("open"); exit(EXIT_FAILURE); } - /* construct an ata request */ + /* Construct an ata request */ memset(&req, 0, sizeof req); req.flags = ATACMD_READ; req.command = WDCC_IDENTIFY; @@ -43,13 +43,13 @@ int main(int argc, char *argv[]) req.datalen = sizeof inbuf; req.timeout = 1000; /* 1 sec */ - /* make the ioctl call */ + /* Make the ioctl call */ if (ioctl(fd, ATAIOCCOMMAND, &req) == -1) { perror("ioctl"); exit(EXIT_FAILURE); } - /* handle ata request return status */ + /* Handle ata request return status */ switch (req.retsts) { case ATACMD_OK: break; @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - /* magic for little endian archs + /* Magic for little endian archs * FIXME: add #ifdef condition for little endian archs */ for (i = 0; i < sizeof inbuf.inqbuf.atap_model; i+=2) { @@ -75,13 +75,13 @@ int main(int argc, char *argv[]) *p = ntohs(*p); } - /* print the model (trim spaces when printing) */ + /* Print the model (trim spaces when printing) */ for (i = 0; i < sizeof inbuf.inqbuf.atap_model; i++) if (inbuf.inqbuf.atap_model[i] != ' ') printf("%c", inbuf.inqbuf.atap_model[i]); printf("\n"); - /* close file descriptor */ + /* Close file descriptor */ close(fd); return EXIT_SUCCESS; -- 2.11.4.GIT