From: Andre Noll Date: Mon, 7 Nov 2022 16:34:31 +0000 (+0100) Subject: Merge topic branch t/net into master X-Git-Tag: v0.7.2~20 X-Git-Url: http://git.tuebingen.mpg.de/?a=commitdiff_plain;h=68c0deb1ae25af923fde02952159c1129a281813;hp=b414b9d3153944d860a10a45ed5db9697994b490;p=paraslash.git Merge topic branch t/net into master A moderately sized series which contains a bunch of simple cleanups for net.c and net.h. * refs/heads/t/net: net: De-doxify static functions. net: Refer to correct man page in stringify_port(). net: Pass true/false instead of 0/1 to makesock(). net: Demote log level of error message in makesock(). net: Rename para_connect_simple() -> para_connect(). net: Make is_valid_ipv{4,6}_address() local to net.c. net: Remove IPPROTO_DCCP define. net: Make single-use macros local. net: Combine documentation of struct flowopts. net: Drop extern keyword of function declarations. --- diff --git a/Makefile.real b/Makefile.real index 9c426673..bf3cb6e0 100644 --- a/Makefile.real +++ b/Makefile.real @@ -313,7 +313,7 @@ distclean: clean $(call SAY, DISTCLEAN) rm -f Makefile autoscan.log config.status config.log rm -f config.h configure config.h.in -maintainer-clean: distclean +maintainer-clean: distclean test-clean $(call SAY, MAINTAINER-CLEAN) rm -f *.tar.bz2 *.tar.xz rm -f GPATH GRTAGS GSYMS GTAGS diff --git a/NEWS.md b/NEWS.md index 5a00175c..c21cc858 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,15 @@ NEWS ==== +------------------------------------------ +0.7.2 (to be announced) "optical friction" +------------------------------------------ + +- Minor cleanup of the net subsystem. + +Downloads: +[tarball](./releases/paraslash-git.tar.xz) + -------------------------------------- 0.7.1 (2022-10-03) "digital spindrift" -------------------------------------- @@ -27,6 +36,7 @@ usual mix of bug fixes and minor improvements not mentioned here. requires support from the compiler, the oldest supported gcc version has been bumped to gcc-5.4 (released in 2015). +Downloads: [tarball](./releases/paraslash-0.7.1.tar.xz), [signature](./releases/paraslash-0.7.1.tar.xz.asc) diff --git a/client_common.c b/client_common.c index 9bcfcb82..95e59fd2 100644 --- a/client_common.c +++ b/client_common.c @@ -255,9 +255,15 @@ static int send_sb_command(struct client_task *ct) return send_sb(ct, 0, command, len, SBD_COMMAND, false); } +/* Find out if the given string is contained in the features vector. */ static bool has_feature(const char *feature, struct client_task *ct) { - return find_arg(feature, ct->features) >= 0? true : false; + if (!ct->features) + return false; + for (int i = 0; ct->features[i]; i++) + if (strcmp(feature, ct->features[i]) == 0) + return i; + return false; } /* diff --git a/error.h b/error.h index a644b967..82920ea8 100644 --- a/error.h +++ b/error.h @@ -29,7 +29,6 @@ PARA_ERROR(AO_OPEN_LIVE, "ao: could not open audio device"), \ PARA_ERROR(AO_PLAY, "ao_play() failed"), \ PARA_ERROR(AO_PTHREAD, "pthread error"), \ - PARA_ERROR(ARG_NOT_FOUND, "argument not found in arg vector"), \ PARA_ERROR(ASN1_PARSE, "could not parse ASN.1 key"), \ PARA_ERROR(ATOI_JUNK_AT_END, "further characters after number"), \ PARA_ERROR(ATOI_NO_DIGITS, "no digits found in string"), \ diff --git a/gui_theme.c b/gui_theme.c index 6f4acf37..f71e802b 100644 --- a/gui_theme.c +++ b/gui_theme.c @@ -122,16 +122,16 @@ static void init_theme_colorful_blackness(struct gui_theme *t) d[SI_status_flags].align = LEFT; d[SI_status_flags].x = 11; d[SI_status_flags].y = 17; - d[SI_status_flags].len = 10; + d[SI_status_flags].len = 8; d[SI_image_id].prefix = "img: "; d[SI_image_id].postfix = ""; d[SI_image_id].color.fg = COLOR_RED; d[SI_image_id].color.bg = COLOR_BLACK; d[SI_image_id].align = CENTER; - d[SI_image_id].x = 21; + d[SI_image_id].x = 19; d[SI_image_id].y = 17; - d[SI_image_id].len = 10; + d[SI_image_id].len = 12; d[SI_lyrics_id].prefix = "lyr: "; d[SI_lyrics_id].postfix = ""; diff --git a/mood.c b/mood.c index bcc9bc57..d47c54ef 100644 --- a/mood.c +++ b/mood.c @@ -249,20 +249,22 @@ int mood_check_callback(struct afs_callback_arg *aca) * overflows and rounding errors we store the common divisor of the * correction factors separately. */ -static int64_t normalized_value(int64_t x, int64_t n, int64_t sum, int64_t qd) -{ - if (!n || !qd) - return 0; - return 100 * (n * x - sum) / (int64_t)int_sqrt(n) / (int64_t)int_sqrt(qd); -} - static long compute_score(struct afs_info *afsi) { - long score = -normalized_value(afsi->num_played, statistics.num, - statistics.num_played_sum, statistics.num_played_qd); - score -= normalized_value(afsi->last_played, statistics.num, - statistics.last_played_sum, statistics.last_played_qd); - return score / 2; + int64_t mean_n, mean_l,score_n, score_l; + + assert(statistics.normalization_divisor > 0); + assert(statistics.num > 0); + mean_n = statistics.num_played_sum / statistics.num; + mean_l = statistics.last_played_sum / statistics.num; + + score_n = -((int64_t)afsi->num_played - mean_n) + * statistics.num_played_correction + / statistics.normalization_divisor; + score_l = -((int64_t)afsi->last_played - mean_l) + * statistics.last_played_correction + / statistics.normalization_divisor; + return (score_n + score_l) / 2; } static int add_afs_statistics(const struct osl_row *row) diff --git a/string.c b/string.c index 2c6d35d6..46b34623 100644 --- a/string.c +++ b/string.c @@ -806,27 +806,6 @@ int create_shifted_argv(const char *buf, const char *delim, char ***result) return create_argv_offset(1, buf, delim, result); } -/** - * Find out if the given string is contained in the arg vector. - * - * \param arg The string to look for. - * \param argv The array to search. - * - * \return The first index whose value equals \a arg, or \p -E_ARG_NOT_FOUND if - * arg was not found in \a argv. - */ -int find_arg(const char *arg, char **argv) -{ - int i; - - if (!argv) - return -E_ARG_NOT_FOUND; - for (i = 0; argv[i]; i++) - if (strcmp(arg, argv[i]) == 0) - return i; - return -E_ARG_NOT_FOUND; -} - /** * Compile a regular expression. * diff --git a/string.h b/string.h index 060d6540..d773600f 100644 --- a/string.h +++ b/string.h @@ -88,7 +88,6 @@ int para_atoi32(const char *str, int32_t *value); int read_size_header(const char *buf); int create_argv(const char *buf, const char *delim, char ***result); int create_shifted_argv(const char *buf, const char *delim, char ***result); -int find_arg(const char *arg, char **argv); void free_argv(char **argv); int para_regcomp(regex_t *preg, const char *regex, int cflags); void freep(void *arg);