Replace lowercase min/max macros with opr_min/max

The commit:
    "opr: replace MIN/MAX macros with opr_min/opr_max" (915c5cff16)
replaced all uses of the MIN and MAX macros with opr_min and opr_max.

Since we now have a consolidated version of opr_min and opr_max,
replace the min/max macros with opr_min and opr_max, except for the
files in src/WINNT (which can be handled in a future commit).

The exception are the min/max macros that are defined and used in the
external sources src/external/heimdal, which cannot be changed.

Change-Id: Ib7c91b4e59aaf76ab77f293016496d6179c23c88
Reviewed-on: https://gerrit.openafs.org/15825
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
This commit is contained in:
Cheyenne Wills 2024-10-10 05:31:39 -06:00 committed by Michael Meffie
parent 65290ac18b
commit 8e1e242ce4
22 changed files with 47 additions and 40 deletions

View File

@ -789,7 +789,7 @@ afspgin_setup_io_ranges(vfspage_t * vm_info, pgcnt_t bpages, k_off_t isize,
start_blk = dbd->dbd_data;
maxpage =
startindex + (bpages - (startindex + file_offset) % bpages);
maxpage = min(maxpage, multio_maxpage);
maxpage = opr_min(maxpage, multio_maxpage);
count =
expand_faultin_up(vm_info, dbdtype, bpages, maxpage,
1 /* count */ ,

View File

@ -2482,14 +2482,14 @@ afsd_run(void)
if (!filesSet) {
cacheFiles = cacheBlocks / 32; /* Assume 32k avg filesize */
cacheFiles = max(cacheFiles, 1000);
cacheFiles = opr_max(cacheFiles, 1000);
/* Always allow more files than chunks. Presume average V-file
* is ~67% of a chunk... (another guess, perhaps Honeyman will
* have a grad student write a paper). i is KILOBYTES.
*/
i = 1 << (chunkSize < 10 ? 0 : chunkSize - 10);
cacheFiles = max(cacheFiles, 1.5 * (cacheBlocks / i));
cacheFiles = opr_max(cacheFiles, 1.5 * (cacheBlocks / i));
/* never permit more files than blocks, while leaving space for
* VolumeInfo and CacheItems files. VolumeInfo is usually 20K,

View File

@ -461,7 +461,7 @@ Print_fs_CallBackStats(struct xstat_fs_ProbeResults *a_fs_Results)
a_fs_Results->collectionNumber, a_fs_Results->connP->hostName,
a_fs_Results->probeNum, printableTime);
numInt32s = min(numInt32s, sizeof(CbCounterStrings)/sizeof(*CbCounterStrings));
numInt32s = opr_min(numInt32s, sizeof(CbCounterStrings)/sizeof(*CbCounterStrings));
for (i=0; i<numInt32s; i++) {
fprintf(fs_outFD, "\t%10u %s\n", val[i], CbCounterStrings[i]);
}

View File

@ -1786,7 +1786,7 @@ save_FS_results_inCB(int a_newProbeCycle) /* start of a new probe cycle ? */
/* copy the probe data information */
tmp_fsPR->data.AFS_CollData_len =
min(xstat_fs_Results.data.AFS_CollData_len,
opr_min(xstat_fs_Results.data.AFS_CollData_len,
afsmon_fs_results_length[index]);
memcpy(tmp_fsPR->data.AFS_CollData_val,
xstat_fs_Results.data.AFS_CollData_val,
@ -2650,7 +2650,7 @@ save_CM_results_inCB(int a_newProbeCycle) /* start of new probe cycle ? */
/* copy the probe data information */
tmp_cmPR->data.AFSCB_CollData_len =
min(xstat_cm_Results.data.AFSCB_CollData_len,
opr_min(xstat_cm_Results.data.AFSCB_CollData_len,
afsmon_cm_results_length[index]);
memcpy(tmp_cmPR->data.AFSCB_CollData_val,
xstat_cm_Results.data.AFSCB_CollData_val,

View File

@ -715,7 +715,7 @@ rxkad_build_native_token(krb5_context context, krb5_creds *v5cred,
}
}
#else
len = min(get_princ_len(context, v5cred->client, 0),
len = opr_min(get_princ_len(context, v5cred->client, 0),
second_comp(context, v5cred->client) ?
MAXKTCNAMELEN - 2 : MAXKTCNAMELEN - 1);
strncpy(username, get_princ_str(context, v5cred->client, 0), len);
@ -724,7 +724,7 @@ rxkad_build_native_token(krb5_context context, krb5_creds *v5cred,
if (second_comp(context, v5cred->client)) {
strcat(username, ".");
p = username + strlen(username);
len = min(get_princ_len(context, v5cred->client, 1),
len = opr_min(get_princ_len(context, v5cred->client, 1),
MAXKTCNAMELEN - strlen(username) - 1);
strncpy(p, get_princ_str(context, v5cred->client, 1), len);
p[len] = '\0';

View File

@ -593,7 +593,7 @@ GetToken(struct ktc_principal *aserver, struct ktc_token *atoken,
== 0)
&& (strcmp(local_tokens[i].server.cell, aserver->cell) == 0)) {
memcpy(atoken, &local_tokens[i].token,
min(atokenLen, sizeof(struct ktc_token)));
opr_min(atokenLen, sizeof(struct ktc_token)));
if (aclient)
*aclient = local_tokens[i].client;
UNLOCK_GLOBAL_MUTEX;
@ -624,7 +624,7 @@ GetToken(struct ktc_principal *aserver, struct ktc_token *atoken,
if (aclient)
strcpy(aclient->cell, lcell);
memcpy(atoken, &ctoken,
min(atokenLen, sizeof(struct ktc_token)));
opr_min(atokenLen, sizeof(struct ktc_token)));
afs_tf_close();
UNLOCK_GLOBAL_MUTEX;

View File

@ -984,7 +984,7 @@ GetLocalToken(struct ktc_principal *aserver, struct ktc_token *atoken,
0)
&& (strcmp(local_tokens[i].server.cell, aserver->cell) == 0)) {
memcpy(atoken, &local_tokens[i].token,
min(atokenLen, sizeof(struct ktc_token)));
opr_min(atokenLen, sizeof(struct ktc_token)));
memcpy(aclient, &local_tokens[i].client,
sizeof(struct ktc_principal));
UNLOCK_GLOBAL_MUTEX;

View File

@ -12,6 +12,7 @@
#include <afsconfig.h>
#include <afs/stds.h>
#include <afs/opr.h>
#include <roken.h>
#include <afs/cmd.h>
#include <afs/auth.h>
@ -581,7 +582,7 @@ bcdb_SaveTextFile(udbClientTextP ctPtr)
offset = 0;
while (fileSize != 0) {
chunkSize = min(fileSize, bufferSize);
chunkSize = opr_min(fileSize, bufferSize);
code =
fread(charList.charListT_val, sizeof(char), chunkSize,
ctPtr->textStream);

View File

@ -499,7 +499,7 @@ writeText(struct ubik_trans *ut, int fid, int textType)
if (code)
ERROR(code);
writeSize = min(textSize, BLOCK_DATA_SIZE);
writeSize = opr_min(textSize, BLOCK_DATA_SIZE);
if (!writeSize)
break;

View File

@ -10,6 +10,7 @@
#include <afsconfig.h>
#include <afs/param.h>
#include <afs/opr.h>
#include <roken.h>
#include <ubik.h>
@ -110,7 +111,7 @@ GetText(struct rx_call *call, afs_uint32 lockHandle, afs_int32 textType,
/* compute minimum of remaining text or user buffer */
textRemaining = ntohl(tbPtr->size) - offset;
transferSize = min(textRemaining, maxLength);
transferSize = opr_min(textRemaining, maxLength);
/* allocate the transfer storage */
if (transferSize <= 0) {
@ -149,7 +150,7 @@ GetText(struct rx_call *call, afs_uint32 lockHandle, afs_int32 textType,
/* compute the data size to extract */
blockOffset = offset % BLOCK_DATA_SIZE;
textRemaining = BLOCK_DATA_SIZE - blockOffset;
chunkSize = min(textRemaining, transferSize);
chunkSize = opr_min(textRemaining, transferSize);
memcpy(textPtr, &block.a[blockOffset], chunkSize);
@ -365,7 +366,7 @@ SaveText(struct rx_call *call, afs_uint32 lockHandle, afs_int32 textType,
while (textLength) {
/* compute the transfer size */
remainingInBlock = (BLOCK_DATA_SIZE - (offset % BLOCK_DATA_SIZE));
chunkSize = min(remainingInBlock, textLength);
chunkSize = opr_min(remainingInBlock, textLength);
/* copy in the data */
memcpy(&diskBlock.a[offset % BLOCK_DATA_SIZE], textptr, chunkSize);
@ -466,7 +467,7 @@ saveTextToFile(struct ubik_trans *ut, struct textBlock *tbPtr)
totalSize = size = ntohl(tbPtr->size);
blockAddr = ntohl(tbPtr->textAddr);
while (size) {
chunkSize = min(BLOCK_DATA_SIZE, size);
chunkSize = opr_min(BLOCK_DATA_SIZE, size);
dbread(ut, blockAddr, (char *)&block, sizeof(block));
if (write(fid, &block.a[0], chunkSize) < 0)
break;

View File

@ -1538,7 +1538,7 @@ ObjectDescriptor *BSAobjDescP
for that max len as well. For now these are the same value.
================================================================*/
if (strlen(BSAqryDescP->objName.pathName) >
min(DSM_MAX_HL_LENGTH, BSA_MAX_PATHNAME))
opr_min(DSM_MAX_HL_LENGTH, BSA_MAX_PATHNAME))
{
sprintf(traceStr2, "BSAQueryObject: pathName too long (%" AFS_SIZET_FMT ")",
strlen(BSAqryDescP->objName.pathName));
@ -2423,7 +2423,7 @@ BSA_Int16 BSACreateObject(
check for that max len as well. For now these are the same value.
=================================================================*/
if (strlen(BSAobjDescP->objName.pathName) >
min(DSM_MAX_HL_LENGTH, BSA_MAX_PATHNAME))
opr_min(DSM_MAX_HL_LENGTH, BSA_MAX_PATHNAME))
{
sprintf(traceStr2, "BSACreateObject: pathName too long (%" AFS_SIZET_FMT ")",
strlen(BSAobjDescP->objName.pathName));
@ -2755,7 +2755,7 @@ BSA_Int16 BSAMarkObjectInactive(
check for that max len as well. For now these are the same value.
=============================================================== */
if (strlen(BSAobjNameP->pathName) >
min(DSM_MAX_HL_LENGTH, BSA_MAX_PATHNAME))
opr_min(DSM_MAX_HL_LENGTH, BSA_MAX_PATHNAME))
{
sprintf(traceStr2, "BSAMarkObjectInactive: pathName too long (%" AFS_SIZET_FMT ")",
strlen(BSAobjNameP->pathName));

View File

@ -700,7 +700,7 @@ ChangePassWord(struct rx_call *call, char *aname, char *ainstance,
if ((code = DES_key_sched(ktc_to_cblock(&tentry.key), &user_schedule)))
es_Report("In KAChangePassword: key_sched returned %d\n", code);
DES_pcbc_encrypt(arequest->SeqBody, &request,
min(arequest->SeqLen, sizeof(request)), &user_schedule,
opr_min(arequest->SeqLen, sizeof(request)), &user_schedule,
ktc_to_cblockptr(&tentry.key), DECRYPT);
/* validate the request */
@ -1101,7 +1101,7 @@ Authenticate(int version, struct rx_call *call, char *aname, char *ainstance,
if ((code = DES_key_sched(ktc_to_cblock(&tentry.key), &user_schedule)))
es_Report("In KAAuthenticate: key_sched returned %d\n", code);
DES_pcbc_encrypt(arequest->SeqBody, &request,
min(arequest->SeqLen, sizeof(request)), &user_schedule,
opr_min(arequest->SeqLen, sizeof(request)), &user_schedule,
ktc_to_cblockptr(&tentry.key), DECRYPT);
request.time = ntohl(request.time); /* reorder date */

View File

@ -2118,7 +2118,7 @@ scout_SetColumnWidths(struct cmd_item *a_width_item)
if (width > 0) {
int min_width = strlen(scout_underline[i]);
if (min_width) {
width = max(width, min_width);
width = opr_max(width, min_width);
}
scout_col_width[i] = width + 1;
}

View File

@ -15,6 +15,7 @@
#include <sys/stat.h>
#include <netdb.h>
#include <afs/opr.h>
#include <afs/afsint.h>
#define FSINT_COMMON_XG 1
#include <afs/afscbint.h>
@ -515,14 +516,14 @@ main(int argc, char **argv)
/*printf("%d bytes remaining\n",bytesremaining); */
if (slcl) {
if ((bytes =
read(sfd, databuffer, min(blksize, bytesremaining))) <= 0) {
read(sfd, databuffer, opr_min(blksize, bytesremaining))) <= 0) {
fetchcode = errno;
break;
}
} else {
if ((bytes =
rx_Read(scall, databuffer,
min(blksize, bytesremaining))) <= 0)
opr_min(blksize, bytesremaining))) <= 0)
break;
}
if (dlcl) {

View File

@ -94,7 +94,7 @@ guarantee_room(char **buf, size_t * size, size_t len)
if (*size > len)
return 0;
return expand_string(buf, size, min(*size * 2, len));
return expand_string(buf, size, opr_min(*size * 2, len));
}
static char *

View File

@ -33,6 +33,7 @@
#include <afsconfig.h>
#include <afs/param.h>
#include <afs/opr.h>
#include <stdio.h>
#include <stdlib.h>
@ -71,7 +72,7 @@ creat_files(int count, long startsize)
size_t len;
ssize_t ret;
len = min(sizeof(buf), size);
len = opr_min(sizeof(buf), size);
ret = write(fd, buf, len);
if (ret < 0)

View File

@ -9,6 +9,7 @@
#include <afsconfig.h>
#include <afs/param.h>
#include <afs/opr.h>
#include <afs/com_err.h>
@ -457,7 +458,7 @@ auth_to_cell(krb5_context context, char *user, char *cell, char *realm)
int len;
struct ktc_token atoken;
len = min(get_princ_len(context, v5cred->client, 0),
len = opr_min(get_princ_len(context, v5cred->client, 0),
second_comp(context, v5cred->client) ?
MAXKTCNAMELEN - 2 : MAXKTCNAMELEN - 1);
strncpy(username, get_princ_str(context, v5cred->client, 0), len);
@ -466,7 +467,7 @@ auth_to_cell(krb5_context context, char *user, char *cell, char *realm)
if (second_comp(context, v5cred->client)) {
strcat(username, ".");
p = username + strlen(username);
len = min(get_princ_len(context, v5cred->client, 1),
len = opr_min(get_princ_len(context, v5cred->client, 1),
MAXKTCNAMELEN - strlen(username) - 1);
strncpy(p, get_princ_str(context, v5cred->client, 1), len);
p[len] = '\0';

View File

@ -28,6 +28,7 @@
#include <afsconfig.h>
#include <afs/param.h>
#include <afs/opr.h>
#include <roken.h>
#include <afs/afsutil.h>
@ -133,7 +134,7 @@ util_addTableBodyRow(struct util_Table *Table, char **Contents) {
for (i=0;i<Table->numColumns;i++) {
strncpy(Table->Body[indx]->CellContents[i],Contents[i],\
UTIL_T_MAX_CELLCONTENT_LEN);
thisRowLength += min(strlen(Contents[i]),UTIL_T_MAX_CELLCONTENT_LEN);
thisRowLength += opr_min(strlen(Contents[i]),UTIL_T_MAX_CELLCONTENT_LEN);
}
if (thisRowLength > Table->RowLength)
Table->RowLength = thisRowLength;
@ -179,7 +180,7 @@ do_setTableRow(struct util_Table *Table, struct util_TableRow *aRow, char **Cont
return -1;
for (i=0;i<Table->numColumns;i++) {
strcpy(aRow->CellContents[i],Contents[i]);
thisRowLength += min(strlen(Contents[i]),UTIL_T_MAX_CELLCONTENT_LEN);
thisRowLength += opr_min(strlen(Contents[i]),UTIL_T_MAX_CELLCONTENT_LEN);
}
if (thisRowLength > Table->RowLength)
Table->RowLength = thisRowLength;

View File

@ -178,7 +178,7 @@ ih_Initialize(void)
*/
fdMaxCacheSize /= 4;
#endif
fdMaxCacheSize = min(fdMaxCacheSize, vol_io_params.fd_max_cachesize);
fdMaxCacheSize = opr_min(fdMaxCacheSize, vol_io_params.fd_max_cachesize);
opr_Assert(fdMaxCacheSize > 0);
}
#elif defined(AFS_HPUX_ENV)
@ -186,12 +186,12 @@ ih_Initialize(void)
fdMaxCacheSize = 0;
#else
{
long fdMax = max(sysconf(_SC_OPEN_MAX) - vol_io_params.fd_handle_setaside,
long fdMax = opr_max(sysconf(_SC_OPEN_MAX) - vol_io_params.fd_handle_setaside,
0);
fdMaxCacheSize = (int)min(fdMax, vol_io_params.fd_max_cachesize);
fdMaxCacheSize = (int)opr_min(fdMax, vol_io_params.fd_max_cachesize);
}
#endif
fdCacheSize = min(fdMaxCacheSize, vol_io_params.fd_initial_cachesize);
fdCacheSize = opr_min(fdMaxCacheSize, vol_io_params.fd_initial_cachesize);
}
/* Make the file descriptor cache as big as possible. Don't this call

View File

@ -229,7 +229,7 @@ handleit(struct cmd_syndesc *opts, void *arock)
free(optstring);
optstring = NULL;
} else {
Parallel = min(DEFAULT_PARALLELISM, MAXPARALLEL);
Parallel = opr_min(DEFAULT_PARALLELISM, MAXPARALLEL);
}
if (cmd_OptionAsString(opts, OPT_tmpdir, &optstring) == 0) {
DIR *dirp;

View File

@ -693,7 +693,7 @@ VInitAttachVolumes(ProgramType pt)
queue_Append(&params,dpq);
}
threads = min(parts, vol_attach_threads);
threads = opr_min(parts, vol_attach_threads);
if (threads > 1) {
/* spawn off a bunch of initialization threads */
@ -819,7 +819,7 @@ VInitAttachVolumes(ProgramType pt)
}
/* number of worker threads; at least one, not to exceed the number of partitions */
threads = min(parts, vol_attach_threads);
threads = opr_min(parts, vol_attach_threads);
/* create volume work queue */
queue_Init(&vq);

View File

@ -10,6 +10,7 @@
#include <afsconfig.h>
#include <afs/param.h>
#include <afs/opr.h>
#include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
#include <roken.h>
@ -685,10 +686,10 @@ UV_CreateVolume3(afs_uint32 aserver, afs_int32 apart, char *aname,
/* If caller specified RW id, but not RO/BK ids, have them be RW+1 and RW+2 */
lastid = *anewid;
if (aroid && *aroid != 0) {
lastid = max(lastid, *aroid);
lastid = opr_max(lastid, *aroid);
}
if (abkid && *abkid != 0) {
lastid = max(lastid, *abkid);
lastid = opr_max(lastid, *abkid);
}
if (aroid && *aroid == 0) {
*aroid = ++lastid;