Skip to content

Commit

Permalink
[_XXXX] Remove use of bzero
Browse files Browse the repository at this point in the history
  • Loading branch information
alanking committed Mar 10, 2022
1 parent 791cf30 commit 1e8571e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 22 deletions.
28 changes: 11 additions & 17 deletions s3/libirods_s3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1103,9 +1103,8 @@ irods::error s3GetFile(
}

callback_data_t data;
S3BucketContext bucketContext;
S3BucketContext bucketContext{};

bzero (&bucketContext, sizeof (bucketContext));
bucketContext.bucketName = bucket.c_str();
bucketContext.protocol = s3GetProto(_prop_map);
bucketContext.stsDate = s3GetSTSDate(_prop_map);
Expand All @@ -1125,7 +1124,7 @@ irods::error s3GetFile(

size_t retry_cnt = 0;
do {
bzero (&data, sizeof (data));
std::memset(&data, 0, sizeof(data));
data.prop_map_ptr = &_prop_map;
data.fd = cache_fd;
data.contentLength = data.originalContentLength = _fileSize;
Expand Down Expand Up @@ -1157,7 +1156,7 @@ irods::error s3GetFile(
std::stringstream msg;

// Only the FD part of this will be constant
bzero (&data, sizeof (data));
std::memset(&data, 0, sizeof(data));
data.prop_map_ptr = &_prop_map;
data.fd = cache_fd;
data.contentLength = data.originalContentLength = _fileSize;
Expand Down Expand Up @@ -1570,9 +1569,8 @@ irods::error s3PutCopyFile(
}

callback_data_t data;
S3BucketContext bucketContext;
S3BucketContext bucketContext{};

bzero (&bucketContext, sizeof (bucketContext));
bucketContext.bucketName = bucket.c_str();
bucketContext.protocol = s3GetProto(_prop_map);
bucketContext.stsDate = s3GetSTSDate(_prop_map);
Expand All @@ -1598,7 +1596,7 @@ irods::error s3PutCopyFile(
};

do {
bzero (&data, sizeof (data));
std::memset(&data, 0, sizeof(data));
data.prop_map_ptr = &_prop_map;
data.fd = cache_fd;
data.contentLength = data.originalContentLength = _fileSize;
Expand Down Expand Up @@ -1653,7 +1651,7 @@ irods::error s3PutCopyFile(
multipart_data_t partData;
int partContentLength = 0;

bzero (&data, sizeof (data));
std::memset(&data, 0, sizeof(data));
data.prop_map_ptr = &_prop_map;
data.fd = cache_fd;
data.contentLength = data.originalContentLength = _fileSize;
Expand Down Expand Up @@ -1733,15 +1731,14 @@ irods::error s3PutCopyFile(
}

// Following used by S3_COPYOBJECT only
S3BucketContext srcBucketContext;
S3BucketContext srcBucketContext{};
std::string authRegionStr = get_region_name(_prop_map);
if (_mode == S3_COPYOBJECT) {
if (const auto err = parseS3Path(_filename, srcBucket, srcKey, _prop_map); !err.ok()) {
return PASSMSG(fmt::format(
"[resource_name={}] Failed parsing the S3 bucket and key from the physical path: \"{}\".",
resource_name, _filename), err);
}
bzero (&srcBucketContext, sizeof (srcBucketContext));
srcBucketContext.bucketName = srcBucket.c_str();
srcBucketContext.protocol = s3GetProto(_prop_map);
srcBucketContext.stsDate = s3GetSTSDate(_prop_map);
Expand Down Expand Up @@ -1932,11 +1929,10 @@ irods::error s3CopyFile(

callback_data_t data;
data.prop_map_ptr = &_src_ctx.prop_map();
S3BucketContext bucketContext;
S3BucketContext bucketContext{};
int64_t lastModified;
char eTag[256];

bzero (&bucketContext, sizeof (bucketContext));
bucketContext.bucketName = src_bucket.c_str();
bucketContext.protocol = _proto;
bucketContext.stsDate = _stsDate;
Expand All @@ -1959,7 +1955,7 @@ irods::error s3CopyFile(

size_t retry_cnt = 0;
do {
bzero (&data, sizeof (data));
std::memset(&data, 0 sizeof(data));
data.prop_map_ptr = &_src_ctx.prop_map();
std::string&& hostname = s3GetHostname(_src_ctx.prop_map());
bucketContext.hostName = hostname.c_str(); // Safe to do, this is a local copy of the data structure
Expand Down Expand Up @@ -2322,8 +2318,7 @@ irods::error register_archive_object(
// =-=-=-=-=-=-=-
// build out a dataObjInfo_t struct for use in the call
// to rsRegDataObj
dataObjInfo_t dst_data_obj;
bzero( &dst_data_obj, sizeof( dst_data_obj ) );
dataObjInfo_t dst_data_obj{};

resc_mgr.hier_to_leaf_id(resc_hier.c_str(), dst_data_obj.rescId);
strncpy( dst_data_obj.objPath, obj.name().c_str(), MAX_NAME_LEN );
Expand Down Expand Up @@ -2359,8 +2354,7 @@ irods::error register_archive_object(

// =-=-=-=-=-=-=-
// repl to an existing copy
regReplica_t reg_inp;
bzero( &reg_inp, sizeof( reg_inp ) );
regReplica_t reg_inp{};
reg_inp.srcDataObjInfo = &src_data_obj;
reg_inp.destDataObjInfo = &dst_data_obj;
int reg_status = rsRegReplica( _comm, &reg_inp );
Expand Down
9 changes: 4 additions & 5 deletions s3/s3_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ namespace irods_s3 {
// get ref to fco
irods::data_object_ptr object = boost::dynamic_pointer_cast<irods::data_object>(_ctx.fco());

bzero (_statbuf, sizeof (struct stat));
std::memset(_statbuf, 0 sizeof(struct stat));

boost::filesystem::path p(object->physical_path());

Expand Down Expand Up @@ -1136,9 +1136,7 @@ namespace irods_s3 {

std::string region_name = get_region_name(_ctx.prop_map());

callback_data_t data;
S3BucketContext bucketContext;
bzero(&bucketContext, sizeof(bucketContext));
S3BucketContext bucketContext{};

bucketContext.bucketName = bucket.c_str();
bucketContext.protocol = s3GetProto(_ctx.prop_map());
Expand All @@ -1150,8 +1148,9 @@ namespace irods_s3 {

S3ResponseHandler headObjectHandler = { &responsePropertiesCallback, &responseCompleteCallbackIgnoreLoggingNotFound};
size_t retry_cnt = 0;
callback_data_t data;
do {
bzero (&data, sizeof (data));
std::memset(&data, 0 sizeof(data));
std::string&& hostname = s3GetHostname(_ctx.prop_map());
bucketContext.hostName = hostname.c_str();
data.pCtx = &bucketContext;
Expand Down

0 comments on commit 1e8571e

Please sign in to comment.