summaryrefslogtreecommitdiffhomepage
path: root/src/mvsfmt.c
diff options
context:
space:
mode:
authorSean Kurtz <seankurtz75@gmail.com>2026-11-25 00:30:44 -0600
committerSean Kurtz <seankurtz75@gmail.com>2026-11-25 00:30:44 -0600
commit5f92e02ff71be19067a422d324beb610cacd084d (patch)
tree1af510b0e4b9e3de95b18f476a6ebff2f109c488 /src/mvsfmt.c
parent7a7320b6a0d7dd6864b708b7e74fb5032a5bdf8e (diff)
downloadzash-chore/c23-nullptr-constexpr.tar.gz
C23: nullptr for null pointers, constexpr for typed constantschore/c23-nullptr-constexpr
nullptr in every place a null pointer constant was meant; NULL is gone from src/. constexpr where it improves on #define without costing anything: the IGGCSI00 work-area offsets and sizes, and the scalar sizes MVS_DSN_MAX, CSI_FIELD_LEN, CSI_WORK_MIN, PDS_DIRBLK, CSI_WORK, CSI_MAX_CALLS. A constexpr in C is a constant expression, so it still bounds the arrays that use it, and it now carries a type and can be checked with static_assert. Feature switches (#if), the CSIETYPE/EBCDIC byte constants read as octets, and the related-constant enum sets stay as they were.
Diffstat (limited to 'src/mvsfmt.c')
-rw-r--r--src/mvsfmt.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/mvsfmt.c b/src/mvsfmt.c
index 8424ac8..dc268b0 100644
--- a/src/mvsfmt.c
+++ b/src/mvsfmt.c
@@ -138,15 +138,15 @@ static void put32(unsigned char *p, uint32_t v) {
* | 152 | 2 | CSINUMEN | number of field names |
* | 154 | 8 | CSIFLDNM | field names |
*/
-#define CSIFILTK 0
-#define CSIDTYPS 132
-#define CSIRESUM 149
-#define CSIS1CAT 150
-#define CSINUMEN 152
-#define CSIFLDNM 154
+constexpr unsigned CSIFILTK = 0; /**< +0, length of the filter key */
+constexpr unsigned CSIDTYPS = 132; /**< entry types to return */
+constexpr unsigned CSIRESUM = 149; /**< Y: return error information */
+constexpr unsigned CSIS1CAT = 150; /**< Y: search one catalog only */
+constexpr unsigned CSINUMEN = 152; /**< number of field names */
+constexpr unsigned CSIFLDNM = 154; /**< field names, 8 each */
/* Return work area, the first field of it (see csi_parse()). */
-#define CSIREQLN 4
+constexpr unsigned CSIREQLN = 4; /**< length of the entry that failed */
/*
* Return work area: CSIUSRLN +0 (4, set by the caller), CSIREQLN +4,
@@ -156,12 +156,12 @@ static void put32(unsigned char *p, uint32_t v) {
* X'40') or, with halfword lengths, CSITOTLN (2) counting itself, two
* reserved bytes, one length per field and the fields.
*/
-#define CSIUSDLN 8
-#define CSI_FIRST 14
-#define CSIE_NAME 2
-#define CSIE_FIXED 46
-#define CSIE_RETINFO 50
-#define CSIENTER 0x40 /* CSIEFLAG: error, return information follows */
+constexpr unsigned CSIUSDLN = 8; /**< bytes of return information used */
+constexpr unsigned CSI_FIRST = 14; /**< offset of the first entry */
+constexpr unsigned CSIE_NAME = 2; /**< name, within an entry */
+constexpr unsigned CSIE_FIXED = 46; /**< bytes before the lengths */
+constexpr unsigned CSIE_RETINFO = 50; /**< bytes of an entry with return info */
+constexpr unsigned char CSIENTER = 0x40; /**< CSIEFLAG: error, return info follows */
#define EB_ZERO 0xf0 /* CSIETYPE of a catalog entry, EBCDIC '0' */
#define EB_Y 0xe8 /* EBCDIC 'Y' */
@@ -299,7 +299,7 @@ bool csi_parse(const unsigned char *work, size_t worklen, mvs_name_fn *fn,
* at -- and a broad filter on a big catalog is the one way this feature
* can put real work on catalog management.
*/
-#define CSI_MAX_CALLS 3
+constexpr int CSI_MAX_CALLS = 3; /**< searches before giving up */
/**
* @brief Search the catalog: build the criteria, call, decode, and