Skip to content

Commit

Permalink
Cleanup GCCToolChain
Browse files Browse the repository at this point in the history
Fixed some possible null pointer uses, detected by a statical code
analysis tool.
  • Loading branch information
ewaterlander authored and jonahgraham committed Jun 6, 2023
1 parent 9e10c79 commit 9dcaf50
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -280,11 +280,11 @@ public IExtendedScannerInfo getScannerInfo(IBuildConfiguration buildConfig, List
}

List<String> commandLine = new ArrayList<>();
if (command.isAbsolute()) {
commandLine.add(command.toString());
} else {
commandLine.add(getCommandPath(command).toString());
Path commandPath = getCommandPath(command);
if (commandPath == null) {
throw new NullPointerException("Cannot obtain full command path for command " + command); //$NON-NLS-1$
}
commandLine.add(commandPath.toString());

if (baseScannerInfo != null) {
if (baseScannerInfo.getIncludePaths() != null) {
Expand Down Expand Up @@ -415,11 +415,11 @@ public IExtendedScannerInfo getDefaultScannerInfo(IBuildConfiguration buildConfi
// Pick the first one
Path command = Paths.get(commands[0]);
List<String> commandLine = new ArrayList<>();
if (command.isAbsolute()) {
commandLine.add(command.toString());
} else {
commandLine.add(getCommandPath(command).toString());
Path commandPath = getCommandPath(command);
if (commandPath == null) {
throw new NullPointerException("Cannot obtain full command path for command " + command); //$NON-NLS-1$
}
commandLine.add(commandPath.toString());

if (baseScannerInfo != null) {
if (baseScannerInfo.getIncludePaths() != null) {
Expand Down Expand Up @@ -535,7 +535,9 @@ public void run() {
} catch (InterruptedException e) {
Activator.log(e);
}
Files.delete(tmpFile);
if (tmpFile != null) {
Files.delete(tmpFile);
}

return new ExtendedScannerInfo(symbols, includePath.toArray(new String[includePath.size()]));
}
Expand Down Expand Up @@ -649,7 +651,7 @@ public String[] getCompileCommands(ILanguage language) {
private Set<String> getResourcesFileExtensions() {
IContentTypeManager manager = Platform.getContentTypeManager();

Set<String> fileExts = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
Set<String> fileExts = new TreeSet<>(String.CASE_INSENSITIVE_ORDER);

IContentType contentTypeCpp = manager.getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
fileExts.addAll(Arrays.asList(contentTypeCpp.getFileSpecs(IContentType.FILE_EXTENSION_SPEC)));
Expand Down

0 comments on commit 9dcaf50

Please sign in to comment.