summaryrefslogtreecommitdiffstats
path: root/meta-openembedded/meta-oe/recipes-support/libnih/libnih-1.0.3/libnih_1.0.3-4ubuntu16.patch
blob: 5d125c851468c8746d4a78ea674e16a8692027fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
3164
3165
3166
3167
3168
3169
3170
3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
3192
3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
3329
3330
3331
3332
3333
3334
3335
3336
3337
3338
3339
3340
3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
3373
3374
3375
3376
3377
3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
3392
3393
3394
3395
3396
3397
3398
3399
3400
3401
3402
3403
3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
3426
3427
3428
3429
3430
3431
3432
3433
3434
3435
3436
3437
3438
3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
3457
3458
3459
3460
3461
3462
3463
3464
3465
3466
3467
3468
3469
3470
3471
3472
3473
3474
3475
3476
3477
3478
3479
3480
3481
3482
3483
3484
3485
3486
3487
3488
3489
3490
3491
3492
3493
3494
3495
3496
3497
3498
3499
3500
3501
3502
3503
3504
3505
3506
3507
3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
3548
3549
3550
3551
3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
3568
3569
3570
3571
3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
--- libnih-1.0.3.orig/ChangeLog
+++ libnih-1.0.3/ChangeLog
@@ -1,3 +1,84 @@
+2013-03-13  Steve Langasek  <steve.langasek@ubuntu.com>
+
+	* nih/watch.c (nih_watch_walk_filter): New NihFileFilter function
+	passed to nih_dir_walk_scan() to ensure the nih_watch_new() filter
+	function is passed the NihWatch data rather than the data passed to
+	the nih_dir_walk() NihFileVisitor function (LP: #776532).
+
+	* nih/tests/test_watch.c (test_new): New test "with filter and data"
+	to ensure filter is passed correct value.
+
+2013-02-28  James Hunt  <james.hunt@ubuntu.com>
+
+	* Removal of gcc 'malloc' function attribute resulting from
+	  a clarification in its description which makes its use invalid.
+	  (LP: #1123588).
+
+2013-02-05  James Hunt  <james.hunt@ubuntu.com>
+
+	* nih/logging.c: nih_log_abort_message(): Remove erroneous check
+	  left over from use of __abort_msg weak symbol.
+	* nih/tests/test_logging.c: Remove unecessary check on whether
+	  __nih_abort_msg has an address.
+
+2012-12-13  Stéphane Graber  <stgraber@ubuntu.com>
+
+	* nih-dbus-tool/type.c, nih-dbus-tool/marshal.c: Update dbus code
+	generator to allow for empty lists for type 'as'.  This drops the
+	!= NULL check for NULL terminated arrays and moves the iteration
+	loop inside an 'if' statement.
+
+2012-12-11  Dmitrijs Ledkovs  <dmitrijs.ledkovs@canonical.com>
+
+	* nih/file.c (nih_dir_walk_scan): Fallback to lstat, if the
+	non-portable dirent.d_type is not available (LP: #672643) (Closes:
+	#695604).
+
+2012-12-10  Petr Lautrbach  <plautrba@redhat.com>
+
+	* nih/tests/test_file.c: don't use dirent.d_type (not portable)
+
+2012-10-25  James Hunt  <james.hunt@ubuntu.com>
+
+	* nih/logging.c: Use our own __nih_abort_msg rather than the
+	(e)glibc private symbol __abort_msg to avoid upgrade issues (LP: #997359).
+	* nih/tests/test_logging.c: Update tests for __nih_abort_msg.
+
+2011-08-31  James Hunt  <james.hunt@ubuntu.com>
+
+	* nih-dbus-tool/tests/test_com.netsplit.Nih.Test_object.c
+	(test_unix_fd_to_str): Sanity check value before invoking strchr in
+	case it returns address of null (which would give a misleading test
+	pass).
+	* nih-dbus-tool/tests/test_com.netsplit.Nih.Test_proxy.c
+	(test_unix_fd_to_str, test_unix_fd_to_str_sync): Sanity check value
+	before invoking strchr in case it returns address of null (which would
+	give a misleading test pass).
+	* nih/config.c (): nih_config_block_end: Add check to ensure strchr()
+	doesn't return address of null since this would result in a misleading
+	return value of TRUE.
+
+	* nih/string.c (nih_str_split): Fixes to avoid over-running
+	input string and also returning an empty string array entry
+	when repeat is true (LP: #834813).
+	* nih/tests/test_string.c (test_str_split): Added a lot of new
+	tests for nih_str_split().
+
+2011-08-26  James Hunt  <james.hunt@ubuntu.com>
+
+	* nih/io.c (nih_io_select_fds): Ensure number of fds being managed
+	is within limits.
+
+	* nih/config.c, nih/error.h, nih/io.c, nih/test_files.h: Correct
+	typos in comments.
+
+2011-06-20  James Hunt  <james.hunt@ubuntu.com>
+
+	* nih/watch.c (nih_watch_handle): Handle non-directory watches;
+	previously a file watch resulted in an invalid file path ending in
+	a single slash (LP:#777097).
+	* nih/tests/test_watch.c: Added explicit test for watch on a file.
+
 2010-12-23  Scott James Remnant  <scott@netsplit.com>
 
 	* NEWS: Release 1.0.3
--- libnih-1.0.3.orig/nih/watch.c
+++ libnih-1.0.3/nih/watch.c
@@ -2,8 +2,8 @@
  *
  * watch.c - watching of files and directories with inotify
  *
- * Copyright © 2009 Scott James Remnant <scott@netsplit.com>.
- * Copyright © 2009 Canonical Ltd.
+ * Copyright © 2011 Scott James Remnant <scott@netsplit.com>.
+ * Copyright © 2011 Canonical Ltd.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2, as
@@ -71,6 +71,9 @@
 					      uint32_t events, uint32_t cookie,
 					      const char *name,
 					      int *caught_free);
+static int             nih_watch_walk_filter (void *data, const char *path,
+					      int is_dir)
+	__attribute__ ((warn_unused_result));
 
 
 /**
@@ -91,7 +94,7 @@
  * sub-directories will be automatically watched.
  *
  * Additionally, the set of files and directories within @path can be
- * limited by passing a @filter function which will recieve the paths and
+ * limited by passing a @filter function which will receive the paths and
  * may return TRUE to indicate that the path received should not be watched.
  *
  * When a file is created within @path, or moved from outside this location
@@ -104,7 +107,7 @@
  * files that exist under @path when the watch is first added.  This only
  * occurs if the watch can be added.
  *
- * This is a very high level wrapped around the inotify API; lower levels
+ * This is a very high level wrapper around the inotify API; lower levels
  * can be obtained using the inotify API itself and some of the helper
  * functions used by this one.
  *
@@ -185,6 +188,35 @@
 }
 
 
+ /**
+ * nih_watch_walk_filter:
+ * @data: NihWatch,
+ * @path: path to file,
+ * @is_dir: TRUE if @path is a directory.
+ *
+ * Callback function for nih_dir_walk(), used by nih_watch_add() to wrap
+ * the user-specified NihFileFilter (watch->filter) with a filter that can
+ * take watch itself as an argument.
+ *
+ * Returns: TRUE if the path should be ignored, FALSE otherwise.
+ **/
+static int
+nih_watch_walk_filter (void *data, const char *path, int is_dir)
+{
+    NihWatch *watch;
+
+    watch = (NihWatch *)data;
+
+    nih_assert (watch);
+
+    /* No filter, so accept all files */
+    if (! watch->filter)
+           return FALSE;
+
+    return watch->filter (watch->data, path, is_dir);
+}
+
+
 /**
  * nih_watch_handle_by_wd:
  * @watch: watch to search,
@@ -295,7 +327,7 @@
 	 * one; errors within the walk are warned automatically, so if this
 	 * fails, it means we literally couldn't watch the top-level.
 	 */
-	if (subdirs && (nih_dir_walk (path, watch->filter,
+	if (subdirs && (nih_dir_walk (path, nih_watch_walk_filter,
 				      (NihFileVisitor)nih_watch_add_visitor,
 				      NULL, watch) < 0)) {
 		NihError *err;
@@ -494,12 +526,21 @@
 		return;
 	}
 
+	/* Every other event must come with a name */
+	if (name && *name) {
 
-	/* Every other event must come with a name. */
-	if ((! name) || strchr (name, '/'))
-		return;
+		/* If name refers to a directory, there should be no associated
+		 * path - just the name of the path element.
+		 */
+		if (strchr (name, '/'))
+			return;
 
-	path = NIH_MUST (nih_sprintf (NULL, "%s/%s", handle->path, name));
+		/* Event occured for file within a watched directory */
+		path = NIH_MUST (nih_sprintf (NULL, "%s/%s", handle->path, name));
+	} else {
+		/* File event occured */
+		path = NIH_MUST (nih_strdup (NULL, handle->path));
+	}
 
 	/* Check the filter */
 	if (watch->filter && watch->filter (watch->data, path,
--- libnih-1.0.3.orig/nih/hash.h
+++ libnih-1.0.3/nih/hash.h
@@ -141,7 +141,7 @@
  * @hash: hash table to iterate,
  * @iter: name of iterator variable.
  *
- * Expans to nested for statements that iterate over each entry in each
+ * Expands to nested for statements that iterate over each entry in each
  * bin of @hash, except for the bin head pointer, setting @iter to each
  * entry for the block within the loop.  A variable named _@iter_i is used
  * to iterate the hash bins.
@@ -203,7 +203,7 @@
 				   NihKeyFunction key_function,
 				   NihHashFunction hash_function,
 				   NihCmpFunction cmp_function)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NihList *   nih_hash_add          (NihHash *hash, NihList *entry);
 NihList *   nih_hash_add_unique   (NihHash *hash, NihList *entry);
--- libnih-1.0.3.orig/nih/main.h
+++ libnih-1.0.3/nih/main.h
@@ -138,7 +138,7 @@
 
 NihMainLoopFunc *nih_main_loop_add_func  (const void *parent,
 					  NihMainLoopCb callback, void *data)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 void             nih_main_term_signal    (void *data, NihSignal *signal);
 
--- libnih-1.0.3.orig/nih/command.h
+++ libnih-1.0.3/nih/command.h
@@ -123,7 +123,7 @@
 
 NihCommand *nih_command_join   (const void *parent,
 				const NihCommand *a, const NihCommand *b)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih/config.h
+++ libnih-1.0.3/nih/config.h
@@ -140,10 +140,10 @@
 char *    nih_config_next_token      (const void *parent, const char *file,
 				      size_t len, size_t *pos, size_t *lineno,
 				      const char *delim, int dequote)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *    nih_config_next_arg        (const void *parent, const char *file,
 				      size_t len, size_t *pos, size_t *lineno)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 void      nih_config_next_line       (const char *file, size_t len,
 				      size_t *pos, size_t *lineno);
 
@@ -155,15 +155,15 @@
 
 char **   nih_config_parse_args      (const void *parent, const char *file,
 				      size_t len, size_t *pos, size_t *lineno)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *    nih_config_parse_command   (const void *parent, const char *file,
 				      size_t len, size_t *pos, size_t *lineno)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *    nih_config_parse_block     (const void *parent, const char *file,
 				      size_t len, size_t *pos, size_t *lineno,
 				      const char *type)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 int       nih_config_skip_block      (const char *file, size_t len,
 				      size_t *lineno, size_t *pos,
 				      const char *type, size_t *endpos)
--- libnih-1.0.3.orig/nih/io.c
+++ libnih-1.0.3/nih/io.c
@@ -2,8 +2,8 @@
  *
  * io.c - file and socket input/output handling
  *
- * Copyright © 2009 Scott James Remnant <scott@netsplit.com>.
- * Copyright © 2009 Canonical Ltd.
+ * Copyright © 2011 Scott James Remnant <scott@netsplit.com>.
+ * Copyright © 2011 Canonical Ltd.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2, as
@@ -165,6 +165,7 @@
 	nih_assert (readfds != NULL);
 	nih_assert (writefds != NULL);
 	nih_assert (exceptfds != NULL);
+	nih_assert (*nfds <= FD_SETSIZE);
 
 	nih_io_init ();
 
@@ -186,6 +187,9 @@
 			*nfds = nih_max (*nfds, watch->fd + 1);
 		}
 	}
+
+	/* Re-check in case we exceeded the limit in the loop */
+	nih_assert (*nfds <= FD_SETSIZE);
 }
 
 /**
@@ -901,7 +905,7 @@
  * read and placed into the receive buffer or queue, and the reader function
  * is called if set.
  *
- * Any data or messaages in the send buffer or queue are written out if the
+ * Any data or messages in the send buffer or queue are written out if the
  * @events includes NIH_IO_WRITE.
  *
  * Errors are handled when data is read, and result in the error handled
@@ -1211,7 +1215,7 @@
  * This function is called when the local end of a file descriptor being
  * managed by NihIo should be closed.  Usually this is because the remote
  * end has been closed (without error) but it can also be because no
- * error handler was given
+ * error handler was given.
  *
  * Normally this just calls the close handler, or if not available, it
  * closes the file descriptor and frees the structure (which may be
@@ -1291,7 +1295,7 @@
  * @io: structure to be destroyed.
  *
  * Closes the file descriptor associated with an NihIo structure so that
- * the structure can be freed.  IF an error is caught by closing the
+ * the structure can be freed.  If an error is caught by closing the
  * descriptor, the error handler is called instead of the error being raised;
  * this allows you to group your error handling in one place rather than
  * special-case close.
--- libnih-1.0.3.orig/nih/watch.h
+++ libnih-1.0.3/nih/watch.h
@@ -156,7 +156,7 @@
 			     NihCreateHandler create_handler,
 			     NihModifyHandler modify_handler,
 			     NihDeleteHandler delete_handler, void *data)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 int       nih_watch_add     (NihWatch *watch, const char *path, int subdirs)
 	__attribute__ ((warn_unused_result));
--- libnih-1.0.3.orig/nih/tree.h
+++ libnih-1.0.3/nih/tree.h
@@ -344,9 +344,9 @@
 
 void          nih_tree_init           (NihTree *tree);
 NihTree *     nih_tree_new            (const void *parent)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 NihTreeEntry *nih_tree_entry_new      (const void *parent)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NihTree *     nih_tree_add            (NihTree *tree, NihTree *node,
 				       NihTreeWhere where);
--- libnih-1.0.3.orig/nih/file.c
+++ libnih-1.0.3/nih/file.c
@@ -65,7 +65,7 @@
 /* Prototypes for static functions */
 static char **nih_dir_walk_scan  (const char *path, NihFileFilter filter,
 				  void *data)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 static int    nih_dir_walk_visit (const char *dirname, NihList *dirs,
 				  const char *path, NihFileFilter filter,
 				  NihFileVisitor visitor,
@@ -619,6 +619,8 @@
 	struct dirent  *ent;
 	char          **paths;
 	size_t          npaths;
+	int             isdir;
+	struct stat     statbuf;
 
 	nih_assert (path != NULL);
 
@@ -640,7 +642,15 @@
 		subpath = NIH_MUST (nih_sprintf (NULL, "%s/%s",
 						 path, ent->d_name));
 
-		if (filter && filter (data, subpath, ent->d_type == DT_DIR))
+		if (ent->d_type == DT_UNKNOWN) {
+			if ( lstat (subpath, &statbuf))
+				isdir = 0;
+			else
+				isdir = S_ISDIR(statbuf.st_mode);
+		} else
+			isdir = ent->d_type == DT_DIR;
+
+		if (filter && filter (data, subpath, isdir))
 			continue;
 
 		NIH_MUST (nih_str_array_addp (&paths, NULL, &npaths, subpath));
--- libnih-1.0.3.orig/nih/alloc.c
+++ libnih-1.0.3/nih/alloc.c
@@ -119,8 +119,7 @@
 static inline int          nih_alloc_context_free   (NihAllocCtx *ctx);
 
 static inline NihAllocRef *nih_alloc_ref_new        (NihAllocCtx *parent,
-						     NihAllocCtx *child)
-	__attribute__ ((malloc));
+						     NihAllocCtx *child);
 static inline void         nih_alloc_ref_free       (NihAllocRef *ref);
 static inline NihAllocRef *nih_alloc_ref_lookup     (NihAllocCtx *parent,
 						     NihAllocCtx *child);
--- libnih-1.0.3.orig/nih/timer.h
+++ libnih-1.0.3/nih/timer.h
@@ -59,7 +59,7 @@
  * @months: months (1-12),
  * @wdays: days of week (0-7).
  *
- * Indidcates when scheduled timers should be run, each member is a bit
+ * Indicates when scheduled timers should be run, each member is a bit
  * field where the bit is 1 if the timer should be run for that value and
  * 0 if not.
  **/
@@ -117,14 +117,14 @@
 
 NihTimer *nih_timer_add_timeout   (const void *parent, time_t timeout,
 				   NihTimerCb callback, void *data)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 NihTimer *nih_timer_add_periodic  (const void *parent, time_t period,
 				   NihTimerCb callback, void *data)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 NihTimer *nih_timer_add_scheduled (const void *parent,
 				   NihTimerSchedule *schedule,
 				   NihTimerCb callback, void *data)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NihTimer *nih_timer_next_due       (void);
 void      nih_timer_poll           (void);
--- libnih-1.0.3.orig/nih/config.c
+++ libnih-1.0.3/nih/config.c
@@ -2,8 +2,8 @@
  *
  * config.c - configuration file parsing
  *
- * Copyright © 2009 Scott James Remnant <scott@netsplit.com>.
- * Copyright © 2009 Canonical Ltd.
+ * Copyright © 2011 Scott James Remnant <scott@netsplit.com>.
+ * Copyright © 2011 Canonical Ltd.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2, as
@@ -657,7 +657,7 @@
  * of the returned string are freed, the returned string will also be
  * freed.
  *
- * Returns: the command found or NULL on raised error.
+ * Returns: the newly allocated command found or NULL on raised error.
  **/
 char *
 nih_config_parse_command (const void *parent,
@@ -714,7 +714,7 @@
  * @lineno: line number,
  * @type: block identifier.
  *
- * Extracts a block of text from @line, stopping when the pharse "end @type"
+ * Extracts a block of text from @line, stopping when the phrase "end @type"
  * is encountered without any quotes or blackslash escaping within it.
  *
  * @file may be a memory mapped file, in which case @pos should be given
@@ -950,7 +950,7 @@
 		return FALSE;
 
 	/* Must be whitespace after */
-	if (! strchr (NIH_CONFIG_WS, file[p + 3]))
+	if (file[p + 3] && ! strchr (NIH_CONFIG_WS, file[p + 3]))
 		return FALSE;
 
 	/* Find the second word */
--- libnih-1.0.3.orig/nih/option.h
+++ libnih-1.0.3/nih/option.h
@@ -124,11 +124,11 @@
 char **    nih_option_parser         (const void *parent,
 				      int argc, char *argv[],
 				      NihOption *options, int break_nonopt)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NihOption *nih_option_join           (const void *parent,
 				      const NihOption *a, const NihOption *b)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 int        nih_option_count          (NihOption *option, const char *arg);
 int        nih_option_int            (NihOption *option, const char *arg);
--- libnih-1.0.3.orig/nih/signal.h
+++ libnih-1.0.3/nih/signal.h
@@ -76,7 +76,7 @@
 
 NihSignal * nih_signal_add_handler (const void *parent, int signum,
 				   NihSignalHandler handler, void *data)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 void        nih_signal_handler     (int signum);
 void        nih_signal_poll        (void);
--- libnih-1.0.3.orig/nih/list.h
+++ libnih-1.0.3/nih/list.h
@@ -37,7 +37,7 @@
  * after a known entry, and remove an entry from the list.
  *
  * List entries may be created in one of two ways.  The most common is to
- * embed the NihList structure as the frist member of your own structure,
+ * embed the NihList structure as the first member of your own structure,
  * and initialise it with nih_list_init() after allocating the structure.
  * Alternatively you may create NihListEntry structures with
  * nih_list_entry_new() and point at your own data from them.
@@ -196,10 +196,10 @@
 
 void          nih_list_init      (NihList *entry);
 NihList *     nih_list_new       (const void *parent)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NihListEntry *nih_list_entry_new (const void *parent)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 
 NihList *     nih_list_add       (NihList *list, NihList *entry);
--- libnih-1.0.3.orig/nih/logging.c
+++ libnih-1.0.3/nih/logging.c
@@ -39,11 +39,11 @@
 
 
 /**
- * __abort_msg:
+ * __nih_abort_msg:
  *
- * A glibc variable that keeps the assertion message in the core dump.
+ * A variable that keeps the assertion message in the core dump.
  **/
-extern char *__abort_msg __attribute__ ((weak));
+char *__nih_abort_msg = NULL;
 
 /**
  * logger:
@@ -114,19 +114,16 @@
  * nih_log_abort_message:
  * @message: message to be logged.
  *
- * Save @message in the glibc __abort_msg variable so it can be retrieved
+ * Save @message in the __nih_abort_msg variable so it can be retrieved
  * by debuggers if we should crash at this point.
  **/
 static void
 nih_log_abort_message (const char *message)
 {
-	if (! &__abort_msg)
-		return;
+	if (__nih_abort_msg)
+		nih_discard (__nih_abort_msg);
 
-	if (__abort_msg)
-		nih_discard (__abort_msg);
-
-	__abort_msg = NIH_MUST (nih_strdup (NULL, message));
+	__nih_abort_msg = NIH_MUST (nih_strdup (NULL, message));
 }
 
 /**
--- libnih-1.0.3.orig/nih/test_files.h
+++ libnih-1.0.3/nih/test_files.h
@@ -1,7 +1,7 @@
 /* libnih
  *
- * Copyright © 2009 Scott James Remnant <scott@netsplit.com>.
- * Copyright © 2009 Canonical Ltd.
+ * Copyright © 2011 Scott James Remnant <scott@netsplit.com>.
+ * Copyright © 2011 Canonical Ltd.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2, as
@@ -39,7 +39,7 @@
  * TEST_FILENAME:
  * @_var: variable to store filename in.
  *
- * Generate a filename that may be used for testing, it's unlinked it if
+ * Generate a filename that may be used for testing, it's unlinked if it
  * exists and it's up to you to unlink it when done.  @_var should be at
  * least PATH_MAX long.
  **/
--- libnih-1.0.3.orig/nih/test_process.h
+++ libnih-1.0.3/nih/test_process.h
@@ -36,7 +36,7 @@
  * Spawn a child in which a test can be performed without affecting the
  * main flow of the process.  The pid of the child is stored in @_pid.
  *
- * This macro ensures that the child has begun exectution before the
+ * This macro ensures that the child has begun execution before the
  * parent is allowed to continue through the usual use of a pipe.
  *
  * A block of code should follow this macro, which is the code that will
--- libnih-1.0.3.orig/nih/child.h
+++ libnih-1.0.3/nih/child.h
@@ -98,7 +98,7 @@
 NihChildWatch *nih_child_add_watch (const void *parent, pid_t pid,
 				    NihChildEvents events,
 				    NihChildHandler handler, void *data)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 void           nih_child_poll      (void);
 
--- libnih-1.0.3.orig/nih/alloc.h
+++ libnih-1.0.3/nih/alloc.h
@@ -299,7 +299,7 @@
  * It is permissible to take references to foo within its scope, or by
  * functions called, in which case it will not be freed.  Also it is
  * generally nonsensical to allocate with a parent, since this too will
- * prevent it from beign freed.
+ * prevent it from being freed.
  **/
 #define nih_local __attribute__ ((cleanup(_nih_discard_local)))
 
@@ -307,11 +307,11 @@
 NIH_BEGIN_EXTERN
 
 void * nih_alloc                     (const void *parent, size_t size)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 void * nih_realloc                   (void *ptr, const void *parent,
 				      size_t size)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 int    nih_free                      (void *ptr);
 int    nih_discard                   (void *ptr);
--- libnih-1.0.3.orig/nih/io.h
+++ libnih-1.0.3/nih/io.h
@@ -269,7 +269,7 @@
 NihIoWatch *  nih_io_add_watch           (const void *parent, int fd,
 					  NihIoEvents events,
 					  NihIoWatcher watcher, void *data)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 void          nih_io_select_fds          (int *nfds, fd_set *readfds,
 					  fd_set *writefds, fd_set *exceptfds);
@@ -278,12 +278,12 @@
 
 
 NihIoBuffer * nih_io_buffer_new          (const void *parent)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 int           nih_io_buffer_resize       (NihIoBuffer *buffer, size_t grow);
 char *        nih_io_buffer_pop          (const void *parent,
 					  NihIoBuffer *buffer, size_t *len)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 void          nih_io_buffer_shrink       (NihIoBuffer *buffer, size_t len);
 int           nih_io_buffer_push         (NihIoBuffer *buffer,
 					  const char *str, size_t len)
@@ -291,7 +291,7 @@
 
 
 NihIoMessage *nih_io_message_new         (const void *parent)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 int           nih_io_message_add_control (NihIoMessage *message, int level,
 					  int type, socklen_t len,
@@ -300,7 +300,7 @@
 
 NihIoMessage *nih_io_message_recv        (const void *parent, int fd,
 					  size_t *len)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 ssize_t       nih_io_message_send        (NihIoMessage *message, int fd)
 	__attribute__ ((warn_unused_result));
 
@@ -310,7 +310,7 @@
 					  NihIoCloseHandler close_handler,
 					  NihIoErrorHandler error_handler,
 					  void *data)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 void          nih_io_shutdown            (NihIo *io);
 int           nih_io_destroy             (NihIo *io);
 
@@ -319,14 +319,14 @@
 
 char *        nih_io_read                (const void *parent, NihIo *io,
 					  size_t *len)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 int           nih_io_write               (NihIo *io, const char *str,
 					  size_t len)
 	__attribute__ ((warn_unused_result));
 
 char *        nih_io_get                 (const void *parent, NihIo *io,
 					  const char *delim)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 int           nih_io_printf              (NihIo *io, const char *format, ...)
 	__attribute__ ((warn_unused_result, format (printf, 2, 3)));
--- libnih-1.0.3.orig/nih/test_output.h
+++ libnih-1.0.3/nih/test_output.h
@@ -61,10 +61,10 @@
 
 /**
  * TEST_FEATURE:
- * @_feat: name of function feature being tested.
+ * @_feat: name of function or group feature being tested.
  *
- * Output a message indicating that a sub-test of a function is being
- * performed, specifically the feature named _feat.
+ * Output a message indicating that a sub-test of a function or
+ * group is being performed, specifically the feature named _feat.
  **/
 #define TEST_FEATURE(_feat) \
 	printf ("...%s\n", _feat);
--- libnih-1.0.3.orig/nih/error.h
+++ libnih-1.0.3/nih/error.h
@@ -1,7 +1,7 @@
 /* libnih
  *
- * Copyright © 2009 Scott James Remnant <scott@netsplit.com>.
- * Copyright © 2009 Canonical Ltd.
+ * Copyright © 2011 Scott James Remnant <scott@netsplit.com>.
+ * Copyright © 2011 Canonical Ltd.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2, as
@@ -111,7 +111,7 @@
  * @message: human-readable message.
  *
  * Raises an error with the given details in the current error context,
- * if an unhandled error already exists then an error message is emmitted
+ * if an unhandled error already exists then an error message is emitted
  * through the logging system; you should try to avoid this.
  *
  * @message should be a static string, as it will not be freed when the
@@ -126,7 +126,7 @@
  * @format: format string for human-readable message.
  *
  * Raises an error with the given details in the current error context,
- * if an unhandled error already exists then an error message is emmitted
+ * if an unhandled error already exists then an error message is emitted
  * through the logging system; you should try to avoid this.
  *
  * The human-readable message for the error is parsed according to @format,
@@ -140,7 +140,7 @@
  * nih_error_raise_system:
  *
  * Raises an error with details taken from the current value of errno,
- * if an unhandled error already exists then an error message is emmitted
+ * if an unhandled error already exists then an error message is emitted
  * through the logging system; you should try to avoid this.
  **/
 #define nih_error_raise_system() \
@@ -162,7 +162,7 @@
  * @error: existing object to raise.
  *
  * Raises the existing error object in the current error context,
- * if an unhandled error already exists then an error message is emmitted
+ * if an unhandled error already exists then an error message is emitted
  * through the logging system; you should try to avoid this.
  *
  * This is normally used to raise a taken error that has not been handled,
@@ -182,7 +182,7 @@
  * @message: human-readable message.
  *
  * Raises an error with the given details in the current error context,
- * if an unhandled error already exists then an error message is emmitted
+ * if an unhandled error already exists then an error message is emitted
  * through the logging system; you should try to avoid this.
  *
  * Will return from the current function with @retval, which may be left
@@ -199,7 +199,7 @@
  * @retval: return value for function.
  *
  * Raises an error with details taken from the current value of errno,
- * if an unhandled error already exists then an error message is emmitted
+ * if an unhandled error already exists then an error message is emitted
  * through the logging system; you should try to avoid this.
  *
  * Will return from the current function with @retval, which may be left
--- libnih-1.0.3.orig/nih/string.h
+++ libnih-1.0.3/nih/string.h
@@ -35,60 +35,60 @@
 NIH_BEGIN_EXTERN
 
 char * nih_sprintf          (const void *parent, const char *format, ...)
-	__attribute__ ((format (printf, 2, 3), warn_unused_result, malloc));
+	__attribute__ ((format (printf, 2, 3), warn_unused_result));
 
 char * nih_vsprintf         (const void *parent, const char *format,
 			     va_list args)
-	__attribute__ ((format (printf, 2, 0), warn_unused_result, malloc));
+	__attribute__ ((format (printf, 2, 0), warn_unused_result));
 
 char * nih_strdup           (const void *parent, const char *str)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char * nih_strndup          (const void *parent, const char *str, size_t len)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char * nih_strcat           (char **str, const void *parent, const char *src)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char * nih_strncat          (char **str, const void *parent, const char *src,
 			     size_t len)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char * nih_strcat_sprintf   (char **str, const void *parent,
 			     const char *format, ...)
-	__attribute__ ((format (printf, 3, 4), warn_unused_result, malloc));
+	__attribute__ ((format (printf, 3, 4), warn_unused_result));
 char * nih_strcat_vsprintf  (char **str, const void *parent,
 			     const char *format, va_list args)
-	__attribute__ ((format (printf, 3, 0), warn_unused_result, malloc));
+	__attribute__ ((format (printf, 3, 0), warn_unused_result));
 
 char **nih_str_split        (const void *parent, const char *str,
 			     const char *delim, int repeat)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char **nih_str_array_new    (const void *parent)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char **nih_str_array_add    (char ***array, const void *parent, size_t *len,
 			     const char *str)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char **nih_str_array_addn   (char ***array, const void *parent, size_t *len,
 			     const char *str, size_t strlen)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char **nih_str_array_addp   (char ***array, const void *parent, size_t *len,
 			     void *ptr)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char **nih_str_array_copy   (const void *parent, size_t *len,
 			     char * const *array)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char **nih_str_array_append (char ***array, const void *parent, size_t *len,
 			     char * const *args)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char * nih_str_wrap         (const void *parent, const char *str, size_t len,
 		             size_t first_indent, size_t indent)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 size_t nih_str_screen_width (void);
 char * nih_str_screen_wrap  (const void *parent, const char *str,
 			     size_t first_indent, size_t indent)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih/string.c
+++ libnih-1.0.3/nih/string.c
@@ -405,7 +405,7 @@
 		const char  *ptr;
 
 		/* Skip initial delimiters */
-		while (repeat && strchr (delim, *str))
+		while (repeat && *str && strchr (delim, *str))
 			str++;
 
 		/* Find the end of the token */
@@ -413,6 +413,13 @@
 		while (*str && (! strchr (delim, *str)))
 			str++;
 
+		/* Don't create an empty string array element in repeat
+		 * mode if there is no token (as a result of a
+		 * duplicated delimiter character).
+		 */
+		if (repeat && (str == ptr))
+			continue;
+
 		if (! nih_str_array_addn (&array, parent, &len,
 					  ptr, str - ptr)) {
 			nih_free (array);
--- libnih-1.0.3.orig/nih/file.h
+++ libnih-1.0.3/nih/file.h
@@ -82,7 +82,7 @@
 
 char *nih_file_read         (const void *parent, const char *path,
 			     size_t *length)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 void *nih_file_map          (const char *path, int flags, size_t *length)
 	__attribute__ ((warn_unused_result));
--- libnih-1.0.3.orig/nih/tests/test_option.c
+++ libnih-1.0.3/nih/tests/test_option.c
@@ -1574,7 +1574,7 @@
 		output = tmpfile ();
 		TEST_CHILD (pid) {
 			TEST_DIVERT_STDOUT (output) {
-				char **args;
+				char **args __attribute__((unused));
 
 				args = nih_option_parser (NULL, argc, argv,
 							  options, FALSE);
@@ -1652,7 +1652,7 @@
 			unsetenv ("COLUMNS");
 
 			TEST_DIVERT_STDOUT (output) {
-				char **args;
+				char **args __attribute__((unused));
 
 				args = nih_option_parser (NULL, argc, argv,
 							  options, FALSE);
--- libnih-1.0.3.orig/nih/tests/test_logging.c
+++ libnih-1.0.3/nih/tests/test_logging.c
@@ -31,7 +31,7 @@
 #include <nih/main.h>
 
 
-extern char *__abort_msg __attribute__ ((weak));
+extern char *__nih_abort_msg;
 
 static NihLogLevel last_priority = NIH_LOG_UNKNOWN;
 static char *      last_message = NULL;
@@ -156,68 +156,63 @@
 	}
 
 
-	/* Check that a fatal message is also stored in the glibc __abort_msg
+	/* Check that a fatal message is also stored in the __nih_abort_msg
 	 * variable.
 	 */
-	if (&__abort_msg) {
-		TEST_FEATURE ("with fatal message");
-		TEST_ALLOC_FAIL {
-			__abort_msg = NULL;
-			last_priority = NIH_LOG_UNKNOWN;
-			last_message = NULL;
-
-			ret = nih_log_message (NIH_LOG_FATAL,
-					       "message with %s %d formatting",
-					       "some", 20);
-
-			TEST_EQ (ret, 0);
-			TEST_EQ (last_priority, NIH_LOG_FATAL);
-			TEST_EQ_STR (last_message, "message with some 20 formatting");
-
-			TEST_NE_P (__abort_msg, NULL);
-			TEST_ALLOC_PARENT (__abort_msg, NULL);
-			TEST_EQ_STR (__abort_msg, "message with some 20 formatting");
+	TEST_FEATURE ("with fatal message");
+	TEST_ALLOC_FAIL {
+		__nih_abort_msg = NULL;
+		last_priority = NIH_LOG_UNKNOWN;
+		last_message = NULL;
 
-			free (last_message);
-		}
+		ret = nih_log_message (NIH_LOG_FATAL,
+				"message with %s %d formatting",
+				"some", 20);
 
+		TEST_EQ (ret, 0);
+		TEST_EQ (last_priority, NIH_LOG_FATAL);
+		TEST_EQ_STR (last_message, "message with some 20 formatting");
 
-		/* Check that a fatal message can safely overwrite one already stored
-		 * in the glibc __abort_msg variable.
-		 */
-		TEST_FEATURE ("with second fatal message");
-		TEST_ALLOC_FAIL {
-			TEST_ALLOC_SAFE {
-				msg = nih_strdup (NULL, "test");
-			}
-
-			__abort_msg = msg;
-			TEST_FREE_TAG (msg);
-
-			last_priority = NIH_LOG_UNKNOWN;
-			last_message = NULL;
-
-			ret = nih_log_message (NIH_LOG_FATAL,
-					       "message with %s %d formatting",
-					       "some", 20);
-
-			TEST_EQ (ret, 0);
-			TEST_EQ (last_priority, NIH_LOG_FATAL);
-			TEST_EQ_STR (last_message, "message with some 20 formatting");
-
-			TEST_FREE (msg);
-
-			TEST_NE_P (__abort_msg, NULL);
-			TEST_ALLOC_PARENT (__abort_msg, NULL);
-			TEST_EQ_STR (__abort_msg, "message with some 20 formatting");
+		TEST_NE_P (__nih_abort_msg, NULL);
+		TEST_ALLOC_PARENT (__nih_abort_msg, NULL);
+		TEST_EQ_STR (__nih_abort_msg, "message with some 20 formatting");
 
-			free (last_message);
-		}
-	} else {
-		printf ("SKIP: __abort_msg not available\n");
+		free (last_message);
 	}
 
 
+	/* Check that a fatal message can safely overwrite one already stored
+	 * in the __nih_abort_msg variable.
+	 */
+	TEST_FEATURE ("with second fatal message");
+	TEST_ALLOC_FAIL {
+		TEST_ALLOC_SAFE {
+			msg = nih_strdup (NULL, "test");
+		}
+
+		__nih_abort_msg = msg;
+		TEST_FREE_TAG (msg);
+
+		last_priority = NIH_LOG_UNKNOWN;
+		last_message = NULL;
+
+		ret = nih_log_message (NIH_LOG_FATAL,
+				"message with %s %d formatting",
+				"some", 20);
+
+		TEST_EQ (ret, 0);
+		TEST_EQ (last_priority, NIH_LOG_FATAL);
+		TEST_EQ_STR (last_message, "message with some 20 formatting");
+
+		TEST_FREE (msg);
+
+		TEST_NE_P (__nih_abort_msg, NULL);
+		TEST_ALLOC_PARENT (__nih_abort_msg, NULL);
+		TEST_EQ_STR (__nih_abort_msg, "message with some 20 formatting");
+
+		free (last_message);
+	}
+
 	/* Check that the nih_debug macro wraps the call properly and
 	 * includes the function in which the message occurred.
 	 */
--- libnih-1.0.3.orig/nih/tests/test_hash.c
+++ libnih-1.0.3/nih/tests/test_hash.c
@@ -470,7 +470,8 @@
 test_lookup (void)
 {
 	NihHash *hash;
-	NihList *entry1, *entry2, *entry3, *ptr;
+	NihList *entry1, *entry2, *ptr;
+	NihList *entry3 __attribute__((unused));
 
 	TEST_FUNCTION ("nih_hash_lookup");
 	hash = nih_hash_string_new (NULL, 0);
--- libnih-1.0.3.orig/nih/tests/test_main.c
+++ libnih-1.0.3/nih/tests/test_main.c
@@ -457,7 +457,7 @@
 test_main_loop (void)
 {
 	NihMainLoopFunc *func;
-	NihTimer        *timer;
+	NihTimer        *timer __attribute__((unused));
 	int              ret;
 
 	/* Check that we can run through the main loop, and that the
--- libnih-1.0.3.orig/nih/tests/test_watch.c
+++ libnih-1.0.3/nih/tests/test_watch.c
@@ -2,8 +2,8 @@
  *
  * test_watch.c - test suite for nih/watch.c
  *
- * Copyright © 2009 Scott James Remnant <scott@netsplit.com>.
- * Copyright © 2009 Canonical Ltd.
+ * Copyright © 2011 Scott James Remnant <scott@netsplit.com>.
+ * Copyright © 2011 Canonical Ltd.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2, as
@@ -39,6 +39,8 @@
 #include <nih/error.h>
 #include <nih/logging.h>
 
+/* Read "The Hitchhikers Guide to the Galaxy" */
+#define FILTER_VALUE 42
 
 static int
 my_filter (void       *data,
@@ -54,6 +56,26 @@
 	return FALSE;
 }
 
+/* Set by my_filter2 () so it knows if it has already been called */
+static int my_filter2_called = 0;
+
+static int
+my_filter2 (int       *value,
+	   const char *path,
+	   int         is_dir)
+{
+	/* we only want to toggle the value once */
+	if (my_filter2_called)
+		return TRUE;
+
+	my_filter2_called = 1;
+
+	nih_assert (value && *value == FILTER_VALUE);
+	*value = 0;
+
+	return FALSE;
+}
+
 static int create_called = 0;
 static int modify_called = 0;
 static int delete_called = 0;
@@ -553,6 +575,44 @@
 		nih_free (watch);
 	}
 
+	/* Ensure the file filter gets passed the correct data pointer.
+	 */
+	TEST_FEATURE ("with filter and data");
+
+	/* Ensure we have a new directory */
+	TEST_FILENAME (dirname);
+	mkdir (dirname, 0755);
+
+	/* Create a single file */
+	strcpy (filename, dirname);
+	strcat (filename, "/foo");
+
+	fd = fopen (filename, "w");
+	fprintf (fd, "test\n");
+	fclose (fd);
+
+	TEST_ALLOC_FAIL {
+		int watch_data = FILTER_VALUE;
+
+		/* Reset required to appease TEST_ALLOC_FAIL */
+		my_filter2_called = 0;
+
+		watch = nih_watch_new (NULL, dirname,
+				TRUE, TRUE,
+				(NihFileFilter)my_filter2,
+				NULL, NULL, NULL,
+				&watch_data);
+
+		TEST_NE_P (watch, NULL);
+
+		/* Ensure the filter was called and changed the value */
+
+		TEST_NE (my_filter2_called, 0);
+		TEST_EQ (watch_data, 0);
+
+		nih_free (watch);
+	}
+
 	strcpy (filename, dirname);
 	strcat (filename, "/bar");
 	chmod (filename, 0755);
@@ -946,13 +1006,82 @@
 	nih_error_init ();
 
 	TEST_FILENAME (dirname);
-	mkdir (dirname, 0755);
+	TEST_EQ (mkdir (dirname, 0755), 0);
 
-	watch = nih_watch_new (NULL, dirname, TRUE, TRUE, my_filter,
-			       my_create_handler, my_modify_handler,
+	TEST_FEATURE ("with watched file");
+	strcpy (filename, dirname);
+	strcat (filename, "/foo");
+
+	/* Create file first since we don't set a create handler on the
+	 * watch.
+	 */
+	fd = fopen (filename, "w");
+	fprintf (fd, "bar\n");
+	fclose (fd);
+
+	create_called = 0;
+	modify_called = 0;
+	delete_called = 0;
+	logger_called = 0;
+	last_path  = NULL;
+	last_watch = NULL;
+	last_data  = NULL;
+
+	watch = nih_watch_new (NULL, filename, FALSE, FALSE, NULL,
+			       NULL, my_modify_handler,
 			       my_delete_handler, &watch);
+	TEST_NE_P (watch, NULL);
+
+	/* Now, modify the existing file to trigger the modify handler. */
+	fd = fopen (filename, "a+");
+	fprintf (fd, "baz\n");
+	fclose (fd);
+
+	nfds = 0;
+	FD_ZERO (&readfds);
+	FD_ZERO (&writefds);
+	FD_ZERO (&exceptfds);
+
+	nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds);
+	select (nfds, &readfds, &writefds, &exceptfds, NULL);
+	nih_io_handle_fds (&readfds, &writefds, &exceptfds);
+
+	TEST_EQ_STR (watch->path, filename);
+
+	/* Ensure no regression to old behaviour (LP:#777097) */
+	TEST_NE (last_path[ strlen(last_path) - 1 ], '/');
+
+	TEST_EQ_STR (last_path, filename);
+	TEST_EQ (modify_called, 1);
+
+	unlink (filename);
+
+	nfds = 0;
+	FD_ZERO (&readfds);
+	FD_ZERO (&writefds);
+	FD_ZERO (&exceptfds);
+
+	nih_io_select_fds (&nfds, &readfds, &writefds, &exceptfds);
+	select (nfds, &readfds, &writefds, &exceptfds, NULL);
+	nih_io_handle_fds (&readfds, &writefds, &exceptfds);
 
+	TEST_EQ (delete_called, 1);
 
+	rmdir (filename);
+	nih_free (last_path);
+
+	create_called = 0;
+	modify_called = 0;
+	delete_called = 0;
+	logger_called = 0;
+	last_path  = NULL;
+	last_watch = NULL;
+	last_data  = NULL;
+
+
+	watch = nih_watch_new (NULL, dirname, TRUE, TRUE, my_filter,
+			       my_create_handler, my_modify_handler,
+			       my_delete_handler, &watch);
 	/* Check that creating a file within the directory being watched
 	 * results in the create handler being called, and passed the full
 	 * path of the created file to it.
--- libnih-1.0.3.orig/nih/tests/test_string.c
+++ libnih-1.0.3/nih/tests/test_string.c
@@ -619,6 +619,215 @@
 		nih_free (array);
 	}
 
+	TEST_FEATURE ("with no repeat and multiple identical delimiter "
+			"characters at string start");
+	TEST_ALLOC_FAIL {
+		array = nih_str_split (NULL, "\t\tthis is a test", " \t", FALSE);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (array, NULL);
+			continue;
+		}
+
+		TEST_ALLOC_SIZE (array, sizeof (char *) * 7);
+		for (i = 0; i < 6; i++)
+			TEST_ALLOC_PARENT (array[i], array);
+
+		TEST_EQ_STR (array[0], "");
+		TEST_EQ_STR (array[1], "");
+		TEST_EQ_STR (array[2], "this");
+		TEST_EQ_STR (array[3], "is");
+		TEST_EQ_STR (array[4], "a");
+		TEST_EQ_STR (array[5], "test");
+		TEST_EQ_P (array[6], NULL);
+
+		nih_free (array);
+	}
+
+	TEST_FEATURE ("with no repeat and multiple different delimiter "
+			"characters at string start");
+	TEST_ALLOC_FAIL {
+		array = nih_str_split (NULL, " \tthis is a test", " \t", FALSE);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (array, NULL);
+			continue;
+		}
+
+		TEST_ALLOC_SIZE (array, sizeof (char *) * 7);
+		for (i = 0; i < 6; i++)
+			TEST_ALLOC_PARENT (array[i], array);
+
+		TEST_EQ_STR (array[0], "");
+		TEST_EQ_STR (array[1], "");
+		TEST_EQ_STR (array[2], "this");
+		TEST_EQ_STR (array[3], "is");
+		TEST_EQ_STR (array[4], "a");
+		TEST_EQ_STR (array[5], "test");
+		TEST_EQ_P (array[6], NULL);
+
+		nih_free (array);
+	}
+
+	TEST_FEATURE ("with no repeat and multiple identical delimiter "
+			"characters within string");
+	TEST_ALLOC_FAIL {
+		array = nih_str_split (NULL, "this is   a\t\ttest", " \t", FALSE);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (array, NULL);
+			continue;
+		}
+
+		TEST_ALLOC_SIZE (array, sizeof (char *) * 8);
+		for (i = 0; i < 7; i++)
+			TEST_ALLOC_PARENT (array[i], array);
+
+		TEST_EQ_STR (array[0], "this");
+		TEST_EQ_STR (array[1], "is");
+		TEST_EQ_STR (array[2], "");
+		TEST_EQ_STR (array[3], "");
+		TEST_EQ_STR (array[4], "a");
+		TEST_EQ_STR (array[5], "");
+		TEST_EQ_STR (array[6], "test");
+		TEST_EQ_P (array[7], NULL);
+
+		nih_free (array);
+	}
+
+	TEST_FEATURE ("with no repeat and multiple different delimiter "
+			"characters within string");
+	TEST_ALLOC_FAIL {
+		array = nih_str_split (NULL, "this is \n\ta\ttest", " \t\n", FALSE);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (array, NULL);
+			continue;
+		}
+
+		TEST_ALLOC_SIZE (array, sizeof (char *) * 7);
+		for (i = 0; i < 6; i++)
+			TEST_ALLOC_PARENT (array[i], array);
+
+		TEST_EQ_STR (array[0], "this");
+		TEST_EQ_STR (array[1], "is");
+		TEST_EQ_STR (array[2], "");
+		TEST_EQ_STR (array[3], "");
+		TEST_EQ_STR (array[4], "a");
+		TEST_EQ_STR (array[5], "test");
+		TEST_EQ_P (array[6], NULL);
+
+		nih_free (array);
+	}
+
+	TEST_FEATURE ("with no repeat and multiple identical delimiter "
+			"characters at string end");
+	TEST_ALLOC_FAIL {
+		array = nih_str_split (NULL, "this is a test  ", " \t", FALSE);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (array, NULL);
+			continue;
+		}
+
+		TEST_ALLOC_SIZE (array, sizeof (char *) * 6);
+		for (i = 0; i < 5; i++)
+			TEST_ALLOC_PARENT (array[i], array);
+
+		TEST_EQ_STR (array[0], "this");
+		TEST_EQ_STR (array[1], "is");
+		TEST_EQ_STR (array[2], "a");
+		TEST_EQ_STR (array[3], "test");
+		TEST_EQ_STR (array[4], "");
+		TEST_EQ_P (array[5], NULL);
+
+		nih_free (array);
+	}
+
+	TEST_FEATURE ("with no repeat and multiple different delimiter "
+			"characters at string end");
+	TEST_ALLOC_FAIL {
+		array = nih_str_split (NULL, "this is a test \t", " \t", FALSE);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (array, NULL);
+			continue;
+		}
+
+		TEST_ALLOC_SIZE (array, sizeof (char *) * 6);
+		for (i = 0; i < 5; i++)
+			TEST_ALLOC_PARENT (array[i], array);
+
+		TEST_EQ_STR (array[0], "this");
+		TEST_EQ_STR (array[1], "is");
+		TEST_EQ_STR (array[2], "a");
+		TEST_EQ_STR (array[3], "test");
+		TEST_EQ_STR (array[4], "");
+		TEST_EQ_P (array[5], NULL);
+
+		nih_free (array);
+	}
+
+	TEST_FEATURE ("with no repeat and multiple identical delimiter "
+			"characters at beginning, middle and end of string");
+	TEST_ALLOC_FAIL {
+		array = nih_str_split (NULL, "   this is\n\n\na test\t\t\t", " \t\n", FALSE);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (array, NULL);
+			continue;
+		}
+
+		TEST_ALLOC_SIZE (array, sizeof (char *) * 12);
+		for (i = 0; i < 11; i++)
+			TEST_ALLOC_PARENT (array[i], array);
+
+		TEST_EQ_STR (array[0], "");
+		TEST_EQ_STR (array[1], "");
+		TEST_EQ_STR (array[2], "");
+		TEST_EQ_STR (array[3], "this");
+		TEST_EQ_STR (array[4], "is");
+		TEST_EQ_STR (array[5], "");
+		TEST_EQ_STR (array[6], "");
+		TEST_EQ_STR (array[7], "a");
+		TEST_EQ_STR (array[8], "test");
+		TEST_EQ_STR (array[9], "");
+		TEST_EQ_STR (array[10], "");
+		TEST_EQ_P (array[11], NULL);
+
+		nih_free (array);
+	}
+
+	TEST_FEATURE ("with no repeat and multiple different delimiter "
+			"characters at beginning, middle and end of string");
+	TEST_ALLOC_FAIL {
+		array = nih_str_split (NULL, ": \nthis is\t \n:a test:\n ", "\n :\t", FALSE);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (array, NULL);
+			continue;
+		}
+
+		TEST_ALLOC_SIZE (array, sizeof (char *) * 13);
+		for (i = 0; i < 12; i++)
+			TEST_ALLOC_PARENT (array[i], array);
+
+		TEST_EQ_STR (array[0], "");
+		TEST_EQ_STR (array[1], "");
+		TEST_EQ_STR (array[2], "");
+		TEST_EQ_STR (array[3], "this");
+		TEST_EQ_STR (array[4], "is");
+		TEST_EQ_STR (array[5], "");
+		TEST_EQ_STR (array[6], "");
+		TEST_EQ_STR (array[7], "");
+		TEST_EQ_STR (array[8], "a");
+		TEST_EQ_STR (array[9], "test");
+		TEST_EQ_STR (array[10], "");
+		TEST_EQ_STR (array[11], "");
+		TEST_EQ_P (array[12], NULL);
+
+		nih_free (array);
+	}
 
 	/* Check that we can split a string treating multiple consecutive
 	 * matching characters as a single separator to be skipped.
@@ -645,6 +854,177 @@
 		nih_free (array);
 	}
 
+	/* Check that we can split a string containing multiple
+	 * occurences of one of the delimiter characters at the
+	 * beginning of the string.
+	 */
+	TEST_FEATURE ("with repeat and multiple identical adjacent delimiter characters at string start");
+	TEST_ALLOC_FAIL {
+		array = nih_str_split (NULL, "\n\nhello", " \t\r\n", TRUE);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (array, NULL);
+			continue;
+		}
+
+		TEST_ALLOC_SIZE (array, sizeof (char *) * 2);
+		for (i = 0; i < 1; i++)
+			TEST_ALLOC_PARENT (array[i], array);
+
+		TEST_EQ_STR (array[0], "hello");
+		TEST_EQ_P (array[1], NULL);
+
+		nih_free (array);
+	}
+
+	TEST_FEATURE ("with repeat and multiple different adjacent delimiter characters at string start");
+	TEST_ALLOC_FAIL {
+		array = nih_str_split (NULL, "\n\r hello", " \t\r\n", TRUE);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (array, NULL);
+			continue;
+		}
+
+		TEST_ALLOC_SIZE (array, sizeof (char *) * 2);
+		for (i = 0; i < 1; i++)
+			TEST_ALLOC_PARENT (array[i], array);
+
+		TEST_EQ_STR (array[0], "hello");
+		TEST_EQ_P (array[1], NULL);
+
+		nih_free (array);
+	}
+
+	TEST_FEATURE ("with repeat and multiple identical adjacent delimiter "
+			"characters within string");
+	TEST_ALLOC_FAIL {
+		array = nih_str_split (NULL, "hello\n\rworld", " \t\n\r", TRUE);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (array, NULL);
+			continue;
+		}
+
+		TEST_ALLOC_SIZE (array, sizeof (char *) * 3);
+		for (i = 0; i < 2; i++)
+			TEST_ALLOC_PARENT (array[i], array);
+
+		TEST_EQ_STR (array[0], "hello");
+		TEST_EQ_STR (array[1], "world");
+		TEST_EQ_P (array[2], NULL);
+
+		nih_free (array);
+	}
+
+	TEST_FEATURE ("with repeat and multiple different adjacent delimiter "
+			"characters within string");
+	TEST_ALLOC_FAIL {
+		array = nih_str_split (NULL, "hello\n\r\tworld", " \t\n\r", TRUE);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (array, NULL);
+			continue;
+		}
+
+		TEST_ALLOC_SIZE (array, sizeof (char *) * 3);
+		for (i = 0; i < 2; i++)
+			TEST_ALLOC_PARENT (array[i], array);
+
+		TEST_EQ_STR (array[0], "hello");
+		TEST_EQ_STR (array[1], "world");
+		TEST_EQ_P (array[2], NULL);
+
+		nih_free (array);
+	}
+
+	TEST_FEATURE ("with repeat and multiple identical adjacent delimiter "
+			"characters at string end");
+	TEST_ALLOC_FAIL {
+		array = nih_str_split (NULL, "hello\n\n\n\n\n\n\n", " \t\r\n", TRUE);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (array, NULL);
+			continue;
+		}
+
+		TEST_ALLOC_SIZE (array, sizeof (char *) * 2);
+		for (i = 0; i < 1; i++)
+			TEST_ALLOC_PARENT (array[i], array);
+
+		TEST_EQ_STR (array[0], "hello");
+		TEST_EQ_P (array[1], NULL);
+
+		nih_free (array);
+	}
+
+	TEST_FEATURE ("with repeat and multiple different adjacent delimiter "
+			"characters at string end");
+	TEST_ALLOC_FAIL {
+		array = nih_str_split (NULL, "hello \r\t\r\t\n ", " \t\r\n", TRUE);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (array, NULL);
+			continue;
+		}
+
+		TEST_ALLOC_SIZE (array, sizeof (char *) * 2);
+		for (i = 0; i < 1; i++)
+			TEST_ALLOC_PARENT (array[i], array);
+
+		TEST_EQ_STR (array[0], "hello");
+		TEST_EQ_P (array[1], NULL);
+
+		nih_free (array);
+	}
+
+	TEST_FEATURE ("with repeat and multiple identical adjacent delimiter "
+			"characters at beginning, middle and end of string");
+	TEST_ALLOC_FAIL {
+		array = nih_str_split (NULL,
+				"        hello\n\n\n,  world\n\n\n",
+				"\r\t\n ", TRUE);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (array, NULL);
+			continue;
+		}
+
+		TEST_ALLOC_SIZE (array, sizeof (char *) * 4);
+		for (i = 0; i < 3; i++)
+			TEST_ALLOC_PARENT (array[i], array);
+
+		TEST_EQ_STR (array[0], "hello");
+		TEST_EQ_STR (array[1], ",");
+		TEST_EQ_STR (array[2], "world");
+		TEST_EQ_P (array[3], NULL);
+
+		nih_free (array);
+	}
+
+	TEST_FEATURE ("with repeat and multiple different adjacent delimiter "
+			"characters at beginning, middle and end of string");
+	TEST_ALLOC_FAIL {
+		array = nih_str_split (NULL,
+				"\n    \r\thello\n\n\r , \n\t\rworld\t \r\n \n",
+				" \t\n\r", TRUE);
+
+		if (test_alloc_failed) {
+			TEST_EQ_P (array, NULL);
+			continue;
+		}
+
+		TEST_ALLOC_SIZE (array, sizeof (char *) * 4);
+		for (i = 0; i < 3; i++)
+			TEST_ALLOC_PARENT (array[i], array);
+
+		TEST_EQ_STR (array[0], "hello");
+		TEST_EQ_STR (array[1], ",");
+		TEST_EQ_STR (array[2], "world");
+		TEST_EQ_P (array[3], NULL);
+
+		nih_free (array);
+	}
 
 	/* Check that we can give an empty string, and end up with a
 	 * one-element array that only contains a NULL pointer.
--- libnih-1.0.3.orig/nih/tests/test_file.c
+++ libnih-1.0.3/nih/tests/test_file.c
@@ -724,6 +724,25 @@
 	return FALSE;
 }
 
+/* find only frodo files */
+static int
+my_filter_frodo_file (void       *data,
+	   const char *path,
+	   int         is_dir)
+{
+	char *slash;
+
+	if (is_dir)
+		return FALSE;
+
+	slash = strrchr (path, '/');
+	if (strcmp (slash, "/frodo"))
+		return TRUE;
+
+	return FALSE;
+}
+
+
 static int logger_called = 0;
 
 static int
@@ -905,6 +924,48 @@
 		TEST_EQ_STR (v->path, filename);
 
 		nih_free (visited);
+
+				/* Try also inverse filter */
+		TEST_ALLOC_SAFE {
+			visitor_called = 0;
+			visited = nih_list_new (NULL);
+		}
+
+		ret = nih_dir_walk (dirname, my_filter_frodo_file,
+				    my_visitor, NULL, &ret);
+
+		TEST_EQ (ret, 0);
+		TEST_EQ (visitor_called, 4);
+
+		v = (Visited *)visited->next;
+		TEST_EQ (v->data, &ret);
+		TEST_EQ_STR (v->dirname, dirname);
+		strcpy (filename, dirname);
+		strcat (filename, "/bar");
+		TEST_EQ_STR (v->path, filename);
+
+		v = (Visited *)v->entry.next;
+		TEST_EQ (v->data, &ret);
+		TEST_EQ_STR (v->dirname, dirname);
+		strcpy (filename, dirname);
+		strcat (filename, "/bar/frodo");
+		TEST_EQ_STR (v->path, filename);
+
+		v = (Visited *)v->entry.next;
+		TEST_EQ (v->data, &ret);
+		TEST_EQ_STR (v->dirname, dirname);
+		strcpy (filename, dirname);
+		strcat (filename, "/baz");
+		TEST_EQ_STR (v->path, filename);
+
+		v = (Visited *)v->entry.next;
+		TEST_EQ (v->data, &ret);
+		TEST_EQ_STR (v->dirname, dirname);
+		strcpy (filename, dirname);
+		strcat (filename, "/frodo");
+		TEST_EQ_STR (v->path, filename);
+
+		nih_free (visited);
 	}
 
 
--- libnih-1.0.3.orig/debian/control
+++ libnih-1.0.3/debian/control
@@ -0,0 +1,81 @@
+Source: libnih
+Section: libs
+Priority: required
+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
+XSBC-Original-Maintainer: Scott James Remnant <scott@netsplit.com>
+Standards-Version: 3.9.4
+Build-Depends: debhelper (>= 9), pkg-config (>= 0.22), libdbus-1-dev (>= 1.4), libexpat1-dev (>= 2.0.0), dbus (>= 1.4), libc6-dev (>= 2.15~) | libc6.1-dev (>= 2.15~),
+               dh-autoreconf, autopoint, dpkg-dev (>= 1.16.1~)
+# To cross build this package also needs: libdbus-1-dev:native (>= 1.4), libexpat1-dev:native (>= 2.0.0)
+# But :native build-deps are not supported yet, so instead one can do
+# $ apt-get build-dep libnih
+# $ apt-get build-dep libnih -aarmhf
+# instead to get all required build-deps
+Vcs-Bzr: lp:ubuntu/libnih
+XSC-Debian-Vcs-Git: git://git.debian.org/git/collab-maint/libnih.git
+XSC-Debian-Vcs-Browser: http://git.debian.org/?p=collab-maint/libnih.git;a=summary
+Homepage: https://launchpad.net/libnih
+
+Package: libnih1
+Architecture: any
+Pre-Depends: ${misc:Pre-Depends}, ${shlibs:Depends}, ${misc:Depends}
+Multi-Arch: same
+Description: NIH Utility Library
+ libnih is a light-weight "standard library" of C functions to ease the
+ development of other libraries and applications, especially those
+ normally found in /lib.
+ .
+ This package contains the shared library.
+
+Package: libnih-dev
+Priority: optional
+Section: libdevel
+Architecture: any
+Multi-Arch: same
+Depends: libnih1 (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
+Description: NIH Utility Library (development files)
+ libnih is a light-weight "standard library" of C functions to ease the
+ development of other libraries and applications, especially those
+ normally found in /lib.
+ .
+ This package contains the static library and C header files which are
+ needed for developing software using libnih.
+
+Package: libnih-dbus1
+Architecture: any
+Pre-Depends: ${misc:Pre-Depends}
+Depends: libnih1 (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
+Multi-Arch: same
+Description: NIH D-Bus Bindings Library
+ libnih-dbus is a D-Bus bindings library that integrates with the main
+ loop provided by libnih.
+ .
+ This package contains the shared library.
+
+Package: libnih-dbus-dev
+Priority: optional
+Section: libdevel
+Architecture: any
+Multi-Arch: same
+Depends: libnih-dbus1 (= ${binary:Version}), libnih-dev (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
+Recommends: nih-dbus-tool (= ${binary:Version})
+Description: NIH D-Bus Bindings Library (development files)
+ libnih-dbus is a D-Bus bindings library that integrates with the main
+ loop provided by libnih.
+ .
+ This package contains the static library and C header files which are
+ needed for developing software using libnih-dbus.
+
+Package: nih-dbus-tool
+Section: devel
+Architecture: any
+Multi-Arch: foreign
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Recommends: libnih-dbus-dev (= ${binary:Version})
+Description: NIH D-Bus Binding Tool
+ nih-dbus-tool generates C source code from the D-Bus Introspection XML
+ data provided by most services; either to make implementing the
+ described objects in C programs or to make proxying to the described
+ remote objects easier.
+ .
+ The generated code requires libnih-dbus-dev to be compiled.
--- libnih-1.0.3.orig/debian/libnih-dev.install
+++ libnih-1.0.3/debian/libnih-dev.install
@@ -0,0 +1,6 @@
+lib/*/libnih.a
+lib/*/libnih.so
+usr/include/libnih.h
+usr/include/nih
+usr/lib/*/pkgconfig/libnih.pc
+usr/share/aclocal/libnih.m4
--- libnih-1.0.3.orig/debian/libnih1.docs
+++ libnih-1.0.3/debian/libnih1.docs
@@ -0,0 +1,3 @@
+AUTHORS
+NEWS
+README
--- libnih-1.0.3.orig/debian/libnih-dbus1.install
+++ libnih-1.0.3/debian/libnih-dbus1.install
@@ -0,0 +1 @@
+lib/*/libnih-dbus.so.*
--- libnih-1.0.3.orig/debian/libnih1.install
+++ libnih-1.0.3/debian/libnih1.install
@@ -0,0 +1 @@
+lib/*/libnih.so.*
--- libnih-1.0.3.orig/debian/rules
+++ libnih-1.0.3/debian/rules
@@ -0,0 +1,54 @@
+#!/usr/bin/make -f
+
+include /usr/share/dpkg/architecture.mk
+
+%:
+	dh $@ --with autoreconf
+
+
+CFLAGS := -Wall -fstack-protector -fPIE $(shell dpkg-buildflags --get CFLAGS)
+LDFLAGS := -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -pie $(shell dpkg-buildflags --get LDFLAGS)
+
+override_dh_auto_configure:
+ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
+	dh_auto_configure -- CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
+		--libdir=/lib/$(DEB_HOST_MULTIARCH)
+else
+	dh_auto_configure -B build-dbus-tool/ -- CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
+		--libdir=/lib/$(DEB_BUILD_MULTIARCH) \
+		--host=$(DEB_BUILD_GNU_TYPE)
+	dh_auto_build -B build-dbus-tool/ --parallel
+	dh_auto_configure -- CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
+		NIH_DBUS_TOOL=$(CURDIR)/build-dbus-tool/nih-dbus-tool/nih-dbus-tool \
+		--libdir=/lib/$(DEB_HOST_MULTIARCH)
+endif
+
+override_dh_auto_build:
+	dh_auto_build --parallel
+
+override_dh_auto_test:
+ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
+	dh_auto_test --parallel
+endif
+
+override_dh_auto_install:
+	dh_auto_install -- pkgconfigdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH)/pkgconfig
+
+override_dh_makeshlibs:
+	dh_makeshlibs -plibnih1 -V 'libnih1 (>= 1.0.0)'
+	dh_makeshlibs -plibnih-dbus1 -V 'libnih-dbus1 (>= 1.0.0)'
+	dh_makeshlibs -Nlibnih1 -Nlibnih-dbus1
+
+override_dh_shlibdeps:
+	dh_shlibdeps
+	sed -i 's/2\.14/2.15/' debian/*.substvars
+	sed -i 's/>= 2.15)/>= 2.15~)/g' debian/*.substvars
+
+
+# Symlink /usr/share/doc directories together
+override_dh_installdocs:
+	dh_installdocs --link-doc=libnih1
+
+override_dh_clean:
+	rm -rf build-dbus-tool/
+	dh_clean
--- libnih-1.0.3.orig/debian/compat
+++ libnih-1.0.3/debian/compat
@@ -0,0 +1 @@
+9
--- libnih-1.0.3.orig/debian/nih-dbus-tool.install
+++ libnih-1.0.3/debian/nih-dbus-tool.install
@@ -0,0 +1,2 @@
+usr/bin/nih-dbus-tool
+usr/share/man/man1/nih-dbus-tool.1
--- libnih-1.0.3.orig/debian/copyright
+++ libnih-1.0.3/debian/copyright
@@ -0,0 +1,18 @@
+This is the Ubuntu package of libnih, the NIH Utility Library.
+
+Copyright © 2009 Canonical Ltd.
+Copyright © 2009 Scott James Remnant <scott@netsplit.com>
+
+Licence:
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 2, as
+published by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+On Ubuntu systems, the complete text of the GNU General Public License
+can be found in ‘/usr/share/common-licenses/GPL-2’.
--- libnih-1.0.3.orig/debian/libnih-dbus1.postinst
+++ libnih-1.0.3/debian/libnih-dbus1.postinst
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+set -e
+
+if [ "$1" = configure ]; then
+    # A dependent library of Upstart has changed, so restart Upstart
+    # such that it can safely unmount the root filesystem (LP: #740390)
+
+    # Query running version of Upstart, but only when we know
+    # that initctl will work.
+    #
+    # The calculated version string may be the null string if
+    # Upstart is not running (where for example an alternative
+    # init is running outside a chroot environment) or if the
+    # query failed for some reason. However, the version check
+    # below handles a null version string correctly.
+    UPSTART_VERSION_RUNNING=$(initctl version 2>/dev/null |\
+        awk '{print $3}'|tr -d ')' || :)
+
+    if ischroot; then
+        # Do not honour re-exec when requested from within a
+        # chroot since:
+        #
+        # (a) The version of Upstart outside might not support it.
+        # (b) An isolated environment such as a chroot should
+        #     not be able to modify its containing environment.
+        #
+        # A sufficiently new Upstart will actually handle a re-exec
+        # request coming from telinit within a chroot correctly (by
+        # doing nothing) but it's simple enough to perform the check
+        # here and save Upstart the effort.
+        :
+    elif dpkg --compare-versions "$UPSTART_VERSION_RUNNING" ge 1.6.1; then
+        # We are not running inside a chroot and the running version
+        # of Upstart supports stateful re-exec, so we can
+        # restart immediately.
+        #
+        # XXX: Note that the check on the running version must
+        # remain *indefinitely* since it's the only safe way to
+        # know if stateful re-exec is supported: simply checking
+        # packaged version numbers is not sufficient since
+        # the package could be upgraded multiple times without a
+        # reboot.
+        telinit u || :
+    else
+        # Before we shutdown or reboot, we need to re-exec so that we
+        # can safely remount the root filesystem; we can't just do that
+        # here because we lose state.
+        touch /var/run/init.upgraded || :
+    fi
+fi
+
+#DEBHELPER#
--- libnih-1.0.3.orig/debian/changelog.DEBIAN
+++ libnih-1.0.3/debian/changelog.DEBIAN
@@ -0,0 +1,118 @@
+libnih (1.0.3-4) unstable; urgency=low
+
+  * Rebuild for new libc to update versioned dependency; this comes from
+    the __abort_msg dependency, dpkg-shlibs needs overriding since this is
+    actually a weak link, but this rebuild fixes things for now.
+    Closes: #625257.
+
+ -- Scott James Remnant <scott@netsplit.com>  Mon, 02 May 2011 15:08:33 -0700
+
+libnih (1.0.3-3) unstable; urgency=low
+
+  * New maintainer.  Closes: #624442.
+
+ -- Scott James Remnant <scott@netsplit.com>  Thu, 28 Apr 2011 14:26:05 -0700
+
+libnih (1.0.3-2) unstable; urgency=low
+
+  * Bump build dependency on libdbus-1-dev and dbus to (>= 1.4) for Unix file
+    descriptor passing support.
+
+ -- Michael Biebl <biebl@debian.org>  Thu, 10 Feb 2011 20:25:18 +0100
+
+libnih (1.0.3-1ubuntu1) natty; urgency=low
+
+  * Rebuild with libc6-dev (>= 2.13~).
+
+ -- Matthias Klose <doko@ubuntu.com>  Fri, 18 Feb 2011 12:09:29 +0100
+
+libnih (1.0.3-1) unstable; urgency=low
+
+  * New upstream release.
+  * Bump debhelper compatibility level to 8 and update build dependency
+    accordingly.
+
+ -- Michael Biebl <biebl@debian.org>  Mon, 07 Feb 2011 22:19:13 +0100
+
+libnih (1.0.2-2) unstable; urgency=low
+
+  * Install library development files to /usr/lib and not /lib.
+  * Remove libtool *.la files as there are no reverse dependencies referencing
+    them.
+  * Bump Standards-Version to 3.9.1. No further changes.
+
+ -- Michael Biebl <biebl@debian.org>  Sun, 02 Jan 2011 21:09:40 +0100
+
+libnih (1.0.2-1ubuntu3) natty; urgency=low
+
+  * Disable some tests on ppc64 to build an initial package.
+
+ -- Matthias Klose <doko@ubuntu.com>  Thu, 18 Nov 2010 10:59:38 +0100
+
+libnih (1.0.2-1ubuntu2) maverick; urgency=low
+
+  * Re-add -fPIE to the testsuite on armel, removing all armel-specific tests;
+    current gcc-4.4 don't seem affected by the ICE anymore (see LP #398403).
+
+ -- Loïc Minier <loic.minier@linaro.org>  Mon, 23 Aug 2010 10:25:31 +0200
+
+libnih (1.0.2-1ubuntu1) maverick; urgency=low
+
+  * Rebuild with libc6-dev (>= 2.12~), after checking that
+    __abort_msg is available with the same signature in eglibc 2.12.
+  * Don't build the testsuite with -fPIE on armel; LP: #398403.
+
+ -- Matthias Klose <doko@ubuntu.com>  Sun, 30 May 2010 02:54:56 +0200
+
+libnih (1.0.2-1) unstable; urgency=low
+
+  * Initial upload to Debian. Closes: #585071
+  * Based on the Ubuntu package for Lucid done by Scott James Remnant with the
+    following changes:
+    - Switch packages to priority optional.
+    - Use binary:Version instead of Source-Version.
+    - Bump Standards-Version to 3.8.4.
+    - Add Homepage and Vcs-* fields.
+    - Don't symlink /usr/share/doc directories.
+    - Refer to versioned /usr/share/common-licenses/GPL-2 file in
+      debian/copyright.
+    - List all symbols explicitly instead of using a wildcard and add symbols
+      introduced in 1.0.1.
+    - Use the symbols files to create the correct version info instead of
+      specifying it manually via shlibs.
+    - Switch to source format 3.0 (quilt).
+    - Add watch file to track new upstream releases.
+
+ -- Michael Biebl <biebl@debian.org>  Sun, 13 Jun 2010 23:36:52 +0200
+
+libnih (1.0.1-1) lucid; urgency=low
+
+  * New upstream release:
+    - Add missing __nih_* symbols to linker version script so that we
+      can link Upstart's test suite.
+    - Glibc __abort_msg symbol now only linked as a weak symbol.
+
+ -- Scott James Remnant <scott@ubuntu.com>  Thu, 04 Feb 2010 14:53:26 -0800
+
+libnih (1.0.0-2build1) lucid; urgency=low
+
+  * Rebuild to pick up relaxed dependency on libc6, after checking that
+    __abort_msg is available with the same signature in eglibc 2.11.
+    LP: #508702.
+
+ -- Matthias Klose <doko@ubuntu.com>  Mon, 18 Jan 2010 16:09:13 +0100
+
+libnih (1.0.0-2) lucid; urgency=low
+
+  * debian/control: Add build-dependency on dbus so the test suite can
+    pass on the buildds.
+
+ -- Scott James Remnant <scott@ubuntu.com>  Sat, 28 Nov 2009 23:28:27 +0000
+
+libnih (1.0.0-1) lucid; urgency=low
+
+  * First upstream release.  Previously this code was included in the
+    upstart, mountall and ureadahead source packages.
+
+ -- Scott James Remnant <scott@ubuntu.com>  Sat, 28 Nov 2009 21:14:00 +0000
+
--- libnih-1.0.3.orig/debian/libnih1.symbols
+++ libnih-1.0.3/debian/libnih1.symbols
@@ -0,0 +1,2 @@
+libnih.so.1 libnih1 #MINVER#
+ *@LIBNIH_1_0 1.0.0
--- libnih-1.0.3.orig/debian/libnih-dbus-dev.install
+++ libnih-1.0.3/debian/libnih-dbus-dev.install
@@ -0,0 +1,5 @@
+lib/*/libnih-dbus.a
+lib/*/libnih-dbus.so
+usr/include/libnih-dbus.h
+usr/include/nih-dbus
+usr/lib/*/pkgconfig/libnih-dbus.pc
--- libnih-1.0.3.orig/debian/libnih1.postinst
+++ libnih-1.0.3/debian/libnih1.postinst
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+set -e
+
+if [ "$1" = configure ]; then
+    # A dependent library of Upstart has changed, so restart Upstart
+    # such that it can safely unmount the root filesystem (LP: #740390)
+
+    # Query running version of Upstart, but only when we know
+    # that initctl will work.
+    #
+    # The calculated version string may be the null string if
+    # Upstart is not running (where for example an alternative
+    # init is running outside a chroot environment) or if the
+    # query failed for some reason. However, the version check
+    # below handles a null version string correctly.
+    UPSTART_VERSION_RUNNING=$(initctl version 2>/dev/null |\
+        awk '{print $3}'|tr -d ')' || :)
+
+    if ischroot; then
+        # Do not honour re-exec when requested from within a
+        # chroot since:
+        #
+        # (a) The version of Upstart outside might not support it.
+        # (b) An isolated environment such as a chroot should
+        #     not be able to modify its containing environment.
+        #
+        # A sufficiently new Upstart will actually handle a re-exec
+        # request coming from telinit within a chroot correctly (by
+        # doing nothing) but it's simple enough to perform the check
+        # here and save Upstart the effort.
+        :
+    elif dpkg --compare-versions "$UPSTART_VERSION_RUNNING" ge 1.6.1; then
+        # We are not running inside a chroot and the running version
+        # of Upstart supports stateful re-exec, so we can
+        # restart immediately.
+        #
+        # XXX: Note that the check on the running version must
+        # remain *indefinitely* since it's the only safe way to
+        # know if stateful re-exec is supported: simply checking
+        # packaged version numbers is not sufficient since
+        # the package could be upgraded multiple times without a
+        # reboot.
+        telinit u || :
+    else
+        # Before we shutdown or reboot, we need to re-exec so that we
+        # can safely remount the root filesystem; we can't just do that
+        # here because we lose state.
+        touch /var/run/init.upgraded || :
+    fi
+fi
+
+#DEBHELPER#
--- libnih-1.0.3.orig/debian/libnih-dbus1.symbols
+++ libnih-1.0.3/debian/libnih-dbus1.symbols
@@ -0,0 +1,2 @@
+libnih-dbus.so.1 libnih-dbus1 #MINVER#
+ *@LIBNIH_DBUS_1_0 1.0.0
--- libnih-1.0.3.orig/debian/changelog
+++ libnih-1.0.3/debian/changelog
@@ -0,0 +1,213 @@
+libnih (1.0.3-4ubuntu16) raring; urgency=low
+
+  * debian/{libnih1.postinst,libnih-dbus1.postinst}: Force an upgrade to
+    restart Upstart (to pick up new package version) if the running
+    instance supports it.
+  * Merge of important fixes from lp:~upstart-devel/libnih/nih
+    (LP: #776532, LP: #777097, LP: #834813, LP: #1123588).
+
+ -- James Hunt <james.hunt@ubuntu.com>  Thu, 14 Mar 2013 09:14:22 +0000
+
+libnih (1.0.3-4ubuntu15) raring; urgency=low
+
+  * Enable cross-building, sans adding :native build-dependencies.
+    See comments in debian/control.
+  * Lintian fixes.
+
+ -- Dmitrijs Ledkovs <dmitrij.ledkov@ubuntu.com>  Tue, 08 Jan 2013 15:38:58 +0000
+
+libnih (1.0.3-4ubuntu14) raring; urgency=low
+
+  * Update dbus code generator to allow for empty lists for type 'as'.
+    This drops the != NULL check for NULL terminated arrays and moves the
+    iteration loop inside an 'if' statement.
+
+ -- Stéphane Graber <stgraber@ubuntu.com>  Thu, 13 Dec 2012 10:00:27 -0500
+
+libnih (1.0.3-4ubuntu13) raring; urgency=low
+
+  [ Petr Lautrbach <plautrba@redhat.com>, Dmitrijs Ledkovs ]
+  * Fallback to lstat, if dirent.d_type is not available (not portable)
+    (LP: #672643) (Closes: #695604)
+
+ -- Dmitrijs Ledkovs <dmitrij.ledkov@ubuntu.com>  Tue, 11 Dec 2012 17:26:52 +0000
+
+libnih (1.0.3-4ubuntu12) raring; urgency=low
+
+  * nih/logging.c: Use our own __nih_abort_msg rather than the (e)glibc
+    private symbol __abort_msg to avoid upgrade issues (LP: #997359).
+  * nih/tests/test_logging.c: Update tests for __nih_abort_msg.
+
+ -- James Hunt <james.hunt@ubuntu.com>  Thu, 25 Oct 2012 10:57:30 +0100
+
+libnih (1.0.3-4ubuntu11) quantal; urgency=low
+
+  * Addition of debian/libnih-dbus1.postinst and
+    debian/libnih1.postinst to force Upstart re-exec on shutdown
+    to avoid unmounting disks uncleanly (LP: #740390).
+
+ -- James Hunt <james.hunt@ubuntu.com>  Wed, 03 Oct 2012 16:49:40 +0100
+
+libnih (1.0.3-4ubuntu10) quantal; urgency=low
+
+  * Update config.guess,sub for aarch64
+
+ -- Wookey <wookey@wookware.org>  Mon, 01 Oct 2012 12:57:05 +0100
+
+libnih (1.0.3-4ubuntu9) precise; urgency=low
+
+  * Mark the nih-dbus-tool package Multi-Arch: foreign so it can be used as
+    a build-dependency of upstart when cross-building.
+
+ -- Steve Langasek <steve.langasek@ubuntu.com>  Wed, 15 Feb 2012 22:57:50 -0800
+
+libnih (1.0.3-4ubuntu8) precise; urgency=low
+
+  * libnih1 needs a versioned Pre-Depend on libc6 instead of just a Depend,
+    because libc6 itself uses runlevel from the upstart package in its
+    preinst, which in turn uses libnih1, which needs to be loadable (i.e.,
+    its symbol references resolve).  We therefore need to ensure that
+    libnih1's dependencies are always unpacked before libnih1 itself is
+    unpacked.  While having something further up the stack (such as upstart,
+    or something on top of upstart) being marked Essential: yes and with the
+    necessary pre-depends would let apt handle this for us with its
+    "immediate configuration" support, but for various reasons we don't want
+    to make upstart essential.  LP: #508083.
+
+ -- Steve Langasek <steve.langasek@ubuntu.com>  Fri, 10 Feb 2012 12:13:25 -0800
+
+libnih (1.0.3-4ubuntu7) precise; urgency=low
+
+  * Relax dependency on libc6.
+
+ -- Matthias Klose <doko@ubuntu.com>  Wed, 08 Feb 2012 23:43:21 +0100
+
+libnih (1.0.3-4ubuntu6) precise; urgency=low
+
+  * Rebuild with libc6-dev (>= 2.15~).
+
+ -- Matthias Klose <doko@ubuntu.com>  Wed, 08 Feb 2012 21:48:57 +0100
+
+libnih (1.0.3-4ubuntu5) precise; urgency=low
+
+  * Mark libnih-dev and libnih-dbus-dev Multi-Arch: same as well.
+
+ -- Steve Langasek <steve.langasek@ubuntu.com>  Sun, 06 Nov 2011 14:45:07 -0800
+
+libnih (1.0.3-4ubuntu4) precise; urgency=low
+
+  * Make libnih1 and libnih-dbus1 installable using multi-arch.
+
+ -- James Hunt <james.hunt@ubuntu.com>  Tue, 01 Nov 2011 14:25:09 -0400
+
+libnih (1.0.3-4ubuntu3) precise; urgency=low
+
+  * Build to install with eglibc-2.15.
+
+ -- Matthias Klose <doko@ubuntu.com>  Fri, 14 Oct 2011 14:05:03 +0200
+
+libnih (1.0.3-4ubuntu2) oneiric; urgency=low
+
+  * Use dpkg-buildflags to get the build flags.
+  * Build with the default build flags, don't hard-code -Os. LP: #791315.
+
+ -- Matthias Klose <doko@ubuntu.com>  Wed, 15 Jun 2011 16:45:42 +0200
+
+libnih (1.0.3-4ubuntu1) oneiric; urgency=low
+
+  * Merge from debian unstable. Retained Ubuntu Build-Depends and Priority.
+
+ -- James Hunt <james.hunt@ubuntu.com>  Mon, 23 May 2011 19:28:19 +0100
+
+libnih (1.0.3-1ubuntu1) natty; urgency=low
+
+  * Rebuild with libc6-dev (>= 2.13~).
+
+ -- Matthias Klose <doko@ubuntu.com>  Fri, 18 Feb 2011 12:09:29 +0100
+
+libnih (1.0.3-1) natty; urgency=low
+
+  * New upstream release:
+    - Added support for passing file descriptors over D-Bus to nih-dbus-tool
+
+ -- Scott James Remnant <scott@ubuntu.com>  Thu, 23 Dec 2010 22:28:24 +0000
+
+libnih (1.0.2-2) natty; urgency=low
+
+  * Revert the previous upload.  It is never acceptable to simply disable
+    tests, especially when it turns out that the test that was disabled
+    was failing because there was a serious bug that could cause kernel
+    panics for people on boot.
+
+    Test suites are here for a reason.
+
+  * Bumped libdbus Build-Dependency to the version with the bug fix that
+    caused the test suite to fail.
+
+ -- Scott James Remnant <scott@ubuntu.com>  Wed, 08 Dec 2010 19:40:15 +0000
+
+libnih (1.0.2-1ubuntu3) natty; urgency=low
+
+  * Disable some tests on ppc64 to build an initial package.
+
+ -- Matthias Klose <doko@ubuntu.com>  Thu, 18 Nov 2010 10:59:38 +0100
+
+libnih (1.0.2-1ubuntu2) maverick; urgency=low
+
+  * Re-add -fPIE to the testsuite on armel, removing all armel-specific tests;
+    current gcc-4.4 don't seem affected by the ICE anymore (see LP #398403).
+
+ -- Loïc Minier <loic.minier@linaro.org>  Mon, 23 Aug 2010 10:25:31 +0200
+
+libnih (1.0.2-1ubuntu1) maverick; urgency=low
+
+  * Rebuild with libc6-dev (>= 2.12~), after checking that
+    __abort_msg is available with the same signature in eglibc 2.12.
+  * Don't build the testsuite with -fPIE on armel; LP: #398403.
+
+ -- Matthias Klose <doko@ubuntu.com>  Sun, 30 May 2010 02:54:56 +0200
+
+libnih (1.0.2-1) maverick; urgency=low
+
+  * New upstream release:
+    - Rename AC_COPYRIGHT to NIH_COPYRIGHT to avoid conflict with other
+      packages.
+    - Add serial to libnih.m4
+    - Add NIH_WITH_LOCAL_LIBNIH macro.
+
+  * Fix use of ${Source-Version} to be ${binary:Version}
+  * Add debian/source/format with "1.0" to be future compatible.
+  * Bump standards version.
+
+ -- Scott James Remnant <scott@ubuntu.com>  Tue, 27 Apr 2010 10:49:55 -0700
+
+libnih (1.0.1-1) lucid; urgency=low
+
+  * New upstream release:
+    - Add missing __nih_* symbols to linker version script so that we
+      can link Upstart's test suite.
+    - Glibc __abort_msg symbol now only linked as a weak symbol.
+
+ -- Scott James Remnant <scott@ubuntu.com>  Thu, 04 Feb 2010 14:53:26 -0800
+
+libnih (1.0.0-2build1) lucid; urgency=low
+
+  * Rebuild to pick up relaxed dependency on libc6, after checking that
+    __abort_msg is available with the same signature in eglibc 2.11.
+    LP: #508702.
+
+ -- Matthias Klose <doko@ubuntu.com>  Mon, 18 Jan 2010 16:09:13 +0100
+
+libnih (1.0.0-2) lucid; urgency=low
+
+  * debian/control: Add build-dependency on dbus so the test suite can
+    pass on the buildds.
+
+ -- Scott James Remnant <scott@ubuntu.com>  Sat, 28 Nov 2009 23:28:27 +0000
+
+libnih (1.0.0-1) lucid; urgency=low
+
+  * First upstream release.  Previously this code was included in the
+    upstart, mountall and ureadahead source packages.
+
+ -- Scott James Remnant <scott@ubuntu.com>  Sat, 28 Nov 2009 21:14:00 +0000
--- libnih-1.0.3.orig/debian/source/format
+++ libnih-1.0.3/debian/source/format
@@ -0,0 +1 @@
+1.0
--- libnih-1.0.3.orig/nih-dbus/dbus_proxy.h
+++ libnih-1.0.3/nih-dbus/dbus_proxy.h
@@ -146,14 +146,14 @@
 					    const char *name, const char *path,
 					    NihDBusLostHandler lost_handler,
 					    void *data)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NihDBusProxySignal *nih_dbus_proxy_connect (NihDBusProxy *proxy,
 					    const NihDBusInterface *interface,
 					    const char *name,
 					    NihDBusSignalHandler handler,
 					    void *data)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih-dbus/dbus_object.h
+++ libnih-1.0.3/nih-dbus/dbus_object.h
@@ -61,8 +61,7 @@
 				    DBusConnection *connection,
 				    const char *path,
 				    const NihDBusInterface **interfaces,
-				    void *data)
-	__attribute__ ((malloc));
+				    void *data);
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih-dbus/dbus_util.h
+++ libnih-1.0.3/nih-dbus/dbus_util.h
@@ -26,7 +26,7 @@
 NIH_BEGIN_EXTERN
 
 char *nih_dbus_path (const void *parent, const char *root, ...)
-	__attribute__ ((sentinel, warn_unused_result, malloc));
+	__attribute__ ((sentinel, warn_unused_result));
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih-dbus/dbus_pending_data.h
+++ libnih-1.0.3/nih-dbus/dbus_pending_data.h
@@ -104,7 +104,7 @@
 					       NihDBusReplyHandler handler,
 					       NihDBusErrorHandler error_handler,
 					       void *data)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih-dbus/dbus_proxy.c
+++ libnih-1.0.3/nih-dbus/dbus_proxy.c
@@ -46,11 +46,11 @@
 	__attribute__ ((warn_unused_result));
 static char *nih_dbus_proxy_name_rule         (const void *parent,
 					       NihDBusProxy *proxy)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 static int   nih_dbus_proxy_signal_destroy    (NihDBusProxySignal *proxied);
 static char *nih_dbus_proxy_signal_rule       (const void *parent,
 					       NihDBusProxySignal *proxied)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 /* Prototypes for handler functions */
 static DBusHandlerResult nih_dbus_proxy_name_owner_changed (DBusConnection *connection,
--- libnih-1.0.3.orig/nih-dbus-tool/symbol.c
+++ libnih-1.0.3/nih-dbus-tool/symbol.c
@@ -40,10 +40,10 @@
 /* Prototypes for static functions */
 static char *symbol_strcat_interface (char **str, const void *parent,
 				      const char *format, ...)
-	__attribute__ ((format (printf, 3, 4), warn_unused_result, malloc));
+	__attribute__ ((format (printf, 3, 4), warn_unused_result));
 static char *symbol_strcat_title     (char **str, const void *parent,
 				      const char *format, ...)
-	__attribute__ ((format (printf, 3, 4), warn_unused_result, malloc));
+	__attribute__ ((format (printf, 3, 4), warn_unused_result));
 
 
 /**
--- libnih-1.0.3.orig/nih-dbus-tool/demarshal.h
+++ libnih-1.0.3/nih-dbus-tool/demarshal.h
@@ -37,7 +37,7 @@
 		 const char *prefix, const char *interface_symbol,
 		 const char *member_symbol, const char *symbol,
 		 NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih-dbus-tool/symbol.h
+++ libnih-1.0.3/nih-dbus-tool/symbol.h
@@ -28,22 +28,22 @@
 int   symbol_valid     (const char *symbol);
 
 char *symbol_from_name (const void *parent, const char *name)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *symbol_impl      (const void *parent, const char *prefix,
 			const char *interface_name, const char *name,
 			const char *postfix)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *symbol_extern    (const void *parent, const char *prefix,
 			const char *interface_symbol, const char *midfix,
 			const char *symbol, const char *postfix)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *symbol_typedef   (const void *parent, const char *prefix,
 			const char *interface_symbol, const char *midfix,
 			const char *symbol, const char *postfix)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih-dbus-tool/output.h
+++ libnih-1.0.3/nih-dbus-tool/output.h
@@ -35,9 +35,9 @@
 	__attribute__ ((warn_unused_result));
 
 char *output_preamble (const void *parent, const char *path)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *output_sentinel (const void *parent, const char *path)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih-dbus-tool/parse.h
+++ libnih-1.0.3/nih-dbus-tool/parse.h
@@ -95,7 +95,7 @@
 
 ParseStack *parse_stack_push (const void *parent, NihList *stack,
 			      ParseStackType type, void *data)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 ParseStack *parse_stack_top  (NihList *stack);
 
 void        parse_start_tag  (XML_Parser xmlp, const char *tag,
@@ -103,7 +103,7 @@
 void        parse_end_tag    (XML_Parser xmlp, const char *tag);
 
 Node *      parse_xml        (const void *parent, int fd, const char *filename)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih-dbus-tool/type.h
+++ libnih-1.0.3/nih-dbus-tool/type.h
@@ -94,43 +94,43 @@
 
 char *      type_of               (const void * parent,
 				   DBusSignatureIter *iter)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 TypeVar *   type_var_new          (const void *parent, const char *type,
 				   const char *name)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *      type_var_to_string    (const void *parent, TypeVar *var)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *      type_var_layout       (const void *parent, NihList *vars)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 TypeFunc *  type_func_new         (const void *parent, const char *type,
 				   const char *name)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *      type_func_to_string   (const void *parent, TypeFunc *func)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *      type_func_to_typedef  (const void *parent, TypeFunc *func)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *      type_func_layout      (const void *parent, NihList *funcs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 TypeStruct *type_struct_new       (const void *parent, const char *name)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *      type_struct_to_string (const void *parent, TypeStruct *structure)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *      type_to_const         (char **type, const void *parent)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *      type_to_pointer       (char **type, const void *parent)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *      type_to_static        (char **type, const void *parent)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *      type_to_extern        (char **type, const void *parent)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *      type_strcat_assert    (char **block, const void *parent,
 				   TypeVar *var, TypeVar *prev, TypeVar *next)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih-dbus-tool/argument.h
+++ libnih-1.0.3/nih-dbus-tool/argument.h
@@ -61,7 +61,7 @@
 
 Argument *argument_new        (const void *parent, const char *name,
 			       const char *type, NihDBusArgDir direction)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 int       argument_start_tag  (XML_Parser xmlp, const char *tag,
 			       char * const *attr)
--- libnih-1.0.3.orig/nih-dbus-tool/indent.h
+++ libnih-1.0.3/nih-dbus-tool/indent.h
@@ -26,9 +26,9 @@
 NIH_BEGIN_EXTERN
 
 char *indent  (char **str, const void *parent, int level)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *comment (char **str, const void *parent)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih-dbus-tool/main.c
+++ libnih-1.0.3/nih-dbus-tool/main.c
@@ -52,10 +52,10 @@
 /* Prototypes for local functions */
 char *source_file_path (const void *parent, const char *output_path,
 			const char *filename)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *header_file_path (const void *parent, const char *output_path,
 			const char *filename)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 
 /**
--- libnih-1.0.3.orig/nih-dbus-tool/signal.h
+++ libnih-1.0.3/nih-dbus-tool/signal.h
@@ -58,7 +58,7 @@
 int       signal_name_valid      (const char *name);
 
 Signal *  signal_new             (const void *parent, const char *name)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 int       signal_start_tag       (XML_Parser xmlp, const char *tag,
 				  char * const *attr)
@@ -76,18 +76,18 @@
 char *    signal_object_function (const void *parent, const char *prefix,
 				  Interface *interface, Signal *signal,
 				  NihList *prototypes, NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *    signal_proxy_function  (const void *parent, const char *prefix,
 				  Interface *interface, Signal *signal,
 				  NihList *prototypes, NihList *typedefs,
 				  NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *    signal_args_array      (const void *parent, const char *prefix,
 				  Interface *interface, Signal *signal,
 				  NihList *prototypes)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih-dbus-tool/marshal.c
+++ libnih-1.0.3/nih-dbus-tool/marshal.c
@@ -49,7 +49,7 @@
 			     const char *prefix, const char *interface_symbol,
 			     const char *member_symbol, const char *symbol,
 			     NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 static char *marshal_array  (const void *parent,
 			     DBusSignatureIter *iter,
 			     const char *iter_name, const char *name,
@@ -58,7 +58,7 @@
 			     const char *prefix, const char *interface_symbol,
 			     const char *member_symbol, const char *symbol,
 			     NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 static char *marshal_struct (const void *parent,
 			     DBusSignatureIter *iter,
 			     const char *iter_name, const char *name,
@@ -67,7 +67,7 @@
 			     const char *prefix, const char *interface_symbol,
 			     const char *member_symbol, const char *symbol,
 			     NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 
 /**
@@ -364,6 +364,7 @@
 	nih_local TypeVar *element_len_var = NULL;
 	nih_local char *   block = NULL;
 	nih_local char *   vars_block = NULL;
+	nih_local char *   loop_block = NULL;
 
 	nih_assert (iter != NULL);
 	nih_assert (iter_name != NULL);
@@ -448,7 +449,7 @@
 	nih_list_add (locals, &array_iter_var->entry);
 
 	if (dbus_type_is_fixed (element_type)) {
-		if (! nih_strcat_sprintf (&code, parent,
+		if (! nih_strcat_sprintf (&loop_block, parent,
 					  "for (size_t %s = 0; %s < %s; %s++) {\n",
 					  loop_name, loop_name, len_name, loop_name)) {
 			nih_free (code);
@@ -456,6 +457,12 @@
 		}
 	} else {
 		if (! nih_strcat_sprintf (&code, parent,
+					  "if (%s) {\n",
+					  name)) {
+			nih_free (code);
+			return NULL;
+		}
+		if (! nih_strcat_sprintf (&loop_block, parent,
 					  "for (size_t %s = 0; %s[%s]; %s++) {\n",
 					  loop_name, name, loop_name, loop_name)) {
 			nih_free (code);
@@ -576,7 +583,7 @@
 	}
 
 
-	if (! nih_strcat_sprintf (&code, parent,
+	if (! nih_strcat_sprintf (&loop_block, parent,
 			   "%s"
 			   "\n"
 			   "%s"
@@ -590,9 +597,34 @@
 	}
 
 	/* Close the container again */
+	if (! nih_strcat_sprintf (&loop_block, parent,
+				  "}\n")) {
+		nih_free (code);
+		return NULL;
+	}
+
+	if (dbus_type_is_fixed (element_type)) {
+		if (! nih_strcat_sprintf (&code, parent,
+				 "%s\n", loop_block)) {
+			nih_free (code);
+			return NULL;
+		}
+	}
+	else {
+		if (! indent (&loop_block, NULL, 1)) {
+			nih_free (code);
+			return NULL;
+		}
+
+		if (! nih_strcat_sprintf (&code, parent,
+				 "%s"
+				 "}\n\n", loop_block)) {
+			nih_free (code);
+			return NULL;
+		}
+	}
+
 	if (! nih_strcat_sprintf (&code, parent,
-				  "}\n"
-				  "\n"
 				  "if (! dbus_message_iter_close_container (&%s, &%s)) {\n"
 				  "%s"
 				  "}\n",
--- libnih-1.0.3.orig/nih-dbus-tool/demarshal.c
+++ libnih-1.0.3/nih-dbus-tool/demarshal.c
@@ -51,7 +51,7 @@
 			       const char *prefix, const char *interface_symbol,
 			       const char *member_symbol, const char *symbol,
 			       NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 static char *demarshal_array  (const void *parent,
 			       DBusSignatureIter *iter,
 			       const char *parent_name,
@@ -62,7 +62,7 @@
 			       const char *prefix, const char *interface_symbol,
 			       const char *member_symbol, const char *symbol,
 			       NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 static char *demarshal_struct (const void *parent,
 			       DBusSignatureIter *iter,
 			       const char *parent_name,
@@ -73,7 +73,7 @@
 			       const char *prefix, const char *interface_symbol,
 			       const char *member_symbol, const char *symbol,
 			       NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 
 /**
--- libnih-1.0.3.orig/nih-dbus-tool/interface.h
+++ libnih-1.0.3/nih-dbus-tool/interface.h
@@ -61,7 +61,7 @@
 
 Interface *interface_new                           (const void *parent,
 						    const char *name)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 int        interface_start_tag                     (XML_Parser xmlp,
 						    const char *tag,
@@ -81,26 +81,26 @@
 						    Interface *interface,
 						    int with_handlers,
 						    NihList *prototypes)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *     interface_signals_array                 (const void *parent,
 						    const char *prefix,
 						    Interface *interface,
 						    int with_filters,
 						    NihList *prototypes)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *     interface_properties_array              (const void *parent,
 						    const char *prefix,
 						    Interface *interface,
 						    int with_handlers,
 						    NihList *prototypes)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *     interface_struct                        (const void *parent,
 						    const char *prefix,
 						    Interface *interface,
 						    int object,
 						    NihList *prototypes)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 
 char *     interface_proxy_get_all_function        (const void *parent,
@@ -108,7 +108,7 @@
 						    Interface *interface,
 						    NihList *prototypes,
 						    NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *     interface_proxy_get_all_notify_function (const void *parent,
 						    const char *prefix,
@@ -116,14 +116,14 @@
 						    NihList *prototypes,
 						    NihList *typedefs,
 						    NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *     interface_proxy_get_all_sync_function   (const void *parent,
 						    const char *prefix,
 						    Interface *interface,
 						    NihList *prototypes,
 						    NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih-dbus-tool/method.h
+++ libnih-1.0.3/nih-dbus-tool/method.h
@@ -62,7 +62,7 @@
 int       method_name_valid            (const char *name);
 
 Method *  method_new                   (const void *parent, const char *name)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 int       method_start_tag             (XML_Parser xmlp, const char *tag,
 					char * const *attr)
@@ -82,33 +82,33 @@
 					Interface *interface, Method *method,
 					NihList *prototypes, NihList *handlers,
 					NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *    method_reply_function        (const void *parent, const char *prefix,
 					Interface *interface, Method *method,
 					NihList *prototypes, NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *    method_proxy_function        (const void *parent, const char *prefix,
 					Interface *interface, Method *method,
 					NihList *prototypes, NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *    method_proxy_notify_function (const void *parent, const char *prefix,
 					Interface *interface, Method *method,
 					NihList *prototypes, NihList *typedefs,
 					NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *    method_proxy_sync_function   (const void *parent, const char *prefix,
 					Interface *interface, Method *method,
 					NihList *prototypes, NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *    method_args_array            (const void *parent, const char *prefix,
 					Interface *interface, Method *method,
 					NihList *prototypes)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih-dbus-tool/node.h
+++ libnih-1.0.3/nih-dbus-tool/node.h
@@ -47,7 +47,7 @@
 int        node_path_valid       (const char *name);
 
 Node *     node_new              (const void *parent, const char *path)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 int        node_start_tag        (XML_Parser xmlp, const char *tag,
 				  char * const *attr)
@@ -59,18 +59,18 @@
 
 char *     node_interfaces_array (const void *parent, const char *prefix,
 				  Node *node, int object, NihList *prototypes)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *     node_object_functions (const void *parent, const char *prefix,
 				  Node *node,
 				  NihList *prototypes, NihList *handlers,
 				  NihList *structs, NihList *externs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *     node_proxy_functions  (const void *parent, const char *prefix,
 				  Node *node,
 				  NihList *prototypes, NihList *structs,
 				  NihList *typedefs, NihList *externs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih-dbus-tool/marshal.h
+++ libnih-1.0.3/nih-dbus-tool/marshal.h
@@ -35,7 +35,7 @@
 	       const char *prefix, const char *interface_symbol,
 	       const char *member_symbol, const char *symbol,
 	       NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih-dbus-tool/type.c
+++ libnih-1.0.3/nih-dbus-tool/type.c
@@ -1101,7 +1101,7 @@
 	nih_assert (block != NULL);
 	nih_assert (var != NULL);
 
-	if (! strchr (var->type, '*'))
+	if (! strchr (var->type, '*') || ! strcmp (var->type, "char * const *"))
 		return *block;
 
 	if (next && (! strcmp (next->type, "size_t"))) {
--- libnih-1.0.3.orig/nih-dbus-tool/property.h
+++ libnih-1.0.3/nih-dbus-tool/property.h
@@ -65,7 +65,7 @@
 					      const char *name,
 					      const char *type,
 					      NihDBusAccess access)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 int       property_start_tag                 (XML_Parser xmlp, const char *tag,
 					      char * const *attr)
@@ -88,7 +88,7 @@
 					      NihList *prototypes,
 					      NihList *handlers,
 					      NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *    property_object_set_function       (const void *parent,
 					      const char *prefix,
 					      Interface *interface,
@@ -96,7 +96,7 @@
 					      NihList *prototypes,
 					      NihList *handlers,
 					      NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *    property_proxy_get_function        (const void *parent,
 					      const char *prefix,
@@ -104,7 +104,7 @@
 					      Property *property,
 					      NihList *prototypes,
 					      NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *    property_proxy_get_notify_function (const void *parent,
 					      const char *prefix,
 					      Interface *interface,
@@ -112,7 +112,7 @@
 					      NihList *prototypes,
 					      NihList *typedefs,
 					      NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *    property_proxy_set_function        (const void *parent,
 					      const char *prefix,
@@ -120,7 +120,7 @@
 					      Property *property,
 					      NihList *prototypes,
 					      NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *    property_proxy_set_notify_function (const void *parent,
 					      const char *prefix,
 					      Interface *interface,
@@ -128,7 +128,7 @@
 					      NihList *prototypes,
 					      NihList *typedefs,
 					      NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 char *    property_proxy_get_sync_function   (const void *parent,
 					      const char *prefix,
@@ -136,14 +136,14 @@
 					      Property *property,
 					      NihList *prototypes,
 					      NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 char *    property_proxy_set_sync_function   (const void *parent,
 					      const char *prefix,
 					      Interface *interface,
 					      Property *property,
 					      NihList *prototypes,
 					      NihList *structs)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 NIH_END_EXTERN
 
--- libnih-1.0.3.orig/nih-dbus-tool/tests/test_main.c
+++ libnih-1.0.3/nih-dbus-tool/tests/test_main.c
@@ -100,10 +100,10 @@
 
 extern char *source_file_path (const void *parent, const char *output_path,
 			       const char *filename)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 extern char *header_file_path (const void *parent, const char *output_path,
 			       const char *filename)
-	__attribute__ ((warn_unused_result, malloc));
+	__attribute__ ((warn_unused_result));
 
 void
 test_source_file_path (void)
--- libnih-1.0.3.orig/nih-dbus-tool/tests/test_com.netsplit.Nih.Test_object.c
+++ libnih-1.0.3/nih-dbus-tool/tests/test_com.netsplit.Nih.Test_object.c
@@ -12524,6 +12524,7 @@
 		dbus_message_iter_init (reply, &iter);
 
 		dbus_message_iter_get_basic (&iter, &str_value);
+		TEST_NE (str_value[0], '\0');
 		TEST_TRUE (strchr ("0123456789", str_value[0]));
 
 		dbus_message_unref (reply);
--- libnih-1.0.3.orig/nih-dbus-tool/tests/test_marshal.c
+++ libnih-1.0.3/nih-dbus-tool/tests/test_marshal.c
@@ -1479,39 +1479,41 @@
 				   "\treturn -1;\n"
 				   "}\n"
 				   "\n"
-				   "for (size_t value_i = 0; value[value_i]; value_i++) {\n"
-				   "\tDBusMessageIter value_element_iter;\n"
-				   "\tconst int16_t * value_element;\n"
-				   "\tsize_t          value_element_len;\n"
+				   "if (value) {\n"
+				   "\tfor (size_t value_i = 0; value[value_i]; value_i++) {\n"
+				   "\t\tDBusMessageIter value_element_iter;\n"
+				   "\t\tconst int16_t * value_element;\n"
+				   "\t\tsize_t          value_element_len;\n"
 				   "\n"
-				   "\tvalue_element = value[value_i];\n"
-				   "\tvalue_element_len = value_len[value_i];\n"
+				   "\t\tvalue_element = value[value_i];\n"
+				   "\t\tvalue_element_len = value_len[value_i];\n"
 				   "\n"
 
-				   "\t/* Marshal an array onto the message */\n"
-				   "\tif (! dbus_message_iter_open_container (&value_iter, DBUS_TYPE_ARRAY, \"n\", &value_element_iter)) {\n"
-				   "\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
-				   "\t\treturn -1;\n"
-				   "\t}\n"
+				   "\t\t/* Marshal an array onto the message */\n"
+				   "\t\tif (! dbus_message_iter_open_container (&value_iter, DBUS_TYPE_ARRAY, \"n\", &value_element_iter)) {\n"
+				   "\t\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
+				   "\t\t\treturn -1;\n"
+				   "\t\t}\n"
 				   "\n"
-				   "\tfor (size_t value_element_i = 0; value_element_i < value_element_len; value_element_i++) {\n"
-				   "\t\tint16_t value_element_element;\n"
+				   "\t\tfor (size_t value_element_i = 0; value_element_i < value_element_len; value_element_i++) {\n"
+				   "\t\t\tint16_t value_element_element;\n"
 				   "\n"
-				   "\t\tvalue_element_element = value_element[value_element_i];\n"
+				   "\t\t\tvalue_element_element = value_element[value_element_i];\n"
 				   "\n"
-				   "\t\t/* Marshal a int16_t onto the message */\n"
-				   "\t\tif (! dbus_message_iter_append_basic (&value_element_iter, DBUS_TYPE_INT16, &value_element_element)) {\n"
-				   "\t\t\tdbus_message_iter_abandon_container (&value_iter, &value_element_iter);\n"
+				   "\t\t\t/* Marshal a int16_t onto the message */\n"
+				   "\t\t\tif (! dbus_message_iter_append_basic (&value_element_iter, DBUS_TYPE_INT16, &value_element_element)) {\n"
+				   "\t\t\t\tdbus_message_iter_abandon_container (&value_iter, &value_element_iter);\n"
+				   "\t\t\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
+				   "\t\t\t\treturn -1;\n"
+				   "\t\t\t}\n"
+				   "\t\t}\n"
+				   "\n"
+				   "\t\tif (! dbus_message_iter_close_container (&value_iter, &value_element_iter)) {\n"
 				   "\t\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
 				   "\t\t\treturn -1;\n"
 				   "\t\t}\n"
-				   "\t}\n"
-				   "\n"
-				   "\tif (! dbus_message_iter_close_container (&value_iter, &value_element_iter)) {\n"
-				   "\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
-				   "\t\treturn -1;\n"
-				   "\t}\n"
 
+				   "\t}\n"
 				   "}\n"
 				   "\n"
 				   "if (! dbus_message_iter_close_container (&iter, &value_iter)) {\n"
@@ -1766,15 +1768,17 @@
 				   "\treturn -1;\n"
 				   "}\n"
 				   "\n"
-				   "for (size_t value_i = 0; value[value_i]; value_i++) {\n"
-				   "\tconst char *value_element;\n"
+				   "if (value) {\n"
+				   "\tfor (size_t value_i = 0; value[value_i]; value_i++) {\n"
+				   "\t\tconst char *value_element;\n"
 				   "\n"
-				   "\tvalue_element = value[value_i];\n"
+				   "\t\tvalue_element = value[value_i];\n"
 				   "\n"
-				   "\t/* Marshal a char * onto the message */\n"
-				   "\tif (! dbus_message_iter_append_basic (&value_iter, DBUS_TYPE_STRING, &value_element)) {\n"
-				   "\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
-				   "\t\treturn -1;\n"
+				   "\t\t/* Marshal a char * onto the message */\n"
+				   "\t\tif (! dbus_message_iter_append_basic (&value_iter, DBUS_TYPE_STRING, &value_element)) {\n"
+				   "\t\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
+				   "\t\t\treturn -1;\n"
+				   "\t\t}\n"
 				   "\t}\n"
 				   "}\n"
 				   "\n"
@@ -1933,35 +1937,39 @@
 				   "\treturn -1;\n"
 				   "}\n"
 				   "\n"
-				   "for (size_t value_i = 0; value[value_i]; value_i++) {\n"
-				   "\tDBusMessageIter value_element_iter;\n"
-				   "\tchar * const *  value_element;\n"
+				   "if (value) {\n"
+				   "\tfor (size_t value_i = 0; value[value_i]; value_i++) {\n"
+				   "\t\tDBusMessageIter value_element_iter;\n"
+				   "\t\tchar * const *  value_element;\n"
 				   "\n"
-				   "\tvalue_element = value[value_i];\n"
+				   "\t\tvalue_element = value[value_i];\n"
 				   "\n"
-				   "\t/* Marshal an array onto the message */\n"
-				   "\tif (! dbus_message_iter_open_container (&value_iter, DBUS_TYPE_ARRAY, \"s\", &value_element_iter)) {\n"
-				   "\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
-				   "\t\treturn -1;\n"
-				   "\t}\n"
-				   "\n"
-				   "\tfor (size_t value_element_i = 0; value_element[value_element_i]; value_element_i++) {\n"
-				   "\t\tconst char *value_element_element;\n"
+				   "\t\t/* Marshal an array onto the message */\n"
+				   "\t\tif (! dbus_message_iter_open_container (&value_iter, DBUS_TYPE_ARRAY, \"s\", &value_element_iter)) {\n"
+				   "\t\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
+				   "\t\t\treturn -1;\n"
+				   "\t\t}\n"
 				   "\n"
-				   "\t\tvalue_element_element = value_element[value_element_i];\n"
+				   "\t\tif (value_element) {\n"
+				   "\t\t\tfor (size_t value_element_i = 0; value_element[value_element_i]; value_element_i++) {\n"
+				   "\t\t\t\tconst char *value_element_element;\n"
+				   "\n"
+				   "\t\t\t\tvalue_element_element = value_element[value_element_i];\n"
+				   "\n"
+				   "\t\t\t\t/* Marshal a char * onto the message */\n"
+				   "\t\t\t\tif (! dbus_message_iter_append_basic (&value_element_iter, DBUS_TYPE_STRING, &value_element_element)) {\n"
+				   "\t\t\t\t\tdbus_message_iter_abandon_container (&value_iter, &value_element_iter);\n"
+				   "\t\t\t\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
+				   "\t\t\t\t\treturn -1;\n"
+				   "\t\t\t\t}\n"
+				   "\t\t\t}\n"
+				   "\t\t}\n"
 				   "\n"
-				   "\t\t/* Marshal a char * onto the message */\n"
-				   "\t\tif (! dbus_message_iter_append_basic (&value_element_iter, DBUS_TYPE_STRING, &value_element_element)) {\n"
-				   "\t\t\tdbus_message_iter_abandon_container (&value_iter, &value_element_iter);\n"
+				   "\t\tif (! dbus_message_iter_close_container (&value_iter, &value_element_iter)) {\n"
 				   "\t\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
 				   "\t\t\treturn -1;\n"
 				   "\t\t}\n"
 				   "\t}\n"
-				   "\n"
-				   "\tif (! dbus_message_iter_close_container (&value_iter, &value_element_iter)) {\n"
-				   "\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
-				   "\t\treturn -1;\n"
-				   "\t}\n"
 				   "}\n"
 				   "\n"
 				   "if (! dbus_message_iter_close_container (&iter, &value_iter)) {\n"
@@ -2194,16 +2202,18 @@
 				   "\treturn -1;\n"
 				   "}\n"
 				   "\n"
-				   "for (size_t value_item2_i = 0; value_item2[value_item2_i]; value_item2_i++) {\n"
-				   "\tconst char *value_item2_element;\n"
+				   "if (value_item2) {\n"
+				   "\tfor (size_t value_item2_i = 0; value_item2[value_item2_i]; value_item2_i++) {\n"
+				   "\t\tconst char *value_item2_element;\n"
 				   "\n"
-				   "\tvalue_item2_element = value_item2[value_item2_i];\n"
+				   "\t\tvalue_item2_element = value_item2[value_item2_i];\n"
 				   "\n"
-				   "\t/* Marshal a char * onto the message */\n"
-				   "\tif (! dbus_message_iter_append_basic (&value_item2_iter, DBUS_TYPE_STRING, &value_item2_element)) {\n"
-				   "\t\tdbus_message_iter_abandon_container (&value_iter, &value_item2_iter);\n"
-				   "\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
-				   "\t\treturn -1;\n"
+				   "\t\t/* Marshal a char * onto the message */\n"
+				   "\t\tif (! dbus_message_iter_append_basic (&value_item2_iter, DBUS_TYPE_STRING, &value_item2_element)) {\n"
+				   "\t\t\tdbus_message_iter_abandon_container (&value_iter, &value_item2_iter);\n"
+				   "\t\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
+				   "\t\t\treturn -1;\n"
+				   "\t\t}\n"
 				   "\t}\n"
 				   "}\n"
 				   "\n"
@@ -2642,41 +2652,43 @@
 				   "\treturn -1;\n"
 				   "}\n"
 				   "\n"
-				   "for (size_t value_i = 0; value[value_i]; value_i++) {\n"
-				   "\tDBusMessageIter                  value_element_iter;\n"
-				   "\tconst char *                     value_element_item0;\n"
-				   "\tuint32_t                         value_element_item1;\n"
-				   "\tconst MyStructArrayValueElement *value_element;\n"
+				   "if (value) {\n"
+				   "\tfor (size_t value_i = 0; value[value_i]; value_i++) {\n"
+				   "\t\tDBusMessageIter                  value_element_iter;\n"
+				   "\t\tconst char *                     value_element_item0;\n"
+				   "\t\tuint32_t                         value_element_item1;\n"
+				   "\t\tconst MyStructArrayValueElement *value_element;\n"
 				   "\n"
-				   "\tvalue_element = value[value_i];\n"
+				   "\t\tvalue_element = value[value_i];\n"
 				   "\n"
-				   "\t/* Marshal a structure onto the message */\n"
-				   "\tif (! dbus_message_iter_open_container (&value_iter, DBUS_TYPE_STRUCT, NULL, &value_element_iter)) {\n"
-				   "\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
-				   "\t\treturn -1;\n"
-				   "\t}\n"
+				   "\t\t/* Marshal a structure onto the message */\n"
+				   "\t\tif (! dbus_message_iter_open_container (&value_iter, DBUS_TYPE_STRUCT, NULL, &value_element_iter)) {\n"
+				   "\t\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
+				   "\t\t\treturn -1;\n"
+				   "\t\t}\n"
 				   "\n"
-				   "\tvalue_element_item0 = value_element->item0;\n"
+				   "\t\tvalue_element_item0 = value_element->item0;\n"
 				   "\n"
-				   "\t/* Marshal a char * onto the message */\n"
-				   "\tif (! dbus_message_iter_append_basic (&value_element_iter, DBUS_TYPE_STRING, &value_element_item0)) {\n"
-				   "\t\tdbus_message_iter_abandon_container (&value_iter, &value_element_iter);\n"
-				   "\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
-				   "\t\treturn -1;\n"
-				   "\t}\n"
+				   "\t\t/* Marshal a char * onto the message */\n"
+				   "\t\tif (! dbus_message_iter_append_basic (&value_element_iter, DBUS_TYPE_STRING, &value_element_item0)) {\n"
+				   "\t\t\tdbus_message_iter_abandon_container (&value_iter, &value_element_iter);\n"
+				   "\t\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
+				   "\t\t\treturn -1;\n"
+				   "\t\t}\n"
 				   "\n"
-				   "\tvalue_element_item1 = value_element->item1;\n"
+				   "\t\tvalue_element_item1 = value_element->item1;\n"
 				   "\n"
-				   "\t/* Marshal a uint32_t onto the message */\n"
-				   "\tif (! dbus_message_iter_append_basic (&value_element_iter, DBUS_TYPE_UINT32, &value_element_item1)) {\n"
-				   "\t\tdbus_message_iter_abandon_container (&value_iter, &value_element_iter);\n"
-				   "\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
-				   "\t\treturn -1;\n"
-				   "\t}\n"
+				   "\t\t/* Marshal a uint32_t onto the message */\n"
+				   "\t\tif (! dbus_message_iter_append_basic (&value_element_iter, DBUS_TYPE_UINT32, &value_element_item1)) {\n"
+				   "\t\t\tdbus_message_iter_abandon_container (&value_iter, &value_element_iter);\n"
+				   "\t\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
+				   "\t\t\treturn -1;\n"
+				   "\t\t}\n"
 				   "\n"
-				   "\tif (! dbus_message_iter_close_container (&value_iter, &value_element_iter)) {\n"
-				   "\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
-				   "\t\treturn -1;\n"
+				   "\t\tif (! dbus_message_iter_close_container (&value_iter, &value_element_iter)) {\n"
+				   "\t\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
+				   "\t\t\treturn -1;\n"
+				   "\t\t}\n"
 				   "\t}\n"
 				   "}\n"
 				   "\n"
@@ -2912,41 +2924,43 @@
 				   "\treturn -1;\n"
 				   "}\n"
 				   "\n"
-				   "for (size_t value_i = 0; value[value_i]; value_i++) {\n"
-				   "\tDBusMessageIter                     value_element_iter;\n"
-				   "\tconst char *                        value_element_item0;\n"
-				   "\tuint32_t                            value_element_item1;\n"
-				   "\tconst MyDictEntryArrayValueElement *value_element;\n"
+				   "if (value) {\n"
+				   "\tfor (size_t value_i = 0; value[value_i]; value_i++) {\n"
+				   "\t\tDBusMessageIter                     value_element_iter;\n"
+				   "\t\tconst char *                        value_element_item0;\n"
+				   "\t\tuint32_t                            value_element_item1;\n"
+				   "\t\tconst MyDictEntryArrayValueElement *value_element;\n"
 				   "\n"
-				   "\tvalue_element = value[value_i];\n"
+				   "\t\tvalue_element = value[value_i];\n"
 				   "\n"
-				   "\t/* Marshal a structure onto the message */\n"
-				   "\tif (! dbus_message_iter_open_container (&value_iter, DBUS_TYPE_DICT_ENTRY, NULL, &value_element_iter)) {\n"
-				   "\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
-				   "\t\treturn -1;\n"
-				   "\t}\n"
+				   "\t\t/* Marshal a structure onto the message */\n"
+				   "\t\tif (! dbus_message_iter_open_container (&value_iter, DBUS_TYPE_DICT_ENTRY, NULL, &value_element_iter)) {\n"
+				   "\t\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
+				   "\t\t\treturn -1;\n"
+				   "\t\t}\n"
 				   "\n"
-				   "\tvalue_element_item0 = value_element->item0;\n"
+				   "\t\tvalue_element_item0 = value_element->item0;\n"
 				   "\n"
-				   "\t/* Marshal a char * onto the message */\n"
-				   "\tif (! dbus_message_iter_append_basic (&value_element_iter, DBUS_TYPE_STRING, &value_element_item0)) {\n"
-				   "\t\tdbus_message_iter_abandon_container (&value_iter, &value_element_iter);\n"
-				   "\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
-				   "\t\treturn -1;\n"
-				   "\t}\n"
+				   "\t\t/* Marshal a char * onto the message */\n"
+				   "\t\tif (! dbus_message_iter_append_basic (&value_element_iter, DBUS_TYPE_STRING, &value_element_item0)) {\n"
+				   "\t\t\tdbus_message_iter_abandon_container (&value_iter, &value_element_iter);\n"
+				   "\t\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
+				   "\t\t\treturn -1;\n"
+				   "\t\t}\n"
 				   "\n"
-				   "\tvalue_element_item1 = value_element->item1;\n"
+				   "\t\tvalue_element_item1 = value_element->item1;\n"
 				   "\n"
-				   "\t/* Marshal a uint32_t onto the message */\n"
-				   "\tif (! dbus_message_iter_append_basic (&value_element_iter, DBUS_TYPE_UINT32, &value_element_item1)) {\n"
-				   "\t\tdbus_message_iter_abandon_container (&value_iter, &value_element_iter);\n"
-				   "\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
-				   "\t\treturn -1;\n"
-				   "\t}\n"
+				   "\t\t/* Marshal a uint32_t onto the message */\n"
+				   "\t\tif (! dbus_message_iter_append_basic (&value_element_iter, DBUS_TYPE_UINT32, &value_element_item1)) {\n"
+				   "\t\t\tdbus_message_iter_abandon_container (&value_iter, &value_element_iter);\n"
+				   "\t\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
+				   "\t\t\treturn -1;\n"
+				   "\t\t}\n"
 				   "\n"
-				   "\tif (! dbus_message_iter_close_container (&value_iter, &value_element_iter)) {\n"
-				   "\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
-				   "\t\treturn -1;\n"
+				   "\t\tif (! dbus_message_iter_close_container (&value_iter, &value_element_iter)) {\n"
+				   "\t\t\tdbus_message_iter_abandon_container (&iter, &value_iter);\n"
+				   "\t\t\treturn -1;\n"
+				   "\t\t}\n"
 				   "\t}\n"
 				   "}\n"
 				   "\n"
--- libnih-1.0.3.orig/nih-dbus-tool/tests/test_com.netsplit.Nih.Test_proxy.c
+++ libnih-1.0.3/nih-dbus-tool/tests/test_com.netsplit.Nih.Test_proxy.c
@@ -27359,6 +27359,7 @@
 		TEST_TRUE (unix_fd_to_str_replied);
 
 		TEST_EQ_P (last_data, parent);
+		TEST_NE (last_str_value[0], '\0');
 		TEST_TRUE (strchr ("0123456789", last_str_value[0]));
 		TEST_ALLOC_PARENT (last_str_value, parent);
 
@@ -27673,6 +27674,7 @@
 
 		TEST_EQ (ret, 0);
 
+		TEST_NE (str_value[0], '\0');
 		TEST_TRUE (strchr ("0123456789", str_value[0]));
 		TEST_ALLOC_PARENT (str_value, parent);
 
--- libnih-1.0.3.orig/nih-dbus-tool/tests/test_property.c
+++ libnih-1.0.3/nih-dbus-tool/tests/test_property.c
@@ -8733,7 +8733,7 @@
 	TypeVar *       var;
 	NihListEntry *  attrib;
 	NihDBusProxy *  proxy = NULL;
-	void *          parent = NULL;
+	void *          parent __attribute__((unused)) = NULL;
 	pid_t           pid = -1;
 	int             status;
 	DBusMessage *   method_call;
--- libnih-1.0.3.orig/nih-dbus-tool/tests/expected/test_method_object_function_standard.c
+++ libnih-1.0.3/nih-dbus-tool/tests/expected/test_method_object_function_standard.c
@@ -136,17 +136,19 @@
 			goto enomem;
 		}
 
-		for (size_t output_i = 0; output[output_i]; output_i++) {
-			const char *output_element;
+		if (output) {
+			for (size_t output_i = 0; output[output_i]; output_i++) {
+				const char *output_element;
 
-			output_element = output[output_i];
+				output_element = output[output_i];
 
-			/* Marshal a char * onto the message */
-			if (! dbus_message_iter_append_basic (&output_iter, DBUS_TYPE_STRING, &output_element)) {
-				dbus_message_iter_abandon_container (&iter, &output_iter);
-				dbus_message_unref (reply);
-				reply = NULL;
-				goto enomem;
+				/* Marshal a char * onto the message */
+				if (! dbus_message_iter_append_basic (&output_iter, DBUS_TYPE_STRING, &output_element)) {
+					dbus_message_iter_abandon_container (&iter, &output_iter);
+					dbus_message_unref (reply);
+					reply = NULL;
+					goto enomem;
+				}
 			}
 		}
 
--- libnih-1.0.3.orig/nih-dbus-tool/tests/expected/test_method_reply_function_standard.c
+++ libnih-1.0.3/nih-dbus-tool/tests/expected/test_method_reply_function_standard.c
@@ -7,7 +7,6 @@
 	DBusMessageIter output_iter;
 
 	nih_assert (message != NULL);
-	nih_assert (output != NULL);
 
 	/* If the sender doesn't care about a reply, don't bother wasting
 	 * effort constructing and sending one.
@@ -28,16 +27,18 @@
 		return -1;
 	}
 
-	for (size_t output_i = 0; output[output_i]; output_i++) {
-		const char *output_element;
-
-		output_element = output[output_i];
-
-		/* Marshal a char * onto the message */
-		if (! dbus_message_iter_append_basic (&output_iter, DBUS_TYPE_STRING, &output_element)) {
-			dbus_message_iter_abandon_container (&iter, &output_iter);
-			dbus_message_unref (reply);
-			return -1;
+	if (output) {
+		for (size_t output_i = 0; output[output_i]; output_i++) {
+			const char *output_element;
+
+			output_element = output[output_i];
+
+			/* Marshal a char * onto the message */
+			if (! dbus_message_iter_append_basic (&output_iter, DBUS_TYPE_STRING, &output_element)) {
+				dbus_message_iter_abandon_container (&iter, &output_iter);
+				dbus_message_unref (reply);
+				return -1;
+			}
 		}
 	}
 
--- libnih-1.0.3.orig/nih-dbus-tool/tests/expected/test_method_reply_function_deprecated.c
+++ libnih-1.0.3/nih-dbus-tool/tests/expected/test_method_reply_function_deprecated.c
@@ -7,7 +7,6 @@
 	DBusMessageIter output_iter;
 
 	nih_assert (message != NULL);
-	nih_assert (output != NULL);
 
 	/* If the sender doesn't care about a reply, don't bother wasting
 	 * effort constructing and sending one.
@@ -28,16 +27,18 @@
 		return -1;
 	}
 
-	for (size_t output_i = 0; output[output_i]; output_i++) {
-		const char *output_element;
-
-		output_element = output[output_i];
-
-		/* Marshal a char * onto the message */
-		if (! dbus_message_iter_append_basic (&output_iter, DBUS_TYPE_STRING, &output_element)) {
-			dbus_message_iter_abandon_container (&iter, &output_iter);
-			dbus_message_unref (reply);
-			return -1;
+	if (output) {
+		for (size_t output_i = 0; output[output_i]; output_i++) {
+			const char *output_element;
+
+			output_element = output[output_i];
+
+			/* Marshal a char * onto the message */
+			if (! dbus_message_iter_append_basic (&output_iter, DBUS_TYPE_STRING, &output_element)) {
+				dbus_message_iter_abandon_container (&iter, &output_iter);
+				dbus_message_unref (reply);
+				return -1;
+			}
 		}
 	}
 
--- libnih-1.0.3.orig/nih-dbus-tool/tests/expected/test_method_object_function_no_input.c
+++ libnih-1.0.3/nih-dbus-tool/tests/expected/test_method_object_function_no_input.c
@@ -88,17 +88,19 @@
 			goto enomem;
 		}
 
-		for (size_t output_i = 0; output[output_i]; output_i++) {
-			const char *output_element;
+		if (output) {
+			for (size_t output_i = 0; output[output_i]; output_i++) {
+				const char *output_element;
 
-			output_element = output[output_i];
+				output_element = output[output_i];
 
-			/* Marshal a char * onto the message */
-			if (! dbus_message_iter_append_basic (&output_iter, DBUS_TYPE_STRING, &output_element)) {
-				dbus_message_iter_abandon_container (&iter, &output_iter);
-				dbus_message_unref (reply);
-				reply = NULL;
-				goto enomem;
+				/* Marshal a char * onto the message */
+				if (! dbus_message_iter_append_basic (&output_iter, DBUS_TYPE_STRING, &output_element)) {
+					dbus_message_iter_abandon_container (&iter, &output_iter);
+					dbus_message_unref (reply);
+					reply = NULL;
+					goto enomem;
+				}
 			}
 		}
 
OpenPOWER on IntegriCloud