Closed Bug 1714307 Opened 3 years ago Closed 3 years ago

Autofix static-analysis warnings in netwerk/

Categories

(Core :: Networking, task, P2)

task

Tracking

()

RESOLVED FIXED
Iteration:
91.1 - May 31 - Jun 13
Tracking Status
firefox91 --- fixed

People

(Reporter: valentin, Assigned: valentin)

References

Details

(Whiteboard: [necko-triaged])

Attachments

(3 files)

Simply running ./mach static-analysis check netwerk/ --fix improves things a bit.
I also plan to run modernize-use-default-member-init after initial autofixes land.

Iteration: --- → 91.1 - May 31 - Jun 13
Keywords: leave-open
Pushed by valentin.gosu@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/6a301646ecc9
Autofix static-analysis warnings in netwerk/ r=necko-reviewers,kershaw

This changeset is the result of adding modernize-use-default-member-init to
tools/clang-tidy/config.yaml then proceeding to run
./mach static-analysis check netwerk/ --fix
I then went through the resulting fix and manually updated all of the member
variables which were missed due to them having a non-trivial constructor.

Note that the tool was only run on Linux, so code that only runs on some
platforms may have been missed.

The member variables that are still initialized in the contructor definition
are:

  • bitfields (not all currently supported compilers allow default-member-init
  • variables that are initialized via a parameter
  • variables that use code not visible in the header file

There are a few advantages to landing this change:

  • fewer lines of code - now declaration is in the same place as initialization
    this also makes it easier to see when looking at the header.
  • it makes it harder to miss initializing a member when adding a new contructor
  • variables that depend on an include guard look much nicer now

Additionally I removed some unnecessary reinitialization of NetAddr members
(it has a constructor that does that now), and changed nsWifiScannerDBus to
use the thread-safe strtok_r instead of strtok.

Pushed by valentin.gosu@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/6e00f8bd2acc
Run modernize-use-default-member-init --fix check on netwerk r=necko-reviewers,kershaw

Backed out for causing hazard bustage.

backout: https://hg.mozilla.org/integration/autoland/rev/f9a898a9f06620d243eb67cb952f89f162a39b0b

push: https://treeherder.mozilla.org/jobs?repo=autoland&selectedTaskRun=cAcitJVdS1e6d_CL7ULsYw.0&revision=6e00f8bd2acce363c60e022eedb43421382edd57&group_state=expanded

failure log: https://treeherder.mozilla.org/logviewer?job_id=342290046&repo=autoland&lineNumber=12672

[task 2021-06-09T18:38:21.909Z] 29:57.02 startupcache
[task 2021-06-09T18:38:22.636Z] 29:57.74 make[4]: *** Deleting file 'nsHttpHandler.o'
[task 2021-06-09T18:38:22.637Z] 29:57.74 *** WARNING *** there are active plugins, do not report this as a bug unless you can reproduce it without enabling any plugins.
[task 2021-06-09T18:38:22.637Z] 29:57.74 Event                            | Plugins
[task 2021-06-09T18:38:22.637Z] 29:57.74 PLUGIN_FINISH_TYPE               | xgill
[task 2021-06-09T18:38:22.639Z] 29:57.74 PLUGIN_FINISH_DECL               | xgill
[task 2021-06-09T18:38:22.640Z] 29:57.74 PLUGIN_FINISH_UNIT               | xgill
[task 2021-06-09T18:38:22.640Z] 29:57.74 PLUGIN_PRE_GENERICIZE            | xgill
[task 2021-06-09T18:38:22.640Z] 29:57.74 PLUGIN_ATTRIBUTES                | xgill
[task 2021-06-09T18:38:22.640Z] 29:57.74 PLUGIN_START_UNIT                | xgill
[task 2021-06-09T18:38:22.640Z] 29:57.74 /builds/worker/checkouts/gecko/netwerk/protocol/http/nsHttpHandler.cpp: In destructor 'virtual mozilla::net::nsHttpHandler::~nsHttpHandler()':
[task 2021-06-09T18:38:22.640Z] 29:57.74 /builds/worker/checkouts/gecko/netwerk/protocol/http/nsHttpHandler.cpp:265:1: internal compiler error: in XIL_GetFunctionFields, at type.c:492
[task 2021-06-09T18:38:22.640Z] 29:57.74   265 | }
[task 2021-06-09T18:38:22.640Z] 29:57.74       | ^
[task 2021-06-09T18:38:22.641Z] 29:57.74 0x7f53b5f418b7 XIL_GetFunctionFields(tree_node*)
[task 2021-06-09T18:38:22.641Z] 29:57.74 	/builds/worker/fetches/sixgill/gcc/type.c:492
[task 2021-06-09T18:38:22.641Z] 29:57.74 0x7f53b5f419fc XIL_GetFunctionFields(tree_node*)
[task 2021-06-09T18:38:22.641Z] 29:57.74 	/builds/worker/fetches/sixgill/gcc/type.c:516
[task 2021-06-09T18:38:22.641Z] 29:57.74 0x7f53b5f4287c XIL_TranslateRecordType(tree_node*)
[task 2021-06-09T18:38:22.641Z] 29:57.74 	/builds/worker/fetches/sixgill/gcc/type.c:776
[task 2021-06-09T18:38:22.641Z] 29:57.74 0x7f53b5f43291 generate_TranslateType(tree_node*)
[task 2021-06-09T18:38:22.641Z] 29:57.74 	/builds/worker/fetches/sixgill/gcc/type.c:947
[task 2021-06-09T18:38:22.641Z] 29:57.74 0x7f53b5f4033c XIL_TranslatePointerType(tree_node*)
[task 2021-06-09T18:38:22.641Z] 29:57.74 	/builds/worker/fetches/sixgill/gcc/type.c:71
[task 2021-06-09T18:38:22.641Z] 29:57.74 0x7f53b5f4325e generate_TranslateType(tree_node*)
[task 2021-06-09T18:38:22.642Z] 29:57.74 	/builds/worker/fetches/sixgill/gcc/type.c:936
[task 2021-06-09T18:38:22.642Z] 29:57.74 0x7f53b5f42b35 XIL_TranslateFunctionType(tree_node*)
[task 2021-06-09T18:38:22.642Z] 29:57.74 	/builds/worker/fetches/sixgill/gcc/type.c:817
[task 2021-06-09T18:38:22.642Z] 29:57.74 0x7f53b5f432a2 generate_TranslateType(tree_node*)
[task 2021-06-09T18:38:22.642Z] 29:57.74 	/builds/worker/fetches/sixgill/gcc/type.c:951
[task 2021-06-09T18:38:22.642Z] 29:57.74 0x7f53b5f43847 generate_TranslateField(tree_node*)
[task 2021-06-09T18:38:22.642Z] 29:57.74 	/builds/worker/fetches/sixgill/gcc/type.c:1067
[task 2021-06-09T18:38:22.642Z] 29:57.74 0x7f53b5f41e10 XIL_GetFunctionFields(tree_node*)
[task 2021-06-09T18:38:22.642Z] 29:57.74 	/builds/worker/fetches/sixgill/gcc/type.c:594
[task 2021-06-09T18:38:22.642Z] 29:57.74 0x7f53b5f4f3dd XIL_GetVTableField
[task 2021-06-09T18:38:22.642Z] 29:57.75 	/builds/worker/fetches/sixgill/gcc/tree.c:1565
[task 2021-06-09T18:38:22.643Z] 29:57.75 0x7f53b5f537ce XIL_TranslateExpression(XIL_TreeEnv*, tree_node*)
[task 2021-06-09T18:38:22.643Z] 29:57.75 	/builds/worker/fetches/sixgill/gcc/tree.c:2232
[task 2021-06-09T18:38:22.643Z] 29:57.75 0x7f53b5f548e2 generate_TranslateTree(XIL_TreeEnv*, tree_node*)
[task 2021-06-09T18:38:22.643Z] 29:57.75 	/builds/worker/fetches/sixgill/gcc/tree.c:2437
[task 2021-06-09T18:38:22.643Z] 29:57.75 0x7f53b5f504f0 XIL_TranslateExpression(XIL_TreeEnv*, tree_node*)
[task 2021-06-09T18:38:22.643Z] 29:57.75 	/builds/worker/fetches/sixgill/gcc/tree.c:1734
[task 2021-06-09T18:38:22.643Z] 29:57.75 0x7f53b5f548e2 generate_TranslateTree(XIL_TreeEnv*, tree_node*)
[task 2021-06-09T18:38:22.643Z] 29:57.75 	/builds/worker/fetches/sixgill/gcc/tree.c:2437
[task 2021-06-09T18:38:22.643Z] 29:57.75 0x7f53b5f4a3fd XIL_TranslateUnary(XIL_TreeEnv*, tree_node*)
[task 2021-06-09T18:38:22.644Z] 29:57.75 	/builds/worker/fetches/sixgill/gcc/tree.c:573
[task 2021-06-09T18:38:22.644Z] 29:57.75 0x7f53b5f54888 generate_TranslateTree(XIL_TreeEnv*, tree_node*)
[task 2021-06-09T18:38:22.644Z] 29:57.75 	/builds/worker/fetches/sixgill/gcc/tree.c:2427
[task 2021-06-09T18:38:22.644Z] 29:57.75 0x7f53b5f542a4 XIL_TranslateExpression(XIL_TreeEnv*, tree_node*)
[task 2021-06-09T18:38:22.644Z] 29:57.75 	/builds/worker/fetches/sixgill/gcc/tree.c:2357
[task 2021-06-09T18:38:22.644Z] 29:57.75 0x7f53b5f548e2 generate_TranslateTree(XIL_TreeEnv*, tree_node*)
[task 2021-06-09T18:38:22.644Z] 29:57.75 	/builds/worker/fetches/sixgill/gcc/tree.c:2437
[task 2021-06-09T18:38:22.644Z] 29:57.75 0x7f53b5f54137 XIL_TranslateExpression(XIL_TreeEnv*, tree_node*)
[task 2021-06-09T18:38:22.644Z] 29:57.75 	/builds/worker/fetches/sixgill/gcc/tree.c:2332
[task 2021-06-09T18:38:22.645Z] 29:57.75 Please submit a full bug report,
[task 2021-06-09T18:38:22.645Z] 29:57.75 with preprocessed source if appropriate.
[task 2021-06-09T18:38:22.645Z] 29:57.75 Please include the complete backtrace with any bug report.
[task 2021-06-09T18:38:22.645Z] 29:57.75 See <https://gcc.gnu.org/bugs/> for instructions.
[..]
[task 2021-06-09T18:42:08.414Z] build finished (status 2): Wed Jun  9 18:42:08 2021
[task 2021-06-09T18:42:08.414Z] Exiting run_complete with status 2
[task 2021-06-09T18:42:08.414Z] Traceback (most recent call last):
[task 2021-06-09T18:42:08.414Z]   File "/builds/worker/checkouts/gecko/js/src/devtools/rootAnalysis/analyze.py", line 414, in <module>
[task 2021-06-09T18:42:08.416Z]     run_job(step, data)
[task 2021-06-09T18:42:08.416Z]   File "/builds/worker/checkouts/gecko/js/src/devtools/rootAnalysis/analyze.py", line 244, in run_job
[task 2021-06-09T18:42:08.416Z]     subprocess.check_call(command, env=env(config))
[task 2021-06-09T18:42:08.416Z]   File "/usr/lib/python2.7/subprocess.py", line 190, in check_call
[task 2021-06-09T18:42:08.416Z]     raise CalledProcessError(retcode, cmd)
[task 2021-06-09T18:42:08.416Z] subprocess.CalledProcessError: Command '['/builds/worker/checkouts/gecko/js/src/devtools/rootAnalysis/run_complete', '--foreground', '--no-logs', '--build-root=/builds/worker/workspace/obj-analyzed-browser', '--wrap-dir=/builds/worker/fetches/sixgill/usr/libexec/sixgill/scripts/wrap_gcc', '--work-dir=work', '-b', '/builds/worker/fetches/sixgill/usr/bin', '--buildcommand=/builds/worker/checkouts/gecko/mach hazards compile --application=browser --haz-objdir=/builds/worker/workspace/obj-analyzed-browser', '.']' returned non-zero exit status 2
[task 2021-06-09T18:42:08.423Z] Error running mach:
[task 2021-06-09T18:42:08.423Z] 
[task 2021-06-09T18:42:08.423Z]     ['hazards', 'gather', '--application=browser', '--haz-objdir=/builds/worker/workspace/obj-analyzed-browser', '--work-dir=/builds/worker/workspace/haz-browser']
[task 2021-06-09T18:42:08.423Z] 
[task 2021-06-09T18:42:08.423Z] The error occurred in code that was called by the mach command. This is either
[task 2021-06-09T18:42:08.423Z] a bug in the called code itself or in the way that mach is calling it.
[task 2021-06-09T18:42:08.423Z] You can invoke |./mach busted| to check if this issue is already on file. If it
[task 2021-06-09T18:42:08.423Z] isn't, please use |./mach busted file hazards| to report it. If |./mach busted| is
[task 2021-06-09T18:42:08.423Z] misbehaving, you can also inspect the dependencies of bug 1543241.
[task 2021-06-09T18:42:08.423Z] 
[task 2021-06-09T18:42:08.423Z] If filing a bug, please include the full output of mach, including this error
[task 2021-06-09T18:42:08.423Z] message.
[task 2021-06-09T18:42:08.423Z] 
[task 2021-06-09T18:42:08.423Z] The details of the failure are as follows:
[task 2021-06-09T18:42:08.423Z] 
[task 2021-06-09T18:42:08.423Z] Exception: Process executed with non-0 exit code 1: ['/builds/worker/checkouts/gecko/js/src/devtools/rootAnalysis/analyze.py', 'dbs', '--upto', 'dbs', '-v', '--buildcommand=/builds/worker/checkouts/gecko/mach hazards compile --application=browser --haz-objdir=/builds/worker/workspace/obj-analyzed-browser']
[task 2021-06-09T18:42:08.423Z] 
[task 2021-06-09T18:42:08.423Z]   File "/builds/worker/checkouts/gecko/js/src/devtools/rootAnalysis/mach_commands.py", line 259, in gather_hazard_data
[task 2021-06-09T18:42:08.423Z]     return self.run_process(args=args, cwd=work_dir, pass_thru=True)
[task 2021-06-09T18:42:08.423Z]   File "/builds/worker/checkouts/gecko/python/mach/mach/mixin/process.py", line 177, in run_process
[task 2021-06-09T18:42:08.423Z]     "Process executed with non-0 exit code %d: %s" % (status, args)
[task 2021-06-09T18:42:08.462Z] + grab_artifacts
[task 2021-06-09T18:42:08.462Z] + local artifacts
[task 2021-06-09T18:42:08.462Z] + artifacts=/builds/worker/artifacts
[task 2021-06-09T18:42:08.462Z] + '[' -d /builds/worker/workspace/haz-browser ']'
[task 2021-06-09T18:42:08.463Z] + cd /builds/worker/workspace/haz-browser
[task 2021-06-09T18:42:08.463Z] + ls -lah
[task 2021-06-09T18:42:08.466Z] total 4.4G
Flags: needinfo?(valentin.gosu)
Pushed by valentin.gosu@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/453a12cf60be
Run modernize-use-default-member-init --fix check on netwerk r=necko-reviewers,kershaw

I landed the part of the patch that doesn't trigger the hazard build failure. Currently bisecting the patch to find which file is causing the failure.

Flags: needinfo?(valentin.gosu)
Depends on: 1716035
Pushed by valentin.gosu@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/2e0259e63913
Run modernize-use-default-member-init --fix check on netwerk/protocol/http/ r=necko-reviewers,kershaw
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Summary: Fix static-analysis warnings in netwerk/ → Autofix static-analysis warnings in netwerk/
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: