Commit f10efe39f308066ad1e932e6b16b8133880aee6e

Authored by Jay Berkenbilt
1 parent 0152f254

Tweak README-maintainer about unique_ptr

Also remove trailing whitespace
Showing 1 changed file with 41 additions and 32 deletions
README-maintainer.md
@@ -77,7 +77,7 @@ configurations. @@ -77,7 +77,7 @@ configurations.
77 * The version number on the main branch is whatever the version would 77 * The version number on the main branch is whatever the version would
78 be if the top of the branch were released. If the most recent 78 be if the top of the branch were released. If the most recent
79 release is version a.b.c, then 79 release is version a.b.c, then
80 - 80 +
81 * If there are any ABI-breaking changes since the last release, 81 * If there are any ABI-breaking changes since the last release,
82 main's version is a+1.0.0 82 main's version is a+1.0.0
83 * Else if there is any new public API, main's version is a.b+1.0 83 * Else if there is any new public API, main's version is a.b+1.0
@@ -116,9 +116,9 @@ Building docs from pull requests is also enabled. @@ -116,9 +116,9 @@ Building docs from pull requests is also enabled.
116 116
117 * To test locally, see https://github.com/google/oss-fuzz/tree/master/docs/, 117 * To test locally, see https://github.com/google/oss-fuzz/tree/master/docs/,
118 especially new_project_guide.md. Summary: 118 especially new_project_guide.md. Summary:
119 - 119 +
120 Clone the oss-fuzz project. From the root directory of the repository: 120 Clone the oss-fuzz project. From the root directory of the repository:
121 - 121 +
122 ``` 122 ```
123 python3 infra/helper.py build_image --pull qpdf 123 python3 infra/helper.py build_image --pull qpdf
124 python3 infra/helper.py build_fuzzers [ --sanitizer memory|undefined|address ] qpdf [path-to-qpdf-source] 124 python3 infra/helper.py build_fuzzers [ --sanitizer memory|undefined|address ] qpdf [path-to-qpdf-source]
@@ -126,18 +126,18 @@ Building docs from pull requests is also enabled. @@ -126,18 +126,18 @@ Building docs from pull requests is also enabled.
126 python3 infra/helper.py build_fuzzers --sanitizer coverage qpdf 126 python3 infra/helper.py build_fuzzers --sanitizer coverage qpdf
127 python3 infra/helper.py coverage qpdf 127 python3 infra/helper.py coverage qpdf
128 ``` 128 ```
129 - 129 +
130 To reproduce a test case, build with the correct sanitizer, then run 130 To reproduce a test case, build with the correct sanitizer, then run
131 - 131 +
132 python3 infra/helper.py reproduce qpdf <specific-fuzzer> testcase 132 python3 infra/helper.py reproduce qpdf <specific-fuzzer> testcase
133 - 133 +
134 where fuzzer is the fuzzer used in the crash. 134 where fuzzer is the fuzzer used in the crash.
135 - 135 +
136 The fuzzer is in build/out/qpdf. It can be run with a directory as 136 The fuzzer is in build/out/qpdf. It can be run with a directory as
137 an argument to run against files in a directory. You can use 137 an argument to run against files in a directory. You can use
138 - 138 +
139 qpdf_fuzzer -merge=1 cur new >& /dev/null& 139 qpdf_fuzzer -merge=1 cur new >& /dev/null&
140 - 140 +
141 to add any files from new into cur if they increase coverage. You 141 to add any files from new into cur if they increase coverage. You
142 need to do this with the coverage build (the one with 142 need to do this with the coverage build (the one with
143 --sanitizer coverage) 143 --sanitizer coverage)
@@ -160,18 +160,18 @@ Building docs from pull requests is also enabled. @@ -160,18 +160,18 @@ Building docs from pull requests is also enabled.
160 * Use std::to_string instead of QUtil::int_to_string et al 160 * Use std::to_string instead of QUtil::int_to_string et al
161 161
162 * Use of assert: 162 * Use of assert:
163 - 163 +
164 * Test code: #include <qpdf/assert_test.h> first. 164 * Test code: #include <qpdf/assert_test.h> first.
165 * Debug code: #include <qpdf/assert_debug.h> first and use 165 * Debug code: #include <qpdf/assert_debug.h> first and use
166 qpdf_assert_debug instead of assert. 166 qpdf_assert_debug instead of assert.
167 - 167 +
168 These rules are enforced by the check-assert test. This practices 168 These rules are enforced by the check-assert test. This practices
169 serves to 169 serves to
170 - 170 +
171 * remind us that assert in release code disappears and so should only 171 * remind us that assert in release code disappears and so should only
172 be used for debugging; when doing so use a Debug build 172 be used for debugging; when doing so use a Debug build
173 configuration 173 configuration
174 - 174 +
175 * protect us from using assert in test code without explicitly 175 * protect us from using assert in test code without explicitly
176 removing the NDEBUG definition, since that would cause the assert 176 removing the NDEBUG definition, since that would cause the assert
177 not to actually be testing anything in non-Debug build 177 not to actually be testing anything in non-Debug build
@@ -220,7 +220,7 @@ Building docs from pull requests is also enabled. @@ -220,7 +220,7 @@ Building docs from pull requests is also enabled.
220 dynamic_cast with those, but doing it anyway may help with some 220 dynamic_cast with those, but doing it anyway may help with some
221 strange cases for mingw or with some code generators that may 221 strange cases for mingw or with some code generators that may
222 systematically do this for other reasons. 222 systematically do this for other reasons.
223 - 223 +
224 IMPORTANT NOTE ABOUT QPDF_DLL_CLASS: On mingw, the vtable for a 224 IMPORTANT NOTE ABOUT QPDF_DLL_CLASS: On mingw, the vtable for a
225 class with some virtual methods and no pure virtual methods seems 225 class with some virtual methods and no pure virtual methods seems
226 often (always?) not to be generated if the destructor is inline or 226 often (always?) not to be generated if the destructor is inline or
@@ -229,7 +229,7 @@ Building docs from pull requests is also enabled. @@ -229,7 +229,7 @@ Building docs from pull requests is also enabled.
229 methods, you must declare the destructor in the header without 229 methods, you must declare the destructor in the header without
230 `= default` and provide a non-inline implementation in the source 230 `= default` and provide a non-inline implementation in the source
231 file. Add this comment to the implementation: 231 file. Add this comment to the implementation:
232 - 232 +
233 ```cpp 233 ```cpp
234 // Must be explicit and not inline -- see QPDF_DLL_CLASS in 234 // Must be explicit and not inline -- see QPDF_DLL_CLASS in
235 // README-maintainer 235 // README-maintainer
@@ -255,6 +255,16 @@ Building docs from pull requests is also enabled. @@ -255,6 +255,16 @@ Building docs from pull requests is also enabled.
255 class initialized to nullptr to give the flexibility to add data members 255 class initialized to nullptr to give the flexibility to add data members
256 without breaking the ABI. 256 without breaking the ABI.
257 257
  258 + Note that, as of qpdf 11, many public classes use `std::shared_ptr`
  259 + instead. Changing this to `std::unique_ptr` is ABI-breaking. If the
  260 + class doesn't allow copying, we can switch it to std::unique_ptr and
  261 + let that be the thing that prevents copying. If the intention is to
  262 + allow the object to be copied by value and treated as if it were
  263 + copied by reference, then `std::shared_ptr<Members>` should be used.
  264 + The `JSON` class is an example of this. As a rule, we should avoid
  265 + this design pattern. It's better to make things non-copiable and to
  266 + require explicit use of shared pointers, so going forward,
  267 + `std::unique_ptr` should be preferred.
