malloc to calloc

This commit is contained in:
Jasmine Iwanek
2025-01-07 00:42:06 -05:00
parent f599e72114
commit 4e6f29a7d5
183 changed files with 245 additions and 493 deletions

View File

@@ -925,8 +925,7 @@ aha_setnvr(x54x_t *dev)
return;
/* Allocate and initialize the EEPROM. */
dev->nvr = (uint8_t *) malloc(NVR_SIZE);
memset(dev->nvr, 0x00, NVR_SIZE);
dev->nvr = (uint8_t *) calloc(1, NVR_SIZE);
fp = nvr_fopen(dev->nvr_path, "rb");
if (fp) {

View File

@@ -1546,8 +1546,7 @@ buslogic_init(const device_t *info)
dev = x54x_init(info);
dev->bus = scsi_get_bus();
dev->ven_data = malloc(sizeof(buslogic_data_t));
memset(dev->ven_data, 0x00, sizeof(buslogic_data_t));
dev->ven_data = calloc(1, sizeof(buslogic_data_t));
bl = (buslogic_data_t *) dev->ven_data;

View File

@@ -632,14 +632,10 @@ ncr53c400_init(const device_t *info)
{
const char *bios_ver = NULL;
const char *fn;
ncr53c400_t *ncr400;
ncr_t *ncr;
ncr53c400_t *ncr400 = calloc(1, sizeof(ncr53c400_t));
ncr_t *ncr = &ncr400->ncr;
scsi_bus_t *scsi_bus;
ncr400 = malloc(sizeof(ncr53c400_t));
memset(ncr400, 0x00, sizeof(ncr53c400_t));
ncr = &ncr400->ncr;
ncr400->type = info->local;
ncr->bus = scsi_get_bus();

View File

@@ -2530,10 +2530,7 @@ ncr53c8xx_pci_write(UNUSED(int func), int addr, uint8_t val, void *priv)
static void *
ncr53c8xx_init(const device_t *info)
{
ncr53c8xx_t *dev;
dev = malloc(sizeof(ncr53c8xx_t));
memset(dev, 0x00, sizeof(ncr53c8xx_t));
ncr53c8xx_t *dev = calloc(1, sizeof(ncr53c8xx_t));
dev->bus = scsi_get_bus();

View File

@@ -2204,10 +2204,7 @@ esp_pci_write(UNUSED(int func), int addr, uint8_t val, void *priv)
static void *
dc390_init(UNUSED(const device_t *info))
{
esp_t *dev;
dev = malloc(sizeof(esp_t));
memset(dev, 0x00, sizeof(esp_t));
esp_t *dev = calloc(1, sizeof(esp_t));
dev->bus = scsi_get_bus();
@@ -2419,10 +2416,7 @@ ncr53c9x_mca_feedb(void *priv)
static void *
ncr53c9x_mca_init(const device_t *info)
{
esp_t *dev;
dev = malloc(sizeof(esp_t));
memset(dev, 0x00, sizeof(esp_t));
esp_t *dev = calloc(1, sizeof(esp_t));
dev->bus = scsi_get_bus();

View File

@@ -1162,8 +1162,7 @@ spock_mca_reset(void *priv)
static void *
spock_init(const device_t *info)
{
spock_t *scsi = malloc(sizeof(spock_t));
memset(scsi, 0x00, sizeof(spock_t));
spock_t *scsi = calloc(1, sizeof(spock_t));
scsi->bus = scsi_get_bus();

View File

@@ -472,14 +472,10 @@ t228_feedb(void *priv)
static void *
t128_init(const device_t *info)
{
t128_t *t128;
ncr_t *ncr;
t128_t *t128 = calloc(1, sizeof(t128_t));
ncr_t *ncr = &t128->ncr;
scsi_bus_t *scsi_bus;
t128 = malloc(sizeof(t128_t));
memset(t128, 0x00, sizeof(t128_t));
ncr = &t128->ncr;
ncr->bus = scsi_get_bus();
scsi_bus = &ncr->scsibus;

View File

@@ -287,10 +287,9 @@ x54x_bios_scsi_command(scsi_device_t *dev, uint8_t *cdb, uint8_t *buf, int len,
static uint8_t
x54x_bios_read_capacity(scsi_device_t *sd, uint8_t *buf, int transfer_size)
{
uint8_t *cdb;
uint8_t *cdb = (uint8_t *) malloc(12);;
uint8_t ret;
cdb = (uint8_t *) malloc(12);
memset(cdb, 0, 12);
cdb[0] = GPCMD_READ_CDROM_CAPACITY;
@@ -305,10 +304,9 @@ x54x_bios_read_capacity(scsi_device_t *sd, uint8_t *buf, int transfer_size)
static uint8_t
x54x_bios_inquiry(scsi_device_t *sd, uint8_t *buf, int transfer_size)
{
uint8_t *cdb;
uint8_t *cdb = (uint8_t *) malloc(12);
uint8_t ret;
cdb = (uint8_t *) malloc(12);
memset(cdb, 0, 12);
cdb[0] = GPCMD_INQUIRY;
cdb[4] = 36;
@@ -324,14 +322,13 @@ x54x_bios_inquiry(scsi_device_t *sd, uint8_t *buf, int transfer_size)
static uint8_t
x54x_bios_command_08(scsi_device_t *sd, uint8_t *buffer, int transfer_size)
{
uint8_t *rcbuf;
uint8_t *rcbuf = (uint8_t *) malloc(8);
uint8_t ret;
int i;
memset(buffer, 0x00, 6);
rcbuf = (uint8_t *) malloc(8);
ret = x54x_bios_read_capacity(sd, rcbuf, transfer_size);
ret = x54x_bios_read_capacity(sd, rcbuf, transfer_size);
if (ret) {
free(rcbuf);
return ret;
@@ -353,13 +350,12 @@ x54x_bios_command_08(scsi_device_t *sd, uint8_t *buffer, int transfer_size)
static int
x54x_bios_command_15(scsi_device_t *sd, uint8_t *buffer, int transfer_size)
{
uint8_t *inqbuf;
uint8_t *inqbuf = (uint8_t *) malloc(36);
uint8_t *rcbuf;
uint8_t ret;
memset(buffer, 0x00, 6);
inqbuf = (uint8_t *) malloc(36);
ret = x54x_bios_inquiry(sd, inqbuf, transfer_size);
if (ret) {
free(inqbuf);
@@ -1896,13 +1892,11 @@ x54x_mem_disable(x54x_t *dev)
void *
x54x_init(const device_t *info)
{
x54x_t *dev;
x54x_t *dev = calloc(1, sizeof(x54x_t));
/* Allocate control block and set up basic stuff. */
dev = malloc(sizeof(x54x_t));
if (dev == NULL)
return dev;
memset(dev, 0x00, sizeof(x54x_t));
dev->type = info->local;
dev->card_bus = info->flags;