Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

big warning cleanup

  • Loading branch information...
commit 0c6d6a0bc739d8d02ee2d0328e4d8a20395fd1c8 1 parent 431d5f9
@bwalex authored
View
12 Makefile
@@ -1,9 +1,15 @@
+WARNFLAGS= -Wsystem-headers -Werror -Wall -W -Wno-unused-parameter \
+ -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
+ -Wold-style-definition -Wreturn-type -Wcast-qual -Wwrite-strings \
+ -Wswitch -Wshadow -Wcast-align -Wunused-parameter -Wchar-subscripts \
+ -Winline -Wnested-externs -Wredundant-decls
+
all:
- gcc -O0 -Wall -g tc-play.c crc32.c safe_mem.c io.c crypto.c hdr.c openssl/openssl/libcrypto.a -o tc-play -ldevmapper -lprop -lutil
+ gcc -O0 $(WARNFLAGS) -g tc-play.c crc32.c safe_mem.c io.c crypto.c hdr.c openssl/openssl/libcrypto.a -o tc-play -ldevmapper -lprop -lutil
experimental:
- gcc -O0 -Wall -g main.c tc-play.c crc32.c safe_mem.c io.c crypto-dev.c hdr.c openssl/openssl/libcrypto.a -o tc-play -ldevmapper -lprop -lutil
+ gcc -O0 $(WARNFLAGS) -g main.c tc-play.c crc32.c safe_mem.c io.c crypto-dev.c hdr.c openssl/openssl/libcrypto.a -o tc-play -ldevmapper -lprop -lutil
lib:
- gcc -c -fPIC -O0 -Wall -g tc-play-api.c tc-play.c crc32.c safe_mem.c io.c crypto-dev.c hdr.c
+ gcc $(WARNFLAGS) -c -fPIC -O0 -Wall -g tc-play-api.c tc-play.c crc32.c safe_mem.c io.c crypto-dev.c hdr.c
gcc -shared -Wl -o libtcplay.so tc-play-api.o tc-play.o crc32.o safe_mem.o io.o crypto-dev.o hdr.o
clean:
rm -f tc-play tc-play.core *.o ktrace.out
View
3  crc32.c
@@ -38,6 +38,7 @@
*/
#include <stdlib.h>
+#include "crc32.h"
uint32_t crc32_tab[] = {
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
@@ -104,4 +105,4 @@ uint32_t
crc32_intermediate(uint32_t crc, uint8_t d)
{
return crc32_tab[(crc ^ d) & 0xFF] ^ (crc >> 8);
-}
+}
View
3  hdr.c
@@ -119,7 +119,8 @@ verify_hdr(struct tchdr_dec *hdr)
struct tchdr_enc *
create_hdr(unsigned char *pass, int passlen, struct pbkdf_prf_algo *prf_algo,
- struct tc_cipher_chain *cipher_chain, size_t sec_sz, size_t total_blocks,
+ struct tc_cipher_chain *cipher_chain, size_t sec_sz,
+ size_t total_blocks __unused,
off_t offset, size_t blocks, int hidden)
{
struct tchdr_enc *ehdr;
View
7 io.c
@@ -163,7 +163,7 @@ secure_erase(const char *dev, size_t bytes, size_t blksz)
return -1;
}
- if (r < blksz)
+ if (r < (ssize_t)blksz)
continue;
if ((w = write(fd, buf, r)) < 0) {
@@ -211,7 +211,8 @@ get_disk_info(const char *dev, size_t *blocks, size_t *bsize)
}
int
-write_mem(const char *dev, off_t offset, size_t blksz, void *mem, size_t bytes)
+write_mem(const char *dev, off_t offset, size_t blksz __unused, void *mem,
+ size_t bytes)
{
ssize_t w;
int fd;
@@ -238,7 +239,7 @@ write_mem(const char *dev, off_t offset, size_t blksz, void *mem, size_t bytes)
}
int
-read_passphrase(char *prompt, char *pass, size_t passlen)
+read_passphrase(const char *prompt, char *pass, size_t passlen)
{
struct termios termios_old, termios_new;
ssize_t n;
View
3  tc-play-api.c
@@ -53,7 +53,8 @@ tc_api_uninit(void)
char *
tc_api_get_error_msg(void)
{
- return (tc_internal_verbose) ? "" : tc_internal_log_buffer;
+ return (tc_internal_verbose) ? __DECONST(char *, "") :
+ tc_internal_log_buffer;
}
char *
View
36 tc-play.c
@@ -52,12 +52,12 @@ int tc_internal_verbose = 1;
char tc_internal_log_buffer[LOG_BUFFER_SZ];
void
-tc_log(int err, char *fmt, ...)
+tc_log(int is_err, const char *fmt, ...)
{
__va_list ap;
FILE *fp;
- if (err)
+ if (is_err)
fp = stderr;
else
fp = stdout;
@@ -94,7 +94,7 @@ struct tc_crypto_algo tc_crypto_algos[] = {
{ NULL, NULL, 0, 0 }
};
-char *valid_cipher_chains[][MAX_CIPHER_CHAINS] = {
+const char *valid_cipher_chains[][MAX_CIPHER_CHAINS] = {
{ "AES-256-XTS", NULL },
{ "TWOFISH-256-XTS", NULL },
{ "SERPENT-256-XTS", NULL },
@@ -172,25 +172,8 @@ tc_build_cipher_chains(void)
}
}
-int
-hex2key(char *hex, size_t key_len, unsigned char *key)
-{
- char hex_buf[3];
- size_t key_idx;
- hex_buf[2] = 0;
- for (key_idx = 0; key_idx < key_len; ++key_idx) {
- hex_buf[0] = *hex++;
- hex_buf[1] = *hex++;
- key[key_idx] = (unsigned char)strtoul(hex_buf, NULL, 16);
- }
- hex_buf[0] = 0;
- hex_buf[1] = 0;
-
- return 0;
-}
-
#ifdef DEBUG
-void
+static void
print_hex(unsigned char *buf, off_t start, size_t len)
{
size_t i;
@@ -226,13 +209,14 @@ print_info(struct tcplay_info *info)
printf("Volume size:\t\t%d sectors\n", info->size);
}
+static
struct tcplay_info *
new_info(const char *dev, struct tc_cipher_chain *cipher_chain,
struct pbkdf_prf_algo *prf, struct tchdr_dec *hdr, off_t start)
{
struct tcplay_info *info;
- size_t i;
- int err;
+ int i;
+ int error;
if ((info = (struct tcplay_info *)alloc_safe_mem(sizeof(*info))) == NULL) {
tc_log(1, "could not allocate safe info memory\n");
@@ -249,8 +233,8 @@ new_info(const char *dev, struct tc_cipher_chain *cipher_chain,
info->offset = hdr->off_mk_scope / hdr->sec_sz; /* block offset */
/* Associate a key out of the key pool with each cipher in the chain */
- err = tc_cipher_chain_populate_keys(cipher_chain, hdr->keys);
- if (err) {
+ error = tc_cipher_chain_populate_keys(cipher_chain, hdr->keys);
+ if (error) {
tc_log(1, "could not populate keys in cipher chain\n");
return NULL;
}
@@ -933,7 +917,7 @@ dm_setup(const char *mapname, struct tcplay_info *info)
}
struct tc_crypto_algo *
-check_cipher(char *cipher, int quiet)
+check_cipher(const char *cipher, int quiet)
{
int i, found = 0;
View
12 tc-play.h
@@ -60,13 +60,13 @@
#include <uuid.h>
struct pbkdf_prf_algo {
- char *name;
+ const char *name;
int iteration_count;
};
struct tc_crypto_algo {
- char *name;
- char *dm_crypt_str;
+ const char *name;
+ const char *dm_crypt_str;
int klen;
int ivlen;
};
@@ -130,7 +130,7 @@ int get_random(unsigned char *buf, size_t len);
int secure_erase(const char *dev, size_t bytes, size_t blksz);
int get_disk_info(const char *dev, size_t *blocks, size_t *bsize);
int write_mem(const char *dev, off_t offset, size_t blksz, void *mem, size_t bytes);
-int read_passphrase(char *prompt, char *pass, size_t passlen);
+int read_passphrase(const char *prompt, char *pass, size_t passlen);
int tc_crypto_init(void);
int tc_cipher_chain_populate_keys(struct tc_cipher_chain *cipher_chain,
@@ -158,12 +158,12 @@ void *_alloc_safe_mem(size_t req_sz, const char *file, int line);
void _free_safe_mem(void *mem, const char *file, int line);
void check_and_purge_safe_mem(void);
-struct tc_crypto_algo *check_cipher(char *cipher, int quiet);
+struct tc_crypto_algo *check_cipher(const char *cipher, int quiet);
struct tc_cipher_chain *check_cipher_chain(char *cipher_chain, int quiet);
struct pbkdf_prf_algo *check_prf_algo(char *algo, int quiet);
void tc_play_init(void);
-void tc_log(int err, char *fmt, ...);
+void tc_log(int err, const char *fmt, ...);
void print_info(struct tcplay_info *info);
int adjust_info(struct tcplay_info *info, struct tcplay_info *hinfo);
int process_hdr(const char *dev, unsigned char *pass, int passlen,
Please sign in to comment.
Something went wrong with that request. Please try again.