Fix compiler warnings.

* common/dotlock.c (use_hardlinks_p, dotlock_take_unix): Check return
value of link().
* g13/g13.c: Make sure err is initialized.
* scd/scdaemon.c (main) [!USE_GCRY_THREAD_CBS]: Do not define ERR.
This commit is contained in:
Marcus Brinkmann 2012-01-03 17:08:01 +01:00
parent 61ccd8d92d
commit 0dce26778e
3 changed files with 24 additions and 9 deletions

View File

@ -583,16 +583,21 @@ use_hardlinks_p (const char *tname)
strcpy (lname, tname); strcpy (lname, tname);
strcat (lname, "x"); strcat (lname, "x");
link (tname, lname); res = link (tname, lname);
if (res < 0)
if (stat (tname, &sb)) res = -1;
res = -1; /* Ooops. */
else if (sb.st_nlink == nlink + 1)
res = 0; /* Yeah, hardlinks are supported. */
else else
res = 1; /* No hardlink support. */ {
if (stat (tname, &sb))
res = -1; /* Ooops. */
else if (sb.st_nlink == nlink + 1)
res = 0; /* Yeah, hardlinks are supported. */
else
res = 1; /* No hardlink support. */
unlink (lname);
}
unlink (lname);
jnlib_free (lname); jnlib_free (lname);
return res; return res;
} }
@ -948,6 +953,7 @@ dotlock_destroy (dotlock_t h)
static int static int
dotlock_take_unix (dotlock_t h, long timeout) dotlock_take_unix (dotlock_t h, long timeout)
{ {
int res;
int wtime = 0; int wtime = 0;
int sumtime = 0; int sumtime = 0;
int pid; int pid;
@ -1004,7 +1010,13 @@ dotlock_take_unix (dotlock_t h, long timeout)
{ {
struct stat sb; struct stat sb;
link (h->tname, h->lockname); res = link (h->tname, h->lockname);
if (res < 0)
{
my_error_1 ("lock not made: Oops: link of tmp file failed: %s\n",
strerror (errno));
return -1;
}
if (stat (h->tname, &sb)) if (stat (h->tname, &sb))
{ {

View File

@ -686,6 +686,7 @@ main ( int argc, char **argv)
#endif /*0*/ #endif /*0*/
/* Dispatch command. */ /* Dispatch command. */
err = 0;
switch (cmd) switch (cmd)
{ {
case aGPGConfList: case aGPGConfList:

View File

@ -382,7 +382,9 @@ main (int argc, char **argv )
{ {
ARGPARSE_ARGS pargs; ARGPARSE_ARGS pargs;
int orig_argc; int orig_argc;
#ifdef USE_GCRY_THREAD_CBS
gpg_error_t err; gpg_error_t err;
#endif
char **orig_argv; char **orig_argv;
FILE *configfp = NULL; FILE *configfp = NULL;
char *configname = NULL; char *configname = NULL;