1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Fix more compiler warnings, typos and other minor issues (#260)

Many of these changes are minor typo fixes. The other changes
(which are mostly compiler warning fixes) are:

NEWS:
- The --globcasedetect shell option works on older Linux kernels
  when used with FAT32/VFAT file systems, so remove the note about
  it only working with 5.2+ kernels.

src/cmd/ksh93/COMPATIBILITY:
- Update the documentation on function scoping with an addition
  from ksh93v- (this does apply to ksh93u+).

src/cmd/ksh93/edit/emacs.c:
- Check for '_AST_ksh_release', not 'AST_ksh_release'.

src/cmd/INIT/mamake.c,
src/cmd/INIT/ratz.c,
src/cmd/INIT/release.c,
src/cmd/builtin/pty.c:
- Add more uses of UNREACHABLE() and noreturn, this time for the
  build system and pty.

src/cmd/builtin/pty.c,
src/cmd/builtin/array.c,
src/cmd/ksh93/sh/name.c,
src/cmd/ksh93/sh/nvtype.c,
src/cmd/ksh93/sh/suid_exec.c:
- Fix six -Wunused-variable warnings (the name.c nv_arrayptr()
  fixes are also in ksh93v-).
- Remove the unused 'tableval' function to fix a -Wunused-function
  warning.

src/cmd/ksh93/sh/lex.c:
- Remove unused 'SHOPT_DOS' code, which isn't enabled anywhere.
  https://github.com/att/ast/issues/272#issuecomment-354363112

src/cmd/ksh93/bltins/misc.c,
src/cmd/ksh93/bltins/trap.c,
src/cmd/ksh93/bltins/typeset.c:
- Add dictionary generator function declarations for former
  aliases that are now builtins (re: 1fbbeaa1, ef1621c1, 3ba4900e).
- For consistency with the rest of the codebase, use '(void)'
  instead of '()' for print_cpu_times.

src/cmd/ksh93/sh/init.c,
src/lib/libast/path/pathshell.c:
- Move the otherwise unused EXE macro to pathshell() and only
  search for 'sh.exe' on Windows.

src/cmd/ksh93/sh/xec.c,
src/lib/libast/include/ast.h:
- Add an empty definition for inline when compiling with C89.
  This allows the timeval_to_double() function to be inlined.

src/cmd/ksh93/include/shlex.h:
- Remove the unused 'PIPESYM2' macro.

src/cmd/ksh93/tests/pty.sh:
- Add '# err_exit #' to count the regression test added in
  commit 113a9392.

src/lib/libast/disc/sfdcdio.c:
- Move diordwr, dioread, diowrite and dioexcept behind
  '#ifdef F_DIOINFO' to fix one -Wunused-variable warning and
  multiple -Wunused-function warnings (sfdcdio() only uses these
  functions when F_DIOINFO is defined).

src/lib/libast/string/fmtdev.c:
- Fix two -Wimplicit-function-declaration warnings on Linux by
  including sys/sysmacros.h in fmtdev().
This commit is contained in:
Johnothan King 2021-04-08 11:58:07 -07:00 committed by GitHub
parent ecf260c282
commit a065558291
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
96 changed files with 299 additions and 282 deletions

View file

@ -283,7 +283,7 @@
08-12-07 include/ast_std.h,misc/getenv.c: no _ast_getenv for uwin ast54 compatibility
08-12-07 tm/tmxfmt.c: add %[_][EO]K for [space pad] [full|long] iso
08-12-07 sfio/sfvscanf.c: fix ok[] short by one allocation
08-12-07 comp/setlocale.c: fix off by one composite initialition loop test
08-12-07 comp/setlocale.c: fix off by one composite initialization loop test
08-12-07 path/pathkey.c: fix off by one loop test
08-12-04 vmalloc/vmbest.c: catch sbrk() wraparound
08-12-04 comp/spawnveg.c: clean up attrs on failure too

View file

@ -42,6 +42,8 @@ typedef struct _direct_s
/* convert a pointer to an int */
#define P2I(p) (Sfulong_t)((char*)(p) - (char*)0)
#ifdef F_DIOINFO
#if __STD_C
static ssize_t diordwr(Sfio_t* f, Void_t* buf, size_t n, Direct_t* di, int type)
#else
@ -59,7 +61,6 @@ int type;
done = 0; /* amount processed by direct IO */
rv = 0;
#ifdef F_DIOINFO
if((P2I(buf)%di->dio.d_mem) == 0 &&
(f->here%di->dio.d_miniosz) == 0 && n >= di->dio.d_miniosz )
{ /* direct IO ok, make sure we're in the right mode */
@ -92,7 +93,6 @@ int type;
di->cntl &= ~FDIRECT;
(void)fcntl(f->file, F_SETFL, di->cntl);
}
#endif /*F_DIOINFO*/
if((rw = n-done) > 0 &&
(rv = type == SF_READ ? read(f->file,buf,rw) : write(f->file,buf,rw)) > 0 )
@ -141,18 +141,18 @@ Sfdisc_t* disc;
if(type == SF_FINAL || type == SF_DPOP)
{
#ifdef F_DIOINFO
if(di->cntl&FDIRECT)
{ di->cntl &= ~FDIRECT;
(void)fcntl(f->file,F_SETFL,di->cntl);
}
#endif
free(disc);
}
return 0;
}
#endif /* F_DIOINFO */
#if __STD_C
int sfdcdio(Sfio_t* f, size_t bufsize)
#else

