mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-09 15:28:14 +02:00
fixed uninitialized function results
git-svn-id: trunk@16088 -
This commit is contained in:
parent
d27b3adf0d
commit
c81aab571f
@ -2965,7 +2965,7 @@ end;
|
||||
function TextBeginsWith(Txt: PChar; TxtLen: integer; StartTxt: PChar;
|
||||
StartTxtLen: integer; CaseSensitive: boolean): boolean;
|
||||
begin
|
||||
if TxtLen<StartTxtLen then exit;
|
||||
if TxtLen<StartTxtLen then exit(false);
|
||||
Result:=CompareText(Txt,StartTxtLen,StartTxt,StartTxtLen,CaseSensitive)=0;
|
||||
end;
|
||||
|
||||
|
@ -177,6 +177,7 @@ function AtomPosition(StartPos, EndPos: integer): TAtomPosition;
|
||||
begin
|
||||
Result.StartPos:=StartPos;
|
||||
Result.EndPos:=EndPos;
|
||||
Result.Flag:=cafNone;
|
||||
end;
|
||||
|
||||
function CodePosition(P: integer; Code: TCodeBuffer): TCodePosition;
|
||||
@ -406,6 +407,7 @@ begin
|
||||
else begin
|
||||
Result.StartPos:=1;
|
||||
Result.EndPos:=1;
|
||||
Result.Flag:=cafNone;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -2099,7 +2099,7 @@ var
|
||||
function HasCodeBetween(FromPos, ToPos: integer): boolean;
|
||||
begin
|
||||
if FromPos<1 then FromPos:=1;
|
||||
if FromPos>ToPos then exit;
|
||||
if FromPos>ToPos then exit(false);
|
||||
MoveCursorToPos(FromPos);
|
||||
ReadNextAtom;
|
||||
Result:=AtomStart<ToPos;
|
||||
|
@ -1817,7 +1817,7 @@ end;
|
||||
function TFindDeclarationTool.FindUnitCaseInsensitive(var AnUnitName,
|
||||
AnUnitInFilename: string): string;
|
||||
begin
|
||||
if not CheckDirectoryCache then exit;
|
||||
if not CheckDirectoryCache then exit('');
|
||||
Result:=DirectoryCache.FindUnitSourceInCompletePath(
|
||||
AnUnitName,AnUnitInFilename,true);
|
||||
end;
|
||||
|
@ -431,7 +431,7 @@ end;
|
||||
|
||||
function TLFMTree.ParseIfNeeded: boolean;
|
||||
begin
|
||||
if not UpdateNeeded then exit;
|
||||
if not UpdateNeeded then exit(true);
|
||||
Result:=Parse(LFMBuffer);
|
||||
end;
|
||||
|
||||
|
@ -82,6 +82,7 @@ function TResourceCodeTool.FindLazarusResourceHeaderComment(
|
||||
begin
|
||||
Result.StartPos:=-1;
|
||||
Result.EndPos:=-1;
|
||||
Result.Flag:=cafNone;
|
||||
SetSource(ResourceCode);
|
||||
|
||||
Result.StartPos:=FindNextNonSpace(Src,1);
|
||||
|
@ -1400,6 +1400,8 @@ var LinkIndex: integer;
|
||||
CurCode: TCodeBuffer;
|
||||
begin
|
||||
Result.StartPos:=-1;
|
||||
Result.EndPos:=-1;
|
||||
Result.Flag:=cafNone;
|
||||
LinkIndex:=-1;
|
||||
CurCode:=FindNextIncludeInInitialization(LinkIndex);
|
||||
while (CurCode<>nil) do begin
|
||||
|
@ -3301,7 +3301,7 @@ end;
|
||||
|
||||
function TDBGCallStack.InternalGetEntry(AIndex: Integer): TCallStackEntry;
|
||||
begin
|
||||
if FEntries.GetData(AIndex, Result) then Exit;
|
||||
if FEntries.GetData(AIndex, Result) then Exit(nil);
|
||||
|
||||
Result := CreateStackEntry(AIndex);
|
||||
if Result = nil then Exit;
|
||||
|
@ -655,6 +655,7 @@ function TDesignerMainMenu.GetMaxCoordinates(DesignerMenuItem: PDesignerMenuItem
|
||||
var
|
||||
temp_coord: TRect;
|
||||
begin
|
||||
Result:=Rect(0,0,0,0);
|
||||
if (DesignerMenuItem^.coord.Right > Max_Width) then
|
||||
Max_Width:=DesignerMenuItem^.coord.Right;
|
||||
if (DesignerMenuItem^.coord.Bottom > Max_Height) then
|
||||
|
@ -1123,7 +1123,7 @@ var
|
||||
ChildNode: TTreeNode;
|
||||
HasVisibleChilds: Boolean;
|
||||
begin
|
||||
if ANode=nil then exit;
|
||||
if ANode=nil then exit(false);
|
||||
ChildNode:=ANode.GetFirstChild;
|
||||
HasVisibleChilds:=false;
|
||||
while ChildNode<>nil do begin
|
||||
|
@ -1391,7 +1391,7 @@ function TCodeToolsDefinesEditor.ConsistencyCheck: integer;
|
||||
function CheckNode(ATreeNode: TTreeNode): integer;
|
||||
var ADefNode, DummyDefNode: TDefineTemplate;
|
||||
begin
|
||||
if ATreeNode=nil then exit;
|
||||
if ATreeNode=nil then exit(0);
|
||||
ADefNode:=TDefineTemplate(ATreeNode.Data);
|
||||
//writeln(' CheckNode "',ATreeNode.Text,'" "',ADefNode.Name,'"');
|
||||
if ADefNode=nil then begin
|
||||
|
@ -1985,7 +1985,7 @@ var
|
||||
OldBreakPoint: TIDEBreakPoint;
|
||||
begin
|
||||
OldBreakPoint:=FBreakPoints.Find(AFilename,ALine);
|
||||
if OldBreakPoint=nil then exit;
|
||||
if OldBreakPoint=nil then exit(mrOk);
|
||||
OldBreakPoint.Free;
|
||||
Project1.Modified:=true;
|
||||
Result := mrOK
|
||||
|
@ -179,7 +179,7 @@ begin
|
||||
if EnvironmentOptions.CheckDiskChangesWithLoading then begin
|
||||
CheckUnitsWithLoading;
|
||||
CheckPackagesWithLoading;
|
||||
if ListsAreEmpty then exit;
|
||||
if ListsAreEmpty then exit(mrIgnore);
|
||||
end;
|
||||
DiskDiffsDlg:=TDiskDiffsDlg.Create(nil);
|
||||
DiskDiffsDlg.UnitList:=AnUnitList;
|
||||
|
@ -1252,7 +1252,7 @@ begin
|
||||
BaseURL:='';
|
||||
HTMLHint:='';
|
||||
Code:=CodeToolBoss.LoadFile(ExpandedFilename,true,false);
|
||||
if Code=nil then exit;
|
||||
if Code=nil then exit(shrHelpNotFound);
|
||||
if CodeHelpBoss.GetHTMLHint(Code,CodePos.X,CodePos.Y,true,
|
||||
BaseURL,HTMLHint,CacheWasUsed)=chprSuccess
|
||||
then
|
||||
|
@ -12522,7 +12522,7 @@ var
|
||||
ActiveUnitInfo: TUnitInfo;
|
||||
LogCaretXY: TPoint;
|
||||
begin
|
||||
if not BeginCodeTool(ActiveSrcEdit,ActiveUnitInfo,[]) then exit;
|
||||
if not BeginCodeTool(ActiveSrcEdit,ActiveUnitInfo,[]) then exit(false);
|
||||
{$IFDEF IDE_DEBUG}
|
||||
writeln('');
|
||||
writeln('[TMainIDE.DoInitIdentCompletion] ************');
|
||||
@ -12544,7 +12544,7 @@ var
|
||||
ActiveSrcEdit: TSourceEditor;
|
||||
ActiveUnitInfo: TUnitInfo;
|
||||
begin
|
||||
if not BeginCodeTool(ActiveSrcEdit,ActiveUnitInfo,[]) then exit;
|
||||
if not BeginCodeTool(ActiveSrcEdit,ActiveUnitInfo,[]) then exit(false);
|
||||
{$IFDEF IDE_DEBUG}
|
||||
writeln('');
|
||||
writeln('[TMainIDE.DoShowCodeContext] ************');
|
||||
|
@ -555,7 +555,7 @@ end;
|
||||
|
||||
function TSourceMarks.Add(AMark: TSourceMark): integer;
|
||||
begin
|
||||
if AMark=nil then exit;
|
||||
if AMark=nil then exit(-1);
|
||||
Result:=fItems.Add(AMark);
|
||||
fSortedItems.Add(AMark);
|
||||
AMark.FSourceMarks:=Self;
|
||||
|
@ -601,7 +601,9 @@ end;
|
||||
function TIDETextConverter.GetTempFilename: string;
|
||||
begin
|
||||
if TextConverterToolClasses<>nil then
|
||||
Result:=TextConverterToolClasses.GetTempFilename;
|
||||
Result:=TextConverterToolClasses.GetTempFilename
|
||||
else
|
||||
Result:='';
|
||||
if Result='' then
|
||||
Result:='temp.txt';
|
||||
end;
|
||||
|
@ -1490,7 +1490,6 @@ end;
|
||||
function NormalizarRect(const R:TRect): TRect;
|
||||
begin
|
||||
Result.Left:=Min(R.Left, R.Right);
|
||||
|
||||
Result.Top:=Min(R.Top, R.Bottom);
|
||||
Result.Right:=Max(R.Left, R.Right);
|
||||
Result.Bottom:=Max(R.Top, R.Bottom);
|
||||
@ -4398,6 +4397,7 @@ function TCustomGrid.ColRowToOffset(IsCol, Relative: Boolean; Index:Integer;
|
||||
var
|
||||
Dim: Integer;
|
||||
begin
|
||||
Result:=false;
|
||||
with FGCache do begin
|
||||
if IsCol then begin
|
||||
StartPos:=integer(PtrUInt(AccumWidth[index]));
|
||||
|
@ -747,6 +747,7 @@ begin
|
||||
if CanReadFromCache then
|
||||
Result:=FCount
|
||||
else begin
|
||||
Result:=0;
|
||||
if ClipboardGetFormats(ClipboardType,Result,List) then begin
|
||||
if List<>nil then FreeMem(List);
|
||||
end else
|
||||
|
@ -348,7 +348,7 @@ var
|
||||
function Breakable(Breaks : TList; Index : Integer) : Boolean;
|
||||
begin
|
||||
If not Assigned(Breaks) then
|
||||
exit;
|
||||
exit(false);
|
||||
Result := Breaks.IndexOf(Pointer(PtrInt(Index))) <> -1;
|
||||
end;
|
||||
|
||||
|
@ -106,14 +106,14 @@ begin
|
||||
// ToDo: Eventually there must be a 'before paint message'.
|
||||
if IsAfterGtk then
|
||||
begin
|
||||
if TObject(Target) is TCustomControl then exit;
|
||||
if TObject(Target) is TCustomControl then exit(false);
|
||||
end else
|
||||
begin
|
||||
if not (TObject(Target) is TCustomControl) then exit;
|
||||
if not (TObject(Target) is TCustomControl) then exit(false);
|
||||
end;
|
||||
{$ENDIF}
|
||||
|
||||
if (not RepaintAll) and ((Area^.Width<1) or (Area^.Height<1)) then exit;
|
||||
if (not RepaintAll) and ((Area^.Width<1) or (Area^.Height<1)) then exit(false);
|
||||
|
||||
MSG.Msg := LM_GTKPAINT;
|
||||
MSG.Data := TLMGtkPaintData.Create;
|
||||
|
@ -942,7 +942,7 @@ function TGtkWidgetSet.AddProcessEventHandler(AHandle: THandle;
|
||||
var
|
||||
lHandler: PChildSignalEventHandler;
|
||||
begin
|
||||
if AEventHandler = nil then exit;
|
||||
if AEventHandler = nil then exit(nil);
|
||||
New(lHandler);
|
||||
lHandler^.PID := TPid(AHandle);
|
||||
lHandler^.UserData := AData;
|
||||
|
@ -865,6 +865,7 @@ var
|
||||
PS : PPaintStruct;
|
||||
Widget: PGtkWidget;
|
||||
begin
|
||||
FillByte(Result,SizeOf(Result),0);
|
||||
Result.Msg := LM_PAINT;
|
||||
New(PS);
|
||||
FillChar(PS^, SizeOf(TPaintStruct), 0);
|
||||
@ -5292,7 +5293,7 @@ end;
|
||||
function SetAccelKey(const Widget: PGtkWidget;
|
||||
Key: guint; Mods: TGdkModifierType; const Signal: string): PAcceleratorKey;
|
||||
begin
|
||||
if (Widget = nil) then exit;
|
||||
if (Widget = nil) then exit(nil);
|
||||
Result:=GetAccelKey(Widget);
|
||||
if Result=nil then begin
|
||||
if Key>0 then begin
|
||||
@ -9473,6 +9474,7 @@ function GetWindowFunction(AForm : TCustomForm) : Longint;
|
||||
var
|
||||
ABorderStyle: TFormBorderStyle;
|
||||
begin
|
||||
Result:=0;
|
||||
if not (csDesigning in AForm.ComponentState) then
|
||||
ABorderStyle:=AForm.BorderStyle
|
||||
else
|
||||
|
@ -198,6 +198,7 @@ var
|
||||
DevCtx: TGtkDeviceContext absolute DC;
|
||||
ClientWidget: PGtkWidget;
|
||||
begin
|
||||
FillByte(Result,SizeOf(Result),0);
|
||||
Result.Style := nil;
|
||||
if not GTKWidgetSet.IsValidDC(DC) then Exit;
|
||||
|
||||
|
@ -8543,7 +8543,7 @@ var
|
||||
NewTopLevelObject: TObject;
|
||||
NewForm: TCustomForm;
|
||||
begin
|
||||
if hWnd=0 then exit;
|
||||
if hWnd=0 then exit(0);
|
||||
Widget:=PGtkWidget(hWnd);
|
||||
{$IfDef VerboseFocus}
|
||||
DebugLn('');
|
||||
|
@ -755,6 +755,7 @@ var
|
||||
Iter: TGtkTreeIter;
|
||||
AValue: gboolean;
|
||||
begin
|
||||
Result:=false;
|
||||
if not WSCheckHandleAllocated(ALV, 'ItemGetChecked')
|
||||
then Exit;
|
||||
|
||||
|
@ -303,6 +303,7 @@ var
|
||||
Group: PGSList;
|
||||
Item: Pointer;
|
||||
begin
|
||||
Result:=false;
|
||||
if not WSCheckMenuItem(AMenuItem, 'SetCheck') then
|
||||
Exit;
|
||||
Item := Pointer(AMenuItem.Handle);
|
||||
|
@ -736,6 +736,7 @@ class function TGtk2WSCustomListBox.GetStrings(
|
||||
var
|
||||
Widget: PGtkWidget;// pointer to gtk-widget
|
||||
begin
|
||||
Result:=nil;
|
||||
if not WSCheckHandleAllocated(ACustomListBox, 'GetStrings') then
|
||||
Exit;
|
||||
case ACustomListBox.fCompStyle of
|
||||
|
@ -658,6 +658,7 @@ end;
|
||||
function QueryDescription(AFlags: TRawImageQueryFlags; AWidth: Integer = -1; AHeight: integer = -1): TRawImageDescription;
|
||||
begin
|
||||
Exclude(AFlags, riqfUpdate);
|
||||
Result.Init;
|
||||
QueryDescription(Result, AFlags, AWidth, AHeight);
|
||||
end;
|
||||
|
||||
@ -671,7 +672,6 @@ begin
|
||||
else begin
|
||||
if not (riqfUpdate in AFlags) then ADesc.Init;
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
function GetDescriptionFromDevice(ADC: HDC; AWidth, AHeight: integer): TRawImageDescription;
|
||||
@ -698,9 +698,10 @@ function AddAlphaToDescription(var ADesc: TRawImageDescription; APrec: Byte): Bo
|
||||
var
|
||||
Mask: Cardinal;
|
||||
begin
|
||||
if ADesc.AlphaPrec >= APrec then Exit(False);
|
||||
if ADesc.BitsPerPixel <> 32 then Exit(False);
|
||||
if ADesc.Depth <> 24 then Exit(False);
|
||||
Result:=false;
|
||||
if ADesc.AlphaPrec >= APrec then Exit;
|
||||
if ADesc.BitsPerPixel <> 32 then Exit;
|
||||
if ADesc.Depth <> 24 then Exit;
|
||||
|
||||
Mask := CreateBitMask(ADesc.RedShift, ADesc.RedPrec)
|
||||
or CreateBitMask(ADesc.GreenShift, ADesc.GreenPrec)
|
||||
|
@ -2910,7 +2910,7 @@ begin
|
||||
else
|
||||
begin
|
||||
if SrcI >= SrcCharCount then
|
||||
if UnfinishedCharError then Exit
|
||||
if UnfinishedCharError then Exit(trInvalidChar)
|
||||
else Break;
|
||||
|
||||
B2 := Byte(Src[SrcI]);
|
||||
@ -2924,12 +2924,12 @@ begin
|
||||
Inc(DestI);
|
||||
end
|
||||
else // invalid character, assume single byte UTF-8 char
|
||||
if InvalidCharError(1) then Exit;
|
||||
if InvalidCharError(1) then Exit(trInvalidChar);
|
||||
end
|
||||
else
|
||||
begin
|
||||
if SrcI >= SrcCharCount then
|
||||
if UnfinishedCharError then Exit
|
||||
if UnfinishedCharError then Exit(trInvalidChar)
|
||||
else Break;
|
||||
|
||||
B3 := Byte(Src[SrcI]);
|
||||
@ -2955,12 +2955,12 @@ begin
|
||||
end;
|
||||
end
|
||||
else // invalid character, assume single byte UTF-8 char
|
||||
if InvalidCharError(2) then Exit;
|
||||
if InvalidCharError(2) then Exit(trInvalidChar);
|
||||
end
|
||||
else
|
||||
begin
|
||||
if SrcI >= SrcCharCount then
|
||||
if UnfinishedCharError then Exit
|
||||
if UnfinishedCharError then Exit(trInvalidChar)
|
||||
else Break;
|
||||
|
||||
B4 := Byte(Src[SrcI]);
|
||||
@ -2979,7 +2979,7 @@ begin
|
||||
Inc(DestI);
|
||||
end
|
||||
else // invalid character, assume single byte UTF-8 char
|
||||
if InvalidCharError(3) then Exit;
|
||||
if InvalidCharError(3) then Exit(trInvalidChar);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -3115,7 +3115,7 @@ begin
|
||||
else
|
||||
begin
|
||||
if SrcI >= SrcWideCharCount then
|
||||
if UnfinishedCharError then Exit
|
||||
if UnfinishedCharError then Exit(trInvalidChar)
|
||||
else Break;
|
||||
|
||||
W2 := Word(Src[SrcI]);
|
||||
@ -3155,13 +3155,13 @@ begin
|
||||
end;
|
||||
end
|
||||
else // invalid character, assume single wide char UTF-16 char
|
||||
if InvalidCharError(1) then Exit;
|
||||
if InvalidCharError(1) then Exit(trInvalidChar);
|
||||
end
|
||||
else // invalid character, assume single wide char UTF-16 char
|
||||
if InvalidCharError(1) then Exit;
|
||||
if InvalidCharError(1) then Exit(trInvalidChar);
|
||||
end
|
||||
else // invalid character, assume single wide char UTF-16 char
|
||||
if InvalidCharError(1) then Exit;
|
||||
if InvalidCharError(1) then Exit(trInvalidChar);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -1533,6 +1533,7 @@ begin
|
||||
dvaInt32:
|
||||
Read(Result, SizeOf(Result));
|
||||
else
|
||||
Result:=0;
|
||||
PropValueError;
|
||||
end;
|
||||
end;
|
||||
@ -1745,6 +1746,7 @@ begin
|
||||
dvaNull:
|
||||
Result := 'Null';
|
||||
else
|
||||
Result:='';
|
||||
PropValueError;
|
||||
end;
|
||||
end;
|
||||
@ -3728,6 +3730,9 @@ begin
|
||||
Result := 'True';
|
||||
vaNull:
|
||||
Result := 'Null';
|
||||
else
|
||||
Result:='';
|
||||
RaiseGDBException('');
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -3824,7 +3829,6 @@ begin
|
||||
Read(Pointer(@Result[1])^, i);
|
||||
end;
|
||||
|
||||
|
||||
function TLRSObjectReader.ReadWideString: WideString;
|
||||
var
|
||||
i: Integer;
|
||||
|
@ -1985,7 +1985,7 @@ end;
|
||||
|
||||
function TPackageEditorForm.CanBeAddedToProject: boolean;
|
||||
begin
|
||||
if LazPackage=nil then exit;
|
||||
if LazPackage=nil then exit(false);
|
||||
Result:=PackageEditors.AddToProject(LazPackage,true)=mrOk;
|
||||
end;
|
||||
|
||||
|
@ -816,7 +816,7 @@ function TPkgManager.OnPackageEditorRevertPackage(Sender: TObject;
|
||||
begin
|
||||
if APackage.AutoCreated or (not FilenameIsAbsolute(APackage.Filename))
|
||||
or (not FileExists(APackage.Filename)) then
|
||||
exit;
|
||||
exit(mrCancel);
|
||||
Result:=DoOpenPackageFile(APackage.Filename,[pofRevert]);
|
||||
end;
|
||||
|
||||
@ -918,7 +918,7 @@ end;
|
||||
function TPkgManager.PackageGraphExplorerOpenProject(Sender: TObject;
|
||||
AProject: TProject): TModalResult;
|
||||
begin
|
||||
if AProject<>Project1 then exit;
|
||||
if AProject<>Project1 then exit(mrCancel);
|
||||
Result:=MainIDE.DoShowProjectInspector;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user