* splint and -Wall fixes

--HG--
extra : convert_revision : svn%3Aeebe1cee-a9af-4fe4-bd26-ad572b19c5ab/trunk%4045
This commit is contained in:
mathias 2006-09-07 22:03:31 +00:00
parent 3857559d82
commit 5deb0de590
10 changed files with 66 additions and 61 deletions

View file

@ -2,7 +2,7 @@
#define alock_mask_height 100 #define alock_mask_height 100
#define alock_mask_x_hot 23 #define alock_mask_x_hot 23
#define alock_mask_y_hot 46 #define alock_mask_y_hot 46
static unsigned char alock_mask_bits[] = { static char alock_mask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

View file

@ -2,5 +2,5 @@
#define mini_height 8 #define mini_height 8
#define mini_x_hot 3 #define mini_x_hot 3
#define mini_y_hot 3 #define mini_y_hot 3
static unsigned char mini_bits[] = { static char mini_bits[] = {
0x3c, 0x42, 0x7e, 0x42, 0x5a, 0x42, 0x7e, 0x00}; 0x3c, 0x42, 0x7e, 0x42, 0x5a, 0x42, 0x7e, 0x00};

View file

@ -2,5 +2,5 @@
#define mini_mask_height 8 #define mini_mask_height 8
#define mini_mask_x_hot 3 #define mini_mask_x_hot 3
#define mini_mask_y_hot 3 #define mini_mask_y_hot 3
static unsigned char mini_mask_bits[] = { static char mini_mask_bits[] = {
0x3c, 0x42, 0x7e, 0x7e, 0x66, 0x7e, 0x7e, 0x00}; 0x3c, 0x42, 0x7e, 0x7e, 0x66, 0x7e, 0x7e, 0x00};

View file

@ -18,7 +18,7 @@ endef
########################## ##########################
MAKEDEP ?= gcc -MM MAKEDEP ?= gcc -MM
CC ?= gcc CC ?= gcc
CFLAGS += -DVERSION=$(VERSION) CFLAGS += -Wall -DVERSION=$(VERSION)
LDFLAGS ?= LDFLAGS ?=
LIBS ?= -lX11 LIBS ?= -lX11
########################## ##########################

View file

@ -62,7 +62,7 @@ static struct aAuth* alock_authmodules[] = {
&alock_auth_sha256, &alock_auth_sha256,
&alock_auth_sha384, &alock_auth_sha384,
&alock_auth_sha512, &alock_auth_sha512,
#endif /* HASH_PWD */ #endif /* HAVE_HASH */
NULL NULL
}; };
/*------------------------------------------------------------------*\ /*------------------------------------------------------------------*\
@ -114,7 +114,7 @@ static struct aCursor* alock_cursors[] = {
/*------------------------------------------------------------------*\ /*------------------------------------------------------------------*\
\*------------------------------------------------------------------*/ \*------------------------------------------------------------------*/
void displayUsage() { static void displayUsage() {
printf("alock [-hv] [-bg type:options] [-cursor type:options] "); printf("alock [-hv] [-bg type:options] [-cursor type:options] ");
printf("[-auth type:options]\n"); printf("[-auth type:options]\n");
} }
@ -122,23 +122,24 @@ void displayUsage() {
/*------------------------------------------------------------------*\ /*------------------------------------------------------------------*\
\*------------------------------------------------------------------*/ \*------------------------------------------------------------------*/
void initXInfo(struct aXInfo* xinfo, struct aOpts* opts) { static void initXInfo(struct aXInfo* xinfo, struct aOpts* opts) {
Display* dpy = XOpenDisplay(NULL); Display* dpy = XOpenDisplay(NULL);
if (!dpy) { if (!dpy) {
perror("alock: error, can't open connection to X"); perror("alock: error, can't open connection to X");
exit(1); exit(EXIT_FAILURE);
} }
{
const size_t nr_screens = ScreenCount(dpy);
xinfo->display = dpy; xinfo->display = dpy;
xinfo->nr_screens = ScreenCount(dpy); xinfo->nr_screens = nr_screens;
xinfo->window = (Window*)calloc(nr_screens, sizeof(Window));
xinfo->window = (Window*)calloc(xinfo->nr_screens, sizeof(Window)); xinfo->root = (Window*)calloc(nr_screens, sizeof(Window));
xinfo->root = (Window*)calloc(xinfo->nr_screens, sizeof(Window)); xinfo->colormap = (Colormap*)calloc(nr_screens, sizeof(Colormap));
xinfo->colormap = (Colormap*)calloc(xinfo->nr_screens, sizeof(Colormap)); xinfo->cursor = (Cursor*)calloc(nr_screens, sizeof(Cursor));
xinfo->cursor = (Cursor*)calloc(xinfo->nr_screens, sizeof(Cursor)); }
{ {
int scr; int scr;
for (scr = 0; scr < xinfo->nr_screens; scr++) { for (scr = 0; scr < xinfo->nr_screens; scr++) {
@ -149,7 +150,7 @@ void initXInfo(struct aXInfo* xinfo, struct aOpts* opts) {
} }
} }
int event_loop(struct aOpts* opts, struct aXInfo* xinfo) { static int event_loop(struct aOpts* opts, struct aXInfo* xinfo) {
XEvent ev; XEvent ev;
KeySym ks; KeySym ks;
@ -243,11 +244,11 @@ int main(int argc, char **argv) {
char* char_tmp; char* char_tmp;
struct aBackground* bg_tmp = NULL; struct aBackground* bg_tmp = NULL;
struct aBackground** i; struct aBackground** i;
if (!strcmp(argv[arg], "list")) { if (strcmp(argv[arg], "list") == 0) {
for(i = alock_backgrounds; *i; ++i) { for(i = alock_backgrounds; *i; ++i) {
printf("%s\n", (*i)->name); printf("%s\n", (*i)->name);
} }
exit(0); exit(EXIT_SUCCESS);
} }
for(i = alock_backgrounds; *i; ++i) { for(i = alock_backgrounds; *i; ++i) {
@ -261,15 +262,15 @@ int main(int argc, char **argv) {
} }
} }
if (!bg_tmp) { if (bg_tmp == NULL) {
printf("alock: error, couldnt find the bg-module you specified.\n"); printf("alock: error, couldnt find the bg-module you specified.\n");
exit(1); exit(EXIT_FAILURE);
} }
} else { } else {
printf("alock, error, missing argument\n"); printf("alock, error, missing argument\n");
displayUsage(); displayUsage();
exit(1); exit(EXIT_FAILURE);
} }
} else if (!strcmp(argv[arg - 1], "-auth")) { } else if (!strcmp(argv[arg - 1], "-auth")) {
if (arg < argc) { if (arg < argc) {
@ -281,16 +282,16 @@ int main(int argc, char **argv) {
for(i = alock_authmodules; *i; ++i) { for(i = alock_authmodules; *i; ++i) {
printf("%s\n", (*i)->name); printf("%s\n", (*i)->name);
} }
exit(0); exit(EXIT_SUCCESS);
} }
for(i = alock_authmodules; *i; ++i) { for(i = alock_authmodules; *i; ++i) {
char_tmp = strstr(argv[arg], (*i)->name); char_tmp = strstr(argv[arg], (*i)->name);
if(char_tmp && char_tmp == argv[arg]) { if(char_tmp && char_tmp == argv[arg]) {
auth_tmp = (*i); auth_tmp = (*i);
if (!auth_tmp->init(argv[arg])) { if (auth_tmp->init(argv[arg]) == 0) {
printf("alock: error, failed init of [%s].\n", auth_tmp->name); printf("alock: error, failed init of [%s].\n", auth_tmp->name);
exit(1); exit(EXIT_FAILURE);
} }
opts.auth = auth_tmp; opts.auth = auth_tmp;
++arg; ++arg;
@ -298,27 +299,27 @@ int main(int argc, char **argv) {
} }
} }
if (!auth_tmp) { if (auth_tmp == NULL) {
printf("alock: error, couldnt find the auth-module you specified.\n"); printf("alock: error, couldnt find the auth-module you specified.\n");
exit(1); exit(EXIT_FAILURE);
} }
} else { } else {
printf("alock, error, missing argument\n"); printf("alock, error, missing argument\n");
displayUsage(); displayUsage();
exit(1); exit(EXIT_FAILURE);
} }
} else if (!strcmp(argv[arg - 1], "-cursor")) { } else if (strcmp(argv[arg - 1], "-cursor") == 0) {
if (arg < argc) { if (arg < argc) {
char* char_tmp; char* char_tmp;
struct aCursor* cursor_tmp = NULL; struct aCursor* cursor_tmp = NULL;
struct aCursor** i; struct aCursor** i;
if (!strcmp(argv[arg], "list")) { if (strcmp(argv[arg], "list") == 0) {
for(i = alock_cursors; *i; ++i) { for(i = alock_cursors; *i; ++i) {
printf("%s\n", (*i)->name); printf("%s\n", (*i)->name);
} }
exit(0); exit(EXIT_SUCCESS);
} }
for(i = alock_cursors; *i; ++i) { for(i = alock_cursors; *i; ++i) {
@ -334,20 +335,20 @@ int main(int argc, char **argv) {
if (!cursor_tmp) { if (!cursor_tmp) {
printf("alock: error, couldnt find the cursor-module you specified.\n"); printf("alock: error, couldnt find the cursor-module you specified.\n");
exit(1); exit(EXIT_FAILURE);
} }
} else { } else {
printf("alock, error, missing argument\n"); printf("alock, error, missing argument\n");
displayUsage(); displayUsage();
exit(1); exit(EXIT_FAILURE);
} }
} else if (!strcmp(argv[arg - 1], "-h")) { } else if (strcmp(argv[arg - 1], "-h") == 0) {
displayUsage(); displayUsage();
exit(0); exit(EXIT_SUCCESS);
} else if (!strcmp(argv[arg - 1], "-v")) { } else if (strcmp(argv[arg - 1], "-v") == 0) {
printf("alock-%s by m.gumz 2005\n", VERSION); printf("alock-%s by m.gumz 2005 - 2006\n", VERSION);
exit(0); exit(EXIT_SUCCESS);
} }
} }
} }
@ -355,25 +356,25 @@ int main(int argc, char **argv) {
if (!opts.auth) { if (!opts.auth) {
printf("alock: error, no auth-method specified.\n"); printf("alock: error, no auth-method specified.\n");
displayUsage(); displayUsage();
exit(1); exit(EXIT_FAILURE);
} }
opts.auth->init(NULL); opts.auth->init(NULL);
initXInfo(&xinfo, &opts); initXInfo(&xinfo, &opts);
if (!opts.background->init(background_args, &xinfo)) { if (opts.background->init(background_args, &xinfo) == 0) {
printf("alock: error, couldnt init [%s] with [%s].\n", printf("alock: error, couldnt init [%s] with [%s].\n",
opts.background->name, opts.background->name,
background_args); background_args);
exit(1); exit(EXIT_FAILURE);
} }
if (!opts.cursor->init(cursor_args, &xinfo)) { if (opts.cursor->init(cursor_args, &xinfo) == 0) {
printf("alock: error, couldnt init [%s] with [%s].\n", printf("alock: error, couldnt init [%s] with [%s].\n",
opts.cursor->name, opts.cursor->name,
cursor_args); cursor_args);
exit(1); exit(EXIT_FAILURE);
} }
{ {
@ -395,17 +396,18 @@ int main(int argc, char **argv) {
if ((XGrabKeyboard(xinfo.display, xinfo.window[0], True, GrabModeAsync, GrabModeAsync, if ((XGrabKeyboard(xinfo.display, xinfo.window[0], True, GrabModeAsync, GrabModeAsync,
CurrentTime)) != GrabSuccess) { CurrentTime)) != GrabSuccess) {
printf("alock: couldnt grab the keyboard.\n"); printf("alock: couldnt grab the keyboard.\n");
exit(1); exit(EXIT_FAILURE);
} }
} }
/* TODO: think about it: do we really need NR_SCREEN cursors ? we grab the /* TODO: think about it: do we really need NR_SCREEN cursors ? we grab the
* pointer on :*.0 anyway ... */ * pointer on :*.0 anyway ... */
if (XGrabPointer(xinfo.display, xinfo.window[0], False, (KeyPressMask|KeyReleaseMask) & 0, if (XGrabPointer(xinfo.display, xinfo.window[0], False, None,
GrabModeAsync, GrabModeAsync, None, xinfo.cursor[0], CurrentTime) != GrabSuccess) { GrabModeAsync, GrabModeAsync, None, xinfo.cursor[0], CurrentTime) != GrabSuccess) {
XUngrabKeyboard(xinfo.display, CurrentTime); XUngrabKeyboard(xinfo.display, CurrentTime);
printf("alock: couldnt grab the pointer.\n"); printf("alock: couldnt grab the pointer.\n");
exit(1); exit(EXIT_FAILURE);
} }
event_loop(&opts, &xinfo); event_loop(&opts, &xinfo);
@ -415,6 +417,6 @@ int main(int argc, char **argv) {
opts.background->deinit(&xinfo); opts.background->deinit(&xinfo);
XCloseDisplay(xinfo.display); XCloseDisplay(xinfo.display);
return 0; return EXIT_SUCCESS;
} }

View file

@ -32,9 +32,10 @@
/*------------------------------------------------------------------*\ /*------------------------------------------------------------------*\
\*------------------------------------------------------------------*/ \*------------------------------------------------------------------*/
void alock_string2lower(char* string) { void alock_string2lower(char* string) {
static unsigned int i; const size_t s = strlen(string);
for(i = strlen(string) - 1; i; --i) size_t i;
tolower(string[i]); for(i = 0; i < s; i++)
string[i] = tolower(string[i]);
} }
/* ---------------------------------------------------------------- *\ /* ---------------------------------------------------------------- *\

View file

@ -383,10 +383,10 @@ static int alock_auth_md5_auth(const char* pass) {
memset(stringdigest, 0, MD5_DIGEST_STRING_LENGTH); memset(stringdigest, 0, MD5_DIGEST_STRING_LENGTH);
for (i = 0; i < MD5_DIGEST_LENGTH; i++) { for (i = 0; i < MD5_DIGEST_LENGTH; i++) {
sprintf(&stringdigest[i*2], "%02x", digest[i]); sprintf((char*)&stringdigest[i*2], "%02x", digest[i]);
} }
return !strcmp(stringdigest, userhash); return !strcmp((char*)stringdigest, userhash);
} }
struct aAuth alock_auth_md5 = { struct aAuth alock_auth_md5 = {

View file

@ -28,8 +28,10 @@
#include <X11/Xlib.h> #include <X11/Xlib.h>
#include <string.h> #include <string.h>
#include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include <unistd.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <pwd.h> #include <pwd.h>

View file

@ -319,10 +319,10 @@ static int alock_auth_sha1_auth(const char* pass) {
memset(stringdigest, 0, SHA1_DIGEST_STRING_LENGTH); memset(stringdigest, 0, SHA1_DIGEST_STRING_LENGTH);
for (i = 0; i < SHA1_DIGEST_LENGTH; i++) { for (i = 0; i < SHA1_DIGEST_LENGTH; i++) {
sprintf(&stringdigest[i*2], "%02x", digest[i]); sprintf((char*)&stringdigest[i*2], "%02x", digest[i]);
} }
return !strcmp(stringdigest, userhash); return !strcmp((char*)stringdigest, userhash);
} }
struct aAuth alock_auth_sha1 = { struct aAuth alock_auth_sha1 = {

View file

@ -992,9 +992,9 @@ static int alock_auth_sha2_auth(const char* pass) {
memset(stringdigest, 0, SHA256_DIGEST_STRING_LENGTH); memset(stringdigest, 0, SHA256_DIGEST_STRING_LENGTH);
for (i = 0; i < SHA256_DIGEST_LENGTH; i++) { for (i = 0; i < SHA256_DIGEST_LENGTH; i++) {
sprintf(&stringdigest[i*2], "%02x", digest[i]); sprintf((char*)&stringdigest[i*2], "%02x", digest[i]);
} }
return !strcmp(stringdigest, userhash); return !strcmp((char*)stringdigest, userhash);
} }
break; break;
case 512: { case 512: {
@ -1009,9 +1009,9 @@ static int alock_auth_sha2_auth(const char* pass) {
memset(stringdigest, 0, SHA512_DIGEST_STRING_LENGTH); memset(stringdigest, 0, SHA512_DIGEST_STRING_LENGTH);
for (i = 0; i < SHA512_DIGEST_LENGTH; i++) { for (i = 0; i < SHA512_DIGEST_LENGTH; i++) {
sprintf(&stringdigest[i*2], "%02x", digest[i]); sprintf((char*)&stringdigest[i*2], "%02x", digest[i]);
} }
return !strcmp(stringdigest, userhash); return !strcmp((char*)stringdigest, userhash);
} }
break; break;
case 384: { case 384: {
@ -1026,9 +1026,9 @@ static int alock_auth_sha2_auth(const char* pass) {
memset(stringdigest, 0, SHA384_DIGEST_STRING_LENGTH); memset(stringdigest, 0, SHA384_DIGEST_STRING_LENGTH);
for (i = 0; i < SHA384_DIGEST_LENGTH; i++) { for (i = 0; i < SHA384_DIGEST_LENGTH; i++) {
sprintf(&stringdigest[i*2], "%02x", digest[i]); sprintf((char*)&stringdigest[i*2], "%02x", digest[i]);
} }
return !strcmp(stringdigest, userhash); return !strcmp((char*)stringdigest, userhash);
} }
break; break;
}; };