]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Merge topic branch t/fd into master
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 6 Aug 2023 16:38:05 +0000 (18:38 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sun, 6 Aug 2023 16:39:01 +0000 (18:39 +0200)
A rash of patches which clean up a good part of fd.c. Nothing major
here, mostly simplifications and documentation improvements.

* refs/heads/t/fd:
  fd: Simplify and move for_each_file_in_dir().
  fd.c: Improve error checking of para_mkdir().
  fd: Revamp para_mkdir().
  fd: Improve read_pattern(), rename it to read_and_compare().
  fd: Remove log message from para_munmap().
  fd: Open-code para_chdir().
  fd: Remove file_exists().
  fd: Improve documentation of xwritev().
  fd: Improve documentation of write_all().
  fd: Improve documentation of write_va_buffer().

1  2 
NEWS.md
afs.c
client_common.c

diff --combined NEWS.md
index a259ef3e140ceeb5649217c903ee6820a973a0f0,598db71fae93734158509fa5f76853ceb09ccb7b..a0484f09d177cb3f7effdd4962650cdce28281ad
+++ b/NEWS.md
@@@ -1,20 -1,6 +1,21 @@@
  NEWS
  ====
  
 +----------------------------------------------
 +0.7.3 (to be announced) "weighted correctness"
 +----------------------------------------------
 +
 +- Old style PEM keys are now deprecated. They still work but their
 +  use results in a run-time warning. The removal of PEM key support is
 +  scheduled for paraslash-0.8.0.
 +- Version 1.0 of the openssl library has been deprecated. A warning
 +  is printed at compile-time on systems which have this outdated version
 +  because it will no longer be supported once paraslash-0.8.0 comes out.
++- A spring cleanup for the senescent code in fd.c.
 +
 +Downloads:
 +[tarball](./releases/paraslash-git.tar.xz)
 +
  -------------------------------------
  0.7.2 (2023-03-08) "optical friction"
  -------------------------------------
diff --combined afs.c
index 83889bb90653360af7badaa3ba67b2ed61b4ed2e,8bd52c9af282c59c31106bf667625bd586ca1c53..865effde671a4848298ab09d502898c6225a937c
--- 1/afs.c
--- 2/afs.c
+++ b/afs.c
@@@ -448,7 -448,7 +448,7 @@@ static int activate_mood_or_playlist(co
                mode = PLAY_MODE_MOOD;
        } else {
                ret = -ERRNO_TO_PARA_ERROR(EINVAL);
 -              msg = make_message("%s: parse error", arg);
 +              msg = make_message("%s: parse error\n", arg);
        }
        if (pb)
                para_printf(pb, "%s", msg);
@@@ -529,8 -529,8 +529,8 @@@ static void init_admissible_files(cons
  {
        int ret = activate_mood_or_playlist(arg, NULL);
        if (ret < 0) {
 -              PARA_WARNING_LOG("could not activate %s: %s\n", arg,
 -                      para_strerror(-ret));
 +              PARA_WARNING_LOG("could not activate %s: %s\n", arg?
 +                      arg : "dummy", para_strerror(-ret));
                if (arg)
                        activate_mood_or_playlist(NULL, NULL);
        }
@@@ -580,17 -580,6 +580,6 @@@ static void get_database_dir(void
        PARA_INFO_LOG("afs_database dir %s\n", database_dir);
  }
  
- static int make_database_dir(void)
- {
-       int ret;
-       get_database_dir();
-       ret = para_mkdir(database_dir, 0777);
-       if (ret >= 0 || ret == -ERRNO_TO_PARA_ERROR(EEXIST))
-               return 1;
-       return ret;
- }
  static int open_afs_tables(void)
  {
        int i, ret;
@@@ -963,7 -952,6 +952,7 @@@ __noreturn void afs_init(int socket_fd
        ret = schedule(&s);
        sched_shutdown(&s);
        mood_unload();
 +      playlist_unload();
  out_close:
        close_afs_tables();
  out:
@@@ -1062,7 -1050,8 +1051,8 @@@ static int com_init(struct command_cont
                .size = sizeof(table_mask)};
        unsigned num_inputs = lls_num_inputs(lpr);
  
-       ret = make_database_dir();
+       get_database_dir();
+       ret = para_mkdir(database_dir);
        if (ret < 0)
                return ret;
        if (num_inputs > 0) {
diff --combined client_common.c
index 43527ddb71647eee5936760cda40e722085b21f8,642852ec6b8751454538ac9f3a021970f5cfbdef..3b90000f90ccdcc64be78e98e564bddc9cff3adb
@@@ -262,7 -262,7 +262,7 @@@ static bool has_feature(const char *fea
                return false;
        for (int i = 0; ct->features[i]; i++)
                if (strcmp(feature, ct->features[i]) == 0)
 -                      return i;
 +                      return true;
        return false;
  }
  
@@@ -578,8 -578,9 +578,9 @@@ int client_parse_config(int argc, char 
        if (CLIENT_OPT_GIVEN(KEY_FILE, lpr))
                kf = para_strdup(CLIENT_OPT_STRING_VAL(KEY_FILE, lpr));
        else {
+               struct stat statbuf;
                kf = make_message("%s/.paraslash/key.%s", home, user);
-               if (!file_exists(kf)) {
+               if (stat(kf, &statbuf) != 0) { /* assume file does not exist */
                        free(kf);
                        kf = make_message("%s/.ssh/id_rsa", home);
                }