- // get entries in path
- OSArray *array = OSArray::withCapacity(5);
- if (!array) {
- data->release();
- return kIOReturnNoMemory;
- }
- do
- array->setObject(entry);
- while ((entry = entry->getParentEntry(gIODTPlane)));
-
- // append path
- for (int i = array->getCount() - 3;
- (entry = (IORegistryEntry *) array->getObject(i));
- i--) {
-
- name = entry->getName(gIODTPlane);
- comp = entry->getLocation(gIODTPlane);
- if( comp && (0 == strcmp("pci", name))
- && (0 == strcmp("80000000", comp))) {
- // yosemite hack
- comp = "/pci@80000000";
- } else {
- if (comp)
- ok &= data->appendBytes("/@", 2);
- else {
- if (!name)
- continue;
- ok &= data->appendByte('/', 1);
- comp = name;
- }
- }
- ok &= data->appendBytes(comp, strlen(comp));
- }
- ok &= data->appendByte(0, 1);
- array->release();
-
- // append prop name
- ok &= data->appendBytes(propName->getCStringNoCopy(), propName->getLength() + 1);
-
- // append escaped data
- oldData = escapeDataToData(value);
- ok &= (oldData != 0);
- if (ok)
- ok &= data->appendBytes(oldData);
-
+ if (value && value->getLength()) {
+ // get entries in path
+ OSArray *array = OSArray::withCapacity(5);
+ if (!array) {
+ data->release();
+ return kIOReturnNoMemory;
+ }
+ do
+ array->setObject(entry);
+ while ((entry = entry->getParentEntry(gIODTPlane)));
+
+ // append path
+ for (int i = array->getCount() - 3;
+ (entry = (IORegistryEntry *) array->getObject(i));
+ i--) {
+
+ name = entry->getName(gIODTPlane);
+ comp = entry->getLocation(gIODTPlane);
+ if( comp && (0 == strncmp("pci", name, sizeof("pci")))
+ && (0 == strncmp("80000000", comp, sizeof("80000000")))) {
+ // yosemite hack
+ comp = "/pci@80000000";
+ } else {
+ if (comp)
+ ok &= data->appendBytes("/@", 2);
+ else {
+ if (!name)
+ continue;
+ ok &= data->appendByte('/', 1);
+ comp = name;
+ }
+ }
+ ok &= data->appendBytes(comp, strlen(comp));
+ }
+ ok &= data->appendByte(0, 1);
+ array->release();
+
+ // append prop name
+ ok &= data->appendBytes(propName->getCStringNoCopy(), propName->getLength() + 1);
+
+ // append escaped data
+ oldData = escapeDataToData(value);
+ ok &= (oldData != 0);
+ if (ok)
+ ok &= data->appendBytes(oldData);
+ }