to no longer be displayed. This was because the reimplementation of
setup_buffer() did not copy the previous contents into any reallocated
buffer.
Reported by: James Wright <james.wright@jigsawdezign.com>
PR: 236947
MFC after: 3 days
In line_update(), set lastcol correctly after moving to any non-zero
column, so the "overwrite old stuff" part does not attempt to address
negative offsets in the current line.
Rewrite setup_buffer() to always allocate at least 80 characters,
otherwise various calls to summary_format() will overwrite the end of
the buffers, if the screen width gets small enough.
MFC after: 1 week
Avoid setting zero bytes beyond the length of the 'thisline' parameters
in i_process() and u_process(), and don't attempt to memset a negative
number of bytes.
MFC after: 1 week
Encoding-specific processing introduced in r335836 is not recommended.
And doing getenv("LANG") and assuming an encoding based on it is a
very bad practice to internationalize software.
Submitted by: hrs
Differential Revision: https://reviews.freebsd.org/D16203
2nd argument of vsnprintf() to get the strlen of next_msg so that the
appropriate size is used.
Found with gcc.
/usr.bin/top/display.c: In function 'new_message':
/usr.bin/top/display.c:963:31: error:
argument to 'sizeof' in 'vsnprintf' call is the same expression as the
destination; did you mean to provide an explicit length?
[-Werror=sizeof-pointer-memaccess]
vsnprintf(next_msg, sizeof(next_msg), msgfmt, args);
Reviewed by: daichi
- initialize all maybe uninitialized vars with bogus values. This shuts
up the compiler, and causes crashes if it changes later.
- mark noreturn as noreturn
- removed unused macro
- handle x_procstate as runtime rather than pre-processor
- avoid using void functions in condtionals
Tested with clang, gcc 7, gcc 9
I had changed this from a for loop to a memset during an earlier
cleanup. This change was incorrect so revert it.
While here, clean up
Reported by: flo
- Change headers to more closely match what we use
- use more standard functions instead of bzero, bcmp, bcopy
- Add myself to authors.
Tested with: base clang (amd64), gcc 9 (amd64), base clang (i386), base
gcc (mips)
- avoid the need to call a function to get size of known array. I'll
likely re-arrange some of the indirect in a later to avoid the magic
constants.
- use correct type
- add const
- replace caddr_t with void*. This corrects an alignment warning.
- remove duplicated include from immediately prior commit
Under base clang we're now down to:
- 3 warning in top.c, 1 warning in mahcine.c, 4 warning in display.c,
- 1 warning in utils.c
Tested with base clang, gcc7, gcc9, base gcc (mips)
- Add const where helpful
- add missing 'static' for file-local functions
- use nitems where possible
- convert manual abort() to assert
- use strndup instead of homegrown version
Tested with clang, gcc7, and gcc9
- Prefer calloc over malloc. This is more predicable and we're not in a
performance sensitive context. [1]
- Remove bogus comment (obsolete from prior commit). [2]
- Remove void casts and type casts of NULL
- Remove redundant declaration of 'quit'
- Add additional const
Reported by: kib [1], vangyzen [2]
- Prefer using ansi prototypes rather than C prototypes
- Keep type on separate line from name of function
- Try to keep things const where possible. This will help get to WARNS=6
- switch to "bool" where it makes sense
Remove 'top.local.hs'. This was not noticed since
/srv/obj/fbsd/srv/src/freebsd/svn/head/amd64.amd64/usr.bin/top/top.local.h
existed locally on my machine despite "make clean". Only fully removing
the objdir allowed me to observe the error directly.
Pointyhat to: me
- Replace caddr_t with "void *". This reduces
the number of warnings at WARNS=6
- use "static" where possible
- sprinkle const where possible
This leaves at WARNS=6:
35 warnings in top.c
88 warnings in machine.c
7 warnings in commands.c
all of which are either "incompatible-pointer-types-discards-qualifiers"
or "cast-qual"
- Replace caddr_t with "void *". This reduces
the number of warnings at WARNS=6
- use "static" where possible
- sprinkle const where possible
This leaves at WARNS=6:
35 warnings in top.c
72 warnings in machine.c
5 warnings in commands.c
all of which are either "incompatible-pointer-types-discards-qualifiers"
or "cast-qual"
We've been maintaining top(1) for a long time, and the upstream
hasn't existed/been used in similarly as long. Make it clear that we own
top(1)
Tested with 'make universe'. Everything passed except MIPS which failed
for unrelated reasons. Install also tested for amd64.
Reviewed by: sbruno
No objections: imp, mmacy
Differential Revision: https://reviews.freebsd.org/D15387