mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-06 00:10:04 +01:00
Fix some warnings if compiled with clang.
git-svn-id: https://cryptsetup.googlecode.com/svn/trunk@371 36d66b0a-2a48-0410-832c-cd162a569da5
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user