Fix some warnings if compiled with clang.
authorMilan Broz <gmazyland@gmail.com>
Mon, 15 Nov 2010 16:19:19 +0000 (16:19 +0000)
committerMilan Broz <gmazyland@gmail.com>
Mon, 15 Nov 2010 16:19:19 +0000 (16:19 +0000)
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@371 36d66b0a-2a48-0410-832c-cd162a569da5

lib/luks1/af.c
lib/setup.c
lib/utils.c
lib/utils_crypt.c
src/cryptsetup.c

index aad6691..8958cdb 100644 (file)
@@ -124,7 +124,8 @@ int AF_merge(char *src, char *dst, size_t blocksize, unsigned int blocknumbers,
        if (!(hash_id = gcry_md_map_name(hash)))
                return -EINVAL;
 
-       if((bufblock = calloc(blocksize, 1)) == NULL) return -ENOMEM;
+       if((bufblock = calloc(blocksize, 1)) == NULL)
+               return -ENOMEM;
 
        memset(bufblock,0,blocksize);
        for(i=0; i<blocknumbers-1; i++) {
@@ -136,5 +137,5 @@ int AF_merge(char *src, char *dst, size_t blocksize, unsigned int blocknumbers,
        r = 0;
 out:
        free(bufblock);
-       return 0;
+       return r;
 }
index 9519e99..6a13f84 100644 (file)
@@ -932,7 +932,7 @@ int crypt_luksDump(struct crypt_options *options)
        r = crypt_dump(cd);
 
        crypt_free(cd);
-       return 0;
+       return r;
 }
 
 void crypt_get_error(char *buf, size_t size)
@@ -1263,7 +1263,7 @@ int crypt_load(struct crypt_device *cd,
 
        if (!r) {
                memcpy(&cd->hdr, &hdr, sizeof(hdr));
-               cd->type = strdup(requested_type);
+               cd->type = strdup(CRYPT_LUKS1);
                if (!cd->type)
                        r = -ENOMEM;
        }
@@ -1776,6 +1776,7 @@ int crypt_activate_by_passphrase(struct crypt_device *cd,
        crypt_status_info ci;
        struct volume_key *vk = NULL;
        char *read_passphrase = NULL;
+       unsigned int passphraseLen = 0;
        int r;
 
        log_dbg("%s volume %s [keyslot %d] using %spassphrase.",
@@ -1796,10 +1797,11 @@ int crypt_activate_by_passphrase(struct crypt_device *cd,
        if (isPLAIN(cd->type)) {
                if (!passphrase) {
                        r = key_from_terminal(cd, NULL, &read_passphrase,
-                                             &passphrase_size, 0);
+                                             &passphraseLen, 0);
                        if (r < 0)
                                goto out;
                        passphrase = read_passphrase;
+                       passphrase_size = passphraseLen;
                }
                r = create_device_helper(cd, name, cd->plain_hdr.hash,
                                         cd->plain_cipher, cd->plain_cipher_mode,
index 510ab6d..3454691 100644 (file)
@@ -171,7 +171,7 @@ ssize_t read_blockwise(int fd, void *orig_buf, size_t count) {
        if ((long)orig_buf & (alignment - 1)) {
                buf = aligned_malloc(&buf_base, count, alignment);
                if (!buf)
-                       goto out;
+                       return -1;
        } else
                buf = orig_buf;
 
index 9547a1a..6ad4196 100644 (file)
@@ -154,7 +154,7 @@ static int interactive_pass(const char *prompt, char *pass, size_t maxlen,
        tcsetattr(infd, TCSAFLUSH, &orig);
 
 out_err:
-       if (!failed && write(outfd, "\n", 1));
+       if (!failed && write(outfd, "\n", 1)) {};
 
        if (infd != STDIN_FILENO)
                close(infd);
@@ -206,7 +206,7 @@ int crypt_get_key(char *prompt, char **key, unsigned int *passLen, int key_size,
                int i;
 
                pass = crypt_safe_alloc(MAX_TTY_PASSWORD_LEN);
-               if (!pass || (i = interactive_pass(prompt, pass, MAX_TTY_PASSWORD_LEN, timeout))) {
+               if (!pass || interactive_pass(prompt, pass, MAX_TTY_PASSWORD_LEN, timeout)) {
                        crypt_log(cd, CRYPT_LOG_ERROR,
                                  _("Error reading passphrase from terminal.\n"));
                        goto out_err;
index d2d8f89..666b4fe 100644 (file)
@@ -801,8 +801,9 @@ out:
        return r;
 }
 
-static void usage(poptContext popt_context, int exitcode,
-                  const char *error, const char *more)
+static __attribute__ ((noreturn)) void usage(poptContext popt_context,
+                                            int exitcode, const char *error,
+                                            const char *more)
 {
        poptPrintUsage(popt_context, stderr, 0);
        if (error)
@@ -1025,7 +1026,7 @@ int main(int argc, char **argv)
                      _("Key size must be a multiple of 8 bits"),
                      poptGetInvocationName(popt_context));
 
-       if (!strcmp(aname, "luksKillSlot"))
+       if (!strcmp(aname, "luksKillSlot") && action_argc > 1)
                opt_key_slot = atoi(action_argv[1]);
        if (opt_key_slot != CRYPT_ANY_SLOT &&
            (opt_key_slot < 0 || opt_key_slot > crypt_keyslot_max(CRYPT_LUKS1)))