pgbackrest.git / summary / log / commit / refs
commit e00f2dd4ad574c7680bce2126df4d320c9c8d6ac
Author: David Steele <david@pgmasters.net>
Date: Sat Apr 07 01:46:45 2018 +0000
More C type cleanup.
* Remove typec.h entirely.
* Order all typdefs above local includes.
doc/xml/release.xml | 2 +-
src/cipher/block.h | 12 ++++++----
src/cipher/cipher.h | 6 +++--
src/cipher/random.h | 4 +++-
src/command/archive/push/push.c | 2 +-
src/command/help/help.c | 1 -
src/common/encode.c | 1 +
src/common/encode.h | 2 --
src/common/encode/base64.h | 2 --
src/common/error.c | 1 +
src/common/error.h | 3 +--
src/common/log.c | 1 +
src/common/log.h | 2 +-
src/common/memContext.h | 13 ++++++-----
src/common/regExp.c | 1 -
src/common/regExp.h | 2 +-
src/common/time.c | 2 +-
src/common/time.h | 2 +-
src/common/type/keyValue.c | 2 ++
src/common/type/keyValue.h | 2 +-
src/common/type/list.h | 10 ++++----
src/common/type/string.c | 1 +
src/common/type/string.h | 4 ++--
src/common/type/stringList.h | 2 +-
src/common/type/variant.c | 1 +
src/common/type/variant.h | 18 +++++++--------
src/common/type/variantList.h | 2 +-
src/common/typec.h | 34 ----------------------------
src/common/wait.h | 2 +-
src/config/define.c | 1 +
src/config/define.h | 5 ++--
src/perl/exec.c | 1 -
src/postgres/pageChecksum.h | 2 +-
src/storage/file.h | 10 ++++----
src/storage/storage.h | 12 +++++-----
test/lib/pgBackRestTest/Common/DefineTest.pm | 11 ---------
36 files changed, 70 insertions(+), 109 deletions(-)
diff --git a/doc/xml/release.xml b/doc/xml/release.xml
index 15f920a96..aa06671be 100644
--- a/doc/xml/release.xml
+++ b/doc/xml/release.xml
@@ -64,7 +64,7 @@
</release-item>
<release-item>
- <p>Cleanup C types. Remove <backrest/> defined types included with the C types. Remove redefinition of standard C types.</p>
+ <p>Cleanup C types. Remove <code>typec.h</code>. Order all typdefs above local includes.</p>
</release-item>
<release-item>
diff --git a/src/cipher/block.h b/src/cipher/block.h
index ea66450f4..84efd8db1 100644
--- a/src/cipher/block.h
+++ b/src/cipher/block.h
@@ -4,12 +4,16 @@ Block Cipher Header
#ifndef CIPHER_BLOCK_H
#define CIPHER_BLOCK_H
-#include "cipher/cipher.h"
-
-// Track cipher state
+/***********************************************************************************************************************************
+CipherBlock object
+***********************************************************************************************************************************/
typedef struct CipherBlock CipherBlock;
-// Functions
+#include "cipher/cipher.h"
+
+/***********************************************************************************************************************************
+Functions
+***********************************************************************************************************************************/
CipherBlock *cipherBlockNew(
CipherMode mode, const char *cipherName, const unsigned char *pass, size_t passSize, const char *digestName);
size_t cipherBlockProcessSize(CipherBlock *this, size_t sourceSize);
diff --git a/src/cipher/cipher.h b/src/cipher/cipher.h
index 756876336..a468e241c 100644
--- a/src/cipher/cipher.h
+++ b/src/cipher/cipher.h
@@ -4,9 +4,11 @@ Cipher Header
#ifndef CIPHER_CIPHER_H
#define CIPHER_CIPHER_H
-#include "common/typec.h"
+#include <stdbool.h>
-// Define cipher modes
+/***********************************************************************************************************************************
+Cipher modes
+***********************************************************************************************************************************/
typedef enum
{
cipherModeEncrypt,
diff --git a/src/cipher/random.h b/src/cipher/random.h
index d423fc199..4eb3da40c 100644
--- a/src/cipher/random.h
+++ b/src/cipher/random.h
@@ -4,7 +4,9 @@ Random Header
#ifndef CIPHER_RANDOM_H
#define CIPHER_RANDOM_H
-// Functions
+/***********************************************************************************************************************************
+Functions
+***********************************************************************************************************************************/
void randomBytes(unsigned char *buffer, size_t size);
#endif
diff --git a/src/command/archive/push/push.c b/src/command/archive/push/push.c
index d5f8e41b4..38bf8aaaa 100644
--- a/src/command/archive/push/push.c
+++ b/src/command/archive/push/push.c
@@ -2,6 +2,7 @@
Archive Push Command
***********************************************************************************************************************************/
#include <libgen.h>
+#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
@@ -12,7 +13,6 @@ Archive Push Command
#include "common/log.h"
#include "common/memContext.h"
#include "common/regExp.h"
-#include "common/typec.h"
#include "common/wait.h"
#include "config/config.h"
#include "perl/exec.h"
diff --git a/src/command/help/help.c b/src/command/help/help.c
index 633ace6a2..1b5b35a14 100644
--- a/src/command/help/help.c
+++ b/src/command/help/help.c
@@ -6,7 +6,6 @@ Help Command
#include "common/io/handle.h"
#include "common/memContext.h"
-#include "common/typec.h"
#include "config/config.h"
#include "config/define.h"
#include "version.h"
diff --git a/src/common/encode.c b/src/common/encode.c
index 50558eca9..917403d81 100644
--- a/src/common/encode.c
+++ b/src/common/encode.c
@@ -1,6 +1,7 @@
/***********************************************************************************************************************************
Binary to String Encode/Decode
***********************************************************************************************************************************/
+#include <stdbool.h>
#include <string.h>
#include "common/encode.h"
diff --git a/src/common/encode.h b/src/common/encode.h
index b43421e8d..e5c27d9f9 100644
--- a/src/common/encode.h
+++ b/src/common/encode.h
@@ -6,8 +6,6 @@ These high-level functions are preferred to the low-level functions for each enc
#ifndef COMMON_ENCODE_H
#define COMMON_ENCODE_H
-#include "common/typec.h"
-
/***********************************************************************************************************************************
Encoding types
***********************************************************************************************************************************/
diff --git a/src/common/encode/base64.h b/src/common/encode/base64.h
index 8a7703332..9d66419b5 100644
--- a/src/common/encode/base64.h
+++ b/src/common/encode/base64.h
@@ -6,8 +6,6 @@ The high-level functions in encode.c should be used in preference to these low-l
#ifndef COMMON_ENCODE_BASE64_H
#define COMMON_ENCODE_BASE64_H
-#include "common/typec.h"
-
/***********************************************************************************************************************************
Functions
***********************************************************************************************************************************/
diff --git a/src/common/error.c b/src/common/error.c
index 53e5817cf..336dfa705 100644
--- a/src/common/error.c
+++ b/src/common/error.c
@@ -2,6 +2,7 @@
Error Handler
***********************************************************************************************************************************/
#include <stdarg.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/common/error.h b/src/common/error.h
index 720c1533a..e36e18da5 100644
--- a/src/common/error.h
+++ b/src/common/error.h
@@ -39,8 +39,7 @@ IMPORTANT: Never call return from within any of the error-handling blocks.
#include <errno.h>
#include <setjmp.h>
-
-#include "common/typec.h"
+#include <stdbool.h>
/***********************************************************************************************************************************
Error type object
diff --git a/src/common/log.c b/src/common/log.c
index f3b4e512c..5e8645d75 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -4,6 +4,7 @@ Log Handler
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
+#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <time.h>
diff --git a/src/common/log.h b/src/common/log.h
index f30b70e75..270778a77 100644
--- a/src/common/log.h
+++ b/src/common/log.h
@@ -4,7 +4,7 @@ Log Handler
#ifndef COMMON_LOG_H
#define COMMON_LOG_H
-#include "common/typec.h"
+#include <stdbool.h>
/***********************************************************************************************************************************
Log types
diff --git a/src/common/memContext.h b/src/common/memContext.h
index 01ae7e9fc..b2c9f2963 100644
--- a/src/common/memContext.h
+++ b/src/common/memContext.h
@@ -4,8 +4,14 @@ Memory Context Manager
#ifndef COMMON_MEMCONTEXT_H
#define COMMON_MEMCONTEXT_H
+#include <stddef.h>
+
+/***********************************************************************************************************************************
+Memory context object
+***********************************************************************************************************************************/
+typedef struct MemContext MemContext;
+
#include "common/error.h"
-#include "common/typec.h"
/***********************************************************************************************************************************
Memory context names cannot be larger than this size (excluding terminator) or an error will be thrown
@@ -27,11 +33,6 @@ Space is reserved for this many allocations when a context is created. When mor
***********************************************************************************************************************************/
#define MEM_CONTEXT_ALLOC_INITIAL_SIZE 4
-/***********************************************************************************************************************************
-Memory context object
-***********************************************************************************************************************************/
-typedef struct MemContext MemContext;
-
/***********************************************************************************************************************************
Memory context callback function type, useful for casts in memContextCallback()
***********************************************************************************************************************************/
diff --git a/src/common/regExp.c b/src/common/regExp.c
index a526f78ed..a5061141c 100644
--- a/src/common/regExp.c
+++ b/src/common/regExp.c
@@ -6,7 +6,6 @@ Regular Expression Handler
#include "common/memContext.h"
#include "common/regExp.h"
-#include "common/typec.h"
/***********************************************************************************************************************************
Contains information about the regular expression handler
diff --git a/src/common/regExp.h b/src/common/regExp.h
index e75deba43..4ea0681cf 100644
--- a/src/common/regExp.h
+++ b/src/common/regExp.h
@@ -5,7 +5,7 @@ Regular Expression Handler
#define COMMON_REGEXP_H
/***********************************************************************************************************************************
-Ini object
+RegExp object
***********************************************************************************************************************************/
typedef struct RegExp RegExp;
diff --git a/src/common/time.c b/src/common/time.c
index 21299930a..b7512355f 100644
--- a/src/common/time.c
+++ b/src/common/time.c
@@ -1,10 +1,10 @@
/***********************************************************************************************************************************
Time Management
***********************************************************************************************************************************/
+#include "stdio.h"
#include "sys/time.h"
#include "common/time.h"
-#include "common/typec.h"
/***********************************************************************************************************************************
Constants describing number of sub-units in an interval
diff --git a/src/common/time.h b/src/common/time.h
index 4c698b66b..cfb2d4555 100644
--- a/src/common/time.h
+++ b/src/common/time.h
@@ -4,7 +4,7 @@ Time Management
#ifndef COMMON_TIME_H
#define COMMON_TIME_H
-#include "common/typec.h"
+#include <stdint.h>
/***********************************************************************************************************************************
Time types
diff --git a/src/common/type/keyValue.c b/src/common/type/keyValue.c
index 04fdb7315..5029bb469 100644
--- a/src/common/type/keyValue.c
+++ b/src/common/type/keyValue.c
@@ -1,6 +1,8 @@
/***********************************************************************************************************************************
Key Value Handler
***********************************************************************************************************************************/
+#include <limits.h>
+
#include "common/memContext.h"
#include "common/type/keyValue.h"
#include "common/type/list.h"
diff --git a/src/common/type/keyValue.h b/src/common/type/keyValue.h
index 2e9bfa3a4..a0c404530 100644
--- a/src/common/type/keyValue.h
+++ b/src/common/type/keyValue.h
@@ -5,7 +5,7 @@ Key Value Handler
#define COMMON_TYPE_KEYVALUE_H
/***********************************************************************************************************************************
-Key value object
+KeyValue object
***********************************************************************************************************************************/
typedef struct KeyValue KeyValue;
diff --git a/src/common/type/list.h b/src/common/type/list.h
index 287e28960..c4eae235b 100644
--- a/src/common/type/list.h
+++ b/src/common/type/list.h
@@ -4,6 +4,11 @@ List Handler
#ifndef COMMON_TYPE_LIST_H
#define COMMON_TYPE_LIST_H
+/***********************************************************************************************************************************
+List object
+***********************************************************************************************************************************/
+typedef struct List List;
+
#include "common/memContext.h"
#include "common/type/string.h"
@@ -12,11 +17,6 @@ Define initial size of a list
***********************************************************************************************************************************/
#define LIST_INITIAL_SIZE 8
-/***********************************************************************************************************************************
-List type
-***********************************************************************************************************************************/
-typedef struct List List;
-
/***********************************************************************************************************************************
Functions
***********************************************************************************************************************************/
diff --git a/src/common/type/string.c b/src/common/type/string.c
index 564ed86ca..9e84584cc 100644
--- a/src/common/type/string.c
+++ b/src/common/type/string.c
@@ -3,6 +3,7 @@ String Handler
***********************************************************************************************************************************/
#include <ctype.h>
#include <stdarg.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/common/type/string.h b/src/common/type/string.h
index d6d32416d..75e5d3280 100644
--- a/src/common/type/string.h
+++ b/src/common/type/string.h
@@ -9,11 +9,11 @@ String object
***********************************************************************************************************************************/
typedef struct String String;
+#include "common/type/buffer.h"
+
/***********************************************************************************************************************************
Functions
***********************************************************************************************************************************/
-#include "common/type/buffer.h"
-
String *strNew(const char *string);
String *strNewBuf(const Buffer *buffer);
String *strNewFmt(const char *format, ...) __attribute__((format(printf, 1, 2)));
diff --git a/src/common/type/stringList.h b/src/common/type/stringList.h
index 7c07596a6..fab623b4f 100644
--- a/src/common/type/stringList.h
+++ b/src/common/type/stringList.h
@@ -5,7 +5,7 @@ String List Handler
#define COMMON_TYPE_STRINGLIST_H
/***********************************************************************************************************************************
-String list type
+StringList object
***********************************************************************************************************************************/
typedef struct StringList StringList;
diff --git a/src/common/type/variant.c b/src/common/type/variant.c
index a92502353..8401d7f7d 100644
--- a/src/common/type/variant.c
+++ b/src/common/type/variant.c
@@ -2,6 +2,7 @@
Variant Data Type
***********************************************************************************************************************************/
#include <inttypes.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
diff --git a/src/common/type/variant.h b/src/common/type/variant.h
index 97b57ea40..26de62c45 100644
--- a/src/common/type/variant.h
+++ b/src/common/type/variant.h
@@ -4,7 +4,12 @@ Variant Data Type
#ifndef COMMON_TYPE_VARIANT_H
#define COMMON_TYPE_VARIANT_H
-#include "common/typec.h"
+#include <stdint.h>
+
+/***********************************************************************************************************************************
+Variant object
+***********************************************************************************************************************************/
+typedef struct Variant Variant;
/***********************************************************************************************************************************
Variant type
@@ -20,18 +25,13 @@ typedef enum
varTypeVariantList,
} VariantType;
-/***********************************************************************************************************************************
-Variant object
-***********************************************************************************************************************************/
-typedef struct Variant Variant;
-
-/***********************************************************************************************************************************
-Functions
-***********************************************************************************************************************************/
#include "common/type/keyValue.h"
#include "common/type/string.h"
#include "common/type/variantList.h"
+/***********************************************************************************************************************************
+Functions
+***********************************************************************************************************************************/
Variant *varNewBool(bool data);
bool varBool(const Variant *this);
bool varBoolForce(const Variant *this);
diff --git a/src/common/type/variantList.h b/src/common/type/variantList.h
index a8934ff1a..50c163693 100644
--- a/src/common/type/variantList.h
+++ b/src/common/type/variantList.h
@@ -5,7 +5,7 @@ Variant List Handler
#define COMMON_TYPE_VARIANTLIST_H
/***********************************************************************************************************************************
-Variant list type
+Variant list object
***********************************************************************************************************************************/
typedef struct VariantList VariantList;
diff --git a/src/common/typec.h b/src/common/typec.h
deleted file mode 100644
index 6ae9f4fbd..000000000
--- a/src/common/typec.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/***********************************************************************************************************************************
-C Types
-***********************************************************************************************************************************/
-#ifndef COMMON_TYPEC_H
-#define COMMON_TYPEC_H
-
-/***********************************************************************************************************************************
-Include true/false
-***********************************************************************************************************************************/
-#include <stdbool.h>
-
-/***********************************************************************************************************************************
-Include NULL
-***********************************************************************************************************************************/
-#include <stdio.h>
-
-/***********************************************************************************************************************************
-Include limits for data types
-***********************************************************************************************************************************/
-#include <limits.h>
-
-/***********************************************************************************************************************************
-Define standard integer types for portability
-***********************************************************************************************************************************/
-#include <stdint.h>
-
-/***********************************************************************************************************************************
-Ensure that ints are at least 32 bits
-***********************************************************************************************************************************/
-#if INT_MAX < 2147483647L
- #error "int type must be at least 32 bits"
-#endif
-
-#endif
diff --git a/src/common/wait.h b/src/common/wait.h
index ba010f0ed..2acdc4060 100644
--- a/src/common/wait.h
+++ b/src/common/wait.h
@@ -5,7 +5,7 @@ Wait Handler
#define COMMON_WAIT_H
/***********************************************************************************************************************************
-Ini object
+Wait object
***********************************************************************************************************************************/
typedef struct Wait Wait;
diff --git a/src/config/define.c b/src/config/define.c
index c310be64e..16949da6f 100644
--- a/src/config/define.c
+++ b/src/config/define.c
@@ -2,6 +2,7 @@
Command and Option Configuration Definition
***********************************************************************************************************************************/
#include <limits.h>
+#include <stdint.h>
#include <string.h>
#include "common/error.h"
diff --git a/src/config/define.h b/src/config/define.h
index e71e304f6..d9fcb2a1f 100644
--- a/src/config/define.h
+++ b/src/config/define.h
@@ -4,9 +4,6 @@ Command and Option Configuration Definition
#ifndef CONFIG_DEFINE_H
#define CONFIG_DEFINE_H
-#include "common/typec.h"
-#include "config/define.auto.h"
-
/***********************************************************************************************************************************
Section enum - defines which sections of the config an option can appear in
***********************************************************************************************************************************/
@@ -17,6 +14,8 @@ typedef enum
cfgDefSectionStanza, // command-line or in any config stanza section
} ConfigDefSection;
+#include "config/define.auto.h"
+
/***********************************************************************************************************************************
Define global section name
***********************************************************************************************************************************/
diff --git a/src/perl/exec.c b/src/perl/exec.c
index 34aa0368c..9e40397b0 100644
--- a/src/perl/exec.c
+++ b/src/perl/exec.c
@@ -10,7 +10,6 @@ Execute Perl for Legacy Functionality
#include "version.h"
#include "common/error.h"
#include "common/memContext.h"
-#include "common/typec.h"
#include "config/config.h"
#include "perl/config.h"
diff --git a/src/postgres/pageChecksum.h b/src/postgres/pageChecksum.h
index 87efb5370..9199fa933 100644
--- a/src/postgres/pageChecksum.h
+++ b/src/postgres/pageChecksum.h
@@ -4,7 +4,7 @@ Checksum Implementation for Data Pages
#ifndef POSTGRES_PAGECHECKSUM_H
#define POSTGRES_PAGECHECKSUM_H
-#include "common/typec.h"
+#include <stdint.h>
/***********************************************************************************************************************************
Functions
diff --git a/src/storage/file.h b/src/storage/file.h
index 5848d4ecb..a8cde224f 100644
--- a/src/storage/file.h
+++ b/src/storage/file.h
@@ -4,7 +4,10 @@ Storage File
#ifndef STORAGE_FILE_H
#define STORAGE_FILE_H
-#include "common/type/string.h"
+/***********************************************************************************************************************************
+Storage file object
+***********************************************************************************************************************************/
+typedef struct StorageFile StorageFile;
/***********************************************************************************************************************************
Types of storage files, i.e. read or write. The storage module does not allow files to be opened for both read and write since this
@@ -16,11 +19,6 @@ typedef enum
storageFileTypeWrite,
} StorageFileType;
-/***********************************************************************************************************************************
-Storage file object
-***********************************************************************************************************************************/
-typedef struct StorageFile StorageFile;
-
#include "storage/storage.h"
/***********************************************************************************************************************************
diff --git a/src/storage/storage.h b/src/storage/storage.h
index acd01cfa6..19f65c006 100644
--- a/src/storage/storage.h
+++ b/src/storage/storage.h
@@ -6,8 +6,14 @@ Storage Manager
#include <sys/types.h>
+/***********************************************************************************************************************************
+Storage object
+***********************************************************************************************************************************/
+typedef struct Storage Storage;
+
#include "common/type/buffer.h"
#include "common/type/stringList.h"
+#include "storage/file.h"
/***********************************************************************************************************************************
Default buffer size
@@ -23,12 +29,6 @@ Default file and path modes
#define STORAGE_FILE_MODE_DEFAULT 0640
#define STORAGE_PATH_MODE_DEFAULT 0750
-/***********************************************************************************************************************************
-Storage object
-***********************************************************************************************************************************/
-typedef struct Storage Storage;
-
-#include "storage/file.h"
/***********************************************************************************************************************************
Path expression callback function type - used to modify paths based on expressions enclosed in <>
diff --git a/test/lib/pgBackRestTest/Common/DefineTest.pm b/test/lib/pgBackRestTest/Common/DefineTest.pm
index 25ca96a8e..13f0a42ff 100644
--- a/test/lib/pgBackRestTest/Common/DefineTest.pm
+++ b/test/lib/pgBackRestTest/Common/DefineTest.pm
@@ -100,17 +100,6 @@ my $oTestDef =
&TESTDEF_TEST =>
[
- {
- &TESTDEF_NAME => 'typec',
- &TESTDEF_TOTAL => 2,
- &TESTDEF_C => true,
- &TESTDEF_CDEF => '-DNO_ERROR -DNO_LOG',
-
- &TESTDEF_COVERAGE =>
- {
- 'common/typec' => TESTDEF_COVERAGE_NOCODE,
- },
- },
{
&TESTDEF_NAME => 'time',
&TESTDEF_TOTAL => 2,
[parent: f3b56cf8f328]