tftpd: whitespace cleanup

This commit is contained in:
Dag-Erling Smørgrav 2022-11-17 16:09:58 +00:00
parent 9f9544fd92
commit bacb00ab40
12 changed files with 64 additions and 64 deletions

View file

@ -2,7 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (C) 2008 Edwin Groothuis. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -11,7 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

View file

@ -2,7 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (C) 2008 Edwin Groothuis. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -11,7 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

View file

@ -2,7 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (C) 2008 Edwin Groothuis. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -11,7 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -120,7 +120,7 @@ send_packet(int peer, uint16_t block, char *pkt, int size)
return (0);
}
tftp_log(LOG_ERR,
"%s block %d, attempt %d failed (Error %d: %s)",
"%s block %d, attempt %d failed (Error %d: %s)",
packettype(ntohs(((struct tftphdr *)(pkt))->th_opcode)),
block, i, errno, strerror(errno));
sleep(t);
@ -145,7 +145,7 @@ send_error(int peer, int error)
struct errmsg *pe;
char buf[MAXPKTSIZE];
if (debug&DEBUG_PACKETS)
if (debug & DEBUG_PACKETS)
tftp_log(LOG_DEBUG, "Sending ERROR %d", error);
DROPPACKET("send_error");
@ -165,7 +165,7 @@ send_error(int peer, int error)
tp->th_msg[length] = '\0';
length += 5;
if (debug&DEBUG_PACKETS)
if (debug & DEBUG_PACKETS)
tftp_log(LOG_DEBUG, "Sending ERROR %d: %s", error, tp->th_msg);
if (sendto(peer, buf, length, 0,
@ -185,7 +185,7 @@ send_wrq(int peer, char *filename, char *mode)
char buf[MAXPKTSIZE];
int size;
if (debug&DEBUG_PACKETS)
if (debug & DEBUG_PACKETS)
tftp_log(LOG_DEBUG, "Sending WRQ: filename: '%s', mode '%s'",
filename, mode
);
@ -233,7 +233,7 @@ send_rrq(int peer, char *filename, char *mode)
char buf[MAXPKTSIZE];
int size;
if (debug&DEBUG_PACKETS)
if (debug & DEBUG_PACKETS)
tftp_log(LOG_DEBUG, "Sending RRQ: filename: '%s', mode '%s'",
filename, mode
);
@ -282,7 +282,7 @@ send_oack(int peer)
char *bp;
char buf[MAXPKTSIZE];
if (debug&DEBUG_PACKETS)
if (debug & DEBUG_PACKETS)
tftp_log(LOG_DEBUG, "Sending OACK");
DROPPACKETn("send_oack", 0);
@ -328,7 +328,7 @@ send_ack(int fp, uint16_t block)
int size;
char buf[MAXPKTSIZE];
if (debug&DEBUG_PACKETS)
if (debug & DEBUG_PACKETS)
tftp_log(LOG_DEBUG, "Sending ACK for block %d", block);
DROPPACKETn("send_ack", 0);
@ -358,7 +358,7 @@ send_data(int peer, uint16_t block, char *data, int size)
struct tftphdr *pkt;
int n;
if (debug&DEBUG_PACKETS)
if (debug & DEBUG_PACKETS)
tftp_log(LOG_DEBUG, "Sending DATA packet %d of %d bytes",
block, size);
@ -399,7 +399,7 @@ receive_packet(int peer, char *data, int size, struct sockaddr_storage *from,
int n;
static int timed_out;
if (debug&DEBUG_PACKETS)
if (debug & DEBUG_PACKETS)
tftp_log(LOG_DEBUG,
"Waiting %d seconds for packet", timeoutpacket);
@ -462,7 +462,7 @@ receive_packet(int peer, char *data, int size, struct sockaddr_storage *from,
return (RP_ERROR);
}
if (debug&DEBUG_PACKETS)
if (debug & DEBUG_PACKETS)
tftp_log(LOG_DEBUG, "Received %d bytes in a %s packet",
n, packettype(pkt->th_opcode));

View file

@ -2,7 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (C) 2008 Edwin Groothuis. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -11,7 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

View file

@ -2,7 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (C) 2008 Edwin Groothuis. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -11,7 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -89,7 +89,7 @@ option_tsize(int peer __unused, struct tftphdr *tp __unused, int mode,
if (options[OPT_TSIZE].o_request == NULL)
return (0);
if (mode == RRQ)
if (mode == RRQ)
asprintf(&options[OPT_TSIZE].o_reply,
"%ju", (uintmax_t)stbuf->st_size);
else
@ -124,7 +124,7 @@ option_timeout(int peer)
}
settimeouts(timeoutpacket, timeoutnetwork, maxtimeouts);
if (debug&DEBUG_OPTIONS)
if (debug & DEBUG_OPTIONS)
tftp_log(LOG_DEBUG, "Setting timeout to '%s'",
options[OPT_TIMEOUT].o_reply);
@ -154,7 +154,7 @@ option_rollover(int peer)
options[OPT_ROLLOVER].o_reply =
strdup(options[OPT_ROLLOVER].o_request);
if (debug&DEBUG_OPTIONS)
if (debug & DEBUG_OPTIONS)
tftp_log(LOG_DEBUG, "Setting rollover to '%s'",
options[OPT_ROLLOVER].o_reply);
@ -215,7 +215,7 @@ option_blksize(int peer)
asprintf(&options[OPT_BLKSIZE].o_reply, "%d", size);
segsize = size;
pktsize = size + 4;
if (debug&DEBUG_OPTIONS)
if (debug & DEBUG_OPTIONS)
tftp_log(LOG_DEBUG, "Setting blksize to '%s'",
options[OPT_BLKSIZE].o_reply);
@ -269,7 +269,7 @@ option_blksize2(int peer __unused)
asprintf(&options[OPT_BLKSIZE2].o_reply, "%d", size);
segsize = size;
pktsize = size + 4;
if (debug&DEBUG_OPTIONS)
if (debug & DEBUG_OPTIONS)
tftp_log(LOG_DEBUG, "Setting blksize2 to '%s'",
options[OPT_BLKSIZE2].o_reply);
@ -304,7 +304,7 @@ option_windowsize(int peer)
asprintf(&options[OPT_WINDOWSIZE].o_reply, "%d", size);
windowsize = size;
if (debug&DEBUG_OPTIONS)
if (debug & DEBUG_OPTIONS)
tftp_log(LOG_DEBUG, "Setting windowsize to '%s'",
options[OPT_WINDOWSIZE].o_reply);
@ -368,7 +368,7 @@ parse_options(int peer, char *buffer, uint16_t size)
/* Parse the options */
cp = buffer;
options_failed = 0;
options_failed = 0;
while (size > 0) {
option = cp;
i = get_field(peer, cp, size);
@ -381,7 +381,7 @@ parse_options(int peer, char *buffer, uint16_t size)
/* We are at the end */
if (*option == '\0') break;
if (debug&DEBUG_OPTIONS)
if (debug & DEBUG_OPTIONS)
tftp_log(LOG_DEBUG,
"option: '%s' value: '%s'", option, value);

View file

@ -2,7 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (C) 2008 Edwin Groothuis. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -11,7 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

View file

@ -2,7 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (C) 2008 Edwin Groothuis. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -11,7 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -76,7 +76,7 @@ tftp_send(int peer, uint16_t *block, struct tftp_stats *ts)
acktry = 0;
do {
read_block:
if (debug&DEBUG_SIMPLE)
if (debug & DEBUG_SIMPLE)
tftp_log(LOG_DEBUG, "Sending block %d (window block %d)",
*block, windowblock);
@ -138,7 +138,7 @@ tftp_send(int peer, uint16_t *block, struct tftp_stats *ts)
}
/* Either read failure or ERROR packet */
if (debug&DEBUG_SIMPLE)
if (debug & DEBUG_SIMPLE)
tftp_log(LOG_ERR, "Aborting: %s",
rp_strerror(n_ack));
goto abort;
@ -155,7 +155,7 @@ tftp_send(int peer, uint16_t *block, struct tftp_stats *ts)
if (i == windowblock) {
/* Did not recognize ACK. */
if (debug&DEBUG_SIMPLE)
if (debug & DEBUG_SIMPLE)
tftp_log(LOG_DEBUG,
"ACK %d out of window",
rp->th_block);
@ -180,7 +180,7 @@ tftp_send(int peer, uint16_t *block, struct tftp_stats *ts)
/* ACKed at least some data. */
acktry = 0;
for (j = 0; j <= i; j++) {
if (debug&DEBUG_SIMPLE)
if (debug & DEBUG_SIMPLE)
tftp_log(LOG_DEBUG,
"ACKed block %d",
window[j].block);
@ -193,7 +193,7 @@ tftp_send(int peer, uint16_t *block, struct tftp_stats *ts)
* un-ACKed block.
*/
if (i + 1 != windowblock) {
if (debug&DEBUG_SIMPLE)
if (debug & DEBUG_SIMPLE)
tftp_log(LOG_DEBUG,
"Partial ACK");
if (seek_file(window[i + 1].offset) !=
@ -307,7 +307,7 @@ tftp_receive(int peer, uint16_t *block, struct tftp_stats *ts,
}
for (retry = 0; ; retry++) {
if (debug&DEBUG_SIMPLE)
if (debug & DEBUG_SIMPLE)
tftp_log(LOG_DEBUG,
"Receiving DATA block %d (window block %d)",
*block, windowblock);
@ -331,7 +331,7 @@ tftp_receive(int peer, uint16_t *block, struct tftp_stats *ts,
}
/* Either read failure or ERROR packet */
if (debug&DEBUG_SIMPLE)
if (debug & DEBUG_SIMPLE)
tftp_log(LOG_DEBUG, "Aborting: %s",
rp_strerror(n_data));
goto abort;
@ -357,7 +357,7 @@ tftp_receive(int peer, uint16_t *block, struct tftp_stats *ts,
windowstart = 0;
if (rp->th_block > windowstart &&
rp->th_block < *block) {
if (debug&DEBUG_SIMPLE)
if (debug & DEBUG_SIMPLE)
tftp_log(LOG_DEBUG,
"Ignoring duplicate DATA block %d",
rp->th_block);
@ -365,7 +365,7 @@ tftp_receive(int peer, uint16_t *block, struct tftp_stats *ts,
retry = 0;
continue;
}
tftp_log(LOG_WARNING,
"Expected DATA block %d, got block %d",
*block, rp->th_block);
@ -423,7 +423,7 @@ tftp_receive(int peer, uint16_t *block, struct tftp_stats *ts,
continue;
}
if (debug&DEBUG_SIMPLE)
if (debug & DEBUG_SIMPLE)
tftp_log(LOG_DEBUG, "Sent ACK for %d", *block);
windowblock = 0;
break;

View file

@ -2,7 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (C) 2008 Edwin Groothuis. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -11,7 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

View file

@ -2,7 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (C) 2008 Edwin Groothuis. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -11,7 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@ -66,11 +66,11 @@ int
settimeouts(int _timeoutpacket, int _timeoutnetwork, int _maxtimeouts __unused)
{
int i;
/* We cannot do impossible things */
if (_timeoutpacket >= _timeoutnetwork)
return (0);
maxtimeouts = 0;
i = _timeoutpacket;
while (i < _timeoutnetwork || maxtimeouts < MIN_TIMEOUTS) {

View file

@ -2,7 +2,7 @@
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (C) 2008 Edwin Groothuis. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@ -11,7 +11,7 @@
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE

View file

@ -300,7 +300,7 @@ main(int argc, char *argv[])
request_set(&req, RQ_DAEMON, "tftpd", 0);
if (hosts_access(&req) == 0) {
if (debug&DEBUG_ACCESS)
if (debug & DEBUG_ACCESS)
tftp_log(LOG_WARNING,
"Access denied by 'tftpd' entry "
"in /etc/hosts.allow");
@ -321,7 +321,7 @@ main(int argc, char *argv[])
exit(1);
}
if (debug&DEBUG_ACCESS) {
if (debug & DEBUG_ACCESS) {
if (allow_ro)
tftp_log(LOG_WARNING,
"But allowed readonly access "
@ -332,7 +332,7 @@ main(int argc, char *argv[])
"via 'tftpd-wo' entry");
}
} else
if (debug&DEBUG_ACCESS)
if (debug & DEBUG_ACCESS)
tftp_log(LOG_WARNING,
"Full access allowed"
"in /etc/hosts.allow");
@ -597,13 +597,13 @@ tftp_rrq(int peer, char *recvbuffer, ssize_t size)
n = receive_packet(peer, lrecvbuffer, MAXPKTSIZE,
NULL, timeoutpacket);
if (n < 0) {
if (debug&DEBUG_SIMPLE)
if (debug & DEBUG_SIMPLE)
tftp_log(LOG_DEBUG, "Aborting: %s",
rp_strerror(n));
return;
}
if (rp->th_opcode != ACK) {
if (debug&DEBUG_SIMPLE)
if (debug & DEBUG_SIMPLE)
tftp_log(LOG_DEBUG,
"Expected ACK, got %s on OACK",
packettype(rp->th_opcode));
@ -668,7 +668,7 @@ find_next_name(char *filename, int *fd)
for (i = 0; i < 100; i++) {
sprintf(newname, "%s.%s.%02d", filename, yyyymmdd, i);
*fd = open(newname,
O_WRONLY | O_CREAT | O_EXCL,
O_WRONLY | O_CREAT | O_EXCL,
S_IRUSR | S_IWUSR | S_IRGRP |
S_IWGRP | S_IROTH | S_IWOTH);
if (*fd > 0)
@ -789,8 +789,8 @@ validate_access(int peer, char **filep, int mode)
return (error + 100);
} else
fd = open(filename,
O_WRONLY | O_TRUNC | O_CREAT,
S_IRUSR | S_IWUSR | S_IRGRP |
O_WRONLY | O_TRUNC | O_CREAT,
S_IRUSR | S_IWUSR | S_IRGRP |
S_IWGRP | S_IROTH | S_IWOTH );
} else
fd = open(filename, O_WRONLY | O_TRUNC);
@ -814,14 +814,14 @@ tftp_xmitfile(int peer, const char *mode)
memset(&ts, 0, sizeof(ts));
now = time(NULL);
if (debug&DEBUG_SIMPLE)
if (debug & DEBUG_SIMPLE)
tftp_log(LOG_DEBUG, "Transmitting file");
read_init(0, file, mode);
block = 1;
tftp_send(peer, &block, &ts);
read_close();
if (debug&DEBUG_SIMPLE)
if (debug & DEBUG_SIMPLE)
tftp_log(LOG_INFO, "Sent %jd bytes in %jd seconds",
(intmax_t)ts.amount, (intmax_t)time(NULL) - now);
}
@ -834,7 +834,7 @@ tftp_recvfile(int peer, const char *mode)
struct tftp_stats ts;
gettimeofday(&now1, NULL);
if (debug&DEBUG_SIMPLE)
if (debug & DEBUG_SIMPLE)
tftp_log(LOG_DEBUG, "Receiving file");
write_init(0, file, mode);
@ -844,7 +844,7 @@ tftp_recvfile(int peer, const char *mode)
gettimeofday(&now2, NULL);
if (debug&DEBUG_SIMPLE) {
if (debug & DEBUG_SIMPLE) {
double f;
if (now1.tv_usec > now2.tv_usec) {
now2.tv_usec += 1000000;

View file

@ -96,7 +96,7 @@ xmitfile(int peer, char *port, int fd, char *name, char *mode)
struct sockaddr_storage from;
/* Tell the other side what we want to do */
if (debug&DEBUG_SIMPLE)
if (debug & DEBUG_SIMPLE)
printf("Sending %s\n", name);
n = send_wrq(peer, name, mode);
@ -196,7 +196,7 @@ recvfile(int peer, char *port, int fd, char *name, char *mode)
struct sockaddr_storage from;
/* Tell the other side what we want to do */
if (debug&DEBUG_SIMPLE)
if (debug & DEBUG_SIMPLE)
printf("Requesting %s\n", name);
n = send_rrq(peer, name, mode);