From 68537e1e3273f786a7f551215fb1053aa81295a8 Mon Sep 17 00:00:00 2001 From: Yuval Tassa Date: Fri, 23 Jan 2026 10:50:53 -0800 Subject: [PATCH] Replace mjtSize with size_t for size calculations. Use unsigned size_t instead of signed mjtSize for size multiplications to avoid Clang's overflow-checking intrinsic. This is semantically correct as size calculations are inherently unsigned. PiperOrigin-RevId: 860172221 Change-Id: I3b6cb720db8771b8f266f1927e2980ac7514538b --- src/user/user_model.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/user/user_model.cc b/src/user/user_model.cc index be61c7b8..f201daed 100644 --- a/src/user/user_model.cc +++ b/src/user/user_model.cc @@ -2219,18 +2219,18 @@ void mjCModel::SetSizes() { // nhfielddata for (int i=0; i < nhfield; i++) { - nhfielddata += static_cast(hfields_[i]->nrow) * hfields_[i]->ncol; + nhfielddata += static_cast(hfields_[i]->nrow) * hfields_[i]->ncol; } // ntexdata for (int i=0; i < ntex; i++) { const mjCTexture* tex = textures_[i]; - ntexdata += static_cast(tex->nchannel) * tex->width * tex->height; + ntexdata += static_cast(tex->nchannel) * tex->width * tex->height; } // nwrap for (int i=0; i < ntendon; i++) { - nwrap += (int)tendons_[i]->path.size(); + nwrap += static_cast(tendons_[i]->path.size()); } // nsensordata @@ -3574,7 +3574,7 @@ void mjCModel::CopyObjects(mjModel* m) { // copy elevation data memcpy(m->hfield_data + data_adr, phf->data.data(), - static_cast(phf->nrow) * phf->ncol * sizeof(float)); + static_cast(phf->nrow) * phf->ncol * sizeof(float)); // advance counter data_adr += phf->nrow*phf->ncol; @@ -3595,7 +3595,7 @@ void mjCModel::CopyObjects(mjModel* m) { m->tex_adr[i] = data_adr; // copy rgb data - mjtSize nbytes = static_cast(ptex->nchannel) * ptex->width * ptex->height; + size_t nbytes = static_cast(ptex->nchannel) * ptex->width * ptex->height; memcpy(m->tex_data + data_adr, ptex->data_.data(), nbytes); // advance counter