Skip to content

Commit

Permalink
core: use uintXX_t instead of u_intXX_t
Browse files Browse the repository at this point in the history
Previously some portions of the code used the non-standard BSD u_intXX_t
type names. This patch changes these into the C99 standard conforming
uintXX_t instead.
  • Loading branch information
arogge committed May 25, 2020
1 parent f8c199d commit aa36725
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 51 deletions.
4 changes: 2 additions & 2 deletions core/src/filed/crypto.cc
Expand Up @@ -604,8 +604,8 @@ bool DecryptData(JobControlRecord* jcr,
/*
* Decrypt the input block
*/
if (!CryptoCipherUpdate(cipher_ctx->cipher, (const u_int8_t*)*data, *length,
(u_int8_t*)&cipher_ctx->buf[cipher_ctx->buf_len],
if (!CryptoCipherUpdate(cipher_ctx->cipher, (const uint8_t*)*data, *length,
(uint8_t*)&cipher_ctx->buf[cipher_ctx->buf_len],
&decrypted_len)) {
/*
* Decryption failed. Shouldn't happen.
Expand Down
40 changes: 20 additions & 20 deletions core/src/lib/bmtio.h
Expand Up @@ -123,7 +123,7 @@ struct mtget {
#if defined(__FreeBSD__)
int32_t mt_blksiz; /**< presently operating blocksize */
int32_t mt_density; /**< presently operating density */
u_int32_t mt_comp; /**< presently operating compression */
uint32_t mt_comp; /**< presently operating compression */
int32_t mt_blksiz0; /**< blocksize for mode 0 */
int32_t mt_blksiz1; /**< blocksize for mode 1 */
int32_t mt_blksiz2; /**< blocksize for mode 2 */
Expand All @@ -133,10 +133,10 @@ struct mtget {
int32_t mt_density2; /**< density for mode 2 */
int32_t mt_density3; /**< density for mode 3 */
/* the following are not yet implemented */
u_int32_t mt_comp0; /**< compression type for mode 0 */
u_int32_t mt_comp1; /**< compression type for mode 1 */
u_int32_t mt_comp2; /**< compression type for mode 2 */
u_int32_t mt_comp3; /**< compression type for mode 3 */
uint32_t mt_comp0; /**< compression type for mode 0 */
uint32_t mt_comp1; /**< compression type for mode 1 */
uint32_t mt_comp2; /**< compression type for mode 2 */
uint32_t mt_comp3; /**< compression type for mode 3 */
/* end not yet implemented */
#endif
int32_t mt_fileno; /**< relative file number of current position */
Expand All @@ -151,23 +151,23 @@ struct scsi_tape_errors {
* Check Condition noted for these operations. The act
* of issuing an MTIOCERRSTAT unlatches and clears them.
*/
u_int8_t io_sense[32]; /**< Last Sense Data For Data I/O */
uint8_t io_sense[32]; /**< Last Sense Data For Data I/O */
int32_t io_resid; /**< residual count from last Data I/O */
u_int8_t io_cdb[16]; /**< Command that Caused the Last Data Sense */
u_int8_t ctl_sense[32]; /**< Last Sense Data For Control I/O */
uint8_t io_cdb[16]; /**< Command that Caused the Last Data Sense */
uint8_t ctl_sense[32]; /**< Last Sense Data For Control I/O */
int32_t ctl_resid; /**< residual count from last Control I/O */
u_int8_t ctl_cdb[16]; /**< Command that Caused the Last Control Sense */
uint8_t ctl_cdb[16]; /**< Command that Caused the Last Control Sense */
/*
* These are the read and write cumulative error counters.
* (how to reset cumulative error counters is not yet defined).
* (not implemented as yet but space is being reserved for them)
*/
struct {
u_int32_t retries; /**< total # retries performed */
u_int32_t corrected; /**< total # corrections performed */
u_int32_t processed; /**< total # corrections successful */
u_int32_t failures; /**< total # corrections/retries failed */
u_int64_t nbytes; /**< total # bytes processed */
uint32_t retries; /**< total # retries performed */
uint32_t corrected; /**< total # corrections performed */
uint32_t processed; /**< total # corrections successful */
uint32_t failures; /**< total # corrections/retries failed */
uint64_t nbytes; /**< total # bytes processed */
} wterr, rderr;
};

Expand Down Expand Up @@ -213,18 +213,18 @@ union mterrstat {
* rethink these ioctls to support all the entities they haul into
* the picture (64 bit blocks, logical file record numbers, etc..).
*/
#define MTIOCRDSPOS _IOR('m', 5, u_int32_t) /**< get logical blk addr */
#define MTIOCRDHPOS _IOR('m', 6, u_int32_t) /**< get hardware blk addr */
#define MTIOCSLOCATE _IOW('m', 5, u_int32_t) /**< seek to logical blk addr */
#define MTIOCHLOCATE _IOW('m', 6, u_int32_t) /**< seek to hardware blk addr */
#define MTIOCRDSPOS _IOR('m', 5, uint32_t) /**< get logical blk addr */
#define MTIOCRDHPOS _IOR('m', 6, uint32_t) /**< get hardware blk addr */
#define MTIOCSLOCATE _IOW('m', 5, uint32_t) /**< seek to logical blk addr */
#define MTIOCHLOCATE _IOW('m', 6, uint32_t) /**< seek to hardware blk addr */
#define MTIOCERRSTAT _IOR('m', 7, union mterrstat) /**< get tape errors */
/*
* Set EOT model- argument is number of filemarks to end a tape with.
* Note that not all possible values will be accepted.
*/
#define MTIOCSETEOTMODEL _IOW('m', 8, u_int32_t)
#define MTIOCSETEOTMODEL _IOW('m', 8, uint32_t)
/* Get current EOT model */
#define MTIOCGETEOTMODEL _IOR('m', 8, u_int32_t)
#define MTIOCGETEOTMODEL _IOR('m', 8, uint32_t)

#ifndef _KERNEL
#define DEFTAPE "/dev/nsa0"
Expand Down
4 changes: 2 additions & 2 deletions core/src/lib/crypto_none.cc
Expand Up @@ -79,7 +79,7 @@ bool CryptoDigestUpdate(DIGEST* digest, const uint8_t* data, uint32_t length)
return true;
case CRYPTO_DIGEST_SHA1:
/* Doesn't return anything ... */
SHA1Update(&digest->sha1, (const u_int8_t*)data, (unsigned int)length);
SHA1Update(&digest->sha1, (const uint8_t*)data, (unsigned int)length);
return true;
default:
return false;
Expand All @@ -102,7 +102,7 @@ bool CryptoDigestFinalize(DIGEST* digest, uint8_t* dest, uint32_t* length)
* an out-of-sync CRYPTO_DIGEST_MAX_SIZE */
assert(*length >= CRYPTO_DIGEST_SHA1_SIZE);
*length = CRYPTO_DIGEST_SHA1_SIZE;
SHA1Final((u_int8_t*)dest, &digest->sha1);
SHA1Final((uint8_t*)dest, &digest->sha1);
return true;
default:
return false;
Expand Down
4 changes: 2 additions & 2 deletions core/src/lib/crypto_nss.cc
Expand Up @@ -81,7 +81,7 @@ bool CryptoDigestUpdate(DIGEST* digest, const uint8_t* data, uint32_t length)
return true;
case CRYPTO_DIGEST_SHA1:
/* Doesn't return anything ... */
SHA1Update(&digest->sha1, (const u_int8_t*)data, (unsigned int)length);
SHA1Update(&digest->sha1, (const uint8_t*)data, (unsigned int)length);
return true;
default:
return false;
Expand All @@ -104,7 +104,7 @@ bool CryptoDigestFinalize(DIGEST* digest, uint8_t* dest, uint32_t* length)
* an out-of-sync CRYPTO_DIGEST_MAX_SIZE */
assert(*length >= CRYPTO_DIGEST_SHA1_SIZE);
*length = CRYPTO_DIGEST_SHA1_SIZE;
SHA1Final((u_int8_t*)dest, &digest->sha1);
SHA1Final((uint8_t*)dest, &digest->sha1);
return true;
default:
return false;
Expand Down
2 changes: 1 addition & 1 deletion core/src/lib/scsi_lli.cc
Expand Up @@ -338,7 +338,7 @@ static inline bool do_scsi_cmd_page(int fd,
NULL, /* cbfcnp */
direction, /* flags */
MSG_SIMPLE_Q_TAG, /* tagaction */
(u_int8_t*)cmd_page, /* dataptr */
(uint8_t*)cmd_page, /* dataptr */
cmd_page_len, /* datalen */
sizeof(sense), /* senselength */
cdb_len, /* cdblength */
Expand Down
28 changes: 14 additions & 14 deletions core/src/lib/sha1.cc
Expand Up @@ -27,7 +27,7 @@ A million repetitions of "a"

#include "sha1.h"

void SHA1Transform(u_int32_t state[5], const u_int8_t buffer[64]);
void SHA1Transform(uint32_t state[5], const uint8_t buffer[64]);

#define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))

Expand Down Expand Up @@ -65,16 +65,16 @@ void SHA1Transform(u_int32_t state[5], const u_int8_t buffer[64]);

/* Hash a single 512-bit block. This is the core of the algorithm. */

void SHA1Transform(u_int32_t state[5], const u_int8_t buffer[64])
void SHA1Transform(uint32_t state[5], const uint8_t buffer[64])
{
u_int32_t a, b, c, d, e;
uint32_t a, b, c, d, e;
typedef union {
u_int8_t c[64];
u_int32_t l[16];
uint8_t c[64];
uint32_t l[16];
} CHAR64LONG16;
CHAR64LONG16* block;
#ifdef SHA1HANDSOFF
static u_int8_t workspace[64];
static uint8_t workspace[64];
block = (CHAR64LONG16*)workspace;
memcpy(block, buffer, 64);
#else
Expand Down Expand Up @@ -194,7 +194,7 @@ void SHA1Init(SHA1_CTX* context)

/* Run your data through this. */

void SHA1Update(SHA1_CTX* context, const u_int8_t* data, unsigned int len)
void SHA1Update(SHA1_CTX* context, const uint8_t* data, unsigned int len)
{
unsigned int i, j;

Expand All @@ -214,24 +214,24 @@ void SHA1Update(SHA1_CTX* context, const u_int8_t* data, unsigned int len)

/* Add padding and return the message digest. */

void SHA1Final(u_int8_t digest[20], SHA1_CTX* context)
void SHA1Final(uint8_t digest[20], SHA1_CTX* context)
{
u_int32_t i, j;
u_int8_t finalcount[8];
uint32_t i, j;
uint8_t finalcount[8];

for (i = 0; i < 8; i++) {
finalcount[i] =
(u_int8_t)((context->count[(i >= 4 ? 0 : 1)] >> ((3 - (i & 3)) * 8)) &
(uint8_t)((context->count[(i >= 4 ? 0 : 1)] >> ((3 - (i & 3)) * 8)) &
255); /* Endian independent */
}
SHA1Update(context, (u_int8_t*)"\200", 1);
SHA1Update(context, (uint8_t*)"\200", 1);
while ((context->count[0] & 504) != 448) {
SHA1Update(context, (u_int8_t*)"\0", 1);
SHA1Update(context, (uint8_t*)"\0", 1);
}
SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
for (i = 0; i < 20; i++) {
digest[i] =
(u_int8_t)((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255);
(uint8_t)((context->state[i >> 2] >> ((3 - (i & 3)) * 8)) & 255);
}
/* Wipe variables */
i = j = 0;
Expand Down
6 changes: 3 additions & 3 deletions core/src/lib/sha1.h
Expand Up @@ -15,13 +15,13 @@
#define SHA1_DIGEST_LENGTH 20

typedef struct {
u_int32_t state[5];
u_int32_t count[2];
uint32_t state[5];
uint32_t count[2];
unsigned char buffer[SHA1_BLOCK_LENGTH];
} SHA1_CTX;

void SHA1Init(SHA1_CTX* context);
void SHA1Transform(u_int32_t state[5],
void SHA1Transform(uint32_t state[5],
const unsigned char buffer[SHA1_BLOCK_LENGTH]);
void SHA1Update(SHA1_CTX* context, const unsigned char* data, unsigned int len);
void SHA1Final(unsigned char digest[SHA1_DIGEST_LENGTH], SHA1_CTX* context);
Expand Down
14 changes: 7 additions & 7 deletions core/src/ndmp/ndmos_freebsd.c
Expand Up @@ -174,11 +174,11 @@ ndmp9_error ndmos_scsi_execute_cdb(struct ndm_session* sess,
struct ndm_robot_agent* robot = sess->robot_acb;
struct cam_device* camdev = robot->camdev;
union ccb* ccb;
u_int32_t flags;
u_int8_t* data_ptr = 0;
u_int8_t* data_in_ptr = 0;
u_int32_t data_len = 0;
u_int32_t data_done;
uint32_t flags;
uint8_t* data_ptr = 0;
uint8_t* data_in_ptr = 0;
uint32_t data_len = 0;
uint32_t data_done;
int rc;

NDMOS_MACRO_ZEROFILL(reply);
Expand All @@ -203,7 +203,7 @@ ndmp9_error ndmos_scsi_execute_cdb(struct ndm_session* sess,
}

data_len = request->datain_len;
data_in_ptr = (u_int8_t*)malloc(data_len);
data_in_ptr = (uint8_t*)malloc(data_len);

if (!data_in_ptr) {
reply->error = NDMP9_NO_MEM_ERR;
Expand All @@ -215,7 +215,7 @@ ndmp9_error ndmos_scsi_execute_cdb(struct ndm_session* sess,

case NDMP9_SCSI_DATA_DIR_OUT:
data_len = request->dataout.dataout_len;
data_ptr = (u_int8_t*)request->dataout.dataout_val;
data_ptr = (uint8_t*)request->dataout.dataout_val;
flags = CAM_DIR_OUT;
break;

Expand Down

0 comments on commit aa36725

Please sign in to comment.