Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

big warning cleanup

  • Loading branch information...
commit 0c6d6a0bc739d8d02ee2d0328e4d8a20395fd1c8 1 parent 431d5f9
Alex Hornung authored
12 Makefile
... ... @@ -1,9 +1,15 @@
  1 +WARNFLAGS= -Wsystem-headers -Werror -Wall -W -Wno-unused-parameter \
  2 + -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith \
  3 + -Wold-style-definition -Wreturn-type -Wcast-qual -Wwrite-strings \
  4 + -Wswitch -Wshadow -Wcast-align -Wunused-parameter -Wchar-subscripts \
  5 + -Winline -Wnested-externs -Wredundant-decls
  6 +
1 7 all:
2   - 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
  8 + 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
3 9 experimental:
4   - 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
  10 + 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
5 11 lib:
6   - 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
  12 + 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
7 13 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
8 14 clean:
9 15 rm -f tc-play tc-play.core *.o ktrace.out
3  crc32.c
@@ -38,6 +38,7 @@
38 38 */
39 39
40 40 #include <stdlib.h>
  41 +#include "crc32.h"
41 42
42 43 uint32_t crc32_tab[] = {
43 44 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
@@ -104,4 +105,4 @@ uint32_t
104 105 crc32_intermediate(uint32_t crc, uint8_t d)
105 106 {
106 107 return crc32_tab[(crc ^ d) & 0xFF] ^ (crc >> 8);
107   -}
  108 +}
3  hdr.c
@@ -119,7 +119,8 @@ verify_hdr(struct tchdr_dec *hdr)
119 119
120 120 struct tchdr_enc *
121 121 create_hdr(unsigned char *pass, int passlen, struct pbkdf_prf_algo *prf_algo,
122   - struct tc_cipher_chain *cipher_chain, size_t sec_sz, size_t total_blocks,
  122 + struct tc_cipher_chain *cipher_chain, size_t sec_sz,
  123 + size_t total_blocks __unused,
123 124 off_t offset, size_t blocks, int hidden)
124 125 {
125 126 struct tchdr_enc *ehdr;
7 io.c
@@ -163,7 +163,7 @@ secure_erase(const char *dev, size_t bytes, size_t blksz)
163 163 return -1;
164 164 }
165 165
166   - if (r < blksz)
  166 + if (r < (ssize_t)blksz)
167 167 continue;
168 168
169 169 if ((w = write(fd, buf, r)) < 0) {
@@ -211,7 +211,8 @@ get_disk_info(const char *dev, size_t *blocks, size_t *bsize)
211 211 }
212 212
213 213 int
214   -write_mem(const char *dev, off_t offset, size_t blksz, void *mem, size_t bytes)
  214 +write_mem(const char *dev, off_t offset, size_t blksz __unused, void *mem,
  215 + size_t bytes)
215 216 {
216 217 ssize_t w;
217 218 int fd;
@@ -238,7 +239,7 @@ write_mem(const char *dev, off_t offset, size_t blksz, void *mem, size_t bytes)
238 239 }
239 240
240 241 int
241   -read_passphrase(char *prompt, char *pass, size_t passlen)
  242 +read_passphrase(const char *prompt, char *pass, size_t passlen)
