We already employ this attribute extensively to help the compiler
improve optimization. However, a few malloc-like functions were not
yet marked with __malloc. Fix that and enable the warning to make
sure that new malloc-like functions get marked.
Since not all supported compilers know about this warning option, we
need to check at compile time whether the option is supported. Thanks
to the existing cc-option make(1) function, this is a simple one-liner
for Makefile.real.
STRICT_CFLAGS += $(call cc-option, -Wformat-signedness)
STRICT_CFLAGS += $(call cc-option, -Wdiscarded-qualifiers)
STRICT_CFLAGS += $(call cc-option, -Wformat-signedness)
STRICT_CFLAGS += $(call cc-option, -Wdiscarded-qualifiers)
+STRICT_CFLAGS += $(call cc-option, -Wsuggest-attribute=malloc)
# To put more focus on warnings, be less verbose as default
# Use 'make V=1' to see the full commands
# To put more focus on warnings, be less verbose as default
# Use 'make V=1' to see the full commands
*
* \return A string that must be freed by the caller.
*/
*
* \return A string that must be freed by the caller.
*/
-char *get_time_string(void)
+__malloc char *get_time_string(void)
{
int ret, seconds = 0, length = stat_task->length_seconds;
struct timeval *tmp, sum, sss, /* server stream start */
{
int ret, seconds = 0, length = stat_task->length_seconds;
struct timeval *tmp, sum, sss, /* server stream start */
struct btr_node *audiod_get_btr_root(void);
__malloc char *audiod_get_decoder_flags(void);
void clear_and_dump_items(void);
struct btr_node *audiod_get_btr_root(void);
__malloc char *audiod_get_decoder_flags(void);
void clear_and_dump_items(void);
-char *get_time_string(void);
+__malloc char *get_time_string(void);
bool uid_is_whitelisted(uid_t uid);
/* defined in audiod_command.c */
bool uid_is_whitelisted(uid_t uid);
/* defined in audiod_command.c */
* function also returns NULL. Otherwise a copy of the tag value is returned
* and the caller should free this memory when it is no longer needed.
*/
* function also returns NULL. Otherwise a copy of the tag value is returned
* and the caller should free this memory when it is no longer needed.
*/
-char *mp4_get_tag_value(const struct mp4 *f, const char *item)
+__malloc char *mp4_get_tag_value(const struct mp4 *f, const char *item)
{
for (unsigned n = 0; n < f->meta.count; n++)
if (!strcasecmp(f->meta.tags[n].item, item))
{
for (unsigned n = 0; n < f->meta.count; n++)
if (!strcasecmp(f->meta.tags[n].item, item))
int mp4_open_meta(const struct mp4_callback *cb, struct mp4 **result);
struct mp4_metadata *mp4_get_meta(struct mp4 *f);
int mp4_update_meta(struct mp4 *f);
int mp4_open_meta(const struct mp4_callback *cb, struct mp4 **result);
struct mp4_metadata *mp4_get_meta(struct mp4 *f);
int mp4_update_meta(struct mp4 *f);
-char *mp4_get_tag_value(const struct mp4 *f, const char *item);
+__malloc char *mp4_get_tag_value(const struct mp4 *f, const char *item);
* \return In all cases the returned string is a allocated with malloc(3) and
* has to be freed by the caller.
*/
* \return In all cases the returned string is a allocated with malloc(3) and
* has to be freed by the caller.
*/
-char *format_url(const char *url, int default_port)
+__malloc char *format_url(const char *url, int default_port)
{
char host[MAX_HOSTLEN];
int url_port;
{
char host[MAX_HOSTLEN];
int url_port;
char *addr, ssize_t addrlen, int32_t *netmask);
char *parse_url(const char *url,
char *host, ssize_t hostlen, int32_t *port);
char *addr, ssize_t addrlen, int32_t *netmask);
char *parse_url(const char *url,
char *host, ssize_t hostlen, int32_t *port);
-char *format_url(const char *url, int default_port);
+__malloc char *format_url(const char *url, int default_port);
const char *stringify_port(int port, const char *transport);
int lookup_address(unsigned l4type, bool passive, const char *host,
const char *stringify_port(int port, const char *transport);
int lookup_address(unsigned l4type, bool passive, const char *host,
*
* \sa \ref oac_custom_header_init().
*/
*
* \sa \ref oac_custom_header_init().
*/
-struct oac_custom_header *oac_custom_header_new(void)
+__malloc struct oac_custom_header *oac_custom_header_new(void)
{
return zalloc(sizeof(struct oac_custom_header));
}
{
return zalloc(sizeof(struct oac_custom_header));
}
* handlers that use the ogg container format.
*/
* handlers that use the ogg container format.
*/
-struct oac_custom_header *oac_custom_header_new(void);
+__malloc struct oac_custom_header *oac_custom_header_new(void);
void oac_custom_header_init(int serial, struct oac_custom_header *h);
int oac_custom_header_append(ogg_packet *op, struct oac_custom_header *h);
void oac_custom_header_flush(struct oac_custom_header *h);
void oac_custom_header_init(int serial, struct oac_custom_header *h);
int oac_custom_header_append(ogg_packet *op, struct oac_custom_header *h);
void oac_custom_header_flush(struct oac_custom_header *h);
const struct lls_opt_result *listen_address_opt_result,
int default_port, int max_clients, int default_deny);
void free_sender_status(const struct sender_status *ss);
const struct lls_opt_result *listen_address_opt_result,
int default_port, int max_clients, int default_deny);
void free_sender_status(const struct sender_status *ss);
-char *generic_sender_status(struct sender_status *ss, const char *name);
+__malloc char *generic_sender_status(struct sender_status *ss, const char *name);
void generic_com_allow(struct sender_command_data *scd,
struct sender_status *ss);
void generic_com_deny(struct sender_command_data *scd,
void generic_com_allow(struct sender_command_data *scd,
struct sender_status *ss);
void generic_com_deny(struct sender_command_data *scd,
void generic_com_on(struct sender_status *ss, unsigned protocol);
void generic_acl_deplete(struct list_head *acl);
void generic_com_off(struct sender_status *ss);
void generic_com_on(struct sender_status *ss, unsigned protocol);
void generic_acl_deplete(struct list_head *acl);
void generic_com_off(struct sender_status *ss);
-char *generic_sender_help(void);
+__malloc char *generic_sender_help(void);
struct sender_client *accept_sender_client(struct sender_status *ss);
int send_queued_chunks(int fd, struct chunk_queue *cq);
int parse_fec_url(const char *arg, struct sender_command_data *scd);
struct sender_client *accept_sender_client(struct sender_status *ss);
int send_queued_chunks(int fd, struct chunk_queue *cq);
int parse_fec_url(const char *arg, struct sender_command_data *scd);
*
* \return The string printed in the "si" command.
*/
*
* \return The string printed in the "si" command.
*/
-char *generic_sender_status(struct sender_status *ss, const char *name)
+__malloc char *generic_sender_status(struct sender_status *ss, const char *name)
{
char *clnts = NULL, *ret, *addr = NULL;
struct sender_client *sc, *tmp_sc;
{
char *clnts = NULL, *ret, *addr = NULL;
struct sender_client *sc, *tmp_sc;
* \return A dynamically allocated string containing the help text for
* a paraslash sender.
*/
* \return A dynamically allocated string containing the help text for
* a paraslash sender.
*/
-char *generic_sender_help(void)
+__malloc char *generic_sender_help(void)
{
return make_message(
"usage: {on|off}\n"
{
return make_message(
"usage: {on|off}\n"