Skip to content

Commit 371b25b

Browse files
authored
Merge pull request #131 from maxmind/greg/clang-static-analysis
Add Clang static analysis build
2 parents a301c04 + 56f8ce4 commit 371b25b

File tree

5 files changed

+66
-11
lines changed

5 files changed

+66
-11
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Clang Static Analysis
2+
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '45 3 * * SUN'
8+
9+
jobs:
10+
run:
11+
name: "Clang Static Analysis"
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Setup PHP
15+
uses: shivammathur/setup-php@v2
16+
with:
17+
php-version: 8.0
18+
tools: composer, phpize
19+
20+
- name: Checkout
21+
# We use v1 due to https://github.com/actions/checkout/issues/334
22+
uses: actions/checkout@v1
23+
with:
24+
submodules: true
25+
26+
- name: Install clang-tools and libmaxminddb
27+
run: sudo apt-get install clang-tools libmaxminddb-dev
28+
29+
- name: Build extension
30+
run: |
31+
export CFLAGS="-L$HOME/libmaxminddb/lib"
32+
export CPPFLAGS="-I$HOME/libmaxminddb/include"
33+
cd ext
34+
phpize
35+
scan-build --status-bugs ./configure --with-maxminddb --enable-maxminddb-debug
36+
make clean
37+
scan-build --status-bugs make

.github/workflows/lint.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: PHP Lints
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '45 3 * * SUN'
48

59
jobs:
610
run:

.github/workflows/test.yml

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
name: PHPUnit
22

3-
on: [push, pull_request]
3+
on:
4+
push:
5+
pull_request:
6+
schedule:
7+
- cron: '45 3 * * SUN'
48

59
jobs:
610
run:
@@ -15,13 +19,12 @@ jobs:
1519
name: "PHP ${{ matrix.php-versions }} (with ${{ matrix.php-extensions }}) test on ${{ matrix.operating-system }}/${{ matrix.arch }}"
1620
steps:
1721
- name: Install PHP
18-
run: |
19-
spc -U
20-
spc --php-version "${{ matrix.php-versions }}" \
21-
--extensions "mbstring, intl, ${{ matrix.php-extensions }}" \
22-
--ini-values "post_max_size=256M, max_execution_time=180" \
23-
--coverage "xdebug" \
24-
--tools "composer,phpize"
22+
uses: shivammathur/setup-php@v2
23+
with:
24+
php-version: ${{ matrix.php-versions }}
25+
extensions: "mbstring, intl, ${{ matrix.php-extensions }}"
26+
tools: "composer, phpize"
27+
coverage: xdebug
2528

2629
- name: Checkout
2730
# We use v1 due to https://github.com/actions/checkout/issues/334

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
CHANGELOG
22
=========
33

4+
1.10.2
5+
-------------------
6+
7+
* Resolve minor issue found by the Clang static analyzer in the C
8+
extension.
9+
410
1.10.1 (2021-04-14)
511
-------------------
612

ext/maxminddb.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ typedef zend_object free_obj_t;
6969
#define IS_MIXED IS_UNDEF
7070
#endif
7171

72+
/* ZEND_THIS was added in 7.4 */
73+
#ifndef ZEND_THIS
74+
#define ZEND_THIS (&EX(This))
75+
#endif
76+
7277
typedef struct _maxminddb_obj {
7378
MMDB_s *mmdb;
7479
zend_object std;
@@ -151,7 +156,7 @@ PHP_METHOD(MaxMind_Db_Reader, __construct) {
151156
return;
152157
}
153158

154-
maxminddb_obj *mmdb_obj = Z_MAXMINDDB_P(getThis());
159+
maxminddb_obj *mmdb_obj = Z_MAXMINDDB_P(ZEND_THIS);
155160
mmdb_obj->mmdb = mmdb;
156161
}
157162

@@ -202,7 +207,7 @@ get_record(INTERNAL_FUNCTION_PARAMETERS, zval *record, int *prefix_len) {
202207
return FAILURE;
203208
}
204209

205-
const maxminddb_obj *mmdb_obj = (maxminddb_obj *)Z_MAXMINDDB_P(getThis());
210+
const maxminddb_obj *mmdb_obj = (maxminddb_obj *)Z_MAXMINDDB_P(ZEND_THIS);
206211

207212
MMDB_s *mmdb = mmdb_obj->mmdb;
208213

0 commit comments

Comments
 (0)