Bug Summary

File:/boot/home/haiku/haiku/src/kits/storage/disk_device/jobs/SetStringJob.cpp
Location:line 76, column 21
Description:Called C++ object pointer is null

Annotated Source Code

1/*
2 * Copyright 2007, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7#include "SetStringJob.h"
8
9#include <syscalls.h>
10
11#include "DiskDeviceUtils.h"
12#include "PartitionReference.h"
13
14
15// constructor
16SetStringJob::SetStringJob(PartitionReference* partition,
17 PartitionReference* child)
18 :
19 DiskDeviceJob(partition, child),
20 fString(NULL__null)
21{
22}
23
24
25// destructor
26SetStringJob::~SetStringJob()
27{
28 free(fString);
29}
30
31
32// Init
33status_t
34SetStringJob::Init(const char* string, uint32 jobType)
35{
36 switch (jobType) {
37 case B_DISK_DEVICE_JOB_SET_NAME:
38 case B_DISK_DEVICE_JOB_SET_CONTENT_NAME:
39 case B_DISK_DEVICE_JOB_SET_TYPE:
40 case B_DISK_DEVICE_JOB_SET_PARAMETERS:
41 case B_DISK_DEVICE_JOB_SET_CONTENT_PARAMETERS:
42 break;
43 default:
44 return B_BAD_VALUE((-2147483647 - 1) + 5);
45 }
46
47 fJobType = jobType;
48 SET_STRING_RETURN_ON_ERROR(fString, string){ status_t error = set_string(fString, string); if (error != (
(int)0)) return error; }
;
49
50 return B_OK((int)0);
51}
52
53
54// Do
55status_t
56SetStringJob::Do()
57{
58 int32 changeCounter = fPartition->ChangeCounter();
59 int32 childChangeCounter = (fChild ? fChild->ChangeCounter() : 0);
1
Assuming pointer value is null
2
'?' condition is false
60 status_t error;
61 bool updateChildChangeCounter = false;
62
63 switch (fJobType) {
3
Control jumps to 'case B_DISK_DEVICE_JOB_SET_TYPE:' at line 74
64 case B_DISK_DEVICE_JOB_SET_NAME:
65 error = _kern_set_partition_name(fPartition->PartitionID(),
66 &changeCounter, fChild->PartitionID(), &childChangeCounter,
67 fString);
68 updateChildChangeCounter = true;
69 break;
70 case B_DISK_DEVICE_JOB_SET_CONTENT_NAME:
71 error = _kern_set_partition_content_name(fPartition->PartitionID(),
72 &changeCounter, fString);
73 break;
74 case B_DISK_DEVICE_JOB_SET_TYPE:
75 error = _kern_set_partition_type(fPartition->PartitionID(),
76 &changeCounter, fChild->PartitionID(), &childChangeCounter,
4
Called C++ object pointer is null
77 fString);
78 updateChildChangeCounter = true;
79 break;
80 case B_DISK_DEVICE_JOB_SET_PARAMETERS:
81 error = _kern_set_partition_parameters(fPartition->PartitionID(),
82 &changeCounter, fChild->PartitionID(), &childChangeCounter,
83 fString);
84 updateChildChangeCounter = true;
85 break;
86 case B_DISK_DEVICE_JOB_SET_CONTENT_PARAMETERS:
87 error = _kern_set_partition_content_parameters(
88 fPartition->PartitionID(), &changeCounter, fString);
89 break;
90 default:
91 return B_BAD_VALUE((-2147483647 - 1) + 5);
92 }
93
94 if (error != B_OK((int)0))
95 return error;
96
97 fPartition->SetChangeCounter(changeCounter);
98 if (updateChildChangeCounter)
99 fChild->SetChangeCounter(childChangeCounter);
100
101 return B_OK((int)0);
102}
103