Hash :
f3d96537
Author :
Date :
2024-11-14T15:56:50
Eliminate gcc -Wzero-as-null-pointer-constant warnings. * lib/argp-help.c: Use NULL, not 0, to denote a null pointer. * lib/argp-parse.c: Likewise. * lib/backup-find.c (get_version): Likewise. * lib/bitset/list.c: Likewise. * lib/bitset/stats.c (bitset_stats_init): Likewise. * lib/bitset/table.c: Likewise. * lib/bitsetv.c (bitsetv_alloc): Likewise. * lib/error.c (print_errno_message): Likewise. * lib/exclude.c (new_exclude_segment): Likewise. * lib/getopt.c (GETOPT_ENTRY): Likewise. * lib/human.c (block_size_args): Likewise. * lib/obstack.c (_obstack_begin_worker, _obstack_newchunk, _obstack_allocated_p, _obstack_free, _obstack_memory_used): Likewise. * lib/quotearg.c (quoting_style_args, quotearg_buffer_restyled, quotearg_alloc_mem): Likewise. * lib/readutmp.c (read_utmp_from_file): Likewise. * lib/savedir.c (comparison_function_table): Likewise. * lib/settime.c (settime): Likewise. * tests/nap.h (nap_works): Likewise. * tests/test-fts.c (argv, fts_dealloc, remove_tree, main): Likewise. * tests/test-getaddrinfo.c (simple): Likewise. * tests/test-nstrftime.h (posixtm_test, TZ, quarter_test, errno_test, locales_test): Likewise. * tests/test-parse-datetime.c (main): Likewise. * tests/test-regex.c (main): Likewise.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
/* settime -- set the system clock
Copyright (C) 2002, 2004-2007, 2009-2024 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
#include <config.h>
#include "timespec.h"
#include <sys/time.h>
#include <unistd.h>
#include <errno.h>
/* Set the system time. */
int
settime (struct timespec const *ts)
{
#if defined CLOCK_REALTIME && HAVE_CLOCK_SETTIME
{
int r = clock_settime (CLOCK_REALTIME, ts);
if (r == 0 || errno == EPERM)
return r;
}
#endif
#if HAVE_SETTIMEOFDAY
{
struct timeval tv = { .tv_sec = ts->tv_sec,
.tv_usec = ts->tv_nsec / 1000 };
return settimeofday (&tv, NULL);
}
#elif HAVE_STIME
/* This fails to compile on OSF1 V5.1, due to stime requiring
a 'long int*' and tv_sec is 'int'. But that system does provide
settimeofday. */
return stime (&ts->tv_sec);
#else
errno = ENOSYS;
return -1;
#endif
}