diff --git a/.github/workflows/Format-check.yml b/.github/workflows/Format-check.yml deleted file mode 100644 index 3a5ca7575..000000000 --- a/.github/workflows/Format-check.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: format - -on: - push: - branches: - - 'master' - - 'release-' - tags: '*' - pull_request: - -jobs: - check: - runs-on: ${{ matrix.os }} - strategy: - matrix: - julia-version: ['1'] - julia-arch: [x64] - os: [ubuntu-latest] - steps: - - uses: julia-actions/setup-julia@latest - with: - version: ${{ matrix.julia-version }} - - - uses: actions/checkout@v4 - - name: Install JuliaFormatter and format - run: | - julia -e 'using Pkg; Pkg.add(PackageSpec(name="JuliaFormatter"))' - julia -e 'using JuliaFormatter; format(["src", "test", "ext", "filters", "gen"], verbose=true)' - - - name: Format check - run: | - git diff --color=always --exit-code diff --git a/.github/workflows/Format.yml b/.github/workflows/Format.yml new file mode 100644 index 000000000..87b25049b --- /dev/null +++ b/.github/workflows/Format.yml @@ -0,0 +1,13 @@ +name: Format suggestions +on: + pull_request: + # this argument is not required if you don't use the `suggestion-label` input + types: [ opened, reopened, synchronize, labeled, unlabeled ] +jobs: + code-style: + runs-on: ubuntu-latest + steps: + - uses: julia-actions/julia-format@v3 + with: + version: '1' # Set `version` to '1.0.54' if you need to use JuliaFormatter.jl v1.0.54 (default: '1') + suggestion-label: 'format-suggest' # leave this unset or empty to show suggestions for all PRs diff --git a/filters/H5Zbitshuffle/src/H5Zbitshuffle.jl b/filters/H5Zbitshuffle/src/H5Zbitshuffle.jl index ca5dc50de..b6f4119d2 100644 --- a/filters/H5Zbitshuffle/src/H5Zbitshuffle.jl +++ b/filters/H5Zbitshuffle/src/H5Zbitshuffle.jl @@ -196,6 +196,7 @@ function H5Z_filter_bitshuffle( end size = nbytes_uncomp ÷ elem_size + buf_size_out <= 0 && error("bitshuffle_h5plugin: Non-positive buf_size_out for malloc: $buf_size_out") out_buf = Libc.malloc(buf_size_out) if out_buf == C_NULL error( diff --git a/filters/H5Zblosc/src/H5Zblosc.jl b/filters/H5Zblosc/src/H5Zblosc.jl index 26b5d1ae4..2806e322b 100644 --- a/filters/H5Zblosc/src/H5Zblosc.jl +++ b/filters/H5Zblosc/src/H5Zblosc.jl @@ -96,6 +96,7 @@ function blosc_filter( # the result is larger, we simply return 0. The filter is flagged # as optional, so HDF5 marks the chunk as uncompressed and proceeds. outbuf_size = unsafe_load(buf_size) + outbuf_size <= 0 && return Csize_t(0) outbuf = Libc.malloc(outbuf_size) outbuf == C_NULL && return Csize_t(0) @@ -121,6 +122,7 @@ function blosc_filter( # See https://github.com/JuliaLang/julia/issues/43402 # Resolved in https://github.com/JuliaLang/julia/pull/43408 outbuf_size, cbytes, blocksize = Blosc.cbuffer_sizes(in) + outbuf_size <= 0 && return Csize_t(0) outbuf = Libc.malloc(outbuf_size) outbuf == C_NULL && return Csize_t(0) status = Blosc.blosc_decompress(in, outbuf, outbuf_size) diff --git a/filters/H5Zbzip2/src/H5Zbzip2.jl b/filters/H5Zbzip2/src/H5Zbzip2.jl index 65bbe7843..b469f0008 100644 --- a/filters/H5Zbzip2/src/H5Zbzip2.jl +++ b/filters/H5Zbzip2/src/H5Zbzip2.jl @@ -40,6 +40,7 @@ function H5Z_filter_bzip2( # Decompress outbuflen = nbytes * 3 + 1 + outbuflen <= 0 && error("H5Zbzip2: Non-positive outbuflen for malloc: $outbuflen.") outbuf = Libc.malloc(outbuflen) if outbuf == C_NULL error("H5Zbzip2: memory allocation failed for bzip2 decompression.") @@ -106,6 +107,7 @@ function H5Z_filter_bzip2( # Prepare the output buffer outbuflen = nbytes + nbytes ÷ 100 + 600 # worse case (bzip2 docs) + outbuflen <= 0 && error("H5Zbzip2: Non-positive outbuflen for malloc: $outbuflen.") outbuf = Libc.malloc(outbuflen) @debug "Allocated" outbuflen outbuf if outbuf == C_NULL diff --git a/filters/H5Zlz4/src/H5Zlz4.jl b/filters/H5Zlz4/src/H5Zlz4.jl index 39de93945..bf84003eb 100644 --- a/filters/H5Zlz4/src/H5Zlz4.jl +++ b/filters/H5Zlz4/src/H5Zlz4.jl @@ -66,7 +66,9 @@ function H5Z_filter_lz4( # malloc a byte buffer of origSize # outBuf = Vector{UInt8}(undef, origSize) @debug "OrigSize" origSize + origSize <= 0 && error("H5Zlz4: Non-positive origSize for malloc: $origSize") outBuf = Libc.malloc(origSize) + outBuf == C_NULL && error("H5Zlz4: Could not allocate memory via malloc") # Julia should throw an error if it cannot allocate this roBuf = Ptr{UInt8}(outBuf) decompSize = 0 @@ -126,7 +128,9 @@ function H5Z_filter_lz4( nBlocks = (nbytes - 1) ÷ blockSize + 1 maxDestSize = nBlocks * CodecLz4.LZ4_compressBound(blockSize) + 4 + 8 + nBlocks * 4 + maxDestSize <= 0 && error("H5Zlz4: Non-positive maxDestSize for malloc: $maxDestSize") outBuf = Libc.malloc(maxDestSize) + outBuf == C_NULL && error("H5Zlz4: Could not allocate memory via malloc") rpos = Ptr{UInt8}(unsafe_load(buf)) roBuf = Ptr{UInt8}(outBuf) @@ -189,7 +193,7 @@ function H5Z_filter_lz4( catch err # "In the case of failure, the return value is 0 (zero) and all pointer arguments are left unchanged." ret_value = Csize_t(0) - @error "H5Zlz4.jl Non-Fatal ERROR: " err + @async @error "H5Zlz4.jl Non-Fatal ERROR: " err display(stacktrace(catch_backtrace())) finally if outBuf != C_NULL