242 243 {
243 244 struct termios termios_old, termios_new;
244 245 ssize_t n;
3  tc-play-api.c
@@ -53,7 +53,8 @@ tc_api_uninit(void)
53 53 char *
54 54 tc_api_get_error_msg(void)
55 55 {
56   - return (tc_internal_verbose) ? "" : tc_internal_log_buffer;
  56 + return (tc_internal_verbose) ? __DECONST(char *, "") :
  57 + tc_internal_log_buffer;
57 58 }
58 59
59 60 char *
36 tc-play.c
@@ -52,12 +52,12 @@ int tc_internal_verbose = 1;
52 52 char tc_internal_log_buffer[LOG_BUFFER_SZ];
53 53
54 54 void
55   -tc_log(int err, char *fmt, ...)
  55 +tc_log(int is_err, const char *fmt, ...)
56 56 {
57 57 __va_list ap;
58 58 FILE *fp;
59 59
60   - if (err)
  60 + if (is_err)
61 61 fp = stderr;
62 62 else
63 63 fp = stdout;
@@ -94,7 +94,7 @@ struct tc_crypto_algo tc_crypto_algos[] = {
94 94 { NULL, NULL, 0, 0 }
95 95 };
96 96
97   -char *valid_cipher_chains[][MAX_CIPHER_CHAINS] = {
  97 +const char *valid_cipher_chains[][MAX_CIPHER_CHAINS] = {
98 98 { "AES-256-XTS", NULL },
99 99 { "TWOFISH-256-XTS", NULL },
100 100 { "SERPENT-256-XTS", NULL },
@@ -172,25 +172,8 @@ tc_build_cipher_chains(void)
172 172 }
173 173 }
174 174
175   -int
176   -hex2key(char *hex, size_t key_len, unsigned char *key)
177   -{
178   - char hex_buf[3];
179   - size_t key_idx;
180   - hex_buf[2] = 0;
181   - for (key_idx = 0; key_idx < key_len; ++key_idx) {
182   - hex_buf[0] = *hex++;
183   - hex_buf[1] = *hex++;
184   - key[key_idx] = (unsigned char)strtoul(hex_buf, NULL, 16);
185   - }
186   - hex_buf[0] = 0;
187   - hex_buf[1] = 0;
188   -
189   - return 0;
190   -}
191   -
192 175 #ifdef DEBUG
193   -void
  176 +static void
194 177 print_hex(unsigned char *buf, off_t start, size_t len)
195 178 {
196 179 size_t i;
@@ -226,13 +209,14 @@ print_info(struct tcplay_info *info)
226 209 printf("Volume size:\t\t%d sectors\n", info->size);
227 210 }
228 211
  212 +static
229 213 struct tcplay_info *
230 214 new_info(const char *dev, struct tc_cipher_chain *cipher_chain,
231 215 struct pbkdf_prf_algo *prf, struct tchdr_dec *hdr, off_t start)
232 216 {
233 217 struct tcplay_info *info;
234   - size_t i;
235   - int err;
  218 + int i;
  219 + int error;
236 220
237 221 if ((info = (struct tcplay_info *)alloc_safe_mem(sizeof(*info))) == NULL) {
238 222 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,
249 233 info->offset = hdr->off_mk_scope / hdr->sec_sz; /* block offset */
250 234
251 235 /* Associate a key out of the key pool with each cipher in the chain */
252   - err = tc_cipher_chain_populate_keys(cipher_chain, hdr->keys);
253   - if (err) {
  236 + error = tc_cipher_chain_populate_keys(cipher_chain, hdr->keys);
  237 + if (error) {
254 238 tc_log(1, "could not populate keys in cipher chain\n");
255 239 return NULL;
256 240 }
@@ -933,7 +917,7 @@ dm_setup(const char *mapname, struct tcplay_info *info)
933 917 }
934 918
935 919 struct tc_crypto_algo *
936   -check_cipher(char *cipher, int quiet)
  920 +check_cipher(const char *cipher, int quiet)
937 921 {
938 922 int i, found = 0;
939 923
12 tc-play.h
@@ -60,13 +60,13 @@
60 60 #include <uuid.h>
61 61
62 62 struct pbkdf_prf_algo {
63   - char *name;
  63 + const char *name;
64 64 int iteration_count;
65 65 };
66 66
67 67 struct tc_crypto_algo {
68   - char *name;
69   - char *dm_crypt_str;
  68 + const char *name;
  69 + const char *dm_crypt_str;
70 70 int klen;
71 71 int ivlen;
72 72 };
@@ -130,7 +130,7 @@ int get_random(unsigned char *buf, size_t len);
130 130 int secure_erase(const char *dev, size_t bytes, size_t blksz);
131 131 int get_disk_info(const char *dev, size_t *blocks, size_t *bsize);
132 132 int write_mem(const char *dev, off_t offset, size_t blksz, void *mem, size_t bytes);
133   -int read_passphrase(char *prompt, char *pass, size_t passlen);
  133 +int read_passphrase(const char *prompt, char *pass, size_t passlen);
134 134
135 135 int tc_crypto_init(void);
136 136 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);
158 158 void _free_safe_mem(void *mem, const char *file, int line);
159 159 void check_and_purge_safe_mem(void);
160 160
161   -struct tc_crypto_algo *check_cipher(char *cipher, int quiet);
  161 +struct tc_crypto_algo *check_cipher(const char *cipher, int quiet);
162 162 struct tc_cipher_chain *check_cipher_chain(char *cipher_chain, int quiet);
163 163 struct pbkdf_prf_algo *check_prf_algo(char *algo, int quiet);
164 164
165 165 void tc_play_init(void);
166   -void tc_log(int err, char *fmt, ...);
  166 +void tc_log(int err, const char *fmt, ...);
167 167 void print_info(struct tcplay_info *info);
168 168 int adjust_info(struct tcplay_info *info, struct tcplay_info *hinfo);
169 169 int process_hdr(const char *dev, unsigned char *pass, int passlen,

0 comments on commit 0c6d6a0

Please sign in to comment.
Something went wrong with that request. Please try again.