postgresql-interfaces/psqlodbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: faviansamatha (@faviansamatha) <[email protected]>
To: postgresql-interfaces/psqlodbc <[email protected]>
Subject: [postgresql-interfaces/psqlodbc] PR #107: fix: use memset if memset_s is not available
Date: Fri, 11 Apr 2025 21:26:40 +0000
Message-ID: <[email protected]> (raw)

## Summary
A previous PR (https://github.com/postgresql-interfaces/psqlodbc/pull/105) replaced the instances of memset with memset_s or SecureZeroMemory because there's a chance that compiler may remove these calls during optimization. However, this PR will break builds with compilers that do not have memset_s. `memset_s` was introduced in C11, but it is flagged as optional and many compilers like GCC do not implement this.

For the time being, this commit will re-introduce memset if `memset_s` is not implemented in the compiler by checking `__STDC_LIB_EXT1__`  and defining `__STDC_WANT_LIB_EXT1__` before the needed imports. (reference: https://en.cppreference.com/w/c/string/byte/memset).

This commit also removes the changes in the unit test. `memset` should be safe in the unit tests. (previous implementaiton caused 2 unit tests to fail, (`not ok 9 - result-conversions test output differs``not ok 40 - diagnostic test`) because it used memset with a non-zero value. 

## Testing
Built on:
- Mac M2 
- Windows
- Linux Ubuntu 24

Ran regression test on Windows and tests had same results as mainline prior to 105


reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: github://postgresql-interfaces/psqlodbc
  Cc: [email protected], [email protected]
  Subject: Re: [postgresql-interfaces/psqlodbc] PR #107: fix: use memset if memset_s is not available
  In-Reply-To: <<[email protected]>>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox