From: Andre Noll Date: Sun, 29 Sep 2013 10:59:04 +0000 (+0200) Subject: Merge branch 't/misc_cleanups' X-Git-Tag: v0.5.1~12 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=74145aabe851ba5b7eff47b650f401f49b5c740d;hp=282a5e463090205ef8a12f50a9ecf6498b860e88 Merge branch 't/misc_cleanups' Was cooking since 2013-08-04. 3f97ae buffer_tree: Improve documentation of btr_no_parent(). fb9209 Avoid gcc warning on FreeBSD. 778af7 command.c: Avoid declaration after statement. 61c957 extract_v4_addr(): Don't return a structure. 1d7937 command.c: Remove pointless initialization. c17ede crypt.c: Remove condition which is always true. a12ecb ipc: Close proc fd. 01d37b Make log functions static. 0ba631 score: Improve documentation of score_update(). d6cf71 GIT-VERSION-GEN: Don't include output of git update-index. --- diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN index 32802232..df7ed327 100755 --- a/GIT-VERSION-GEN +++ b/GIT-VERSION-GEN @@ -16,7 +16,7 @@ elif [[ -d .git || -f .git ]] && case "$VN" in *$LF*) (exit 1) ;; v[0-9]*) - git update-index -q --refresh + git update-index -q --refresh &>/dev/null test -z "$(git diff-index --name-only HEAD --)" || VN="$VN-dirty" ;; esac diff --git a/acl.c b/acl.c index 60f835ae..e70ab9b3 100644 --- a/acl.c +++ b/acl.c @@ -57,7 +57,7 @@ static int acl_lookup(int fd, struct list_head *acl) PARA_ERROR_LOG("Can not determine peer address: %s\n", strerror(errno)); goto no_match; } - v4_addr = extract_v4_addr(&ss); + extract_v4_addr(&ss, &v4_addr); if (!v4_addr.s_addr) goto no_match; diff --git a/buffer_tree.c b/buffer_tree.c index aa9f1cdb..b1eeb036 100644 --- a/buffer_tree.c +++ b/buffer_tree.c @@ -544,14 +544,16 @@ static bool btr_no_children(struct btr_node *btrn) } /** - * Find out whether a node is an orphan node. + * Find out whether a node is an orphan. * * \param btrn The buffer tree node. * * \return True if \a btrn has no parent. * - * This function will always return true for the root node. However in case - * nodes have been removed from the tree, other nodes may become orphans too. + * This function returns true for the root node and false for any other node. + * + * After a (non-leaf) node was removed removed from the tree, the function + * returns true for all child nodes. */ bool btr_no_parent(struct btr_node *btrn) { diff --git a/command.c b/command.c index 9f349ee5..3d40023f 100644 --- a/command.c +++ b/command.c @@ -220,8 +220,8 @@ int send_sb(struct stream_cipher_context *scc, void *buf, size_t numbytes, int ret; struct sb_context *sbc; struct iovec iov[2]; - struct sb_buffer sbb = SBB_INIT(band, buf, numbytes); sb_transformation trafo = band < SBD_PROCEED? NULL : sc_trafo; + struct sb_buffer sbb = SBB_INIT(band, buf, numbytes); sbc = sb_new_send(&sbb, dont_free, trafo, scc->send); do { @@ -842,7 +842,7 @@ static int parse_sb_command(struct command_context *cc, struct iovec *iov) if (ret < 0) goto out; end = iov->iov_base + iov->iov_len; - for (i = 0, p = iov->iov_base; p < end; i++) + for (i = 0; p < end; i++) p += strlen(p) + 1; cc->argc = i; cc->argv = para_malloc((cc->argc + 1) * sizeof(char *)); diff --git a/crypt.c b/crypt.c index b8577dfc..5445138d 100644 --- a/crypt.c +++ b/crypt.c @@ -147,8 +147,7 @@ static int read_rsa_bignums(const unsigned char *blob, int blen, RSA **result) *result = rsa; return 1; fail: - if (rsa) - RSA_free(rsa); + RSA_free(rsa); return ret; } diff --git a/fade.c b/fade.c index 878b83a1..a8424d67 100644 --- a/fade.c +++ b/fade.c @@ -27,7 +27,7 @@ static struct mixer supported_mixer[] = {MIXER_ARRAY}; #define FOR_EACH_MIXER(i) for ((i) = 0; (i) < NUM_SUPPORTED_MIXERS; (i)++) static int loglevel; -__printf_2_3 void date_log(int ll, const char *fmt, ...) +static __printf_2_3 void date_log(int ll, const char *fmt, ...) { va_list argp; time_t t1; diff --git a/fd.c b/fd.c index 3ab5cad0..4d4a859b 100644 --- a/fd.c +++ b/fd.c @@ -526,6 +526,7 @@ static int para_opendir(const char *dirname, DIR **dir, int *cwd) { int ret; + *dir = NULL; if (cwd) { ret = para_open(".", O_RDONLY, 0); if (ret < 0) diff --git a/gui.c b/gui.c index baab0bd9..54fc9db9 100644 --- a/gui.c +++ b/gui.c @@ -526,7 +526,7 @@ static int add_output_line(char *line, void *data) static int loglevel; -__printf_2_3 void curses_log(int ll, const char *fmt,...) +static __printf_2_3 void curses_log(int ll, const char *fmt,...) { int color; char *msg; diff --git a/ipc.c b/ipc.c index 1ec53c30..89bbe535 100644 --- a/ipc.c +++ b/ipc.c @@ -209,6 +209,7 @@ size_t shm_get_shmmax(void) buf[ret] = '\0'; shmmax = strtoul(buf, NULL, 10); } + close(fd); } } #elif defined SYSCTL_SHMMAX_VARIABLE diff --git a/net.c b/net.c index 2ec3f03e..4a31f013 100644 --- a/net.c +++ b/net.c @@ -672,19 +672,19 @@ char *remote_name(int sockfd) /** * Extract IPv4 or IPv6-mapped-IPv4 address from sockaddr_storage. - * \param ss Container of IPv4/6 address - * \return Extracted IPv4 address (different from 0) or 0 if unsuccessful. * - * \sa RFC 3493 + * \param ss Container of IPv4/6 address. + * \param ia Extracted IPv4 address (different from 0) or 0 if unsuccessful. + * + * \sa RFC 3493. */ -struct in_addr extract_v4_addr(const struct sockaddr_storage *ss) +void extract_v4_addr(const struct sockaddr_storage *ss, struct in_addr *ia) { - struct in_addr ia = {.s_addr = 0}; const struct sockaddr *sa = normalize_ip_address(ss); + memset(ia, 0, sizeof(*ia)); if (sa->sa_family == AF_INET) - ia = ((struct sockaddr_in *)sa)->sin_addr; - return ia; + *ia = ((struct sockaddr_in *)sa)->sin_addr; } /** diff --git a/net.h b/net.h index ae5e8015..0003fa9d 100644 --- a/net.h +++ b/net.h @@ -114,7 +114,7 @@ static inline int para_connect_simple(unsigned l4type, return makesock(l4type, 0, host, port, NULL); } -extern struct in_addr extract_v4_addr(const struct sockaddr_storage *ss); +void extract_v4_addr(const struct sockaddr_storage *ss, struct in_addr *ia); /** * Functions to support listening sockets. diff --git a/para.h b/para.h index 6655d356..29658f47 100644 --- a/para.h +++ b/para.h @@ -62,7 +62,7 @@ extern __printf_2_3 void (*para_log)(int, const char*, ...); * */ #define DEFINE_STDERR_LOGGER(funcname, loglevel_barrier) \ - __printf_2_3 void funcname(int ll, const char* fmt,...) \ + static __printf_2_3 void funcname(int ll, const char* fmt,...) \ { \ va_list argp; \ if (ll < loglevel_barrier) \ diff --git a/score.c b/score.c index ca94e8de..37f4c550 100644 --- a/score.c +++ b/score.c @@ -168,13 +168,11 @@ static int get_nth_score(unsigned n, long *score) * \param aft_row Determines the audio file to change. * \param percent The position to re-insert the audio file. * - * The percent parameter must be between \p 0 and 100 and. A value of zero - * means to re-insert the audio file into the score table with a score lower - * than any other admissible file. + * The percent parameter must be between 0 and 100. A value of zero means to + * re-insert the audio file into the score table with a score lower than any + * other admissible file. * - * \return Positive on success, negative on errors. Possible errors: Errors - * returned by osl_get_row(), get_num_admissible_files(), osl_get_nth_row(), - * osl_get_object(), osl_update_object(). + * \return Positive on success, negative on errors. */ int score_update(const struct osl_row *aft_row, long percent) {