Commit Graph
100 Commits
Author SHA1 Message Date
nhmall 4d09009fff Guidebook follow-up 2024-01-29 10:56:16 -05:00
nhmall b9bf956ec9 follow-up 2 for italic 2024-01-29 10:55:44 -05:00
nhmall d3dd9277f9 follow-up 1 for italic 2024-01-29 10:00:06 -05:00
nhmall 0dfe92ac61 more italic support
There might be some follow-ups to this.
2024-01-29 08:40:05 -05:00
nhmall bac8ebad34 revisit Makefile sysconf steps
Add distinct potential steps into Makefile.top for putting
sysconf into place, instead of appending the steps for doing so
to the generic POSTINSTALL.

SYSCONFINSTALL is used for 'make install' and unconditionally
copies sys/unix/sysconf to the install directory.

SYSCONFENSURE is used for 'make update' and only copies
sys/unix/sysconf to the installation directory if it doesn't
already exist.

The initial trigger for revisiting this was because of new reports
that cp from (GNU coreutils) 9.4 is now issuing a warning during
NetHack builds. The warning pertains to deprecated use of the '-n'
switch with cp, which is used to only copy the file if the target
does not exist.

After this update, the shell is used to make that determination,
and if the file doesn't exist, cp is now invoked on Linux without
the '-n' switch.

For the macOS hints file, macOS.370, cp wasn't being used for sysconf
anyway, a utility script was being invoked and this doesn't change
that. macOS.370 was updated to remain in sync with linux.370 and
Makefile.top regarding the use of SYSCONFINSTALL and SYSCONFENSURE.
2024-01-27 18:12:18 -05:00
nhmall fa672fa1ba some utf8map corrections
Correct a color value and remove an unnecessary variable
2024-01-25 16:45:58 -05:00
nhmall 8aadfd794c comment updates
The comments referred to the function pointer variable before those
changed names, so this assumes that they still should.
2024-01-24 18:51:12 -05:00
nhmall ebd09e94f6 nonnull update for m_harmless_trap()
Both arguments are immediately dereferenced.
2024-01-23 18:50:35 -05:00
nhmall b2f7c56e95 adjust comment wording for beyond 3.6 2024-01-23 11:00:23 -05:00
nhmall 7f8c7dda64 Merge branch 'rotten-rottables' of https://github.com/bitofhope/NetHack into NetHack-3.7 2024-01-22 11:08:30 -05:00
nhmall 81b45f92c8 static analyzer bit in sounds.c 2024-01-21 14:09:46 -05:00
nhmall d4f04fbdc8 static analyzer bit in options.c
Analyzer didn't like the use of strchr on an incomplete type.
Move the guts into a function in o_init.c.
2024-01-21 13:38:25 -05:00
nhmall 0b684339ef more vestiges of C(color) 2024-01-21 11:12:13 -05:00
nhmall 8f35e33a2e follow-up nonnull in u_init.c
u_init.c had had assessments for nonnull arguments on
its local functions carried out already.

A couple of new static functions added earlier today immediately
dereference their args, so declare those as nonnull.

This also gives a more self-describing name to one arg.
2024-01-21 09:48:36 -05:00
nhmall da4bf5a87e updated Guidebook.txt 2024-01-19 09:31:29 -05:00
nhmall 5ab9904b8f fix Guidebook.tex processing 2024-01-19 08:36:12 -05:00
nhmall a82317e364 update tested versions of Visual Studio 2024-01-17 2024-01-17 12:28:33 -05:00
nhmall c134a128ac rephrase rotten metal
Resolves #1202
2024-01-15 17:58:11 -05:00
nhmall bbb7523a04 vestiges of C(color) 2024-01-14 08:57:28 -05:00
nhmall 6274ad3259 whitespace adjustment src/nhlua.c
I noticed some tabs had crept into the file, so adjust the whitespace.
2024-01-12 12:33:26 -05:00
nhmall 213302d973 check def_monsyms[], def_oc_syms[] index
Resolves #1179
2024-01-11 20:13:02 -05:00
nhmall 9a0f9b37cb Merge branch 'fix-windows' of https://github.com/argrath/NetHack into NetHack-3.7 2024-01-11 19:50:12 -05:00
nhmall 97e4c0f34a another comment bit 2024-01-11 14:44:58 -05:00
nhmall 2fa996eb19 comment update/clarification 2024-01-11 14:19:28 -05:00
nhmall 25a8c258e6 replace x >= LOW_PM with ismnum(x) shorthand macro 2024-01-11 14:01:10 -05:00
nhmall f4055c5bc5 Merge branch 'toss_up_fix' of https://github.com/mkuoppal/NetHack into NetHack-3.7 2024-01-11 12:04:38 -05:00
nhmall 52940a4620 inappropriate null sobj check - pull request 1173 2024-01-08 23:59:41 -05:00
nhmall a764d4fd61 Merge branch 'fix-detect' of https://github.com/argrath/NetHack into NetHack-3.7 2024-01-08 23:45:53 -05:00
nhmall 3786b2c1d0 follow-up to restore.c 2024-01-07 14:38:03 -05:00
nhmall 132d642504 avoid alloc(0), read(fd,NULL,0), write(fd,NULL,0) 2024-01-07 14:30:53 -05:00
nhmall 3e1eeced1a CI update - take 4 2024-01-05 08:15:37 -05:00
nhmall 2b3938e45b CI update - take 3 2024-01-05 07:57:04 -05:00
nhmall 9cc5f54e96 CI update - take 2 2024-01-05 07:34:41 -05:00
nhmall 9b87881f0e update some builds in CI
- attempt build using ncurses6
- attempt build using qt6
2024-01-05 06:59:19 -05:00
nhmall c3ffc284ad uudecode follow-up 2024-01-05 06:25:47 -05:00
nhmall 4e19221e55 variable 'display' causes shadow variable warnings in X11 build
display.botl      -> disp.botl
display.botlx     -> disp.botlx
display.time_botl -> disp.time_botl
2024-01-05 05:58:51 -05:00
nhmall f8230eff4b quiet compiler warnings building sys/share/uudecode.c 2024-01-05 00:33:47 -05:00
nhmall 49a5d043c0 consistent use of TRUE vs 1 with botl and botlx 2024-01-04 23:48:38 -05:00
nhmall 22e52ee905 bundle the display-related hints, that tell bot() and others
that an update is required, into a struct. Remove it from
context since there is no reason to save those.
2024-01-04 23:16:27 -05:00
nhmall 1cc90d740f replace a wav file that was acting differently than rest 2024-01-04 00:10:44 -05:00
nhmall 6db79b9f18 Guidebook update 2024-01-02 12:34:05 -05:00
nhmall 00af468020 add specialized voice for an audio assistant 2024-01-01 12:43:53 -05:00
nhmall aeab3f69a6 update year in copyright to 2024 2024-01-01 11:04:26 -05:00
nhmall 76179ea0ba assert that u.ulevel is in range for use as index
Resolves #1189
2024-01-01 10:55:14 -05:00
nhmall 9d32956616 curses static analyzer bits
This is mostly just adding some Null guards ahead of
code that was already dereferencing pointers, so there
should be no change in behavior.

Also adds one validation of an array index that was
drawing a complaint.
2023-12-29 10:38:37 -05:00
nhmall bed3b1d667 fix typo in attrib.c
Closes #1187
2023-12-29 08:34:13 -05:00
nhmall 01d6d94e30 non-Null handling for uhitm.c 2023-12-29 00:34:37 -05:00
nhmall 9d2d437d0e follow-up comment bit 2023-12-28 19:25:49 -05:00
nhmall 719919b16a revisit destroy_armor()
add a static function maybe_destroy_armor() to replace
the DESTROY_ARM() macro.

The DESTROY_ARM() macro expanded to legal code, but did include
side-effects of making assignments to local variable otmp (not an
argument to the macro), referenced local variable atmp (not an
argument to the macro), and sometimes setting the in_use field
on the impacted armor obj.

The assignment statements within the if (...) caused some compilers
and code analyzers to complain and suggest that perhaps
'=' should have been '==', which was incorrect.

