We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4746 - add SDL_zeroa
Summary: add SDL_zeroa
Status: RESOLVED FIXED
Alias: None
Product: SDL
Classification: Unclassified
Component: *don't know* (show other bugs)
Version: HG 2.0
Hardware: All All
: P2 normal
Assignee: Ryan C. Gordon
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-07-30 21:56 UTC by Ozkan Sezer
Modified: 2019-07-30 22:23 UTC (History)
0 users

See Also:


Attachments
SDL_zeroa patch (3.20 KB, patch)
2019-07-30 21:56 UTC, Ozkan Sezer
Details | Diff
SDL_zeroa patch (2.83 KB, patch)
2019-07-30 22:15 UTC, Ozkan Sezer
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ozkan Sezer 2019-07-30 21:56:00 UTC
We currently have code like below which seems wrong:
  type_t array[2];
  SDL_zero(array);

From watcom, I get the following warnings in c++ mode:

src/audio/SDL_audio.c(951): Warning! W007: col(26) '&array' may not produce intended result
src/audio/SDL_audio.c(1611): Warning! W007: col(26) '&array' may not produce intended result
  SDL_zero(open_devices);

src/audio/SDL_audiocvt.c(918): Warning! W007: col(26) '&array' may not produce intended result
  SDL_zero(cvt->filters);

src/audio/SDL_wave.c(650): Warning! W007: col(20) '&array' may not produce intended result
  SDL_zero(cstate);

src/joystick/SDL_gamecontroller.c(645): Warning! W007: col(26) '&array' may not produce intended result
src/joystick/SDL_gamecontroller.c(646): Warning! W007: col(30) '&array' may not produce intended result
  SDL_zero(szGameButton);
  SDL_zero(szJoystickButton);

src/joystick/SDL_gamecontroller.c(658): Warning! W007: col(34) '&array' may not produce intended result
src/joystick/SDL_gamecontroller.c(659): Warning! W007: col(38) '&array' may not produce intended result
  SDL_zero(szGameButton);
  SDL_zero(szJoystickButton);


I suggest adding a new SDL_zeroa macro like below, and changing
the relevant statements to it:
#define SDL_zeroa(x) SDL_memset((x), 0, sizeof((x)))
-  SDL_zero(array);
+  SDL_zeroa(array);

A patch is attached for it.
After applying it, Watcom's binary output is identical for me.


Comments?  OK?
Comment 1 Ozkan Sezer 2019-07-30 21:56:46 UTC
Created attachment 3909 [details]
SDL_zeroa patch
Comment 2 Ozkan Sezer 2019-07-30 22:15:00 UTC
Created attachment 3910 [details]
SDL_zeroa patch

(Attaching the correct patch file this time.)
Comment 3 Ryan C. Gordon 2019-07-30 22:18:22 UTC
This looks good to me, go ahead and apply it.

--ryan.
Comment 4 Ozkan Sezer 2019-07-30 22:23:04 UTC
Applied:  https://hg.libsdl.org/SDL/rev/0262d439e9c6