Skip to content
Permalink
Browse files

Cleanup: fsync(), rename() and uname() are POSIX.1-2001

 fsync(), rename() and uname() are POSIX.1-2001, so old code can be cleaned up.

* Modernize: rename() is C89, POSIX.1-2001
* Modernize: fsync() is C89, POSIX.1-2001
* Modernize: fsync() is POSIX.1-2001
  • Loading branch information...
michaelortmann authored and vanosg committed Jun 29, 2019
1 parent 92d7d3e commit 98799b300aebaf93592a48a577fb95a62a8b1b4c
Showing with 5 additions and 39 deletions.
  1. +1 −1 configure.ac
  2. +1 −7 src/chanprog.c
  3. +1 −8 src/misc.c
  4. +0 −8 src/misc_file.c
  5. +1 −3 src/mod/irc.mod/irc.c
  6. +0 −4 src/mod/irc.mod/msgcmds.c
  7. +1 −8 src/tclmisc.c
@@ -111,7 +111,7 @@ AX_TYPE_SOCKLEN_T
AX_CREATE_STDINT_H([eggint.h])

# Checks for functions and their arguments.
AC_CHECK_FUNCS([clock dprintf fsync getrandom getrusage inet_aton inet_ntop isascii random rand lrand48 rename setpgid snprintf strcasecmp strlcpy strncasecmp uname vsnprintf])
AC_CHECK_FUNCS([clock dprintf getrandom getrusage inet_aton inet_ntop isascii random rand lrand48 setpgid snprintf strcasecmp strlcpy strncasecmp vsnprintf])
AC_FUNC_SELECT_ARGTYPES
EGG_FUNC_VPRINTF
AC_FUNC_MMAP
@@ -35,9 +35,7 @@
# endif
#endif

#ifdef HAVE_UNAME
# include <sys/utsname.h>
#endif
#include <sys/utsname.h>

#include "modules.h"

@@ -291,19 +289,15 @@ void tell_verbose_status(int idx)
int i;
time_t now2 = now - online_since, hr, min;
double cputime, cache_total;
#ifdef HAVE_UNAME
struct utsname un;

if (uname(&un) < 0) {
#endif
vers_t = " ";
uni_t = "*unknown*";
#ifdef HAVE_UNAME
} else {
vers_t = un.release;
uni_t = un.sysname;
}
#endif

i = count_users(userlist);
dprintf(idx, "I am %s, running %s: %d user%s (mem: %uk).\n",
@@ -35,9 +35,7 @@
#include "tandem.h"
#include "modules.h"

#ifdef HAVE_UNAME
# include <sys/utsname.h>
#endif
#include <sys/utsname.h>

#include "stat.h"

@@ -807,10 +805,7 @@ void help_subst(char *s, char *nick, struct flag_record *flags,
struct chanset_t *chan;
int i, j, center = 0;
static int help_flags;

#ifdef HAVE_UNAME
struct utsname uname_info;
#endif

if (s == NULL) {
/* Used to reset substitutions */
@@ -900,13 +895,11 @@ void help_subst(char *s, char *nick, struct flag_record *flags,
}
break;
case 'U':
#ifdef HAVE_UNAME
if (uname(&uname_info) >= 0) {
egg_snprintf(sub, sizeof sub, "%s %s", uname_info.sysname,
uname_info.release);
towrite = sub;
} else
#endif
towrite = "*UNKNOWN*";
break;
case 'B':
@@ -70,9 +70,7 @@ int copyfile(char *oldpath, char *newpath)
}
}
}
#ifdef HAVE_FSYNC
fsync(fo);
#endif /* HAVE_FSYNC */
close(fo);
close(fi);
return 0;
@@ -121,9 +119,7 @@ int copyfilef(char *oldpath, FILE *newfile)
}
}

#ifdef HAVE_FSYNC
fsync(fileno(newfile));
#endif /* HAVE_FSYNC */
close(fi);

fseek(newfile, oripos, SEEK_SET);
@@ -171,9 +167,7 @@ int fcopyfile(FILE *oldfile, char *newpath)
}
}

#ifdef HAVE_FSYNC
fsync(fo);
#endif /* HAVE_FSYNC */
close(fo);

fseek(oldfile, oripos, SEEK_SET);
@@ -185,11 +179,9 @@ int movefile(char *oldpath, char *newpath)
{
int ret;

#ifdef HAVE_RENAME
/* Try to use rename first */
if (!rename(oldpath, newpath))
return 0;
#endif /* HAVE_RENAME */

/* If that fails, fall back to just copying and then
* deleting the file.
@@ -29,9 +29,7 @@
#include "server.mod/server.h"
#include "channels.mod/channels.h"

#ifdef HAVE_UNAME
# include <sys/utsname.h>
#endif
#include <sys/utsname.h>

static p_tcl_bind_list H_topc, H_splt, H_sign, H_rejn, H_part, H_pub, H_pubm;
static p_tcl_bind_list H_nick, H_mode, H_kick, H_join, H_need;
@@ -788,19 +788,15 @@ static int msg_status(char *nick, char *host, struct userrec *u, char *par)
struct chanset_t *chan;
time_t now2 = now - online_since, hr, min;

#ifdef HAVE_UNAME
struct utsname un;

if (uname(&un) < 0) {
#endif
vers_t = " ";
uni_t = "*unknown*";
#ifdef HAVE_UNAME
} else {
vers_t = un.release;
uni_t = un.sysname;
}
#endif

if (match_my_nick(nick))
return 1;
@@ -38,10 +38,7 @@
#endif

#include <sys/stat.h>

#ifdef HAVE_UNAME
# include <sys/utsname.h>
#endif
#include <sys/utsname.h>

extern p_tcl_bind_list bind_table_list;
extern tcl_timer_t *timer, *utimer;
@@ -574,19 +571,15 @@ static int tcl_unloadmodule STDVAR
static int tcl_unames STDVAR
{
char *unix_n, *vers_n;
#ifdef HAVE_UNAME
struct utsname un;

if (uname(&un) < 0) {
#endif
unix_n = "*unknown*";
vers_n = "";
#ifdef HAVE_UNAME
} else {
unix_n = un.sysname;
vers_n = un.release;
}
#endif
Tcl_AppendResult(irp, unix_n, " ", vers_n, NULL);
return TCL_OK;
}

0 comments on commit 98799b3

Please sign in to comment.
You can’t perform that action at this time.