The maybe_destroy_armor() function provides the
caller with information about whether the armor resisted,
so that appropriate action can be taken within the caller.
2023-12-28 19:17:43 -05:00
nhmall 9f5f4b3c32 fix broken 'make install' with hints/linux.370 2023-12-28 11:45:36 -05:00
nhmall caf436934e NONNULLxxx for several files
src/date.c
src/mdlib.c
src/timeout.c
src/u_init.c
src/vault.c
src/version.c
src/windows.c
2023-12-27 20:11:59 -05:00
nhmall e69c98c14a Windows follow-up: minimize pragma scope
Avoid disruption to mingw32-x64 build, by placing
some Visual Studio pragmas in #ifdef _MSC_VER
conditional blocks.
2023-12-27 15:00:08 -05:00
nhmall 3eb0fab317 Windows error checking and warnings 2023-12-27 14:56:03 -05:00
nhmall 0927726900 static analyzer bit for trap.c
src/trap.c(5794): warning: Dereferencing NULL pointer 'which'.
2023-12-27 11:13:22 -05:00
nhmall d51e92d4bd static analyzer bit for symbols.c
src/symbols.c(532): warning: Dereferencing NULL pointer.
                             'tmpsp' contains the same NULL value as 'lastsp' did.
2023-12-27 11:10:35 -05:00
nhmall aedbebad18 static analyzer bit for shknam.c
src/shknam.c(530): warning: Dereferencing NULL pointer 'shname'.
2023-12-27 11:05:38 -05:00
nhmall 6e654cb9a5 static analyzer bits for restore.c
src/restore.c(275): warning: Dereferencing NULL pointer. 'otmp' contains the
                             same NULL value as 'first' did.
src/restore.c(402): warning: Dereferencing NULL pointer. 'mtmp' contains the
                             same NULL value as 'first' did.
2023-12-27 11:03:25 -05:00
nhmall e9ced6e2f9 static analyzer bit for priest.c
src/priest.c(865): warning: Dereferencing NULL pointer '((priest))->mextra->emin'.
2023-12-27 11:02:09 -05:00
nhmall 11c2586bdb static analyzer bit for pickup.c
src/pickup.c(3266): warning: Dereferencing NULL pointer 'otmp'.
2023-12-27 10:59:36 -05:00
nhmall 2f5fc70f02 static analyzer bits for pager.c
src/pager.c(209): warning: Dereferencing NULL pointer 'otmp'.
2023-12-27 10:56:00 -05:00
nhmall e138f497ff static analyzer bits for bones.c
src/bones.c(646): warning: Using uninitialized memory 'oldbonesid'.
src/bones.c(646): warning: String 'oldbonesid' might not be zero-terminated.

Also help prevent a buffer overflow on corrupt or ill-formed bones.
2023-12-27 10:49:21 -05:00
nhmall 80afc96def comment follow-up 2023-12-27 10:44:50 -05:00
nhmall 6d8c37b754 static analyzer bit for do_name.c
src/do_name.c(1494): warning C28183: 'aname' could be '0'
2023-12-27 10:40:02 -05:00
nhmall 5e6d2cd6b5 static analyzer bit for makemon.c
src/makemon.c(907): warning: Dereferencing NULL pointer '((mon))->mextra'.
2023-12-27 09:04:33 -05:00
nhmall 94b59cbd35 static analyzer bit for read.c
src/read.c(2889): warning: Dereferencing NULL pointer 'sobj'.

The analyzer doesn't know that the one caller that passes a NULL
sobj argument, angrygods(), checks !Punished before doing so.
Use a NULL guard before dereferencing sobj so that it doesn't
matter anyway.
2023-12-26 23:42:23 -05:00
nhmall 90d1e30ebd follow-up to display.c, add a comment 2023-12-26 13:48:56 -05:00
nhmall 9da895f285 fix build if UNBUFFERED_GLYPHINFO is defined
The reason this wasn't caught sooner was because the version
of the Glyphinfo_at(x,y,glyph) macro, that was defined when
UNBUFFERED_GLYPHINFO is not defined (when glyphinfo's are
buffered - the default), does not use the 3rd argument at
all.
2023-12-26 13:34:55 -05:00
nhmall 7b20c1fc98 static analyzer bit for weapon.c
src/weapon.c(451): warning: Dereferencing NULL pointer 'uleft'.

The analyzer couldn't tell that a STRANGE_OBJECT not being made of
SILVER material, was sufficient to guard against dereference of
NULL uleft or uright in the l_ag and r_ag assignments.

Test and dereference each once to set indicator booleans, and use
the booleans afterwards.
2023-12-26 11:27:34 -05:00
nhmall 36e8e504c2 another static analyzer bit for wield.c
src/wield.c(745): warning: Dereferencing NULL pointer 'obj'.
See line 685 for an earlier location where this can occur

