Page MenuHomeFreeBSD

D57073.diff
No OneTemporary

D57073.diff

diff --git a/usr.bin/tftp/main.c b/usr.bin/tftp/main.c
--- a/usr.bin/tftp/main.c
+++ b/usr.bin/tftp/main.c
@@ -76,7 +76,7 @@
static char *margv[MAX_MARGV];
int verbose;
-static char *port = NULL;
+static char *port;
static void get(int, char **);
static void help(int, char **);
@@ -100,14 +100,14 @@
static void setpacketdrop(int, char **);
static void setwindowsize(int, char **);
-static void command(bool, EditLine *, History *, HistEvent *) __dead2;
+static void command(bool, EditLine *, History *, HistEvent *) __dead2;
static const char *command_prompt(void);
-static void urihandling(char *URI);
-static void getusage(char *);
-static void makeargv(char *argv0, char *line);
-static void putusage(char *);
-static void settftpmode(const char *);
+static void urihandling(char *URI);
+static void getusage(char *);
+static void makeargv(char *argv0, char *line);
+static void putusage(char *);
+static void settftpmode(const char *);
static char *tail(char *);
static const struct cmd *getcmd(const char *);
@@ -116,7 +116,7 @@
struct cmd {
const char *name;
- void (*handler)(int, char **);
+ void (*handler)(int, char **);
const char *help;
};
@@ -224,13 +224,13 @@
static void
urihandling(char *URI)
{
- char meth[] = "get";
- char *host = NULL;
- char *path = NULL;
- char *opts = NULL;
const char *tmode = "octet";
- char *s;
- int i;
+ char meth[] = "get";
+ char *host = NULL;
+ char *path = NULL;
+ char *opts = NULL;
+ char *s;
+ int i;
host = URI + 7;
@@ -271,8 +271,8 @@
setpeer0(char *host, const char *lport)
{
struct addrinfo hints, *res0, *res;
- int error;
const char *cause = "unknown";
+ int error;
if (connected) {
close(peer);
@@ -285,7 +285,7 @@
hints.ai_socktype = SOCK_DGRAM;
hints.ai_protocol = IPPROTO_UDP;
hints.ai_flags = AI_CANONNAME;
- if (!lport)
+ if (lport == NULL)
lport = "tftp";
error = getaddrinfo(host, lport, &hints, &res0);
if (error) {
@@ -347,7 +347,7 @@
argc = margc;
argv = margv;
}
- if ((argc < 2) || (argc > 3)) {
+ if (argc < 2 || argc > 3) {
printf("usage: %s [host [port]]\n", argv[0]);
return;
}
@@ -393,21 +393,18 @@
static void
setbinary(int argc __unused, char *argv[] __unused)
{
-
settftpmode("octet");
}
static void
setascii(int argc __unused, char *argv[] __unused)
{
-
settftpmode("netascii");
}
static void
settftpmode(const char *newmode)
{
-
strlcpy(mode, newmode, sizeof(mode));
if (verbose)
printf("mode set to %s\n", mode);
@@ -422,9 +419,9 @@
{
static char *line;
static size_t sz;
- int fd, n;
- char *cp, *targ, *path;
struct stat sb;
+ char *cp, *targ, *path;
+ int fd, n;
if (argc < 2) {
printf("(file) ");
@@ -517,7 +514,6 @@
static void
putusage(char *s)
{
-
printf("usage: %s file [remotename]\n", s);
printf(" %s file host:remotename\n", s);
printf(" %s file1 file2 ... fileN [[host:]remote-directory]\n", s);
@@ -531,8 +527,8 @@
{
static char *line;
static size_t sz;
- int fd, n;
char *cp, *src;
+ int fd, n;
if (argc < 2) {
printf("(files) ");
@@ -608,7 +604,6 @@
static void
getusage(char *s)
{
-
printf("usage: %s file [localname]\n", s);
printf(" %s [host:]file [localname]\n", s);
printf(" %s [host1:]file1 [host2:]file2 ... [hostN:]fileN\n", s);
@@ -671,7 +666,6 @@
static void
showstatus(int argc __unused, char *argv[] __unused)
{
-
printf("Remote host: %s\n",
connected ? hostname : "none specified yet");
printf("RFC2347 Options support: %s\n",
@@ -692,7 +686,6 @@
static void
intr(int dummy __unused)
{
-
signal(SIGALRM, SIG_IGN);
alarm(0);
longjmp(toplevel, -1);
@@ -717,7 +710,6 @@
static const char *
command_prompt(void)
{
-
return ("tftp> ");
}
@@ -835,7 +827,6 @@
static void
quit(int argc __unused, char *argv[] __unused)
{
-
exit(txrx_error);
}
@@ -873,7 +864,6 @@
static void
setverbose(int argc __unused, char *argv[] __unused)
{
-
verbose = !verbose;
printf("Verbose mode %s.\n", verbose ? "on" : "off");
}
@@ -881,7 +871,6 @@
static void
setoptions(int argc, char *argv[])
{
-
if (argc == 2) {
if (strcasecmp(argv[1], "enable") == 0 ||
strcasecmp(argv[1], "on") == 0) {
@@ -911,7 +900,6 @@
static void
setrollover(int argc, char *argv[])
{
-
if (argc == 2) {
if (strcasecmp(argv[1], "never") == 0 ||
strcasecmp(argv[1], "none") == 0) {
@@ -962,7 +950,6 @@
static void
setblocksize(int argc, char *argv[])
{
-
if (!options_rfc_enabled)
printf("RFC2347 style options are not enabled "
"(but proceeding anyway)\n");
@@ -998,7 +985,6 @@
static void
setblocksize2(int argc, char *argv[])
{
-
if (!options_rfc_enabled || !options_extra_enabled)
printf(
"RFC2347 style or non-RFC defined options are not enabled "
@@ -1054,7 +1040,6 @@
static void
setpacketdrop(int argc, char *argv[])
{
-
if (argc != 1)
packetdroppercentage = atoi(argv[1]);
@@ -1065,7 +1050,6 @@
static void
setwindowsize(int argc, char *argv[])
{
-
if (!options_rfc_enabled)
printf("RFC2347 style options are not enabled "
"(but proceeding anyway)\n");
diff --git a/usr.bin/tftp/tftp.c b/usr.bin/tftp/tftp.c
--- a/usr.bin/tftp/tftp.c
+++ b/usr.bin/tftp/tftp.c
@@ -63,13 +63,13 @@
int
xmitfile(int peer, char *port, int fd, char *name, char *mode)
{
+ char recvbuffer[MAXPKTSIZE];
+ struct sockaddr_storage serv; /* valid server port number */
+ struct tftp_stats tftp_stats;
struct tftphdr *rp;
struct servent *se;
int n, i, ret = 0;
uint16_t block, portn;
- struct sockaddr_storage serv; /* valid server port number */
- char recvbuffer[MAXPKTSIZE];
- struct tftp_stats tftp_stats;
stats_init(&tftp_stats);
@@ -82,7 +82,7 @@
portn = htons(atoi(port));
if (portn == 0) {
printf("Invalid port '%s'.\n", port ? port : "tftp");
- return -1;
+ return (-1);
}
((struct sockaddr_in *)&peer_sock)->sin_port = portn;
@@ -96,7 +96,7 @@
n = send_wrq(peer, name, mode);
if (n > 0) {
printf("Cannot send WRQ packet\n");
- return -1;
+ return (-1);
}
/*
@@ -125,11 +125,11 @@
}
if (i == 12) {
printf("Transfer timed out.\n");
- return -1;
+ return (-1);
}
if (rp->th_opcode == ERROR) {
printf("Got ERROR, aborted\n");
- return -1;
+ return (-1);
}
/*
@@ -140,7 +140,7 @@
if (!options_rfc_enabled) {
printf("Got OACK while options are not enabled!\n");
send_error(peer, EBADOP);
- return -1;
+ return (-1);
}
parse_options(peer, rp->th_stuff, n + 2);
@@ -148,7 +148,7 @@
if (read_init(fd, NULL, mode) < 0) {
warn("read_init()");
- return -1;
+ return (-1);
}
block = 1;
@@ -158,7 +158,7 @@
read_close();
if (tftp_stats.amount > 0)
printstats("Sent", verbose, &tftp_stats);
- return ret;
+ return (ret);
}
/*
@@ -167,12 +167,12 @@
int
recvfile(int peer, char *port, int fd, char *name, char *mode)
{
+ char recvbuffer[MAXPKTSIZE];
+ struct tftp_stats tftp_stats;
struct tftphdr *rp;
struct servent *se;
- uint16_t block, portn;
- char recvbuffer[MAXPKTSIZE];
int n, i, ret = 0;
- struct tftp_stats tftp_stats;
+ uint16_t block, portn;
stats_init(&tftp_stats);
@@ -198,7 +198,7 @@
n = send_rrq(peer, name, mode);
if (n > 0) {
printf("Cannot send RRQ packet\n");
- return -1;
+ return (-1);
}
/*
@@ -227,16 +227,16 @@
}
if (i == 12) {
printf("Transfer timed out.\n");
- return -1;
+ return (-1);
}
if (rp->th_opcode == ERROR) {
tftp_log(LOG_ERR, "Error code %d: %s", rp->th_code, rp->th_msg);
- return -1;
+ return (-1);
}
if (write_init(fd, NULL, mode) < 0) {
warn("write_init");
- return -1;
+ return (-1);
}
/*
@@ -247,7 +247,7 @@
if (!options_rfc_enabled) {
printf("Got OACK while options are not enabled!\n");
send_error(peer, EBADOP);
- return -1;
+ return (-1);
}
parse_options(peer, rp->th_stuff, n + 2);
@@ -255,7 +255,7 @@
n = send_ack(peer, 0);
if (n > 0) {
printf("Cannot send ACK on OACK.\n");
- return -1;
+ return (-1);
}
block = 0;
if (tftp_receive(peer, &block, &tftp_stats, NULL, 0) != 0)
@@ -268,5 +268,5 @@
if (tftp_stats.amount > 0)
printstats("Received", verbose, &tftp_stats);
- return ret;
+ return (ret);
}

File Metadata

Mime Type
text/plain
Expires
Tue, May 26, 8:13 AM (6 h, 15 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33517000
Default Alt Text
D57073.diff (8 KB)

Event Timeline