258 268
259 * Traversal of objects is expensive. It's worth adding some complexity 269 * Traversal of objects is expensive. It's worth adding some complexity
260 to avoid needless traversals of objects. 270 to avoid needless traversals of objects.
@@ -323,13 +333,13 @@ When done, the following should happen: @@ -323,13 +333,13 @@ When done, the following should happen:
323 333
324 * Each year, update copyright notices. This will find all relevant 334 * Each year, update copyright notices. This will find all relevant
325 places (assuming current copyright is from last year): 335 places (assuming current copyright is from last year):
326 - 336 +
327 git --no-pager grep -i -n -P "copyright.*$(expr $(date +%Y) - 1).*berkenbilt" 337 git --no-pager grep -i -n -P "copyright.*$(expr $(date +%Y) - 1).*berkenbilt"
328 - 338 +
329 Also update the copyright in these places: 339 Also update the copyright in these places:
330 * debian package -- search for copyright.*berkenbilt in debian/copyright 340 * debian package -- search for copyright.*berkenbilt in debian/copyright
331 * qtest-driver, TestDriver.pm in qtest source 341 * qtest-driver, TestDriver.pm in qtest source
332 - 342 +
333 Copyright last updated: 2023. 343 Copyright last updated: 2023.
334 344
335 * Take a look at "External Libraries" in TODO to see if we need to 345 * Take a look at "External Libraries" in TODO to see if we need to
@@ -351,24 +361,24 @@ When done, the following should happen: @@ -351,24 +361,24 @@ When done, the following should happen:
351 * Check work `qpdf` project for private issues 361 * Check work `qpdf` project for private issues
352 362
353 * Make sure the code is formatted. 363 * Make sure the code is formatted.
354 - 364 +
355 ./format-code 365 ./format-code
356 366
357 * Run a spelling checker over the source code to catch errors in 367 * Run a spelling checker over the source code to catch errors in
358 variable names, strings, and comments. 368 variable names, strings, and comments.
359 - 369 +
360 ./spell-check 370 ./spell-check
361 - 371 +
362 This uses cspell. Install with `npm install -g cspell`. The output 372 This uses cspell. Install with `npm install -g cspell`. The output
363 of cspell is suitable for use with `M-x grep` in emacs. Add 373 of cspell is suitable for use with `M-x grep` in emacs. Add
364 exceptions to cSpell.json. 374 exceptions to cSpell.json.
365 375
366 * If needed, run large file and image comparison tests by setting 376 * If needed, run large file and image comparison tests by setting
367 these environment variables: 377 these environment variables:
368 - 378 +
369 QPDF_LARGE_FILE_TEST_PATH=/full/path 379 QPDF_LARGE_FILE_TEST_PATH=/full/path
370 QPDF_TEST_COMPARE_IMAGES=1 380 QPDF_TEST_COMPARE_IMAGES=1
371 - 381 +
372 For Windows, use a Windows style path, not an MSYS path for large files. 382 For Windows, use a Windows style path, not an MSYS path for large files.
373 383
374 * If any interfaces were added or changed, check C API to see whether 384 * If any interfaces were added or changed, check C API to see whether
@@ -380,12 +390,12 @@ When done, the following should happen: @@ -380,12 +390,12 @@ When done, the following should happen:
380 390
381 * Double check versions and shared library details. They should 391 * Double check versions and shared library details. They should
382 already be up to date in the code. 392 already be up to date in the code.
383 - 393 +
384 * Make sure version numbers are consistent in the following locations: 394 * Make sure version numbers are consistent in the following locations:
385 * CMakeLists.txt 395 * CMakeLists.txt
386 * include/qpdf/DLL.h 396 * include/qpdf/DLL.h
387 * manual/conf.py 397 * manual/conf.py
388 - 398 +
389 `make_dist` verifies this consistency, and CI fails if they are 399 `make_dist` verifies this consistency, and CI fails if they are
390 inconsistent. 400 inconsistent.
391 401
@@ -402,12 +412,12 @@ When done, the following should happen: @@ -402,12 +412,12 @@ When done, the following should happen:
402 testing, do performance testing. 412 testing, do performance testing.
403 413
404 * Test for performance and binary compatibility: 414 * Test for performance and binary compatibility:
405 - 415 +
406 ./abi-perf-test v<old> @ 416 ./abi-perf-test v<old> @
407 - 417 +
408 Prefix with SKIP_PERF=1 to skip performance test. 418 Prefix with SKIP_PERF=1 to skip performance test.
409 Prefix with SKIP_TESTS=1 to skip test suite run. 419 Prefix with SKIP_TESTS=1 to skip test suite run.
410 - 420 +
411 See "ABI checks" for details about the process. 421 See "ABI checks" for details about the process.
412 End state: 422 End state:
413 * /tmp/check-abi/perf contains the performance comparison 423 * /tmp/check-abi/perf contains the performance comparison
@@ -754,16 +764,16 @@ on. @@ -754,16 +764,16 @@ on.
754 that builds the concatenated string. 764 that builds the concatenated string.
755 765
756 * With 766 * With
757 - 767 +
758 ```cpp 768 ```cpp
759 long_function(long_function( 769 long_function(long_function(
760 args) 770 args)
761 771
762 ``` 772 ```
763 - 773 +
764 clang-format anchors relative to the first function, and emacs 774 clang-format anchors relative to the first function, and emacs
765 anchors relative to the second function. Use 775 anchors relative to the second function. Use
766 - 776 +
767 ```cpp 777 ```cpp
768 long_function( 778 long_function(
769 // line-break 779 // line-break
@@ -780,4 +790,3 @@ that clang-format produces several results. (In git this is commit @@ -780,4 +790,3 @@ that clang-format produces several results. (In git this is commit
780 790
781 The commits that have the bulk of automatic or mechanical reformatting are 791 The commits that have the bulk of automatic or mechanical reformatting are
782 listed in .git-blame-ignore-revs. Any new bulk updates should be added there. 792 listed in .git-blame-ignore-revs. Any new bulk updates should be added there.
783 -