Skip to content

Commit

Permalink
fixed warnings related to sprintf and vsprintf
Browse files Browse the repository at this point in the history
  • Loading branch information
jilei-hao committed Mar 18, 2024
1 parent 45cbc7c commit d877af8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/AffineCostFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class RigidCostFunctionImpl
virtual vnl_vector<double> backward(const vnl_vector<double> &g)
{ return vnl_vector<double>(); }

static vnl_vector<double> GetAxisAngle(const Mat &R) { return Vec(); }
static vnl_vector<double> GetAxisAngle(const Mat &R) { return Vec().as_vector(); }

static Mat GetRandomRotation(vnl_random &randy, double alpha) { return Mat(); }
static unsigned int GetNumberOfParameters() { return 0; }
Expand Down
8 changes: 4 additions & 4 deletions testing/src/GreedyTestDriver.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ std::string GetFileName(const char *pattern, ...)
va_list args;
va_start(args, pattern);
char filename_local[2048];
vsprintf(filename_local, pattern, args);
vsnprintf(filename_local, sizeof(filename_local), pattern, args);
va_end(args);

// Prepend the root
Expand Down Expand Up @@ -364,7 +364,7 @@ std::string printf_index(const char *format, itk::Index<VDim> index)
for(unsigned int i = 0; i < VDim; i++)
{
char buf[256];
sprintf(buf, format, index[i]);
snprintf(buf, sizeof(buf), format, index[i]);
result += buf;
if(i < VDim - 1)
result += ",";
Expand All @@ -379,7 +379,7 @@ std::string printf_vec(const char *format, T *arr)
for(unsigned int i = 0; i < VDim; i++)
{
char buf[256];
sprintf(buf, format, arr[i]);
snprintf(buf, sizeof(buf), format, arr[i]);
result += buf;
if(i < VDim - 1)
result += ",";
Expand Down Expand Up @@ -815,7 +815,7 @@ int RunMetricVoxelwiseGradientTest(CommandLineHelper &cl)
double ana_deriv = LDDMMType::img_voxel_sum(idot);

char buffer[256];
sprintf(buffer, "/tmp/variation%d.nii.gz", i);
snprintf(buffer, sizeof(buffer), "/tmp/variation%d.nii.gz", i);
LDDMMType::vimg_write(variation, buffer);

// Compute numeric derivatives
Expand Down
2 changes: 1 addition & 1 deletion testing/src/greedy_multi_chunk.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ std::string ssprintf(const char *format, ...)
char buffer[4096];
va_list args;
va_start (args, format);
vsprintf (buffer, format, args);
vsnprintf (buffer, sizeof(buffer), format, args);
va_end (args);
return std::string(buffer);
}
Expand Down

0 comments on commit d877af8

Please sign in to comment.