View file

@ -202,6 +202,14 @@ typedef struct
#define FMT_EXP_NOCR 0x100 /* skip \r */
#define FMT_EXP_NONL 0x200 /* skip \n */
/*
* Define inline as an empty macro if we are
* compiling with C89.
*/
#if __STDC_VERSION__ < 199901L
#define inline
#endif
/*
* multibyte macros
*/

View file

@ -226,7 +226,7 @@ outputs an
prompt specified by
.I "format, .\|.\|."
to the controlling terminal and reads a response from the controlling terminal.
Offirmative response returns
Affirmative response returns
.LR 0 ,
.L EOF
or quit response returns

View file

@ -69,7 +69,7 @@ That is, \fIuserf\fP is called on a directory only after its descendants have
been processed.
The absence of this bit indicates that calls to the user functions
are issued in preorder. That is, \fIuserf\fP is
called on a directory before its descendants are processed.
called on a directory before its descendants are processed.
.IP
FTW_PHYSICAL: Use \fIlstat\fR(2) instead of \fIstat\fR(2) to get
file status and allow detection of symbolic links.

View file

@ -696,7 +696,7 @@ may result in undefined behavior.
.PP
.Ss " int sfgetc(Sfio_t* f)"
.Ss " int sfputc(Sfio_t* f, int c)"
These functions read/write a byte from/to stream \f5f\fP.
These functions read/write a byte from/to stream \f5f\fP.
\f5sfgetc()\fP returns the byte read or \f5-1\fP on error.
\f5sfputc()\fP returns \f5c\fP on success and \f5-1\fP on error.
@ -2356,8 +2356,8 @@ symbol may be removed in a future release.
The printing and scanning functions were extended to handle multibyte characters
and to conform to the C99 standard.
.PP
The function \f5sfpoll()\fP was rehauled to make it useful
for writing servers that must commnunicate with multiple streams
The function \f5sfpoll()\fP was overhauled to make it useful
for writing servers that must communicate with multiple streams
without blocking.
.PP
The formatting pattern \f5%c\fP for \f5sf*printf\fP was extended

View file

@ -284,7 +284,7 @@ events in a \fIregion\fP.
There are two standard disciplines, both with \f5round\fP being 0 and \f5exceptf\fP being \f5NULL\fP.
.TP
.MW Vmdcsystem
A discipline whose \f5memoryf\fP function gets space from the operation system
A discipline whose \f5memoryf\fP function gets space from the operation system
via different available methods which include \fImmap(2)\fP, \fIsbrk(2)\fP and
functions from the WIN32 API.
For historical reason, \fIVmdcsbrk\fP is also available and functions like \fIVmdcsystem\fP.
@ -523,7 +523,7 @@ A \f5Vmstat_t\fP structure has at least these members:
.MW "size_t m_free; /* maximum free block size */
.MW "int n_seg; /* count of segments */
.MW "size_t extent; /* memory extent of region */
.MW "int n_region; /* total Malloc regions */
.MW "int n_region; /* total Malloc regions */
.MW "int n_open; /* non-blocked operations */
.MW "int n_lock; /* blocked operations */
.MW "int n_probe; /* region searches */