In wield_tool(), the comparisons against uwep were intended
for when uwep wasn't null.

gcc/clang analyzers now have some awareness of obj arg being
notnull for wield_tool() since the extern.h prototypes
were changed to declare that, but other compilers/analyzers
do not necessarily have that information, and this:
    'if (obj == uwep)'
would be a match if both were NULL.
2023-12-24 15:38:06 -05:00
nhmall 3bc8af9836 static analyzer bit for wield.c
src/wield.c(254): warning: Dereferencing NULL pointer 'wep'.
See line 190 for an earlier location where this can occur

This seems to be a case where an unnecessary null test (A) caused
the analyzer to call into question whether or not wep
is null at (B):

    if (!wep) {
    } else if (wep->otyp == CORPSE && cant_wield_corpse(wep)) {
    } else if (uarms && bimanual(wep)) {
    } else if (!retouch_object(&wep, FALSE)) {
    } else {
        /* Weapon WILL be wielded after this point */
        if (will_weld(wep)) {
        } else {
        }
        if (was_twoweap && !u.twoweap && flags.verbose) {
        }
        /* KMH -- Talking artifacts are finally implemented */
A ==>   if (wep && wep->oartifact) {
        }
        if (artifact_light(wep) && !wep->lamplit) {
        }
B ==>   if (wep->unpaid) {
        }
    }

Removing the extraneous wep test from (A) resolves the complaint.
2023-12-24 14:47:08 -05:00
nhmall a30c5ceba2 static analyzer bit for makemon.c
src/makemon.c(918): warning: Dereferencing NULL pointer '((mon))->mextra'.
2023-12-24 00:40:48 -05:00
nhmall fbf8e0d5bc static analyzer warnings for mon.c
src/mon.c(2370): warning: Dereferencing NULL pointer '((mtmp2))->mextra->epri'.
src/mon.c(2375): warning: Dereferencing NULL pointer '((mtmp2))->mextra->eshk'.
src/mon.c(2380): warning: Dereferencing NULL pointer '((mtmp2))->mextra->emin'.
src/mon.c(2385): warning: Dereferencing NULL pointer '((mtmp2))->mextra->edog'.
src/mon.c(4419): warning: Dereferencing NULL pointer 'ga.animal_list'.
2023-12-24 00:36:21 -05:00
nhmall 547adae5f9 follow-up invent.c 2023-12-24 00:23:15 -05:00
nhmall 2e35f04c1d static analyzer bit for invent.c
src/invent.c(4882): warning: Dereferencing NULL pointer '((otmp))->oextra'.
2023-12-24 00:19:41 -05:00
nhmall 9b7694d2c5 static analyzer bit for ball.c
src/ball.c(50): warning C6011: Dereferencing NULL pointer 'uball'.
2023-12-23 23:14:17 -05:00
nhmall 93bcfeac29 static analyzer bit for artifact.c
src/artifact.c(1589): warning C6011: Dereferencing NULL pointer 'magr'.

The 'struct monst *magr' parameter to artifact_hit() can be Null
if 'mdef' is youmonst. mdef is nonnull.
2023-12-23 22:56:21 -05:00
nhmall 7e131649c4 static analyzer bit for rumors.c
src/rumors.c(800): warning: Dereferencing NULL pointer 'CapMons'.
2023-12-23 22:25:49 -05:00
nhmall 4f96accfb1 follow-up role.c 2023-12-23 14:07:03 -05:00
nhmall f3a9d91676 static analyzer bits in role.c
src/role.c(1543): warning: Reading invalid data from 'roles'.
src/role.c(1765): warning: Reading invalid data from 'roles'.
src/role.c(1780): warning: Reading invalid data from 'races'.
2023-12-23 13:56:56 -05:00
nhmall e9e05db113 add a pair of shorthand macros to validate an index into an array
Two variations:

IndexOk(idx, array)       validate that idx is a valid index into the array

IndexOkT(idx, array)      validate that idx is a valid index into the
                          array, excluding the final Terminator element
2023-12-23 13:46:54 -05:00
nhmall 415f8c559b static analyzer bit for monmove.c
src/monmove.c(1820): warning: Reading invalid data from 'info'.
2023-12-22 22:43:58 -05:00
nhmall 1c867ce528 another static analyzer bit for mkobj.c
src/mkobj.c(419): warning: '((obj2))->oextra->omonst' could be '0'
                : this does not adhere to the specification for the
                  function 'memcpy'.
src/mkobj.c(421): warning: Dereferencing NULL pointer
                  '((obj2))->oextra->omonst'.
                  See line 419 for an earlier location where this can occur

The analyzer was not aware that newoextra() sets up an oextra block:
    if (!obj2->oextra)
        obj2->oextra = newoextra();

The analyzer was also not aware that newomonst() was setting up a valid
OMONST pointer.
    if (!OMONST(obj2))
        newomonst(obj2);

Add an assert(has_omonst(obj2)) before copying the content from
OMONST(obj1) into OMONST(obj2).
2023-12-22 22:30:38 -05:00
nhmall d123cd77d1 static analyzer bit in mklev.c
src/mklev.c(137): warning: Using uninitialized memory 'ri'.

There was a for-loop assigning values to some elements of
ri[], but not all of them.

Initialize the array.
2023-12-22 22:02:18 -05:00
nhmall 4bc5e26082 static analyzer bit in files.c
src/files.c(4403): warning: Reading invalid data from 'buf'.
2023-12-22 21:47:48 -05:00
nhmall 18efc74db2 static analyzer bit in mkobj.c
src/mkobj.c(2211): warning: Reading invalid data from 'gl.level.objects[x]'.
2023-12-22 19:32:07 -05:00
nhmall a03a614883 include assert.h in cstd.h
Three src files already were including it, and another was
about to be added, so include it in include/cstd.h.
2023-12-22 19:24:09 -05:00
nhmall 48c067a6e9 follow-up bit options.c 2023-12-22 19:01:57 -05:00
nhmall 0cde312437 static analyzer bit in options.c
src/options.c(711): warning: Reading invalid data from 'roleoptvals[roleoptindx]'.

Validate the roleoptvals[][] array indexes to appease the static
analyzer.
2023-12-22 17:41:06 -05:00
nhmall d6f036f329 static analyzer bit in timeout.c
src/timeout.c(2033): warning: Reading invalid data from 'gl.level.locations'.

Analyzer couldn't tell that isok(x, y) had validated x and y to be
safe indexes into gl.level.locations[x][y].

Code it a bit differently, so that the static analyzer becomes perfectly
aware that the indexes are, indeed, in range.
2023-12-22 17:18:40 -05:00
nhmall fcc91cec94 static analyzer bit in uhitm.c
src/uhitm.c(1172): warning: Reading invalid data from 'mons'.

Analyzer wasn't happy with the index into mons[] array only
being validated by '!= -1'.

Update the check for the index to include the full array
index range, including ensuring that it is also '< NUMMONS'.
2023-12-22 16:30:24 -05:00
nhmall 51bf9dd76d comment typo 2023-12-22 14:57:50 -05:00
nhmall de8d1ef0d1 Merge branch 'NetHack-3.7' of https://rodney.nethack.org:20040/git/NHsource into NetHack-3.7 2023-12-22 14:38:33 -05:00
nhmall 746d00d170 assess wizard.c static functions for nonnull
No nonnull return attributes were appropriate for wizard.c section
of include/extern.h either.
2023-12-22 14:35:59 -05:00
nhmall 34d6cf105e zap.c, write.c, worn.c, worm.c nonnull returns 2023-12-22 13:54:51 -05:00
nhmall 92250aa15d assess worm.c static functions for nonnull 2023-12-22 13:18:04 -05:00
nhmall 741d2929b4 assess worn.c static functions for nonnull 2023-12-22 13:10:39 -05:00
nhmall 2542f9bada follow-up correction 2023-12-22 11:42:19 -05:00
nhmall c1fc52e644 assess write.c static functions for nonnull 2023-12-22 10:38:38 -05:00
nhmall 10e7f61380 assess zap.c static functions for nonnull 2023-12-22 10:34:15 -05:00
nhmall c3ce08b794 NO_NONNULLS -> NO_NNARGS
I find:
    extern char *an(const char *) NONNULL NO_NNARGS;

slightly better than this:
    extern char *an(const char *) NONNULL NO_NONNULLS;
2023-12-20 22:26:16 -05:00