Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:25
erlang
2901-ssl-replace-size-1-by-xxx_size-1.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 2901-ssl-replace-size-1-by-xxx_size-1.patch of Package erlang
From 8e5b63ed5cb43e0818e7502d944450fd36a11adb Mon Sep 17 00:00:00 2001 From: Kiko Fernandez-Reyes <kiko@erlang.org> Date: Tue, 7 Feb 2023 10:02:43 +0100 Subject: [PATCH] ssl: replace size/1 by xxx_size/1 The <c>size/1</c> BIF is not optimized by the JIT, and its use can result in worse types for Dialyzer. When one knows that the value being tested must be a tuple, <c>tuple_size/1</c> should always be preferred. When one knows that the value being tested must be a binary, <c>byte_size/1</c> should be preferred. However, <c>byte_size/1</c> also accepts a bitstring (rounding up size to a whole number of bytes), so one must make sure that the call to <c>byte_size/</c> is preceded by a call to <c>is_binary/1</c> to ensure that bitstrings are rejected. Note that the compiler removes redundant calls to <c>is_binary/1</c>, so if one is not sure whether previous code had made sure that the argument is a binary, it does not harm to add an <c>is_binary/1</c> test immediately before the call to <c>byte_size/1</c>. --- lib/ssl/src/ssl_trace.erl | 2 +- lib/ssl/src/tls_gen_connection.erl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ssl/src/ssl_trace.erl b/lib/ssl/src/ssl_trace.erl index 896cb5cd10..886662e31e 100644 --- a/lib/ssl/src/ssl_trace.erl +++ b/lib/ssl/src/ssl_trace.erl @@ -358,7 +358,7 @@ trace_pid(T) when element(1,T)==trace %% Pick last element, the Time Stamp, and format it trace_ts(T) when element(1,T)==trace_ts -> - ts( element(size(T), T) ). + ts( element(tuple_size(T), T) ). ts({_,_,Usec}=Now) when is_integer(Usec) -> {_Date,{HH,MM,SS}} = calendar:now_to_local_time(Now), diff --git a/lib/ssl/src/tls_gen_connection.erl b/lib/ssl/src/tls_gen_connection.erl index 932b0c999b..c3b03fd1be 100644 --- a/lib/ssl/src/tls_gen_connection.erl +++ b/lib/ssl/src/tls_gen_connection.erl @@ -359,7 +359,7 @@ handle_info({CloseTag, Socket}, StateName, handle_info({ssl_tls, Port, Type, {Major, Minor}, Data}, StateName, #state{static_env = #static_env{data_tag = Protocol}, ssl_options = #{ktls := true}} = State0) -> - Len = size(Data), + Len = byte_size(Data), handle_info({Protocol, Port, <<Type, Major, Minor, Len:16, Data/binary>>}, StateName, State0); handle_info(Msg, StateName, State) -> ssl_gen_statem:handle_info(Msg, StateName, State). -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor