]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge branch 't/audioc_cleanups'
authorAndre Noll <maan@systemlinux.org>
Sun, 4 Mar 2012 21:40:27 +0000 (22:40 +0100)
committerAndre Noll <maan@systemlinux.org>
Mon, 5 Mar 2012 07:46:58 +0000 (08:46 +0100)
Has been cooking for long enough.

1  2 
NEWS
audioc.c

diff --combined NEWS
index e5ae590e22605236ada049eb5d758eb293ba901e,16e8e4e8cf2dba2709b75b612d386434838609ff..d9e0d0a377e7fec9c833e5f7a021671ace796214
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -2,15 -2,6 +2,16 @@@
  0.4.10 (to be announced) "heterogeneous vacuum"
  -----------------------------------------------
  
 +      - The --no_default_filters option of para_filter has been
 +        depricated. It still works but has no effect and will be
 +        removed in the next version.
 +      - Cleanup and consolidation of the various wrappers for
 +        write(), writev(), send() and friends.
 +      - The obscure error messages on mmap() failures have been
 +        replaced by meaningful messages. This affects mainly
 +        para_afh.
++      - para_audioc: Cleanups and memory leak fixes.
 +
  -------------------------------------
  0.4.9 (2011-12-06) "hybrid causality"
  -------------------------------------
diff --combined audioc.c
index 84c2a39472f6fcf58f7c6fecf62e752d35d1a098,09b21ba95c73b976e753eac5da06ff5208ca16da..d3e092e29301f71e02948259483623e56967966f
+++ b/audioc.c
@@@ -253,16 -253,15 +253,15 @@@ __noreturn static void print_completion
  
  static char *configfile_exists(void)
  {
-       static char *config_file;
+       char *config_file;
        struct stat statbuf;
+       char *home = para_homedir();
  
-       if (!config_file) {
-               char *home = para_homedir();
-               config_file = make_message("%s/.paraslash/audioc.conf", home);
-               free(home);
-       }
+       config_file = make_message("%s/.paraslash/audioc.conf", home);
+       free(home);
        if (!stat(config_file, &statbuf))
                return config_file;
+       free(config_file);
        return NULL;
  }
  
   * \param argc Usual argument count.
   * \param argv Usual argument vector.
   *
-  * It creates a temporary local socket in order to communicate with para_audiod.
-  * Authentication consists in sending a ucred buffer that contains the user id.
+  * It connects to the "well-known" local socket to communicate with
+  * para_audiod. Authentication is performed by sending a ucred buffer
+  * containing the user id to the local socket.
   *
-  * Any output received through the local socket is sent to stdout.
+  * Any data received from the socket is written to stdout.
   *
   * \return EXIT_SUCCESS or EXIT_FAILURE.
   *
  int main(int argc, char *argv[])
  {
        int ret = -E_AUDIOC_SYNTAX, fd;
-       char *cf, *buf = NULL, *args;
+       char *cf, *buf = NULL, *args = NULL;
        size_t bufsize;
  
        if (audioc_cmdline_parser(argc, argv, &conf))
                        .check_required = 0,
                        .check_ambiguity = 0
                };
-               if (audioc_cmdline_parser_config_file(cf, &conf, &params)) {
+               ret = audioc_cmdline_parser_config_file(cf, &conf, &params);
+               free(cf);
+               if (ret) {
                        fprintf(stderr, "parse error in config file\n");
                        exit(EXIT_FAILURE);
                }
                size_t n = ret = recv_bin_buffer(fd, buf, bufsize);
                if (ret <= 0)
                        break;
 -              ret = write_all(STDOUT_FILENO, buf, &n);
 +              ret = write_all(STDOUT_FILENO, buf, n);
        } while (ret >= 0);
  out:
+       free(buf);
+       free(args);
        if (ret < 0)
                PARA_ERROR_LOG("%s\n", para_strerror(-ret));
        return ret < 0? EXIT_FAILURE : EXIT_SUCCESS;