aac: fix some signedness warnings
[paraslash.git] / mysql_selector.c
index 0a7d81f8caaee1dd6c69e1b5ef07ccce6dff0f0d..b2a925e09311a6cc71bf45c488c73eca8a163e99 100644 (file)
@@ -52,7 +52,7 @@ struct para_macro {
        const char *replacement;
 };
 
-static struct para_macro mysql_macro_list[] = {
+static const struct para_macro mysql_macro_list[] = {
        {       .name = "IS_N_SET",
                .replacement = "(data.%s != '1')"
        }, {
@@ -146,9 +146,10 @@ out:
  * \return \p NULL if one of the underlying calls to \p s_a_r returned \p NULL.
  * Otherwise the completely expanded version of \p src is returned.
  */
-__must_check __malloc static char *s_a_r_list(struct para_macro *macro_list, char *src)
+__must_check __malloc static char *s_a_r_list(const struct para_macro *macro_list,
+               char *src)
 {
-       struct para_macro *mp = macro_list;
+       const struct para_macro *mp = macro_list;
        char *ret = NULL, *tmp = para_strdup(src);
 
        while (mp->name) {
@@ -899,7 +900,6 @@ write:
        return info;
 }
 
-
 /* might return NULL */
 static char *get_current_audio_file(void)
 {
@@ -910,6 +910,29 @@ static char *get_current_audio_file(void)
        return name;
 }
 
+/* If called as child, mmd_lock must be held */
+static void update_mmd(char *info)
+{
+       PARA_DEBUG_LOG("%s", "updating shared memory area\n");
+       strncpy(mmd->selector_info, info, MMD_INFO_SIZE - 1);
+       mmd->selector_info[MMD_INFO_SIZE - 1] = '\0';
+}
+
+static void refresh_selector_info(void)
+{
+       char *name = get_current_audio_file();
+       char *info;
+
+       if (!name)
+               return;
+       info = get_selector_info(name);
+       free(name);
+       mmd_lock();
+       update_mmd(info);
+       mmd_unlock();
+       free(info);
+}
+
 /* list attributes / print database info */
 static int com_la_info(int fd, int argc, char *argv[])
 {
@@ -1185,7 +1208,10 @@ int com_picass(int fd, int argc, char *argv[])
  */
 int com_snp(int fd, int argc, char *argv[])
 {
-       return com_set(fd, argc, argv);
+       int ret = com_set(fd, argc, argv);
+       if (ret >= 0)
+               refresh_selector_info();
+       return ret;
 }
 
 /*
@@ -1462,14 +1488,6 @@ out:
        return ret;
 }
 
-/* If called as child, mmd_lock must be held */
-static void update_mmd(char *info)
-{
-       PARA_DEBUG_LOG("%s", "updating shared memory area\n");
-       strncpy(mmd->selector_info, info, MMD_INFO_SIZE - 1);
-       mmd->selector_info[MMD_INFO_SIZE - 1] = '\0';
-}
-
 static void update_audio_file_server_handler(char *name)
 {
        char *info;
@@ -1491,24 +1509,11 @@ int com_us(__a_unused int fd, int argc, char *argv[])
                return -E_ESCAPE;
        ret = update_audio_file(argv[1]);
        free(tmp);
+       if (ret >= 0)
+               refresh_selector_info();
        return ret;
 }
 
-static void refresh_selector_info(void)
-{
-       char *name = get_current_audio_file();
-       char *info;
-
-       if (!name)
-               return;
-       info = get_selector_info(name);
-       free(name);
-       mmd_lock();
-       update_mmd(info);
-       mmd_unlock();
-       free(info);
-}
-
 /* select previous / next stream */
 static int com_ps_ns(__a_unused int fd, int argc, char *argv[])
 {