Commit b7d2d4cf authored by Max Kellermann's avatar Max Kellermann

database: don't allow uri==NULL

Add nonnull attributes and fix all callers.
parent a6c797ee
......@@ -963,7 +963,7 @@ handle_find(struct client *client, int argc, char *argv[])
}
GError *error = NULL;
enum command_return ret = findSongsIn(client, NULL, list, &error)
enum command_return ret = findSongsIn(client, "", list, &error)
? COMMAND_RETURN_OK
: print_error(client, error);
......@@ -987,7 +987,7 @@ handle_findadd(struct client *client, int argc, char *argv[])
GError *error = NULL;
enum command_return ret =
findAddIn(client->player_control, NULL, list, &error)
findAddIn(client->player_control, "", list, &error)
? COMMAND_RETURN_OK
: print_error(client, error);
......@@ -1011,7 +1011,7 @@ handle_search(struct client *client, int argc, char *argv[])
}
GError *error = NULL;
enum command_return ret = searchForSongsIn(client, NULL, list, &error)
enum command_return ret = searchForSongsIn(client, "", list, &error)
? COMMAND_RETURN_OK
: print_error(client, error);
......@@ -1036,7 +1036,7 @@ handle_count(struct client *client, int argc, char *argv[])
GError *error = NULL;
enum command_return ret =
searchStatsForSongsIn(client, NULL, list, &error)
searchStatsForSongsIn(client, "", list, &error)
? COMMAND_RETURN_OK
: print_error(client, error);
......@@ -1266,7 +1266,7 @@ handle_prioid(struct client *client, int argc, char *argv[])
static enum command_return
handle_listall(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
{
char *directory = NULL;
const char *directory = "";
if (argc == 2)
directory = argv[1];
......@@ -1537,7 +1537,7 @@ handle_seekid(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
static enum command_return
handle_listallinfo(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
{
char *directory = NULL;
const char *directory = "";
if (argc == 2)
directory = argv[1];
......
......@@ -20,6 +20,8 @@
#ifndef MPD_DATABASE_H
#define MPD_DATABASE_H
#include "gcc.h"
#include <glib.h>
#include <sys/time.h>
......@@ -47,12 +49,15 @@ db_finish(void);
struct directory *
db_get_root(void);
gcc_nonnull(1)
struct directory *
db_get_directory(const char *name);
gcc_nonnull(1)
struct song *
db_get_song(const char *file);
gcc_nonnull(1,2)
bool
db_walk(const char *uri,
const struct db_visitor *visitor, void *ctx,
......
......@@ -20,23 +20,26 @@
#ifndef MPD_DB_UTILS_H
#define MPD_DB_UTILS_H
#include "gcc.h"
#include <glib.h>
#include <stdbool.h>
struct locate_item_list;
struct player_control;
gcc_nonnull(1,2)
bool
addAllIn(struct player_control *pc, const char *uri, GError **error_r);
gcc_nonnull(1,2)
bool
addAllInToStoredPlaylist(const char *uri_utf8, const char *path_utf8,
GError **error_r);
gcc_nonnull(1,2,3)
bool
findAddIn(struct player_control *pc, const char *name,
const struct locate_item_list *criteria, GError **error_r);
unsigned long sumSongTimesIn(const char *name);
#endif
......@@ -286,7 +286,7 @@ listAllUniqueTags(struct client *client, int type,
data.set = strset_new();
}
if (!db_walk(NULL, &unique_tags_visitor, &data, error_r)) {
if (!db_walk("", &unique_tags_visitor, &data, error_r)) {
freeListCommandItem(item);
return false;
}
......
......@@ -20,6 +20,8 @@
#ifndef MPD_DB_PRINT_H
#define MPD_DB_PRINT_H
#include "gcc.h"
#include <glib.h>
#include <stdbool.h>
......@@ -27,28 +29,34 @@ struct client;
struct locate_item_list;
struct db_visitor;
gcc_nonnull(1,2)
bool
printAllIn(struct client *client, const char *uri_utf8, GError **error_r);
gcc_nonnull(1,2)
bool
printInfoForAllIn(struct client *client, const char *uri_utf8,
GError **error_r);
gcc_nonnull(1,2,3)
bool
searchForSongsIn(struct client *client, const char *name,
const struct locate_item_list *criteria,
GError **error_r);
gcc_nonnull(1,2,3)
bool
findSongsIn(struct client *client, const char *name,
const struct locate_item_list *criteria,
GError **error_r);
gcc_nonnull(1,2,3)
bool
searchStatsForSongsIn(struct client *client, const char *name,
const struct locate_item_list *criteria,
GError **error_r);
gcc_nonnull(1,3)
bool
listAllUniqueTags(struct client *client, int type,
const struct locate_item_list *criteria,
......
......@@ -20,6 +20,8 @@
#ifndef MPD_LOCATE_H
#define MPD_LOCATE_H
#include "gcc.h"
#include <stdint.h>
#include <stdbool.h>
......@@ -57,6 +59,7 @@ struct locate_item_list *
locate_item_list_new(unsigned length);
/* return number of items or -1 on error */
gcc_nonnull(1)
struct locate_item_list *
locate_item_list_parse(char *argv[], int argc);
......@@ -64,19 +67,24 @@ locate_item_list_parse(char *argv[], int argc);
* Duplicate the struct locate_item_list object and convert all
* needles with g_utf8_casefold().
*/
gcc_nonnull(1)
struct locate_item_list *
locate_item_list_casefold(const struct locate_item_list *list);
gcc_nonnull(1)
void
locate_item_list_free(struct locate_item_list *list);
gcc_nonnull(1)
void
locate_item_free(struct locate_item *item);
gcc_nonnull(1,2)
bool
locate_song_search(const struct song *song,
const struct locate_item_list *criteria);
gcc_nonnull(1,2)
bool
locate_song_match(const struct song *song,
const struct locate_item_list *criteria);
......
......@@ -98,7 +98,7 @@ void stats_update(void)
data.artists = strset_new();
data.albums = strset_new();
db_walk(NULL, &collect_stats_visitor, &data, NULL);
db_walk("", &collect_stats_visitor, &data, NULL);
stats.artist_count = strset_size(data.artists);
stats.album_count = strset_size(data.albums);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment