DragonFly submit List (threaded) for 2005-04
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]
[PATCH] sbin/dump general cleanup
General clean up only.
The only warnings left are signed values comparing unsigned values.
They would be fixed after Joerg and Matt has done their libc type dump up
work
(http://leaf.dragonflybsd.org/mailarchive/kernel/2005-04/msg00096.html)
Please review them.
Best Regards,
sephe
Index: unctime.c
===================================================================
RCS file: /opt/df_cvs/src/sbin/dump/unctime.c,v
retrieving revision 1.3
diff -u -r1.3 unctime.c
--- unctime.c 28 Sep 2003 14:39:17 -0000 1.3
+++ unctime.c 12 Apr 2005 09:51:42 -0000
@@ -44,6 +44,7 @@
* Return -1 if the string is not in ctime format.
*/
+time_t unctime(char *);
time_t
unctime(char *str)
1) split atomic() to atomic_read() and atomic_write(), because to write(2)/read(2)'s function type are not same
2) add static for locally use function definition
3) add __unused for unused funtion parameter
4) change local variable name to avoid shadowing
5) add `volatile' type modifier for loacl variable where longjmp()/setjmp() may junk it
Index: tape.c
===================================================================
RCS file: /opt/df_cvs/src/sbin/dump/tape.c,v
retrieving revision 1.8
diff -u -r1.8 tape.c
--- tape.c 27 Dec 2004 22:36:37 -0000 1.8
+++ tape.c 12 Apr 2005 09:51:08 -0000
@@ -77,7 +77,8 @@
extern char *host;
char *nexttape;
-static int atomic(ssize_t (*)(), int, char *, int);
+static int atomic_read(int, char *, int);
+static int atomic_write(int, const char *, int);
static void doslave(int, int);
static void enslave(void);
static void flushtape(void);
@@ -203,8 +204,8 @@
int nogripe = 0;
-void
-tperror(int signo)
+static void
+tperror(int signo __unused)
{
if (pipeout) {
@@ -224,8 +225,8 @@
Exit(X_REWRITE);
}
-void
-sigpipe(int signo)
+static void
+sigpipe(int signo __unused)
{
quit("Broken pipe\n");
@@ -241,7 +242,7 @@
slp->req[trecno].count = 0; /* Sentinel */
- if (atomic(write, slp->fd, (char *)slp->req, siz) != siz)
+ if (atomic_write(slp->fd, (char *)slp->req, siz) != siz)
quit("error writing command pipe: %s\n", strerror(errno));
slp->sent = 1; /* we sent a request, read the response later */
@@ -252,7 +253,7 @@
/* Read results back from next slave */
if (slp->sent) {
- if (atomic(read, slp->fd, (char *)&got, sizeof got)
+ if (atomic_read(slp->fd, (char *)&got, sizeof got)
!= sizeof got) {
perror(" DUMP: error reading command pipe in master");
dumpabort(0);
@@ -269,7 +270,7 @@
*/
for (i = 0; i < SLAVES; i++) {
if (slaves[i].sent) {
- if (atomic(read, slaves[i].fd,
+ if (atomic_read(slaves[i].fd,
(char *)&got, sizeof got)
!= sizeof got) {
perror(" DUMP: error reading command pipe in master");
@@ -325,7 +326,7 @@
* fixme: punt for now.
*/
if (slaves[f].sent) {
- if (atomic(read, slaves[f].fd, (char *)&got, sizeof got)
+ if (atomic_read(slaves[f].fd, (char *)&got, sizeof got)
!= sizeof got) {
perror(" DUMP: error reading command pipe in master");
dumpabort(0);
@@ -442,7 +443,7 @@
lastspclrec = savedtapea - 1;
}
size = (char *)ntb - (char *)q;
- if (atomic(write, slp->fd, (char *)q, size) != size) {
+ if (atomic_write(slp->fd, (char *)q, size) != size) {
perror(" DUMP: error writing command pipe");
dumpabort(0);
}
@@ -482,7 +483,7 @@
* worked ok, otherwise the tape is much too short!
*/
if (slp->sent) {
- if (atomic(read, slp->fd, (char *)&got, sizeof got)
+ if (atomic_read(slp->fd, (char *)&got, sizeof got)
!= sizeof got) {
perror(" DUMP: error reading command pipe in master");
dumpabort(0);
@@ -510,7 +511,7 @@
int parentpid;
int childpid;
int status;
- int waitpid;
+ int wait_pid;
char *p;
#ifdef sunos
void (*interrupt_save)();
@@ -544,9 +545,9 @@
msg("Tape: %d; parent process: %d child process %d\n",
tapeno+1, parentpid, childpid);
#endif /* TDEBUG */
- while ((waitpid = wait(&status)) != childpid)
+ while ((wait_pid = wait(&status)) != childpid)
msg("Parent %d waiting for child %d has another child %d return\n",
- parentpid, childpid, waitpid);
+ parentpid, childpid, wait_pid);
if (status & 0xFF) {
msg("Child %d returns LOB status %o\n",
childpid, status&0xFF);
@@ -641,7 +642,7 @@
}
void
-dumpabort(int signo)
+dumpabort(int signo __unused)
{
if (master != 0 && master != getpid())
@@ -670,8 +671,8 @@
/*
* proceed - handler for SIGUSR2, used to synchronize IO between the slaves.
*/
-void
-proceed(int signo)
+static void
+proceed(int signo __unused)
{
if (ready)
@@ -715,10 +716,11 @@
}
}
- for (i = 0; i < SLAVES; i++)
- atomic(write, slaves[i].fd,
+ for (i = 0; i < SLAVES; i++) {
+ atomic_write(slaves[i].fd,
(char *) &slaves[(i + 1) % SLAVES].pid,
sizeof slaves[0].pid);
+ }
master = 0;
}
@@ -743,10 +745,11 @@
* get the lock back for the next cycle by swapping descriptors.
*/
static void
-doslave(int cmd, int slave_number)
+doslave(int cmd, int slave_number __unused)
{
int nread;
- int nextslave, size, wrote = 0, eot_count;
+ int nextslave, size, eot_count;
+ volatile int wrote = 0;
/*
* Need our own seek pointer.
@@ -758,7 +761,7 @@
/*
* Need the pid of the next slave in the loop...
*/
- if ((nread = atomic(read, cmd, (char *)&nextslave, sizeof nextslave))
+ if ((nread = atomic_read(cmd, (char *)&nextslave, sizeof nextslave))
!= sizeof nextslave) {
quit("master/slave protocol botched - didn't get pid of next slave.\n");
}
@@ -766,7 +769,7 @@
/*
* Get list of blocks to dump, read the blocks into tape buffer
*/
- while ((nread = atomic(read, cmd, (char *)slp->req, reqsiz)) == reqsiz) {
+ while ((nread = atomic_read(cmd, (char *)slp->req, reqsiz)) == reqsiz) {
struct req *p = slp->req;
for (trecno = 0; trecno < ntrec;
@@ -775,7 +778,7 @@
bread(p->dblk, slp->tblock[trecno],
p->count * TP_BSIZE);
} else {
- if (p->count != 1 || atomic(read, cmd,
+ if (p->count != 1 || atomic_read(cmd,
(char *)slp->tblock[trecno],
TP_BSIZE) != TP_BSIZE)
quit("master/slave protocol botched.\n");
@@ -838,7 +841,7 @@
* pass size of write back to master
* (for EOT handling)
*/
- atomic(write, cmd, (char *)&size, sizeof size);
+ atomic_write(cmd, (char *)&size, sizeof size);
}
/*
@@ -857,11 +860,21 @@
* loop until the count is satisfied (or error).
*/
static int
-atomic(ssize_t (*func)(), int fd, char *buf, int count)
+atomic_read(int fd, char *buf, int count)
+{
+ int got, need = count;
+
+ while ((got = read(fd, buf, need)) > 0 && (need -= got) > 0)
+ buf += got;
+ return (got < 0 ? got : count - need);
+}
+
+static int
+atomic_write(int fd, const char *buf, int count)
{
int got, need = count;
- while ((got = (*func)(fd, buf, need)) > 0 && (need -= got) > 0)
+ while ((got = write(fd, buf, need)) > 0 && (need -= got) > 0)
buf += got;
return (got < 0 ? got : count - need);
}
Index: main.c
===================================================================
RCS file: /opt/df_cvs/src/sbin/dump/main.c,v
retrieving revision 1.9
diff -u -r1.9 main.c
--- main.c 27 Dec 2004 22:36:37 -0000 1.9
+++ main.c 12 Apr 2005 09:49:51 -0000
@@ -80,7 +80,7 @@
long blocksperfile; /* output blocks per file */
char *host = NULL; /* remote host (if any) */
-static long numarg(char *, long, long);
+static long numarg(const char *, long, long);
static void obsolete(int *, char **[]);
static void usage(void);
@@ -253,9 +253,14 @@
}
if (strchr(tape, ':')) {
- host = tape;
- tape = strchr(host, ':');
- *tape++ = '\0';
+ if ((host = strdup(tape)) != NULL) {
+ char *ehost;
+ ehost = strchr(host, ':');
+ *ehost++ = '\0';
+ tape = ehost;
+ } else {
+ err(1, NULL);
+ }
#ifdef RDUMP
if (strchr(tape, '\n')) {
fprintf(stderr, "invalid characters in tape\n");
@@ -518,7 +523,7 @@
* range (except that a vmax of 0 means unlimited).
*/
static long
-numarg(char *meaning, long vmin, long vmax)
+numarg(const char *meaning, long vmin, long vmax)
{
char *p;
long val;
1) add const constraint
2) add extern, when duplicated definition warning encounted
3) rename certain function declaration's parameter avoid name shadowing
Index: dump.h
===================================================================
RCS file: /opt/df_cvs/src/sbin/dump/dump.h,v
retrieving revision 1.6
diff -u -r1.6 dump.h
--- dump.h 2 Apr 2005 22:25:32 -0000 1.6
+++ dump.h 12 Apr 2005 09:49:04 -0000
@@ -60,9 +60,9 @@
* All calculations done in 0.1" units!
*/
char *disk; /* name of the disk file */
-char *tape; /* name of the tape file */
-char *dumpdates; /* name of the file containing dump date information*/
-char *temp; /* name of the file for doing rewrite of dumpdates */
+const char *tape; /* name of the tape file */
+const char *dumpdates; /* name of the file containing dump date information*/
+const char *temp; /* name of the file for doing rewrite of dumpdates */
char lastlevel; /* dump level of previous dump */
char level; /* dump level of this dump */
int uflag; /* update flag */
@@ -71,34 +71,34 @@
int pipeout; /* true => output to standard output */
ino_t curino; /* current inumber; used globally */
int newtape; /* new tape flag */
-int density; /* density in 0.1" units */
+extern int density; /* density in 0.1" units */
long tapesize; /* estimated tape size, blocks */
long tsize; /* tape size in 0.1" units */
long asize; /* number of 0.1" units written on current tape */
int etapes; /* estimated number of tapes */
int nonodump; /* if set, do not honor UF_NODUMP user flags */
int unlimited; /* if set, write to end of medium */
-int cachesize; /* size of block cache */
+extern int cachesize; /* size of block cache */
-int notify; /* notify operator flag */
-int blockswritten; /* number of blocks written on current tape */
-int tapeno; /* current tape number */
+extern int notify; /* notify operator flag */
+extern int blockswritten; /* number of blocks written on current tape */
+extern int tapeno; /* current tape number */
time_t tstart_writing; /* when started writing the first tape block */
time_t tend_writing; /* after writing the last tape block */
int passno; /* current dump pass number */
struct fs *sblock; /* the file system super block */
char sblock_buf[MAXBSIZE];
-long dev_bsize; /* block size of underlying disk device */
+extern long dev_bsize; /* block size of underlying disk device */
int dev_bshift; /* log2(dev_bsize) */
int tp_bshift; /* log2(TP_BSIZE) */
/* operator interface functions */
-void broadcast(char *message);
+void broadcast(const char *message);
void infosch(int);
void lastdump(int arg); /* int should be char */
void msg(const char *fmt, ...) __printflike(1, 2);
void msgtail(const char *fmt, ...) __printflike(1, 2);
-int query(char *question);
+int query(const char *question);
void quit(const char *fmt, ...) __printflike(1, 2);
void timeest(void);
time_t unctime(char *str);
@@ -106,8 +106,8 @@
/* mapping rouintes */
struct dinode;
long blockest(struct dinode *dp);
-int mapfiles(ino_t maxino, long *tapesize);
-int mapdirs(ino_t maxino, long *tapesize);
+int mapfiles(ino_t maxino, long *_tapesize);
+int mapdirs(ino_t maxino, long *_tapesize);
/* file dumping routines */
void blksout(daddr_t *blkp, int frags, ino_t ino);
@@ -136,7 +136,7 @@
#ifdef RDUMP
void rmtclose(void);
int rmthost(char *host);
-int rmtopen(char *tape, int mode);
+int rmtopen(const char *_tape, int mode);
int rmtwrite(char *buf, int count);
#endif /* RDUMP */
@@ -167,8 +167,9 @@
char dd_level;
time_t dd_ddate;
};
-int nddates; /* number of records (might be zero) */
-struct dumpdates **ddatev; /* the arrayfied version */
+extern int nddates; /* number of records (might be zero) */
+extern struct dumpdates **ddatev; /* the arrayfied version */
+
void initdumptimes(void);
void getdumptime(void);
void putdumptime(void);
rename function parameter name to avoid name shadowing
Index: traverse.c
===================================================================
RCS file: /opt/df_cvs/src/sbin/dump/traverse.c,v
retrieving revision 1.9
diff -u -r1.9 traverse.c
--- traverse.c 2 Apr 2005 22:25:32 -0000 1.9
+++ traverse.c 12 Apr 2005 09:51:25 -0000
@@ -70,11 +70,11 @@
typedef long fsizeT;
#endif
-static int dirindir(ino_t ino, daddr_t blkno, int level, long *size,
- long *tapesize, int nodump);
-static void dmpindir(ino_t ino, daddr_t blk, int level, fsizeT *size);
+static int dirindir(ino_t ino, daddr_t blkno, int _level, long *size,
+ long *tape_size, int nodump);
+static void dmpindir(ino_t ino, daddr_t blk, int _level, fsizeT *size);
static int searchdir(ino_t ino, daddr_t blkno, long size, long filesize,
- long *tapesize, int nodump);
+ long *tape_size, int nodump);
/*
* This is an estimation of the number of TP_BSIZE blocks in the file.
@@ -136,7 +136,7 @@
* the directories in the filesystem.
*/
int
-mapfiles(ino_t maxino, long *tapesize)
+mapfiles(ino_t maxino, long *tape_size)
{
int mode;
ino_t ino;
@@ -159,9 +159,9 @@
if (WANTTODUMP(dp)) {
SETINO(ino, dumpinomap);
if (mode != IFREG && mode != IFDIR && mode != IFLNK)
- *tapesize += 1;
+ *tape_size += 1;
else
- *tapesize += blockest(dp);
+ *tape_size += blockest(dp);
continue;
}
if (mode == IFDIR) {
@@ -191,7 +191,7 @@
* pass using this algorithm.
*/
int
-mapdirs(ino_t maxino, long *tapesize)
+mapdirs(ino_t maxino, long *tape_size)
{
struct dinode *dp;
int i, isdir, nodump;
@@ -221,10 +221,11 @@
di = *dp; /* inode buf may change in searchdir(). */
filesize = di.di_size;
for (ret = 0, i = 0; filesize > 0 && i < NDADDR; i++) {
- if (di.di_db[i] != 0)
+ if (di.di_db[i] != 0) {
ret |= searchdir(ino, di.di_db[i],
(long)dblksize(sblock, &di, i),
- filesize, tapesize, nodump);
+ filesize, tape_size, nodump);
+ }
if (ret & HASDUMPEDFILE)
filesize = 0;
else
@@ -234,11 +235,11 @@
if (di.di_ib[i] == 0)
continue;
ret |= dirindir(ino, di.di_ib[i], i, &filesize,
- tapesize, nodump);
+ tape_size, nodump);
}
if (ret & HASDUMPEDFILE) {
SETINO(ino, dumpinomap);
- *tapesize += blockest(&di);
+ *tape_size += blockest(&di);
change = 1;
continue;
}
@@ -262,7 +263,7 @@
*/
static int
dirindir(ino_t ino, daddr_t blkno, int ind_level, long *filesize,
- long *tapesize, int nodump)
+ long *tape_size, int nodump)
{
int ret = 0;
int i;
@@ -272,9 +273,10 @@
if (ind_level <= 0) {
for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) {
blkno = idblk[i];
- if (blkno != 0)
+ if (blkno != 0) {
ret |= searchdir(ino, blkno, sblock->fs_bsize,
- *filesize, tapesize, nodump);
+ *filesize, tape_size, nodump);
+ }
if (ret & HASDUMPEDFILE)
*filesize = 0;
else
@@ -285,9 +287,10 @@
ind_level--;
for (i = 0; *filesize > 0 && i < NINDIR(sblock); i++) {
blkno = idblk[i];
- if (blkno != 0)
+ if (blkno != 0) {
ret |= dirindir(ino, blkno, ind_level, filesize,
- tapesize, nodump);
+ tape_size, nodump);
+ }
}
return (ret);
}
@@ -299,7 +302,7 @@
*/
static int
searchdir(ino_t ino, daddr_t blkno, long size, long filesize,
- long *tapesize, int nodump)
+ long *tape_size, int nodump)
{
struct direct *dp;
struct dinode *ip;
@@ -328,7 +331,7 @@
ip = getino(dp->d_ino);
if (TSTINO(dp->d_ino, dumpinomap)) {
CLRINO(dp->d_ino, dumpinomap);
- *tapesize -= blockest(ip);
+ *tape_size -= blockest(ip);
}
/*
* Add back to dumpdirmap and remove from usedinomap
1) add const constraint
2) add __unused for certain unused function parameter
3) add static for locally used only function definition
4) add const during type cast on const void pointer
Index: optr.c
===================================================================
RCS file: /opt/df_cvs/src/sbin/dump/optr.c,v
retrieving revision 1.6
diff -u -r1.6 optr.c
--- optr.c 27 Dec 2004 22:36:37 -0000 1.6
+++ optr.c 12 Apr 2005 09:50:42 -0000
@@ -54,7 +54,7 @@
#include "dump.h"
#include "pathnames.h"
-void alarmcatch(/* int, int */);
+void alarmcatch(int); /* int, int */
int datesort(const void *, const void *);
/*
@@ -68,11 +68,11 @@
* Every 2 minutes we reprint the message, alerting others
* that dump needs attention.
*/
-static int timeout;
-static char *attnmessage; /* attention message */
+static int timeout;
+static const char *attnmessage; /* attention message */
int
-query(char *question)
+query(const char *question)
{
char replybuffer[64];
int back, errcount;
@@ -82,7 +82,7 @@
quit("fopen on %s fails: %s\n", _PATH_TTY, strerror(errno));
attnmessage = question;
timeout = 0;
- alarmcatch();
+ alarmcatch(0);
back = -1;
errcount = 0;
do {
@@ -118,7 +118,7 @@
* sleep for 2 minutes in case nobody comes to satisfy dump
*/
void
-alarmcatch()
+alarmcatch(int signo __unused)
{
if (notify == 0) {
if (timeout == 0)
@@ -142,7 +142,7 @@
* Here if an inquisitive operator interrupts the dump program
*/
void
-interrupt(int signo)
+interrupt(int signo __unused)
{
msg("Interrupt received.\n");
if (query("Do you want to abort dump?"))
@@ -153,7 +153,7 @@
* We now use wall(1) to do the actual broadcasting.
*/
void
-broadcast(char *message)
+broadcast(const char *message)
{
FILE *fp;
char buf[sizeof(_PATH_WALL) + sizeof(OPGRENT) + 3];
@@ -209,7 +209,7 @@
* Schedule a printout of the estimate in the next call to timeest().
*/
void
-infosch(int signal)
+infosch(int signo __unused)
{
tschedule = 0;
}
@@ -263,7 +263,7 @@
* we don't actually do it
*/
-struct fstab *
+static struct fstab *
allocfsent(struct fstab *fs)
{
struct fstab *new;
@@ -355,7 +355,8 @@
int i;
struct fstab *dt;
struct dumpdates *dtwalk;
- char *lastname, *date;
+ const char *lastname;
+ char *date;
int dumpme;
time_t tnow;
struct tm *tlast;
@@ -399,8 +400,8 @@
int
datesort(const void *a1, const void *a2)
{
- struct dumpdates *d1 = *(struct dumpdates **)a1;
- struct dumpdates *d2 = *(struct dumpdates **)a2;
+ const struct dumpdates *d1 = *(const struct dumpdates **)a1;
+ const struct dumpdates *d2 = *(const struct dumpdates **)a2;
int diff;
diff = strncmp(d1->dd_name, d2->dd_name, sizeof(d1->dd_name));
1) add const constraint
2) add fake int parameter for rmtconnabort(), which also severs as a signal handler
3) msg("") -> msg("%s", "") to shut up gcc's empty fmt string warning
4) rename certain function parameter to avoid name shadowing
5) remove unused function
6) cast strlen(3)'s return value to (ssize_t) when it is compared write(2)'s return value
Index: dumprmt.c
===================================================================
RCS file: /opt/df_cvs/src/sbin/dump/dumprmt.c,v
retrieving revision 1.7
diff -u -r1.7 dumprmt.c
--- dumprmt.c 27 Dec 2004 22:36:37 -0000 1.7
+++ dumprmt.c 12 Apr 2005 09:49:26 -0000
@@ -76,12 +76,12 @@
static char *rmtpeer;
static int okname(char *);
-static int rmtcall(char *, char *);
-static void rmtconnaborted(/* int, int */);
+static int rmtcall(const char *, const char *);
+static void rmtconnaborted(int);
static int rmtgetb(void);
static void rmtgetconn(void);
static void rmtgets(char *, int);
-static int rmtreply(char *);
+static int rmtreply(const char *);
#ifdef KERBEROS
int krcmd(char **, int /*u_short*/, char *, char *, int *, char *);
#endif
@@ -107,7 +107,7 @@
}
static void
-rmtconnaborted(void)
+rmtconnaborted(int signo __unused)
{
msg("Lost connection to remote host.\n");
if (errfd != -1) {
@@ -168,7 +168,7 @@
tuser = pwd->pw_name;
if ((rmt = getenv("RMT")) == NULL)
rmt = _PATH_RMT;
- msg("");
+ msg("%s", "");
#ifdef KERBEROS
if (dokerberos)
rmtape = krcmd(&rmtpeer, sp->s_port, tuser, rmt, &errfd,
@@ -217,13 +217,13 @@
}
int
-rmtopen(char *tape, int mode)
+rmtopen(const char *rtape, int mode)
{
char buf[256];
- snprintf(buf, sizeof (buf), "O%.226s\n%d\n", tape, mode);
+ snprintf(buf, sizeof (buf), "O%.226s\n%d\n", rtape, mode);
rmtstate = TS_OPEN;
- return (rmtcall(tape, buf));
+ return (rmtcall(rtape, buf));
}
void
@@ -237,25 +237,6 @@
}
int
-rmtread(char *buf, int count)
-{
- char line[30];
- int n, i, cc;
-
- snprintf(line, sizeof (line), "R%d\n", count);
- n = rmtcall("read", line);
- if (n < 0)
- /* rmtcall() properly sets errno for us on errors. */
- return (n);
- for (i = 0; i < n; i += cc) {
- cc = read(rmtape, buf+i, n - i);
- if (cc <= 0)
- rmtconnaborted();
- }
- return (n);
-}
-
-int
rmtwrite(char *buf, int count)
{
char line[30];
@@ -266,76 +247,17 @@
return (rmtreply("write"));
}
-void
-rmtwrite0(int count)
-{
- char line[30];
-
- snprintf(line, sizeof (line), "W%d\n", count);
- write(rmtape, line, strlen(line));
-}
-
-void
-rmtwrite1(char *buf, int count)
-{
-
- write(rmtape, buf, count);
-}
-
-int
-rmtwrite2(void)
-{
-
- return (rmtreply("write"));
-}
-
-int
-rmtseek(int offset, int pos)
-{
- char line[80];
-
- snprintf(line, sizeof (line), "L%d\n%d\n", offset, pos);
- return (rmtcall("seek", line));
-}
-
-struct mtget mts;
-
-struct mtget *
-rmtstatus(void)
-{
- int i;
- char *cp;
-
- if (rmtstate != TS_OPEN)
- return (NULL);
- rmtcall("status", "S\n");
- for (i = 0, cp = (char *)&mts; i < sizeof(mts); i++)
- *cp++ = rmtgetb();
- return (&mts);
-}
-
-int
-rmtioctl(int cmd, int count)
-{
- char buf[256];
-
- if (count < 0)
- return (-1);
- snprintf(buf, sizeof (buf), "I%d\n%d\n", cmd, count);
- return (rmtcall("ioctl", buf));
-}
-
static int
-rmtcall(char *cmd, char *buf)
+rmtcall(const char *cmd, const char *buf)
{
- if (write(rmtape, buf, strlen(buf)) != strlen(buf))
- rmtconnaborted();
+ if (write(rmtape, buf, strlen(buf)) != (ssize_t)strlen(buf))
+ rmtconnaborted(0);
return (rmtreply(cmd));
}
static int
-rmtreply(char *cmd)
+rmtreply(const char *cmd)
{
char *cp;
char code[30], emsg[BUFSIZ];
@@ -357,7 +279,7 @@
msg("Protocol to remote tape server botched (code \"%s\").\n",
code);
- rmtconnaborted();
+ rmtconnaborted(0);
}
return (atoi(code + 1));
}
@@ -368,7 +290,7 @@
char c;
if (read(rmtape, &c, 1) != 1)
- rmtconnaborted();
+ rmtconnaborted(0);
return (c);
}
@@ -390,5 +312,5 @@
*cp = '\0';
msg("Protocol to remote tape server botched.\n");
msg("(rmtgets got \"%s\").\n", line);
- rmtconnaborted();
+ rmtconnaborted(0);
}
[
Date Prev][
Date Next]
[
Thread Prev][
Thread Next]
[
Date Index][
Thread Index]