2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-24 02:58:38 +00:00
bind/doc/dev/results
Ondřej Surý 58bd26b6cf Update the copyright information in all files in the repository
This commit converts the license handling to adhere to the REUSE
specification.  It specifically:

1. Adds used licnses to LICENSES/ directory

2. Add "isc" template for adding the copyright boilerplate

3. Changes all source files to include copyright and SPDX license
   header, this includes all the C sources, documentation, zone files,
   configuration files.  There are notes in the doc/dev/copyrights file
   on how to add correct headers to the new files.

4. Handle the rest that can't be modified via .reuse/dep5 file.  The
   binary (or otherwise unmodifiable) files could have license places
   next to them in <foo>.license file, but this would lead to cluttered
   repository and most of the files handled in the .reuse/dep5 file are
   system test files.
2022-01-11 09:05:02 +01:00

70 lines
2.1 KiB
Plaintext

<!--
Copyright (C) Internet Systems Consortium, Inc. ("ISC")
SPDX-License-Identifier: MPL-2.0
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, you can obtain one at https://mozilla.org/MPL/2.0/.
See the COPYRIGHT file distributed with this work for additional
information regarding copyright ownership.
-->
Result Codes
The use of global variables or a GetLastError() function to return results
doesn't work well in a multithreaded application. The global variable has
obvious problems, as does a global GetLastError(). A per-object GetLastError()
seems more promising, e.g.
sometype_t s;
sometype_dosomething(s, buffer);
if (sometype_error(s)) {
/* ... */
}
If 's' is shared however this approach doesn't work unless the locking is
done by the caller, e.g.
sometype_lock();
sometype_dosomething(s, buffer);
if (sometype_error(s)) {
/* ... */
}
sometype_unlock();
Those ISC and DNS libraries which have locks almost universally put the
locking inside of the called routines, since it's more convenient for
the calling programmer, makes for a cleaner API, and puts the burden
of locking on the library programmer, who should know best what the
locking needs of the routine are.
Because of this locking style the ISC and DNS libraries typically provide
result information as the return value of the function. E.g.
isc_result_t result;
result = isc_task_send(task, &event);
Note that an explicit result type is used, instead of mixing the error result
type with the normal result type. E.g. the C library routine getc() can
return a character or EOF, but the BIND 9 style keeps the types of the
function's return values separate.
char c;
result = isc_io_getc(stream, &c);
if (result == ISC_R_SUCCESS) {
/* Do something with 'c'. */
} else if (result == ISC_R_EOF) {
/* EOF. */
} else {
/* Some other error. */
}
Functions which cannot fail (assuming the caller has provided valid
arguments) need not return a result type. For example, dns_name_issubdomain()
returns an bool, because it cannot fail.