Skip to content

Commit 0dcc1d4

Browse files
committed
src: migrate deprecated c-ares APIs to modern replacements
1 parent fc4b334 commit 0dcc1d4

2 files changed

Lines changed: 26 additions & 19 deletions

File tree

src/crypto/crypto_x509.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,12 @@ ManagedX509::ManagedX509(const ManagedX509& that) {
5959
}
6060

6161
ManagedX509& ManagedX509::operator=(const ManagedX509& that) {
62-
cert_.reset(that.get());
63-
if (cert_) [[likely]]
64-
X509_up_ref(cert_.get());
62+
if (this == &that) return *this;
63+
64+
X509* cert = that.get();
65+
if (cert) [[likely]]
66+
X509_up_ref(cert);
67+
cert_.reset(cert);
6568
return *this;
6669
}
6770

test/parallel/test-dns.js

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -123,15 +123,11 @@ const ports = [
123123
'4.4.4.4:53',
124124
'[2001:4860:4860::8888]:53',
125125
'103.238.225.181:666',
126-
'[fe80::483a:5aff:fee6:1f04]:666',
127-
'[fe80::483a:5aff:fee6:1f04]',
128126
];
129127
const portsExpected = [
130128
'4.4.4.4',
131129
'2001:4860:4860::8888',
132130
'103.238.225.181:666',
133-
'[fe80::483a:5aff:fee6:1f04]:666',
134-
'fe80::483a:5aff:fee6:1f04',
135131
];
136132
dns.setServers(ports);
137133
assert.deepStrictEqual(dns.getServers(), portsExpected);
@@ -144,7 +140,7 @@ assert.deepStrictEqual(dns.getServers(), []);
144140
code: 'ERR_INVALID_ARG_TYPE',
145141
name: 'TypeError',
146142
message: 'The "rrtype" argument must be of type string. ' +
147-
'Received an instance of Array'
143+
'Received an instance of Array'
148144
};
149145
assert.throws(() => {
150146
dns.resolve('example.com', [], common.mustNotCall());
@@ -158,7 +154,7 @@ assert.deepStrictEqual(dns.getServers(), []);
158154
code: 'ERR_INVALID_ARG_TYPE',
159155
name: 'TypeError',
160156
message: 'The "name" argument must be of type string. ' +
161-
'Received undefined'
157+
'Received undefined'
162158
};
163159
assert.throws(() => {
164160
dnsPromises.resolve();
@@ -349,7 +345,7 @@ assert.throws(() => {
349345
code: 'ERR_MISSING_ARGS',
350346
name: 'TypeError',
351347
message: 'The "address", "port", and "callback" arguments must be ' +
352-
'specified'
348+
'specified'
353349
};
354350

355351
assert.throws(() => dns.lookupService('0.0.0.0'), err);
@@ -374,7 +370,7 @@ assert.throws(() => {
374370
}, err);
375371
}
376372

377-
[null, undefined, 65538, 'test', NaN, Infinity, Symbol(), 0n, true, false, '', () => {}, {}].forEach((port) => {
373+
[null, undefined, 65538, 'test', NaN, Infinity, Symbol(), 0n, true, false, '', () => { }, {}].forEach((port) => {
378374
const err = {
379375
code: 'ERR_SOCKET_BAD_PORT',
380376
name: 'RangeError'
@@ -407,7 +403,8 @@ assert.throws(() => {
407403

408404
{
409405
const cases = [
410-
{ method: 'resolveAny',
406+
{
407+
method: 'resolveAny',
411408
answers: [
412409
{ type: 'A', address: '1.2.3.4', ttl: 0 },
413410
{ type: 'AAAA', address: '::42', ttl: 0 },
@@ -424,17 +421,23 @@ assert.throws(() => {
424421
expire: 1800,
425422
minttl: 3333333333
426423
},
427-
] },
424+
]
425+
},
428426

429-
{ method: 'resolve4',
427+
{
428+
method: 'resolve4',
430429
options: { ttl: true },
431-
answers: [ { type: 'A', address: '1.2.3.4', ttl: 0 } ] },
430+
answers: [{ type: 'A', address: '1.2.3.4', ttl: 0 }]
431+
},
432432

433-
{ method: 'resolve6',
433+
{
434+
method: 'resolve6',
434435
options: { ttl: true },
435-
answers: [ { type: 'AAAA', address: '::42', ttl: 0 } ] },
436+
answers: [{ type: 'AAAA', address: '::42', ttl: 0 }]
437+
},
436438

437-
{ method: 'resolveSoa',
439+
{
440+
method: 'resolveSoa',
438441
answers: [
439442
{
440443
type: 'SOA',
@@ -446,7 +449,8 @@ assert.throws(() => {
446449
expire: 1800,
447450
minttl: 3333333333
448451
},
449-
] },
452+
]
453+
},
450454
];
451455

452456
const server = dgram.createSocket('udp4');

0 commit comments

Comments
 (0)