mirror of
https://github.com/thelsing/knx.git
synced 2024-12-18 19:08:18 +01:00
Merge branch 'w5500' of https://github.com/OnlineCaveman/knx-samd51 into w5500
This commit is contained in:
commit
277a5d57fa
25
.github/workflows/codeql-analysis.yml
vendored
25
.github/workflows/codeql-analysis.yml
vendored
@ -18,32 +18,27 @@ jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
# Override automatic language detection by changing the below list
|
||||
# Supported options are ['csharp', 'cpp', 'go', 'java', 'javascript', 'python']
|
||||
language: ['cpp']
|
||||
language: ['cpp', 'python']
|
||||
# Learn more...
|
||||
# https://docs.github.com/en/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#overriding-automatic-language-detection
|
||||
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
# We must fetch at least the immediate parents so that if this is
|
||||
# a pull request then we can checkout the head.
|
||||
fetch-depth: 2
|
||||
|
||||
# If this run was triggered by a pull request event, then checkout
|
||||
# the head of the pull request instead of the merge commit.
|
||||
- run: git checkout HEAD^2
|
||||
if: ${{ github.event_name == 'pull_request' }}
|
||||
uses: actions/checkout@v3
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
@ -54,7 +49,7 @@ jobs:
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v1
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
@ -68,4 +63,4 @@ jobs:
|
||||
# make release
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
@ -37,9 +37,28 @@ uint16_t AddressTableObject::getGroupAddress(uint16_t tsap)
|
||||
uint16_t AddressTableObject::getTsap(uint16_t addr)
|
||||
{
|
||||
uint16_t size = entryCount();
|
||||
#ifdef USE_BINSEARCH
|
||||
|
||||
uint16_t low,high,i;
|
||||
low = 1;
|
||||
high = size;
|
||||
|
||||
while(low <= high)
|
||||
{
|
||||
i = (low+high)/2;
|
||||
uint16_t ga = ntohs(_groupAddresses[i]);
|
||||
if (ga == addr)
|
||||
return i;
|
||||
if(addr < ga)
|
||||
high = i - 1;
|
||||
else
|
||||
low = i + 1 ;
|
||||
}
|
||||
#else
|
||||
for (uint16_t i = 1; i <= size; i++)
|
||||
if (ntohs(_groupAddresses[i]) == addr)
|
||||
return i;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -58,12 +77,7 @@ const uint8_t* AddressTableObject::restore(const uint8_t* buffer)
|
||||
|
||||
bool AddressTableObject::contains(uint16_t addr)
|
||||
{
|
||||
uint16_t size = entryCount();
|
||||
for (uint16_t i = 1; i <= size; i++)
|
||||
if (ntohs(_groupAddresses[i]) == addr)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return (getTsap(addr) > 0);
|
||||
}
|
||||
|
||||
void AddressTableObject::beforeStateChange(LoadState& newState)
|
||||
|
@ -50,11 +50,35 @@ const uint8_t* AssociationTableObject::restore(const uint8_t* buffer)
|
||||
int32_t AssociationTableObject::translateAsap(uint16_t asap)
|
||||
{
|
||||
uint16_t entries = entryCount();
|
||||
#ifdef USE_BINSEARCH
|
||||
uint16_t low,high,i;
|
||||
low = 0;
|
||||
high = entries-1;
|
||||
|
||||
while(low <= high)
|
||||
{
|
||||
i = (low+high)/2;
|
||||
uint16_t asap_i = getASAP(i);
|
||||
if (asap_i == asap)
|
||||
{
|
||||
// as the binary search does not hit the first element in a list with identical items,
|
||||
// search downwards to return the first occurence in the table
|
||||
while(getASAP(--i) == asap)
|
||||
;
|
||||
return getTSAP(i+1);
|
||||
}
|
||||
if(asap_i > asap)
|
||||
high = i - 1;
|
||||
else
|
||||
low = i + 1 ;
|
||||
}
|
||||
#else
|
||||
for (uint16_t i = 0; i < entries; i++)
|
||||
{
|
||||
if (getASAP(i) == asap)
|
||||
return getTSAP(i);
|
||||
}
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user