Fix lockfile compiler warnings
Now that we've patched the source for typos in commit
921c2059f9
("Fix typos"),
also fix the compiler warnings.
Change-Id: I0e1f1bfe19a475c431d2244257e245482950a843
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126380
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
This commit is contained in:
parent
b2e3cfb19e
commit
f989406acd
4 changed files with 51 additions and 51 deletions
|
@ -9,8 +9,6 @@
|
|||
|
||||
$(eval $(call gb_Executable_Executable,lockfile))
|
||||
|
||||
$(eval $(call gb_Executable_set_warnings_not_errors,lockfile))
|
||||
|
||||
$(eval $(call gb_Executable_set_include,lockfile, \
|
||||
-I$(SRCDIR)/solenv/lockfile \
|
||||
-I$(BUILDDIR)/solenv/lockfile \
|
||||
|
|
|
@ -27,8 +27,8 @@
|
|||
#include <signal.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <maillock.h>
|
||||
#include <lockfile.h>
|
||||
#include "maillock.h"
|
||||
#include "lockfile.h"
|
||||
|
||||
#ifdef HAVE_GETOPT_H
|
||||
#include <getopt.h>
|
||||
|
@ -40,10 +40,6 @@ extern char *optarg;
|
|||
extern int optind;
|
||||
#endif
|
||||
|
||||
extern int is_maillock(const char *lockfile);
|
||||
extern int lockfile_create_set_tmplock(const char *lockfile,
|
||||
volatile char **tmplock, int retries, int flags, struct __lockargs *);
|
||||
|
||||
static volatile char *tmplock;
|
||||
static int quiet;
|
||||
|
||||
|
@ -51,7 +47,7 @@ static int quiet;
|
|||
* If we got SIGINT, SIGQUIT, SIGHUP, remove the
|
||||
* tempfile and re-raise the signal.
|
||||
*/
|
||||
void got_signal(int sig)
|
||||
static void got_signal(int sig)
|
||||
{
|
||||
if (tmplock && tmplock[0])
|
||||
unlink((char *)tmplock);
|
||||
|
@ -59,15 +55,16 @@ void got_signal(int sig)
|
|||
raise(sig);
|
||||
}
|
||||
|
||||
void ignore_signal(int sig)
|
||||
static void ignore_signal(int sig)
|
||||
{
|
||||
(void)sig;
|
||||
}
|
||||
|
||||
/*
|
||||
* Install signal handler only if the signal was
|
||||
* not ignored already.
|
||||
*/
|
||||
int set_signal(int sig, void (*handler)(int))
|
||||
static int set_signal(int sig, void (*handler)(int))
|
||||
{
|
||||
struct sigaction sa;
|
||||
|
||||
|
@ -92,7 +89,7 @@ int check_sleep(int sleeptime, int flags)
|
|||
|
||||
if (ppid == 0) ppid = getppid();
|
||||
|
||||
if (flags & __L_INTERVAL)
|
||||
if (flags & L_INTERVAL_D_)
|
||||
interval = 1;
|
||||
|
||||
for (i = 0; i < sleeptime; i += interval) {
|
||||
|
@ -106,7 +103,8 @@ int check_sleep(int sleeptime, int flags)
|
|||
/*
|
||||
* Split a filename up in file and directory.
|
||||
*/
|
||||
int fn_split(char *fn, char **fn_p, char **dir_p)
|
||||
#ifdef MAILGROUP
|
||||
static int fn_split(char *fn, char **fn_p, char **dir_p)
|
||||
{
|
||||
static char *buf = NULL;
|
||||
char *p;
|
||||
|
@ -127,12 +125,12 @@ int fn_split(char *fn, char **fn_p, char **dir_p)
|
|||
}
|
||||
return L_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Return name of lockfile for mail.
|
||||
*/
|
||||
char *mlockname(char *user)
|
||||
static char *mlockname(char *user)
|
||||
{
|
||||
static char *buf = NULL;
|
||||
char *e;
|
||||
|
@ -155,7 +153,8 @@ char *mlockname(char *user)
|
|||
return buf;
|
||||
}
|
||||
|
||||
void perror_exit(const char *why) {
|
||||
static void perror_exit(const char *why)
|
||||
{
|
||||
if (!quiet) {
|
||||
fprintf(stderr, "dotlockfile: ");
|
||||
perror(why);
|
||||
|
@ -166,7 +165,7 @@ void perror_exit(const char *why) {
|
|||
/*
|
||||
* Print usage message and exit.
|
||||
*/
|
||||
void usage(void)
|
||||
static void usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: dotlockfile -l [-r retries] [-i interval] [-p] [-q] <-m|lockfile>\n");
|
||||
fprintf(stderr, " dotlockfile -l [-r retries] [-i interval] [-p] [-q] <-m|lockfile> [-P] command args...\n");
|
||||
|
@ -177,7 +176,7 @@ void usage(void)
|
|||
int main(int argc, char **argv)
|
||||
{
|
||||
struct passwd *pwd;
|
||||
struct __lockargs args = { 0 };
|
||||
struct lockargs_s_ args = { 0 };
|
||||
gid_t gid, egid;
|
||||
char *lockfile = NULL;
|
||||
char **cmd = NULL;
|
||||
|
@ -191,15 +190,17 @@ int main(int argc, char **argv)
|
|||
int touch = 0;
|
||||
int writepid = 0;
|
||||
int passthrough = 0;
|
||||
int cwd_fd = -1;
|
||||
int need_privs = 0;
|
||||
pid_t pid = -1;
|
||||
int e, wstatus;
|
||||
|
||||
/*
|
||||
* Remember real and effective gid, and
|
||||
* drop privs for now.
|
||||
*/
|
||||
if ((gid = getgid()) < 0)
|
||||
perror_exit("getgid");
|
||||
if ((egid = getegid()) < 0)
|
||||
perror_exit("getegid");
|
||||
gid = getgid();
|
||||
egid = getegid();
|
||||
if (gid != egid) {
|
||||
if (setregid(-1, gid) < 0)
|
||||
perror_exit("setregid(-1, gid)");
|
||||
|
@ -267,7 +268,7 @@ int main(int argc, char **argv)
|
|||
fprintf(stderr, "dotlockfile: -i needs argument >= 0\n");
|
||||
return L_ERROR;
|
||||
}
|
||||
flags |= __L_INTERVAL;
|
||||
flags |= L_INTERVAL_D_;
|
||||
args.interval = interval;
|
||||
break;
|
||||
case 't':
|
||||
|
@ -316,8 +317,6 @@ int main(int argc, char **argv)
|
|||
/*
|
||||
* Check if we run setgid.
|
||||
*/
|
||||
int cwd_fd = -1;
|
||||
int need_privs = 0;
|
||||
#ifdef MAILGROUP
|
||||
if (gid != egid) {
|
||||
/*
|
||||
|
@ -406,7 +405,7 @@ int main(int argc, char **argv)
|
|||
set_signal(SIGHUP, ignore_signal);
|
||||
set_signal(SIGALRM, ignore_signal);
|
||||
|
||||
pid_t pid = fork();
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
if (!quiet)
|
||||
perror("fork");
|
||||
|
@ -434,7 +433,6 @@ int main(int argc, char **argv)
|
|||
}
|
||||
|
||||
/* wait for child */
|
||||
int e, wstatus;
|
||||
while (1) {
|
||||
if (!writepid)
|
||||
alarm(30);
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <errno.h>
|
||||
#include <lockfile.h>
|
||||
#include <maillock.h>
|
||||
#include "lockfile.h"
|
||||
#include "maillock.h"
|
||||
|
||||
#ifdef HAVE_UTIME
|
||||
#include <utime.h>
|
||||
|
@ -40,10 +40,6 @@ static char *mlockfile;
|
|||
static int islocked = 0;
|
||||
#endif
|
||||
|
||||
#ifndef LIB
|
||||
extern int check_sleep(int, int);
|
||||
#endif
|
||||
|
||||
#ifdef MAILGROUP
|
||||
/*
|
||||
* Get the id of the mailgroup, by statting the helper program.
|
||||
|
@ -176,7 +172,7 @@ static int run_helper(char *opt, const char *lockfile, int retries, int flags)
|
|||
#define TMPLOCKFILENAMESZ (TMPLOCKSTRSZ + TMPLOCKPIDSZ + \
|
||||
TMPLOCKTIMESZ + TMPLOCKSYSNAMESZ)
|
||||
|
||||
static int lockfilename(const char *lockfile, char *tmplock, int tmplocksz)
|
||||
static int lockfilename(const char *lockfile, char *tmplock, size_t tmplocksz)
|
||||
{
|
||||
char sysname[256];
|
||||
char *p;
|
||||
|
@ -226,9 +222,9 @@ static int lockfilename(const char *lockfile, char *tmplock, int tmplocksz)
|
|||
* Create a lockfile.
|
||||
*/
|
||||
static int lockfile_create_save_tmplock(const char *lockfile,
|
||||
char *tmplock, int tmplocksz,
|
||||
char *tmplock, size_t tmplocksz,
|
||||
volatile char **xtmplock,
|
||||
int retries, int flags, struct __lockargs *args)
|
||||
int retries, int flags, struct lockargs_s_ *args)
|
||||
{
|
||||
struct stat st, st1;
|
||||
char pidbuf[40];
|
||||
|
@ -241,7 +237,7 @@ static int lockfile_create_save_tmplock(const char *lockfile,
|
|||
int tries = retries + 1;
|
||||
|
||||
/* process optional flags that have arguments */
|
||||
if (flags & __L_INTERVAL) {
|
||||
if (flags & L_INTERVAL_D_) {
|
||||
sleeptime = args->interval;
|
||||
}
|
||||
|
||||
|
@ -256,7 +252,7 @@ static int lockfile_create_save_tmplock(const char *lockfile,
|
|||
}
|
||||
}
|
||||
pidlen = snprintf(pidbuf, sizeof(pidbuf), "%d\n", pid);
|
||||
if (pidlen > sizeof(pidbuf) - 1) {
|
||||
if (pidlen < 0 || pidlen > (int) sizeof(pidbuf) - 1) {
|
||||
errno = EOVERFLOW;
|
||||
return L_ERROR;
|
||||
}
|
||||
|
@ -294,7 +290,7 @@ static int lockfile_create_save_tmplock(const char *lockfile,
|
|||
*/
|
||||
for (i = 0; i < tries && tries > 0; i++) {
|
||||
if (!dontsleep) {
|
||||
if (!(flags & __L_INTERVAL))
|
||||
if (!(flags & L_INTERVAL_D_))
|
||||
sleeptime += 5;
|
||||
|
||||
if (sleeptime > 5) sleeptime = 5;
|
||||
|
@ -385,10 +381,11 @@ static int lockfile_create_save_tmplock(const char *lockfile,
|
|||
#ifdef LIB
|
||||
static
|
||||
#endif
|
||||
int lockfile_create_set_tmplock(const char *lockfile, volatile char **xtmplock, int retries, int flags, struct __lockargs *args)
|
||||
int lockfile_create_set_tmplock(const char *lockfile, volatile char **xtmplock, int retries, int flags, struct lockargs_s_ *args)
|
||||
{
|
||||
char *tmplock;
|
||||
int l, r, e;
|
||||
int r, e;
|
||||
size_t l;
|
||||
|
||||
l = strlen(lockfile)+TMPLOCKFILENAMESZ+1;
|
||||
if ((tmplock = (char *)malloc(l)) == NULL)
|
||||
|
@ -417,14 +414,14 @@ int lockfile_create(const char *lockfile, int retries, int flags)
|
|||
|
||||
#ifdef STATIC
|
||||
int lockfile_create2(const char *lockfile, int retries,
|
||||
int flags, struct __lockargs *args, int args_sz)
|
||||
int flags, struct lockargs_s_ *args, int args_sz)
|
||||
{
|
||||
|
||||
#define FLAGS_WITH_ARGS (__L_INTERVAL)
|
||||
#define KNOWN_FLAGS (L_PID|L_PPID|__L_INTERVAL)
|
||||
#define FLAGS_WITH_ARGS (L_INTERVAL_D_)
|
||||
#define KNOWN_FLAGS (L_PID|L_PPID|L_INTERVAL_D_)
|
||||
|
||||
/* check if size is the same (version check) */
|
||||
if (args != NULL && sizeof(struct __lockargs) != args_sz) {
|
||||
if (args != NULL && sizeof(struct lockargs_s_) != args_sz) {
|
||||
errno = EINVAL;
|
||||
return L_ERROR;
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
* General Public License can be found in `/usr/doc/copyright/LGPL'.
|
||||
* You can also find a copy on the GNU website at http://www.gnu.org/
|
||||
*/
|
||||
#ifndef _LOCKFILE_H
|
||||
#define _LOCKFILE_H
|
||||
#ifndef LOCKFILE_H_
|
||||
#define LOCKFILE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -47,17 +47,24 @@ int lockfile_check(const char *lockfile, int flags);
|
|||
/*
|
||||
* Experimental.
|
||||
*/
|
||||
struct __lockargs {
|
||||
struct lockargs_s_ {
|
||||
int interval; /* Static interval between retries */
|
||||
};
|
||||
#define __L_INTERVAL 64 /* Specify consistent retry interval */
|
||||
#define L_INTERVAL_D_ 64 /* Specify consistent retry interval */
|
||||
#ifdef LOCKFILE_EXPERIMENTAL
|
||||
#define lockargs __lockargs
|
||||
#define L_INTERVAL __L_INTERVAL
|
||||
#define lockargs lockargs_s_
|
||||
#define L_INTERVAL L_INTERVAL_D_
|
||||
int lockfile_create2(const char *lockfile, int retries,
|
||||
int flags, struct lockargs *args, int args_sz);
|
||||
#endif
|
||||
|
||||
#ifndef LIB
|
||||
int check_sleep(int, int);
|
||||
#endif
|
||||
int is_maillock(const char *lockfile);
|
||||
int lockfile_create_set_tmplock(const char *lockfile, volatile char **tmplock,
|
||||
int retries, int flags, struct lockargs_s_ *);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue