Просмотр исходного кода

libdpkg: Do not use typedefs for structs and enums

Guillem Jover лет назад: 16
Родитель
Сommit
3cf8ba3ba6
2 измененных файлов с 15 добавлено и 19 удалено
  1. 12 13
      lib/dpkg/tarfn.c
  2. 3 6
      lib/dpkg/tarfn.h

+ 12 - 13
lib/dpkg/tarfn.c

@@ -53,9 +53,8 @@ struct TarHeader {
 	char MinorDevice[8];
 	char Prefix[155];	/* Only valid on ustar. */
 };
-typedef struct TarHeader TarHeader;
 
-static const size_t TarChecksumOffset = offsetof(TarHeader, Checksum);
+static const size_t TarChecksumOffset = offsetof(struct TarHeader, Checksum);
 
 /* Octal-ASCII-to-long */
 static long
@@ -91,7 +90,7 @@ StoC(const char *s, int size)
 
 /* FIXME: Rewrite using varbuf, once it supports the needed functionality. */
 static char *
-get_prefix_name(TarHeader *h)
+get_prefix_name(struct TarHeader *h)
 {
 	char *prefix, *name, *s;
 
@@ -112,9 +111,9 @@ get_prefix_name(TarHeader *h)
 }
 
 static int
-DecodeTarHeader(char * block, TarInfo * d)
+DecodeTarHeader(char *block, struct TarInfo *d)
 {
-	TarHeader *h = (TarHeader *)block;
+	struct TarHeader *h = (struct TarHeader *)block;
 	unsigned char *s = (unsigned char *)block;
 	struct passwd *passwd = NULL;
 	struct group *group = NULL;
@@ -150,7 +149,7 @@ DecodeTarHeader(char * block, TarInfo * d)
 	checksum = OtoL(h->Checksum, sizeof(h->Checksum));
 	d->UserID = (uid_t)OtoL(h->UserID, sizeof(h->UserID));
 	d->GroupID = (gid_t)OtoL(h->GroupID, sizeof(h->GroupID));
-	d->Type = (TarFileType)h->LinkFlag;
+	d->Type = (enum TarFileType)h->LinkFlag;
 
 	if (passwd)
 		d->UserID = passwd->pw_uid;
@@ -171,23 +170,23 @@ DecodeTarHeader(char * block, TarInfo * d)
 	return (sum == checksum);
 }
 
-typedef struct symlinkList {
-	TarInfo h;
+struct symlinkList {
+	struct TarInfo h;
 	struct symlinkList *next;
-} symlinkList;
+};
 
 int
-TarExtractor(void *userData, const TarFunctions *ops)
+TarExtractor(void *userData, const struct TarFunctions *ops)
 {
 	int status;
 	char buffer[TARBLKSZ];
-	TarInfo h;
+	struct TarInfo h;
 
 	char *next_long_name, *next_long_link;
 	char *bp;
 	char **longp;
 	int long_read;
-	symlinkList *symlink_head, *symlink_tail, *symlink_node;
+	struct symlinkList *symlink_head, *symlink_tail, *symlink_node;
 
 	next_long_name = NULL;
 	next_long_link = NULL;
@@ -252,7 +251,7 @@ TarExtractor(void *userData, const TarFunctions *ops)
 			break;
 		case SymbolicLink:
 			symlink_node = m_malloc(sizeof(*symlink_node));
-			memcpy(&symlink_node->h, &h, sizeof(TarInfo));
+			memcpy(&symlink_node->h, &h, sizeof(struct TarInfo));
 			symlink_node->h.Name = m_strdup(h.Name);
 			symlink_node->h.LinkName = m_strdup(h.LinkName);
 			symlink_node->next = NULL;

+ 3 - 6
lib/dpkg/tarfn.h

@@ -47,7 +47,6 @@ enum TarFileType {
 	GNU_LONGLINK = 'K',
 	GNU_LONGNAME = 'L'
 };
-typedef enum TarFileType	TarFileType;
 
 struct	TarInfo {
 	enum tar_format	format;		/* Tar archive format. */
@@ -56,17 +55,16 @@ struct	TarInfo {
 	mode_t		Mode;		/* Unix mode, including device bits. */
 	size_t		Size;		/* Size of file */
 	time_t		ModTime;	/* Last-modified time */
-	TarFileType	Type;		/* Regular, Directory, Special, Link */
+	enum TarFileType Type;		/* Regular, Directory, Special, Link */
 	char *		LinkName;	/* Name for symbolic and hard links */
 	dev_t		Device;		/* Special device for mknod() */
 	uid_t		UserID;		/* Numeric UID */
 	gid_t		GroupID;	/* Numeric GID */
 };
-typedef struct TarInfo	TarInfo;
 
 typedef	int	(*TarReadFunction)(void * userData, char * buffer, int length);
 
-typedef int	(*TarFunction)(TarInfo * h);
+typedef int	(*TarFunction)(struct TarInfo * h);
 
 struct TarFunctions {
 	TarReadFunction	Read;
@@ -76,8 +74,7 @@ struct TarFunctions {
 	TarFunction	MakeSymbolicLink;
 	TarFunction	MakeSpecialFile;
 };
-typedef struct TarFunctions	TarFunctions;
 
-int TarExtractor(void *userData, const TarFunctions *ops);
+int TarExtractor(void *userData, const struct TarFunctions *ops);
 
 #endif