From 29eba419627437fb6f20714bb553d39a58305c5e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 26 Aug 2008 08:27:09 +0200 Subject: converted MpdTagItem.type to an enum Don't use CPP macros when you can use C enum... this also allows better type checking. --- src/tag.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/tag.c') diff --git a/src/tag.c b/src/tag.c index 5023a58cb..fc85a6ff9 100644 --- a/src/tag.c +++ b/src/tag.c @@ -606,7 +606,7 @@ static void deleteItem(MpdTag * tag, int idx) } } -void clearItemsFromMpdTag(MpdTag * tag, int type) +void clearItemsFromMpdTag(MpdTag * tag, enum tag_type type) { int i; @@ -697,7 +697,8 @@ int mpdTagsAreEqual(MpdTag * tag1, MpdTag * tag2) } \ } -static void appendToTagItems(MpdTag * tag, int type, char *value, int len) +static void appendToTagItems(MpdTag * tag, enum tag_type type, + char *value, int len) { int i = tag->numOfItems; char *duplicated = xmalloc(len + 1); @@ -717,7 +718,8 @@ static void appendToTagItems(MpdTag * tag, int type, char *value, int len) free(duplicated); } -void addItemToMpdTagWithLen(MpdTag * tag, int itemType, char *value, int len) +void addItemToMpdTagWithLen(MpdTag * tag, enum tag_type itemType, + char *value, int len) { if (ignoreTagItems[itemType]) { -- cgit v1.2.3 From ad02ebe21138fed633af5465d1690db103c4934e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 28 Aug 2008 20:02:16 +0200 Subject: unsigned integers and size_t Use "unsigned int" whenever negative values are not meaningful. Use size_t whenever we are going to describe buffer sizes. --- src/tag.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/tag.c') diff --git a/src/tag.c b/src/tag.c index fc85a6ff9..00f09f10f 100644 --- a/src/tag.c +++ b/src/tag.c @@ -25,7 +25,6 @@ #include "charConv.h" #include "tagTracker.h" #include "song.h" -#include "os_compat.h" #ifdef HAVE_ID3TAG # define isId3v1(tag) (id3_tag_options(tag, 0, 0) & ID3_TAG_OPTION_ID3V1) @@ -698,9 +697,9 @@ int mpdTagsAreEqual(MpdTag * tag1, MpdTag * tag2) } static void appendToTagItems(MpdTag * tag, enum tag_type type, - char *value, int len) + char *value, size_t len) { - int i = tag->numOfItems; + unsigned int i = tag->numOfItems; char *duplicated = xmalloc(len + 1); memcpy(duplicated, value, len); @@ -719,7 +718,7 @@ static void appendToTagItems(MpdTag * tag, enum tag_type type, } void addItemToMpdTagWithLen(MpdTag * tag, enum tag_type itemType, - char *value, int len) + char *value, size_t len) { if (ignoreTagItems[itemType]) { -- cgit v1.2.3 From c52667aa8eee2a40547026735b9670a2221d4168 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 28 Aug 2008 20:02:17 +0200 Subject: const pointers The usual bunch of pointer arguments which should be const. --- src/tag.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/tag.c') diff --git a/src/tag.c b/src/tag.c index 00f09f10f..c1ccd0a42 100644 --- a/src/tag.c +++ b/src/tag.c @@ -697,7 +697,7 @@ int mpdTagsAreEqual(MpdTag * tag1, MpdTag * tag2) } static void appendToTagItems(MpdTag * tag, enum tag_type type, - char *value, size_t len) + const char *value, size_t len) { unsigned int i = tag->numOfItems; char *duplicated = xmalloc(len + 1); @@ -718,7 +718,7 @@ static void appendToTagItems(MpdTag * tag, enum tag_type type, } void addItemToMpdTagWithLen(MpdTag * tag, enum tag_type itemType, - char *value, size_t len) + const char *value, size_t len) { if (ignoreTagItems[itemType]) { -- cgit v1.2.3