Ensure <sys/socket.h> is included by using "rtc_base/net_helpers.h".
* IWYU export <sys/socket.h> from rtc_base/net_helpers.h. * Add a presubmit check to ensures that <sys/socket.h> is included through net_helpers.h (expect if there is a IWYU pragma or a no-presubmit-check). * Clean up existing includes of <sys/socket.h> Change-Id: I4bc6cce045c046287f8f74f89edfc9321293b274 Bug: b/236227627 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/362082 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Jeremy Leconte <jleconte@google.com> Cr-Commit-Position: refs/heads/main@{#42996}
This commit is contained in:
parent
84273f56d9
commit
83d1f9abd0
25
PRESUBMIT.py
25
PRESUBMIT.py
@ -1051,6 +1051,8 @@ def CommonChecks(input_api, output_api):
|
|||||||
non_third_party_sources))
|
non_third_party_sources))
|
||||||
results.extend(
|
results.extend(
|
||||||
CheckObjcApiSymbols(input_api, output_api, non_third_party_sources))
|
CheckObjcApiSymbols(input_api, output_api, non_third_party_sources))
|
||||||
|
results.extend(
|
||||||
|
CheckSysSocketInclude(input_api, output_api, non_third_party_sources))
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
@ -1157,6 +1159,29 @@ def CheckBannedAbslOptional(input_api, output_api, source_file_filter):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
def CheckSysSocketInclude(input_api, output_api, source_file_filter):
|
||||||
|
sys_socket = re.compile(
|
||||||
|
'^#include <sys/socket.h>((?!IWYU pragma|no-presubmit-check).)*$')
|
||||||
|
file_filter = lambda f: (f.LocalPath().endswith(
|
||||||
|
('.cc', '.h')) and source_file_filter(f))
|
||||||
|
|
||||||
|
files = []
|
||||||
|
for f in input_api.AffectedFiles(include_deletes=False,
|
||||||
|
file_filter=file_filter):
|
||||||
|
for _, line in f.ChangedContents():
|
||||||
|
if sys_socket.search(line):
|
||||||
|
files.append(f.LocalPath())
|
||||||
|
break
|
||||||
|
|
||||||
|
if files:
|
||||||
|
return [
|
||||||
|
output_api.PresubmitError(
|
||||||
|
'PleaseInclude "rtc_base/net_helpers.h" instead of '
|
||||||
|
'<sys/socket.h>.\nAffected files:', files)
|
||||||
|
]
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
def CheckObjcApiSymbols(input_api, output_api, source_file_filter):
|
def CheckObjcApiSymbols(input_api, output_api, source_file_filter):
|
||||||
rtc_objc_export = re.compile(r'RTC_OBJC_EXPORT(.|\n){26}',
|
rtc_objc_export = re.compile(r'RTC_OBJC_EXPORT(.|\n){26}',
|
||||||
re.MULTILINE | re.DOTALL)
|
re.MULTILINE | re.DOTALL)
|
||||||
|
|||||||
@ -48,6 +48,7 @@ rtc_library("network_emulation") {
|
|||||||
"../../../rtc_base:copy_on_write_buffer",
|
"../../../rtc_base:copy_on_write_buffer",
|
||||||
"../../../rtc_base:ip_address",
|
"../../../rtc_base:ip_address",
|
||||||
"../../../rtc_base:net_helper",
|
"../../../rtc_base:net_helper",
|
||||||
|
"../../../rtc_base:net_helpers",
|
||||||
"../../../rtc_base:socket_address",
|
"../../../rtc_base:socket_address",
|
||||||
"../../numerics",
|
"../../numerics",
|
||||||
"../../task_queue",
|
"../../task_queue",
|
||||||
|
|||||||
@ -9,10 +9,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "api/test/network_emulation/network_emulation_interfaces.h"
|
#include "api/test/network_emulation/network_emulation_interfaces.h"
|
||||||
|
|
||||||
#if defined(WEBRTC_POSIX)
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#include "api/units/data_rate.h"
|
#include "api/units/data_rate.h"
|
||||||
@ -20,6 +16,7 @@
|
|||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/copy_on_write_buffer.h"
|
#include "rtc_base/copy_on_write_buffer.h"
|
||||||
#include "rtc_base/net_helper.h"
|
#include "rtc_base/net_helper.h"
|
||||||
|
#include "rtc_base/net_helpers.h"
|
||||||
#include "rtc_base/socket_address.h"
|
#include "rtc_base/socket_address.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|||||||
@ -117,6 +117,7 @@ rtc_source_set("stun_types") {
|
|||||||
"../../rtc_base:digest",
|
"../../rtc_base:digest",
|
||||||
"../../rtc_base:ip_address",
|
"../../rtc_base:ip_address",
|
||||||
"../../rtc_base:logging",
|
"../../rtc_base:logging",
|
||||||
|
"../../rtc_base:net_helpers",
|
||||||
"../../rtc_base:socket_address",
|
"../../rtc_base:socket_address",
|
||||||
"../../system_wrappers:metrics",
|
"../../system_wrappers:metrics",
|
||||||
"//third_party/abseil-cpp/absl/strings:string_view",
|
"//third_party/abseil-cpp/absl/strings:string_view",
|
||||||
|
|||||||
@ -2,6 +2,7 @@ specific_include_rules = {
|
|||||||
"stun\.h": [
|
"stun\.h": [
|
||||||
"+rtc_base/byte_buffer.h",
|
"+rtc_base/byte_buffer.h",
|
||||||
"+rtc_base/ip_address.h",
|
"+rtc_base/ip_address.h",
|
||||||
|
"+rtc_base/net_helpers.h",
|
||||||
"+rtc_base/socket_address.h",
|
"+rtc_base/socket_address.h",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#if defined(WEBRTC_POSIX)
|
#if defined(WEBRTC_POSIX)
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@ -36,6 +35,7 @@
|
|||||||
#include "rtc_base/ip_address.h"
|
#include "rtc_base/ip_address.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
#include "rtc_base/message_digest.h"
|
#include "rtc_base/message_digest.h"
|
||||||
|
#include "rtc_base/net_helpers.h"
|
||||||
#include "rtc_base/socket_address.h"
|
#include "rtc_base/socket_address.h"
|
||||||
#include "system_wrappers/include/metrics.h"
|
#include "system_wrappers/include/metrics.h"
|
||||||
|
|
||||||
|
|||||||
@ -14,9 +14,6 @@
|
|||||||
// This file contains classes for dealing with the STUN protocol, as specified
|
// This file contains classes for dealing with the STUN protocol, as specified
|
||||||
// in RFC 5389, and its descendants.
|
// in RFC 5389, and its descendants.
|
||||||
|
|
||||||
#if defined(WEBRTC_POSIX)
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@ -30,6 +27,7 @@
|
|||||||
#include "rtc_base/byte_buffer.h"
|
#include "rtc_base/byte_buffer.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/ip_address.h"
|
#include "rtc_base/ip_address.h"
|
||||||
|
#include "rtc_base/net_helpers.h"
|
||||||
#include "rtc_base/socket_address.h"
|
#include "rtc_base/socket_address.h"
|
||||||
|
|
||||||
namespace cricket {
|
namespace cricket {
|
||||||
|
|||||||
@ -792,6 +792,7 @@ if (is_linux || is_chromeos || is_win) {
|
|||||||
]
|
]
|
||||||
deps = [
|
deps = [
|
||||||
"../rtc_base:checks",
|
"../rtc_base:checks",
|
||||||
|
"../rtc_base:net_helpers",
|
||||||
"../rtc_base:stringutils",
|
"../rtc_base:stringutils",
|
||||||
"../system_wrappers:field_trial",
|
"../system_wrappers:field_trial",
|
||||||
"../test:field_trial",
|
"../test:field_trial",
|
||||||
|
|||||||
@ -11,7 +11,7 @@
|
|||||||
#include "examples/androidvoip/jni/android_voip_client.h"
|
#include "examples/androidvoip/jni/android_voip_client.h"
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h> // no-presubmit-check
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|||||||
@ -11,14 +11,16 @@
|
|||||||
#ifndef EXAMPLES_PEERCONNECTION_SERVER_DATA_SOCKET_H_
|
#ifndef EXAMPLES_PEERCONNECTION_SERVER_DATA_SOCKET_H_
|
||||||
#define EXAMPLES_PEERCONNECTION_SERVER_DATA_SOCKET_H_
|
#define EXAMPLES_PEERCONNECTION_SERVER_DATA_SOCKET_H_
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "rtc_base/net_helpers.h"
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#include <winsock2.h>
|
|
||||||
typedef int socklen_t;
|
typedef int socklen_t;
|
||||||
typedef SOCKET NativeSocket;
|
typedef SOCKET NativeSocket;
|
||||||
#else
|
#else
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
#define closesocket close
|
#define closesocket close
|
||||||
typedef int NativeSocket;
|
typedef int NativeSocket;
|
||||||
|
|
||||||
@ -31,7 +33,6 @@ typedef int NativeSocket;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
class SocketBase {
|
class SocketBase {
|
||||||
public:
|
public:
|
||||||
|
|||||||
@ -1158,6 +1158,7 @@ rtc_source_set("peer_connection") {
|
|||||||
"../rtc_base:logging",
|
"../rtc_base:logging",
|
||||||
"../rtc_base:macromagic",
|
"../rtc_base:macromagic",
|
||||||
"../rtc_base:net_helper",
|
"../rtc_base:net_helper",
|
||||||
|
"../rtc_base:net_helpers",
|
||||||
"../rtc_base:network",
|
"../rtc_base:network",
|
||||||
"../rtc_base:network_constants",
|
"../rtc_base:network_constants",
|
||||||
"../rtc_base:socket_address",
|
"../rtc_base:socket_address",
|
||||||
|
|||||||
@ -109,6 +109,7 @@
|
|||||||
#include "rtc_base/ip_address.h"
|
#include "rtc_base/ip_address.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
#include "rtc_base/net_helper.h"
|
#include "rtc_base/net_helper.h"
|
||||||
|
#include "rtc_base/net_helpers.h"
|
||||||
#include "rtc_base/network.h"
|
#include "rtc_base/network.h"
|
||||||
#include "rtc_base/network_constants.h"
|
#include "rtc_base/network_constants.h"
|
||||||
#include "rtc_base/rtc_certificate.h"
|
#include "rtc_base/rtc_certificate.h"
|
||||||
|
|||||||
@ -1064,6 +1064,7 @@ rtc_library("socket") {
|
|||||||
":buffer",
|
":buffer",
|
||||||
":checks",
|
":checks",
|
||||||
":macromagic",
|
":macromagic",
|
||||||
|
":net_helpers",
|
||||||
":socket_address",
|
":socket_address",
|
||||||
"../api/units:timestamp",
|
"../api/units:timestamp",
|
||||||
"./network:ecn_marking",
|
"./network:ecn_marking",
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h> // no-presubmit-check
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/utsname.h>
|
#include <sys/utsname.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
#define RTC_BASE_IFADDRS_ANDROID_H_
|
#define RTC_BASE_IFADDRS_ANDROID_H_
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h> // no-presubmit-check
|
||||||
|
|
||||||
// Implementation of getifaddrs for Android.
|
// Implementation of getifaddrs for Android.
|
||||||
// Fills out a list of ifaddr structs (see below) which contain information
|
// Fills out a list of ifaddr structs (see below) which contain information
|
||||||
|
|||||||
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
#if defined(WEBRTC_POSIX)
|
#if defined(WEBRTC_POSIX)
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#ifdef OPENBSD
|
#ifdef OPENBSD
|
||||||
|
|||||||
@ -15,12 +15,10 @@
|
|||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
|
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
#endif
|
#endif
|
||||||
#if defined(WEBRTC_WIN)
|
#if defined(WEBRTC_WIN)
|
||||||
#include <winsock2.h>
|
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
#endif
|
#endif
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -32,6 +30,7 @@
|
|||||||
#include "rtc_base/win32.h"
|
#include "rtc_base/win32.h"
|
||||||
#endif
|
#endif
|
||||||
#include "absl/strings/string_view.h"
|
#include "absl/strings/string_view.h"
|
||||||
|
#include "rtc_base/net_helpers.h"
|
||||||
#include "rtc_base/system/rtc_export.h"
|
#include "rtc_base/system/rtc_export.h"
|
||||||
namespace rtc {
|
namespace rtc {
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@
|
|||||||
#define RTC_BASE_NET_HELPERS_H_
|
#define RTC_BASE_NET_HELPERS_H_
|
||||||
|
|
||||||
#if defined(WEBRTC_POSIX)
|
#if defined(WEBRTC_POSIX)
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h> // IWYU pragma: export
|
||||||
#elif WEBRTC_WIN
|
#elif WEBRTC_WIN
|
||||||
#include <winsock2.h> // NOLINT
|
#include <winsock2.h> // NOLINT
|
||||||
|
|
||||||
|
|||||||
@ -20,17 +20,13 @@
|
|||||||
#if defined(WEBRTC_POSIX)
|
#if defined(WEBRTC_POSIX)
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#define SOCKET_EACCES EACCES
|
#define SOCKET_EACCES EACCES
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WEBRTC_WIN)
|
|
||||||
#include "rtc_base/win32.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "api/units/timestamp.h"
|
#include "api/units/timestamp.h"
|
||||||
#include "rtc_base/buffer.h"
|
#include "rtc_base/buffer.h"
|
||||||
|
#include "rtc_base/net_helpers.h"
|
||||||
#include "rtc_base/network/ecn_marking.h"
|
#include "rtc_base/network/ecn_marking.h"
|
||||||
#include "rtc_base/socket_address.h"
|
#include "rtc_base/socket_address.h"
|
||||||
#include "rtc_base/system/rtc_export.h"
|
#include "rtc_base/system/rtc_export.h"
|
||||||
|
|||||||
@ -15,7 +15,6 @@
|
|||||||
|
|
||||||
#if defined(WEBRTC_POSIX)
|
#if defined(WEBRTC_POSIX)
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#if defined(OPENBSD)
|
#if defined(OPENBSD)
|
||||||
#include <netinet/in_systm.h>
|
#include <netinet/in_systm.h>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user