Module Name: src
Committed By: nonaka
Date: Tue Apr 28 10:57:24 UTC 2009
Modified Files:
src/usr.sbin/tpctl: data.c main.c tp.c tpctl.h
Log Message:
Fix WARNS=4 issues.
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/tpctl/data.c src/usr.sbin/tpctl/tpctl.h
cvs rdiff -u -r1.4 -r1.5 src/usr.sbin/tpctl/main.c
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/tpctl/tp.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/tpctl/data.c
diff -u src/usr.sbin/tpctl/data.c:1.5 src/usr.sbin/tpctl/data.c:1.6
--- src/usr.sbin/tpctl/data.c:1.5 Sat May 10 15:31:05 2008
+++ src/usr.sbin/tpctl/data.c Tue Apr 28 10:57:24 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: data.c,v 1.5 2008/05/10 15:31:05 martin Exp $ */
+/* $NetBSD: data.c,v 1.6 2009/04/28 10:57:24 nonaka Exp $ */
/*-
* Copyright (c) 2002 TAKEMRUA Shin
@@ -41,7 +41,7 @@
#ifndef lint
#include <sys/cdefs.h>
-__RCSID("$NetBSD: data.c,v 1.5 2008/05/10 15:31:05 martin Exp $");
+__RCSID("$NetBSD: data.c,v 1.6 2009/04/28 10:57:24 nonaka Exp $");
#endif /* not lint */
static void *
@@ -86,7 +86,7 @@
}
int
-read_data(char *filename, struct tpctl_data *data)
+read_data(const char *filename, struct tpctl_data *data)
{
int res, len, n, i, t;
char buf[MAXDATALEN + 2], *p, *p2;
@@ -252,32 +252,32 @@
}
int
-write_data(char *filename, struct tpctl_data *data)
+write_data(const char *filename, struct tpctl_data *data)
{
int res, fd;
FILE *fp;
struct tpctl_data_elem *elem;
- char *p, tmpfile[MAXPATHLEN + 1];
+ char *p, tempfile[MAXPATHLEN + 1];
fd = 0; /* XXXGCC -Wuninitialized [hpcarm] */
if (filename == NULL) {
fp = stdout;
} else {
- strncpy(tmpfile, filename, MAXPATHLEN);
- tmpfile[MAXPATHLEN] = '\0';
- if ((p = strrchr(tmpfile, '/')) == NULL) {
- strcpy(tmpfile, TPCTL_TMP_FILENAME);
+ strncpy(tempfile, filename, MAXPATHLEN);
+ tempfile[MAXPATHLEN] = '\0';
+ if ((p = strrchr(tempfile, '/')) == NULL) {
+ strcpy(tempfile, TPCTL_TMP_FILENAME);
} else {
p++;
if (MAXPATHLEN <
- p - tmpfile + strlen(TPCTL_TMP_FILENAME))
+ p - tempfile + strlen(TPCTL_TMP_FILENAME))
return (ERR_NOFILE);/* file name is too long */
- strcat(tmpfile, TPCTL_TMP_FILENAME);
+ strcat(tempfile, TPCTL_TMP_FILENAME);
}
- if ((fd = open(tmpfile, O_RDWR|O_CREAT|O_EXCL, 0644)) < 0) {
+ if ((fd = open(tempfile, O_RDWR|O_CREAT|O_EXCL, 0644)) < 0) {
fprintf(stderr, "%s: can't create %s\n",
- getprogname(), tmpfile);
+ getprogname(), tempfile);
return (ERR_NOFILE);
}
if ((fp = fdopen(fd, "w")) == NULL) {
@@ -304,8 +304,8 @@
if (filename != NULL) {
fclose(fp);
close(fd);
- if (rename(tmpfile, filename) < 0) {
- unlink(tmpfile);
+ if (rename(tempfile, filename) < 0) {
+ unlink(tempfile);
return (ERR_NOFILE);
}
}
Index: src/usr.sbin/tpctl/tpctl.h
diff -u src/usr.sbin/tpctl/tpctl.h:1.5 src/usr.sbin/tpctl/tpctl.h:1.6
--- src/usr.sbin/tpctl/tpctl.h:1.5 Sat May 10 15:31:05 2008
+++ src/usr.sbin/tpctl/tpctl.h Tue Apr 28 10:57:24 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: tpctl.h,v 1.5 2008/05/10 15:31:05 martin Exp $ */
+/* $NetBSD: tpctl.h,v 1.6 2009/04/28 10:57:24 nonaka Exp $ */
/*-
* Copyright (c) 2002, 2003 TAKEMRUA Shin
@@ -86,8 +86,8 @@
};
int init_data(struct tpctl_data *);
-int read_data(char *, struct tpctl_data *);
-int write_data(char *, struct tpctl_data *);
+int read_data(const char *, struct tpctl_data *);
+int write_data(const char *, struct tpctl_data *);
void write_coords(FILE *, char *, struct wsmouse_calibcoords *);
void free_data(struct tpctl_data *);
int replace_data(struct tpctl_data *, char *, struct wsmouse_calibcoords *);
Index: src/usr.sbin/tpctl/main.c
diff -u src/usr.sbin/tpctl/main.c:1.4 src/usr.sbin/tpctl/main.c:1.5
--- src/usr.sbin/tpctl/main.c:1.4 Sat May 10 15:31:05 2008
+++ src/usr.sbin/tpctl/main.c Tue Apr 28 10:57:24 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.4 2008/05/10 15:31:05 martin Exp $ */
+/* $NetBSD: main.c,v 1.5 2009/04/28 10:57:24 nonaka Exp $ */
/*-
* Copyright (c) 2002 TAKEMRUA Shin
@@ -49,12 +49,12 @@
#ifndef lint
#include <sys/cdefs.h>
-__RCSID("$NetBSD: main.c,v 1.4 2008/05/10 15:31:05 martin Exp $");
+__RCSID("$NetBSD: main.c,v 1.5 2009/04/28 10:57:24 nonaka Exp $");
#endif /* not lint */
-void load_data(char *data_file, struct tpctl_data *);
-void save_data(char *data_file, struct tpctl_data *);
-int do_calibration(char *, struct tp *, struct wsmouse_calibcoords *);
+void load_data(const char *, struct tpctl_data *);
+void save_data(const char *, struct tpctl_data *);
+int do_calibration(const char *, struct tp *, struct wsmouse_calibcoords *);
void drawcross(struct fb *, int, int, int, fb_pixel_t);
int check_esc(void *);
@@ -79,9 +79,9 @@
struct tp tp;
struct wsmouse_calibcoords *pref;
struct tpctl_data data;
- char *data_file;
- char *dev_name;
- char *dispdev_name;
+ const char *data_file;
+ const char *dev_name;
+ const char *dispdev_name;
/* set default values */
opt_verbose = 0;
@@ -178,13 +178,13 @@
* return: none (it won't return if some error occurs)
*/
void
-load_data(char *data_file, struct tpctl_data *data)
+load_data(const char *data_file, struct tpctl_data *data)
{
- int err;
+ int error;
init_data(data);
- err = read_data(data_file, data);
- switch (err) {
+ error = read_data(data_file, data);
+ switch (error) {
case ERR_NONE:
break;
case ERR_NOFILE:
@@ -220,12 +220,12 @@
* return: none (it won't return if some error occurs)
*/
void
-save_data(char *data_file, struct tpctl_data *data)
+save_data(const char *data_file, struct tpctl_data *data)
{
- int err;
+ int error;
- err = write_data(data_file, data);
- switch (err) {
+ error = write_data(data_file, data);
+ switch (error) {
case ERR_NONE:
break;
case ERR_NOFILE:
@@ -254,11 +254,12 @@
* (it won't return if some error occurs)
*/
int
-do_calibration(char *dev, struct tp *tp, struct wsmouse_calibcoords *coords)
+do_calibration(const char *dev, struct tp *tp,
+ struct wsmouse_calibcoords *coords)
{
int fbfd;
struct fb fb;
- int i, x, y, xm, ym, cursize, err, res;
+ int i, x, y, xm, ym, cursize, error, res;
/* open frame buffer device and initialize frame buffer routine */
if ((fbfd = open(dev, O_RDWR)) < 0)
@@ -298,7 +299,7 @@
coords->samples[4].y = ym;
tp_setrawmode(tp);
- err = 0;
+ error = 0;
for (i = 0; i < coords->samplelen; i++) {
drawcross(&fb,
coords->samples[i].x,
@@ -308,7 +309,7 @@
tp_flush(tp);
res = tp_get(tp, &x, &y, check_esc, 0 /* stdin */);
if (res < 0) {
- err = errno;
+ error = errno;
break;
}
if (0 < res) {
@@ -338,8 +339,8 @@
fb.conf.hf_offset);
}
- if (err) {
- errno = err;
+ if (error) {
+ errno = error;
errx(EXIT_FAILURE, "can't get samples");
}
@@ -380,7 +381,7 @@
check_esc(void *data)
{
int fd = (int)data;
- int flg, n, err;
+ int flg, n, error;
char buf[1];
struct termios tm, raw;
@@ -395,11 +396,11 @@
if (fcntl(fd, F_SETFL, flg | O_NONBLOCK) == -1)
return (-1);
n = read(fd, buf, 1);
- err = errno;
+ error = errno;
fcntl(fd, F_SETFL, flg);
tcsetattr(fd, TCSANOW, &tm);
if (n < 0)
- return (err == EWOULDBLOCK ? 0 : -1);
+ return (error == EWOULDBLOCK ? 0 : -1);
if (n == 0)
return (0); /* EOF */
if (*buf == 0x1b)
Index: src/usr.sbin/tpctl/tp.c
diff -u src/usr.sbin/tpctl/tp.c:1.8 src/usr.sbin/tpctl/tp.c:1.9
--- src/usr.sbin/tpctl/tp.c:1.8 Tue Mar 3 18:43:15 2009
+++ src/usr.sbin/tpctl/tp.c Tue Apr 28 10:57:24 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: tp.c,v 1.8 2009/03/03 18:43:15 nonaka Exp $ */
+/* $NetBSD: tp.c,v 1.9 2009/04/28 10:57:24 nonaka Exp $ */
/*-
* Copyright (c) 2002, 2003 TAKEMRUA Shin
@@ -43,7 +43,7 @@
#ifndef lint
#include <sys/cdefs.h>
-__RCSID("$NetBSD: tp.c,v 1.8 2009/03/03 18:43:15 nonaka Exp $");
+__RCSID("$NetBSD: tp.c,v 1.9 2009/04/28 10:57:24 nonaka Exp $");
#endif /* not lint */
int
@@ -74,7 +74,7 @@
return (-1);
#endif
flags = fcntl(tp->fd, F_GETFL);
- if (flags == -1)
+ if (flags == (u_int)-1)
return (-1);
flags |= O_NONBLOCK;
if (fcntl(tp->fd, F_SETFL, flags) < 0)