database: don't allow uri==NULL
Add nonnull attributes and fix all callers.
This commit is contained in:
parent
a6c797ee4b
commit
b7d2d4cfe8
|
@ -963,7 +963,7 @@ handle_find(struct client *client, int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
enum command_return ret = findSongsIn(client, NULL, list, &error)
|
enum command_return ret = findSongsIn(client, "", list, &error)
|
||||||
? COMMAND_RETURN_OK
|
? COMMAND_RETURN_OK
|
||||||
: print_error(client, error);
|
: print_error(client, error);
|
||||||
|
|
||||||
|
@ -987,7 +987,7 @@ handle_findadd(struct client *client, int argc, char *argv[])
|
||||||
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
enum command_return ret =
|
enum command_return ret =
|
||||||
findAddIn(client->player_control, NULL, list, &error)
|
findAddIn(client->player_control, "", list, &error)
|
||||||
? COMMAND_RETURN_OK
|
? COMMAND_RETURN_OK
|
||||||
: print_error(client, error);
|
: print_error(client, error);
|
||||||
|
|
||||||
|
@ -1011,7 +1011,7 @@ handle_search(struct client *client, int argc, char *argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
enum command_return ret = searchForSongsIn(client, NULL, list, &error)
|
enum command_return ret = searchForSongsIn(client, "", list, &error)
|
||||||
? COMMAND_RETURN_OK
|
? COMMAND_RETURN_OK
|
||||||
: print_error(client, error);
|
: print_error(client, error);
|
||||||
|
|
||||||
|
@ -1036,7 +1036,7 @@ handle_count(struct client *client, int argc, char *argv[])
|
||||||
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
enum command_return ret =
|
enum command_return ret =
|
||||||
searchStatsForSongsIn(client, NULL, list, &error)
|
searchStatsForSongsIn(client, "", list, &error)
|
||||||
? COMMAND_RETURN_OK
|
? COMMAND_RETURN_OK
|
||||||
: print_error(client, error);
|
: print_error(client, error);
|
||||||
|
|
||||||
|
@ -1266,7 +1266,7 @@ handle_prioid(struct client *client, int argc, char *argv[])
|
||||||
static enum command_return
|
static enum command_return
|
||||||
handle_listall(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
|
handle_listall(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *directory = NULL;
|
const char *directory = "";
|
||||||
|
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
directory = argv[1];
|
directory = argv[1];
|
||||||
|
@ -1537,7 +1537,7 @@ handle_seekid(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
|
||||||
static enum command_return
|
static enum command_return
|
||||||
handle_listallinfo(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
|
handle_listallinfo(struct client *client, G_GNUC_UNUSED int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *directory = NULL;
|
const char *directory = "";
|
||||||
|
|
||||||
if (argc == 2)
|
if (argc == 2)
|
||||||
directory = argv[1];
|
directory = argv[1];
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#ifndef MPD_DATABASE_H
|
#ifndef MPD_DATABASE_H
|
||||||
#define MPD_DATABASE_H
|
#define MPD_DATABASE_H
|
||||||
|
|
||||||
|
#include "gcc.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
@ -47,12 +49,15 @@ db_finish(void);
|
||||||
struct directory *
|
struct directory *
|
||||||
db_get_root(void);
|
db_get_root(void);
|
||||||
|
|
||||||
|
gcc_nonnull(1)
|
||||||
struct directory *
|
struct directory *
|
||||||
db_get_directory(const char *name);
|
db_get_directory(const char *name);
|
||||||
|
|
||||||
|
gcc_nonnull(1)
|
||||||
struct song *
|
struct song *
|
||||||
db_get_song(const char *file);
|
db_get_song(const char *file);
|
||||||
|
|
||||||
|
gcc_nonnull(1,2)
|
||||||
bool
|
bool
|
||||||
db_walk(const char *uri,
|
db_walk(const char *uri,
|
||||||
const struct db_visitor *visitor, void *ctx,
|
const struct db_visitor *visitor, void *ctx,
|
||||||
|
|
|
@ -20,23 +20,26 @@
|
||||||
#ifndef MPD_DB_UTILS_H
|
#ifndef MPD_DB_UTILS_H
|
||||||
#define MPD_DB_UTILS_H
|
#define MPD_DB_UTILS_H
|
||||||
|
|
||||||
|
#include "gcc.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
struct locate_item_list;
|
struct locate_item_list;
|
||||||
struct player_control;
|
struct player_control;
|
||||||
|
|
||||||
|
gcc_nonnull(1,2)
|
||||||
bool
|
bool
|
||||||
addAllIn(struct player_control *pc, const char *uri, GError **error_r);
|
addAllIn(struct player_control *pc, const char *uri, GError **error_r);
|
||||||
|
|
||||||
|
gcc_nonnull(1,2)
|
||||||
bool
|
bool
|
||||||
addAllInToStoredPlaylist(const char *uri_utf8, const char *path_utf8,
|
addAllInToStoredPlaylist(const char *uri_utf8, const char *path_utf8,
|
||||||
GError **error_r);
|
GError **error_r);
|
||||||
|
|
||||||
|
gcc_nonnull(1,2,3)
|
||||||
bool
|
bool
|
||||||
findAddIn(struct player_control *pc, const char *name,
|
findAddIn(struct player_control *pc, const char *name,
|
||||||
const struct locate_item_list *criteria, GError **error_r);
|
const struct locate_item_list *criteria, GError **error_r);
|
||||||
|
|
||||||
unsigned long sumSongTimesIn(const char *name);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -286,7 +286,7 @@ listAllUniqueTags(struct client *client, int type,
|
||||||
data.set = strset_new();
|
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);
|
freeListCommandItem(item);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#ifndef MPD_DB_PRINT_H
|
#ifndef MPD_DB_PRINT_H
|
||||||
#define MPD_DB_PRINT_H
|
#define MPD_DB_PRINT_H
|
||||||
|
|
||||||
|
#include "gcc.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
@ -27,28 +29,34 @@ struct client;
|
||||||
struct locate_item_list;
|
struct locate_item_list;
|
||||||
struct db_visitor;
|
struct db_visitor;
|
||||||
|
|
||||||
|
gcc_nonnull(1,2)
|
||||||
bool
|
bool
|
||||||
printAllIn(struct client *client, const char *uri_utf8, GError **error_r);
|
printAllIn(struct client *client, const char *uri_utf8, GError **error_r);
|
||||||
|
|
||||||
|
gcc_nonnull(1,2)
|
||||||
bool
|
bool
|
||||||
printInfoForAllIn(struct client *client, const char *uri_utf8,
|
printInfoForAllIn(struct client *client, const char *uri_utf8,
|
||||||
GError **error_r);
|
GError **error_r);
|
||||||
|
|
||||||
|
gcc_nonnull(1,2,3)
|
||||||
bool
|
bool
|
||||||
searchForSongsIn(struct client *client, const char *name,
|
searchForSongsIn(struct client *client, const char *name,
|
||||||
const struct locate_item_list *criteria,
|
const struct locate_item_list *criteria,
|
||||||
GError **error_r);
|
GError **error_r);
|
||||||
|
|
||||||
|
gcc_nonnull(1,2,3)
|
||||||
bool
|
bool
|
||||||
findSongsIn(struct client *client, const char *name,
|
findSongsIn(struct client *client, const char *name,
|
||||||
const struct locate_item_list *criteria,
|
const struct locate_item_list *criteria,
|
||||||
GError **error_r);
|
GError **error_r);
|
||||||
|
|
||||||
|
gcc_nonnull(1,2,3)
|
||||||
bool
|
bool
|
||||||
searchStatsForSongsIn(struct client *client, const char *name,
|
searchStatsForSongsIn(struct client *client, const char *name,
|
||||||
const struct locate_item_list *criteria,
|
const struct locate_item_list *criteria,
|
||||||
GError **error_r);
|
GError **error_r);
|
||||||
|
|
||||||
|
gcc_nonnull(1,3)
|
||||||
bool
|
bool
|
||||||
listAllUniqueTags(struct client *client, int type,
|
listAllUniqueTags(struct client *client, int type,
|
||||||
const struct locate_item_list *criteria,
|
const struct locate_item_list *criteria,
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#ifndef MPD_LOCATE_H
|
#ifndef MPD_LOCATE_H
|
||||||
#define MPD_LOCATE_H
|
#define MPD_LOCATE_H
|
||||||
|
|
||||||
|
#include "gcc.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
@ -57,6 +59,7 @@ struct locate_item_list *
|
||||||
locate_item_list_new(unsigned length);
|
locate_item_list_new(unsigned length);
|
||||||
|
|
||||||
/* return number of items or -1 on error */
|
/* return number of items or -1 on error */
|
||||||
|
gcc_nonnull(1)
|
||||||
struct locate_item_list *
|
struct locate_item_list *
|
||||||
locate_item_list_parse(char *argv[], int argc);
|
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
|
* Duplicate the struct locate_item_list object and convert all
|
||||||
* needles with g_utf8_casefold().
|
* needles with g_utf8_casefold().
|
||||||
*/
|
*/
|
||||||
|
gcc_nonnull(1)
|
||||||
struct locate_item_list *
|
struct locate_item_list *
|
||||||
locate_item_list_casefold(const struct locate_item_list *list);
|
locate_item_list_casefold(const struct locate_item_list *list);
|
||||||
|
|
||||||
|
gcc_nonnull(1)
|
||||||
void
|
void
|
||||||
locate_item_list_free(struct locate_item_list *list);
|
locate_item_list_free(struct locate_item_list *list);
|
||||||
|
|
||||||
|
gcc_nonnull(1)
|
||||||
void
|
void
|
||||||
locate_item_free(struct locate_item *item);
|
locate_item_free(struct locate_item *item);
|
||||||
|
|
||||||
|
gcc_nonnull(1,2)
|
||||||
bool
|
bool
|
||||||
locate_song_search(const struct song *song,
|
locate_song_search(const struct song *song,
|
||||||
const struct locate_item_list *criteria);
|
const struct locate_item_list *criteria);
|
||||||
|
|
||||||
|
gcc_nonnull(1,2)
|
||||||
bool
|
bool
|
||||||
locate_song_match(const struct song *song,
|
locate_song_match(const struct song *song,
|
||||||
const struct locate_item_list *criteria);
|
const struct locate_item_list *criteria);
|
||||||
|
|
|
@ -98,7 +98,7 @@ void stats_update(void)
|
||||||
data.artists = strset_new();
|
data.artists = strset_new();
|
||||||
data.albums = 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.artist_count = strset_size(data.artists);
|
||||||
stats.album_count = strset_size(data.albums);
|
stats.album_count = strset_size(data.albums);
|
||||||
|
|
Loading…
Reference in New Issue