diff options
author | Andre Heider <[email protected]> | 2018-11-25 10:49:59 +0100 |
---|---|---|
committer | Axel Davy <[email protected]> | 2018-12-01 21:32:53 +0100 |
commit | b6f095f7ce2988045daf32e03f7a4ecc5fb466bb (patch) | |
tree | cfa0119f9e999cc830a0964a3ba183bb05c90cb4 /src | |
parent | 37a2072e97af8f7f3143f0dc130a4e11a85c621a (diff) |
d3dadapter9: use snprintf(..., "%s", ...) instead of strncpy
Fixes -Wstringop-truncation compiler warnings.
See f836d799f9066adf58f36 "intel/decoder: use snprintf(..., "%s", ...) instead of strncpy"
Signed-off-by: Andre Heider <[email protected]>
Reviewed-by: Axel Davy <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/targets/d3dadapter9/description.c | 27 | ||||
-rw-r--r-- | src/gallium/targets/d3dadapter9/drm.c | 8 |
2 files changed, 22 insertions, 13 deletions
diff --git a/src/gallium/targets/d3dadapter9/description.c b/src/gallium/targets/d3dadapter9/description.c index c0a86782f8e..a3e4cd61770 100644 --- a/src/gallium/targets/d3dadapter9/description.c +++ b/src/gallium/targets/d3dadapter9/description.c @@ -20,6 +20,7 @@ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE * USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include <stdio.h> #include <string.h> #include "adapter9.h" @@ -239,7 +240,7 @@ d3d_match_vendor_id( D3DADAPTER_IDENTIFIER9* drvid, DBG("unknown vendor 0x4%x, emulating 0x4%x\n", drvid->VendorId, fallback_ven); drvid->VendorId = fallback_ven; drvid->DeviceId = fallback_dev; - strncpy(drvid->Description, fallback_name, sizeof(drvid->Description)); + snprintf(drvid->Description, sizeof(drvid->Description), "%s", fallback_name); } /* fill in driver name and version */ @@ -277,46 +278,54 @@ void d3d_fill_cardname(D3DADAPTER_IDENTIFIER9* drvid) { case HW_VENDOR_INTEL: for (i = 0; i < sizeof(cards_intel) / sizeof(cards_intel[0]); i++) { if (strstr(drvid->Description, cards_intel[i].mesaname)) { - strncpy(drvid->Description, cards_intel[i].d3d9name, sizeof(drvid->Description)); + snprintf(drvid->Description, sizeof(drvid->Description), + "%s", cards_intel[i].d3d9name); return; } } /* use a fall-back if nothing matches */ DBG("Unknown card name %s!\n", drvid->DeviceName); - strncpy(drvid->Description, cards_intel[0].d3d9name, sizeof(drvid->Description)); + snprintf(drvid->Description, sizeof(drvid->Description), + "%s", cards_intel[0].d3d9name); break; case HW_VENDOR_VMWARE: for (i = 0; i < sizeof(cards_vmware) / sizeof(cards_vmware[0]); i++) { if (strstr(drvid->Description, cards_vmware[i].mesaname)) { - strncpy(drvid->Description, cards_vmware[i].d3d9name, sizeof(drvid->Description)); + snprintf(drvid->Description, sizeof(drvid->Description), + "%s", cards_vmware[i].d3d9name); return; } } /* use a fall-back if nothing matches */ DBG("Unknown card name %s!\n", drvid->DeviceName); - strncpy(drvid->Description, cards_vmware[0].d3d9name, sizeof(drvid->Description)); + snprintf(drvid->Description, sizeof(drvid->Description), + "%s", cards_vmware[0].d3d9name); break; case HW_VENDOR_AMD: for (i = 0; i < sizeof(cards_amd) / sizeof(cards_amd[0]); i++) { if (strstr(drvid->Description, cards_amd[i].mesaname)) { - strncpy(drvid->Description, cards_amd[i].d3d9name, sizeof(drvid->Description)); + snprintf(drvid->Description, sizeof(drvid->Description), + "%s", cards_amd[i].d3d9name); return; } } /* use a fall-back if nothing matches */ DBG("Unknown card name %s!\n", drvid->DeviceName); - strncpy(drvid->Description, cards_amd[0].d3d9name, sizeof(drvid->Description)); + snprintf(drvid->Description, sizeof(drvid->Description), + "%s", cards_amd[0].d3d9name); break; case HW_VENDOR_NVIDIA: for (i = 0; i < sizeof(cards_nvidia) / sizeof(cards_nvidia[0]); i++) { if (strstr(drvid->Description, cards_nvidia[i].mesaname)) { - strncpy(drvid->Description, cards_nvidia[i].d3d9name, sizeof(drvid->Description)); + snprintf(drvid->Description, sizeof(drvid->Description), + "%s", cards_nvidia[i].d3d9name); return; } } /* use a fall-back if nothing matches */ DBG("Unknown card name %s!\n", drvid->DeviceName); - strncpy(drvid->Description, cards_nvidia[0].d3d9name, sizeof(drvid->Description)); + snprintf(drvid->Description, sizeof(drvid->Description), + "%s", cards_nvidia[0].d3d9name); break; default: break; diff --git a/src/gallium/targets/d3dadapter9/drm.c b/src/gallium/targets/d3dadapter9/drm.c index 6fb8caf5c2f..e08778b81d4 100644 --- a/src/gallium/targets/d3dadapter9/drm.c +++ b/src/gallium/targets/d3dadapter9/drm.c @@ -149,8 +149,8 @@ read_descriptor( struct d3dadapter9_context *ctx, &drvid->SubSysId, &drvid->Revision); snprintf(drvid->DeviceName, sizeof(drvid->DeviceName), "Gallium 0.4 with %s", ctx->hal->get_vendor(ctx->hal)); - strncpy(drvid->Description, ctx->hal->get_name(ctx->hal), - sizeof(drvid->Description)); + snprintf(drvid->Description, sizeof(drvid->Description), + "%s", ctx->hal->get_name(ctx->hal)); if (override_vendorid > 0) { found = FALSE; @@ -163,8 +163,8 @@ read_descriptor( struct d3dadapter9_context *ctx, fallback_cards[i].device_id); drvid->VendorId = fallback_cards[i].vendor_id; drvid->DeviceId = fallback_cards[i].device_id; - strncpy(drvid->Description, fallback_cards[i].name, - sizeof(drvid->Description)); + snprintf(drvid->Description, sizeof(drvid->Description), + "%s", fallback_cards[i].name); found = TRUE; break; } |