Merge branch 't/gvf'
authorAndre Noll <maan@systemlinux.org>
Fri, 8 Apr 2011 09:12:46 +0000 (11:12 +0200)
committerAndre Noll <maan@systemlinux.org>
Fri, 8 Apr 2011 09:12:46 +0000 (11:12 +0200)
1  2 
Makefile.in
audiod.c
command.c
fade.c
gui.c
para.h
write.c

diff --combined Makefile.in
index 8963adad3b7339a1ff6b750f69b597acde1c49f6,06c86eb622247a2944f26a762e6f0986cdc2fe25..8b33aaac0c9fe58bab3b20c61cee25476af90965
@@@ -9,19 -9,17 +9,21 @@@ PACKAGE_VERSION := @PACKAGE_VERSION
  PACKAGE_STRING := @PACKAGE_STRING@
  install_sh := @install_sh@
  cmdline_dir := @cmdline_dir@
 +executables := @executables@
  
  build_date := $(shell date)
  uname_s := $(shell uname -s 2>/dev/null || echo "UNKNOWN_OS")
  uname_rs := $(shell uname -rs)
  cc_version := $(shell $(CC) --version | head -n 1)
 -codename := deterministic entropy
 +codename := infinite rollback
  
+ GIT_VERSION := $(shell ./GIT-VERSION-GEN git-version.h)
  DEBUG_CPPFLAGS += -Wno-sign-compare -g -Wunused -Wundef -W
  DEBUG_CPPFLAGS += -Wredundant-decls
 +DEBUG_CPPFLAGS += -Wall
 +DEBUG_CPPFLAGS += -Wformat-security
 +DEBUG_CPPFLAGS += -Wmissing-format-attribute
  # produces false positives
  # DEBUG_CPPFLAGS += -Wunreachable-code
  # DEBUG_CPPFLAGS += -Wwrite-strings
@@@ -41,25 -39,28 +43,24 @@@ ifeq ($(uname_s),Linux
        CPPFLAGS += -Wshadow
  endif
  CPPFLAGS += -Os
 -CPPFLAGS += -Wall
  CPPFLAGS += -Wuninitialized
  CPPFLAGS += -Wchar-subscripts
 -CPPFLAGS += -Wformat-security
  CPPFLAGS += -DBINDIR='"$(BINDIR)"'
  CPPFLAGS += -DBUILD_DATE='"$(build_date)"'
  CPPFLAGS += -DUNAME_RS='"$(uname_rs)"'
  CPPFLAGS += -DCODENAME='"$(codename)"'
  CPPFLAGS += -DCC_VERSION='"$(cc_version)"'
  CPPFLAGS += -Werror-implicit-function-declaration
 -CPPFLAGS += -Wmissing-format-attribute
  CPPFLAGS += -Wmissing-noreturn
  CPPFLAGS += -Wunused-macros
  CPPFLAGS += -Wbad-function-cast
  CPPFLAGS += -fno-strict-aliasing
  CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F)
  CPPFLAGS += @SSL_CPPFLAGS@
 -CPPFLAGS += @ncurses_cppflags@
  CPPFLAGS += @arch_cppflags@
  CPPFLAGS += -I/usr/local/include
  CPPFLAGS += -I$(cmdline_dir)
  CPPFLAGS += @osl_cppflags@
- CPPFLAGS += -DGIT_VERSION='"$(GIT_VERSION)"'
  
  man_pages := $(patsubst %, man/man1/%.1, @executables@)
  man_pages_in := $(patsubst %, web/%.man.in.html, @executables@)
@@@ -67,7 -68,6 +68,7 @@@
  ggo_dir := ggo
  object_dir := objects
  man_dir := man/man1
 +test_dir := t
  
  m4_ggos := afh audioc audiod client filter gui recv server write
  all_ggos := $(m4_ggos) dccp_recv alsa_write oss_write fade http_recv \
@@@ -94,24 -94,18 +95,18 @@@ endi
  ifndef BUILD_VERBOSE
        BUILD_VERBOSE = 0
  endif
 -ifeq ($(BUILD_VERBOSE),1)
 -      Q =
 -else
 +ifeq ($(BUILD_VERBOSE),0)
        Q = @
 +else
 +      Q =
  endif
  
- .PHONY: dep all clean distclean maintainer-clean install man tarball\
-       .FORCE-GIT-VERSION-FILE
+ .PHONY: dep all clean distclean maintainer-clean install man tarball
  all: dep @executables@ $(man_pages)
  dep: $(deps)
  man: $(man_pages)
  tarball: $(tarball)
  
- GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
-       @./GIT-VERSION-GEN GIT-VERSION-FILE
- -include GIT-VERSION-FILE
- @executables@: GIT-VERSION-FILE
  -include $(ggo_dir)/makefile
  
  %_command_list.c: %.cmd
@@@ -195,10 -189,6 +190,10 @@@ $(object_dir)/aac_afh.o: aac_afh.c | $(
        @[ -z "$(Q)" ] || echo 'CC $<'
        $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @faad_cppflags@ $<
  
 +$(object_dir)/gui%.o: gui%.c | $(object_dir)
 +      @[ -z "$(Q)" ] || echo 'CC $<'
 +      $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(DEBUG_CPPFLAGS) @curses_cppflags@ $<
 +
  $(object_dir)/%.cmdline.o: $(cmdline_dir)/%.cmdline.c $(cmdline_dir)/%.cmdline.h | $(object_dir)
        @[ -z "$(Q)" ] || echo 'CC $<'
        $(Q) $(CC) -c $(CPPFLAGS) -Wno-unused-function -o $@ $<
@@@ -215,7 -205,6 +210,7 @@@ $(object_dir)/%.d: %.c | $(object_dir
        @[ -z "$(Q)" ] || echo 'DEP $<'
        $(Q) ./depend.sh $(object_dir) $(cmdline_dir) $(CPPFLAGS) $< > $@
  
 +
  recv_objs := $(addprefix $(object_dir)/, @recv_objs@)
  filter_objs := $(addprefix $(object_dir)/, @filter_objs@)
  client_objs := $(addprefix $(object_dir)/, @client_objs@)
@@@ -251,7 -240,7 +246,7 @@@ para_client: $(client_objs
  
  para_gui: $(gui_objs)
        @[ -z "$(Q)" ] || echo 'LD $@'
 -      $(Q) $(CC) $(LDFLAGS) -o $@ $(gui_objs) -lncurses
 +      $(Q) $(CC) $(LDFLAGS) -o $@ $(gui_objs) -lcurses
  
  para_audiod: audiod_command_list.c audiod_command_list.h $(audiod_objs)
        @[ -z "$(Q)" ] || echo 'LD $@'
@@@ -286,7 -275,7 +281,7 @@@ clean2: clea
        $(Q) rm -rf man $(object_dir)
        $(Q) rm -f *_command_list.*
  
 -distclean: clean2
 +distclean: clean2 test-clean
        @[ -z "$(Q)" ] || echo 'DISTCLEAN'
        $(Q) rm -f Makefile autoscan.log config.status config.log
        $(Q) rm -rf autom4te.cache aclocal.m4
@@@ -309,7 -298,7 +304,7 @@@ $(tarball): $(cmdline_generated
        git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \
                | tar --delete $(tarball_delete) > $(tarball_pfx).tar
        mkdir -p $(tarball_pfx)/$(cmdline_dir)
-       echo $(GIT_VERSION) > $(tarball_pfx)/VERSION
+       ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION
        cp -r $(autocrap) $(tarball_pfx)
        cp -r $(cmdline_generated) $(tarball_pfx)/$(cmdline_dir)
        tar rf $(tarball_pfx).tar $(tarball_pfx)/*
  %.pdf: %.ps
        ps2pdf - - < $< > $@
  
 +include $(test_dir)/makefile.test
diff --combined audiod.c
index e5db0cd2b075c726e931f22ea854d0b916b7e8ef,8dd69c60910a725999b193c3e254df9f9c69c2a3..5bc22c816896d22b7c1269dc7ceb3fa234efd7b0
+++ b/audiod.c
@@@ -33,6 -33,7 +33,7 @@@
  #include "write.h"
  #include "write_common.h"
  #include "signal.h"
+ #include "version.h"
  
  /** define the array of error lists needed by para_audiod */
  INIT_AUDIOD_ERRLISTS;
@@@ -167,7 -168,7 +168,7 @@@ struct command_task 
   * \return The audio format number on success, -E_UNSUPPORTED_AUDIO_FORMAT if
   * \a name is not a supported audio format.
   */
 -int get_audio_format_num(const char *name)
 +static int get_audio_format_num(const char *name)
  {
        int i;
  
@@@ -469,6 -470,20 +470,6 @@@ static int get_empty_slot(void
        return -E_NO_MORE_SLOTS;
  }
  
 -/**
 - * get the number of filters
 - *
 - * \param audio_format_num the number identifying the audio format
 - *
 - * \return the number of filters for the given audio format
 - *
 - * \sa struct filter;
 - */
 -int num_filters(int audio_format_num)
 -{
 -      return afi[audio_format_num].num_filters;
 -}
 -
  static void open_filters(struct slot_info *s)
  {
        struct audio_format_info *a = afi + s->format;
@@@ -1083,17 -1098,17 +1084,17 @@@ static void try_to_close_slot(int slot_
  
        if (s->format < 0)
                return;
 -      if (s->receiver_node && s->receiver_node->task.error != -E_TASK_UNREGISTERED)
 +      if (s->receiver_node && s->receiver_node->task.error >= 0)
                return;
        for (i = 0; i < a->num_filters; i++)
 -              if (s->fns && s->fns[i].task.error != -E_TASK_UNREGISTERED)
 +              if (s->fns && s->fns[i].task.error >= 0)
                        return;
        if (a->num_writers > 0) {
                for (i = 0; i < a->num_writers; i++)
 -                      if (s->wns && s->wns[i].task.error != -E_TASK_UNREGISTERED)
 +                      if (s->wns && s->wns[i].task.error >= 0)
                                return;
        } else {
 -              if (s->wns && s->wns[0].task.error != -E_TASK_UNREGISTERED)
 +              if (s->wns && s->wns[0].task.error >= 0)
                        return;
        }
        PARA_INFO_LOG("closing slot %d\n", slot_num);
@@@ -1174,7 -1189,7 +1175,7 @@@ static void status_post_select(__a_unus
                        kill_btrn(st->ct->btrn, &st->ct->task, -E_AUDIOD_OFF);
                        goto out;
                }
 -              if (st->ct->task.error != -E_TASK_UNREGISTERED)
 +              if (st->ct->task.error >= 0)
                        goto out;
                close_stat_pipe();
                st->clock_diff_count = conf.clock_diff_count_arg;
                size_t sz;
                int ret;
                if (st->ct->task.error < 0) {
 -                      if (st->ct->task.error != -E_TASK_UNREGISTERED)
 +                      if (st->ct->task.error >= 0)
                                goto out;
                        close_stat_pipe();
                        goto out;
diff --combined command.c
index 5217f9b487cd260aebe5d5a986f4fd8e957b0270,029e28908d70237041570063aca0f13d4bb78416..24ddf7897d81e3b27c6f1777f975da49ca31ee52
+++ b/command.c
@@@ -37,6 -37,7 +37,7 @@@
  #include "afs_command_list.h"
  #include "sched.h"
  #include "signal.h"
+ #include "version.h"
  
  /** Commands including options must be shorter than this. */
  #define MAX_COMMAND_LEN 32768
@@@ -255,8 -256,7 +256,8 @@@ int com_si(struct rc4_context *rc4c, in
                free(info);
        }
        ut = uptime_str();
 -      ret = rc4_send_va_buffer(rc4c, "up: %s\nplayed: %u\n"
 +      ret = rc4_send_va_buffer(rc4c, "version: " GIT_VERSION "\n"
 +              "up: %s\nplayed: %u\n"
                "server_pid: %d\n"
                "afs_pid: %d\n"
                "connections (active/accepted/total): %u/%u/%u\n"
diff --combined fade.c
index 5fbd0dd48027ad990345aa5d8f86fa0d952e6188,8affd69d57682cde8b41ec1cef4d6f51af44c52a..41b4a6d78e2b40d80cb24e31a5b0030c37db4584
--- 1/fade.c
--- 2/fade.c
+++ b/fade.c
@@@ -23,6 -23,7 +23,7 @@@
  #include "fd.h"
  #include "string.h"
  #include "error.h"
+ #include "version.h"
  
  INIT_FADE_ERRLISTS;
  static struct fade_args_info conf;
@@@ -125,7 -126,6 +126,7 @@@ static void fixup_mixer_channel_arg(voi
                case mixer_channel_arg_reclev: val = SOUND_MIXER_RECLEV; break;
                case mixer_channel_arg_igain: val = SOUND_MIXER_IGAIN; break;
                case mixer_channel_arg_ogain: val = SOUND_MIXER_OGAIN; break;
 +              default: break;
        }
        conf.mixer_channel_arg = val;
  }
@@@ -345,15 -345,15 +346,15 @@@ int main(int argc, char *argv[]
        }
        fixup_mixer_channel_arg();
        switch (conf.mode_arg) {
 -      case mode_arg_sleep:
 -              ret = sweet_dreams();
 -              break;
        case mode_arg_fade:
                ret = fade(conf.fade_vol_arg, conf.fade_time_arg);
                break;
        case mode_arg_snooze:
                ret = snooze();
                break;
 +      default: /* sleep mode */
 +              ret = sweet_dreams();
 +              break;
        }
        if (ret < 0)
                PARA_EMERG_LOG("%s\n", para_strerror(-ret));
diff --combined gui.c
index 3c1889ca51ae44fa89fdea7999aad0dcd31dcb33,4be81f749da4bfd244443973b0a6acb0c9207439..578eeed0c96d502767a57b5cb80f0cad2c9cfc07
--- 1/gui.c
--- 2/gui.c
+++ b/gui.c
@@@ -22,6 -22,7 +22,7 @@@
  #include "list.h"
  #include "sched.h"
  #include "signal.h"
+ #include "version.h"
  
  /** define the array of error lists needed by para_gui */
  INIT_GUI_ERRLISTS;
@@@ -33,10 -34,10 +34,10 @@@ static int signal_pipe
  
  static struct win_data {
        WINDOW *win;
 -      NCURSES_SIZE_T begx;
 -      NCURSES_SIZE_T begy;
 -      NCURSES_SIZE_T cols;
 -      NCURSES_SIZE_T lines;
 +      size_t begx;
 +      size_t begy;
 +      size_t cols;
 +      size_t lines;
  } top, bot, sb, in, sep;
  
  #define RINGBUFFER_SIZE 512
diff --combined para.h
index 08eb0ee6c20ab1a7779cc3f10de2b5fca094f44b,3121850f87ae27581d45da79e0f3ae9d57eced78..7217486d7965c93dfa0361c54982e6225aa06875
--- 1/para.h
--- 2/para.h
+++ b/para.h
                va_end(argp); \
        }
  
- /** Version text used by various commands if -V switch was given. */
- #define VERSION_TEXT(prefix) "para_" prefix " " PACKAGE_VERSION \
-       " (" GIT_VERSION ": " CODENAME ")" "\n" \
-       "Copyright (C) 2011 Andre Noll\n" \
-       "This is free software with ABSOLUTELY NO WARRANTY." \
-       " See COPYING for details.\n" \
-       "Written by Andre Noll.\n" \
-       "Report bugs to <maan@systemlinux.org>.\n"
- /** Print out \p VERSION_TEXT and exit if version flag was given. */
- #define HANDLE_VERSION_FLAG(_prefix, _args_info_struct) \
-       if (_args_info_struct.version_given) { \
-               printf("%s", VERSION_TEXT(_prefix)); \
-               exit(EXIT_SUCCESS); \
-       }
  /** Sent by para_client to initiate the authentication procedure. */
  #define AUTH_REQUEST_MSG "auth rsa "
  /** Sent by para_server for commands that expect a data file. */
@@@ -221,9 -205,6 +205,9 @@@ _static_inline_ long int para_random(un
  /** Used to avoid a shortcoming in vim's syntax highlighting. */
  #define EMBRACE(...) { __VA_ARGS__}
  
 +/** A nice cup of STFU for Mr gcc. */
 +#define do_nothing do {/* nothing */} while (0)
 +
  /**
   * The sample formats supported by paraslash.
   *
diff --combined write.c
index b3824a081f594dee23617502caf65261717d77b9,cf48922a473e23a85d4153d9784af0cfcbb3011f..571dc4ed8e4c0d35e253f277205975d5eac8758c
+++ b/write.c
@@@ -23,6 -23,7 +23,7 @@@
  #include "write_common.h"
  #include "fd.h"
  #include "error.h"
+ #include "version.h"
  
  INIT_WRITE_ERRLISTS;
  
@@@ -209,20 -210,6 +210,20 @@@ static int main_btr(struct sched *s
        s->default_timeout.tv_sec = 10;
        s->default_timeout.tv_usec = 50000;
        ret = schedule(s);
 +      if (ret >= 0) {
 +              int j;
 +              for (j = 0; j < i; j++) {
 +                      struct task *t = &wns[j].task;
 +                      assert(t->error < 0);
 +                      if (t->error != -E_WRITE_COMMON_EOF
 +                                      && t->error != -E_BTR_EOF) {
 +                              PARA_ERROR_LOG("%s: %s\n", t->status,
 +                                      para_strerror(-t->error));
 +                              if (ret >= 0)
 +                                      ret = t->error;
 +                      }
 +              }
 +      }
  out:
        for (i--; i >= 0; i--) {
                struct writer_node *wn = wns + i;