File: openmp.c

package info (click to toggle)
cppcheck 2.19.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 26,688 kB
  • sloc: cpp: 272,455; python: 22,408; ansic: 8,088; sh: 1,059; makefile: 1,041; xml: 987; cs: 291
file content (32 lines) | stat: -rw-r--r-- 802 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32

// Test library configuration for openmp.cfg
//
// Usage:
// $ cppcheck --check-library --library=openmp --enable=style,information --inconclusive --error-exitcode=1 --inline-suppr test/cfg/openmp.c
// =>
// No warnings about bad library configuration, unmatched suppressions, etc. exitcode=0
//

#include <omp.h>
#include <stdio.h>

void validCode()
{
    int arr[20] = { 0 };
    #pragma omp parallel for
    for (int i = 0; i < 20; ++i) {
        // cppcheck-suppress unreadVariable
        arr[i] = i * i;
    }

    char * pChars = (char *) omp_target_alloc(4, 1);
    printf("pChars: %p", pChars);
    omp_target_free(pChars, 1);
}

void memleak_omp_target_alloc()
{
    const char * pChars = (char *) omp_target_alloc(2, 0);
    printf("pChars: %p", pChars);
    // cppcheck-suppress memleak
}