This is an automated email from the ASF dual-hosted git repository. zwoop pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/9.0.x by this push: new ff6c5da clang-analyzer: Fix dead nested assignment issues ff6c5da is described below commit ff6c5da7968508f09ddcbcac02d9bef7f2cb0d73 Author: Masakazu Kitajo <mas...@apache.org> AuthorDate: Wed May 13 17:30:01 2020 +0900 clang-analyzer: Fix dead nested assignment issues (cherry picked from commit 9c88bb74755ecd18eb9e16a91cc8bfbdcf7b83b9) --- iocore/dns/DNSConnection.cc | 2 +- iocore/net/Connection.cc | 25 +++++++------- iocore/net/UnixUDPNet.cc | 31 +++++++++-------- mgmt/api/EventControlMain.cc | 2 +- plugins/esi/esi.cc | 8 ++--- .../experimental/access_control/access_control.cc | 2 +- plugins/experimental/mp4/mp4_meta.cc | 4 +-- proxy/http/remap/RemapConfig.cc | 4 +-- tools/jtest/jtest.cc | 39 +++++++++++----------- 9 files changed, 57 insertions(+), 60 deletions(-) diff --git a/iocore/dns/DNSConnection.cc b/iocore/dns/DNSConnection.cc index 5462156..1f2dab6 100644 --- a/iocore/dns/DNSConnection.cc +++ b/iocore/dns/DNSConnection.cc @@ -157,7 +157,7 @@ DNSConnection::connect(sockaddr const *addr, Options const &opt) p = static_cast<uint16_t>((p % (LAST_RANDOM_PORT - FIRST_RANDOM_PORT)) + FIRST_RANDOM_PORT); ats_ip_port_cast(&bind_addr.sa) = htons(p); // stuff port in sockaddr. Debug("dns", "random port = %s", ats_ip_nptop(&bind_addr.sa, b, sizeof b)); - if ((res = socketManager.ink_bind(fd, &bind_addr.sa, bind_size, Proto)) < 0) { + if (socketManager.ink_bind(fd, &bind_addr.sa, bind_size, Proto) < 0) { continue; } goto Lok; diff --git a/iocore/net/Connection.cc b/iocore/net/Connection.cc index 99c1088..4f5395c 100644 --- a/iocore/net/Connection.cc +++ b/iocore/net/Connection.cc @@ -192,7 +192,7 @@ Server::setup_fd_for_listen(bool non_blocking, const NetProcessor::AcceptOptions } } - if ((res = safe_fcntl(fd, F_SETFD, FD_CLOEXEC)) < 0) { + if (safe_fcntl(fd, F_SETFD, FD_CLOEXEC) < 0) { goto Lerror; } @@ -201,44 +201,44 @@ Server::setup_fd_for_listen(bool non_blocking, const NetProcessor::AcceptOptions l.l_onoff = 0; l.l_linger = 0; if ((opt.sockopt_flags & NetVCOptions::SOCK_OPT_LINGER_ON) && - (res = safe_setsockopt(fd, SOL_SOCKET, SO_LINGER, reinterpret_cast<char *>(&l), sizeof(l))) < 0) { + safe_setsockopt(fd, SOL_SOCKET, SO_LINGER, reinterpret_cast<char *>(&l), sizeof(l)) < 0) { goto Lerror; } } - if (ats_is_ip6(&addr) && (res = safe_setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, SOCKOPT_ON, sizeof(int))) < 0) { + if (ats_is_ip6(&addr) && safe_setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, SOCKOPT_ON, sizeof(int)) < 0) { goto Lerror; } - if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, SOCKOPT_ON, sizeof(int))) < 0) { + if (safe_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, SOCKOPT_ON, sizeof(int)) < 0) { goto Lerror; } REC_ReadConfigInteger(listen_per_thread, "proxy.config.exec_thread.listen"); if (listen_per_thread == 1) { - if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, SOCKOPT_ON, sizeof(int))) < 0) { + if (safe_setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, SOCKOPT_ON, sizeof(int)) < 0) { goto Lerror; } #ifdef SO_REUSEPORT_LB - if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_REUSEPORT_LB, SOCKOPT_ON, sizeof(int))) < 0) { + if (safe_setsockopt(fd, SOL_SOCKET, SO_REUSEPORT_LB, SOCKOPT_ON, sizeof(int)) < 0) { goto Lerror; } #endif } if ((opt.sockopt_flags & NetVCOptions::SOCK_OPT_NO_DELAY) && - (res = safe_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, SOCKOPT_ON, sizeof(int))) < 0) { + safe_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, SOCKOPT_ON, sizeof(int)) < 0) { goto Lerror; } // enables 2 hour inactivity probes, also may fix IRIX FIN_WAIT_2 leak if ((opt.sockopt_flags & NetVCOptions::SOCK_OPT_KEEP_ALIVE) && - (res = safe_setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, SOCKOPT_ON, sizeof(int))) < 0) { + safe_setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, SOCKOPT_ON, sizeof(int)) < 0) { goto Lerror; } #ifdef TCP_FASTOPEN if ((opt.sockopt_flags & NetVCOptions::SOCK_OPT_TCP_FAST_OPEN) && - (res = safe_setsockopt(fd, IPPROTO_TCP, TCP_FASTOPEN, (char *)&opt.tfo_queue_length, sizeof(int)))) { + safe_setsockopt(fd, IPPROTO_TCP, TCP_FASTOPEN, (char *)&opt.tfo_queue_length, sizeof(int))) { goto Lerror; } #endif @@ -260,8 +260,7 @@ Server::setup_fd_for_listen(bool non_blocking, const NetProcessor::AcceptOptions #if defined(TCP_MAXSEG) if (NetProcessor::accept_mss > 0) { - if ((res = safe_setsockopt(fd, IPPROTO_TCP, TCP_MAXSEG, reinterpret_cast<char *>(&NetProcessor::accept_mss), sizeof(int))) < - 0) { + if (safe_setsockopt(fd, IPPROTO_TCP, TCP_MAXSEG, reinterpret_cast<char *>(&NetProcessor::accept_mss), sizeof(int)) < 0) { goto Lerror; } } @@ -270,7 +269,7 @@ Server::setup_fd_for_listen(bool non_blocking, const NetProcessor::AcceptOptions #ifdef TCP_DEFER_ACCEPT // set tcp defer accept timeout if it is configured, this will not trigger an accept until there is // data on the socket ready to be read - if (opt.defer_accept > 0 && (res = setsockopt(fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &opt.defer_accept, sizeof(int))) < 0) { + if (opt.defer_accept > 0 && setsockopt(fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &opt.defer_accept, sizeof(int)) < 0) { // FIXME: should we go to the error // goto error; Error("[Server::listen] Defer accept is configured but set failed: %d", errno); @@ -278,7 +277,7 @@ Server::setup_fd_for_listen(bool non_blocking, const NetProcessor::AcceptOptions #endif if (non_blocking) { - if ((res = safe_nonblocking(fd)) < 0) { + if (safe_nonblocking(fd) < 0) { goto Lerror; } } diff --git a/iocore/net/UnixUDPNet.cc b/iocore/net/UnixUDPNet.cc index d2d3a71..64ed2ec 100644 --- a/iocore/net/UnixUDPNet.cc +++ b/iocore/net/UnixUDPNet.cc @@ -647,7 +647,7 @@ UDPNetProcessor::CreateUDPSocket(int *resfd, sockaddr const *remote_addr, Action } fd = res; - if ((res = safe_fcntl(fd, F_SETFL, O_NONBLOCK)) < 0) { + if (safe_fcntl(fd, F_SETFL, O_NONBLOCK) < 0) { goto HardError; } @@ -666,12 +666,12 @@ UDPNetProcessor::CreateUDPSocket(int *resfd, sockaddr const *remote_addr, Action bool succeeded = false; int enable = 1; #ifdef IP_PKTINFO - if ((res = safe_setsockopt(fd, IPPROTO_IP, IP_PKTINFO, reinterpret_cast<char *>(&enable), sizeof(enable))) == 0) { + if (safe_setsockopt(fd, IPPROTO_IP, IP_PKTINFO, reinterpret_cast<char *>(&enable), sizeof(enable)) == 0) { succeeded = true; } #endif #ifdef IP_RECVDSTADDR - if ((res = safe_setsockopt(fd, IPPROTO_IP, IP_RECVDSTADDR, reinterpret_cast<char *>(&enable), sizeof(enable))) == 0) { + if (safe_setsockopt(fd, IPPROTO_IP, IP_RECVDSTADDR, reinterpret_cast<char *>(&enable), sizeof(enable)) == 0) { succeeded = true; } #endif @@ -683,12 +683,12 @@ UDPNetProcessor::CreateUDPSocket(int *resfd, sockaddr const *remote_addr, Action bool succeeded = false; int enable = 1; #ifdef IPV6_PKTINFO - if ((res = safe_setsockopt(fd, IPPROTO_IPV6, IPV6_PKTINFO, reinterpret_cast<char *>(&enable), sizeof(enable))) == 0) { + if (safe_setsockopt(fd, IPPROTO_IPV6, IPV6_PKTINFO, reinterpret_cast<char *>(&enable), sizeof(enable)) == 0) { succeeded = true; } #endif #ifdef IPV6_RECVPKTINFO - if ((res = safe_setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, reinterpret_cast<char *>(&enable), sizeof(enable))) == 0) { + if (safe_setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, reinterpret_cast<char *>(&enable), sizeof(enable)) == 0) { succeeded = true; } #endif @@ -705,7 +705,7 @@ UDPNetProcessor::CreateUDPSocket(int *resfd, sockaddr const *remote_addr, Action goto SoftError; } - if ((res = safe_getsockname(fd, &local_addr.sa, &local_addr_len)) < 0) { + if (safe_getsockname(fd, &local_addr.sa, &local_addr_len) < 0) { Debug("udpnet", "CreateUdpsocket: getsockname didn't work"); goto HardError; } @@ -749,7 +749,7 @@ UDPNetProcessor::UDPBind(Continuation *cont, sockaddr const *addr, int send_bufs goto Lerror; } fd = res; - if ((res = fcntl(fd, F_SETFL, O_NONBLOCK) < 0)) { + if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) { goto Lerror; } @@ -757,12 +757,12 @@ UDPNetProcessor::UDPBind(Continuation *cont, sockaddr const *addr, int send_bufs bool succeeded = false; int enable = 1; #ifdef IP_PKTINFO - if ((res = safe_setsockopt(fd, IPPROTO_IP, IP_PKTINFO, reinterpret_cast<char *>(&enable), sizeof(enable))) == 0) { + if (safe_setsockopt(fd, IPPROTO_IP, IP_PKTINFO, reinterpret_cast<char *>(&enable), sizeof(enable)) == 0) { succeeded = true; } #endif #ifdef IP_RECVDSTADDR - if ((res = safe_setsockopt(fd, IPPROTO_IP, IP_RECVDSTADDR, reinterpret_cast<char *>(&enable), sizeof(enable))) == 0) { + if (safe_setsockopt(fd, IPPROTO_IP, IP_RECVDSTADDR, reinterpret_cast<char *>(&enable), sizeof(enable)) == 0) { succeeded = true; } #endif @@ -774,12 +774,12 @@ UDPNetProcessor::UDPBind(Continuation *cont, sockaddr const *addr, int send_bufs bool succeeded = false; int enable = 1; #ifdef IPV6_PKTINFO - if ((res = safe_setsockopt(fd, IPPROTO_IPV6, IPV6_PKTINFO, reinterpret_cast<char *>(&enable), sizeof(enable))) == 0) { + if (safe_setsockopt(fd, IPPROTO_IPV6, IPV6_PKTINFO, reinterpret_cast<char *>(&enable), sizeof(enable)) == 0) { succeeded = true; } #endif #ifdef IPV6_RECVPKTINFO - if ((res = safe_setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, reinterpret_cast<char *>(&enable), sizeof(enable))) == 0) { + if (safe_setsockopt(fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, reinterpret_cast<char *>(&enable), sizeof(enable)) == 0) { succeeded = true; } #endif @@ -793,17 +793,16 @@ UDPNetProcessor::UDPBind(Continuation *cont, sockaddr const *addr, int send_bufs if (ats_is_ip_multicast(addr)) { int enable_reuseaddr = 1; - if ((res = safe_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<char *>(&enable_reuseaddr), - sizeof(enable_reuseaddr)) < 0)) { + if (safe_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, reinterpret_cast<char *>(&enable_reuseaddr), sizeof(enable_reuseaddr)) < 0) { goto Lerror; } } - if (ats_is_ip6(addr) && (res = safe_setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, SOCKOPT_ON, sizeof(int))) < 0) { + if (ats_is_ip6(addr) && safe_setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, SOCKOPT_ON, sizeof(int)) < 0) { goto Lerror; } - if ((res = socketManager.ink_bind(fd, addr, ats_ip_size(addr))) < 0) { + if (socketManager.ink_bind(fd, addr, ats_ip_size(addr)) < 0) { goto Lerror; } @@ -817,7 +816,7 @@ UDPNetProcessor::UDPBind(Continuation *cont, sockaddr const *addr, int send_bufs Debug("udpnet", "set_dnsbuf_size(%d) failed", send_bufsize); } } - if ((res = safe_getsockname(fd, &myaddr.sa, &myaddr_len)) < 0) { + if (safe_getsockname(fd, &myaddr.sa, &myaddr_len) < 0) { goto Lerror; } n = new UnixUDPConnection(fd); diff --git a/mgmt/api/EventControlMain.cc b/mgmt/api/EventControlMain.cc index 94e6ea0..ff154cb 100644 --- a/mgmt/api/EventControlMain.cc +++ b/mgmt/api/EventControlMain.cc @@ -243,7 +243,7 @@ event_callback_main(void *arg) Debug("event", "[event_callback_main] listen on socket = %d", con_socket_fd); // initialize queue for holding mgmt events - if ((ret = init_mgmt_events()) != TS_ERR_OKAY) { + if (init_mgmt_events() != TS_ERR_OKAY) { return nullptr; } // register callback with alarms processor diff --git a/plugins/esi/esi.cc b/plugins/esi/esi.cc index cf02b3b..e02fa55 100644 --- a/plugins/esi/esi.cc +++ b/plugins/esi/esi.cc @@ -1212,7 +1212,7 @@ maskOsCacheHeaders(TSHttpTxn txnp) TSMLoc field_loc; const char *name, *value; int name_len, value_len, n_field_values; - bool os_response_cacheable, is_cache_header, mask_header; + bool os_response_cacheable, mask_header; string masked_name; os_response_cacheable = true; for (int i = 0; i < n_mime_headers; ++i) { @@ -1223,14 +1223,14 @@ maskOsCacheHeaders(TSHttpTxn txnp) } name = TSMimeHdrFieldNameGet(bufp, hdr_loc, field_loc, &name_len); if (name) { - mask_header = is_cache_header = false; - n_field_values = TSMimeHdrFieldValuesCount(bufp, hdr_loc, field_loc); + mask_header = false; + n_field_values = TSMimeHdrFieldValuesCount(bufp, hdr_loc, field_loc); for (int j = 0; j < n_field_values; ++j) { value = TSMimeHdrFieldValueStringGet(bufp, hdr_loc, field_loc, j, &value_len); if (nullptr == value || !value_len) { TSDebug(DEBUG_TAG, "[%s] Error while getting value #%d of header [%.*s]", __FUNCTION__, j, name_len, name); } else { - is_cache_header = checkForCacheHeader(name, name_len, value, value_len, os_response_cacheable); + bool is_cache_header = checkForCacheHeader(name, name_len, value, value_len, os_response_cacheable); if (!os_response_cacheable) { break; } diff --git a/plugins/experimental/access_control/access_control.cc b/plugins/experimental/access_control/access_control.cc index 7401c5f..3f71c0f 100644 --- a/plugins/experimental/access_control/access_control.cc +++ b/plugins/experimental/access_control/access_control.cc @@ -164,7 +164,7 @@ AccessToken::validateTiming(time_t time) } /* "issued at" time-stamp is currently only for info, so check if the time-stamp is valid only */ - if (!_issuedAt.empty() && 0 == (t = string2int(_issuedAt))) { + if (!_issuedAt.empty() && 0 == string2int(_issuedAt)) { return _state = INVALID_FIELD_VALUE; } diff --git a/plugins/experimental/mp4/mp4_meta.cc b/plugins/experimental/mp4/mp4_meta.cc index 87ae60e..873f5a0 100644 --- a/plugins/experimental/mp4/mp4_meta.cc +++ b/plugins/experimental/mp4/mp4_meta.cc @@ -1012,7 +1012,7 @@ int Mp4Meta::mp4_update_stts_atom(Mp4Trak *trak) { uint32_t i, entries, count, duration, pass; - uint32_t start_sample, left, start_count; + uint32_t start_sample, left; uint32_t key_sample, old_sample; uint64_t start_time, sum; int64_t atom_size; @@ -1022,7 +1022,7 @@ Mp4Meta::mp4_update_stts_atom(Mp4Trak *trak) return -1; } - sum = start_count = 0; + sum = 0; entries = trak->time_to_sample_entries; start_time = this->start * trak->timescale / 1000; diff --git a/proxy/http/remap/RemapConfig.cc b/proxy/http/remap/RemapConfig.cc index 5844dca..24f9247 100644 --- a/proxy/http/remap/RemapConfig.cc +++ b/proxy/http/remap/RemapConfig.cc @@ -981,7 +981,7 @@ remap_parse_config_bti(const char *path, BUILD_TABLE_INFO *bti) --cur_line_tmp; } - if ((cur_line_size = strlen(cur_line)) <= 0 || *cur_line == '#' || *cur_line == '\0') { + if (strlen(cur_line) <= 0 || *cur_line == '#' || *cur_line == '\0') { cur_line = tokLine(nullptr, &tok_state, '\\'); ++cln; continue; @@ -1055,7 +1055,7 @@ remap_parse_config_bti(const char *path, BUILD_TABLE_INFO *bti) new_mapping = new url_mapping(); // apply filter rules if we have to - if ((errStr = process_filter_opt(new_mapping, bti, errStrBuf, sizeof(errStrBuf))) != nullptr) { + if (process_filter_opt(new_mapping, bti, errStrBuf, sizeof(errStrBuf)) != nullptr) { errStr = errStrBuf; goto MAP_ERROR; } diff --git a/tools/jtest/jtest.cc b/tools/jtest/jtest.cc index fa96f4e..eaaa402 100644 --- a/tools/jtest/jtest.cc +++ b/tools/jtest/jtest.cc @@ -1710,7 +1710,6 @@ open_server(unsigned short int port, accept_fn_t accept_fn) struct linger lngr; int sock; int one = 1; - int err = 0; /* Create the socket. */ sock = socket(AF_INET, SOCK_STREAM, 0); @@ -1728,7 +1727,7 @@ open_server(unsigned short int port, accept_fn_t accept_fn) perror((char *)"setsockopt"); exit(EXIT_FAILURE); } - if ((err = bind(sock, (struct sockaddr *)&name, sizeof(name))) < 0) { + if (bind(sock, (struct sockaddr *)&name, sizeof(name)) < 0) { if (errno == EADDRINUSE) { close(sock); return -EADDRINUSE; @@ -1738,13 +1737,13 @@ open_server(unsigned short int port, accept_fn_t accept_fn) } int addrlen = sizeof(name); - if ((err = getsockname(sock, (struct sockaddr *)&name, + if (getsockname(sock, (struct sockaddr *)&name, #if 0 &addrlen #else - (socklen_t *)&addrlen + (socklen_t *)&addrlen #endif - )) < 0) { + ) < 0) { perror("getsockname"); exit(EXIT_FAILURE); } @@ -3871,23 +3870,23 @@ ink_web_decompose_url(const char *src_url, char *sche, char *host, char *port, c const char *end = start + len; const char *ptr = start; const char *ptr2, *temp, *temp2; - const char *sche1, *sche2; - const char *host1, *host2; - const char *port1, *port2; - const char *path1, *path2; - const char *frag1, *frag2; - const char *quer1, *quer2; - const char *para1, *para2; + const char *sche1 = nullptr, *sche2 = nullptr; + const char *host1 = nullptr, *host2 = nullptr; + const char *port1 = nullptr, *port2 = nullptr; + const char *path1 = nullptr, *path2 = nullptr; + const char *frag1 = nullptr, *frag2 = nullptr; + const char *quer1 = nullptr, *quer2 = nullptr; + const char *para1 = nullptr, *para2 = nullptr; bool fail = false; int num; - int sche_exists, host_exists, port_exists, path_exists, frag_exists, quer_exists, para_exists; - int leading_slash; - - sche_exists = host_exists = port_exists = path_exists = 0; - frag_exists = quer_exists = para_exists = 0; - sche1 = sche2 = host1 = host2 = port1 = port2 = nullptr; - path1 = path2 = frag1 = frag2 = quer1 = quer2 = para1 = para2 = nullptr; - leading_slash = 0; + int sche_exists = 0; + int host_exists = 0; + int port_exists = 0; + int path_exists = 0; + int frag_exists = 0; + int quer_exists = 0; + int para_exists = 0; + int leading_slash = 0; temp2 = ptr; /* strip fragments "#" off the end */