View file

@ -47,6 +47,12 @@
* not done for `csh script arg ...'
*/
#ifdef _WINIX
# define EXE "?(.exe)"
#else
# define EXE
#endif
char*
pathshell(void)
{
@ -59,13 +65,13 @@ pathshell(void)
static char* val;
if ((sh = getenv("SHELL")) && *sh == '/' && strmatch(sh, "*/(sh|*[!cC]sh)*([[:digit:]])?(-+([.[:alnum:]]))?(.exe)"))
if ((sh = getenv("SHELL")) && *sh == '/' && strmatch(sh, "*/(sh|*[!cC]sh)*([[:digit:]])?(-+([.[:alnum:]]))" EXE))
{
if (!(ru = getuid()) || !eaccess("/bin", W_OK))
{
if (stat(sh, &st))
goto defshell;
if (ru != st.st_uid && !strmatch(sh, "?(/usr)?(/local)/?([ls])bin/?([[:lower:]])sh?(.exe)"))
if (ru != st.st_uid && !strmatch(sh, "?(/usr)?(/local)/?([ls])bin/?([[:lower:]])sh" EXE))
goto defshell;
}
else

View file

@ -57,7 +57,7 @@ int* peek;
}
/* buffer used during scanning of a double value or a multi-byte
character. the fields mirror certain local variables in sfvscanf. */
character. the fields mirror certain local variables in sfvscanf. */
typedef struct _scan_s
{ int error; /* get set by _sfdscan if no value specified */
int inp; /* last input character read */

View file

@ -30,6 +30,9 @@
#include <ast.h>
#include <ctype.h>
#include <ls.h>
#ifdef __linux__
#include <sys/sysmacros.h>
#endif
char*
fmtdev(struct stat* st)

View file

@ -465,7 +465,7 @@ static C_block PC2ROT[2][64/CHUNKBITS][1<<CHUNKBITS];
/* Initial permutation/expansion table */
static C_block IE3264[32/CHUNKBITS][1<<CHUNKBITS];
/* Table that combines the S, P, and E operations. */
/* Table that combines the S, P, and E operations. */
static long SPE[2][8][64];
/* compressed/interleaved => final permutation table */

View file

@ -248,7 +248,7 @@ sc1 = 9.97395106984001955652274773456e+000,
sc2 = 2.80952153365721279953959310660e+001,
sc3 = 2.19826478142545234106819407316e+001;
/*
* Coefficients for approximation to erfc in [4,28]
* Coefficients for approximation to erfc in [4,28]
*/
static double
rd0 = -2.1491361969012978677e-016, /* includes lsqrtPI_lo */
@ -280,7 +280,7 @@ extern double erf(x)
if (ax < .84375) {
if (ax < 3.7e-09) {
if (ax < 1.0e-308)
return 0.125*(8.0*x+p0t8*x); /*avoid underflow */
return 0.125*(8.0*x+p0t8*x); /* avoid underflow */
return x + p0*x;
}
y = x*x;

View file

@ -165,7 +165,7 @@ double x;
#endif
/* returns exp(r = x + c) for |c| < |x| with no overlap. */
/* returns exp(r = x + c) for |c| < |x| with no overlap. */
double __exp__D(x, c)
double x, c;

View file

@ -166,7 +166,7 @@ double x;
/* end of x < lnhuge */
else
/* expm1(INF) is INF, expm1(+big#) overflows to INF */
/* expm1(INF) is INF, expm1(+big#) overflows to INF */
return( finite(x) ? scalb(one,5000) : x);
}

View file

@ -57,7 +57,7 @@ static char sccsid[] = "@(#)log1p.c 8.1 (Berkeley) 6/4/93";
* Method :
* 1. Argument Reduction: find k and f such that
* 1+x = 2^k * (1+f),
* where sqrt(2)/2 < 1+f < sqrt(2) .
* where sqrt(2)/2 < 1+f < sqrt(2) .
*
* 2. Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
* = 2s + 2/3 s**3 + 2/5 s**5 + .....,

View file

@ -267,7 +267,7 @@ static int vmflinit()
return 0;
}
/* use multiple regions to reduce blocking by concurrent threads */
/* use multiple regions to reduce blocking by concurrent threads */
#if _mem_mmap_anon || _mem_mmap_zero
static Vmalloc_t *Region[64]; /* list of concurrent regions */
static unsigned int Regmax = 64; /* max number of regions */

View file

@ -430,7 +430,7 @@ struct _seg_s
#define DB2BEST(d) ((Vmuchar_t*)(d) - 2*sizeof(Head_t))
#define DB2DEBUG(b) ((Vmuchar_t*)(b) + 2*sizeof(Head_t))
/* set file and line number, note that DBLN > 0 so that DBISBAD will work */
/* set file and line number, note that DBLN > 0 so that DBISBAD will work */
#define DBSETFL(d,f,l) (DBFILE(d) = (f), DBLN(d) = (f) ? (l) : 1)
/* set and test the state of known to be corrupted */

View file

@ -57,7 +57,7 @@ static const char usage[] =
"converted back to the native encoding. Multibyte characters in the "
"current locale are treated as printable characters.]"
"[A:show-all?Equivalent to \b-vET\b.]"
"[B:squeeze-blank?Multiple adjacent new-line characters are replace by one"
"[B:squeeze-blank?Multiple adjacent new-line characters are replaced by one"
" new-line.]"
"[D:dos-output?Output files are opened in \atext\amode which inserts carriage"
" returns in front of new-lines on some systems.]"

View file

@ -43,7 +43,7 @@ static const char usage[] =
"to zero. \bfold\b will not insert a newline immediately "
"before or after a carriage-return.]"
"[+backspace?If positive, the current count of line width will be "
"decremented by one. \bfold\b will not insert a newline "
"decremented by one. \bfold\b will not insert a newline "
"immediately before or after a backspace.]"
"[+tab?Each tab character encountered will advance the column "
"position to the next tab stop. Tab stops are at each "

View file

@ -478,7 +478,7 @@ outfield(Join_t* jp, int index, register int n, int last)
{
register unsigned char* sp = jp->state;
/*eliminate leading spaces */
/* eliminate leading spaces */
if (jp->mb)
for (;;)
{

View file

@ -48,7 +48,7 @@ static const char usage[] =
"[+m?1 MiB.]"
"[+g?1 GiB.]"
"}"
"[+?For backwards compatibility, \b-\b\anumber\a is equivalent to "
"[+?For backwards compatibility, \b-\b\anumber\a is equivalent to "
"\b-n\b \anumber\a and \b+\b\anumber\a is equivalent to "
"\b-n -\b\anumber\a. \anumber\a may also have these option "
"suffixes: \bb c f g k l m r\b.]"

View file

@ -37,7 +37,7 @@ static const char usage[] =
"to standard output. If no \ainfile\a is given, or if the \ainfile\a "
"is \b-\b, \buniq\b reads from standard input with the start of "
"the file defined as the current offset.]"
"[c:count?Output the number of times each line occurred along with "
"[c:count?Output the number of times each line occurred along with "
"the line.]"
"[d:repeated|duplicates?Output the first of each duplicate line.]"
"[D:all-repeated?Output all duplicate lines as a group with an empty "

View file

@ -201,9 +201,9 @@ static const char id[] = "\n@(#)$Id: dll library (AT&T Research) 2010-10-20 $\0\
* its virtual origin and where it was
* actually placed
*/
/*N.B. o_sndata etc. are one based */
/* N.B. o_sndata etc. are one based */
datareloc = (ulong)data - hdr->s[hdr->a.o_sndata-1].s_vaddr;
/*hdr is address of header, not text, so add text s_scnptr */
/* hdr is address of header, not text, so add text s_scnptr */
textreloc = (ulong)hdr + hdr->s[hdr->a.o_sntext-1].s_scnptr
- hdr->s[hdr->a.o_sntext-1].s_vaddr;
ldhdr = (void*)((char*)hdr+ hdr->s[hdr->a.o_snloader-1].s_scnptr);

View file

@ -40,7 +40,7 @@
* ASSERT NOTE:
* Some sanity checking code is included using assert(). On my FreeBSD
* system, this additional code can be removed by compiling with NDEBUG
* defined. Check your own systems man page on assert() to see how to
* defined. Check your own system's man page on assert() to see how to
* compile WITHOUT the sanity checking code on your system.
*
* UNROLLED TRANSFORM LOOP NOTE: